Paladox has uploaded a new change for review.
https://gerrit.wikimedia.org/r/279957
Change subject: Make VisualEditor support truly optional
......................................................................
Make VisualEditor support truly optional
Currently if you doin't have VisualEditor installed it will throw errors
in the Develeper Tools on IE and Microsoft Edge and chrome,
Lets make the support truly optional even though in the installation
manauly on Flow extension page says that it is optional. But it is not
really since the modules are loaded causing js problems.
Bug: T131055
Change-Id: I2b2247eccd310755a221c4ca016a1c1e221fe03a
---
M Hooks.php
M Resources.php
M modules/editor/editors/ext.flow.editors.none.js
M modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
4 files changed, 131 insertions(+), 99 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/57/279957/1
diff --git a/Hooks.php b/Hooks.php
index cb0dfa5..1afc830 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -47,16 +47,111 @@
$resourceLoader->register(
'ext.guidedTour.tour.flowOptIn', array(
'localBasePath' => __DIR__ . '/modules',
'remoteExtPath' => 'Flow/modules',
- 'scripts' => 'tours/flowOptIn.js',
- 'styles' => 'tours/flowOptIn.less',
- 'messages' => array(
- "flow-guidedtour-optin-welcome",
-
"flow-guidedtour-optin-welcome-description",
-
"flow-guidedtour-optin-find-old-conversations",
-
"flow-guidedtour-optin-find-old-conversations-description",
-
"flow-guidedtour-optin-feedback",
-
"flow-guidedtour-optin-feedback-description"
- )
+ 'scripts' => 'tours/flowOptIn.js',
+ 'styles' => 'tours/flowOptIn.less',
+ 'messages' => array(
+ "flow-guidedtour-optin-welcome",
+
"flow-guidedtour-optin-welcome-description",
+
"flow-guidedtour-optin-find-old-conversations",
+
"flow-guidedtour-optin-find-old-conversations-description",
+ "flow-guidedtour-optin-feedback",
+
"flow-guidedtour-optin-feedback-description"
+ )
+ ) );
+ }
+
+ if ( class_exists( 'VisualEditorHooks' ) ) {
+ $resourceLoader->register( 'ext.flow.ui', array(
+ 'localBasePath' => __DIR__ . '/modules',
+ 'remoteExtPath' => 'Flow/modules',
+ 'scripts' => array(
+
'flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js',
+ )
+ ) );
+
+ $resourceLoader->register( 'ext.flow', array(
+ 'localBasePath' => __DIR__ . '/modules',
+ 'remoteExtPath' => 'Flow/modules',
+ 'scripts' => array(
+ // Feature: VisualEditor
+
'engine/components/board/features/flow-board-visualeditor.js',
+ )
+ ) );
+
+ // Basically this is just all the Flow-specific VE
stuff, except ext.flow.editors.visualeditor.js,
+ // That needs to register itself even if the browser
doesn't support VE (so we can tell
+ // the editor dispatcher that). But we want to reduce
what we load if the browser can't actually
+ // use VE.
+ $resourceLoader->register( 'ext.flow.visualEditor',
array(
+ 'localBasePath' => __DIR__ . '/modules',
+ 'remoteExtPath' => 'Flow/modules',
+ 'scripts' => array(
+
'editor/editors/visualeditor/mw.flow.ve.Target.js',
+
'editor/editors/visualeditor/mw.flow.ve.UserCache.js',
+
'editor/editors/visualeditor/ui/inspectors/mw.flow.ve.ui.MentionInspector.js',
+
'editor/editors/visualeditor/ui/tools/mw.flow.ve.ui.MentionInspectorTool.js',
+ // MentionInspectorTool must be after
MentionInspector and before MentionContextItem.
+
'editor/editors/visualeditor/ui/contextitem/mw.flow.ve.ui.MentionContextItem.js',
+
'editor/editors/visualeditor/ui/widgets/mw.flow.ve.ui.MentionTargetInputWidget.js',
+
'editor/editors/visualeditor/ui/tools/mw.flow.ve.ui.SwitchEditorTool.js',
+
'editor/editors/visualeditor/ui/actions/mw.flow.ve.ui.SwitchEditorAction.js',
+
'editor/editors/visualeditor/mw.flow.ve.CommandRegistry.js',
+
'editor/editors/visualeditor/mw.flow.ve.SequenceRegistry.js',
+ ),
+ 'styles' => array(
+
'editor/editors/visualeditor/mw.flow.ve.Target.less',
+
'editor/editors/visualeditor/ui/mw.flow.ve.ui.Icons.less',
+ ),
+ 'skinStyles' => array(
+ 'vector' => array(
+
'editor/editors/visualeditor/mw.flow.ve.Target-vector.less',
+ ),
+ 'monobook' => array(
+
'editor/editors/visualeditor/mw.flow.ve.Target-monobook.less',
+ ),
+ ),
+ 'dependencies' => array(
+ 'es5-shim',
+ 'ext.visualEditor.core',
+ 'ext.visualEditor.core.desktop',
+ 'ext.visualEditor.data',
+ 'ext.visualEditor.icons',
+ // See comment at bottom of
mw.flow.ve.Target.js.
+ 'ext.visualEditor.mediawiki',
+ 'ext.visualEditor.desktopTarget',
+ 'ext.visualEditor.mwimage',
+ 'ext.visualEditor.mwlink',
+ 'ext.visualEditor.mwtransclusion',
+ 'ext.visualEditor.standalone',
+ 'oojs-ui.styles.icons-editing-advanced',
+ 'site',
+ 'user',
+ 'mediawiki.api',
+ 'ext.flow.editors.none', // needed to
figure out if that editor is supported, for switch button
+ ),
+ 'messages' => array(
+ 'flow-ve-mention-context-item-label',
+ 'flow-ve-mention-inspector-title',
+
'flow-ve-mention-inspector-remove-label',
+
'flow-ve-mention-inspector-invalid-user',
+ 'flow-ve-mention-placeholder',
+ 'flow-ve-mention-tool-title',
+ 'flow-ve-switch-editor-tool-title',
+ )
+ ) );
+
+ // Actual VE is currently not supported on mobile since
we use the desktop target, but we still
+ // need this part to load (and reject it in isSupported)
+ $resourceLoader->register(
'ext.flow.editors.visualeditor', array(
+ 'localBasePath' => __DIR__ . '/modules',
+ 'remoteExtPath' => 'Flow/modules',
+ 'scripts' => array(
+ // Feature: VisualEditor
+
'editor/editors/visualeditor/ext.flow.editors.visualeditor.js',
+ ),
+ 'dependencies' => array(
+ // ve dependencies will be loaded via JS
+ )
) );
}
@@ -743,6 +838,7 @@
$vars['wgFlowMaxTopicLength'] =
Flow\Model\PostRevision::MAX_TOPIC_LENGTH;
$vars['wgFlowMentionTemplate'] = wfMessage(
'flow-ve-mention-template-title' )->inContentLanguage()->plain();
$vars['wgFlowAjaxTimeout'] = $wgFlowAjaxTimeout;
+ $vars['wgFlowDetectVisualClass'] = class_exists(
'VisualEditorHooks' );
return true;
}
diff --git a/Resources.php b/Resources.php
index 1a86367..37ccbfc 100644
--- a/Resources.php
+++ b/Resources.php
@@ -387,7 +387,6 @@
'flow/ui/widgets/editor/editors/mw.flow.ui.AbstractEditorWidget.js',
'flow/ui/widgets/editor/editors/mw.flow.ui.WikitextEditorWidget.js',
-
'flow/ui/widgets/editor/editors/mw.flow.ui.VisualEditorWidget.js',
'flow/ui/widgets/editor/mw.flow.ui.AnonWarningWidget.js',
'flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js',
'flow/ui/widgets/editor/mw.flow.ui.EditorControlsWidget.js',
@@ -457,8 +456,6 @@
'engine/components/board/features/flow-board-navigation.js',
// Feature: Side Rail
'engine/components/board/features/flow-board-side-rail.js',
- // Feature: VisualEditor
-
'engine/components/board/features/flow-board-visualeditor.js',
// Feature: Switch between editors
'engine/components/board/features/flow-board-switcheditor.js',
@@ -527,75 +524,6 @@
'dependencies' => array(
'oojs-ui',
)
- ) + $mobile,
-
- // Basically this is just all the Flow-specific VE stuff, except
ext.flow.editors.visualeditor.js,
- // That needs to register itself even if the browser doesn't support VE
(so we can tell
- // the editor dispatcher that). But we want to reduce what we load if
the browser can't actually
- // use VE.
- 'ext.flow.visualEditor' => $flowResourceTemplate + array(
- 'scripts' => array(
- 'editor/editors/visualeditor/mw.flow.ve.Target.js',
- 'editor/editors/visualeditor/mw.flow.ve.UserCache.js',
-
'editor/editors/visualeditor/ui/inspectors/mw.flow.ve.ui.MentionInspector.js',
-
'editor/editors/visualeditor/ui/tools/mw.flow.ve.ui.MentionInspectorTool.js',
- // MentionInspectorTool must be after MentionInspector
and before MentionContextItem.
-
'editor/editors/visualeditor/ui/contextitem/mw.flow.ve.ui.MentionContextItem.js',
-
'editor/editors/visualeditor/ui/widgets/mw.flow.ve.ui.MentionTargetInputWidget.js',
-
'editor/editors/visualeditor/ui/tools/mw.flow.ve.ui.SwitchEditorTool.js',
-
'editor/editors/visualeditor/ui/actions/mw.flow.ve.ui.SwitchEditorAction.js',
-
'editor/editors/visualeditor/mw.flow.ve.CommandRegistry.js',
-
'editor/editors/visualeditor/mw.flow.ve.SequenceRegistry.js',
- ),
- 'styles' => array(
- 'editor/editors/visualeditor/mw.flow.ve.Target.less',
-
'editor/editors/visualeditor/ui/mw.flow.ve.ui.Icons.less',
- ),
- 'skinStyles' => array(
- 'vector' => array(
-
'editor/editors/visualeditor/mw.flow.ve.Target-vector.less',
- ),
- 'monobook' => array(
-
'editor/editors/visualeditor/mw.flow.ve.Target-monobook.less',
- ),
- ),
- 'dependencies' => array(
- 'es5-shim',
- 'ext.visualEditor.core',
- 'ext.visualEditor.core.desktop',
- 'ext.visualEditor.data',
- 'ext.visualEditor.icons',
- // See comment at bottom of mw.flow.ve.Target.js.
- 'ext.visualEditor.mediawiki',
- 'ext.visualEditor.desktopTarget',
- 'ext.visualEditor.mwimage',
- 'ext.visualEditor.mwlink',
- 'ext.visualEditor.mwtransclusion',
- 'ext.visualEditor.standalone',
- 'oojs-ui.styles.icons-editing-advanced',
- 'site',
- 'user',
- 'mediawiki.api',
- 'ext.flow.editors.none', // needed to figure out if
that editor is supported, for switch button
- ),
- 'messages' => array(
- 'flow-ve-mention-context-item-label',
- 'flow-ve-mention-inspector-title',
- 'flow-ve-mention-inspector-remove-label',
- 'flow-ve-mention-inspector-invalid-user',
- 'flow-ve-mention-placeholder',
- 'flow-ve-mention-tool-title',
- 'flow-ve-switch-editor-tool-title',
- ),
- ),
-
- // Actual VE is currently not supported on mobile since we use the
desktop target, but we still
- // need this part to load (and reject it in isSupported)
- 'ext.flow.editors.visualeditor' => $flowResourceTemplate + array(
- 'scripts' =>
'editor/editors/visualeditor/ext.flow.editors.visualeditor.js',
- 'dependencies' => array(
- // ve dependencies will be loaded via JS
- ),
) + $mobile,
// This integrates with core mediawiki.messagePoster, and the module
name
diff --git a/modules/editor/editors/ext.flow.editors.none.js
b/modules/editor/editors/ext.flow.editors.none.js
index e42a650..5113d37 100644
--- a/modules/editor/editors/ext.flow.editors.none.js
+++ b/modules/editor/editors/ext.flow.editors.none.js
@@ -52,8 +52,10 @@
// only attach switcher if VE is actually enabled and supported
// code to figure out if that VE is supported is in that module
- if ( mw.config.get( 'wgFlowEditorList' ).indexOf(
'visualeditor' ) !== -1 ) {
- mw.loader.using( 'ext.flow.editors.visualeditor',
$.proxy( this.attachControls, this ) );
+ if ( mw.config.get( 'wgFlowDetectVisualClass' ) ) {
+ if ( mw.config.get( 'wgFlowEditorList' ).indexOf(
'visualeditor' ) !== -1 ) {
+ mw.loader.using(
'ext.flow.editors.visualeditor', $.proxy( this.attachControls, this ) );
+ }
}
this.widget.connect( this, { change: [ 'emit', 'change' ] } );
@@ -113,20 +115,22 @@
.attr( 'target', '_blank' )
.end();
- if ( mw.flow.editors.visualeditor.static.isSupported() ) {
- $preview = $( '<a>' ).attr( {
- href: '#',
- 'data-flow-interactive-handler': 'switchEditor',
- 'data-flow-target': '< .flow-editor
textarea.flow-editor-initialized'
- } ).text( mw.message(
'flow-wikitext-editor-help-preview-the-result' ).text() );
+ if ( mw.config.get( 'wgFlowDetectVisualClass' ) ) {
+ if ( mw.flow.editors.visualeditor.static.isSupported()
) {
+ $preview = $( '<a>' ).attr( {
+ href: '#',
+ 'data-flow-interactive-handler':
'switchEditor',
+ 'data-flow-target': '< .flow-editor
textarea.flow-editor-initialized'
+ } ).text( mw.message(
'flow-wikitext-editor-help-preview-the-result' ).text() );
- templateArgs = {
- enable_switcher: true,
- help_text: mw.message(
'flow-wikitext-editor-help-and-preview' ).params( [
- $usesWikitext.html(),
- $preview[ 0 ].outerHTML
- ] ).parse()
- };
+ templateArgs = {
+ enable_switcher: true,
+ help_text: mw.message(
'flow-wikitext-editor-help-and-preview' ).params( [
+ $usesWikitext.html(),
+ $preview[ 0 ].outerHTML
+ ] ).parse()
+ };
+ }
} else {
// render just a basic help text
templateArgs = {
diff --git a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
index 7971194..8a9724f 100644
--- a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
+++ b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
@@ -103,8 +103,12 @@
* @property {Object}
*/
mw.flow.ui.EditorSwitcherWidget.static.editorDefinitions = {
- wikitext: mw.flow.ui.WikitextEditorWidget,
- visualeditor: mw.flow.ui.VisualEditorWidget
+ if ( mw.config.get( 'wgFlowDetectVisualClass' ) ) {
+ wikitext: mw.flow.ui.WikitextEditorWidget,
+ visualeditor: mw.flow.ui.VisualEditorWidget
+ } else {
+ wikitext: mw.flow.ui.WikitextEditorWidget
+ }
};
/* Methods */
--
To view, visit https://gerrit.wikimedia.org/r/279957
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b2247eccd310755a221c4ca016a1c1e221fe03a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits