|
|
@ -124,6 +124,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
cursor.pushDelta = function (oldVal, newVal) {
|
|
|
|
cursor.pushDelta = function (oldVal, newVal) {
|
|
|
|
if (oldVal === newVal) { return; }
|
|
|
|
if (oldVal === newVal) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
var commonStart = 0;
|
|
|
|
var commonStart = 0;
|
|
|
|
while (oldVal.charAt(commonStart) === newVal.charAt(commonStart)) {
|
|
|
|
while (oldVal.charAt(commonStart) === newVal.charAt(commonStart)) {
|
|
|
|
commonStart++;
|
|
|
|
commonStart++;
|
|
|
@ -156,6 +157,31 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor.transformRange = function (cursorRange, ops) {
|
|
|
|
|
|
|
|
var transformCursor = function (cursor, op) {
|
|
|
|
|
|
|
|
if (!op) { return cursor; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pos = op.offset;
|
|
|
|
|
|
|
|
var remove = op.toRemove;
|
|
|
|
|
|
|
|
var insert = op.toInsert.length;
|
|
|
|
|
|
|
|
if (typeof cursor === 'undefined') { return; }
|
|
|
|
|
|
|
|
if (typeof remove === 'number' && pos < cursor) {
|
|
|
|
|
|
|
|
cursor -= Math.min(remove, cursor - pos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof insert === 'number' && pos < cursor) {
|
|
|
|
|
|
|
|
cursor += insert;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cursor;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var c = cursorRange.offset;
|
|
|
|
|
|
|
|
if (Array.isArray(ops)) {
|
|
|
|
|
|
|
|
for (var i = ops.length - 1; i >= 0; i--) {
|
|
|
|
|
|
|
|
c = transformCursor(c, ops[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cursorRange.offset = c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
cursor.brFix = function () {
|
|
|
|
cursor.brFix = function () {
|
|
|
|
cursor.update();
|
|
|
|
cursor.update();
|
|
|
|
var start = Range.start;
|
|
|
|
var start = Range.start;
|
|
|
|