CKEDITOR.plugins.copyformatting
Filtering
Properties
-
breakOnElements : Array
An 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 : Array
An 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 : Array
An array of attributes that should be excluded from extracted styles.
Defaults to
['id', 'style', 'href', 'data-cke-saved-href', 'dir']
-
An 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']
-
An 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 : Array
An 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 : Array
An 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']
-
_initialKeystrokePasteCommand : String
private
Stores 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
-
_addScreenReaderContainer() → element
private
Adds the screen reader messages wrapper. Multiple calls will create only one message container.
Returns
element
Inserted
aria-live
container.
-
_applyFormat( editor, newStyles ) → Boolean
private
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
Returns
Boolean
false
if styles could not be applied,true
otherwise.
-
_applyStylesToListContext( editor, range, styles )
private
Applies the list style inside the list context.
-
_applyStylesToTableContext( editor, range, styles )
private
Applies the table style inside the table context.
-
_applyStylesToTextContext( editor, range, styles )
private
Applies styles inside the plain text context.
-
_attachPasteKeystrokeHandler( editor )
private
Attaches the paste keystroke handler to the given editor instance.
Parameters
editor : editor
-
_convertElementToStyleDef( element ) → Object
private
Converts a given element into a style definition that could be used to create an instance of CKEDITOR.style.
Note that all definitions have a
type
property set to CKEDITOR.STYLE_INLINE.Parameters
element : element
The element to be converted.
Returns
Object
The style definition created from the element.
-
_detachPasteKeystrokeHandler( editor )
private
Detaches the paste keystroke handler from the given editor instance.
Parameters
editor : editor
-
_determineContext( range ) → String
private
Determines the context of the given selection. See CKEDITOR.config.copyFormatting_allowedContexts for a list of possible context values.
-
_extractStylesFromElement( editor, element ) → style[]
private
Extracts 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.
-
_extractStylesFromRange( editor, range ) → style[]
private
Extracts styles from the given range. This function finds all elements in the given range and then applies _extractStylesFromElement on them.
-
_filterStyles( styles ) → style[]
private
Filters styles before applying them by using CKEDITOR.filter.
-
_getCursorContainer( editor ) → element
private
Returns a container element where the mouse cursor should be overridden.
-
_getScreenReaderContainer() → Object
private
Returns a screen reader messages wrapper.
Returns
Object
-
_getSelectedWordOffset( range ) → Object
private
Gets 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 : range
Selected range.
Returns
Object
return An object with the following properties:
Properties
-
_putScreenReaderMessage( editor, msg )
private
Puts a message solely for screen readers, meant to provide status updates for the Copy Formatting plugin.
Parameters
editor : editor
The editor instance.
msg : string
The name of the message in the language file.
-
_removeStylesFromElementInRange( range, element )
private
Removes all styles from the element in a given range without removing the element itself.
Parameters
range : range
The range where the element should be found.
element : String
The tag name of the element.