Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

modify function Editor Disable #553

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
* Deactivate editor (make it readonly)
*/
disable: function() {
this.synchronizer.disable();
this.currentView.disable();
return this;
},
Expand Down
12 changes: 10 additions & 2 deletions src/views/synchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
}
},

/**
* Deactivate editor (make it readonly)
*/
disable: function() {
this._domObserveSubmit.stop();
this._domObserveReset.stop();
},

/**
* Initializes interval-based syncing
* also makes sure that on-submit the composer's content is synced with the textarea
Expand All @@ -73,10 +81,10 @@
if (form) {
// If the textarea is in a form make sure that after onreset and onsubmit the composer
// has the correct state
wysihtml5.dom.observe(form, "submit", function() {
this._domObserveSubmit = wysihtml5.dom.observe(form, "submit", function() {
that.sync(true);
});
wysihtml5.dom.observe(form, "reset", function() {
this._domObserveReset = wysihtml5.dom.observe(form, "reset", function() {
setTimeout(function() { that.fromTextareaToComposer(); }, 0);
});
}
Expand Down