@editora/plugins 1.0.8 → 1.0.9

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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/dist/approval-workflow.cjs.js +447 -0
  4. package/dist/approval-workflow.esm.js +1070 -0
  5. package/dist/blocks-library.cjs.js +442 -0
  6. package/dist/blocks-library.esm.js +1317 -0
  7. package/dist/citations.cjs.js +548 -0
  8. package/dist/citations.esm.js +1457 -0
  9. package/dist/conditional-content.cjs.js +626 -0
  10. package/dist/conditional-content.esm.js +1360 -0
  11. package/dist/content-rules.cjs.js +408 -0
  12. package/dist/content-rules.esm.js +1093 -0
  13. package/dist/data-binding.cjs.js +321 -0
  14. package/dist/data-binding.esm.js +913 -0
  15. package/dist/doc-schema.cjs.js +398 -0
  16. package/dist/doc-schema.esm.js +1310 -0
  17. package/dist/enterprise.cjs.js +1 -0
  18. package/dist/enterprise.esm.js +56 -0
  19. package/dist/index.cjs.js +1 -1
  20. package/dist/index.esm.js +109 -81
  21. package/dist/mentions.cjs.js +105 -0
  22. package/dist/mentions.esm.js +726 -0
  23. package/dist/page-break.cjs.js +2 -2
  24. package/dist/page-break.esm.js +32 -32
  25. package/dist/pii-redaction.cjs.js +436 -0
  26. package/dist/pii-redaction.esm.js +1377 -0
  27. package/dist/preview.cjs.js +3 -3
  28. package/dist/preview.esm.js +29 -29
  29. package/dist/slash-commands.cjs.js +90 -0
  30. package/dist/slash-commands.esm.js +752 -0
  31. package/dist/smart-paste.cjs.js +398 -0
  32. package/dist/smart-paste.esm.js +1388 -0
  33. package/dist/track-changes.cjs.js +77 -0
  34. package/dist/track-changes.esm.js +755 -0
  35. package/dist/translation-workflow.cjs.js +626 -0
  36. package/dist/translation-workflow.esm.js +1718 -0
  37. package/dist/version-diff.cjs.js +362 -0
  38. package/dist/version-diff.esm.js +768 -0
  39. package/index.d.ts +798 -0
  40. package/package.json +104 -5
@@ -0,0 +1,408 @@
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`
2
+ <li class="rte-content-rules-item rte-content-rules-item-${a.severity}">
3
+ <button
4
+ type="button"
5
+ class="rte-content-rules-item-btn"
6
+ data-action="focus-issue"
7
+ data-issue-id="${k(a.id)}"
8
+ data-role="issue-button"
9
+ aria-label="${k(w)}"
10
+ >
11
+ <span class="rte-content-rules-badge">${k(Ie(a.severity))}</span>
12
+ <span class="rte-content-rules-message">${k(a.message)}</span>
13
+ </button>
14
+ ${y}
15
+ ${D}
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=`
18
+ <header class="rte-content-rules-header">
19
+ <h2 class="rte-content-rules-title">${k(n.labels.panelTitle)}</h2>
20
+ <button type="button" class="rte-content-rules-icon-btn" data-action="close" aria-label="${k(n.labels.closeText)}">✕</button>
21
+ </header>
22
+ <div class="rte-content-rules-body">
23
+ <div class="rte-content-rules-topline">
24
+ <p class="rte-content-rules-summary" aria-live="polite"></p>
25
+ <span class="rte-content-rules-count" aria-hidden="true">0</span>
26
+ </div>
27
+ <div class="rte-content-rules-controls" role="toolbar" aria-label="Content rules controls">
28
+ <button type="button" class="rte-content-rules-btn rte-content-rules-btn-primary" data-action="run-audit">${k(n.labels.runAuditText)}</button>
29
+ <button type="button" class="rte-content-rules-btn" data-action="toggle-realtime" aria-pressed="false"></button>
30
+ </div>
31
+ <ul class="rte-content-rules-list" role="list" aria-label="Detected content rule issues"></ul>
32
+ <p class="rte-content-rules-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + R</p>
33
+ <span class="rte-content-rules-live" aria-live="polite"></span>
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=`
36
+ .rte-toolbar-group-items.content-rules,
37
+ .editora-toolbar-group-items.content-rules {
38
+ display: flex;
39
+ border: 1px solid #ccc;
40
+ border-radius: 3px;
41
+ background: #fff;
42
+ }
43
+
44
+ .rte-toolbar-group-items.content-rules .rte-toolbar-button,
45
+ .editora-toolbar-group-items.content-rules .editora-toolbar-button {
46
+ border: none;
47
+ border-radius: 0px;
48
+ }
49
+
50
+ .rte-toolbar-group-items.content-rules .rte-toolbar-button,
51
+ .editora-toolbar-group-items.content-rules .editora-toolbar-button {
52
+ border-right: 1px solid #ccc;
53
+ }
54
+ .rte-toolbar-group-items.content-rules .rte-toolbar-item:last-child .rte-toolbar-button,
55
+ .editora-toolbar-group-items.content-rules .editora-toolbar-item:last-child .editora-toolbar-button {
56
+ border-right: none;
57
+ }
58
+ .rte-toolbar-button[data-command="toggleContentRulesRealtime"].active,
59
+ .editora-toolbar-button[data-command="toggleContentRulesRealtime"].active {
60
+ background-color: #ccc;
61
+ }
62
+
63
+ ${P} .rte-toolbar-group-items.content-rules,
64
+ ${P} .editora-toolbar-group-items.content-rules {
65
+ border-color: #566275;
66
+ }
67
+ ${P} .rte-toolbar-group-items.content-rules .rte-toolbar-button,
68
+ ${P} .editora-toolbar-group-items.content-rules .editora-toolbar-button
69
+ {
70
+ border-color: #566275;
71
+ }
72
+ ${P} .rte-toolbar-group-items.content-rules .rte-toolbar-button svg{
73
+ fill: none;
74
+ }
75
+ .${f} {
76
+ position: fixed;
77
+ z-index: 12000;
78
+ display: none;
79
+ width: min(360px, calc(100vw - 20px));
80
+ max-height: calc(100vh - 20px);
81
+ border: 1px solid #d1d5db;
82
+ border-radius: 14px;
83
+ background: #ffffff;
84
+ color: #111827;
85
+ box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
86
+ overflow: hidden;
87
+ }
88
+
89
+ .${f}.show {
90
+ display: flex;
91
+ flex-direction: column;
92
+ }
93
+
94
+ .${f}.rte-content-rules-theme-dark {
95
+ border-color: #334155;
96
+ background: #0f172a;
97
+ color: #e2e8f0;
98
+ box-shadow: 0 20px 46px rgba(2, 6, 23, 0.68);
99
+ }
100
+
101
+ .rte-content-rules-header {
102
+ display: flex;
103
+ align-items: center;
104
+ justify-content: space-between;
105
+ gap: 8px;
106
+ padding: 12px 14px;
107
+ border-bottom: 1px solid #e5e7eb;
108
+ background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
109
+ }
110
+
111
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-header {
112
+ border-color: #1e293b;
113
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
114
+ }
115
+
116
+ .rte-content-rules-title {
117
+ margin: 0;
118
+ font-size: 15px;
119
+ line-height: 1.2;
120
+ font-weight: 700;
121
+ }
122
+
123
+ .rte-content-rules-icon-btn {
124
+ width: 34px;
125
+ height: 34px;
126
+ border: 1px solid #cbd5e1;
127
+ border-radius: 6px;
128
+ background: #ffffff;
129
+ color: #0f172a;
130
+ font-size: 16px;
131
+ line-height: 1;
132
+ font-weight: 600;
133
+ padding: 0;
134
+ display: inline-flex;
135
+ align-items: center;
136
+ justify-content: center;
137
+ cursor: pointer;
138
+ }
139
+
140
+ .rte-content-rules-icon-btn:hover,
141
+ .rte-content-rules-icon-btn:focus-visible {
142
+ outline: none;
143
+ border-color: #3b82f6;
144
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
145
+ }
146
+
147
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-icon-btn {
148
+ background: #0f172a;
149
+ border-color: #475569;
150
+ color: #e2e8f0;
151
+ }
152
+
153
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-icon-btn:hover,
154
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-icon-btn:focus-visible {
155
+ border-color: #60a5fa;
156
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
157
+ }
158
+
159
+ .rte-content-rules-body {
160
+ display: flex;
161
+ flex-direction: column;
162
+ gap: 10px;
163
+ padding: 12px;
164
+ overflow: auto;
165
+ }
166
+
167
+ .rte-content-rules-topline {
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: space-between;
171
+ gap: 8px;
172
+ }
173
+
174
+ .rte-content-rules-summary {
175
+ margin: 0;
176
+ font-size: 12px;
177
+ line-height: 1.35;
178
+ color: #475569;
179
+ flex: 1;
180
+ }
181
+
182
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-summary {
183
+ color: #94a3b8;
184
+ }
185
+
186
+ .rte-content-rules-count {
187
+ min-width: 32px;
188
+ height: 32px;
189
+ border-radius: 999px;
190
+ display: inline-flex;
191
+ align-items: center;
192
+ justify-content: center;
193
+ font-weight: 700;
194
+ font-size: 13px;
195
+ border: 1px solid #cbd5e1;
196
+ background: #f8fafc;
197
+ }
198
+
199
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-count {
200
+ border-color: #334155;
201
+ background: #111827;
202
+ color: #cbd5e1;
203
+ }
204
+
205
+ .rte-content-rules-controls {
206
+ display: flex;
207
+ gap: 8px;
208
+ flex-wrap: wrap;
209
+ }
210
+
211
+ .rte-content-rules-btn {
212
+ border: 1px solid #cbd5e1;
213
+ border-radius: 8px;
214
+ height: 34px;
215
+ padding: 0 10px;
216
+ background: #ffffff;
217
+ color: inherit;
218
+ font-size: 12px;
219
+ font-weight: 600;
220
+ cursor: pointer;
221
+ }
222
+
223
+ .rte-content-rules-btn:hover,
224
+ .rte-content-rules-btn:focus-visible {
225
+ border-color: #94a3b8;
226
+ background: #f8fafc;
227
+ outline: none;
228
+ }
229
+
230
+ .rte-content-rules-btn-primary {
231
+ border-color: #0284c7;
232
+ background: #0ea5e9;
233
+ color: #f8fafc;
234
+ }
235
+
236
+ .rte-content-rules-btn-primary:hover,
237
+ .rte-content-rules-btn-primary:focus-visible {
238
+ border-color: #0369a1;
239
+ background: #0284c7;
240
+ color: #ffffff;
241
+ }
242
+
243
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-btn {
244
+ border-color: #334155;
245
+ background: #111827;
246
+ color: #e2e8f0;
247
+ }
248
+
249
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-btn:hover,
250
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-btn:focus-visible {
251
+ border-color: #475569;
252
+ background: #1e293b;
253
+ }
254
+
255
+ .rte-content-rules-list {
256
+ list-style: none;
257
+ margin: 0;
258
+ padding: 0;
259
+ display: flex;
260
+ flex-direction: column;
261
+ gap: 8px;
262
+ max-height: min(55vh, 420px);
263
+ overflow: auto;
264
+ }
265
+
266
+ .rte-content-rules-item {
267
+ border: 1px solid #e2e8f0;
268
+ border-radius: 10px;
269
+ padding: 8px;
270
+ background: #ffffff;
271
+ }
272
+
273
+ .rte-content-rules-item-error {
274
+ border-color: #fca5a5;
275
+ background: #fef2f2;
276
+ }
277
+
278
+ .rte-content-rules-item-warning {
279
+ border-color: #fcd34d;
280
+ background: #fffbeb;
281
+ }
282
+
283
+ .rte-content-rules-item-info {
284
+ border-color: #93c5fd;
285
+ background: #eff6ff;
286
+ }
287
+
288
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item {
289
+ border-color: #334155;
290
+ background: #0b1220;
291
+ }
292
+
293
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item-error {
294
+ border-color: #7f1d1d;
295
+ background: #2b0b11;
296
+ }
297
+
298
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item-warning {
299
+ border-color: #78350f;
300
+ background: #2b1907;
301
+ }
302
+
303
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item-info {
304
+ border-color: #1d4ed8;
305
+ background: #0a162f;
306
+ }
307
+
308
+ .rte-content-rules-item-btn {
309
+ width: 100%;
310
+ border: none;
311
+ background: transparent;
312
+ display: flex;
313
+ align-items: flex-start;
314
+ gap: 8px;
315
+ text-align: left;
316
+ padding: 0;
317
+ color: inherit;
318
+ cursor: pointer;
319
+ }
320
+
321
+ .rte-content-rules-item-btn:focus-visible {
322
+ outline: 2px solid #0284c7;
323
+ outline-offset: 3px;
324
+ border-radius: 6px;
325
+ }
326
+
327
+ .rte-content-rules-badge {
328
+ flex: 0 0 auto;
329
+ margin-top: 1px;
330
+ border-radius: 999px;
331
+ border: 1px solid currentColor;
332
+ padding: 1px 8px;
333
+ font-size: 10px;
334
+ font-weight: 700;
335
+ line-height: 1.3;
336
+ text-transform: uppercase;
337
+ opacity: 0.86;
338
+ }
339
+
340
+ .rte-content-rules-message {
341
+ font-size: 13px;
342
+ line-height: 1.35;
343
+ font-weight: 600;
344
+ }
345
+
346
+ .rte-content-rules-excerpt,
347
+ .rte-content-rules-suggestion {
348
+ margin: 8px 0 0;
349
+ font-size: 12px;
350
+ line-height: 1.35;
351
+ color: #334155;
352
+ }
353
+
354
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-excerpt,
355
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-suggestion {
356
+ color: #94a3b8;
357
+ }
358
+
359
+ .rte-content-rules-empty {
360
+ border: 1px dashed #cbd5e1;
361
+ border-radius: 10px;
362
+ padding: 10px;
363
+ font-size: 13px;
364
+ color: #475569;
365
+ background: #f8fafc;
366
+ }
367
+
368
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-empty {
369
+ border-color: #334155;
370
+ background: #0b1220;
371
+ color: #94a3b8;
372
+ }
373
+
374
+ .rte-content-rules-shortcut {
375
+ margin: 2px 0 0;
376
+ font-size: 11px;
377
+ color: #64748b;
378
+ }
379
+
380
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-shortcut {
381
+ color: #94a3b8;
382
+ }
383
+
384
+ .rte-content-rules-live {
385
+ position: absolute;
386
+ width: 1px;
387
+ height: 1px;
388
+ margin: -1px;
389
+ padding: 0;
390
+ overflow: hidden;
391
+ clip: rect(0 0 0 0);
392
+ border: 0;
393
+ }
394
+
395
+ @media (max-width: 768px) {
396
+ .${f} {
397
+ left: 10px !important;
398
+ right: 10px;
399
+ top: 10px !important;
400
+ width: auto !important;
401
+ max-height: calc(100vh - 20px);
402
+ }
403
+
404
+ .rte-content-rules-list {
405
+ max-height: 45vh;
406
+ }
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;