@editora/plugins 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-DESvGCrJ.mjs} +61 -53
  2. package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-DJqwsRPZ.js} +11 -11
  3. package/dist/a11y-checker.cjs.js +3 -3
  4. package/dist/a11y-checker.esm.js +6 -4
  5. package/dist/anchor.cjs.js +4 -4
  6. package/dist/anchor.esm.js +19 -18
  7. package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
  8. package/dist/anchoredPopover-Cygmit_o.js +1 -0
  9. package/dist/approval-workflow.cjs.js +7 -7
  10. package/dist/approval-workflow.esm.js +55 -54
  11. package/dist/background-color.cjs.js +2 -2
  12. package/dist/background-color.esm.js +72 -67
  13. package/dist/blocks-library.cjs.js +18 -19
  14. package/dist/blocks-library.esm.js +41 -42
  15. package/dist/citations.cjs.js +4 -4
  16. package/dist/citations.esm.js +50 -50
  17. package/dist/code-sample.cjs.js +10 -10
  18. package/dist/code-sample.esm.js +4 -4
  19. package/dist/code.cjs.js +1 -1
  20. package/dist/code.esm.js +1 -1
  21. package/dist/comments.cjs.js +23 -11
  22. package/dist/comments.esm.js +167 -149
  23. package/dist/conditional-content.cjs.js +2 -2
  24. package/dist/conditional-content.esm.js +2 -2
  25. package/dist/confirmDialog-6BPaNPis.mjs +106 -0
  26. package/dist/confirmDialog-C4UWENes.js +46 -0
  27. package/dist/content-rules.cjs.js +6 -6
  28. package/dist/content-rules.esm.js +51 -51
  29. package/dist/data-binding.cjs.js +2 -2
  30. package/dist/data-binding.esm.js +2 -2
  31. package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
  32. package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
  33. package/dist/document-manager.cjs.js +1 -1
  34. package/dist/document-manager.esm.js +1 -1
  35. package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
  36. package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
  37. package/dist/embed-iframe.cjs.js +6 -6
  38. package/dist/embed-iframe.esm.js +6 -6
  39. package/dist/emojis.cjs.js +5 -5
  40. package/dist/emojis.esm.js +3 -3
  41. package/dist/enterprise.cjs.js +1 -1
  42. package/dist/enterprise.esm.js +1 -1
  43. package/dist/format-painter.cjs.js +1 -1
  44. package/dist/format-painter.esm.js +172 -151
  45. package/dist/heading.cjs.js +1 -1
  46. package/dist/heading.esm.js +96 -83
  47. package/dist/history.cjs.js +1 -1
  48. package/dist/history.esm.js +176 -97
  49. package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
  50. package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
  51. package/dist/index.cjs.js +1 -1
  52. package/dist/index.esm.js +2 -2
  53. package/dist/katex-Cc3-mvOY.js +257 -0
  54. package/dist/katex-DoRnZ_sp.mjs +11682 -0
  55. package/dist/katex.min--Ws3c9be.mjs +5 -0
  56. package/dist/katex.min-Dk2VscxB.js +2 -0
  57. package/dist/link.cjs.js +3 -3
  58. package/dist/link.esm.js +3 -3
  59. package/dist/list.cjs.js +1 -1
  60. package/dist/list.esm.js +140 -52
  61. package/dist/math.cjs.js +14 -14
  62. package/dist/math.esm.js +149 -136
  63. package/dist/media-manager.cjs.js +46 -46
  64. package/dist/media-manager.esm.js +320 -264
  65. package/dist/mentions.cjs.js +12 -12
  66. package/dist/mentions.esm.js +149 -143
  67. package/dist/merge-tag.cjs.js +5 -3
  68. package/dist/merge-tag.esm.js +5 -3
  69. package/dist/notify-BkbzMopb.js +32 -0
  70. package/dist/notify-zOp-mUOJ.mjs +59 -0
  71. package/dist/pii-redaction.cjs.js +1 -1
  72. package/dist/pii-redaction.esm.js +1 -1
  73. package/dist/preview.cjs.js +1 -1
  74. package/dist/preview.esm.js +1 -1
  75. package/dist/shared-config.cjs.js +1 -1
  76. package/dist/shared-config.esm.js +14 -14
  77. package/dist/slash-commands.cjs.js +5 -5
  78. package/dist/slash-commands.esm.js +259 -236
  79. package/dist/smart-paste.cjs.js +1 -1
  80. package/dist/smart-paste.esm.js +1 -1
  81. package/dist/special-characters.cjs.js +3 -3
  82. package/dist/special-characters.esm.js +3 -3
  83. package/dist/spell-check.cjs.js +9 -9
  84. package/dist/spell-check.esm.js +288 -251
  85. package/dist/table.cjs.js +14 -14
  86. package/dist/table.esm.js +175 -154
  87. package/dist/template.cjs.js +5 -3
  88. package/dist/template.esm.js +15 -13
  89. package/dist/text-color.cjs.js +4 -4
  90. package/dist/text-color.esm.js +38 -34
  91. package/dist/translation-workflow.cjs.js +9 -9
  92. package/dist/translation-workflow.esm.js +98 -95
  93. package/dist/version-diff.cjs.js +4 -4
  94. package/dist/version-diff.esm.js +36 -36
  95. package/package.json +6 -5
  96. package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
  97. package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
  98. package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
  99. package/dist/dialogHelpers-zU6zpMIA.js +0 -12
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const qe=require("./dialogHelpers-zU6zpMIA.js"),L=".rte-content, .editora-content",w='.rte-conditional-block[data-conditional-content="true"]',f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',b=':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)',p=":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)",h=":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)",Ce="rte-conditional-content-styles",c="rte-conditional-dialog-overlay",u="rte-conditional-floating-toolbar",k=new WeakMap,$e=new WeakMap,E=new WeakMap,_=new Map,F=new Map;let le=null,se=0,G=null,U=null,X=null,Y=null,J=null,Q=null,H=null,g=null,ee=null;const Ie={dialogTitleInsert:"Insert Conditional Content",dialogTitleEdit:"Edit Conditional Content",conditionLabel:"Condition",conditionPlaceholder:'user.role == "admin"',audienceLabel:"Audience (comma separated)",audiencePlaceholder:"all",localeLabel:"Locale (comma separated)",localePlaceholder:"all",elseLabel:"Enable Else Block",saveText:"Save",cancelText:"Cancel",blockIfLabel:"IF",blockElseLabel:"ELSE",allAudiencesText:"all audiences",allLocalesText:"all locales"};function y(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function O(e){return e?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function Le(e){return!e||e.length===0?"":e.join(", ")}function te(e){return e?e.map(t=>t.trim()).filter(Boolean):[]}function Ke(e){return{...Ie,...e||{}}}function T(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function ce(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function ue(e){if(!e)return!1;const t=e.getAttribute("data-theme")||e.getAttribute("theme");return t&&t.toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark")}function _e(e){const t=ce(e);if(ue(t))return!0;const o=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ue(o)?!0:ue(document.documentElement)||ue(document.body)}function fe(e){if(!e)return!1;const t=e.getAttribute("data-theme")||e.getAttribute("theme");return t&&t.toLowerCase()==="acme"?!0:e.classList.contains("editora-theme-acme")||e.classList.contains("rte-theme-acme")}function Fe(e){const t=ce(e);if(fe(t))return!0;const o=t.closest("[data-theme], [theme], .editora-theme-acme, .rte-theme-acme");return fe(o)?!0:fe(document.documentElement)||fe(document.body)}function ze(e){return _e(e)?"dark":Fe(e)?"acme":"light"}function he(e,t){const o=ze(t);e.classList.remove("rte-conditional-theme-dark","rte-conditional-theme-acme"),o==="dark"?e.classList.add("rte-conditional-theme-dark"):o==="acme"&&e.classList.add("rte-conditional-theme-acme")}function A(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(L))return n;const a=n.querySelector(L);if(a instanceof HTMLElement)return a}const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0).startContainer,r=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(L);if(r)return r}const i=document.activeElement;if(i){if(i.matches(L))return i;const n=i.closest(L);if(n)return n}return g&&g.isConnected?g:t?document.querySelector(L):null}function Te(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const o=t.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function Ee(e,t){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(t),e.focus({preventScroll:!0}))}function Se(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Be(e,t){if(t===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,e.innerHTML)}catch{}}function pe(e,t){const o=document.createRange();o.selectNodeContents(t),o.collapse(!1),Ee(e,o)}function ye(e,t){if(t)return t.split(".").filter(Boolean).reduce((o,i)=>{if(o!=null&&typeof o=="object")return o[i]},e)}function je(e){const t=e.trim();if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;const o=Number(t);if(!Number.isNaN(o)&&t!=="")return o;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("{")&&t.endsWith("}"))try{return JSON.parse(t)}catch{return t}return t}function Ve(e,t){const o=e.trim();if(!o)return!0;if(o.startsWith("!")){const x=o.slice(1).trim();return!ye(t,x)}const i=o.match(/^([a-zA-Z_$][\w.$]*)\s*(==|!=|>=|<=|>|<|in|contains|~=)\s*(.+)$/);if(!i)return!!ye(t,o);const[,n,a,r]=i,l=ye(t,n),d=je(r);switch(a){case"==":return l==d;case"!=":return l!=d;case">":return Number(l)>Number(d);case"<":return Number(l)<Number(d);case">=":return Number(l)>=Number(d);case"<=":return Number(l)<=Number(d);case"in":return Array.isArray(d)?d.some(x=>x==l):typeof d=="string"?d.split(",").map(x=>x.trim()).includes(String(l)):!1;case"contains":case"~=":return Array.isArray(l)?l.some(x=>String(x).toLowerCase()===String(d).toLowerCase()):typeof l=="string"?l.toLowerCase().includes(String(d).toLowerCase()):!1;default:return!1}}function We(){if(typeof document>"u"||document.getElementById(Ce))return;const e=document.createElement("style");e.id=Ce,e.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const qe=require("./dialogHelpers-BxSQ7A6M.js"),L=".rte-content, .editora-content",w='.rte-conditional-block[data-conditional-content="true"]',f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',b=':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)',p=":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)",h=":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)",Ce="rte-conditional-content-styles",c="rte-conditional-dialog-overlay",u="rte-conditional-floating-toolbar",k=new WeakMap,$e=new WeakMap,E=new WeakMap,_=new Map,F=new Map;let le=null,se=0,G=null,U=null,X=null,Y=null,J=null,Q=null,H=null,g=null,ee=null;const Ie={dialogTitleInsert:"Insert Conditional Content",dialogTitleEdit:"Edit Conditional Content",conditionLabel:"Condition",conditionPlaceholder:'user.role == "admin"',audienceLabel:"Audience (comma separated)",audiencePlaceholder:"all",localeLabel:"Locale (comma separated)",localePlaceholder:"all",elseLabel:"Enable Else Block",saveText:"Save",cancelText:"Cancel",blockIfLabel:"IF",blockElseLabel:"ELSE",allAudiencesText:"all audiences",allLocalesText:"all locales"};function y(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function O(e){return e?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function Le(e){return!e||e.length===0?"":e.join(", ")}function te(e){return e?e.map(t=>t.trim()).filter(Boolean):[]}function Ke(e){return{...Ie,...e||{}}}function T(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function ce(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function ue(e){if(!e)return!1;const t=e.getAttribute("data-theme")||e.getAttribute("theme");return t&&t.toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark")}function _e(e){const t=ce(e);if(ue(t))return!0;const o=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ue(o)?!0:ue(document.documentElement)||ue(document.body)}function fe(e){if(!e)return!1;const t=e.getAttribute("data-theme")||e.getAttribute("theme");return t&&t.toLowerCase()==="acme"?!0:e.classList.contains("editora-theme-acme")||e.classList.contains("rte-theme-acme")}function Fe(e){const t=ce(e);if(fe(t))return!0;const o=t.closest("[data-theme], [theme], .editora-theme-acme, .rte-theme-acme");return fe(o)?!0:fe(document.documentElement)||fe(document.body)}function ze(e){return _e(e)?"dark":Fe(e)?"acme":"light"}function he(e,t){const o=ze(t);e.classList.remove("rte-conditional-theme-dark","rte-conditional-theme-acme"),o==="dark"?e.classList.add("rte-conditional-theme-dark"):o==="acme"&&e.classList.add("rte-conditional-theme-acme")}function A(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(L))return n;const a=n.querySelector(L);if(a instanceof HTMLElement)return a}const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0).startContainer,r=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(L);if(r)return r}const i=document.activeElement;if(i){if(i.matches(L))return i;const n=i.closest(L);if(n)return n}return g&&g.isConnected?g:t?document.querySelector(L):null}function Te(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const o=t.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function Ee(e,t){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(t),e.focus({preventScroll:!0}))}function Se(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Be(e,t){if(t===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,e.innerHTML)}catch{}}function pe(e,t){const o=document.createRange();o.selectNodeContents(t),o.collapse(!1),Ee(e,o)}function ye(e,t){if(t)return t.split(".").filter(Boolean).reduce((o,i)=>{if(o!=null&&typeof o=="object")return o[i]},e)}function je(e){const t=e.trim();if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;const o=Number(t);if(!Number.isNaN(o)&&t!=="")return o;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("{")&&t.endsWith("}"))try{return JSON.parse(t)}catch{return t}return t}function Ve(e,t){const o=e.trim();if(!o)return!0;if(o.startsWith("!")){const x=o.slice(1).trim();return!ye(t,x)}const i=o.match(/^([a-zA-Z_$][\w.$]*)\s*(==|!=|>=|<=|>|<|in|contains|~=)\s*(.+)$/);if(!i)return!!ye(t,o);const[,n,a,r]=i,l=ye(t,n),d=je(r);switch(a){case"==":return l==d;case"!=":return l!=d;case">":return Number(l)>Number(d);case"<":return Number(l)<Number(d);case">=":return Number(l)>=Number(d);case"<=":return Number(l)<=Number(d);case"in":return Array.isArray(d)?d.some(x=>x==l):typeof d=="string"?d.split(",").map(x=>x.trim()).includes(String(l)):!1;case"contains":case"~=":return Array.isArray(l)?l.some(x=>String(x).toLowerCase()===String(d).toLowerCase()):typeof l=="string"?l.toLowerCase().includes(String(d).toLowerCase()):!1;default:return!1}}function We(){if(typeof document>"u"||document.getElementById(Ce))return;const e=document.createElement("style");e.id=Ce,e.textContent=`
2
2
  .rte-conditional-block {
3
3
  border: 1px solid #dbe3ec;
4
4
  border-radius: 8px;
@@ -630,4 +630,4 @@
630
630
  <button type="button" class="rte-conditional-btn" data-action="cancel">${y(a.cancelText)}</button>
631
631
  <button type="button" class="rte-conditional-btn rte-conditional-btn-primary" data-action="save">${y(a.saveText)}</button>
632
632
  </footer>
633
- `,l.appendChild(d),document.body.appendChild(l);const B=d.querySelector(".rte-conditional-input-condition"),z=d.querySelector(".rte-conditional-input-audience"),N=d.querySelector(".rte-conditional-input-locale"),ge=d.querySelector(".rte-conditional-input-else"),M=()=>{l.removeEventListener("click",R),l.removeEventListener("keydown",ae,!0),document.removeEventListener("keydown",de,!0),l.parentNode&&l.parentNode.removeChild(l),le=null,e.focus({preventScroll:!0}),D(e)},de=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),M())},R=s=>{s.target===l&&M()},ie=s=>{if(s.key!=="Tab")return;const q=Array.from(d.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(q.length===0)return;const V=q[0],I=q[q.length-1],re=document.activeElement;if(s.shiftKey&&re===V){s.preventDefault(),I.focus();return}!s.shiftKey&&re===I&&(s.preventDefault(),V.focus())},j=async()=>{const s={condition:B?.value?.trim()||"",audience:O(z?.value),locale:O(N?.value),hasElse:ge?.checked||!1},q=e.innerHTML;if(n)ot(n,s,a),oe(n,k.get(e)===!0);else{Je(e,r);const I=Me(s,a);try{De(e,I)}catch{e.appendChild(I);const re=I.querySelector('.rte-conditional-body[data-slot="if"]');re?pe(e,re):pe(e,I)}}k.get(e)===!0&&await Z(e,t,!0),Se(e),Be(e,q),D(e),M()},ae=s=>{if(s.key==="Escape"){s.preventDefault(),M();return}ie(s),s.key==="Enter"&&!s.shiftKey&&s.target instanceof HTMLInputElement&&(s.preventDefault(),j())};d.addEventListener("click",s=>{const V=s.target.getAttribute("data-action");if(V==="cancel"){M();return}V==="save"&&j()}),l.addEventListener("click",R),l.addEventListener("keydown",ae,!0),document.addEventListener("keydown",de,!0),le={cleanup:M},B?.focus()}function rt(e){const t=e.metaKey||e.ctrlKey,i=(typeof e.key=="string"?e.key:"").toLowerCase(),n=typeof e.code=="string"?e.code.toLowerCase():"",a=t&&e.altKey&&e.shiftKey&&(i==="c"||n==="keyc"),r=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(i==="f9"||n==="f9");return a||r}function lt(e){const t=e.metaKey||e.ctrlKey,i=(typeof e.key=="string"?e.key:"").toLowerCase(),n=typeof e.code=="string"?e.code.toLowerCase():"",a=t&&e.altKey&&e.shiftKey&&(i==="p"||n==="keyp"),r=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(i==="f10"||n==="f10");return a||r}function ct(e){ee=e,U||(U=t=>{const i=t.target?.closest(L);if(!i)return;g=i,E.has(i)||E.set(i,e);const n=E.get(i)||e;ne(i,n.labels),Oe(i,k.get(i)===!0),D(i)},document.addEventListener("focusin",U,!0)),G||(G=t=>{if(document.querySelector(`.${c}`))return;const i=t.target;if(!!i?.closest("input, textarea, select"))return;const r=i?.closest(L)||A(void 0,!1)||g;if(!r||T(r))return;const l=E.get(r)||ee||e,d=document.activeElement,x=i?.closest(".rte-conditional-header")||d?.closest(".rte-conditional-header");if(x&&(t.key==="Enter"||t.key===" ")){const m=x.closest(w);if(m&&r.contains(m)){t.preventDefault(),t.stopPropagation(),C(r,l,"edit",void 0,m);return}}if(rt(t)){t.preventDefault(),t.stopPropagation();const m=W(r);m?C(r,l,"edit",void 0,m):C(r,l,"insert");return}if(lt(t)){t.preventDefault(),t.stopPropagation();const m=k.get(r)!==!0;Z(r,l,m),D(r);return}if((t.key==="Backspace"||t.key==="Delete")&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const m=window.getSelection();if(!m||m.rangeCount===0)return;const v=m.getRangeAt(0);if(!v.collapsed||!r.contains(v.commonAncestorContainer))return;const S=Ge(v.startContainer)?.closest(".rte-conditional-body");if(!S||!r.contains(S))return;if(t.key==="Backspace"&&ke(v,S,"start")){t.preventDefault();return}if(t.key==="Delete"&&ke(v,S,"end")){t.preventDefault();return}}},document.addEventListener("keydown",G,!0)),Y||(Y=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&K(g);return}if(T(i))return;g=i,E.has(i)||E.set(i,e);const n=o.closest(w);if(!n){K(i);return}requestAnimationFrame(()=>{!i.isConnected||!i.contains(n)||me(i,n)})},document.addEventListener("mousedown",Y,!0)),X||(X=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&K(g);return}if(T(i))return;g=i,E.has(i)||E.set(i,e);const n=E.get(i)||e,a=o.closest(w),r=!!o.closest(".rte-conditional-header, .rte-conditional-summary, .rte-conditional-meta, .rte-conditional-else-label");if(a&&r){t.preventDefault(),t.stopPropagation(),C(i,n,"edit",void 0,a),me(i,a);return}a?me(i,a):K(i)},document.addEventListener("click",X,!0)),J||(J=()=>{const t=A(void 0,!1)||g;t&&t.isConnected&&D(t)},document.addEventListener("selectionchange",J)),Q||(Q=t=>{const i=t.target?.closest(L);if(!i)return;const n=E.get(i)||ee||e;ne(i,n.labels),D(i)},document.addEventListener("input",Q,!0)),H||(H=()=>{at()},window.addEventListener("scroll",H,!0),window.addEventListener("resize",H))}function dt(){U&&(document.removeEventListener("focusin",U,!0),U=null),G&&(document.removeEventListener("keydown",G,!0),G=null),X&&(document.removeEventListener("click",X,!0),X=null),Y&&(document.removeEventListener("mousedown",Y,!0),Y=null),J&&(document.removeEventListener("selectionchange",J),J=null),Q&&(document.removeEventListener("input",Q,!0),Q=null),H&&(window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),H=null),_.forEach(e=>{e.remove()}),_.clear(),F.clear(),ee=null,g=null}const st=(e={})=>{const t=Ze(e);return We(),{name:"conditionalContent",toolbar:[{id:"conditionalContentGroup",label:"Conditional Content",type:"group",command:"conditionalContent",items:[{id:"conditionalContent",label:"Conditional Rule",command:"openConditionalDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12a1 1 0 0 1 1 1v3h-2V7H7v3H5V6a1 1 0 0 1 1-1Zm-1 9h2v3h10v-3h2v4a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-4Zm3-2a1 1 0 0 1 1-1h2.6l1.8-2.4a1 1 0 1 1 1.6 1.2L13.8 11H15a1 1 0 1 1 0 2h-2.7l-1.9 2.5a1 1 0 1 1-1.6-1.2L10.1 13H9a1 1 0 0 1-1-1Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-c"},{id:"conditionalPreview",label:"Conditional Preview",command:"toggleConditionalPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6h16a1 1 0 0 1 1 1v3h-2V8H5v8h14v-2h2v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm5 3h2v2H9V9Zm0 4h2v2H9v-2Zm4-4h6v2h-6V9Zm0 4h6v2h-6v-2Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-p"}]}],commands:{conditionalContent:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t),ne(n,t.labels);const a=o?.target;if(a==="insert")return C(n,t,"insert",o),!0;const r=W(n);return a==="edit"||r?!r&&a==="edit"?!1:(C(n,t,"edit",o,r||void 0),!0):(C(n,t,"insert",o),!0)},openConditionalDialog:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t),ne(n,t.labels);const a=o?.target;if(a==="insert")return C(n,t,"insert",o),!0;const r=W(n);return a==="edit"||r?!r&&a==="edit"?!1:(C(n,t,"edit",o,r||void 0),!0):(C(n,t,"insert",o),!0)},conditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,E.set(n,t);const a=typeof o=="boolean"?o:k.get(n)!==!0;return await Z(n,t,a),D(n),!0},editConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t);const a=W(n);return a?(C(n,t,"edit",o,a),!0):!1},deleteConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;const a=W(n);if(!a)return!1;const r=Re(n,a);return r&&D(n),r},insertConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t);const a={condition:o?.condition??t.defaultCondition,audience:o?.audience??t.defaultAudience,locale:o?.locale??t.defaultLocale,hasElse:o?.hasElse??t.enableElseByDefault},r=Me(a,t.labels);return De(n,r),k.get(n)===!0&&Z(n,t,!0),!0},toggleConditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,E.set(n,t);const a=typeof o=="boolean"?o:k.get(n)!==!0;return await Z(n,t,a),!0},setConditionalContext:(o,i)=>{const n=A(i);return n?(g=n,!o||typeof o!="object"?$e.delete(n):$e.set(n,o),k.get(n)===!0&&Z(n,t,!0),!0):!1}},keymap:{"Mod-Alt-Shift-c":"openConditionalDialog","Mod-Alt-Shift-C":"openConditionalDialog","Mod-Alt-Shift-p":"toggleConditionalPreview","Mod-Alt-Shift-P":"toggleConditionalPreview",F9:"openConditionalDialog",F10:"toggleConditionalPreview"},init:()=>{se+=1,ct(t)},destroy:()=>{se=Math.max(0,se-1),se===0&&(Ne(),dt())}}};exports.ConditionalContentPlugin=st;
633
+ `,l.appendChild(d),document.body.appendChild(l);const B=d.querySelector(".rte-conditional-input-condition"),z=d.querySelector(".rte-conditional-input-audience"),N=d.querySelector(".rte-conditional-input-locale"),ge=d.querySelector(".rte-conditional-input-else"),M=()=>{l.removeEventListener("click",R),l.removeEventListener("keydown",ae,!0),document.removeEventListener("keydown",de,!0),l.parentNode&&l.parentNode.removeChild(l),le=null,e.focus({preventScroll:!0}),D(e)},de=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),M())},R=s=>{s.target===l&&M()},ie=s=>{if(s.key!=="Tab"||s.defaultPrevented)return;const q=Array.from(d.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(q.length===0)return;const V=q[0],I=q[q.length-1],re=document.activeElement;if(s.shiftKey&&re===V){s.preventDefault(),I.focus();return}!s.shiftKey&&re===I&&(s.preventDefault(),V.focus())},j=async()=>{const s={condition:B?.value?.trim()||"",audience:O(z?.value),locale:O(N?.value),hasElse:ge?.checked||!1},q=e.innerHTML;if(n)ot(n,s,a),oe(n,k.get(e)===!0);else{Je(e,r);const I=Me(s,a);try{De(e,I)}catch{e.appendChild(I);const re=I.querySelector('.rte-conditional-body[data-slot="if"]');re?pe(e,re):pe(e,I)}}k.get(e)===!0&&await Z(e,t,!0),Se(e),Be(e,q),D(e),M()},ae=s=>{if(s.key==="Escape"){s.preventDefault(),M();return}ie(s),s.key==="Enter"&&!s.shiftKey&&s.target instanceof HTMLInputElement&&(s.preventDefault(),j())};d.addEventListener("click",s=>{const V=s.target.getAttribute("data-action");if(V==="cancel"){M();return}V==="save"&&j()}),l.addEventListener("click",R),l.addEventListener("keydown",ae,!0),document.addEventListener("keydown",de,!0),le={cleanup:M},B?.focus()}function rt(e){const t=e.metaKey||e.ctrlKey,i=(typeof e.key=="string"?e.key:"").toLowerCase(),n=typeof e.code=="string"?e.code.toLowerCase():"",a=t&&e.altKey&&e.shiftKey&&(i==="c"||n==="keyc"),r=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(i==="f9"||n==="f9");return a||r}function lt(e){const t=e.metaKey||e.ctrlKey,i=(typeof e.key=="string"?e.key:"").toLowerCase(),n=typeof e.code=="string"?e.code.toLowerCase():"",a=t&&e.altKey&&e.shiftKey&&(i==="p"||n==="keyp"),r=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(i==="f10"||n==="f10");return a||r}function ct(e){ee=e,U||(U=t=>{const i=t.target?.closest(L);if(!i)return;g=i,E.has(i)||E.set(i,e);const n=E.get(i)||e;ne(i,n.labels),Oe(i,k.get(i)===!0),D(i)},document.addEventListener("focusin",U,!0)),G||(G=t=>{if(document.querySelector(`.${c}`))return;const i=t.target;if(!!i?.closest("input, textarea, select"))return;const r=i?.closest(L)||A(void 0,!1)||g;if(!r||T(r))return;const l=E.get(r)||ee||e,d=document.activeElement,x=i?.closest(".rte-conditional-header")||d?.closest(".rte-conditional-header");if(x&&(t.key==="Enter"||t.key===" ")){const m=x.closest(w);if(m&&r.contains(m)){t.preventDefault(),t.stopPropagation(),C(r,l,"edit",void 0,m);return}}if(rt(t)){t.preventDefault(),t.stopPropagation();const m=W(r);m?C(r,l,"edit",void 0,m):C(r,l,"insert");return}if(lt(t)){t.preventDefault(),t.stopPropagation();const m=k.get(r)!==!0;Z(r,l,m),D(r);return}if((t.key==="Backspace"||t.key==="Delete")&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const m=window.getSelection();if(!m||m.rangeCount===0)return;const v=m.getRangeAt(0);if(!v.collapsed||!r.contains(v.commonAncestorContainer))return;const S=Ge(v.startContainer)?.closest(".rte-conditional-body");if(!S||!r.contains(S))return;if(t.key==="Backspace"&&ke(v,S,"start")){t.preventDefault();return}if(t.key==="Delete"&&ke(v,S,"end")){t.preventDefault();return}}},document.addEventListener("keydown",G,!0)),Y||(Y=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&K(g);return}if(T(i))return;g=i,E.has(i)||E.set(i,e);const n=o.closest(w);if(!n){K(i);return}requestAnimationFrame(()=>{!i.isConnected||!i.contains(n)||me(i,n)})},document.addEventListener("mousedown",Y,!0)),X||(X=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&K(g);return}if(T(i))return;g=i,E.has(i)||E.set(i,e);const n=E.get(i)||e,a=o.closest(w),r=!!o.closest(".rte-conditional-header, .rte-conditional-summary, .rte-conditional-meta, .rte-conditional-else-label");if(a&&r){t.preventDefault(),t.stopPropagation(),C(i,n,"edit",void 0,a),me(i,a);return}a?me(i,a):K(i)},document.addEventListener("click",X,!0)),J||(J=()=>{const t=A(void 0,!1)||g;t&&t.isConnected&&D(t)},document.addEventListener("selectionchange",J)),Q||(Q=t=>{const i=t.target?.closest(L);if(!i)return;const n=E.get(i)||ee||e;ne(i,n.labels),D(i)},document.addEventListener("input",Q,!0)),H||(H=()=>{at()},window.addEventListener("scroll",H,!0),window.addEventListener("resize",H))}function dt(){U&&(document.removeEventListener("focusin",U,!0),U=null),G&&(document.removeEventListener("keydown",G,!0),G=null),X&&(document.removeEventListener("click",X,!0),X=null),Y&&(document.removeEventListener("mousedown",Y,!0),Y=null),J&&(document.removeEventListener("selectionchange",J),J=null),Q&&(document.removeEventListener("input",Q,!0),Q=null),H&&(window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),H=null),_.forEach(e=>{e.remove()}),_.clear(),F.clear(),ee=null,g=null}const st=(e={})=>{const t=Ze(e);return We(),{name:"conditionalContent",toolbar:[{id:"conditionalContentGroup",label:"Conditional Content",type:"group",command:"conditionalContent",items:[{id:"conditionalContent",label:"Conditional Rule",command:"openConditionalDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12a1 1 0 0 1 1 1v3h-2V7H7v3H5V6a1 1 0 0 1 1-1Zm-1 9h2v3h10v-3h2v4a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-4Zm3-2a1 1 0 0 1 1-1h2.6l1.8-2.4a1 1 0 1 1 1.6 1.2L13.8 11H15a1 1 0 1 1 0 2h-2.7l-1.9 2.5a1 1 0 1 1-1.6-1.2L10.1 13H9a1 1 0 0 1-1-1Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-c"},{id:"conditionalPreview",label:"Conditional Preview",command:"toggleConditionalPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6h16a1 1 0 0 1 1 1v3h-2V8H5v8h14v-2h2v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm5 3h2v2H9V9Zm0 4h2v2H9v-2Zm4-4h6v2h-6V9Zm0 4h6v2h-6v-2Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-p"}]}],commands:{conditionalContent:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t),ne(n,t.labels);const a=o?.target;if(a==="insert")return C(n,t,"insert",o),!0;const r=W(n);return a==="edit"||r?!r&&a==="edit"?!1:(C(n,t,"edit",o,r||void 0),!0):(C(n,t,"insert",o),!0)},openConditionalDialog:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t),ne(n,t.labels);const a=o?.target;if(a==="insert")return C(n,t,"insert",o),!0;const r=W(n);return a==="edit"||r?!r&&a==="edit"?!1:(C(n,t,"edit",o,r||void 0),!0):(C(n,t,"insert",o),!0)},conditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,E.set(n,t);const a=typeof o=="boolean"?o:k.get(n)!==!0;return await Z(n,t,a),D(n),!0},editConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t);const a=W(n);return a?(C(n,t,"edit",o,a),!0):!1},deleteConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;const a=W(n);if(!a)return!1;const r=Re(n,a);return r&&D(n),r},insertConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t);const a={condition:o?.condition??t.defaultCondition,audience:o?.audience??t.defaultAudience,locale:o?.locale??t.defaultLocale,hasElse:o?.hasElse??t.enableElseByDefault},r=Me(a,t.labels);return De(n,r),k.get(n)===!0&&Z(n,t,!0),!0},toggleConditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,E.set(n,t);const a=typeof o=="boolean"?o:k.get(n)!==!0;return await Z(n,t,a),!0},setConditionalContext:(o,i)=>{const n=A(i);return n?(g=n,!o||typeof o!="object"?$e.delete(n):$e.set(n,o),k.get(n)===!0&&Z(n,t,!0),!0):!1}},keymap:{"Mod-Alt-Shift-c":"openConditionalDialog","Mod-Alt-Shift-C":"openConditionalDialog","Mod-Alt-Shift-p":"toggleConditionalPreview","Mod-Alt-Shift-P":"toggleConditionalPreview",F9:"openConditionalDialog",F10:"toggleConditionalPreview"},init:()=>{se+=1,ct(t)},destroy:()=>{se=Math.max(0,se-1),se===0&&(Ne(),dt())}}};exports.ConditionalContentPlugin=st;
@@ -1,4 +1,4 @@
1
- import { i as qe } from "./dialogHelpers-5d5BuOCW.mjs";
1
+ import { i as qe } from "./dialogHelpers-BbwpIXD9.mjs";
2
2
  const L = ".rte-content, .editora-content", w = '.rte-conditional-block[data-conditional-content="true"]', f = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', b = ':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)', p = ":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)", h = ":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)", Ce = "rte-conditional-content-styles", c = "rte-conditional-dialog-overlay", u = "rte-conditional-floating-toolbar", k = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
3
3
  let le = null, se = 0, G = null, U = null, X = null, Y = null, J = null, Q = null, M = null, g = null, ee = null;
4
4
  const Ie = {
@@ -1138,7 +1138,7 @@ function C(e, t, o, i, n) {
1138
1138
  }, P = (s) => {
1139
1139
  s.target === l && H();
1140
1140
  }, ie = (s) => {
1141
- if (s.key !== "Tab") return;
1141
+ if (s.key !== "Tab" || s.defaultPrevented) return;
1142
1142
  const q = Array.from(
1143
1143
  d.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')
1144
1144
  );
@@ -0,0 +1,106 @@
1
+ import { e as l } from "./escapeHtml-DyksyvcZ.mjs";
2
+ import { i as p } from "./dialogHelpers-BbwpIXD9.mjs";
3
+ const u = "rte-confirm-styles", x = '[data-theme="dark"], .dark, .editora-theme-dark';
4
+ let g = 0;
5
+ function v() {
6
+ if (document.getElementById(u)) return;
7
+ const o = document.createElement("style");
8
+ o.id = u, o.textContent = `
9
+ .rte-confirm-overlay {
10
+ position: fixed; inset: 0; z-index: 100002; display: flex; align-items: center; justify-content: center;
11
+ padding: 16px; background: rgba(15, 23, 36, 0.56);
12
+ --rte-confirm-bg: #ffffff; --rte-confirm-text: #101828; --rte-confirm-muted: #5f6b7d; --rte-confirm-border: #d6dbe4;
13
+ --rte-confirm-accent: #1f75fe; --rte-confirm-danger: #c62828;
14
+ }
15
+ .rte-confirm-overlay.rte-confirm-dark {
16
+ --rte-confirm-bg: #1f2937; --rte-confirm-text: #e5e7eb; --rte-confirm-muted: #9ca3af; --rte-confirm-border: #3b4657;
17
+ --rte-confirm-accent: #3b82f6; --rte-confirm-danger: #ef4444;
18
+ }
19
+ .rte-confirm-dialog {
20
+ box-sizing: border-box; width: min(100%, 420px); padding: 20px; border-radius: 10px;
21
+ background: var(--rte-confirm-bg); color: var(--rte-confirm-text); border: 1px solid var(--rte-confirm-border);
22
+ box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35); font-size: 14px; line-height: 1.45;
23
+ }
24
+ .rte-confirm-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
25
+ .rte-confirm-message { margin: 0 0 14px; color: var(--rte-confirm-muted); }
26
+ .rte-confirm-field { display: block; margin: 0 0 6px; }
27
+ .rte-confirm-input {
28
+ box-sizing: border-box; width: 100%; padding: 8px 10px; border-radius: 6px; font: inherit;
29
+ border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
30
+ }
31
+ .rte-confirm-input[aria-invalid="true"] { border-color: var(--rte-confirm-danger); }
32
+ .rte-confirm-error { margin: 6px 0 0; color: var(--rte-confirm-danger); font-size: 13px; }
33
+ .rte-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
34
+ .rte-confirm-button {
35
+ padding: 8px 14px; border-radius: 6px; font: inherit; cursor: pointer;
36
+ border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
37
+ }
38
+ .rte-confirm-button.primary { background: var(--rte-confirm-accent); border-color: var(--rte-confirm-accent); color: #fff; }
39
+ .rte-confirm-button.danger { background: var(--rte-confirm-danger); border-color: var(--rte-confirm-danger); color: #fff; }
40
+ .rte-confirm-button:focus-visible, .rte-confirm-input:focus-visible { outline: 2px solid var(--rte-confirm-accent); outline-offset: 2px; }
41
+ `, document.head.appendChild(o);
42
+ }
43
+ function m(o, t, r) {
44
+ v();
45
+ const e = `rte-confirm-${++g}`, c = document.createElement("div");
46
+ p(c), c.className = "rte-confirm-overlay", (t.context ?? (document.activeElement instanceof Element ? document.activeElement : null))?.closest(x) && c.classList.add("rte-confirm-dark");
47
+ const f = t.title ?? (r ? "Enter a value" : "Please confirm"), a = t.confirmText ?? (r ? "OK" : "Confirm"), d = t.cancelText ?? "Cancel", i = t.danger === !0, n = document.createElement("div");
48
+ return n.className = "rte-confirm-dialog", n.setAttribute("role", r ? "dialog" : "alertdialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-labelledby", `${e}-title`), n.setAttribute("aria-describedby", `${e}-message`), n.innerHTML = `
49
+ <h2 class="rte-confirm-title" id="${e}-title">${l(f)}</h2>
50
+ <p class="rte-confirm-message" id="${e}-message">${l(o)}</p>
51
+ ${r ? `<label class="rte-confirm-field" for="${e}-input">${l(r.label ?? o)}</label>
52
+ <input class="rte-confirm-input" id="${e}-input" type="text" inputmode="${r.inputMode ?? "text"}"
53
+ autocomplete="off" value="${l(r.initialValue ?? "")}" placeholder="${l(r.placeholder ?? "")}"
54
+ aria-describedby="${e}-error">
55
+ <p class="rte-confirm-error" id="${e}-error" role="alert" hidden></p>` : ""}
56
+ <div class="rte-confirm-actions">
57
+ <button type="button" class="rte-confirm-button" data-action="cancel">${l(d)}</button>
58
+ <button type="button" class="rte-confirm-button ${i ? "danger" : "primary"}" data-action="confirm">${l(a)}</button>
59
+ </div>
60
+ `, c.appendChild(n), {
61
+ overlay: c,
62
+ confirmButton: n.querySelector('[data-action="confirm"]'),
63
+ cancelButton: n.querySelector('[data-action="cancel"]'),
64
+ input: n.querySelector("input"),
65
+ error: n.querySelector(".rte-confirm-error")
66
+ };
67
+ }
68
+ function b(o, t) {
69
+ return new Promise((r) => {
70
+ const { overlay: e, confirmButton: c, cancelButton: s } = o;
71
+ let f = !1;
72
+ const a = (i) => {
73
+ const n = t(i);
74
+ n !== void 0 && (f || (f = !0, window.removeEventListener("keydown", d, !0), e.remove(), r(n)));
75
+ }, d = (i) => {
76
+ i.key !== "Escape" || !e.isConnected || (i.preventDefault(), i.stopPropagation(), a(!1));
77
+ };
78
+ window.addEventListener("keydown", d, !0), s.addEventListener("click", () => a(!1)), c.addEventListener("click", () => a(!0)), e.addEventListener("click", (i) => {
79
+ i.target === e && a(!1);
80
+ }), o.input?.addEventListener("keydown", (i) => {
81
+ i.key === "Enter" && (i.preventDefault(), a(!0));
82
+ }), document.body.appendChild(e);
83
+ });
84
+ }
85
+ function k(o, t = {}) {
86
+ const r = m(o, t, null);
87
+ return b(r, (e) => e);
88
+ }
89
+ function E(o, t = {}) {
90
+ const r = m(o, t, t), { input: e, error: c } = r, s = b(r, (f) => {
91
+ if (!f) return null;
92
+ const a = e?.value ?? "", d = t.validate ? t.validate(a) : null;
93
+ if (d) {
94
+ c && (c.textContent = d, c.hidden = !1), e?.setAttribute("aria-invalid", "true"), e?.focus(), e?.select();
95
+ return;
96
+ }
97
+ return a;
98
+ });
99
+ return window.setTimeout(() => {
100
+ e?.isConnected && (e.focus(), e.select());
101
+ }, 10), s;
102
+ }
103
+ export {
104
+ k as c,
105
+ E as p
106
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";const d=require("./escapeHtml-D2Zh82pD.js"),b=require("./dialogHelpers-BxSQ7A6M.js"),u="rte-confirm-styles",x='[data-theme="dark"], .dark, .editora-theme-dark';let g=0;function v(){if(document.getElementById(u))return;const o=document.createElement("style");o.id=u,o.textContent=`
2
+ .rte-confirm-overlay {
3
+ position: fixed; inset: 0; z-index: 100002; display: flex; align-items: center; justify-content: center;
4
+ padding: 16px; background: rgba(15, 23, 36, 0.56);
5
+ --rte-confirm-bg: #ffffff; --rte-confirm-text: #101828; --rte-confirm-muted: #5f6b7d; --rte-confirm-border: #d6dbe4;
6
+ --rte-confirm-accent: #1f75fe; --rte-confirm-danger: #c62828;
7
+ }
8
+ .rte-confirm-overlay.rte-confirm-dark {
9
+ --rte-confirm-bg: #1f2937; --rte-confirm-text: #e5e7eb; --rte-confirm-muted: #9ca3af; --rte-confirm-border: #3b4657;
10
+ --rte-confirm-accent: #3b82f6; --rte-confirm-danger: #ef4444;
11
+ }
12
+ .rte-confirm-dialog {
13
+ box-sizing: border-box; width: min(100%, 420px); padding: 20px; border-radius: 10px;
14
+ background: var(--rte-confirm-bg); color: var(--rte-confirm-text); border: 1px solid var(--rte-confirm-border);
15
+ box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35); font-size: 14px; line-height: 1.45;
16
+ }
17
+ .rte-confirm-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
18
+ .rte-confirm-message { margin: 0 0 14px; color: var(--rte-confirm-muted); }
19
+ .rte-confirm-field { display: block; margin: 0 0 6px; }
20
+ .rte-confirm-input {
21
+ box-sizing: border-box; width: 100%; padding: 8px 10px; border-radius: 6px; font: inherit;
22
+ border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
23
+ }
24
+ .rte-confirm-input[aria-invalid="true"] { border-color: var(--rte-confirm-danger); }
25
+ .rte-confirm-error { margin: 6px 0 0; color: var(--rte-confirm-danger); font-size: 13px; }
26
+ .rte-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
27
+ .rte-confirm-button {
28
+ padding: 8px 14px; border-radius: 6px; font: inherit; cursor: pointer;
29
+ border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
30
+ }
31
+ .rte-confirm-button.primary { background: var(--rte-confirm-accent); border-color: var(--rte-confirm-accent); color: #fff; }
32
+ .rte-confirm-button.danger { background: var(--rte-confirm-danger); border-color: var(--rte-confirm-danger); color: #fff; }
33
+ .rte-confirm-button:focus-visible, .rte-confirm-input:focus-visible { outline: 2px solid var(--rte-confirm-accent); outline-offset: 2px; }
34
+ `,document.head.appendChild(o)}function m(o,r,t){v();const e=`rte-confirm-${++g}`,c=document.createElement("div");b.initDialogOverlay(c),c.className="rte-confirm-overlay",(r.context??(document.activeElement instanceof Element?document.activeElement:null))?.closest(x)&&c.classList.add("rte-confirm-dark");const f=r.title??(t?"Enter a value":"Please confirm"),a=r.confirmText??(t?"OK":"Confirm"),l=r.cancelText??"Cancel",i=r.danger===!0,n=document.createElement("div");return n.className="rte-confirm-dialog",n.setAttribute("role",t?"dialog":"alertdialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-labelledby",`${e}-title`),n.setAttribute("aria-describedby",`${e}-message`),n.innerHTML=`
35
+ <h2 class="rte-confirm-title" id="${e}-title">${d.escapeHtml(f)}</h2>
36
+ <p class="rte-confirm-message" id="${e}-message">${d.escapeHtml(o)}</p>
37
+ ${t?`<label class="rte-confirm-field" for="${e}-input">${d.escapeHtml(t.label??o)}</label>
38
+ <input class="rte-confirm-input" id="${e}-input" type="text" inputmode="${t.inputMode??"text"}"
39
+ autocomplete="off" value="${d.escapeHtml(t.initialValue??"")}" placeholder="${d.escapeHtml(t.placeholder??"")}"
40
+ aria-describedby="${e}-error">
41
+ <p class="rte-confirm-error" id="${e}-error" role="alert" hidden></p>`:""}
42
+ <div class="rte-confirm-actions">
43
+ <button type="button" class="rte-confirm-button" data-action="cancel">${d.escapeHtml(l)}</button>
44
+ <button type="button" class="rte-confirm-button ${i?"danger":"primary"}" data-action="confirm">${d.escapeHtml(a)}</button>
45
+ </div>
46
+ `,c.appendChild(n),{overlay:c,confirmButton:n.querySelector('[data-action="confirm"]'),cancelButton:n.querySelector('[data-action="cancel"]'),input:n.querySelector("input"),error:n.querySelector(".rte-confirm-error")}}function p(o,r){return new Promise(t=>{const{overlay:e,confirmButton:c,cancelButton:s}=o;let f=!1;const a=i=>{const n=r(i);n!==void 0&&(f||(f=!0,window.removeEventListener("keydown",l,!0),e.remove(),t(n)))},l=i=>{i.key!=="Escape"||!e.isConnected||(i.preventDefault(),i.stopPropagation(),a(!1))};window.addEventListener("keydown",l,!0),s.addEventListener("click",()=>a(!1)),c.addEventListener("click",()=>a(!0)),e.addEventListener("click",i=>{i.target===e&&a(!1)}),o.input?.addEventListener("keydown",i=>{i.key==="Enter"&&(i.preventDefault(),a(!0))}),document.body.appendChild(e)})}function y(o,r={}){const t=m(o,r,null);return p(t,e=>e)}function h(o,r={}){const t=m(o,r,r),{input:e,error:c}=t,s=p(t,f=>{if(!f)return null;const a=e?.value??"",l=r.validate?r.validate(a):null;if(l){c&&(c.textContent=l,c.hidden=!1),e?.setAttribute("aria-invalid","true"),e?.focus(),e?.select();return}return a});return window.setTimeout(()=>{e?.isConnected&&(e.focus(),e.select())},10),s}exports.confirmAction=y;exports.promptText=h;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",se="__editoraCommandEditorRoot",le="rte-content-rules-styles",f="rte-content-rules-panel",P=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',pe={panelTitle:"Content Rules",panelAriaLabel:"Content rules panel",runAuditText:"Run Audit",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No rule violations detected.",summaryPrefix:"Issues",locateText:"Locate",bannedWordMessage:"Banned word found",requiredHeadingMessage:"Missing required heading",sentenceLengthMessage:"Sentence is too long",readabilityMessage:"Readability score is below threshold"},d=new WeakMap,C=new WeakMap,fe=new WeakMap,T=new WeakMap,V=new WeakMap,ae=new WeakMap,Y=new WeakMap,h=new Map,B=new WeakMap,z=new Set;let N=0,xe=0,E=null,g=null,L=null,I=null,H=null,S=null;function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ye(e){return{...pe,...e||{}}}function we(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ie(e){if(!e)return[];const t=new Set;return e.forEach(n=>{const o=n.trim();o&&t.add(o)}),Array.from(t)}function j(e={}){return{bannedWords:ie(e.bannedWords),requiredHeadings:ie(e.requiredHeadings),maxSentenceWords:Math.max(8,Number(e.maxSentenceWords??32)),minReadabilityScore:Math.max(0,Math.min(120,Number(e.minReadabilityScore??55))),maxIssues:Math.max(1,Number(e.maxIssues??100)),debounceMs:Math.max(50,Number(e.debounceMs??220)),enableRealtime:e.enableRealtime!==!1,labels:ye(e.labels),normalizeText:e.normalizeText||we,customRules:Array.isArray(e.customRules)?e.customRules:[]}}function X(e){return e.closest(ee)||e}function F(e){if(!e)return null;if(e.matches(R))return e;const t=e.querySelector(R);return t instanceof HTMLElement?t:null}function ke(){if(typeof window>"u")return null;const e=window[se];if(!(e instanceof HTMLElement))return null;window[se]=null;const t=F(e);if(t)return t;const n=e.closest(ee);if(n){const o=F(n);if(o)return o}return null}function Re(e){const t=e.closest("[data-editora-editor]");if(t&&F(t)===e)return t;let n=e;for(;n;){if(n.matches(ee)&&(n===e||F(n)===e))return n;n=n.parentElement}return X(e)}function K(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Ee(e){const t=X(e);if(K(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return K(n)?!0:K(document.documentElement)||K(document.body)}function G(e,t){e.classList.remove("rte-content-rules-theme-dark"),Ee(t)&&e.classList.add("rte-content-rules-theme-dark")}function ve(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function $(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=e.editorElement;if(s.matches(R))return s;const i=s.querySelector(R);if(i instanceof HTMLElement)return i}const n=ke();if(n)return n;const o=window.getSelection();if(o&&o.rangeCount>0){const s=o.getRangeAt(0).startContainer,l=ve(s)?.closest(R);if(l)return l}const r=document.activeElement;if(r){if(r.matches(R))return r;const s=r.closest(R);if(s)return s}return g&&g.isConnected?g:(g&&!g.isConnected&&(g=null),t?document.querySelector(R):null)}function Z(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function Ce(e,t){const n=e.innerText||e.textContent||"";return t(n)}function Me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ue(e){const t=e.match(/\b[\w'-]+\b/g);return t?t.length:0}function ge(e){const t=e.match(/[^.!?]+[.!?]*/g);return t?t.map(n=>n.trim()).filter(Boolean).length:0}function $e(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(t.length<=3)return 1;const n=t.match(/[aeiouy]+/g);let o=n?n.length:1;return t.endsWith("e")&&(o-=1),Math.max(1,o)}function Se(e){const t=e.match(/\b[\w'-]+\b/g)||[],n=t.length;if(n===0)return 100;const o=Math.max(1,ge(e)),r=t.reduce((i,l)=>i+$e(l),0),s=206.835-1.015*(n/o)-84.6*(r/Math.max(1,n));return Number.isFinite(s)?Math.max(0,Math.min(120,s)):0}function _(e,t){return`${e}-${t}`}function x(e,t){return e.length>=t}function q(e,t,n){x(e,n)||e.push(t)}function me(e,t=140){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function Te(e,t,n,o){return{id:e.id||_(t,o),ruleId:e.ruleId||t,severity:e.severity||n,message:e.message||t,excerpt:e.excerpt?me(e.excerpt,220):void 0,suggestion:e.suggestion,locateText:e.locateText,selector:e.selector}}function Ae(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),o=new Set;return n.forEach(r=>{const s=t(r.textContent||"").toLowerCase();s&&o.add(s)}),o}function Le(e){const t=e.match(/[^.!?\n]+[.!?]?/g);return t?t.map(n=>n.trim()).filter(Boolean):[]}async function v(e,t,n=!1){const o=Ce(e,t.normalizeText),r=e.innerHTML,s=`${o.length}:${ce(o)}:${r.length}:${ce(r)}`;if(!n&&ae.get(e)===s)return C.get(e)||[];const i=(Y.get(e)||0)+1;Y.set(e,i);const l=ue(o),c=ge(o),u=Se(o),a=[],y=t.labels;if(t.bannedWords.length>0){let w=0;for(const p of t.bannedWords){const m=new RegExp(`\\b${Me(p)}\\b`,"gi");let b=m.exec(o);for(;b&&!x(a,t.maxIssues);){const oe=b[0];q(a,{id:_("banned-word",w),ruleId:"banned-word",severity:"error",message:`${y.bannedWordMessage}: "${oe}"`,locateText:oe,suggestion:"Replace or remove banned terms."},t.maxIssues),w+=1,b=m.exec(o)}if(x(a,t.maxIssues))break}}if(!x(a,t.maxIssues)&&t.requiredHeadings.length>0){const w=Ae(e,t.normalizeText);let p=0;t.requiredHeadings.forEach(m=>{if(x(a,t.maxIssues))return;const b=t.normalizeText(m).toLowerCase();!b||w.has(b)||(q(a,{id:_("required-heading",p),ruleId:"required-heading",severity:"warning",message:`${y.requiredHeadingMessage}: "${m}"`,suggestion:`Add a heading named "${m}".`},t.maxIssues),p+=1)})}if(!x(a,t.maxIssues)){const w=Le(o);let p=0;for(const m of w){if(x(a,t.maxIssues))break;const b=ue(m);b<=t.maxSentenceWords||(q(a,{id:_("sentence-length",p),ruleId:"sentence-length",severity:"warning",message:`${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,excerpt:me(m,200),locateText:m.slice(0,64),suggestion:"Split into shorter sentences for readability."},t.maxIssues),p+=1)}}if(!x(a,t.maxIssues)&&l>0&&u<t.minReadabilityScore&&q(a,{id:_("readability",0),ruleId:"readability",severity:"info",message:`${y.readabilityMessage}: ${u.toFixed(1)} < ${t.minReadabilityScore}`,suggestion:"Use shorter sentences and simpler wording."},t.maxIssues),!x(a,t.maxIssues)&&t.customRules.length>0){const w={editor:e,editorRoot:X(e),text:o,html:r,wordCount:l,sentenceCount:c,readabilityScore:u};for(const p of t.customRules){if(x(a,t.maxIssues))break;try{const m=await p.evaluate(w);if(!Array.isArray(m))continue;for(let b=0;b<m.length&&!x(a,t.maxIssues);b+=1)q(a,Te(m[b],p.id,p.severity||"warning",b),t.maxIssues)}catch{}}}if(Y.get(e)!==i)return C.get(e)||[];const D={readabilityScore:u,wordCount:l,sentenceCount:c};return ae.set(e,s),C.set(e,a),fe.set(e,D),te(e),e.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:a,metrics:D}})),a}function Ie(e){return e.reduce((t,n)=>(t[n.severity]+=1,t),{error:0,warning:0,info:0})}function He(e){return e==="error"?"Error":e==="warning"?"Warning":"Info"}function M(e,t,n){const o=Re(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(s=>{s.classList.toggle("active",n),s.setAttribute("data-active",n?"true":"false"),s.setAttribute("aria-pressed",n?"true":"false")})}function U(e){return B.get(e)===!0}function J(e,t){if(!t.classList.contains("show"))return;const o=X(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360);t.style.width=`${r}px`,t.style.maxHeight=`${Math.max(220,window.innerHeight-24)}px`;const s=Math.max(10,o.right-r),i=Math.max(10,window.innerWidth-r-10),l=Math.min(s,i),c=Math.max(10,Math.min(window.innerHeight-10-240,o.top+10));t.style.left=`${l}px`,t.style.top=`${c}px`}function de(e,t){const n=t.trim().toLowerCase();if(!n)return!1;const o=window.getSelection();if(!o)return!1;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s=r.nextNode();for(;s;){const l=s.data.toLowerCase().indexOf(n);if(l!==-1){const c=document.createRange();c.setStart(s,l),c.setEnd(s,Math.min(s.length,l+n.length)),o.removeAllRanges(),o.addRange(c);const u=s.parentElement;return u&&u.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0}s=r.nextNode()}return!1}function Oe(e,t){if(t.selector){const n=e.querySelector(t.selector);if(n)return n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0}),!0}return!!(t.locateText&&de(e,t.locateText)||t.excerpt&&de(e,t.excerpt.slice(0,64)))}function We(e,t){return(C.get(e)||[]).find(o=>o.id===t)}function A(e,t){const n=T.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function W(e,t,n){const o=t.querySelector('[data-action="toggle-realtime"]');if(!o)return;const r=A(e,n);o.textContent=r?n.labels.realtimeOnText:n.labels.realtimeOffText,o.setAttribute("aria-pressed",r?"true":"false"),M(e,"toggleContentRulesRealtime",r)}function te(e){const t=h.get(e);if(!t)return;const n=d.get(e)||E;if(!n)return;const o=C.get(e)||[],r=fe.get(e)||{readabilityScore:100},s=t.querySelector(".rte-content-rules-count"),i=t.querySelector(".rte-content-rules-summary"),l=t.querySelector(".rte-content-rules-list"),c=t.querySelector(".rte-content-rules-live");if(!s||!i||!l||!c)return;const u=Ie(o);if(s.textContent=String(o.length),i.textContent=`${n.labels.summaryPrefix}: ${o.length} | Error ${u.error} | Warning ${u.warning} | Info ${u.info} | Readability ${r.readabilityScore.toFixed(1)}`,c.textContent=`${o.length} issues. ${u.error} errors, ${u.warning} warnings, ${u.info} info.`,o.length===0){l.innerHTML=`<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;return}l.innerHTML=o.map(a=>{const y=a.excerpt?`<p class="rte-content-rules-excerpt">${k(a.excerpt)}</p>`:"",D=a.suggestion?`<p class="rte-content-rules-suggestion">${k(a.suggestion)}</p>`:"",w=`${n.labels.locateText}: ${a.message}`;return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",se="__editoraCommandEditorRoot",le="rte-content-rules-styles",f="rte-content-rules-panel",P=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',xe={panelTitle:"Content Rules",panelAriaLabel:"Content rules panel",runAuditText:"Run Audit",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No rule violations detected.",summaryPrefix:"Issues",locateText:"Locate",bannedWordMessage:"Banned word found",requiredHeadingMessage:"Missing required heading",sentenceLengthMessage:"Sentence is too long",readabilityMessage:"Readability score is below threshold"},d=new WeakMap,C=new WeakMap,ge=new WeakMap,T=new WeakMap,V=new WeakMap,ae=new WeakMap,Y=new WeakMap,h=new Map,B=new WeakMap,z=new Set;let N=0,ye=0,E=null,g=null,L=null,I=null,H=null,S=null;function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function we(e){return{...xe,...e||{}}}function ke(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ie(e){if(!e)return[];const t=new Set;return e.forEach(n=>{const o=n.trim();o&&t.add(o)}),Array.from(t)}function j(e={}){return{bannedWords:ie(e.bannedWords),requiredHeadings:ie(e.requiredHeadings),maxSentenceWords:Math.max(8,Number(e.maxSentenceWords??32)),minReadabilityScore:Math.max(0,Math.min(120,Number(e.minReadabilityScore??55))),maxIssues:Math.max(1,Number(e.maxIssues??100)),debounceMs:Math.max(50,Number(e.debounceMs??220)),enableRealtime:e.enableRealtime!==!1,labels:we(e.labels),normalizeText:e.normalizeText||ke,customRules:Array.isArray(e.customRules)?e.customRules:[]}}function X(e){return e.closest(ee)||e}function F(e){if(!e)return null;if(e.matches(R))return e;const t=e.querySelector(R);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[se];if(!(e instanceof HTMLElement))return null;window[se]=null;const t=F(e);if(t)return t;const n=e.closest(ee);if(n){const o=F(n);if(o)return o}return null}function Ee(e){const t=e.closest("[data-editora-editor]");if(t&&F(t)===e)return t;let n=e;for(;n;){if(n.matches(ee)&&(n===e||F(n)===e))return n;n=n.parentElement}return X(e)}function K(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function ve(e){const t=X(e);if(K(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return K(n)?!0:K(document.documentElement)||K(document.body)}function G(e,t){e.classList.remove("rte-content-rules-theme-dark"),ve(t)&&e.classList.add("rte-content-rules-theme-dark")}function Ce(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function M(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=e.editorElement;if(s.matches(R))return s;const i=s.querySelector(R);if(i instanceof HTMLElement)return i}const n=Re();if(n)return n;const o=window.getSelection();if(o&&o.rangeCount>0){const s=o.getRangeAt(0).startContainer,l=Ce(s)?.closest(R);if(l)return l}const r=document.activeElement;if(r){if(r.matches(R))return r;const s=r.closest(R);if(s)return s}return g&&g.isConnected?g:(g&&!g.isConnected&&(g=null),t?document.querySelector(R):null)}function Z(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function $e(e,t){const n=e.innerText||e.textContent||"";return t(n)}function Me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ue(e){const t=e.match(/\b[\w'-]+\b/g);return t?t.length:0}function me(e){const t=e.match(/[^.!?]+[.!?]*/g);return t?t.map(n=>n.trim()).filter(Boolean).length:0}function Se(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(t.length<=3)return 1;const n=t.match(/[aeiouy]+/g);let o=n?n.length:1;return t.endsWith("e")&&(o-=1),Math.max(1,o)}function Te(e){const t=e.match(/\b[\w'-]+\b/g)||[],n=t.length;if(n===0)return 100;const o=Math.max(1,me(e)),r=t.reduce((i,l)=>i+Se(l),0),s=206.835-1.015*(n/o)-84.6*(r/Math.max(1,n));return Number.isFinite(s)?Math.max(0,Math.min(120,s)):0}function _(e,t){return`${e}-${t}`}function x(e,t){return e.length>=t}function q(e,t,n){x(e,n)||e.push(t)}function be(e,t=140){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function Ae(e,t,n,o){return{id:e.id||_(t,o),ruleId:e.ruleId||t,severity:e.severity||n,message:e.message||t,excerpt:e.excerpt?be(e.excerpt,220):void 0,suggestion:e.suggestion,locateText:e.locateText,selector:e.selector}}function Le(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),o=new Set;return n.forEach(r=>{const s=t(r.textContent||"").toLowerCase();s&&o.add(s)}),o}function Ie(e){const t=e.match(/[^.!?\n]+[.!?]?/g);return t?t.map(n=>n.trim()).filter(Boolean):[]}async function v(e,t,n=!1){const o=$e(e,t.normalizeText),r=e.innerHTML,s=`${o.length}:${ce(o)}:${r.length}:${ce(r)}`;if(!n&&ae.get(e)===s)return C.get(e)||[];const i=(Y.get(e)||0)+1;Y.set(e,i);const l=ue(o),c=me(o),u=Te(o),a=[],y=t.labels;if(t.bannedWords.length>0){let w=0;for(const p of t.bannedWords){const m=new RegExp(`\\b${Me(p)}\\b`,"gi");let b=m.exec(o);for(;b&&!x(a,t.maxIssues);){const oe=b[0];q(a,{id:_("banned-word",w),ruleId:"banned-word",severity:"error",message:`${y.bannedWordMessage}: "${oe}"`,locateText:oe,suggestion:"Replace or remove banned terms."},t.maxIssues),w+=1,b=m.exec(o)}if(x(a,t.maxIssues))break}}if(!x(a,t.maxIssues)&&t.requiredHeadings.length>0){const w=Le(e,t.normalizeText);let p=0;t.requiredHeadings.forEach(m=>{if(x(a,t.maxIssues))return;const b=t.normalizeText(m).toLowerCase();!b||w.has(b)||(q(a,{id:_("required-heading",p),ruleId:"required-heading",severity:"warning",message:`${y.requiredHeadingMessage}: "${m}"`,suggestion:`Add a heading named "${m}".`},t.maxIssues),p+=1)})}if(!x(a,t.maxIssues)){const w=Ie(o);let p=0;for(const m of w){if(x(a,t.maxIssues))break;const b=ue(m);b<=t.maxSentenceWords||(q(a,{id:_("sentence-length",p),ruleId:"sentence-length",severity:"warning",message:`${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,excerpt:be(m,200),locateText:m.slice(0,64),suggestion:"Split into shorter sentences for readability."},t.maxIssues),p+=1)}}if(!x(a,t.maxIssues)&&l>0&&u<t.minReadabilityScore&&q(a,{id:_("readability",0),ruleId:"readability",severity:"info",message:`${y.readabilityMessage}: ${u.toFixed(1)} < ${t.minReadabilityScore}`,suggestion:"Use shorter sentences and simpler wording."},t.maxIssues),!x(a,t.maxIssues)&&t.customRules.length>0){const w={editor:e,editorRoot:X(e),text:o,html:r,wordCount:l,sentenceCount:c,readabilityScore:u};for(const p of t.customRules){if(x(a,t.maxIssues))break;try{const m=await p.evaluate(w);if(!Array.isArray(m))continue;for(let b=0;b<m.length&&!x(a,t.maxIssues);b+=1)q(a,Ae(m[b],p.id,p.severity||"warning",b),t.maxIssues)}catch{}}}if(Y.get(e)!==i)return C.get(e)||[];const D={readabilityScore:u,wordCount:l,sentenceCount:c};return ae.set(e,s),C.set(e,a),ge.set(e,D),te(e),e.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:a,metrics:D}})),a}function He(e){return e.reduce((t,n)=>(t[n.severity]+=1,t),{error:0,warning:0,info:0})}function de(e){return e==="error"?"Error":e==="warning"?"Warning":"Info"}function $(e,t,n){const o=Ee(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(s=>{s.classList.toggle("active",n),s.setAttribute("data-active",n?"true":"false"),s.setAttribute("aria-pressed",n?"true":"false")})}function U(e){return B.get(e)===!0}function J(e,t){if(!t.classList.contains("show"))return;const o=X(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360);t.style.width=`${r}px`,t.style.maxHeight=`${Math.max(220,window.innerHeight-24)}px`;const s=Math.max(10,o.right-r),i=Math.max(10,window.innerWidth-r-10),l=Math.min(s,i),c=Math.max(10,Math.min(window.innerHeight-10-240,o.top+10));t.style.left=`${l}px`,t.style.top=`${c}px`}function fe(e,t){const n=t.trim().toLowerCase();if(!n)return!1;const o=window.getSelection();if(!o)return!1;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s=r.nextNode();for(;s;){const l=s.data.toLowerCase().indexOf(n);if(l!==-1){const c=document.createRange();c.setStart(s,l),c.setEnd(s,Math.min(s.length,l+n.length)),o.removeAllRanges(),o.addRange(c);const u=s.parentElement;return u&&u.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0}s=r.nextNode()}return!1}function Oe(e,t){if(t.selector){const n=e.querySelector(t.selector);if(n)return n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0}),!0}return!!(t.locateText&&fe(e,t.locateText)||t.excerpt&&fe(e,t.excerpt.slice(0,64)))}function We(e,t){return(C.get(e)||[]).find(o=>o.id===t)}function A(e,t){const n=T.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function W(e,t,n){const o=t.querySelector('[data-action="toggle-realtime"]');if(!o)return;const r=A(e,n);o.textContent=r?n.labels.realtimeOnText:n.labels.realtimeOffText,o.setAttribute("aria-pressed",r?"true":"false"),$(e,"toggleContentRulesRealtime",r)}function te(e){const t=h.get(e);if(!t)return;const n=d.get(e)||E;if(!n)return;const o=C.get(e)||[],r=ge.get(e)||{readabilityScore:100},s=t.querySelector(".rte-content-rules-count"),i=t.querySelector(".rte-content-rules-summary"),l=t.querySelector(".rte-content-rules-list"),c=t.querySelector(".rte-content-rules-live");if(!s||!i||!l||!c)return;const u=He(o);if(s.textContent=String(o.length),i.textContent=`${n.labels.summaryPrefix}: ${o.length} | Error ${u.error} | Warning ${u.warning} | Info ${u.info} | Readability ${r.readabilityScore.toFixed(1)}`,c.textContent=`${o.length} issues. ${u.error} errors, ${u.warning} warnings, ${u.info} info.`,o.length===0){l.innerHTML=`<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;return}l.innerHTML=o.map(a=>{const y=a.excerpt?`<p class="rte-content-rules-excerpt">${k(a.excerpt)}</p>`:"",D=a.suggestion?`<p class="rte-content-rules-suggestion">${k(a.suggestion)}</p>`:"",w=`${de(a.severity)} ${a.message}. ${n.labels.locateText}`;return`
2
2
  <li class="rte-content-rules-item rte-content-rules-item-${a.severity}">
3
3
  <button
4
4
  type="button"
@@ -8,13 +8,13 @@
8
8
  data-role="issue-button"
9
9
  aria-label="${k(w)}"
10
10
  >
11
- <span class="rte-content-rules-badge">${k(He(a.severity))}</span>
11
+ <span class="rte-content-rules-badge">${k(de(a.severity))}</span>
12
12
  <span class="rte-content-rules-message">${k(a.message)}</span>
13
13
  </button>
14
14
  ${y}
15
15
  ${D}
16
16
  </li>
17
- `}).join("")}function O(e,t=!1){const n=h.get(e);n&&(n.classList.remove("show"),B.set(e,!1),M(e,"toggleContentRulesPanel",!1),t&&e.focus({preventScroll:!0}))}function Pe(e){h.forEach((t,n)=>{n!==e&&O(n,!1)})}function qe(e){const t=h.get(e);if(t)return t;const n=d.get(e)||E||j(),o=`rte-content-rules-panel-${xe++}`,r=document.createElement("section");return r.className=f,r.id=o,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",n.labels.panelAriaLabel),r.innerHTML=`
17
+ `}).join("")}function O(e,t=!1){const n=h.get(e);n&&(n.classList.remove("show"),B.set(e,!1),$(e,"toggleContentRulesPanel",!1),t&&e.focus({preventScroll:!0}))}function Pe(e){h.forEach((t,n)=>{n!==e&&O(n,!1)})}function qe(e){const t=h.get(e);if(t)return t;const n=d.get(e)||E||j(),o=`rte-content-rules-panel-${ye++}`,r=document.createElement("section");return r.className=f,r.id=o,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",n.labels.panelAriaLabel),r.innerHTML=`
18
18
  <header class="rte-content-rules-header">
19
19
  <h2 class="rte-content-rules-title">${k(n.labels.panelTitle)}</h2>
20
20
  <button type="button" class="rte-content-rules-icon-btn" data-action="close" aria-label="${k(n.labels.closeText)}">✕</button>
@@ -32,7 +32,7 @@
32
32
  <p class="rte-content-rules-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + R</p>
33
33
  <span class="rte-content-rules-live" aria-live="polite"></span>
34
34
  </div>
35
- `,r.addEventListener("click",s=>{const l=s.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action");if(c){if(c==="close"){O(e,!0);return}if(c==="run-audit"){const u=d.get(e)||E||n;v(e,u,!0);return}if(c==="toggle-realtime"){const a=!A(e,d.get(e)||E||n);if(T.set(e,a),W(e,r,d.get(e)||E||n),a){const y=d.get(e)||E||n;v(e,y,!0)}return}if(c==="focus-issue"){const u=l.getAttribute("data-issue-id")||"",a=We(e,u);if(!a)return;Oe(e,a),O(e,!1)}}}),r.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),O(e,!0);return}if(s.key!=="ArrowDown"&&s.key!=="ArrowUp")return;const i=Array.from(r.querySelectorAll('[data-role="issue-button"]'));if(i.length===0)return;const l=document.activeElement,c=i.findIndex(y=>y===l);if(c===-1)return;s.preventDefault();const u=s.key==="ArrowDown"?1:-1,a=(c+u+i.length)%i.length;i[a].focus()}),G(r,e),document.body.appendChild(r),h.set(e,r),B.set(e,!1),W(e,r,n),r}function ne(e){const t=qe(e);Pe(e),t.classList.add("show"),B.set(e,!0),G(t,e),J(e,t),te(e),M(e,"toggleContentRulesPanel",!0),t.querySelector('[data-action="run-audit"]')?.focus()}function Q(e,t){const n=U(e);return(typeof t=="boolean"?t:!n)?ne(e):O(e,!1),!0}function be(e){const t=V.get(e);typeof t=="number"&&(window.clearTimeout(t),z.delete(t),V.delete(e))}function he(e){const t=d.get(e)||E;if(!t||!A(e,t))return;be(e);const n=window.setTimeout(()=>{z.delete(n),V.delete(e),v(e,t,!1)},t.debounceMs);z.add(n),V.set(e,n)}function re(e){return typeof e.key=="string"?e.key.toLowerCase():""}function _e(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="r"}function ze(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function Be(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="t"}function De(){if(typeof document>"u"||document.getElementById(le))return;const e=document.createElement("style");e.id=le,e.textContent=`
35
+ `,r.addEventListener("click",s=>{const l=s.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action");if(c){if(c==="close"){O(e,!0);return}if(c==="run-audit"){const u=d.get(e)||E||n;v(e,u,!0);return}if(c==="toggle-realtime"){const a=!A(e,d.get(e)||E||n);if(T.set(e,a),W(e,r,d.get(e)||E||n),a){const y=d.get(e)||E||n;v(e,y,!0)}return}if(c==="focus-issue"){const u=l.getAttribute("data-issue-id")||"",a=We(e,u);if(!a)return;Oe(e,a),O(e,!1)}}}),r.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),O(e,!0);return}if(s.key!=="ArrowDown"&&s.key!=="ArrowUp")return;const i=Array.from(r.querySelectorAll('[data-role="issue-button"]'));if(i.length===0)return;const l=document.activeElement,c=i.findIndex(y=>y===l);if(c===-1)return;s.preventDefault();const u=s.key==="ArrowDown"?1:-1,a=(c+u+i.length)%i.length;i[a].focus()}),G(r,e),document.body.appendChild(r),h.set(e,r),B.set(e,!1),W(e,r,n),r}function ne(e){const t=qe(e);Pe(e),t.classList.add("show"),B.set(e,!0),G(t,e),J(e,t),te(e),$(e,"toggleContentRulesPanel",!0),t.querySelector('[data-action="run-audit"]')?.focus()}function Q(e,t){const n=U(e);return(typeof t=="boolean"?t:!n)?ne(e):O(e,!1),!0}function he(e){const t=V.get(e);typeof t=="number"&&(window.clearTimeout(t),z.delete(t),V.delete(e))}function pe(e){const t=d.get(e)||E;if(!t||!A(e,t))return;he(e);const n=window.setTimeout(()=>{z.delete(n),V.delete(e),v(e,t,!1)},t.debounceMs);z.add(n),V.set(e,n)}function re(e){return typeof e.key=="string"?e.key.toLowerCase():""}function _e(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="r"}function ze(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function Be(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="t"}function De(){if(typeof document>"u"||document.getElementById(le))return;const e=document.createElement("style");e.id=le,e.textContent=`
36
36
  .rte-toolbar-group-items.content-rules,
37
37
  .editora-toolbar-group-items.content-rules {
38
38
  display: flex;
@@ -236,7 +236,7 @@
236
236
  .rte-content-rules-btn-primary:hover,
237
237
  .rte-content-rules-btn-primary:focus-visible {
238
238
  border-color: #0369a1;
239
- background: #0284c7;
239
+ background: #0369a1;
240
240
  color: #ffffff;
241
241
  }
242
242
 
@@ -405,4 +405,4 @@
405
405
  max-height: 45vh;
406
406
  }
407
407
  }
408
- `,document.head.appendChild(e)}function Ne(e){E=e,L||(L=t=>{const o=t.target?.closest(R);if(!o)return;g=o,d.has(o)||d.set(o,e),C.has(o)||C.set(o,[]),T.has(o)||T.set(o,e.enableRealtime);const r=h.get(o);r&&(G(r,o),J(o,r),W(o,r,d.get(o)||e)),M(o,"toggleContentRulesPanel",U(o)),M(o,"toggleContentRulesRealtime",A(o,e))},document.addEventListener("focusin",L,!0)),I||(I=t=>{const o=t.target?.closest(R);o&&(g=o,he(o))},document.addEventListener("input",I,!0)),H||(H=t=>{if(t.defaultPrevented||t.target?.closest("input, textarea, select"))return;const o=t.key==="Escape",r=_e(t),s=ze(t),i=Be(t);if(!o&&!r&&!s&&!i)return;const l=$(void 0,!1);if(!l||Z(l))return;const c=d.get(l)||E||e;if(d.set(l,c),g=l,o&&U(l)){t.preventDefault(),O(l,!0);return}if(r){t.preventDefault(),t.stopPropagation(),Q(l);return}if(s){t.preventDefault(),t.stopPropagation(),v(l,c,!0),ne(l);return}if(i){t.preventDefault(),t.stopPropagation();const u=!A(l,c);T.set(l,u);const a=h.get(l);a&&W(l,a,c),M(l,"toggleContentRulesRealtime",u),u&&v(l,c,!0)}},document.addEventListener("keydown",H,!0)),S||(S=()=>{h.forEach((t,n)=>{if(!n.isConnected||!t.isConnected){be(n),t.remove(),h.delete(n),B.delete(n);return}G(t,n),J(n,t)})},window.addEventListener("scroll",S,!0),window.addEventListener("resize",S))}function Ke(){L&&(document.removeEventListener("focusin",L,!0),L=null),I&&(document.removeEventListener("input",I,!0),I=null),H&&(document.removeEventListener("keydown",H,!0),H=null),S&&(window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),S=null),h.forEach(e=>{e.remove()}),h.clear(),E=null,g=null}const je=(e={})=>{const t=j(e);return De(),{name:"contentRules",toolbar:[{id:"contentRulesGroup",label:"Content Rules",type:"group",command:"contentRules",items:[{id:"contentRules",label:"Content Rules",command:"toggleContentRulesPanel",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"contentRulesAudit",label:"Run Rules Audit",command:"runContentRulesAudit",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"contentRulesRealtime",label:"Toggle Realtime Rules",command:"toggleContentRulesRealtime",shortcut:"Mod-Alt-Shift-t",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{contentRules:(n,o)=>{const r=$(o);if(!r||Z(r))return!1;const s=d.get(r)||t;return d.set(r,s),g=r,Q(r,!0),v(r,s,!1),!0},toggleContentRulesPanel:(n,o)=>{const r=$(o);if(!r||Z(r))return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=Q(r,typeof n=="boolean"?n:void 0);return U(r)&&v(r,s,!1),i},runContentRulesAudit:async(n,o)=>{const r=$(o);if(!r)return!1;g=r;const s=d.get(r)||t;return d.set(r,s),await v(r,s,!0),ne(r),!0},toggleContentRulesRealtime:(n,o)=>{const r=$(o);if(!r)return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=typeof n=="boolean"?n:!A(r,s);T.set(r,i);const l=h.get(r);return l&&W(r,l,s),M(r,"toggleContentRulesRealtime",i),i&&v(r,s,!0),!0},getContentRulesIssues:(n,o)=>{const r=$(o);if(!r)return!1;const s=C.get(r)||[];if(typeof n=="function")try{n(s)}catch{}return r.__contentRulesIssues=s,r.dispatchEvent(new CustomEvent("editora:content-rules-issues",{bubbles:!0,detail:{issues:s}})),!0},setContentRulesOptions:(n,o)=>{const r=$(o);if(!r||!n||typeof n!="object")return!1;const s=d.get(r)||t,i=j({...s,...n,labels:{...s.labels,...n.labels||{}}});d.set(r,i),typeof n.enableRealtime=="boolean"&&T.set(r,n.enableRealtime),A(r,i)&&v(r,i,!0);const l=h.get(r);if(l){l.setAttribute("aria-label",i.labels.panelAriaLabel);const c=l.querySelector(".rte-content-rules-title");c&&(c.textContent=i.labels.panelTitle),W(r,l,i),te(r)}return!0}},keymap:{"Mod-Alt-Shift-r":"toggleContentRulesPanel","Mod-Alt-Shift-R":"toggleContentRulesPanel","Mod-Alt-Shift-l":"runContentRulesAudit","Mod-Alt-Shift-L":"runContentRulesAudit","Mod-Alt-Shift-t":"toggleContentRulesRealtime","Mod-Alt-Shift-T":"toggleContentRulesRealtime"},init:function(o){N+=1;const r=this&&typeof this.__pluginConfig=="object"?j({...t,...this.__pluginConfig}):t;Ne(r);const s=$(o&&o.editorElement?{editorElement:o.editorElement}:void 0,!1);s&&(g=s,d.set(s,r),T.set(s,r.enableRealtime),C.set(s,[]),M(s,"toggleContentRulesPanel",!1),M(s,"toggleContentRulesRealtime",r.enableRealtime),r.enableRealtime&&he(s))},destroy:()=>{N=Math.max(0,N-1),!(N>0)&&(z.forEach(n=>{window.clearTimeout(n)}),z.clear(),Ke())}}};exports.ContentRulesPlugin=je;
408
+ `,document.head.appendChild(e)}function Ne(e){E=e,L||(L=t=>{const o=t.target?.closest(R);if(!o)return;g=o,d.has(o)||d.set(o,e),C.has(o)||C.set(o,[]),T.has(o)||T.set(o,e.enableRealtime);const r=h.get(o);r&&(G(r,o),J(o,r),W(o,r,d.get(o)||e)),$(o,"toggleContentRulesPanel",U(o)),$(o,"toggleContentRulesRealtime",A(o,e))},document.addEventListener("focusin",L,!0)),I||(I=t=>{const o=t.target?.closest(R);o&&(g=o,pe(o))},document.addEventListener("input",I,!0)),H||(H=t=>{if(t.defaultPrevented||t.target?.closest("input, textarea, select"))return;const o=t.key==="Escape",r=_e(t),s=ze(t),i=Be(t);if(!o&&!r&&!s&&!i)return;const l=M(void 0,!1);if(!l||Z(l))return;const c=d.get(l)||E||e;if(d.set(l,c),g=l,o&&U(l)){t.preventDefault(),O(l,!0);return}if(r){t.preventDefault(),t.stopPropagation(),Q(l);return}if(s){t.preventDefault(),t.stopPropagation(),v(l,c,!0),ne(l);return}if(i){t.preventDefault(),t.stopPropagation();const u=!A(l,c);T.set(l,u);const a=h.get(l);a&&W(l,a,c),$(l,"toggleContentRulesRealtime",u),u&&v(l,c,!0)}},document.addEventListener("keydown",H,!0)),S||(S=()=>{h.forEach((t,n)=>{if(!n.isConnected||!t.isConnected){he(n),t.remove(),h.delete(n),B.delete(n);return}G(t,n),J(n,t)})},window.addEventListener("scroll",S,!0),window.addEventListener("resize",S))}function Ke(){L&&(document.removeEventListener("focusin",L,!0),L=null),I&&(document.removeEventListener("input",I,!0),I=null),H&&(document.removeEventListener("keydown",H,!0),H=null),S&&(window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),S=null),h.forEach(e=>{e.remove()}),h.clear(),E=null,g=null}const je=(e={})=>{const t=j(e);return De(),{name:"contentRules",toolbar:[{id:"contentRulesGroup",label:"Content Rules",type:"group",command:"contentRules",items:[{id:"contentRules",label:"Content Rules",command:"toggleContentRulesPanel",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"contentRulesAudit",label:"Run Rules Audit",command:"runContentRulesAudit",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"contentRulesRealtime",label:"Toggle Realtime Rules",command:"toggleContentRulesRealtime",shortcut:"Mod-Alt-Shift-t",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{contentRules:(n,o)=>{const r=M(o);if(!r||Z(r))return!1;const s=d.get(r)||t;return d.set(r,s),g=r,Q(r,!0),v(r,s,!1),!0},toggleContentRulesPanel:(n,o)=>{const r=M(o);if(!r||Z(r))return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=Q(r,typeof n=="boolean"?n:void 0);return U(r)&&v(r,s,!1),i},runContentRulesAudit:async(n,o)=>{const r=M(o);if(!r)return!1;g=r;const s=d.get(r)||t;return d.set(r,s),await v(r,s,!0),ne(r),!0},toggleContentRulesRealtime:(n,o)=>{const r=M(o);if(!r)return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=typeof n=="boolean"?n:!A(r,s);T.set(r,i);const l=h.get(r);return l&&W(r,l,s),$(r,"toggleContentRulesRealtime",i),i&&v(r,s,!0),!0},getContentRulesIssues:(n,o)=>{const r=M(o);if(!r)return!1;const s=C.get(r)||[];if(typeof n=="function")try{n(s)}catch{}return r.__contentRulesIssues=s,r.dispatchEvent(new CustomEvent("editora:content-rules-issues",{bubbles:!0,detail:{issues:s}})),!0},setContentRulesOptions:(n,o)=>{const r=M(o);if(!r||!n||typeof n!="object")return!1;const s=d.get(r)||t,i=j({...s,...n,labels:{...s.labels,...n.labels||{}}});d.set(r,i),typeof n.enableRealtime=="boolean"&&T.set(r,n.enableRealtime),A(r,i)&&v(r,i,!0);const l=h.get(r);if(l){l.setAttribute("aria-label",i.labels.panelAriaLabel);const c=l.querySelector(".rte-content-rules-title");c&&(c.textContent=i.labels.panelTitle),W(r,l,i),te(r)}return!0}},keymap:{"Mod-Alt-Shift-r":"toggleContentRulesPanel","Mod-Alt-Shift-R":"toggleContentRulesPanel","Mod-Alt-Shift-l":"runContentRulesAudit","Mod-Alt-Shift-L":"runContentRulesAudit","Mod-Alt-Shift-t":"toggleContentRulesRealtime","Mod-Alt-Shift-T":"toggleContentRulesRealtime"},init:function(o){N+=1;const r=this&&typeof this.__pluginConfig=="object"?j({...t,...this.__pluginConfig}):t;Ne(r);const s=M(o&&o.editorElement?{editorElement:o.editorElement}:void 0,!1);s&&(g=s,d.set(s,r),T.set(s,r.enableRealtime),C.set(s,[]),$(s,"toggleContentRulesPanel",!1),$(s,"toggleContentRulesRealtime",r.enableRealtime),r.enableRealtime&&pe(s))},destroy:()=>{N=Math.max(0,N-1),!(N>0)&&(z.forEach(n=>{window.clearTimeout(n)}),z.clear(),Ke())}}};exports.ContentRulesPlugin=je;