Add changeDelta event on the document
This commit is contained in:
parent
a71f50ac9a
commit
ddd5b3093d
1 changed files with 22 additions and 16 deletions
|
|
@ -511,15 +511,17 @@ var Document = function(text, mode) {
|
|||
args.push.apply(args, lines);
|
||||
this.lines.splice.apply(this.lines, args);
|
||||
|
||||
var delta = {
|
||||
action: "insertText",
|
||||
range: new Range(row, 0, row + lines.length, 0),
|
||||
text: lines.join(nl) + nl
|
||||
};
|
||||
if (!fromUndo && this.$undoManager) {
|
||||
var nl = this.$getNewLineCharacter();
|
||||
this.$deltas.push({
|
||||
action: "insertText",
|
||||
range: new Range(row, 0, row + lines.length, 0),
|
||||
text: lines.join(nl) + nl
|
||||
});
|
||||
this.$deltas.push(delta);
|
||||
this.$informUndoManager.schedule();
|
||||
}
|
||||
this._dispatchEvent("changeDelta", { data: delta });
|
||||
},
|
||||
|
||||
this.$insert = function(position, text, fromUndo) {
|
||||
|
|
@ -571,14 +573,16 @@ var Document = function(text, mode) {
|
|||
};
|
||||
}
|
||||
|
||||
var delta = {
|
||||
action: "insertText",
|
||||
range: Range.fromPoints(position, end),
|
||||
text: text
|
||||
};
|
||||
if (!fromUndo && this.$undoManager) {
|
||||
this.$deltas.push({
|
||||
action: "insertText",
|
||||
range: Range.fromPoints(position, end),
|
||||
text: text
|
||||
});
|
||||
this.$deltas.push(delta);
|
||||
this.$informUndoManager.schedule();
|
||||
}
|
||||
this._dispatchEvent("changeDelta", { data: delta });
|
||||
|
||||
return end;
|
||||
};
|
||||
|
|
@ -623,13 +627,13 @@ var Document = function(text, mode) {
|
|||
if (range.isEmpty())
|
||||
return;
|
||||
|
||||
var delta = {
|
||||
action: "removeText",
|
||||
range: range.clone(),
|
||||
text: this.getTextRange(range)
|
||||
};
|
||||
if (!fromUndo && this.$undoManager) {
|
||||
var nl = this.$getNewLineCharacter();
|
||||
this.$deltas.push({
|
||||
action: "removeText",
|
||||
range: range.clone(),
|
||||
text: this.getTextRange(range)
|
||||
});
|
||||
this.$deltas.push(delta);
|
||||
this.$informUndoManager.schedule();
|
||||
}
|
||||
|
||||
|
|
@ -645,6 +649,8 @@ var Document = function(text, mode) {
|
|||
this.lines.splice(firstRow, lastRow - firstRow + 1, row);
|
||||
else
|
||||
this.lines.splice(firstRow, lastRow - firstRow + 1, "");
|
||||
|
||||
this._dispatchEvent("changeDelta", { data: delta });
|
||||
return range.start;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue