1 import {EditorButton} from "../framework/buttons";
2 import {EditorContainerUiElement, EditorSimpleClassContainer, EditorUiContext, EditorUiElement} from "../framework/core";
3 import {EditorFormatMenu} from "../framework/blocks/format-menu";
4 import {FormatPreviewButton} from "../framework/blocks/format-preview-button";
5 import {EditorDropdownButton} from "../framework/blocks/dropdown-button";
6 import {EditorColorPicker} from "../framework/blocks/color-picker";
7 import {EditorTableCreator} from "../framework/blocks/table-creator";
8 import {EditorColorButton} from "../framework/blocks/color-button";
9 import {EditorOverflowContainer} from "../framework/blocks/overflow-container";
11 cellProperties, clearTableFormatting,
19 deleteTableMenuAction,
28 pasteRowBefore, resizeTableToContents,
31 table, tableProperties
32 } from "./buttons/tables";
33 import {about, fullscreen, redo, source, undo} from "./buttons/controls";
35 blockquote, dangerCallout,
44 } from "./buttons/block-formats";
46 bold, clearFormating, code,
47 highlightColor, highlightColorAction,
49 strikethrough, subscript,
51 textColor, textColorAction,
53 } from "./buttons/inline-formats";
61 } from "./buttons/alignments";
68 } from "./buttons/lists";
71 details, detailsEditLabel, detailsToggle, detailsUnwrap,
72 diagram, diagramManager,
78 } from "./buttons/objects";
79 import {el} from "../../utils/dom";
80 import {EditorButtonWithMenu} from "../framework/blocks/button-with-menu";
81 import {EditorSeparator} from "../framework/blocks/separator";
83 export function getMainEditorFullToolbar(context: EditorUiContext): EditorContainerUiElement {
85 const inRtlMode = context.manager.getDefaultDirection() === 'rtl';
87 return new EditorSimpleClassContainer('editor-toolbar-main', [
90 new EditorOverflowContainer(2, [
91 new EditorButton(undo),
92 new EditorButton(redo),
96 new EditorFormatMenu([
97 new FormatPreviewButton(el('h2'), h2),
98 new FormatPreviewButton(el('h3'), h3),
99 new FormatPreviewButton(el('h4'), h4),
100 new FormatPreviewButton(el('h5'), h5),
101 new FormatPreviewButton(el('blockquote'), blockquote),
102 new FormatPreviewButton(el('p'), paragraph),
103 new EditorDropdownButton({button: {label: 'Callouts', format: 'long'}, showOnHover: true, direction: 'vertical'}, [
104 new FormatPreviewButton(el('p', {class: 'callout info'}), infoCallout),
105 new FormatPreviewButton(el('p', {class: 'callout success'}), successCallout),
106 new FormatPreviewButton(el('p', {class: 'callout warning'}), warningCallout),
107 new FormatPreviewButton(el('p', {class: 'callout danger'}), dangerCallout),
112 new EditorOverflowContainer(6, [
113 new EditorButton(bold),
114 new EditorButton(italic),
115 new EditorButton(underline),
116 new EditorDropdownButton({ button: new EditorColorButton(textColor, 'color') }, [
117 new EditorColorPicker(textColorAction),
119 new EditorDropdownButton({button: new EditorColorButton(highlightColor, 'background-color')}, [
120 new EditorColorPicker(highlightColorAction),
122 new EditorButton(strikethrough),
123 new EditorButton(superscript),
124 new EditorButton(subscript),
125 new EditorButton(code),
126 new EditorButton(clearFormating),
130 new EditorOverflowContainer(6, [
131 new EditorButton(alignLeft),
132 new EditorButton(alignCenter),
133 new EditorButton(alignRight),
134 new EditorButton(alignJustify),
135 inRtlMode ? new EditorButton(directionLTR) : null,
136 inRtlMode ? new EditorButton(directionRTL) : null,
137 ].filter(x => x !== null)),
140 new EditorOverflowContainer(3, [
141 new EditorButton(bulletList),
142 new EditorButton(numberList),
143 new EditorButton(taskList),
144 new EditorButton(indentDecrease),
145 new EditorButton(indentIncrease),
149 new EditorOverflowContainer(4, [
150 new EditorButton(link),
152 new EditorDropdownButton({button: table, direction: 'vertical', showAside: false}, [
153 new EditorDropdownButton({button: {label: 'Insert', format: 'long'}, showOnHover: true, showAside: true}, [
154 new EditorTableCreator(),
156 new EditorSeparator(),
157 new EditorDropdownButton({button: {label: 'Cell', format: 'long'}, direction: 'vertical', showOnHover: true}, [
158 new EditorButton(cellProperties),
159 new EditorButton(mergeCells),
160 new EditorButton(splitCell),
162 new EditorDropdownButton({button: {label: 'Row', format: 'long'}, direction: 'vertical', showOnHover: true}, [
163 new EditorButton({...insertRowAbove, format: 'long'}),
164 new EditorButton({...insertRowBelow, format: 'long'}),
165 new EditorButton({...deleteRow, format: 'long'}),
166 new EditorButton(rowProperties),
167 new EditorSeparator(),
168 new EditorButton(cutRow),
169 new EditorButton(copyRow),
170 new EditorButton(pasteRowBefore),
171 new EditorButton(pasteRowAfter),
173 new EditorDropdownButton({button: {label: 'Column', format: 'long'}, direction: 'vertical', showOnHover: true}, [
174 new EditorButton({...insertColumnBefore, format: 'long'}),
175 new EditorButton({...insertColumnAfter, format: 'long'}),
176 new EditorButton({...deleteColumn, format: 'long'}),
177 new EditorSeparator(),
178 new EditorButton(cutColumn),
179 new EditorButton(copyColumn),
180 new EditorButton(pasteColumnBefore),
181 new EditorButton(pasteColumnAfter),
183 new EditorSeparator(),
184 new EditorButton({...tableProperties, format: 'long'}),
185 new EditorButton(clearTableFormatting),
186 new EditorButton(resizeTableToContents),
187 new EditorButton(deleteTableMenuAction),
190 new EditorButton(image),
191 new EditorButton(horizontalRule),
192 new EditorButton(codeBlock),
193 new EditorButtonWithMenu(
194 new EditorButton(diagram),
195 [new EditorButton(diagramManager)],
197 new EditorButton(media),
198 new EditorButton(details),
202 new EditorOverflowContainer(3, [
203 new EditorButton(source),
204 new EditorButton(about),
205 new EditorButton(fullscreen),
208 // new EditorButton({
209 // label: 'Test button',
210 // action(context: EditorUiContext) {
211 // context.editor.update(() => {
223 export function getImageToolbarContent(): EditorUiElement[] {
224 return [new EditorButton(image)];
227 export function getMediaToolbarContent(): EditorUiElement[] {
228 return [new EditorButton(media)];
231 export function getLinkToolbarContent(): EditorUiElement[] {
233 new EditorButton(link),
234 new EditorButton(unlink),
238 export function getCodeToolbarContent(): EditorUiElement[] {
240 new EditorButton(editCodeBlock),
244 export function getTableToolbarContent(): EditorUiElement[] {
246 new EditorOverflowContainer(2, [
247 new EditorButton(tableProperties),
248 new EditorButton(deleteTable),
250 new EditorOverflowContainer(3, [
251 new EditorButton(insertRowAbove),
252 new EditorButton(insertRowBelow),
253 new EditorButton(deleteRow),
255 new EditorOverflowContainer(3, [
256 new EditorButton(insertColumnBefore),
257 new EditorButton(insertColumnAfter),
258 new EditorButton(deleteColumn),
263 export function getDetailsToolbarContent(): EditorUiElement[] {
265 new EditorButton(detailsEditLabel),
266 new EditorButton(detailsToggle),
267 new EditorButton(detailsUnwrap),