@editora/plugins 1.0.2 → 1.0.4

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 (105) hide show
  1. package/README.md +30 -5
  2. package/dist/a11y-checker.cjs.js +109 -0
  3. package/dist/a11y-checker.esm.js +509 -0
  4. package/dist/anchor.cjs.js +176 -0
  5. package/dist/anchor.esm.js +400 -0
  6. package/dist/background-color.cjs.js +218 -0
  7. package/dist/background-color.esm.js +482 -0
  8. package/dist/blockquote.cjs.js +1 -0
  9. package/dist/blockquote.esm.js +47 -0
  10. package/dist/bold.cjs.js +1 -0
  11. package/dist/bold.esm.js +44 -0
  12. package/dist/capitalization.cjs.js +1 -0
  13. package/dist/capitalization.esm.js +78 -0
  14. package/dist/checklist.cjs.js +1 -0
  15. package/dist/checklist.esm.js +305 -0
  16. package/dist/clear-formatting.cjs.js +1 -0
  17. package/dist/clear-formatting.esm.js +138 -0
  18. package/dist/code-sample.cjs.js +161 -0
  19. package/dist/code-sample.esm.js +381 -0
  20. package/dist/code.cjs.js +598 -0
  21. package/dist/code.esm.js +2034 -0
  22. package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
  23. package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
  24. package/dist/comments.cjs.js +354 -0
  25. package/dist/comments.esm.js +692 -0
  26. package/dist/direction.cjs.js +1 -0
  27. package/dist/direction.esm.js +129 -0
  28. package/dist/document-manager.cjs.js +1 -0
  29. package/dist/document-manager.esm.js +6 -0
  30. package/dist/{documentManager-CYC9totK.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
  31. package/dist/{documentManager-BGlu3WRB.js → documentManager-_tQQfQi9.js} +3 -3
  32. package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
  33. package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
  34. package/dist/embed-iframe.cjs.js +361 -0
  35. package/dist/embed-iframe.esm.js +556 -0
  36. package/dist/emojis.cjs.js +284 -0
  37. package/dist/emojis.esm.js +1080 -0
  38. package/dist/font-family.cjs.js +1 -0
  39. package/dist/font-family.esm.js +152 -0
  40. package/dist/font-size.cjs.js +1 -0
  41. package/dist/font-size.esm.js +278 -0
  42. package/dist/footnote.cjs.js +85 -0
  43. package/dist/footnote.esm.js +397 -0
  44. package/dist/fullscreen.cjs.js +1 -0
  45. package/dist/fullscreen.esm.js +73 -0
  46. package/dist/heading.cjs.js +1 -0
  47. package/dist/heading.esm.js +63 -0
  48. package/dist/history.cjs.js +1 -0
  49. package/dist/history.esm.js +246 -0
  50. package/dist/indent.cjs.js +1 -0
  51. package/dist/indent.esm.js +146 -0
  52. package/dist/index-Bskk414V.mjs +145 -0
  53. package/dist/index-D3pJyAsj.js +1 -0
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/{index.es-B-to-4j4.js → index.es-Cz1qItab.js} +1 -1
  56. package/dist/{index.es-BbXJ7tyO.mjs → index.es-DEcRmSTY.mjs} +1 -1
  57. package/dist/index.esm.js +89 -49
  58. package/dist/italic.cjs.js +1 -0
  59. package/dist/italic.esm.js +40 -0
  60. package/dist/line-height.cjs.js +1 -0
  61. package/dist/line-height.esm.js +145 -0
  62. package/dist/link.cjs.js +138 -0
  63. package/dist/link.esm.js +276 -0
  64. package/dist/list.cjs.js +1 -0
  65. package/dist/list.esm.js +102 -0
  66. package/dist/lite.cjs.js +1 -0
  67. package/dist/lite.esm.js +61 -0
  68. package/dist/math.cjs.js +45 -0
  69. package/dist/math.esm.js +249 -0
  70. package/dist/media-manager.cjs.js +619 -0
  71. package/dist/media-manager.esm.js +994 -0
  72. package/dist/merge-tag.cjs.js +93 -0
  73. package/dist/merge-tag.esm.js +412 -0
  74. package/dist/page-break.cjs.js +72 -0
  75. package/dist/page-break.esm.js +295 -0
  76. package/dist/plugins.css +1 -1
  77. package/dist/preview.cjs.js +230 -0
  78. package/dist/preview.esm.js +321 -0
  79. package/dist/print.cjs.js +254 -0
  80. package/dist/print.esm.js +309 -0
  81. package/dist/purify.es-DHhaBdbu.mjs +470 -0
  82. package/dist/purify.es-T2a3nLiC.js +3 -0
  83. package/dist/shared-config.cjs.js +1 -0
  84. package/dist/shared-config.esm.js +30 -0
  85. package/dist/special-characters.cjs.js +257 -0
  86. package/dist/special-characters.esm.js +772 -0
  87. package/dist/spell-check.cjs.js +512 -0
  88. package/dist/spell-check.esm.js +1013 -0
  89. package/dist/strikethrough.cjs.js +1 -0
  90. package/dist/strikethrough.esm.js +71 -0
  91. package/dist/table.cjs.js +35 -0
  92. package/dist/table.esm.js +477 -0
  93. package/dist/template.cjs.js +356 -0
  94. package/dist/template.esm.js +560 -0
  95. package/dist/text-alignment.cjs.js +1 -0
  96. package/dist/text-alignment.esm.js +105 -0
  97. package/dist/text-color.cjs.js +300 -0
  98. package/dist/text-color.esm.js +507 -0
  99. package/dist/underline.cjs.js +1 -0
  100. package/dist/underline.esm.js +34 -0
  101. package/index.d.ts +62 -0
  102. package/package.json +218 -6
  103. package/LICENSE +0 -21
  104. package/dist/index-BbORIHoM.mjs +0 -11763
  105. package/dist/index-C-OCBS_6.js +0 -3753
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N="__editoraCommandEditorRoot",w=t=>{if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null},A=()=>{if(typeof window>"u")return null;const t=window[N];if(!(t instanceof HTMLElement))return null;window[N]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const r=w(e);if(r)return r;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null},S=()=>{const t=A();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){let r=e.getRangeAt(0).startContainer;for(;r&&r!==document.body;){if(r.nodeType===Node.ELEMENT_NODE){const o=r;if(o.getAttribute("contenteditable")==="true")return o}r=r.parentNode}}const n=document.activeElement;if(n){if(n.getAttribute("contenteditable")==="true")return n;const r=n.closest('[contenteditable="true"]');if(r)return r}return document.querySelector('[contenteditable="true"]')},_=t=>t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null,H=t=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n:null},y=t=>{t.dispatchEvent(new Event("input",{bubbles:!0}))},M=(t,e)=>{if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch{}},k=(t,e)=>{if(!t.isConnected){e.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.selectNodeContents(t),r.collapse(!1),n.removeAllRanges();try{n.addRange(r)}catch{e.focus({preventScroll:!0});return}e.focus({preventScroll:!0})},I=t=>{let e=t.querySelector(":scope > p");if(!e){e=document.createElement("p");const n=[];t.childNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(r.tagName)||n.push(r)}),n.forEach(r=>e.appendChild(r)),t.insertBefore(e,t.firstChild)}return e.innerHTML.trim()||(e.innerHTML="<br>"),e},C=t=>{const e=document.createElement("li");e.setAttribute("data-type","checklist-item"),e.setAttribute("data-checked","false");const n=document.createElement("p");return n.innerHTML=t.trim()||"<br>",e.appendChild(n),e},T=t=>Array.from(t.children).filter(e=>e instanceof HTMLLIElement),R=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),b=t=>R.has(t.tagName)&&t.getAttribute("contenteditable")!=="true",v=(t,e)=>{const n=[],r=new Set,o=i=>{!i||r.has(i)||e.contains(i)&&b(i)&&(i.closest("ul, ol")||(r.add(i),n.push(i)))},u=i=>{let a=i;for(;a&&a!==document.body;){if(a.nodeType===Node.ELEMENT_NODE){const h=a;if(b(h))return h;if(h.getAttribute("contenteditable")==="true")break}a=a.parentNode}return null};if(t.collapsed)return o(u(t.startContainer)),n;const d=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const a=i;if(!b(a)||a.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof t.intersectsNode=="function")return t.intersectsNode(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const h=document.createRange();return h.selectNodeContents(a),t.compareBoundaryPoints(Range.END_TO_START,h)>0&&t.compareBoundaryPoints(Range.START_TO_END,h)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let l=d.nextNode();for(;l;)o(l),l=d.nextNode();if(n.length===0&&o(u(t.commonAncestorContainer)),n.length<=1)return n;const m=n.filter(i=>!n.some(a=>a!==i&&i.contains(a)));return m.length>0?m:n},O=t=>{const e=[],n=document.createElement("div"),r=()=>{const o=n.innerHTML.trim();if(!o)return;const u=document.createElement("p");u.innerHTML=o,e.push(u),n.innerHTML=""};if(t.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){r();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){r();const u=o.innerHTML.trim(),d=document.createElement("p");d.innerHTML=u||"<br>",e.push(d);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||n.appendChild(o.cloneNode(!0))}),r(),e.length===0){const o=document.createElement("p");o.innerHTML="<br>",e.push(o)}return e},P=()=>({name:"checklist",init:()=>{if(typeof document>"u"||typeof window>"u"||window.__checklistPluginClickInitialized)return;window.__checklistPluginClickInitialized=!0;const t=e=>{const r=e.target.closest('li[data-type="checklist-item"]');if(!r)return;const o=r.getBoundingClientRect();if(!(e.clientX-o.left<32))return;e.preventDefault(),e.stopPropagation();const l=r.closest("[contenteditable], .rte-content, .editora-content");if(l?.getAttribute("contenteditable")==="false"||!!l?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const i=l?.innerHTML||"",a=r.getAttribute("data-checked")==="true";r.setAttribute("data-checked",(!a).toString()),l&&(M(l,i),y(l))};document.addEventListener("click",t)},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:t=>({checked:t.getAttribute("data-checked")==="true"})}],toDOM:t=>["li",{"data-type":"checklist-item","data-checked":t?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const t=S();if(!t)return!1;const e=t.innerHTML,n=()=>(M(t,e),y(t),!0),r=H(t);if(!r)return!1;const o=_(r.startContainer);if(!o)return!1;const u=o.closest('ul[data-type="checklist"]');if(u&&t.contains(u)){const c=T(u);if(c.length===0)return!1;const p=document.createDocumentFragment();let s=null;return c.forEach((f,g)=>{const E=O(f);E.forEach(L=>{p.appendChild(L),!s&&(f.contains(r.startContainer)||g===0)&&(s=L)}),!s&&g===0&&E[0]&&(s=E[0])}),u.replaceWith(p),s&&k(s,t),n()}const d=o.closest("ul, ol");if(d&&t.contains(d)){let c;if(d.tagName.toLowerCase()==="ul")c=d;else{for(c=document.createElement("ul");d.firstChild;)c.appendChild(d.firstChild);d.replaceWith(c)}c.setAttribute("data-type","checklist");let p=T(c);p.length===0&&(c.appendChild(C("")),p=T(c));let s=null;p.forEach(g=>{g.setAttribute("data-type","checklist-item"),g.hasAttribute("data-checked")||g.setAttribute("data-checked","false");const E=I(g);g.contains(r.startContainer)&&(s=E)});const f=c.querySelector(':scope > li[data-type="checklist-item"] > p');return k(s||f||c,t),n()}const l=v(r,t);if(l.length>1){const c=document.createElement("ul");c.setAttribute("data-type","checklist"),l.forEach(f=>{c.appendChild(C(f.innerHTML))}),l[0].replaceWith(c),l.slice(1).forEach(f=>{f.isConnected&&f.remove()});const s=c.querySelector(':scope > li[data-type="checklist-item"] > p');return s&&k(s,t),n()}const m=l[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(m&&m!==t){const c=document.createElement("ul");c.setAttribute("data-type","checklist");const p=C(m.innerHTML);c.appendChild(p),m.replaceWith(c);const s=p.querySelector(":scope > p");return s&&k(s,t),n()}const i=document.createElement("ul");i.setAttribute("data-type","checklist");const a=C("");i.appendChild(a),r.deleteContents(),r.insertNode(i);const h=a.querySelector(":scope > p");return h&&k(h,t),n()}catch(t){return console.error("Failed to toggle checklist:",t),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=P;
@@ -0,0 +1,305 @@
1
+ const N = "__editoraCommandEditorRoot", w = (t) => {
2
+ if (!t) return null;
3
+ const e = t.querySelector('[contenteditable="true"]');
4
+ return e instanceof HTMLElement ? e : null;
5
+ }, A = () => {
6
+ if (typeof window > "u") return null;
7
+ const t = window[N];
8
+ if (!(t instanceof HTMLElement)) return null;
9
+ window[N] = null;
10
+ const e = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null);
11
+ if (e) {
12
+ const r = w(e);
13
+ if (r) return r;
14
+ if (e.getAttribute("contenteditable") === "true") return e;
15
+ }
16
+ if (t.getAttribute("contenteditable") === "true")
17
+ return t;
18
+ const n = t.closest('[contenteditable="true"]');
19
+ return n instanceof HTMLElement ? n : null;
20
+ }, _ = () => {
21
+ const t = A();
22
+ if (t && document.contains(t))
23
+ return t;
24
+ const e = window.getSelection();
25
+ if (e && e.rangeCount > 0) {
26
+ let r = e.getRangeAt(0).startContainer;
27
+ for (; r && r !== document.body; ) {
28
+ if (r.nodeType === Node.ELEMENT_NODE) {
29
+ const o = r;
30
+ if (o.getAttribute("contenteditable") === "true")
31
+ return o;
32
+ }
33
+ r = r.parentNode;
34
+ }
35
+ }
36
+ const n = document.activeElement;
37
+ if (n) {
38
+ if (n.getAttribute("contenteditable") === "true")
39
+ return n;
40
+ const r = n.closest('[contenteditable="true"]');
41
+ if (r) return r;
42
+ }
43
+ return document.querySelector('[contenteditable="true"]');
44
+ }, H = (t) => t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null, S = (t) => {
45
+ const e = window.getSelection();
46
+ if (!e || e.rangeCount === 0) return null;
47
+ const n = e.getRangeAt(0);
48
+ return t.contains(n.commonAncestorContainer) ? n : null;
49
+ }, y = (t) => {
50
+ t.dispatchEvent(new Event("input", { bubbles: !0 }));
51
+ }, M = (t, e) => {
52
+ if (e === t.innerHTML) return;
53
+ const n = window.execEditorCommand || window.executeEditorCommand;
54
+ if (typeof n == "function")
55
+ try {
56
+ n("recordDomTransaction", t, e, t.innerHTML);
57
+ } catch {
58
+ }
59
+ }, k = (t, e) => {
60
+ if (!t.isConnected) {
61
+ e.focus({ preventScroll: !0 });
62
+ return;
63
+ }
64
+ const n = window.getSelection();
65
+ if (!n) return;
66
+ const r = document.createRange();
67
+ r.selectNodeContents(t), r.collapse(!1), n.removeAllRanges();
68
+ try {
69
+ n.addRange(r);
70
+ } catch {
71
+ e.focus({ preventScroll: !0 });
72
+ return;
73
+ }
74
+ e.focus({ preventScroll: !0 });
75
+ }, I = (t) => {
76
+ let e = t.querySelector(":scope > p");
77
+ if (!e) {
78
+ e = document.createElement("p");
79
+ const n = [];
80
+ t.childNodes.forEach((r) => {
81
+ r.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(r.tagName) || n.push(r);
82
+ }), n.forEach((r) => e.appendChild(r)), t.insertBefore(e, t.firstChild);
83
+ }
84
+ return e.innerHTML.trim() || (e.innerHTML = "<br>"), e;
85
+ }, C = (t) => {
86
+ const e = document.createElement("li");
87
+ e.setAttribute("data-type", "checklist-item"), e.setAttribute("data-checked", "false");
88
+ const n = document.createElement("p");
89
+ return n.innerHTML = t.trim() || "<br>", e.appendChild(n), e;
90
+ }, T = (t) => Array.from(t.children).filter(
91
+ (e) => e instanceof HTMLLIElement
92
+ ), R = /* @__PURE__ */ new Set([
93
+ "P",
94
+ "DIV",
95
+ "H1",
96
+ "H2",
97
+ "H3",
98
+ "H4",
99
+ "H5",
100
+ "H6",
101
+ "BLOCKQUOTE",
102
+ "PRE",
103
+ "LI"
104
+ ]), b = (t) => R.has(t.tagName) && t.getAttribute("contenteditable") !== "true", v = (t, e) => {
105
+ const n = [], r = /* @__PURE__ */ new Set(), o = (i) => {
106
+ !i || r.has(i) || e.contains(i) && b(i) && (i.closest("ul, ol") || (r.add(i), n.push(i)));
107
+ }, u = (i) => {
108
+ let a = i;
109
+ for (; a && a !== document.body; ) {
110
+ if (a.nodeType === Node.ELEMENT_NODE) {
111
+ const h = a;
112
+ if (b(h)) return h;
113
+ if (h.getAttribute("contenteditable") === "true") break;
114
+ }
115
+ a = a.parentNode;
116
+ }
117
+ return null;
118
+ };
119
+ if (t.collapsed)
120
+ return o(u(t.startContainer)), n;
121
+ const d = document.createTreeWalker(
122
+ e,
123
+ NodeFilter.SHOW_ELEMENT,
124
+ {
125
+ acceptNode: (i) => {
126
+ const a = i;
127
+ if (!b(a) || a.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
128
+ if (typeof t.intersectsNode == "function")
129
+ return t.intersectsNode(a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
130
+ const h = document.createRange();
131
+ return h.selectNodeContents(a), t.compareBoundaryPoints(Range.END_TO_START, h) > 0 && t.compareBoundaryPoints(Range.START_TO_END, h) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
132
+ }
133
+ }
134
+ );
135
+ let l = d.nextNode();
136
+ for (; l; )
137
+ o(l), l = d.nextNode();
138
+ if (n.length === 0 && o(u(t.commonAncestorContainer)), n.length <= 1)
139
+ return n;
140
+ const m = n.filter((i) => !n.some((a) => a !== i && i.contains(a)));
141
+ return m.length > 0 ? m : n;
142
+ }, O = (t) => {
143
+ const e = [], n = document.createElement("div"), r = () => {
144
+ const o = n.innerHTML.trim();
145
+ if (!o) return;
146
+ const u = document.createElement("p");
147
+ u.innerHTML = o, e.push(u), n.innerHTML = "";
148
+ };
149
+ if (t.childNodes.forEach((o) => {
150
+ if (o.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(o.tagName)) {
151
+ r();
152
+ return;
153
+ }
154
+ if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
155
+ r();
156
+ const u = o.innerHTML.trim(), d = document.createElement("p");
157
+ d.innerHTML = u || "<br>", e.push(d);
158
+ return;
159
+ }
160
+ o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || n.appendChild(o.cloneNode(!0));
161
+ }), r(), e.length === 0) {
162
+ const o = document.createElement("p");
163
+ o.innerHTML = "<br>", e.push(o);
164
+ }
165
+ return e;
166
+ }, D = () => ({
167
+ name: "checklist",
168
+ // Initialize click handler when plugin is loaded
169
+ init: () => {
170
+ if (typeof document > "u" || typeof window > "u" || window.__checklistPluginClickInitialized) return;
171
+ window.__checklistPluginClickInitialized = !0;
172
+ const t = (e) => {
173
+ const r = e.target.closest('li[data-type="checklist-item"]');
174
+ if (!r) return;
175
+ const o = r.getBoundingClientRect();
176
+ if (!(e.clientX - o.left < 32)) return;
177
+ e.preventDefault(), e.stopPropagation();
178
+ const l = r.closest("[contenteditable], .rte-content, .editora-content");
179
+ if (l?.getAttribute("contenteditable") === "false" || !!l?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
180
+ const i = l?.innerHTML || "", a = r.getAttribute("data-checked") === "true";
181
+ r.setAttribute("data-checked", (!a).toString()), l && (M(l, i), y(l));
182
+ };
183
+ document.addEventListener("click", t);
184
+ },
185
+ // Schema definition for checklist nodes
186
+ nodes: {
187
+ checklist: {
188
+ content: "checklistItem+",
189
+ group: "block",
190
+ parseDOM: [{ tag: 'ul[data-type="checklist"]' }],
191
+ toDOM: () => ["ul", { "data-type": "checklist" }, 0]
192
+ },
193
+ checklistItem: {
194
+ content: "paragraph",
195
+ attrs: {
196
+ checked: { default: !1 }
197
+ },
198
+ parseDOM: [
199
+ {
200
+ tag: 'li[data-type="checklist-item"]',
201
+ getAttrs: (t) => ({
202
+ checked: t.getAttribute("data-checked") === "true"
203
+ })
204
+ }
205
+ ],
206
+ toDOM: (t) => [
207
+ "li",
208
+ {
209
+ "data-type": "checklist-item",
210
+ "data-checked": t?.attrs?.checked ? "true" : "false"
211
+ },
212
+ 0
213
+ ]
214
+ }
215
+ },
216
+ toolbar: [
217
+ {
218
+ label: "Checklist",
219
+ command: "toggleChecklist",
220
+ icon: '<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',
221
+ shortcut: "Mod-Shift-9"
222
+ }
223
+ ],
224
+ commands: {
225
+ toggleChecklist: () => {
226
+ try {
227
+ const t = _();
228
+ if (!t) return !1;
229
+ const e = t.innerHTML, n = () => (M(t, e), y(t), !0), r = S(t);
230
+ if (!r) return !1;
231
+ const o = H(r.startContainer);
232
+ if (!o) return !1;
233
+ const u = o.closest('ul[data-type="checklist"]');
234
+ if (u && t.contains(u)) {
235
+ const c = T(u);
236
+ if (c.length === 0) return !1;
237
+ const p = document.createDocumentFragment();
238
+ let s = null;
239
+ return c.forEach((f, g) => {
240
+ const E = O(f);
241
+ E.forEach((L) => {
242
+ p.appendChild(L), !s && (f.contains(r.startContainer) || g === 0) && (s = L);
243
+ }), !s && g === 0 && E[0] && (s = E[0]);
244
+ }), u.replaceWith(p), s && k(s, t), n();
245
+ }
246
+ const d = o.closest("ul, ol");
247
+ if (d && t.contains(d)) {
248
+ let c;
249
+ if (d.tagName.toLowerCase() === "ul")
250
+ c = d;
251
+ else {
252
+ for (c = document.createElement("ul"); d.firstChild; )
253
+ c.appendChild(d.firstChild);
254
+ d.replaceWith(c);
255
+ }
256
+ c.setAttribute("data-type", "checklist");
257
+ let p = T(c);
258
+ p.length === 0 && (c.appendChild(C("")), p = T(c));
259
+ let s = null;
260
+ p.forEach((g) => {
261
+ g.setAttribute("data-type", "checklist-item"), g.hasAttribute("data-checked") || g.setAttribute("data-checked", "false");
262
+ const E = I(g);
263
+ g.contains(r.startContainer) && (s = E);
264
+ });
265
+ const f = c.querySelector(':scope > li[data-type="checklist-item"] > p');
266
+ return k(s || f || c, t), n();
267
+ }
268
+ const l = v(r, t);
269
+ if (l.length > 1) {
270
+ const c = document.createElement("ul");
271
+ c.setAttribute("data-type", "checklist"), l.forEach((f) => {
272
+ c.appendChild(C(f.innerHTML));
273
+ }), l[0].replaceWith(c), l.slice(1).forEach((f) => {
274
+ f.isConnected && f.remove();
275
+ });
276
+ const s = c.querySelector(':scope > li[data-type="checklist-item"] > p');
277
+ return s && k(s, t), n();
278
+ }
279
+ const m = l[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
280
+ if (m && m !== t) {
281
+ const c = document.createElement("ul");
282
+ c.setAttribute("data-type", "checklist");
283
+ const p = C(m.innerHTML);
284
+ c.appendChild(p), m.replaceWith(c);
285
+ const s = p.querySelector(":scope > p");
286
+ return s && k(s, t), n();
287
+ }
288
+ const i = document.createElement("ul");
289
+ i.setAttribute("data-type", "checklist");
290
+ const a = C("");
291
+ i.appendChild(a), r.deleteContents(), r.insertNode(i);
292
+ const h = a.querySelector(":scope > p");
293
+ return h && k(h, t), n();
294
+ } catch (t) {
295
+ return console.error("Failed to toggle checklist:", t), !1;
296
+ }
297
+ }
298
+ },
299
+ keymap: {
300
+ "Mod-Shift-9": "toggleChecklist"
301
+ }
302
+ });
303
+ export {
304
+ D as ChecklistPlugin
305
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=f();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const o=e.getRangeAt(0);if(!t.contains(o.commonAncestorContainer))return!1;const n=o.cloneRange();return t.focus({preventScroll:!0}),document.execCommand("unlink",!1),document.execCommand("removeFormat",!1),h(t,n),m(t,n),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),l=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),u=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),d=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function f(){const t=window.getSelection();if(t&&t.rangeCount>0){const o=t.getRangeAt(0).startContainer,r=(o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(r)return r}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function c(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch{}const o=document.createRange();return e.nodeType===Node.ELEMENT_NODE?o.selectNodeContents(e):o.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,o)>0&&t.compareBoundaryPoints(Range.START_TO_END,o)<0}function a(t){let e=0,o=t;for(;o&&o.parentNode;)e+=1,o=o.parentNode;return e}function g(t){d.forEach(e=>{t.style.removeProperty(e)}),(!t.getAttribute("style")||t.style.length===0)&&t.removeAttribute("style"),t.classList.contains("rte-text-color")&&t.classList.remove("rte-text-color"),t.classList.contains("rte-bg-color")&&t.classList.remove("rte-bg-color"),t.classList.length===0&&t.removeAttribute("class")}function i(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function h(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(!c(e,n)||!u.has(n.tagName))return;const r=document.createElement("p");for(;n.firstChild;)r.appendChild(n.firstChild);n.parentNode?.replaceChild(r,n)})}function m(t,e){const o=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));o.sort((n,r)=>a(r)-a(n)),o.forEach(n=>{if(n.isConnected&&c(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(g(n),l.has(n.tagName)){i(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&i(n)}})}exports.ClearFormattingPlugin=s;
@@ -0,0 +1,138 @@
1
+ const m = () => ({
2
+ name: "clearFormatting",
3
+ // Toolbar button configuration
4
+ toolbar: [
5
+ {
6
+ label: "Clear Formatting",
7
+ command: "clearFormatting",
8
+ icon: '<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',
9
+ shortcut: "Mod-\\"
10
+ }
11
+ ],
12
+ // Native command implementations
13
+ commands: {
14
+ /**
15
+ * Remove all formatting from current selection
16
+ */
17
+ clearFormatting: () => {
18
+ const t = d();
19
+ if (!t) return !1;
20
+ const e = window.getSelection();
21
+ if (!e || e.rangeCount === 0) return !1;
22
+ const o = e.getRangeAt(0);
23
+ if (!t.contains(o.commonAncestorContainer)) return !1;
24
+ const n = o.cloneRange();
25
+ return t.focus({ preventScroll: !0 }), document.execCommand("unlink", !1), document.execCommand("removeFormat", !1), g(t, n), h(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
26
+ }
27
+ },
28
+ // Keyboard shortcuts
29
+ keymap: {
30
+ "Mod-\\": "clearFormatting"
31
+ }
32
+ }), s = /* @__PURE__ */ new Set([
33
+ "A",
34
+ "B",
35
+ "STRONG",
36
+ "I",
37
+ "EM",
38
+ "U",
39
+ "S",
40
+ "STRIKE",
41
+ "DEL",
42
+ "FONT",
43
+ "MARK",
44
+ "CODE",
45
+ "SUB",
46
+ "SUP"
47
+ ]), l = /* @__PURE__ */ new Set([
48
+ "H1",
49
+ "H2",
50
+ "H3",
51
+ "H4",
52
+ "H5",
53
+ "H6",
54
+ "BLOCKQUOTE",
55
+ "PRE"
56
+ ]), u = [
57
+ "color",
58
+ "background-color",
59
+ "font-size",
60
+ "font-family",
61
+ "font-weight",
62
+ "font-style",
63
+ "text-decoration",
64
+ "text-transform",
65
+ "line-height",
66
+ "letter-spacing",
67
+ "word-spacing",
68
+ "vertical-align",
69
+ "text-align",
70
+ "padding-left"
71
+ ];
72
+ function d() {
73
+ const t = window.getSelection();
74
+ if (t && t.rangeCount > 0) {
75
+ const o = t.getRangeAt(0).startContainer, r = (o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
76
+ if (r) return r;
77
+ }
78
+ const e = document.activeElement;
79
+ return e ? e.getAttribute("contenteditable") === "true" ? e : e.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
80
+ }
81
+ function c(t, e) {
82
+ try {
83
+ if (typeof t.intersectsNode == "function")
84
+ return t.intersectsNode(e);
85
+ } catch {
86
+ }
87
+ const o = document.createRange();
88
+ return e.nodeType === Node.ELEMENT_NODE ? o.selectNodeContents(e) : o.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, o) > 0 && t.compareBoundaryPoints(Range.START_TO_END, o) < 0;
89
+ }
90
+ function a(t) {
91
+ let e = 0, o = t;
92
+ for (; o && o.parentNode; )
93
+ e += 1, o = o.parentNode;
94
+ return e;
95
+ }
96
+ function f(t) {
97
+ u.forEach((e) => {
98
+ t.style.removeProperty(e);
99
+ }), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class");
100
+ }
101
+ function i(t) {
102
+ const e = t.parentNode;
103
+ if (e) {
104
+ for (; t.firstChild; )
105
+ e.insertBefore(t.firstChild, t);
106
+ e.removeChild(t);
107
+ }
108
+ }
109
+ function g(t, e) {
110
+ Array.from(
111
+ t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
112
+ ).forEach((n) => {
113
+ if (!c(e, n) || !l.has(n.tagName)) return;
114
+ const r = document.createElement("p");
115
+ for (; n.firstChild; )
116
+ r.appendChild(n.firstChild);
117
+ n.parentNode?.replaceChild(r, n);
118
+ });
119
+ }
120
+ function h(t, e) {
121
+ const o = Array.from(
122
+ t.querySelectorAll(
123
+ "a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
124
+ )
125
+ );
126
+ o.sort((n, r) => a(r) - a(n)), o.forEach((n) => {
127
+ if (n.isConnected && c(e, n) && !(n.getAttribute("contenteditable") === "false" || n.closest('[contenteditable="false"]'))) {
128
+ if (f(n), s.has(n.tagName)) {
129
+ i(n);
130
+ return;
131
+ }
132
+ n.tagName === "SPAN" && n.attributes.length === 0 && i(n);
133
+ }
134
+ });
135
+ }
136
+ export {
137
+ m as ClearFormattingPlugin
138
+ };
@@ -0,0 +1,161 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=()=>{const d=window.getSelection();if(d&&d.rangeCount>0){let t=d.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const n=t;if(n.getAttribute("contenteditable")==="true")return n}t=t.parentNode}}const a=document.activeElement;if(a){if(a.getAttribute("contenteditable")==="true")return a;const t=a.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},k='[data-theme="dark"], .dark, .editora-theme-dark',N=()=>{if(w()?.closest(k))return!0;const a=window.getSelection();if(a&&a.rangeCount>0){const n=a.getRangeAt(0).startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(k))return!0}return document.activeElement?.closest(k)?!0:document.body.matches(k)||document.documentElement.matches(k)},A=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"csharp",label:"C#"},{value:"cpp",label:"C++"},{value:"c",label:"C"},{value:"php",label:"PHP"},{value:"ruby",label:"Ruby"},{value:"go",label:"Go"},{value:"rust",label:"Rust"},{value:"swift",label:"Swift"},{value:"kotlin",label:"Kotlin"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"scss",label:"SCSS"},{value:"json",label:"JSON"},{value:"xml",label:"XML"},{value:"yaml",label:"YAML"},{value:"markdown",label:"Markdown"},{value:"sql",label:"SQL"},{value:"bash",label:"Bash"},{value:"shell",label:"Shell"},{value:"plaintext",label:"Plain Text"}],T=new Map;function $(d,a,t,n){const s=!!a,c=n||"javascript",g=t||"",p=N(),e=p?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",dialogBorder:"#4b5563",text:"#e2e8f0",mutedText:"#a8b5c8",headerFooterBg:"#222d3a",border:"#3b4657",fieldBg:"#111827",fieldBorder:"#4b5563",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",primaryBg:"#3b82f6",primaryHover:"#2563eb"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",dialogBorder:"#e0e0e0",text:"#333333",mutedText:"#666666",headerFooterBg:"#ffffff",border:"#e0e0e0",fieldBg:"#ffffff",fieldBorder:"#dddddd",cancelBg:"#e5e7eb",cancelHover:"#d1d5db",cancelText:"#333333",primaryBg:"#2563eb",primaryHover:"#1d4ed8"},l=document.createElement("div");l.className="rte-code-sample-overlay",p&&l.classList.add("rte-theme-dark"),l.style.cssText=`
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ background: ${e.overlay};
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ z-index: 10000;
12
+ animation: fadeIn 160ms ease-out;
13
+ `;const o=document.createElement("div");o.className="rte-code-sample-dialog",o.style.cssText=`
14
+ background: ${e.dialogBg};
15
+ border: 1px solid ${e.dialogBorder};
16
+ border-radius: 8px;
17
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
18
+ max-width: 700px;
19
+ width: 90vw;
20
+ max-height: 80vh;
21
+ display: flex;
22
+ flex-direction: column;
23
+ animation: slideUp 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
24
+ `;const u=document.createElement("div");u.style.cssText=`
25
+ padding: 20px;
26
+ border-bottom: 1px solid ${e.border};
27
+ background: ${e.headerFooterBg};
28
+ display: flex;
29
+ justify-content: space-between;
30
+ align-items: center;
31
+ `,u.innerHTML=`
32
+ <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">
33
+ ${s?"Edit Code Sample":"Insert Code Sample"}
34
+ </h2>
35
+ <button class="rte-code-close-btn" style="background: none; border: none; font-size: 28px; color: ${e.mutedText}; cursor: pointer; padding: 0; width: 32px; height: 32px;">×</button>
36
+ `;const m=document.createElement("div");m.style.cssText=`
37
+ flex: 1;
38
+ overflow-y: auto;
39
+ padding: 20px;
40
+ `;const i=document.createElement("div");i.style.marginBottom="20px",i.innerHTML=`
41
+ <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Language</label>
42
+ <select class="rte-code-language" style="
43
+ width: 100%;
44
+ padding: 10px 12px;
45
+ border: 1px solid ${e.fieldBorder};
46
+ border-radius: 4px;
47
+ font-size: 14px;
48
+ background-color: ${e.fieldBg};
49
+ color: ${e.text};
50
+ cursor: pointer;
51
+ ">
52
+ ${A.map(r=>`
53
+ <option value="${r.value}" ${r.value===c?"selected":""}>
54
+ ${r.label}
55
+ </option>
56
+ `).join("")}
57
+ </select>
58
+ `;const b=document.createElement("div");b.style.marginBottom="20px",b.innerHTML=`
59
+ <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Code</label>
60
+ <textarea class="rte-code-textarea" spellcheck="false" placeholder="Paste or type your code here..." style="
61
+ width: 100%;
62
+ padding: 12px;
63
+ border: 1px solid ${e.fieldBorder};
64
+ border-radius: 4px;
65
+ font-family: 'Courier New', Courier, monospace;
66
+ font-size: 13px;
67
+ line-height: 1.5;
68
+ resize: vertical;
69
+ min-height: 250px;
70
+ max-height: 400px;
71
+ background-color: ${e.fieldBg};
72
+ color: ${e.text};
73
+ box-sizing: border-box;
74
+ ">${g}</textarea>
75
+ <div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
76
+ `;const x=document.createElement("div");x.style.cssText=`color: ${e.mutedText}; font-size: 12px; margin-top: 10px;`,x.innerHTML="💡 Tip: Press Ctrl+Enter (or Cmd+Enter on Mac) to save, or Escape to cancel",m.appendChild(i),m.appendChild(b),m.appendChild(x);const y=document.createElement("div");y.style.cssText=`
77
+ padding: 20px;
78
+ border-top: 1px solid ${e.border};
79
+ background: ${e.headerFooterBg};
80
+ display: flex;
81
+ justify-content: flex-end;
82
+ gap: 12px;
83
+ `,y.innerHTML=`
84
+ <button class="rte-code-cancel-btn" style="
85
+ padding: 10px 16px;
86
+ border: none;
87
+ border-radius: 4px;
88
+ font-size: 14px;
89
+ font-weight: 500;
90
+ cursor: pointer;
91
+ background: ${e.cancelBg};
92
+ color: ${e.cancelText};
93
+ ">Cancel</button>
94
+ <button class="rte-code-save-btn" style="
95
+ padding: 10px 16px;
96
+ border: none;
97
+ border-radius: 4px;
98
+ font-size: 14px;
99
+ font-weight: 500;
100
+ cursor: pointer;
101
+ background: ${e.primaryBg};
102
+ color: #fff;
103
+ ">${s?"Update Code Sample":"Insert Code Sample"}</button>
104
+ `,o.appendChild(u),o.appendChild(m),o.appendChild(y),l.appendChild(o);const L=i.querySelector(".rte-code-language"),E=b.querySelector(".rte-code-textarea"),S=b.querySelector(".rte-code-error"),f=u.querySelector(".rte-code-close-btn"),v=y.querySelector(".rte-code-cancel-btn"),h=y.querySelector(".rte-code-save-btn");f.onmouseover=()=>{f.style.color="#f8fafc",f.style.background=p?"#334155":"#f0f0f0",f.style.borderRadius="4px"},f.onmouseout=()=>{f.style.color=e.mutedText,f.style.background="none"},v.onmouseover=()=>{v.style.background=e.cancelHover},v.onmouseout=()=>{v.style.background=e.cancelBg},h.onmouseover=()=>{h.style.background=e.primaryHover},h.onmouseout=()=>{h.style.background=e.primaryBg};const C=()=>{l.remove()},B=()=>{const r=E.value.trim();if(!r){S.textContent="⚠ Code cannot be empty",S.style.display="block";return}const M=L.value;d(r,M),C()};if(f.onclick=C,v.onclick=C,h.onclick=B,E.addEventListener("keydown",r=>{(r.ctrlKey||r.metaKey)&&r.key==="Enter"&&(r.preventDefault(),B()),r.key==="Escape"&&C()}),E.addEventListener("input",()=>{S.style.display="none"}),l.addEventListener("click",r=>{r.target===l&&C()}),!document.getElementById("rte-code-sample-animations")){const r=document.createElement("style");r.id="rte-code-sample-animations",r.textContent=`
105
+ @keyframes fadeIn {
106
+ from { opacity: 0; }
107
+ to { opacity: 1; }
108
+ }
109
+ @keyframes slideUp {
110
+ from { transform: translateY(20px); opacity: 0; }
111
+ to { transform: translateY(0); opacity: 1; }
112
+ }
113
+ `,document.head.appendChild(r)}return document.body.appendChild(l),setTimeout(()=>E.focus(),100),l}function R(){if(!w())return;let a=null;const t=window.getSelection();t&&t.rangeCount>0&&(a=t.getRangeAt(0).cloneRange()),$((n,s)=>{const c=window.getSelection();if(a&&(c?.removeAllRanges(),c?.addRange(a)),!c||c.rangeCount===0)return;const g=w();if(!g)return;const p=c.anchorNode;if(!p||!g.contains(p))return;const e=c.getRangeAt(0),l=`code-block-${Date.now()}`,o=document.createElement("pre");o.className="rte-code-block",o.id=l,o.setAttribute("data-type","code-block"),o.setAttribute("data-lang",s),o.setAttribute("data-code-id",l),o.setAttribute("contenteditable","false"),o.style.cssText=`
114
+ display: block;
115
+ position: relative;
116
+ background: #f5f5f5;
117
+ border: 1px solid #e0e0e0;
118
+ border-radius: 6px;
119
+ padding: 12px;
120
+ margin: 12px 0;
121
+ overflow-x: auto;
122
+ font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
123
+ font-size: 13px;
124
+ line-height: 1.5;
125
+ color: #333;
126
+ user-select: text;
127
+ cursor: default;
128
+ `;const u=document.createElement("code");u.className=`language-${s}`,u.style.cssText=`
129
+ font-family: inherit;
130
+ font-size: inherit;
131
+ line-height: inherit;
132
+ color: inherit;
133
+ white-space: pre;
134
+ word-break: normal;
135
+ display: block;
136
+ `,u.textContent=n;const m=document.createElement("span");m.style.cssText=`
137
+ position: absolute;
138
+ top: 0;
139
+ right: 0;
140
+ background: #333;
141
+ color: #fff;
142
+ padding: 2px 8px;
143
+ font-size: 11px;
144
+ font-weight: bold;
145
+ border-radius: 0 6px 0 4px;
146
+ text-transform: uppercase;
147
+ letter-spacing: 0.5px;
148
+ pointer-events: none;
149
+ `,m.textContent=s;const i=document.createElement("button");i.className="rte-code-copy",i.textContent="Copy",i.style.cssText=`
150
+ position: absolute;
151
+ top: 8px;
152
+ left: 8px;
153
+ background: #fff;
154
+ border: 1px solid #d0d0d0;
155
+ border-radius: 3px;
156
+ padding: 4px 8px;
157
+ font-size: 11px;
158
+ cursor: pointer;
159
+ opacity: 0;
160
+ transition: opacity 0.2s ease;
161
+ `,i.onclick=x=>{x.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{i.textContent="✓ Copied!",setTimeout(()=>{i.textContent="Copy"},2e3)})},o.appendChild(m),o.appendChild(i),o.appendChild(u),o.addEventListener("mouseenter",()=>{i.style.opacity="1"}),o.addEventListener("mouseleave",()=>{i.style.opacity="0"}),o.addEventListener("dblclick",()=>{z(l)}),T.set(l,{id:l,language:s,code:n}),e.insertNode(o);const b=document.createRange();b.setStartAfter(o),b.collapse(!0),c.removeAllRanges(),c.addRange(b)})}function z(d){const a=w();if(!a)return;const t=a.querySelector(`#${d}`);if(!t)return;const n=T.get(d);n&&$((s,c)=>{const g=t.querySelector("code");g&&(g.textContent=s,g.className=`language-${c}`);const p=t.querySelector("span");p&&(p.textContent=c),t.setAttribute("data-lang",c),n.language=c,n.code=s;const e=t.querySelector(".rte-code-copy");e&&(e.onclick=l=>{l.stopPropagation(),navigator.clipboard.writeText(s).then(()=>{e.textContent="✓ Copied!",setTimeout(()=>{e.textContent="Copy"},2e3)})})},d,n.code,n.language)}const H=()=>({name:"codeSample",toolbar:[{label:"Code Block",command:"insertCodeBlock",icon:'<svg width="18px" height="18px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 8L3 11.6923L7 16M17 8L21 11.6923L17 16M14 4L10 20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',shortcut:"Mod-Shift-C"}],commands:{insertCodeBlock:(...d)=>(R(),!0)}});exports.CodeSamplePlugin=H;