X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2Fpackagist%2Fpiedsjaloux-ckeditor-component.git;a=blobdiff_plain;f=sources%2Fcore%2Fstyle.js;h=b3cf0bc9f79adf13130bbdb228cf8f846deab02d;hp=09b117baf59b0645de05d1b3e55f8273cd377084;hb=refs%2Ftags%2F4.7.3;hpb=1096cdefb1c9a3f3c4ca6807e272da6c92e5ed9c
diff --git a/sources/core/style.js b/sources/core/style.js
index 09b117b..b3cf0bc 100644
--- a/sources/core/style.js
+++ b/sources/core/style.js
@@ -1,5 +1,5 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
@@ -235,7 +235,7 @@ CKEDITOR.STYLE_OBJECT = 3;
var initialEnterMode = this._.enterMode;
// Before CKEditor 4.4 style knew nothing about editor, so in order to provide enterMode
- // which should be used developers were forced to hack the style object (see #10190).
+ // which should be used developers were forced to hack the style object (see http://dev.ckeditor.com/ticket/10190).
// Since CKEditor 4.4 style knows about editor (at least when it's being applied/removed), but we
// use _.enterMode for backward compatibility with those hacks.
// Note: we should not change style's enter mode if it was already set.
@@ -569,7 +569,7 @@ CKEDITOR.STYLE_OBJECT = 3;
var styleVal = stylesDef[ style ],
text = ( style + ':' + styleVal ).replace( semicolonFixRegex, ';' );
- // Some browsers don't support 'inherit' property value, leave them intact. (#5242)
+ // Some browsers don't support 'inherit' property value, leave them intact. (http://dev.ckeditor.com/ticket/5242)
if ( styleVal == 'inherit' )
specialStylesText += text;
else
@@ -1024,7 +1024,7 @@ CKEDITOR.STYLE_OBJECT = 3;
if ( !CKEDITOR.env.ie )
styleNode.$.normalize();
}
- // Style already inherit from parents, left just to clear up any internal overrides. (#5931)
+ // Style already inherit from parents, left just to clear up any internal overrides. (http://dev.ckeditor.com/ticket/5931)
else {
styleNode = new CKEDITOR.dom.element( 'span' );
styleRange.extractContents().appendTo( styleNode );
@@ -1042,7 +1042,7 @@ CKEDITOR.STYLE_OBJECT = 3;
// Remove the bookmark nodes.
range.moveToBookmark( boundaryNodes );
- // Minimize the result range to exclude empty text nodes. (#5374)
+ // Minimize the result range to exclude empty text nodes. (http://dev.ckeditor.com/ticket/5374)
range.shrink( CKEDITOR.SHRINK_TEXT );
// Get inside the remaining element if range.shrink( TEXT ) has failed because of non-editable elements inside.
@@ -1058,27 +1058,31 @@ CKEDITOR.STYLE_OBJECT = 3;
range.enlarge( CKEDITOR.ENLARGE_INLINE, 1 );
var bookmark = range.createBookmark(),
- startNode = bookmark.startNode;
+ startNode = bookmark.startNode,
+ alwaysRemoveElement = this._.definition.alwaysRemoveElement;
if ( range.collapsed ) {
var startPath = new CKEDITOR.dom.elementPath( startNode.getParent(), range.root ),
- // The topmost element in elementspatch which we should jump out of.
+ // The topmost element in elements path which we should jump out of.
boundaryElement;
-
for ( var i = 0, element; i < startPath.elements.length && ( element = startPath.elements[ i ] ); i++ ) {
// 1. If it's collaped inside text nodes, try to remove the style from the whole element.
//
// 2. Otherwise if it's collapsed on element boundaries, moving the selection
// outside the styles instead of removing the whole tag,
- // also make sure other inner styles were well preserverd.(#3309)
- if ( element == startPath.block || element == startPath.blockLimit )
+ // also make sure other inner styles were well preserved.(http://dev.ckeditor.com/ticket/3309)
+ //
+ // 3. Force removing the element even if it's an boundary element when alwaysRemoveElement is true.
+ // Without it, the links won't be unlinked if the cursor is placed right before/after it. (http://dev.ckeditor.com/ticket/13062)
+ if ( element == startPath.block || element == startPath.blockLimit ) {
break;
+ }
if ( this.checkElementRemovable( element ) ) {
var isStart;
- if ( range.collapsed && ( range.checkBoundaryOfElement( element, CKEDITOR.END ) || ( isStart = range.checkBoundaryOfElement( element, CKEDITOR.START ) ) ) ) {
+ if ( !alwaysRemoveElement && range.collapsed && ( range.checkBoundaryOfElement( element, CKEDITOR.END ) || ( isStart = range.checkBoundaryOfElement( element, CKEDITOR.START ) ) ) ) {
boundaryElement = element;
boundaryElement.match = isStart ? 'start' : 'end';
} else {
@@ -1087,10 +1091,11 @@ CKEDITOR.STYLE_OBJECT = 3;
// no difference that they're separate entities in the DOM tree. So, merge
// them before removal.
element.mergeSiblings();
- if ( element.is( this.element ) )
+ if ( element.is( this.element ) ) {
removeFromElement.call( this, element );
- else
+ } else {
removeOverrides( element, getOverrides( this )[ element.getName() ] );
+ }
}
}
}
@@ -1235,7 +1240,7 @@ CKEDITOR.STYLE_OBJECT = 3;
}
function applyObjectStyle( range ) {
- // Selected or parent element. (#9651)
+ // Selected or parent element. (http://dev.ckeditor.com/ticket/9651)
var start = range.getEnclosedNode() || range.getCommonAncestor( false, true ),
element = new CKEDITOR.dom.elementPath( start, range.root ).contains( this.element, 1 );
@@ -1276,7 +1281,7 @@ CKEDITOR.STYLE_OBJECT = 3;
var iterator = range.createIterator();
iterator.enforceRealBlocks = true;
- // make recognize
tag as a separator in ENTER_BR mode (#5121)
+ // make recognize
tag as a separator in ENTER_BR mode (http://dev.ckeditor.com/ticket/5121)
if ( this._.enterMode )
iterator.enlargeBr = ( this._.enterMode != CKEDITOR.ENTER_BR );
@@ -1326,7 +1331,7 @@ CKEDITOR.STYLE_OBJECT = 3;
// Replace the original block with new one, with special treatment
// for
blocks to make sure content format is well preserved, and merging/splitting adjacent - // when necessary. (#3188) + // when necessary. (http://dev.ckeditor.com/ticket/3188) function replaceBlock( block, newBlock ) { // Block is to be removed, create a temp element to // save contents. @@ -1502,11 +1507,11 @@ CKEDITOR.STYLE_OBJECT = 3; // Remove definition attributes/style from the elemnt. for ( var attName in attributes ) { - // The 'class' element value must match (#1318). + // The 'class' element value must match (http://dev.ckeditor.com/ticket/1318). if ( ( attName == 'class' || this._.definition.fullMatch ) && element.getAttribute( attName ) != normalizeProperty( attName, attributes[ attName ] ) ) continue; - // Do not touch data-* attributes (#11011) (#11258). + // Do not touch data-* attributes (http://dev.ckeditor.com/ticket/11011) (http://dev.ckeditor.com/ticket/11258). if ( keepDataAttrs && attName.slice( 0, 5 ) == 'data-' ) continue; @@ -1515,7 +1520,7 @@ CKEDITOR.STYLE_OBJECT = 3; } for ( var styleName in styles ) { - // Full match style insist on having fully equivalence. (#5018) + // Full match style insist on having fully equivalence. (http://dev.ckeditor.com/ticket/5018) if ( this._.definition.fullMatch && element.getStyle( styleName ) != normalizeProperty( styleName, styles[ styleName ], true ) ) continue; @@ -1649,7 +1654,7 @@ CKEDITOR.STYLE_OBJECT = 3; // Create the element. el = new CKEDITOR.dom.element( elementName, targetDocument ); - // #6226: attributes should be copied before the new ones are applied + // http://dev.ckeditor.com/ticket/6226: attributes should be copied before the new ones are applied if ( element ) element.copyAttributes( el ); @@ -1794,15 +1799,28 @@ CKEDITOR.STYLE_OBJECT = 3; // is treated as a wildcard which will match any value. // @param {Object/String} source // @param {Object/String} target + // @returns {Boolean} function compareCssText( source, target ) { + function filter( string, propertyName ) { + // In case of font-families we'll skip quotes. (http://dev.ckeditor.com/ticket/10750) + return propertyName.toLowerCase() == 'font-family' ? string.replace( /["']/g, '' ) : string; + } + if ( typeof source == 'string' ) source = CKEDITOR.tools.parseCssText( source ); if ( typeof target == 'string' ) target = CKEDITOR.tools.parseCssText( target, true ); for ( var name in source ) { - if ( !( name in target && ( target[ name ] == source[ name ] || source[ name ] == 'inherit' || target[ name ] == 'inherit' ) ) ) + if ( !( name in target ) ) { return false; + } + + if ( !( filter( target[ name ], name ) == filter( source[ name ], name ) || + source[ name ] == 'inherit' || + target[ name ] == 'inherit' ) ) { + return false; + } } return true; } @@ -1811,13 +1829,25 @@ CKEDITOR.STYLE_OBJECT = 3; var doc = selection.document, ranges = selection.getRanges(), func = remove ? this.removeFromRange : this.applyToRange, - range; + originalRanges, + range, + i; + + // In case of fake table selection, we would like to apply all styles and then select + // the original ranges. Otherwise browsers would complain about discontiguous selection. + if ( selection.isFake && selection.isInTable() ) { + originalRanges = []; + + for ( i = 0; i < ranges.length; i++ ) { + originalRanges.push( ranges[ i ].clone() ); + } + } var iterator = ranges.createIterator(); while ( ( range = iterator.getNextRange() ) ) func.call( this, range, editor ); - selection.selectRanges( ranges ); + selection.selectRanges( originalRanges || ranges ); doc.removeCustomData( 'doc_processing_style' ); } } )(); @@ -1888,7 +1918,7 @@ CKEDITOR.styleCommand.prototype.exec = function( editor ) { */ CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' ); -// Backward compatibility (#5025). +// Backward compatibility (http://dev.ckeditor.com/ticket/5025). CKEDITOR.addStylesSet = CKEDITOR.tools.bind( CKEDITOR.stylesSet.add, CKEDITOR.stylesSet ); CKEDITOR.loadStylesSet = function( name, url, callback ) { CKEDITOR.stylesSet.addExternal( name, url, '' ); @@ -1991,7 +2021,7 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype, { return; } - // #5352 Allow to define the styles directly in the config object + // http://dev.ckeditor.com/ticket/5352 Allow to define the styles directly in the config object if ( configStyleSet instanceof Array ) { editor._.stylesDefinitions = configStyleSet; callback( configStyleSet );