jenkins-bot has submitted this change and it was merged.
Change subject: AceEditorWidget: Add method to clear undo stack
......................................................................
AceEditorWidget: Add method to clear undo stack
After the widget is initialised the caller will probably
want to clear the undo stack, so that the first state
is the initial value provided.
Bonus: Add documentation for the widget.
Change-Id: Ia331acc4177e32784061cae55c450eb0f83fd744
---
M modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
1 file changed, 26 insertions(+), 1 deletion(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
b/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
index 0e78cf7..a743047 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
@@ -7,7 +7,17 @@
/* global ace, require */
/**
- * Text input widget which hides but preserves leading and trailing whitespace
+ * Text input widget which use an Ace editor instance when available
+ *
+ * For the most part this can be treated just like a TextInputWidget with
+ * a few extra considerations:
+ *
+ * - For performance it is recommended to destroy the editor when
+ * you are finished with it, using #teardown. If you need to use
+ * the widget again let the editor can be restored with #setup.
+ * - After setting an initial value the undo stack can be reset
+ * using clearUndoStack so that you can't undo past the initial
+ * state.
*
* @class
* @extends ve.ui.WhitespacePreservingTextInputWidget
@@ -128,6 +138,21 @@
};
/**
+ * Clear the editor's undo stack
+ *
+ * @chainable
+ */
+ve.ui.MWAceEditorWidget.prototype.clearUndoStack = function () {
+ var widget = this;
+ this.loadingPromise.done( function () {
+ widget.editor.session.setUndoManager(
+ new ace.UndoManager()
+ );
+ } );
+ return this;
+};
+
+/**
* Toggle the visibility of line numbers
*
* @param {boolean} visible Visible
--
To view, visit https://gerrit.wikimedia.org/r/250032
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia331acc4177e32784061cae55c450eb0f83fd744
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Ferdbold <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits