zt-react-milkdown 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/README.md +149 -0
- package/dist/commands-CDrea4WB.cjs +1 -0
- package/dist/commands-DoqeX5uJ.js +36 -0
- package/dist/debounce-Bqj_3iJs.cjs +1 -0
- package/dist/debounce-Cuk3VGPr.js +118 -0
- package/dist/dist-BCCSKc3M.cjs +5 -0
- package/dist/dist-C0PSMrs7.cjs +37 -0
- package/dist/dist-CPVooDwj.cjs +2 -0
- package/dist/dist-CxZn1qUo.js +1584 -0
- package/dist/dist-Cxaq2crg.js +409 -0
- package/dist/dist-DaM7GJv6.js +3499 -0
- package/dist/dist-Dhukmh4L.js +7562 -0
- package/dist/dist-mOpTMw1E.cjs +1 -0
- package/dist/floating-ui.dom-CKbcbmJV.js +883 -0
- package/dist/floating-ui.dom-VaZZ2gzS.cjs +1 -0
- package/dist/index.browser-5LtNN9G9.cjs +1 -0
- package/dist/index.browser-D2DmEB8o.js +26 -0
- package/dist/index.cjs +393 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +43325 -0
- package/dist/lib-38nxOnTd.cjs +4 -0
- package/dist/lib-8Tr6mAln.cjs +1 -0
- package/dist/lib-B0rHJ9lJ.js +28 -0
- package/dist/lib-BJgvZywM.cjs +3 -0
- package/dist/lib-BNOSyYeU.cjs +3 -0
- package/dist/lib-C5AzmhNY.cjs +5 -0
- package/dist/lib-C8xOD1Bp.cjs +1 -0
- package/dist/lib-CCUU16r8.js +1081 -0
- package/dist/lib-CK9MEMX-.js +73 -0
- package/dist/lib-D4HMdvmK.cjs +1 -0
- package/dist/lib-DWZA8C0h.cjs +1 -0
- package/dist/lib-Dbe-cVjv.js +367 -0
- package/dist/lib-DkE7Uq2b.js +1886 -0
- package/dist/lib-DzK_kn7a.js +21 -0
- package/dist/lib-IahjxPWM.cjs +3 -0
- package/dist/lib-m8lKZKxK.js +80 -0
- package/dist/lib-r5eNG0sa.js +754 -0
- package/dist/lib-wmHesNI0.js +2223 -0
- package/dist/rolldown-runtime-CerMd-t8.cjs +1 -0
- package/dist/rolldown-runtime-DnwLefa7.js +23 -0
- package/dist/schema-list-DSdBEAWW.js +171 -0
- package/dist/schema-list-bL8FNes5.cjs +1 -0
- package/dist/src/components/ui/button.d.ts +16 -0
- package/dist/src/components/ui/button.d.ts.map +1 -0
- package/dist/src/components/ui/dialog.d.ts +36 -0
- package/dist/src/components/ui/dialog.d.ts.map +1 -0
- package/dist/src/components/ui/popover.d.ts +14 -0
- package/dist/src/components/ui/popover.d.ts.map +1 -0
- package/dist/src/core/commands.d.ts +7 -0
- package/dist/src/core/commands.d.ts.map +1 -0
- package/dist/src/core/createEditor.d.ts +6 -0
- package/dist/src/core/createEditor.d.ts.map +1 -0
- package/dist/src/core/schema.d.ts +8 -0
- package/dist/src/core/schema.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/editor-overlay-position.d.ts +83 -0
- package/dist/src/lib/editor-overlay-position.d.ts.map +1 -0
- package/dist/src/lib/global-scroll-listener.d.ts +9 -0
- package/dist/src/lib/global-scroll-listener.d.ts.map +1 -0
- package/dist/src/lib/utils.d.ts +6 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/local/en-US.d.ts +6 -0
- package/dist/src/local/en-US.d.ts.map +1 -0
- package/dist/src/local/i18n.d.ts +10 -0
- package/dist/src/local/i18n.d.ts.map +1 -0
- package/dist/src/local/zh-CN.d.ts +6 -0
- package/dist/src/local/zh-CN.d.ts.map +1 -0
- package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts +5 -0
- package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts.map +1 -0
- package/dist/src/plugins/custom/blockquote/index.d.ts +3 -0
- package/dist/src/plugins/custom/blockquote/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-editable.d.ts +7 -0
- package/dist/src/plugins/custom/code-block/code-block-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts +7 -0
- package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts +5 -0
- package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-prism.d.ts +5 -0
- package/dist/src/plugins/custom/code-block/code-block-prism.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/index.d.ts +9 -0
- package/dist/src/plugins/custom/code-block/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/cursor/drop-cursor.d.ts +5 -0
- package/dist/src/plugins/custom/cursor/drop-cursor.d.ts.map +1 -0
- package/dist/src/plugins/custom/cursor/gap-cursor.d.ts +5 -0
- package/dist/src/plugins/custom/cursor/gap-cursor.d.ts.map +1 -0
- package/dist/src/plugins/custom/cursor/index.d.ts +5 -0
- package/dist/src/plugins/custom/cursor/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-editable.d.ts +7 -0
- package/dist/src/plugins/custom/image/image-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-resizable-schema.d.ts +41 -0
- package/dist/src/plugins/custom/image/image-resizable-schema.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts +31 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts +20 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/index.d.ts +7 -0
- package/dist/src/plugins/custom/image/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/indent/index.d.ts +3 -0
- package/dist/src/plugins/custom/indent/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/indent/tab-space-indent.d.ts +5 -0
- package/dist/src/plugins/custom/indent/tab-space-indent.d.ts.map +1 -0
- package/dist/src/plugins/custom/list/index.d.ts +3 -0
- package/dist/src/plugins/custom/list/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/list/task-list-toggle.d.ts +5 -0
- package/dist/src/plugins/custom/list/task-list-toggle.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/index.d.ts +7 -0
- package/dist/src/plugins/custom/math/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-backspace-entry.d.ts +5 -0
- package/dist/src/plugins/custom/math/math-backspace-entry.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-block-editable.d.ts +7 -0
- package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts +47 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +7 -0
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts +7 -0
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts +25 -0
- package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +21 -0
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts +58 -0
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/index.d.ts +9 -0
- package/dist/src/plugins/custom/slash-menu/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts +6 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +23 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts +50 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts +15 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/index.d.ts +13 -0
- package/dist/src/plugins/custom/table/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-arrow-entry.d.ts +5 -0
- package/dist/src/plugins/custom/table/table-arrow-entry.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-deletion-actions.d.ts +10 -0
- package/dist/src/plugins/custom/table/table-deletion-actions.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-focus-actions.d.ts +7 -0
- package/dist/src/plugins/custom/table/table-focus-actions.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-more-actions.d.ts +37 -0
- package/dist/src/plugins/custom/table/table-more-actions.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-row-insertion.d.ts +35 -0
- package/dist/src/plugins/custom/table/table-row-insertion.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-selection.d.ts +30 -0
- package/dist/src/plugins/custom/table/table-selection.d.ts.map +1 -0
- package/dist/src/plugins/preset-common.d.ts +56 -0
- package/dist/src/plugins/preset-common.d.ts.map +1 -0
- package/dist/src/react/components/MilkdownEditor.d.ts +7 -0
- package/dist/src/react/components/MilkdownEditor.d.ts.map +1 -0
- package/dist/src/react/components/index.d.ts +2 -0
- package/dist/src/react/components/index.d.ts.map +1 -0
- package/dist/src/react/context/EditorContext.d.ts +16 -0
- package/dist/src/react/context/EditorContext.d.ts.map +1 -0
- package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +5 -0
- package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +1 -0
- package/dist/src/react/hooks/useControlledState.d.ts +9 -0
- package/dist/src/react/hooks/useControlledState.d.ts.map +1 -0
- package/dist/src/react/hooks/useMilkdownEditor.d.ts +35 -0
- package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -0
- package/dist/src/types/editor.d.ts +233 -0
- package/dist/src/types/editor.d.ts.map +1 -0
- package/dist/src/types/plugin.d.ts +10 -0
- package/dist/src/types/plugin.d.ts.map +1 -0
- package/dist/src/utils/guard.d.ts +5 -0
- package/dist/src/utils/guard.d.ts.map +1 -0
- package/dist/src/utils/markdown.d.ts +9 -0
- package/dist/src/utils/markdown.d.ts.map +1 -0
- package/dist/state-CHAiIqOA.cjs +1 -0
- package/dist/state-DNxqltZl.js +16 -0
- package/dist/style.css +3 -0
- package/package.json +89 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { C as e, _ as t, b as n, c as r, d as i, f as a, h as o, k as s, m as c, o as l, r as u, s as d, t as f, v as p, y as m } from "./dist-DaM7GJv6.js";
|
|
2
|
+
//#region node_modules/.pnpm/prosemirror-commands@1.7.1/node_modules/prosemirror-commands/dist/index.js
|
|
3
|
+
var h = (e, t) => e.selection.empty ? !1 : (t && t(e.tr.deleteSelection().scrollIntoView()), !0);
|
|
4
|
+
function g(e, t) {
|
|
5
|
+
let { $cursor: n } = e.selection;
|
|
6
|
+
return !n || (t ? !t.endOfTextblock("backward", e) : n.parentOffset > 0) ? null : n;
|
|
7
|
+
}
|
|
8
|
+
var _ = (e, t, r) => {
|
|
9
|
+
let i = g(e, r);
|
|
10
|
+
if (!i) return !1;
|
|
11
|
+
let a = S(i);
|
|
12
|
+
if (!a) {
|
|
13
|
+
let n = i.blockRange(), r = n && m(n);
|
|
14
|
+
return r == null ? !1 : (t && t(e.tr.lift(n, r).scrollIntoView()), !0);
|
|
15
|
+
}
|
|
16
|
+
let o = a.nodeBefore;
|
|
17
|
+
if (R(e, a, t, -1)) return !0;
|
|
18
|
+
if (i.parent.content.size == 0 && (b(o, "end") || u.isSelectable(o))) for (let r = i.depth;; r--) {
|
|
19
|
+
let c = n(e.doc, i.before(r), i.after(r), s.empty);
|
|
20
|
+
if (c && c.slice.size < c.to - c.from) {
|
|
21
|
+
if (t) {
|
|
22
|
+
let n = e.tr.step(c);
|
|
23
|
+
n.setSelection(b(o, "end") ? l.findFrom(n.doc.resolve(n.mapping.map(a.pos, -1)), -1) : u.create(n.doc, a.pos - o.nodeSize)), t(n.scrollIntoView());
|
|
24
|
+
}
|
|
25
|
+
return !0;
|
|
26
|
+
}
|
|
27
|
+
if (r == 1 || i.node(r - 1).childCount > 1) break;
|
|
28
|
+
}
|
|
29
|
+
return o.isAtom && a.depth == i.depth - 1 ? (t && t(e.tr.delete(a.pos - o.nodeSize, a.pos).scrollIntoView()), !0) : !1;
|
|
30
|
+
}, v = (e, t, n) => {
|
|
31
|
+
let r = g(e, n);
|
|
32
|
+
if (!r) return !1;
|
|
33
|
+
let i = S(r);
|
|
34
|
+
return i ? y(e, i, t) : !1;
|
|
35
|
+
}, ee = (e, t, n) => {
|
|
36
|
+
let r = C(e, n);
|
|
37
|
+
if (!r) return !1;
|
|
38
|
+
let i = E(r);
|
|
39
|
+
return i ? y(e, i, t) : !1;
|
|
40
|
+
};
|
|
41
|
+
function y(e, t, i) {
|
|
42
|
+
let o = t.nodeBefore, c = t.pos - 1;
|
|
43
|
+
for (; !o.isTextblock; c--) {
|
|
44
|
+
if (o.type.spec.isolating) return !1;
|
|
45
|
+
let e = o.lastChild;
|
|
46
|
+
if (!e) return !1;
|
|
47
|
+
o = e;
|
|
48
|
+
}
|
|
49
|
+
let l = t.nodeAfter, u = t.pos + 1;
|
|
50
|
+
for (; !l.isTextblock; u++) {
|
|
51
|
+
if (l.type.spec.isolating) return !1;
|
|
52
|
+
let e = l.firstChild;
|
|
53
|
+
if (!e) return !1;
|
|
54
|
+
l = e;
|
|
55
|
+
}
|
|
56
|
+
let d = n(e.doc, c, u, s.empty);
|
|
57
|
+
if (!d || d.from != c || d instanceof a && d.slice.size >= u - c) return !1;
|
|
58
|
+
if (i) {
|
|
59
|
+
let t = e.tr.step(d);
|
|
60
|
+
t.setSelection(r.create(t.doc, c)), i(t.scrollIntoView());
|
|
61
|
+
}
|
|
62
|
+
return !0;
|
|
63
|
+
}
|
|
64
|
+
function b(e, t, n = !1) {
|
|
65
|
+
for (let r = e; r; r = t == "start" ? r.firstChild : r.lastChild) {
|
|
66
|
+
if (r.isTextblock) return !0;
|
|
67
|
+
if (n && r.childCount != 1) return !1;
|
|
68
|
+
}
|
|
69
|
+
return !1;
|
|
70
|
+
}
|
|
71
|
+
var x = (e, t, n) => {
|
|
72
|
+
let { $head: r, empty: i } = e.selection, a = r;
|
|
73
|
+
if (!i) return !1;
|
|
74
|
+
if (r.parent.isTextblock) {
|
|
75
|
+
if (n ? !n.endOfTextblock("backward", e) : r.parentOffset > 0) return !1;
|
|
76
|
+
a = S(r);
|
|
77
|
+
}
|
|
78
|
+
let o = a && a.nodeBefore;
|
|
79
|
+
return !o || !u.isSelectable(o) ? !1 : (t && t(e.tr.setSelection(u.create(e.doc, a.pos - o.nodeSize)).scrollIntoView()), !0);
|
|
80
|
+
};
|
|
81
|
+
function S(e) {
|
|
82
|
+
if (!e.parent.type.spec.isolating) for (let t = e.depth - 1; t >= 0; t--) {
|
|
83
|
+
if (e.index(t) > 0) return e.doc.resolve(e.before(t + 1));
|
|
84
|
+
if (e.node(t).type.spec.isolating) break;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
function C(e, t) {
|
|
89
|
+
let { $cursor: n } = e.selection;
|
|
90
|
+
return !n || (t ? !t.endOfTextblock("forward", e) : n.parentOffset < n.parent.content.size) ? null : n;
|
|
91
|
+
}
|
|
92
|
+
var w = (e, t, r) => {
|
|
93
|
+
let i = C(e, r);
|
|
94
|
+
if (!i) return !1;
|
|
95
|
+
let a = E(i);
|
|
96
|
+
if (!a) return !1;
|
|
97
|
+
let o = a.nodeAfter;
|
|
98
|
+
if (R(e, a, t, 1)) return !0;
|
|
99
|
+
if (i.parent.content.size == 0 && (b(o, "start") || u.isSelectable(o))) {
|
|
100
|
+
let r = n(e.doc, i.before(), i.after(), s.empty);
|
|
101
|
+
if (r && r.slice.size < r.to - r.from) {
|
|
102
|
+
if (t) {
|
|
103
|
+
let n = e.tr.step(r);
|
|
104
|
+
n.setSelection(b(o, "start") ? l.findFrom(n.doc.resolve(n.mapping.map(a.pos)), 1) : u.create(n.doc, n.mapping.map(a.pos))), t(n.scrollIntoView());
|
|
105
|
+
}
|
|
106
|
+
return !0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return o.isAtom && a.depth == i.depth - 1 ? (t && t(e.tr.delete(a.pos, a.pos + o.nodeSize).scrollIntoView()), !0) : !1;
|
|
110
|
+
}, T = (e, t, n) => {
|
|
111
|
+
let { $head: r, empty: i } = e.selection, a = r;
|
|
112
|
+
if (!i) return !1;
|
|
113
|
+
if (r.parent.isTextblock) {
|
|
114
|
+
if (n ? !n.endOfTextblock("forward", e) : r.parentOffset < r.parent.content.size) return !1;
|
|
115
|
+
a = E(r);
|
|
116
|
+
}
|
|
117
|
+
let o = a && a.nodeAfter;
|
|
118
|
+
return !o || !u.isSelectable(o) ? !1 : (t && t(e.tr.setSelection(u.create(e.doc, a.pos)).scrollIntoView()), !0);
|
|
119
|
+
};
|
|
120
|
+
function E(e) {
|
|
121
|
+
if (!e.parent.type.spec.isolating) for (let t = e.depth - 1; t >= 0; t--) {
|
|
122
|
+
let n = e.node(t);
|
|
123
|
+
if (e.index(t) + 1 < n.childCount) return e.doc.resolve(e.after(t + 1));
|
|
124
|
+
if (n.type.spec.isolating) break;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
var te = (e, t) => {
|
|
129
|
+
let n = e.selection, r = n instanceof u, i;
|
|
130
|
+
if (r) {
|
|
131
|
+
if (n.node.isTextblock || !c(e.doc, n.from)) return !1;
|
|
132
|
+
i = n.from;
|
|
133
|
+
} else if (i = p(e.doc, n.from, -1), i == null) return !1;
|
|
134
|
+
if (t) {
|
|
135
|
+
let n = e.tr.join(i);
|
|
136
|
+
r && n.setSelection(u.create(n.doc, i - e.doc.resolve(i).nodeBefore.nodeSize)), t(n.scrollIntoView());
|
|
137
|
+
}
|
|
138
|
+
return !0;
|
|
139
|
+
}, ne = (e, t) => {
|
|
140
|
+
let n = e.selection, r;
|
|
141
|
+
if (n instanceof u) {
|
|
142
|
+
if (n.node.isTextblock || !c(e.doc, n.to)) return !1;
|
|
143
|
+
r = n.to;
|
|
144
|
+
} else if (r = p(e.doc, n.to, 1), r == null) return !1;
|
|
145
|
+
return t && t(e.tr.join(r).scrollIntoView()), !0;
|
|
146
|
+
}, D = (e, t) => {
|
|
147
|
+
let { $from: n, $to: r } = e.selection, i = n.blockRange(r), a = i && m(i);
|
|
148
|
+
return a == null ? !1 : (t && t(e.tr.lift(i, a).scrollIntoView()), !0);
|
|
149
|
+
}, O = (e, t) => {
|
|
150
|
+
let { $head: n, $anchor: r } = e.selection;
|
|
151
|
+
return !n.parent.type.spec.code || !n.sameParent(r) ? !1 : (t && t(e.tr.insertText("\n").scrollIntoView()), !0);
|
|
152
|
+
};
|
|
153
|
+
function k(e) {
|
|
154
|
+
for (let t = 0; t < e.edgeCount; t++) {
|
|
155
|
+
let { type: n } = e.edge(t);
|
|
156
|
+
if (n.isTextblock && !n.hasRequiredAttrs()) return n;
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
var A = (e, t) => {
|
|
161
|
+
let { $head: n, $anchor: r } = e.selection;
|
|
162
|
+
if (!n.parent.type.spec.code || !n.sameParent(r)) return !1;
|
|
163
|
+
let i = n.node(-1), a = n.indexAfter(-1), o = k(i.contentMatchAt(a));
|
|
164
|
+
if (!o || !i.canReplaceWith(a, a, o)) return !1;
|
|
165
|
+
if (t) {
|
|
166
|
+
let r = n.after(), i = e.tr.replaceWith(r, r, o.createAndFill());
|
|
167
|
+
i.setSelection(l.near(i.doc.resolve(r), 1)), t(i.scrollIntoView());
|
|
168
|
+
}
|
|
169
|
+
return !0;
|
|
170
|
+
}, j = (e, t) => {
|
|
171
|
+
let n = e.selection, { $from: i, $to: a } = n;
|
|
172
|
+
if (n instanceof f || i.parent.inlineContent || a.parent.inlineContent) return !1;
|
|
173
|
+
let o = k(a.parent.contentMatchAt(a.indexAfter()));
|
|
174
|
+
if (!o || !o.isTextblock) return !1;
|
|
175
|
+
if (t) {
|
|
176
|
+
let n = (!i.parentOffset && a.index() < a.parent.childCount ? i : a).pos, s = e.tr.insert(n, o.createAndFill());
|
|
177
|
+
s.setSelection(r.create(s.doc, n + 1)), t(s.scrollIntoView());
|
|
178
|
+
}
|
|
179
|
+
return !0;
|
|
180
|
+
}, M = (e, t) => {
|
|
181
|
+
let { $cursor: n } = e.selection;
|
|
182
|
+
if (!n || n.parent.content.size) return !1;
|
|
183
|
+
if (n.depth > 1 && n.after() != n.end(-1)) {
|
|
184
|
+
let r = n.before();
|
|
185
|
+
if (o(e.doc, r)) return t && t(e.tr.split(r).scrollIntoView()), !0;
|
|
186
|
+
}
|
|
187
|
+
let r = n.blockRange(), i = r && m(r);
|
|
188
|
+
return i == null ? !1 : (t && t(e.tr.lift(r, i).scrollIntoView()), !0);
|
|
189
|
+
};
|
|
190
|
+
function N(e) {
|
|
191
|
+
return (t, n) => {
|
|
192
|
+
let { $from: i, $to: a } = t.selection;
|
|
193
|
+
if (t.selection instanceof u && t.selection.node.isBlock) return !i.parentOffset || !o(t.doc, i.pos) ? !1 : (n && n(t.tr.split(i.pos).scrollIntoView()), !0);
|
|
194
|
+
if (!i.depth) return !1;
|
|
195
|
+
let s = [], c, l, d = !1, p = !1;
|
|
196
|
+
for (let t = i.depth;; t--) if (i.node(t).isBlock) {
|
|
197
|
+
d = i.end(t) == i.pos + (i.depth - t), p = i.start(t) == i.pos - (i.depth - t), l = k(i.node(t - 1).contentMatchAt(i.indexAfter(t - 1)));
|
|
198
|
+
let n = e && e(a.parent, d, i);
|
|
199
|
+
s.unshift(n || (d && l ? { type: l } : null)), c = t;
|
|
200
|
+
break;
|
|
201
|
+
} else {
|
|
202
|
+
if (t == 1) return !1;
|
|
203
|
+
s.unshift(null);
|
|
204
|
+
}
|
|
205
|
+
let m = t.tr;
|
|
206
|
+
(t.selection instanceof r || t.selection instanceof f) && m.deleteSelection();
|
|
207
|
+
let h = m.mapping.map(i.pos), g = o(m.doc, h, s.length, s);
|
|
208
|
+
if (g ||= (s[0] = l ? { type: l } : null, o(m.doc, h, s.length, s)), !g) return !1;
|
|
209
|
+
if (m.split(h, s.length, s), !d && p && i.node(c).type != l) {
|
|
210
|
+
let e = m.mapping.map(i.before(c)), t = m.doc.resolve(e);
|
|
211
|
+
l && i.node(c - 1).canReplaceWith(t.index(), t.index() + 1, l) && m.setNodeMarkup(m.mapping.map(i.before(c)), l);
|
|
212
|
+
}
|
|
213
|
+
return n && n(m.scrollIntoView()), !0;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
var P = N(), F = (e, t) => P(e, t && ((n) => {
|
|
217
|
+
let r = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
|
|
218
|
+
r && n.ensureMarks(r), t(n);
|
|
219
|
+
})), I = (e, t) => {
|
|
220
|
+
let { $from: n, to: r } = e.selection, i, a = n.sharedDepth(r);
|
|
221
|
+
return a == 0 ? !1 : (i = n.before(a), t && t(e.tr.setSelection(u.create(e.doc, i))), !0);
|
|
222
|
+
}, L = (e, t) => (t && t(e.tr.setSelection(new f(e.doc))), !0);
|
|
223
|
+
function re(e, t, n) {
|
|
224
|
+
let r = t.nodeBefore, i = t.nodeAfter, a = t.index();
|
|
225
|
+
return !r || !i || !r.type.compatibleContent(i.type) ? !1 : !r.content.size && t.parent.canReplace(a - 1, a) ? (n && n(e.tr.delete(t.pos - r.nodeSize, t.pos).scrollIntoView()), !0) : !t.parent.canReplace(a, a + 1) || !(i.isTextblock || c(e.doc, t.pos)) ? !1 : (n && n(e.tr.join(t.pos).scrollIntoView()), !0);
|
|
226
|
+
}
|
|
227
|
+
function R(t, n, r, a) {
|
|
228
|
+
let o = n.nodeBefore, u = n.nodeAfter, d, f, p = o.type.spec.isolating || u.type.spec.isolating;
|
|
229
|
+
if (!p && re(t, n, r)) return !0;
|
|
230
|
+
let h = !p && n.parent.canReplace(n.index(), n.index() + 1);
|
|
231
|
+
if (h && (d = (f = o.contentMatchAt(o.childCount)).findWrapping(u.type)) && f.matchType(d[0] || u.type).validEnd) {
|
|
232
|
+
if (r) {
|
|
233
|
+
let a = n.pos + u.nodeSize, l = e.empty;
|
|
234
|
+
for (let t = d.length - 1; t >= 0; t--) l = e.from(d[t].create(null, l));
|
|
235
|
+
l = e.from(o.copy(l));
|
|
236
|
+
let f = t.tr.step(new i(n.pos - 1, a, n.pos, a, new s(l, 1, 0), d.length, !0)), p = f.doc.resolve(a + 2 * d.length);
|
|
237
|
+
p.nodeAfter && p.nodeAfter.type == o.type && c(f.doc, p.pos) && f.join(p.pos), r(f.scrollIntoView());
|
|
238
|
+
}
|
|
239
|
+
return !0;
|
|
240
|
+
}
|
|
241
|
+
let g = u.type.spec.isolating || a > 0 && p ? null : l.findFrom(n, 1), _ = g && g.$from.blockRange(g.$to), v = _ && m(_);
|
|
242
|
+
if (v != null && v >= n.depth) return r && r(t.tr.lift(_, v).scrollIntoView()), !0;
|
|
243
|
+
if (h && b(u, "start", !0) && b(o, "end")) {
|
|
244
|
+
let a = o, c = [];
|
|
245
|
+
for (; c.push(a), !a.isTextblock;) a = a.lastChild;
|
|
246
|
+
let l = u, d = 1;
|
|
247
|
+
for (; !l.isTextblock; l = l.firstChild) d++;
|
|
248
|
+
if (a.canReplace(a.childCount, a.childCount, l.content)) {
|
|
249
|
+
if (r) {
|
|
250
|
+
let a = e.empty;
|
|
251
|
+
for (let t = c.length - 1; t >= 0; t--) a = e.from(c[t].copy(a));
|
|
252
|
+
r(t.tr.step(new i(n.pos - c.length, n.pos + u.nodeSize, n.pos + d, n.pos + u.nodeSize - d, new s(a, c.length, 0), 0, !0)).scrollIntoView());
|
|
253
|
+
}
|
|
254
|
+
return !0;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return !1;
|
|
258
|
+
}
|
|
259
|
+
function z(e) {
|
|
260
|
+
return function(t, n) {
|
|
261
|
+
let i = t.selection, a = e < 0 ? i.$from : i.$to, o = a.depth;
|
|
262
|
+
for (; a.node(o).isInline;) {
|
|
263
|
+
if (!o) return !1;
|
|
264
|
+
o--;
|
|
265
|
+
}
|
|
266
|
+
return a.node(o).isTextblock ? (n && n(t.tr.setSelection(r.create(t.doc, e < 0 ? a.start(o) : a.end(o)))), !0) : !1;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
var B = z(-1), V = z(1);
|
|
270
|
+
function H(e, n = null) {
|
|
271
|
+
return function(r, i) {
|
|
272
|
+
let { $from: a, $to: o } = r.selection, s = a.blockRange(o), c = s && t(s, e, n);
|
|
273
|
+
return c ? (i && i(r.tr.wrap(s, c).scrollIntoView()), !0) : !1;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function U(e, t = null) {
|
|
277
|
+
return function(n, r) {
|
|
278
|
+
let i = !1;
|
|
279
|
+
for (let r = 0; r < n.selection.ranges.length && !i; r++) {
|
|
280
|
+
let { $from: { pos: a }, $to: { pos: o } } = n.selection.ranges[r];
|
|
281
|
+
n.doc.nodesBetween(a, o, (r, a) => {
|
|
282
|
+
if (i) return !1;
|
|
283
|
+
if (!(!r.isTextblock || r.hasMarkup(e, t))) if (r.type == e) i = !0;
|
|
284
|
+
else {
|
|
285
|
+
let t = n.doc.resolve(a), r = t.index();
|
|
286
|
+
i = t.parent.canReplaceWith(r, r + 1, e);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
if (!i) return !1;
|
|
291
|
+
if (r) {
|
|
292
|
+
let i = n.tr;
|
|
293
|
+
for (let r = 0; r < n.selection.ranges.length; r++) {
|
|
294
|
+
let { $from: { pos: a }, $to: { pos: o } } = n.selection.ranges[r];
|
|
295
|
+
i.setBlockType(a, o, e, t);
|
|
296
|
+
}
|
|
297
|
+
r(i.scrollIntoView());
|
|
298
|
+
}
|
|
299
|
+
return !0;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function W(e, t, n, r) {
|
|
303
|
+
for (let i = 0; i < t.length; i++) {
|
|
304
|
+
let { $from: a, $to: o } = t[i], s = a.depth == 0 ? e.inlineContent && e.type.allowsMarkType(n) : !1;
|
|
305
|
+
if (e.nodesBetween(a.pos, o.pos, (e, t) => {
|
|
306
|
+
if (s || !r && e.isAtom && e.isInline && t >= a.pos && t + e.nodeSize <= o.pos) return !1;
|
|
307
|
+
s = e.inlineContent && e.type.allowsMarkType(n);
|
|
308
|
+
}), s) return !0;
|
|
309
|
+
}
|
|
310
|
+
return !1;
|
|
311
|
+
}
|
|
312
|
+
function G(e) {
|
|
313
|
+
let t = [];
|
|
314
|
+
for (let n = 0; n < e.length; n++) {
|
|
315
|
+
let { $from: r, $to: i } = e[n];
|
|
316
|
+
r.doc.nodesBetween(r.pos, i.pos, (e, n) => {
|
|
317
|
+
if (e.isAtom && e.content.size && e.isInline && n >= r.pos && n + e.nodeSize <= i.pos) return n + 1 > r.pos && t.push(new d(r, r.doc.resolve(n + 1))), r = r.doc.resolve(n + 1 + e.content.size), !1;
|
|
318
|
+
}), r.pos < i.pos && t.push(new d(r, i));
|
|
319
|
+
}
|
|
320
|
+
return t;
|
|
321
|
+
}
|
|
322
|
+
function K(e, t = null, n) {
|
|
323
|
+
let r = (n && n.removeWhenPresent) !== !1, i = (n && n.enterInlineAtoms) !== !1, a = !(n && n.includeWhitespace);
|
|
324
|
+
return function(n, o) {
|
|
325
|
+
let { empty: s, $cursor: c, ranges: l } = n.selection;
|
|
326
|
+
if (s && !c || !W(n.doc, l, e, i)) return !1;
|
|
327
|
+
if (o) if (c) e.isInSet(n.storedMarks || c.marks()) ? o(n.tr.removeStoredMark(e)) : o(n.tr.addStoredMark(e.create(t)));
|
|
328
|
+
else {
|
|
329
|
+
let s, c = n.tr;
|
|
330
|
+
i || (l = G(l)), s = r ? !l.some((t) => n.doc.rangeHasMark(t.$from.pos, t.$to.pos, e)) : !l.every((t) => {
|
|
331
|
+
let n = !1;
|
|
332
|
+
return c.doc.nodesBetween(t.$from.pos, t.$to.pos, (r, i, a) => {
|
|
333
|
+
if (n) return !1;
|
|
334
|
+
n = !e.isInSet(r.marks) && !!a && a.type.allowsMarkType(e) && !(r.isText && /^\s*$/.test(r.textBetween(Math.max(0, t.$from.pos - i), Math.min(r.nodeSize, t.$to.pos - i))));
|
|
335
|
+
}), !n;
|
|
336
|
+
});
|
|
337
|
+
for (let n = 0; n < l.length; n++) {
|
|
338
|
+
let { $from: r, $to: i } = l[n];
|
|
339
|
+
if (!s) c.removeMark(r.pos, i.pos, e);
|
|
340
|
+
else {
|
|
341
|
+
let n = r.pos, o = i.pos, s = r.nodeAfter, l = i.nodeBefore, u = a && s && s.isText ? /^\s*/.exec(s.text)[0].length : 0, d = a && l && l.isText ? /\s*$/.exec(l.text)[0].length : 0;
|
|
342
|
+
n + u < o && (n += u, o -= d), c.addMark(n, o, e.create(t));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
o(c.scrollIntoView());
|
|
346
|
+
}
|
|
347
|
+
return !0;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function q(e, t) {
|
|
351
|
+
return (n) => {
|
|
352
|
+
if (!n.isGeneric) return e(n);
|
|
353
|
+
let r = [];
|
|
354
|
+
for (let e = 0; e < n.mapping.maps.length; e++) {
|
|
355
|
+
let t = n.mapping.maps[e];
|
|
356
|
+
for (let e = 0; e < r.length; e++) r[e] = t.map(r[e]);
|
|
357
|
+
t.forEach((e, t, n, i) => r.push(n, i));
|
|
358
|
+
}
|
|
359
|
+
let i = [];
|
|
360
|
+
for (let e = 0; e < r.length; e += 2) {
|
|
361
|
+
let a = r[e], o = r[e + 1], s = n.doc.resolve(a), c = s.sharedDepth(o), l = s.node(c);
|
|
362
|
+
for (let e = s.indexAfter(c), n = s.after(c + 1); n <= o; ++e) {
|
|
363
|
+
let r = l.maybeChild(e);
|
|
364
|
+
if (!r) break;
|
|
365
|
+
if (e && i.indexOf(n) == -1) {
|
|
366
|
+
let a = l.child(e - 1);
|
|
367
|
+
a.type == r.type && t(a, r) && i.push(n);
|
|
368
|
+
}
|
|
369
|
+
n += r.nodeSize;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
i.sort((e, t) => e - t);
|
|
373
|
+
for (let e = i.length - 1; e >= 0; e--) c(n.doc, i[e]) && n.join(i[e]);
|
|
374
|
+
e(n);
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function J(e, t) {
|
|
378
|
+
let n = Array.isArray(t) ? (e) => t.indexOf(e.type.name) > -1 : t;
|
|
379
|
+
return (t, r, i) => e(t, r && q(r, n), i);
|
|
380
|
+
}
|
|
381
|
+
function Y(...e) {
|
|
382
|
+
return function(t, n, r) {
|
|
383
|
+
for (let i = 0; i < e.length; i++) if (e[i](t, n, r)) return !0;
|
|
384
|
+
return !1;
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
var X = Y(h, _, x), Z = Y(h, w, T), Q = {
|
|
388
|
+
Enter: Y(O, j, M, P),
|
|
389
|
+
"Mod-Enter": A,
|
|
390
|
+
Backspace: X,
|
|
391
|
+
"Mod-Backspace": X,
|
|
392
|
+
"Shift-Backspace": X,
|
|
393
|
+
Delete: Z,
|
|
394
|
+
"Mod-Delete": Z,
|
|
395
|
+
"Mod-a": L
|
|
396
|
+
}, $ = {
|
|
397
|
+
"Ctrl-h": Q.Backspace,
|
|
398
|
+
"Alt-Backspace": Q["Mod-Backspace"],
|
|
399
|
+
"Ctrl-d": Q.Delete,
|
|
400
|
+
"Ctrl-Alt-Backspace": Q["Mod-Delete"],
|
|
401
|
+
"Alt-Delete": Q["Mod-Delete"],
|
|
402
|
+
"Alt-d": Q["Mod-Delete"],
|
|
403
|
+
"Ctrl-a": B,
|
|
404
|
+
"Ctrl-e": V
|
|
405
|
+
};
|
|
406
|
+
for (let e in Q) $[e] = Q[e];
|
|
407
|
+
var ie = (typeof navigator < "u" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os < "u" && os.platform && os.platform() == "darwin") ? $ : Q;
|
|
408
|
+
//#endregion
|
|
409
|
+
export { B as C, F as D, N as E, K as O, V as S, P as T, Q as _, h as a, T as b, ne as c, ee as d, te as f, O as g, $ as h, j as i, H as k, w as l, M as m, ie as n, A as o, D as p, Y as r, _ as s, J as t, v as u, L as v, U as w, I as x, x as y };
|