Rich Text Editor Plugin Components
Plugin Component is a resource which allow to register feature allows to edit text content.
Plugin component should provide configuration in JSON format:
Where type
should point script with plugin definition and configuration
contains all aditional properties used by plugin.
RichText editor is based on TipTap and plugins are responsible for interaction with TipTap Editor.
Plugin defintinon should provide methods:
const Plugin = (configuration) => {
return {
getTipTapExtensions: () => {
return [...]
},
getAction: (context) => {
return {
execute: (state) => {}
}
},
getState: (context) => {
return {...}
}
}
}
export default Plugin;
Where:
-
getTipTapExtensions
- should return TipTap extensions required by plugin. -
getAction
- should return object with execute method. This method will be executed by UI Component. It can get current state as a paramater. -
getState
- should return an object with properties required to build proper state of UI Component. Object with this same structure is expected inexecute
method. -
configuration
- contains data from JCR config -
context
- Contains keyeditor
referencing Tip Tap editor. -
state
- Object with same structure as returned bygetState
Available plugins
Plugin | Example Usage |
---|---|
Boldwcm/dialogs/components/richtext/plugin/bold | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/bold"} |
Italicwcm/dialogs/components/richtext/plugin/italic | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/italic"} |
Underlinewcm/dialogs/components/richtext/plugin/underline | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/underline"} |
Strikethroughwcm/dialogs/components/richtext/plugin/strikethrough | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/strikethrough"} |
BulletListwcm/dialogs/components/richtext/plugin/bulletlist | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/bulletlist"} |
OrderedListwcm/dialogs/components/richtext/plugin/orderedlist | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/orderedlist"} |
Paragraphwcm/dialogs/components/richtext/plugin/paragraph | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/paragraph"}` |
Headingwcm/dialogs/components/richtext/plugin/heading | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/heading", "level": "3""} level - number (default: 1) - Heading level (1-6) |
Linkwcm/dialogs/components/richtext/plugin/link | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/link""} |
UnsetLinkwcm/dialogs/components/richtext/plugin/unsetlink | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/unsetlink""} |
ClearFormattingwcm/dialogs/components/richtext/plugin/clearformatting | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/clearformatting""} |
HardBreakwcm/dialogs/components/richtext/plugin/hardbreak | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/hardbreak""} |
TextAlignwcm/dialogs/components/richtext/plugin/textalign | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/textalignment", "alignment": "right""} alignment - string (default: 'left') - Text alignment ('left', ‘center', ‘right', 'justify') |
Undowcm/dialogs/components/richtext/plugin/undo | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/undo"} |
Redowcm/dialogs/components/richtext/plugin/redo | "plugin": { "sling:resourceType": "wcm/dialogs/components/richtext/plugin/redo"} |
Interfaces
All the plugins provides some interfaces that should be met by UI components:
Plugin | getAction | getState |
---|---|---|
BoldItalicUnderlineStrikethroughBulletListOrderedListParagraphHeadingTextAlign | { execute({}) => {...} } |
{ isActive: ... } |
UnsetLinkUndoRedo | { execute({}) => {...} } |
{ isDisabled: ... } |
ClearFormattingHardBreak | { execute({}) => {...} } |
{} |
Link | { execute({ href, target }) => {...}} |
{ isActive: ..., href: ..., target: ... } |