From c56a921585cb02cff0953c983d7721ed8d1a7874 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 24 Nov 2014 17:43:16 +0000 Subject: [PATCH] Change command list from whitelist to blacklist Also remove toolbar definitions as they can now be derived from command availability. Depends on If32d514a in core. Change-Id: I2313f3cc2531686b27f96dc1110b28bb4b295f89 --- .../targets/ve.init.mw.MobileViewTarget.js | 7 +- modules/ve-mw/init/ve.init.mw.Target.js | 3 +- .../ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js | 96 +++------------- .../ui/dialogs/ve.ui.MWReferenceDialog.js | 105 +++++------------- 4 files changed, 47 insertions(+), 164 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js b/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js index 203396197d..d7ed1ed563 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js @@ -39,6 +39,7 @@ ve.init.mw.MobileViewTarget = function VeInitMwMobileViewTarget( $container, con OO.inheritClass( ve.init.mw.MobileViewTarget, ve.init.mw.Target ); /* Static Properties */ + ve.init.mw.MobileViewTarget.static.toolbarGroups = [ // Style { include: [ 'bold', 'italic' ] }, @@ -55,11 +56,7 @@ ve.init.mw.MobileViewTarget.static.toolbarGroups = [ } ]; -ve.init.mw.MobileViewTarget.static.surfaceCommands = [ - 'bold', - 'italic', - 'link' -]; +ve.init.mw.MobileViewTarget.static.excludeCommands = []; ve.init.mw.MobileViewTarget.static.name = 'mobile'; diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 24f6a2ba17..48a9358bb3 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -1360,11 +1360,10 @@ ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) { ); setTimeout( function () { // Create ui.Surface (also creates ce.Surface and dm.Surface and builds CE tree) - var surface = target.createSurface( dmDoc ); + var surface = target.createSurface( dmDoc, { excludeCommands: target.constructor.static.excludeCommands } ); target.surface = surface; surface.$element.addClass( 've-init-mw-viewPageTarget-surface' ) .addClass( target.protectedClasses ); - surface.addCommands( target.constructor.static.surfaceCommands ); setTimeout( function () { var surfaceView = surface.getView(), $documentNode = surfaceView.getDocument().getDocumentNode().$element; diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js index f96700a611..b75665b81e 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js @@ -77,84 +77,24 @@ ve.ui.MWMediaDialog.static.actions = [ ve.ui.MWMediaDialog.static.modelClasses = [ ve.dm.MWBlockImageNode, ve.dm.MWInlineImageNode ]; -ve.ui.MWMediaDialog.static.toolbarGroups = [ - // History - { include: [ 'undo', 'redo' ] }, +ve.ui.MWMediaDialog.static.excludeCommands = [ // No formatting - /* { - type: 'menu', - indicator: 'down', - title: OO.ui.deferMsg( 'visualeditor-toolbar-format-tooltip' ), - include: [ { group: 'format' } ], - promote: [ 'paragraph' ], - demote: [ 'preformatted', 'heading1' ] - },*/ - // Style - { - type: 'list', - icon: 'text-style', - indicator: 'down', - title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ), - include: [ { group: 'textStyle' }, 'language', 'clear' ], - forceExpand: [ 'bold', 'italic', 'clear' ], - promote: [ 'bold', 'italic' ], - demote: [ 'strikethrough', 'code', 'underline', 'language', 'clear' ] - }, - // Link - { include: [ 'link' ] }, - // Cite - { - type: 'list', - label: OO.ui.deferMsg( 'visualeditor-toolbar-cite-label' ), - indicator: 'down', - include: [ { group: 'cite' }, 'reference', 'reference/existing' ], - demote: [ 'reference', 'reference/existing' ] - }, + 'paragraph', + 'heading1', + 'heading2', + 'heading3', + 'heading4', + 'heading5', + 'heading6', + 'preformatted', + // TODO: Decide if tables tools should be allowed + 'tableCellHeader', + 'tableCellData', // No structure - /* { - type: 'list', - icon: 'bullet-list', - indicator: 'down', - include: [ { group: 'structure' } ], - demote: [ 'outdent', 'indent' ] - },*/ - // Insert - { - label: OO.ui.deferMsg( 'visualeditor-toolbar-insert' ), - indicator: 'down', - include: '*', - exclude: [ - { group: 'format' }, - { group: 'structure' }, - 'referencesList', - 'gallery' - ], - forceExpand: [ 'media', 'transclusion', 'insertTable' ], - promote: [ 'media', 'transclusion' ], - demote: [ 'specialcharacter' ] - }, - // Table - { - header: OO.ui.deferMsg( 'visualeditor-toolbar-table' ), - type: 'list', - icon: 'table-insert', - indicator: 'down', - include: [ { group: 'table' } ], - demote: [ 'deleteTable' ] - } -]; - -ve.ui.MWMediaDialog.static.surfaceCommands = [ - 'undo', - 'redo', - 'bold', - 'italic', - 'link', - 'clear', - 'underline', - 'subscript', - 'superscript', - 'pasteSpecial' + 'bullet', + 'number', + 'indent', + 'outdent' ]; /** @@ -894,8 +834,8 @@ ve.ui.MWMediaDialog.prototype.resetCaption = function () { captionDocument, { $: this.$, - tools: this.constructor.static.toolbarGroups, - commands: this.constructor.static.surfaceCommands, + tools: ve.init.target.constructor.static.toolbarGroups, + excludeCommands: this.constructor.static.excludeCommands, pasteRules: this.constructor.static.getPasteRules() } ); diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js index 68fc26225e..2ed713a6d0 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js @@ -68,85 +68,32 @@ ve.ui.MWReferenceDialog.static.actions = [ ve.ui.MWReferenceDialog.static.modelClasses = [ ve.dm.MWReferenceNode ]; -ve.ui.MWReferenceDialog.static.toolbarGroups = [ - // History - { include: [ 'undo', 'redo' ] }, +ve.ui.MWReferenceDialog.static.excludeCommands = [ // No formatting - /* { - type: 'menu', - indicator: 'down', - title: OO.ui.deferMsg( 'visualeditor-toolbar-format-tooltip' ), - include: [ { group: 'format' } ], - promote: [ 'paragraph' ], - demote: [ 'preformatted', 'heading1' ] - },*/ - // Style - { - type: 'list', - icon: 'text-style', - indicator: 'down', - title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ), - include: [ { group: 'textStyle' }, 'language', 'clear' ], - forceExpand: [ 'bold', 'italic', 'clear' ], - promote: [ 'bold', 'italic' ], - demote: [ 'strikethrough', 'code', 'underline', 'language', 'clear' ] - }, - // Link - { include: [ 'link' ] }, - // Cite-transclusion but not reference - { - type: 'list', - label: OO.ui.deferMsg( 'visualeditor-toolbar-cite-label' ), - indicator: 'down', - include: [ { group: 'cite-transclusion' }/*, 'reference', 'reference/existing'*/ ] - /*demote: [ 'reference', 'reference/existing' ]*/ - }, + 'paragraph', + 'heading1', + 'heading2', + 'heading3', + 'heading4', + 'heading5', + 'heading6', + 'preformatted', + // No tables + 'insertTable', + 'deleteTable', + 'mergeCells', + 'tableCaption', + 'tableCellHeader', + 'tableCellData', // No structure - /* { - type: 'list', - icon: 'bullet-list', - indicator: 'down', - include: [ { group: 'structure' } ], - demote: [ 'outdent', 'indent' ] - },*/ - // Insert - { - label: OO.ui.deferMsg( 'visualeditor-toolbar-insert' ), - indicator: 'down', - include: '*', - exclude: [ - { group: 'format' }, - { group: 'structure' }, - 'reference', - 'referencesList', - 'gallery' - ], - forceExpand: [ 'media', 'transclusion', 'insertTable' ], - promote: [ 'media', 'transclusion' ], - demote: [ 'specialcharacter' ] - }, - // Table - { - header: OO.ui.deferMsg( 'visualeditor-toolbar-table' ), - type: 'list', - icon: 'table-insert', - indicator: 'down', - include: [ { group: 'table' } ], - demote: [ 'deleteTable' ] - } -]; - -ve.ui.MWReferenceDialog.static.surfaceCommands = [ - 'undo', - 'redo', - 'bold', - 'italic', - 'link', - 'clear', - 'underline', - 'subscript', - 'superscript', - 'pasteSpecial' + 'bullet', + 'number', + 'indent', + 'outdent', + // References + 'reference', + 'reference/existing', + 'referencesList' ]; /** @@ -264,8 +211,8 @@ ve.ui.MWReferenceDialog.prototype.useReference = function ( ref ) { this.referenceModel.getDocument(), { $: this.$, - tools: this.constructor.static.toolbarGroups, - commands: this.constructor.static.surfaceCommands, + tools: ve.init.target.constructor.static.toolbarGroups, + excludeCommands: this.constructor.static.excludeCommands, pasteRules: this.constructor.static.getPasteRules() } );