jenkins-bot has submitted this change and it was merged.
Change subject: Fix some VisualEditor annoyances:
......................................................................
Fix some VisualEditor annoyances:
* Made the editor restore focus to whatever had focus, instead of allowing VE
to steal it.
* Hid the textarea that is being converted into a VE instance, replaced with a
spinner
so people do not start typing in the wrong place and then lose their work.
Change-Id: I3f0515beafc450804cf536fdcf2c80e1ba469696
---
M Resources.php
M modules/editor/editors/ext.flow.editors.visualeditor.js
2 files changed, 21 insertions(+), 3 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Resources.php b/Resources.php
index f611fce..b204365 100644
--- a/Resources.php
+++ b/Resources.php
@@ -93,6 +93,7 @@
'ext.flow.editors.visualeditor' => $flowResourceTemplate + array(
'scripts' => 'editor/editors/ext.flow.editors.visualeditor.js',
'dependencies' => array(
+ 'jquery.spinner',
// ve dependencies will be loaded via JS
),
),
diff --git a/modules/editor/editors/ext.flow.editors.visualeditor.js
b/modules/editor/editors/ext.flow.editors.visualeditor.js
index c00735e..a1229b0 100644
--- a/modules/editor/editors/ext.flow.editors.visualeditor.js
+++ b/modules/editor/editors/ext.flow.editors.visualeditor.js
@@ -9,6 +9,14 @@
// node the editor is associated with.
this.$node = $node;
+ // Replace the node with a spinner
+ $node.hide();
+ $node.injectSpinner( {
+ 'size' : 'large',
+ 'type' : 'block',
+ 'id' : 'flow-editor-loading'
+ } );
+
// load dependencies & init editor
mw.loader.using( this.getModules(), this.init.bind( this,
content || '' ) );
};
@@ -31,7 +39,8 @@
// add i18n messages to VE
window.ve.init.platform.addMessages( mw.messages.values );
- this.$node.hide();
+ $.removeSpinner( 'flow-editor-loading' );
+ var $focussedElement = $( ':focus' );
// init ve, save target object
this.target = new window.ve.init.sa.Target(
@@ -40,10 +49,13 @@
window.ve.createDocumentFromHtml( content || '' )
);
- // focus VE instance if textarea had focus
$veNode = this.target.surface.$.find( '.ve-ce-documentNode' );
- if ( this.$node.is( ':focus' ) ) {
+
+ // focus VE instance if textarea had focus
+ if ( !$focussedElement.length || this.$node.is(
$focussedElement ) ) {
$veNode.focus();
+ } else {
+ $focussedElement.focus();
}
// simulate a keyup event on the original node, so the
validation code will
@@ -101,6 +113,11 @@
mw.flow.editors.visualeditor.prototype.getRawContent = function () {
var doc;
+ // If we haven't fully loaded yet, just return nothing.
+ if ( ! this.target ) {
+ return '';
+ }
+
// get document from ve
doc = this.target.surface.getModel().getDocument();
doc = window.ve.dm.converter.getDomFromData( doc.getFullData(),
doc.getStore(), doc.getInternalList() );
--
To view, visit https://gerrit.wikimedia.org/r/88684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3f0515beafc450804cf536fdcf2c80e1ba469696
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits