@editora/plugins 1.0.11 → 1.0.13

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/approval-workflow.cjs.js +14 -14
  3. package/dist/approval-workflow.esm.js +265 -262
  4. package/dist/blockquote.cjs.js +1 -1
  5. package/dist/blockquote.esm.js +177 -15
  6. package/dist/blocks-library.cjs.js +6 -6
  7. package/dist/blocks-library.esm.js +95 -92
  8. package/dist/bold.cjs.js +1 -1
  9. package/dist/bold.esm.js +10 -6
  10. package/dist/capitalization.cjs.js +1 -1
  11. package/dist/capitalization.esm.js +124 -44
  12. package/dist/checklist.cjs.js +1 -1
  13. package/dist/checklist.esm.js +251 -191
  14. package/dist/citations.cjs.js +4 -4
  15. package/dist/citations.esm.js +131 -128
  16. package/dist/clear-formatting.cjs.js +1 -1
  17. package/dist/clear-formatting.esm.js +68 -36
  18. package/dist/code.cjs.js +121 -44
  19. package/dist/code.esm.js +2694 -889
  20. package/dist/content-rules.cjs.js +5 -5
  21. package/dist/content-rules.esm.js +104 -101
  22. package/dist/data-binding.cjs.js +3 -3
  23. package/dist/data-binding.esm.js +51 -48
  24. package/dist/direction.cjs.js +1 -1
  25. package/dist/direction.esm.js +97 -74
  26. package/dist/doc-schema.cjs.js +4 -4
  27. package/dist/doc-schema.esm.js +104 -101
  28. package/dist/embed-iframe.cjs.js +21 -4
  29. package/dist/embed-iframe.esm.js +279 -116
  30. package/dist/heading.cjs.js +1 -1
  31. package/dist/heading.esm.js +239 -56
  32. package/dist/history.cjs.js +1 -1
  33. package/dist/history.esm.js +74 -89
  34. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  35. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  36. package/dist/italic.cjs.js +1 -1
  37. package/dist/italic.esm.js +12 -8
  38. package/dist/math.cjs.js +27 -21
  39. package/dist/math.esm.js +218 -146
  40. package/dist/merge-tag.cjs.js +8 -2
  41. package/dist/merge-tag.esm.js +130 -111
  42. package/dist/pii-redaction.cjs.js +6 -6
  43. package/dist/pii-redaction.esm.js +169 -166
  44. package/dist/smart-paste.cjs.js +5 -5
  45. package/dist/smart-paste.esm.js +120 -117
  46. package/dist/special-characters.cjs.js +6 -10
  47. package/dist/special-characters.esm.js +97 -75
  48. package/dist/strikethrough.cjs.js +1 -1
  49. package/dist/strikethrough.esm.js +11 -25
  50. package/dist/translation-workflow.cjs.js +7 -7
  51. package/dist/translation-workflow.esm.js +103 -100
  52. package/dist/underline.cjs.js +1 -1
  53. package/dist/underline.esm.js +7 -3
  54. package/package.json +3 -3
@@ -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",oe="__editoraCommandEditorRoot",se="rte-content-rules-styles",f="rte-content-rules-panel",P=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',he={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,v=new WeakMap,de=new WeakMap,T=new WeakMap,V=new WeakMap,le=new WeakMap,Y=new WeakMap,h=new Map,B=new WeakMap,z=new Set;let N=0,pe=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 xe(e){return{...he,...e||{}}}function ye(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ae(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:ae(e.bannedWords),requiredHeadings:ae(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:xe(e.labels),normalizeText:e.normalizeText||ye,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 we(){if(typeof window>"u")return null;const e=window[oe];if(!(e instanceof HTMLElement))return null;window[oe]=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 ke(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 Re(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"),Re(t)&&e.classList.add("rte-content-rules-theme-dark")}function Ee(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=we();if(n)return n;const o=window.getSelection();if(o&&o.rangeCount>0){const s=o.getRangeAt(0).startContainer,l=Ee(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 ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(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 ce(e){const t=e.match(/\b[\w'-]+\b/g);return t?t.length:0}function fe(e){const t=e.match(/[^.!?]+[.!?]*/g);return t?t.map(n=>n.trim()).filter(Boolean).length:0}function Me(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 $e(e){const t=e.match(/\b[\w'-]+\b/g)||[],n=t.length;if(n===0)return 100;const o=Math.max(1,fe(e)),r=t.reduce((i,l)=>i+Me(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 ge(e,t=140){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function Se(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?ge(e.excerpt,220):void 0,suggestion:e.suggestion,locateText:e.locateText,selector:e.selector}}function Te(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 Ae(e){const t=e.match(/[^.!?\n]+[.!?]?/g);return t?t.map(n=>n.trim()).filter(Boolean):[]}async function C(e,t,n=!1){const o=Ce(e,t.normalizeText),r=e.innerHTML,s=`${o.length}:${ie(o)}:${r.length}:${ie(r)}`;if(!n&&le.get(e)===s)return v.get(e)||[];const i=(Y.get(e)||0)+1;Y.set(e,i);const l=ce(o),c=fe(o),u=$e(o),a=[],y=t.labels;if(t.bannedWords.length>0){let w=0;for(const p of t.bannedWords){const m=new RegExp(`\\b${ve(p)}\\b`,"gi");let b=m.exec(o);for(;b&&!x(a,t.maxIssues);){const re=b[0];q(a,{id:_("banned-word",w),ruleId:"banned-word",severity:"error",message:`${y.bannedWordMessage}: "${re}"`,locateText:re,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=Te(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=Ae(o);let p=0;for(const m of w){if(x(a,t.maxIssues))break;const b=ce(m);b<=t.maxSentenceWords||(q(a,{id:_("sentence-length",p),ruleId:"sentence-length",severity:"warning",message:`${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,excerpt:ge(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,Se(m[b],p.id,p.severity||"warning",b),t.maxIssues)}catch{}}}if(Y.get(e)!==i)return v.get(e)||[];const D={readabilityScore:u,wordCount:l,sentenceCount:c};return le.set(e,s),v.set(e,a),de.set(e,D),te(e),e.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:a,metrics:D}})),a}function Le(e){return e.reduce((t,n)=>(t[n.severity]+=1,t),{error:0,warning:0,info:0})}function Ie(e){return e==="error"?"Error":e==="warning"?"Warning":"Info"}function M(e,t,n){const o=ke(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 ue(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 He(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&&ue(e,t.locateText)||t.excerpt&&ue(e,t.excerpt.slice(0,64)))}function Oe(e,t){return(v.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=v.get(e)||[],r=de.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=Le(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)',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`
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(Ie(a.severity))}</span>
11
+ <span class="rte-content-rules-badge">${k(He(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 We(e){h.forEach((t,n)=>{n!==e&&O(n,!1)})}function Pe(e){const t=h.get(e);if(t)return t;const n=d.get(e)||E||j(),o=`rte-content-rules-panel-${pe++}`,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),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=`
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;C(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;C(e,y,!0)}return}if(c==="focus-issue"){const u=l.getAttribute("data-issue-id")||"",a=Oe(e,u);if(!a)return;He(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=Pe(e);We(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 me(e){const t=V.get(e);typeof t=="number"&&(window.clearTimeout(t),z.delete(t),V.delete(e))}function be(e){const t=d.get(e)||E;if(!t||!A(e,t))return;me(e);const n=window.setTimeout(()=>{z.delete(n),V.delete(e),C(e,t,!1)},t.debounceMs);z.add(n),V.set(e,n)}function qe(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="r"}function _e(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function ze(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="t"}function Be(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,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),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=`
36
36
  .rte-toolbar-group-items.content-rules,
37
37
  .editora-toolbar-group-items.content-rules {
38
38
  display: flex;
@@ -405,4 +405,4 @@
405
405
  max-height: 45vh;
406
406
  }
407
407
  }
408
- `,document.head.appendChild(e)}function De(e){E=e,L||(L=t=>{const o=t.target?.closest(R);if(!o)return;g=o,d.has(o)||d.set(o,e),v.has(o)||v.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,be(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=qe(t),s=_e(t),i=ze(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(),C(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&&C(l,c,!0)}},document.addEventListener("keydown",H,!0)),S||(S=()=>{h.forEach((t,n)=>{if(!n.isConnected||!t.isConnected){me(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 Ne(){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 Ke=(e={})=>{const t=j(e);return Be(),{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),C(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)&&C(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 C(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&&C(r,s,!0),!0},getContentRulesIssues:(n,o)=>{const r=$(o);if(!r)return!1;const s=v.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)&&C(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;De(r);const s=$(o&&o.editorElement?{editorElement:o.editorElement}:void 0,!1);s&&(g=s,d.set(s,r),T.set(s,r.enableRealtime),v.set(s,[]),M(s,"toggleContentRulesPanel",!1),M(s,"toggleContentRulesRealtime",r.enableRealtime),r.enableRealtime&&be(s))},destroy:()=>{N=Math.max(0,N-1),!(N>0)&&(z.forEach(n=>{window.clearTimeout(n)}),z.clear(),Ne())}}};exports.ContentRulesPlugin=Ke;
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;