fountainjs-editor 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 +460 -0
- package/dist/fountainjs-react.cjs +1 -0
- package/dist/fountainjs-react.js +8 -0
- package/dist/fountainjs.cjs +1 -0
- package/dist/fountainjs.js +219 -0
- package/dist/index-1c508d95.js +1172 -0
- package/dist/index-cafd8e26.cjs +40 -0
- package/package.json +76 -0
- package/src/core/editor.ts +15 -0
- package/src/core/index.ts +6 -0
- package/src/core/plugin.ts +4 -0
- package/src/core/schema/index.ts +5 -0
- package/src/core/schema/mark-spec.ts +5 -0
- package/src/core/schema/mark.ts +7 -0
- package/src/core/schema/node-spec.ts +12 -0
- package/src/core/schema/node.ts +12 -0
- package/src/core/schema/schema.ts +17 -0
- package/src/core/selection.ts +17 -0
- package/src/core/state.ts +13 -0
- package/src/core/transaction/add-mark-step.ts +19 -0
- package/src/core/transaction/index.ts +9 -0
- package/src/core/transaction/insert-text-step.ts +18 -0
- package/src/core/transaction/remove-mark-step.ts +17 -0
- package/src/core/transaction/replace-step.ts +6 -0
- package/src/core/transaction/replace-text-step.ts +33 -0
- package/src/core/transaction/set-node-attrs-step.ts +30 -0
- package/src/core/transaction/step.ts +2 -0
- package/src/core/transaction/transaction.ts +8 -0
- package/src/core/transaction/transform.ts +23 -0
- package/src/extensions/index.ts +64 -0
- package/src/extensions/marks/em.ts +2 -0
- package/src/extensions/marks/strong.ts +2 -0
- package/src/extensions/nodes/bullet-list.ts +9 -0
- package/src/extensions/nodes/doc.ts +2 -0
- package/src/extensions/nodes/figcaption.ts +5 -0
- package/src/extensions/nodes/heading.ts +7 -0
- package/src/extensions/nodes/image-super-view.ts +90 -0
- package/src/extensions/nodes/image-super.ts +7 -0
- package/src/extensions/nodes/list-item.ts +9 -0
- package/src/extensions/nodes/paragraph.ts +2 -0
- package/src/extensions/nodes/table-cell.ts +5 -0
- package/src/extensions/nodes/table-row.ts +2 -0
- package/src/extensions/nodes/table.ts +5 -0
- package/src/extensions/nodes/text.ts +2 -0
- package/src/extensions/plugins/history.ts +12 -0
- package/src/extensions/plugins/markdown-shortcuts.ts +52 -0
- package/src/index.ts +12 -0
- package/src/react/FountainEditor.tsx +19 -0
- package/src/react/Navigator.tsx +36 -0
- package/src/react/index.ts +4 -0
- package/src/react/useFountain.ts +10 -0
- package/src/react/useNavigatorState.ts +41 -0
- package/src/view/dom-renderer.ts +77 -0
- package/src/view/index.ts +2 -0
- package/src/view/input.ts +74 -0
- package/src/view/node-view.ts +9 -0
- package/src/view/selection-handler.ts +76 -0
- package/src/view/view.ts +290 -0
|
@@ -0,0 +1,1172 @@
|
|
|
1
|
+
var yt = Object.defineProperty;
|
|
2
|
+
var wt = (u, t, r) => t in u ? yt(u, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : u[t] = r;
|
|
3
|
+
var h = (u, t, r) => (wt(u, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
import je, { useState as Ne, useRef as bt, useEffect as Me } from "react";
|
|
5
|
+
class b {
|
|
6
|
+
constructor(t, r, n = [], i, d = []) {
|
|
7
|
+
h(this, "type");
|
|
8
|
+
h(this, "attrs");
|
|
9
|
+
h(this, "content");
|
|
10
|
+
h(this, "text");
|
|
11
|
+
h(this, "marks");
|
|
12
|
+
this.type = t, this.attrs = r, this.content = n, this.text = i, this.marks = d;
|
|
13
|
+
}
|
|
14
|
+
get isText() {
|
|
15
|
+
return this.type.name === "text";
|
|
16
|
+
}
|
|
17
|
+
withText(t) {
|
|
18
|
+
if (!this.isText)
|
|
19
|
+
throw new Error("Cannot call withText on a non-text node.");
|
|
20
|
+
return new b(this.type, this.attrs, [], t, this.marks);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class xt {
|
|
24
|
+
constructor(t, r) {
|
|
25
|
+
h(this, "name");
|
|
26
|
+
h(this, "spec");
|
|
27
|
+
h(this, "isBlock");
|
|
28
|
+
h(this, "isInline");
|
|
29
|
+
this.name = t, this.spec = r, this.isInline = !!r.inline, this.isBlock = !this.isInline;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class Et {
|
|
33
|
+
constructor(t, r) {
|
|
34
|
+
h(this, "name");
|
|
35
|
+
h(this, "spec");
|
|
36
|
+
this.name = t, this.spec = r;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class Rt {
|
|
40
|
+
constructor(t) {
|
|
41
|
+
h(this, "spec");
|
|
42
|
+
h(this, "nodes");
|
|
43
|
+
h(this, "marks");
|
|
44
|
+
this.spec = t, this.nodes = this.compileNodes(t.nodes), this.marks = this.compileMarks(t.marks || {});
|
|
45
|
+
}
|
|
46
|
+
compileNodes(t) {
|
|
47
|
+
const r = {};
|
|
48
|
+
for (const n in t)
|
|
49
|
+
r[n] = new xt(n, t[n]);
|
|
50
|
+
return r;
|
|
51
|
+
}
|
|
52
|
+
compileMarks(t) {
|
|
53
|
+
const r = {};
|
|
54
|
+
for (const n in t)
|
|
55
|
+
r[n] = new Et(n, t[n]);
|
|
56
|
+
return r;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class K {
|
|
60
|
+
}
|
|
61
|
+
class Tt extends K {
|
|
62
|
+
constructor(t, r, n) {
|
|
63
|
+
super(), this.from = t, this.to = r, this.content = n;
|
|
64
|
+
}
|
|
65
|
+
apply(t) {
|
|
66
|
+
if (this.from > this.to || this.from > t.content.length || this.to > t.content.length)
|
|
67
|
+
throw new Error("ReplaceStep apply error: Invalid range");
|
|
68
|
+
const r = [...t.content.slice(0, this.from), ...this.content, ...t.content.slice(this.to)];
|
|
69
|
+
return new b(t.type, t.attrs, r);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class _t extends K {
|
|
73
|
+
constructor(t, r, n, i) {
|
|
74
|
+
super(), this.path = t, this.from = r, this.to = n, this.text = i;
|
|
75
|
+
}
|
|
76
|
+
apply(t) {
|
|
77
|
+
let r = t, n = [];
|
|
78
|
+
for (const f of this.path)
|
|
79
|
+
n.push(r), r = r.content[f];
|
|
80
|
+
if (!r || !r.isText)
|
|
81
|
+
throw new Error("Target for ReplaceTextStep is not a text node.");
|
|
82
|
+
const i = r.text || "", d = i.slice(0, this.from) + this.text + i.slice(this.to);
|
|
83
|
+
let o = r.withText(d);
|
|
84
|
+
for (let f = n.length - 1; f >= 0; f--) {
|
|
85
|
+
const w = n[f], y = [...w.content];
|
|
86
|
+
y[this.path[f]] = o, o = new b(w.type, w.attrs, y, w.text, w.marks);
|
|
87
|
+
}
|
|
88
|
+
return o;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
class St extends K {
|
|
92
|
+
constructor(t, r) {
|
|
93
|
+
super(), this.path = t, this.mark = r;
|
|
94
|
+
}
|
|
95
|
+
apply(t) {
|
|
96
|
+
let r = t, n = [];
|
|
97
|
+
for (const o of this.path)
|
|
98
|
+
n.push(r), r = r.content[o];
|
|
99
|
+
if (!r || !r.isText)
|
|
100
|
+
return t;
|
|
101
|
+
const i = [this.mark, ...r.marks.filter((o) => o.type !== this.mark.type)];
|
|
102
|
+
let c = new b(r.type, r.attrs, [], r.text, i);
|
|
103
|
+
for (let o = n.length - 1; o >= 0; o--) {
|
|
104
|
+
const f = n[o], w = [...f.content];
|
|
105
|
+
w[this.path[o]] = c, c = new b(f.type, f.attrs, w, f.text, f.marks);
|
|
106
|
+
}
|
|
107
|
+
return c;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
class Ct extends K {
|
|
111
|
+
constructor(t, r, n) {
|
|
112
|
+
super(), this.from = t, this.to = r, this.markType = n;
|
|
113
|
+
}
|
|
114
|
+
apply(t) {
|
|
115
|
+
const r = t.content.map((n, i) => {
|
|
116
|
+
if (i >= this.from && i < this.to && n.type.name === "paragraph") {
|
|
117
|
+
const d = n.content.map((c) => {
|
|
118
|
+
if (c.isText) {
|
|
119
|
+
const o = c.marks.filter((f) => f.type !== this.markType);
|
|
120
|
+
return new b(c.type, c.attrs, [], c.text, o);
|
|
121
|
+
}
|
|
122
|
+
return c;
|
|
123
|
+
});
|
|
124
|
+
return new b(n.type, n.attrs, d);
|
|
125
|
+
}
|
|
126
|
+
return n;
|
|
127
|
+
});
|
|
128
|
+
return new b(t.type, t.attrs, r);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
class kt extends K {
|
|
132
|
+
constructor(t, r) {
|
|
133
|
+
super(), this.path = t, this.attrs = r;
|
|
134
|
+
}
|
|
135
|
+
apply(t) {
|
|
136
|
+
let r = t, n = [];
|
|
137
|
+
for (const o of this.path)
|
|
138
|
+
n.push(r), r = r.content[o];
|
|
139
|
+
if (!r)
|
|
140
|
+
throw new Error("No node found at path");
|
|
141
|
+
const i = { ...r.attrs, ...this.attrs };
|
|
142
|
+
let c = new b(r.type, i, r.content, r.text, r.marks);
|
|
143
|
+
for (let o = n.length - 1; o >= 0; o--) {
|
|
144
|
+
const f = n[o], w = [...f.content];
|
|
145
|
+
w[this.path[o]] = c, c = new b(f.type, f.attrs, w, f.text, f.marks);
|
|
146
|
+
}
|
|
147
|
+
return c;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
class Ot {
|
|
151
|
+
constructor(t) {
|
|
152
|
+
h(this, "originalDoc");
|
|
153
|
+
h(this, "doc");
|
|
154
|
+
h(this, "steps");
|
|
155
|
+
this.originalDoc = t, this.doc = t, this.steps = [];
|
|
156
|
+
}
|
|
157
|
+
step(t) {
|
|
158
|
+
const r = t.apply(this.doc);
|
|
159
|
+
return r && (this.doc = r, this.steps.push(t)), this;
|
|
160
|
+
}
|
|
161
|
+
replace(t, r, n = []) {
|
|
162
|
+
return this.step(new Tt(t, r, n));
|
|
163
|
+
}
|
|
164
|
+
// --- REPLACE `insertText` WITH THIS NEW METHOD ---
|
|
165
|
+
replaceText(t, r, n, i) {
|
|
166
|
+
return this.step(new _t(t, r, n, i));
|
|
167
|
+
}
|
|
168
|
+
addMark(t, r) {
|
|
169
|
+
return this.step(new St(t, r));
|
|
170
|
+
}
|
|
171
|
+
removeMark(t, r, n) {
|
|
172
|
+
return this.step(new Ct(t, r, n));
|
|
173
|
+
}
|
|
174
|
+
setNodeAttrs(t, r) {
|
|
175
|
+
return this.step(new kt(t, r));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
class F {
|
|
179
|
+
// A selection is defined by a single path and a start/end offset within that path's node.
|
|
180
|
+
constructor(t, r, n) {
|
|
181
|
+
this.path = t, this.from = r, this.to = n;
|
|
182
|
+
}
|
|
183
|
+
// A collapsed selection (cursor)
|
|
184
|
+
static createCursor(t, r) {
|
|
185
|
+
return new F(t, r, r);
|
|
186
|
+
}
|
|
187
|
+
get isCollapsed() {
|
|
188
|
+
return this.from === this.to;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
class Pt extends Ot {
|
|
192
|
+
constructor(r) {
|
|
193
|
+
super(r);
|
|
194
|
+
h(this, "selection");
|
|
195
|
+
h(this, "selectionSet", !1);
|
|
196
|
+
this.selection = F.createCursor([], 0);
|
|
197
|
+
}
|
|
198
|
+
setSelection(r) {
|
|
199
|
+
return this.selection = r, this.selectionSet = !0, this;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
class z {
|
|
203
|
+
constructor(t) {
|
|
204
|
+
h(this, "schema");
|
|
205
|
+
h(this, "doc");
|
|
206
|
+
h(this, "selection");
|
|
207
|
+
h(this, "plugins");
|
|
208
|
+
h(this, "pluginStates");
|
|
209
|
+
this.schema = t.schema, this.doc = t.doc || this.createDefaultDoc(t.schema), this.selection = t.selection || F.createCursor([0, 0], 19), this.plugins = t.plugins || [], t.pluginStates ? this.pluginStates = t.pluginStates : this.pluginStates = this.plugins.map((r) => {
|
|
210
|
+
var n;
|
|
211
|
+
return (n = r.spec.state) == null ? void 0 : n.init({}, this);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
static create(t) {
|
|
215
|
+
return new z(t);
|
|
216
|
+
}
|
|
217
|
+
apply(t) {
|
|
218
|
+
const r = this.plugins.map((d, c) => {
|
|
219
|
+
const o = d.spec.state;
|
|
220
|
+
return o ? o.apply(t, this.pluginStates[c], this) : this.pluginStates[c];
|
|
221
|
+
}), n = t.doc, i = t.selectionSet ? t.selection : this.selection;
|
|
222
|
+
return new z({ schema: this.schema, doc: n, selection: i, plugins: this.plugins, pluginStates: r });
|
|
223
|
+
}
|
|
224
|
+
createTransaction() {
|
|
225
|
+
return new Pt(this.doc);
|
|
226
|
+
}
|
|
227
|
+
createDefaultDoc(t) {
|
|
228
|
+
const r = t.nodes.doc, n = t.nodes.paragraph, i = t.nodes.text;
|
|
229
|
+
if (!r || !n || !i)
|
|
230
|
+
throw new Error("Schema is missing core nodes.");
|
|
231
|
+
const d = new b(i, {}, [], "Start typing here..."), c = new b(n, {}, [d]);
|
|
232
|
+
return new b(r, {}, [c]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
class Dt {
|
|
236
|
+
constructor(t) {
|
|
237
|
+
h(this, "_state");
|
|
238
|
+
h(this, "subscribers", /* @__PURE__ */ new Set());
|
|
239
|
+
this._state = t.state;
|
|
240
|
+
}
|
|
241
|
+
get state() {
|
|
242
|
+
return this._state;
|
|
243
|
+
}
|
|
244
|
+
createTransaction() {
|
|
245
|
+
return this.state.createTransaction();
|
|
246
|
+
}
|
|
247
|
+
dispatch(t) {
|
|
248
|
+
const r = this._state.apply(t);
|
|
249
|
+
r !== this._state && (this._state = r, this.subscribers.forEach((n) => n(r)));
|
|
250
|
+
}
|
|
251
|
+
subscribe(t) {
|
|
252
|
+
return this.subscribers.add(t), () => this.subscribers.delete(t);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function jt(u) {
|
|
256
|
+
const t = new Rt(u.schema), r = u.plugins || [], n = u.state || z.create({ schema: t, plugins: r });
|
|
257
|
+
return new Dt({ state: n });
|
|
258
|
+
}
|
|
259
|
+
class Nt {
|
|
260
|
+
constructor(t, r) {
|
|
261
|
+
h(this, "editor");
|
|
262
|
+
h(this, "dom");
|
|
263
|
+
h(this, "isDestroyed", !1);
|
|
264
|
+
h(this, "isReconciling", !1);
|
|
265
|
+
h(this, "unsubscribe");
|
|
266
|
+
h(this, "nodeToDOM", /* @__PURE__ */ new WeakMap());
|
|
267
|
+
h(this, "domToPath", /* @__PURE__ */ new WeakMap());
|
|
268
|
+
h(this, "handleInput", () => {
|
|
269
|
+
this.isReconciling || this.reconcile();
|
|
270
|
+
});
|
|
271
|
+
h(this, "handleKeyDown", (t) => {
|
|
272
|
+
if ((t.ctrlKey || t.metaKey) && t.key === "b") {
|
|
273
|
+
t.preventDefault(), this.toggleMark("strong");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if ((t.ctrlKey || t.metaKey) && t.key === "i") {
|
|
277
|
+
t.preventDefault(), this.toggleMark("em");
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if ((t.ctrlKey || t.metaKey) && t.key === "z" && !t.shiftKey) {
|
|
281
|
+
t.preventDefault();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
h(this, "handlePaste", (t) => {
|
|
286
|
+
var n;
|
|
287
|
+
t.preventDefault();
|
|
288
|
+
const r = (n = t.clipboardData) == null ? void 0 : n.getData("text/plain");
|
|
289
|
+
r && document.execCommand("insertText", !1, r);
|
|
290
|
+
});
|
|
291
|
+
h(this, "reconcile", () => {
|
|
292
|
+
if (!this.isReconciling) {
|
|
293
|
+
this.isReconciling = !0;
|
|
294
|
+
try {
|
|
295
|
+
const { state: t } = this.editor, r = window.getSelection();
|
|
296
|
+
if (!r || !r.anchorNode) {
|
|
297
|
+
this.isReconciling = !1;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const n = this.extractContent(this.dom);
|
|
301
|
+
if (n.length > 0) {
|
|
302
|
+
const i = t.createTransaction().replace(0, t.doc.content.length, n);
|
|
303
|
+
if (r.anchorNode) {
|
|
304
|
+
const d = r.anchorOffset;
|
|
305
|
+
i.setSelection(F.createCursor([0, 0], d));
|
|
306
|
+
}
|
|
307
|
+
this.editor.dispatch(i);
|
|
308
|
+
}
|
|
309
|
+
} finally {
|
|
310
|
+
queueMicrotask(() => {
|
|
311
|
+
this.isReconciling = !1;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
h(this, "onStateChange", (t) => {
|
|
317
|
+
this.isDestroyed || this.isReconciling || this.render(t);
|
|
318
|
+
});
|
|
319
|
+
this.editor = r, this.dom = document.createElement("div"), this.dom.setAttribute("role", "textbox"), this.dom.setAttribute("aria-label", "Editor"), this.dom.contentEditable = "true", this.dom.style.cssText = `
|
|
320
|
+
padding: 12px;
|
|
321
|
+
min-height: 200px;
|
|
322
|
+
outline: none;
|
|
323
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
324
|
+
font-size: 16px;
|
|
325
|
+
line-height: 1.6;
|
|
326
|
+
color: #333;
|
|
327
|
+
`, t.appendChild(this.dom), this.dom.addEventListener("input", this.handleInput), this.dom.addEventListener("keydown", this.handleKeyDown), this.dom.addEventListener("paste", this.handlePaste), this.unsubscribe = this.editor.subscribe(this.onStateChange), this.render(this.editor.state);
|
|
328
|
+
}
|
|
329
|
+
toggleMark(t) {
|
|
330
|
+
const { state: r } = this.editor, n = window.getSelection();
|
|
331
|
+
if (!n || n.isCollapsed)
|
|
332
|
+
return;
|
|
333
|
+
const { anchorNode: i, focusNode: d, anchorOffset: c, focusOffset: o } = n;
|
|
334
|
+
if (!i || !d)
|
|
335
|
+
return;
|
|
336
|
+
const f = n.toString();
|
|
337
|
+
if (r.schema.marks[t]) {
|
|
338
|
+
const y = document.createElement("span");
|
|
339
|
+
t === "strong" && (y.style.fontWeight = "bold"), t === "em" && (y.style.fontStyle = "italic"), y.textContent = f;
|
|
340
|
+
try {
|
|
341
|
+
const R = n.getRangeAt(0);
|
|
342
|
+
R.deleteContents(), R.insertNode(y);
|
|
343
|
+
} catch {
|
|
344
|
+
t === "strong" && document.execCommand("bold"), t === "em" && document.execCommand("italic");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
queueMicrotask(() => this.reconcile());
|
|
348
|
+
}
|
|
349
|
+
extractContent(t) {
|
|
350
|
+
const r = [];
|
|
351
|
+
for (let n = 0; n < t.childNodes.length; n++) {
|
|
352
|
+
const i = t.childNodes[n];
|
|
353
|
+
if (i.nodeType === 3) {
|
|
354
|
+
const d = i.textContent || "";
|
|
355
|
+
if (d.trim()) {
|
|
356
|
+
const c = new b(this.editor.state.schema.nodes.text, {}, [], d), o = new b(this.editor.state.schema.nodes.paragraph, {}, [c]);
|
|
357
|
+
r.push(o);
|
|
358
|
+
}
|
|
359
|
+
} else if (i.nodeType === 1) {
|
|
360
|
+
const d = i, c = d.tagName.toLowerCase();
|
|
361
|
+
if (c === "p" || c === "div") {
|
|
362
|
+
const o = d.textContent || "", f = new b(this.editor.state.schema.nodes.text, {}, [], o), w = new b(this.editor.state.schema.nodes.paragraph, {}, [f]);
|
|
363
|
+
r.push(w);
|
|
364
|
+
} else if (c === "h1" || c === "h2" || c === "h3") {
|
|
365
|
+
const o = parseInt(c[1]), f = d.textContent || "", w = new b(this.editor.state.schema.nodes.text, {}, [], f), y = new b(this.editor.state.schema.nodes.heading, { level: o }, [w]);
|
|
366
|
+
r.push(y);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return r.length > 0 ? r : [
|
|
371
|
+
new b(this.editor.state.schema.nodes.paragraph, {}, [
|
|
372
|
+
new b(this.editor.state.schema.nodes.text, {}, [], "")
|
|
373
|
+
])
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
render(t) {
|
|
377
|
+
this.nodeToDOM = /* @__PURE__ */ new WeakMap(), this.domToPath = /* @__PURE__ */ new WeakMap();
|
|
378
|
+
const r = this.renderNode(t.doc, []);
|
|
379
|
+
if (r.childNodes.length > 0) {
|
|
380
|
+
this.dom.innerHTML = "";
|
|
381
|
+
for (let n = 0; n < r.childNodes.length; n++)
|
|
382
|
+
this.dom.appendChild(r.childNodes[n].cloneNode(!0));
|
|
383
|
+
}
|
|
384
|
+
queueMicrotask(() => this.restoreSelection(t.selection));
|
|
385
|
+
}
|
|
386
|
+
renderNode(t, r) {
|
|
387
|
+
const n = document.createElement("div");
|
|
388
|
+
if (t.type && t.type.name === "text")
|
|
389
|
+
n.textContent = t.text || "";
|
|
390
|
+
else {
|
|
391
|
+
const d = this.getTagForNode(t), c = document.createElement(d);
|
|
392
|
+
if (t.attrs && t.attrs.level && c.setAttribute("data-level", t.attrs.level), t.attrs && t.attrs.src) {
|
|
393
|
+
const o = document.createElement("img");
|
|
394
|
+
o.src = t.attrs.src, o.style.maxWidth = "100%", o.style.height = "auto", c.appendChild(o);
|
|
395
|
+
}
|
|
396
|
+
if (t.content)
|
|
397
|
+
for (let o = 0; o < t.content.length; o++) {
|
|
398
|
+
const f = t.content[o], w = [...r, o], y = this.renderNode(f, w);
|
|
399
|
+
for (let R = 0; R < y.childNodes.length; R++)
|
|
400
|
+
c.appendChild(y.childNodes[R].cloneNode(!0));
|
|
401
|
+
}
|
|
402
|
+
else
|
|
403
|
+
t.text && (c.textContent = t.text);
|
|
404
|
+
this.nodeToDOM.set(t, c), n.appendChild(c);
|
|
405
|
+
}
|
|
406
|
+
return n;
|
|
407
|
+
}
|
|
408
|
+
getTagForNode(t) {
|
|
409
|
+
var i;
|
|
410
|
+
const r = t.type.name;
|
|
411
|
+
return {
|
|
412
|
+
heading: `h${((i = t.attrs) == null ? void 0 : i.level) || 1}`,
|
|
413
|
+
paragraph: "p",
|
|
414
|
+
bullet_list: "ul",
|
|
415
|
+
list_item: "li",
|
|
416
|
+
table: "table",
|
|
417
|
+
table_row: "tr",
|
|
418
|
+
table_cell: "td",
|
|
419
|
+
image_super: "figure",
|
|
420
|
+
figcaption: "figcaption"
|
|
421
|
+
}[r] || "div";
|
|
422
|
+
}
|
|
423
|
+
restoreSelection(t) {
|
|
424
|
+
var n;
|
|
425
|
+
const r = window.getSelection();
|
|
426
|
+
if (r)
|
|
427
|
+
try {
|
|
428
|
+
const i = this.dom.querySelector("p, h1, h2, h3, h4, h5, h6");
|
|
429
|
+
if (i != null && i.firstChild) {
|
|
430
|
+
const d = document.createRange(), c = Math.min(t.to, (((n = i.firstChild.textContent) == null ? void 0 : n.length) ?? 0) - 1);
|
|
431
|
+
d.setStart(i.firstChild, Math.max(0, c)), d.collapse(!0), r.removeAllRanges(), r.addRange(d);
|
|
432
|
+
}
|
|
433
|
+
} catch {
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
execCommand(t, r) {
|
|
437
|
+
return document.execCommand(t, !1, r);
|
|
438
|
+
}
|
|
439
|
+
destroy() {
|
|
440
|
+
this.isDestroyed || (this.isDestroyed = !0, this.unsubscribe(), this.dom.removeEventListener("input", this.handleInput), this.dom.removeEventListener("keydown", this.handleKeyDown), this.dom.removeEventListener("paste", this.handlePaste), this.dom.remove());
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function Lt(u) {
|
|
444
|
+
const [t] = Ne(() => u ? jt(u) : null);
|
|
445
|
+
return t;
|
|
446
|
+
}
|
|
447
|
+
var se = { exports: {} }, L = {};
|
|
448
|
+
/**
|
|
449
|
+
* @license React
|
|
450
|
+
* react-jsx-runtime.production.min.js
|
|
451
|
+
*
|
|
452
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
453
|
+
*
|
|
454
|
+
* This source code is licensed under the MIT license found in the
|
|
455
|
+
* LICENSE file in the root directory of this source tree.
|
|
456
|
+
*/
|
|
457
|
+
var Pe;
|
|
458
|
+
function Mt() {
|
|
459
|
+
if (Pe)
|
|
460
|
+
return L;
|
|
461
|
+
Pe = 1;
|
|
462
|
+
var u = je, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, i = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, d = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
463
|
+
function c(o, f, w) {
|
|
464
|
+
var y, R = {}, O = null, U = null;
|
|
465
|
+
w !== void 0 && (O = "" + w), f.key !== void 0 && (O = "" + f.key), f.ref !== void 0 && (U = f.ref);
|
|
466
|
+
for (y in f)
|
|
467
|
+
n.call(f, y) && !d.hasOwnProperty(y) && (R[y] = f[y]);
|
|
468
|
+
if (o && o.defaultProps)
|
|
469
|
+
for (y in f = o.defaultProps, f)
|
|
470
|
+
R[y] === void 0 && (R[y] = f[y]);
|
|
471
|
+
return { $$typeof: t, type: o, key: O, ref: U, props: R, _owner: i.current };
|
|
472
|
+
}
|
|
473
|
+
return L.Fragment = r, L.jsx = c, L.jsxs = c, L;
|
|
474
|
+
}
|
|
475
|
+
var Y = {};
|
|
476
|
+
/**
|
|
477
|
+
* @license React
|
|
478
|
+
* react-jsx-runtime.development.js
|
|
479
|
+
*
|
|
480
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
481
|
+
*
|
|
482
|
+
* This source code is licensed under the MIT license found in the
|
|
483
|
+
* LICENSE file in the root directory of this source tree.
|
|
484
|
+
*/
|
|
485
|
+
var De;
|
|
486
|
+
function At() {
|
|
487
|
+
return De || (De = 1, process.env.NODE_ENV !== "production" && function() {
|
|
488
|
+
var u = je, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), d = Symbol.for("react.profiler"), c = Symbol.for("react.provider"), o = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), U = Symbol.for("react.offscreen"), ae = Symbol.iterator, Ae = "@@iterator";
|
|
489
|
+
function Fe(e) {
|
|
490
|
+
if (e === null || typeof e != "object")
|
|
491
|
+
return null;
|
|
492
|
+
var s = ae && e[ae] || e[Ae];
|
|
493
|
+
return typeof s == "function" ? s : null;
|
|
494
|
+
}
|
|
495
|
+
var j = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
496
|
+
function T(e) {
|
|
497
|
+
{
|
|
498
|
+
for (var s = arguments.length, a = new Array(s > 1 ? s - 1 : 0), l = 1; l < s; l++)
|
|
499
|
+
a[l - 1] = arguments[l];
|
|
500
|
+
Ie("error", e, a);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function Ie(e, s, a) {
|
|
504
|
+
{
|
|
505
|
+
var l = j.ReactDebugCurrentFrame, m = l.getStackAddendum();
|
|
506
|
+
m !== "" && (s += "%s", a = a.concat([m]));
|
|
507
|
+
var g = a.map(function(v) {
|
|
508
|
+
return String(v);
|
|
509
|
+
});
|
|
510
|
+
g.unshift("Warning: " + s), Function.prototype.apply.call(console[e], console, g);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
var We = !1, $e = !1, Le = !1, Ye = !1, Ke = !1, ie;
|
|
514
|
+
ie = Symbol.for("react.module.reference");
|
|
515
|
+
function Ue(e) {
|
|
516
|
+
return !!(typeof e == "string" || typeof e == "function" || e === n || e === d || Ke || e === i || e === w || e === y || Ye || e === U || We || $e || Le || typeof e == "object" && e !== null && (e.$$typeof === O || e.$$typeof === R || e.$$typeof === c || e.$$typeof === o || e.$$typeof === f || // This needs to include all possible module reference object
|
|
517
|
+
// types supported by any Flight configuration anywhere since
|
|
518
|
+
// we don't know which Flight build this will end up being used
|
|
519
|
+
// with.
|
|
520
|
+
e.$$typeof === ie || e.getModuleId !== void 0));
|
|
521
|
+
}
|
|
522
|
+
function Ve(e, s, a) {
|
|
523
|
+
var l = e.displayName;
|
|
524
|
+
if (l)
|
|
525
|
+
return l;
|
|
526
|
+
var m = s.displayName || s.name || "";
|
|
527
|
+
return m !== "" ? a + "(" + m + ")" : a;
|
|
528
|
+
}
|
|
529
|
+
function oe(e) {
|
|
530
|
+
return e.displayName || "Context";
|
|
531
|
+
}
|
|
532
|
+
function k(e) {
|
|
533
|
+
if (e == null)
|
|
534
|
+
return null;
|
|
535
|
+
if (typeof e.tag == "number" && T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
536
|
+
return e.displayName || e.name || null;
|
|
537
|
+
if (typeof e == "string")
|
|
538
|
+
return e;
|
|
539
|
+
switch (e) {
|
|
540
|
+
case n:
|
|
541
|
+
return "Fragment";
|
|
542
|
+
case r:
|
|
543
|
+
return "Portal";
|
|
544
|
+
case d:
|
|
545
|
+
return "Profiler";
|
|
546
|
+
case i:
|
|
547
|
+
return "StrictMode";
|
|
548
|
+
case w:
|
|
549
|
+
return "Suspense";
|
|
550
|
+
case y:
|
|
551
|
+
return "SuspenseList";
|
|
552
|
+
}
|
|
553
|
+
if (typeof e == "object")
|
|
554
|
+
switch (e.$$typeof) {
|
|
555
|
+
case o:
|
|
556
|
+
var s = e;
|
|
557
|
+
return oe(s) + ".Consumer";
|
|
558
|
+
case c:
|
|
559
|
+
var a = e;
|
|
560
|
+
return oe(a._context) + ".Provider";
|
|
561
|
+
case f:
|
|
562
|
+
return Ve(e, e.render, "ForwardRef");
|
|
563
|
+
case R:
|
|
564
|
+
var l = e.displayName || null;
|
|
565
|
+
return l !== null ? l : k(e.type) || "Memo";
|
|
566
|
+
case O: {
|
|
567
|
+
var m = e, g = m._payload, v = m._init;
|
|
568
|
+
try {
|
|
569
|
+
return k(v(g));
|
|
570
|
+
} catch {
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
var P = Object.assign, I = 0, ce, le, ue, fe, de, he, pe;
|
|
578
|
+
function ve() {
|
|
579
|
+
}
|
|
580
|
+
ve.__reactDisabledLog = !0;
|
|
581
|
+
function Be() {
|
|
582
|
+
{
|
|
583
|
+
if (I === 0) {
|
|
584
|
+
ce = console.log, le = console.info, ue = console.warn, fe = console.error, de = console.group, he = console.groupCollapsed, pe = console.groupEnd;
|
|
585
|
+
var e = {
|
|
586
|
+
configurable: !0,
|
|
587
|
+
enumerable: !0,
|
|
588
|
+
value: ve,
|
|
589
|
+
writable: !0
|
|
590
|
+
};
|
|
591
|
+
Object.defineProperties(console, {
|
|
592
|
+
info: e,
|
|
593
|
+
log: e,
|
|
594
|
+
warn: e,
|
|
595
|
+
error: e,
|
|
596
|
+
group: e,
|
|
597
|
+
groupCollapsed: e,
|
|
598
|
+
groupEnd: e
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
I++;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
function qe() {
|
|
605
|
+
{
|
|
606
|
+
if (I--, I === 0) {
|
|
607
|
+
var e = {
|
|
608
|
+
configurable: !0,
|
|
609
|
+
enumerable: !0,
|
|
610
|
+
writable: !0
|
|
611
|
+
};
|
|
612
|
+
Object.defineProperties(console, {
|
|
613
|
+
log: P({}, e, {
|
|
614
|
+
value: ce
|
|
615
|
+
}),
|
|
616
|
+
info: P({}, e, {
|
|
617
|
+
value: le
|
|
618
|
+
}),
|
|
619
|
+
warn: P({}, e, {
|
|
620
|
+
value: ue
|
|
621
|
+
}),
|
|
622
|
+
error: P({}, e, {
|
|
623
|
+
value: fe
|
|
624
|
+
}),
|
|
625
|
+
group: P({}, e, {
|
|
626
|
+
value: de
|
|
627
|
+
}),
|
|
628
|
+
groupCollapsed: P({}, e, {
|
|
629
|
+
value: he
|
|
630
|
+
}),
|
|
631
|
+
groupEnd: P({}, e, {
|
|
632
|
+
value: pe
|
|
633
|
+
})
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
I < 0 && T("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
var G = j.ReactCurrentDispatcher, H;
|
|
640
|
+
function V(e, s, a) {
|
|
641
|
+
{
|
|
642
|
+
if (H === void 0)
|
|
643
|
+
try {
|
|
644
|
+
throw Error();
|
|
645
|
+
} catch (m) {
|
|
646
|
+
var l = m.stack.trim().match(/\n( *(at )?)/);
|
|
647
|
+
H = l && l[1] || "";
|
|
648
|
+
}
|
|
649
|
+
return `
|
|
650
|
+
` + H + e;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
var X = !1, B;
|
|
654
|
+
{
|
|
655
|
+
var Je = typeof WeakMap == "function" ? WeakMap : Map;
|
|
656
|
+
B = new Je();
|
|
657
|
+
}
|
|
658
|
+
function me(e, s) {
|
|
659
|
+
if (!e || X)
|
|
660
|
+
return "";
|
|
661
|
+
{
|
|
662
|
+
var a = B.get(e);
|
|
663
|
+
if (a !== void 0)
|
|
664
|
+
return a;
|
|
665
|
+
}
|
|
666
|
+
var l;
|
|
667
|
+
X = !0;
|
|
668
|
+
var m = Error.prepareStackTrace;
|
|
669
|
+
Error.prepareStackTrace = void 0;
|
|
670
|
+
var g;
|
|
671
|
+
g = G.current, G.current = null, Be();
|
|
672
|
+
try {
|
|
673
|
+
if (s) {
|
|
674
|
+
var v = function() {
|
|
675
|
+
throw Error();
|
|
676
|
+
};
|
|
677
|
+
if (Object.defineProperty(v.prototype, "props", {
|
|
678
|
+
set: function() {
|
|
679
|
+
throw Error();
|
|
680
|
+
}
|
|
681
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
|
682
|
+
try {
|
|
683
|
+
Reflect.construct(v, []);
|
|
684
|
+
} catch (S) {
|
|
685
|
+
l = S;
|
|
686
|
+
}
|
|
687
|
+
Reflect.construct(e, [], v);
|
|
688
|
+
} else {
|
|
689
|
+
try {
|
|
690
|
+
v.call();
|
|
691
|
+
} catch (S) {
|
|
692
|
+
l = S;
|
|
693
|
+
}
|
|
694
|
+
e.call(v.prototype);
|
|
695
|
+
}
|
|
696
|
+
} else {
|
|
697
|
+
try {
|
|
698
|
+
throw Error();
|
|
699
|
+
} catch (S) {
|
|
700
|
+
l = S;
|
|
701
|
+
}
|
|
702
|
+
e();
|
|
703
|
+
}
|
|
704
|
+
} catch (S) {
|
|
705
|
+
if (S && l && typeof S.stack == "string") {
|
|
706
|
+
for (var p = S.stack.split(`
|
|
707
|
+
`), _ = l.stack.split(`
|
|
708
|
+
`), x = p.length - 1, E = _.length - 1; x >= 1 && E >= 0 && p[x] !== _[E]; )
|
|
709
|
+
E--;
|
|
710
|
+
for (; x >= 1 && E >= 0; x--, E--)
|
|
711
|
+
if (p[x] !== _[E]) {
|
|
712
|
+
if (x !== 1 || E !== 1)
|
|
713
|
+
do
|
|
714
|
+
if (x--, E--, E < 0 || p[x] !== _[E]) {
|
|
715
|
+
var C = `
|
|
716
|
+
` + p[x].replace(" at new ", " at ");
|
|
717
|
+
return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && B.set(e, C), C;
|
|
718
|
+
}
|
|
719
|
+
while (x >= 1 && E >= 0);
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
} finally {
|
|
724
|
+
X = !1, G.current = g, qe(), Error.prepareStackTrace = m;
|
|
725
|
+
}
|
|
726
|
+
var M = e ? e.displayName || e.name : "", D = M ? V(M) : "";
|
|
727
|
+
return typeof e == "function" && B.set(e, D), D;
|
|
728
|
+
}
|
|
729
|
+
function ze(e, s, a) {
|
|
730
|
+
return me(e, !1);
|
|
731
|
+
}
|
|
732
|
+
function Ge(e) {
|
|
733
|
+
var s = e.prototype;
|
|
734
|
+
return !!(s && s.isReactComponent);
|
|
735
|
+
}
|
|
736
|
+
function q(e, s, a) {
|
|
737
|
+
if (e == null)
|
|
738
|
+
return "";
|
|
739
|
+
if (typeof e == "function")
|
|
740
|
+
return me(e, Ge(e));
|
|
741
|
+
if (typeof e == "string")
|
|
742
|
+
return V(e);
|
|
743
|
+
switch (e) {
|
|
744
|
+
case w:
|
|
745
|
+
return V("Suspense");
|
|
746
|
+
case y:
|
|
747
|
+
return V("SuspenseList");
|
|
748
|
+
}
|
|
749
|
+
if (typeof e == "object")
|
|
750
|
+
switch (e.$$typeof) {
|
|
751
|
+
case f:
|
|
752
|
+
return ze(e.render);
|
|
753
|
+
case R:
|
|
754
|
+
return q(e.type, s, a);
|
|
755
|
+
case O: {
|
|
756
|
+
var l = e, m = l._payload, g = l._init;
|
|
757
|
+
try {
|
|
758
|
+
return q(g(m), s, a);
|
|
759
|
+
} catch {
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return "";
|
|
764
|
+
}
|
|
765
|
+
var W = Object.prototype.hasOwnProperty, ge = {}, ye = j.ReactDebugCurrentFrame;
|
|
766
|
+
function J(e) {
|
|
767
|
+
if (e) {
|
|
768
|
+
var s = e._owner, a = q(e.type, e._source, s ? s.type : null);
|
|
769
|
+
ye.setExtraStackFrame(a);
|
|
770
|
+
} else
|
|
771
|
+
ye.setExtraStackFrame(null);
|
|
772
|
+
}
|
|
773
|
+
function He(e, s, a, l, m) {
|
|
774
|
+
{
|
|
775
|
+
var g = Function.call.bind(W);
|
|
776
|
+
for (var v in e)
|
|
777
|
+
if (g(e, v)) {
|
|
778
|
+
var p = void 0;
|
|
779
|
+
try {
|
|
780
|
+
if (typeof e[v] != "function") {
|
|
781
|
+
var _ = Error((l || "React class") + ": " + a + " type `" + v + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[v] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
782
|
+
throw _.name = "Invariant Violation", _;
|
|
783
|
+
}
|
|
784
|
+
p = e[v](s, v, l, a, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
785
|
+
} catch (x) {
|
|
786
|
+
p = x;
|
|
787
|
+
}
|
|
788
|
+
p && !(p instanceof Error) && (J(m), T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", l || "React class", a, v, typeof p), J(null)), p instanceof Error && !(p.message in ge) && (ge[p.message] = !0, J(m), T("Failed %s type: %s", a, p.message), J(null));
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
var Xe = Array.isArray;
|
|
793
|
+
function Z(e) {
|
|
794
|
+
return Xe(e);
|
|
795
|
+
}
|
|
796
|
+
function Ze(e) {
|
|
797
|
+
{
|
|
798
|
+
var s = typeof Symbol == "function" && Symbol.toStringTag, a = s && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
799
|
+
return a;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function Qe(e) {
|
|
803
|
+
try {
|
|
804
|
+
return we(e), !1;
|
|
805
|
+
} catch {
|
|
806
|
+
return !0;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
function we(e) {
|
|
810
|
+
return "" + e;
|
|
811
|
+
}
|
|
812
|
+
function be(e) {
|
|
813
|
+
if (Qe(e))
|
|
814
|
+
return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ze(e)), we(e);
|
|
815
|
+
}
|
|
816
|
+
var $ = j.ReactCurrentOwner, et = {
|
|
817
|
+
key: !0,
|
|
818
|
+
ref: !0,
|
|
819
|
+
__self: !0,
|
|
820
|
+
__source: !0
|
|
821
|
+
}, xe, Ee, Q;
|
|
822
|
+
Q = {};
|
|
823
|
+
function tt(e) {
|
|
824
|
+
if (W.call(e, "ref")) {
|
|
825
|
+
var s = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
826
|
+
if (s && s.isReactWarning)
|
|
827
|
+
return !1;
|
|
828
|
+
}
|
|
829
|
+
return e.ref !== void 0;
|
|
830
|
+
}
|
|
831
|
+
function rt(e) {
|
|
832
|
+
if (W.call(e, "key")) {
|
|
833
|
+
var s = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
834
|
+
if (s && s.isReactWarning)
|
|
835
|
+
return !1;
|
|
836
|
+
}
|
|
837
|
+
return e.key !== void 0;
|
|
838
|
+
}
|
|
839
|
+
function nt(e, s) {
|
|
840
|
+
if (typeof e.ref == "string" && $.current && s && $.current.stateNode !== s) {
|
|
841
|
+
var a = k($.current.type);
|
|
842
|
+
Q[a] || (T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', k($.current.type), e.ref), Q[a] = !0);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
function st(e, s) {
|
|
846
|
+
{
|
|
847
|
+
var a = function() {
|
|
848
|
+
xe || (xe = !0, T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", s));
|
|
849
|
+
};
|
|
850
|
+
a.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
851
|
+
get: a,
|
|
852
|
+
configurable: !0
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function at(e, s) {
|
|
857
|
+
{
|
|
858
|
+
var a = function() {
|
|
859
|
+
Ee || (Ee = !0, T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", s));
|
|
860
|
+
};
|
|
861
|
+
a.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
862
|
+
get: a,
|
|
863
|
+
configurable: !0
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
var it = function(e, s, a, l, m, g, v) {
|
|
868
|
+
var p = {
|
|
869
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
870
|
+
$$typeof: t,
|
|
871
|
+
// Built-in properties that belong on the element
|
|
872
|
+
type: e,
|
|
873
|
+
key: s,
|
|
874
|
+
ref: a,
|
|
875
|
+
props: v,
|
|
876
|
+
// Record the component responsible for creating this element.
|
|
877
|
+
_owner: g
|
|
878
|
+
};
|
|
879
|
+
return p._store = {}, Object.defineProperty(p._store, "validated", {
|
|
880
|
+
configurable: !1,
|
|
881
|
+
enumerable: !1,
|
|
882
|
+
writable: !0,
|
|
883
|
+
value: !1
|
|
884
|
+
}), Object.defineProperty(p, "_self", {
|
|
885
|
+
configurable: !1,
|
|
886
|
+
enumerable: !1,
|
|
887
|
+
writable: !1,
|
|
888
|
+
value: l
|
|
889
|
+
}), Object.defineProperty(p, "_source", {
|
|
890
|
+
configurable: !1,
|
|
891
|
+
enumerable: !1,
|
|
892
|
+
writable: !1,
|
|
893
|
+
value: m
|
|
894
|
+
}), Object.freeze && (Object.freeze(p.props), Object.freeze(p)), p;
|
|
895
|
+
};
|
|
896
|
+
function ot(e, s, a, l, m) {
|
|
897
|
+
{
|
|
898
|
+
var g, v = {}, p = null, _ = null;
|
|
899
|
+
a !== void 0 && (be(a), p = "" + a), rt(s) && (be(s.key), p = "" + s.key), tt(s) && (_ = s.ref, nt(s, m));
|
|
900
|
+
for (g in s)
|
|
901
|
+
W.call(s, g) && !et.hasOwnProperty(g) && (v[g] = s[g]);
|
|
902
|
+
if (e && e.defaultProps) {
|
|
903
|
+
var x = e.defaultProps;
|
|
904
|
+
for (g in x)
|
|
905
|
+
v[g] === void 0 && (v[g] = x[g]);
|
|
906
|
+
}
|
|
907
|
+
if (p || _) {
|
|
908
|
+
var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
909
|
+
p && st(v, E), _ && at(v, E);
|
|
910
|
+
}
|
|
911
|
+
return it(e, p, _, m, l, $.current, v);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
var ee = j.ReactCurrentOwner, Re = j.ReactDebugCurrentFrame;
|
|
915
|
+
function N(e) {
|
|
916
|
+
if (e) {
|
|
917
|
+
var s = e._owner, a = q(e.type, e._source, s ? s.type : null);
|
|
918
|
+
Re.setExtraStackFrame(a);
|
|
919
|
+
} else
|
|
920
|
+
Re.setExtraStackFrame(null);
|
|
921
|
+
}
|
|
922
|
+
var te;
|
|
923
|
+
te = !1;
|
|
924
|
+
function re(e) {
|
|
925
|
+
return typeof e == "object" && e !== null && e.$$typeof === t;
|
|
926
|
+
}
|
|
927
|
+
function Te() {
|
|
928
|
+
{
|
|
929
|
+
if (ee.current) {
|
|
930
|
+
var e = k(ee.current.type);
|
|
931
|
+
if (e)
|
|
932
|
+
return `
|
|
933
|
+
|
|
934
|
+
Check the render method of \`` + e + "`.";
|
|
935
|
+
}
|
|
936
|
+
return "";
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function ct(e) {
|
|
940
|
+
{
|
|
941
|
+
if (e !== void 0) {
|
|
942
|
+
var s = e.fileName.replace(/^.*[\\\/]/, ""), a = e.lineNumber;
|
|
943
|
+
return `
|
|
944
|
+
|
|
945
|
+
Check your code at ` + s + ":" + a + ".";
|
|
946
|
+
}
|
|
947
|
+
return "";
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
var _e = {};
|
|
951
|
+
function lt(e) {
|
|
952
|
+
{
|
|
953
|
+
var s = Te();
|
|
954
|
+
if (!s) {
|
|
955
|
+
var a = typeof e == "string" ? e : e.displayName || e.name;
|
|
956
|
+
a && (s = `
|
|
957
|
+
|
|
958
|
+
Check the top-level render call using <` + a + ">.");
|
|
959
|
+
}
|
|
960
|
+
return s;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
function Se(e, s) {
|
|
964
|
+
{
|
|
965
|
+
if (!e._store || e._store.validated || e.key != null)
|
|
966
|
+
return;
|
|
967
|
+
e._store.validated = !0;
|
|
968
|
+
var a = lt(s);
|
|
969
|
+
if (_e[a])
|
|
970
|
+
return;
|
|
971
|
+
_e[a] = !0;
|
|
972
|
+
var l = "";
|
|
973
|
+
e && e._owner && e._owner !== ee.current && (l = " It was passed a child from " + k(e._owner.type) + "."), N(e), T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', a, l), N(null);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function Ce(e, s) {
|
|
977
|
+
{
|
|
978
|
+
if (typeof e != "object")
|
|
979
|
+
return;
|
|
980
|
+
if (Z(e))
|
|
981
|
+
for (var a = 0; a < e.length; a++) {
|
|
982
|
+
var l = e[a];
|
|
983
|
+
re(l) && Se(l, s);
|
|
984
|
+
}
|
|
985
|
+
else if (re(e))
|
|
986
|
+
e._store && (e._store.validated = !0);
|
|
987
|
+
else if (e) {
|
|
988
|
+
var m = Fe(e);
|
|
989
|
+
if (typeof m == "function" && m !== e.entries)
|
|
990
|
+
for (var g = m.call(e), v; !(v = g.next()).done; )
|
|
991
|
+
re(v.value) && Se(v.value, s);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
function ut(e) {
|
|
996
|
+
{
|
|
997
|
+
var s = e.type;
|
|
998
|
+
if (s == null || typeof s == "string")
|
|
999
|
+
return;
|
|
1000
|
+
var a;
|
|
1001
|
+
if (typeof s == "function")
|
|
1002
|
+
a = s.propTypes;
|
|
1003
|
+
else if (typeof s == "object" && (s.$$typeof === f || // Note: Memo only checks outer props here.
|
|
1004
|
+
// Inner props are checked in the reconciler.
|
|
1005
|
+
s.$$typeof === R))
|
|
1006
|
+
a = s.propTypes;
|
|
1007
|
+
else
|
|
1008
|
+
return;
|
|
1009
|
+
if (a) {
|
|
1010
|
+
var l = k(s);
|
|
1011
|
+
He(a, e.props, "prop", l, e);
|
|
1012
|
+
} else if (s.PropTypes !== void 0 && !te) {
|
|
1013
|
+
te = !0;
|
|
1014
|
+
var m = k(s);
|
|
1015
|
+
T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", m || "Unknown");
|
|
1016
|
+
}
|
|
1017
|
+
typeof s.getDefaultProps == "function" && !s.getDefaultProps.isReactClassApproved && T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function ft(e) {
|
|
1021
|
+
{
|
|
1022
|
+
for (var s = Object.keys(e.props), a = 0; a < s.length; a++) {
|
|
1023
|
+
var l = s[a];
|
|
1024
|
+
if (l !== "children" && l !== "key") {
|
|
1025
|
+
N(e), T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", l), N(null);
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
e.ref !== null && (N(e), T("Invalid attribute `ref` supplied to `React.Fragment`."), N(null));
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
var ke = {};
|
|
1033
|
+
function Oe(e, s, a, l, m, g) {
|
|
1034
|
+
{
|
|
1035
|
+
var v = Ue(e);
|
|
1036
|
+
if (!v) {
|
|
1037
|
+
var p = "";
|
|
1038
|
+
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (p += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
1039
|
+
var _ = ct(m);
|
|
1040
|
+
_ ? p += _ : p += Te();
|
|
1041
|
+
var x;
|
|
1042
|
+
e === null ? x = "null" : Z(e) ? x = "array" : e !== void 0 && e.$$typeof === t ? (x = "<" + (k(e.type) || "Unknown") + " />", p = " Did you accidentally export a JSX literal instead of a component?") : x = typeof e, T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", x, p);
|
|
1043
|
+
}
|
|
1044
|
+
var E = ot(e, s, a, m, g);
|
|
1045
|
+
if (E == null)
|
|
1046
|
+
return E;
|
|
1047
|
+
if (v) {
|
|
1048
|
+
var C = s.children;
|
|
1049
|
+
if (C !== void 0)
|
|
1050
|
+
if (l)
|
|
1051
|
+
if (Z(C)) {
|
|
1052
|
+
for (var M = 0; M < C.length; M++)
|
|
1053
|
+
Ce(C[M], e);
|
|
1054
|
+
Object.freeze && Object.freeze(C);
|
|
1055
|
+
} else
|
|
1056
|
+
T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
1057
|
+
else
|
|
1058
|
+
Ce(C, e);
|
|
1059
|
+
}
|
|
1060
|
+
if (W.call(s, "key")) {
|
|
1061
|
+
var D = k(e), S = Object.keys(s).filter(function(gt) {
|
|
1062
|
+
return gt !== "key";
|
|
1063
|
+
}), ne = S.length > 0 ? "{key: someKey, " + S.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
1064
|
+
if (!ke[D + ne]) {
|
|
1065
|
+
var mt = S.length > 0 ? "{" + S.join(": ..., ") + ": ...}" : "{}";
|
|
1066
|
+
T(`A props object containing a "key" prop is being spread into JSX:
|
|
1067
|
+
let props = %s;
|
|
1068
|
+
<%s {...props} />
|
|
1069
|
+
React keys must be passed directly to JSX without using spread:
|
|
1070
|
+
let props = %s;
|
|
1071
|
+
<%s key={someKey} {...props} />`, ne, D, mt, D), ke[D + ne] = !0;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return e === n ? ft(E) : ut(E), E;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function dt(e, s, a) {
|
|
1078
|
+
return Oe(e, s, a, !0);
|
|
1079
|
+
}
|
|
1080
|
+
function ht(e, s, a) {
|
|
1081
|
+
return Oe(e, s, a, !1);
|
|
1082
|
+
}
|
|
1083
|
+
var pt = ht, vt = dt;
|
|
1084
|
+
Y.Fragment = n, Y.jsx = pt, Y.jsxs = vt;
|
|
1085
|
+
}()), Y;
|
|
1086
|
+
}
|
|
1087
|
+
process.env.NODE_ENV === "production" ? se.exports = Mt() : se.exports = At();
|
|
1088
|
+
var A = se.exports;
|
|
1089
|
+
const Yt = ({ editor: u }) => {
|
|
1090
|
+
const t = bt(null);
|
|
1091
|
+
return Me(() => {
|
|
1092
|
+
if (!u || !t.current)
|
|
1093
|
+
return;
|
|
1094
|
+
const r = new Nt(t.current, u);
|
|
1095
|
+
return () => {
|
|
1096
|
+
r.destroy();
|
|
1097
|
+
};
|
|
1098
|
+
}, [u]), /* @__PURE__ */ A.jsx("div", { ref: t });
|
|
1099
|
+
};
|
|
1100
|
+
function Ft(u) {
|
|
1101
|
+
const t = [];
|
|
1102
|
+
function r(n, i) {
|
|
1103
|
+
n.type.name === "heading" && t.push({
|
|
1104
|
+
id: `${i.join("-")}-${n.attrs.level}`,
|
|
1105
|
+
level: n.attrs.level,
|
|
1106
|
+
text: n.content.map((d) => d.text).join("") || "Untitled Heading",
|
|
1107
|
+
path: i
|
|
1108
|
+
}), n.content.forEach((d, c) => {
|
|
1109
|
+
r(d, [...i, c]);
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
return r(u, []), t;
|
|
1113
|
+
}
|
|
1114
|
+
function It(u) {
|
|
1115
|
+
const [t, r] = Ne([]);
|
|
1116
|
+
return Me(() => {
|
|
1117
|
+
if (!u)
|
|
1118
|
+
return;
|
|
1119
|
+
const n = () => {
|
|
1120
|
+
const d = Ft(u.state.doc);
|
|
1121
|
+
r(d);
|
|
1122
|
+
};
|
|
1123
|
+
n();
|
|
1124
|
+
const i = u.subscribe(n);
|
|
1125
|
+
return () => i();
|
|
1126
|
+
}, [u]), t;
|
|
1127
|
+
}
|
|
1128
|
+
const Kt = ({ editor: u }) => {
|
|
1129
|
+
const t = It(u);
|
|
1130
|
+
if (!u)
|
|
1131
|
+
return null;
|
|
1132
|
+
const r = (n) => {
|
|
1133
|
+
const i = F.createCursor(n, 0), d = u.createTransaction().setSelection(i);
|
|
1134
|
+
u.dispatch(d);
|
|
1135
|
+
};
|
|
1136
|
+
return /* @__PURE__ */ A.jsxs("div", { style: { padding: "1rem", border: "1px solid #eee", background: "#fcfcfc" }, children: [
|
|
1137
|
+
/* @__PURE__ */ A.jsx("h3", { style: { marginTop: 0 }, children: "Navigator" }),
|
|
1138
|
+
t.length === 0 && /* @__PURE__ */ A.jsx("p", { style: { color: "#999" }, children: "No headings yet." }),
|
|
1139
|
+
/* @__PURE__ */ A.jsx("ul", { children: t.map((n) => /* @__PURE__ */ A.jsx(
|
|
1140
|
+
"li",
|
|
1141
|
+
{
|
|
1142
|
+
onClick: () => r(n.path),
|
|
1143
|
+
style: { listStyle: "none", paddingLeft: `${(n.level - 1) * 20}px`, cursor: "pointer", marginBottom: "0.5rem" },
|
|
1144
|
+
children: n.text
|
|
1145
|
+
},
|
|
1146
|
+
n.id
|
|
1147
|
+
)) })
|
|
1148
|
+
] });
|
|
1149
|
+
};
|
|
1150
|
+
export {
|
|
1151
|
+
St as A,
|
|
1152
|
+
z as E,
|
|
1153
|
+
Yt as F,
|
|
1154
|
+
Et as M,
|
|
1155
|
+
b as N,
|
|
1156
|
+
Tt as R,
|
|
1157
|
+
K as S,
|
|
1158
|
+
Ot as T,
|
|
1159
|
+
xt as a,
|
|
1160
|
+
Rt as b,
|
|
1161
|
+
_t as c,
|
|
1162
|
+
Ct as d,
|
|
1163
|
+
kt as e,
|
|
1164
|
+
Pt as f,
|
|
1165
|
+
F as g,
|
|
1166
|
+
Dt as h,
|
|
1167
|
+
jt as i,
|
|
1168
|
+
Nt as j,
|
|
1169
|
+
It as k,
|
|
1170
|
+
Kt as l,
|
|
1171
|
+
Lt as u
|
|
1172
|
+
};
|