I wish to write an Angular application which integrates the Ace editor with a toolbar for saving + undo/redo. I've created a basic plunk for working out this app.
As you should be able to tell from the plunk there is a 'toolbar' directive responsible for rendering the toolbar (with three buttons: Save, Undo and Redo) and an 'ace' directive responsible for rendering the Ace editor. Both directives reside in 'directives.coffee'.
The toolbar should behave the way you would expect from a text editor toolbar, ie:
So my question is, how can I devise an Angular binding between the Ace editor and the application toolbar so that the above specification is met?
I am not sure what do you need to do on angular side, but ace provides methods for all of this
var undoManager = editor.session.getUndoManager()
undoManager.isClean()
undoManager.markClean()
undoManager.hasUndo()
undoManager.hasRedo()
Note that isClean
is based on undo stack not on document value, so writing and deleting a letter will enable save button even though value isn't changed.
Also it is better to use editor.on("input", function(){})
instead of 'change'
since input event is fired asynchronously.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.