stilo-editor 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +172 -2
- package/dist/characters--8h5uTeF.js +854 -0
- package/dist/content.css +161 -0
- package/dist/core/drop.d.ts +6 -0
- package/dist/core/editor.d.ts +108 -0
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/events.d.ts +19 -0
- package/dist/core/extension-manager.d.ts +57 -0
- package/dist/core/extension.d.ts +43 -0
- package/dist/core/helpers/active.d.ts +33 -0
- package/dist/core/helpers/input-rules.d.ts +21 -0
- package/dist/core/helpers/lists.d.ts +12 -0
- package/dist/core/helpers/marks.d.ts +38 -0
- package/dist/core/helpers/nodes.d.ts +14 -0
- package/dist/core/helpers/parse-rules.d.ts +8 -0
- package/dist/core/html/css.d.ts +91 -0
- package/dist/core/html/parse.d.ts +7 -0
- package/dist/core/html/sanitize.d.ts +49 -0
- package/dist/core/html/serialize.d.ts +31 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/extensions/blockquote/index.d.ts +15 -0
- package/dist/extensions/bold/index.d.ts +17 -0
- package/dist/extensions/bullet-list/index.d.ts +9 -0
- package/dist/extensions/clear-formatting/index.d.ts +12 -0
- package/dist/extensions/code/index.d.ts +15 -0
- package/dist/extensions/default-extensions/index.d.ts +46 -0
- package/dist/extensions/document/index.d.ts +17 -0
- package/dist/extensions/drop-cursor/index.d.ts +15 -0
- package/dist/extensions/gap-cursor/index.d.ts +6 -0
- package/dist/extensions/hard-break/index.d.ts +11 -0
- package/dist/extensions/heading/index.d.ts +24 -0
- package/dist/extensions/highlight/index.d.ts +24 -0
- package/dist/extensions/history/index.d.ts +21 -0
- package/dist/extensions/horizontal-rule/index.d.ts +11 -0
- package/dist/extensions/index.d.ts +27 -0
- package/dist/extensions/italic/index.d.ts +16 -0
- package/dist/extensions/link/index.d.ts +23 -0
- package/dist/extensions/list-item/index.d.ts +16 -0
- package/dist/extensions/move-block/index.d.ts +17 -0
- package/dist/extensions/ordered-list/index.d.ts +12 -0
- package/dist/extensions/paragraph/index.d.ts +14 -0
- package/dist/extensions/placeholder/index.d.ts +13 -0
- package/dist/extensions/strike/index.d.ts +16 -0
- package/dist/extensions/subscript/index.d.ts +16 -0
- package/dist/extensions/superscript/index.d.ts +17 -0
- package/dist/extensions/text/index.d.ts +12 -0
- package/dist/extensions/text-style/index.d.ts +14 -0
- package/dist/extensions/underline/index.d.ts +15 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -0
- package/dist/src-3tAxKI0c.js +1316 -0
- package/dist/style.css +797 -0
- package/dist/ui/components/character-picker.d.ts +22 -0
- package/dist/ui/components/characters.d.ts +10 -0
- package/dist/ui/components/color-button.d.ts +23 -0
- package/dist/ui/components/dropdown.d.ts +25 -0
- package/dist/ui/components/icon.d.ts +3 -0
- package/dist/ui/components/link-bubble.d.ts +19 -0
- package/dist/ui/components/link-popover.d.ts +20 -0
- package/dist/ui/components/popover.d.ts +27 -0
- package/dist/ui/components/shortcut.d.ts +11 -0
- package/dist/ui/i18n/en.d.ts +3 -0
- package/dist/ui/i18n/it.d.ts +3 -0
- package/dist/ui/i18n/types.d.ts +4 -0
- package/dist/ui/index.d.ts +19 -0
- package/dist/ui/toolbar/items.d.ts +12 -0
- package/dist/ui/toolbar/palette.d.ts +6 -0
- package/dist/ui/toolbar/toolbar.d.ts +28 -0
- package/dist/ui/toolbar/types.d.ts +87 -0
- package/dist/ui.css +635 -0
- package/dist/ui.js +1292 -0
- package/package.json +86 -4
|
@@ -0,0 +1,1316 @@
|
|
|
1
|
+
import { closeHistory as e, history as t, redo as n, undo as r } from "prosemirror-history";
|
|
2
|
+
import { EditorState as i, NodeSelection as a, Plugin as o, Selection as s, TextSelection as c } from "prosemirror-state";
|
|
3
|
+
import { Decoration as l, DecorationSet as u, EditorView as d } from "prosemirror-view";
|
|
4
|
+
import { DOMParser as f, DOMSerializer as p, Fragment as ee, Schema as m, Slice as te } from "prosemirror-model";
|
|
5
|
+
import { Mapping as h } from "prosemirror-transform";
|
|
6
|
+
import { baseKeymap as g, lift as _, selectAll as ne, setBlockType as v, wrapIn as y } from "prosemirror-commands";
|
|
7
|
+
import { InputRule as b, inputRules as re, textblockTypeInputRule as ie, undoInputRule as ae, wrappingInputRule as x } from "prosemirror-inputrules";
|
|
8
|
+
import { keymap as S } from "prosemirror-keymap";
|
|
9
|
+
import oe from "dompurify";
|
|
10
|
+
import { liftListItem as se, sinkListItem as ce, splitListItem as le, wrapInList as ue } from "prosemirror-schema-list";
|
|
11
|
+
import { dropCursor as de } from "prosemirror-dropcursor";
|
|
12
|
+
import { gapCursor as fe } from "prosemirror-gapcursor";
|
|
13
|
+
//#region src/core/drop.ts
|
|
14
|
+
function pe(e) {
|
|
15
|
+
if (!(e instanceof c) || e.empty) return null;
|
|
16
|
+
let { $from: t, $to: n } = e;
|
|
17
|
+
return !t.parent.isTextblock || !n.parent.isTextblock || t.parentOffset !== 0 || n.parentOffset !== n.parent.content.size ? null : {
|
|
18
|
+
$from: t,
|
|
19
|
+
$to: n
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function me(e, t) {
|
|
23
|
+
let { state: n } = e, r = pe(n.selection);
|
|
24
|
+
if (!r || r.$from.node(-1) !== r.$to.node(-1)) return !1;
|
|
25
|
+
let i = r.$from.before(), a = r.$to.after(), o = e.posAtCoords({
|
|
26
|
+
left: t.clientX,
|
|
27
|
+
top: t.clientY
|
|
28
|
+
});
|
|
29
|
+
if (!o) return !1;
|
|
30
|
+
if (o.pos >= i && o.pos <= a) return !0;
|
|
31
|
+
if (!n.doc.resolve(o.pos).parent.isTextblock) return !1;
|
|
32
|
+
let s = n.tr.deleteSelection(), l = s.mapping.map(o.pos), u = s.doc.resolve(l), { listItem: d } = n.schema.nodes, f = [];
|
|
33
|
+
n.doc.slice(i, a).content.forEach((e) => {
|
|
34
|
+
f.push(e);
|
|
35
|
+
});
|
|
36
|
+
let p = 1;
|
|
37
|
+
if (u.depth > 2 && u.node(-1).type === d) {
|
|
38
|
+
let e = f.every((e) => d.contentMatch.matchType(e.type));
|
|
39
|
+
p = e ? 2 : 3, e && (f = f.map((e) => d.create(null, e)));
|
|
40
|
+
}
|
|
41
|
+
let m = u.parentOffset === 0, h = u.parentOffset === u.parent.content.size, g = l;
|
|
42
|
+
for (let e = u.depth; p > 0 && (m || h); e--) {
|
|
43
|
+
let t = m ? 0 : u.node(e).childCount - 1;
|
|
44
|
+
if (e < u.depth && u.index(e) !== t) break;
|
|
45
|
+
g = m ? u.before(e) : u.after(e), p--;
|
|
46
|
+
}
|
|
47
|
+
p > 0 && (s.split(g, p), g += p), s.replaceRange(g, g, new te(ee.from(f), 0, 0));
|
|
48
|
+
let _ = g;
|
|
49
|
+
return s.mapping.maps[s.mapping.maps.length - 1]?.forEach((e, t, n, r) => {
|
|
50
|
+
_ = r;
|
|
51
|
+
}), s.setSelection(c.between(s.doc.resolve(g), s.doc.resolve(_))), e.focus(), e.dispatch(s.setMeta("uiEvent", "drop")), !0;
|
|
52
|
+
}
|
|
53
|
+
function he(e, t, n) {
|
|
54
|
+
let r = pe(e.selection);
|
|
55
|
+
if (!r) return null;
|
|
56
|
+
let i = n.map(r.$from.before(), 1), a = n.map(r.$to.after(), -1), o = t.doc.resolve(i), s = o.nodeAfter;
|
|
57
|
+
if (!s?.isTextblock || s.content.size !== 0 || a !== i + s.nodeSize) return null;
|
|
58
|
+
let c = o.depth;
|
|
59
|
+
for (; c > 0 && o.node(c).childCount === 1;) c--;
|
|
60
|
+
return o.node(c).canReplace(o.index(c), o.index(c) + 1) ? c === o.depth ? t.tr.delete(i, a) : t.tr.delete(o.before(c + 1), o.after(c + 1)) : null;
|
|
61
|
+
}
|
|
62
|
+
function ge() {
|
|
63
|
+
return new o({
|
|
64
|
+
props: { handleDrop: (e, t, n, r) => r && me(e, t) },
|
|
65
|
+
appendTransaction(e, t, n) {
|
|
66
|
+
if (!e.some((e) => e.getMeta("uiEvent") === "drop")) return null;
|
|
67
|
+
let r = new h();
|
|
68
|
+
for (let t of e) r.appendMapping(t.mapping);
|
|
69
|
+
return he(t, n, r);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/core/events.ts
|
|
75
|
+
var _e = class {
|
|
76
|
+
handlers = {};
|
|
77
|
+
on(e, t) {
|
|
78
|
+
let n = this.handlers[e];
|
|
79
|
+
n || (n = /* @__PURE__ */ new Set(), this.handlers[e] = n), n.add(t);
|
|
80
|
+
}
|
|
81
|
+
off(e, t) {
|
|
82
|
+
this.handlers[e]?.delete(t);
|
|
83
|
+
}
|
|
84
|
+
emit(e, t) {
|
|
85
|
+
for (let n of [...this.handlers[e] ?? []]) n(t);
|
|
86
|
+
}
|
|
87
|
+
clear() {
|
|
88
|
+
this.handlers = {};
|
|
89
|
+
}
|
|
90
|
+
}, C = class extends Error {
|
|
91
|
+
constructor(e) {
|
|
92
|
+
super(`[stilo] ${e}`), this.name = "StiloError";
|
|
93
|
+
}
|
|
94
|
+
}, w = [
|
|
95
|
+
"link",
|
|
96
|
+
"highlight",
|
|
97
|
+
"textStyle",
|
|
98
|
+
"bold",
|
|
99
|
+
"italic",
|
|
100
|
+
"underline",
|
|
101
|
+
"strike",
|
|
102
|
+
"subscript",
|
|
103
|
+
"superscript",
|
|
104
|
+
"code"
|
|
105
|
+
], ve = [
|
|
106
|
+
"doc",
|
|
107
|
+
"paragraph",
|
|
108
|
+
"text"
|
|
109
|
+
];
|
|
110
|
+
function ye(e) {
|
|
111
|
+
return e.flat().sort((e, t) => t.priority - e.priority);
|
|
112
|
+
}
|
|
113
|
+
function T(e, t, n) {
|
|
114
|
+
if (e) throw new C(`Duplicate ${t} name "${n}".`);
|
|
115
|
+
}
|
|
116
|
+
function E(e) {
|
|
117
|
+
let t = w.indexOf(e);
|
|
118
|
+
return t === -1 ? w.length : t;
|
|
119
|
+
}
|
|
120
|
+
var be = class {
|
|
121
|
+
extensions;
|
|
122
|
+
schema;
|
|
123
|
+
commandFactories = /* @__PURE__ */ new Map();
|
|
124
|
+
constructor(e) {
|
|
125
|
+
this.extensions = ye(e);
|
|
126
|
+
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
127
|
+
for (let e of this.extensions) {
|
|
128
|
+
T(t.has(e.name), "extension", e.name), t.add(e.name);
|
|
129
|
+
for (let [t, r] of Object.entries(e.spec.nodes?.(e.options) ?? {})) T(n.has(t), "node", t), n.set(t, r);
|
|
130
|
+
for (let [t, n] of Object.entries(e.spec.marks?.(e.options) ?? {})) T(r.has(t), "mark", t), r.set(t, n);
|
|
131
|
+
}
|
|
132
|
+
for (let e of ve) if (!n.has(e)) throw new C(`The schema requires a "${e}" node.`);
|
|
133
|
+
let i = [...r].sort(([e], [t]) => E(e) - E(t));
|
|
134
|
+
this.schema = new m({
|
|
135
|
+
nodes: Object.fromEntries(n),
|
|
136
|
+
marks: Object.fromEntries(i),
|
|
137
|
+
topNode: "doc"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
get commands() {
|
|
141
|
+
return this.commandFactories;
|
|
142
|
+
}
|
|
143
|
+
createPlugins(e) {
|
|
144
|
+
let t = [], n = [], r = [];
|
|
145
|
+
for (let i of this.extensions) {
|
|
146
|
+
let { spec: a } = i, o = {
|
|
147
|
+
options: i.options,
|
|
148
|
+
schema: this.schema,
|
|
149
|
+
editor: e
|
|
150
|
+
}, s = Object.entries(a.commands?.(o) ?? {});
|
|
151
|
+
for (let [e, t] of s) T(this.commandFactories.has(e), "command", e), this.commandFactories.set(e, t);
|
|
152
|
+
t.push(...a.inputRules?.(o) ?? []);
|
|
153
|
+
let c = a.keymap?.(o);
|
|
154
|
+
c && n.push(S(c)), r.push(...a.plugins?.(o) ?? []);
|
|
155
|
+
}
|
|
156
|
+
return [
|
|
157
|
+
re({ rules: t }),
|
|
158
|
+
S({ Backspace: ae }),
|
|
159
|
+
...n,
|
|
160
|
+
...r,
|
|
161
|
+
S(g)
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/core/helpers/active.ts
|
|
167
|
+
function D(e, t) {
|
|
168
|
+
return !t || Object.entries(t).every(([t, n]) => e[t] === n);
|
|
169
|
+
}
|
|
170
|
+
function O(e, t, n) {
|
|
171
|
+
let r = (e) => e.some((e) => e.type === t && D(e.attrs, n)), { empty: i, from: a, to: o, $from: s } = e.selection;
|
|
172
|
+
if (i) return r(e.storedMarks ?? s.marks());
|
|
173
|
+
let c = !1, l = !0;
|
|
174
|
+
return e.doc.nodesBetween(a, o, (e) => (e.isText && (c = !0, l &&= r(e.marks)), l)), c && l;
|
|
175
|
+
}
|
|
176
|
+
function k(e, t, n) {
|
|
177
|
+
let { selection: r } = e, i = r instanceof a ? [r.node] : [];
|
|
178
|
+
for (let e = r.$from.depth; e >= 0; e--) i.push(r.$from.node(e));
|
|
179
|
+
return i.some((e) => e.type === t && D(e.attrs, n));
|
|
180
|
+
}
|
|
181
|
+
function xe(e, t) {
|
|
182
|
+
let { empty: n, from: r, to: i, $from: a } = e.selection;
|
|
183
|
+
if (n) return t.isInSet(e.storedMarks ?? a.marks())?.attrs ?? {};
|
|
184
|
+
let o;
|
|
185
|
+
return e.doc.nodesBetween(r, i, (e) => (o ??= t.isInSet(e.marks)?.attrs, !o)), o ?? {};
|
|
186
|
+
}
|
|
187
|
+
function Se(e, t) {
|
|
188
|
+
let { selection: n } = e;
|
|
189
|
+
if (n instanceof a && n.node.type === t) return n.node.attrs;
|
|
190
|
+
for (let e = n.$from.depth; e >= 0; e--) {
|
|
191
|
+
let r = n.$from.node(e);
|
|
192
|
+
if (r.type === t) return r.attrs;
|
|
193
|
+
}
|
|
194
|
+
return {};
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/core/html/css.ts
|
|
198
|
+
var A = [
|
|
199
|
+
"font-family",
|
|
200
|
+
"font-size",
|
|
201
|
+
"color",
|
|
202
|
+
"background-color",
|
|
203
|
+
"text-align"
|
|
204
|
+
], Ce = [
|
|
205
|
+
"font-weight",
|
|
206
|
+
"font-style",
|
|
207
|
+
"text-decoration",
|
|
208
|
+
"text-decoration-line",
|
|
209
|
+
"vertical-align"
|
|
210
|
+
], we = [
|
|
211
|
+
"inherit",
|
|
212
|
+
"initial",
|
|
213
|
+
"unset",
|
|
214
|
+
"revert",
|
|
215
|
+
"currentcolor"
|
|
216
|
+
], j = /url\s*\(|expression\s*\(|javascript:|[<>{}\\]/i;
|
|
217
|
+
function M(e) {
|
|
218
|
+
let t = /* @__PURE__ */ new Map(), n = e.split(";");
|
|
219
|
+
for (let e of n) {
|
|
220
|
+
let n = e.indexOf(":");
|
|
221
|
+
if (n <= 0) continue;
|
|
222
|
+
let r = e.slice(0, n).trim().toLowerCase();
|
|
223
|
+
if (!r) continue;
|
|
224
|
+
let i = e.slice(n + 1).trim();
|
|
225
|
+
i && (i = i.replace(/!important/g, "").trim(), i && t.set(r, i));
|
|
226
|
+
}
|
|
227
|
+
return t;
|
|
228
|
+
}
|
|
229
|
+
function Te(e) {
|
|
230
|
+
let t = e.trim().toLowerCase(), n = t.match(/^#([0-9a-f]{3})$/);
|
|
231
|
+
if (n) {
|
|
232
|
+
let e = n[1];
|
|
233
|
+
return `#${e[0]}${e[0]}${e[1]}${e[1]}${e[2]}${e[2]}`;
|
|
234
|
+
}
|
|
235
|
+
let r = t.match(/^#([0-9a-f]{6})$/);
|
|
236
|
+
if (r) return r[0];
|
|
237
|
+
let i = t.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
|
|
238
|
+
if (i) {
|
|
239
|
+
let e = Number(i[1]), t = Number(i[2]), n = Number(i[3]);
|
|
240
|
+
return e > 255 || t > 255 || n > 255 ? null : `#${e.toString(16).padStart(2, "0")}${t.toString(16).padStart(2, "0")}${n.toString(16).padStart(2, "0")}`;
|
|
241
|
+
}
|
|
242
|
+
let a = t.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d+(?:\.\d+)?%|\d+(?:\.\d+)?)\s*\)$/);
|
|
243
|
+
if (a) {
|
|
244
|
+
let e = Number(a[1]), t = Number(a[2]), n = Number(a[3]);
|
|
245
|
+
if (e > 255 || t > 255 || n > 255) return null;
|
|
246
|
+
let r = a[4], i;
|
|
247
|
+
return i = r.endsWith("%") ? Number(r.slice(0, -1)) / 100 : Number(r), i > 1 ? null : i === 1 ? `#${e.toString(16).padStart(2, "0")}${t.toString(16).padStart(2, "0")}${n.toString(16).padStart(2, "0")}` : `rgba(${e}, ${t}, ${n}, ${String(Math.round(i * 1e3) / 1e3)})`;
|
|
248
|
+
}
|
|
249
|
+
return /^[a-z]{3,20}$/.test(t) ? we.includes(t) ? null : t : null;
|
|
250
|
+
}
|
|
251
|
+
function Ee(e) {
|
|
252
|
+
let t = e.trim().toLowerCase().match(/^(\d+(\.\d+)?)(px|pt|em|rem|%)$/);
|
|
253
|
+
return t ? t[1] + t[3] : null;
|
|
254
|
+
}
|
|
255
|
+
function De(e) {
|
|
256
|
+
let t = e.split(","), n = [];
|
|
257
|
+
for (let e of t) {
|
|
258
|
+
let t = e.trim();
|
|
259
|
+
if (t.length >= 2) {
|
|
260
|
+
let e = t[0], n = t[t.length - 1];
|
|
261
|
+
(e === "\"" || e === "'") && e === n && (t = t.slice(1, -1).trim());
|
|
262
|
+
}
|
|
263
|
+
t = t.replace(/\s+/g, " "), t && (/[<>"';]/.test(t) || (/^[A-Za-z0-9-]+$/.test(t) ? n.push(t) : n.push(`'${t}'`)));
|
|
264
|
+
}
|
|
265
|
+
return n.length === 0 ? null : n.join(", ");
|
|
266
|
+
}
|
|
267
|
+
function Oe(e) {
|
|
268
|
+
switch (e.trim().toLowerCase()) {
|
|
269
|
+
case "left": return "left";
|
|
270
|
+
case "center": return "center";
|
|
271
|
+
case "right": return "right";
|
|
272
|
+
case "justify": return "justify";
|
|
273
|
+
case "start": return "left";
|
|
274
|
+
default: return null;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function N(e, t) {
|
|
278
|
+
if (j.test(t)) return null;
|
|
279
|
+
switch (e) {
|
|
280
|
+
case "color":
|
|
281
|
+
case "background-color": return Te(t);
|
|
282
|
+
case "font-size": return Ee(t);
|
|
283
|
+
case "font-family": return De(t);
|
|
284
|
+
case "text-align": return Oe(t);
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
function P(e) {
|
|
289
|
+
let t = [];
|
|
290
|
+
for (let n of A) {
|
|
291
|
+
let r = e[n];
|
|
292
|
+
if (r == null) continue;
|
|
293
|
+
let i = N(n, r);
|
|
294
|
+
i != null && t.push(`${n}: ${i}`);
|
|
295
|
+
}
|
|
296
|
+
return t.length === 0 ? null : t.join("; ");
|
|
297
|
+
}
|
|
298
|
+
function F(e, t) {
|
|
299
|
+
let n = e.getAttribute("style");
|
|
300
|
+
if (!n) return null;
|
|
301
|
+
let r = M(n).get(t);
|
|
302
|
+
return r == null ? null : N(t, r);
|
|
303
|
+
}
|
|
304
|
+
function I(e) {
|
|
305
|
+
let t = M(e), n = [];
|
|
306
|
+
for (let e of A) {
|
|
307
|
+
let r = t.get(e);
|
|
308
|
+
if (r == null) continue;
|
|
309
|
+
let i = N(e, r);
|
|
310
|
+
i != null && n.push(`${e}: ${i}`);
|
|
311
|
+
}
|
|
312
|
+
for (let e of Ce) {
|
|
313
|
+
let r = t.get(e);
|
|
314
|
+
if (r == null) continue;
|
|
315
|
+
let i = r.toLowerCase();
|
|
316
|
+
/^[a-z0-9 .,%#()-]+$/.test(i) && !j.test(i) && n.push(`${e}: ${i}`);
|
|
317
|
+
}
|
|
318
|
+
return n.length === 0 ? null : n.join("; ");
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/core/html/sanitize.ts
|
|
322
|
+
var ke = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.blockquote.pre.code.ul.ol.li.table.thead.tbody.tfoot.tr.th.td.colgroup.col.img.figure.figcaption.a.strong.b.em.i.u.s.del.strike.sub.sup.mark.font".split("."), Ae = [
|
|
323
|
+
"href",
|
|
324
|
+
"target",
|
|
325
|
+
"rel",
|
|
326
|
+
"title",
|
|
327
|
+
"src",
|
|
328
|
+
"alt",
|
|
329
|
+
"width",
|
|
330
|
+
"height",
|
|
331
|
+
"start",
|
|
332
|
+
"colspan",
|
|
333
|
+
"rowspan",
|
|
334
|
+
"style",
|
|
335
|
+
"class",
|
|
336
|
+
"data-type",
|
|
337
|
+
"data-checked",
|
|
338
|
+
"data-colwidth",
|
|
339
|
+
"face",
|
|
340
|
+
"size",
|
|
341
|
+
"color"
|
|
342
|
+
], je = [
|
|
343
|
+
"http",
|
|
344
|
+
"https",
|
|
345
|
+
"mailto",
|
|
346
|
+
"tel"
|
|
347
|
+
], Me = ["http", "https"], Ne = /^data:image\/(png|jpeg|gif|webp);base64,[a-z0-9+/=\s]+$/i, L = /* @__PURE__ */ new WeakMap();
|
|
348
|
+
function R(e) {
|
|
349
|
+
let t = [...e].filter((e) => !/\s/.test(e) && e.charCodeAt(0) >= 32).join("").match(/^([a-z][a-z0-9+.-]*):/i);
|
|
350
|
+
return t ? t[1].toLowerCase() : null;
|
|
351
|
+
}
|
|
352
|
+
function z(e) {
|
|
353
|
+
let t = R(e);
|
|
354
|
+
return t === null || je.includes(t);
|
|
355
|
+
}
|
|
356
|
+
function Pe(e) {
|
|
357
|
+
let t = e.trim();
|
|
358
|
+
if (!t) return !1;
|
|
359
|
+
if (Ne.test(t)) return !0;
|
|
360
|
+
let n = R(t);
|
|
361
|
+
return n === null || Me.includes(n);
|
|
362
|
+
}
|
|
363
|
+
function B() {
|
|
364
|
+
let e = L.get(window);
|
|
365
|
+
return e || (e = oe(window), e.addHook("uponSanitizeAttribute", (e, t) => {
|
|
366
|
+
let n = Fe(t.attrName, t.attrValue);
|
|
367
|
+
n === null ? t.keepAttr = !1 : t.attrValue = n;
|
|
368
|
+
}), L.set(window, e)), e;
|
|
369
|
+
}
|
|
370
|
+
function Fe(e, t) {
|
|
371
|
+
switch (e) {
|
|
372
|
+
case "style": return I(t);
|
|
373
|
+
case "class": {
|
|
374
|
+
let e = t.split(/\s+/).filter((e) => /^language-[\w-]+$/.test(e));
|
|
375
|
+
return e.length ? e.join(" ") : null;
|
|
376
|
+
}
|
|
377
|
+
case "href": return z(t.trim()) ? t.trim() : null;
|
|
378
|
+
case "src": return Pe(t.trim()) ? t.trim() : null;
|
|
379
|
+
case "target": return t === "_blank" ? "_blank" : null;
|
|
380
|
+
default: return t;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function V() {
|
|
384
|
+
return {
|
|
385
|
+
ALLOWED_TAGS: [...ke],
|
|
386
|
+
ALLOWED_ATTR: [...Ae],
|
|
387
|
+
ALLOW_DATA_ATTR: !1
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function Ie(e) {
|
|
391
|
+
return B().sanitize(e, V());
|
|
392
|
+
}
|
|
393
|
+
function Le(e) {
|
|
394
|
+
return B().sanitize(e, {
|
|
395
|
+
...V(),
|
|
396
|
+
RETURN_DOM: !0
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/core/html/parse.ts
|
|
401
|
+
function H(e, t) {
|
|
402
|
+
return f.fromSchema(e).parse(Le(t));
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/core/html/serialize.ts
|
|
406
|
+
var Re = ["li"];
|
|
407
|
+
function ze(e, t) {
|
|
408
|
+
for (let t of e.querySelectorAll("[style]")) {
|
|
409
|
+
let e = I(t.getAttribute("style") ?? "");
|
|
410
|
+
e ? t.setAttribute("style", e) : t.removeAttribute("style");
|
|
411
|
+
}
|
|
412
|
+
if (t?.compactParagraphs ?? !0) {
|
|
413
|
+
let t = Re.map((e) => `${e} > p:only-child`).join(", ");
|
|
414
|
+
for (let n of e.querySelectorAll(t)) n.attributes.length === 0 && n.replaceWith(...n.childNodes);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function Be(e, t, n = {}) {
|
|
418
|
+
let r = document.implementation.createHTMLDocument(""), i = r.createElement("div");
|
|
419
|
+
return i.append(p.fromSchema(e).serializeFragment(t, { document: r })), ze(i, n), i.innerHTML;
|
|
420
|
+
}
|
|
421
|
+
function Ve(e, t) {
|
|
422
|
+
let n = p.fromSchema(e);
|
|
423
|
+
return new class extends p {
|
|
424
|
+
constructor() {
|
|
425
|
+
super(n.nodes, n.marks);
|
|
426
|
+
}
|
|
427
|
+
serializeFragment(e, n, r) {
|
|
428
|
+
let i = super.serializeFragment(e, n, r);
|
|
429
|
+
return r === void 0 && ze(i, t), i;
|
|
430
|
+
}
|
|
431
|
+
}();
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/core/editor.ts
|
|
435
|
+
var He = "stiloSkipInput", Ue = class {
|
|
436
|
+
view;
|
|
437
|
+
schema;
|
|
438
|
+
commands;
|
|
439
|
+
manager;
|
|
440
|
+
plugins;
|
|
441
|
+
emitter = new _e();
|
|
442
|
+
compactParagraphs;
|
|
443
|
+
destroyed = !1;
|
|
444
|
+
constructor(e) {
|
|
445
|
+
this.manager = new be(e.extensions), this.schema = this.manager.schema, this.plugins = [...this.manager.createPlugins(this), ge()], this.commands = this.createRunners(), this.compactParagraphs = e.compactParagraphs ?? !0;
|
|
446
|
+
let t = e.editable ?? !0, n = Ve(this.schema, { compactParagraphs: this.compactParagraphs });
|
|
447
|
+
this.view = new d(e.element, {
|
|
448
|
+
state: this.createState(H(this.schema, e.content ?? "")),
|
|
449
|
+
editable: () => t,
|
|
450
|
+
attributes: {
|
|
451
|
+
class: "stilo-content",
|
|
452
|
+
role: "textbox",
|
|
453
|
+
"aria-multiline": "true",
|
|
454
|
+
...e.ariaLabel ? { "aria-label": e.ariaLabel } : {}
|
|
455
|
+
},
|
|
456
|
+
transformPastedHTML: (e) => Ie(e),
|
|
457
|
+
clipboardSerializer: n,
|
|
458
|
+
dispatchTransaction: (e) => this.dispatch(e),
|
|
459
|
+
handleDOMEvents: {
|
|
460
|
+
focus: (e, t) => this.emitter.emit("focus", {
|
|
461
|
+
editor: this,
|
|
462
|
+
event: t
|
|
463
|
+
}),
|
|
464
|
+
blur: (e, t) => this.emitter.emit("blur", {
|
|
465
|
+
editor: this,
|
|
466
|
+
event: t
|
|
467
|
+
})
|
|
468
|
+
}
|
|
469
|
+
}), e.autofocus && this.focus(e.autofocus === "end" ? "end" : "start");
|
|
470
|
+
}
|
|
471
|
+
get state() {
|
|
472
|
+
return this.view.state;
|
|
473
|
+
}
|
|
474
|
+
get isEmpty() {
|
|
475
|
+
let { doc: e } = this.state, t = e.firstChild;
|
|
476
|
+
return e.childCount === 1 && t?.type.name === "paragraph" && t.content.size === 0;
|
|
477
|
+
}
|
|
478
|
+
get isEditable() {
|
|
479
|
+
return this.view.editable;
|
|
480
|
+
}
|
|
481
|
+
get isDestroyed() {
|
|
482
|
+
return this.destroyed;
|
|
483
|
+
}
|
|
484
|
+
getHTML() {
|
|
485
|
+
let { compactParagraphs: e } = this;
|
|
486
|
+
return Be(this.schema, this.state.doc.content, { compactParagraphs: e });
|
|
487
|
+
}
|
|
488
|
+
setHTML(e, t) {
|
|
489
|
+
this.setContent(H(this.schema, e), t);
|
|
490
|
+
}
|
|
491
|
+
getJSON() {
|
|
492
|
+
return this.state.doc.toJSON();
|
|
493
|
+
}
|
|
494
|
+
setJSON(e, t) {
|
|
495
|
+
this.setContent(this.schema.nodeFromJSON(e), t);
|
|
496
|
+
}
|
|
497
|
+
getText() {
|
|
498
|
+
let { doc: e } = this.state;
|
|
499
|
+
return e.textBetween(0, e.content.size, "\n\n");
|
|
500
|
+
}
|
|
501
|
+
isActive(e, t) {
|
|
502
|
+
let n = this.schema.marks[e];
|
|
503
|
+
if (n) return O(this.state, n, t);
|
|
504
|
+
let r = this.schema.nodes[e];
|
|
505
|
+
return r ? k(this.state, r, t) : !1;
|
|
506
|
+
}
|
|
507
|
+
getAttributes(e) {
|
|
508
|
+
let t = this.schema.marks[e];
|
|
509
|
+
if (t) return xe(this.state, t);
|
|
510
|
+
let n = this.schema.nodes[e];
|
|
511
|
+
return n ? Se(this.state, n) : {};
|
|
512
|
+
}
|
|
513
|
+
setEditable(e) {
|
|
514
|
+
this.view.setProps({ editable: () => e });
|
|
515
|
+
}
|
|
516
|
+
focus(e) {
|
|
517
|
+
if (e) {
|
|
518
|
+
let { doc: t } = this.state, n = e === "start" ? s.atStart(t) : s.atEnd(t);
|
|
519
|
+
this.view.dispatch(this.state.tr.setSelection(n));
|
|
520
|
+
}
|
|
521
|
+
this.view.focus();
|
|
522
|
+
}
|
|
523
|
+
blur() {
|
|
524
|
+
this.view.dom.blur();
|
|
525
|
+
}
|
|
526
|
+
on(e, t) {
|
|
527
|
+
this.emitter.on(e, t);
|
|
528
|
+
}
|
|
529
|
+
off(e, t) {
|
|
530
|
+
this.emitter.off(e, t);
|
|
531
|
+
}
|
|
532
|
+
destroy() {
|
|
533
|
+
this.destroyed || (this.destroyed = !0, this.emitter.emit("destroy", { editor: this }), this.view.destroy(), this.emitter.clear());
|
|
534
|
+
}
|
|
535
|
+
createState(e) {
|
|
536
|
+
return i.create({
|
|
537
|
+
schema: this.schema,
|
|
538
|
+
doc: e,
|
|
539
|
+
plugins: this.plugins
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
createRunners() {
|
|
543
|
+
let e = {};
|
|
544
|
+
for (let [t, n] of this.manager.commands) e[t] = Object.assign((...e) => n(...e)(this.state, (e) => this.view.dispatch(e), this.view), { can: (...e) => n(...e)(this.state, void 0, this.view) });
|
|
545
|
+
return e;
|
|
546
|
+
}
|
|
547
|
+
setContent(t, n = {}) {
|
|
548
|
+
let { resetHistory: r = !1, emitInput: i = !0 } = n;
|
|
549
|
+
if (r) {
|
|
550
|
+
this.view.updateState(this.createState(t)), i && this.emitter.emit("input", {
|
|
551
|
+
editor: this,
|
|
552
|
+
transaction: null
|
|
553
|
+
});
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
let a = this.state.tr.replaceWith(0, this.state.doc.content.size, t.content);
|
|
557
|
+
a.setSelection(s.atStart(a.doc)), e(a), i || a.setMeta(He, !0), this.view.dispatch(a);
|
|
558
|
+
}
|
|
559
|
+
dispatch(e) {
|
|
560
|
+
if (this.destroyed) return;
|
|
561
|
+
let t = this.state, { state: n, transactions: r } = t.applyTransaction(e);
|
|
562
|
+
this.view.updateState(n);
|
|
563
|
+
let i = {
|
|
564
|
+
editor: this,
|
|
565
|
+
transaction: e
|
|
566
|
+
};
|
|
567
|
+
this.emitter.emit("transaction", i), r.some((e) => e.docChanged) ? e.getMeta(He) || this.emitter.emit("input", i) : t.selection.eq(n.selection) || this.emitter.emit("selectionchange", i);
|
|
568
|
+
}
|
|
569
|
+
}, We = 100;
|
|
570
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
571
|
+
function U(e) {
|
|
572
|
+
return (t) => ({
|
|
573
|
+
name: e.name,
|
|
574
|
+
priority: e.priority ?? 100,
|
|
575
|
+
options: Object.freeze({
|
|
576
|
+
...e.defaultOptions,
|
|
577
|
+
...t
|
|
578
|
+
}),
|
|
579
|
+
spec: e
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/core/helpers/input-rules.ts
|
|
584
|
+
function W(e, t, n = null) {
|
|
585
|
+
let r = e.hasIndices ? e : new RegExp(e.source, `${e.flags}d`);
|
|
586
|
+
return new b(r, (e, r, i, a) => {
|
|
587
|
+
let o = r.indices?.[0], s = r.indices?.[1], c = r[1];
|
|
588
|
+
if (!o || !s || !c) return null;
|
|
589
|
+
let l = i + s[0] - o[0], u = l + c.length, d = l - (o[1] - s[1]);
|
|
590
|
+
return e.doc.resolve(d).parent.type.allowsMarkType(t) ? e.tr.delete(u, a).addMark(l, u, t.create(n)).delete(d, l).removeStoredMark(t) : null;
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
//#endregion
|
|
594
|
+
//#region src/core/helpers/lists.ts
|
|
595
|
+
function G(e, t, n = null) {
|
|
596
|
+
return (r, i) => {
|
|
597
|
+
let { $from: a } = r.selection;
|
|
598
|
+
for (let o = a.depth; o > 0; o--) {
|
|
599
|
+
let s = a.node(o);
|
|
600
|
+
if (s.type.isInGroup("list")) return s.type === e ? se(t)(r, i) : (i?.(r.tr.setNodeMarkup(a.before(o), e, n).scrollIntoView()), !0);
|
|
601
|
+
}
|
|
602
|
+
return ue(e, n)(r, i);
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/core/helpers/marks.ts
|
|
607
|
+
function Ge(e, t) {
|
|
608
|
+
return e.some((e) => e.type !== t && e.type.excludes(t) && !t.excludes(e.type));
|
|
609
|
+
}
|
|
610
|
+
function K(e, t = null) {
|
|
611
|
+
return (n, r) => {
|
|
612
|
+
let { empty: i, $from: a, ranges: o } = n.selection;
|
|
613
|
+
if (i) {
|
|
614
|
+
let i = n.storedMarks ?? a.marks();
|
|
615
|
+
return !a.parent.type.allowsMarkType(e) || Ge(i, e) ? !1 : (r?.(n.tr.addStoredMark(e.create(t))), !0);
|
|
616
|
+
}
|
|
617
|
+
let s = !1;
|
|
618
|
+
for (let t of o) n.doc.nodesBetween(t.$from.pos, t.$to.pos, (t, n, r) => (s ||= t.isText && r?.type.allowsMarkType(e) === !0 && !Ge(t.marks, e), !s));
|
|
619
|
+
if (!s) return !1;
|
|
620
|
+
if (r) {
|
|
621
|
+
let i = n.tr;
|
|
622
|
+
for (let n of o) i.addMark(n.$from.pos, n.$to.pos, e.create(t));
|
|
623
|
+
r(i.scrollIntoView());
|
|
624
|
+
}
|
|
625
|
+
return !0;
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function q(e) {
|
|
629
|
+
return (t, n) => {
|
|
630
|
+
let { empty: r, $from: i, ranges: a } = t.selection;
|
|
631
|
+
if (r) return e.isInSet(t.storedMarks ?? i.marks()) ? (n?.(t.tr.removeStoredMark(e)), !0) : !1;
|
|
632
|
+
if (!a.some((n) => t.doc.rangeHasMark(n.$from.pos, n.$to.pos, e))) return !1;
|
|
633
|
+
if (n) {
|
|
634
|
+
let r = t.tr;
|
|
635
|
+
for (let t of a) r.removeMark(t.$from.pos, t.$to.pos, e);
|
|
636
|
+
n(r.scrollIntoView());
|
|
637
|
+
}
|
|
638
|
+
return !0;
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function J(e, t = null) {
|
|
642
|
+
return (n, r) => O(n, e, t ?? void 0) ? q(e)(n, r) : K(e, t)(n, r);
|
|
643
|
+
}
|
|
644
|
+
function Ke(e, t) {
|
|
645
|
+
let n = t.isInSet(e.marks());
|
|
646
|
+
if (!n) return null;
|
|
647
|
+
let { parent: r } = e, i = e.textOffset === 0 && e.index() > 0 ? e.index() - 1 : e.index(), a = i + 1;
|
|
648
|
+
for (; i > 0 && n.isInSet(r.child(i - 1).marks);) i--;
|
|
649
|
+
for (; a < r.childCount && n.isInSet(r.child(a).marks);) a++;
|
|
650
|
+
let o = e.start();
|
|
651
|
+
for (let e = 0; e < i; e++) o += r.child(e).nodeSize;
|
|
652
|
+
let s = o;
|
|
653
|
+
for (let e = i; e < a; e++) s += r.child(e).nodeSize;
|
|
654
|
+
return {
|
|
655
|
+
from: o,
|
|
656
|
+
to: s
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/core/helpers/nodes.ts
|
|
661
|
+
function Y(e, t) {
|
|
662
|
+
if (e.replaceSelectionWith(t), e.selection instanceof a) {
|
|
663
|
+
let t = e.selection.to;
|
|
664
|
+
e.doc.resolve(t).nodeAfter?.isTextblock || e.insert(t, e.doc.type.schema.nodes.paragraph.create()), e.setSelection(c.create(e.doc, t + 1));
|
|
665
|
+
}
|
|
666
|
+
return e.scrollIntoView();
|
|
667
|
+
}
|
|
668
|
+
function qe(e, t = null) {
|
|
669
|
+
return (n, r) => {
|
|
670
|
+
let { $from: i } = n.selection, a = i.parent.isTextblock ? i.depth - 1 : i.depth;
|
|
671
|
+
return i.node(a).canReplaceWith(i.index(a), i.indexAfter(a), e) ? (r?.(Y(n.tr, e.create(t))), !0) : !1;
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/core/helpers/parse-rules.ts
|
|
676
|
+
function X(e) {
|
|
677
|
+
return ["text-decoration", "text-decoration-line"].map((t) => ({
|
|
678
|
+
style: t,
|
|
679
|
+
consuming: !1,
|
|
680
|
+
getAttrs: (t) => t.split(/\s+/).includes(e) && null
|
|
681
|
+
}));
|
|
682
|
+
}
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region src/extensions/blockquote/index.ts
|
|
685
|
+
var Je = /* @__PURE__ */ U({
|
|
686
|
+
name: "blockquote",
|
|
687
|
+
nodes: () => ({ blockquote: {
|
|
688
|
+
group: "block",
|
|
689
|
+
content: "block+",
|
|
690
|
+
defining: !0,
|
|
691
|
+
parseDOM: [{ tag: "blockquote" }],
|
|
692
|
+
toDOM: () => ["blockquote", 0]
|
|
693
|
+
} }),
|
|
694
|
+
commands: ({ schema: e }) => {
|
|
695
|
+
let t = e.nodes.blockquote;
|
|
696
|
+
return {
|
|
697
|
+
setBlockquote: () => y(t),
|
|
698
|
+
unsetBlockquote: () => (e, n) => k(e, t) && _(e, n),
|
|
699
|
+
toggleBlockquote: () => (e, n) => k(e, t) ? _(e, n) : y(t)(e, n)
|
|
700
|
+
};
|
|
701
|
+
},
|
|
702
|
+
keymap: ({ editor: e }) => ({ "Mod-Shift-b": () => e.commands.toggleBlockquote() }),
|
|
703
|
+
inputRules: ({ schema: e }) => [x(/^\s*>\s$/, e.nodes.blockquote)]
|
|
704
|
+
});
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/extensions/bold/index.ts
|
|
707
|
+
function Ye(e) {
|
|
708
|
+
return e === "bold" || Number(e) >= 600;
|
|
709
|
+
}
|
|
710
|
+
var Xe = /* @__PURE__ */ U({
|
|
711
|
+
name: "bold",
|
|
712
|
+
marks: () => ({ bold: {
|
|
713
|
+
parseDOM: [
|
|
714
|
+
{ tag: "strong" },
|
|
715
|
+
{
|
|
716
|
+
tag: "b",
|
|
717
|
+
getAttrs: (e) => M(e.getAttribute("style") ?? "").get("font-weight") !== "normal" && null
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
style: "font-weight",
|
|
721
|
+
getAttrs: (e) => Ye(e) && null
|
|
722
|
+
}
|
|
723
|
+
],
|
|
724
|
+
group: "formatting",
|
|
725
|
+
toDOM: () => ["strong", 0]
|
|
726
|
+
} }),
|
|
727
|
+
commands: ({ schema: e }) => {
|
|
728
|
+
let t = e.marks.bold;
|
|
729
|
+
return {
|
|
730
|
+
setBold: () => K(t),
|
|
731
|
+
unsetBold: () => q(t),
|
|
732
|
+
toggleBold: () => J(t)
|
|
733
|
+
};
|
|
734
|
+
},
|
|
735
|
+
keymap: ({ editor: e }) => ({ "Mod-b": () => e.commands.toggleBold() }),
|
|
736
|
+
inputRules: ({ schema: e }) => [W(/(?:^|[^*])\*\*([^*]+)\*\*$/, e.marks.bold)]
|
|
737
|
+
}), Ze = /* @__PURE__ */ U({
|
|
738
|
+
name: "bulletList",
|
|
739
|
+
nodes: () => ({ bulletList: {
|
|
740
|
+
group: "block list",
|
|
741
|
+
content: "listItem+",
|
|
742
|
+
parseDOM: [{ tag: "ul" }],
|
|
743
|
+
toDOM: () => ["ul", 0]
|
|
744
|
+
} }),
|
|
745
|
+
commands: ({ schema: e }) => ({ toggleBulletList: () => G(e.nodes.bulletList, e.nodes.listItem) }),
|
|
746
|
+
keymap: ({ editor: e }) => ({ "Mod-Shift-8": () => e.commands.toggleBulletList() }),
|
|
747
|
+
inputRules: ({ schema: e }) => [x(/^\s*([-+*])\s$/, e.nodes.bulletList)]
|
|
748
|
+
});
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/extensions/clear-formatting/index.ts
|
|
751
|
+
function Qe(e) {
|
|
752
|
+
return (t, n) => {
|
|
753
|
+
let { empty: r, $from: i, ranges: a } = t.selection;
|
|
754
|
+
if (r) {
|
|
755
|
+
let r = t.storedMarks ?? i.marks(), a = r.filter((t) => !e.includes(t.type));
|
|
756
|
+
return a.length !== r.length && (n?.(t.tr.setStoredMarks(a)), !0);
|
|
757
|
+
}
|
|
758
|
+
if (!a.some((n) => e.some((e) => t.doc.rangeHasMark(n.$from.pos, n.$to.pos, e)))) return !1;
|
|
759
|
+
if (n) {
|
|
760
|
+
let r = t.tr;
|
|
761
|
+
for (let t of a) for (let n of e) r.removeMark(t.$from.pos, t.$to.pos, n);
|
|
762
|
+
n(r.scrollIntoView());
|
|
763
|
+
}
|
|
764
|
+
return !0;
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
var $e = /* @__PURE__ */ U({
|
|
768
|
+
name: "clearFormatting",
|
|
769
|
+
commands: ({ schema: e }) => {
|
|
770
|
+
let t = Object.values(e.marks).filter((e) => (e.spec.group ?? "").split(" ").includes("formatting"));
|
|
771
|
+
return { clearFormatting: () => Qe(t) };
|
|
772
|
+
},
|
|
773
|
+
keymap: ({ editor: e }) => ({ "Mod-\\": () => e.commands.clearFormatting() })
|
|
774
|
+
}), et = /* @__PURE__ */ U({
|
|
775
|
+
name: "code",
|
|
776
|
+
marks: () => ({ code: {
|
|
777
|
+
parseDOM: [{ tag: "code" }],
|
|
778
|
+
excludes: "formatting",
|
|
779
|
+
group: "formatting",
|
|
780
|
+
code: !0,
|
|
781
|
+
toDOM: () => ["code", 0]
|
|
782
|
+
} }),
|
|
783
|
+
commands: ({ schema: e }) => {
|
|
784
|
+
let t = e.marks.code;
|
|
785
|
+
return {
|
|
786
|
+
setCode: () => K(t),
|
|
787
|
+
unsetCode: () => q(t),
|
|
788
|
+
toggleCode: () => J(t)
|
|
789
|
+
};
|
|
790
|
+
},
|
|
791
|
+
keymap: ({ editor: e }) => ({ "Mod-e": () => e.commands.toggleCode() }),
|
|
792
|
+
inputRules: ({ schema: e }) => [W(/(?:^|[^`])`([^`]+)`$/, e.marks.code)]
|
|
793
|
+
}), tt = /* @__PURE__ */ U({
|
|
794
|
+
name: "doc",
|
|
795
|
+
nodes: () => ({ doc: { content: "block+" } }),
|
|
796
|
+
commands: () => ({
|
|
797
|
+
select: (e, t = e) => (n, r) => {
|
|
798
|
+
let { doc: i } = n;
|
|
799
|
+
return Math.min(e, t) < 0 || Math.max(e, t) > i.content.size ? !1 : (r?.(n.tr.setSelection(c.between(i.resolve(e), i.resolve(t)))), !0);
|
|
800
|
+
},
|
|
801
|
+
selectNode: (e) => (t, n) => {
|
|
802
|
+
let { doc: r } = t, i = e >= 0 && e < r.content.size ? r.nodeAt(e) : null;
|
|
803
|
+
return !i || !a.isSelectable(i) ? !1 : (n?.(t.tr.setSelection(a.create(r, e))), !0);
|
|
804
|
+
},
|
|
805
|
+
selectAll: () => ne
|
|
806
|
+
})
|
|
807
|
+
}), nt = /* @__PURE__ */ U({
|
|
808
|
+
name: "dropCursor",
|
|
809
|
+
defaultOptions: {
|
|
810
|
+
color: "currentColor",
|
|
811
|
+
width: 1
|
|
812
|
+
},
|
|
813
|
+
plugins: ({ options: e }) => [de(e)]
|
|
814
|
+
}), rt = /* @__PURE__ */ U({
|
|
815
|
+
name: "gapCursor",
|
|
816
|
+
plugins: () => [fe()]
|
|
817
|
+
}), it = /* @__PURE__ */ U({
|
|
818
|
+
name: "hardBreak",
|
|
819
|
+
nodes: () => ({ hardBreak: {
|
|
820
|
+
inline: !0,
|
|
821
|
+
group: "inline",
|
|
822
|
+
selectable: !1,
|
|
823
|
+
linebreakReplacement: !0,
|
|
824
|
+
leafText: () => "\n",
|
|
825
|
+
parseDOM: [{ tag: "br" }],
|
|
826
|
+
toDOM: () => ["br"]
|
|
827
|
+
} }),
|
|
828
|
+
commands: ({ schema: e }) => ({ setHardBreak: () => (t, n) => {
|
|
829
|
+
let r = e.nodes.hardBreak, { $from: i } = t.selection;
|
|
830
|
+
return i.parent.canReplaceWith(i.index(), i.index(), r) ? (n?.(t.tr.replaceSelectionWith(r.create()).scrollIntoView()), !0) : !1;
|
|
831
|
+
} }),
|
|
832
|
+
keymap: ({ editor: e }) => ({ "Shift-Enter": () => e.commands.setHardBreak() })
|
|
833
|
+
}), at = /* @__PURE__ */ U({
|
|
834
|
+
name: "heading",
|
|
835
|
+
defaultOptions: { levels: [
|
|
836
|
+
1,
|
|
837
|
+
2,
|
|
838
|
+
3,
|
|
839
|
+
4,
|
|
840
|
+
5,
|
|
841
|
+
6
|
|
842
|
+
] },
|
|
843
|
+
nodes: ({ levels: e }) => ({ heading: {
|
|
844
|
+
group: "block",
|
|
845
|
+
content: "inline*",
|
|
846
|
+
defining: !0,
|
|
847
|
+
attrs: { level: { default: e[0] ?? 1 } },
|
|
848
|
+
parseDOM: e.map((e) => ({
|
|
849
|
+
tag: `h${e}`,
|
|
850
|
+
attrs: { level: e }
|
|
851
|
+
})),
|
|
852
|
+
toDOM: (e) => [`h${e.attrs.level}`, 0]
|
|
853
|
+
} }),
|
|
854
|
+
commands: ({ schema: e, options: t }) => {
|
|
855
|
+
let n = e.nodes.heading, r = (e) => t.levels.includes(e.level) ? v(n, { level: e.level }) : () => !1;
|
|
856
|
+
return {
|
|
857
|
+
setHeading: r,
|
|
858
|
+
toggleHeading: (t) => (i, a) => k(i, n, { level: t.level }) ? v(e.nodes.paragraph)(i, a) : r(t)(i, a)
|
|
859
|
+
};
|
|
860
|
+
},
|
|
861
|
+
keymap: ({ editor: e, options: t }) => Object.fromEntries(t.levels.map((t) => [`Mod-Alt-${t}`, () => e.commands.toggleHeading({ level: t })])),
|
|
862
|
+
inputRules: ({ schema: e, options: t }) => t.levels.map((t) => ie(RegExp(`^#{${t}}\\s$`), e.nodes.heading, { level: t }))
|
|
863
|
+
});
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/extensions/highlight/index.ts
|
|
866
|
+
function Z(e) {
|
|
867
|
+
let t = e == null ? null : N("background-color", e);
|
|
868
|
+
return t === "transparent" ? null : t;
|
|
869
|
+
}
|
|
870
|
+
function ot({ color: e = null }) {
|
|
871
|
+
if (e === null) return { color: e };
|
|
872
|
+
let t = Z(e);
|
|
873
|
+
return t ? { color: t } : null;
|
|
874
|
+
}
|
|
875
|
+
var st = /* @__PURE__ */ U({
|
|
876
|
+
name: "highlight",
|
|
877
|
+
priority: 102,
|
|
878
|
+
marks: () => ({ highlight: {
|
|
879
|
+
attrs: { color: { default: null } },
|
|
880
|
+
parseDOM: [{
|
|
881
|
+
tag: "mark",
|
|
882
|
+
getAttrs: (e) => ({ color: Z(F(e, "background-color")) })
|
|
883
|
+
}, {
|
|
884
|
+
style: "background-color",
|
|
885
|
+
getAttrs: (e) => {
|
|
886
|
+
let t = Z(e);
|
|
887
|
+
return t ? { color: t } : !1;
|
|
888
|
+
}
|
|
889
|
+
}],
|
|
890
|
+
group: "formatting",
|
|
891
|
+
toDOM: (e) => e.attrs.color ? [
|
|
892
|
+
"mark",
|
|
893
|
+
{ style: P({ "background-color": e.attrs.color }) },
|
|
894
|
+
0
|
|
895
|
+
] : ["mark", 0]
|
|
896
|
+
} }),
|
|
897
|
+
commands: ({ schema: e }) => {
|
|
898
|
+
let t = e.marks.highlight;
|
|
899
|
+
return {
|
|
900
|
+
setHighlight: (e = {}) => {
|
|
901
|
+
let n = ot(e);
|
|
902
|
+
return n ? K(t, n) : () => !1;
|
|
903
|
+
},
|
|
904
|
+
unsetHighlight: () => q(t),
|
|
905
|
+
toggleHighlight: (e) => {
|
|
906
|
+
if (!e) return J(t);
|
|
907
|
+
let n = ot(e);
|
|
908
|
+
return n ? J(t, n) : () => !1;
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
},
|
|
912
|
+
keymap: ({ editor: e }) => ({ "Mod-Shift-h": () => e.commands.toggleHighlight() }),
|
|
913
|
+
inputRules: ({ schema: e }) => [W(/(?:^|[^=])==([^=]+)==$/, e.marks.highlight)]
|
|
914
|
+
}), ct = /* @__PURE__ */ U({
|
|
915
|
+
name: "history",
|
|
916
|
+
defaultOptions: {
|
|
917
|
+
depth: 100,
|
|
918
|
+
newGroupDelay: 500
|
|
919
|
+
},
|
|
920
|
+
commands: () => ({
|
|
921
|
+
undo: () => r,
|
|
922
|
+
redo: () => n
|
|
923
|
+
}),
|
|
924
|
+
keymap: ({ editor: e }) => ({
|
|
925
|
+
"Mod-z": () => e.commands.undo(),
|
|
926
|
+
"Mod-Shift-z": () => e.commands.redo(),
|
|
927
|
+
"Mod-y": () => e.commands.redo()
|
|
928
|
+
}),
|
|
929
|
+
plugins: ({ options: e }) => [t(e)]
|
|
930
|
+
}), lt = /* @__PURE__ */ U({
|
|
931
|
+
name: "horizontalRule",
|
|
932
|
+
nodes: () => ({ horizontalRule: {
|
|
933
|
+
group: "block",
|
|
934
|
+
parseDOM: [{ tag: "hr" }],
|
|
935
|
+
toDOM: () => ["hr"]
|
|
936
|
+
} }),
|
|
937
|
+
commands: ({ schema: e }) => ({ setHorizontalRule: () => qe(e.nodes.horizontalRule) }),
|
|
938
|
+
inputRules: ({ schema: e }) => [new b(/^---$/, (t, n, r, i) => Y(t.tr.delete(r, i), e.nodes.horizontalRule.create()))]
|
|
939
|
+
}), ut = /* @__PURE__ */ U({
|
|
940
|
+
name: "italic",
|
|
941
|
+
marks: () => ({ italic: {
|
|
942
|
+
parseDOM: [
|
|
943
|
+
{ tag: "em" },
|
|
944
|
+
{ tag: "i" },
|
|
945
|
+
{
|
|
946
|
+
style: "font-style",
|
|
947
|
+
getAttrs: (e) => e === "italic" && null
|
|
948
|
+
}
|
|
949
|
+
],
|
|
950
|
+
group: "formatting",
|
|
951
|
+
toDOM: () => ["em", 0]
|
|
952
|
+
} }),
|
|
953
|
+
commands: ({ schema: e }) => {
|
|
954
|
+
let t = e.marks.italic;
|
|
955
|
+
return {
|
|
956
|
+
setItalic: () => K(t),
|
|
957
|
+
unsetItalic: () => q(t),
|
|
958
|
+
toggleItalic: () => J(t)
|
|
959
|
+
};
|
|
960
|
+
},
|
|
961
|
+
keymap: ({ editor: e }) => ({ "Mod-i": () => e.commands.toggleItalic() }),
|
|
962
|
+
inputRules: ({ schema: e }) => [W(/(?:^|[^*])\*([^*]+)\*$/, e.marks.italic), W(/(?:^|\s)_([^_]+)_$/, e.marks.italic)]
|
|
963
|
+
});
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region src/extensions/link/index.ts
|
|
966
|
+
function dt(e) {
|
|
967
|
+
let t = e.getAttribute("href")?.trim() ?? "";
|
|
968
|
+
return !t || !z(t) ? !1 : {
|
|
969
|
+
href: t,
|
|
970
|
+
target: e.getAttribute("target") === "_blank" ? "_blank" : null
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
function ft(e, { href: t, target: n = null }) {
|
|
974
|
+
return (r, i) => {
|
|
975
|
+
let a = t.trim();
|
|
976
|
+
if (!a || !z(a)) return !1;
|
|
977
|
+
let o = {
|
|
978
|
+
href: a,
|
|
979
|
+
target: n
|
|
980
|
+
};
|
|
981
|
+
if (!r.selection.empty) return K(e, o)(r, i);
|
|
982
|
+
let s = Ke(r.selection.$from, e);
|
|
983
|
+
return s ? (i?.(r.tr.addMark(s.from, s.to, e.create(o)).scrollIntoView()), !0) : !1;
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
function pt(e) {
|
|
987
|
+
return (t, n) => {
|
|
988
|
+
if (!t.selection.empty) return q(e)(t, n);
|
|
989
|
+
let r = Ke(t.selection.$from, e);
|
|
990
|
+
return r ? (n?.(t.tr.removeMark(r.from, r.to, e).scrollIntoView()), !0) : !1;
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
var mt = /* @__PURE__ */ U({
|
|
994
|
+
name: "link",
|
|
995
|
+
priority: 103,
|
|
996
|
+
marks: () => ({ link: {
|
|
997
|
+
attrs: {
|
|
998
|
+
href: {},
|
|
999
|
+
target: { default: null }
|
|
1000
|
+
},
|
|
1001
|
+
inclusive: !1,
|
|
1002
|
+
parseDOM: [{
|
|
1003
|
+
tag: "a[href]",
|
|
1004
|
+
getAttrs: dt
|
|
1005
|
+
}],
|
|
1006
|
+
toDOM: (e) => [
|
|
1007
|
+
"a",
|
|
1008
|
+
e.attrs.target === "_blank" ? {
|
|
1009
|
+
href: e.attrs.href,
|
|
1010
|
+
target: "_blank",
|
|
1011
|
+
rel: "noopener noreferrer nofollow"
|
|
1012
|
+
} : { href: e.attrs.href },
|
|
1013
|
+
0
|
|
1014
|
+
]
|
|
1015
|
+
} }),
|
|
1016
|
+
commands: ({ schema: e }) => {
|
|
1017
|
+
let t = e.marks.link;
|
|
1018
|
+
return {
|
|
1019
|
+
setLink: (e) => ft(t, e),
|
|
1020
|
+
unsetLink: () => pt(t)
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/extensions/list-item/index.ts
|
|
1026
|
+
function ht(e) {
|
|
1027
|
+
return (t, n) => {
|
|
1028
|
+
let { $from: r, empty: i } = t.selection;
|
|
1029
|
+
if (!i || !r.parent.isTextblock || r.parentOffset !== 0 || r.index(-1) === 0) return !1;
|
|
1030
|
+
let a = r.node(-1).child(r.index(-1) - 1);
|
|
1031
|
+
if (a.lastChild?.type !== e) return !1;
|
|
1032
|
+
let o = r.before() - 1;
|
|
1033
|
+
for (; !a.isTextblock;) {
|
|
1034
|
+
let e = a.lastChild;
|
|
1035
|
+
if (!e) return !1;
|
|
1036
|
+
a = e, --o;
|
|
1037
|
+
}
|
|
1038
|
+
if (n) {
|
|
1039
|
+
let e = t.tr.delete(r.before(), r.after()).insert(o, r.parent.content);
|
|
1040
|
+
n(e.setSelection(c.create(e.doc, o)).scrollIntoView());
|
|
1041
|
+
}
|
|
1042
|
+
return !0;
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
var gt = /* @__PURE__ */ U({
|
|
1046
|
+
name: "listItem",
|
|
1047
|
+
nodes: () => ({ listItem: {
|
|
1048
|
+
content: "paragraph block*",
|
|
1049
|
+
defining: !0,
|
|
1050
|
+
parseDOM: [{ tag: "li" }],
|
|
1051
|
+
toDOM: () => ["li", 0]
|
|
1052
|
+
} }),
|
|
1053
|
+
commands: ({ schema: e }) => {
|
|
1054
|
+
let t = e.nodes.listItem;
|
|
1055
|
+
return {
|
|
1056
|
+
splitListItem: () => le(t),
|
|
1057
|
+
sinkListItem: () => ce(t),
|
|
1058
|
+
liftListItem: () => se(t)
|
|
1059
|
+
};
|
|
1060
|
+
},
|
|
1061
|
+
keymap: ({ editor: e, schema: t }) => ({
|
|
1062
|
+
Enter: () => e.commands.splitListItem(),
|
|
1063
|
+
Tab: () => e.commands.sinkListItem(),
|
|
1064
|
+
"Shift-Tab": () => e.commands.liftListItem(),
|
|
1065
|
+
Backspace: (n, r) => {
|
|
1066
|
+
let { $from: i, empty: a } = n.selection;
|
|
1067
|
+
return a && i.parentOffset === 0 && i.depth >= 2 && i.node(-1).type === t.nodes.listItem && i.index(-1) === 0 ? e.commands.liftListItem() : ht(t.nodes.listItem)(n, r);
|
|
1068
|
+
}
|
|
1069
|
+
})
|
|
1070
|
+
});
|
|
1071
|
+
//#endregion
|
|
1072
|
+
//#region src/extensions/move-block/index.ts
|
|
1073
|
+
function _t(e) {
|
|
1074
|
+
return e.type.isInGroup("list") || e.type.name === "doc" || e.type.name === "blockquote" || e.type.name === "tableCell" || e.type.name === "tableHeader";
|
|
1075
|
+
}
|
|
1076
|
+
function vt(e, t, n, r) {
|
|
1077
|
+
let i = e.blockRange(t, _t);
|
|
1078
|
+
if (!i) return !1;
|
|
1079
|
+
let { parent: a, startIndex: o, start: s, end: c } = i;
|
|
1080
|
+
if (o === 0) return !1;
|
|
1081
|
+
let l = a.child(o - 1);
|
|
1082
|
+
if (!r) return !0;
|
|
1083
|
+
let u = l.nodeSize, d = s - u, f = n.tr;
|
|
1084
|
+
return f.delete(d, d + u), f.insert(c - u, l), f.scrollIntoView(), r(f), !0;
|
|
1085
|
+
}
|
|
1086
|
+
function yt(e, t, n, r) {
|
|
1087
|
+
let i = e.blockRange(t, _t);
|
|
1088
|
+
if (!i) return !1;
|
|
1089
|
+
let { parent: a, endIndex: o, start: s, end: c } = i;
|
|
1090
|
+
if (o >= a.childCount) return !1;
|
|
1091
|
+
let l = a.child(o);
|
|
1092
|
+
if (!r) return !0;
|
|
1093
|
+
let u = l.nodeSize, d = c, f = d + u, p = n.tr;
|
|
1094
|
+
return p.delete(d, f), p.insert(s, l), p.scrollIntoView(), r(p), !0;
|
|
1095
|
+
}
|
|
1096
|
+
var bt = /* @__PURE__ */ U({
|
|
1097
|
+
name: "moveBlock",
|
|
1098
|
+
commands: ({ editor: e }) => ({
|
|
1099
|
+
moveBlockUp: () => (e, t) => {
|
|
1100
|
+
let { $from: n, $to: r } = e.selection;
|
|
1101
|
+
return vt(n, r, e, t);
|
|
1102
|
+
},
|
|
1103
|
+
moveBlockDown: () => (e, t) => {
|
|
1104
|
+
let { $from: n, $to: r } = e.selection;
|
|
1105
|
+
return yt(n, r, e, t);
|
|
1106
|
+
}
|
|
1107
|
+
}),
|
|
1108
|
+
keymap: ({ editor: e }) => ({
|
|
1109
|
+
"Alt-ArrowUp": () => e.commands.moveBlockUp(),
|
|
1110
|
+
"Alt-ArrowDown": () => e.commands.moveBlockDown()
|
|
1111
|
+
})
|
|
1112
|
+
}), Q = /* @__PURE__ */ U({
|
|
1113
|
+
name: "orderedList",
|
|
1114
|
+
nodes: () => ({ orderedList: {
|
|
1115
|
+
group: "block list",
|
|
1116
|
+
content: "listItem+",
|
|
1117
|
+
attrs: { start: { default: 1 } },
|
|
1118
|
+
parseDOM: [{
|
|
1119
|
+
tag: "ol",
|
|
1120
|
+
getAttrs: (e) => ({ start: xt(e) })
|
|
1121
|
+
}],
|
|
1122
|
+
toDOM: (e) => e.attrs.start === 1 ? ["ol", 0] : [
|
|
1123
|
+
"ol",
|
|
1124
|
+
{ start: e.attrs.start },
|
|
1125
|
+
0
|
|
1126
|
+
]
|
|
1127
|
+
} }),
|
|
1128
|
+
commands: ({ schema: e }) => ({ toggleOrderedList: () => G(e.nodes.orderedList, e.nodes.listItem) }),
|
|
1129
|
+
keymap: ({ editor: e }) => ({ "Mod-Shift-7": () => e.commands.toggleOrderedList() }),
|
|
1130
|
+
inputRules: ({ schema: e }) => [x(/^(\d+)\.\s$/, e.nodes.orderedList, (e) => ({ start: Number(e[1]) }), (e, t) => t.childCount + t.attrs.start === Number(e[1]))]
|
|
1131
|
+
});
|
|
1132
|
+
function xt(e) {
|
|
1133
|
+
let t = e.getAttribute("start")?.trim() ?? "";
|
|
1134
|
+
return /^\d+$/.test(t) ? Number(t) : 1;
|
|
1135
|
+
}
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region src/extensions/paragraph/index.ts
|
|
1138
|
+
var St = /* @__PURE__ */ U({
|
|
1139
|
+
name: "paragraph",
|
|
1140
|
+
priority: 1e3,
|
|
1141
|
+
nodes: () => ({ paragraph: {
|
|
1142
|
+
group: "block",
|
|
1143
|
+
content: "inline*",
|
|
1144
|
+
parseDOM: [{ tag: "p" }],
|
|
1145
|
+
toDOM: () => ["p", 0]
|
|
1146
|
+
} }),
|
|
1147
|
+
commands: ({ schema: e }) => ({ setParagraph: () => v(e.nodes.paragraph) }),
|
|
1148
|
+
keymap: ({ editor: e }) => ({ "Mod-Alt-0": () => e.commands.setParagraph() })
|
|
1149
|
+
}), Ct = /* @__PURE__ */ U({
|
|
1150
|
+
name: "placeholder",
|
|
1151
|
+
defaultOptions: { placeholder: "" },
|
|
1152
|
+
plugins: ({ options: e }) => [new o({ props: { decorations(t) {
|
|
1153
|
+
if (!e.placeholder) return null;
|
|
1154
|
+
let { doc: n } = t;
|
|
1155
|
+
if (n.childCount !== 1) return null;
|
|
1156
|
+
let r = n.firstChild;
|
|
1157
|
+
return r?.type.name !== "paragraph" || r.content.size !== 0 ? null : u.create(n, [l.node(0, r.nodeSize, {
|
|
1158
|
+
class: "stilo-placeholder",
|
|
1159
|
+
"data-placeholder": e.placeholder
|
|
1160
|
+
})]);
|
|
1161
|
+
} } })]
|
|
1162
|
+
}), wt = /* @__PURE__ */ U({
|
|
1163
|
+
name: "strike",
|
|
1164
|
+
marks: () => ({ strike: {
|
|
1165
|
+
parseDOM: [
|
|
1166
|
+
{ tag: "s" },
|
|
1167
|
+
{ tag: "del" },
|
|
1168
|
+
{ tag: "strike" },
|
|
1169
|
+
...X("line-through")
|
|
1170
|
+
],
|
|
1171
|
+
group: "formatting",
|
|
1172
|
+
toDOM: () => ["s", 0]
|
|
1173
|
+
} }),
|
|
1174
|
+
commands: ({ schema: e }) => {
|
|
1175
|
+
let t = e.marks.strike;
|
|
1176
|
+
return {
|
|
1177
|
+
setStrike: () => K(t),
|
|
1178
|
+
unsetStrike: () => q(t),
|
|
1179
|
+
toggleStrike: () => J(t)
|
|
1180
|
+
};
|
|
1181
|
+
},
|
|
1182
|
+
keymap: ({ editor: e }) => ({ "Mod-Shift-s": () => e.commands.toggleStrike() }),
|
|
1183
|
+
inputRules: ({ schema: e }) => [W(/(?:^|[^~])~~([^~]+)~~$/, e.marks.strike)]
|
|
1184
|
+
}), Tt = /* @__PURE__ */ U({
|
|
1185
|
+
name: "subscript",
|
|
1186
|
+
marks: () => ({ subscript: {
|
|
1187
|
+
parseDOM: [{ tag: "sub" }, {
|
|
1188
|
+
style: "vertical-align",
|
|
1189
|
+
getAttrs: (e) => e === "sub" && null
|
|
1190
|
+
}],
|
|
1191
|
+
group: "formatting script",
|
|
1192
|
+
excludes: "script",
|
|
1193
|
+
toDOM: () => ["sub", 0]
|
|
1194
|
+
} }),
|
|
1195
|
+
commands: ({ schema: e }) => {
|
|
1196
|
+
let t = e.marks.subscript;
|
|
1197
|
+
return {
|
|
1198
|
+
setSubscript: () => K(t),
|
|
1199
|
+
unsetSubscript: () => q(t),
|
|
1200
|
+
toggleSubscript: () => J(t)
|
|
1201
|
+
};
|
|
1202
|
+
},
|
|
1203
|
+
keymap: ({ editor: e }) => ({ "Mod-,": () => e.commands.toggleSubscript() })
|
|
1204
|
+
}), Et = /* @__PURE__ */ U({
|
|
1205
|
+
name: "superscript",
|
|
1206
|
+
marks: () => ({ superscript: {
|
|
1207
|
+
parseDOM: [{ tag: "sup" }, {
|
|
1208
|
+
style: "vertical-align",
|
|
1209
|
+
getAttrs: (e) => e === "super" && null
|
|
1210
|
+
}],
|
|
1211
|
+
group: "formatting script",
|
|
1212
|
+
excludes: "script",
|
|
1213
|
+
toDOM: () => ["sup", 0]
|
|
1214
|
+
} }),
|
|
1215
|
+
commands: ({ schema: e }) => {
|
|
1216
|
+
let t = e.marks.superscript;
|
|
1217
|
+
return {
|
|
1218
|
+
setSuperscript: () => K(t),
|
|
1219
|
+
unsetSuperscript: () => q(t),
|
|
1220
|
+
toggleSuperscript: () => J(t)
|
|
1221
|
+
};
|
|
1222
|
+
},
|
|
1223
|
+
keymap: ({ editor: e }) => ({ "Mod-.": () => e.commands.toggleSuperscript() })
|
|
1224
|
+
}), Dt = /* @__PURE__ */ U({
|
|
1225
|
+
name: "text",
|
|
1226
|
+
nodes: () => ({ text: { group: "inline" } }),
|
|
1227
|
+
commands: () => ({ insertText: (e) => (t, n) => e ? (n?.(t.tr.insertText(e).scrollIntoView()), !0) : !1 })
|
|
1228
|
+
});
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/extensions/text-style/index.ts
|
|
1231
|
+
function Ot(e) {
|
|
1232
|
+
return e ? { color: e } : !1;
|
|
1233
|
+
}
|
|
1234
|
+
var kt = /* @__PURE__ */ U({
|
|
1235
|
+
name: "textStyle",
|
|
1236
|
+
priority: 101,
|
|
1237
|
+
marks: () => ({ textStyle: {
|
|
1238
|
+
attrs: { color: { default: null } },
|
|
1239
|
+
parseDOM: [{
|
|
1240
|
+
tag: "span[style]",
|
|
1241
|
+
getAttrs: (e) => Ot(F(e, "color"))
|
|
1242
|
+
}, {
|
|
1243
|
+
tag: "font[color]",
|
|
1244
|
+
getAttrs: (e) => Ot(N("color", e.getAttribute("color") ?? ""))
|
|
1245
|
+
}],
|
|
1246
|
+
group: "formatting",
|
|
1247
|
+
toDOM: (e) => [
|
|
1248
|
+
"span",
|
|
1249
|
+
{ style: P({ color: e.attrs.color }) },
|
|
1250
|
+
0
|
|
1251
|
+
]
|
|
1252
|
+
} }),
|
|
1253
|
+
commands: ({ schema: e }) => {
|
|
1254
|
+
let t = e.marks.textStyle;
|
|
1255
|
+
return {
|
|
1256
|
+
setColor: (e) => {
|
|
1257
|
+
let n = N("color", e);
|
|
1258
|
+
return n ? K(t, { color: n }) : () => !1;
|
|
1259
|
+
},
|
|
1260
|
+
unsetColor: () => q(t)
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
}), At = /* @__PURE__ */ U({
|
|
1264
|
+
name: "underline",
|
|
1265
|
+
marks: () => ({ underline: {
|
|
1266
|
+
parseDOM: [{ tag: "u" }, ...X("underline")],
|
|
1267
|
+
group: "formatting",
|
|
1268
|
+
toDOM: () => ["u", 0]
|
|
1269
|
+
} }),
|
|
1270
|
+
commands: ({ schema: e }) => {
|
|
1271
|
+
let t = e.marks.underline;
|
|
1272
|
+
return {
|
|
1273
|
+
setUnderline: () => K(t),
|
|
1274
|
+
unsetUnderline: () => q(t),
|
|
1275
|
+
toggleUnderline: () => J(t)
|
|
1276
|
+
};
|
|
1277
|
+
},
|
|
1278
|
+
keymap: ({ editor: e }) => ({ "Mod-u": () => e.commands.toggleUnderline() })
|
|
1279
|
+
});
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region src/extensions/default-extensions/index.ts
|
|
1282
|
+
function $(e, t) {
|
|
1283
|
+
return t === !1 ? [] : [e(t)];
|
|
1284
|
+
}
|
|
1285
|
+
function jt(e = {}) {
|
|
1286
|
+
return [
|
|
1287
|
+
...$(tt, e.doc),
|
|
1288
|
+
...$(Dt, e.text),
|
|
1289
|
+
...$(St, e.paragraph),
|
|
1290
|
+
...$(at, e.heading),
|
|
1291
|
+
...$(Je, e.blockquote),
|
|
1292
|
+
...$(lt, e.horizontalRule),
|
|
1293
|
+
...$(it, e.hardBreak),
|
|
1294
|
+
...$(Ze, e.bulletList),
|
|
1295
|
+
...$(Q, e.orderedList),
|
|
1296
|
+
...$(gt, e.listItem),
|
|
1297
|
+
...$(Xe, e.bold),
|
|
1298
|
+
...$(ut, e.italic),
|
|
1299
|
+
...$(At, e.underline),
|
|
1300
|
+
...$(wt, e.strike),
|
|
1301
|
+
...$(Tt, e.subscript),
|
|
1302
|
+
...$(Et, e.superscript),
|
|
1303
|
+
...$(et, e.code),
|
|
1304
|
+
...$(mt, e.link),
|
|
1305
|
+
...$(kt, e.textStyle),
|
|
1306
|
+
...$(st, e.highlight),
|
|
1307
|
+
...$($e, e.clearFormatting),
|
|
1308
|
+
...$(ct, e.history),
|
|
1309
|
+
...$(bt, e.moveBlock),
|
|
1310
|
+
...$(Ct, e.placeholder),
|
|
1311
|
+
...$(nt, e.dropCursor),
|
|
1312
|
+
...$(rt, e.gapCursor)
|
|
1313
|
+
];
|
|
1314
|
+
}
|
|
1315
|
+
//#endregion
|
|
1316
|
+
export { Y as A, O as B, et as C, Je as D, Xe as E, W as F, C as H, We as I, U as L, J as M, q as N, X as O, G as P, Ue as R, tt as S, Ze as T, k as V, st as _, Et as a, rt as b, Ct as c, bt as d, gt as f, ct as g, lt as h, Dt as i, K as j, qe as k, St as l, ut as m, At as n, Tt as o, mt as p, kt as r, wt as s, jt as t, Q as u, at as v, $e as w, nt as x, it as y, D as z };
|