ElementDefinition (engine/view)
@ckeditor/ckeditor5-engine/src/view/elementdefinition
A plain object that describes a view element in a way that a concrete, exact view element could be created from that description.
const viewDefinition = {
name: 'h1',
classes: [ 'foo', 'bar' ]
};
Above describes a view element:
<h1 class="foo bar"></h1>
An example with styles and attributes:
const viewDefinition = {
name: 'span',
styles: {
'font-size': '12px',
'font-weight': 'bold'
},
attributes: {
'data-id': '123'
}
};
Describes:
<span style="font-size:12px;font-weight:bold" data-id="123"></span>
Elements without attributes can be given simply as a string:
const viewDefinition = 'p';
Which will be treated as:
const viewDefinition = {
name: 'p'
};
Filtering
Properties
-
attributes : Object
module:engine/view/elementdefinition~ElementDefinition#attributes
Object with key-value pairs representing attributes. Each object key represents attribute name. Value under that key must be a string.
-
classes : String | Array.<String>
module:engine/view/elementdefinition~ElementDefinition#classes
Class name or array of class names to match. Each name can be provided in a form of string.
-
name : String
module:engine/view/elementdefinition~ElementDefinition#name
View element name.
-
priority : Number
module:engine/view/elementdefinition~ElementDefinition#priority
Element's priority.
-
styles : Object
module:engine/view/elementdefinition~ElementDefinition#styles
Object with key-value pairs representing styles. Each object key represents style name. Value under that key must be a string.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.