2024-06-12 14:51:42 -04:00
|
|
|
import {EditorButton} from "./framework/buttons";
|
2024-05-29 15:38:31 -04:00
|
|
|
import {
|
2024-06-19 11:14:20 -04:00
|
|
|
blockquote, bold, bulletList, clearFormating, code,
|
2024-07-01 05:44:23 -04:00
|
|
|
dangerCallout, details, fullscreen,
|
2024-06-27 10:48:06 -04:00
|
|
|
h2, h3, h4, h5, highlightColor, horizontalRule, image,
|
2024-06-19 11:14:20 -04:00
|
|
|
infoCallout, italic, link, numberList, paragraph,
|
2024-06-12 09:01:36 -04:00
|
|
|
redo, source, strikethrough, subscript,
|
2024-06-21 11:18:44 -04:00
|
|
|
successCallout, superscript, table, taskList, textColor, underline,
|
2024-06-30 14:52:09 -04:00
|
|
|
undo, unlink,
|
2024-05-29 15:38:31 -04:00
|
|
|
warningCallout
|
|
|
|
} from "./defaults/button-definitions";
|
2024-06-30 07:13:13 -04:00
|
|
|
import {EditorContainerUiElement, EditorSimpleClassContainer, EditorUiContext, EditorUiElement} from "./framework/core";
|
2024-05-30 07:25:25 -04:00
|
|
|
import {el} from "../helpers";
|
2024-06-12 14:51:42 -04:00
|
|
|
import {EditorFormatMenu} from "./framework/blocks/format-menu";
|
|
|
|
import {FormatPreviewButton} from "./framework/blocks/format-preview-button";
|
|
|
|
import {EditorDropdownButton} from "./framework/blocks/dropdown-button";
|
|
|
|
import {EditorColorPicker} from "./framework/blocks/color-picker";
|
2024-06-21 11:18:44 -04:00
|
|
|
import {EditorTableCreator} from "./framework/blocks/table-creator";
|
2024-06-23 10:50:41 -04:00
|
|
|
import {EditorColorButton} from "./framework/blocks/color-button";
|
2024-06-27 11:28:06 -04:00
|
|
|
import {EditorOverflowContainer} from "./framework/blocks/overflow-container";
|
2024-05-29 15:38:31 -04:00
|
|
|
|
|
|
|
export function getMainEditorFullToolbar(): EditorContainerUiElement {
|
2024-05-30 07:25:25 -04:00
|
|
|
return new EditorSimpleClassContainer('editor-toolbar-main', [
|
2024-06-12 09:24:50 -04:00
|
|
|
// History state
|
2024-05-29 15:38:31 -04:00
|
|
|
new EditorButton(undo),
|
|
|
|
new EditorButton(redo),
|
|
|
|
|
2024-06-12 09:24:50 -04:00
|
|
|
// Block formats
|
2024-05-29 15:38:31 -04:00
|
|
|
new EditorFormatMenu([
|
2024-05-30 07:25:25 -04:00
|
|
|
new FormatPreviewButton(el('h2'), h2),
|
|
|
|
new FormatPreviewButton(el('h3'), h3),
|
|
|
|
new FormatPreviewButton(el('h4'), h4),
|
|
|
|
new FormatPreviewButton(el('h5'), h5),
|
|
|
|
new FormatPreviewButton(el('blockquote'), blockquote),
|
|
|
|
new FormatPreviewButton(el('p'), paragraph),
|
|
|
|
new FormatPreviewButton(el('p', {class: 'callout info'}), infoCallout),
|
|
|
|
new FormatPreviewButton(el('p', {class: 'callout success'}), successCallout),
|
|
|
|
new FormatPreviewButton(el('p', {class: 'callout warning'}), warningCallout),
|
|
|
|
new FormatPreviewButton(el('p', {class: 'callout danger'}), dangerCallout),
|
2024-05-29 15:38:31 -04:00
|
|
|
]),
|
|
|
|
|
2024-06-12 09:24:50 -04:00
|
|
|
// Inline formats
|
2024-05-29 15:38:31 -04:00
|
|
|
new EditorButton(bold),
|
|
|
|
new EditorButton(italic),
|
|
|
|
new EditorButton(underline),
|
2024-06-23 10:50:41 -04:00
|
|
|
new EditorDropdownButton(new EditorColorButton(textColor, 'color'), [
|
2024-06-12 14:51:42 -04:00
|
|
|
new EditorColorPicker('color'),
|
|
|
|
]),
|
2024-06-23 10:50:41 -04:00
|
|
|
new EditorDropdownButton(new EditorColorButton(highlightColor, 'background-color'), [
|
2024-06-12 14:51:42 -04:00
|
|
|
new EditorColorPicker('background-color'),
|
|
|
|
]),
|
2024-05-29 15:38:31 -04:00
|
|
|
new EditorButton(strikethrough),
|
|
|
|
new EditorButton(superscript),
|
|
|
|
new EditorButton(subscript),
|
|
|
|
new EditorButton(code),
|
2024-06-12 09:24:50 -04:00
|
|
|
new EditorButton(clearFormating),
|
2024-05-29 15:38:31 -04:00
|
|
|
|
2024-06-19 11:14:20 -04:00
|
|
|
// Lists
|
|
|
|
new EditorButton(bulletList),
|
|
|
|
new EditorButton(numberList),
|
|
|
|
new EditorButton(taskList),
|
|
|
|
|
2024-06-12 09:24:50 -04:00
|
|
|
// Insert types
|
2024-06-27 11:28:06 -04:00
|
|
|
new EditorOverflowContainer(6, [
|
|
|
|
new EditorButton(link),
|
|
|
|
new EditorDropdownButton(table, [
|
|
|
|
new EditorTableCreator(),
|
|
|
|
]),
|
|
|
|
new EditorButton(image),
|
|
|
|
new EditorButton(horizontalRule),
|
|
|
|
new EditorButton(details),
|
2024-06-21 11:18:44 -04:00
|
|
|
]),
|
2024-06-12 09:01:36 -04:00
|
|
|
|
2024-06-12 09:24:50 -04:00
|
|
|
// Meta elements
|
2024-06-12 09:01:36 -04:00
|
|
|
new EditorButton(source),
|
2024-07-01 05:44:23 -04:00
|
|
|
new EditorButton(fullscreen),
|
2024-06-24 15:50:17 -04:00
|
|
|
|
|
|
|
// Test
|
|
|
|
new EditorButton({
|
2024-06-27 10:48:06 -04:00
|
|
|
label: 'Test button',
|
2024-06-24 15:50:17 -04:00
|
|
|
action(context: EditorUiContext) {
|
|
|
|
context.editor.update(() => {
|
2024-06-27 10:48:06 -04:00
|
|
|
// Do stuff
|
2024-06-24 15:50:17 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
isActive() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
})
|
2024-05-29 15:38:31 -04:00
|
|
|
]);
|
2024-06-30 07:13:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getImageToolbarContent(): EditorUiElement[] {
|
|
|
|
return [new EditorButton(image)];
|
2024-06-30 14:52:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getLinkToolbarContent(): EditorUiElement[] {
|
|
|
|
return [
|
|
|
|
new EditorButton(link),
|
|
|
|
new EditorButton(unlink),
|
|
|
|
];
|
2024-05-29 15:38:31 -04:00
|
|
|
}
|