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,1081 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DnwLefa7.js";
|
|
2
|
+
import { O as t, T as n, a as r, i, n as a, r as o, w as s, x as c } from "./dist-DaM7GJv6.js";
|
|
3
|
+
import { a as l, c as u, f as d, o as f, r as p, u as m, y as ee } from "./dist-Dhukmh4L.js";
|
|
4
|
+
import { a as te, n as ne, r as re, u as ie, y as ae } from "./dist-Cxaq2crg.js";
|
|
5
|
+
//#region node_modules/.pnpm/@milkdown+exception@7.20.0/node_modules/@milkdown/exception/lib/index.js
|
|
6
|
+
var h = /* @__PURE__ */ function(e) {
|
|
7
|
+
return e.docTypeError = "docTypeError", e.contextNotFound = "contextNotFound", e.timerNotFound = "timerNotFound", e.ctxCallOutOfScope = "ctxCallOutOfScope", e.createNodeInParserFail = "createNodeInParserFail", e.stackOverFlow = "stackOverFlow", e.parserMatchError = "parserMatchError", e.serializerMatchError = "serializerMatchError", e.getAtomFromSchemaFail = "getAtomFromSchemaFail", e.expectDomTypeError = "expectDomTypeError", e.callCommandBeforeEditorView = "callCommandBeforeEditorView", e.missingRootElement = "missingRootElement", e.missingNodeInSchema = "missingNodeInSchema", e.missingMarkInSchema = "missingMarkInSchema", e.ctxNotBind = "ctxNotBind", e.missingYjsDoc = "missingYjsDoc", e;
|
|
8
|
+
}({}), g = class extends Error {
|
|
9
|
+
constructor(e, t) {
|
|
10
|
+
super(t), this.name = "MilkdownError", this.code = e;
|
|
11
|
+
}
|
|
12
|
+
}, oe = (e, t) => typeof t == "function" ? "[Function]" : t, se = (e) => JSON.stringify(e, oe);
|
|
13
|
+
function ce(e) {
|
|
14
|
+
return new g(h.docTypeError, `Doc type error, unsupported type: ${se(e)}`);
|
|
15
|
+
}
|
|
16
|
+
function le(e) {
|
|
17
|
+
return new g(h.contextNotFound, `Context "${e}" not found, do you forget to inject it?`);
|
|
18
|
+
}
|
|
19
|
+
function ue(e) {
|
|
20
|
+
return new g(h.timerNotFound, `Timer "${e}" not found, do you forget to record it?`);
|
|
21
|
+
}
|
|
22
|
+
function de() {
|
|
23
|
+
return new g(h.ctxCallOutOfScope, "Should not call a context out of the plugin.");
|
|
24
|
+
}
|
|
25
|
+
function fe(e, t, n) {
|
|
26
|
+
let r = `Cannot create node for ${"name" in e ? e.name : e}`, i = (e) => {
|
|
27
|
+
if (e == null) return "null";
|
|
28
|
+
if (Array.isArray(e)) return `[${e.map(i).join(", ")}]`;
|
|
29
|
+
if (typeof e == "object") return "toJSON" in e && typeof e.toJSON == "function" ? JSON.stringify(e.toJSON()) : "spec" in e ? JSON.stringify(e.spec) : JSON.stringify(e);
|
|
30
|
+
if (typeof e == "string" || typeof e == "number" || typeof e == "boolean") return JSON.stringify(e);
|
|
31
|
+
if (typeof e == "function") return `[Function: ${e.name || "anonymous"}]`;
|
|
32
|
+
try {
|
|
33
|
+
return String(e);
|
|
34
|
+
} catch {
|
|
35
|
+
return "[Unserializable]";
|
|
36
|
+
}
|
|
37
|
+
}, a = [
|
|
38
|
+
["[Description]", r],
|
|
39
|
+
["[Attributes]", t],
|
|
40
|
+
["[Content]", (n ?? []).map((e) => e ? typeof e == "object" && "type" in e ? `${e}` : i(e) : "null")]
|
|
41
|
+
].reduce((e, [t, n]) => {
|
|
42
|
+
let r = `${t}: ${i(n)}.`;
|
|
43
|
+
return e.concat(r);
|
|
44
|
+
}, []);
|
|
45
|
+
return new g(h.createNodeInParserFail, a.join("\n"));
|
|
46
|
+
}
|
|
47
|
+
function pe() {
|
|
48
|
+
return new g(h.stackOverFlow, "Stack over flow, cannot pop on an empty stack.");
|
|
49
|
+
}
|
|
50
|
+
function me(e) {
|
|
51
|
+
return new g(h.parserMatchError, `Cannot match target parser for node: ${se(e)}.`);
|
|
52
|
+
}
|
|
53
|
+
function he(e) {
|
|
54
|
+
return new g(h.serializerMatchError, `Cannot match target serializer for node: ${se(e)}.`);
|
|
55
|
+
}
|
|
56
|
+
function ge(e) {
|
|
57
|
+
return new g(h.expectDomTypeError, `Expect to be a dom, but get: ${se(e)}.`);
|
|
58
|
+
}
|
|
59
|
+
function _e() {
|
|
60
|
+
return new g(h.callCommandBeforeEditorView, "You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized");
|
|
61
|
+
}
|
|
62
|
+
function ve(e) {
|
|
63
|
+
return new g(h.missingNodeInSchema, `Missing node in schema, milkdown cannot find "${e}" in schema.`);
|
|
64
|
+
}
|
|
65
|
+
function ye(e) {
|
|
66
|
+
return new g(h.missingMarkInSchema, `Missing mark in schema, milkdown cannot find "${e}" in schema.`);
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region node_modules/.pnpm/@milkdown+ctx@7.20.0/node_modules/@milkdown/ctx/lib/index.js
|
|
70
|
+
var be = class {
|
|
71
|
+
constructor() {
|
|
72
|
+
this.sliceMap = /* @__PURE__ */ new Map(), this.get = (e) => {
|
|
73
|
+
let t = typeof e == "string" ? [...this.sliceMap.values()].find((t) => t.type.name === e) : this.sliceMap.get(e.id);
|
|
74
|
+
if (!t) throw le(typeof e == "string" ? e : e.name);
|
|
75
|
+
return t;
|
|
76
|
+
}, this.remove = (e) => {
|
|
77
|
+
let t = typeof e == "string" ? [...this.sliceMap.values()].find((t) => t.type.name === e) : this.sliceMap.get(e.id);
|
|
78
|
+
t && this.sliceMap.delete(t.type.id);
|
|
79
|
+
}, this.has = (e) => typeof e == "string" ? [...this.sliceMap.values()].some((t) => t.type.name === e) : this.sliceMap.has(e.id);
|
|
80
|
+
}
|
|
81
|
+
}, xe = class {
|
|
82
|
+
#e = [];
|
|
83
|
+
#t;
|
|
84
|
+
#n = () => {
|
|
85
|
+
this.#e.forEach((e) => e(this.#t));
|
|
86
|
+
};
|
|
87
|
+
constructor(e, t, n) {
|
|
88
|
+
this.set = (e) => {
|
|
89
|
+
this.#t = e, this.#n();
|
|
90
|
+
}, this.get = () => this.#t, this.update = (e) => {
|
|
91
|
+
this.#t = e(this.#t), this.#n();
|
|
92
|
+
}, this.type = n, this.#t = t, e.set(n.id, this);
|
|
93
|
+
}
|
|
94
|
+
on(e) {
|
|
95
|
+
return this.#e.push(e), () => {
|
|
96
|
+
this.#e = this.#e.filter((t) => t !== e);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
once(e) {
|
|
100
|
+
let t = this.on((n) => {
|
|
101
|
+
e(n), t();
|
|
102
|
+
});
|
|
103
|
+
return t;
|
|
104
|
+
}
|
|
105
|
+
off(e) {
|
|
106
|
+
this.#e = this.#e.filter((t) => t !== e);
|
|
107
|
+
}
|
|
108
|
+
offAll() {
|
|
109
|
+
this.#e = [];
|
|
110
|
+
}
|
|
111
|
+
}, Se = class {
|
|
112
|
+
constructor(e, t) {
|
|
113
|
+
this.id = Symbol(`Context-${t}`), this.name = t, this._defaultValue = e, this._typeInfo = () => {
|
|
114
|
+
throw de();
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
create(e, t = this._defaultValue) {
|
|
118
|
+
return new xe(e, t, this);
|
|
119
|
+
}
|
|
120
|
+
}, _ = (e, t) => new Se(e, t), Ce = class {
|
|
121
|
+
#e;
|
|
122
|
+
#t;
|
|
123
|
+
#n;
|
|
124
|
+
#r = /* @__PURE__ */ new Set();
|
|
125
|
+
#i = /* @__PURE__ */ new Set();
|
|
126
|
+
#a = /* @__PURE__ */ new Map();
|
|
127
|
+
#o = /* @__PURE__ */ new Map();
|
|
128
|
+
constructor(e, t, n) {
|
|
129
|
+
this.read = () => ({
|
|
130
|
+
metadata: this.#e,
|
|
131
|
+
injectedSlices: [...this.#r].map((e) => ({
|
|
132
|
+
name: typeof e == "string" ? e : e.name,
|
|
133
|
+
value: this.#s(e)
|
|
134
|
+
})),
|
|
135
|
+
consumedSlices: [...this.#i].map((e) => ({
|
|
136
|
+
name: typeof e == "string" ? e : e.name,
|
|
137
|
+
value: this.#s(e)
|
|
138
|
+
})),
|
|
139
|
+
recordedTimers: [...this.#a].map(([e, { duration: t }]) => ({
|
|
140
|
+
name: e.name,
|
|
141
|
+
duration: t,
|
|
142
|
+
status: this.#c(e)
|
|
143
|
+
})),
|
|
144
|
+
waitTimers: [...this.#o].map(([e, { duration: t }]) => ({
|
|
145
|
+
name: e.name,
|
|
146
|
+
duration: t,
|
|
147
|
+
status: this.#c(e)
|
|
148
|
+
}))
|
|
149
|
+
}), this.onRecord = (e) => {
|
|
150
|
+
this.#a.set(e, {
|
|
151
|
+
start: Date.now(),
|
|
152
|
+
duration: 0
|
|
153
|
+
});
|
|
154
|
+
}, this.onClear = (e) => {
|
|
155
|
+
this.#a.delete(e);
|
|
156
|
+
}, this.onDone = (e) => {
|
|
157
|
+
let t = this.#a.get(e);
|
|
158
|
+
t && (t.duration = Date.now() - t.start);
|
|
159
|
+
}, this.onWait = (e, t) => {
|
|
160
|
+
let n = Date.now();
|
|
161
|
+
t.finally(() => {
|
|
162
|
+
this.#o.set(e, { duration: Date.now() - n });
|
|
163
|
+
}).catch(console.error);
|
|
164
|
+
}, this.onInject = (e) => {
|
|
165
|
+
this.#r.add(e);
|
|
166
|
+
}, this.onRemove = (e) => {
|
|
167
|
+
this.#r.delete(e);
|
|
168
|
+
}, this.onUse = (e) => {
|
|
169
|
+
this.#i.add(e);
|
|
170
|
+
}, this.#t = e, this.#n = t, this.#e = n;
|
|
171
|
+
}
|
|
172
|
+
#s = (e) => this.#t.get(e).get();
|
|
173
|
+
#c = (e) => this.#n.get(e).status;
|
|
174
|
+
}, we = class e {
|
|
175
|
+
#e;
|
|
176
|
+
#t;
|
|
177
|
+
#n;
|
|
178
|
+
#r;
|
|
179
|
+
constructor(t, n, r) {
|
|
180
|
+
this.produce = (t) => t && Object.keys(t).length ? new e(this.#e, this.#t, { ...t }) : this, this.inject = (e, t) => {
|
|
181
|
+
let n = e.create(this.#e.sliceMap);
|
|
182
|
+
return t != null && n.set(t), this.#r?.onInject(e), this;
|
|
183
|
+
}, this.remove = (e) => (this.#e.remove(e), this.#r?.onRemove(e), this), this.record = (e) => (e.create(this.#t.store), this.#r?.onRecord(e), this), this.clearTimer = (e) => (this.#t.remove(e), this.#r?.onClear(e), this), this.isInjected = (e) => this.#e.has(e), this.isRecorded = (e) => this.#t.has(e), this.use = (e) => (this.#r?.onUse(e), this.#e.get(e)), this.get = (e) => this.use(e).get(), this.set = (e, t) => this.use(e).set(t), this.update = (e, t) => this.use(e).update(t), this.timer = (e) => this.#t.get(e), this.done = (e) => {
|
|
184
|
+
this.timer(e).done(), this.#r?.onDone(e);
|
|
185
|
+
}, this.wait = (e) => {
|
|
186
|
+
let t = this.timer(e).start();
|
|
187
|
+
return this.#r?.onWait(e, t), t;
|
|
188
|
+
}, this.waitTimers = async (e) => {
|
|
189
|
+
await Promise.all(this.get(e).map((e) => this.wait(e)));
|
|
190
|
+
}, this.#e = t, this.#t = n, this.#n = r, r && (this.#r = new Ce(t, n, r));
|
|
191
|
+
}
|
|
192
|
+
get meta() {
|
|
193
|
+
return this.#n;
|
|
194
|
+
}
|
|
195
|
+
get inspector() {
|
|
196
|
+
return this.#r;
|
|
197
|
+
}
|
|
198
|
+
}, Te = class {
|
|
199
|
+
constructor() {
|
|
200
|
+
this.store = /* @__PURE__ */ new Map(), this.get = (e) => {
|
|
201
|
+
let t = this.store.get(e.id);
|
|
202
|
+
if (!t) throw ue(e.name);
|
|
203
|
+
return t;
|
|
204
|
+
}, this.remove = (e) => {
|
|
205
|
+
this.store.delete(e.id);
|
|
206
|
+
}, this.has = (e) => this.store.has(e.id);
|
|
207
|
+
}
|
|
208
|
+
}, Ee = class {
|
|
209
|
+
#e = null;
|
|
210
|
+
#t = null;
|
|
211
|
+
#n;
|
|
212
|
+
#r = "pending";
|
|
213
|
+
constructor(e, t) {
|
|
214
|
+
this.start = () => (this.#e ??= new Promise((e, t) => {
|
|
215
|
+
this.#t = (t) => {
|
|
216
|
+
t instanceof CustomEvent && t.detail.id === this.#n && (this.#r = "resolved", this.#i(), t.stopImmediatePropagation(), e());
|
|
217
|
+
}, this.#a(() => {
|
|
218
|
+
this.#r === "pending" && (this.#r = "rejected"), this.#i(), t(/* @__PURE__ */ Error(`Timing ${this.type.name} timeout.`));
|
|
219
|
+
}), this.#r = "pending", addEventListener(this.type.name, this.#t);
|
|
220
|
+
}), this.#e), this.done = () => {
|
|
221
|
+
let e = new CustomEvent(this.type.name, { detail: { id: this.#n } });
|
|
222
|
+
dispatchEvent(e);
|
|
223
|
+
}, this.#n = Symbol(t.name), this.type = t, e.set(t.id, this);
|
|
224
|
+
}
|
|
225
|
+
get status() {
|
|
226
|
+
return this.#r;
|
|
227
|
+
}
|
|
228
|
+
#i = () => {
|
|
229
|
+
this.#t && removeEventListener(this.type.name, this.#t);
|
|
230
|
+
};
|
|
231
|
+
#a = (e) => {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
e();
|
|
234
|
+
}, this.type.timeout);
|
|
235
|
+
};
|
|
236
|
+
}, De = class {
|
|
237
|
+
constructor(e, t = 3e3) {
|
|
238
|
+
this.create = (e) => new Ee(e, this), this.id = Symbol(`Timer-${e}`), this.name = e, this.timeout = t;
|
|
239
|
+
}
|
|
240
|
+
}, v = (e, t = 3e3) => new De(e, t), y = typeof navigator < "u" ? navigator : null, Oe = typeof document < "u" ? document : null, b = y && y.userAgent || "", ke = /Edge\/(\d+)/.exec(b), Ae = /MSIE \d/.exec(b), je = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b), Me = !!(Ae || je || ke);
|
|
241
|
+
Ae ? document.documentMode : je ? +je[1] : ke && +ke[1], !Me && /gecko\/(\d+)/i.test(b) && +(/Firefox\/(\d+)/.exec(b) || [0, 0])[1];
|
|
242
|
+
var Ne = !Me && /Chrome\/(\d+)/.exec(b), Pe = !!Ne;
|
|
243
|
+
Ne && +Ne[1], !Me && y && /Apple Computer/.test(y.vendor) && (/Mobile\/\w+/.test(b) || y && y.maxTouchPoints > 2) || y && /Mac/.test(y.platform);
|
|
244
|
+
var Fe = /Android \d/.test(b);
|
|
245
|
+
Oe && "webkitFontSmoothing" in Oe.documentElement.style && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1];
|
|
246
|
+
function Ie(e, t, n, r, i, a) {
|
|
247
|
+
if (e.composing) return !1;
|
|
248
|
+
let o = e.state, s = o.doc.resolve(t);
|
|
249
|
+
if (s.parent.type.spec.code) return !1;
|
|
250
|
+
let c = s.parent.textBetween(Math.max(0, s.parentOffset - 500), s.parentOffset, void 0, "") + r;
|
|
251
|
+
for (let s of i) {
|
|
252
|
+
let i = s, l = i.match.exec(c), u = l && l[0] && i.handler(o, l, t - (l[0].length - r.length), n);
|
|
253
|
+
if (u) return i.undoable !== !1 && u.setMeta(a, {
|
|
254
|
+
transform: u,
|
|
255
|
+
from: t,
|
|
256
|
+
to: n,
|
|
257
|
+
text: r
|
|
258
|
+
}), e.dispatch(u), !0;
|
|
259
|
+
}
|
|
260
|
+
return !1;
|
|
261
|
+
}
|
|
262
|
+
var Le = new r("MILKDOWN_CUSTOM_INPUTRULES");
|
|
263
|
+
function Re({ rules: e }) {
|
|
264
|
+
let t = new i({
|
|
265
|
+
key: Le,
|
|
266
|
+
isInputRules: !0,
|
|
267
|
+
state: {
|
|
268
|
+
init() {
|
|
269
|
+
return null;
|
|
270
|
+
},
|
|
271
|
+
apply(e, t) {
|
|
272
|
+
return e.getMeta(this) || (e.selectionSet || e.docChanged ? null : t);
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
props: {
|
|
276
|
+
handleTextInput(n, r, i, a) {
|
|
277
|
+
return Ie(n, r, i, a, e, t);
|
|
278
|
+
},
|
|
279
|
+
handleDOMEvents: {
|
|
280
|
+
compositionend: (n) => (setTimeout(() => {
|
|
281
|
+
let { $cursor: r } = n.state.selection;
|
|
282
|
+
r && Ie(n, r.pos, r.pos, "", e, t);
|
|
283
|
+
}), !1),
|
|
284
|
+
keydown: (e, t) => !(Fe && Pe && t.key === "Enter") || e.composing ? !1 : e.someProp("handleKeyDown", (n) => n(e, t)) ? (t.preventDefault(), !0) : !1
|
|
285
|
+
},
|
|
286
|
+
handleKeyDown(n, r) {
|
|
287
|
+
if (r.key !== "Enter") return !1;
|
|
288
|
+
let { $cursor: i } = n.state.selection;
|
|
289
|
+
return i ? Ie(n, i.pos, i.pos, "\n", e, t) : !1;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
return t;
|
|
294
|
+
}
|
|
295
|
+
function ze(e, t, n = {}) {
|
|
296
|
+
return new f(e, (e, r, i, a) => {
|
|
297
|
+
var o;
|
|
298
|
+
let { tr: s } = e, c = r[r.length - 1], l = r[0], u = [], d, f = {
|
|
299
|
+
group: c,
|
|
300
|
+
fullMatch: l,
|
|
301
|
+
start: i,
|
|
302
|
+
end: a
|
|
303
|
+
}, p = n.updateCaptured?.call(n, f);
|
|
304
|
+
if (Object.assign(f, p), {group: c, fullMatch: l, start: i, end: a} = f, l === null || c?.trim() === "") return null;
|
|
305
|
+
if (c) {
|
|
306
|
+
let e = l.search(/\S/), f = i + l.indexOf(c), p = f + c.length;
|
|
307
|
+
u = s.storedMarks ?? [], p < a && s.delete(p, a), f > i && s.delete(i + e, f), d = i + e + c.length;
|
|
308
|
+
let m = n.getAttr?.call(n, r);
|
|
309
|
+
s.addMark(i, d, t.create(m)), s.setStoredMarks(u), (o = n.beforeDispatch) == null || o.call(n, {
|
|
310
|
+
match: r,
|
|
311
|
+
start: i,
|
|
312
|
+
end: a,
|
|
313
|
+
tr: s
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return s;
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function Be(e, t, n = {}) {
|
|
320
|
+
return new f(e, (e, r, i, a) => {
|
|
321
|
+
var o;
|
|
322
|
+
let { tr: s } = e, c = r[1], l = r[0], u = {
|
|
323
|
+
group: c,
|
|
324
|
+
fullMatch: l,
|
|
325
|
+
start: i,
|
|
326
|
+
end: a
|
|
327
|
+
}, d = n.updateCaptured?.call(n, u);
|
|
328
|
+
if (Object.assign(u, d), {group: c, fullMatch: l, start: i, end: a} = u, l === null || !c || c.trim() === "") return null;
|
|
329
|
+
let f = n.getAttr?.call(n, r), p = t.createAndFill(f);
|
|
330
|
+
return p && (s.replaceRangeWith(t.isBlock ? s.doc.resolve(i).before() : i, a, p), (o = n.beforeDispatch) == null || o.call(n, {
|
|
331
|
+
match: [l, c],
|
|
332
|
+
start: i,
|
|
333
|
+
end: a,
|
|
334
|
+
tr: s
|
|
335
|
+
})), s;
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function Ve(e) {
|
|
339
|
+
return Object.assign(Object.create(e), e).setTime(Date.now());
|
|
340
|
+
}
|
|
341
|
+
function He(e, t) {
|
|
342
|
+
return Array.isArray(e) && e.includes(t.type) || t.type === e;
|
|
343
|
+
}
|
|
344
|
+
function Ue(e) {
|
|
345
|
+
if (e.content.childCount === 1) {
|
|
346
|
+
let t = e.content.firstChild;
|
|
347
|
+
if (t?.type.name === "text" && t.marks.length === 0) return t;
|
|
348
|
+
if (t?.type.name === "paragraph" && t.childCount === 1) {
|
|
349
|
+
let e = t.firstChild;
|
|
350
|
+
if (e?.type.name === "text" && e.marks.length === 0) return e;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return !1;
|
|
354
|
+
}
|
|
355
|
+
function We(e, t = !0) {
|
|
356
|
+
let n = [];
|
|
357
|
+
return e.descendants((e, r) => {
|
|
358
|
+
if (n.push({
|
|
359
|
+
node: e,
|
|
360
|
+
pos: r
|
|
361
|
+
}), !t) return !1;
|
|
362
|
+
}), n;
|
|
363
|
+
}
|
|
364
|
+
function Ge(e) {
|
|
365
|
+
return (t, n) => We(t, n).filter((t) => e(t.node));
|
|
366
|
+
}
|
|
367
|
+
function Ke(e) {
|
|
368
|
+
return (t) => {
|
|
369
|
+
for (let n = t.depth; n > 0; --n) {
|
|
370
|
+
let r = t.node(n);
|
|
371
|
+
if (e(r)) return {
|
|
372
|
+
from: t.before(n),
|
|
373
|
+
to: t.after(n),
|
|
374
|
+
node: r
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function qe(e, t) {
|
|
380
|
+
return Ke((e) => e.type === t)(e);
|
|
381
|
+
}
|
|
382
|
+
function Je(e) {
|
|
383
|
+
return (t) => {
|
|
384
|
+
for (let n = t.depth; n > 0; n--) {
|
|
385
|
+
let r = t.node(n);
|
|
386
|
+
if (e(r)) return {
|
|
387
|
+
pos: t.before(n),
|
|
388
|
+
start: t.start(n),
|
|
389
|
+
depth: n,
|
|
390
|
+
node: r
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function Ye(e, t) {
|
|
396
|
+
if (!(e instanceof o)) return;
|
|
397
|
+
let { node: n, $from: r } = e;
|
|
398
|
+
if (He(t, n)) return {
|
|
399
|
+
node: n,
|
|
400
|
+
pos: r.pos,
|
|
401
|
+
start: r.start(r.depth),
|
|
402
|
+
depth: r.depth
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
var Xe = (e, t) => {
|
|
406
|
+
let { selection: n, doc: r } = e;
|
|
407
|
+
if (n instanceof o) return {
|
|
408
|
+
hasNode: n.node.type === t,
|
|
409
|
+
pos: n.from,
|
|
410
|
+
target: n.node
|
|
411
|
+
};
|
|
412
|
+
let { from: i, to: a } = n, s = !1, c = -1, l = null;
|
|
413
|
+
return r.nodesBetween(i, a, (e, n) => l ? !1 : e.type === t ? (s = !0, c = n, l = e, !1) : !0), {
|
|
414
|
+
hasNode: s,
|
|
415
|
+
pos: c,
|
|
416
|
+
target: l
|
|
417
|
+
};
|
|
418
|
+
}, Ze = class {}, Qe = class {
|
|
419
|
+
constructor() {
|
|
420
|
+
this.elements = [], this.size = () => this.elements.length, this.top = () => this.elements.at(-1), this.push = (e) => {
|
|
421
|
+
this.top()?.push(e);
|
|
422
|
+
}, this.open = (e) => {
|
|
423
|
+
this.elements.push(e);
|
|
424
|
+
}, this.close = () => {
|
|
425
|
+
let e = this.elements.pop();
|
|
426
|
+
if (!e) throw pe();
|
|
427
|
+
return e;
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}, $e = class e extends Ze {
|
|
431
|
+
constructor(e, t, n) {
|
|
432
|
+
super(), this.type = e, this.content = t, this.attrs = n;
|
|
433
|
+
}
|
|
434
|
+
push(e, ...t) {
|
|
435
|
+
this.content.push(e, ...t);
|
|
436
|
+
}
|
|
437
|
+
pop() {
|
|
438
|
+
return this.content.pop();
|
|
439
|
+
}
|
|
440
|
+
static create(t, n, r) {
|
|
441
|
+
return new e(t, n, r);
|
|
442
|
+
}
|
|
443
|
+
}, et = class extends Qe {
|
|
444
|
+
#e = s.none;
|
|
445
|
+
static {
|
|
446
|
+
this.create = (e, t) => {
|
|
447
|
+
let n = new this(e);
|
|
448
|
+
return (e) => (n.run(t, e), n.toDoc());
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
constructor(e) {
|
|
452
|
+
super(), this.injectRoot = (e, t, n) => (this.openNode(t, n), this.next(e.children), this), this.openNode = (e, t) => (this.open($e.create(e, [], t)), this), this.closeNode = () => {
|
|
453
|
+
try {
|
|
454
|
+
this.#a();
|
|
455
|
+
} catch (e) {
|
|
456
|
+
console.error(e);
|
|
457
|
+
}
|
|
458
|
+
return this;
|
|
459
|
+
}, this.addNode = (e, t, n) => {
|
|
460
|
+
try {
|
|
461
|
+
this.#o(e, t, n);
|
|
462
|
+
} catch (e) {
|
|
463
|
+
console.error(e);
|
|
464
|
+
}
|
|
465
|
+
return this;
|
|
466
|
+
}, this.openMark = (e, t) => (this.#e = e.create(t).addToSet(this.#e), this), this.closeMark = (e) => (this.#e = e.removeFromSet(this.#e), this), this.addText = (e) => {
|
|
467
|
+
try {
|
|
468
|
+
let t = this.top();
|
|
469
|
+
if (!t) throw pe();
|
|
470
|
+
let n = t.pop(), r = this.schema.text(e, this.#e);
|
|
471
|
+
if (!n) return t.push(r), this;
|
|
472
|
+
let i = this.#n(n, r);
|
|
473
|
+
return i ? (t.push(i), this) : (t.push(n, r), this);
|
|
474
|
+
} catch (e) {
|
|
475
|
+
return console.error(e), this;
|
|
476
|
+
}
|
|
477
|
+
}, this.build = () => {
|
|
478
|
+
let e;
|
|
479
|
+
do
|
|
480
|
+
e = this.#a();
|
|
481
|
+
while (this.size());
|
|
482
|
+
return e;
|
|
483
|
+
}, this.next = (e = []) => ([e].flat().forEach((e) => this.#i(e)), this), this.toDoc = () => this.build(), this.run = (e, t) => {
|
|
484
|
+
let n = e.runSync(e.parse(t), t);
|
|
485
|
+
return this.next(n), this;
|
|
486
|
+
}, this.schema = e;
|
|
487
|
+
}
|
|
488
|
+
#t = (e) => e.isText;
|
|
489
|
+
#n = (e, t) => {
|
|
490
|
+
if (this.#t(e) && this.#t(t) && s.sameSet(e.marks, t.marks)) return this.schema.text(e.text + t.text, e.marks);
|
|
491
|
+
};
|
|
492
|
+
#r = (e) => {
|
|
493
|
+
let t = Object.values({
|
|
494
|
+
...this.schema.nodes,
|
|
495
|
+
...this.schema.marks
|
|
496
|
+
}).find((t) => t.spec.parseMarkdown.match(e));
|
|
497
|
+
if (!t) throw me(e);
|
|
498
|
+
return t;
|
|
499
|
+
};
|
|
500
|
+
#i = (e) => {
|
|
501
|
+
let t = this.#r(e);
|
|
502
|
+
t.spec.parseMarkdown.runner(this, e, t);
|
|
503
|
+
};
|
|
504
|
+
#a = () => {
|
|
505
|
+
this.#e = s.none;
|
|
506
|
+
let e = this.close();
|
|
507
|
+
return this.#o(e.type, e.attrs, e.content);
|
|
508
|
+
};
|
|
509
|
+
#o = (e, t, n) => {
|
|
510
|
+
let r = e.createAndFill(t, n, this.#e);
|
|
511
|
+
if (!r) throw fe(e, t, n);
|
|
512
|
+
return this.push(r), r;
|
|
513
|
+
};
|
|
514
|
+
}, tt = class e extends Ze {
|
|
515
|
+
constructor(e, t, n, r = {}) {
|
|
516
|
+
super(), this.type = e, this.children = t, this.value = n, this.props = r, this.push = (e, ...t) => {
|
|
517
|
+
this.children ||= [], this.children.push(e, ...t);
|
|
518
|
+
}, this.pop = () => this.children?.pop();
|
|
519
|
+
}
|
|
520
|
+
static {
|
|
521
|
+
this.create = (t, n, r, i = {}) => new e(t, n, r, i);
|
|
522
|
+
}
|
|
523
|
+
}, nt = (e) => Object.prototype.hasOwnProperty.call(e, "size"), rt = class extends Qe {
|
|
524
|
+
#e = s.none;
|
|
525
|
+
static {
|
|
526
|
+
this.create = (e, t) => {
|
|
527
|
+
let n = new this(e);
|
|
528
|
+
return (e) => (n.run(e), n.toString(t));
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
constructor(e) {
|
|
532
|
+
super(), this.openNode = (e, t, n) => (this.open(tt.create(e, void 0, t, n)), this), this.closeNode = () => (this.#l(), this), this.addNode = (e, t, n, r) => (this.#u(e, t, n, r), this), this.withMark = (e, t, n, r) => (this.#d(e, t, n, r), this), this.closeMark = (e) => (this.#f(e), this), this.build = () => {
|
|
533
|
+
let e = null;
|
|
534
|
+
do
|
|
535
|
+
e = this.#l();
|
|
536
|
+
while (this.size());
|
|
537
|
+
return e;
|
|
538
|
+
}, this.next = (e) => nt(e) ? (e.forEach((e) => {
|
|
539
|
+
this.#i(e);
|
|
540
|
+
}), this) : (this.#i(e), this), this.toString = (e) => e.stringify(this.build()), this.run = (e) => (this.next(e), this), this.schema = e;
|
|
541
|
+
}
|
|
542
|
+
#t = (e) => {
|
|
543
|
+
let t = Object.values({
|
|
544
|
+
...this.schema.nodes,
|
|
545
|
+
...this.schema.marks
|
|
546
|
+
}).find((t) => t.spec.toMarkdown.match(e));
|
|
547
|
+
if (!t) throw he(e.type);
|
|
548
|
+
return t;
|
|
549
|
+
};
|
|
550
|
+
#n = (e) => this.#t(e).spec.toMarkdown.runner(this, e);
|
|
551
|
+
#r = (e, t) => this.#t(e).spec.toMarkdown.runner(this, e, t);
|
|
552
|
+
#i = (e) => {
|
|
553
|
+
let { marks: t } = e, n = (e) => e.type.spec.priority ?? 50;
|
|
554
|
+
[...t].sort((e, t) => n(e) - n(t)).every((t) => !this.#r(t, e)) && this.#n(e), t.forEach((e) => this.#f(e));
|
|
555
|
+
};
|
|
556
|
+
#a = (e, t) => {
|
|
557
|
+
if (e.type === t || e.children?.length !== 1) return e;
|
|
558
|
+
let n = (e) => {
|
|
559
|
+
if (e.type === t) return e.value == null ? e : null;
|
|
560
|
+
if (e.children?.length !== 1) return null;
|
|
561
|
+
let [r] = e.children;
|
|
562
|
+
return r ? n(r) : null;
|
|
563
|
+
}, r = n(e);
|
|
564
|
+
if (!r) return e;
|
|
565
|
+
let i = r.children ? [...r.children] : void 0, a = {
|
|
566
|
+
...e,
|
|
567
|
+
children: i
|
|
568
|
+
};
|
|
569
|
+
return a.children = i, r.children = [a], r;
|
|
570
|
+
};
|
|
571
|
+
#o = (e) => {
|
|
572
|
+
let { children: t } = e;
|
|
573
|
+
return t && (e.children = t.reduce((e, t, n) => {
|
|
574
|
+
if (n === 0) return [t];
|
|
575
|
+
let r = e.at(-1);
|
|
576
|
+
if (r && r.isMark && t.isMark) {
|
|
577
|
+
t = this.#a(t, r.type);
|
|
578
|
+
let { children: n, ...i } = t, { children: a, ...o } = r;
|
|
579
|
+
if (t.type === r.type && n && a && JSON.stringify(i) === JSON.stringify(o)) {
|
|
580
|
+
let t = {
|
|
581
|
+
...o,
|
|
582
|
+
children: [...a, ...n]
|
|
583
|
+
};
|
|
584
|
+
return e.slice(0, -1).concat(this.#o(t));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return e.concat(t);
|
|
588
|
+
}, [])), e;
|
|
589
|
+
};
|
|
590
|
+
#s = (e) => {
|
|
591
|
+
let t = {
|
|
592
|
+
...e.props,
|
|
593
|
+
type: e.type
|
|
594
|
+
};
|
|
595
|
+
return e.children && (t.children = e.children), e.value && (t.value = e.value), t;
|
|
596
|
+
};
|
|
597
|
+
#c = (e, t) => {
|
|
598
|
+
let n = "", r = "", i = e.children, a = -1, o = -1, s = (e) => {
|
|
599
|
+
e && e.forEach((e, t) => {
|
|
600
|
+
e.type === "text" && e.value && (a < 0 && (a = t), o = t);
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
if (i) {
|
|
604
|
+
s(i);
|
|
605
|
+
let e = i?.[o], t = i?.[a];
|
|
606
|
+
if (e && e.value.endsWith(" ")) {
|
|
607
|
+
let t = e.value, n = t.trimEnd();
|
|
608
|
+
r = t.slice(n.length), e.value = n;
|
|
609
|
+
}
|
|
610
|
+
if (t && t.value.startsWith(" ")) {
|
|
611
|
+
let e = t.value, r = e.trimStart();
|
|
612
|
+
n = e.slice(0, e.length - r.length), t.value = r;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
n.length && this.#u("text", void 0, n);
|
|
616
|
+
let c = t();
|
|
617
|
+
return r.length && this.#u("text", void 0, r), c;
|
|
618
|
+
};
|
|
619
|
+
#l = (e = !1) => {
|
|
620
|
+
let t = this.close(), n = () => this.#u(t.type, t.children, t.value, t.props);
|
|
621
|
+
return e ? this.#c(t, n) : n();
|
|
622
|
+
};
|
|
623
|
+
#u = (e, t, n, r) => {
|
|
624
|
+
let i = tt.create(e, t, n, r), a = this.#o(this.#s(i));
|
|
625
|
+
return this.push(a), a;
|
|
626
|
+
};
|
|
627
|
+
#d = (e, t, n, r) => e.isInSet(this.#e) ? this : (this.#e = e.addToSet(this.#e), this.openNode(t, n, {
|
|
628
|
+
...r,
|
|
629
|
+
isMark: !0
|
|
630
|
+
}));
|
|
631
|
+
#f = (e) => {
|
|
632
|
+
e.isInSet(this.#e) && (this.#e = e.type.removeFromSet(this.#e), this.#l(!0));
|
|
633
|
+
};
|
|
634
|
+
}, it = /* @__PURE__ */ e({
|
|
635
|
+
CommandManager: () => ft,
|
|
636
|
+
CommandsReady: () => z,
|
|
637
|
+
ConfigReady: () => j,
|
|
638
|
+
Editor: () => Bt,
|
|
639
|
+
EditorStateReady: () => J,
|
|
640
|
+
EditorStatus: () => $,
|
|
641
|
+
EditorViewReady: () => jt,
|
|
642
|
+
InitReady: () => M,
|
|
643
|
+
KeymapManager: () => _t,
|
|
644
|
+
KeymapReady: () => V,
|
|
645
|
+
ParserReady: () => H,
|
|
646
|
+
PasteRulesReady: () => Z,
|
|
647
|
+
SchemaReady: () => N,
|
|
648
|
+
SerializerReady: () => W,
|
|
649
|
+
commands: () => ht,
|
|
650
|
+
commandsCtx: () => mt,
|
|
651
|
+
commandsTimerCtx: () => R,
|
|
652
|
+
config: () => ct,
|
|
653
|
+
createCmdKey: () => pt,
|
|
654
|
+
defaultValueCtx: () => Et,
|
|
655
|
+
editorCtx: () => st,
|
|
656
|
+
editorState: () => kt,
|
|
657
|
+
editorStateCtx: () => C,
|
|
658
|
+
editorStateOptionsCtx: () => K,
|
|
659
|
+
editorStateTimerCtx: () => q,
|
|
660
|
+
editorView: () => zt,
|
|
661
|
+
editorViewCtx: () => S,
|
|
662
|
+
editorViewOptionsCtx: () => Mt,
|
|
663
|
+
editorViewTimerCtx: () => Q,
|
|
664
|
+
getDoc: () => Dt,
|
|
665
|
+
init: () => lt,
|
|
666
|
+
initTimerCtx: () => ot,
|
|
667
|
+
inputRulesCtx: () => w,
|
|
668
|
+
keymap: () => yt,
|
|
669
|
+
keymapCtx: () => B,
|
|
670
|
+
keymapTimerCtx: () => vt,
|
|
671
|
+
markViewCtx: () => O,
|
|
672
|
+
marksCtx: () => L,
|
|
673
|
+
nodeViewCtx: () => D,
|
|
674
|
+
nodesCtx: () => I,
|
|
675
|
+
parser: () => St,
|
|
676
|
+
parserCtx: () => U,
|
|
677
|
+
parserTimerCtx: () => xt,
|
|
678
|
+
pasteRule: () => At,
|
|
679
|
+
pasteRulesCtx: () => Y,
|
|
680
|
+
pasteRulesTimerCtx: () => X,
|
|
681
|
+
prosePluginsCtx: () => T,
|
|
682
|
+
remarkCtx: () => k,
|
|
683
|
+
remarkPluginsCtx: () => E,
|
|
684
|
+
remarkStringifyOptionsCtx: () => A,
|
|
685
|
+
rootAttrsCtx: () => Ft,
|
|
686
|
+
rootCtx: () => Nt,
|
|
687
|
+
rootDOMCtx: () => Pt,
|
|
688
|
+
schema: () => dt,
|
|
689
|
+
schemaCtx: () => F,
|
|
690
|
+
schemaTimerCtx: () => P,
|
|
691
|
+
serializer: () => Tt,
|
|
692
|
+
serializerCtx: () => G,
|
|
693
|
+
serializerTimerCtx: () => Ct
|
|
694
|
+
});
|
|
695
|
+
function x(e, t) {
|
|
696
|
+
return e.meta = {
|
|
697
|
+
package: "@milkdown/core",
|
|
698
|
+
group: "System",
|
|
699
|
+
...t
|
|
700
|
+
}, e;
|
|
701
|
+
}
|
|
702
|
+
var at = {
|
|
703
|
+
text: (e, t, n, r) => {
|
|
704
|
+
let i = e.value;
|
|
705
|
+
return /^[^*_\\]*\s+$/.test(i) ? i : n.safe(i, {
|
|
706
|
+
...r,
|
|
707
|
+
encode: []
|
|
708
|
+
});
|
|
709
|
+
},
|
|
710
|
+
strong: (e, t, n, r) => {
|
|
711
|
+
let i = e.marker || n.options.strong || "*", a = n.enter("strong"), o = n.createTracker(r), s = o.move(i + i);
|
|
712
|
+
return s += o.move(n.containerPhrasing(e, {
|
|
713
|
+
before: s,
|
|
714
|
+
after: i,
|
|
715
|
+
...o.current()
|
|
716
|
+
})), s += o.move(i + i), a(), s;
|
|
717
|
+
},
|
|
718
|
+
emphasis: (e, t, n, r) => {
|
|
719
|
+
let i = e.marker || n.options.emphasis || "*", a = n.enter("emphasis"), o = n.createTracker(r), s = o.move(i);
|
|
720
|
+
return s += o.move(n.containerPhrasing(e, {
|
|
721
|
+
before: s,
|
|
722
|
+
after: i,
|
|
723
|
+
...o.current()
|
|
724
|
+
})), s += o.move(i), a(), s;
|
|
725
|
+
}
|
|
726
|
+
}, S = _({}, "editorView"), C = _({}, "editorState"), ot = _([], "initTimer"), st = _({}, "editor"), w = _([], "inputRules"), T = _([], "prosePlugins"), E = _([], "remarkPlugins"), D = _([], "nodeView"), O = _([], "markView"), k = _(m().use(ee).use(d), "remark"), A = _({
|
|
727
|
+
handlers: at,
|
|
728
|
+
encode: []
|
|
729
|
+
}, "remarkStringifyOptions"), j = v("ConfigReady");
|
|
730
|
+
function ct(e) {
|
|
731
|
+
let t = (t) => (t.record(j), async () => (await e(t), t.done(j), () => {
|
|
732
|
+
t.clearTimer(j);
|
|
733
|
+
}));
|
|
734
|
+
return x(t, { displayName: "Config" }), t;
|
|
735
|
+
}
|
|
736
|
+
var M = v("InitReady");
|
|
737
|
+
function lt(e) {
|
|
738
|
+
let t = (t) => (t.inject(st, e).inject(T, []).inject(E, []).inject(w, []).inject(D, []).inject(O, []).inject(A, {
|
|
739
|
+
handlers: at,
|
|
740
|
+
encode: []
|
|
741
|
+
}).inject(k, m().use(ee).use(d)).inject(ot, [j]).record(M), async () => {
|
|
742
|
+
await t.waitTimers(ot);
|
|
743
|
+
let e = t.get(A);
|
|
744
|
+
return t.set(k, m().use(ee).use(d, e)), t.done(M), () => {
|
|
745
|
+
t.remove(st).remove(T).remove(E).remove(w).remove(D).remove(O).remove(A).remove(k).remove(ot).clearTimer(M);
|
|
746
|
+
};
|
|
747
|
+
});
|
|
748
|
+
return x(t, { displayName: "Init" }), t;
|
|
749
|
+
}
|
|
750
|
+
var N = v("SchemaReady"), P = _([], "schemaTimer"), F = _({}, "schema"), I = _([], "nodes"), L = _([], "marks");
|
|
751
|
+
function ut(e) {
|
|
752
|
+
return {
|
|
753
|
+
...e,
|
|
754
|
+
parseDOM: e.parseDOM?.map((t) => ({
|
|
755
|
+
priority: e.priority,
|
|
756
|
+
...t
|
|
757
|
+
}))
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
var dt = (e) => (e.inject(F, {}).inject(I, []).inject(L, []).inject(P, [M]).record(N), async () => {
|
|
761
|
+
await e.waitTimers(P);
|
|
762
|
+
let n = e.get(k), r = e.get(E).reduce((e, t) => e.use(t.plugin, t.options), n);
|
|
763
|
+
e.set(k, r);
|
|
764
|
+
let i = new t({
|
|
765
|
+
nodes: Object.fromEntries(e.get(I).map(([e, t]) => [e, ut(t)])),
|
|
766
|
+
marks: Object.fromEntries(e.get(L).map(([e, t]) => [e, ut(t)]))
|
|
767
|
+
});
|
|
768
|
+
return e.set(F, i), e.done(N), () => {
|
|
769
|
+
e.remove(F).remove(I).remove(L).remove(P).clearTimer(N);
|
|
770
|
+
};
|
|
771
|
+
});
|
|
772
|
+
x(dt, { displayName: "Schema" });
|
|
773
|
+
var ft = class {
|
|
774
|
+
constructor() {
|
|
775
|
+
this.setCtx = (e) => {
|
|
776
|
+
this.#t = e;
|
|
777
|
+
}, this.chain = () => {
|
|
778
|
+
if (this.#t == null) throw _e();
|
|
779
|
+
let e = this.#t, t = [], n = this.get.bind(this), r = {
|
|
780
|
+
run: () => {
|
|
781
|
+
let n = re(...t), r = e.get(S);
|
|
782
|
+
return n(r.state, r.dispatch, r);
|
|
783
|
+
},
|
|
784
|
+
inline: (e) => (t.push(e), r),
|
|
785
|
+
pipe: i.bind(this)
|
|
786
|
+
};
|
|
787
|
+
function i(e, i) {
|
|
788
|
+
let a = n(e);
|
|
789
|
+
return t.push(a(i)), r;
|
|
790
|
+
}
|
|
791
|
+
return r;
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
#e = new be();
|
|
795
|
+
#t = null;
|
|
796
|
+
get ctx() {
|
|
797
|
+
return this.#t;
|
|
798
|
+
}
|
|
799
|
+
create(e, t) {
|
|
800
|
+
let n = e.create(this.#e.sliceMap);
|
|
801
|
+
return n.set(t), n;
|
|
802
|
+
}
|
|
803
|
+
get(e) {
|
|
804
|
+
return this.#e.get(e).get();
|
|
805
|
+
}
|
|
806
|
+
remove(e) {
|
|
807
|
+
return this.#e.remove(e);
|
|
808
|
+
}
|
|
809
|
+
call(e, t) {
|
|
810
|
+
if (this.#t == null) throw _e();
|
|
811
|
+
let n = this.get(e)(t), r = this.#t.get(S);
|
|
812
|
+
return n(r.state, r.dispatch, r);
|
|
813
|
+
}
|
|
814
|
+
inline(e) {
|
|
815
|
+
if (this.#t == null) throw _e();
|
|
816
|
+
let t = this.#t.get(S);
|
|
817
|
+
return e(t.state, t.dispatch, t);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
function pt(e = "cmdKey") {
|
|
821
|
+
return _((() => () => !1), e);
|
|
822
|
+
}
|
|
823
|
+
var mt = _(new ft(), "commands"), R = _([N], "commandsTimer"), z = v("CommandsReady"), ht = (e) => {
|
|
824
|
+
let t = new ft();
|
|
825
|
+
return t.setCtx(e), e.inject(mt, t).inject(R, [N]).record(z), async () => (await e.waitTimers(R), e.done(z), () => {
|
|
826
|
+
e.remove(mt).remove(R).clearTimer(z);
|
|
827
|
+
});
|
|
828
|
+
};
|
|
829
|
+
x(ht, { displayName: "Commands" });
|
|
830
|
+
function gt(e) {
|
|
831
|
+
return e.Backspace = re(u, te, ie, ae), e;
|
|
832
|
+
}
|
|
833
|
+
var _t = class {
|
|
834
|
+
constructor() {
|
|
835
|
+
this.setCtx = (e) => {
|
|
836
|
+
this.#e = e;
|
|
837
|
+
}, this.add = (e) => (this.#t.push(e), () => {
|
|
838
|
+
this.#t = this.#t.filter((t) => t !== e);
|
|
839
|
+
}), this.addObjectKeymap = (e) => {
|
|
840
|
+
let t = [];
|
|
841
|
+
return Object.entries(e).forEach(([e, n]) => {
|
|
842
|
+
if (typeof n == "function") {
|
|
843
|
+
let r = {
|
|
844
|
+
key: e,
|
|
845
|
+
onRun: () => n
|
|
846
|
+
};
|
|
847
|
+
this.#t.push(r), t.push(() => {
|
|
848
|
+
this.#t = this.#t.filter((e) => e !== r);
|
|
849
|
+
});
|
|
850
|
+
} else this.#t.push(n), t.push(() => {
|
|
851
|
+
this.#t = this.#t.filter((e) => e !== n);
|
|
852
|
+
});
|
|
853
|
+
}), () => {
|
|
854
|
+
t.forEach((e) => e());
|
|
855
|
+
};
|
|
856
|
+
}, this.addBaseKeymap = () => {
|
|
857
|
+
let e = gt(ne);
|
|
858
|
+
return this.addObjectKeymap(e);
|
|
859
|
+
}, this.build = () => {
|
|
860
|
+
let e = {};
|
|
861
|
+
return this.#t.forEach((t) => {
|
|
862
|
+
e[t.key] = [...e[t.key] || [], t];
|
|
863
|
+
}), Object.fromEntries(Object.entries(e).map(([e, t]) => {
|
|
864
|
+
let n = t.sort((e, t) => (t.priority ?? 50) - (e.priority ?? 50));
|
|
865
|
+
return [e, (e, t, r) => {
|
|
866
|
+
let i = this.#e;
|
|
867
|
+
if (i == null) throw de();
|
|
868
|
+
return re(...n.map((e) => e.onRun(i)))(e, t, r);
|
|
869
|
+
}];
|
|
870
|
+
}));
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
#e = null;
|
|
874
|
+
#t = [];
|
|
875
|
+
get ctx() {
|
|
876
|
+
return this.#e;
|
|
877
|
+
}
|
|
878
|
+
}, B = _(new _t(), "keymap"), vt = _([N], "keymapTimer"), V = v("KeymapReady"), yt = (e) => {
|
|
879
|
+
let t = new _t();
|
|
880
|
+
return t.setCtx(e), e.inject(B, t).inject(vt, [N]).record(V), async () => (await e.waitTimers(vt), e.done(V), () => {
|
|
881
|
+
e.remove(B).remove(vt).clearTimer(V);
|
|
882
|
+
});
|
|
883
|
+
}, H = v("ParserReady"), bt = (() => {
|
|
884
|
+
throw de();
|
|
885
|
+
}), U = _(bt, "parser"), xt = _([], "parserTimer"), St = (e) => (e.inject(U, bt).inject(xt, [N]).record(H), async () => {
|
|
886
|
+
await e.waitTimers(xt);
|
|
887
|
+
let t = e.get(k), n = e.get(F);
|
|
888
|
+
return e.set(U, et.create(n, t)), e.done(H), () => {
|
|
889
|
+
e.remove(U).remove(xt).clearTimer(H);
|
|
890
|
+
};
|
|
891
|
+
});
|
|
892
|
+
x(St, { displayName: "Parser" });
|
|
893
|
+
var W = v("SerializerReady"), Ct = _([], "serializerTimer"), wt = (() => {
|
|
894
|
+
throw de();
|
|
895
|
+
}), G = _(wt, "serializer"), Tt = (e) => (e.inject(G, wt).inject(Ct, [N]).record(W), async () => {
|
|
896
|
+
await e.waitTimers(Ct);
|
|
897
|
+
let t = e.get(k), n = e.get(F);
|
|
898
|
+
return e.set(G, rt.create(n, t)), e.done(W), () => {
|
|
899
|
+
e.remove(G).remove(Ct).clearTimer(W);
|
|
900
|
+
};
|
|
901
|
+
});
|
|
902
|
+
x(Tt, { displayName: "Serializer" });
|
|
903
|
+
var Et = _("", "defaultValue"), K = _((e) => e, "stateOptions"), q = _([], "editorStateTimer"), J = v("EditorStateReady");
|
|
904
|
+
function Dt(e, t, r) {
|
|
905
|
+
if (typeof e == "string") return t(e);
|
|
906
|
+
if (e.type === "html") return c.fromSchema(r).parse(e.dom);
|
|
907
|
+
if (e.type === "json") return n.fromJSON(r, e.value);
|
|
908
|
+
throw ce(e);
|
|
909
|
+
}
|
|
910
|
+
var Ot = new r("MILKDOWN_STATE_TRACKER"), kt = (e) => (e.inject(Et, "").inject(C, {}).inject(K, (e) => e).inject(q, [
|
|
911
|
+
H,
|
|
912
|
+
W,
|
|
913
|
+
z,
|
|
914
|
+
V
|
|
915
|
+
]).record(J), async () => {
|
|
916
|
+
await e.waitTimers(q);
|
|
917
|
+
let t = e.get(F), n = e.get(U), r = e.get(w), o = e.get(K), s = e.get(T), c = Dt(e.get(Et), n, t), u = e.get(B), d = u.addBaseKeymap(), f = [
|
|
918
|
+
...s,
|
|
919
|
+
new i({
|
|
920
|
+
key: Ot,
|
|
921
|
+
state: {
|
|
922
|
+
init: () => {},
|
|
923
|
+
apply: (t, n, r, i) => {
|
|
924
|
+
e.set(C, i);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}),
|
|
928
|
+
Re({ rules: r }),
|
|
929
|
+
l(u.build())
|
|
930
|
+
];
|
|
931
|
+
e.set(T, f);
|
|
932
|
+
let p = o({
|
|
933
|
+
schema: t,
|
|
934
|
+
doc: c,
|
|
935
|
+
plugins: f
|
|
936
|
+
}), m = a.create(p);
|
|
937
|
+
return e.set(C, m), e.done(J), () => {
|
|
938
|
+
d(), e.remove(Et).remove(C).remove(K).remove(q).clearTimer(J);
|
|
939
|
+
};
|
|
940
|
+
});
|
|
941
|
+
x(kt, { displayName: "EditorState" });
|
|
942
|
+
var Y = _([], "pasteRule"), X = _([N], "pasteRuleTimer"), Z = v("PasteRuleReady"), At = (e) => (e.inject(Y, []).inject(X, [N]).record(Z), async () => (await e.waitTimers(X), e.done(Z), () => {
|
|
943
|
+
e.remove(Y).remove(X).clearTimer(Z);
|
|
944
|
+
}));
|
|
945
|
+
x(At, { displayName: "PasteRule" });
|
|
946
|
+
var jt = v("EditorViewReady"), Q = _([], "editorViewTimer"), Mt = _({}, "editorViewOptions"), Nt = _(null, "root"), Pt = _(null, "rootDOM"), Ft = _({}, "rootAttrs");
|
|
947
|
+
function It(e, t) {
|
|
948
|
+
let n = document.createElement("div");
|
|
949
|
+
n.className = "milkdown", e.appendChild(n), t.set(Pt, n);
|
|
950
|
+
let r = t.get(Ft);
|
|
951
|
+
return Object.entries(r).forEach(([e, t]) => n.setAttribute(e, t)), n;
|
|
952
|
+
}
|
|
953
|
+
function Lt(e) {
|
|
954
|
+
e.classList.add("editor"), e.setAttribute("role", "textbox");
|
|
955
|
+
}
|
|
956
|
+
var Rt = new r("MILKDOWN_VIEW_CLEAR"), zt = (e) => (e.inject(Nt, document.body).inject(S, {}).inject(Mt, {}).inject(Pt, null).inject(Ft, {}).inject(Q, [J, Z]).record(jt), async () => {
|
|
957
|
+
await e.wait(M);
|
|
958
|
+
let t = e.get(Nt) || document.body, n = typeof t == "string" ? document.querySelector(t) : t;
|
|
959
|
+
e.update(T, (t) => [new i({
|
|
960
|
+
key: Rt,
|
|
961
|
+
view: (t) => {
|
|
962
|
+
let r = n ? It(n, e) : void 0;
|
|
963
|
+
return (() => {
|
|
964
|
+
if (r && n) {
|
|
965
|
+
let e = t.dom;
|
|
966
|
+
n.replaceChild(r, e), r.appendChild(e);
|
|
967
|
+
}
|
|
968
|
+
})(), { destroy: () => {
|
|
969
|
+
r?.parentNode && r?.parentNode.replaceChild(t.dom, r), r?.remove();
|
|
970
|
+
} };
|
|
971
|
+
}
|
|
972
|
+
}), ...t]), await e.waitTimers(Q);
|
|
973
|
+
let r = e.get(C), a = e.get(Mt), o = new p(n, {
|
|
974
|
+
state: r,
|
|
975
|
+
nodeViews: Object.fromEntries(e.get(D)),
|
|
976
|
+
markViews: Object.fromEntries(e.get(O)),
|
|
977
|
+
transformPasted: (t, n, r) => (e.get(Y).sort((e, t) => (t.priority ?? 50) - (e.priority ?? 50)).map((e) => e.run).forEach((e) => {
|
|
978
|
+
t = e(t, n, r);
|
|
979
|
+
}), t),
|
|
980
|
+
...a
|
|
981
|
+
});
|
|
982
|
+
return Lt(o.dom), e.set(S, o), e.done(jt), () => {
|
|
983
|
+
o?.destroy(), e.remove(Nt).remove(S).remove(Mt).remove(Pt).remove(Ft).remove(Q).clearTimer(jt);
|
|
984
|
+
};
|
|
985
|
+
});
|
|
986
|
+
x(zt, { displayName: "EditorView" });
|
|
987
|
+
var $ = /* @__PURE__ */ function(e) {
|
|
988
|
+
return e.Idle = "Idle", e.OnCreate = "OnCreate", e.Created = "Created", e.OnDestroy = "OnDestroy", e.Destroyed = "Destroyed", e;
|
|
989
|
+
}({}), Bt = class e {
|
|
990
|
+
constructor() {
|
|
991
|
+
this.enableInspector = (e = !0) => (this.#e = e, this), this.onStatusChange = (e) => (this.#r = e, this), this.config = (e) => (this.#n.push(e), this), this.removeConfig = (e) => (this.#n = this.#n.filter((t) => t !== e), this), this.use = (e) => {
|
|
992
|
+
let t = [e].flat();
|
|
993
|
+
return t.flat().forEach((e) => {
|
|
994
|
+
this.#o.set(e, {
|
|
995
|
+
ctx: void 0,
|
|
996
|
+
handler: void 0,
|
|
997
|
+
cleanup: void 0
|
|
998
|
+
});
|
|
999
|
+
}), this.#t === $.Created && this.#u(t, this.#o), this;
|
|
1000
|
+
}, this.remove = async (e) => this.#t === $.OnCreate ? (console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."), new Promise((t) => {
|
|
1001
|
+
setTimeout(() => {
|
|
1002
|
+
t(this.remove(e));
|
|
1003
|
+
}, 50);
|
|
1004
|
+
})) : (await this.#d([e].flat(), !0), this), this.create = async () => this.#t === $.OnCreate ? this : (this.#t === $.Created && await this.destroy(), this.#p($.OnCreate), this.#l(), this.#u([...this.#o.keys()], this.#o), await Promise.all([this.#m(this.#s), this.#m(this.#o)].flat()), this.#p($.Created), this), this.destroy = async (e = !1) => this.#t === $.Destroyed || this.#t === $.OnDestroy ? this : this.#t === $.OnCreate ? new Promise((t) => {
|
|
1005
|
+
setTimeout(() => {
|
|
1006
|
+
t(this.destroy(e));
|
|
1007
|
+
}, 50);
|
|
1008
|
+
}) : (e && (this.#n = []), this.#p($.OnDestroy), await this.#d([...this.#o.keys()], e), await this.#f(), this.#p($.Destroyed), this), this.action = (e) => e(this.#c), this.inspect = () => this.#e ? [...this.#s.values(), ...this.#o.values()].map(({ ctx: e }) => e?.inspector?.read()).filter((e) => !!e) : (console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."), []);
|
|
1009
|
+
}
|
|
1010
|
+
static make() {
|
|
1011
|
+
return new e();
|
|
1012
|
+
}
|
|
1013
|
+
#e = !1;
|
|
1014
|
+
#t = $.Idle;
|
|
1015
|
+
#n = [];
|
|
1016
|
+
#r = () => void 0;
|
|
1017
|
+
#i = new be();
|
|
1018
|
+
#a = new Te();
|
|
1019
|
+
#o = /* @__PURE__ */ new Map();
|
|
1020
|
+
#s = /* @__PURE__ */ new Map();
|
|
1021
|
+
#c = new we(this.#i, this.#a);
|
|
1022
|
+
#l = () => {
|
|
1023
|
+
let e = ct(async (e) => {
|
|
1024
|
+
await Promise.all(this.#n.map((t) => Promise.resolve(t(e))));
|
|
1025
|
+
}), t = [
|
|
1026
|
+
dt,
|
|
1027
|
+
St,
|
|
1028
|
+
Tt,
|
|
1029
|
+
ht,
|
|
1030
|
+
yt,
|
|
1031
|
+
At,
|
|
1032
|
+
kt,
|
|
1033
|
+
zt,
|
|
1034
|
+
lt(this),
|
|
1035
|
+
e
|
|
1036
|
+
];
|
|
1037
|
+
this.#u(t, this.#s);
|
|
1038
|
+
};
|
|
1039
|
+
#u = (e, t) => {
|
|
1040
|
+
e.forEach((e) => {
|
|
1041
|
+
let n = this.#c.produce(this.#e ? e.meta : void 0), r = e(n);
|
|
1042
|
+
t.set(e, {
|
|
1043
|
+
ctx: n,
|
|
1044
|
+
handler: r,
|
|
1045
|
+
cleanup: void 0
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
#d = (e, t = !1) => Promise.all([e].flat().map(async (e) => {
|
|
1050
|
+
let n = this.#o.get(e)?.cleanup;
|
|
1051
|
+
return t ? this.#o.delete(e) : this.#o.set(e, {
|
|
1052
|
+
ctx: void 0,
|
|
1053
|
+
handler: void 0,
|
|
1054
|
+
cleanup: void 0
|
|
1055
|
+
}), typeof n == "function" ? n() : n;
|
|
1056
|
+
}));
|
|
1057
|
+
#f = async () => {
|
|
1058
|
+
await Promise.all([...this.#s.entries()].map(async ([e, { cleanup: t }]) => typeof t == "function" ? t() : t)), this.#s.clear();
|
|
1059
|
+
};
|
|
1060
|
+
#p = (e) => {
|
|
1061
|
+
this.#t = e, this.#r(e);
|
|
1062
|
+
};
|
|
1063
|
+
#m = (e) => [...e.entries()].map(async ([t, n]) => {
|
|
1064
|
+
let { ctx: r, handler: i } = n;
|
|
1065
|
+
if (!i) return;
|
|
1066
|
+
let a = await i();
|
|
1067
|
+
e.set(t, {
|
|
1068
|
+
ctx: r,
|
|
1069
|
+
handler: i,
|
|
1070
|
+
cleanup: a
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
1073
|
+
get ctx() {
|
|
1074
|
+
return this.#c;
|
|
1075
|
+
}
|
|
1076
|
+
get status() {
|
|
1077
|
+
return this.#t;
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
//#endregion
|
|
1081
|
+
export { Ve as A, v as B, X as C, F as D, A as E, Ye as F, ye as H, Ue as I, ze as L, Xe as M, Je as N, P as O, qe as P, Be as R, Y as S, E as T, ve as U, ge as V, O as _, N as a, I as b, R as c, q as d, S as f, it as g, B as h, V as i, Ge as j, G as k, pt as l, w as m, jt as n, W as o, Q as p, M as r, mt as s, z as t, K as u, L as v, T as w, U as x, D as y, _ as z };
|