import { Obj } from '@ephox/katamari'; import { TinyHooks } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; interface Settings { readonly addSettings: (config: Record) => void; readonly cleanupSettings: () => void; } const Settings = (hook: TinyHooks.Hook): Settings => { let settings = new Set(); const addSettings = (config: Record) => { const editor = hook.editor(); Obj.each(config, (val, key) => { editor.options.set(key, val); settings.add(key); }); }; const cleanupSettings = () => { const editor = hook.editor(); settings.forEach((key) => editor.options.unset(key)); settings = new Set(); }; return { addSettings, cleanupSettings }; }; export { Settings };