aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/widget/plugin.js
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/widget/plugin.js')
-rw-r--r--sources/plugins/widget/plugin.js91
1 files changed, 56 insertions, 35 deletions
diff --git a/sources/plugins/widget/plugin.js b/sources/plugins/widget/plugin.js
index 37374ab..2708e09 100644
--- a/sources/plugins/widget/plugin.js
+++ b/sources/plugins/widget/plugin.js
@@ -14,7 +14,7 @@
14 14
15 CKEDITOR.plugins.add( 'widget', { 15 CKEDITOR.plugins.add( 'widget', {
16 // jscs:disable maximumLineLength 16 // jscs:disable maximumLineLength
17 lang: 'af,ar,az,bg,ca,cs,cy,da,de,de-ch,el,en,en-gb,eo,es,eu,fa,fi,fr,gl,he,hr,hu,id,it,ja,km,ko,ku,lv,nb,nl,no,oc,pl,pt,pt-br,ru,sk,sl,sq,sv,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% 17 lang: 'af,ar,az,bg,ca,cs,cy,da,de,de-ch,el,en,en-gb,eo,es,es-mx,eu,fa,fi,fr,gl,he,hr,hu,id,it,ja,km,ko,ku,lv,nb,nl,no,oc,pl,pt,pt-br,ru,sk,sl,sq,sv,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%
18 // jscs:enable maximumLineLength 18 // jscs:enable maximumLineLength
19 requires: 'lineutils,clipboard,widgetselection', 19 requires: 'lineutils,clipboard,widgetselection',
20 onLoad: function() { 20 onLoad: function() {
@@ -46,13 +46,13 @@
46 'width:' + DRAG_HANDLER_SIZE + 'px;' + 46 'width:' + DRAG_HANDLER_SIZE + 'px;' +
47 'height:0;' + 47 'height:0;' +
48 // Initially drag handler should not be visible, until its position will be 48 // Initially drag handler should not be visible, until its position will be
49 // calculated (#11177). 49 // calculated (http://dev.ckeditor.com/ticket/11177).
50 // We need to hide unpositined handlers, so they don't extend 50 // We need to hide unpositined handlers, so they don't extend
51 // widget's outline far to the left (#12024). 51 // widget's outline far to the left (http://dev.ckeditor.com/ticket/12024).
52 'display:none;' + 52 'display:none;' +
53 'opacity:0.75;' + 53 'opacity:0.75;' +
54 'transition:height 0s 0.2s;' + // Delay hiding drag handler. 54 'transition:height 0s 0.2s;' + // Delay hiding drag handler.
55 // Prevent drag handler from being misplaced (#11198). 55 // Prevent drag handler from being misplaced (http://dev.ckeditor.com/ticket/11198).
56 'line-height:0' + 56 'line-height:0' +
57 '}' + 57 '}' +
58 '.cke_widget_wrapper:hover>.cke_widget_drag_handler_container{' + 58 '.cke_widget_wrapper:hover>.cke_widget_drag_handler_container{' +
@@ -1211,7 +1211,7 @@
1211 * @returns {Boolean} Whether an editable was successfully initialized. 1211 * @returns {Boolean} Whether an editable was successfully initialized.
1212 */ 1212 */
1213 initEditable: function( editableName, definition ) { 1213 initEditable: function( editableName, definition ) {
1214 // Don't fetch just first element which matched selector but look for a correct one. (#13334) 1214 // Don't fetch just first element which matched selector but look for a correct one. (http://dev.ckeditor.com/ticket/13334)
1215 var editable = this._findOneNotNested( definition.selector ); 1215 var editable = this._findOneNotNested( definition.selector );
1216 1216
1217 if ( editable && editable.is( CKEDITOR.dtd.$editable ) ) { 1217 if ( editable && editable.is( CKEDITOR.dtd.$editable ) ) {
@@ -1255,7 +1255,7 @@
1255 1255
1256 /** 1256 /**
1257 * Looks inside wrapper element to find a node that 1257 * Looks inside wrapper element to find a node that
1258 * matches given selector and is not nested in other widget. (#13334) 1258 * matches given selector and is not nested in other widget. (http://dev.ckeditor.com/ticket/13334)
1259 * 1259 *
1260 * @since 4.5 1260 * @since 4.5
1261 * @private 1261 * @private
@@ -1320,7 +1320,7 @@
1320 !isDirty && this.editor.resetDirty(); 1320 !isDirty && this.editor.resetDirty();
1321 } 1321 }
1322 1322
1323 // Always focus editor (not only when focusManger.hasFocus is false) (because of #10483). 1323 // Always focus editor (not only when focusManger.hasFocus is false) (because of http://dev.ckeditor.com/ticket/10483).
1324 this.editor.focus(); 1324 this.editor.focus();
1325 }, 1325 },
1326 1326
@@ -1473,7 +1473,7 @@
1473 if ( oldPos && newPos.x == oldPos.x && newPos.y == oldPos.y ) 1473 if ( oldPos && newPos.x == oldPos.x && newPos.y == oldPos.y )
1474 return; 1474 return;
1475 1475
1476 // We need to make sure that dirty state is not changed (#11487). 1476 // We need to make sure that dirty state is not changed (http://dev.ckeditor.com/ticket/11487).
1477 var initialDirty = editor.checkDirty(); 1477 var initialDirty = editor.checkDirty();
1478 1478
1479 editor.fire( 'lockSnapshot' ); 1479 editor.fire( 'lockSnapshot' );
@@ -2008,7 +2008,7 @@
2008 2008
2009 // Remove widgets which have no corresponding elements in DOM. 2009 // Remove widgets which have no corresponding elements in DOM.
2010 for ( i in instances ) { 2010 for ( i in instances ) {
2011 // #13410 Remove widgets that are ready. This prevents from destroying widgets that are during loading process. 2011 // http://dev.ckeditor.com/ticket/13410 Remove widgets that are ready. This prevents from destroying widgets that are during loading process.
2012 if ( instances[ i ].isReady() && !editable.contains( instances[ i ].wrapper ) ) 2012 if ( instances[ i ].isReady() && !editable.contains( instances[ i ].wrapper ) )
2013 this.destroy( instances[ i ], true ); 2013 this.destroy( instances[ i ], true );
2014 } 2014 }
@@ -2027,7 +2027,7 @@
2027 2027
2028 // Check if: 2028 // Check if:
2029 // * there's no instance for this widget 2029 // * there's no instance for this widget
2030 // * wrapper is not inside some temporary element like copybin (#11088) 2030 // * wrapper is not inside some temporary element like copybin (http://dev.ckeditor.com/ticket/11088)
2031 // * it was a nested widget's wrapper which has been detached from DOM, 2031 // * it was a nested widget's wrapper which has been detached from DOM,
2032 // when nested editable has been initialized (it overwrites its innerHTML 2032 // when nested editable has been initialized (it overwrites its innerHTML
2033 // and initializes nested widgets). 2033 // and initializes nested widgets).
@@ -2095,7 +2095,7 @@
2095 // @returns {CKEDITOR.filter} Filter instance or `null` if rules are not defined. 2095 // @returns {CKEDITOR.filter} Filter instance or `null` if rules are not defined.
2096 // @context CKEDITOR.plugins.widget.repository 2096 // @context CKEDITOR.plugins.widget.repository
2097 function createEditableFilter( widgetName, editableName, editableDefinition ) { 2097 function createEditableFilter( widgetName, editableName, editableDefinition ) {
2098 if ( !editableDefinition.allowedContent ) 2098 if ( !editableDefinition.allowedContent && !editableDefinition.disallowedContent )
2099 return null; 2099 return null;
2100 2100
2101 var editables = this._.filters[ widgetName ]; 2101 var editables = this._.filters[ widgetName ];
@@ -2105,8 +2105,15 @@
2105 2105
2106 var filter = editables[ editableName ]; 2106 var filter = editables[ editableName ];
2107 2107
2108 if ( !filter ) 2108 if ( !filter ) {
2109 editables[ editableName ] = filter = new CKEDITOR.filter( editableDefinition.allowedContent ); 2109 filter = editableDefinition.allowedContent ? new CKEDITOR.filter( editableDefinition.allowedContent ) : this.editor.filter.clone();
2110
2111 editables[ editableName ] = filter;
2112
2113 if ( editableDefinition.disallowedContent ) {
2114 filter.disallow( editableDefinition.disallowedContent );
2115 }
2116 }
2110 2117
2111 return filter; 2118 return filter;
2112 } 2119 }
@@ -2149,7 +2156,7 @@
2149 return false; 2156 return false;
2150 } 2157 }
2151 else if ( ( upcastsLength = upcasts.length ) ) { 2158 else if ( ( upcastsLength = upcasts.length ) ) {
2152 // Ignore elements with data-cke-widget-upcasted to avoid multiple upcasts (#11533). 2159 // Ignore elements with data-cke-widget-upcasted to avoid multiple upcasts (http://dev.ckeditor.com/ticket/11533).
2153 // Do not iterate over descendants. 2160 // Do not iterate over descendants.
2154 if ( element.attributes[ 'data-cke-widget-upcasted' ] ) 2161 if ( element.attributes[ 'data-cke-widget-upcasted' ] )
2155 return false; 2162 return false;
@@ -2356,7 +2363,7 @@
2356 '(?:</(?:div|span)>)?' + 2363 '(?:</(?:div|span)>)?' +
2357 '(?:</(?:div|span)>)?' + 2364 '(?:</(?:div|span)>)?' +
2358 '$', 2365 '$',
2359 // IE8 prefers uppercase when browsers stick to lowercase HTML (#13460). 2366 // IE8 prefers uppercase when browsers stick to lowercase HTML (http://dev.ckeditor.com/ticket/13460).
2360 'i' 2367 'i'
2361 ); 2368 );
2362 2369
@@ -2384,7 +2391,7 @@
2384 // IE needs focus. 2391 // IE needs focus.
2385 editor.focus(); 2392 editor.focus();
2386 2393
2387 // and widget need to be focused on drag start (#12172#comment:10). 2394 // and widget need to be focused on drag start (http://dev.ckeditor.com/ticket/12172#comment:10).
2388 widget.focus(); 2395 widget.focus();
2389 } 2396 }
2390 } ); 2397 } );
@@ -2396,7 +2403,7 @@
2396 dragRange = editor.createRange(), 2403 dragRange = editor.createRange(),
2397 sourceWidget; 2404 sourceWidget;
2398 2405
2399 // Disable cross-editor drag & drop for widgets - #13599. 2406 // Disable cross-editor drag & drop for widgets - http://dev.ckeditor.com/ticket/13599.
2400 if ( id !== '' && transferType === CKEDITOR.DATA_TRANSFER_CROSS_EDITORS ) { 2407 if ( id !== '' && transferType === CKEDITOR.DATA_TRANSFER_CROSS_EDITORS ) {
2401 evt.cancel(); 2408 evt.cancel();
2402 return; 2409 return;
@@ -2440,16 +2447,16 @@
2440 if ( !el.is( CKEDITOR.dtd.$block ) ) 2447 if ( !el.is( CKEDITOR.dtd.$block ) )
2441 return; 2448 return;
2442 2449
2443 // Allow drop line inside, but never before or after nested editable (#12006). 2450 // Allow drop line inside, but never before or after nested editable (http://dev.ckeditor.com/ticket/12006).
2444 if ( Widget.isDomNestedEditable( el ) ) 2451 if ( Widget.isDomNestedEditable( el ) )
2445 return; 2452 return;
2446 2453
2447 // Do not allow droping inside the widget being dragged (#13397). 2454 // Do not allow droping inside the widget being dragged (http://dev.ckeditor.com/ticket/13397).
2448 if ( widgetsRepo._.draggedWidget.wrapper.contains( el ) ) { 2455 if ( widgetsRepo._.draggedWidget.wrapper.contains( el ) ) {
2449 return; 2456 return;
2450 } 2457 }
2451 2458
2452 // If element is nested editable, make sure widget can be dropped there (#12006). 2459 // If element is nested editable, make sure widget can be dropped there (http://dev.ckeditor.com/ticket/12006).
2453 var nestedEditable = Widget.getNestedEditable( editable, el ); 2460 var nestedEditable = Widget.getNestedEditable( editable, el );
2454 if ( nestedEditable ) { 2461 if ( nestedEditable ) {
2455 var draggedWidget = widgetsRepo._.draggedWidget; 2462 var draggedWidget = widgetsRepo._.draggedWidget;
@@ -2503,11 +2510,11 @@
2503 editable.attachListener( evtRoot, 'mousedown', function( evt ) { 2510 editable.attachListener( evtRoot, 'mousedown', function( evt ) {
2504 var target = evt.data.getTarget(); 2511 var target = evt.data.getTarget();
2505 2512
2506 // #10887 Clicking scrollbar in IE8 will invoke event with empty target object. 2513 // Clicking scrollbar in Chrome will invoke event with target object of document type (#663).
2507 if ( !target.type ) 2514 // In IE8 the target object will be empty (http://dev.ckeditor.com/ticket/10887).
2508 return false; 2515 // We need to check if target is a proper element.
2516 widget = ( target instanceof CKEDITOR.dom.element ) ? widgetsRepo.getByElement( target ) : null;
2509 2517
2510 widget = widgetsRepo.getByElement( target );
2511 mouseDownOnDragHandler = 0; // Reset. 2518 mouseDownOnDragHandler = 0; // Reset.
2512 2519
2513 // Widget was clicked, but not editable nested in it. 2520 // Widget was clicked, but not editable nested in it.
@@ -2518,7 +2525,7 @@
2518 mouseDownOnDragHandler = 1; 2525 mouseDownOnDragHandler = 1;
2519 2526
2520 // When drag handler is pressed we have to clear current selection if it wasn't already on this widget. 2527 // When drag handler is pressed we have to clear current selection if it wasn't already on this widget.
2521 // Otherwise, the selection may be in a fillingChar, which prevents dragging a widget. (#13284, see comment 8 and 9.) 2528 // Otherwise, the selection may be in a fillingChar, which prevents dragging a widget. (http://dev.ckeditor.com/ticket/13284, see comment 8 and 9.)
2522 if ( widgetsRepo.focused != widget ) 2529 if ( widgetsRepo.focused != widget )
2523 editor.getSelection().removeAllRanges(); 2530 editor.getSelection().removeAllRanges();
2524 2531
@@ -2725,7 +2732,7 @@
2725 // Save the reference to this nested editable in the closest widget to be downcasted. 2732 // Save the reference to this nested editable in the closest widget to be downcasted.
2726 // Nested editables are downcasted in the successive toDataFormat to create an opportunity 2733 // Nested editables are downcasted in the successive toDataFormat to create an opportunity
2727 // for dataFilter's "excludeNestedEditable" option to do its job (that option relies on 2734 // for dataFilter's "excludeNestedEditable" option to do its job (that option relies on
2728 // contenteditable="true" attribute) (#11372). 2735 // contenteditable="true" attribute) (http://dev.ckeditor.com/ticket/11372).
2729 toBeDowncasted[ toBeDowncasted.length - 1 ].editables[ attrs[ 'data-cke-widget-editable' ] ] = element; 2736 toBeDowncasted[ toBeDowncasted.length - 1 ].editables[ attrs[ 'data-cke-widget-editable' ] ] = element;
2730 2737
2731 // Don't check children - there won't be next wrapper or nested editable which we 2738 // Don't check children - there won't be next wrapper or nested editable which we
@@ -2836,7 +2843,7 @@
2836 // If drag'n'drop kind of paste into nested editable (data.range), selection is set AFTER 2843 // If drag'n'drop kind of paste into nested editable (data.range), selection is set AFTER
2837 // data is pasted, which means editor has no chance to change activeFilter's context. 2844 // data is pasted, which means editor has no chance to change activeFilter's context.
2838 // As a result, pasted data is filtered with default editor's filter instead of NE's and 2845 // As a result, pasted data is filtered with default editor's filter instead of NE's and
2839 // funny things get inserted. Changing the filter by analysis of the paste range below (#13186). 2846 // funny things get inserted. Changing the filter by analysis of the paste range below (http://dev.ckeditor.com/ticket/13186).
2840 if ( data.range ) { 2847 if ( data.range ) {
2841 // Check if pasting into nested editable. 2848 // Check if pasting into nested editable.
2842 var nestedEditable = Widget.getNestedEditable( editor.editable(), data.range.startContainer ); 2849 var nestedEditable = Widget.getNestedEditable( editor.editable(), data.range.startContainer );
@@ -3132,7 +3139,7 @@
3132 } ); 3139 } );
3133 } 3140 }
3134 3141
3135 // Add a listener to data event that will set/change widget's label (#14539). 3142 // Add a listener to data event that will set/change widget's label (http://dev.ckeditor.com/ticket/14539).
3136 function setupA11yListener( widget ) { 3143 function setupA11yListener( widget ) {
3137 // Note, the function gets executed in a context of widget instance. 3144 // Note, the function gets executed in a context of widget instance.
3138 function getLabelDefault() { 3145 function getLabelDefault() {
@@ -3160,11 +3167,11 @@
3160 return; 3167 return;
3161 3168
3162 var editor = widget.editor, 3169 var editor = widget.editor,
3163 // Use getLast to find wrapper's direct descendant (#12022). 3170 // Use getLast to find wrapper's direct descendant (http://dev.ckeditor.com/ticket/12022).
3164 container = widget.wrapper.getLast( Widget.isDomDragHandlerContainer ), 3171 container = widget.wrapper.getLast( Widget.isDomDragHandlerContainer ),
3165 img; 3172 img;
3166 3173
3167 // Reuse drag handler if already exists (#11281). 3174 // Reuse drag handler if already exists (http://dev.ckeditor.com/ticket/11281).
3168 if ( container ) 3175 if ( container )
3169 img = container.findOne( 'img' ); 3176 img = container.findOne( 'img' );
3170 else { 3177 else {
@@ -3191,7 +3198,7 @@
3191 widget.wrapper.append( container ); 3198 widget.wrapper.append( container );
3192 } 3199 }
3193 3200
3194 // Preventing page reload when dropped content on widget wrapper (#13015). 3201 // Preventing page reload when dropped content on widget wrapper (http://dev.ckeditor.com/ticket/13015).
3195 // Widget is not editable so by default drop on it isn't allowed what means that 3202 // Widget is not editable so by default drop on it isn't allowed what means that
3196 // browser handles it (there's no editable#drop event). If there's no drop event we cannot block 3203 // browser handles it (there's no editable#drop event). If there's no drop event we cannot block
3197 // the drop, so page is reloaded. This listener enables drop on widget wrappers. 3204 // the drop, so page is reloaded. This listener enables drop on widget wrappers.
@@ -3336,7 +3343,7 @@
3336 if ( !widget.mask ) 3343 if ( !widget.mask )
3337 return; 3344 return;
3338 3345
3339 // Reuse mask if already exists (#11281). 3346 // Reuse mask if already exists (http://dev.ckeditor.com/ticket/11281).
3340 var img = widget.wrapper.findOne( '.cke_widget_mask' ); 3347 var img = widget.wrapper.findOne( '.cke_widget_mask' );
3341 3348
3342 if ( !img ) { 3349 if ( !img ) {
@@ -3377,7 +3384,7 @@
3377 setupDataClassesListener( widget ); 3384 setupDataClassesListener( widget );
3378 setupA11yListener( widget ); 3385 setupA11yListener( widget );
3379 3386
3380 // #11145: [IE8] Non-editable content of widget is draggable. 3387 // http://dev.ckeditor.com/ticket/11145: [IE8] Non-editable content of widget is draggable.
3381 if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) { 3388 if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) {
3382 widget.wrapper.on( 'dragstart', function( evt ) { 3389 widget.wrapper.on( 'dragstart', function( evt ) {
3383 var target = evt.data.getTarget(); 3390 var target = evt.data.getTarget();
@@ -3415,7 +3422,7 @@
3415 widget.on( 'doubleclick', function( evt ) { 3422 widget.on( 'doubleclick', function( evt ) {
3416 if ( widget.edit() ) { 3423 if ( widget.edit() ) {
3417 // We have to cancel event if edit method opens a dialog, otherwise 3424 // We have to cancel event if edit method opens a dialog, otherwise
3418 // link plugin may open extra dialog (#12140). 3425 // link plugin may open extra dialog (http://dev.ckeditor.com/ticket/12140).
3419 evt.cancel(); 3426 evt.cancel();
3420 } 3427 }
3421 } ); 3428 } );
@@ -4116,11 +4123,25 @@
4116 * This option is similar to {@link CKEDITOR.config#allowedContent} and one can 4123 * This option is similar to {@link CKEDITOR.config#allowedContent} and one can
4117 * use it to limit the editor features available in the nested editable. 4124 * use it to limit the editor features available in the nested editable.
4118 * 4125 *
4126 * If no `allowedContent` is specified, the editable will use the editor default
4127 * {@link CKEDITOR.editor#filter}.
4128 *
4119 * @property {CKEDITOR.filter.allowedContentRules} allowedContent 4129 * @property {CKEDITOR.filter.allowedContentRules} allowedContent
4120 */ 4130 */
4121 4131
4122/** 4132/**
4123 * Nested editable name displayed in elements path. 4133 * The [Advanced Content Filter](#!/guide/dev_advanced_content_filter) rules
4134 * which will be used to blacklist elements within this nested editable.
4135 * This option is similar to {@link CKEDITOR.config#disallowedContent}.
4136 *
4137 * Note that `disallowedContent` work on top of the definition's {@link #allowedContent}.
4138 *
4139 * @since 4.7.3
4140 * @property {CKEDITOR.filter.disallowedContentRules} disallowedContent
4141 */
4142
4143/**
4144 * Nested editable name displayed in the elements path.
4124 * 4145 *
4125 * @property {String} pathName 4146 * @property {String} pathName
4126 */ 4147 */