CKEDITOR.plugins.copyformatting
Filtering
Properties
breakOnElements : ArrayCKEDITOR.plugins.copyformatting#breakOnElementsAn array of elements on which extracting formatting should be stopped. If Copy Formatting reaches an element from the array, it ends going up the document tree and fetching the element parents' styles.
Defaults to
['ul', 'ol', 'table']elementsForInlineTransform : ArrayCKEDITOR.plugins.copyformatting#elementsForInlineTransformAn array of elements that will be transformed into inline styles while applying formatting to the plain text context, e.g. trying to apply styles from the
<li>element (<li style="font-size: 24px;">) to a regular paragraph will cause changing the<li>element into a corresponding<span>element (<span style="font-size: 24px;">).Defaults to
['li']excludedAttributes : ArrayCKEDITOR.plugins.copyformatting#excludedAttributesAn array of attributes that should be excluded from extracted styles.
Defaults to
['id', 'style', 'href', 'data-cke-saved-href', 'dir']excludedAttributesFromInlineTransform : ArrayCKEDITOR.plugins.copyformatting#excludedAttributesFromInlineTransformAn array of attributes to be excluded while transforming styles from elements inside elementsForInlineTransform into
<span>elements with styles (e.g. when applying these styles to text context).Defaults to
['value', 'type']excludedElementsFromInlineTransform : ArrayCKEDITOR.plugins.copyformatting#excludedElementsFromInlineTransformAn array of elements that will be excluded from the transformation while applying formatting to the plain text context.
Defaults to
['table', 'thead', 'tbody', 'ul', 'ol']inlineBoundary : ArrayCKEDITOR.plugins.copyformatting#inlineBoundaryAn array of block boundaries that should be always transformed into inline elements with styles, e.g.
<div style="font-size: 24px;" class="important">becomes<span style="font-size: 24px;" class="important">.Defaults to
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div']preservedElements : ArrayCKEDITOR.plugins.copyformatting#preservedElementsAn array of elements which should not be deleted when removing old styles from the current selection. Instead the styles are stripped from the elements, preserving the elements themselves, e.g.
<ul style="font-size: 24px" class="important">becomes<ul>.Defaults to
['ul', 'ol', 'li', 'td', 'th', 'tr', 'thead', 'tbody', 'table']private
_initialKeystrokePasteCommand : StringCKEDITOR.plugins.copyformatting#_initialKeystrokePasteCommandStores the name of the command (if any) initially bound to the keystroke used for format applying (CKEDITOR.config.copyFormatting_keystrokePaste), to restore it after copy formatting is deactivated.
Methods
private
_addScreenReaderContainer() → elementCKEDITOR.plugins.copyformatting#_addScreenReaderContainerAdds the screen reader messages wrapper. Multiple calls will create only one message container.
Returns
elementInserted
aria-livecontainer.
-
Initializes applying given styles to the currently selected content in the editor.
The actual applying is performed inside event listeners for the CKEDITOR.plugins.copyformatting.state.applyFormatting event.
Parameters
editor : editorThe editor instance.
newStyles : style[]An array of styles to be applied.
Returns
Booleanfalseif styles could not be applied,trueotherwise.
private
_applyStylesToListContext( editor, range, styles )CKEDITOR.plugins.copyformatting#_applyStylesToListContextApplies the list style inside the list context.
Parameters
editor : editorThe editor instance.
range : rangeThe range where the styles should be applied.
styles : style[]The style to be applied.
private
_applyStylesToTableContext( editor, range, styles )CKEDITOR.plugins.copyformatting#_applyStylesToTableContextApplies the table style inside the table context.
Parameters
editor : editorThe editor instance.
range : rangeThe range where the styles should be applied.
styles : style[]The style to be applied.
private
_applyStylesToTextContext( editor, range, styles )CKEDITOR.plugins.copyformatting#_applyStylesToTextContextApplies styles inside the plain text context.
Parameters
editor : editorThe editor instance.
range : rangeThe range that the context can be determined from.
styles : style[]The styles to be applied.
private
_attachPasteKeystrokeHandler( editor )CKEDITOR.plugins.copyformatting#_attachPasteKeystrokeHandlerAttaches the paste keystroke handler to the given editor instance.
Parameters
editor : editor
private
_convertElementToStyleDef( element ) → ObjectCKEDITOR.plugins.copyformatting#_convertElementToStyleDefConverts a given element into a style definition that could be used to create an instance of CKEDITOR.style.
Note that all definitions have a
typeproperty set to CKEDITOR.STYLE_INLINE.Parameters
element : elementThe element to be converted.
Returns
ObjectThe style definition created from the element.
private
_detachPasteKeystrokeHandler( editor )CKEDITOR.plugins.copyformatting#_detachPasteKeystrokeHandlerDetaches the paste keystroke handler from the given editor instance.
Parameters
editor : editor
-
Determines the context of the given selection. See CKEDITOR.config.copyFormatting_allowedContexts for a list of possible context values.
Parameters
range : rangeThe range that the context should be determined from.
Returns
String
private
_extractStylesFromElement( editor, element ) → style[]CKEDITOR.plugins.copyformatting#_extractStylesFromElementExtracts styles from the given element and its ancestors. This function walks up the document tree, starting from the given element, and ends on the editor's editable or when the element from breakOnElements is reached.
Parameters
editor : editorThe editor instance.
element : elementThe element whose styles should be extracted.
Returns
style[]An array containing all extracted styles.
private
_extractStylesFromRange( editor, range ) → style[]CKEDITOR.plugins.copyformatting#_extractStylesFromRangeExtracts styles from the given range. This function finds all elements in the given range and then applies _extractStylesFromElement on them.
Parameters
editor : editorThe editor instance.
range : rangeThe range that styles should be extracted from.
Returns
style[]An array containing all extracted styles. Styles in the array returned by this method might be duplicated; it should be cleaned later on.
-
Filters styles before applying them by using CKEDITOR.filter.
Parameters
styles : style[]An array of styles to be filtered.
Returns
style[]Filtered styles.
-
Returns a container element where the mouse cursor should be overridden.
Parameters
editor : editorThe editor instance.
Returns
elementFor inline editor, it is the editable itself and for classic editor it is the document element of the editor iframe.
private
_getScreenReaderContainer() → ObjectCKEDITOR.plugins.copyformatting#_getScreenReaderContainerprivate
_getSelectedWordOffset( range ) → ObjectCKEDITOR.plugins.copyformatting#_getSelectedWordOffsetGets offsets as well as start and end containers for the selected word. It also handles cases like
lu<span style="color: #f00;">n</span>ar.Parameters
range : rangeSelected range.
Returns
Objectreturn An object with the following properties:
PropertiesstartNode : elementThe node where the word's beginning is located.
startOffset : NumberThe offset inside the
startNodeindicating the word's beginning.endNode : elementThe node where the word's ending is located.
endOffset : NumberThe offset inside the
endNodeindicating the word's ending.
private
_putScreenReaderMessage( editor, msg )CKEDITOR.plugins.copyformatting#_putScreenReaderMessagePuts a message solely for screen readers, meant to provide status updates for the Copy Formatting plugin.
Parameters
editor : editorThe editor instance.
msg : stringThe name of the message in the language file.
private
_removeStylesFromElementInRange( range, element )CKEDITOR.plugins.copyformatting#_removeStylesFromElementInRangeRemoves all styles from the element in a given range without removing the element itself.
Parameters
range : rangeThe range where the element should be found.
element : StringThe tag name of the element.