zt-react-milkdown 0.1.0 → 0.1.2

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.
Files changed (100) hide show
  1. package/dist/{dist-Cxaq2crg.js → commands-BJpevWrH.js} +123 -123
  2. package/dist/commands-BmZHd6RL.js +2 -0
  3. package/dist/{dist-CPVooDwj.cjs → commands-CM7IuhpT.cjs} +2 -2
  4. package/dist/commands-f4yOm8DQ.cjs +1 -0
  5. package/dist/{debounce-Bqj_3iJs.cjs → debounce-C_TNzOFT.cjs} +1 -1
  6. package/dist/{dist-DaM7GJv6.js → dist-CLTsQjPD.js} +319 -318
  7. package/dist/{dist-CxZn1qUo.js → dist-CZTw9GLV.js} +198 -198
  8. package/dist/dist-DQnWlYyo.cjs +5 -0
  9. package/dist/dist-ZPtYoqTI.cjs +1 -0
  10. package/dist/floating-ui.dom-CV-TLBRq.cjs +1 -0
  11. package/dist/floating-ui.dom-CoOubeUs.js +762 -0
  12. package/dist/index.cjs +25 -149
  13. package/dist/index.mjs +6235 -15737
  14. package/dist/{lib-C8xOD1Bp.cjs → lib-5pUyY-Tl.cjs} +1 -1
  15. package/dist/{lib-DkE7Uq2b.js → lib-Bhr5EVOu.js} +110 -112
  16. package/dist/lib-BmAQCwSQ.cjs +1 -0
  17. package/dist/{lib-wmHesNI0.js → lib-C1A-pN4b.js} +574 -575
  18. package/dist/lib-CVebEyb8.cjs +4 -0
  19. package/dist/lib-ChwoE6v5.js +331 -0
  20. package/dist/lib-DIx8C5AZ.cjs +1 -0
  21. package/dist/lib-DVE2k9i1.js +387 -0
  22. package/dist/{lib-DzK_kn7a.js → lib-D_0WAhKU.js} +3 -3
  23. package/dist/{lib-m8lKZKxK.js → lib-Dd20rlmV.js} +28 -28
  24. package/dist/lib-De0djIEV.cjs +5 -0
  25. package/dist/{lib-D4HMdvmK.cjs → lib-DgEwQN1U.cjs} +1 -1
  26. package/dist/{dist-Dhukmh4L.js → lib-DmD940Fq.js} +2849 -1735
  27. package/dist/lib-Dplx6t-N.cjs +3 -0
  28. package/dist/lib-DzY83R_P.cjs +39 -0
  29. package/dist/lib-F08NY8fk.cjs +1 -0
  30. package/dist/{lib-B0rHJ9lJ.js → lib-_NDReOAt.js} +3 -3
  31. package/dist/{lib-CK9MEMX-.js → lib-bsXGz3fj.js} +28 -27
  32. package/dist/schema-list-D9Q6QKgo.cjs +1 -0
  33. package/dist/schema-list-DooYP5HM.js +110 -0
  34. package/dist/src/core/createEditor.d.ts.map +1 -1
  35. package/dist/src/local/en-US.d.ts.map +1 -1
  36. package/dist/src/local/zh-CN.d.ts.map +1 -1
  37. package/dist/src/plugins/custom/block-transform/block-transform.d.ts +15 -0
  38. package/dist/src/plugins/custom/block-transform/block-transform.d.ts.map +1 -0
  39. package/dist/src/plugins/custom/block-transform/index.d.ts +2 -0
  40. package/dist/src/plugins/custom/block-transform/index.d.ts.map +1 -0
  41. package/dist/src/plugins/custom/math/index.d.ts +6 -0
  42. package/dist/src/plugins/custom/math/index.d.ts.map +1 -1
  43. package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -1
  44. package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts +5 -0
  45. package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts.map +1 -0
  46. package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts +29 -0
  47. package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts.map +1 -0
  48. package/dist/src/plugins/custom/math/math-inline-editable.d.ts +7 -0
  49. package/dist/src/plugins/custom/math/math-inline-editable.d.ts.map +1 -0
  50. package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -1
  51. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +5 -1
  52. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -1
  53. package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
  54. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +34 -3
  55. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -1
  56. package/dist/src/plugins/custom/selection-tooltip/types.d.ts +16 -1
  57. package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -1
  58. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -1
  59. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +4 -0
  60. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -1
  61. package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -1
  62. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
  63. package/dist/src/plugins/preset-common.d.ts +6 -0
  64. package/dist/src/plugins/preset-common.d.ts.map +1 -1
  65. package/dist/src/react/hooks/useMilkdownEditor.d.ts +2 -2
  66. package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -1
  67. package/dist/src/types/editor.d.ts +35 -5
  68. package/dist/src/types/editor.d.ts.map +1 -1
  69. package/dist/state-BC1dqWPQ.cjs +1 -0
  70. package/dist/state-BvRk9kiK.cjs +0 -0
  71. package/dist/state-BvRk9kiK.js +0 -0
  72. package/dist/state-rTW_1XVf.js +3 -0
  73. package/dist/style.css +2 -2
  74. package/package.json +1 -1
  75. package/dist/commands-CDrea4WB.cjs +0 -1
  76. package/dist/commands-DoqeX5uJ.js +0 -36
  77. package/dist/dist-BCCSKc3M.cjs +0 -5
  78. package/dist/dist-C0PSMrs7.cjs +0 -37
  79. package/dist/dist-mOpTMw1E.cjs +0 -1
  80. package/dist/floating-ui.dom-CKbcbmJV.js +0 -883
  81. package/dist/floating-ui.dom-VaZZ2gzS.cjs +0 -1
  82. package/dist/index.browser-5LtNN9G9.cjs +0 -1
  83. package/dist/index.browser-D2DmEB8o.js +0 -26
  84. package/dist/lib-38nxOnTd.cjs +0 -4
  85. package/dist/lib-8Tr6mAln.cjs +0 -1
  86. package/dist/lib-BJgvZywM.cjs +0 -3
  87. package/dist/lib-BNOSyYeU.cjs +0 -3
  88. package/dist/lib-C5AzmhNY.cjs +0 -5
  89. package/dist/lib-CCUU16r8.js +0 -1081
  90. package/dist/lib-DWZA8C0h.cjs +0 -1
  91. package/dist/lib-Dbe-cVjv.js +0 -367
  92. package/dist/lib-IahjxPWM.cjs +0 -3
  93. package/dist/lib-r5eNG0sa.js +0 -754
  94. package/dist/rolldown-runtime-CerMd-t8.cjs +0 -1
  95. package/dist/rolldown-runtime-DnwLefa7.js +0 -23
  96. package/dist/schema-list-DSdBEAWW.js +0 -171
  97. package/dist/schema-list-bL8FNes5.cjs +0 -1
  98. package/dist/state-CHAiIqOA.cjs +0 -1
  99. package/dist/state-DNxqltZl.js +0 -16
  100. /package/dist/{debounce-Cuk3VGPr.js → debounce-Z8-khnlZ.js} +0 -0
@@ -1,754 +0,0 @@
1
- import { O as e, T as t, a as n, i as r, n as i, w as a, x as o } from "./dist-DaM7GJv6.js";
2
- import { a as s, c, f as l, r as u, u as d, y as f } from "./dist-Dhukmh4L.js";
3
- import { a as ee, n as te, r as p, u as ne, y as re } from "./dist-Cxaq2crg.js";
4
- import { t as ie } from "./index.browser-D2DmEB8o.js";
5
- //#region node_modules/.pnpm/@milkdown+exception@7.21.0/node_modules/@milkdown/exception/lib/index.js
6
- var m = /* @__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.aiProviderError = "aiProviderError", e.aiBuildContextError = "aiBuildContextError", e;
8
- }({}), h = class extends Error {
9
- constructor(e, t, n) {
10
- super(t, n), this.name = "MilkdownError", this.code = e, n?.cause !== void 0 && (this.cause = n.cause);
11
- }
12
- }, ae = (e, t) => typeof t == "function" ? "[Function]" : t, g = (e) => JSON.stringify(e, ae);
13
- function oe(e) {
14
- return new h(m.docTypeError, `Doc type error, unsupported type: ${g(e)}`);
15
- }
16
- function se(e) {
17
- return new h(m.contextNotFound, `Context "${e}" not found, do you forget to inject it?`);
18
- }
19
- function _() {
20
- return new h(m.ctxCallOutOfScope, "Should not call a context out of the plugin.");
21
- }
22
- function ce(e, t, n) {
23
- let r = `Cannot create node for ${"name" in e ? e.name : e}`, i = (e) => {
24
- if (e == null) return "null";
25
- if (Array.isArray(e)) return `[${e.map(i).join(", ")}]`;
26
- 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);
27
- if (typeof e == "string" || typeof e == "number" || typeof e == "boolean") return JSON.stringify(e);
28
- if (typeof e == "function") return `[Function: ${e.name || "anonymous"}]`;
29
- try {
30
- return String(e);
31
- } catch {
32
- return "[Unserializable]";
33
- }
34
- }, a = [
35
- ["[Description]", r],
36
- ["[Attributes]", t],
37
- ["[Content]", (n ?? []).map((e) => e ? typeof e == "object" && "type" in e ? `${e}` : i(e) : "null")]
38
- ].reduce((e, [t, n]) => {
39
- let r = `${t}: ${i(n)}.`;
40
- return e.concat(r);
41
- }, []);
42
- return new h(m.createNodeInParserFail, a.join("\n"));
43
- }
44
- function le() {
45
- return new h(m.stackOverFlow, "Stack over flow, cannot pop on an empty stack.");
46
- }
47
- function ue(e) {
48
- return new h(m.parserMatchError, `Cannot match target parser for node: ${g(e)}.`);
49
- }
50
- function de(e) {
51
- return new h(m.serializerMatchError, `Cannot match target serializer for node: ${g(e)}.`);
52
- }
53
- function fe(e, t) {
54
- return new h(m.getAtomFromSchemaFail, `Cannot get ${e}: ${t} from schema.`);
55
- }
56
- function v() {
57
- return new h(m.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");
58
- }
59
- //#endregion
60
- //#region node_modules/.pnpm/@milkdown+prose@7.21.0/node_modules/@milkdown/prose/lib/index.js
61
- var y = typeof navigator < "u" ? navigator : null, pe = typeof document < "u" ? document : null, b = y && y.userAgent || "", me = /Edge\/(\d+)/.exec(b), he = /MSIE \d/.exec(b), x = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b), S = !!(he || x || me);
62
- he ? document.documentMode : x ? +x[1] : me && +me[1], !S && /gecko\/(\d+)/i.test(b) && +(/Firefox\/(\d+)/.exec(b) || [0, 0])[1];
63
- var C = !S && /Chrome\/(\d+)/.exec(b), ge = !!C;
64
- C && +C[1], !S && y && /Apple Computer/.test(y.vendor) && (/Mobile\/\w+/.test(b) || y && y.maxTouchPoints > 2) || y && /Mac/.test(y.platform);
65
- var _e = /Android \d/.test(b);
66
- pe && "webkitFontSmoothing" in pe.documentElement.style && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1];
67
- function w(e, t, n, r, i, a) {
68
- if (e.composing) return !1;
69
- let o = e.state, s = o.doc.resolve(t);
70
- if (s.parent.type.spec.code) return !1;
71
- let c = s.parent.textBetween(Math.max(0, s.parentOffset - 500), s.parentOffset, void 0, "") + r;
72
- for (let s of i) {
73
- let i = s, l = i.match.exec(c), u = l && l[0] && i.handler(o, l, t - (l[0].length - r.length), n);
74
- if (u) return i.undoable !== !1 && u.setMeta(a, {
75
- transform: u,
76
- from: t,
77
- to: n,
78
- text: r
79
- }), e.dispatch(u), !0;
80
- }
81
- return !1;
82
- }
83
- var ve = new n("MILKDOWN_CUSTOM_INPUTRULES");
84
- function ye({ rules: e }) {
85
- let t = new r({
86
- key: ve,
87
- isInputRules: !0,
88
- state: {
89
- init() {
90
- return null;
91
- },
92
- apply(e, t) {
93
- return e.getMeta(this) || (e.selectionSet || e.docChanged ? null : t);
94
- }
95
- },
96
- props: {
97
- handleTextInput(n, r, i, a) {
98
- return w(n, r, i, a, e, t);
99
- },
100
- handleDOMEvents: {
101
- compositionend: (n) => (setTimeout(() => {
102
- let { $cursor: r } = n.state.selection;
103
- r && w(n, r.pos, r.pos, "", e, t);
104
- }), !1),
105
- keydown: (e, t) => !(_e && ge && t.key === "Enter") || e.composing ? !1 : e.someProp("handleKeyDown", (n) => n(e, t)) ? (t.preventDefault(), !0) : !1
106
- },
107
- handleKeyDown(n, r) {
108
- if (r.key !== "Enter") return !1;
109
- let { $cursor: i } = n.state.selection;
110
- return i ? w(n, i.pos, i.pos, "\n", e, t) : !1;
111
- }
112
- }
113
- });
114
- return t;
115
- }
116
- var be = Object.defineProperty, xe = Object.defineProperties, Se = Object.getOwnPropertyDescriptors, Ce = Object.getOwnPropertySymbols, we = Object.prototype.hasOwnProperty, Te = Object.prototype.propertyIsEnumerable, Ee = (e, t, n) => t in e ? be(e, t, {
117
- enumerable: !0,
118
- configurable: !0,
119
- writable: !0,
120
- value: n
121
- }) : e[t] = n, De = (e, t) => {
122
- for (var n in t ||= {}) we.call(t, n) && Ee(e, n, t[n]);
123
- if (Ce) for (var n of Ce(t)) Te.call(t, n) && Ee(e, n, t[n]);
124
- return e;
125
- }, Oe = (e, t) => xe(e, Se(t));
126
- function ke(e = 0, t = 0, n = 0) {
127
- return Math.min(Math.max(e, t), n);
128
- }
129
- function Ae(e, t, n) {
130
- let r = e.state.doc.content.size, i = ke(t, 0, r), a = ke(n, 0, r), o = e.coordsAtPos(i), s = e.coordsAtPos(a, -1), c = Math.min(o.top, s.top), l = Math.max(o.bottom, s.bottom), u = Math.min(o.left, s.left), d = Math.max(o.right, s.right), f = {
131
- top: c,
132
- bottom: l,
133
- left: u,
134
- right: d,
135
- width: d - u,
136
- height: l - c,
137
- x: u,
138
- y: c
139
- };
140
- return Oe(De({}, f), { toJSON: () => f });
141
- }
142
- function je(e) {
143
- if (e.content.childCount === 1) {
144
- let t = e.content.firstChild;
145
- if (t?.type.name === "text" && t.marks.length === 0) return t;
146
- if (t?.type.name === "paragraph" && t.childCount === 1) {
147
- let e = t.firstChild;
148
- if (e?.type.name === "text" && e.marks.length === 0) return e;
149
- }
150
- }
151
- return !1;
152
- }
153
- function Me(e, t) {
154
- let n = t.nodes[e];
155
- if (!n) throw fe("node", e);
156
- return n;
157
- }
158
- //#endregion
159
- //#region node_modules/.pnpm/@milkdown+ctx@7.21.0/node_modules/@milkdown/ctx/lib/index.js
160
- var Ne = class {
161
- constructor() {
162
- this.sliceMap = /* @__PURE__ */ new Map(), this.get = (e) => {
163
- let t = typeof e == "string" ? [...this.sliceMap.values()].find((t) => t.type.name === e) : this.sliceMap.get(e.id);
164
- if (!t) throw se(typeof e == "string" ? e : e.name);
165
- return t;
166
- }, this.remove = (e) => {
167
- let t = typeof e == "string" ? [...this.sliceMap.values()].find((t) => t.type.name === e) : this.sliceMap.get(e.id);
168
- t && this.sliceMap.delete(t.type.id);
169
- }, this.has = (e) => typeof e == "string" ? [...this.sliceMap.values()].some((t) => t.type.name === e) : this.sliceMap.has(e.id);
170
- }
171
- }, Pe = class {
172
- #e;
173
- #t;
174
- #n;
175
- constructor(e, t, n) {
176
- this.#e = [], this.#n = () => {
177
- this.#e.forEach((e) => e(this.#t));
178
- }, this.set = (e) => {
179
- this.#t = e, this.#n();
180
- }, this.get = () => this.#t, this.update = (e) => {
181
- this.#t = e(this.#t), this.#n();
182
- }, this.type = n, this.#t = t, e.set(n.id, this);
183
- }
184
- on(e) {
185
- return this.#e.push(e), () => {
186
- this.#e = this.#e.filter((t) => t !== e);
187
- };
188
- }
189
- once(e) {
190
- let t = this.on((n) => {
191
- e(n), t();
192
- });
193
- return t;
194
- }
195
- off(e) {
196
- this.#e = this.#e.filter((t) => t !== e);
197
- }
198
- offAll() {
199
- this.#e = [];
200
- }
201
- }, Fe = class {
202
- constructor(e, t) {
203
- this.id = Symbol(`Context-${t}`), this.name = t, this._defaultValue = e, this._typeInfo = () => {
204
- throw _();
205
- };
206
- }
207
- create(e, t = this._defaultValue) {
208
- return new Pe(e, t, this);
209
- }
210
- }, T = (e, t) => new Fe(e, t), Ie = class {
211
- #e;
212
- #t;
213
- #n;
214
- #r;
215
- constructor(e, t) {
216
- this.#e = null, this.#t = null, this.#r = "pending", this.start = () => (this.#e ??= new Promise((e, t) => {
217
- this.#t = (t) => {
218
- t instanceof CustomEvent && t.detail.id === this.#n && (this.#r = "resolved", this.#i(), t.stopImmediatePropagation(), e());
219
- }, this.#a(() => {
220
- this.#r === "pending" && (this.#r = "rejected"), this.#i(), t(/* @__PURE__ */ Error(`Timing ${this.type.name} timeout.`));
221
- }), this.#r = "pending", addEventListener(this.type.name, this.#t);
222
- }), this.#e), this.done = () => {
223
- let e = new CustomEvent(this.type.name, { detail: { id: this.#n } });
224
- dispatchEvent(e);
225
- }, this.#i = () => {
226
- this.#t && removeEventListener(this.type.name, this.#t);
227
- }, this.#a = (e) => {
228
- setTimeout(() => {
229
- e();
230
- }, this.type.timeout);
231
- }, this.#n = Symbol(t.name), this.type = t, e.set(t.id, this);
232
- }
233
- get status() {
234
- return this.#r;
235
- }
236
- #i;
237
- #a;
238
- }, Le = class {
239
- constructor(e, t = 3e3) {
240
- this.create = (e) => new Ie(e, this), this.id = Symbol(`Timer-${e}`), this.name = e, this.timeout = t;
241
- }
242
- }, E = (e, t = 3e3) => new Le(e, t), Re = class {}, ze = class {
243
- constructor() {
244
- this.elements = [], this.size = () => this.elements.length, this.top = () => this.elements.at(-1), this.push = (e) => {
245
- this.top()?.push(e);
246
- }, this.open = (e) => {
247
- this.elements.push(e);
248
- }, this.close = () => {
249
- let e = this.elements.pop();
250
- if (!e) throw le();
251
- return e;
252
- };
253
- }
254
- }, Be = class e extends Re {
255
- constructor(e, t, n) {
256
- super(), this.type = e, this.content = t, this.attrs = n;
257
- }
258
- push(e, ...t) {
259
- this.content.push(e, ...t);
260
- }
261
- pop() {
262
- return this.content.pop();
263
- }
264
- static create(t, n, r) {
265
- return new e(t, n, r);
266
- }
267
- }, Ve = class extends ze {
268
- #e;
269
- static {
270
- this.create = (e, t) => {
271
- let n = new this(e);
272
- return (e) => (n.run(t, e), n.toDoc());
273
- };
274
- }
275
- constructor(e) {
276
- super(), this.#e = a.none, this.#t = (e) => e.isText, this.#n = (e, t) => {
277
- if (this.#t(e) && this.#t(t) && a.sameSet(e.marks, t.marks)) return this.schema.text(e.text + t.text, e.marks);
278
- }, this.#r = (e) => {
279
- let t = Object.values({
280
- ...this.schema.nodes,
281
- ...this.schema.marks
282
- }).find((t) => t.spec.parseMarkdown.match(e));
283
- if (!t) throw ue(e);
284
- return t;
285
- }, this.#i = (e) => {
286
- let t = this.#r(e);
287
- t.spec.parseMarkdown.runner(this, e, t);
288
- }, this.injectRoot = (e, t, n) => (this.openNode(t, n), this.next(e.children), this), this.openNode = (e, t) => (this.open(Be.create(e, [], t)), this), this.#a = () => {
289
- this.#e = a.none;
290
- let e = this.close();
291
- return this.#o(e.type, e.attrs, e.content);
292
- }, this.closeNode = () => {
293
- try {
294
- this.#a();
295
- } catch (e) {
296
- console.error(e);
297
- }
298
- return this;
299
- }, this.#o = (e, t, n) => {
300
- let r = e.createAndFill(t, n, this.#e);
301
- if (!r) throw ce(e, t, n);
302
- return this.push(r), r;
303
- }, this.addNode = (e, t, n) => {
304
- try {
305
- this.#o(e, t, n);
306
- } catch (e) {
307
- console.error(e);
308
- }
309
- return this;
310
- }, this.openMark = (e, t) => {
311
- let n = e.create(t);
312
- return this.#e = n.addToSet(this.#e), this;
313
- }, this.closeMark = (e) => (this.#e = e.removeFromSet(this.#e), this), this.addText = (e) => {
314
- try {
315
- let t = this.top();
316
- if (!t) throw le();
317
- let n = t.pop(), r = this.schema.text(e, this.#e);
318
- if (!n) return t.push(r), this;
319
- let i = this.#n(n, r);
320
- return i ? (t.push(i), this) : (t.push(n, r), this);
321
- } catch (e) {
322
- return console.error(e), this;
323
- }
324
- }, this.build = () => {
325
- let e;
326
- do
327
- e = this.#a();
328
- while (this.size());
329
- return e;
330
- }, this.next = (e = []) => ([e].flat().forEach((e) => this.#i(e)), this), this.toDoc = () => this.build(), this.run = (e, t) => {
331
- let n = e.runSync(e.parse(t), t);
332
- return this.next(n), this;
333
- }, this.schema = e;
334
- }
335
- #t;
336
- #n;
337
- #r;
338
- #i;
339
- #a;
340
- #o;
341
- }, He = class e extends Re {
342
- constructor(e, t, n, r = {}) {
343
- super(), this.type = e, this.children = t, this.value = n, this.props = r, this.push = (e, ...t) => {
344
- this.children ||= [], this.children.push(e, ...t);
345
- }, this.pop = () => this.children?.pop();
346
- }
347
- static {
348
- this.create = (t, n, r, i = {}) => new e(t, n, r, i);
349
- }
350
- }, Ue = (e) => Object.prototype.hasOwnProperty.call(e, "size"), We = class extends ze {
351
- #e;
352
- static {
353
- this.create = (e, t) => {
354
- let n = new this(e);
355
- return (e) => (n.run(e), n.toString(t));
356
- };
357
- }
358
- constructor(e) {
359
- super(), this.#e = a.none, this.#t = (e) => {
360
- let t = Object.values({
361
- ...this.schema.nodes,
362
- ...this.schema.marks
363
- }).find((t) => t.spec.toMarkdown.match(e));
364
- if (!t) throw de(e.type);
365
- return t;
366
- }, this.#n = (e) => this.#t(e).spec.toMarkdown.runner(this, e), this.#r = (e, t) => this.#t(e).spec.toMarkdown.runner(this, e, t), this.#i = (e) => {
367
- let { marks: t } = e, n = (e) => e.type.spec.priority ?? 50;
368
- [...t].sort((e, t) => n(e) - n(t)).every((t) => !this.#r(t, e)) && this.#n(e), t.forEach((e) => this.#f(e));
369
- }, this.#a = (e, t) => {
370
- if (e.type === t || e.children?.length !== 1) return e;
371
- let n = (e) => {
372
- if (e.type === t) return e.value == null ? e : null;
373
- if (e.children?.length !== 1) return null;
374
- let [r] = e.children;
375
- return r ? n(r) : null;
376
- }, r = n(e);
377
- if (!r) return e;
378
- let i = r.children ? [...r.children] : void 0, a = {
379
- ...e,
380
- children: i
381
- };
382
- return a.children = i, r.children = [a], r;
383
- }, this.#o = (e) => {
384
- let { children: t } = e;
385
- return t && (e.children = t.reduce((e, t, n) => {
386
- if (n === 0) return [t];
387
- let r = e.at(-1);
388
- if (r && r.isMark && t.isMark) {
389
- t = this.#a(t, r.type);
390
- let { children: n, ...i } = t, { children: a, ...o } = r;
391
- if (t.type === r.type && n && a && JSON.stringify(i) === JSON.stringify(o)) {
392
- let t = {
393
- ...o,
394
- children: [...a, ...n]
395
- };
396
- return e.slice(0, -1).concat(this.#o(t));
397
- }
398
- }
399
- return e.concat(t);
400
- }, [])), e;
401
- }, this.#s = (e) => {
402
- let t = {
403
- ...e.props,
404
- type: e.type
405
- };
406
- return e.children && (t.children = e.children), e.value && (t.value = e.value), t;
407
- }, this.openNode = (e, t, n) => (this.open(He.create(e, void 0, t, n)), this), this.#c = (e, t) => {
408
- let n = "", r = "", i = e.children, a = -1, o = -1, s = (e) => {
409
- e && e.forEach((e, t) => {
410
- e.type === "text" && e.value && (a < 0 && (a = t), o = t);
411
- });
412
- };
413
- if (i) {
414
- s(i);
415
- let e = i?.[o], t = i?.[a];
416
- if (e && e.value.endsWith(" ")) {
417
- let t = e.value, n = t.trimEnd();
418
- r = t.slice(n.length), e.value = n;
419
- }
420
- if (t && t.value.startsWith(" ")) {
421
- let e = t.value, r = e.trimStart();
422
- n = e.slice(0, e.length - r.length), t.value = r;
423
- }
424
- }
425
- n.length && this.#u("text", void 0, n);
426
- let c = t();
427
- return r.length && this.#u("text", void 0, r), c;
428
- }, this.#l = (e = !1) => {
429
- let t = this.close(), n = () => this.#u(t.type, t.children, t.value, t.props);
430
- return e ? this.#c(t, n) : n();
431
- }, this.closeNode = () => (this.#l(), this), this.#u = (e, t, n, r) => {
432
- let i = He.create(e, t, n, r), a = this.#o(this.#s(i));
433
- return this.push(a), a;
434
- }, this.addNode = (e, t, n, r) => (this.#u(e, t, n, r), this), this.#d = (e, t, n, r) => e.isInSet(this.#e) ? this : (this.#e = e.addToSet(this.#e), this.openNode(t, n, {
435
- ...r,
436
- isMark: !0
437
- })), this.#f = (e) => {
438
- e.isInSet(this.#e) && (this.#e = e.type.removeFromSet(this.#e), this.#l(!0));
439
- }, this.withMark = (e, t, n, r) => (this.#d(e, t, n, r), this), this.closeMark = (e) => (this.#f(e), this), this.build = () => {
440
- let e = null;
441
- do
442
- e = this.#l();
443
- while (this.size());
444
- return e;
445
- }, this.next = (e) => Ue(e) ? (e.forEach((e) => {
446
- this.#i(e);
447
- }), this) : (this.#i(e), this), this.toString = (e) => e.stringify(this.build()), this.run = (e) => (this.next(e), this), this.schema = e;
448
- }
449
- #t;
450
- #n;
451
- #r;
452
- #i;
453
- #a;
454
- #o;
455
- #s;
456
- #c;
457
- #l;
458
- #u;
459
- #d;
460
- #f;
461
- };
462
- //#endregion
463
- //#region node_modules/.pnpm/@milkdown+core@7.21.0/node_modules/@milkdown/core/lib/index.js
464
- function D(e, t) {
465
- return e.meta = {
466
- package: "@milkdown/core",
467
- group: "System",
468
- ...t
469
- }, e;
470
- }
471
- var Ge = {
472
- text: (e, t, n, r) => {
473
- let i = e.value;
474
- return /^[^*_\\]*\s+$/.test(i) ? i : n.safe(i, {
475
- ...r,
476
- encode: []
477
- });
478
- },
479
- strong: (e, t, n, r) => {
480
- let i = e.marker || n.options.strong || "*", a = n.enter("strong"), o = n.createTracker(r), s = o.move(i + i);
481
- return s += o.move(n.containerPhrasing(e, {
482
- before: s,
483
- after: i,
484
- ...o.current()
485
- })), s += o.move(i + i), a(), s;
486
- },
487
- emphasis: (e, t, n, r) => {
488
- let i = e.marker || n.options.emphasis || "*", a = n.enter("emphasis"), o = n.createTracker(r), s = o.move(i);
489
- return s += o.move(n.containerPhrasing(e, {
490
- before: s,
491
- after: i,
492
- ...o.current()
493
- })), s += o.move(i), a(), s;
494
- }
495
- }, O = T({}, "editorView"), k = T({}, "editorState");
496
- T([], "initTimer"), T({}, "editor");
497
- var Ke = T([], "inputRules"), A = T([], "prosePlugins"), qe = T([], "remarkPlugins"), Je = T([], "nodeView"), Ye = T([], "markView"), j = T(d().use(f).use(l), "remark");
498
- T({
499
- handlers: Ge,
500
- encode: []
501
- }, "remarkStringifyOptions"), E("ConfigReady");
502
- var Xe = E("InitReady"), M = E("SchemaReady"), Ze = T([], "schemaTimer"), N = T({}, "schema"), P = T([], "nodes"), F = T([], "marks");
503
- function Qe(e) {
504
- return {
505
- ...e,
506
- parseDOM: e.parseDOM?.map((t) => ({
507
- priority: e.priority,
508
- ...t
509
- }))
510
- };
511
- }
512
- D((t) => (t.inject(N, {}).inject(P, []).inject(F, []).inject(Ze, [Xe]).record(M), async () => {
513
- await t.waitTimers(Ze);
514
- let n = t.get(j), r = t.get(qe).reduce((e, t) => e.use(t.plugin, t.options), n);
515
- t.set(j, r);
516
- let i = new e({
517
- nodes: Object.fromEntries(t.get(P).map(([e, t]) => [e, Qe(t)])),
518
- marks: Object.fromEntries(t.get(F).map(([e, t]) => [e, Qe(t)]))
519
- });
520
- return t.set(N, i), t.done(M), () => {
521
- t.remove(N).remove(P).remove(F).remove(Ze).clearTimer(M);
522
- };
523
- }), { displayName: "Schema" });
524
- var $e = class {
525
- constructor() {
526
- this.#e = new Ne(), this.#t = null, this.setCtx = (e) => {
527
- this.#t = e;
528
- }, this.chain = () => {
529
- if (this.#t == null) throw v();
530
- let e = this.#t, t = [], n = this.get.bind(this), r = {
531
- run: () => {
532
- let n = p(...t), r = e.get(O);
533
- return n(r.state, r.dispatch, r);
534
- },
535
- inline: (e) => (t.push(e), r),
536
- pipe: i.bind(this)
537
- };
538
- function i(e, i) {
539
- let a = n(e);
540
- return t.push(a(i)), r;
541
- }
542
- return r;
543
- };
544
- }
545
- #e;
546
- #t;
547
- get ctx() {
548
- return this.#t;
549
- }
550
- create(e, t) {
551
- let n = e.create(this.#e.sliceMap);
552
- return n.set(t), n;
553
- }
554
- get(e) {
555
- return this.#e.get(e).get();
556
- }
557
- remove(e) {
558
- return this.#e.remove(e);
559
- }
560
- call(e, t) {
561
- if (this.#t == null) throw v();
562
- let n = this.get(e)(t), r = this.#t.get(O);
563
- return n(r.state, r.dispatch, r);
564
- }
565
- inline(e) {
566
- if (this.#t == null) throw v();
567
- let t = this.#t.get(O);
568
- return e(t.state, t.dispatch, t);
569
- }
570
- }, et = T(new $e(), "commands"), I = T([M], "commandsTimer"), L = E("CommandsReady");
571
- D((e) => {
572
- let t = new $e();
573
- return t.setCtx(e), e.inject(et, t).inject(I, [M]).record(L), async () => (await e.waitTimers(I), e.done(L), () => {
574
- e.remove(et).remove(I).clearTimer(L);
575
- });
576
- }, { displayName: "Commands" });
577
- function tt(e) {
578
- return e.Backspace = p(c, ee, ne, re), e;
579
- }
580
- var nt = T(new class {
581
- constructor() {
582
- this.#e = null, this.#t = [], this.setCtx = (e) => {
583
- this.#e = e;
584
- }, this.add = (e) => (this.#t.push(e), () => {
585
- this.#t = this.#t.filter((t) => t !== e);
586
- }), this.addObjectKeymap = (e) => {
587
- let t = [];
588
- return Object.entries(e).forEach(([e, n]) => {
589
- if (typeof n == "function") {
590
- let r = {
591
- key: e,
592
- onRun: () => n
593
- };
594
- this.#t.push(r), t.push(() => {
595
- this.#t = this.#t.filter((e) => e !== r);
596
- });
597
- } else this.#t.push(n), t.push(() => {
598
- this.#t = this.#t.filter((e) => e !== n);
599
- });
600
- }), () => {
601
- t.forEach((e) => e());
602
- };
603
- }, this.addBaseKeymap = () => {
604
- let e = tt(te);
605
- return this.addObjectKeymap(e);
606
- }, this.build = () => {
607
- let e = {};
608
- return this.#t.forEach((t) => {
609
- e[t.key] = [...e[t.key] || [], t];
610
- }), Object.fromEntries(Object.entries(e).map(([e, t]) => {
611
- let n = t.sort((e, t) => (t.priority ?? 50) - (e.priority ?? 50));
612
- return [e, (e, t, r) => {
613
- let i = this.#e;
614
- if (i == null) throw _();
615
- return p(...n.map((e) => e.onRun(i)))(e, t, r);
616
- }];
617
- }));
618
- };
619
- }
620
- #e;
621
- #t;
622
- get ctx() {
623
- return this.#e;
624
- }
625
- }(), "keymap");
626
- T([M], "keymapTimer");
627
- var rt = E("KeymapReady"), R = E("ParserReady"), it = (() => {
628
- throw _();
629
- }), z = T(it, "parser"), B = T([], "parserTimer");
630
- D((e) => (e.inject(z, it).inject(B, [M]).record(R), async () => {
631
- await e.waitTimers(B);
632
- let t = e.get(j), n = e.get(N);
633
- return e.set(z, Ve.create(n, t)), e.done(R), () => {
634
- e.remove(z).remove(B).clearTimer(R);
635
- };
636
- }), { displayName: "Parser" });
637
- var V = E("SerializerReady"), H = T([], "serializerTimer"), at = (() => {
638
- throw _();
639
- }), U = T(at, "serializer");
640
- D((e) => (e.inject(U, at).inject(H, [M]).record(V), async () => {
641
- await e.waitTimers(H);
642
- let t = e.get(j), n = e.get(N);
643
- return e.set(U, We.create(n, t)), e.done(V), () => {
644
- e.remove(U).remove(H).clearTimer(V);
645
- };
646
- }), { displayName: "Serializer" });
647
- var W = T("", "defaultValue"), G = T((e) => e, "stateOptions"), K = T([], "editorStateTimer"), q = E("EditorStateReady");
648
- function ot(e, n, r) {
649
- if (typeof e == "string") return n(e);
650
- if (e.type === "html") return o.fromSchema(r).parse(e.dom);
651
- if (e.type === "json") return t.fromJSON(r, e.value);
652
- throw oe(e);
653
- }
654
- var st = new n("MILKDOWN_STATE_TRACKER");
655
- D((e) => (e.inject(W, "").inject(k, {}).inject(G, (e) => e).inject(K, [
656
- R,
657
- V,
658
- L,
659
- rt
660
- ]).record(q), async () => {
661
- await e.waitTimers(K);
662
- let t = e.get(N), n = e.get(z), a = e.get(Ke), o = e.get(G), c = e.get(A), l = ot(e.get(W), n, t), u = e.get(nt), d = u.addBaseKeymap(), f = [
663
- ...c,
664
- new r({
665
- key: st,
666
- state: {
667
- init: () => {},
668
- apply: (t, n, r, i) => {
669
- e.set(k, i);
670
- }
671
- }
672
- }),
673
- ye({ rules: a }),
674
- s(u.build())
675
- ];
676
- e.set(A, f);
677
- let ee = o({
678
- schema: t,
679
- doc: l,
680
- plugins: f
681
- }), te = i.create(ee);
682
- return e.set(k, te), e.done(q), () => {
683
- d(), e.remove(W).remove(k).remove(G).remove(K).clearTimer(q);
684
- };
685
- }), { displayName: "EditorState" });
686
- var J = T([], "pasteRule"), Y = T([M], "pasteRuleTimer"), X = E("PasteRuleReady");
687
- D((e) => (e.inject(J, []).inject(Y, [M]).record(X), async () => (await e.waitTimers(Y), e.done(X), () => {
688
- e.remove(J).remove(Y).clearTimer(X);
689
- })), { displayName: "PasteRule" });
690
- var Z = E("EditorViewReady"), Q = T([], "editorViewTimer"), $ = T({}, "editorViewOptions"), ct = T(null, "root"), lt = T(null, "rootDOM"), ut = T({}, "rootAttrs");
691
- function dt(e, t) {
692
- let n = document.createElement("div");
693
- n.className = "milkdown", e.appendChild(n), t.set(lt, n);
694
- let r = t.get(ut);
695
- return Object.entries(r).forEach(([e, t]) => n.setAttribute(e, t)), n;
696
- }
697
- function ft(e) {
698
- e.classList.add("editor"), e.setAttribute("role", "textbox");
699
- }
700
- var pt = new n("MILKDOWN_VIEW_CLEAR");
701
- D((e) => (e.inject(ct, document.body).inject(O, {}).inject($, {}).inject(lt, null).inject(ut, {}).inject(Q, [q, X]).record(Z), async () => {
702
- await e.wait(Xe);
703
- let t = e.get(ct) || document.body, n = typeof t == "string" ? document.querySelector(t) : t;
704
- e.update(A, (t) => [new r({
705
- key: pt,
706
- view: (t) => {
707
- let r = n ? dt(n, e) : void 0;
708
- return (() => {
709
- if (r && n) {
710
- let e = t.dom;
711
- n.replaceChild(r, e), r.appendChild(e);
712
- }
713
- })(), { destroy: () => {
714
- r?.parentNode && r?.parentNode.replaceChild(t.dom, r), r?.remove();
715
- } };
716
- }
717
- }), ...t]), await e.waitTimers(Q);
718
- let i = e.get(k), a = e.get($), o = new u(n, {
719
- state: i,
720
- nodeViews: Object.fromEntries(e.get(Je)),
721
- markViews: Object.fromEntries(e.get(Ye)),
722
- transformPasted: (t, n, r) => (e.get(J).sort((e, t) => (t.priority ?? 50) - (e.priority ?? 50)).map((e) => e.run).forEach((e) => {
723
- t = e(t, n, r);
724
- }), t),
725
- ...a
726
- });
727
- return ft(o.dom), e.set(O, o), e.done(Z), () => {
728
- o?.destroy(), e.remove(ct).remove(O).remove($).remove(lt).remove(ut).remove(Q).clearTimer(Z);
729
- };
730
- }), { displayName: "EditorView" }), ie("abcedfghicklmn", 10);
731
- function mt(e) {
732
- let t, n = (n) => async () => (await n.wait(M), t = e(n), n.update(A, (e) => [...e, t]), () => {
733
- n.update(A, (e) => e.filter((e) => e !== t));
734
- });
735
- return n.plugin = () => t, n.key = () => t.spec.key, n;
736
- }
737
- function ht(e) {
738
- let t = (n) => async () => {
739
- await n.wait(rt);
740
- let r = n.get(nt), i = e(n), a = r.addObjectKeymap(i);
741
- return t.keymap = i, () => {
742
- a();
743
- };
744
- };
745
- return t;
746
- }
747
- function gt(e, t) {
748
- let n = T(e, t), r = (e) => (e.inject(n), () => () => {
749
- e.remove(n);
750
- });
751
- return r.key = n, r;
752
- }
753
- //#endregion
754
- export { z as a, Me as c, $ as i, je as l, mt as n, N as o, ht as r, U as s, gt as t, Ae as u };