From f1b402f26e733fcb4ec6e56e1bbde12fdfe2e396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 31 Oct 2013 11:59:08 +0100 Subject: [PATCH 1/8] Normalize styles because IE8 use uppercased properties. --- plugins/image2/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/image2/plugin.js b/plugins/image2/plugin.js index db0d42a34ee..ab73be28a1e 100644 --- a/plugins/image2/plugin.js +++ b/plugins/image2/plugin.js @@ -597,7 +597,7 @@ if ( childName != 'img' && !( childName == 'figure' && child.hasClass( 'caption' ) ) ) return false; - var styles = CKEDITOR.tools.parseCssText( el.attributes.style || '' ); + var styles = CKEDITOR.tools.parseCssText( el.attributes.style || '', true ); // Centering wrapper got to be... centering. if ( styles[ 'text-align' ] == 'center' ) From c824d0522cedbe84a52b3401a12bf9f2abd18f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 31 Oct 2013 14:11:02 +0100 Subject: [PATCH 2/8] Trim whitespaces, so data processor is not creating data-cke-markers breaking 'single widget pasted' check. --- plugins/widget/plugin.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/widget/plugin.js b/plugins/widget/plugin.js index 2ee13a30b06..2707e1502be 100644 --- a/plugins/widget/plugin.js +++ b/plugins/widget/plugin.js @@ -1778,6 +1778,12 @@ '$' ); + function pasteReplaceFn( match, wrapperHtml ) { + // Avoid polluting pasted data with any whitspaces, + // what's going to break check whether only one widget was pasted. + return CKEDITOR.tools.trim( wrapperHtml ); + } + // Set up data processing like: // * toHtml/toDataFormat, // * pasting handling, @@ -1794,10 +1800,7 @@ // Handle pasted single widget. editor.on( 'paste', function( evt ) { - evt.data.dataValue = evt.data.dataValue.replace( - pasteReplaceRegex, - '$1' - ); + evt.data.dataValue = evt.data.dataValue.replace( pasteReplaceRegex, pasteReplaceFn ); } ); } From 296fa9e5b8f122d6d0177b159a00fc7d1512e0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 31 Oct 2013 15:03:10 +0100 Subject: [PATCH 3/8] Strip expandos in data processor's data filter. --- core/htmldataprocessor.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/htmldataprocessor.js b/core/htmldataprocessor.js index 908c0fcdf17..8b230841768 100644 --- a/core/htmldataprocessor.js +++ b/core/htmldataprocessor.js @@ -545,7 +545,11 @@ attributeNames: [ // Event attributes (onXYZ) must not be directly set. They can become // active in the editing area (IE|WebKit). - [ ( /^on/ ), 'data-cke-pa-on' ] + [ ( /^on/ ), 'data-cke-pa-on' ], + + // Don't let some old expando enter editor. Concerns only IE8, + // but for consistency remove on all browsers. + [ ( /^data-cke-expando$/ ), '' ] ] }; From 019da9d47e6a2c6da1c25685bb5446834277808b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 31 Oct 2013 16:37:03 +0100 Subject: [PATCH 4/8] Inputs are marked with contenteditable=false flags, so filters for them need to be applied to non-editable content as well. --- plugins/forms/plugin.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/forms/plugin.js b/plugins/forms/plugin.js index 59d1cb16caf..9a5fb8a514f 100644 --- a/plugins/forms/plugin.js +++ b/plugins/forms/plugin.js @@ -242,8 +242,10 @@ CKEDITOR.plugins.add( 'forms', { dataFilter = dataProcessor && dataProcessor.dataFilter; // Cleanup certain IE form elements default values. + // Note: Inputs are marked with contenteditable=false flags, so filters for them + // need to be applied to non-editable content as well. if ( CKEDITOR.env.ie ) { - htmlFilter && htmlFilter.addRules({ + htmlFilter && htmlFilter.addRules( { elements: { input: function( input ) { var attrs = input.attributes, @@ -255,18 +257,18 @@ CKEDITOR.plugins.add( 'forms', { attrs.value == 'on' && delete attrs.value; } } - }); + }, { applyToAll: true } ); } if ( dataFilter ) { - dataFilter.addRules({ + dataFilter.addRules( { elements: { input: function( element ) { if ( element.attributes.type == 'hidden' ) return editor.createFakeParserElement( element, 'cke_hidden', 'hiddenfield' ); } } - }); + }, { applyToAll: true } ); } } }); From 331cfbdc2593c1e8615db1719f3f82470fc754de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Wed, 6 Nov 2013 14:12:57 +0100 Subject: [PATCH 5/8] Do not auto initialize widgets in temporary elements like copybin. --- plugins/widget/plugin.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/widget/plugin.js b/plugins/widget/plugin.js index 2707e1502be..0b9a07c1185 100644 --- a/plugins/widget/plugin.js +++ b/plugins/widget/plugin.js @@ -293,7 +293,9 @@ for ( i = 0, count = wrappers.count(); i < count; i++ ) { wrapper = wrappers.getItem( i ); - if ( !this.getByElement( wrapper, true ) ) { + // Check if there's no instance for this widget and that + // wrapper is not inside some temporary element like copybin (#11088). + if ( !this.getByElement( wrapper, true ) && !findParent( wrapper, isTemp2 ) ) { // Add cke_widget_new class because otherwise // widget will not be created on such wrapper. wrapper.addClass( 'cke_widget_new' ); @@ -1542,6 +1544,20 @@ return filter; } + // Finds a first parent that matches query. + // + // @param {CKEDITOR.dom.element} element + // @param {Function} query + function findParent( element, query ) { + var parent = element; + + while ( ( parent = parent.getParent() ) ) { + if ( query( parent ) ) + return true; + } + return false; + } + // Gets nested editable if node is its descendant or the editable itself. // // @param {CKEDITOR.dom.element} guard Stop ancestor search on this node (usually editor's editable). @@ -1639,6 +1655,11 @@ return node.type == CKEDITOR.NODE_ELEMENT && node.hasAttribute( 'data-cke-widget-editable' ); } + // @param {CKEDITOR.dom.element} + function isTemp2( element ) { + return element.hasAttribute( 'data-cke-temp' ); + } + function moveSelectionToDropPosition( editor, dropEvt ) { var $evt = dropEvt.data.$, $range, From c326495553508fe47be6cf11f733ba84b425f1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Wed, 6 Nov 2013 14:20:10 +0100 Subject: [PATCH 6/8] Marked copybin and pastebin with data-cke-temp. --- plugins/clipboard/plugin.js | 5 ++++- plugins/widget/plugin.js | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/clipboard/plugin.js b/plugins/clipboard/plugin.js index 044d25ed519..bf513c5f44f 100644 --- a/plugins/clipboard/plugin.js +++ b/plugins/clipboard/plugin.js @@ -683,7 +683,10 @@ var pastebin = new CKEDITOR.dom.element( ( CKEDITOR.env.webkit || editable.is( 'body' ) ) && !( CKEDITOR.env.ie || CKEDITOR.env.opera ) ? 'body' : 'div', doc ); - pastebin.setAttribute( 'id', 'cke_pastebin' ); + pastebin.setAttributes( { + id: 'cke_pastebin', + 'data-cke-temp': '1' + } ); // Append bogus to prevent Opera from doing this. (#9522) if ( CKEDITOR.env.opera ) diff --git a/plugins/widget/plugin.js b/plugins/widget/plugin.js index 0b9a07c1185..491895e74ea 100644 --- a/plugins/widget/plugin.js +++ b/plugins/widget/plugin.js @@ -1791,7 +1791,7 @@ // * We use spans on IE and blockless editors, but divs in other cases. var pasteReplaceRegex = new RegExp( '^' + - '(?:<(?:div|span)(?: id="cke_copybin")?>)?' + + '(?:<(?:div|span)(?: data-cke-temp="1")?(?: id="cke_copybin")?(?: data-cke-temp="1")?>)?' + '(?:<(?:div|span)(?: style="[^"]+")?>)?' + ']*data-cke-copybin-start="1"[^>]*>.?([\\s\\S]+)]*data-cke-copybin-end="1"[^>]*>.?' + '(?:)?' + @@ -2383,7 +2383,10 @@ // IE8 always jumps to the end of document. needsScrollHack = CKEDITOR.env.ie && CKEDITOR.env.version < 9; - copybinContainer.setAttribute( 'id', 'cke_copybin' ); + copybinContainer.setAttributes( { + id: 'cke_copybin', + 'data-cke-temp': '1' + } ); // Position copybin element outside current viewport. copybin.setStyles( { From 568e4bdb196110c146f9e165a2f6a95bbe9365e9 Mon Sep 17 00:00:00 2001 From: "m.lewandowski" Date: Tue, 5 Nov 2013 10:15:29 +0100 Subject: [PATCH 7/8] Fixed IE8 issue, when clicking scrollbar would throw an exception. --- plugins/widget/plugin.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/widget/plugin.js b/plugins/widget/plugin.js index 491895e74ea..571f2e89ccf 100644 --- a/plugins/widget/plugin.js +++ b/plugins/widget/plugin.js @@ -2004,6 +2004,10 @@ editable.attachListener( evtRoot, 'mousedown', function( evt ) { var target = evt.data.getTarget(); + // #10887 Clicking scrollbar in IE8 will invoke event with empty target object. + if ( !target.type ) + return false; + widget = widgetsRepo.getByElement( target ); mouseDownOnDragHandler = 0; // Reset. From 517dc15279dc85a1c618b6ac078ca5ad949caeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 7 Nov 2013 08:16:56 +0100 Subject: [PATCH 8/8] Changelog entry. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index cc52321b8ca..05a07e7d3f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -48,6 +48,7 @@ Fixed Issues: * [#10911](http://dev.ckeditor.com/ticket/10911): Browser alt hotkeys will no longer be blocked while widget is focused. * [#11082](http://dev.ckeditor.com/ticket/11082): Selected widget is not copied/cut when using toolbar buttons or context menu. * [#11083](http://dev.ckeditor.com/ticket/11083): Fixed lists and divs application to block widgets. +* [#10887](http://dev.ckeditor.com/ticket/10887): Internet Explorer 8 compatibility issues related to the Widget System. ## CKEditor 4.3 Beta