UNPKG

@tabler/core

Version:

Premium and Open Source dashboard template with responsive and high quality UI.

7 lines 1.81 kB
/** * HugeRTE version 1.0.9 (2025-03-15) * Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc. * Copyright (c) 2024 HugeRTE contributors * Licensed under the MIT license (https://github.com/hugerte/hugerte/blob/main/LICENSE.TXT) */ !function(){"use strict";var e=hugerte.util.Tools.resolve("hugerte.PluginManager");const o=("function",e=>"function"==typeof e);var t=hugerte.util.Tools.resolve("hugerte.dom.DOMUtils"),n=hugerte.util.Tools.resolve("hugerte.util.Tools");const a=e=>o=>o.options.get(e),r=a("save_enablewhendirty"),c=a("save_onsavecallback"),s=a("save_oncancelcallback"),i=(e,o)=>{e.notificationManager.open({text:o,type:"error"})},l=e=>o=>{const t=()=>{o.setEnabled(!r(e)||e.isDirty())};return t(),e.on("NodeChange dirty",t),()=>e.off("NodeChange dirty",t)};e.add("save",(e=>{(e=>{const o=e.options.register;o("save_enablewhendirty",{processor:"boolean",default:!0}),o("save_onsavecallback",{processor:"function"}),o("save_oncancelcallback",{processor:"function"})})(e),(e=>{e.ui.registry.addButton("save",{icon:"save",tooltip:"Save",enabled:!1,onAction:()=>e.execCommand("mceSave"),onSetup:l(e),shortcut:"Meta+S"}),e.ui.registry.addButton("cancel",{icon:"cancel",tooltip:"Cancel",enabled:!1,onAction:()=>e.execCommand("mceCancel"),onSetup:l(e)}),e.addShortcut("Meta+S","","mceSave")})(e),(e=>{e.addCommand("mceSave",(()=>{(e=>{const n=t.DOM.getParent(e.id,"form");if(r(e)&&!e.isDirty())return;e.save();const a=c(e);if(o(a))return a.call(e,e),void e.nodeChanged();n?(e.setDirty(!1),n.onsubmit&&!n.onsubmit()||("function"==typeof n.submit?n.submit():i(e,"Error: Form submit field collision.")),e.nodeChanged()):i(e,"Error: No form element found.")})(e)})),e.addCommand("mceCancel",(()=>{(e=>{const t=n.trim(e.startContent),a=s(e);o(a)?a.call(e,e):e.resetContent(t)})(e)}))})(e)}))}();