@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/text-color.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
import { a as y, b as w } from "./anchoredPopover-Dts0IrgU.mjs";
|
|
2
|
+
let n = null, d = null, g = null, i = "#000000";
|
|
3
|
+
const u = '[data-theme="dark"], .dark, .editora-theme-dark', C = [
|
|
4
4
|
"#000000",
|
|
5
5
|
"#ffffff",
|
|
6
6
|
"#808080",
|
|
@@ -14,79 +14,95 @@ const s = '[data-theme="dark"], .dark, .editora-theme-dark', k = [
|
|
|
14
14
|
"#800080",
|
|
15
15
|
"#ffc0cb"
|
|
16
16
|
];
|
|
17
|
-
function
|
|
17
|
+
function v() {
|
|
18
18
|
const e = window.getSelection();
|
|
19
19
|
if (e && e.rangeCount > 0) {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
20
|
+
const c = e.getRangeAt(0).startContainer, l = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
|
|
21
|
+
if (l) {
|
|
22
|
+
const r = l.closest(
|
|
23
23
|
'[data-editora-editor="true"], .rte-editor, .editora-editor'
|
|
24
24
|
);
|
|
25
|
-
if (
|
|
25
|
+
if (r) return r;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
return
|
|
28
|
+
const o = document.activeElement;
|
|
29
|
+
return o ? o.closest(
|
|
30
30
|
'[data-editora-editor="true"], .rte-editor, .editora-editor'
|
|
31
31
|
) : null;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const t =
|
|
35
|
-
if (t) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
function E(e) {
|
|
34
|
+
const o = window.__editoraLastCommand, t = window.__editoraLastCommandButton;
|
|
35
|
+
if (o === e && t && t.isConnected) {
|
|
36
|
+
const a = window.getComputedStyle(t), s = t.getBoundingClientRect();
|
|
37
|
+
if (a.display !== "none" && a.visibility !== "hidden" && a.pointerEvents !== "none" && !(s.width === 0 && s.height === 0))
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
const c = (a) => {
|
|
41
|
+
for (const s of a) {
|
|
42
|
+
const b = window.getComputedStyle(s), h = s.getBoundingClientRect();
|
|
43
|
+
if (!(b.display === "none" || b.visibility === "hidden" || b.pointerEvents === "none") && !(h.width === 0 && h.height === 0))
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}, l = v();
|
|
48
|
+
if (l) {
|
|
49
|
+
const a = Array.from(
|
|
50
|
+
l.querySelectorAll(`[data-command="${e}"]`)
|
|
51
|
+
), s = c(a);
|
|
52
|
+
if (s) return s;
|
|
40
53
|
}
|
|
41
|
-
|
|
54
|
+
const r = Array.from(
|
|
55
|
+
document.querySelectorAll(`[data-command="${e}"]`)
|
|
56
|
+
);
|
|
57
|
+
return c(r);
|
|
42
58
|
}
|
|
43
|
-
function
|
|
44
|
-
if (e?.closest(
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
if ((
|
|
59
|
+
function S(e) {
|
|
60
|
+
if (e?.closest(u)) return !0;
|
|
61
|
+
const o = window.getSelection();
|
|
62
|
+
if (o && o.rangeCount > 0) {
|
|
63
|
+
const c = o.getRangeAt(0).startContainer;
|
|
64
|
+
if ((c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement)?.closest(u)) return !0;
|
|
49
65
|
}
|
|
50
|
-
return document.activeElement?.closest(
|
|
66
|
+
return document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
|
|
51
67
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
68
|
+
function f(e) {
|
|
69
|
+
return y({
|
|
54
70
|
color: e,
|
|
55
71
|
className: "rte-text-color",
|
|
56
72
|
styleProperty: "color",
|
|
57
73
|
commands: ["foreColor"],
|
|
58
|
-
savedRange:
|
|
59
|
-
getActiveEditorRoot:
|
|
74
|
+
savedRange: g,
|
|
75
|
+
getActiveEditorRoot: v,
|
|
60
76
|
warnMessage: "[TextColor] Could not apply color for current selection"
|
|
61
77
|
});
|
|
62
78
|
}
|
|
63
|
-
function
|
|
79
|
+
function T() {
|
|
64
80
|
const e = window.getSelection();
|
|
65
81
|
if (!e || e.rangeCount === 0) return "#000000";
|
|
66
|
-
let
|
|
67
|
-
for (;
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
82
|
+
let t = e.getRangeAt(0).startContainer;
|
|
83
|
+
for (; t && t !== document.body; ) {
|
|
84
|
+
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
85
|
+
const c = t, l = c.style.color || window.getComputedStyle(c).color;
|
|
86
|
+
if (l && l !== "rgb(0, 0, 0)")
|
|
87
|
+
return A(l);
|
|
72
88
|
}
|
|
73
|
-
|
|
89
|
+
t = t.parentNode;
|
|
74
90
|
}
|
|
75
91
|
return "#000000";
|
|
76
92
|
}
|
|
77
|
-
function
|
|
93
|
+
function A(e) {
|
|
78
94
|
if (e.startsWith("#")) return e;
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
82
|
-
return "#" + [
|
|
83
|
-
const
|
|
84
|
-
return
|
|
95
|
+
const o = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
96
|
+
if (!o) return "#000000";
|
|
97
|
+
const t = parseInt(o[1]), c = parseInt(o[2]), l = parseInt(o[3]);
|
|
98
|
+
return "#" + [t, c, l].map((r) => {
|
|
99
|
+
const a = r.toString(16);
|
|
100
|
+
return a.length === 1 ? "0" + a : a;
|
|
85
101
|
}).join("");
|
|
86
102
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
|
|
103
|
+
function L(e) {
|
|
104
|
+
const o = window.getSelection();
|
|
105
|
+
o && o.rangeCount > 0 && (g = o.getRangeAt(0).cloneRange()), i = T(), n = document.createElement("div"), n.className = "rte-inline-color-picker", S(e) && n.classList.add("rte-theme-dark"), n.addEventListener("click", (t) => t.stopPropagation()), n.innerHTML = `
|
|
90
106
|
<div class="rte-color-picker-header">
|
|
91
107
|
<span class="rte-color-picker-title">Text Color</span>
|
|
92
108
|
<button class="rte-color-picker-close" aria-label="Close">×</button>
|
|
@@ -103,13 +119,13 @@ function E(e) {
|
|
|
103
119
|
<div class="rte-color-section">
|
|
104
120
|
<label class="rte-color-section-label">Colors</label>
|
|
105
121
|
<div class="rte-color-palette">
|
|
106
|
-
${
|
|
122
|
+
${C.map((t) => `
|
|
107
123
|
<button
|
|
108
|
-
class="rte-color-swatch ${i ===
|
|
109
|
-
style="background-color: ${
|
|
110
|
-
data-color="${
|
|
111
|
-
title="${
|
|
112
|
-
aria-label="${
|
|
124
|
+
class="rte-color-swatch ${i === t ? "selected" : ""}"
|
|
125
|
+
style="background-color: ${t}; ${t === "#ffffff" ? "border: 1px solid #ccc;" : ""}"
|
|
126
|
+
data-color="${t}"
|
|
127
|
+
title="${t.toUpperCase()}"
|
|
128
|
+
aria-label="${t.toUpperCase()}"
|
|
113
129
|
></button>
|
|
114
130
|
`).join("")}
|
|
115
131
|
</div>
|
|
@@ -136,72 +152,72 @@ function E(e) {
|
|
|
136
152
|
</div>
|
|
137
153
|
</div>
|
|
138
154
|
</div>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
155
|
+
`, document.body.appendChild(n), d && (d.destroy(), d = null), d = w({
|
|
156
|
+
popover: n,
|
|
157
|
+
anchor: e,
|
|
158
|
+
onClose: p,
|
|
159
|
+
gap: 4,
|
|
160
|
+
margin: 8,
|
|
161
|
+
zIndex: 1e4
|
|
162
|
+
}), P();
|
|
142
163
|
}
|
|
143
|
-
function
|
|
144
|
-
if (!
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
164
|
+
function P() {
|
|
165
|
+
if (!n) return;
|
|
166
|
+
n.querySelector(".rte-color-picker-close")?.addEventListener("click", () => p()), n.querySelectorAll(".rte-color-swatch").forEach((l) => {
|
|
167
|
+
l.addEventListener("click", () => {
|
|
168
|
+
const r = l.getAttribute("data-color");
|
|
169
|
+
r && (i = r, f(r), p());
|
|
149
170
|
});
|
|
150
171
|
});
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
i =
|
|
172
|
+
const t = n.querySelector(".rte-color-input-native");
|
|
173
|
+
t?.addEventListener("change", (l) => {
|
|
174
|
+
const r = l.target.value;
|
|
175
|
+
i = r, f(r), p();
|
|
155
176
|
});
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
160
|
-
}),
|
|
161
|
-
const
|
|
162
|
-
i =
|
|
163
|
-
}),
|
|
164
|
-
const
|
|
165
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
177
|
+
const c = n.querySelector(".rte-color-input-text");
|
|
178
|
+
c?.addEventListener("change", (l) => {
|
|
179
|
+
const r = l.target.value;
|
|
180
|
+
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, f(r), p());
|
|
181
|
+
}), t?.addEventListener("input", (l) => {
|
|
182
|
+
const r = l.target.value;
|
|
183
|
+
i = r, m(r), k(r), _(r);
|
|
184
|
+
}), c?.addEventListener("input", (l) => {
|
|
185
|
+
const r = l.target.value;
|
|
186
|
+
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, m(r), k(r), $(r));
|
|
166
187
|
});
|
|
167
188
|
}
|
|
168
|
-
function
|
|
169
|
-
if (!
|
|
170
|
-
const
|
|
171
|
-
|
|
189
|
+
function m(e) {
|
|
190
|
+
if (!n) return;
|
|
191
|
+
const o = n.querySelector(".rte-color-preview-box"), t = n.querySelector(".rte-color-preview-label");
|
|
192
|
+
o && (o.style.backgroundColor = e, o.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), t && (t.textContent = e.toUpperCase());
|
|
172
193
|
}
|
|
173
|
-
function
|
|
174
|
-
if (!
|
|
175
|
-
|
|
176
|
-
|
|
194
|
+
function k(e) {
|
|
195
|
+
if (!n) return;
|
|
196
|
+
n.querySelectorAll(".rte-color-swatch").forEach((t) => {
|
|
197
|
+
t.getAttribute("data-color") === e ? t.classList.add("selected") : t.classList.remove("selected");
|
|
177
198
|
});
|
|
178
199
|
}
|
|
179
|
-
function
|
|
180
|
-
if (!
|
|
181
|
-
const
|
|
182
|
-
|
|
200
|
+
function $(e) {
|
|
201
|
+
if (!n) return;
|
|
202
|
+
const o = n.querySelector(".rte-color-input-native");
|
|
203
|
+
o && (o.value = e);
|
|
183
204
|
}
|
|
184
|
-
function
|
|
185
|
-
if (!
|
|
186
|
-
const
|
|
187
|
-
|
|
205
|
+
function _(e) {
|
|
206
|
+
if (!n) return;
|
|
207
|
+
const o = n.querySelector(".rte-color-input-text");
|
|
208
|
+
o && (o.value = e);
|
|
188
209
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
210
|
+
function p() {
|
|
211
|
+
d && (d.destroy(), d = null), n && (n.remove(), n = null), g = null;
|
|
191
212
|
}
|
|
192
|
-
function
|
|
193
|
-
if (
|
|
194
|
-
return
|
|
195
|
-
const e =
|
|
196
|
-
return e ? (
|
|
213
|
+
function R() {
|
|
214
|
+
if (x(), n)
|
|
215
|
+
return p(), !0;
|
|
216
|
+
const e = E("openTextColorPicker");
|
|
217
|
+
return e ? (L(e), !0) : !1;
|
|
197
218
|
}
|
|
198
|
-
function
|
|
199
|
-
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, document.
|
|
200
|
-
if (o && p) {
|
|
201
|
-
const t = e.target;
|
|
202
|
-
!o.contains(t) && !p.contains(t) && a();
|
|
203
|
-
}
|
|
204
|
-
}), !document.getElementById("text-color-plugin-styles"))) {
|
|
219
|
+
function x() {
|
|
220
|
+
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, !document.getElementById("text-color-plugin-styles"))) {
|
|
205
221
|
const e = document.createElement("style");
|
|
206
222
|
e.id = "text-color-plugin-styles", e.textContent = `
|
|
207
223
|
.rte-inline-color-picker {
|
|
@@ -455,8 +471,8 @@ function g() {
|
|
|
455
471
|
`, document.head.appendChild(e);
|
|
456
472
|
}
|
|
457
473
|
}
|
|
458
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
459
|
-
const
|
|
474
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", x) : setTimeout(x, 100);
|
|
475
|
+
const N = () => ({
|
|
460
476
|
name: "textColor",
|
|
461
477
|
marks: {
|
|
462
478
|
textColor: {
|
|
@@ -467,15 +483,15 @@ const A = () => ({
|
|
|
467
483
|
{
|
|
468
484
|
tag: "span[style*=color]",
|
|
469
485
|
getAttrs: (e) => {
|
|
470
|
-
const
|
|
471
|
-
return
|
|
486
|
+
const t = (e.getAttribute("style") || "").match(/color:\s*([^;]+)/);
|
|
487
|
+
return t ? { color: t[1] } : null;
|
|
472
488
|
}
|
|
473
489
|
},
|
|
474
490
|
{
|
|
475
491
|
tag: "font[color]",
|
|
476
492
|
getAttrs: (e) => {
|
|
477
|
-
const
|
|
478
|
-
return
|
|
493
|
+
const o = e.getAttribute("color");
|
|
494
|
+
return o ? { color: o } : null;
|
|
479
495
|
}
|
|
480
496
|
}
|
|
481
497
|
],
|
|
@@ -497,11 +513,11 @@ const A = () => ({
|
|
|
497
513
|
}
|
|
498
514
|
],
|
|
499
515
|
commands: {
|
|
500
|
-
openTextColorPicker: () =>
|
|
501
|
-
setTextColor: (e) => e ?
|
|
516
|
+
openTextColorPicker: () => R(),
|
|
517
|
+
setTextColor: (e) => e ? f(e) : !1
|
|
502
518
|
},
|
|
503
519
|
keymap: {}
|
|
504
520
|
});
|
|
505
521
|
export {
|
|
506
|
-
|
|
522
|
+
N as TextColorPlugin
|
|
507
523
|
};
|
package/index.d.ts
CHANGED
|
@@ -8,6 +8,48 @@ export interface ApiConfig {
|
|
|
8
8
|
export type MediaManagerConfig = Record<string, unknown>;
|
|
9
9
|
export type DocumentManagerConfig = Record<string, unknown>;
|
|
10
10
|
|
|
11
|
+
export interface MergeTagItem {
|
|
12
|
+
key?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
preview?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MergeTagCategory {
|
|
21
|
+
id?: string;
|
|
22
|
+
name: string;
|
|
23
|
+
tags: MergeTagItem[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface MergeTagDialogOptions {
|
|
27
|
+
title?: string;
|
|
28
|
+
searchPlaceholder?: string;
|
|
29
|
+
emptyStateText?: string;
|
|
30
|
+
cancelText?: string;
|
|
31
|
+
insertText?: string;
|
|
32
|
+
showPreview?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MergeTagPluginOptions {
|
|
36
|
+
tags?: MergeTagItem[];
|
|
37
|
+
categories?: MergeTagCategory[];
|
|
38
|
+
defaultCategory?: string;
|
|
39
|
+
dialog?: MergeTagDialogOptions;
|
|
40
|
+
tokenTemplate?: string | ((tag: MergeTagItem & { key: string; category: string }) => string);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface Template {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
category: string;
|
|
47
|
+
html: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
preview?: string;
|
|
50
|
+
tags?: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
11
53
|
export function HeadingPlugin(): Plugin;
|
|
12
54
|
export function BoldPlugin(): Plugin;
|
|
13
55
|
export function ItalicPlugin(): Plugin;
|
|
@@ -50,8 +92,16 @@ export function PrintPlugin(): Plugin;
|
|
|
50
92
|
export function PageBreakPlugin(): Plugin;
|
|
51
93
|
export function FootnotePlugin(): Plugin;
|
|
52
94
|
export function CodeSamplePlugin(): Plugin;
|
|
53
|
-
export function MergeTagPlugin(): Plugin;
|
|
95
|
+
export function MergeTagPlugin(options?: MergeTagPluginOptions): Plugin;
|
|
54
96
|
export function TemplatePlugin(): Plugin;
|
|
97
|
+
export const PREDEFINED_TEMPLATES: Template[];
|
|
98
|
+
export function addCustomTemplate(template: Template): boolean;
|
|
99
|
+
export function getAllTemplates(): Template[];
|
|
100
|
+
export function getTemplatesByCategory(category: string): Template[];
|
|
101
|
+
export function getTemplateCategories(): string[];
|
|
102
|
+
export function searchTemplates(query: string): Template[];
|
|
103
|
+
export function sanitizeTemplate(html: string): string;
|
|
104
|
+
export function validateTemplate(template: Template): boolean;
|
|
55
105
|
export function CommentsPlugin(): Plugin;
|
|
56
106
|
export function SpellCheckPlugin(): Plugin;
|
|
57
107
|
export function A11yCheckerPlugin(): Plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/plugins",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "40+ Free Premium Plugins for Editora Rich Text Editor. Table editor, code formatting, accessibility, math, media, and more. Free enterprise plugin collection.",
|
|
5
5
|
"author": "Ajay Kumar <ajaykr089@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"main": "dist/index.cjs.js",
|
|
41
41
|
"module": "dist/index.esm.js",
|
|
42
42
|
"types": "index.d.ts",
|
|
43
|
+
"style": "dist/plugins.css",
|
|
43
44
|
"exports": {
|
|
44
45
|
".": {
|
|
45
46
|
"types": "./index.d.ts",
|
|
@@ -298,7 +299,8 @@
|
|
|
298
299
|
"import": "./dist/underline.esm.js",
|
|
299
300
|
"require": "./dist/underline.cjs.js",
|
|
300
301
|
"default": "./dist/underline.esm.js"
|
|
301
|
-
}
|
|
302
|
+
},
|
|
303
|
+
"./styles.css": "./dist/plugins.css"
|
|
302
304
|
},
|
|
303
305
|
"files": [
|
|
304
306
|
"dist",
|
|
@@ -315,14 +317,14 @@
|
|
|
315
317
|
"prepublishOnly": "npm run typecheck:build && npm run build"
|
|
316
318
|
},
|
|
317
319
|
"peerDependencies": {
|
|
318
|
-
"@editora/core": "^1.0.
|
|
320
|
+
"@editora/core": "^1.0.7"
|
|
319
321
|
},
|
|
320
322
|
"dependencies": {
|
|
321
323
|
"katex": "^0.16.27",
|
|
322
324
|
"mathjax": "^3.2.2"
|
|
323
325
|
},
|
|
324
326
|
"devDependencies": {
|
|
325
|
-
"@editora/core": "^1.0.
|
|
327
|
+
"@editora/core": "^1.0.7",
|
|
326
328
|
"@types/katex": "^0.16.8",
|
|
327
329
|
"typescript": "^5.0.0",
|
|
328
330
|
"vite": "^7.3.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const u="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function i(e){return!!e.cloneContents().querySelector(u)}function s(e,t){return(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest('[contenteditable="true"]')||t()?.querySelector('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function c(e,t){const n=s(e,t);n&&n.dispatchEvent(new Event("input",{bubbles:!0}))}function f(e,t){let o=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentElement:e.startContainer;for(;o&&o!==document.body;){if(o.classList.contains(t)){const a=document.createRange();if(a.selectNodeContents(o),a.compareBoundaryPoints(Range.START_TO_START,e)<=0&&a.compareBoundaryPoints(Range.END_TO_END,e)>=0)return o}o=o.parentElement}return null}function m(e){try{if(e.savedRange){const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(e.savedRange.cloneRange()))}const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0);if(n.collapsed)return!1;const o=f(n,e.className);if(o)return e.styleProperty==="backgroundColor"?o.style.backgroundColor=e.color:o.style.color=e.color,c(o,e.getActiveEditorRoot),!0;s(n.commonAncestorContainer,e.getActiveEditorRoot)?.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let l=!1;if(e.commands.forEach(r=>{l||(l=document.execCommand(r,!1,e.color))}),!l&&!i(n)){const r=document.createElement("span");e.styleProperty==="backgroundColor"?r.style.backgroundColor=e.color:r.style.color=e.color,r.className=e.className;const d=n.extractContents();r.appendChild(d),n.insertNode(r),n.setStartAfter(r),n.collapse(!0),t.removeAllRanges(),t.addRange(n),l=!0}return l?(c(n.commonAncestorContainer,e.getActiveEditorRoot),!0):(e.warnMessage&&console.warn(e.warnMessage),!1)}catch(t){return e.warnMessage?console.error(e.warnMessage,t):console.error("[ColorApply] Failed to apply color",t),!1}}exports.applyColorToSelection=m;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const u = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
|
|
2
|
-
function i(e) {
|
|
3
|
-
return !!e.cloneContents().querySelector(u);
|
|
4
|
-
}
|
|
5
|
-
function s(e, t) {
|
|
6
|
-
return (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest('[contenteditable="true"]') || t()?.querySelector('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
|
|
7
|
-
}
|
|
8
|
-
function c(e, t) {
|
|
9
|
-
const n = s(e, t);
|
|
10
|
-
n && n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
11
|
-
}
|
|
12
|
-
function f(e, t) {
|
|
13
|
-
let o = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
|
|
14
|
-
for (; o && o !== document.body; ) {
|
|
15
|
-
if (o.classList.contains(t)) {
|
|
16
|
-
const l = document.createRange();
|
|
17
|
-
if (l.selectNodeContents(o), l.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && l.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
|
|
18
|
-
return o;
|
|
19
|
-
}
|
|
20
|
-
o = o.parentElement;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
function m(e) {
|
|
25
|
-
try {
|
|
26
|
-
if (e.savedRange) {
|
|
27
|
-
const r = window.getSelection();
|
|
28
|
-
r && (r.removeAllRanges(), r.addRange(e.savedRange.cloneRange()));
|
|
29
|
-
}
|
|
30
|
-
const t = window.getSelection();
|
|
31
|
-
if (!t || t.rangeCount === 0 || t.isCollapsed)
|
|
32
|
-
return !1;
|
|
33
|
-
const n = t.getRangeAt(0);
|
|
34
|
-
if (n.collapsed)
|
|
35
|
-
return !1;
|
|
36
|
-
const o = f(n, e.className);
|
|
37
|
-
if (o)
|
|
38
|
-
return e.styleProperty === "backgroundColor" ? o.style.backgroundColor = e.color : o.style.color = e.color, c(o, e.getActiveEditorRoot), !0;
|
|
39
|
-
s(
|
|
40
|
-
n.commonAncestorContainer,
|
|
41
|
-
e.getActiveEditorRoot
|
|
42
|
-
)?.focus({ preventScroll: !0 });
|
|
43
|
-
try {
|
|
44
|
-
document.execCommand("styleWithCSS", !1, "true");
|
|
45
|
-
} catch {
|
|
46
|
-
}
|
|
47
|
-
let a = !1;
|
|
48
|
-
if (e.commands.forEach((r) => {
|
|
49
|
-
a || (a = document.execCommand(r, !1, e.color));
|
|
50
|
-
}), !a && !i(n)) {
|
|
51
|
-
const r = document.createElement("span");
|
|
52
|
-
e.styleProperty === "backgroundColor" ? r.style.backgroundColor = e.color : r.style.color = e.color, r.className = e.className;
|
|
53
|
-
const d = n.extractContents();
|
|
54
|
-
r.appendChild(d), n.insertNode(r), n.setStartAfter(r), n.collapse(!0), t.removeAllRanges(), t.addRange(n), a = !0;
|
|
55
|
-
}
|
|
56
|
-
return a ? (c(n.commonAncestorContainer, e.getActiveEditorRoot), !0) : (e.warnMessage && console.warn(e.warnMessage), !1);
|
|
57
|
-
} catch (t) {
|
|
58
|
-
return e.warnMessage ? console.error(e.warnMessage, t) : console.error("[ColorApply] Failed to apply color", t), !1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
m as a
|
|
63
|
-
};
|