]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/ui/toolbars.ts
Lexical: Added horizontal rule node
[bookstack] / resources / js / wysiwyg / ui / toolbars.ts
1 import {EditorButton} from "./framework/buttons";
2 import {
3     blockquote, bold, bulletList, clearFormating, code,
4     dangerCallout, details,
5     h2, h3, h4, h5, highlightColor, horizontalRule, image,
6     infoCallout, italic, link, numberList, paragraph,
7     redo, source, strikethrough, subscript,
8     successCallout, superscript, table, taskList, textColor, underline,
9     undo,
10     warningCallout
11 } from "./defaults/button-definitions";
12 import {EditorContainerUiElement, EditorSimpleClassContainer, EditorUiContext} from "./framework/core";
13 import {el} from "../helpers";
14 import {EditorFormatMenu} from "./framework/blocks/format-menu";
15 import {FormatPreviewButton} from "./framework/blocks/format-preview-button";
16 import {EditorDropdownButton} from "./framework/blocks/dropdown-button";
17 import {EditorColorPicker} from "./framework/blocks/color-picker";
18 import {EditorTableCreator} from "./framework/blocks/table-creator";
19 import {EditorColorButton} from "./framework/blocks/color-button";
20 import {$isCustomTableNode, $setTableColumnWidth, CustomTableNode} from "../nodes/custom-table";
21 import {$getRoot} from "lexical";
22
23 export function getMainEditorFullToolbar(): EditorContainerUiElement {
24     return new EditorSimpleClassContainer('editor-toolbar-main', [
25         // History state
26         new EditorButton(undo),
27         new EditorButton(redo),
28
29         // Block formats
30         new EditorFormatMenu([
31             new FormatPreviewButton(el('h2'), h2),
32             new FormatPreviewButton(el('h3'), h3),
33             new FormatPreviewButton(el('h4'), h4),
34             new FormatPreviewButton(el('h5'), h5),
35             new FormatPreviewButton(el('blockquote'), blockquote),
36             new FormatPreviewButton(el('p'), paragraph),
37             new FormatPreviewButton(el('p', {class: 'callout info'}), infoCallout),
38             new FormatPreviewButton(el('p', {class: 'callout success'}), successCallout),
39             new FormatPreviewButton(el('p', {class: 'callout warning'}), warningCallout),
40             new FormatPreviewButton(el('p', {class: 'callout danger'}), dangerCallout),
41         ]),
42
43         // Inline formats
44         new EditorButton(bold),
45         new EditorButton(italic),
46         new EditorButton(underline),
47         new EditorDropdownButton(new EditorColorButton(textColor, 'color'), [
48             new EditorColorPicker('color'),
49         ]),
50         new EditorDropdownButton(new EditorColorButton(highlightColor, 'background-color'), [
51             new EditorColorPicker('background-color'),
52         ]),
53         new EditorButton(strikethrough),
54         new EditorButton(superscript),
55         new EditorButton(subscript),
56         new EditorButton(code),
57         new EditorButton(clearFormating),
58
59         // Lists
60         new EditorButton(bulletList),
61         new EditorButton(numberList),
62         new EditorButton(taskList),
63
64         // Insert types
65         new EditorButton(link),
66         new EditorDropdownButton(table, [
67             new EditorTableCreator(),
68         ]),
69         new EditorButton(image),
70         new EditorButton(horizontalRule),
71         new EditorButton(details),
72
73         // Meta elements
74         new EditorButton(source),
75
76         // Test
77         new EditorButton({
78             label: 'Test button',
79             action(context: EditorUiContext) {
80                 context.editor.update(() => {
81                     // Do stuff
82                 });
83             },
84             isActive() {
85                 return false;
86             }
87         })
88     ]);
89 }