Skip to content

Commit

Permalink
Merge branch 't/10887' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Nov 7, 2013
2 parents dd70588 + 517dc15 commit 1a7833e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion core/htmldataprocessor.js
Expand Up @@ -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$/ ), '' ]
]
};

Expand Down
5 changes: 4 additions & 1 deletion plugins/clipboard/plugin.js
Expand Up @@ -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 )
Expand Down
10 changes: 6 additions & 4 deletions plugins/forms/plugin.js
Expand Up @@ -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,
Expand All @@ -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 } );
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion plugins/image2/plugin.js
Expand Up @@ -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' )
Expand Down
45 changes: 38 additions & 7 deletions plugins/widget/plugin.js
Expand Up @@ -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' );
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1770,14 +1791,20 @@
// * 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="[^"]+")?>)?' +
'<span [^>]*data-cke-copybin-start="1"[^>]*>.?</span>([\\s\\S]+)<span [^>]*data-cke-copybin-end="1"[^>]*>.?</span>' +
'(?:</(?:div|span)>)?' +
'(?:</(?:div|span)>)?' +
'$'
);

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,
Expand All @@ -1794,10 +1821,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 );
} );
}

Expand Down Expand Up @@ -1980,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.

Expand Down Expand Up @@ -2359,7 +2387,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( {
Expand Down

0 comments on commit 1a7833e

Please sign in to comment.