@editora/plugins 1.0.6 → 1.0.8
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/README.md +57 -4
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/anchor.cjs.js +11 -11
- package/dist/anchor.esm.js +130 -107
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/background-color.cjs.js +3 -3
- package/dist/background-color.esm.js +116 -119
- package/dist/code.cjs.js +82 -102
- package/dist/code.esm.js +1172 -662
- package/dist/comments.cjs.js +10 -10
- package/dist/comments.esm.js +195 -177
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/embed-iframe.cjs.js +2 -2
- package/dist/embed-iframe.esm.js +8 -5
- package/dist/emojis.cjs.js +64 -39
- package/dist/emojis.esm.js +133 -104
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
- package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
- 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-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
- package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
- package/dist/index.esm.js +87 -79
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
- package/dist/link.cjs.js +6 -6
- package/dist/link.esm.js +41 -39
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +151 -112
- package/dist/media-manager.cjs.js +15 -15
- package/dist/media-manager.esm.js +227 -206
- package/dist/merge-tag.cjs.js +44 -12
- package/dist/merge-tag.esm.js +368 -241
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +77 -69
- package/dist/special-characters.cjs.js +83 -45
- package/dist/special-characters.esm.js +149 -100
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +235 -216
- package/dist/template.cjs.js +14 -14
- package/dist/template.esm.js +157 -131
- package/dist/text-color.cjs.js +9 -9
- package/dist/text-color.esm.js +131 -115
- package/index.d.ts +51 -1
- package/package.json +6 -4
- package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
- package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
- package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
- package/dist/documentManager-_tQQfQi9.js +0 -317
- package/dist/index-D3pJyAsj.js +0 -1
package/dist/template.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 q=require("./purify.es-T2a3nLiC.js");let n=null,d=null,u=null,o=null,m="",g="",v="insert",x=null,s=null,E=null;function N(t,e){if(e===t.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,t.innerHTML)}catch{}}function V(t){if(!t)return null;let e=t.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true")return r}e=e.parentNode}return null}const I=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
|
|
2
2
|
<p>{{ Today }}</p>
|
|
3
3
|
<p>Dear {{ first_name }} {{ last_name }},</p>
|
|
4
4
|
<p>I hope this letter finds you well. [Your letter content here]</p>
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
<h3>Q: How do I get started?</h3>
|
|
41
41
|
<p>A: [Answer here]</p>
|
|
42
42
|
<h3>Q: What are the requirements?</h3>
|
|
43
|
-
<p>A: [Answer here]</p>`}];let
|
|
43
|
+
<p>A: [Answer here]</p>`}];let b=[...I];const L=()=>b,z=t=>b.filter(e=>e.category===t),C=()=>{const t=new Set(b.map(e=>e.category));return Array.from(t)},P=t=>{const e=t.toLowerCase();return b.filter(r=>r.name.toLowerCase().includes(e)||r.description?.toLowerCase().includes(e)||r.tags?.some(l=>l.toLowerCase().includes(e)))},A=t=>q.default.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","u","h1","h2","h3","h4","ul","ol","li","blockquote","table","thead","tbody","tr","th","td","a","span"],ALLOWED_ATTR:["href","target","class","data-key","data-category"]}),B=t=>b.some(e=>e.id===t.id)?(console.warn(`Template with ID ${t.id} already exists`),!1):(b.push(t),!0),F=t=>!!(t.id&&t.name&&t.category&&t.html&&t.html.trim().length>0);function O(t){d=document.createElement("div"),d.className="rte-dialog-overlay",Z(t)&&d.classList.add("rte-ui-theme-dark"),d.addEventListener("click",()=>c()),n=document.createElement("div"),n.className="rte-dialog rte-template-dialog",n.addEventListener("click",r=>r.stopPropagation());const e=C();e.length>0&&!m&&(m=e[0]),y(),d.appendChild(n),document.body.appendChild(d),Q(),X()}function Q(){_(),x=t=>{t.key==="Escape"&&(!d||!n||(t.preventDefault(),t.stopPropagation(),c()))},document.addEventListener("keydown",x,!0)}function _(){x&&(document.removeEventListener("keydown",x,!0),x=null)}const W='[data-theme="dark"], .dark, .editora-theme-dark',R=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},Z=t=>{const e=t||R();return e?!!e.closest(W):!1};function S(){const t=V(u);if(t)return t;if(E?.isConnected)return E;const e=R();return e||document.querySelector(".rte-content, .editora-content")}function y(){if(!n)return;const t=C(),e=M();n.innerHTML=`
|
|
44
44
|
<div class="rte-dialog-header">
|
|
45
45
|
<h2>Insert Template</h2>
|
|
46
46
|
<button class="rte-dialog-close" aria-label="Close">✕</button>
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<input
|
|
52
52
|
type="text"
|
|
53
53
|
placeholder="Search templates..."
|
|
54
|
-
value="${
|
|
54
|
+
value="${g}"
|
|
55
55
|
class="rte-input rte-template-search"
|
|
56
56
|
aria-label="Search templates"
|
|
57
57
|
/>
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
<!-- Category Tabs -->
|
|
60
60
|
<div class="rte-tabs">
|
|
61
61
|
${t.map(r=>`
|
|
62
|
-
<button class="rte-tab ${
|
|
62
|
+
<button class="rte-tab ${m===r?"active":""}" data-category="${r}">
|
|
63
63
|
${r}
|
|
64
64
|
</button>
|
|
65
65
|
`).join("")}
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
<div class="rte-template-list">
|
|
70
70
|
${e.length>0?e.map(r=>`
|
|
71
71
|
<div
|
|
72
|
-
class="rte-template-item ${
|
|
72
|
+
class="rte-template-item ${o?.id===r.id?"selected":""}"
|
|
73
73
|
data-template-id="${r.id}"
|
|
74
74
|
>
|
|
75
75
|
<div class="template-name">${r.name}</div>
|
|
@@ -79,21 +79,21 @@
|
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
81
|
<!-- Preview -->
|
|
82
|
-
${
|
|
82
|
+
${o?`
|
|
83
83
|
<div class="rte-template-preview">
|
|
84
84
|
<strong>Preview:</strong>
|
|
85
|
-
<div class="template-preview-content">${
|
|
85
|
+
<div class="template-preview-content">${o.html}</div>
|
|
86
86
|
</div>
|
|
87
87
|
`:""}
|
|
88
88
|
|
|
89
89
|
<!-- Insert Mode Toggle -->
|
|
90
90
|
<div class="rte-insert-mode">
|
|
91
91
|
<label>
|
|
92
|
-
<input type="radio" name="insertMode" value="insert" ${
|
|
92
|
+
<input type="radio" name="insertMode" value="insert" ${v==="insert"?"checked":""} />
|
|
93
93
|
Insert at cursor
|
|
94
94
|
</label>
|
|
95
95
|
<label>
|
|
96
|
-
<input type="radio" name="insertMode" value="replace" ${
|
|
96
|
+
<input type="radio" name="insertMode" value="replace" ${v==="replace"?"checked":""} />
|
|
97
97
|
Replace document
|
|
98
98
|
</label>
|
|
99
99
|
</div>
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
|
|
102
102
|
<div class="rte-dialog-footer">
|
|
103
103
|
<button class="rte-button-secondary rte-cancel-btn">Cancel</button>
|
|
104
|
-
<button class="rte-button-primary rte-insert-btn" ${
|
|
105
|
-
${
|
|
104
|
+
<button class="rte-button-primary rte-insert-btn" ${o?"":"disabled"}>
|
|
105
|
+
${v==="insert"?"Insert":"Replace"}
|
|
106
106
|
</button>
|
|
107
107
|
</div>
|
|
108
|
-
`,
|
|
108
|
+
`,K()}function G(){if(!n)return;n.innerHTML=`
|
|
109
109
|
<div class="rte-dialog-header">
|
|
110
110
|
<h2>Replace Document?</h2>
|
|
111
111
|
</div>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
<button class="rte-button-secondary rte-cancel-warning-btn">Cancel</button>
|
|
117
117
|
<button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
|
|
118
118
|
</div>
|
|
119
|
-
`;const t=
|
|
119
|
+
`;const t=n.querySelector(".rte-cancel-warning-btn"),e=n.querySelector(".rte-confirm-replace-btn");t?.addEventListener("click",()=>y()),e?.addEventListener("click",()=>Y())}function M(){const t=L();return g.trim()?P(g):m?t.filter(e=>e.category===m):t}function K(){if(!n)return;n.querySelector(".rte-dialog-close")?.addEventListener("click",()=>c()),n.querySelector(".rte-cancel-btn")?.addEventListener("click",()=>c()),n.querySelector(".rte-insert-btn")?.addEventListener("click",()=>k());const l=n.querySelector(".rte-template-search");l?.addEventListener("input",a=>{s!==null&&cancelAnimationFrame(s),g=a.target.value,s=requestAnimationFrame(()=>{s=null,H()})}),l?.addEventListener("keydown",a=>{a.key==="Enter"&&o?k():a.key==="Escape"&&c()}),n.querySelector(".rte-tabs")?.addEventListener("click",a=>{const f=a.target.closest(".rte-tab");if(!f)return;const h=f.getAttribute("data-category");h&&(m=h,g="",s!==null&&(cancelAnimationFrame(s),s=null),H())});const T=n.querySelector(".rte-template-list"),p=a=>{const f=a.target.closest(".rte-template-item");if(!f)return null;const h=f.getAttribute("data-template-id");return h&&L().find(j=>j.id===h)||null};T?.addEventListener("click",a=>{const i=p(a);i&&(o=i,y())}),T?.addEventListener("dblclick",a=>{const i=p(a);i&&(o=i,k())}),n.querySelector(".rte-insert-mode")?.addEventListener("change",a=>{const i=a.target;!i||i.name!=="insertMode"||(v=i.value,y())})}function H(){const t=M();t.length>0?(!o||!t.find(e=>e.id===o.id))&&(o=t[0]):o=null,y()}function k(){if(o)if(v==="replace"){if(S()?.innerHTML?.trim()){G();return}$(o),c()}else J(o),c()}function Y(){o&&($(o),c())}function J(t){const e=window.getSelection();if(!e)return;const r=S();if(!r)return;if(u)e.removeAllRanges(),e.addRange(u);else{const w=document.createRange();w.selectNodeContents(r),w.collapse(!1),e.removeAllRanges(),e.addRange(w)}if(e.rangeCount===0)return;const l=e.getRangeAt(0),D=r?.innerHTML??"",T=document.createRange().createContextualFragment(A(t.html));l.deleteContents(),l.insertNode(T);const p=document.createRange();p.setStartAfter(l.endContainer),p.collapse(!0),e.removeAllRanges(),e.addRange(p),r&&(N(r,D),r.dispatchEvent(new Event("input",{bubbles:!0})))}function $(t){const e=S();if(e){const r=e.innerHTML;e.innerHTML=A(t.html),N(e,r),e.dispatchEvent(new Event("input",{bubbles:!0}))}}function c(){_(),s!==null&&(cancelAnimationFrame(s),s=null),d&&(d.remove(),d=null),n=null,u=null,g="",E=null}function U(t){const e=window.getSelection();e&&e.rangeCount>0?u=e.getRangeAt(0).cloneRange():u=null;const r=M();r.length>0&&!o&&(o=r[0]);const l=t?.contentElement instanceof HTMLElement?t.contentElement:R();E=l||null,O(l)}function X(){if(typeof document>"u")return;const t="template-plugin-dialog-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
|
|
120
120
|
.rte-dialog-overlay {
|
|
121
121
|
--rte-tmpl-overlay-bg: rgba(15, 23, 36, 0.56);
|
|
122
122
|
--rte-tmpl-dialog-bg: #fff;
|
|
@@ -353,4 +353,4 @@
|
|
|
353
353
|
.rte-button-secondary:hover {
|
|
354
354
|
background-color: var(--rte-tmpl-subtle-hover);
|
|
355
355
|
}
|
|
356
|
-
`,document.head.appendChild(e)}const
|
|
356
|
+
`,document.head.appendChild(e)}const ee=()=>({name:"template",toolbar:[{label:"Template",command:"insertTemplate",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><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 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'}],commands:{insertTemplate:(t,e)=>(U(e),!0)},keymap:{}});exports.PREDEFINED_TEMPLATES=I;exports.TemplatePlugin=ee;exports.addCustomTemplate=B;exports.getAllTemplates=L;exports.getTemplateCategories=C;exports.getTemplatesByCategory=z;exports.sanitizeTemplate=A;exports.searchTemplates=P;exports.validateTemplate=F;
|
package/dist/template.esm.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
let
|
|
3
|
-
|
|
1
|
+
import j from "./purify.es-DHhaBdbu.mjs";
|
|
2
|
+
let n = null, d = null, u = null, o = null, m = "", g = "", v = "insert", x = null, s = null, E = null;
|
|
3
|
+
function M(t, e) {
|
|
4
|
+
if (e === t.innerHTML) return;
|
|
5
|
+
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
6
|
+
if (typeof r == "function")
|
|
7
|
+
try {
|
|
8
|
+
r("recordDomTransaction", t, e, t.innerHTML);
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function q(t) {
|
|
13
|
+
if (!t) return null;
|
|
14
|
+
let e = t.startContainer;
|
|
15
|
+
for (; e && e !== document.body; ) {
|
|
16
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
17
|
+
const r = e;
|
|
18
|
+
if (r.getAttribute("contenteditable") === "true")
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
e = e.parentNode;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const z = [
|
|
4
26
|
{
|
|
5
27
|
id: "formal-letter",
|
|
6
28
|
name: "Formal Letter",
|
|
@@ -72,39 +94,54 @@ const M = [
|
|
|
72
94
|
<p>A: [Answer here]</p>`
|
|
73
95
|
}
|
|
74
96
|
];
|
|
75
|
-
let
|
|
76
|
-
const
|
|
77
|
-
const t = new Set(
|
|
97
|
+
let b = [...z];
|
|
98
|
+
const H = () => b, U = (t) => b.filter((e) => e.category === t), D = () => {
|
|
99
|
+
const t = new Set(b.map((e) => e.category));
|
|
78
100
|
return Array.from(t);
|
|
79
|
-
},
|
|
101
|
+
}, B = (t) => {
|
|
80
102
|
const e = t.toLowerCase();
|
|
81
|
-
return
|
|
103
|
+
return b.filter(
|
|
82
104
|
(r) => r.name.toLowerCase().includes(e) || r.description?.toLowerCase().includes(e) || r.tags?.some((l) => l.toLowerCase().includes(e))
|
|
83
105
|
);
|
|
84
|
-
},
|
|
106
|
+
}, N = (t) => j.sanitize(t, {
|
|
85
107
|
ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
|
|
86
108
|
ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
|
|
87
|
-
});
|
|
88
|
-
function
|
|
89
|
-
d = document.createElement("div"), d.className = "rte-dialog-overlay",
|
|
90
|
-
const e =
|
|
91
|
-
e.length > 0 && !
|
|
109
|
+
}), X = (t) => b.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (b.push(t), !0), ee = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
|
|
110
|
+
function F(t) {
|
|
111
|
+
d = document.createElement("div"), d.className = "rte-dialog-overlay", Q(t) && d.classList.add("rte-ui-theme-dark"), d.addEventListener("click", () => c()), n = document.createElement("div"), n.className = "rte-dialog rte-template-dialog", n.addEventListener("click", (r) => r.stopPropagation());
|
|
112
|
+
const e = D();
|
|
113
|
+
e.length > 0 && !m && (m = e[0]), y(), d.appendChild(n), document.body.appendChild(d), P(), Y();
|
|
92
114
|
}
|
|
93
|
-
|
|
115
|
+
function P() {
|
|
116
|
+
$(), x = (t) => {
|
|
117
|
+
t.key === "Escape" && (!d || !n || (t.preventDefault(), t.stopPropagation(), c()));
|
|
118
|
+
}, document.addEventListener("keydown", x, !0);
|
|
119
|
+
}
|
|
120
|
+
function $() {
|
|
121
|
+
x && (document.removeEventListener("keydown", x, !0), x = null);
|
|
122
|
+
}
|
|
123
|
+
const _ = '[data-theme="dark"], .dark, .editora-theme-dark', L = () => {
|
|
94
124
|
const t = window.getSelection();
|
|
95
125
|
if (!t || t.rangeCount === 0) return null;
|
|
96
126
|
const e = t.anchorNode;
|
|
97
127
|
return (e instanceof HTMLElement ? e : e?.parentElement)?.closest(
|
|
98
128
|
".rte-content, .editora-content"
|
|
99
129
|
) || null;
|
|
100
|
-
},
|
|
101
|
-
const e = t ||
|
|
102
|
-
return e ? !!e.closest(
|
|
130
|
+
}, Q = (t) => {
|
|
131
|
+
const e = t || L();
|
|
132
|
+
return e ? !!e.closest(_) : !1;
|
|
103
133
|
};
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
function C() {
|
|
135
|
+
const t = q(u);
|
|
136
|
+
if (t) return t;
|
|
137
|
+
if (E?.isConnected) return E;
|
|
138
|
+
const e = L();
|
|
139
|
+
return e || document.querySelector(".rte-content, .editora-content");
|
|
140
|
+
}
|
|
141
|
+
function y() {
|
|
142
|
+
if (!n) return;
|
|
143
|
+
const t = D(), e = A();
|
|
144
|
+
n.innerHTML = `
|
|
108
145
|
<div class="rte-dialog-header">
|
|
109
146
|
<h2>Insert Template</h2>
|
|
110
147
|
<button class="rte-dialog-close" aria-label="Close">✕</button>
|
|
@@ -115,7 +152,7 @@ function b() {
|
|
|
115
152
|
<input
|
|
116
153
|
type="text"
|
|
117
154
|
placeholder="Search templates..."
|
|
118
|
-
value="${
|
|
155
|
+
value="${g}"
|
|
119
156
|
class="rte-input rte-template-search"
|
|
120
157
|
aria-label="Search templates"
|
|
121
158
|
/>
|
|
@@ -123,7 +160,7 @@ function b() {
|
|
|
123
160
|
<!-- Category Tabs -->
|
|
124
161
|
<div class="rte-tabs">
|
|
125
162
|
${t.map((r) => `
|
|
126
|
-
<button class="rte-tab ${
|
|
163
|
+
<button class="rte-tab ${m === r ? "active" : ""}" data-category="${r}">
|
|
127
164
|
${r}
|
|
128
165
|
</button>
|
|
129
166
|
`).join("")}
|
|
@@ -133,7 +170,7 @@ function b() {
|
|
|
133
170
|
<div class="rte-template-list">
|
|
134
171
|
${e.length > 0 ? e.map((r) => `
|
|
135
172
|
<div
|
|
136
|
-
class="rte-template-item ${
|
|
173
|
+
class="rte-template-item ${o?.id === r.id ? "selected" : ""}"
|
|
137
174
|
data-template-id="${r.id}"
|
|
138
175
|
>
|
|
139
176
|
<div class="template-name">${r.name}</div>
|
|
@@ -143,21 +180,21 @@ function b() {
|
|
|
143
180
|
</div>
|
|
144
181
|
|
|
145
182
|
<!-- Preview -->
|
|
146
|
-
${
|
|
183
|
+
${o ? `
|
|
147
184
|
<div class="rte-template-preview">
|
|
148
185
|
<strong>Preview:</strong>
|
|
149
|
-
<div class="template-preview-content">${
|
|
186
|
+
<div class="template-preview-content">${o.html}</div>
|
|
150
187
|
</div>
|
|
151
188
|
` : ""}
|
|
152
189
|
|
|
153
190
|
<!-- Insert Mode Toggle -->
|
|
154
191
|
<div class="rte-insert-mode">
|
|
155
192
|
<label>
|
|
156
|
-
<input type="radio" name="insertMode" value="insert" ${
|
|
193
|
+
<input type="radio" name="insertMode" value="insert" ${v === "insert" ? "checked" : ""} />
|
|
157
194
|
Insert at cursor
|
|
158
195
|
</label>
|
|
159
196
|
<label>
|
|
160
|
-
<input type="radio" name="insertMode" value="replace" ${
|
|
197
|
+
<input type="radio" name="insertMode" value="replace" ${v === "replace" ? "checked" : ""} />
|
|
161
198
|
Replace document
|
|
162
199
|
</label>
|
|
163
200
|
</div>
|
|
@@ -165,15 +202,15 @@ function b() {
|
|
|
165
202
|
|
|
166
203
|
<div class="rte-dialog-footer">
|
|
167
204
|
<button class="rte-button-secondary rte-cancel-btn">Cancel</button>
|
|
168
|
-
<button class="rte-button-primary rte-insert-btn" ${
|
|
169
|
-
${
|
|
205
|
+
<button class="rte-button-primary rte-insert-btn" ${o ? "" : "disabled"}>
|
|
206
|
+
${v === "insert" ? "Insert" : "Replace"}
|
|
170
207
|
</button>
|
|
171
208
|
</div>
|
|
172
|
-
`,
|
|
209
|
+
`, W();
|
|
173
210
|
}
|
|
174
|
-
function
|
|
175
|
-
if (!
|
|
176
|
-
|
|
211
|
+
function O() {
|
|
212
|
+
if (!n) return;
|
|
213
|
+
n.innerHTML = `
|
|
177
214
|
<div class="rte-dialog-header">
|
|
178
215
|
<h2>Replace Document?</h2>
|
|
179
216
|
</div>
|
|
@@ -185,119 +222,100 @@ function I() {
|
|
|
185
222
|
<button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
|
|
186
223
|
</div>
|
|
187
224
|
`;
|
|
188
|
-
const t =
|
|
189
|
-
t?.addEventListener("click", () =>
|
|
225
|
+
const t = n.querySelector(".rte-cancel-warning-btn"), e = n.querySelector(".rte-confirm-replace-btn");
|
|
226
|
+
t?.addEventListener("click", () => y()), e?.addEventListener("click", () => Z());
|
|
190
227
|
}
|
|
191
|
-
function
|
|
192
|
-
const t =
|
|
193
|
-
return
|
|
228
|
+
function A() {
|
|
229
|
+
const t = H();
|
|
230
|
+
return g.trim() ? B(g) : m ? t.filter((e) => e.category === m) : t;
|
|
194
231
|
}
|
|
195
|
-
function
|
|
196
|
-
if (!
|
|
197
|
-
|
|
198
|
-
const l =
|
|
232
|
+
function W() {
|
|
233
|
+
if (!n) return;
|
|
234
|
+
n.querySelector(".rte-dialog-close")?.addEventListener("click", () => c()), n.querySelector(".rte-cancel-btn")?.addEventListener("click", () => c()), n.querySelector(".rte-insert-btn")?.addEventListener("click", () => k());
|
|
235
|
+
const l = n.querySelector(".rte-template-search");
|
|
199
236
|
l?.addEventListener("input", (a) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
a.key === "Enter" && n ? x() : a.key === "Escape" && c();
|
|
203
|
-
}), o.querySelectorAll(".rte-tab").forEach((a) => {
|
|
204
|
-
a.addEventListener("click", () => {
|
|
205
|
-
const i = a.getAttribute("data-category");
|
|
206
|
-
i && (p = i, m = "", T());
|
|
207
|
-
});
|
|
208
|
-
}), o.querySelectorAll(".rte-template-item").forEach((a) => {
|
|
209
|
-
a.addEventListener("click", () => {
|
|
210
|
-
const i = a.getAttribute("data-template-id");
|
|
211
|
-
if (i) {
|
|
212
|
-
const u = y().find((v) => v.id === i);
|
|
213
|
-
u && (n = u, b());
|
|
214
|
-
}
|
|
215
|
-
}), a.addEventListener("dblclick", () => {
|
|
216
|
-
const i = a.getAttribute("data-template-id");
|
|
217
|
-
if (i) {
|
|
218
|
-
const u = y().find((v) => v.id === i);
|
|
219
|
-
u && (n = u, x());
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}), o.querySelectorAll('input[name="insertMode"]').forEach((a) => {
|
|
223
|
-
a.addEventListener("change", (i) => {
|
|
224
|
-
g = i.target.value, b();
|
|
237
|
+
s !== null && cancelAnimationFrame(s), g = a.target.value, s = requestAnimationFrame(() => {
|
|
238
|
+
s = null, S();
|
|
225
239
|
});
|
|
240
|
+
}), l?.addEventListener("keydown", (a) => {
|
|
241
|
+
a.key === "Enter" && o ? k() : a.key === "Escape" && c();
|
|
242
|
+
}), n.querySelector(".rte-tabs")?.addEventListener("click", (a) => {
|
|
243
|
+
const f = a.target.closest(".rte-tab");
|
|
244
|
+
if (!f) return;
|
|
245
|
+
const h = f.getAttribute("data-category");
|
|
246
|
+
h && (m = h, g = "", s !== null && (cancelAnimationFrame(s), s = null), S());
|
|
247
|
+
});
|
|
248
|
+
const w = n.querySelector(".rte-template-list"), p = (a) => {
|
|
249
|
+
const f = a.target.closest(".rte-template-item");
|
|
250
|
+
if (!f) return null;
|
|
251
|
+
const h = f.getAttribute("data-template-id");
|
|
252
|
+
return h && H().find((V) => V.id === h) || null;
|
|
253
|
+
};
|
|
254
|
+
w?.addEventListener("click", (a) => {
|
|
255
|
+
const i = p(a);
|
|
256
|
+
i && (o = i, y());
|
|
257
|
+
}), w?.addEventListener("dblclick", (a) => {
|
|
258
|
+
const i = p(a);
|
|
259
|
+
i && (o = i, k());
|
|
260
|
+
}), n.querySelector(".rte-insert-mode")?.addEventListener("change", (a) => {
|
|
261
|
+
const i = a.target;
|
|
262
|
+
!i || i.name !== "insertMode" || (v = i.value, y());
|
|
226
263
|
});
|
|
227
264
|
}
|
|
228
|
-
function
|
|
229
|
-
const t =
|
|
230
|
-
t.length > 0 ? (!
|
|
265
|
+
function S() {
|
|
266
|
+
const t = A();
|
|
267
|
+
t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, y();
|
|
231
268
|
}
|
|
232
|
-
function
|
|
233
|
-
if (
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let e = s.startContainer;
|
|
238
|
-
for (; e && e !== document.body; ) {
|
|
239
|
-
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
240
|
-
const r = e;
|
|
241
|
-
if (r.getAttribute("contenteditable") === "true") {
|
|
242
|
-
t = r;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
e = e.parentNode;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (t || (t = document.querySelector('[contenteditable="true"]')), t?.innerHTML?.trim()) {
|
|
250
|
-
I();
|
|
269
|
+
function k() {
|
|
270
|
+
if (o)
|
|
271
|
+
if (v === "replace") {
|
|
272
|
+
if (C()?.innerHTML?.trim()) {
|
|
273
|
+
O();
|
|
251
274
|
return;
|
|
252
275
|
}
|
|
253
|
-
|
|
276
|
+
I(o), c();
|
|
254
277
|
} else
|
|
255
|
-
|
|
278
|
+
G(o), c();
|
|
256
279
|
}
|
|
257
|
-
function
|
|
258
|
-
|
|
280
|
+
function Z() {
|
|
281
|
+
o && (I(o), c());
|
|
259
282
|
}
|
|
260
|
-
function
|
|
261
|
-
if (s) {
|
|
262
|
-
const f = window.getSelection();
|
|
263
|
-
f && (f.removeAllRanges(), f.addRange(s));
|
|
264
|
-
}
|
|
283
|
+
function G(t) {
|
|
265
284
|
const e = window.getSelection();
|
|
266
|
-
if (!e
|
|
267
|
-
const r =
|
|
268
|
-
r
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
if (!e) return;
|
|
286
|
+
const r = C();
|
|
287
|
+
if (!r) return;
|
|
288
|
+
if (u)
|
|
289
|
+
e.removeAllRanges(), e.addRange(u);
|
|
290
|
+
else {
|
|
291
|
+
const T = document.createRange();
|
|
292
|
+
T.selectNodeContents(r), T.collapse(!1), e.removeAllRanges(), e.addRange(T);
|
|
293
|
+
}
|
|
294
|
+
if (e.rangeCount === 0) return;
|
|
295
|
+
const l = e.getRangeAt(0), R = r?.innerHTML ?? "", w = document.createRange().createContextualFragment(N(t.html));
|
|
296
|
+
l.deleteContents(), l.insertNode(w);
|
|
297
|
+
const p = document.createRange();
|
|
298
|
+
p.setStartAfter(l.endContainer), p.collapse(!0), e.removeAllRanges(), e.addRange(p), r && (M(r, R), r.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
271
299
|
}
|
|
272
|
-
function
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (r.nodeType === Node.ELEMENT_NODE) {
|
|
278
|
-
const l = r;
|
|
279
|
-
if (l.getAttribute("contenteditable") === "true") {
|
|
280
|
-
e = l;
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
r = r.parentNode;
|
|
285
|
-
}
|
|
300
|
+
function I(t) {
|
|
301
|
+
const e = C();
|
|
302
|
+
if (e) {
|
|
303
|
+
const r = e.innerHTML;
|
|
304
|
+
e.innerHTML = N(t.html), M(e, r), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
286
305
|
}
|
|
287
|
-
e || (e = document.querySelector('[contenteditable="true"]')), e && (e.innerHTML = L(t.html), e.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
288
306
|
}
|
|
289
307
|
function c() {
|
|
290
|
-
d && (d.remove(), d = null),
|
|
308
|
+
$(), s !== null && (cancelAnimationFrame(s), s = null), d && (d.remove(), d = null), n = null, u = null, g = "", E = null;
|
|
291
309
|
}
|
|
292
|
-
function
|
|
310
|
+
function K(t) {
|
|
293
311
|
const e = window.getSelection();
|
|
294
|
-
e && e.rangeCount > 0 ?
|
|
295
|
-
const r =
|
|
296
|
-
r.length > 0 && !
|
|
297
|
-
const l = t?.contentElement instanceof HTMLElement ? t.contentElement :
|
|
298
|
-
|
|
312
|
+
e && e.rangeCount > 0 ? u = e.getRangeAt(0).cloneRange() : u = null;
|
|
313
|
+
const r = A();
|
|
314
|
+
r.length > 0 && !o && (o = r[0]);
|
|
315
|
+
const l = t?.contentElement instanceof HTMLElement ? t.contentElement : L();
|
|
316
|
+
E = l || null, F(l);
|
|
299
317
|
}
|
|
300
|
-
function
|
|
318
|
+
function Y() {
|
|
301
319
|
if (typeof document > "u") return;
|
|
302
320
|
const t = "template-plugin-dialog-styles";
|
|
303
321
|
if (document.getElementById(t)) return;
|
|
@@ -541,7 +559,7 @@ function z() {
|
|
|
541
559
|
}
|
|
542
560
|
`, document.head.appendChild(e);
|
|
543
561
|
}
|
|
544
|
-
const
|
|
562
|
+
const te = () => ({
|
|
545
563
|
name: "template",
|
|
546
564
|
toolbar: [
|
|
547
565
|
{
|
|
@@ -551,10 +569,18 @@ const P = () => ({
|
|
|
551
569
|
}
|
|
552
570
|
],
|
|
553
571
|
commands: {
|
|
554
|
-
insertTemplate: (t, e) => (
|
|
572
|
+
insertTemplate: (t, e) => (K(e), !0)
|
|
555
573
|
},
|
|
556
574
|
keymap: {}
|
|
557
575
|
});
|
|
558
576
|
export {
|
|
559
|
-
|
|
577
|
+
z as PREDEFINED_TEMPLATES,
|
|
578
|
+
te as TemplatePlugin,
|
|
579
|
+
X as addCustomTemplate,
|
|
580
|
+
H as getAllTemplates,
|
|
581
|
+
D as getTemplateCategories,
|
|
582
|
+
U as getTemplatesByCategory,
|
|
583
|
+
N as sanitizeTemplate,
|
|
584
|
+
B as searchTemplates,
|
|
585
|
+
ee as validateTemplate
|
|
560
586
|
};
|
package/dist/text-color.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 k=require("./anchoredPopover-BzqGPOAE.js");let n=null,d=null,x=null,i="#000000";const u='[data-theme="dark"], .dark, .editora-theme-dark',w=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function y(){const e=window.getSelection();if(e&&e.rangeCount>0){const c=e.getRangeAt(0).startContainer,l=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;if(l){const r=l.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(r)return r}}const o=document.activeElement;return o?o.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function C(e){const o=window.__editoraLastCommand,t=window.__editoraLastCommandButton;if(o===e&&t&&t.isConnected){const a=window.getComputedStyle(t),s=t.getBoundingClientRect();if(a.display!=="none"&&a.visibility!=="hidden"&&a.pointerEvents!=="none"&&!(s.width===0&&s.height===0))return t}const c=a=>{for(const s of a){const b=window.getComputedStyle(s),h=s.getBoundingClientRect();if(!(b.display==="none"||b.visibility==="hidden"||b.pointerEvents==="none")&&!(h.width===0&&h.height===0))return s}return null},l=y();if(l){const a=Array.from(l.querySelectorAll(`[data-command="${e}"]`)),s=c(a);if(s)return s}const r=Array.from(document.querySelectorAll(`[data-command="${e}"]`));return c(r)}function E(e){if(e?.closest(u))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const c=o.getRangeAt(0).startContainer;if((c.nodeType===Node.ELEMENT_NODE?c:c.parentElement)?.closest(u))return!0}return document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function f(e){return k.applyColorToSelection({color:e,className:"rte-text-color",styleProperty:"color",commands:["foreColor"],savedRange:x,getActiveEditorRoot:y,warnMessage:"[TextColor] Could not apply color for current selection"})}function S(){const e=window.getSelection();if(!e||e.rangeCount===0)return"#000000";let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const c=t,l=c.style.color||window.getComputedStyle(c).color;if(l&&l!=="rgb(0, 0, 0)")return T(l)}t=t.parentNode}return"#000000"}function T(e){if(e.startsWith("#"))return e;const o=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!o)return"#000000";const t=parseInt(o[1]),c=parseInt(o[2]),l=parseInt(o[3]);return"#"+[t,c,l].map(r=>{const a=r.toString(16);return a.length===1?"0"+a:a}).join("")}function A(e){const o=window.getSelection();o&&o.rangeCount>0&&(x=o.getRangeAt(0).cloneRange()),i=S(),n=document.createElement("div"),n.className="rte-inline-color-picker",E(e)&&n.classList.add("rte-theme-dark"),n.addEventListener("click",t=>t.stopPropagation()),n.innerHTML=`
|
|
2
2
|
<div class="rte-color-picker-header">
|
|
3
3
|
<span class="rte-color-picker-title">Text Color</span>
|
|
4
4
|
<button class="rte-color-picker-close" aria-label="Close">×</button>
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
<div class="rte-color-section">
|
|
16
16
|
<label class="rte-color-section-label">Colors</label>
|
|
17
17
|
<div class="rte-color-palette">
|
|
18
|
-
${
|
|
18
|
+
${w.map(t=>`
|
|
19
19
|
<button
|
|
20
|
-
class="rte-color-swatch ${i===
|
|
21
|
-
style="background-color: ${
|
|
22
|
-
data-color="${
|
|
23
|
-
title="${
|
|
24
|
-
aria-label="${
|
|
20
|
+
class="rte-color-swatch ${i===t?"selected":""}"
|
|
21
|
+
style="background-color: ${t}; ${t==="#ffffff"?"border: 1px solid #ccc;":""}"
|
|
22
|
+
data-color="${t}"
|
|
23
|
+
title="${t.toUpperCase()}"
|
|
24
|
+
aria-label="${t.toUpperCase()}"
|
|
25
25
|
></button>
|
|
26
26
|
`).join("")}
|
|
27
27
|
</div>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</div>
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
51
|
-
|
|
51
|
+
`,document.body.appendChild(n),d&&(d.destroy(),d=null),d=k.attachAnchoredPopover({popover:n,anchor:e,onClose:p,gap:4,margin:8,zIndex:1e4}),L()}function L(){if(!n)return;n.querySelector(".rte-color-picker-close")?.addEventListener("click",()=>p()),n.querySelectorAll(".rte-color-swatch").forEach(l=>{l.addEventListener("click",()=>{const r=l.getAttribute("data-color");r&&(i=r,f(r),p())})});const t=n.querySelector(".rte-color-input-native");t?.addEventListener("change",l=>{const r=l.target.value;i=r,f(r),p()});const c=n.querySelector(".rte-color-input-text");c?.addEventListener("change",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,f(r),p())}),t?.addEventListener("input",l=>{const r=l.target.value;i=r,m(r),v(r),$(r)}),c?.addEventListener("input",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,m(r),v(r),P(r))})}function m(e){if(!n)return;const o=n.querySelector(".rte-color-preview-box"),t=n.querySelector(".rte-color-preview-label");o&&(o.style.backgroundColor=e,o.style.border=e==="#ffffff"?"1px solid #ccc":"none"),t&&(t.textContent=e.toUpperCase())}function v(e){if(!n)return;n.querySelectorAll(".rte-color-swatch").forEach(t=>{t.getAttribute("data-color")===e?t.classList.add("selected"):t.classList.remove("selected")})}function P(e){if(!n)return;const o=n.querySelector(".rte-color-input-native");o&&(o.value=e)}function $(e){if(!n)return;const o=n.querySelector(".rte-color-input-text");o&&(o.value=e)}function p(){d&&(d.destroy(),d=null),n&&(n.remove(),n=null),x=null}function _(){if(g(),n)return p(),!0;const e=C("openTextColorPicker");return e?(A(e),!0):!1}function g(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,!document.getElementById("text-color-plugin-styles"))){const e=document.createElement("style");e.id="text-color-plugin-styles",e.textContent=`
|
|
52
52
|
.rte-inline-color-picker {
|
|
53
53
|
background: white;
|
|
54
54
|
border-radius: 8px;
|
|
@@ -297,4 +297,4 @@
|
|
|
297
297
|
.rte-inline-color-picker.rte-theme-dark .rte-color-input-text:focus {
|
|
298
298
|
border-color: #58a6ff;
|
|
299
299
|
}
|
|
300
|
-
`,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):setTimeout(g,100);const
|
|
300
|
+
`,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):setTimeout(g,100);const M=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:e=>{const t=(e.getAttribute("style")||"").match(/color:\s*([^;]+)/);return t?{color:t[1]}:null}},{tag:"font[color]",getAttrs:e=>{const o=e.getAttribute("color");return o?{color:o}:null}}],toDOM:e=>["span",{style:`color: ${e.attrs?.color||"#000000"}`,class:"rte-text-color"},0]}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>_(),setTextColor:e=>e?f(e):!1},keymap:{}});exports.TextColorPlugin=M;
|