Werdna has uploaded a new change for review. https://gerrit.wikimedia.org/r/88684
Change subject: 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 wron ...................................................................... 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(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/84/88684/1 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..dd5f241 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,7 @@ // add i18n messages to VE window.ve.init.platform.addMessages( mw.messages.values ); - this.$node.hide(); + $.removeSpinner( 'flow-editor-loading' ); // init ve, save target object this.target = new window.ve.init.sa.Target( @@ -40,10 +48,14 @@ 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 + var $focussedElement = $( ':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: newchange Gerrit-Change-Id: I3f0515beafc450804cf536fdcf2c80e1ba469696 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Werdna <agarr...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits