import{r as e}from"./rolldown-runtime.WmLfqUcM.js";var t=e({plugin_exports:()=>n});(function(){var e=hugerte.util.Tools.resolve(`hugerte.PluginManager`),t=hugerte.util.Tools.resolve(`hugerte.Env`);let n=e=>t=>t.options.get(e),r=e=>{let t=e.options.register;t(`pagebreak_separator`,{processor:`string`,default:`<!-- pagebreak -->`}),t(`pagebreak_split_block`,{processor:`boolean`,default:!1})},i=n(`pagebreak_separator`),a=n(`pagebreak_split_block`),o=`mce-pagebreak`,s=e=>{let n=`<img src="${t.transparentSrc}" class="${o}" data-mce-resize="false" data-mce-placeholder />`;return e?`<p>${n}</p>`:n},c=e=>{let t=i(e),n=()=>a(e),r=new RegExp(t.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,e=>`\\`+e),`gi`);e.on(`BeforeSetContent`,e=>{e.content=e.content.replace(r,s(n()))}),e.on(`PreInit`,()=>{e.serializer.addNodeFilter(`img`,r=>{let i=r.length,a,s;for(;i--;)if(a=r[i],s=a.attr(`class`),s&&s.indexOf(o)!==-1){let r=a.parent;if(r&&e.schema.getBlockElements()[r.name]&&n()){r.type=3,r.value=t,r.raw=!0,a.remove();continue}a.type=3,a.value=t,a.raw=!0}})})},l=e=>{e.addCommand(`mcePageBreak`,()=>{e.insertContent(s(a(e)))})},u=e=>{e.on(`ResolveName`,t=>{t.target.nodeName===`IMG`&&e.dom.hasClass(t.target,o)&&(t.name=`pagebreak`)})},d=e=>t=>{let n=()=>{t.setEnabled(e.selection.isEditable())};return e.on(`NodeChange`,n),n(),()=>{e.off(`NodeChange`,n)}},f=e=>{let t=()=>e.execCommand(`mcePageBreak`);e.ui.registry.addButton(`pagebreak`,{icon:`page-break`,tooltip:`Page break`,onAction:t,onSetup:d(e)}),e.ui.registry.addMenuItem(`pagebreak`,{text:`Page break`,icon:`page-break`,onAction:t,onSetup:d(e)})};e.add(`pagebreak`,e=>{r(e),l(e),f(e),c(e),u(e)})})();var n={};export{t};