UNPKG

jodit

Version:

Jodit is awesome and usefully wysiwyg editor with filebrowser

49 lines (41 loc) 1.27 kB
/*! * Jodit Editor (https://xdsoft.net/jodit/) * Released under MIT see LICENSE.txt in the project root for license information. * Copyright (c) 2013-2020 Valeriy Chupurnov. All rights reserved. https://xdsoft.net */ import { Config } from '../config'; import * as consts from '../core/constants'; import { Plugin } from '../core/plugin'; import { IControlType, IJodit } from '../types/'; Config.prototype.controls.redo = { mode: consts.MODE_SPLIT, isDisabled: (editor: IJodit): boolean => !editor.observer.stack.canRedo(), tooltip: 'Redo' } as IControlType; Config.prototype.controls.undo = { mode: consts.MODE_SPLIT, isDisabled: (editor: IJodit): boolean => !editor.observer.stack.canUndo(), tooltip: 'Undo' } as IControlType; /** * Custom process Redo and Undo functionality */ export class redoUndo extends Plugin { beforeDestruct(): void { // do nothing } afterInit(editor: IJodit): void { const callback = (command: string): void | false => { editor.observer[command as 'redo' | 'undo'](); return false; }; editor.registerCommand('redo', { exec: callback, hotkeys: ['ctrl+y', 'ctrl+shift+z', 'cmd+y', 'cmd+shift+z'] }); editor.registerCommand('undo', { exec: callback, hotkeys: ['ctrl+z', 'cmd+z'] }); } }