@dooherceg/tiptap-controlled-editor-with-table 0.0.11 → 0.0.12
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.
|
@@ -10,4 +10,4 @@ export interface SimpleEditorProps extends Omit<Partial<EditorOptions>, "content
|
|
|
10
10
|
export interface SimpleEditorRef {
|
|
11
11
|
getEditor: () => Editor | null;
|
|
12
12
|
}
|
|
13
|
-
export declare function SimpleEditor({ themeMode, content, onContentChange, placeholder, ref, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
export declare function SimpleEditor({ themeMode, content, onContentChange, placeholder, ref, autofocus, onFocus, onBlur, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as p, jsxs as w, Fragment as at } from "react/jsx-runtime";
|
|
2
2
|
import { useEditor as Ct, EditorContext as Lt, EditorContent as wt } from "@tiptap/react";
|
|
3
3
|
import { useState as vt, useRef as q, useEffect as D, useImperativeHandle as Mt } from "react";
|
|
4
|
-
import { Mark as Q, markPasteRule as xt, markInputRule as At, mergeAttributes as
|
|
4
|
+
import { Mark as Q, markPasteRule as xt, markInputRule as At, mergeAttributes as T, Node as L, nodeInputRule as It, ResizableNodeView as St, wrappingInputRule as S, renderNestedMarkdownContent as lt, Extension as C, parseIndentedBlocks as F, isNodeActive as _, isAtStartOfNode as Ht, isAtEndOfNode as Et, getNodeType as ut, getNodeAtPosition as $t, textInputRule as y, callOrReturn as dt, getExtensionField as ct, isNodeEmpty as Nt, isNodeSelection as Rt, findParentNodeClosestToPos as Pt } from "@tiptap/core";
|
|
5
5
|
import { Plugin as H, PluginKey as E, TextSelection as Bt } from "prosemirror-state";
|
|
6
6
|
import { dropCursor as Ot } from "prosemirror-dropcursor";
|
|
7
7
|
import { DecorationSet as B, Decoration as K } from "prosemirror-view";
|
|
@@ -83,7 +83,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
|
|
|
83
83
|
];
|
|
84
84
|
},
|
|
85
85
|
renderHTML({ HTMLAttributes: t }) {
|
|
86
|
-
return ["mark",
|
|
86
|
+
return ["mark", T(this.options.HTMLAttributes, t), 0];
|
|
87
87
|
},
|
|
88
88
|
renderMarkdown: (t, e) => `==${e.renderChildren(t)}==`,
|
|
89
89
|
parseMarkdown: (t, e) => e.applyMark("highlight", e.parseInline(t.tokens || [])),
|
|
@@ -176,7 +176,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
|
|
|
176
176
|
];
|
|
177
177
|
},
|
|
178
178
|
renderHTML({ HTMLAttributes: t }) {
|
|
179
|
-
return ["img",
|
|
179
|
+
return ["img", T(this.options.HTMLAttributes, t)];
|
|
180
180
|
},
|
|
181
181
|
parseMarkdown: (t, e) => e.createNode("image", {
|
|
182
182
|
src: t.href,
|
|
@@ -194,14 +194,14 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
|
|
|
194
194
|
const { directions: t, minWidth: e, minHeight: r, alwaysPreserveAspectRatio: n } = this.options.resize;
|
|
195
195
|
return ({ node: s, getPos: i, HTMLAttributes: a }) => {
|
|
196
196
|
const o = document.createElement("img");
|
|
197
|
-
Object.entries(a).forEach(([
|
|
198
|
-
if (
|
|
199
|
-
switch (
|
|
197
|
+
Object.entries(a).forEach(([u, d]) => {
|
|
198
|
+
if (d != null)
|
|
199
|
+
switch (u) {
|
|
200
200
|
case "width":
|
|
201
201
|
case "height":
|
|
202
202
|
break;
|
|
203
203
|
default:
|
|
204
|
-
o.setAttribute(
|
|
204
|
+
o.setAttribute(u, d);
|
|
205
205
|
break;
|
|
206
206
|
}
|
|
207
207
|
}), o.src = a.src;
|
|
@@ -209,17 +209,17 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
|
|
|
209
209
|
element: o,
|
|
210
210
|
node: s,
|
|
211
211
|
getPos: i,
|
|
212
|
-
onResize: (
|
|
213
|
-
o.style.width = `${
|
|
212
|
+
onResize: (u, d) => {
|
|
213
|
+
o.style.width = `${u}px`, o.style.height = `${d}px`;
|
|
214
214
|
},
|
|
215
|
-
onCommit: (
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
width:
|
|
219
|
-
height:
|
|
215
|
+
onCommit: (u, d) => {
|
|
216
|
+
const f = i();
|
|
217
|
+
f !== void 0 && this.editor.chain().setNodeSelection(f).updateAttributes(this.name, {
|
|
218
|
+
width: u,
|
|
219
|
+
height: d
|
|
220
220
|
}).run();
|
|
221
221
|
},
|
|
222
|
-
onUpdate: (
|
|
222
|
+
onUpdate: (u, d, f) => u.type === s.type,
|
|
223
223
|
options: {
|
|
224
224
|
directions: t,
|
|
225
225
|
min: {
|
|
@@ -275,7 +275,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
|
|
|
275
275
|
return [{ tag: "ul" }];
|
|
276
276
|
},
|
|
277
277
|
renderHTML({ HTMLAttributes: t }) {
|
|
278
|
-
return ["ul",
|
|
278
|
+
return ["ul", T(this.options.HTMLAttributes, t), 0];
|
|
279
279
|
},
|
|
280
280
|
markdownTokenName: "list",
|
|
281
281
|
parseMarkdown: (t, e) => t.type !== "list" || t.ordered ? [] : {
|
|
@@ -330,7 +330,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
|
|
|
330
330
|
];
|
|
331
331
|
},
|
|
332
332
|
renderHTML({ HTMLAttributes: t }) {
|
|
333
|
-
return ["li",
|
|
333
|
+
return ["li", T(this.options.HTMLAttributes, t), 0];
|
|
334
334
|
},
|
|
335
335
|
markdownTokenName: "list_item",
|
|
336
336
|
parseMarkdown: (t, e) => {
|
|
@@ -425,14 +425,14 @@ var $ = (t, e) => {
|
|
|
425
425
|
return !1;
|
|
426
426
|
if (!_(t.state, e) && ht(t.state, e, r)) {
|
|
427
427
|
const { $anchor: o } = t.state.selection, c = t.state.doc.resolve(o.before() - 1), l = [];
|
|
428
|
-
c.node().descendants((
|
|
429
|
-
|
|
428
|
+
c.node().descendants((f, b) => {
|
|
429
|
+
f.type.name === e && l.push({ node: f, pos: b });
|
|
430
430
|
});
|
|
431
|
-
const
|
|
432
|
-
if (!
|
|
431
|
+
const u = l.at(-1);
|
|
432
|
+
if (!u)
|
|
433
433
|
return !1;
|
|
434
|
-
const
|
|
435
|
-
return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 },
|
|
434
|
+
const d = t.state.doc.resolve(c.start() + u.pos + 1);
|
|
435
|
+
return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 }, d.end()).joinForward().run();
|
|
436
436
|
}
|
|
437
437
|
if (!_(t.state, e) || !Ht(t.state))
|
|
438
438
|
return !1;
|
|
@@ -509,28 +509,28 @@ function ze(t) {
|
|
|
509
509
|
if (!i)
|
|
510
510
|
break;
|
|
511
511
|
const [, a, o, c] = i, l = a.length;
|
|
512
|
-
let
|
|
513
|
-
const
|
|
514
|
-
for (;
|
|
515
|
-
const
|
|
516
|
-
if (
|
|
512
|
+
let u = c, d = r + 1;
|
|
513
|
+
const f = [s];
|
|
514
|
+
for (; d < t.length; ) {
|
|
515
|
+
const b = t[d];
|
|
516
|
+
if (b.match(et))
|
|
517
517
|
break;
|
|
518
|
-
if (
|
|
519
|
-
|
|
520
|
-
`,
|
|
521
|
-
else if (
|
|
522
|
-
|
|
523
|
-
${
|
|
518
|
+
if (b.trim() === "")
|
|
519
|
+
f.push(b), u += `
|
|
520
|
+
`, d += 1;
|
|
521
|
+
else if (b.match(_e))
|
|
522
|
+
f.push(b), u += `
|
|
523
|
+
${b.slice(l + 2)}`, d += 1;
|
|
524
524
|
else
|
|
525
525
|
break;
|
|
526
526
|
}
|
|
527
527
|
e.push({
|
|
528
528
|
indent: l,
|
|
529
529
|
number: parseInt(o, 10),
|
|
530
|
-
content:
|
|
531
|
-
raw:
|
|
530
|
+
content: u.trim(),
|
|
531
|
+
raw: f.join(`
|
|
532
532
|
`)
|
|
533
|
-
}), n =
|
|
533
|
+
}), n = d, r = d;
|
|
534
534
|
}
|
|
535
535
|
return [e, n];
|
|
536
536
|
}
|
|
@@ -548,24 +548,24 @@ function yt(t, e, r) {
|
|
|
548
548
|
raw: c,
|
|
549
549
|
tokens: r.inlineTokens(c)
|
|
550
550
|
});
|
|
551
|
-
const
|
|
551
|
+
const u = o.slice(1).join(`
|
|
552
552
|
`).trim();
|
|
553
|
-
if (
|
|
554
|
-
const
|
|
555
|
-
l.push(...
|
|
553
|
+
if (u) {
|
|
554
|
+
const b = r.blockTokens(u);
|
|
555
|
+
l.push(...b);
|
|
556
556
|
}
|
|
557
|
-
let
|
|
558
|
-
const
|
|
559
|
-
for (;
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
const
|
|
557
|
+
let d = i + 1;
|
|
558
|
+
const f = [];
|
|
559
|
+
for (; d < t.length && t[d].indent > e; )
|
|
560
|
+
f.push(t[d]), d += 1;
|
|
561
|
+
if (f.length > 0) {
|
|
562
|
+
const b = Math.min(...f.map((g) => g.indent)), h = yt(f, b, r);
|
|
563
563
|
l.push({
|
|
564
564
|
type: "list",
|
|
565
565
|
ordered: !0,
|
|
566
|
-
start:
|
|
567
|
-
items:
|
|
568
|
-
raw:
|
|
566
|
+
start: f[0].number,
|
|
567
|
+
items: h,
|
|
568
|
+
raw: f.map((g) => g.raw).join(`
|
|
569
569
|
`)
|
|
570
570
|
});
|
|
571
571
|
}
|
|
@@ -573,7 +573,7 @@ function yt(t, e, r) {
|
|
|
573
573
|
type: "list_item",
|
|
574
574
|
raw: a.raw,
|
|
575
575
|
tokens: l
|
|
576
|
-
}), i =
|
|
576
|
+
}), i = d;
|
|
577
577
|
} else
|
|
578
578
|
i += 1;
|
|
579
579
|
}
|
|
@@ -638,7 +638,7 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
|
|
|
638
638
|
},
|
|
639
639
|
renderHTML({ HTMLAttributes: t }) {
|
|
640
640
|
const { start: e, ...r } = t;
|
|
641
|
-
return e === 1 ? ["ol",
|
|
641
|
+
return e === 1 ? ["ol", T(this.options.HTMLAttributes, r), 0] : ["ol", T(this.options.HTMLAttributes, t), 0];
|
|
642
642
|
},
|
|
643
643
|
markdownTokenName: "list",
|
|
644
644
|
parseMarkdown: (t, e) => {
|
|
@@ -750,7 +750,7 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
|
|
|
750
750
|
renderHTML({ node: t, HTMLAttributes: e }) {
|
|
751
751
|
return [
|
|
752
752
|
"li",
|
|
753
|
-
|
|
753
|
+
T(this.options.HTMLAttributes, e, {
|
|
754
754
|
"data-type": this.name
|
|
755
755
|
}),
|
|
756
756
|
[
|
|
@@ -792,34 +792,34 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
|
|
|
792
792
|
},
|
|
793
793
|
addNodeView() {
|
|
794
794
|
return ({ node: t, HTMLAttributes: e, getPos: r, editor: n }) => {
|
|
795
|
-
const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (
|
|
796
|
-
var
|
|
797
|
-
o.ariaLabel = ((
|
|
795
|
+
const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (u) => {
|
|
796
|
+
var d, f;
|
|
797
|
+
o.ariaLabel = ((f = (d = this.options.a11y) == null ? void 0 : d.checkboxLabel) == null ? void 0 : f.call(d, u, o.checked)) || `Task item checkbox for ${u.textContent || "empty task item"}`;
|
|
798
798
|
};
|
|
799
|
-
return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (
|
|
799
|
+
return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (u) => u.preventDefault()), o.addEventListener("change", (u) => {
|
|
800
800
|
if (!n.isEditable && !this.options.onReadOnlyChecked) {
|
|
801
801
|
o.checked = !o.checked;
|
|
802
802
|
return;
|
|
803
803
|
}
|
|
804
|
-
const { checked:
|
|
805
|
-
n.isEditable && typeof r == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr:
|
|
806
|
-
const
|
|
807
|
-
if (typeof
|
|
804
|
+
const { checked: d } = u.target;
|
|
805
|
+
n.isEditable && typeof r == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: f }) => {
|
|
806
|
+
const b = r();
|
|
807
|
+
if (typeof b != "number")
|
|
808
808
|
return !1;
|
|
809
|
-
const
|
|
810
|
-
return
|
|
811
|
-
...
|
|
812
|
-
checked:
|
|
809
|
+
const h = f.doc.nodeAt(b);
|
|
810
|
+
return f.setNodeMarkup(b, void 0, {
|
|
811
|
+
...h?.attrs,
|
|
812
|
+
checked: d
|
|
813
813
|
}), !0;
|
|
814
|
-
}).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t,
|
|
815
|
-
}), Object.entries(this.options.HTMLAttributes).forEach(([
|
|
816
|
-
s.setAttribute(
|
|
817
|
-
}), s.dataset.checked = t.attrs.checked, o.checked = t.attrs.checked, i.append(o, a), s.append(i, c), Object.entries(e).forEach(([
|
|
818
|
-
s.setAttribute(
|
|
814
|
+
}).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, d) || (o.checked = !o.checked));
|
|
815
|
+
}), Object.entries(this.options.HTMLAttributes).forEach(([u, d]) => {
|
|
816
|
+
s.setAttribute(u, d);
|
|
817
|
+
}), s.dataset.checked = t.attrs.checked, o.checked = t.attrs.checked, i.append(o, a), s.append(i, c), Object.entries(e).forEach(([u, d]) => {
|
|
818
|
+
s.setAttribute(u, d);
|
|
819
819
|
}), {
|
|
820
820
|
dom: s,
|
|
821
821
|
contentDOM: c,
|
|
822
|
-
update: (
|
|
822
|
+
update: (u) => u.type !== this.type ? !1 : (s.dataset.checked = u.attrs.checked, o.checked = u.attrs.checked, l(u), !0)
|
|
823
823
|
};
|
|
824
824
|
};
|
|
825
825
|
},
|
|
@@ -855,7 +855,7 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
|
|
|
855
855
|
];
|
|
856
856
|
},
|
|
857
857
|
renderHTML({ HTMLAttributes: t }) {
|
|
858
|
-
return ["ul",
|
|
858
|
+
return ["ul", T(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
|
|
859
859
|
},
|
|
860
860
|
parseMarkdown: (t, e) => e.createNode("taskList", {}, e.parseChildren(t.items || [])),
|
|
861
861
|
renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
|
|
@@ -975,7 +975,7 @@ var Ve = Q.create({
|
|
|
975
975
|
];
|
|
976
976
|
},
|
|
977
977
|
renderHTML({ HTMLAttributes: t }) {
|
|
978
|
-
return ["sub",
|
|
978
|
+
return ["sub", T(this.options.HTMLAttributes, t), 0];
|
|
979
979
|
},
|
|
980
980
|
addCommands() {
|
|
981
981
|
return {
|
|
@@ -1010,7 +1010,7 @@ var Ve = Q.create({
|
|
|
1010
1010
|
];
|
|
1011
1011
|
},
|
|
1012
1012
|
renderHTML({ HTMLAttributes: t }) {
|
|
1013
|
-
return ["sup",
|
|
1013
|
+
return ["sup", T(this.options.HTMLAttributes, t), 0];
|
|
1014
1014
|
},
|
|
1015
1015
|
addCommands() {
|
|
1016
1016
|
return {
|
|
@@ -1226,8 +1226,8 @@ C.create({
|
|
|
1226
1226
|
return !0;
|
|
1227
1227
|
if (s > n && i > n && i > s || !e.getMeta("paste"))
|
|
1228
1228
|
return !1;
|
|
1229
|
-
const o = e.selection.$head.pos, c = i - n, l = o - c,
|
|
1230
|
-
return e.deleteRange(l,
|
|
1229
|
+
const o = e.selection.$head.pos, c = i - n, l = o - c, u = o;
|
|
1230
|
+
return e.deleteRange(l, u), !(this.storage.characters({ node: e.doc }) > n);
|
|
1231
1231
|
}
|
|
1232
1232
|
})
|
|
1233
1233
|
];
|
|
@@ -1331,10 +1331,10 @@ var br = C.create({
|
|
|
1331
1331
|
return t.descendants((a, o) => {
|
|
1332
1332
|
const c = n >= o && n <= o + a.nodeSize, l = !a.isLeaf && Nt(a);
|
|
1333
1333
|
if ((c || !this.options.showOnlyCurrent) && l) {
|
|
1334
|
-
const
|
|
1335
|
-
i &&
|
|
1336
|
-
const
|
|
1337
|
-
class:
|
|
1334
|
+
const u = [this.options.emptyNodeClass];
|
|
1335
|
+
i && u.push(this.options.emptyEditorClass);
|
|
1336
|
+
const d = K.node(o, o + a.nodeSize, {
|
|
1337
|
+
class: u.join(" "),
|
|
1338
1338
|
"data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
|
|
1339
1339
|
editor: this.editor,
|
|
1340
1340
|
node: a,
|
|
@@ -1342,7 +1342,7 @@ var br = C.create({
|
|
|
1342
1342
|
hasAnchor: c
|
|
1343
1343
|
}) : this.options.placeholder
|
|
1344
1344
|
});
|
|
1345
|
-
s.push(
|
|
1345
|
+
s.push(d);
|
|
1346
1346
|
}
|
|
1347
1347
|
return this.options.includeChildren;
|
|
1348
1348
|
}), B.create(t, s);
|
|
@@ -1394,9 +1394,9 @@ C.create({
|
|
|
1394
1394
|
new H({
|
|
1395
1395
|
key: e,
|
|
1396
1396
|
appendTransaction: (s, i, a) => {
|
|
1397
|
-
const { doc: o, tr: c, schema: l } = a,
|
|
1398
|
-
if (
|
|
1399
|
-
return c.insert(
|
|
1397
|
+
const { doc: o, tr: c, schema: l } = a, u = e.getState(a), d = o.content.size, f = l.nodes[r];
|
|
1398
|
+
if (u)
|
|
1399
|
+
return c.insert(d, f.create());
|
|
1400
1400
|
},
|
|
1401
1401
|
state: {
|
|
1402
1402
|
init: (s, i) => {
|
|
@@ -1481,7 +1481,7 @@ var kr = L.create({
|
|
|
1481
1481
|
return [{ tag: "td" }];
|
|
1482
1482
|
},
|
|
1483
1483
|
renderHTML({ HTMLAttributes: t }) {
|
|
1484
|
-
return ["td",
|
|
1484
|
+
return ["td", T(this.options.HTMLAttributes, t), 0];
|
|
1485
1485
|
}
|
|
1486
1486
|
}), Tr = L.create({
|
|
1487
1487
|
name: "tableHeader",
|
|
@@ -1514,7 +1514,7 @@ var kr = L.create({
|
|
|
1514
1514
|
return [{ tag: "th" }];
|
|
1515
1515
|
},
|
|
1516
1516
|
renderHTML({ HTMLAttributes: t }) {
|
|
1517
|
-
return ["th",
|
|
1517
|
+
return ["th", T(this.options.HTMLAttributes, t), 0];
|
|
1518
1518
|
}
|
|
1519
1519
|
}), Cr = L.create({
|
|
1520
1520
|
name: "tableRow",
|
|
@@ -1529,7 +1529,7 @@ var kr = L.create({
|
|
|
1529
1529
|
return [{ tag: "tr" }];
|
|
1530
1530
|
},
|
|
1531
1531
|
renderHTML({ HTMLAttributes: t }) {
|
|
1532
|
-
return ["tr",
|
|
1532
|
+
return ["tr", T(this.options.HTMLAttributes, t), 0];
|
|
1533
1533
|
}
|
|
1534
1534
|
});
|
|
1535
1535
|
function j(t, e) {
|
|
@@ -1538,30 +1538,30 @@ function j(t, e) {
|
|
|
1538
1538
|
function it(t, e, r, n, s, i) {
|
|
1539
1539
|
var a;
|
|
1540
1540
|
let o = 0, c = !0, l = e.firstChild;
|
|
1541
|
-
const
|
|
1542
|
-
if (
|
|
1543
|
-
for (let
|
|
1544
|
-
const { colspan:
|
|
1545
|
-
for (let
|
|
1546
|
-
const
|
|
1547
|
-
if (o +=
|
|
1541
|
+
const u = t.firstChild;
|
|
1542
|
+
if (u !== null)
|
|
1543
|
+
for (let f = 0, b = 0; f < u.childCount; f += 1) {
|
|
1544
|
+
const { colspan: h, colwidth: g } = u.child(f).attrs;
|
|
1545
|
+
for (let m = 0; m < h; m += 1, b += 1) {
|
|
1546
|
+
const k = s === b ? i : g && g[m], v = k ? `${k}px` : "";
|
|
1547
|
+
if (o += k || n, k || (c = !1), l) {
|
|
1548
1548
|
if (l.style.width !== v) {
|
|
1549
|
-
const [I, N] = j(n,
|
|
1549
|
+
const [I, N] = j(n, k);
|
|
1550
1550
|
l.style.setProperty(I, N);
|
|
1551
1551
|
}
|
|
1552
1552
|
l = l.nextSibling;
|
|
1553
1553
|
} else {
|
|
1554
|
-
const I = document.createElement("col"), [N, O] = j(n,
|
|
1554
|
+
const I = document.createElement("col"), [N, O] = j(n, k);
|
|
1555
1555
|
I.style.setProperty(N, O), e.appendChild(I);
|
|
1556
1556
|
}
|
|
1557
1557
|
}
|
|
1558
1558
|
}
|
|
1559
1559
|
for (; l; ) {
|
|
1560
|
-
const
|
|
1561
|
-
(a = l.parentNode) == null || a.removeChild(l), l =
|
|
1560
|
+
const f = l.nextSibling;
|
|
1561
|
+
(a = l.parentNode) == null || a.removeChild(l), l = f;
|
|
1562
1562
|
}
|
|
1563
|
-
const
|
|
1564
|
-
c && !
|
|
1563
|
+
const d = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
|
|
1564
|
+
c && !d ? (r.style.width = `${o}px`, r.style.minWidth = "") : (r.style.width = "", r.style.minWidth = `${o}px`);
|
|
1565
1565
|
}
|
|
1566
1566
|
var Lr = class {
|
|
1567
1567
|
constructor(t, e) {
|
|
@@ -1580,13 +1580,13 @@ function wr(t, e, r, n) {
|
|
|
1580
1580
|
const a = [], o = t.firstChild;
|
|
1581
1581
|
if (!o)
|
|
1582
1582
|
return {};
|
|
1583
|
-
for (let
|
|
1584
|
-
const { colspan:
|
|
1585
|
-
for (let
|
|
1586
|
-
const
|
|
1587
|
-
s +=
|
|
1588
|
-
const [
|
|
1589
|
-
a.push(["col", { style: `${
|
|
1583
|
+
for (let d = 0, f = 0; d < o.childCount; d += 1) {
|
|
1584
|
+
const { colspan: b, colwidth: h } = o.child(d).attrs;
|
|
1585
|
+
for (let g = 0; g < b; g += 1, f += 1) {
|
|
1586
|
+
const m = r === f ? n : h && h[g];
|
|
1587
|
+
s += m || e, m || (i = !1);
|
|
1588
|
+
const [k, v] = j(e, m);
|
|
1589
|
+
a.push(["col", { style: `${k}: ${v}` }]);
|
|
1590
1590
|
}
|
|
1591
1591
|
}
|
|
1592
1592
|
const c = i ? `${s}px` : "", l = i ? "" : `${s}px`;
|
|
@@ -1607,10 +1607,10 @@ function vr(t) {
|
|
|
1607
1607
|
function Mr(t, e, r, n, s) {
|
|
1608
1608
|
const i = vr(t), a = [], o = [];
|
|
1609
1609
|
for (let l = 0; l < r; l += 1) {
|
|
1610
|
-
const
|
|
1611
|
-
if (
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1610
|
+
const u = ot(i.cell);
|
|
1611
|
+
if (u && o.push(u), n) {
|
|
1612
|
+
const d = ot(i.header_cell);
|
|
1613
|
+
d && a.push(d);
|
|
1614
1614
|
}
|
|
1615
1615
|
}
|
|
1616
1616
|
const c = [];
|
|
@@ -1642,36 +1642,36 @@ function Sr(t, e, r = {}) {
|
|
|
1642
1642
|
if (!t || !t.content || t.content.length === 0)
|
|
1643
1643
|
return "";
|
|
1644
1644
|
const i = [];
|
|
1645
|
-
t.content.forEach((
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1648
|
-
let
|
|
1649
|
-
|
|
1650
|
-
const v = Ir(
|
|
1651
|
-
|
|
1652
|
-
}), i.push(
|
|
1645
|
+
t.content.forEach((h) => {
|
|
1646
|
+
const g = [];
|
|
1647
|
+
h.content && h.content.forEach((m) => {
|
|
1648
|
+
let k = "";
|
|
1649
|
+
m.content && Array.isArray(m.content) && m.content.length > 1 ? k = m.content.map((O) => e.renderChildren(O)).join(s) : k = m.content ? e.renderChildren(m.content) : "";
|
|
1650
|
+
const v = Ir(k), I = m.type === "tableHeader";
|
|
1651
|
+
g.push({ text: v, isHeader: I });
|
|
1652
|
+
}), i.push(g);
|
|
1653
1653
|
});
|
|
1654
|
-
const a = i.reduce((
|
|
1654
|
+
const a = i.reduce((h, g) => Math.max(h, g.length), 0);
|
|
1655
1655
|
if (a === 0)
|
|
1656
1656
|
return "";
|
|
1657
1657
|
const o = new Array(a).fill(0);
|
|
1658
|
-
i.forEach((
|
|
1659
|
-
var
|
|
1660
|
-
for (let
|
|
1661
|
-
const v = (((
|
|
1662
|
-
v > o[
|
|
1658
|
+
i.forEach((h) => {
|
|
1659
|
+
var g;
|
|
1660
|
+
for (let m = 0; m < a; m += 1) {
|
|
1661
|
+
const v = (((g = h[m]) == null ? void 0 : g.text) || "").length;
|
|
1662
|
+
v > o[m] && (o[m] = v), o[m] < 3 && (o[m] = 3);
|
|
1663
1663
|
}
|
|
1664
1664
|
});
|
|
1665
|
-
const c = (
|
|
1666
|
-
let
|
|
1665
|
+
const c = (h, g) => h + " ".repeat(Math.max(0, g - h.length)), l = i[0], u = l.some((h) => h.isHeader);
|
|
1666
|
+
let d = `
|
|
1667
1667
|
`;
|
|
1668
|
-
const
|
|
1669
|
-
return
|
|
1670
|
-
`,
|
|
1671
|
-
`, (
|
|
1672
|
-
|
|
1668
|
+
const f = new Array(a).fill(0).map((h, g) => u && l[g] && l[g].text || "");
|
|
1669
|
+
return d += `| ${f.map((h, g) => c(h, o[g])).join(" | ")} |
|
|
1670
|
+
`, d += `| ${o.map((h) => "-".repeat(Math.max(3, h))).join(" | ")} |
|
|
1671
|
+
`, (u ? i.slice(1) : i).forEach((h) => {
|
|
1672
|
+
d += `| ${new Array(a).fill(0).map((g, m) => c(h[m] && h[m].text || "", o[m])).join(" | ")} |
|
|
1673
1673
|
`;
|
|
1674
|
-
}),
|
|
1674
|
+
}), d;
|
|
1675
1675
|
}
|
|
1676
1676
|
var Hr = Sr, Er = L.create({
|
|
1677
1677
|
name: "table",
|
|
@@ -1703,7 +1703,7 @@ var Hr = Sr, Er = L.create({
|
|
|
1703
1703
|
}
|
|
1704
1704
|
const o = [
|
|
1705
1705
|
"table",
|
|
1706
|
-
|
|
1706
|
+
T(this.options.HTMLAttributes, e, {
|
|
1707
1707
|
style: a()
|
|
1708
1708
|
}),
|
|
1709
1709
|
r,
|
|
@@ -1874,13 +1874,19 @@ function _n({
|
|
|
1874
1874
|
content: e,
|
|
1875
1875
|
onContentChange: r,
|
|
1876
1876
|
placeholder: n = "",
|
|
1877
|
-
ref: s
|
|
1877
|
+
ref: s,
|
|
1878
|
+
autofocus: i,
|
|
1879
|
+
onFocus: a,
|
|
1880
|
+
onBlur: o
|
|
1878
1881
|
}) {
|
|
1879
|
-
const
|
|
1882
|
+
const c = de(), { height: l } = ce(), [u, d] = vt(
|
|
1880
1883
|
"main"
|
|
1881
|
-
),
|
|
1884
|
+
), f = q(null), b = q(!1), h = Ct({
|
|
1882
1885
|
immediatelyRender: !1,
|
|
1883
1886
|
shouldRerenderOnTransaction: !1,
|
|
1887
|
+
autofocus: i,
|
|
1888
|
+
onFocus: a,
|
|
1889
|
+
onBlur: o,
|
|
1884
1890
|
editorProps: {
|
|
1885
1891
|
attributes: {
|
|
1886
1892
|
autocomplete: "off",
|
|
@@ -1926,49 +1932,49 @@ function _n({
|
|
|
1926
1932
|
],
|
|
1927
1933
|
content: e,
|
|
1928
1934
|
onUpdate: ({ editor: m }) => {
|
|
1929
|
-
if (!
|
|
1930
|
-
const
|
|
1931
|
-
r(
|
|
1935
|
+
if (!b.current && r) {
|
|
1936
|
+
const k = m.getHTML();
|
|
1937
|
+
r(k);
|
|
1932
1938
|
}
|
|
1933
1939
|
}
|
|
1934
|
-
}),
|
|
1935
|
-
editor:
|
|
1936
|
-
overlayHeight:
|
|
1940
|
+
}), g = ue({
|
|
1941
|
+
editor: h,
|
|
1942
|
+
overlayHeight: f.current?.getBoundingClientRect().height ?? 0
|
|
1937
1943
|
});
|
|
1938
1944
|
return D(() => {
|
|
1939
|
-
!
|
|
1940
|
-
}, [
|
|
1941
|
-
|
|
1942
|
-
}, [e,
|
|
1945
|
+
!c && u !== "main" && d("main");
|
|
1946
|
+
}, [c, u]), D(() => {
|
|
1947
|
+
h && e !== void 0 && h.getHTML() !== e && (b.current = !0, h.commands.setContent(e, { emitUpdate: !1 }), b.current = !1);
|
|
1948
|
+
}, [e, h]), D(() => {
|
|
1943
1949
|
document.documentElement.classList.toggle("dark", t === "dark");
|
|
1944
1950
|
}, [t]), Mt(
|
|
1945
1951
|
s,
|
|
1946
1952
|
() => ({
|
|
1947
|
-
getEditor: () =>
|
|
1953
|
+
getEditor: () => h
|
|
1948
1954
|
}),
|
|
1949
|
-
[
|
|
1950
|
-
),
|
|
1955
|
+
[h]
|
|
1956
|
+
), h ? /* @__PURE__ */ p("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ w(Lt.Provider, { value: { editor: h }, children: [
|
|
1951
1957
|
/* @__PURE__ */ p(
|
|
1952
1958
|
Kt,
|
|
1953
1959
|
{
|
|
1954
|
-
ref:
|
|
1960
|
+
ref: f,
|
|
1955
1961
|
style: {
|
|
1956
|
-
...
|
|
1957
|
-
bottom: `calc(100% - ${
|
|
1962
|
+
...c ? {
|
|
1963
|
+
bottom: `calc(100% - ${l - g.y}px)`
|
|
1958
1964
|
} : {}
|
|
1959
1965
|
},
|
|
1960
|
-
children:
|
|
1966
|
+
children: u === "main" ? /* @__PURE__ */ p(
|
|
1961
1967
|
Nr,
|
|
1962
1968
|
{
|
|
1963
|
-
onHighlighterClick: () =>
|
|
1964
|
-
onLinkClick: () =>
|
|
1965
|
-
isMobile:
|
|
1969
|
+
onHighlighterClick: () => d("highlighter"),
|
|
1970
|
+
onLinkClick: () => d("link"),
|
|
1971
|
+
isMobile: c
|
|
1966
1972
|
}
|
|
1967
1973
|
) : /* @__PURE__ */ p(
|
|
1968
1974
|
Rr,
|
|
1969
1975
|
{
|
|
1970
|
-
type:
|
|
1971
|
-
onBack: () =>
|
|
1976
|
+
type: u === "highlighter" ? "highlighter" : "link",
|
|
1977
|
+
onBack: () => d("main")
|
|
1972
1978
|
}
|
|
1973
1979
|
)
|
|
1974
1980
|
}
|
|
@@ -1977,7 +1983,7 @@ function _n({
|
|
|
1977
1983
|
/* @__PURE__ */ p(
|
|
1978
1984
|
wt,
|
|
1979
1985
|
{
|
|
1980
|
-
editor:
|
|
1986
|
+
editor: h,
|
|
1981
1987
|
role: "presentation",
|
|
1982
1988
|
className: "simple-editor-content"
|
|
1983
1989
|
}
|