From 1525a0a3d8508914485e8edaaddef24b99843df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 14:27:34 +0100 Subject: [PATCH 01/13] Basic image dialog integration with ACF. --- plugins/dialog/plugin.js | 7 +++++++ plugins/image/dialogs/image.js | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/plugins/dialog/plugin.js b/plugins/dialog/plugin.js index ad8af7cc339..1d08f44cd5e 100644 --- a/plugins/dialog/plugin.js +++ b/plugins/dialog/plugin.js @@ -1024,6 +1024,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * @param {Object} contents Content definition. */ addPage: function( contents ) { + if ( contents.requiredContent && !this._.editor.filter.check( contents.requiredContent ) ) + return; + var pageHtml = [], titleHtml = contents.label ? ' title="' + CKEDITOR.tools.htmlEncode( contents.label ) + '"' : '', elements = contents.elements, @@ -2191,6 +2194,10 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; id = this.id = elementDefinition.id, i; + // TODO do not touch dialog's private parts. + if ( elementDefinition.requiredContent && !dialog._.editor.filter.check( elementDefinition.requiredContent ) ) + styles.display = 'none'; + // Set the id, a unique id is required for getElement() to work. attributes.id = domId; diff --git a/plugins/image/dialogs/image.js b/plugins/image/dialogs/image.js index 471ee092add..d76207bfe3d 100644 --- a/plugins/image/dialogs/image.js +++ b/plugins/image/dialogs/image.js @@ -552,6 +552,7 @@ children: [ { type: 'hbox', + requiredContent: 'img{width,height}', widths: [ '50%', '50%' ], children: [ { @@ -700,6 +701,7 @@ { type: 'text', id: 'txtBorder', + requiredContent: 'img{border-width}', width: '60px', label: editor.lang.image.border, 'default': '', @@ -742,6 +744,7 @@ { type: 'text', id: 'txtHSpace', + requiredContent: 'img{margin-left,margin-right}', width: '60px', label: editor.lang.image.hSpace, 'default': '', @@ -792,6 +795,7 @@ { type: 'text', id: 'txtVSpace', + requiredContent: 'img{margin-top,margin-bottom}', width: '60px', label: editor.lang.image.vSpace, 'default': '', @@ -840,6 +844,7 @@ }, { id: 'cmbAlign', + requiredContent: 'img{float}', type: 'select', widths: [ '35%', '65%' ], style: 'width:90px', @@ -930,6 +935,7 @@ }, { id: 'Link', + requiredContent: 'a[href]', label: editor.lang.image.linkTab, padding: 0, elements: [ @@ -1030,6 +1036,7 @@ { type: 'text', id: 'linkId', + requiredContent: 'img[id]', label: editor.lang.common.id, setup: function( type, element ) { if ( type == IMAGE ) @@ -1045,6 +1052,7 @@ { id: 'cmbLangDir', type: 'select', + requiredContent: 'img[dir]', style: 'width : 100px;', label: editor.lang.common.langDir, 'default': '', @@ -1067,6 +1075,7 @@ { type: 'text', id: 'txtLangCode', + requiredContent: 'img[lang]', label: editor.lang.common.langCode, 'default': '', setup: function( type, element ) { @@ -1085,6 +1094,7 @@ { type: 'text', id: 'txtGenLongDescr', + requiredContent: 'img[longdesc]', label: editor.lang.common.longDescr, setup: function( type, element ) { if ( type == IMAGE ) @@ -1104,6 +1114,7 @@ { type: 'text', id: 'txtGenClass', + requiredContent: 'img(xyz)', // Random text like 'xyz' class will check if all are allowed. label: editor.lang.common.cssClass, 'default': '', setup: function( type, element ) { @@ -1120,6 +1131,7 @@ { type: 'text', id: 'txtGenTitle', + requiredContent: 'img[title]', label: editor.lang.common.advisoryTitle, 'default': '', onChange: function() { @@ -1145,6 +1157,7 @@ { type: 'text', id: 'txtdlgGenStyle', + requiredContent: 'img{xyz}', // Random text like 'xyz' class will check if all are allowed. label: editor.lang.common.cssStyle, validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ), 'default': '', From cbacf3d00b07e7dd53a17eb3564ee70ad27bdd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 14:59:59 +0100 Subject: [PATCH 02/13] Hide tabs without active fields. --- plugins/dialog/plugin.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/dialog/plugin.js b/plugins/dialog/plugin.js index 1d08f44cd5e..a48027d948a 100644 --- a/plugins/dialog/plugin.js +++ b/plugins/dialog/plugin.js @@ -1039,6 +1039,25 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; style: contents.style || 'width: 100%;' }, pageHtml ); + var contentMap = this._.contents[ contents.id ] = {}, + cursor, + children = vbox.getChild(), + enabledFields = 0; + + while ( ( cursor = children.shift() ) ) { + // Count all allowed fields. + if ( !cursor.notAllowed && cursor.type != 'hbox' && cursor.type != 'vbox' ) + enabledFields++; + + contentMap[ cursor.id ] = cursor; + if ( typeof( cursor.getChild ) == 'function' ) + children.push.apply( children, cursor.getChild() ); + } + + // If all fields are disabled (because they are not allowed) hide this tab. + if ( !enabledFields ) + contents.hidden = true; + // Create the HTML for the tab and the content block. var page = CKEDITOR.dom.element.createFromHtml( pageHtml.join( '' ) ); page.setAttribute( 'role', 'tabpanel' ); @@ -1068,16 +1087,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; this._.lastTab = tab; this.updateStyle(); - var contentMap = this._.contents[ contents.id ] = {}, - cursor, - children = vbox.getChild(); - - while ( ( cursor = children.shift() ) ) { - contentMap[ cursor.id ] = cursor; - if ( typeof( cursor.getChild ) == 'function' ) - children.push.apply( children, cursor.getChild() ); - } - // Attach the DOM nodes. page.setAttribute( 'name', contents.id ); @@ -2195,8 +2204,10 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; i; // TODO do not touch dialog's private parts. - if ( elementDefinition.requiredContent && !dialog._.editor.filter.check( elementDefinition.requiredContent ) ) + if ( elementDefinition.requiredContent && !dialog._.editor.filter.check( elementDefinition.requiredContent ) ) { styles.display = 'none'; + this.notAllowed = true; + } // Set the id, a unique id is required for getElement() to work. attributes.id = domId; From 8e32beaa4a08b96d1aa77d3ba2cd32a6be5bf446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 15:51:01 +0100 Subject: [PATCH 03/13] Do not register tabs' content when they are removed. --- plugins/dialog/plugin.js | 6 ++++++ plugins/image/plugin.js | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/dialog/plugin.js b/plugins/dialog/plugin.js index a48027d948a..57a8ae32c66 100644 --- a/plugins/dialog/plugin.js +++ b/plugins/dialog/plugin.js @@ -1434,6 +1434,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; return CKEDITOR.dialog._.currentTop; }, + isTabEnabled: function( editor, dialogName, tabName ) { + var cfg = editor.config.removeDialogTabs; + + return !( cfg && cfg.match( new RegExp( '(?:^|;)' + dialogName + ':' + tabName + '(?:$|;)', 'i' ) ) ); + }, + /** * The default OK button for dialogs. Fires the `ok` event and closes the dialog if the event succeeds. * diff --git a/plugins/image/plugin.js b/plugins/image/plugin.js index 082d7ccd586..d0d04223e8f 100644 --- a/plugins/image/plugin.js +++ b/plugins/image/plugin.js @@ -19,10 +19,18 @@ // Register the dialog. CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/image.js' ); + var allowed = 'img[alt,src]{border-style,border-width,height,margin,margin-bottom,margin-left,margin-right,margin-top,width}', + required = 'img[alt,src]'; + + if ( CKEDITOR.dialog.isTabEnabled( editor, pluginName, 'advanced' ) ) + allowed += ';img[dir,id,lang,longdesc,title]{*}(*)'; + if ( CKEDITOR.dialog.isTabEnabled( editor, pluginName, 'link' ) ) + allowed += ';a[href]'; + // Register the command. editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName, { - allowedContent: 'img[align,alt,dir,id,lang,longdesc,src,title]{*}(*)', - requiredContent: 'img[alt,src]', + allowedContent: allowed, + requiredContent: required, contentTransformations: [ [ 'img{width}: sizeToStyle', 'img[width]: sizeToAttribute' ] ] From c3e6a09b61677f2e9c7ce99ce84d2409488a9542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 16:03:56 +0100 Subject: [PATCH 04/13] Remove advanced tabs on all editors. --- samples/filter.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/filter.html b/samples/filter.html index c1b63be4bed..3c91a524627 100644 --- a/samples/filter.html +++ b/samples/filter.html @@ -9,6 +9,10 @@ +

From 1946dc9eca06536729c3e78a52226c4b5094fe8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 16:28:27 +0100 Subject: [PATCH 05/13] Integrated link dialog with ACF. --- plugins/image/dialogs/image.js | 4 ++-- plugins/link/dialogs/link.js | 13 +++++++++++++ plugins/link/plugin.js | 12 ++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/plugins/image/dialogs/image.js b/plugins/image/dialogs/image.js index d76207bfe3d..7dfaecb3c7f 100644 --- a/plugins/image/dialogs/image.js +++ b/plugins/image/dialogs/image.js @@ -1114,7 +1114,7 @@ { type: 'text', id: 'txtGenClass', - requiredContent: 'img(xyz)', // Random text like 'xyz' class will check if all are allowed. + requiredContent: 'img(cke-xyz)', // Random text like 'xyz' will check if all are allowed. label: editor.lang.common.cssClass, 'default': '', setup: function( type, element ) { @@ -1157,7 +1157,7 @@ { type: 'text', id: 'txtdlgGenStyle', - requiredContent: 'img{xyz}', // Random text like 'xyz' class will check if all are allowed. + requiredContent: 'img{cke-xyz}', // Random text like 'xyz' will check if all are allowed. label: editor.lang.common.cssStyle, validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ), 'default': '', diff --git a/plugins/link/dialogs/link.js b/plugins/link/dialogs/link.js index c06519c1b46..f471dce3296 100755 --- a/plugins/link/dialogs/link.js +++ b/plugins/link/dialogs/link.js @@ -650,6 +650,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { }, { id: 'target', + requiredContent: 'a[target]', // This is not fully correct, because some target option requires JS. label: linkLang.target, title: linkLang.target, elements: [ @@ -892,6 +893,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', id: 'advId', + requiredContent: 'a[id]', label: linkLang.id, setup: setupAdvParams, commit: commitAdvParams @@ -899,6 +901,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'select', id: 'advLangDir', + requiredContent: 'a[dir]', label: linkLang.langDir, 'default': '', style: 'width:110px', @@ -913,6 +916,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', id: 'advAccessKey', + requiredContent: 'a[accesskey]', width: '80px', label: linkLang.acccessKey, maxLength: 1, @@ -930,6 +934,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { type: 'text', label: linkLang.name, id: 'advName', + requiredContent: 'a[name]', setup: setupAdvParams, commit: commitAdvParams @@ -938,6 +943,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { type: 'text', label: linkLang.langCode, id: 'advLangCode', + requiredContent: 'a[lang]', width: '110px', 'default': '', setup: setupAdvParams, @@ -948,6 +954,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { type: 'text', label: linkLang.tabIndex, id: 'advTabIndex', + requiredContent: 'a[tabindex]', width: '80px', maxLength: 5, setup: setupAdvParams, @@ -969,6 +976,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', label: linkLang.advisoryTitle, + requiredContent: 'a[title]', 'default': '', id: 'advTitle', setup: setupAdvParams, @@ -978,6 +986,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', label: linkLang.advisoryContentType, + requiredContent: 'a[type]', 'default': '', id: 'advContentType', setup: setupAdvParams, @@ -993,6 +1002,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', label: linkLang.cssClasses, + requiredContent: 'a(cke-xyz)', // Random text like 'xyz' will check if all are allowed. 'default': '', id: 'advCSSClasses', setup: setupAdvParams, @@ -1002,6 +1012,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', label: linkLang.charset, + requiredContent: 'a[charset]', 'default': '', id: 'advCharset', setup: setupAdvParams, @@ -1017,6 +1028,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', label: linkLang.rel, + requiredContent: 'a[rel]', 'default': '', id: 'advRel', setup: setupAdvParams, @@ -1025,6 +1037,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) { { type: 'text', label: linkLang.styles, + requiredContent: 'a{cke-xyz}', // Random text like 'xyz' will check if all are allowed. 'default': '', id: 'advStyles', validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ), diff --git a/plugins/link/plugin.js b/plugins/link/plugin.js index 023b2247428..149f4007f9e 100755 --- a/plugins/link/plugin.js +++ b/plugins/link/plugin.js @@ -48,10 +48,18 @@ CKEDITOR.plugins.add( 'link', { }, init: function( editor ) { + var allowed = 'a[!href]', + required = 'a[href]'; + + if ( CKEDITOR.dialog.isTabEnabled( editor, 'link', 'advanced' ) ) + allowed += ';a[accesskey,charset,dir,id,lang,name,rel,tabindex,title,type]{*}(*)'; + if ( CKEDITOR.dialog.isTabEnabled( editor, 'link', 'target' ) ) + allowed += ';a[target,onclick]'; + // Add the link and unlink buttons. editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link', { - allowedContent: 'a[accesskey,charset,dir,!href,id,lang,name,rel,tabindex,target,title,type](*){*}', - requiredContent: 'a[href]' + allowedContent: allowed, + requiredContent: required } ) ); editor.addCommand( 'anchor', new CKEDITOR.dialogCommand( 'anchor', { allowedContent: 'a[!name]', From 73b3fcefb461fe236c11d2f3ef0be108e6cd6de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 16:54:39 +0100 Subject: [PATCH 06/13] Integrated table dialog with ACF. --- plugins/table/dialogs/table.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/table/dialogs/table.js b/plugins/table/dialogs/table.js index e16c828c61b..f8184af31ec 100755 --- a/plugins/table/dialogs/table.js +++ b/plugins/table/dialogs/table.js @@ -290,6 +290,7 @@ { type: 'select', id: 'selHeaders', + requiredContent: 'th', 'default': '', label: editor.lang.table.headers, items: [ @@ -324,6 +325,8 @@ { type: 'text', id: 'txtBorder', + requiredContent: 'table[border]', + // Avoid setting border which will then disappear. 'default': 1, label: editor.lang.table.border, controlStyle: 'width:3em', @@ -341,6 +344,7 @@ { id: 'cmbAlign', type: 'select', + requiredContent: 'table[align]', 'default': '', label: editor.lang.common.align, items: [ @@ -372,6 +376,7 @@ { type: 'text', id: 'txtWidth', + requiredContent: 'table{width}', controlStyle: 'width:5em', label: editor.lang.common.width, title: editor.lang.common.cssLengthTooltip, @@ -398,6 +403,7 @@ { type: 'text', id: 'txtHeight', + requiredContent: 'table{height}', controlStyle: 'width:5em', label: editor.lang.common.height, title: editor.lang.common.cssLengthTooltip, @@ -424,6 +430,7 @@ { type: 'text', id: 'txtCellSpace', + requiredContent: 'table[cellspacing]', controlStyle: 'width:3em', label: editor.lang.table.cellSpace, 'default': 1, @@ -441,6 +448,7 @@ { type: 'text', id: 'txtCellPad', + requiredContent: 'table[cellpadding]', controlStyle: 'width:3em', label: editor.lang.table.cellPad, 'default': 1, @@ -471,6 +479,7 @@ { type: 'text', id: 'txtCaption', + requiredContent: 'caption', label: editor.lang.table.caption, setup: function( selectedTable ) { this.enable(); @@ -517,6 +526,7 @@ { type: 'text', id: 'txtSummary', + requiredContent: 'table[summary]', label: editor.lang.table.summary, setup: function( selectedTable ) { this.setValue( selectedTable.getAttribute( 'summary' ) || '' ); From 535a16970e79c7f52a35d9480e5ba319469ef3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Feb 2013 17:03:34 +0100 Subject: [PATCH 07/13] Reset default values for hidden inputs. --- plugins/table/dialogs/table.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/table/dialogs/table.js b/plugins/table/dialogs/table.js index f8184af31ec..9deec0e34fb 100755 --- a/plugins/table/dialogs/table.js +++ b/plugins/table/dialogs/table.js @@ -327,7 +327,7 @@ id: 'txtBorder', requiredContent: 'table[border]', // Avoid setting border which will then disappear. - 'default': 1, + 'default': editor.filter.check( 'table[border]' ) ? 1 : 0, label: editor.lang.table.border, controlStyle: 'width:3em', validate: CKEDITOR.dialog.validate[ 'number' ]( editor.lang.table.invalidBorder ), @@ -381,7 +381,7 @@ label: editor.lang.common.width, title: editor.lang.common.cssLengthTooltip, // Smarter default table width. (#9600) - 'default': editable.getSize( 'width' ) < 500 ? '100%' : 500, + 'default': editor.filter.check( 'table{width}' ) ? ( editable.getSize( 'width' ) < 500 ? '100%' : 500 ) : 0, getValue: defaultToPixel, validate: CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength.replace( '%1', editor.lang.common.width ) ), onChange: function() { @@ -433,7 +433,7 @@ requiredContent: 'table[cellspacing]', controlStyle: 'width:3em', label: editor.lang.table.cellSpace, - 'default': 1, + 'default': editor.filter.check( 'table[cellspacing]' ) ? 1 : 0, validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellSpacing ), setup: function( selectedTable ) { this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' ); @@ -451,7 +451,7 @@ requiredContent: 'table[cellpadding]', controlStyle: 'width:3em', label: editor.lang.table.cellPad, - 'default': 1, + 'default': editor.filter.check( 'table[cellpadding]' ) ? 1 : 0, validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellPadding ), setup: function( selectedTable ) { this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' ); From a5e02044c196be55afda268004992547da88c8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 12 Feb 2013 09:49:48 +0100 Subject: [PATCH 08/13] Integrated div dialog with ACF. --- plugins/div/dialogs/div.js | 18 +++++++++++++----- plugins/div/plugin.js | 8 ++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/div/dialogs/div.js b/plugins/div/dialogs/div.js index 7debb201c99..2f422a4fe9a 100644 --- a/plugins/div/dialogs/div.js +++ b/plugins/div/dialogs/div.js @@ -275,6 +275,7 @@ { id: 'class', type: 'text', + requiredContent: 'div(cke-xyz)', // Random text like 'xyz' will check if all are allowed. label: editor.lang.common.cssClass, 'default': '' } @@ -298,12 +299,14 @@ { type: 'text', id: 'id', + requiredContent: 'div[id]', label: editor.lang.common.id, 'default': '' }, { type: 'text', id: 'lang', + requiredContent: 'div[lang]', label: editor.lang.common.langCode, 'default': '' } @@ -315,6 +318,7 @@ { type: 'text', id: 'style', + requiredContent: 'div{cke-xyz}', // Random text like 'xyz' will check if all are allowed. style: 'width: 100%;', label: editor.lang.common.cssStyle, 'default': '', @@ -330,6 +334,7 @@ { type: 'text', id: 'title', + requiredContent: 'div[title]', style: 'width: 100%;', label: editor.lang.common.advisoryTitle, 'default': '' @@ -339,6 +344,7 @@ { type: 'select', id: 'dir', + requiredContent: 'div[dir]', style: 'width: 100%;', label: editor.lang.common.langDir, 'default': '', @@ -368,7 +374,7 @@ // Reuse the 'stylescombo' plugin's styles definition. editor.getStylesSet( function( stylesDefinitions ) { - var styleName; + var styleName, style; if ( stylesDefinitions ) { // Digg only those styles that apply to 'div'. @@ -376,11 +382,13 @@ var styleDefinition = stylesDefinitions[ i ]; if ( styleDefinition.element && styleDefinition.element == 'div' ) { styleName = styleDefinition.name; - styles[ styleName ] = new CKEDITOR.style( styleDefinition ); + styles[ styleName ] = style = new CKEDITOR.style( styleDefinition ); - // Populate the styles field options with style name. - stylesField.items.push( [ styleName, styleName ] ); - stylesField.add( styleName, styleName ); + if ( editor.filter.check( style ) ) { + // Populate the styles field options with style name. + stylesField.items.push( [ styleName, styleName ] ); + stylesField.add( styleName, styleName ); + } } } } diff --git a/plugins/div/plugin.js b/plugins/div/plugin.js index 261b889b948..0e7bb796a14 100644 --- a/plugins/div/plugin.js +++ b/plugins/div/plugin.js @@ -17,10 +17,14 @@ if ( editor.blockless ) return; - var lang = editor.lang.div; + var lang = editor.lang.div, + allowed = 'div(*)'; + + if ( CKEDITOR.dialog.isTabEnabled( editor, 'editdiv', 'advanced' ) ) + allowed += ';div[dir,id,lang,title]{*}'; editor.addCommand( 'creatediv', new CKEDITOR.dialogCommand( 'creatediv', { - allowedContent: 'div(*)[dir,id,lang,title]{*}', + allowedContent: allowed, requiredContent: 'div', contextSensitive: true, refresh: function( editor, path ) { From 3af9a093ad814a87ffdf556908e886cd200d0cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 12 Feb 2013 11:06:46 +0100 Subject: [PATCH 09/13] Integrated flash dialog with ACF. --- plugins/flash/dialogs/flash.js | 13 +++++++++++++ plugins/flash/plugin.js | 13 ++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/flash/dialogs/flash.js b/plugins/flash/dialogs/flash.js index d0f6ca51d5c..8d2f0b25658 100644 --- a/plugins/flash/dialogs/flash.js +++ b/plugins/flash/dialogs/flash.js @@ -373,6 +373,7 @@ { type: 'text', id: 'width', + requiredContent: 'embed[width]', style: 'width:95px', label: editor.lang.common.width, validate: CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.width ) ), @@ -382,6 +383,7 @@ { type: 'text', id: 'height', + requiredContent: 'embed[height]', style: 'width:95px', label: editor.lang.common.height, validate: CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.height ) ), @@ -391,6 +393,7 @@ { type: 'text', id: 'hSpace', + requiredContent: 'embed[hspace]', style: 'width:95px', label: editor.lang.flash.hSpace, validate: CKEDITOR.dialog.validate.integer( editor.lang.flash.validateHSpace ), @@ -400,6 +403,7 @@ { type: 'text', id: 'vSpace', + requiredContent: 'embed[vspace]', style: 'width:95px', label: editor.lang.flash.vSpace, validate: CKEDITOR.dialog.validate.integer( editor.lang.flash.validateVSpace ), @@ -454,6 +458,7 @@ { id: 'scale', type: 'select', + requiredContent: 'embed[scale]', label: editor.lang.flash.scale, 'default': '', style: 'width : 100%;', @@ -469,6 +474,7 @@ { id: 'allowScriptAccess', type: 'select', + requiredContent: 'embed[allowscriptaccess]', label: editor.lang.flash.access, 'default': '', style: 'width : 100%;', @@ -490,6 +496,7 @@ { id: 'wmode', type: 'select', + requiredContent: 'embed[wmode]', label: editor.lang.flash.windowMode, 'default': '', style: 'width : 100%;', @@ -505,6 +512,7 @@ { id: 'quality', type: 'select', + requiredContent: 'embed[quality]', label: editor.lang.flash.quality, 'default': 'high', style: 'width : 100%;', @@ -529,6 +537,7 @@ { id: 'align', type: 'select', + requiredContent: 'object[align]', label: editor.lang.common.align, 'default': '', style: 'width : 100%;', @@ -613,6 +622,7 @@ { type: 'text', id: 'id', + requiredContent: 'object[id]', label: editor.lang.common.id, setup: loadValue, commit: commitValue @@ -626,6 +636,7 @@ { type: 'text', id: 'bgcolor', + requiredContent: 'embed[bgcolor]', label: editor.lang.flash.bgcolor, setup: loadValue, commit: commitValue @@ -633,6 +644,7 @@ { type: 'text', id: 'class', + requiredContent: 'embed(cke-xyz)', // Random text like 'xyz' will check if all are allowed. label: editor.lang.common.cssClass, setup: loadValue, commit: commitValue @@ -642,6 +654,7 @@ { type: 'text', id: 'style', + requiredContent: 'embed{cke-xyz}', // Random text like 'xyz' will check if all are allowed. validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ), label: editor.lang.common.cssStyle, setup: loadValue, diff --git a/plugins/flash/plugin.js b/plugins/flash/plugin.js index 56097d4a25c..46d4716e8d0 100644 --- a/plugins/flash/plugin.js +++ b/plugins/flash/plugin.js @@ -34,10 +34,17 @@ }, init: function( editor ) { + var allowed = 'object[classid,codebase,height,hspace,vspace,width];' + + 'param[name,value];' + + 'embed[height,hspace,pluginspage,src,type,vspace,width]'; + + if ( CKEDITOR.dialog.isTabEnabled( editor, 'flash', 'properties' ) ) + allowed += ';object[align]; embed[allowscriptaccess,quality,scale,wmode]'; + if ( CKEDITOR.dialog.isTabEnabled( editor, 'flash', 'advanced' ) ) + allowed += ';object[id]{*}; embed[bgcolor]{*}(*)'; + editor.addCommand( 'flash', new CKEDITOR.dialogCommand( 'flash', { - allowedContent: 'object[align,classid,codebase,height,hspace,vspace,width]{*}(*);' + - 'param[name,value];' + - 'embed[allowscriptaccess,bgcolor,height,hspace,pluginspage,quality,scale,src,type,vspace,width,wmode]{*}(*)', + allowedContent: allowed, requiredContent: 'embed' } ) ); editor.ui.addButton && editor.ui.addButton( 'Flash', { From 825c039a38b30983f2c6efd6f3e278e8a3ed2a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 12 Feb 2013 11:26:24 +0100 Subject: [PATCH 10/13] Integrated iframe dialog with ACF. --- plugins/iframe/dialogs/iframe.js | 8 ++++++++ plugins/iframe/plugin.js | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/iframe/dialogs/iframe.js b/plugins/iframe/dialogs/iframe.js index beeacd8c3af..a4885fad3cf 100644 --- a/plugins/iframe/dialogs/iframe.js +++ b/plugins/iframe/dialogs/iframe.js @@ -107,6 +107,7 @@ { id: 'width', type: 'text', + requiredContent: 'iframe[width]', style: 'width:100%', labelLayout: 'vertical', label: commonLang.width, @@ -117,6 +118,7 @@ { id: 'height', type: 'text', + requiredContent: 'iframe[height]', style: 'width:100%', labelLayout: 'vertical', label: commonLang.height, @@ -127,6 +129,7 @@ { id: 'align', type: 'select', + requiredContent: 'iframe[align]', 'default': '', items: [ [ commonLang.notSet, '' ], @@ -161,6 +164,7 @@ { id: 'scrolling', type: 'checkbox', + requiredContent: 'iframe[scrolling]', label: iframeLang.scrolling, setup: loadValue, commit: commitValue @@ -168,6 +172,7 @@ { id: 'frameborder', type: 'checkbox', + requiredContent: 'iframe[frameborder]', label: iframeLang.border, setup: loadValue, commit: commitValue @@ -181,6 +186,7 @@ { id: 'name', type: 'text', + requiredContent: 'iframe[name]', label: commonLang.name, setup: loadValue, commit: commitValue @@ -188,6 +194,7 @@ { id: 'title', type: 'text', + requiredContent: 'iframe[title]', label: commonLang.advisoryTitle, setup: loadValue, commit: commitValue @@ -197,6 +204,7 @@ { id: 'longdesc', type: 'text', + requiredContent: 'iframe[longdesc]', label: commonLang.longDescr, setup: loadValue, commit: commitValue diff --git a/plugins/iframe/plugin.js b/plugins/iframe/plugin.js index 4bb7ced463f..23245e6bc3e 100644 --- a/plugins/iframe/plugin.js +++ b/plugins/iframe/plugin.js @@ -22,12 +22,15 @@ }, init: function( editor ) { var pluginName = 'iframe', - lang = editor.lang.iframe; + lang = editor.lang.iframe, + allowed = 'iframe[align,longdesc,frameborder,height,name,scrolling,src,title,width]'; + + if ( editor.plugins.dialogadvtab ) + allowed += ';iframe' + editor.plugins.dialogadvtab.allowedContent( { id:1,classes:1,styles:1 } ); CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/iframe.js' ); editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName, { - allowedContent: 'iframe[align,longdesc,frameborder,height,name,scrolling,src,title,width]{height,width};' + - ( editor.plugins.dialogadvtab ? 'iframe' + editor.plugins.dialogadvtab.allowedContent( { id:1,classes:1,styles:1 } ) : '' ), + allowedContent: allowed, requiredContent: 'iframe' } ) ); From 063f6b909a85a45ea8fd83267d49309a37bbfecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 12 Feb 2013 11:36:35 +0100 Subject: [PATCH 11/13] Integrated dialogadvtab with ACF. --- plugins/dialogadvtab/plugin.js | 6 +++++- plugins/iframe/dialogs/iframe.js | 2 +- plugins/table/dialogs/table.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/dialogadvtab/plugin.js b/plugins/dialogadvtab/plugin.js index d31165cbb5e..4a4aa142278 100644 --- a/plugins/dialogadvtab/plugin.js +++ b/plugins/dialogadvtab/plugin.js @@ -68,7 +68,7 @@ // @param tabConfig // id, dir, classes, styles - createAdvancedTab: function( editor, tabConfig ) { + createAdvancedTab: function( editor, tabConfig, element ) { if ( !tabConfig ) tabConfig = defaultTabConfig; @@ -95,6 +95,7 @@ id: 'advId', att: 'id', type: 'text', + requiredContent: element ? element + '[id]' : null, label: lang.id, setup: setupAdvParams, commit: commitAdvParams @@ -106,6 +107,7 @@ id: 'advLangDir', att: 'dir', type: 'select', + requiredContent: element ? element + '[dir]' : null, label: lang.langDir, 'default': '', style: 'width:100%', @@ -134,6 +136,7 @@ id: 'advStyles', att: 'style', type: 'text', + requiredContent: element ? element + '{cke-xyz}' : null, label: lang.styles, 'default': '', @@ -172,6 +175,7 @@ id: 'advCSSClasses', att: 'class', type: 'text', + requiredContent: element ? element + '(cke-xyz)' : null, label: lang.cssClasses, 'default': '', setup: setupAdvParams, diff --git a/plugins/iframe/dialogs/iframe.js b/plugins/iframe/dialogs/iframe.js index a4885fad3cf..f8e7bece6d7 100644 --- a/plugins/iframe/dialogs/iframe.js +++ b/plugins/iframe/dialogs/iframe.js @@ -211,7 +211,7 @@ } ] }, - dialogadvtab && dialogadvtab.createAdvancedTab( editor, { id:1,classes:1,styles:1 } ) + dialogadvtab && dialogadvtab.createAdvancedTab( editor, { id:1,classes:1,styles:1 }, 'iframe' ) ] }; }); diff --git a/plugins/table/dialogs/table.js b/plugins/table/dialogs/table.js index 9deec0e34fb..0645d9366d1 100755 --- a/plugins/table/dialogs/table.js +++ b/plugins/table/dialogs/table.js @@ -542,7 +542,7 @@ } ] }, - dialogadvtab && dialogadvtab.createAdvancedTab( editor ) + dialogadvtab && dialogadvtab.createAdvancedTab( editor, null, 'table' ) ] }; } From f6c436cfb467958d41e767cb752a17206b314215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 12 Feb 2013 13:27:55 +0100 Subject: [PATCH 12/13] Do not touch dialog's private parts. --- plugins/dialog/plugin.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/dialog/plugin.js b/plugins/dialog/plugin.js index 57a8ae32c66..5a7bbbf6016 100644 --- a/plugins/dialog/plugin.js +++ b/plugins/dialog/plugin.js @@ -2209,8 +2209,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; id = this.id = elementDefinition.id, i; - // TODO do not touch dialog's private parts. - if ( elementDefinition.requiredContent && !dialog._.editor.filter.check( elementDefinition.requiredContent ) ) { + if ( elementDefinition.requiredContent && !dialog.getParentEditor().filter.check( elementDefinition.requiredContent ) ) { styles.display = 'none'; this.notAllowed = true; } From 05c1c01669accea4dbec0e7e9070fdded6ffa6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 12 Feb 2013 14:07:08 +0100 Subject: [PATCH 13/13] Docs. --- plugins/dialog/dialogDefinition.js | 9 +++++++++ plugins/dialog/plugin.js | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/plugins/dialog/dialogDefinition.js b/plugins/dialog/dialogDefinition.js index 0abdbcb06c6..fa6b3273fcc 100644 --- a/plugins/dialog/dialogDefinition.js +++ b/plugins/dialog/dialogDefinition.js @@ -195,6 +195,15 @@ * @property {String} title */ +/** + * The content that needs to be allowed to enable this UI element. + * All formats accepted by {@link CKEDITOR.filter#check} may be used. + * + * When all UI elements in a tab are disabled, this tab will be disabled automatically. + * + * @property {String/Object/CKEDITOR.style} requiredContent + */ + /** * CSS class names to append to the UI element. * diff --git a/plugins/dialog/plugin.js b/plugins/dialog/plugin.js index 5a7bbbf6016..fef8d346ed5 100644 --- a/plugins/dialog/plugin.js +++ b/plugins/dialog/plugin.js @@ -1434,6 +1434,14 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; return CKEDITOR.dialog._.currentTop; }, + /** + * Check whether tab wasn't removed by {@link CKEDITOR.config#removeDialogTabs}. + * + * @param {CKEDITOR.editor} editor + * @param {String} dialogName + * @param {String} tabName + * @returns {Boolean} + */ isTabEnabled: function( editor, dialogName, tabName ) { var cfg = editor.config.removeDialogTabs;