jenkins-bot has submitted this change and it was merged.
Change subject: Change flow target to inherit from ve.init.mw.Target
......................................................................
Change flow target to inherit from ve.init.mw.Target
* Removes logic now upstreamed
* Removes no-op calls of target.setSurface(target.getSurface())
* Removes no longer needed hack for T113382
Change-Id: Ie1fb09c4f8d255e51bd09c8ea2c5a40a486378fd
---
M modules/editor/editors/visualeditor/mw.flow.ve.Target.js
M modules/flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js
2 files changed, 27 insertions(+), 35 deletions(-)
Approvals:
Mooeypoo: Looks good to me, approved
Jforrester: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/modules/editor/editors/visualeditor/mw.flow.ve.Target.js
b/modules/editor/editors/visualeditor/mw.flow.ve.Target.js
index 0c82ca5..16b8339 100644
--- a/modules/editor/editors/visualeditor/mw.flow.ve.Target.js
+++ b/modules/editor/editors/visualeditor/mw.flow.ve.Target.js
@@ -9,19 +9,18 @@
* Flow-specific target, inheriting from the stand-alone target
*
* @class
- * @extends ve.init.sa.DesktopTarget
+ * @extends ve.init.mw.Target
*/
mw.flow.ve.Target = function FlowVeTarget() {
- mw.flow.ve.Target.parent.call(
- this,
- { toolbarConfig: { floatable: false } }
- );
+ mw.flow.ve.Target.parent.call( this, {
+ toolbarConfig: { actions: true }
+ } );
// HACK: stop VE's education popups from appearing (T116643)
this.dummyToolbar = true;
};
- OO.inheritClass( mw.flow.ve.Target, ve.init.sa.DesktopTarget );
+ OO.inheritClass( mw.flow.ve.Target, ve.init.mw.Target );
// Static
@@ -50,6 +49,14 @@
// Methods
+ mw.flow.ve.Target.prototype.loadHtml = function ( html ) {
+ var doc = this.parseHtml( this.originalHtml );
+ this.documentReady( doc );
+ };
+
+ // These tools aren't available so don't bother generating them
+ mw.flow.ve.Target.prototype.generateCitationFeatures = function () {};
+
mw.flow.ve.Target.prototype.attachToolbar = function () {
// HACK ve.ui.Surface appends a debugBar *after* itself instead
of putting it
// inside itself (T106927)
diff --git
a/modules/flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js
b/modules/flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js
index 5e987e2..7030610 100644
--- a/modules/flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js
+++ b/modules/flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js
@@ -88,29 +88,24 @@
/**
* Create a VE surface with the provided content in it.
+ *
* @param {string} content HTML to put in the surface (body only)
*/
mw.flow.ui.VisualEditorWidget.prototype.createSurface = function (
content ) {
- var dmDoc,
- // Wrap content in <body> tag to prevent <link>/<meta>
tags from being pulled
- // up into the <head> (T115362)
- htmlDoc = ve.createDocumentFromHtml( '<body>' + content
+ '</body>' );
- ve.init.mw.ArticleTarget.static.fixBase( htmlDoc );
- dmDoc = ve.dm.converter.getModelFromDom( htmlDoc, {
- lang: mw.config.get( 'wgVisualEditor'
).pageLanguageCode,
- dir: mw.config.get( 'wgVisualEditor' ).pageLanguageDir
+ var widget = this,
+ deferred = $.Deferred();
+
+ this.target.loadHtml( content );
+ this.target.once( 'surfaceReady', function () {
+ var surface = widget.target.getSurface();
+
+ surface.setPlaceholder( widget.placeholder );
+ // Relay events
+ surface.getModel().connect( widget, { documentUpdate: [
'emit', 'change' ] } );
+ surface.connect( widget, { switchEditor: [ 'emit',
'switch' ] } );
+ deferred.resolve();
} );
- this.surface = this.target.addSurface( dmDoc, { placeholder:
this.placeholder } );
- // afterAttach() calls setSurface
-
- // Add directionality class
-
this.surface.getView().getDocument().getDocumentNode().$element.addClass(
- 'mw-content-' + mw.config.get( 'wgVisualEditor'
).pageLanguageDir
- );
-
- // Relay events
- this.surface.getModel().connect( this, { documentUpdate: [
'emit', 'change' ] } );
- this.surface.connect( this, { switchEditor: [ 'emit', 'switch'
] } );
+ return deferred.promise();
};
/**
@@ -123,16 +118,7 @@
/**
* @inheritdoc
*/
- mw.flow.ui.VisualEditorWidget.prototype.afterAttach = function () {
- this.target.setSurface( this.surface );
- };
-
- /**
- * @inheritdoc
- */
mw.flow.ui.VisualEditorWidget.prototype.teardown = function () {
- // HACK: ensure target is not disabled, otherwise destroying
the surface breaks (T113382)
- this.target.setDisabled( false );
this.target.clearSurfaces();
return $.Deferred().resolve().promise();
};
@@ -187,7 +173,6 @@
mw.flow.ui.VisualEditorWidget.prototype.setContent = function ( content
) {
this.target.clearSurfaces();
this.createSurface( content );
- this.target.setSurface( this.surface );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/258521
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie1fb09c4f8d255e51bd09c8ea2c5a40a486378fd
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits