1 import {EditorButton, EditorButtonDefinition} from "../../framework/buttons";
2 import undoIcon from "@icons/editor/undo.svg";
3 import {EditorUiContext} from "../../framework/core";
12 import redoIcon from "@icons/editor/redo.svg";
13 import sourceIcon from "@icons/editor/source-view.svg";
14 import {getEditorContentAsHtml} from "../../../actions";
15 import fullscreenIcon from "@icons/editor/fullscreen.svg";
17 export const undo: EditorButtonDefinition = {
20 action(context: EditorUiContext) {
21 context.editor.dispatchCommand(UNDO_COMMAND, undefined);
23 isActive(selection: BaseSelection|null): boolean {
26 setup(context: EditorUiContext, button: EditorButton) {
27 button.toggleDisabled(true);
29 context.editor.registerCommand(CAN_UNDO_COMMAND, (payload: boolean): boolean => {
30 button.toggleDisabled(!payload)
32 }, COMMAND_PRIORITY_LOW);
36 export const redo: EditorButtonDefinition = {
39 action(context: EditorUiContext) {
40 context.editor.dispatchCommand(REDO_COMMAND, undefined);
42 isActive(selection: BaseSelection|null): boolean {
45 setup(context: EditorUiContext, button: EditorButton) {
46 button.toggleDisabled(true);
48 context.editor.registerCommand(CAN_REDO_COMMAND, (payload: boolean): boolean => {
49 button.toggleDisabled(!payload)
51 }, COMMAND_PRIORITY_LOW);
56 export const source: EditorButtonDefinition = {
59 async action(context: EditorUiContext) {
60 const modal = context.manager.createModal('source');
61 const source = await getEditorContentAsHtml(context.editor);
69 export const fullscreen: EditorButtonDefinition = {
72 async action(context: EditorUiContext, button: EditorButton) {
73 const isFullScreen = context.containerDOM.classList.contains('fullscreen');
74 context.containerDOM.classList.toggle('fullscreen', !isFullScreen);
75 (context.containerDOM.closest('body') as HTMLElement).classList.toggle('editor-is-fullscreen', !isFullScreen);
76 button.setActiveState(!isFullScreen);
78 isActive(selection, context: EditorUiContext) {
79 return context.containerDOM.classList.contains('fullscreen');