# CKEDITOR.style.customHandlers.widget

class since 4.4

The class representing a widget style. It is an object like the styles handler for widgets.

Note: This custom style handler does not support all methods of the CKEDITOR.style class. Not supported methods: applyToRange, removeFromRange, applyToObject.

## Properties

• ### alwaysRemoveElement : BooleanCKEDITOR.style.customHandlers.widget#alwaysRemoveElement

since 4.0

Indicates that any matches element of this style will be eventually removed when calling CKEDITOR.editor.removeStyle.

Defaults to false

• ### group : ArrayCKEDITOR.style.customHandlers.widget#group

since 4.6.2

An array of groups that this style belongs to. Styles assigned to the same group cannot be combined.

• ### includeReadonly : BooleanCKEDITOR.style.customHandlers.widget#includeReadonly

since 3.5

Indicates that fully selected read-only elements will be included when applying the style (for inline styles only).

Defaults to false

• ### widget : StringCKEDITOR.style.customHandlers.widget#widget

The name of widget to which this style can be applied. It is extracted from style definition's widget property.

## Methods

• ### constructor( styleDefinition, variablesValues ) → styleCKEDITOR.style.customHandlers.widget#constructor

Creates a style class instance.

#### Parameters

styleDefinition : definition
variablesValues : Object

#### Returns

style
• ### apply( editor )CKEDITOR.style.customHandlers.widget#apply

Applies the style on the editor's current selection.

Before the style is applied, the method checks if the style is applicable.

Note: The recommended way of applying the style is by using the CKEDITOR.editor.applyStyle method, which is a shorthand for this method.

#### Parameters

editor : editor | document

The editor instance in which the style will be applied. A CKEDITOR.dom.document instance is accepted for backward compatibility reasons, although since CKEditor 4.4 this type of argument is deprecated. Read more about the signature change in the CKEDITOR.style documentation.

• ### applyToObject()CKEDITOR.style.customHandlers.widget#applyToObject

Not implemented.

• ### applyToRange()CKEDITOR.style.customHandlers.widget#applyToRange

Not implemented.

• ### buildPreview( [ label ] ) → StringCKEDITOR.style.customHandlers.widget#buildPreview

Builds the preview HTML based on the styles definition.

#### Parameters

[ label ] : String

The label used in the style preview.

#### Returns

String

The HTML of preview.

• ### checkActive( elementPath, editor ) → BooleanCKEDITOR.style.customHandlers.widget#checkActive

Gets the style state inside the elements path.

#### Parameters

elementPath : elementPath
editor : editor

The editor instance. Required argument since CKEditor 4.4. The style system will work without it, but it is highly recommended to provide it for integration with all features. Read more about the signature change in the CKEDITOR.style documentation.

#### Returns

Boolean

true if the element is active in the elements path.

• ### checkApplicable( elementPath, editor, [ filter ] ) → BooleanCKEDITOR.style.customHandlers.widget#checkApplicable

Whether this style can be applied at the specified elements path.

#### Parameters

elementPath : elementPath

The elements path to check the style against.

editor : editor

The editor instance. Required argument since CKEditor 4.4. The style system will work without it, but it is highly recommended to provide it for integration with all features. Read more about the signature change in the CKEDITOR.style documentation.

[ filter ] : filter

If defined, the style will be checked against this filter as well.

#### Returns

Boolean

true if this style can be applied at the elements path.

• ### checkElement( element ) → BooleanCKEDITOR.style.customHandlers.widget#checkElement

Checks if an element is a wrapper of a widget whose name matches the widget name specified in the style definition.

#### Parameters

element : element

#### Returns

Boolean
• ### checkElementMatch( element, fullMatch, editor ) → BooleanCKEDITOR.style.customHandlers.widget#checkElementMatch

Checks if the element matches the current style definition.

#### Parameters

element : element
fullMatch : Boolean
editor : editor

The editor instance. Required argument since CKEditor 4.4. The style system will work without it, but it is highly recommended to provide it for integration with all features. Read more about the signature change in the CKEDITOR.style documentation.

#### Returns

Boolean
• ### checkElementRemovable( element, fullMatch, editor ) → BooleanCKEDITOR.style.customHandlers.widget#checkElementRemovable

Checks if an element, or any of its attributes, is removable by the current style definition.

#### Parameters

element : element
fullMatch : Boolean
editor : editor

The editor instance. Required argument since CKEditor 4.4. The style system will work without it, but it is highly recommended to provide it for integration with all features. Read more about the signature change in the CKEDITOR.style documentation.

#### Returns

Boolean
• ### getClassesArray() → String[]CKEDITOR.style.customHandlers.widget#getClassesArray

Returns classes defined in the style in form of an array.

#### Returns

String[]
• ### getDefinition() → ObjectCKEDITOR.style.customHandlers.widget#getDefinition

since 4.1

Returns the style definition.

#### Returns

Object
• ### remove( editor )CKEDITOR.style.customHandlers.widget#remove

Removes the style from the editor's current selection.

Before the style is applied, the method checks if style could be applied.

Note: The recommended way of removing the style is by using the CKEDITOR.editor.removeStyle method, which is a shorthand for this method.

#### Parameters

editor : editor | document

The editor instance in which the style will be removed. A CKEDITOR.dom.document instance is accepted for backward compatibility reasons, although since CKEditor 4.4 this type of argument is deprecated. Read more about the signature change in the CKEDITOR.style documentation.

• ### removeFromRange()CKEDITOR.style.customHandlers.widget#removeFromRange

Not implemented.

• ### removeStylesFromSameGroup( editor ) → BooleanCKEDITOR.style.customHandlers.widget#removeStylesFromSameGroup

since 4.6.2

Removes all styles that belong to the same group as this style. This method will neither add nor remove the current style. Returns true if any style was removed, otherwise returns false.

#### Parameters

editor : editor

#### Returns

Boolean
• ### toAllowedContentRules( The ) → allowedContentRulesCKEDITOR.style.customHandlers.widget#toAllowedContentRules

Returns allowed content rules which should be registered for this style. Uses widget's CKEDITOR.plugins.widget.definition.styleableElements to make a rule allowing classes on specified elements or use widget's CKEDITOR.plugins.widget.definition.styleToAllowedContentRules method to transform a style into allowed content rules.

#### Parameters

The : editor

editor instance.

#### Returns

allowedContentRules