@editora/plugins 1.0.17 → 1.0.19
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.
- package/dist/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
- package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
- package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +17 -15
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +12 -5
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-CJ90EVWy.mjs +0 -145
- package/dist/index-DTkvH8gX.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=()=>({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=
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./historyHelpers-Cu8Pk7m1.js"),d=()=>({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=E();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const r=e.getRangeAt(0);if(!t.contains(r.commonAncestorContainer))return!1;const n=r.cloneRange(),o=t.innerHTML;return t.focus({preventScroll:!0}),L(t,n),C(t,n),u.recordDomHistory(t,o),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),g=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),h=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),m=["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 E(){const t=window.getSelection();if(t&&t.rangeCount>0){const r=t.getRangeAt(0).startContainer,o=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(o)return o}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 r=document.createRange();return e.nodeType===Node.ELEMENT_NODE?r.selectNodeContents(e):r.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,r)>0&&t.compareBoundaryPoints(Range.START_TO_END,r)<0}function a(t){let e=0,r=t;for(;r&&r.parentNode;)e+=1,r=r.parentNode;return e}function p(t){m.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.contains("rte-format-painted")&&t.classList.remove("rte-format-painted"),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 N(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function l(t){Array.from(t.children).forEach(e=>{N(e)&&e.remove()})}function s(t){l(t),i(t)}function f(t){const e=document.createElement("p");for(Array.from(t.attributes).forEach(r=>{e.setAttribute(r.name,r.value)});t.firstChild;)e.appendChild(t.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),t.parentNode?.replaceChild(e,t)}function y(t){return!/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName)||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, svg, math")}function A(t){Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")).sort((r,n)=>a(n)-a(r)).forEach(r=>{r.isConnected&&y(r)&&r.remove()})}function T(t){if(l(t),t.parentElement instanceof HTMLLIElement){s(t);return}if(Array.from(t.childNodes).filter(o=>o.nodeType!==Node.TEXT_NODE||(o.textContent||"").trim()!=="").some(o=>o instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(o.tagName))){s(t);return}f(t)}function C(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(c(e,n)&&h.has(n.tagName)){if(n.tagName==="BLOCKQUOTE"){T(n);return}f(n)}})}function L(t,e){const r=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));r.sort((n,o)=>a(o)-a(n)),r.forEach(n=>{if(n.isConnected&&c(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(p(n),g.has(n.tagName)){i(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&i(n)}}),A(t)}exports.ClearFormattingPlugin=d;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { r as u } from "./historyHelpers-BEKwNOtA.mjs";
|
|
2
|
+
const S = () => ({
|
|
2
3
|
name: "clearFormatting",
|
|
3
4
|
// Toolbar button configuration
|
|
4
5
|
toolbar: [
|
|
@@ -21,15 +22,15 @@ const T = () => ({
|
|
|
21
22
|
if (!e || e.rangeCount === 0) return !1;
|
|
22
23
|
const r = e.getRangeAt(0);
|
|
23
24
|
if (!t.contains(r.commonAncestorContainer)) return !1;
|
|
24
|
-
const n = r.cloneRange();
|
|
25
|
-
return t.focus({ preventScroll: !0 }), C(t, n),
|
|
25
|
+
const n = r.cloneRange(), o = t.innerHTML;
|
|
26
|
+
return t.focus({ preventScroll: !0 }), C(t, n), T(t, n), u(t, o), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
// Keyboard shortcuts
|
|
29
30
|
keymap: {
|
|
30
31
|
"Mod-\\": "clearFormatting"
|
|
31
32
|
}
|
|
32
|
-
}),
|
|
33
|
+
}), d = /* @__PURE__ */ new Set([
|
|
33
34
|
"A",
|
|
34
35
|
"B",
|
|
35
36
|
"STRONG",
|
|
@@ -44,7 +45,7 @@ const T = () => ({
|
|
|
44
45
|
"CODE",
|
|
45
46
|
"SUB",
|
|
46
47
|
"SUP"
|
|
47
|
-
]),
|
|
48
|
+
]), g = /* @__PURE__ */ new Set([
|
|
48
49
|
"H1",
|
|
49
50
|
"H2",
|
|
50
51
|
"H3",
|
|
@@ -53,7 +54,7 @@ const T = () => ({
|
|
|
53
54
|
"H6",
|
|
54
55
|
"BLOCKQUOTE",
|
|
55
56
|
"PRE"
|
|
56
|
-
]),
|
|
57
|
+
]), m = [
|
|
57
58
|
"color",
|
|
58
59
|
"background-color",
|
|
59
60
|
"font-size",
|
|
@@ -93,8 +94,8 @@ function a(t) {
|
|
|
93
94
|
e += 1, r = r.parentNode;
|
|
94
95
|
return e;
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
97
|
+
function E(t) {
|
|
98
|
+
m.forEach((e) => {
|
|
98
99
|
t.style.removeProperty(e);
|
|
99
100
|
}), (!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.contains("rte-format-painted") && t.classList.remove("rte-format-painted"), t.classList.length === 0 && t.removeAttribute("class");
|
|
100
101
|
}
|
|
@@ -106,12 +107,12 @@ function i(t) {
|
|
|
106
107
|
e.removeChild(t);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
+
function p(t) {
|
|
110
111
|
return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol");
|
|
111
112
|
}
|
|
112
113
|
function l(t) {
|
|
113
114
|
Array.from(t.children).forEach((e) => {
|
|
114
|
-
|
|
115
|
+
p(e) && e.remove();
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
function s(t) {
|
|
@@ -125,17 +126,17 @@ function f(t) {
|
|
|
125
126
|
e.appendChild(t.firstChild);
|
|
126
127
|
e.innerHTML.trim() || (e.innerHTML = "<br>"), t.parentNode?.replaceChild(e, t);
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function N(t) {
|
|
129
130
|
return !/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName) || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, svg, math");
|
|
130
131
|
}
|
|
131
|
-
function
|
|
132
|
+
function A(t) {
|
|
132
133
|
Array.from(
|
|
133
134
|
t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")
|
|
134
135
|
).sort((r, n) => a(n) - a(r)).forEach((r) => {
|
|
135
|
-
r.isConnected &&
|
|
136
|
+
r.isConnected && N(r) && r.remove();
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
+
function y(t) {
|
|
139
140
|
if (l(t), t.parentElement instanceof HTMLLIElement) {
|
|
140
141
|
s(t);
|
|
141
142
|
return;
|
|
@@ -146,13 +147,13 @@ function A(t) {
|
|
|
146
147
|
}
|
|
147
148
|
f(t);
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function T(t, e) {
|
|
150
151
|
Array.from(
|
|
151
152
|
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
|
|
152
153
|
).forEach((n) => {
|
|
153
|
-
if (c(e, n) &&
|
|
154
|
+
if (c(e, n) && g.has(n.tagName)) {
|
|
154
155
|
if (n.tagName === "BLOCKQUOTE") {
|
|
155
|
-
|
|
156
|
+
y(n);
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
158
159
|
f(n);
|
|
@@ -167,14 +168,14 @@ function C(t, e) {
|
|
|
167
168
|
);
|
|
168
169
|
r.sort((n, o) => a(o) - a(n)), r.forEach((n) => {
|
|
169
170
|
if (n.isConnected && c(e, n) && !(n.getAttribute("contenteditable") === "false" || n.closest('[contenteditable="false"]'))) {
|
|
170
|
-
if (
|
|
171
|
+
if (E(n), d.has(n.tagName)) {
|
|
171
172
|
i(n);
|
|
172
173
|
return;
|
|
173
174
|
}
|
|
174
175
|
n.tagName === "SPAN" && n.attributes.length === 0 && i(n);
|
|
175
176
|
}
|
|
176
|
-
}),
|
|
177
|
+
}), A(t);
|
|
177
178
|
}
|
|
178
179
|
export {
|
|
179
|
-
|
|
180
|
+
S as ClearFormattingPlugin
|
|
180
181
|
};
|
package/dist/code-sample.cjs.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const U=require("./escapeHtml-D2Zh82pD.js"),F=require("./dialogHelpers-zU6zpMIA.js"),P=require("./historyHelpers-Cu8Pk7m1.js"),G=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function M(e,o){let t=e;for(;t&&t!==o;){if(t.nodeType===Node.ELEMENT_NODE&&G.has(t.tagName))return t;t=t.parentNode}return null}const _=()=>{const e=window.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const r=t;if(r.getAttribute("contenteditable")==="true")return r}t=t.parentNode}}const o=document.activeElement;if(o){if(o.getAttribute("contenteditable")==="true")return o;const t=o.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},h='[data-theme="dark"], .dark, .editora-theme-dark',Z=()=>{if(_()?.closest(h))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const r=o.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(h))return!0}return document.activeElement?.closest(h)?!0:document.body.matches(h)||document.documentElement.matches(h)},J=[{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"}];let C=null;function O(e,o,t,r){C&&(C.remove(),C=null);const i=!!o,B=r||"javascript",s=t||"",c=Z(),n=c?{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");F.initDialogOverlay(l),l.className="rte-code-sample-overlay",c&&l.classList.add("rte-theme-dark"),l.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
5
5
|
right: 0;
|
|
6
6
|
bottom: 0;
|
|
7
|
-
background: ${
|
|
7
|
+
background: ${n.overlay};
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
10
|
justify-content: center;
|
|
11
11
|
z-index: 10000;
|
|
12
12
|
animation: fadeIn 160ms ease-out;
|
|
13
|
-
`;const
|
|
14
|
-
background: ${
|
|
15
|
-
border: 1px solid ${
|
|
13
|
+
`;const d=document.createElement("div");d.className="rte-code-sample-dialog",d.style.cssText=`
|
|
14
|
+
background: ${n.dialogBg};
|
|
15
|
+
border: 1px solid ${n.dialogBorder};
|
|
16
16
|
border-radius: 8px;
|
|
17
17
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
18
18
|
max-width: 700px;
|
|
@@ -21,46 +21,46 @@
|
|
|
21
21
|
display: flex;
|
|
22
22
|
flex-direction: column;
|
|
23
23
|
animation: slideUp 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
|
|
24
|
-
`;const
|
|
24
|
+
`;const p=document.createElement("div");p.style.cssText=`
|
|
25
25
|
padding: 20px;
|
|
26
|
-
border-bottom: 1px solid ${
|
|
27
|
-
background: ${
|
|
26
|
+
border-bottom: 1px solid ${n.border};
|
|
27
|
+
background: ${n.headerFooterBg};
|
|
28
28
|
display: flex;
|
|
29
29
|
justify-content: space-between;
|
|
30
30
|
align-items: center;
|
|
31
|
-
`,
|
|
32
|
-
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${
|
|
33
|
-
${
|
|
31
|
+
`,p.innerHTML=`
|
|
32
|
+
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">
|
|
33
|
+
${i?"Edit Code Sample":"Insert Code Sample"}
|
|
34
34
|
</h2>
|
|
35
|
-
<button class="rte-code-close-btn" style="background: none; border: none; font-size: 28px; color: ${
|
|
36
|
-
`;const
|
|
35
|
+
<button class="rte-code-close-btn" style="background: none; border: none; font-size: 28px; color: ${n.mutedText}; cursor: pointer; padding: 0; width: 32px; height: 32px;">×</button>
|
|
36
|
+
`;const f=document.createElement("div");f.style.cssText=`
|
|
37
37
|
flex: 1;
|
|
38
38
|
overflow-y: auto;
|
|
39
39
|
padding: 20px;
|
|
40
|
-
`;const
|
|
41
|
-
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${
|
|
40
|
+
`;const E=document.createElement("div");E.style.marginBottom="20px",E.innerHTML=`
|
|
41
|
+
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${n.text}; font-size: 14px;">Language</label>
|
|
42
42
|
<select class="rte-code-language" style="
|
|
43
43
|
width: 100%;
|
|
44
44
|
padding: 10px 12px;
|
|
45
|
-
border: 1px solid ${
|
|
45
|
+
border: 1px solid ${n.fieldBorder};
|
|
46
46
|
border-radius: 4px;
|
|
47
47
|
font-size: 14px;
|
|
48
|
-
background-color: ${
|
|
49
|
-
color: ${
|
|
48
|
+
background-color: ${n.fieldBg};
|
|
49
|
+
color: ${n.text};
|
|
50
50
|
cursor: pointer;
|
|
51
51
|
">
|
|
52
|
-
${
|
|
53
|
-
<option value="${a.value}" ${a.value===
|
|
52
|
+
${J.map(a=>`
|
|
53
|
+
<option value="${a.value}" ${a.value===B?"selected":""}>
|
|
54
54
|
${a.label}
|
|
55
55
|
</option>
|
|
56
56
|
`).join("")}
|
|
57
57
|
</select>
|
|
58
58
|
`;const b=document.createElement("div");b.style.marginBottom="20px",b.innerHTML=`
|
|
59
|
-
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${
|
|
59
|
+
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${n.text}; font-size: 14px;">Code</label>
|
|
60
60
|
<textarea class="rte-code-textarea" spellcheck="false" placeholder="Paste or type your code here..." style="
|
|
61
61
|
width: 100%;
|
|
62
62
|
padding: 12px;
|
|
63
|
-
border: 1px solid ${
|
|
63
|
+
border: 1px solid ${n.fieldBorder};
|
|
64
64
|
border-radius: 4px;
|
|
65
65
|
font-family: 'Courier New', Courier, monospace;
|
|
66
66
|
font-size: 13px;
|
|
@@ -68,19 +68,19 @@
|
|
|
68
68
|
resize: vertical;
|
|
69
69
|
min-height: 250px;
|
|
70
70
|
max-height: 400px;
|
|
71
|
-
background-color: ${
|
|
72
|
-
color: ${
|
|
71
|
+
background-color: ${n.fieldBg};
|
|
72
|
+
color: ${n.text};
|
|
73
73
|
box-sizing: border-box;
|
|
74
|
-
">${
|
|
74
|
+
">${U.escapeHtml(s)}</textarea>
|
|
75
75
|
<div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
|
|
76
|
-
`;const
|
|
76
|
+
`;const L=document.createElement("div");L.style.cssText=`color: ${n.mutedText}; font-size: 12px; margin-top: 10px;`,L.innerHTML="💡 Tip: Press Ctrl+Enter (or Cmd+Enter on Mac) to save, or Escape to cancel",f.appendChild(E),f.appendChild(b),f.appendChild(L);const g=document.createElement("div");g.style.cssText=`
|
|
77
77
|
padding: 20px;
|
|
78
|
-
border-top: 1px solid ${
|
|
79
|
-
background: ${
|
|
78
|
+
border-top: 1px solid ${n.border};
|
|
79
|
+
background: ${n.headerFooterBg};
|
|
80
80
|
display: flex;
|
|
81
81
|
justify-content: flex-end;
|
|
82
82
|
gap: 12px;
|
|
83
|
-
`,
|
|
83
|
+
`,g.innerHTML=`
|
|
84
84
|
<button class="rte-code-cancel-btn" style="
|
|
85
85
|
padding: 10px 16px;
|
|
86
86
|
border: none;
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
font-size: 14px;
|
|
89
89
|
font-weight: 500;
|
|
90
90
|
cursor: pointer;
|
|
91
|
-
background: ${
|
|
92
|
-
color: ${
|
|
91
|
+
background: ${n.cancelBg};
|
|
92
|
+
color: ${n.cancelText};
|
|
93
93
|
">Cancel</button>
|
|
94
94
|
<button class="rte-code-save-btn" style="
|
|
95
95
|
padding: 10px 16px;
|
|
@@ -98,10 +98,10 @@
|
|
|
98
98
|
font-size: 14px;
|
|
99
99
|
font-weight: 500;
|
|
100
100
|
cursor: pointer;
|
|
101
|
-
background: ${
|
|
101
|
+
background: ${n.primaryBg};
|
|
102
102
|
color: #fff;
|
|
103
|
-
">${
|
|
104
|
-
`,
|
|
103
|
+
">${i?"Update Code Sample":"Insert Code Sample"}</button>
|
|
104
|
+
`,d.appendChild(p),d.appendChild(f),d.appendChild(g),l.appendChild(d);const V=E.querySelector(".rte-code-language"),k=b.querySelector(".rte-code-textarea"),H=b.querySelector(".rte-code-error"),u=p.querySelector(".rte-code-close-btn"),y=g.querySelector(".rte-code-cancel-btn"),x=g.querySelector(".rte-code-save-btn");u.onmouseover=()=>{u.style.color="#f8fafc",u.style.background=c?"#334155":"#f0f0f0",u.style.borderRadius="4px"},u.onmouseout=()=>{u.style.color=n.mutedText,u.style.background="none"},y.onmouseover=()=>{y.style.background=n.cancelHover},y.onmouseout=()=>{y.style.background=n.cancelBg},x.onmouseover=()=>{x.style.background=n.primaryHover},x.onmouseout=()=>{x.style.background=n.primaryBg};const v=()=>{l.remove(),C=null},R=()=>{const a=k.value.replace(/^(?:[ \t]*\r?\n)+/,"").replace(/\s+$/,"");if(!a.trim()){H.textContent="⚠ Code cannot be empty",H.style.display="block";return}const K=V.value;e(a,K),v()};if(u.onclick=v,y.onclick=v,x.onclick=R,k.addEventListener("keydown",a=>{(a.ctrlKey||a.metaKey)&&a.key==="Enter"&&(a.preventDefault(),R()),a.key==="Escape"&&v()}),k.addEventListener("input",()=>{H.style.display="none"}),l.addEventListener("click",a=>{a.target===l&&v()}),!document.getElementById("rte-code-sample-animations")){const a=document.createElement("style");a.id="rte-code-sample-animations",a.textContent=`
|
|
105
105
|
@keyframes fadeIn {
|
|
106
106
|
from { opacity: 0; }
|
|
107
107
|
to { opacity: 1; }
|
|
@@ -110,30 +110,9 @@
|
|
|
110
110
|
from { transform: translateY(20px); opacity: 0; }
|
|
111
111
|
to { transform: translateY(0); opacity: 1; }
|
|
112
112
|
}
|
|
113
|
-
`,document.head.appendChild(a)}return document.body.appendChild(l),setTimeout(()=>
|
|
114
|
-
|
|
115
|
-
|
|
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=`
|
|
113
|
+
`,document.head.appendChild(a)}return C=l,document.body.appendChild(l),setTimeout(()=>k.focus(),100),l}const N='pre.rte-code-block, pre[data-type="code-block"]';function q(){if(document.getElementById("rte-code-sample-block-styles"))return;const e=document.createElement("style");e.id="rte-code-sample-block-styles",e.textContent=`
|
|
114
|
+
pre.rte-code-block[data-lang]::after {
|
|
115
|
+
content: attr(data-lang);
|
|
137
116
|
position: absolute;
|
|
138
117
|
top: 0;
|
|
139
118
|
right: 0;
|
|
@@ -146,16 +125,56 @@
|
|
|
146
125
|
text-transform: uppercase;
|
|
147
126
|
letter-spacing: 0.5px;
|
|
148
127
|
pointer-events: none;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
pre.rte-code-block:focus-visible {
|
|
131
|
+
outline: 2px solid #2563eb;
|
|
132
|
+
outline-offset: 2px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.rte-code-copy-floating {
|
|
136
|
+
position: fixed;
|
|
137
|
+
z-index: 9999;
|
|
138
|
+
display: none;
|
|
153
139
|
background: #fff;
|
|
140
|
+
color: #333;
|
|
154
141
|
border: 1px solid #d0d0d0;
|
|
155
142
|
border-radius: 3px;
|
|
156
143
|
padding: 4px 8px;
|
|
157
|
-
font
|
|
144
|
+
font: 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
158
145
|
cursor: pointer;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.rte-code-copy-floating:hover {
|
|
149
|
+
background: #f3f4f6;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@media print {
|
|
153
|
+
.rte-code-copy-floating {
|
|
154
|
+
display: none !important;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`,document.head.appendChild(e)}function I(e){return e.querySelector("code")?.textContent??""}function Y(e){return e.getAttribute("data-lang")||"plaintext"}function Q(e,o){const t=document.createElement("pre");t.className="rte-code-block",t.setAttribute("data-type","code-block"),t.setAttribute("data-lang",o),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","group"),t.setAttribute("aria-label",`Code sample (${o}). Press Enter to edit.`),t.style.cssText=`
|
|
158
|
+
display: block;
|
|
159
|
+
position: relative;
|
|
160
|
+
background: #f5f5f5;
|
|
161
|
+
border: 1px solid #e0e0e0;
|
|
162
|
+
border-radius: 6px;
|
|
163
|
+
padding: 30px 12px 12px;
|
|
164
|
+
margin: 12px 0;
|
|
165
|
+
overflow-x: auto;
|
|
166
|
+
font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
|
|
167
|
+
font-size: 13px;
|
|
168
|
+
line-height: 1.5;
|
|
169
|
+
color: #333;
|
|
170
|
+
user-select: text;
|
|
171
|
+
cursor: default;
|
|
172
|
+
`;const r=document.createElement("code");return r.className=`language-${o}`,r.style.cssText=`
|
|
173
|
+
font-family: inherit;
|
|
174
|
+
font-size: inherit;
|
|
175
|
+
line-height: inherit;
|
|
176
|
+
color: inherit;
|
|
177
|
+
white-space: pre;
|
|
178
|
+
word-break: normal;
|
|
179
|
+
display: block;
|
|
180
|
+
`,r.textContent=e,t.appendChild(r),t}function X(e,o,t){let r=e.querySelector("code");r||(r=document.createElement("code")),r.textContent=o,r.className=`language-${t}`,Array.from(e.childNodes).forEach(i=>{i!==r&&e.removeChild(i)}),e.appendChild(r),e.setAttribute("data-lang",t),e.setAttribute("aria-label",`Code sample (${t}). Press Enter to edit.`),e.style.paddingTop="30px"}let m=null,A=null,T=null,w=null;function S(){T!==null&&(window.clearTimeout(T),T=null)}function $(){S(),m&&(m.style.display="none"),A=null}function j(){S(),T=window.setTimeout($,120)}async function W(e){try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.cssText="position: fixed; top: 0; left: 0; opacity: 0; pointer-events: none;",document.body.appendChild(o);const t=window.getSelection(),r=t&&t.rangeCount>0?t.getRangeAt(0).cloneRange():null;o.select();let i=!1;try{i=document.execCommand("copy")}catch{i=!1}return o.remove(),r&&t&&(t.removeAllRanges(),t.addRange(r)),i}function ee(){if(m&&m.isConnected)return m;const e=document.createElement("button");return e.type="button",e.className="rte-code-copy-floating",e.textContent="Copy",e.setAttribute("aria-label","Copy code"),e.addEventListener("mousedown",o=>o.preventDefault()),e.addEventListener("mouseenter",S),e.addEventListener("mouseleave",j),e.addEventListener("click",async o=>{o.stopPropagation();const t=A;if(!t)return;const r=await W(I(t));e.textContent=r?"✓ Copied!":"Copy failed",w!==null&&window.clearTimeout(w),w=window.setTimeout(()=>{e.textContent="Copy",w=null},2e3)}),document.body.appendChild(e),m=e,e}function te(e){q();const o=ee();S(),A=e;const t=e.getBoundingClientRect();o.style.left=`${Math.max(0,t.left+8)}px`,o.style.top=`${Math.max(0,t.top+5)}px`,o.style.display="block"}function D(e){return!!e.parentElement?.closest('[contenteditable="true"]')}function oe(){if(typeof document>"u"||window.__codeSampleInteractionsReady)return;window.__codeSampleInteractionsReady=!0;const e=o=>(o instanceof Element?o:o instanceof Node?o.parentElement:null)?.closest(N)??null;document.addEventListener("mouseover",o=>{const t=e(o.target);t&&te(t)}),document.addEventListener("mouseout",o=>{e(o.target)&&!(o.relatedTarget instanceof Node&&m?.contains(o.relatedTarget))&&j()}),document.addEventListener("scroll",$,!0),window.addEventListener("resize",$),document.addEventListener("dblclick",o=>{const t=e(o.target);t&&D(t)&&z(t)}),document.addEventListener("keydown",o=>{if(o.key!=="Enter"||o.target!==document.activeElement)return;const t=o.target instanceof HTMLElement&&o.target.matches(N)?o.target:null;t&&D(t)&&(o.preventDefault(),z(t))})}typeof window<"u"&&oe();function ne(){const e=_();if(!e||e.getAttribute("contenteditable")!=="true")return;let o=null;const t=window.getSelection();t&&t.rangeCount>0&&e.contains(t.getRangeAt(0).commonAncestorContainer)&&(o=t.getRangeAt(0).cloneRange()),O((r,i)=>{if(!e.isConnected)return;q();const B=e.innerHTML,s=Q(r,i),c=o?o.cloneRange():document.createRange();o||(c.selectNodeContents(e),c.collapse(!1));const n=M(c.endContainer,e)||M(c.startContainer,e);if(n&&n.parentNode?n.parentNode.insertBefore(s,n.nextSibling):o?c.insertNode(s):e.appendChild(s),!s.nextSibling){const p=document.createElement("p");p.appendChild(document.createElement("br")),s.after(p)}const l=document.createRange();l.setStartAfter(s),l.collapse(!0);const d=window.getSelection();d?.removeAllRanges(),d?.addRange(l),P.recordDomHistory(e,B),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function z(e){const o=e.closest('[contenteditable="true"]');o&&O((t,r)=>{if(!e.isConnected)return;const i=o.innerHTML;X(e,t,r),P.recordDomHistory(o,i),o.dispatchEvent(new Event("input",{bubbles:!0}))},"editing",I(e),Y(e))}const re=()=>({name:"codeSample",toolbar:[{label:"Insert Code",command:"insertCodeBlock",icon:'<svg width="24" height="26" focusable="false"><path d="M7.1 11a2.8 2.8 0 0 1-.8 2 2.8 2.8 0 0 1 .8 2v1.7c0 .3.1.6.4.8.2.3.5.4.8.4.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.7 0-1.4-.3-2-.8-.5-.6-.8-1.3-.8-2V15c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 0 1-.4-.4v-.8c0-.2.2-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V9.3c0-.7.3-1.4.8-2 .6-.5 1.3-.8 2-.8.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8V11Zm9.8 0V9.3c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 0 1-.4-.4V7c0-.2.1-.4.4-.4.7 0 1.4.3 2 .8.5.6.8 1.3.8 2V11c0 .3.1.6.4.8.2.3.5.4.8.4.2 0 .4.2.4.4v.8c0 .2-.2.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8v1.7c0 .7-.3 1.4-.8 2-.6.5-1.3.8-2 .8a.4.4 0 0 1-.4-.4v-.8c0-.2.1-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V15a2.8 2.8 0 0 1 .8-2 2.8 2.8 0 0 1-.8-2Zm-3.3-.4c0 .4-.1.8-.5 1.1-.3.3-.7.5-1.1.5-.4 0-.8-.2-1.1-.5-.4-.3-.5-.7-.5-1.1 0-.5.1-.9.5-1.2.3-.3.7-.4 1.1-.4.4 0 .8.1 1.1.4.4.3.5.7.5 1.2ZM12 13c.4 0 .8.1 1.1.5.4.3.5.7.5 1.1 0 1-.1 1.6-.5 2a3 3 0 0 1-1.1 1c-.4.3-.8.4-1.1.4a.5.5 0 0 1-.5-.5V17a3 3 0 0 0 1-.2l.6-.6c-.6 0-1-.2-1.3-.5-.2-.3-.3-.7-.3-1 0-.5.1-1 .5-1.2.3-.4.7-.5 1.1-.5Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-C"}],commands:{insertCodeBlock:()=>(ne(),!0)}});exports.CodeSamplePlugin=re;
|