Document Editor supports both the single-level and multilevel lists. Lists are used to organize data as step-by-step instructions in documents for easy understanding of key points. You can apply list to the paragraph either using supported APIs.
Bullets are usually used for unordered lists. To apply bulleted list for selected paragraphs, use the following method of ‘Editor’ instance.
applyBullet(bullet, fontFamily);
Parameter | Type | Description |
---|---|---|
Bullet | string | Bullet character. |
fontFamily | string | Bullet font family. |
Refer to the following sample code.
documenteditor.editor.applyBullet('\uf0b7', 'Symbol');
Numbered lists are usually used for ordered lists. To apply numbered list for selected paragraphs, use the following method of ‘Editor’ instance.
applyNumbering(numberFormat,listLevelPattern)
Parameter | Type | Description |
---|---|---|
numberFormat | string | “%n” representations in ‘numberFormat’ parameter will be replaced by respective list level’s value.“%1)” will be displayed as “1)” |
listLevelPattern(optional) | string | Default value is ‘Arabic’. |
Refer to the following example.
documenteditor.editor.applyNumbering('%1)', 'UpRoman');
You can also clear the list formatting applied for selected paragraphs. Refer to the following sample code.
documenteditor.editor.clearList();
The following sample demonstrates how to create bullet and numbering lists in Document Editor.
ej.base.enableRipple(true);
ej.documenteditor.DocumentEditor.Inject(ej.documenteditor.Editor, ej.documenteditor.Selection,ej.documenteditor.EditorHistory);
var documenteditor = new ej.documenteditor.DocumentEditor({ enableEditor: true, isReadOnly: false, enableSelection: true,enableEditorHistory:true,height: '370px'});
function toolbarAction (args){
switch (args.item.id) {
case 'Bullets':
//To create bullet list
documenteditor.editor.applyBullet('\uf0b7', 'Symbol');
break;
case 'Numbering':
//To create numbering list
documenteditor.editor.applyNumbering('%1)', 'UpRoman');
break;
case 'clearlist':
//To clear list
documenteditor.editor.clearList();
break;
}
};
var toolbar = new ej.navigations.Toolbar({
clicked: toolbarAction,
items: [
{
prefixIcon: 'e-de-ctnr-bullets e-icons',
tooltipText: 'Bullets',
id: 'Bullets',
},
{
prefixIcon: 'e-de-ctnr-numbering e-icons',
tooltipText: 'Numbering',
id: 'Numbering',
},
{
text: 'Clear',
id: 'clearlist',
tooltipText: 'Clear List',
},
],
});
toolbar.appendTo('#toolbar');
documenteditor.appendTo('#DocumentEditor');
Document Editor restarts the numbering or continue numbering for a numbered list. These options are found in the built-in context menu, if the list value is selected. Refer to the following screenshot.