@editora/plugins 1.0.10 → 1.0.11
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/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +80 -98
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +115 -128
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +208 -249
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +55 -68
- package/dist/blockquote.esm.js +1 -2
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +178 -245
- package/dist/capitalization.esm.js +1 -2
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +58 -82
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +439 -512
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +27 -33
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +82 -93
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +501 -506
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +116 -158
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +371 -432
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +105 -159
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +328 -368
- package/dist/direction.esm.js +9 -18
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +240 -308
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +4 -5
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +73 -81
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +65 -77
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +54 -56
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +39 -47
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +37 -53
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +76 -117
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +70 -92
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +12 -24
- package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-CE_A4QSm.js +5 -0
- package/dist/index.es-DQ78mYYo.mjs +6665 -0
- package/dist/index.esm.js +125 -128
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +8 -9
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +11 -24
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +24 -30
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +20 -25
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +59 -61
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +139 -146
- package/dist/media-manager.cjs.js +31 -31
- package/dist/media-manager.esm.js +285 -300
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +238 -286
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +177 -216
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +33 -49
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +393 -463
- package/dist/plugins.css +1 -0
- package/dist/preview.esm.js +5 -10
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +17 -20
- package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
- package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
- package/dist/slash-commands.cjs.js +2 -2
- package/dist/slash-commands.esm.js +39 -75
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +280 -336
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +61 -69
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +97 -123
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +14 -19
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +191 -225
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +715 -196
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +21 -27
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +70 -87
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +100 -162
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +602 -678
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +128 -157
- package/package.json +1 -1
- package/dist/_commonjsHelpers-6763f629.js +0 -1
- package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
- package/dist/anchoredPopover-33f1358d.mjs +0 -109
- package/dist/anchoredPopover-8151d535.js +0 -1
- package/dist/documentManager-25b6203c.mjs +0 -9122
- package/dist/documentManager-b69e7054.js +0 -17
- package/dist/html2canvas.esm-09133e29.js +0 -22
- package/dist/index-656d224b.js +0 -231
- package/dist/index-6a8c48bb.js +0 -1
- package/dist/index-d027b7e2.mjs +0 -16859
- package/dist/index.es-730f2d98.mjs +0 -5775
- package/dist/index.es-dd40173b.js +0 -18
- package/dist/jspdf.es.min-90db2c97.js +0 -243
- package/dist/style.css +0 -1
- /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
|
@@ -1 +1 @@
|
|
|
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 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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const m = () => ({
|
|
2
2
|
name: "clearFormatting",
|
|
3
3
|
// Toolbar button configuration
|
|
4
4
|
toolbar: [
|
|
@@ -15,24 +15,21 @@ const p = () => ({
|
|
|
15
15
|
* Remove all formatting from current selection
|
|
16
16
|
*/
|
|
17
17
|
clearFormatting: () => {
|
|
18
|
-
const t =
|
|
19
|
-
if (!t)
|
|
20
|
-
return !1;
|
|
18
|
+
const t = d();
|
|
19
|
+
if (!t) return !1;
|
|
21
20
|
const e = window.getSelection();
|
|
22
|
-
if (!e || e.rangeCount === 0)
|
|
23
|
-
return !1;
|
|
21
|
+
if (!e || e.rangeCount === 0) return !1;
|
|
24
22
|
const o = e.getRangeAt(0);
|
|
25
|
-
if (!t.contains(o.commonAncestorContainer))
|
|
26
|
-
return !1;
|
|
23
|
+
if (!t.contains(o.commonAncestorContainer)) return !1;
|
|
27
24
|
const n = o.cloneRange();
|
|
28
|
-
return t.focus({ preventScroll: !0 }), document.execCommand("unlink", !1), document.execCommand("removeFormat", !1),
|
|
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;
|
|
29
26
|
}
|
|
30
27
|
},
|
|
31
28
|
// Keyboard shortcuts
|
|
32
29
|
keymap: {
|
|
33
30
|
"Mod-\\": "clearFormatting"
|
|
34
31
|
}
|
|
35
|
-
}),
|
|
32
|
+
}), s = /* @__PURE__ */ new Set([
|
|
36
33
|
"A",
|
|
37
34
|
"B",
|
|
38
35
|
"STRONG",
|
|
@@ -47,7 +44,7 @@ const p = () => ({
|
|
|
47
44
|
"CODE",
|
|
48
45
|
"SUB",
|
|
49
46
|
"SUP"
|
|
50
|
-
]),
|
|
47
|
+
]), l = /* @__PURE__ */ new Set([
|
|
51
48
|
"H1",
|
|
52
49
|
"H2",
|
|
53
50
|
"H3",
|
|
@@ -56,7 +53,7 @@ const p = () => ({
|
|
|
56
53
|
"H6",
|
|
57
54
|
"BLOCKQUOTE",
|
|
58
55
|
"PRE"
|
|
59
|
-
]),
|
|
56
|
+
]), u = [
|
|
60
57
|
"color",
|
|
61
58
|
"background-color",
|
|
62
59
|
"font-size",
|
|
@@ -72,17 +69,16 @@ const p = () => ({
|
|
|
72
69
|
"text-align",
|
|
73
70
|
"padding-left"
|
|
74
71
|
];
|
|
75
|
-
function
|
|
72
|
+
function d() {
|
|
76
73
|
const t = window.getSelection();
|
|
77
74
|
if (t && t.rangeCount > 0) {
|
|
78
|
-
const o = t.getRangeAt(0).startContainer,
|
|
79
|
-
if (r)
|
|
80
|
-
return r;
|
|
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;
|
|
81
77
|
}
|
|
82
78
|
const e = document.activeElement;
|
|
83
79
|
return e ? e.getAttribute("contenteditable") === "true" ? e : e.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
|
|
84
80
|
}
|
|
85
|
-
function
|
|
81
|
+
function c(t, e) {
|
|
86
82
|
try {
|
|
87
83
|
if (typeof t.intersectsNode == "function")
|
|
88
84
|
return t.intersectsNode(e);
|
|
@@ -91,18 +87,18 @@ function s(t, e) {
|
|
|
91
87
|
const o = document.createRange();
|
|
92
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;
|
|
93
89
|
}
|
|
94
|
-
function
|
|
90
|
+
function a(t) {
|
|
95
91
|
let e = 0, o = t;
|
|
96
92
|
for (; o && o.parentNode; )
|
|
97
93
|
e += 1, o = o.parentNode;
|
|
98
94
|
return e;
|
|
99
95
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
96
|
+
function f(t) {
|
|
97
|
+
u.forEach((e) => {
|
|
102
98
|
t.style.removeProperty(e);
|
|
103
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");
|
|
104
100
|
}
|
|
105
|
-
function
|
|
101
|
+
function i(t) {
|
|
106
102
|
const e = t.parentNode;
|
|
107
103
|
if (e) {
|
|
108
104
|
for (; t.firstChild; )
|
|
@@ -110,35 +106,33 @@ function c(t) {
|
|
|
110
106
|
e.removeChild(t);
|
|
111
107
|
}
|
|
112
108
|
}
|
|
113
|
-
function
|
|
109
|
+
function g(t, e) {
|
|
114
110
|
Array.from(
|
|
115
111
|
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
|
|
116
112
|
).forEach((n) => {
|
|
117
|
-
|
|
118
|
-
if (!s(e, n) || !u.has(n.tagName))
|
|
119
|
-
return;
|
|
113
|
+
if (!c(e, n) || !l.has(n.tagName)) return;
|
|
120
114
|
const r = document.createElement("p");
|
|
121
115
|
for (; n.firstChild; )
|
|
122
116
|
r.appendChild(n.firstChild);
|
|
123
|
-
|
|
117
|
+
n.parentNode?.replaceChild(r, n);
|
|
124
118
|
});
|
|
125
119
|
}
|
|
126
|
-
function
|
|
120
|
+
function h(t, e) {
|
|
127
121
|
const o = Array.from(
|
|
128
122
|
t.querySelectorAll(
|
|
129
123
|
"a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
|
|
130
124
|
)
|
|
131
125
|
);
|
|
132
|
-
o.sort((n, r) =>
|
|
133
|
-
if (n.isConnected &&
|
|
134
|
-
if (
|
|
135
|
-
|
|
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);
|
|
136
130
|
return;
|
|
137
131
|
}
|
|
138
|
-
n.tagName === "SPAN" && n.attributes.length === 0 &&
|
|
132
|
+
n.tagName === "SPAN" && n.attributes.length === 0 && i(n);
|
|
139
133
|
}
|
|
140
134
|
});
|
|
141
135
|
}
|
|
142
136
|
export {
|
|
143
|
-
|
|
137
|
+
m as ClearFormattingPlugin
|
|
144
138
|
};
|
package/dist/code-sample.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=()=>{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
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=()=>{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 r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const t=r.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},k='[data-theme="dark"], .dark, .editora-theme-dark',N=()=>{if(S()?.closest(k))return!0;const r=window.getSelection();if(r&&r.rangeCount>0){const n=r.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"}],B=new Map;function $(d,r,t,n){const s=!!r,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
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
`,u.innerHTML=`
|
|
32
32
|
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">
|
|
33
|
-
${
|
|
33
|
+
${s?"Edit Code Sample":"Insert Code Sample"}
|
|
34
34
|
</h2>
|
|
35
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
36
|
`;const m=document.createElement("div");m.style.cssText=`
|
|
37
37
|
flex: 1;
|
|
38
38
|
overflow-y: auto;
|
|
39
39
|
padding: 20px;
|
|
40
|
-
`;const
|
|
40
|
+
`;const i=document.createElement("div");i.style.marginBottom="20px",i.innerHTML=`
|
|
41
41
|
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Language</label>
|
|
42
42
|
<select class="rte-code-language" style="
|
|
43
43
|
width: 100%;
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
color: ${e.text};
|
|
50
50
|
cursor: pointer;
|
|
51
51
|
">
|
|
52
|
-
${A.map(
|
|
53
|
-
<option value="${
|
|
54
|
-
${
|
|
52
|
+
${A.map(a=>`
|
|
53
|
+
<option value="${a.value}" ${a.value===c?"selected":""}>
|
|
54
|
+
${a.label}
|
|
55
55
|
</option>
|
|
56
56
|
`).join("")}
|
|
57
57
|
</select>
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
box-sizing: border-box;
|
|
74
74
|
">${g}</textarea>
|
|
75
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(
|
|
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
77
|
padding: 20px;
|
|
78
78
|
border-top: 1px solid ${e.border};
|
|
79
79
|
background: ${e.headerFooterBg};
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
cursor: pointer;
|
|
101
101
|
background: ${e.primaryBg};
|
|
102
102
|
color: #fff;
|
|
103
|
-
">${
|
|
104
|
-
`,o.appendChild(u),o.appendChild(m),o.appendChild(y),
|
|
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"),T=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()},w=()=>{const a=E.value.trim();if(!a){T.textContent="⚠ Code cannot be empty",T.style.display="block";return}const M=L.value;d(a,M),C()};if(f.onclick=C,v.onclick=C,h.onclick=w,E.addEventListener("keydown",a=>{(a.ctrlKey||a.metaKey)&&a.key==="Enter"&&(a.preventDefault(),w()),a.key==="Escape"&&C()}),E.addEventListener("input",()=>{T.style.display="none"}),l.addEventListener("click",a=>{a.target===l&&C()}),!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,7 +110,7 @@
|
|
|
110
110
|
from { transform: translateY(20px); opacity: 0; }
|
|
111
111
|
to { transform: translateY(0); opacity: 1; }
|
|
112
112
|
}
|
|
113
|
-
`,document.head.appendChild(
|
|
113
|
+
`,document.head.appendChild(a)}return document.body.appendChild(l),setTimeout(()=>E.focus(),100),l}function R(){if(!S())return;let r=null;const t=window.getSelection();t&&t.rangeCount>0&&(r=t.getRangeAt(0).cloneRange()),$((n,s)=>{const c=window.getSelection();if(r&&(c?.removeAllRanges(),c?.addRange(r)),!c||c.rangeCount===0)return;const g=S();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
114
|
display: block;
|
|
115
115
|
position: relative;
|
|
116
116
|
background: #f5f5f5;
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
color: #333;
|
|
126
126
|
user-select: text;
|
|
127
127
|
cursor: default;
|
|
128
|
-
`;const u=document.createElement("code");u.className=`language-${
|
|
128
|
+
`;const u=document.createElement("code");u.className=`language-${s}`,u.style.cssText=`
|
|
129
129
|
font-family: inherit;
|
|
130
130
|
font-size: inherit;
|
|
131
131
|
line-height: inherit;
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
white-space: pre;
|
|
134
134
|
word-break: normal;
|
|
135
135
|
display: block;
|
|
136
|
-
`,u.textContent=
|
|
136
|
+
`,u.textContent=n;const m=document.createElement("span");m.style.cssText=`
|
|
137
137
|
position: absolute;
|
|
138
138
|
top: 0;
|
|
139
139
|
right: 0;
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
text-transform: uppercase;
|
|
147
147
|
letter-spacing: 0.5px;
|
|
148
148
|
pointer-events: none;
|
|
149
|
-
`,m.textContent=
|
|
149
|
+
`,m.textContent=s;const i=document.createElement("button");i.className="rte-code-copy",i.textContent="Copy",i.style.cssText=`
|
|
150
150
|
position: absolute;
|
|
151
151
|
top: 8px;
|
|
152
152
|
left: 8px;
|
|
@@ -158,4 +158,4 @@
|
|
|
158
158
|
cursor: pointer;
|
|
159
159
|
opacity: 0;
|
|
160
160
|
transition: opacity 0.2s ease;
|
|
161
|
-
`,
|
|
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)}),B.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 r=S();if(!r)return;const t=r.querySelector(`#${d}`);if(!t)return;const n=B.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:"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:(...d)=>(R(),!0)}});exports.CodeSamplePlugin=H;
|
package/dist/code-sample.esm.js
CHANGED
|
@@ -4,34 +4,29 @@ const T = () => {
|
|
|
4
4
|
let t = d.getRangeAt(0).startContainer;
|
|
5
5
|
for (; t && t !== document.body; ) {
|
|
6
6
|
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
7
|
+
const n = t;
|
|
8
|
+
if (n.getAttribute("contenteditable") === "true")
|
|
9
|
+
return n;
|
|
10
10
|
}
|
|
11
11
|
t = t.parentNode;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
const t =
|
|
19
|
-
if (t)
|
|
20
|
-
return t;
|
|
14
|
+
const r = document.activeElement;
|
|
15
|
+
if (r) {
|
|
16
|
+
if (r.getAttribute("contenteditable") === "true")
|
|
17
|
+
return r;
|
|
18
|
+
const t = r.closest('[contenteditable="true"]');
|
|
19
|
+
if (t) return t;
|
|
21
20
|
}
|
|
22
21
|
return document.querySelector('[contenteditable="true"]');
|
|
23
22
|
}, k = '[data-theme="dark"], .dark, .editora-theme-dark', A = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const a = l.getRangeAt(0).startContainer, i = a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement;
|
|
30
|
-
if (i != null && i.closest(k))
|
|
31
|
-
return !0;
|
|
23
|
+
if (T()?.closest(k)) return !0;
|
|
24
|
+
const r = window.getSelection();
|
|
25
|
+
if (r && r.rangeCount > 0) {
|
|
26
|
+
const n = r.getRangeAt(0).startContainer;
|
|
27
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(k)) return !0;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
return t != null && t.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
|
|
29
|
+
return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
|
|
35
30
|
}, M = [
|
|
36
31
|
{ value: "javascript", label: "JavaScript" },
|
|
37
32
|
{ value: "typescript", label: "TypeScript" },
|
|
@@ -58,8 +53,8 @@ const T = () => {
|
|
|
58
53
|
{ value: "shell", label: "Shell" },
|
|
59
54
|
{ value: "plaintext", label: "Plain Text" }
|
|
60
55
|
], S = /* @__PURE__ */ new Map();
|
|
61
|
-
function $(d,
|
|
62
|
-
const
|
|
56
|
+
function $(d, r, t, n) {
|
|
57
|
+
const s = !!r, c = n || "javascript", f = t || "", p = A(), e = p ? {
|
|
63
58
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
64
59
|
dialogBg: "#1f2937",
|
|
65
60
|
dialogBorder: "#4b5563",
|
|
@@ -89,8 +84,8 @@ function $(d, l, t, a) {
|
|
|
89
84
|
cancelText: "#333333",
|
|
90
85
|
primaryBg: "#2563eb",
|
|
91
86
|
primaryHover: "#1d4ed8"
|
|
92
|
-
},
|
|
93
|
-
|
|
87
|
+
}, l = document.createElement("div");
|
|
88
|
+
l.className = "rte-code-sample-overlay", p && l.classList.add("rte-theme-dark"), l.style.cssText = `
|
|
94
89
|
position: fixed;
|
|
95
90
|
top: 0;
|
|
96
91
|
left: 0;
|
|
@@ -126,7 +121,7 @@ function $(d, l, t, a) {
|
|
|
126
121
|
align-items: center;
|
|
127
122
|
`, u.innerHTML = `
|
|
128
123
|
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">
|
|
129
|
-
${
|
|
124
|
+
${s ? "Edit Code Sample" : "Insert Code Sample"}
|
|
130
125
|
</h2>
|
|
131
126
|
<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>
|
|
132
127
|
`;
|
|
@@ -136,8 +131,8 @@ function $(d, l, t, a) {
|
|
|
136
131
|
overflow-y: auto;
|
|
137
132
|
padding: 20px;
|
|
138
133
|
`;
|
|
139
|
-
const
|
|
140
|
-
|
|
134
|
+
const i = document.createElement("div");
|
|
135
|
+
i.style.marginBottom = "20px", i.innerHTML = `
|
|
141
136
|
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Language</label>
|
|
142
137
|
<select class="rte-code-language" style="
|
|
143
138
|
width: 100%;
|
|
@@ -149,9 +144,9 @@ function $(d, l, t, a) {
|
|
|
149
144
|
color: ${e.text};
|
|
150
145
|
cursor: pointer;
|
|
151
146
|
">
|
|
152
|
-
${M.map((
|
|
153
|
-
<option value="${
|
|
154
|
-
${
|
|
147
|
+
${M.map((a) => `
|
|
148
|
+
<option value="${a.value}" ${a.value === c ? "selected" : ""}>
|
|
149
|
+
${a.label}
|
|
155
150
|
</option>
|
|
156
151
|
`).join("")}
|
|
157
152
|
</select>
|
|
@@ -177,7 +172,7 @@ function $(d, l, t, a) {
|
|
|
177
172
|
<div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
|
|
178
173
|
`;
|
|
179
174
|
const x = document.createElement("div");
|
|
180
|
-
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(
|
|
175
|
+
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);
|
|
181
176
|
const y = document.createElement("div");
|
|
182
177
|
y.style.cssText = `
|
|
183
178
|
padding: 20px;
|
|
@@ -206,9 +201,9 @@ function $(d, l, t, a) {
|
|
|
206
201
|
cursor: pointer;
|
|
207
202
|
background: ${e.primaryBg};
|
|
208
203
|
color: #fff;
|
|
209
|
-
">${
|
|
210
|
-
`, o.appendChild(u), o.appendChild(m), o.appendChild(y),
|
|
211
|
-
const L =
|
|
204
|
+
">${s ? "Update Code Sample" : "Insert Code Sample"}</button>
|
|
205
|
+
`, o.appendChild(u), o.appendChild(m), o.appendChild(y), l.appendChild(o);
|
|
206
|
+
const L = i.querySelector(".rte-code-language"), E = b.querySelector(".rte-code-textarea"), w = b.querySelector(".rte-code-error"), g = u.querySelector(".rte-code-close-btn"), v = y.querySelector(".rte-code-cancel-btn"), h = y.querySelector(".rte-code-save-btn");
|
|
212
207
|
g.onmouseover = () => {
|
|
213
208
|
g.style.color = "#f8fafc", g.style.background = p ? "#334155" : "#f0f0f0", g.style.borderRadius = "4px";
|
|
214
209
|
}, g.onmouseout = () => {
|
|
@@ -223,25 +218,25 @@ function $(d, l, t, a) {
|
|
|
223
218
|
h.style.background = e.primaryBg;
|
|
224
219
|
};
|
|
225
220
|
const C = () => {
|
|
226
|
-
|
|
221
|
+
l.remove();
|
|
227
222
|
}, B = () => {
|
|
228
|
-
const
|
|
229
|
-
if (!
|
|
223
|
+
const a = E.value.trim();
|
|
224
|
+
if (!a) {
|
|
230
225
|
w.textContent = "⚠ Code cannot be empty", w.style.display = "block";
|
|
231
226
|
return;
|
|
232
227
|
}
|
|
233
228
|
const N = L.value;
|
|
234
|
-
d(
|
|
229
|
+
d(a, N), C();
|
|
235
230
|
};
|
|
236
|
-
if (g.onclick = C, v.onclick = C, h.onclick = B, E.addEventListener("keydown", (
|
|
237
|
-
(
|
|
231
|
+
if (g.onclick = C, v.onclick = C, h.onclick = B, E.addEventListener("keydown", (a) => {
|
|
232
|
+
(a.ctrlKey || a.metaKey) && a.key === "Enter" && (a.preventDefault(), B()), a.key === "Escape" && C();
|
|
238
233
|
}), E.addEventListener("input", () => {
|
|
239
234
|
w.style.display = "none";
|
|
240
|
-
}),
|
|
241
|
-
|
|
235
|
+
}), l.addEventListener("click", (a) => {
|
|
236
|
+
a.target === l && C();
|
|
242
237
|
}), !document.getElementById("rte-code-sample-animations")) {
|
|
243
|
-
const
|
|
244
|
-
|
|
238
|
+
const a = document.createElement("style");
|
|
239
|
+
a.id = "rte-code-sample-animations", a.textContent = `
|
|
245
240
|
@keyframes fadeIn {
|
|
246
241
|
from { opacity: 0; }
|
|
247
242
|
to { opacity: 1; }
|
|
@@ -250,27 +245,23 @@ function $(d, l, t, a) {
|
|
|
250
245
|
from { transform: translateY(20px); opacity: 0; }
|
|
251
246
|
to { transform: translateY(0); opacity: 1; }
|
|
252
247
|
}
|
|
253
|
-
`, document.head.appendChild(
|
|
248
|
+
`, document.head.appendChild(a);
|
|
254
249
|
}
|
|
255
|
-
return document.body.appendChild(
|
|
250
|
+
return document.body.appendChild(l), setTimeout(() => E.focus(), 100), l;
|
|
256
251
|
}
|
|
257
252
|
function R() {
|
|
258
|
-
if (!T())
|
|
259
|
-
|
|
260
|
-
let l = null;
|
|
253
|
+
if (!T()) return;
|
|
254
|
+
let r = null;
|
|
261
255
|
const t = window.getSelection();
|
|
262
|
-
t && t.rangeCount > 0 && (
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
265
|
-
return;
|
|
256
|
+
t && t.rangeCount > 0 && (r = t.getRangeAt(0).cloneRange()), $((n, s) => {
|
|
257
|
+
const c = window.getSelection();
|
|
258
|
+
if (r && (c?.removeAllRanges(), c?.addRange(r)), !c || c.rangeCount === 0) return;
|
|
266
259
|
const f = T();
|
|
267
|
-
if (!f)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const e = n.getRangeAt(0), c = `code-block-${Date.now()}`, o = document.createElement("pre");
|
|
273
|
-
o.className = "rte-code-block", o.id = c, o.setAttribute("data-type", "code-block"), o.setAttribute("data-lang", i), o.setAttribute("data-code-id", c), o.setAttribute("contenteditable", "false"), o.style.cssText = `
|
|
260
|
+
if (!f) return;
|
|
261
|
+
const p = c.anchorNode;
|
|
262
|
+
if (!p || !f.contains(p)) return;
|
|
263
|
+
const e = c.getRangeAt(0), l = `code-block-${Date.now()}`, o = document.createElement("pre");
|
|
264
|
+
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 = `
|
|
274
265
|
display: block;
|
|
275
266
|
position: relative;
|
|
276
267
|
background: #f5f5f5;
|
|
@@ -287,7 +278,7 @@ function R() {
|
|
|
287
278
|
cursor: default;
|
|
288
279
|
`;
|
|
289
280
|
const u = document.createElement("code");
|
|
290
|
-
u.className = `language-${
|
|
281
|
+
u.className = `language-${s}`, u.style.cssText = `
|
|
291
282
|
font-family: inherit;
|
|
292
283
|
font-size: inherit;
|
|
293
284
|
line-height: inherit;
|
|
@@ -295,7 +286,7 @@ function R() {
|
|
|
295
286
|
white-space: pre;
|
|
296
287
|
word-break: normal;
|
|
297
288
|
display: block;
|
|
298
|
-
`, u.textContent =
|
|
289
|
+
`, u.textContent = n;
|
|
299
290
|
const m = document.createElement("span");
|
|
300
291
|
m.style.cssText = `
|
|
301
292
|
position: absolute;
|
|
@@ -310,9 +301,9 @@ function R() {
|
|
|
310
301
|
text-transform: uppercase;
|
|
311
302
|
letter-spacing: 0.5px;
|
|
312
303
|
pointer-events: none;
|
|
313
|
-
`, m.textContent =
|
|
314
|
-
const
|
|
315
|
-
|
|
304
|
+
`, m.textContent = s;
|
|
305
|
+
const i = document.createElement("button");
|
|
306
|
+
i.className = "rte-code-copy", i.textContent = "Copy", i.style.cssText = `
|
|
316
307
|
position: absolute;
|
|
317
308
|
top: 8px;
|
|
318
309
|
left: 8px;
|
|
@@ -324,44 +315,42 @@ function R() {
|
|
|
324
315
|
cursor: pointer;
|
|
325
316
|
opacity: 0;
|
|
326
317
|
transition: opacity 0.2s ease;
|
|
327
|
-
`,
|
|
328
|
-
x.stopPropagation(), navigator.clipboard.writeText(
|
|
329
|
-
|
|
330
|
-
|
|
318
|
+
`, i.onclick = (x) => {
|
|
319
|
+
x.stopPropagation(), navigator.clipboard.writeText(n).then(() => {
|
|
320
|
+
i.textContent = "✓ Copied!", setTimeout(() => {
|
|
321
|
+
i.textContent = "Copy";
|
|
331
322
|
}, 2e3);
|
|
332
323
|
});
|
|
333
|
-
}, o.appendChild(m), o.appendChild(
|
|
334
|
-
|
|
324
|
+
}, o.appendChild(m), o.appendChild(i), o.appendChild(u), o.addEventListener("mouseenter", () => {
|
|
325
|
+
i.style.opacity = "1";
|
|
335
326
|
}), o.addEventListener("mouseleave", () => {
|
|
336
|
-
|
|
327
|
+
i.style.opacity = "0";
|
|
337
328
|
}), o.addEventListener("dblclick", () => {
|
|
338
|
-
z(
|
|
339
|
-
}), S.set(
|
|
340
|
-
id:
|
|
341
|
-
language:
|
|
342
|
-
code:
|
|
329
|
+
z(l);
|
|
330
|
+
}), S.set(l, {
|
|
331
|
+
id: l,
|
|
332
|
+
language: s,
|
|
333
|
+
code: n
|
|
343
334
|
}), e.insertNode(o);
|
|
344
335
|
const b = document.createRange();
|
|
345
|
-
b.setStartAfter(o), b.collapse(!0),
|
|
336
|
+
b.setStartAfter(o), b.collapse(!0), c.removeAllRanges(), c.addRange(b);
|
|
346
337
|
});
|
|
347
338
|
}
|
|
348
339
|
function z(d) {
|
|
349
|
-
const
|
|
350
|
-
if (!
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
a && $(
|
|
357
|
-
(i, n) => {
|
|
340
|
+
const r = T();
|
|
341
|
+
if (!r) return;
|
|
342
|
+
const t = r.querySelector(`#${d}`);
|
|
343
|
+
if (!t) return;
|
|
344
|
+
const n = S.get(d);
|
|
345
|
+
n && $(
|
|
346
|
+
(s, c) => {
|
|
358
347
|
const f = t.querySelector("code");
|
|
359
|
-
f && (f.textContent =
|
|
348
|
+
f && (f.textContent = s, f.className = `language-${c}`);
|
|
360
349
|
const p = t.querySelector("span");
|
|
361
|
-
p && (p.textContent =
|
|
350
|
+
p && (p.textContent = c), t.setAttribute("data-lang", c), n.language = c, n.code = s;
|
|
362
351
|
const e = t.querySelector(".rte-code-copy");
|
|
363
|
-
e && (e.onclick = (
|
|
364
|
-
|
|
352
|
+
e && (e.onclick = (l) => {
|
|
353
|
+
l.stopPropagation(), navigator.clipboard.writeText(s).then(() => {
|
|
365
354
|
e.textContent = "✓ Copied!", setTimeout(() => {
|
|
366
355
|
e.textContent = "Copy";
|
|
367
356
|
}, 2e3);
|
|
@@ -369,8 +358,8 @@ function z(d) {
|
|
|
369
358
|
});
|
|
370
359
|
},
|
|
371
360
|
d,
|
|
372
|
-
|
|
373
|
-
|
|
361
|
+
n.code,
|
|
362
|
+
n.language
|
|
374
363
|
);
|
|
375
364
|
}
|
|
376
365
|
const H = () => ({
|