@milkdown/preset-commonmark 7.0.1 → 7.1.1

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/lib/index.es.js CHANGED
@@ -1,107 +1,108 @@
1
- import { $markAttr as K, $markSchema as $, $command as m, $useKeymap as k, $node as te, $nodeAttr as y, $nodeSchema as M, $ctx as F, $inputRule as b, pipe as Pe, $prose as N, $remark as E } from "@milkdown/utils";
2
- import { commandsCtx as g, editorViewCtx as q, serializerCtx as We, parserCtx as qe } from "@milkdown/core";
3
- import { toggleMark as V, setBlockType as S, wrapIn as G } from "@milkdown/prose/commands";
4
- import { Fragment as ne } from "@milkdown/prose/model";
5
- import { expectDomTypeError as w } from "@milkdown/exception";
6
- import { textblockTypeInputRule as re, wrappingInputRule as j, InputRule as oe } from "@milkdown/prose/inputrules";
7
- import { TextSelection as ae, Selection as se, PluginKey as C, Plugin as x } from "@milkdown/prose/state";
8
- import { findSelectedNodeOfType as Fe } from "@milkdown/prose";
9
- import { sinkListItem as Ve, liftListItem as Ge, splitListItem as je } from "@milkdown/prose/schema-list";
10
- import { ReplaceStep as ze, AddMarkStep as Ue } from "@milkdown/prose/transform";
1
+ import { $markAttr as K, $markSchema as B, $command as p, $useKeymap as k, $node as te, $nodeAttr as y, $nodeSchema as M, $ctx as F, $inputRule as b, pipe as We, $prose as v, $remark as $ } from "@milkdown/utils";
2
+ import { commandsCtx as g, editorViewCtx as q, serializerCtx as qe, parserCtx as Fe } from "@milkdown/core";
3
+ import { toggleMark as V, setBlockType as T, wrapIn as z } from "@milkdown/prose/commands";
4
+ import { Fragment as Ve } from "@milkdown/prose/model";
5
+ import { TextSelection as re, Selection as ne, PluginKey as C, Plugin as x } from "@milkdown/prose/state";
6
+ import { expectDomTypeError as N } from "@milkdown/exception";
7
+ import { textblockTypeInputRule as oe, wrappingInputRule as G, InputRule as ae } from "@milkdown/prose/inputrules";
8
+ import ze from "@sindresorhus/slugify";
9
+ import { findSelectedNodeOfType as Ge } from "@milkdown/prose";
10
+ import { sinkListItem as je, liftListItem as Ue, splitListItem as Ye } from "@milkdown/prose/schema-list";
11
+ import { ReplaceStep as Je, AddMarkStep as Qe } from "@milkdown/prose/transform";
11
12
  import { Decoration as Z, DecorationSet as ee } from "@milkdown/prose/view";
12
- import { visit as le } from "unist-util-visit";
13
- import Ye from "remark-inline-links";
14
- const ce = K("emphasis"), ie = $("emphasis", (n) => ({
13
+ import { visit as se } from "unist-util-visit";
14
+ import Xe from "remark-inline-links";
15
+ const le = K("emphasis"), ce = B("emphasis", (t) => ({
15
16
  inclusive: !1,
16
17
  parseDOM: [
17
18
  { tag: "i" },
18
19
  { tag: "em" },
19
20
  { style: "font-style", getAttrs: (e) => e === "italic" }
20
21
  ],
21
- toDOM: (e) => ["em", n.get(ce.key)(e)],
22
+ toDOM: (e) => ["em", t.get(le.key)(e)],
22
23
  parseMarkdown: {
23
24
  match: (e) => e.type === "emphasis",
24
- runner: (e, t, r) => {
25
- e.openMark(r), e.next(t.children), e.closeMark(r);
25
+ runner: (e, r, n) => {
26
+ e.openMark(n), e.next(r.children), e.closeMark(n);
26
27
  }
27
28
  },
28
29
  toMarkdown: {
29
30
  match: (e) => e.type.name === "emphasis",
30
- runner: (e, t) => {
31
- e.withMark(t, "emphasis");
31
+ runner: (e, r) => {
32
+ e.withMark(r, "emphasis");
32
33
  }
33
34
  }
34
- })), de = m("ToggleEmphasis", () => () => V(ie.type())), Je = k("emphasisKeymap", {
35
+ })), ie = p("ToggleEmphasis", () => () => V(ce.type())), Ze = k("emphasisKeymap", {
35
36
  ToggleEmphasis: {
36
37
  shortcuts: "Mod-i",
37
- command: (n) => {
38
- const e = n.get(g);
39
- return () => e.call(de.key);
38
+ command: (t) => {
39
+ const e = t.get(g);
40
+ return () => e.call(ie.key);
40
41
  }
41
42
  }
42
- }), ue = K("strong"), pe = $("strong", (n) => ({
43
+ }), de = K("strong"), ue = B("strong", (t) => ({
43
44
  inclusive: !1,
44
45
  parseDOM: [
45
46
  { tag: "b" },
46
47
  { tag: "strong" },
47
48
  { style: "font-style", getAttrs: (e) => e === "bold" }
48
49
  ],
49
- toDOM: (e) => ["strong", n.get(ue.key)(e)],
50
+ toDOM: (e) => ["strong", t.get(de.key)(e)],
50
51
  parseMarkdown: {
51
52
  match: (e) => e.type === "strong",
52
- runner: (e, t, r) => {
53
- e.openMark(r), e.next(t.children), e.closeMark(r);
53
+ runner: (e, r, n) => {
54
+ e.openMark(n), e.next(r.children), e.closeMark(n);
54
55
  }
55
56
  },
56
57
  toMarkdown: {
57
58
  match: (e) => e.type.name === "strong",
58
- runner: (e, t) => {
59
- e.withMark(t, "strong");
59
+ runner: (e, r) => {
60
+ e.withMark(r, "strong");
60
61
  }
61
62
  }
62
- })), me = m("ToggleStrong", () => () => V(pe.type())), Qe = k("strongKeymap", {
63
+ })), me = p("ToggleStrong", () => () => V(ue.type())), et = k("strongKeymap", {
63
64
  ToggleBold: {
64
65
  shortcuts: ["Mod-b"],
65
- command: (n) => {
66
- const e = n.get(g);
66
+ command: (t) => {
67
+ const e = t.get(g);
67
68
  return () => e.call(me.key);
68
69
  }
69
70
  }
70
- }), ge = K("inlineCode"), A = $("inlineCode", (n) => ({
71
+ }), pe = K("inlineCode"), A = B("inlineCode", (t) => ({
71
72
  priority: 100,
72
73
  code: !0,
73
74
  inclusive: !1,
74
75
  parseDOM: [{ tag: "code" }],
75
- toDOM: (e) => ["code", n.get(ge.key)(e)],
76
+ toDOM: (e) => ["code", t.get(pe.key)(e)],
76
77
  parseMarkdown: {
77
78
  match: (e) => e.type === "inlineCode",
78
- runner: (e, t, r) => {
79
- e.openMark(r), e.addText(t.value), e.closeMark(r);
79
+ runner: (e, r, n) => {
80
+ e.openMark(n), e.addText(r.value), e.closeMark(n);
80
81
  }
81
82
  },
82
83
  toMarkdown: {
83
84
  match: (e) => e.type.name === "inlineCode",
84
- runner: (e, t, r) => {
85
- e.withMark(t, "inlineCode", r.text || "");
85
+ runner: (e, r, n) => {
86
+ e.withMark(r, "inlineCode", n.text || "");
86
87
  }
87
88
  }
88
- })), fe = m("ToggleInlineCode", () => () => (n, e) => {
89
- const { selection: t, tr: r } = n;
90
- if (t.empty)
89
+ })), ge = p("ToggleInlineCode", () => () => (t, e) => {
90
+ const { selection: r, tr: n } = t;
91
+ if (r.empty)
91
92
  return !1;
92
- const { from: o, to: a } = t;
93
- return n.doc.rangeHasMark(o, a, A.type()) ? (e == null || e(r.removeMark(o, a, A.type())), !0) : (Object.keys(n.schema.marks).filter((c) => c !== A.type.name).map((c) => n.schema.marks[c]).forEach((c) => {
94
- r.removeMark(o, a, c);
95
- }), e == null || e(r.addMark(o, a, A.type().create())), !0);
96
- }), Xe = k("inlineCodeKeymap", {
93
+ const { from: o, to: a } = r;
94
+ return t.doc.rangeHasMark(o, a, A.type()) ? (e == null || e(n.removeMark(o, a, A.type())), !0) : (Object.keys(t.schema.marks).filter((c) => c !== A.type.name).map((c) => t.schema.marks[c]).forEach((c) => {
95
+ n.removeMark(o, a, c);
96
+ }), e == null || e(n.addMark(o, a, A.type().create())), !0);
97
+ }), tt = k("inlineCodeKeymap", {
97
98
  ToggleInlineCode: {
98
99
  shortcuts: "Mod-e",
99
- command: (n) => {
100
- const e = n.get(g);
101
- return () => e.call(fe.key);
100
+ command: (t) => {
101
+ const e = t.get(g);
102
+ return () => e.call(ge.key);
102
103
  }
103
104
  }
104
- }), he = K("link"), L = $("link", (n) => ({
105
+ }), fe = K("link"), L = B("link", (t) => ({
105
106
  attrs: {
106
107
  href: {},
107
108
  title: { default: null }
@@ -111,94 +112,96 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
111
112
  tag: "a[href]",
112
113
  getAttrs: (e) => {
113
114
  if (!(e instanceof HTMLElement))
114
- throw w(e);
115
+ throw N(e);
115
116
  return { href: e.getAttribute("href"), title: e.getAttribute("title") };
116
117
  }
117
118
  }
118
119
  ],
119
- toDOM: (e) => ["a", { ...n.get(he.key)(e), ...e.attrs }],
120
+ toDOM: (e) => ["a", { ...t.get(fe.key)(e), ...e.attrs }],
120
121
  parseMarkdown: {
121
122
  match: (e) => e.type === "link",
122
- runner: (e, t, r) => {
123
- const o = t.url, a = t.title;
124
- e.openMark(r, { href: o, title: a }), e.next(t.children), e.closeMark(r);
123
+ runner: (e, r, n) => {
124
+ const o = r.url, a = r.title;
125
+ e.openMark(n, { href: o, title: a }), e.next(r.children), e.closeMark(n);
125
126
  }
126
127
  },
127
128
  toMarkdown: {
128
129
  match: (e) => e.type.name === "link",
129
- runner: (e, t) => {
130
- e.withMark(t, "link", void 0, {
131
- title: t.attrs.title,
132
- url: t.attrs.href
130
+ runner: (e, r) => {
131
+ e.withMark(r, "link", void 0, {
132
+ title: r.attrs.title,
133
+ url: r.attrs.href
133
134
  });
134
135
  }
135
136
  }
136
- })), Ze = m("ToggleLink", () => (n = {}) => V(L.type(), n)), et = m("UpdateLink", () => (n = {}) => (e, t) => {
137
- if (!t)
137
+ })), rt = p("ToggleLink", () => (t = {}) => V(L.type(), t)), nt = p("UpdateLink", () => (t = {}) => (e, r) => {
138
+ if (!r)
138
139
  return !1;
139
- let r, o = -1;
140
+ let n, o = -1;
140
141
  const { selection: a } = e, { from: l, to: s } = a;
141
- if (e.doc.nodesBetween(l, l === s ? s + 1 : s, (p, h) => {
142
- if (L.type().isInSet(p.marks))
143
- return r = p, o = h, !1;
144
- }), !r)
142
+ if (e.doc.nodesBetween(l, l === s ? s + 1 : s, (m, h) => {
143
+ if (L.type().isInSet(m.marks))
144
+ return n = m, o = h, !1;
145
+ }), !n)
145
146
  return !1;
146
- const c = r.marks.find(({ type: p }) => p === L.type());
147
+ const c = n.marks.find(({ type: m }) => m === L.type());
147
148
  if (!c)
148
149
  return !1;
149
- const i = o, d = o + r.nodeSize, { tr: u } = e, f = L.type().create({ ...c.attrs, ...n });
150
- return f ? (t(
151
- u.removeMark(i, d, c).addMark(i, d, f).setSelection(new ae(u.selection.$anchor)).scrollIntoView()
150
+ const i = o, d = o + n.nodeSize, { tr: u } = e, f = L.type().create({ ...c.attrs, ...t });
151
+ return f ? (r(
152
+ u.removeMark(i, d, c).addMark(i, d, f).setSelection(new re(u.selection.$anchor)).scrollIntoView()
152
153
  ), !0) : !1;
153
- }), tt = te("doc", () => ({
154
+ }), ot = te("doc", () => ({
154
155
  content: "block+",
155
156
  parseMarkdown: {
156
- match: ({ type: n }) => n === "root",
157
- runner: (n, e, t) => {
158
- n.injectRoot(e, t);
157
+ match: ({ type: t }) => t === "root",
158
+ runner: (t, e, r) => {
159
+ t.injectRoot(e, r);
159
160
  }
160
161
  },
161
162
  toMarkdown: {
162
- match: (n) => n.type.name === "doc",
163
- runner: (n, e) => {
164
- n.openNode("root"), n.next(e.content);
163
+ match: (t) => t.type.name === "doc",
164
+ runner: (t, e) => {
165
+ t.openNode("root"), t.next(e.content);
165
166
  }
166
167
  }
167
- })), ke = y("paragraph"), T = M("paragraph", (n) => ({
168
+ })), he = (t, e) => {
169
+ var o;
170
+ if (!(e.childCount >= 1 && ((o = e.lastChild) == null ? void 0 : o.type) === w.type())) {
171
+ t.next(e.content);
172
+ return;
173
+ }
174
+ const n = [];
175
+ e.content.forEach((a, l, s) => {
176
+ s !== e.childCount - 1 && n.push(a);
177
+ }), t.next(Ve.fromArray(n));
178
+ }, ke = y("paragraph"), S = M("paragraph", (t) => ({
168
179
  content: "inline*",
169
180
  group: "block",
170
181
  parseDOM: [{ tag: "p" }],
171
- toDOM: (e) => ["p", n.get(ke.key)(e), 0],
182
+ toDOM: (e) => ["p", t.get(ke.key)(e), 0],
172
183
  parseMarkdown: {
173
184
  match: (e) => e.type === "paragraph",
174
- runner: (e, t, r) => {
175
- e.openNode(r), t.children ? e.next(t.children) : e.addText(t.value || ""), e.closeNode();
185
+ runner: (e, r, n) => {
186
+ e.openNode(n), r.children ? e.next(r.children) : e.addText(r.value || ""), e.closeNode();
176
187
  }
177
188
  },
178
189
  toMarkdown: {
179
190
  match: (e) => e.type.name === "paragraph",
180
- runner: (e, t) => {
181
- var o;
182
- if (e.openNode("paragraph"), t.childCount >= 1 && ((o = t.lastChild) == null ? void 0 : o.type.name) === "hardbreak") {
183
- const a = [];
184
- t.content.forEach((l, s, c) => {
185
- c !== t.childCount - 1 && a.push(l);
186
- }), e.next(ne.fromArray(a));
187
- } else
188
- e.next(t.content);
189
- e.closeNode();
191
+ runner: (e, r) => {
192
+ e.openNode("paragraph"), he(e, r), e.closeNode();
190
193
  }
191
194
  }
192
- })), ye = m("TurnIntoText", () => () => S(T.type())), nt = k("paragraphKeymap", {
195
+ })), ye = p("TurnIntoText", () => () => T(S.type())), at = k("paragraphKeymap", {
193
196
  TurnIntoText: {
194
197
  shortcuts: "Mod-Alt-0",
195
- command: (n) => {
196
- const e = n.get(g);
198
+ command: (t) => {
199
+ const e = t.get(g);
197
200
  return () => e.call(ye.key);
198
201
  }
199
202
  }
200
- }), rt = Array(6).fill(0).map((n, e) => e + 1), ot = (n) => n.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), z = F(ot, "headingIdGenerator"), Me = y("heading"), D = M("heading", (n) => {
201
- const e = n.get(z.key);
203
+ }), st = Array(6).fill(0).map((t, e) => e + 1), lt = (t) => ze(t.textContent), j = F(lt, "headingIdGenerator"), Me = y("heading"), D = M("heading", (t) => {
204
+ const e = t.get(j.key);
202
205
  return {
203
206
  content: "inline*",
204
207
  group: "block",
@@ -211,143 +214,135 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
211
214
  default: 1
212
215
  }
213
216
  },
214
- parseDOM: rt.map((t) => ({
215
- tag: `h${t}`,
216
- getAttrs: (r) => {
217
- if (!(r instanceof HTMLElement))
218
- throw w(r);
219
- return { level: t, id: r.id };
217
+ parseDOM: st.map((r) => ({
218
+ tag: `h${r}`,
219
+ getAttrs: (n) => {
220
+ if (!(n instanceof HTMLElement))
221
+ throw N(n);
222
+ return { level: r, id: n.id };
220
223
  }
221
224
  })),
222
- toDOM: (t) => [
223
- `h${t.attrs.level}`,
225
+ toDOM: (r) => [
226
+ `h${r.attrs.level}`,
224
227
  {
225
- ...n.get(Me.key)(t),
226
- id: t.attrs.id || e(t)
228
+ ...t.get(Me.key)(r),
229
+ id: r.attrs.id || e(r)
227
230
  },
228
231
  0
229
232
  ],
230
233
  parseMarkdown: {
231
- match: ({ type: t }) => t === "heading",
232
- runner: (t, r, o) => {
233
- const a = r.depth;
234
- t.openNode(o, { level: a }), t.next(r.children), t.closeNode();
234
+ match: ({ type: r }) => r === "heading",
235
+ runner: (r, n, o) => {
236
+ const a = n.depth;
237
+ r.openNode(o, { level: a }), r.next(n.children), r.closeNode();
235
238
  }
236
239
  },
237
240
  toMarkdown: {
238
- match: (t) => t.type.name === "heading",
239
- runner: (t, r) => {
240
- var a;
241
- if (t.openNode("heading", void 0, { depth: r.attrs.level }), r.childCount >= 1 && ((a = r.lastChild) == null ? void 0 : a.type.name) === "hardbreak") {
242
- const l = [];
243
- r.content.forEach((s, c, i) => {
244
- i !== r.childCount - 1 && l.push(s);
245
- }), t.next(ne.fromArray(l));
246
- } else
247
- t.next(r.content);
248
- t.closeNode();
241
+ match: (r) => r.type.name === "heading",
242
+ runner: (r, n) => {
243
+ r.openNode("heading", void 0, { depth: n.attrs.level }), he(r, n), r.closeNode();
249
244
  }
250
245
  }
251
246
  };
252
- }), at = b((n) => re(/^(?<hashes>#+)\s$/, D.type(), (e) => {
247
+ }), ct = b((t) => oe(/^(?<hashes>#+)\s$/, D.type(), (e) => {
253
248
  var l, s;
254
- const t = ((s = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : s.length) || 0, r = n.get(q), { $from: o } = r.state.selection, a = o.node();
249
+ const r = ((s = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : s.length) || 0, n = t.get(q), { $from: o } = n.state.selection, a = o.node();
255
250
  if (a.type.name === "heading") {
256
- let c = Number(a.attrs.level) + Number(t);
251
+ let c = Number(a.attrs.level) + Number(r);
257
252
  return c > 6 && (c = 6), { level: c };
258
253
  }
259
- return { level: t };
260
- })), I = m("WrapInHeading", () => (n) => (n ?? (n = 1), n < 1 ? S(T.type()) : S(D.type(), { level: n }))), Ie = m("DowngradeHeading", () => () => (n, e, t) => {
261
- const { $from: r } = n.selection, o = r.node();
262
- if (o.type !== D.type() || !n.selection.empty || r.parentOffset !== 0)
254
+ return { level: r };
255
+ })), I = p("WrapInHeading", () => (t) => (t ?? (t = 1), t < 1 ? T(S.type()) : T(D.type(), { level: t }))), Ie = p("DowngradeHeading", () => () => (t, e, r) => {
256
+ const { $from: n } = t.selection, o = n.node();
257
+ if (o.type !== D.type() || !t.selection.empty || n.parentOffset !== 0)
263
258
  return !1;
264
259
  const a = o.attrs.level - 1;
265
260
  return a ? (e == null || e(
266
- n.tr.setNodeMarkup(n.selection.$from.before(), void 0, {
261
+ t.tr.setNodeMarkup(t.selection.$from.before(), void 0, {
267
262
  ...o.attrs,
268
263
  level: a
269
264
  })
270
- ), !0) : S(T.type())(n, e, t);
271
- }), st = k("headingKeymap", {
265
+ ), !0) : T(S.type())(t, e, r);
266
+ }), it = k("headingKeymap", {
272
267
  TurnIntoH1: {
273
268
  shortcuts: "Mod-Alt-1",
274
- command: (n) => {
275
- const e = n.get(g);
269
+ command: (t) => {
270
+ const e = t.get(g);
276
271
  return () => e.call(I.key, 1);
277
272
  }
278
273
  },
279
274
  TurnIntoH2: {
280
275
  shortcuts: "Mod-Alt-2",
281
- command: (n) => {
282
- const e = n.get(g);
276
+ command: (t) => {
277
+ const e = t.get(g);
283
278
  return () => e.call(I.key, 2);
284
279
  }
285
280
  },
286
281
  TurnIntoH3: {
287
282
  shortcuts: "Mod-Alt-3",
288
- command: (n) => {
289
- const e = n.get(g);
283
+ command: (t) => {
284
+ const e = t.get(g);
290
285
  return () => e.call(I.key, 3);
291
286
  }
292
287
  },
293
288
  TurnIntoH4: {
294
289
  shortcuts: "Mod-Alt-4",
295
- command: (n) => {
296
- const e = n.get(g);
290
+ command: (t) => {
291
+ const e = t.get(g);
297
292
  return () => e.call(I.key, 3);
298
293
  }
299
294
  },
300
295
  TurnIntoH5: {
301
296
  shortcuts: "Mod-Alt-5",
302
- command: (n) => {
303
- const e = n.get(g);
297
+ command: (t) => {
298
+ const e = t.get(g);
304
299
  return () => e.call(I.key, 3);
305
300
  }
306
301
  },
307
302
  TurnIntoH6: {
308
303
  shortcuts: "Mod-Alt-6",
309
- command: (n) => {
310
- const e = n.get(g);
304
+ command: (t) => {
305
+ const e = t.get(g);
311
306
  return () => e.call(I.key, 3);
312
307
  }
313
308
  },
314
309
  DowngradeHeading: {
315
310
  shortcuts: ["Delete", "Backspace"],
316
- command: (n) => {
317
- const e = n.get(g);
311
+ command: (t) => {
312
+ const e = t.get(g);
318
313
  return () => e.call(Ie.key);
319
314
  }
320
315
  }
321
- }), be = y("blockquote"), U = M("blockquote", (n) => ({
316
+ }), be = y("blockquote"), U = M("blockquote", (t) => ({
322
317
  content: "block+",
323
318
  group: "block",
324
319
  defining: !0,
325
320
  parseDOM: [{ tag: "blockquote" }],
326
- toDOM: (e) => ["blockquote", n.get(be.key)(e), 0],
321
+ toDOM: (e) => ["blockquote", t.get(be.key)(e), 0],
327
322
  parseMarkdown: {
328
323
  match: ({ type: e }) => e === "blockquote",
329
- runner: (e, t, r) => {
330
- e.openNode(r).next(t.children).closeNode();
324
+ runner: (e, r, n) => {
325
+ e.openNode(n).next(r.children).closeNode();
331
326
  }
332
327
  },
333
328
  toMarkdown: {
334
329
  match: (e) => e.type.name === "blockquote",
335
- runner: (e, t) => {
336
- e.openNode("blockquote").next(t.content).closeNode();
330
+ runner: (e, r) => {
331
+ e.openNode("blockquote").next(r.content).closeNode();
337
332
  }
338
333
  }
339
- })), lt = b(() => j(/^\s*>\s$/, U.type())), we = m("WrapInBlockquote", () => () => G(U.type())), ct = k("blockquoteKeymap", {
334
+ })), dt = b(() => G(/^\s*>\s$/, U.type())), Ne = p("WrapInBlockquote", () => () => z(U.type())), ut = k("blockquoteKeymap", {
340
335
  WrapInBlockquote: {
341
336
  shortcuts: "Mod-Shift-b",
342
- command: (n) => {
343
- const e = n.get(g);
344
- return () => e.call(we.key);
337
+ command: (t) => {
338
+ const e = t.get(g);
339
+ return () => e.call(Ne.key);
345
340
  }
346
341
  }
347
- }), Ne = y("codeBlock", () => ({
342
+ }), we = y("codeBlock", () => ({
348
343
  pre: {},
349
344
  code: {}
350
- })), Y = M("code_block", (n) => ({
345
+ })), Y = M("code_block", (t) => ({
351
346
  content: "text*",
352
347
  group: "block",
353
348
  marks: "",
@@ -364,52 +359,52 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
364
359
  preserveWhitespace: "full",
365
360
  getAttrs: (e) => {
366
361
  if (!(e instanceof HTMLElement))
367
- throw w(e);
362
+ throw N(e);
368
363
  return { language: e.dataset.language };
369
364
  }
370
365
  }
371
366
  ],
372
367
  toDOM: (e) => {
373
- const t = n.get(Ne.key)(e);
368
+ const r = t.get(we.key)(e);
374
369
  return [
375
370
  "pre",
376
371
  {
377
- ...t.pre,
372
+ ...r.pre,
378
373
  "data-language": e.attrs.language
379
374
  },
380
- ["code", t.code, 0]
375
+ ["code", r.code, 0]
381
376
  ];
382
377
  },
383
378
  parseMarkdown: {
384
379
  match: ({ type: e }) => e === "code",
385
- runner: (e, t, r) => {
386
- const o = t.lang, a = t.value;
387
- e.openNode(r, { language: o }), a && e.addText(a), e.closeNode();
380
+ runner: (e, r, n) => {
381
+ const o = r.lang, a = r.value;
382
+ e.openNode(n, { language: o }), a && e.addText(a), e.closeNode();
388
383
  }
389
384
  },
390
385
  toMarkdown: {
391
386
  match: (e) => e.type.name === "code_block",
392
- runner: (e, t) => {
393
- var r;
394
- e.addNode("code", void 0, ((r = t.content.firstChild) == null ? void 0 : r.text) || "", {
395
- lang: t.attrs.language
387
+ runner: (e, r) => {
388
+ var n;
389
+ e.addNode("code", void 0, ((n = r.content.firstChild) == null ? void 0 : n.text) || "", {
390
+ lang: r.attrs.language
396
391
  });
397
392
  }
398
393
  }
399
- })), it = b(() => re(/^```(?<language>[a-z]*)?[\s\n]$/, Y.type(), (n) => {
394
+ })), mt = b(() => oe(/^```(?<language>[a-z]*)?[\s\n]$/, Y.type(), (t) => {
400
395
  var e;
401
396
  return {
402
- language: ((e = n.groups) == null ? void 0 : e.language) ?? ""
397
+ language: ((e = t.groups) == null ? void 0 : e.language) ?? ""
403
398
  };
404
- })), Ce = m("CreateCodeBlock", () => (n = "") => S(Y.type(), { language: n })), fn = m("UpdateCodeBlockLanguage", () => ({ pos: n, language: e } = { pos: -1, language: "" }) => (t, r) => n >= 0 ? (r == null || r(t.tr.setNodeAttribute(n, "language", e)), !0) : !1), dt = k("codeBlockKeymap", {
399
+ })), ve = p("CreateCodeBlock", () => (t = "") => T(Y.type(), { language: t })), Ir = p("UpdateCodeBlockLanguage", () => ({ pos: t, language: e } = { pos: -1, language: "" }) => (r, n) => t >= 0 ? (n == null || n(r.tr.setNodeAttribute(t, "language", e)), !0) : !1), pt = k("codeBlockKeymap", {
405
400
  CreateCodeBlock: {
406
401
  shortcuts: "Mod-Alt-c",
407
- command: (n) => {
408
- const e = n.get(g);
409
- return () => e.call(Ce.key);
402
+ command: (t) => {
403
+ const e = t.get(g);
404
+ return () => e.call(ve.key);
410
405
  }
411
406
  }
412
- }), xe = y("image"), B = M("image", (n) => ({
407
+ }), Ce = y("image"), E = M("image", (t) => ({
413
408
  inline: !0,
414
409
  group: "inline",
415
410
  selectable: !0,
@@ -428,7 +423,7 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
428
423
  tag: "img[src]",
429
424
  getAttrs: (e) => {
430
425
  if (!(e instanceof HTMLElement))
431
- throw w(e);
426
+ throw N(e);
432
427
  return {
433
428
  src: e.getAttribute("src") || "",
434
429
  alt: e.getAttribute("alt") || "",
@@ -437,12 +432,12 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
437
432
  }
438
433
  }
439
434
  ],
440
- toDOM: (e) => ["img", { ...n.get(xe.key)(e), ...e.attrs }],
435
+ toDOM: (e) => ["img", { ...t.get(Ce.key)(e), ...e.attrs }],
441
436
  parseMarkdown: {
442
437
  match: ({ type: e }) => e === "image",
443
- runner: (e, t, r) => {
444
- const o = t.url, a = t.alt, l = t.title;
445
- e.addNode(r, {
438
+ runner: (e, r, n) => {
439
+ const o = r.url, a = r.alt, l = r.title;
440
+ e.addNode(n, {
446
441
  src: o,
447
442
  alt: a,
448
443
  title: l
@@ -451,34 +446,34 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
451
446
  },
452
447
  toMarkdown: {
453
448
  match: (e) => e.type.name === "image",
454
- runner: (e, t) => {
449
+ runner: (e, r) => {
455
450
  e.addNode("image", void 0, void 0, {
456
- title: t.attrs.title,
457
- url: t.attrs.src,
458
- alt: t.attrs.alt
451
+ title: r.attrs.title,
452
+ url: r.attrs.src,
453
+ alt: r.attrs.alt
459
454
  });
460
455
  }
461
456
  }
462
- })), ut = m("InsertImage", () => (n = {}) => (e, t) => {
463
- if (!t)
464
- return !0;
465
- const { src: r = "", alt: o = "", title: a = "" } = n, l = B.type().create({ src: r, alt: o, title: a });
466
- return l && t(e.tr.replaceSelectionWith(l).scrollIntoView()), !0;
467
- }), pt = m("UpdateImage", () => (n = {}) => (e, t) => {
468
- const r = Fe(e.selection, B.type());
457
+ })), gt = p("InsertImage", () => (t = {}) => (e, r) => {
469
458
  if (!r)
459
+ return !0;
460
+ const { src: n = "", alt: o = "", title: a = "" } = t, l = E.type().create({ src: n, alt: o, title: a });
461
+ return l && r(e.tr.replaceSelectionWith(l).scrollIntoView()), !0;
462
+ }), ft = p("UpdateImage", () => (t = {}) => (e, r) => {
463
+ const n = Ge(e.selection, E.type());
464
+ if (!n)
470
465
  return !1;
471
- const { node: o, pos: a } = r, l = { ...o.attrs }, { src: s, alt: c, title: i } = n;
472
- return s !== void 0 && (l.src = s), c !== void 0 && (l.alt = c), i !== void 0 && (l.title = i), t == null || t(e.tr.setNodeMarkup(a, void 0, l).scrollIntoView()), !0;
473
- }), hn = b(() => new oe(
466
+ const { node: o, pos: a } = n, l = { ...o.attrs }, { src: s, alt: c, title: i } = t;
467
+ return s !== void 0 && (l.src = s), c !== void 0 && (l.alt = c), i !== void 0 && (l.title = i), r == null || r(e.tr.setNodeMarkup(a, void 0, l).scrollIntoView()), !0;
468
+ }), br = b(() => new ae(
474
469
  /!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
475
- (n, e, t, r) => {
470
+ (t, e, r, n) => {
476
471
  const [o, a, l = "", s] = e;
477
- return o ? n.tr.replaceWith(t, r, B.type().create({ src: l, alt: a, title: s })) : null;
472
+ return o ? t.tr.replaceWith(r, n, E.type().create({ src: l, alt: a, title: s })) : null;
478
473
  }
479
- )), Ae = y("hardbreak", (n) => ({
480
- "data-is-inline": n.attrs.isInline
481
- })), v = M("hardbreak", (n) => ({
474
+ )), xe = y("hardbreak", (t) => ({
475
+ "data-is-inline": t.attrs.isInline
476
+ })), w = M("hardbreak", (t) => ({
482
477
  inline: !0,
483
478
  group: "inline",
484
479
  attrs: {
@@ -488,48 +483,50 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
488
483
  },
489
484
  selectable: !1,
490
485
  parseDOM: [{ tag: "br" }],
491
- toDOM: (e) => ["br", n.get(Ae.key)(e)],
486
+ toDOM: (e) => ["br", t.get(xe.key)(e)],
492
487
  parseMarkdown: {
493
488
  match: ({ type: e }) => e === "break",
494
- runner: (e, t, r) => {
489
+ runner: (e, r, n) => {
495
490
  var o;
496
- e.addNode(r, { isInline: Boolean((o = t.data) == null ? void 0 : o.isInline) });
491
+ e.addNode(n, { isInline: Boolean((o = r.data) == null ? void 0 : o.isInline) });
497
492
  }
498
493
  },
494
+ leafText: () => `
495
+ `,
499
496
  toMarkdown: {
500
497
  match: (e) => e.type.name === "hardbreak",
501
- runner: (e, t) => {
502
- t.attrs.isInline ? e.addNode("text", void 0, `
498
+ runner: (e, r) => {
499
+ r.attrs.isInline ? e.addNode("text", void 0, `
503
500
  `) : e.addNode("break");
504
501
  }
505
502
  }
506
- })), Le = m("InsertHardbreak", () => () => (n, e) => {
503
+ })), Ae = p("InsertHardbreak", () => () => (t, e) => {
507
504
  var o;
508
- const { selection: t, tr: r } = n;
509
- if (t.empty) {
510
- const a = t.$from.node();
505
+ const { selection: r, tr: n } = t;
506
+ if (r.empty) {
507
+ const a = r.$from.node();
511
508
  if (a.childCount > 0 && ((o = a.lastChild) == null ? void 0 : o.type.name) === "hardbreak")
512
509
  return e == null || e(
513
- r.replaceRangeWith(t.to - 1, t.to, n.schema.node("paragraph")).setSelection(se.near(r.doc.resolve(t.to))).scrollIntoView()
510
+ n.replaceRangeWith(r.to - 1, r.to, t.schema.node("paragraph")).setSelection(ne.near(n.doc.resolve(r.to))).scrollIntoView()
514
511
  ), !0;
515
512
  }
516
- return e == null || e(r.setMeta("hardbreak", !0).replaceSelectionWith(v.type().create()).scrollIntoView()), !0;
517
- }), mt = k("hardbreakKeymap", {
513
+ return e == null || e(n.setMeta("hardbreak", !0).replaceSelectionWith(w.type().create()).scrollIntoView()), !0;
514
+ }), ht = k("hardbreakKeymap", {
518
515
  InsertHardbreak: {
519
516
  shortcuts: "Shift-Enter",
520
- command: (n) => {
521
- const e = n.get(g);
522
- return () => e.call(Le.key);
517
+ command: (t) => {
518
+ const e = t.get(g);
519
+ return () => e.call(Ae.key);
523
520
  }
524
521
  }
525
- }), ve = y("hr"), J = M("hr", (n) => ({
522
+ }), Le = y("hr"), J = M("hr", (t) => ({
526
523
  group: "block",
527
524
  parseDOM: [{ tag: "hr" }],
528
- toDOM: (e) => ["hr", n.get(ve.key)(e)],
525
+ toDOM: (e) => ["hr", t.get(Le.key)(e)],
529
526
  parseMarkdown: {
530
527
  match: ({ type: e }) => e === "thematicBreak",
531
- runner: (e, t, r) => {
532
- e.addNode(r);
528
+ runner: (e, r, n) => {
529
+ e.addNode(n);
533
530
  }
534
531
  },
535
532
  toMarkdown: {
@@ -538,21 +535,21 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
538
535
  e.addNode("thematicBreak");
539
536
  }
540
537
  }
541
- })), gt = b(() => new oe(
538
+ })), kt = b(() => new ae(
542
539
  /^(?:---|___\s|\*\*\*\s)$/,
543
- (n, e, t, r) => {
544
- const { tr: o } = n;
545
- return e[0] && o.replaceWith(t - 1, r, J.type().create()), o;
540
+ (t, e, r, n) => {
541
+ const { tr: o } = t;
542
+ return e[0] && o.replaceWith(r - 1, n, J.type().create()), o;
546
543
  }
547
- )), ft = m("InsertHr", () => () => (n, e) => {
544
+ )), yt = p("InsertHr", () => () => (t, e) => {
548
545
  if (!e)
549
546
  return !0;
550
- const t = T.node.type().create(), { tr: r, selection: o } = n, { from: a } = o, l = J.type().create();
547
+ const r = S.node.type().create(), { tr: n, selection: o } = t, { from: a } = o, l = J.type().create();
551
548
  if (!l)
552
549
  return !0;
553
- const s = r.replaceSelectionWith(l).insert(a, t), c = se.findFrom(s.doc.resolve(a), 1, !0);
550
+ const s = n.replaceSelectionWith(l).insert(a, r), c = ne.findFrom(s.doc.resolve(a), 1, !0);
554
551
  return c && e(s.setSelection(c).scrollIntoView()), !0;
555
- }), Se = y("bulletList"), R = M("bullet_list", (n) => ({
552
+ }), Te = y("bulletList"), R = M("bullet_list", (t) => ({
556
553
  content: "listItem+",
557
554
  group: "block",
558
555
  attrs: {
@@ -565,7 +562,7 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
565
562
  tag: "ul",
566
563
  getAttrs: (e) => {
567
564
  if (!(e instanceof HTMLElement))
568
- throw w(e);
565
+ throw N(e);
569
566
  return {
570
567
  spread: e.dataset.spread
571
568
  };
@@ -575,33 +572,33 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
575
572
  toDOM: (e) => [
576
573
  "ul",
577
574
  {
578
- ...n.get(Se.key)(e),
575
+ ...t.get(Te.key)(e),
579
576
  "data-spread": e.attrs.spread
580
577
  },
581
578
  0
582
579
  ],
583
580
  parseMarkdown: {
584
- match: ({ type: e, ordered: t }) => e === "list" && !t,
585
- runner: (e, t, r) => {
586
- const o = t.spread != null ? `${t.spread}` : "false";
587
- e.openNode(r, { spread: o }).next(t.children).closeNode();
581
+ match: ({ type: e, ordered: r }) => e === "list" && !r,
582
+ runner: (e, r, n) => {
583
+ const o = r.spread != null ? `${r.spread}` : "false";
584
+ e.openNode(n, { spread: o }).next(r.children).closeNode();
588
585
  }
589
586
  },
590
587
  toMarkdown: {
591
588
  match: (e) => e.type.name === "bullet_list",
592
- runner: (e, t) => {
593
- e.openNode("list", void 0, { ordered: !1, spread: t.attrs.spread === "true" }).next(t.content).closeNode();
589
+ runner: (e, r) => {
590
+ e.openNode("list", void 0, { ordered: !1, spread: r.attrs.spread === "true" }).next(r.content).closeNode();
594
591
  }
595
592
  }
596
- })), ht = b(() => j(/^\s*([-+*])\s$/, R.type())), Te = m("WrapInBulletList", () => () => G(R.type())), kt = k("bulletListKeymap", {
593
+ })), Mt = b(() => G(/^\s*([-+*])\s$/, R.type())), Se = p("WrapInBulletList", () => () => z(R.type())), It = k("bulletListKeymap", {
597
594
  WrapInBulletList: {
598
595
  shortcuts: "Mod-Alt-8",
599
- command: (n) => {
600
- const e = n.get(g);
601
- return () => e.call(Te.key);
596
+ command: (t) => {
597
+ const e = t.get(g);
598
+ return () => e.call(Se.key);
602
599
  }
603
600
  }
604
- }), De = y("orderedList"), P = M("ordered_list", (n) => ({
601
+ }), De = y("orderedList"), P = M("ordered_list", (t) => ({
605
602
  content: "listItem+",
606
603
  group: "block",
607
604
  attrs: {
@@ -617,7 +614,7 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
617
614
  tag: "ol",
618
615
  getAttrs: (e) => {
619
616
  if (!(e instanceof HTMLElement))
620
- throw w(e);
617
+ throw N(e);
621
618
  return {
622
619
  spread: e.dataset.spread,
623
620
  order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
@@ -628,39 +625,39 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
628
625
  toDOM: (e) => [
629
626
  "ol",
630
627
  {
631
- ...n.get(De.key)(e),
628
+ ...t.get(De.key)(e),
632
629
  ...e.attrs.order === 1 ? {} : e.attrs.order,
633
630
  "data-spread": e.attrs.spread
634
631
  },
635
632
  0
636
633
  ],
637
634
  parseMarkdown: {
638
- match: ({ type: e, ordered: t }) => e === "list" && !!t,
639
- runner: (e, t, r) => {
640
- const o = t.spread != null ? `${t.spread}` : "true";
641
- e.openNode(r, { spread: o }).next(t.children).closeNode();
635
+ match: ({ type: e, ordered: r }) => e === "list" && !!r,
636
+ runner: (e, r, n) => {
637
+ const o = r.spread != null ? `${r.spread}` : "true";
638
+ e.openNode(n, { spread: o }).next(r.children).closeNode();
642
639
  }
643
640
  },
644
641
  toMarkdown: {
645
642
  match: (e) => e.type.name === "ordered_list",
646
- runner: (e, t) => {
647
- e.openNode("list", void 0, { ordered: !0, start: 1, spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
643
+ runner: (e, r) => {
644
+ e.openNode("list", void 0, { ordered: !0, start: 1, spread: r.attrs.spread === "true" }), e.next(r.content), e.closeNode();
648
645
  }
649
646
  }
650
- })), yt = b(() => j(
647
+ })), bt = b(() => G(
651
648
  /^\s*(\d+)\.\s$/,
652
649
  P.type(),
653
- (n) => ({ order: Number(n[1]) }),
654
- (n, e) => e.childCount + e.attrs.order === Number(n[1])
655
- )), Oe = m("WrapInOrderedList", () => () => G(P.type())), Mt = k("orderedListKeymap", {
650
+ (t) => ({ order: Number(t[1]) }),
651
+ (t, e) => e.childCount + e.attrs.order === Number(t[1])
652
+ )), Oe = p("WrapInOrderedList", () => () => z(P.type())), Nt = k("orderedListKeymap", {
656
653
  WrapInOrderedList: {
657
654
  shortcuts: "Mod-Alt-7",
658
- command: (n) => {
659
- const e = n.get(g);
655
+ command: (t) => {
656
+ const e = t.get(g);
660
657
  return () => e.call(Oe.key);
661
658
  }
662
659
  }
663
- }), He = y("listItem"), O = M("list_item", (n) => ({
660
+ }), He = y("listItem"), O = M("list_item", (t) => ({
664
661
  group: "listItem",
665
662
  content: "paragraph block*",
666
663
  attrs: {
@@ -680,7 +677,7 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
680
677
  tag: "li",
681
678
  getAttrs: (e) => {
682
679
  if (!(e instanceof HTMLElement))
683
- throw w(e);
680
+ throw N(e);
684
681
  return {
685
682
  label: e.dataset.label,
686
683
  listType: e.dataset["list-type"],
@@ -692,7 +689,7 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
692
689
  toDOM: (e) => [
693
690
  "li",
694
691
  {
695
- ...n.get(He.key)(e),
692
+ ...t.get(He.key)(e),
696
693
  "data-label": e.attrs.label,
697
694
  "data-list-type": e.attrs.listType,
698
695
  "data-spread": e.attrs.spread
@@ -701,366 +698,400 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
701
698
  ],
702
699
  parseMarkdown: {
703
700
  match: ({ type: e }) => e === "listItem",
704
- runner: (e, t, r) => {
705
- const o = t.label != null ? `${t.label}.` : "•", a = t.label != null ? "ordered" : "bullet", l = t.spread != null ? `${t.spread}` : "true";
706
- e.openNode(r, { label: o, listType: a, spread: l }), e.next(t.children), e.closeNode();
701
+ runner: (e, r, n) => {
702
+ const o = r.label != null ? `${r.label}.` : "•", a = r.label != null ? "ordered" : "bullet", l = r.spread != null ? `${r.spread}` : "true";
703
+ e.openNode(n, { label: o, listType: a, spread: l }), e.next(r.children), e.closeNode();
707
704
  }
708
705
  },
709
706
  toMarkdown: {
710
707
  match: (e) => e.type.name === "list_item",
711
- runner: (e, t) => {
712
- e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
708
+ runner: (e, r) => {
709
+ e.openNode("listItem", void 0, { spread: r.attrs.spread === "true" }), e.next(r.content), e.closeNode();
713
710
  }
714
711
  }
715
- })), _e = m("SinkListItem", () => () => Ve(O.type())), Ke = m("SplitListItem", () => () => Ge(O.type())), $e = m("SplitListItem", () => () => je(O.type())), It = k("listItemKeymap", {
712
+ })), _e = p("SinkListItem", () => () => je(O.type())), Ke = p("SplitListItem", () => () => Ue(O.type())), Be = p("SplitListItem", () => () => Ye(O.type())), wt = k("listItemKeymap", {
716
713
  NextListItem: {
717
714
  shortcuts: "Enter",
718
- command: (n) => {
719
- const e = n.get(g);
720
- return () => e.call($e.key);
715
+ command: (t) => {
716
+ const e = t.get(g);
717
+ return () => e.call(Be.key);
721
718
  }
722
719
  },
723
720
  SinkListItem: {
724
721
  shortcuts: ["Tab", "Mod-]"],
725
- command: (n) => {
726
- const e = n.get(g);
722
+ command: (t) => {
723
+ const e = t.get(g);
727
724
  return () => e.call(_e.key);
728
725
  }
729
726
  },
730
727
  LiftListItem: {
731
728
  shortcuts: ["Shift-Tab", "Mod-["],
732
- command: (n) => {
733
- const e = n.get(g);
729
+ command: (t) => {
730
+ const e = t.get(g);
734
731
  return () => e.call(Ke.key);
735
732
  }
736
733
  }
737
- }), bt = te("text", () => ({
734
+ }), vt = te("text", () => ({
738
735
  group: "inline",
739
736
  parseMarkdown: {
740
- match: ({ type: n }) => n === "text",
741
- runner: (n, e) => {
742
- n.addText(e.value);
737
+ match: ({ type: t }) => t === "text",
738
+ runner: (t, e) => {
739
+ t.addText(e.value);
743
740
  }
744
741
  },
745
742
  toMarkdown: {
746
- match: (n) => n.type.name === "text",
747
- runner: (n, e) => {
748
- n.addNode("text", void 0, e.text);
743
+ match: (t) => t.type.name === "text",
744
+ runner: (t, e) => {
745
+ t.addNode("text", void 0, e.text);
749
746
  }
750
747
  }
751
- })), wt = [
752
- tt,
748
+ })), $e = y("html"), Ct = M("html", (t) => ({
749
+ atom: !0,
750
+ group: "inline",
751
+ inline: !0,
752
+ attrs: {
753
+ value: {
754
+ default: ""
755
+ }
756
+ },
757
+ toDOM: (e) => {
758
+ const r = document.createElement("span"), n = {
759
+ ...t.get($e.key)(e),
760
+ "data-value": e.attrs.value,
761
+ "data-type": "html"
762
+ };
763
+ return r.textContent = e.attrs.value, ["span", n, e.attrs.value];
764
+ },
765
+ parseDOM: [{
766
+ tag: 'span[data-type="html"]',
767
+ getAttrs: (e) => ({
768
+ value: e.dataset.value ?? ""
769
+ })
770
+ }],
771
+ parseMarkdown: {
772
+ match: ({ type: e }) => Boolean(e === "html"),
773
+ runner: (e, r, n) => {
774
+ e.addNode(n, { value: r.value });
775
+ }
776
+ },
777
+ toMarkdown: {
778
+ match: (e) => e.type.name === "html",
779
+ runner: (e, r) => {
780
+ e.addNode("html", void 0, r.attrs.value);
781
+ }
782
+ }
783
+ })), xt = [
784
+ ot,
753
785
  ke,
754
- T,
755
- z,
786
+ S,
787
+ j,
756
788
  Me,
757
789
  D,
758
- Ae,
759
- v,
790
+ xe,
791
+ w,
760
792
  be,
761
793
  U,
762
- Ne,
794
+ we,
763
795
  Y,
764
- ve,
796
+ Le,
765
797
  J,
766
- xe,
767
- B,
768
- Se,
798
+ Ce,
799
+ E,
800
+ Te,
769
801
  R,
770
802
  De,
771
803
  P,
772
804
  He,
773
805
  O,
806
+ le,
774
807
  ce,
775
- ie,
808
+ de,
776
809
  ue,
777
810
  pe,
778
- ge,
779
811
  A,
780
- he,
812
+ fe,
781
813
  L,
782
- bt
783
- ].flat(), Nt = [
784
- lt,
785
- ht,
786
- yt,
787
- it,
788
- gt,
789
- at
790
- ].flat(), Ct = [
814
+ $e,
815
+ Ct,
816
+ vt
817
+ ].flat(), At = [
818
+ dt,
819
+ Mt,
820
+ bt,
821
+ mt,
822
+ kt,
823
+ ct
824
+ ].flat(), Lt = [
791
825
  ye,
792
- we,
826
+ Ne,
793
827
  I,
794
828
  Ie,
795
- Ce,
796
- Le,
829
+ ve,
830
+ Ae,
831
+ yt,
832
+ gt,
797
833
  ft,
798
- ut,
799
- pt,
800
834
  Oe,
801
- Te,
835
+ Se,
802
836
  _e,
803
- $e,
837
+ Be,
804
838
  Ke,
805
- de,
806
- fe,
839
+ ie,
840
+ ge,
807
841
  me,
842
+ rt,
843
+ nt
844
+ ], Tt = [
845
+ ut,
846
+ pt,
847
+ ht,
848
+ it,
849
+ wt,
850
+ Nt,
851
+ It,
852
+ at,
808
853
  Ze,
854
+ tt,
809
855
  et
810
- ], xt = [
811
- ct,
812
- dt,
813
- mt,
814
- st,
815
- It,
816
- Mt,
817
- kt,
818
- nt,
819
- Je,
820
- Xe,
821
- Qe
822
- ].flat(), W = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, At = (n) => new RegExp(`\\\\(?=[^\\w\\s${n}\\\\]|_)`, "g"), Lt = (n) => {
823
- let e = n, t = e.match(W);
824
- for (; t && t.groups; ) {
825
- const { span: r } = t.groups;
826
- e = e.replace(W, r), t = e.match(W);
856
+ ].flat(), W = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, St = (t) => new RegExp(`\\\\(?=[^\\w\\s${t}\\\\]|_)`, "g"), Dt = (t) => {
857
+ let e = t, r = e.match(W);
858
+ for (; r && r.groups; ) {
859
+ const { span: n } = r.groups;
860
+ e = e.replace(W, n), r = e.match(W);
827
861
  }
828
862
  return e;
829
- }, vt = (n, e, t) => {
830
- const r = n.split(""), o = r[e];
831
- return r[e] && r[t] && (r[e] = r[t], r[t] = o), r.join("").toString();
832
- }, St = (n) => (e) => e.replace(At(n), ""), Tt = (n) => (e) => {
833
- const t = e.indexOf(n.hole), r = e.charAt(t - 1), o = e.charAt(t + 1), a = /[^\w]|_/;
834
- return o ? r && a.test(r) && a.test(o) ? n.punctuation : n.char : n.punctuation;
835
- }, Dt = (n, e, t) => {
836
- let r = e, o = !1;
837
- return n.descendants((a) => {
863
+ }, Ot = (t, e, r) => {
864
+ const n = t.split(""), o = n[e];
865
+ return n[e] && n[r] && (n[e] = n[r], n[r] = o), n.join("").toString();
866
+ }, Ht = (t) => (e) => e.replace(St(t), ""), _t = (t) => (e) => {
867
+ const r = e.indexOf(t.hole), n = e.charAt(r - 1), o = e.charAt(r + 1), a = /[^\w]|_/;
868
+ return o ? n && a.test(n) && a.test(o) ? t.punctuation : t.char : t.punctuation;
869
+ }, Kt = (t, e, r) => {
870
+ let n = e, o = !1;
871
+ return t.descendants((a) => {
838
872
  var l;
839
873
  if (o)
840
874
  return !1;
841
875
  if (a.isText) {
842
- const s = (l = a.text) == null ? void 0 : l.indexOf(t);
876
+ const s = (l = a.text) == null ? void 0 : l.indexOf(r);
843
877
  if (s != null && s >= 0)
844
- return o = !0, r += s, !1;
878
+ return o = !0, n += s, !1;
845
879
  }
846
- r += a.nodeSize;
847
- }), r;
848
- }, Ot = {
880
+ n += a.nodeSize;
881
+ }), n;
882
+ }, Bt = {
849
883
  placeholderConfig: {
850
884
  hole: "∅",
851
885
  punctuation: "⁂",
852
886
  char: "∴"
853
887
  },
854
888
  globalNodes: ["footnote_definition"],
855
- shouldSyncNode: ({ prevNode: n, nextNode: e }) => n.inlineContent && e && n.type === e.type && !n.eq(e),
856
- movePlaceholder: (n, e) => {
857
- const t = ["*", "_"];
858
- let r = e.indexOf(n);
859
- for (; t.includes(e[r - 1] || "") && t.includes(e[r + 1] || ""); )
860
- e = vt(e, r, r + 1), r = r + 1;
889
+ shouldSyncNode: ({ prevNode: t, nextNode: e }) => t.inlineContent && e && t.type === e.type && !t.eq(e),
890
+ movePlaceholder: (t, e) => {
891
+ const r = ["*", "_"];
892
+ let n = e.indexOf(t);
893
+ for (; r.includes(e[n - 1] || "") && r.includes(e[n + 1] || ""); )
894
+ e = Ot(e, n, n + 1), n = n + 1;
861
895
  return e;
862
896
  }
863
- }, H = F(Ot, "inlineSyncConfig"), Ht = (n) => {
864
- const { selection: e } = n, { $from: t } = e;
865
- return t.node();
866
- }, _t = (n, e, t, r) => {
867
- const o = n.get(We), a = e.schema.topNodeType.create(void 0, [t, ...r]);
897
+ }, H = F(Bt, "inlineSyncConfig"), $t = (t) => t.selection.$from.node(), Et = (t, e, r, n) => {
898
+ const o = t.get(qe), a = e.schema.topNodeType.create(void 0, [r, ...n]);
868
899
  return o(a);
869
- }, Kt = (n, e) => {
870
- const t = n.get(H.key), r = t.placeholderConfig.hole, [o = "", ...a] = e.split(`
900
+ }, Rt = (t, e) => {
901
+ const r = t.get(H.key), n = r.placeholderConfig.hole, [o = "", ...a] = e.split(`
871
902
 
872
- `), l = (d) => t.movePlaceholder(r, d);
873
- let c = Pe(St(r), l, Lt)(o);
874
- const i = Tt(t.placeholderConfig)(c);
875
- return c = c.replace(r, i), c = [c, ...a].join(`
903
+ `), l = (d) => r.movePlaceholder(n, d);
904
+ let c = We(Ht(n), l, Dt)(o);
905
+ const i = _t(r.placeholderConfig)(c);
906
+ return c = c.replace(n, i), c = [c, ...a].join(`
876
907
 
877
908
  `), [c, i];
878
- }, $t = (n, e) => {
879
- const r = n.get(qe)(e);
880
- return r ? r.firstChild : null;
881
- }, Et = (n, e) => {
882
- const { globalNodes: t } = n.get(H.key), r = [];
909
+ }, Pt = (t, e) => {
910
+ const n = t.get(Fe)(e);
911
+ return n ? n.firstChild : null;
912
+ }, Wt = (t, e) => {
913
+ const { globalNodes: r } = t.get(H.key), n = [];
883
914
  return e.doc.descendants((o) => {
884
- if (t.includes(o.type.name) || t.includes(o.type))
885
- return r.push(o), !1;
886
- }), r;
887
- }, Bt = (n) => n.split(`
915
+ if (r.includes(o.type.name) || r.includes(o.type))
916
+ return n.push(o), !1;
917
+ }), n;
918
+ }, qt = (t) => t.split(`
888
919
 
889
- `)[0] || "", Ee = (n, e) => {
920
+ `)[0] || "", Ft = (t) => t.childCount === 1 && t.child(0).type.name === "html", Ee = (t, e) => {
890
921
  try {
891
- const t = Et(n, e), r = Ht(e), o = _t(n, e, r, t), [a, l] = Kt(n, o), s = $t(n, a);
892
- return !s || r.type !== s.type ? null : (s.attrs = { ...r.attrs }, s.descendants((c) => {
922
+ const r = Wt(t, e), n = $t(e), o = Et(t, e, n, r), [a, l] = Rt(t, o), s = Pt(t, a);
923
+ return !s || n.type !== s.type || Ft(s) ? null : (s.attrs = { ...n.attrs }, s.descendants((c) => {
893
924
  var u;
894
925
  const d = c.marks.find((f) => f.type.name === "link");
895
926
  d && ((u = c.text) == null ? void 0 : u.includes(l)) && d.attrs.href.includes(l) && (d.attrs.href = d.attrs.href.replace(l, ""));
896
927
  }), {
897
- text: Bt(a),
898
- prevNode: r,
928
+ text: qt(a),
929
+ prevNode: n,
899
930
  nextNode: s,
900
931
  placeholder: l
901
932
  });
902
933
  } catch {
903
934
  return null;
904
935
  }
905
- }, Rt = (n, e, t, r, o) => {
906
- const { placeholderConfig: a } = n.get(H.key), l = a.hole;
907
- let s = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
908
- const c = t.apply(s), i = Ee(n, c);
936
+ }, Vt = (t, e, r, n, o) => {
937
+ const { placeholderConfig: a } = t.get(H.key), l = a.hole;
938
+ let s = r.tr.setMeta(e, !0).insertText(l, r.selection.from);
939
+ const c = r.apply(s), i = Ee(t, c);
909
940
  if (!i)
910
941
  return;
911
- const { $from: d } = c.selection, u = d.before(), f = d.after(), p = Dt(i.nextNode, u, i.placeholder);
912
- s = s.replaceWith(u, f, i.nextNode).setNodeMarkup(u, void 0, o).delete(p + 1, p + 2), s = s.setSelection(ae.near(s.doc.resolve(p + 1))), r(s);
913
- }, Pt = N((n) => {
942
+ const { $from: d } = c.selection, u = d.before(), f = d.after(), m = Kt(i.nextNode, u, i.placeholder);
943
+ s = s.replaceWith(u, f, i.nextNode).setNodeMarkup(u, void 0, o).delete(m + 1, m + 2), s = s.setSelection(re.near(s.doc.resolve(m + 1))), n(s);
944
+ }, zt = v((t) => {
914
945
  let e = null;
915
- const t = new C("MILKDOWN_INLINE_SYNC");
946
+ const r = new C("MILKDOWN_INLINE_SYNC");
916
947
  return new x({
917
- key: t,
948
+ key: r,
918
949
  state: {
919
950
  init: () => null,
920
- apply: (r, o, a, l) => {
951
+ apply: (n, o, a, l) => {
921
952
  var h;
922
- const s = n.get(q);
923
- if (!((h = s.hasFocus) != null && h.call(s)) || !s.editable || !r.docChanged || r.getMeta(t))
953
+ const s = t.get(q);
954
+ if (!((h = s.hasFocus) != null && h.call(s)) || !s.editable || !n.docChanged || n.getMeta(r))
924
955
  return null;
925
- const i = Ee(n, l);
956
+ const i = Ee(t, l);
926
957
  if (!i)
927
958
  return null;
928
959
  e && (cancelAnimationFrame(e), e = null);
929
- const { prevNode: d, nextNode: u, text: f } = i, { shouldSyncNode: p } = n.get(H.key);
930
- return p({ prevNode: d, nextNode: u, ctx: n, tr: r, text: f }) && (e = requestAnimationFrame(() => {
960
+ const { prevNode: d, nextNode: u, text: f } = i, { shouldSyncNode: m } = t.get(H.key);
961
+ return m({ prevNode: d, nextNode: u, ctx: t, tr: n, text: f }) && (e = requestAnimationFrame(() => {
931
962
  e = null;
932
- const { dispatch: _, state: Q } = n.get(q);
933
- Rt(n, t, Q, _, d.attrs);
934
- })), null;
963
+ const { dispatch: _, state: Q } = t.get(q);
964
+ Vt(t, r, Q, _, d.attrs);
965
+ }), n.setMeta("addToHistory", !1)), null;
935
966
  }
936
967
  }
937
968
  });
938
- }), Wt = E(() => () => (n) => {
939
- le(n, "list", (e) => {
969
+ }), Gt = $(() => () => (t) => {
970
+ se(t, "list", (e) => {
940
971
  if (e.ordered) {
941
- const t = e.start ?? 1;
942
- e.children.forEach((r, o) => {
943
- r.label = o + t;
972
+ const r = e.start ?? 1;
973
+ e.children.forEach((n, o) => {
974
+ n.label = o + r;
944
975
  });
945
976
  }
946
977
  });
947
- }), qt = E(() => () => (n) => {
978
+ }), jt = $(() => () => (t) => {
948
979
  const e = /[\t ]*(?:\r?\n|\r)/g;
949
- le(n, "text", (t, r, o) => {
950
- if (!t.value || typeof t.value != "string")
980
+ se(t, "text", (r, n, o) => {
981
+ if (!r.value || typeof r.value != "string")
951
982
  return;
952
983
  const a = [];
953
984
  let l = 0;
954
985
  e.lastIndex = 0;
955
- let s = e.exec(t.value);
986
+ let s = e.exec(r.value);
956
987
  for (; s; ) {
957
988
  const i = s.index;
958
- l !== i && a.push({ type: "text", value: t.value.slice(l, i) }), a.push({ type: "break", data: { isInline: !0 } }), l = i + s[0].length, s = e.exec(t.value);
989
+ l !== i && a.push({ type: "text", value: r.value.slice(l, i) }), a.push({ type: "break", data: { isInline: !0 } }), l = i + s[0].length, s = e.exec(r.value);
959
990
  }
960
- if (!!(a.length > 0 && o && typeof r == "number"))
961
- return l < t.value.length && a.push({ type: "text", value: t.value.slice(l) }), o.children.splice(r, 1, ...a), r + a.length;
991
+ if (!!(a.length > 0 && o && typeof n == "number"))
992
+ return l < r.value.length && a.push({ type: "text", value: r.value.slice(l) }), o.children.splice(n, 1, ...a), n + a.length;
962
993
  });
963
- }), Ft = E(() => Ye), Vt = (n) => !!n.children, Gt = (n) => n.type === "html";
964
- function jt(n, e) {
965
- return t(n, 0, null)[0];
966
- function t(r, o, a) {
967
- if (Vt(r)) {
994
+ }), Ut = $(() => Xe), Yt = (t) => !!t.children, Jt = (t) => t.type === "html";
995
+ function Qt(t, e) {
996
+ return r(t, 0, null)[0];
997
+ function r(n, o, a) {
998
+ if (Yt(n)) {
968
999
  const l = [];
969
- for (let s = 0, c = r.children.length; s < c; s++) {
970
- const i = r.children[s];
1000
+ for (let s = 0, c = n.children.length; s < c; s++) {
1001
+ const i = n.children[s];
971
1002
  if (i) {
972
- const d = t(i, s, r);
1003
+ const d = r(i, s, n);
973
1004
  if (d)
974
1005
  for (let u = 0, f = d.length; u < f; u++) {
975
- const p = d[u];
976
- p && l.push(p);
1006
+ const m = d[u];
1007
+ m && l.push(m);
977
1008
  }
978
1009
  }
979
1010
  }
980
- r.children = l;
1011
+ n.children = l;
981
1012
  }
982
- return e(r, o, a);
1013
+ return e(n, o, a);
983
1014
  }
984
1015
  }
985
- const zt = E(() => () => (n) => {
986
- jt(n, (e) => Gt(e) ? [] : [e]);
987
- }), Ut = N(() => {
988
- let n = !1;
989
- const e = new C("MILKDOWN_INLINE_NODES_CURSOR"), t = new x({
1016
+ const Xt = $(() => () => (t) => {
1017
+ Qt(t, (e, r, n) => Jt(e) ? ((n == null ? void 0 : n.type) === "root" && (e.children = [{ ...e }], delete e.value, e.type = "paragraph"), [e]) : [e]);
1018
+ }), Zt = v(() => {
1019
+ let t = !1;
1020
+ const e = new C("MILKDOWN_INLINE_NODES_CURSOR"), r = new x({
990
1021
  key: e,
991
1022
  state: {
992
1023
  init() {
993
1024
  return !1;
994
1025
  },
995
- apply(r) {
996
- if (!r.selection.empty)
1026
+ apply(n) {
1027
+ if (!n.selection.empty)
997
1028
  return !1;
998
- const o = r.selection.$from, a = o.nodeBefore, l = o.nodeAfter;
1029
+ const o = n.selection.$from, a = o.nodeBefore, l = o.nodeAfter;
999
1030
  return !!(a && l && a.isInline && !a.isText && l.isInline && !l.isText);
1000
1031
  }
1001
1032
  },
1002
1033
  props: {
1003
1034
  handleDOMEvents: {
1004
- compositionend: (r, o) => n ? (n = !1, requestAnimationFrame(() => {
1005
- if (t.getState(r.state)) {
1006
- const l = r.state.selection.from;
1007
- o.preventDefault(), r.dispatch(r.state.tr.insertText(o.data || "", l));
1035
+ compositionend: (n, o) => t ? (t = !1, requestAnimationFrame(() => {
1036
+ if (r.getState(n.state)) {
1037
+ const l = n.state.selection.from;
1038
+ o.preventDefault(), n.dispatch(n.state.tr.insertText(o.data || "", l));
1008
1039
  }
1009
1040
  }), !0) : !1,
1010
- compositionstart: (r) => (t.getState(r.state) && (n = !0), !1),
1011
- beforeinput: (r, o) => {
1012
- if (t.getState(r.state) && o instanceof InputEvent && o.data && !n) {
1013
- const l = r.state.selection.from;
1014
- return o.preventDefault(), r.dispatch(r.state.tr.insertText(o.data || "", l)), !0;
1041
+ compositionstart: (n) => (r.getState(n.state) && (t = !0), !1),
1042
+ beforeinput: (n, o) => {
1043
+ if (r.getState(n.state) && o instanceof InputEvent && o.data && !t) {
1044
+ const l = n.state.selection.from;
1045
+ return o.preventDefault(), n.dispatch(n.state.tr.insertText(o.data || "", l)), !0;
1015
1046
  }
1016
1047
  return !1;
1017
1048
  }
1018
1049
  },
1019
- decorations(r) {
1020
- if (t.getState(r)) {
1021
- const l = r.selection.$from.pos, s = document.createElement("span"), c = Z.widget(l, s, {
1050
+ decorations(n) {
1051
+ if (r.getState(n)) {
1052
+ const l = n.selection.$from.pos, s = document.createElement("span"), c = Z.widget(l, s, {
1022
1053
  side: -1
1023
1054
  }), i = document.createElement("span"), d = Z.widget(l, i);
1024
1055
  return setTimeout(() => {
1025
1056
  s.contentEditable = "true", i.contentEditable = "true";
1026
- }), ee.create(r.doc, [c, d]);
1057
+ }), ee.create(n.doc, [c, d]);
1027
1058
  }
1028
1059
  return ee.empty;
1029
1060
  }
1030
1061
  }
1031
1062
  });
1032
- return t;
1033
- }), Yt = N(() => new x({
1063
+ return r;
1064
+ }), er = v(() => new x({
1034
1065
  key: new C("MILKDOWN_HARDBREAK_MARKS"),
1035
- appendTransaction: (n, e, t) => {
1036
- if (!n.length)
1066
+ appendTransaction: (t, e, r) => {
1067
+ if (!t.length)
1037
1068
  return;
1038
- const [r] = n;
1039
- if (!r)
1069
+ const [n] = t;
1070
+ if (!n)
1040
1071
  return;
1041
- const [o] = r.steps;
1042
- if (r.getMeta("hardbreak")) {
1043
- if (!(o instanceof ze))
1072
+ const [o] = n.steps;
1073
+ if (n.getMeta("hardbreak")) {
1074
+ if (!(o instanceof Je))
1044
1075
  return;
1045
1076
  const { from: s } = o;
1046
- return t.tr.setNodeMarkup(s, v.type(), void 0, []);
1077
+ return r.tr.setNodeMarkup(s, w.type(), void 0, []);
1047
1078
  }
1048
- if (o instanceof Ue) {
1049
- let s = t.tr;
1079
+ if (o instanceof Qe) {
1080
+ let s = r.tr;
1050
1081
  const { from: c, to: i } = o;
1051
- return t.doc.nodesBetween(c, i, (d, u) => {
1052
- d.type === v.type() && (s = s.setNodeMarkup(u, v.type(), void 0, []));
1082
+ return r.doc.nodesBetween(c, i, (d, u) => {
1083
+ d.type === w.type() && (s = s.setNodeMarkup(u, w.type(), void 0, []));
1053
1084
  }), s;
1054
1085
  }
1055
1086
  }
1056
- })), Be = F(["table", "code_block"], "hardbreakFilterNodes"), Jt = N((n) => {
1057
- const e = n.get(Be.key);
1087
+ })), Re = F(["table", "code_block"], "hardbreakFilterNodes"), tr = v((t) => {
1088
+ const e = t.get(Re.key);
1058
1089
  return new x({
1059
1090
  key: new C("MILKDOWN_HARDBREAK_FILTER"),
1060
- filterTransaction: (t, r) => {
1061
- const o = t.getMeta("hardbreak"), [a] = t.steps;
1091
+ filterTransaction: (r, n) => {
1092
+ const o = r.getMeta("hardbreak"), [a] = r.steps;
1062
1093
  if (o && a) {
1063
- const { from: l } = a, s = r.doc.resolve(l);
1094
+ const { from: l } = a, s = n.doc.resolve(l);
1064
1095
  let c = s.depth, i = !0;
1065
1096
  for (; c > 0; )
1066
1097
  e.includes(s.node(c).type.name) && (i = !1), c--;
@@ -1069,13 +1100,13 @@ const zt = E(() => () => (n) => {
1069
1100
  return !0;
1070
1101
  }
1071
1102
  });
1072
- }), Qt = N((n) => {
1073
- const e = new C("MILKDOWN_HEADING_ID"), t = (r) => {
1074
- if (r.composing || !r.editable)
1103
+ }), rr = v((t) => {
1104
+ const e = new C("MILKDOWN_HEADING_ID"), r = (n) => {
1105
+ if (n.composing || !n.editable)
1075
1106
  return;
1076
- const o = n.get(z.key), a = r.state.tr.setMeta("addToHistory", !1);
1107
+ const o = t.get(j.key), a = n.state.tr.setMeta("addToHistory", !1);
1077
1108
  let l = !1;
1078
- r.state.doc.descendants((s, c) => {
1109
+ n.state.doc.descendants((s, c) => {
1079
1110
  if (s.type === D.type()) {
1080
1111
  if (s.textContent.trim().length === 0)
1081
1112
  return;
@@ -1085,153 +1116,155 @@ const zt = E(() => () => (n) => {
1085
1116
  id: d
1086
1117
  }));
1087
1118
  }
1088
- }), l && r.dispatch(a);
1119
+ }), l && n.dispatch(a);
1089
1120
  };
1090
1121
  return new x({
1091
1122
  key: e,
1092
- view: (r) => (t(r), {
1123
+ view: (n) => (r(n), {
1093
1124
  update: (o) => {
1094
- t(o);
1125
+ r(o);
1095
1126
  }
1096
1127
  })
1097
1128
  });
1098
- }), Xt = N(() => {
1099
- const n = (e) => {
1129
+ }), nr = v(() => {
1130
+ const t = (e) => {
1100
1131
  if (e.composing || !e.editable)
1101
1132
  return;
1102
- const t = P.type(), r = R.type(), o = O.type(), a = e.state, l = (i, d) => {
1133
+ const r = P.type(), n = R.type(), o = O.type(), a = e.state, l = (i, d) => {
1103
1134
  let u = !1;
1104
1135
  const f = `${d + 1}.`;
1105
1136
  return i.label !== f && (i.label = f, u = !0), u;
1106
1137
  };
1107
1138
  let s = a.tr, c = !1;
1108
1139
  a.doc.descendants((i, d, u, f) => {
1109
- if (i.type === r) {
1110
- const p = i.maybeChild(0);
1111
- (p == null ? void 0 : p.type) === o && p.attrs.listType === "ordered" && (c = !0, s.setNodeMarkup(d, t, { spread: "true" }), i.descendants((h, _, Q, Re) => {
1140
+ if (i.type === n) {
1141
+ const m = i.maybeChild(0);
1142
+ (m == null ? void 0 : m.type) === o && m.attrs.listType === "ordered" && (c = !0, s.setNodeMarkup(d, r, { spread: "true" }), i.descendants((h, _, Q, Pe) => {
1112
1143
  if (h.type === o) {
1113
1144
  const X = { ...h.attrs };
1114
- l(X, Re) && (s = s.setNodeMarkup(_, void 0, X));
1145
+ l(X, Pe) && (s = s.setNodeMarkup(_, void 0, X));
1115
1146
  }
1116
1147
  return !1;
1117
1148
  }));
1118
- } else if (i.type === o && (u == null ? void 0 : u.type) === t) {
1119
- const p = { ...i.attrs };
1149
+ } else if (i.type === o && (u == null ? void 0 : u.type) === r) {
1150
+ const m = { ...i.attrs };
1120
1151
  let h = !1;
1121
- p.listType !== "ordered" && (p.listType = "ordered", h = !0), (u == null ? void 0 : u.maybeChild(0)) && (h = l(p, f)), h && (s = s.setNodeMarkup(d, void 0, p), c = !0);
1152
+ m.listType !== "ordered" && (m.listType = "ordered", h = !0), (u == null ? void 0 : u.maybeChild(0)) && (h = l(m, f)), h && (s = s.setNodeMarkup(d, void 0, m), c = !0);
1122
1153
  }
1123
1154
  }), c && e.dispatch(s.setMeta("addToHistory", !1));
1124
1155
  };
1125
1156
  return new x({
1126
1157
  key: new C("MILKDOWN_KEEP_LIST_ORDER"),
1127
- view: (e) => (n(e), {
1128
- update: (t) => {
1129
- n(t);
1158
+ view: (e) => (t(e), {
1159
+ update: (r) => {
1160
+ t(r);
1130
1161
  }
1131
1162
  })
1132
1163
  });
1133
- }), Zt = [
1164
+ }), or = [
1134
1165
  H,
1135
- Pt,
1136
- Yt,
1137
- Be,
1138
- Jt,
1139
- Ut,
1140
- Wt,
1141
- Ft,
1142
- qt,
1143
1166
  zt,
1144
- Qt,
1145
- Xt
1146
- ], kn = [wt, Nt, Ct, xt, Zt].flat();
1167
+ er,
1168
+ Re,
1169
+ tr,
1170
+ Zt,
1171
+ Gt,
1172
+ Ut,
1173
+ jt,
1174
+ Xt,
1175
+ rr,
1176
+ nr
1177
+ ], Nr = [xt, At, Lt, Tt, or].flat();
1147
1178
  export {
1148
1179
  be as blockquoteAttr,
1149
- ct as blockquoteKeymap,
1180
+ ut as blockquoteKeymap,
1150
1181
  U as blockquoteSchema,
1151
- Se as bulletListAttr,
1152
- kt as bulletListKeymap,
1182
+ Te as bulletListAttr,
1183
+ It as bulletListKeymap,
1153
1184
  R as bulletListSchema,
1154
- Ne as codeBlockAttr,
1155
- dt as codeBlockKeymap,
1185
+ we as codeBlockAttr,
1186
+ pt as codeBlockKeymap,
1156
1187
  Y as codeBlockSchema,
1157
- Ct as commands,
1158
- kn as commonmark,
1159
- Ce as createCodeBlockCommand,
1160
- it as createCodeBlockInputRule,
1161
- Ot as defaultConfig,
1162
- tt as docSchema,
1188
+ Lt as commands,
1189
+ Nr as commonmark,
1190
+ ve as createCodeBlockCommand,
1191
+ mt as createCodeBlockInputRule,
1192
+ Bt as defaultConfig,
1193
+ ot as docSchema,
1163
1194
  Ie as downgradeHeadingCommand,
1164
- ce as emphasisAttr,
1165
- Je as emphasisKeymap,
1166
- ie as emphasisSchema,
1167
- Ae as hardbreakAttr,
1168
- Yt as hardbreakClearMarkPlugin,
1169
- Be as hardbreakFilterNodes,
1170
- Jt as hardbreakFilterPlugin,
1171
- mt as hardbreakKeymap,
1172
- v as hardbreakSchema,
1195
+ le as emphasisAttr,
1196
+ Ze as emphasisKeymap,
1197
+ ce as emphasisSchema,
1198
+ xe as hardbreakAttr,
1199
+ er as hardbreakClearMarkPlugin,
1200
+ Re as hardbreakFilterNodes,
1201
+ tr as hardbreakFilterPlugin,
1202
+ ht as hardbreakKeymap,
1203
+ w as hardbreakSchema,
1173
1204
  Me as headingAttr,
1174
- z as headingIdGenerator,
1175
- st as headingKeymap,
1205
+ j as headingIdGenerator,
1206
+ it as headingKeymap,
1176
1207
  D as headingSchema,
1177
- ve as hrAttr,
1208
+ Le as hrAttr,
1178
1209
  J as hrSchema,
1179
- xe as imageAttr,
1180
- B as imageSchema,
1181
- ge as inlineCodeAttr,
1182
- Xe as inlineCodeKeymap,
1210
+ $e as htmlAttr,
1211
+ Ct as htmlSchema,
1212
+ Ce as imageAttr,
1213
+ E as imageSchema,
1214
+ pe as inlineCodeAttr,
1215
+ tt as inlineCodeKeymap,
1183
1216
  A as inlineCodeSchema,
1184
- Ut as inlineNodesCursorPlugin,
1217
+ Zt as inlineNodesCursorPlugin,
1185
1218
  H as inlineSyncConfig,
1186
- Pt as inlineSyncPlugin,
1187
- Nt as inputrules,
1188
- Le as insertHardbreakCommand,
1189
- ft as insertHrCommand,
1190
- gt as insertHrInputRule,
1191
- ut as insertImageCommand,
1192
- hn as insertImageInputRule,
1193
- xt as keymap,
1219
+ zt as inlineSyncPlugin,
1220
+ At as inputrules,
1221
+ Ae as insertHardbreakCommand,
1222
+ yt as insertHrCommand,
1223
+ kt as insertHrInputRule,
1224
+ gt as insertImageCommand,
1225
+ br as insertImageInputRule,
1226
+ Tt as keymap,
1194
1227
  Ke as liftListItemCommand,
1195
- he as linkAttr,
1228
+ fe as linkAttr,
1196
1229
  L as linkSchema,
1197
1230
  He as listItemAttr,
1198
- It as listItemKeymap,
1231
+ wt as listItemKeymap,
1199
1232
  O as listItemSchema,
1200
1233
  De as orderedListAttr,
1201
- Mt as orderedListKeymap,
1234
+ Nt as orderedListKeymap,
1202
1235
  P as orderedListSchema,
1203
1236
  ke as paragraphAttr,
1204
- nt as paragraphKeymap,
1205
- T as paragraphSchema,
1206
- Zt as plugins,
1207
- Wt as remarkAddOrderInListPlugin,
1208
- zt as remarkHTMLFilter,
1209
- Ft as remarkInlineLinkPlugin,
1210
- qt as remarkLineBreak,
1211
- wt as schema,
1237
+ at as paragraphKeymap,
1238
+ S as paragraphSchema,
1239
+ or as plugins,
1240
+ Gt as remarkAddOrderInListPlugin,
1241
+ Xt as remarkHtmlTransformer,
1242
+ Ut as remarkInlineLinkPlugin,
1243
+ jt as remarkLineBreak,
1244
+ xt as schema,
1212
1245
  _e as sinkListItemCommand,
1213
- $e as splitListItemCommand,
1214
- ue as strongAttr,
1215
- Qe as strongKeymap,
1216
- pe as strongSchema,
1217
- Qt as syncHeadingIdPlugin,
1218
- Xt as syncListOrderPlugin,
1219
- bt as textSchema,
1220
- de as toggleEmphasisCommand,
1221
- fe as toggleInlineCodeCommand,
1222
- Ze as toggleLinkCommand,
1246
+ Be as splitListItemCommand,
1247
+ de as strongAttr,
1248
+ et as strongKeymap,
1249
+ ue as strongSchema,
1250
+ rr as syncHeadingIdPlugin,
1251
+ nr as syncListOrderPlugin,
1252
+ vt as textSchema,
1253
+ ie as toggleEmphasisCommand,
1254
+ ge as toggleInlineCodeCommand,
1255
+ rt as toggleLinkCommand,
1223
1256
  me as toggleStrongCommand,
1224
1257
  ye as turnIntoTextCommand,
1225
- fn as updateCodeBlockLanguageCommand,
1226
- pt as updateImageCommand,
1227
- et as updateLinkCommand,
1228
- we as wrapInBlockquoteCommand,
1229
- lt as wrapInBlockquoteInputRule,
1230
- Te as wrapInBulletListCommand,
1231
- ht as wrapInBulletListInputRule,
1258
+ Ir as updateCodeBlockLanguageCommand,
1259
+ ft as updateImageCommand,
1260
+ nt as updateLinkCommand,
1261
+ Ne as wrapInBlockquoteCommand,
1262
+ dt as wrapInBlockquoteInputRule,
1263
+ Se as wrapInBulletListCommand,
1264
+ Mt as wrapInBulletListInputRule,
1232
1265
  I as wrapInHeadingCommand,
1233
- at as wrapInHeadingInputRule,
1266
+ ct as wrapInHeadingInputRule,
1234
1267
  Oe as wrapInOrderedListCommand,
1235
- yt as wrapInOrderedListInputRule
1268
+ bt as wrapInOrderedListInputRule
1236
1269
  };
1237
1270
  //# sourceMappingURL=index.es.js.map