jenkins-bot has submitted this change and it was merged.
Change subject: Don't show Parsoid HTML in textarea while loading VE
......................................................................
Don't show Parsoid HTML in textarea while loading VE
There was always a flash of unparsed content, but 6d6601516
made it worse.
Blank the textarea during editor initialization, before
loading the editor modules. This changes the nesting order
in initializeEditors to call mw.loader.using() for every
editor in a loop, as opposed to calling it once and looping
over editors in the callback; but mw.loader is designed
to handle that.
Bonus: don't initialize editors every single time they're focused.
Bug: T97493
Change-Id: Ie38482909c22afd2651ab024d16bb877b77b1ec4
---
M modules/engine/components/common/flow-component-events.js
1 file changed, 24 insertions(+), 13 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/engine/components/common/flow-component-events.js
b/modules/engine/components/common/flow-component-events.js
index a86cb56..9c4bfd9a 100644
--- a/modules/engine/components/common/flow-component-events.js
+++ b/modules/engine/components/common/flow-component-events.js
@@ -732,25 +732,36 @@
* @param {jQuery} $container
*/
function flowEventsMixinInitializeEditors( $container ) {
- var flowComponent = this, $form;
+ var flowComponent = this;
- mw.loader.using( 'ext.flow.editor', function() {
- var $editors = $container.find( '.flow-editor
textarea:not(.flow-input-compressed)' );
+ $container
+ .find( '.flow-editor
textarea:not(.flow-input-compressed)' )
+ .each( function () {
+ var $editor = $( this ),
+ $form = $editor.closest( 'form' ),
+ content = $editor.val();
- $editors.each( function() {
- var $editor = $( this );
+ if ( $editor.data( 'flow-initialized' ) ) {
+ // Editor is already initialized, don't
initialize it again
+ return;
+ }
+ // Mark the editor as initialized so we don't
try to init it again
+ $editor.data( 'flow-initialized', true );
- $form = $editor.closest( 'form' );
- mw.flow.editor.load( $editor, $editor.val() );
+ // Blank editor while loading
+ $editor.val( '' );
- // Kill editor instance when the form it's in
is cancelled
- flowComponent.emitWithReturn(
'addFormCancelCallback', $form, function() {
- if ( mw.flow.editor.exists( $editor ) )
{
- mw.flow.editor.destroy( $editor
);
- }
+ mw.loader.using( 'ext.flow.editor', function() {
+ mw.flow.editor.load( $editor, content );
+
+ // Kill editor instance when the form
it's in is cancelled
+ flowComponent.emitWithReturn(
'addFormCancelCallback', $form, function() {
+ if ( mw.flow.editor.exists(
$editor ) ) {
+ mw.flow.editor.destroy(
$editor );
+ }
+ } );
} );
} );
- } );
}
FlowComponentEventsMixin.eventHandlers.initializeEditors =
flowEventsMixinInitializeEditors;
--
To view, visit https://gerrit.wikimedia.org/r/207870
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie38482909c22afd2651ab024d16bb877b77b1ec4
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Mattflaschen <[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