1 import {EditorButton} from "./framework/buttons";
2 import {EditorContainerUiElement, EditorSimpleClassContainer, EditorUiElement} from "./framework/core";
3 import {$selectionContainsNodeType, el} from "../helpers";
4 import {EditorFormatMenu} from "./framework/blocks/format-menu";
5 import {FormatPreviewButton} from "./framework/blocks/format-preview-button";
6 import {EditorDropdownButton} from "./framework/blocks/dropdown-button";
7 import {EditorColorPicker} from "./framework/blocks/color-picker";
8 import {EditorTableCreator} from "./framework/blocks/table-creator";
9 import {EditorColorButton} from "./framework/blocks/color-button";
10 import {EditorOverflowContainer} from "./framework/blocks/overflow-container";
12 cellProperties, clearTableFormatting,
20 deleteTableMenuAction,
29 pasteRowBefore, resizeTableToContents,
32 table, tableProperties
33 } from "./defaults/buttons/tables";
34 import {fullscreen, redo, source, undo} from "./defaults/buttons/controls";
36 blockquote, dangerCallout,
45 } from "./defaults/buttons/block-formats";
47 bold, clearFormating, code,
50 strikethrough, subscript,
54 } from "./defaults/buttons/inline-formats";
55 import {alignCenter, alignJustify, alignLeft, alignRight} from "./defaults/buttons/alignments";
56 import {bulletList, numberList, taskList} from "./defaults/buttons/lists";
66 } from "./defaults/buttons/objects";
67 import {$isTableNode} from "@lexical/table";
69 export function getMainEditorFullToolbar(): EditorContainerUiElement {
70 return new EditorSimpleClassContainer('editor-toolbar-main', [
73 new EditorOverflowContainer(2, [
74 new EditorButton(undo),
75 new EditorButton(redo),
79 new EditorFormatMenu([
80 new FormatPreviewButton(el('h2'), h2),
81 new FormatPreviewButton(el('h3'), h3),
82 new FormatPreviewButton(el('h4'), h4),
83 new FormatPreviewButton(el('h5'), h5),
84 new FormatPreviewButton(el('blockquote'), blockquote),
85 new FormatPreviewButton(el('p'), paragraph),
86 new EditorDropdownButton({button: {label: 'Callouts'}, showOnHover: true, direction: 'vertical'}, [
87 new FormatPreviewButton(el('p', {class: 'callout info'}), infoCallout),
88 new FormatPreviewButton(el('p', {class: 'callout success'}), successCallout),
89 new FormatPreviewButton(el('p', {class: 'callout warning'}), warningCallout),
90 new FormatPreviewButton(el('p', {class: 'callout danger'}), dangerCallout),
95 new EditorOverflowContainer(6, [
96 new EditorButton(bold),
97 new EditorButton(italic),
98 new EditorButton(underline),
99 new EditorDropdownButton({ button: new EditorColorButton(textColor, 'color') }, [
100 new EditorColorPicker('color'),
102 new EditorDropdownButton({button: new EditorColorButton(highlightColor, 'background-color')}, [
103 new EditorColorPicker('background-color'),
105 new EditorButton(strikethrough),
106 new EditorButton(superscript),
107 new EditorButton(subscript),
108 new EditorButton(code),
109 new EditorButton(clearFormating),
113 new EditorOverflowContainer(4, [
114 new EditorButton(alignLeft),
115 new EditorButton(alignCenter),
116 new EditorButton(alignRight),
117 new EditorButton(alignJustify),
121 new EditorOverflowContainer(3, [
122 new EditorButton(bulletList),
123 new EditorButton(numberList),
124 new EditorButton(taskList),
128 new EditorOverflowContainer(8, [
129 new EditorButton(link),
131 new EditorDropdownButton({button: table, direction: 'vertical'}, [
132 new EditorDropdownButton({button: {...table, format: 'long'}, showOnHover: true}, [
133 new EditorTableCreator(),
135 new EditorDropdownButton({button: {label: 'Cell'}, direction: 'vertical', showOnHover: true}, [
136 new EditorButton(cellProperties),
137 new EditorButton(mergeCells),
138 new EditorButton(splitCell),
140 new EditorDropdownButton({button: {label: 'Row'}, direction: 'vertical', showOnHover: true}, [
141 new EditorButton({...insertRowAbove, format: 'long'}),
142 new EditorButton({...insertRowBelow, format: 'long'}),
143 new EditorButton({...deleteRow, format: 'long'}),
144 new EditorButton(rowProperties),
145 new EditorButton(cutRow),
146 new EditorButton(copyRow),
147 new EditorButton(pasteRowBefore),
148 new EditorButton(pasteRowAfter),
150 new EditorDropdownButton({button: {label: 'Column'}, direction: 'vertical', showOnHover: true}, [
151 new EditorButton({...insertColumnBefore, format: 'long'}),
152 new EditorButton({...insertColumnAfter, format: 'long'}),
153 new EditorButton({...deleteColumn, format: 'long'}),
154 new EditorButton(cutColumn),
155 new EditorButton(copyColumn),
156 new EditorButton(pasteColumnBefore),
157 new EditorButton(pasteColumnAfter),
159 new EditorButton({...tableProperties, format: 'long'}),
160 new EditorButton(clearTableFormatting),
161 new EditorButton(resizeTableToContents),
162 new EditorButton(deleteTableMenuAction),
165 new EditorButton(image),
166 new EditorButton(horizontalRule),
167 new EditorButton(codeBlock),
168 new EditorButton(diagram),
169 new EditorButton(media),
170 new EditorButton(details),
174 new EditorOverflowContainer(3, [
175 new EditorButton(source),
176 new EditorButton(fullscreen),
179 // new EditorButton({
180 // label: 'Test button',
181 // action(context: EditorUiContext) {
182 // context.editor.update(() => {
194 export function getImageToolbarContent(): EditorUiElement[] {
195 return [new EditorButton(image)];
198 export function getLinkToolbarContent(): EditorUiElement[] {
200 new EditorButton(link),
201 new EditorButton(unlink),
205 export function getCodeToolbarContent(): EditorUiElement[] {
207 new EditorButton(editCodeBlock),
211 export function getTableToolbarContent(): EditorUiElement[] {
213 new EditorOverflowContainer(2, [
214 new EditorButton(tableProperties),
215 new EditorButton(deleteTable),
217 new EditorOverflowContainer(3, [
218 new EditorButton(insertRowAbove),
219 new EditorButton(insertRowBelow),
220 new EditorButton(deleteRow),
222 new EditorOverflowContainer(3, [
223 new EditorButton(insertColumnBefore),
224 new EditorButton(insertColumnAfter),
225 new EditorButton(deleteColumn),