-
Notifications
You must be signed in to change notification settings - Fork 164
ContentEdit plugin
Go back to Built-in plugins
ContentEdit
plugin provides some common editing functionalities which are not supported by browser contenteditable DIV by default. These functionalities can be turned on/off separately.
ContentEdit
is a built-in plugin of RoosterJs. When you create an editor with createEditor() API, this plugin is already included.
To manually create an instance of this plugin, you can use its constructor:
interface ContentEditFeatures {
indentWhenTab: boolean;
outdentWhenShiftTab: boolean;
outdentWhenBackspaceOnEmptyFirstLine: boolean;
outdentWhenEnterOnEmptyLine: boolean;
mergeInNewLineWhenBackspaceOnFirstChar: boolean;
unquoteWhenBackspaceOnEmptyFirstLine: boolean;
unquoteWhenEnterOnEmptyLine: boolean;
autoBullet: boolean;
tabInTable: boolean;
}
constructor(private features?: ContentEditFeatures);
The constructor of ContentEdit class takes one optional parameter, which determins what features do you want this plugin to provide. In RoosterJs 6.7.5, the following features are supported:
When press Tab in a list (bullet list, numbering list), indent current list item. Default value is true.
When press Shift+Tab in a list (bullet list, numbering list), outdent current list item. Default value is true.
When press BaskSpace on empty line which is the first item of a list (bullet list, numbering list), outdent current list item. Default value is true.
When press Enter on empty line in a list (bullet list, numbering list), outdent current list item. Default value is true.
When press BaskSpace on first char in a list (bullet list, numbering list), make current item a new line of previous list item. Default value is false.
When press BaskSpace on empty line which is the first line of a blockquote, unquote current line. Default value is true.
When press Enter on empty line in a blockquote, unquote current line. Default value is true.
When press space after an asterik/dash (*/-) or number (1.) in an empty line, turn current line into bullet/numbering list. Default value is true.
When press TAB or SHIFT+TAB key in table cell, jump to next/previous table cell. Default value is true.
To overwrite one or some of the default feature settings, you can use getDefaultContentEditFeatures()
function to get the default feature set then modify it. The code below will turn of "autoBullet" feature but keep all other features using default values:
let features = getDefaultContentEditFeatures();
features.autoBullet = false;
let contentEditPlugin = new ContentEdit(features);
In RoosterJs 6.7.5, ContentEdit plugin will trigger ContentChangedEvent with source equal to 'Format' (ChangeSource.Format). This behavior may be changed in newer build.
Package: roosterjs-editor-plugins
Support from: 6.5.0 (autoBullet feature requires 6.7.0)
Source code: ContentEdit.ts