add change event support to the text document
This commit is contained in:
parent
7cce9d8858
commit
f0bf1dd88c
2 changed files with 56 additions and 6 deletions
|
|
@ -120,6 +120,9 @@ function Editor(doc, renderer)
|
|||
addListener(container, "mousewheel", bind(this.onMouseWheel, this));
|
||||
|
||||
this.doc = doc;
|
||||
doc.addChangeListener(function(startRow, endRow) {
|
||||
console.log(startRow, endRow);
|
||||
});
|
||||
renderer.setDocument(doc);
|
||||
|
||||
this.cursor = {
|
||||
|
|
@ -229,10 +232,11 @@ Editor.prototype =
|
|||
{
|
||||
if (this.hasSelection())
|
||||
{
|
||||
this.cursor = this.doc.remove(this.getSelectionRange());
|
||||
this.cursor = this.doc.replace(this.getSelectionRange(), text);
|
||||
this.clearSelection();
|
||||
} else {
|
||||
this.cursor = this.doc.insert(this.cursor, text);
|
||||
}
|
||||
this.cursor = this.doc.insert(this.cursor, text);
|
||||
this.draw();
|
||||
this.renderer.scrollCursorIntoView();
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue