@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 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:()=>{const o=window.getSelection();if(!o||o.rangeCount===0)return!1;let e=o.anchorNode,t=!1;for(;e&&e!==document.body;){if(e.nodeName==="BLOCKQUOTE"){t=!0;break}e=e.parentNode}return t?document.execCommand("formatBlock",!1,"p"):document.execCommand("formatBlock",!1,"blockquote"),!0}},keymap:{"Mod-Shift-9":"toggleBlockquote"}});exports.BlockquotePlugin=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-content, .editora-content, [contenteditable="true"]',L="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",T=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function E(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function w(e){const t=e?.contentElement;if(t instanceof HTMLElement)return t;const n=e?.editorElement;if(n instanceof HTMLElement){const c=n.querySelector(d);if(c instanceof HTMLElement)return c;if(n.getAttribute("contenteditable")==="true")return n}const o=window.getSelection();if(o&&o.rangeCount>0){const c=E(o.getRangeAt(0).startContainer),i=c?.closest(d);if(i instanceof HTMLElement)return i;const f=c?.closest(L)?.querySelector(d);if(f instanceof HTMLElement)return f}const s=document.activeElement?.closest(d);return s instanceof HTMLElement?s:document.querySelector(d)}function B(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:n}function C(e,t){let n=E(t);if(!n||n===e||!e.contains(n))return null;for(;n.parentElement&&n.parentElement!==e;)n=n.parentElement;if(n.parentElement!==e)return null;if(n.matches(T))return n;const o=n.closest(T);return o instanceof HTMLElement&&o.parentElement===e?o:n}function N(e,t){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(t)}catch{return!1}const n=document.createRange();return n.selectNode(t),e.compareBoundaryPoints(Range.END_TO_START,n)<0&&e.compareBoundaryPoints(Range.START_TO_END,n)>0}function b(e,t){const n=C(e,t.startContainer),o=C(e,t.endContainer);if(!n)return[];if(!o||n===o)return[n];const s=Array.from(e.children).filter(c=>c instanceof HTMLElement).filter(c=>N(t,c));return s.length>0?s:[n]}function k(e,t){const o=E(t)?.closest("blockquote");return o instanceof HTMLQuoteElement&&e.contains(o)?o:null}function v(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function M(e){Array.from(e.children).forEach(t=>{v(t)&&t.remove()})}function p(e){M(e);const t=e.parentNode;if(!t)return;Array.from(e.childNodes).forEach(o=>{t.insertBefore(o,e)}),t.removeChild(e)}function y(e){return e.nodeType===Node.TEXT_NODE&&(e.textContent||"").trim()===""}function S(e){const t=Array.from(e.childNodes).filter(o=>!y(o));if(t.length!==1)return null;const n=t[0];return n instanceof HTMLQuoteElement?n:null}function R(e){const t=document.createElement("blockquote");return Array.from(e.childNodes).filter(o=>!y(o)).forEach(o=>{t.appendChild(o)}),t.childNodes.length||(t.innerHTML="<br>"),e.appendChild(t),t}function q(e,t){const n=Array.from(e.querySelectorAll("li")).filter(r=>r instanceof HTMLLIElement&&N(t,r)),o=new Set(n);return n.filter(r=>{let s=r.parentElement?.closest("li");for(;s;){if(o.has(s))return!1;s=s.parentElement?.closest("li")}return!0})}function m(e){const t=window.getSelection();if(!t)return;const n=document.createRange(),o=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;n.selectNodeContents(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function O(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function x(e,t,n){const o=window.execEditorCommand;if(typeof o=="function"){o("recordDomTransaction",e,t,n);return}const r=window.executeEditorCommand;typeof r=="function"&&r("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:n})}function A(e){const t=w(e);if(!t)return!1;const n=B(t);if(!n)return!1;const o=t.innerHTML,r=k(t,n.startContainer),s=k(t,n.endContainer),c=q(t,n),i=b(t,n),h=i.length>0&&i.every(l=>l.tagName==="BLOCKQUOTE");if(r&&r===s){const l=r.firstChild||r;p(r),m(l)}else if(c.length>0){const l=c.map(S);if(l.every(Boolean)){const u=l[0]?.firstChild||c[0];l.forEach(a=>{a&&p(a)}),m(u)}else{const u=c[0];c.forEach(a=>{S(a)||R(a)}),m(u)}}else if(h){const l=i[0].firstChild||i[0];i.forEach(p),m(l)}else{const l=i.filter(a=>a.tagName!=="BLOCKQUOTE");if(l.length===0)return!1;const g=document.createElement("blockquote"),u=l[0];u.parentNode?.insertBefore(g,u),l.forEach(a=>{g.appendChild(a)}),m(g)}const f=t.innerHTML;return o===f?!1:(x(t,o,f),O(t),!0)}const _=()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(e,t)=>A(t)},keymap:{"Mod-Shift-9":"toggleBlockquote"}});exports.BlockquotePlugin=_;
@@ -1,4 +1,178 @@
1
- const c = () => ({
1
+ const d = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", T = [
2
+ "p",
3
+ "div",
4
+ "h1",
5
+ "h2",
6
+ "h3",
7
+ "h4",
8
+ "h5",
9
+ "h6",
10
+ "ul",
11
+ "ol",
12
+ "blockquote",
13
+ "pre",
14
+ "table"
15
+ ].join(",");
16
+ function E(e) {
17
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
18
+ }
19
+ function y(e) {
20
+ const t = e?.contentElement;
21
+ if (t instanceof HTMLElement) return t;
22
+ const n = e?.editorElement;
23
+ if (n instanceof HTMLElement) {
24
+ const c = n.querySelector(d);
25
+ if (c instanceof HTMLElement) return c;
26
+ if (n.getAttribute("contenteditable") === "true") return n;
27
+ }
28
+ const o = window.getSelection();
29
+ if (o && o.rangeCount > 0) {
30
+ const c = E(o.getRangeAt(0).startContainer), i = c?.closest(d);
31
+ if (i instanceof HTMLElement) return i;
32
+ const f = c?.closest(w)?.querySelector(d);
33
+ if (f instanceof HTMLElement) return f;
34
+ }
35
+ const s = document.activeElement?.closest(d);
36
+ return s instanceof HTMLElement ? s : document.querySelector(d);
37
+ }
38
+ function B(e) {
39
+ const t = window.getSelection();
40
+ if (!t || t.rangeCount === 0) return null;
41
+ const n = t.getRangeAt(0);
42
+ return !e.contains(n.startContainer) || !e.contains(n.endContainer) ? null : n;
43
+ }
44
+ function C(e, t) {
45
+ let n = E(t);
46
+ if (!n || n === e || !e.contains(n)) return null;
47
+ for (; n.parentElement && n.parentElement !== e; )
48
+ n = n.parentElement;
49
+ if (n.parentElement !== e) return null;
50
+ if (n.matches(T)) return n;
51
+ const o = n.closest(T);
52
+ return o instanceof HTMLElement && o.parentElement === e ? o : n;
53
+ }
54
+ function S(e, t) {
55
+ if (typeof e.intersectsNode == "function")
56
+ try {
57
+ return e.intersectsNode(t);
58
+ } catch {
59
+ return !1;
60
+ }
61
+ const n = document.createRange();
62
+ return n.selectNode(t), e.compareBoundaryPoints(Range.END_TO_START, n) < 0 && e.compareBoundaryPoints(Range.START_TO_END, n) > 0;
63
+ }
64
+ function b(e, t) {
65
+ const n = C(e, t.startContainer), o = C(e, t.endContainer);
66
+ if (!n) return [];
67
+ if (!o || n === o) return [n];
68
+ const s = Array.from(e.children).filter(
69
+ (c) => c instanceof HTMLElement
70
+ ).filter((c) => S(t, c));
71
+ return s.length > 0 ? s : [n];
72
+ }
73
+ function k(e, t) {
74
+ const o = E(t)?.closest("blockquote");
75
+ return o instanceof HTMLQuoteElement && e.contains(o) ? o : null;
76
+ }
77
+ function v(e) {
78
+ return e.tagName !== "P" || e.attributes.length > 0 || (e.textContent || "").trim() !== "" ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol");
79
+ }
80
+ function R(e) {
81
+ Array.from(e.children).forEach((t) => {
82
+ v(t) && t.remove();
83
+ });
84
+ }
85
+ function p(e) {
86
+ R(e);
87
+ const t = e.parentNode;
88
+ if (!t) return;
89
+ Array.from(e.childNodes).forEach((o) => {
90
+ t.insertBefore(o, e);
91
+ }), t.removeChild(e);
92
+ }
93
+ function L(e) {
94
+ return e.nodeType === Node.TEXT_NODE && (e.textContent || "").trim() === "";
95
+ }
96
+ function N(e) {
97
+ const t = Array.from(e.childNodes).filter((o) => !L(o));
98
+ if (t.length !== 1) return null;
99
+ const n = t[0];
100
+ return n instanceof HTMLQuoteElement ? n : null;
101
+ }
102
+ function M(e) {
103
+ const t = document.createElement("blockquote");
104
+ return Array.from(e.childNodes).filter((o) => !L(o)).forEach((o) => {
105
+ t.appendChild(o);
106
+ }), t.childNodes.length || (t.innerHTML = "<br>"), e.appendChild(t), t;
107
+ }
108
+ function x(e, t) {
109
+ const n = Array.from(e.querySelectorAll("li")).filter(
110
+ (r) => r instanceof HTMLLIElement && S(t, r)
111
+ ), o = new Set(n);
112
+ return n.filter((r) => {
113
+ let s = r.parentElement?.closest("li");
114
+ for (; s; ) {
115
+ if (o.has(s)) return !1;
116
+ s = s.parentElement?.closest("li");
117
+ }
118
+ return !0;
119
+ });
120
+ }
121
+ function m(e) {
122
+ const t = window.getSelection();
123
+ if (!t) return;
124
+ const n = document.createRange(), o = e instanceof HTMLElement && e.querySelector("p,li,h1,h2,h3,h4,h5,h6") || e;
125
+ n.selectNodeContents(o), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
126
+ }
127
+ function q(e) {
128
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
129
+ }
130
+ function O(e, t, n) {
131
+ const o = window.execEditorCommand;
132
+ if (typeof o == "function") {
133
+ o("recordDomTransaction", e, t, n);
134
+ return;
135
+ }
136
+ const r = window.executeEditorCommand;
137
+ typeof r == "function" && r("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: n });
138
+ }
139
+ function A(e) {
140
+ const t = y(e);
141
+ if (!t) return !1;
142
+ const n = B(t);
143
+ if (!n) return !1;
144
+ const o = t.innerHTML, r = k(t, n.startContainer), s = k(t, n.endContainer), c = x(t, n), i = b(t, n), h = i.length > 0 && i.every((l) => l.tagName === "BLOCKQUOTE");
145
+ if (r && r === s) {
146
+ const l = r.firstChild || r;
147
+ p(r), m(l);
148
+ } else if (c.length > 0) {
149
+ const l = c.map(N);
150
+ if (l.every(Boolean)) {
151
+ const u = l[0]?.firstChild || c[0];
152
+ l.forEach((a) => {
153
+ a && p(a);
154
+ }), m(u);
155
+ } else {
156
+ const u = c[0];
157
+ c.forEach((a) => {
158
+ N(a) || M(a);
159
+ }), m(u);
160
+ }
161
+ } else if (h) {
162
+ const l = i[0].firstChild || i[0];
163
+ i.forEach(p), m(l);
164
+ } else {
165
+ const l = i.filter((a) => a.tagName !== "BLOCKQUOTE");
166
+ if (l.length === 0) return !1;
167
+ const g = document.createElement("blockquote"), u = l[0];
168
+ u.parentNode?.insertBefore(g, u), l.forEach((a) => {
169
+ g.appendChild(a);
170
+ }), m(g);
171
+ }
172
+ const f = t.innerHTML;
173
+ return o === f ? !1 : (O(t, o, f), q(t), !0);
174
+ }
175
+ const H = () => ({
2
176
  name: "blockquote",
3
177
  // Schema definition for blockquote node
4
178
  nodes: {
@@ -23,19 +197,7 @@ const c = () => ({
23
197
  /**
24
198
  * Toggle blockquote formatting on current selection
25
199
  */
26
- toggleBlockquote: () => {
27
- const e = window.getSelection();
28
- if (!e || e.rangeCount === 0) return !1;
29
- let o = e.anchorNode, t = !1;
30
- for (; o && o !== document.body; ) {
31
- if (o.nodeName === "BLOCKQUOTE") {
32
- t = !0;
33
- break;
34
- }
35
- o = o.parentNode;
36
- }
37
- return t ? document.execCommand("formatBlock", !1, "p") : document.execCommand("formatBlock", !1, "blockquote"), !0;
38
- }
200
+ toggleBlockquote: (e, t) => A(t)
39
201
  },
40
202
  // Keyboard shortcuts
41
203
  keymap: {
@@ -43,5 +205,5 @@ const c = () => ({
43
205
  }
44
206
  });
45
207
  export {
46
- c as BlockquotePlugin
208
+ H as BlockquotePlugin
47
209
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Pe=80,Be=new Set(["script","style","meta","link","object","embed","iframe"]),De=/^(https?:|mailto:|tel:|#|\/)/i,Oe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Ne={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,Ke=0,ke=0,M=null,y=null,_=null,P=null,A=null,D=null;function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function je(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function We(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(De.test(t)||Oe.test(t))?t:""}function xe(e){let t=e;return Be.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Fe(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Be.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ge(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function Ce(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=We(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),R=Ge(a),V=[n,h,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||je,r=e.sanitizeBlockHtml||Fe,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...Ne,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=Ce(e.blocks,o),o}function Ue(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Ve(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Ye(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function $e(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function S(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Ve();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=$e(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Xe(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=$e(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(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 Ze(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Ze(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Ye(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=Re(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Te(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function Je(e){const t=Te(e);return t?(He(e,t),!0):!1}function Qe(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function et(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),O.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),Qe(e),r}function Me(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Me(e),et(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),O.delete(e),oe.delete(e),y===e&&(y=null)}function tt(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function rt(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ae(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>Pe){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function ot(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function N(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=rt(e,r);c.innerHTML=B.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;h.disabled=!B,h.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ae(e,r);ot(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,qe=p.tags.length?` • ${p.tags.join(", ")}`:"",_e=B.has(p.id),me=p.previewText.slice(0,180);return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',De=80,Be=new Set(["script","style","meta","link","object","embed","iframe"]),Oe=/^(https?:|mailto:|tel:|#|\/)/i,Ke=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Ne={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,je=0,ke=0,M=null,y=null,_=null,P=null,A=null,D=null;function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function We(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Fe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(Oe.test(t)||Ke.test(t))?t:""}function xe(e){let t=e;return Be.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Ge(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Be.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ue(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function Ce(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=Fe(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),R=Ue(a),V=[n,h,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||We,r=e.sanitizeBlockHtml||Ge,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...Ne,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=Ce(e.blocks,o),o}function Ve(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Ye(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Xe(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function $e(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function S(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Ye();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=$e(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Ze(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=$e(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(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 Je(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Je(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Xe(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=Re(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Te(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function Qe(e){const t=Te(e);return t?(He(e,t),!0):!1}function et(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function tt(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),O.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),et(e),r}function Me(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Me(e),tt(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),O.delete(e),oe.delete(e),y===e&&(y=null)}function rt(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function ot(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ae(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>De){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function nt(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function K(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=ot(e,r);c.innerHTML=B.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;h.disabled=!B,h.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ae(e,r);nt(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,_e=p.tags.length?` • ${p.tags.join(", ")}`:"",Pe=B.has(p.id),me=p.previewText.slice(0,180);return`
2
2
  <li class="rte-blocks-library-item-wrapper" role="presentation">
3
3
  <button
4
4
  type="button"
@@ -11,14 +11,14 @@
11
11
  >
12
12
  <span class="rte-blocks-library-item-head">
13
13
  <span class="rte-blocks-library-item-label">${m(p.label)}</span>
14
- ${_e?`<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>`:""}
14
+ ${Pe?`<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>`:""}
15
15
  </span>
16
- <span class="rte-blocks-library-item-meta">${m(p.category)}${m(qe)}</span>
16
+ <span class="rte-blocks-library-item-meta">${m(p.category)}${m(_e)}</span>
17
17
  ${p.description?`<span class="rte-blocks-library-item-description">${m(p.description)}</span>`:""}
18
18
  ${me?`<span class="rte-blocks-library-item-preview">${m(me)}</span>`:""}
19
19
  </button>
20
20
  </li>
21
- `}).join("")}R&&(R.hidden=H.length>0,R.textContent=r.labels.noResultsText);const K=t.querySelector(".rte-blocks-library-last-inserted");if(K)if(o.lastInsertedBlockId){const B=ae(e).find(p=>p.id===o.lastInsertedBlockId);B?(K.hidden=!1,K.textContent=`${r.labels.lastInsertedPrefix}: ${B.label}`):K.hidden=!0}else K.hidden=!0;t.setAttribute("aria-label",r.labels.panelAriaLabel)}function T(e,t=!1){const r=x.get(e);r&&(r.classList.remove("show"),U.set(e,!1),N(e),t&&(e.focus({preventScroll:!0}),Je(e)))}function nt(e){e.querySelector(".rte-blocks-library-item.active")?.focus()}function ve(e,t){const r=b.get(e)||M;if(!r)return;const o=w.get(e);if(!o)return;const l=Ae(e,r);if(l.length===0)return;const a=(Math.max(0,l.findIndex(i=>i.id===o.selectedBlockId))+t+l.length)%l.length;o.selectedBlockId=l[a].id,L(e);const s=x.get(e);s&&nt(s)}function de(e){const t=ct(e);se(e),x.forEach((o,l)=>{l!==e&&T(l,!1)}),t.classList.add("show"),U.set(e,!0),L(e),ue(e,t),N(e),t.querySelector('[data-field="query"]')?.focus(),be(e,!1)}function Ie(e,t){const r=pe(e);return(typeof t=="boolean"?t:!r)?de(e):T(e,!1),!0}function Re(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null}function He(e,t){if(!e.isConnected)return;const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function Le(e,t,r){const o=t.cloneRange();if(!e.contains(o.commonAncestorContainer))return!1;o.deleteContents();const l=document.createElement("template");l.innerHTML=r;const n=l.content;if(!n)return!1;const a=n.lastChild;if(o.insertNode(n),a){const s=document.createRange();s.setStartAfter(a),s.collapse(!0),He(e,s)}return se(e),!0}function lt(e,t){e.focus({preventScroll:!0});const r=Te(e);if(r&&Le(e,r,t))return!0;try{if(document.execCommand("insertHTML",!1,t))return se(e),!0}catch{}const o=Re(e);return o?Le(e,o,t):!1}function st(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function at(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function F(e,t){const r=b.get(e)||M;if(!r)return!1;const o=k(e,r),l=x.get(e);if(Se(e))return l&&Ee(l,r.labels.readonlyMessage),!1;const n=ae(e).find(i=>i.id===t);if(!n)return!1;const a=e.innerHTML;return lt(e,n.html)?(o.lastInsertedBlockId=n.id,o.selectedBlockId=n.id,o.recentBlockIds=[n.id,...o.recentBlockIds.filter(i=>i!==n.id)].slice(0,r.maxRecentBlocks),st(e,a),at(e),N(e),e.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:n.id,label:n.label,category:n.category}})),L(e),l&&Ee(l,`${r.labels.lastInsertedPrefix}: ${n.label}`),!0):!1}function ze(e){const t=w.get(e);return t?.lastInsertedBlockId?F(e,t.lastInsertedBlockId):!1}function it(e){const t=b.get(e)||M;if(!t)return;const r=w.get(e);if(!r)return;Me(e);const o=()=>{r.debounceTimer=null,r.filterCache.clear(),L(e)};if(t.debounceMs<=0){o();return}r.debounceTimer=window.setTimeout(o,t.debounceMs)}function ct(e){const t=x.get(e);if(t)return t;const r=b.get(e)||M||Q(),o=k(e,r),l=`rte-blocks-library-panel-${Ke++}`,n=`${l}-query`,a=`${l}-category`,s=document.createElement("section");return s.className=d,s.id=l,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",r.labels.panelAriaLabel),s.innerHTML=`
21
+ `}).join("")}R&&(R.hidden=H.length>0,R.textContent=r.labels.noResultsText);const N=t.querySelector(".rte-blocks-library-last-inserted");if(N)if(o.lastInsertedBlockId){const B=ae(e).find(p=>p.id===o.lastInsertedBlockId);B?(N.hidden=!1,N.textContent=`${r.labels.lastInsertedPrefix}: ${B.label}`):N.hidden=!0}else N.hidden=!0;t.setAttribute("aria-label",r.labels.panelAriaLabel)}function T(e,t=!1){const r=x.get(e);r&&(r.classList.remove("show"),U.set(e,!1),K(e),t&&(e.focus({preventScroll:!0}),Qe(e)))}function lt(e){e.querySelector(".rte-blocks-library-item.active")?.focus()}function ve(e,t){const r=b.get(e)||M;if(!r)return;const o=w.get(e);if(!o)return;const l=Ae(e,r);if(l.length===0)return;const a=(Math.max(0,l.findIndex(i=>i.id===o.selectedBlockId))+t+l.length)%l.length;o.selectedBlockId=l[a].id,L(e);const s=x.get(e);s&&lt(s)}function de(e){const t=ut(e);se(e),x.forEach((o,l)=>{l!==e&&T(l,!1)}),t.classList.add("show"),U.set(e,!0),L(e),ue(e,t),K(e),t.querySelector('[data-field="query"]')?.focus(),be(e,!1)}function Ie(e,t){const r=pe(e);return(typeof t=="boolean"?t:!r)?de(e):T(e,!1),!0}function Re(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null}function He(e,t){if(!e.isConnected)return;const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function Le(e,t,r){const o=t.cloneRange();if(!e.contains(o.commonAncestorContainer))return!1;o.deleteContents();const l=document.createElement("template");l.innerHTML=r;const n=l.content;if(!n)return!1;const a=n.lastChild;if(o.insertNode(n),a){const s=document.createRange();s.setStartAfter(a),s.collapse(!0),He(e,s)}return se(e),!0}function st(e,t){e.focus({preventScroll:!0});const r=Te(e);if(r&&Le(e,r,t))return!0;try{if(document.execCommand("insertHTML",!1,t))return se(e),!0}catch{}const o=Re(e);return o?Le(e,o,t):!1}function at(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function it(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function F(e,t){const r=b.get(e)||M;if(!r)return!1;const o=k(e,r),l=x.get(e);if(Se(e))return l&&Ee(l,r.labels.readonlyMessage),!1;const n=ae(e).find(i=>i.id===t);if(!n)return!1;const a=e.innerHTML;return st(e,n.html)?(o.lastInsertedBlockId=n.id,o.selectedBlockId=n.id,o.recentBlockIds=[n.id,...o.recentBlockIds.filter(i=>i!==n.id)].slice(0,r.maxRecentBlocks),at(e,a),it(e),K(e),e.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:n.id,label:n.label,category:n.category}})),L(e),l&&Ee(l,`${r.labels.lastInsertedPrefix}: ${n.label}`),!0):!1}function ze(e){const t=w.get(e);return t?.lastInsertedBlockId?F(e,t.lastInsertedBlockId):!1}function ct(e){const t=b.get(e)||M;if(!t)return;const r=w.get(e);if(!r)return;Me(e);const o=()=>{r.debounceTimer=null,r.filterCache.clear(),L(e)};if(t.debounceMs<=0){o();return}r.debounceTimer=window.setTimeout(o,t.debounceMs)}function ut(e){const t=x.get(e);if(t)return t;const r=b.get(e)||M||Q(),o=k(e,r),l=`rte-blocks-library-panel-${je++}`,n=`${l}-query`,a=`${l}-category`,s=document.createElement("section");return s.className=d,s.id=l,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",r.labels.panelAriaLabel),s.innerHTML=`
22
22
  <header class="rte-blocks-library-header">
23
23
  <h2 class="rte-blocks-library-title">${m(r.labels.panelTitle)}</h2>
24
24
  <button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${m(r.labels.closeText)}">✕</button>
@@ -41,7 +41,7 @@
41
41
  <p class="rte-blocks-library-shortcut"></p>
42
42
  </div>
43
43
  <div class="rte-blocks-library-live" aria-live="polite" aria-atomic="true"></div>
44
- `,s.addEventListener("click",i=>{const c=i.target,u=c?.closest("[data-action]");if(u){const h=u.getAttribute("data-action");if(h==="close"){T(e,!0);return}if(h==="insert-selected"){if(!o.selectedBlockId)return;F(e,o.selectedBlockId)&&T(e,!0)}return}const f=c?.closest("[data-block-id]");if(!f)return;const g=f.getAttribute("data-block-id");g&&(o.selectedBlockId=g,L(e),i.detail>=2&&F(e,g)&&T(e,!0))}),s.addEventListener("input",i=>{const c=i.target;!(c instanceof HTMLInputElement)||c.getAttribute("data-field")!=="query"||(o.query=r.normalizeText(c.value).toLowerCase(),o.filterCache.clear(),it(e))}),s.addEventListener("change",i=>{const c=i.target;!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="category"||(o.category=ne(c.value||"all")||"all",o.filterCache.clear(),L(e))}),s.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),T(e,!0);return}if(i.key==="ArrowDown"){i.preventDefault(),ve(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),ve(e,-1);return}if(i.key==="Enter"){if(!i.target?.matches('[data-field="query"], [data-field="category"], [data-block-id]')||!o.selectedBlockId)return;i.preventDefault(),F(e,o.selectedBlockId)&&T(e,!0)}}),re(s,e),document.body.appendChild(s),x.set(e,s),U.set(e,!1),L(e),s}function ut(e){const t=w.get(e);return{query:t?.query||"",category:t?.category||"all",selectedBlockId:t?.selectedBlockId||null,totalMatches:t?.totalMatches||0,visibleMatches:t?.visibleMatches||0,recentBlockIds:t?.recentBlockIds?[...t.recentBlockIds]:[],lastInsertedBlockId:t?.lastInsertedBlockId||null,loading:t?.loading===!0,loadError:t?.loadError||null}}async function be(e,t){const r=b.get(e)||M;if(!r||typeof r.getBlocks!="function")return;const o=k(e,r),l=O.get(e)||0;if(!t&&r.cacheTtlMs>0&&Date.now()-l<r.cacheTtlMs)return;const n=j.get(e);if(n&&!t)return n;const a=W.get(e);a&&a.abort(),t&&n&&j.delete(e);const s=new AbortController;W.set(e,s);const i=(z.get(e)||0)+1;z.set(e,i),o.loading=!0,o.loadError=null,L(e);const c=Promise.resolve().then(async()=>{const u={editor:e,editorRoot:le(e),signal:s.signal},f=await r.getBlocks?.(u);if(s.signal.aborted||z.get(e)!==i)return;const g=Ce(f||[],r);I.set(e,g),O.set(e,Date.now());const h=w.get(e);h&&(h.loading=!1,h.loadError=null,h.filterCache.clear())}).catch(()=>{if(s.signal.aborted||z.get(e)!==i)return;const u=w.get(e);u&&(u.loading=!1,u.loadError=r.labels.loadErrorText)}).finally(()=>{z.get(e)===i&&(j.delete(e),W.delete(e)),L(e)});return j.set(e,c),c}function dt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="b"}function bt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function ft(e){M=e,_||(_=t=>{ee();const o=t.target?.closest(v);if(!o)return;const l=b.get(o)||e;k(o,l),b.set(o,l),y=o,N(o);const n=x.get(o);n&&(re(n,o),ue(o,n),L(o))},document.addEventListener("focusin",_,!0)),P||(P=t=>{if(t.defaultPrevented)return;const r=`.${d} input, .${d} textarea, .${d} select`,o=t.target;if(o?.closest(r)){if(t.key==="Escape"){const a=o.closest(`.${d}`),s=Array.from(x.entries()).find(([,i])=>i===a);s&&(t.preventDefault(),T(s[0],!0))}return}const l=Xe(t);if(!l)return;const n=b.get(l)||M||e;if(k(l,n),b.set(l,n),y=l,t.key==="Escape"&&pe(l)){t.preventDefault(),T(l,!0);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),Ie(l);return}bt(t)&&(t.preventDefault(),t.stopPropagation(),ze(l))},document.addEventListener("keydown",P,!0)),A||(A=()=>{ee(),x.forEach((t,r)=>{!r.isConnected||!t.isConnected||(re(t,r),ue(r,t))})},window.addEventListener("scroll",A,!0),window.addEventListener("resize",A)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{tt(t)&&ee()}),D.observe(document.body,{childList:!0,subtree:!0}))}function gt(){_&&(document.removeEventListener("focusin",_,!0),_=null),P&&(document.removeEventListener("keydown",P,!0),P=null),A&&(window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A),A=null),D&&(D.disconnect(),D=null),x.forEach(t=>t.remove()),x.clear(),Array.from(oe).forEach(t=>ge(t)),M=null,y=null}function pt(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
44
+ `,s.addEventListener("click",i=>{const c=i.target,u=c?.closest("[data-action]");if(u){const h=u.getAttribute("data-action");if(h==="close"){T(e,!0);return}if(h==="insert-selected"){if(!o.selectedBlockId)return;F(e,o.selectedBlockId)&&T(e,!0)}return}const f=c?.closest("[data-block-id]");if(!f)return;const g=f.getAttribute("data-block-id");g&&(o.selectedBlockId=g,L(e),i.detail>=2&&F(e,g)&&T(e,!0))}),s.addEventListener("input",i=>{const c=i.target;!(c instanceof HTMLInputElement)||c.getAttribute("data-field")!=="query"||(o.query=r.normalizeText(c.value).toLowerCase(),o.filterCache.clear(),ct(e))}),s.addEventListener("change",i=>{const c=i.target;!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="category"||(o.category=ne(c.value||"all")||"all",o.filterCache.clear(),L(e))}),s.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),T(e,!0);return}if(i.key==="ArrowDown"){i.preventDefault(),ve(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),ve(e,-1);return}if(i.key==="Enter"){if(!i.target?.matches('[data-field="query"], [data-field="category"], [data-block-id]')||!o.selectedBlockId)return;i.preventDefault(),F(e,o.selectedBlockId)&&T(e,!0)}}),re(s,e),document.body.appendChild(s),x.set(e,s),U.set(e,!1),L(e),s}function dt(e){const t=w.get(e);return{query:t?.query||"",category:t?.category||"all",selectedBlockId:t?.selectedBlockId||null,totalMatches:t?.totalMatches||0,visibleMatches:t?.visibleMatches||0,recentBlockIds:t?.recentBlockIds?[...t.recentBlockIds]:[],lastInsertedBlockId:t?.lastInsertedBlockId||null,loading:t?.loading===!0,loadError:t?.loadError||null}}async function be(e,t){const r=b.get(e)||M;if(!r||typeof r.getBlocks!="function")return;const o=k(e,r),l=O.get(e)||0;if(!t&&r.cacheTtlMs>0&&Date.now()-l<r.cacheTtlMs)return;const n=j.get(e);if(n&&!t)return n;const a=W.get(e);a&&a.abort(),t&&n&&j.delete(e);const s=new AbortController;W.set(e,s);const i=(z.get(e)||0)+1;z.set(e,i),o.loading=!0,o.loadError=null,L(e);const c=Promise.resolve().then(async()=>{const u={editor:e,editorRoot:le(e),signal:s.signal},f=await r.getBlocks?.(u);if(s.signal.aborted||z.get(e)!==i)return;const g=Ce(f||[],r);I.set(e,g),O.set(e,Date.now());const h=w.get(e);h&&(h.loading=!1,h.loadError=null,h.filterCache.clear())}).catch(()=>{if(s.signal.aborted||z.get(e)!==i)return;const u=w.get(e);u&&(u.loading=!1,u.loadError=r.labels.loadErrorText)}).finally(()=>{z.get(e)===i&&(j.delete(e),W.delete(e)),L(e)});return j.set(e,c),c}function qe(e){return typeof e.key=="string"?e.key.toLowerCase():""}function bt(e){const t=qe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="b"}function ft(e){const t=qe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function gt(e){M=e,_||(_=t=>{ee();const o=t.target?.closest(v);if(!o)return;const l=b.get(o)||e;k(o,l),b.set(o,l),y=o,K(o);const n=x.get(o);n&&(re(n,o),ue(o,n),L(o))},document.addEventListener("focusin",_,!0)),P||(P=t=>{if(t.defaultPrevented)return;const r=`.${d} input, .${d} textarea, .${d} select`,o=t.target;if(o?.closest(r)){if(t.key==="Escape"){const a=o.closest(`.${d}`),s=Array.from(x.entries()).find(([,i])=>i===a);s&&(t.preventDefault(),T(s[0],!0))}return}const l=Ze(t);if(!l)return;const n=b.get(l)||M||e;if(k(l,n),b.set(l,n),y=l,t.key==="Escape"&&pe(l)){t.preventDefault(),T(l,!0);return}if(bt(t)){t.preventDefault(),t.stopPropagation(),Ie(l);return}ft(t)&&(t.preventDefault(),t.stopPropagation(),ze(l))},document.addEventListener("keydown",P,!0)),A||(A=()=>{ee(),x.forEach((t,r)=>{!r.isConnected||!t.isConnected||(re(t,r),ue(r,t))})},window.addEventListener("scroll",A,!0),window.addEventListener("resize",A)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{rt(t)&&ee()}),D.observe(document.body,{childList:!0,subtree:!0}))}function pt(){_&&(document.removeEventListener("focusin",_,!0),_=null),P&&(document.removeEventListener("keydown",P,!0),P=null),A&&(window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A),A=null),D&&(D.disconnect(),D=null),x.forEach(t=>t.remove()),x.clear(),Array.from(oe).forEach(t=>ge(t)),M=null,y=null}function mt(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
45
45
  .rte-toolbar-group-items.${E},
46
46
  .editora-toolbar-group-items.${E},
47
47
  .rte-toolbar-group-items.${C},
@@ -439,4 +439,4 @@
439
439
  max-height: calc(100vh - 20px);
440
440
  }
441
441
  }
442
- `,document.head.appendChild(e)}const mt=(e={})=>{const t=Q(e),r=new Set;return pt(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",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="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},openBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},toggleBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,Ie(n,typeof o=="boolean"?o:void 0)},insertBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a),b.set(n,a);const s=typeof o=="string"?o:o?.id;return s?(y=n,F(n,s)):!1},insertLastBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ze(n)},refreshBlocksLibraryData:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),be(n,!0),!0},setBlocksLibraryOptions:(o,l)=>{const n=S(l,!1,!1);if(!n||!o||typeof o!="object")return!1;const a=b.get(n)||t,s=J.get(n)||Ue(a),i={...s,...o,labels:{...s.labels||{},...o.labels||{}},blocks:Array.isArray(o.blocks)?o.blocks:s.blocks,normalizeText:o.normalizeText||a.normalizeText,sanitizeBlockHtml:o.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:o.getBlocks||a.getBlocks},c=Q(i),u=Array.isArray(o.blocks),f=o.getBlocks!==void 0;b.set(n,c),J.set(n,i),(u||f||!I.has(n))&&(I.set(n,c.blocks),O.set(n,f?0:Date.now()));const g=k(n,c);return g.filterCache.clear(),typeof o.defaultCategory=="string"&&(g.category=ne(c.defaultCategory)||"all"),L(n),N(n),f&&be(n,!0),!0},getBlocksLibraryState:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a);const s=ut(n);if(typeof o=="function")try{o(s)}catch{}return n.__blocksLibraryState=s,n.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(l){X+=1;const n=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Q(n);ft(a);const s=S(l?.editorElement?{editorElement:l.editorElement}:void 0,!1,!1);s&&(y=s,r.add(s),k(s,a),b.set(s,a),J.set(s,n),I.set(s,a.blocks),O.set(s,Date.now()),N(s))},destroy:()=>{r.forEach(o=>ge(o)),r.clear(),X=Math.max(0,X-1),!(X>0)&&gt()}}};exports.BlocksLibraryPlugin=mt;
442
+ `,document.head.appendChild(e)}const yt=(e={})=>{const t=Q(e),r=new Set;return mt(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",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="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},openBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},toggleBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,Ie(n,typeof o=="boolean"?o:void 0)},insertBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a),b.set(n,a);const s=typeof o=="string"?o:o?.id;return s?(y=n,F(n,s)):!1},insertLastBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ze(n)},refreshBlocksLibraryData:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),be(n,!0),!0},setBlocksLibraryOptions:(o,l)=>{const n=S(l,!1,!1);if(!n||!o||typeof o!="object")return!1;const a=b.get(n)||t,s=J.get(n)||Ve(a),i={...s,...o,labels:{...s.labels||{},...o.labels||{}},blocks:Array.isArray(o.blocks)?o.blocks:s.blocks,normalizeText:o.normalizeText||a.normalizeText,sanitizeBlockHtml:o.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:o.getBlocks||a.getBlocks},c=Q(i),u=Array.isArray(o.blocks),f=o.getBlocks!==void 0;b.set(n,c),J.set(n,i),(u||f||!I.has(n))&&(I.set(n,c.blocks),O.set(n,f?0:Date.now()));const g=k(n,c);return g.filterCache.clear(),typeof o.defaultCategory=="string"&&(g.category=ne(c.defaultCategory)||"all"),L(n),K(n),f&&be(n,!0),!0},getBlocksLibraryState:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a);const s=dt(n);if(typeof o=="function")try{o(s)}catch{}return n.__blocksLibraryState=s,n.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(l){X+=1;const n=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Q(n);gt(a);const s=S(l?.editorElement?{editorElement:l.editorElement}:void 0,!1,!1);s&&(y=s,r.add(s),k(s,a),b.set(s,a),J.set(s,n),I.set(s,a.blocks),O.set(s,Date.now()),K(s))},destroy:()=>{r.forEach(o=>ge(o)),r.clear(),X=Math.max(0,X-1),!(X>0)&&pt()}}};exports.BlocksLibraryPlugin=yt;