@milkdown/preset-commonmark 6.3.1 → 6.4.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.
Files changed (50) hide show
  1. package/lib/index.d.ts +1 -0
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.es.js +729 -575
  4. package/lib/index.es.js.map +1 -1
  5. package/lib/mark/code-inline.d.ts.map +1 -1
  6. package/lib/mark/em.d.ts.map +1 -1
  7. package/lib/mark/link.d.ts.map +1 -1
  8. package/lib/mark/strong.d.ts.map +1 -1
  9. package/lib/node/bullet-list.d.ts.map +1 -1
  10. package/lib/node/code-fence.d.ts.map +1 -1
  11. package/lib/node/heading.d.ts.map +1 -1
  12. package/lib/node/image.d.ts.map +1 -1
  13. package/lib/node/list-item.d.ts.map +1 -1
  14. package/lib/node/ordered-list.d.ts.map +1 -1
  15. package/lib/plugin/index.d.ts +2 -0
  16. package/lib/plugin/index.d.ts.map +1 -1
  17. package/lib/plugin/inline-nodes-cursor.d.ts +1 -1
  18. package/lib/plugin/inline-nodes-cursor.d.ts.map +1 -1
  19. package/lib/plugin/inline-sync/config.d.ts +24 -0
  20. package/lib/plugin/inline-sync/config.d.ts.map +1 -0
  21. package/lib/plugin/inline-sync/context.d.ts +12 -0
  22. package/lib/plugin/inline-sync/context.d.ts.map +1 -0
  23. package/lib/plugin/inline-sync/index.d.ts +6 -0
  24. package/lib/plugin/inline-sync/index.d.ts.map +1 -0
  25. package/lib/plugin/inline-sync/regexp.d.ts +3 -0
  26. package/lib/plugin/inline-sync/regexp.d.ts.map +1 -0
  27. package/lib/plugin/inline-sync/replacer.d.ts +5 -0
  28. package/lib/plugin/inline-sync/replacer.d.ts.map +1 -0
  29. package/lib/plugin/inline-sync/utils.d.ts +8 -0
  30. package/lib/plugin/inline-sync/utils.d.ts.map +1 -0
  31. package/package.json +5 -5
  32. package/src/index.ts +1 -0
  33. package/src/mark/code-inline.ts +25 -4
  34. package/src/mark/em.ts +1 -6
  35. package/src/mark/link.ts +1 -19
  36. package/src/mark/strong.ts +1 -5
  37. package/src/node/bullet-list.ts +33 -4
  38. package/src/node/code-fence.ts +5 -1
  39. package/src/node/heading.ts +10 -6
  40. package/src/node/image.ts +4 -5
  41. package/src/node/list-item.ts +22 -7
  42. package/src/node/ordered-list.ts +11 -3
  43. package/src/plugin/index.ts +10 -5
  44. package/src/plugin/inline-nodes-cursor.ts +76 -48
  45. package/src/plugin/inline-sync/config.ts +56 -0
  46. package/src/plugin/inline-sync/context.ts +115 -0
  47. package/src/plugin/inline-sync/index.ts +48 -0
  48. package/src/plugin/inline-sync/regexp.ts +6 -0
  49. package/src/plugin/inline-sync/replacer.ts +43 -0
  50. package/src/plugin/inline-sync/utils.ts +73 -0
package/lib/index.es.js CHANGED
@@ -1,16 +1,16 @@
1
- import { createMark as R, createShortcut as h, createNode as w, createPlugin as He, AtomList as Ne } from "@milkdown/utils";
2
- import { createCmdKey as I, createCmd as M, schemaCtx as A, commandsCtx as we, editorViewCtx as B, getPalette as Te } from "@milkdown/core";
3
- import { markRule as _, calculateTextPosition as Oe, cloneTr as Ae, findSelectedNodeOfType as K, getNodeFromSchema as Ee } from "@milkdown/prose";
4
- import { toggleMark as P, wrapIn as de, setBlockType as E } from "@milkdown/prose/commands";
5
- import { expectDomTypeError as D, missingRootElement as _e } from "@milkdown/exception";
6
- import { InputRule as me, wrappingInputRule as W, textblockTypeInputRule as G } from "@milkdown/prose/inputrules";
7
- import { PluginKey as T, TextSelection as pe, Plugin as H, NodeSelection as ve, Selection as Le } from "@milkdown/prose/state";
8
- import { Fragment as ge } from "@milkdown/prose/model";
9
- import { ReplaceStep as $e, AddMarkStep as Se } from "@milkdown/prose/transform";
10
- import { DecorationSet as O, Decoration as J } from "@milkdown/prose/view";
11
- import { splitListItem as Re, sinkListItem as Be, liftListItem as Pe } from "@milkdown/prose/schema-list";
12
- import We from "remark-inline-links";
13
- import { visit as qe } from "unist-util-visit";
1
+ import { createMark as R, createShortcut as h, createNode as w, pipe as Oe, createPlugin as Se, AtomList as be } from "@milkdown/utils";
2
+ import { createCmdKey as y, createCmd as M, commandsCtx as we, editorViewCtx as A, schemaCtx as P, getPalette as Ae, createSlice as Ee, serializerCtx as ve, parserCtx as _e } from "@milkdown/core";
3
+ import { toggleMark as me, wrapIn as pe, setBlockType as S } from "@milkdown/prose/commands";
4
+ import { expectDomTypeError as L, missingRootElement as $e } from "@milkdown/exception";
5
+ import { calculateTextPosition as Pe, cloneTr as Be, findSelectedNodeOfType as K, getNodeFromSchema as Re } from "@milkdown/prose";
6
+ import { PluginKey as T, TextSelection as J, Plugin as x, NodeSelection as We, Selection as Le } from "@milkdown/prose/state";
7
+ import { wrappingInputRule as W, textblockTypeInputRule as Q, InputRule as Ce } from "@milkdown/prose/inputrules";
8
+ import { Fragment as B } from "@milkdown/prose/model";
9
+ import { ReplaceStep as qe, AddMarkStep as Ke } from "@milkdown/prose/transform";
10
+ import { DecorationSet as O, Decoration as X } from "@milkdown/prose/view";
11
+ import { splitListItem as Fe, sinkListItem as je, liftListItem as ze } from "@milkdown/prose/schema-list";
12
+ import Ue from "remark-inline-links";
13
+ import { visit as Ve } from "unist-util-visit";
14
14
  const k = {
15
15
  HardBreak: "HardBreak",
16
16
  Blockquote: "Blockquote",
@@ -31,14 +31,14 @@ const k = {
31
31
  NextListItem: "NextListItem",
32
32
  SinkListItem: "SinkListItem",
33
33
  LiftListItem: "LiftListItem"
34
- }, he = "code_inline", Q = I("ToggleInlineCode"), Ke = R((c) => ({
34
+ }, he = "code_inline", Z = y("ToggleInlineCode"), Ge = R((a) => ({
35
35
  id: he,
36
36
  schema: () => ({
37
37
  priority: 100,
38
38
  code: !0,
39
39
  inclusive: !1,
40
40
  parseDOM: [{ tag: "code" }],
41
- toDOM: (e) => ["code", { class: c.getClassName(e.attrs, "code-inline") }],
41
+ toDOM: (e) => ["code", { class: a.getClassName(e.attrs, "code-inline") }],
42
42
  parseMarkdown: {
43
43
  match: (e) => e.type === "inlineCode",
44
44
  runner: (e, t, r) => {
@@ -52,20 +52,30 @@ const k = {
52
52
  }
53
53
  }
54
54
  }),
55
- inputRules: (e) => [_(/(?:^|[^`])(`([^`]+)`)$/, e)],
56
- commands: (e) => [M(Q, () => P(e))],
55
+ commands: (e) => [
56
+ M(Z, () => (t, r) => {
57
+ const { selection: n, tr: s } = t;
58
+ if (n.empty)
59
+ return !1;
60
+ const { from: l, to: o } = n;
61
+ return t.doc.rangeHasMark(l, o, e) ? (r == null || r(s.removeMark(l, o, e)), !0) : (Object.keys(t.schema.marks).filter((u) => u !== e.name).map((u) => t.schema.marks[u]).forEach((u) => {
62
+ s.removeMark(l, o, u);
63
+ }), r == null || r(s.addMark(l, o, e.create())), !0);
64
+ })
65
+ ],
57
66
  shortcuts: {
58
- [k.CodeInline]: h(Q, "Mod-e")
67
+ [k.CodeInline]: h(Z, "Mod-e")
59
68
  }
60
- })), F = "em", X = I("ToggleItalic"), Fe = R((c) => ({
69
+ })), F = "em", ee = y("ToggleItalic"), Ye = R((a) => ({
61
70
  id: F,
62
71
  schema: () => ({
72
+ inclusive: !1,
63
73
  parseDOM: [
64
74
  { tag: "i" },
65
75
  { tag: "em" },
66
76
  { style: "font-style", getAttrs: (e) => e === "italic" }
67
77
  ],
68
- toDOM: (e) => ["em", { class: c.getClassName(e.attrs, F) }],
78
+ toDOM: (e) => ["em", { class: a.getClassName(e.attrs, F) }],
69
79
  parseMarkdown: {
70
80
  match: (e) => e.type === "emphasis",
71
81
  runner: (e, t, r) => {
@@ -79,38 +89,33 @@ const k = {
79
89
  }
80
90
  }
81
91
  }),
82
- inputRules: (e) => [
83
- _(/(?:^|[^_])(_([^_]+)_)$/, e),
84
- _(/(?:^|[^*])(\*([^*]+)\*)$/, e)
85
- ],
86
- commands: (e) => [M(X, () => P(e))],
92
+ commands: (e) => [M(ee, () => me(e))],
87
93
  shortcuts: {
88
- [k.Em]: h(X, "Mod-i")
94
+ [k.Em]: h(ee, "Mod-i")
89
95
  }
90
- })), Ue = new T("MILKDOWN_LINK_INPUT"), xe = I("ToggleLink"), Y = I("ModifyLink"), v = "link", Ve = R((c, e) => ({
96
+ })), Je = new T("MILKDOWN_LINK_INPUT"), xe = y("ToggleLink"), te = y("ModifyLink"), v = "link", Qe = R((a, e) => ({
91
97
  id: v,
92
98
  schema: () => ({
93
99
  attrs: {
94
100
  href: {},
95
101
  title: { default: null }
96
102
  },
97
- inclusive: !1,
98
103
  parseDOM: [
99
104
  {
100
105
  tag: "a[href]",
101
106
  getAttrs: (t) => {
102
107
  if (!(t instanceof HTMLElement))
103
- throw D(t);
108
+ throw L(t);
104
109
  return { href: t.getAttribute("href"), title: t.getAttribute("title") };
105
110
  }
106
111
  }
107
112
  ],
108
- toDOM: (t) => ["a", { ...t.attrs, class: c.getClassName(t.attrs, v) }],
113
+ toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs, v) }],
109
114
  parseMarkdown: {
110
115
  match: (t) => t.type === "link",
111
116
  runner: (t, r, n) => {
112
- const o = r.url, a = r.title;
113
- t.openMark(n, { href: o, title: a }), t.next(r.children), t.closeMark(n);
117
+ const s = r.url, l = r.title;
118
+ t.openMark(n, { href: s, title: l }), t.next(r.children), t.closeMark(n);
114
119
  }
115
120
  },
116
121
  toMarkdown: {
@@ -124,114 +129,105 @@ const k = {
124
129
  }
125
130
  }),
126
131
  commands: (t) => [
127
- M(xe, (r = "") => P(t, { href: r })),
128
- M(Y, (r = "") => (n, o) => {
129
- var y;
130
- if (!o)
132
+ M(xe, (r = "") => me(t, { href: r })),
133
+ M(te, (r = "") => (n, s) => {
134
+ var I;
135
+ if (!s)
131
136
  return !1;
132
- const { marks: a } = n.schema;
133
- let s, l = -1;
134
- const { selection: i } = n, { from: u, to: g } = i;
135
- if (n.doc.nodesBetween(u, u === g ? g + 1 : g, (N, x) => {
136
- var L;
137
- if ((L = a.link) != null && L.isInSet(N.marks))
138
- return s = N, l = x, !1;
139
- }), !s)
137
+ const { marks: l } = n.schema;
138
+ let o, c = -1;
139
+ const { selection: i } = n, { from: u, to: f } = i;
140
+ if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b, H) => {
141
+ var C;
142
+ if ((C = l.link) != null && C.isInSet(b.marks))
143
+ return o = b, c = H, !1;
144
+ }), !o)
140
145
  return !1;
141
- const d = s.marks.find(({ type: N }) => N === t);
146
+ const d = o.marks.find(({ type: b }) => b === t);
142
147
  if (!d)
143
148
  return !1;
144
- const m = l, f = l + s.nodeSize, { tr: p } = n, b = (y = a.link) == null ? void 0 : y.create({ ...d.attrs, href: r });
145
- return b ? (o(p.removeMark(m, f, d).addMark(m, f, b).setSelection(new pe(p.selection.$anchor)).scrollIntoView()), !0) : !1;
146
- })
147
- ],
148
- inputRules: (t, r) => [
149
- new me(/\[(?<text>.*?)]\((?<href>.*?)(?=“|\))"?(?<title>[^"]+)?"?\)/, (n, o, a, s) => {
150
- const [l, i = "", u, g] = o, { tr: d } = n;
151
- if (l) {
152
- const m = i || "link";
153
- d.replaceWith(a, s, r.get(A).text(m)).addMark(a, m.length + a, t.create({ title: g, href: u }));
154
- }
155
- return d;
149
+ const m = c, p = c + o.nodeSize, { tr: g } = n, N = (I = l.link) == null ? void 0 : I.create({ ...d.attrs, href: r });
150
+ return N ? (s(g.removeMark(m, p, d).addMark(m, p, N).setSelection(new J(g.selection.$anchor)).scrollIntoView()), !0) : !1;
156
151
  })
157
152
  ],
158
153
  prosePlugins: (t, r) => {
159
154
  let n = !1;
160
155
  return [
161
- new H({
162
- key: Ue,
163
- view: (o) => {
164
- var u, g, d;
165
- const a = c.themeManager.get("input-chip", {
166
- placeholder: (g = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? g : "Input Web Link",
156
+ new x({
157
+ key: Je,
158
+ view: (s) => {
159
+ var u, f, d;
160
+ const l = a.themeManager.get("input-chip", {
161
+ placeholder: (f = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? f : "Input Web Link",
167
162
  buttonText: (d = e == null ? void 0 : e.input) == null ? void 0 : d.buttonText,
168
163
  onUpdate: (m) => {
169
- r.get(we).call(Y, m);
164
+ r.get(we).call(te, m);
170
165
  },
171
- calculatePosition: (m, f) => {
172
- Oe(m, f, (p, b, y, N) => {
173
- const x = m.dom.parentElement;
174
- if (!x)
175
- throw _e();
176
- const L = b.left - p.left;
177
- let q = p.left - N.left - (y.width - L) / 2, fe = p.bottom - N.top + 14 + x.scrollTop;
178
- return n && (fe = p.top - N.top - y.height - 14 + x.scrollTop), q < 0 && (q = 0), [fe, q];
166
+ calculatePosition: (m, p) => {
167
+ Pe(m, p, (g, N, I, b) => {
168
+ const H = m.dom.parentElement;
169
+ if (!H)
170
+ throw $e();
171
+ const C = N.left - g.left;
172
+ let q = g.left - b.left - (I.width - C) / 2, ge = g.bottom - b.top + 14 + H.scrollTop;
173
+ return n && (ge = g.top - b.top - I.height - 14 + H.scrollTop), q < 0 && (q = 0), [ge, q];
179
174
  });
180
175
  }
181
176
  });
182
- if (!a)
177
+ if (!l)
183
178
  return {};
184
- const s = (m) => {
185
- const { selection: f, doc: p } = m.state, { from: b, to: y } = f;
179
+ const o = (m) => {
180
+ const { selection: p, doc: g } = m.state, { from: N, to: I } = p;
186
181
  if (!m.hasFocus())
187
182
  return !1;
188
- if (f.empty && f instanceof pe && y < p.content.size && b < p.content.size && p.rangeHasMark(b, b === y ? y + 1 : y, t))
183
+ if (p.empty && p instanceof J && I < g.content.size && N < g.content.size && g.rangeHasMark(N, N === I ? I + 1 : I, t))
189
184
  return n = !1, !0;
190
- if (f instanceof ve) {
191
- const { node: N } = f;
192
- if (N.type.name === "image" && N.marks.findIndex((x) => x.type.name === v) > -1)
185
+ if (p instanceof We) {
186
+ const { node: b } = p;
187
+ if (b.type.name === "image" && b.marks.findIndex((H) => H.type.name === v) > -1)
193
188
  return n = !0, !0;
194
189
  }
195
190
  return !1;
196
- }, l = (m) => {
197
- const { selection: f } = m.state;
198
- let p;
199
- const { from: b, to: y } = f;
200
- if (m.state.doc.nodesBetween(b, b === y ? y + 1 : y, (L) => {
201
- if (t.isInSet(L.marks))
202
- return p = L, !1;
203
- }), !p)
191
+ }, c = (m) => {
192
+ const { selection: p } = m.state;
193
+ let g;
194
+ const { from: N, to: I } = p;
195
+ if (m.state.doc.nodesBetween(N, N === I ? I + 1 : I, (C) => {
196
+ if (t.isInSet(C.marks))
197
+ return g = C, !1;
198
+ }), !g)
204
199
  return;
205
- const N = p.marks.find((L) => L.type === t);
206
- return N ? N.attrs.href : void 0;
200
+ const b = g.marks.find((C) => C.type === t);
201
+ return b ? b.attrs.href : void 0;
207
202
  }, i = (m) => {
208
203
  if (!m.editable)
209
204
  return;
210
- s(m) ? (a.show(m), a.update(l(m))) : a.hide();
205
+ o(m) ? (l.show(m), l.update(c(m))) : l.hide();
211
206
  };
212
- return a.init(o), i(o), {
213
- update: (m, f) => {
214
- (f == null ? void 0 : f.doc.eq(m.state.doc)) && f.selection.eq(m.state.selection) || requestAnimationFrame(() => {
207
+ return l.init(s), i(s), {
208
+ update: (m, p) => {
209
+ (p == null ? void 0 : p.doc.eq(m.state.doc)) && p.selection.eq(m.state.selection) || requestAnimationFrame(() => {
215
210
  i(m);
216
211
  });
217
212
  },
218
213
  destroy: () => {
219
- a.destroy();
214
+ l.destroy();
220
215
  }
221
216
  };
222
217
  }
223
218
  })
224
219
  ];
225
220
  }
226
- })), U = "strong", Z = I("ToggleBold"), je = R((c) => ({
227
- id: U,
221
+ })), j = "strong", re = y("ToggleBold"), Xe = R((a) => ({
222
+ id: j,
228
223
  schema: () => ({
224
+ inclusive: !1,
229
225
  parseDOM: [
230
226
  { tag: "b" },
231
227
  { tag: "strong" },
232
228
  { style: "font-style", getAttrs: (e) => e === "bold" }
233
229
  ],
234
- toDOM: (e) => ["strong", { class: c.getClassName(e.attrs, U) }],
230
+ toDOM: (e) => ["strong", { class: a.getClassName(e.attrs, j) }],
235
231
  parseMarkdown: {
236
232
  match: (e) => e.type === "strong",
237
233
  runner: (e, t, r) => {
@@ -239,75 +235,95 @@ const k = {
239
235
  }
240
236
  },
241
237
  toMarkdown: {
242
- match: (e) => e.type.name === U,
238
+ match: (e) => e.type.name === j,
243
239
  runner: (e, t) => {
244
240
  e.withMark(t, "strong");
245
241
  }
246
242
  }
247
243
  }),
248
- inputRules: (e) => [
249
- _(/(?:__)([^_]+)(?:__)$/, e),
250
- _(/(?:\*\*)([^*]+)(?:\*\*)$/, e)
251
- ],
252
- commands: (e) => [M(Z, () => P(e))],
244
+ commands: (e) => [M(re, () => me(e))],
253
245
  shortcuts: {
254
- [k.Bold]: h(Z, "Mod-b")
246
+ [k.Bold]: h(re, "Mod-b")
255
247
  }
256
- })), ze = [Ke(), Fe(), je(), Ve()], $ = "blockquote", ee = I("WrapInBlockquote"), Ge = w((c) => ({
257
- id: $,
248
+ })), Ze = [Ge(), Ye(), Xe(), Qe()], _ = "blockquote", ne = y("WrapInBlockquote"), et = w((a) => ({
249
+ id: _,
258
250
  schema: () => ({
259
251
  content: "block+",
260
252
  group: "block",
261
253
  defining: !0,
262
254
  parseDOM: [{ tag: "blockquote" }],
263
- toDOM: (e) => ["blockquote", { class: c.getClassName(e.attrs, $) }, 0],
255
+ toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs, _) }, 0],
264
256
  parseMarkdown: {
265
- match: ({ type: e }) => e === $,
257
+ match: ({ type: e }) => e === _,
266
258
  runner: (e, t, r) => {
267
259
  e.openNode(r).next(t.children).closeNode();
268
260
  }
269
261
  },
270
262
  toMarkdown: {
271
- match: (e) => e.type.name === $,
263
+ match: (e) => e.type.name === _,
272
264
  runner: (e, t) => {
273
265
  e.openNode("blockquote").next(t.content).closeNode();
274
266
  }
275
267
  }
276
268
  }),
277
269
  inputRules: (e) => [W(/^\s*>\s$/, e)],
278
- commands: (e) => [M(ee, () => de(e))],
270
+ commands: (e) => [M(ne, () => pe(e))],
279
271
  shortcuts: {
280
- [k.Blockquote]: h(ee, "Mod-Shift-b")
272
+ [k.Blockquote]: h(ne, "Mod-Shift-b")
281
273
  }
282
- })), te = I("WrapInBulletList"), Je = w((c) => {
274
+ })), se = y("WrapInBulletList"), tt = w((a) => {
283
275
  const e = "bullet_list";
284
276
  return {
285
277
  id: e,
286
278
  schema: () => ({
287
279
  content: "listItem+",
288
280
  group: "block",
289
- parseDOM: [{ tag: "ul" }],
290
- toDOM: (t) => ["ul", { class: c.getClassName(t.attrs, "bullet-list") }, 0],
281
+ attrs: {
282
+ spread: {
283
+ default: !1
284
+ }
285
+ },
286
+ parseDOM: [
287
+ {
288
+ tag: "ul",
289
+ getAttrs: (t) => {
290
+ if (!(t instanceof HTMLElement))
291
+ throw L(t);
292
+ return {
293
+ spread: t.dataset.spread
294
+ };
295
+ }
296
+ }
297
+ ],
298
+ toDOM: (t) => [
299
+ "ul",
300
+ {
301
+ "data-spread": t.attrs.spread,
302
+ class: a.getClassName(t.attrs, "bullet-list")
303
+ },
304
+ 0
305
+ ],
291
306
  parseMarkdown: {
292
307
  match: ({ type: t, ordered: r }) => t === "list" && !r,
293
308
  runner: (t, r, n) => {
294
- t.openNode(n).next(r.children).closeNode();
309
+ const s = r.spread != null ? `${r.spread}` : "false";
310
+ t.openNode(n, { spread: s }).next(r.children).closeNode();
295
311
  }
296
312
  },
297
313
  toMarkdown: {
298
314
  match: (t) => t.type.name === e,
299
315
  runner: (t, r) => {
300
- t.openNode("list", void 0, { ordered: !1 }).next(r.content).closeNode();
316
+ t.openNode("list", void 0, { ordered: !1, spread: r.attrs.spread === "true" }).next(r.content).closeNode();
301
317
  }
302
318
  }
303
319
  }),
304
320
  inputRules: (t) => [W(/^\s*([-+*])\s$/, t)],
305
- commands: (t) => [M(te, () => de(t))],
321
+ commands: (t) => [M(se, () => pe(t))],
306
322
  shortcuts: {
307
- [k.BulletList]: h(te, "Mod-Alt-8")
323
+ [k.BulletList]: h(se, "Mod-Alt-8")
308
324
  }
309
325
  };
310
- }), Qe = [
326
+ }), rt = [
311
327
  "",
312
328
  "javascript",
313
329
  "typescript",
@@ -324,10 +340,10 @@ const k = {
324
340
  "go",
325
341
  "rust",
326
342
  "markdown"
327
- ], Xe = /^```(?<language>[a-z]*)?[\s\n]$/, Ye = /^~~~(?<language>[a-z]*)?[\s\n]$/, re = I("TurnIntoCodeFence"), V = "fence", Ze = w((c, e) => {
328
- const t = (e == null ? void 0 : e.languageList) || Qe;
343
+ ], nt = /^```(?<language>[a-z]*)?[\s\n]$/, st = /^~~~(?<language>[a-z]*)?[\s\n]$/, oe = y("TurnIntoCodeFence"), z = "fence", ot = w((a, e) => {
344
+ const t = (e == null ? void 0 : e.languageList) || rt;
329
345
  return {
330
- id: V,
346
+ id: z,
331
347
  schema: (r) => ({
332
348
  content: "text*",
333
349
  group: "block",
@@ -347,17 +363,20 @@ const k = {
347
363
  tag: "div.code-fence-container",
348
364
  preserveWhitespace: "full",
349
365
  getAttrs: (n) => {
350
- var o;
366
+ var s;
351
367
  if (!(n instanceof HTMLElement))
352
- throw D(n);
353
- return { language: (o = n.querySelector("pre")) == null ? void 0 : o.dataset.language };
368
+ throw L(n);
369
+ return { language: (s = n.querySelector("pre")) == null ? void 0 : s.dataset.language };
354
370
  },
355
- getContent: (n, o) => {
356
- var s, l;
371
+ getContent: (n, s) => {
372
+ var c, i;
357
373
  if (!(n instanceof HTMLElement))
358
- throw D(n);
359
- const a = o.text((l = (s = n.querySelector("pre")) == null ? void 0 : s.textContent) != null ? l : "");
360
- return ge.from(a);
374
+ throw L(n);
375
+ const l = (i = (c = n.querySelector("pre")) == null ? void 0 : c.textContent) != null ? i : "";
376
+ if (!l)
377
+ return B.empty;
378
+ const o = s.text(l);
379
+ return B.from(o);
361
380
  }
362
381
  },
363
382
  {
@@ -365,44 +384,44 @@ const k = {
365
384
  preserveWhitespace: "full",
366
385
  getAttrs: (n) => {
367
386
  if (!(n instanceof HTMLElement))
368
- throw D(n);
387
+ throw L(n);
369
388
  return { language: n.dataset.language };
370
389
  }
371
390
  }
372
391
  ],
373
392
  toDOM: (n) => {
374
- const o = document.createElement("select");
375
- return t.forEach((a) => {
376
- const s = document.createElement("option");
377
- s.value = a, s.innerText = a || "--", a === n.attrs.language && (s.selected = !0), o.appendChild(s);
378
- }), o.onchange = (a) => {
379
- const s = a.target;
380
- if (!(s instanceof HTMLSelectElement))
393
+ const s = document.createElement("select");
394
+ return t.forEach((l) => {
395
+ const o = document.createElement("option");
396
+ o.value = l, o.innerText = l || "--", l === n.attrs.language && (o.selected = !0), s.appendChild(o);
397
+ }), s.onchange = (l) => {
398
+ const o = l.target;
399
+ if (!(o instanceof HTMLSelectElement))
381
400
  return;
382
- const l = r.get(B);
383
- if (!l.editable) {
384
- s.value = n.attrs.language;
401
+ const c = r.get(A);
402
+ if (!c.editable) {
403
+ o.value = n.attrs.language;
385
404
  return;
386
405
  }
387
- const { top: i, left: u } = s.getBoundingClientRect(), g = l.posAtCoords({ top: i, left: u });
388
- if (!g)
406
+ const { top: i, left: u } = o.getBoundingClientRect(), f = c.posAtCoords({ top: i, left: u });
407
+ if (!f)
389
408
  return;
390
- const { tr: d } = l.state;
391
- l.dispatch(d.setNodeMarkup(g.inside, void 0, {
409
+ const { tr: d } = c.state;
410
+ c.dispatch(d.setNodeMarkup(f.inside, void 0, {
392
411
  ...n.attrs,
393
- language: s.value
412
+ language: o.value
394
413
  }));
395
414
  }, [
396
415
  "div",
397
416
  {
398
417
  class: "code-fence-container"
399
418
  },
400
- o,
419
+ s,
401
420
  [
402
421
  "pre",
403
422
  {
404
423
  "data-language": n.attrs.language,
405
- class: c.getClassName(n.attrs, "code-fence")
424
+ class: a.getClassName(n.attrs, "code-fence")
406
425
  },
407
426
  ["code", { spellCheck: "false" }, 0]
408
427
  ]
@@ -410,93 +429,93 @@ const k = {
410
429
  },
411
430
  parseMarkdown: {
412
431
  match: ({ type: n }) => n === "code",
413
- runner: (n, o, a) => {
414
- const s = o.lang, l = o.value;
415
- n.openNode(a, { language: s }), l && n.addText(l), n.closeNode();
432
+ runner: (n, s, l) => {
433
+ const o = s.lang, c = s.value;
434
+ n.openNode(l, { language: o }), c && n.addText(c), n.closeNode();
416
435
  }
417
436
  },
418
437
  toMarkdown: {
419
- match: (n) => n.type.name === V,
420
- runner: (n, o) => {
421
- var a;
422
- n.addNode("code", void 0, ((a = o.content.firstChild) == null ? void 0 : a.text) || "", {
423
- lang: o.attrs.language
438
+ match: (n) => n.type.name === z,
439
+ runner: (n, s) => {
440
+ var l;
441
+ n.addNode("code", void 0, ((l = s.content.firstChild) == null ? void 0 : l.text) || "", {
442
+ lang: s.attrs.language
424
443
  });
425
444
  }
426
445
  }
427
446
  }),
428
447
  inputRules: (r) => [
429
- G(Xe, r, (n) => {
430
- const [o, a] = n;
431
- if (!!o)
432
- return { language: a };
448
+ Q(nt, r, (n) => {
449
+ const [s, l] = n;
450
+ if (!!s)
451
+ return { language: l };
433
452
  }),
434
- G(Ye, r, (n) => {
435
- const [o, a] = n;
436
- if (!!o)
437
- return { language: a };
453
+ Q(st, r, (n) => {
454
+ const [s, l] = n;
455
+ if (!!s)
456
+ return { language: l };
438
457
  })
439
458
  ],
440
- commands: (r) => [M(re, () => E(r))],
459
+ commands: (r) => [M(oe, () => S(r))],
441
460
  shortcuts: {
442
- [k.CodeFence]: h(re, "Mod-Alt-c")
461
+ [k.CodeFence]: h(oe, "Mod-Alt-c")
443
462
  },
444
- view: () => (r, n, o) => {
445
- let a = r;
446
- const s = (p) => {
447
- const { tr: b } = n.state;
448
- n.dispatch(b.setNodeMarkup(o(), void 0, {
463
+ view: () => (r, n, s) => {
464
+ let l = r;
465
+ const o = (g) => {
466
+ const { tr: N } = n.state;
467
+ n.dispatch(N.setNodeMarkup(s(), void 0, {
449
468
  fold: !0,
450
- language: p
469
+ language: g
451
470
  }));
452
- }, l = () => {
453
- const { tr: p } = n.state;
454
- n.dispatch(p.setNodeMarkup(o(), void 0, {
455
- ...a.attrs,
471
+ }, c = () => {
472
+ const { tr: g } = n.state;
473
+ n.dispatch(g.setNodeMarkup(s(), void 0, {
474
+ ...l.attrs,
456
475
  fold: !0
457
476
  }));
458
477
  }, i = () => {
459
- const { tr: p } = n.state;
460
- n.dispatch(p.setNodeMarkup(o(), void 0, {
461
- ...a.attrs,
478
+ const { tr: g } = n.state;
479
+ n.dispatch(g.setNodeMarkup(s(), void 0, {
480
+ ...l.attrs,
462
481
  fold: !1
463
482
  }));
464
- }, u = c.themeManager.get("code-fence", {
465
- onBlur: l,
483
+ }, u = a.themeManager.get("code-fence", {
484
+ onBlur: c,
466
485
  onFocus: i,
467
- onSelectLanguage: s,
486
+ onSelectLanguage: o,
468
487
  editable: () => n.editable,
469
488
  languageList: t
470
489
  });
471
490
  if (!u)
472
491
  return {};
473
- const { dom: g, contentDOM: d, onUpdate: m, onDestroy: f } = u;
474
- return m(a), {
475
- dom: g,
492
+ const { dom: f, contentDOM: d, onUpdate: m, onDestroy: p } = u;
493
+ return m(l), {
494
+ dom: f,
476
495
  contentDOM: d,
477
- update: (p) => p.type.name !== V ? !1 : (a = p, m(a), !0),
478
- destroy: f
496
+ update: (g) => g.type.name !== z ? !1 : (l = g, m(l), !0),
497
+ destroy: p
479
498
  };
480
499
  }
481
500
  };
482
- }), et = w(() => ({
501
+ }), at = w(() => ({
483
502
  id: "doc",
484
503
  schema: () => ({
485
504
  content: "block+",
486
505
  parseMarkdown: {
487
- match: ({ type: c }) => c === "root",
488
- runner: (c, e, t) => {
489
- c.injectRoot(e, t);
506
+ match: ({ type: a }) => a === "root",
507
+ runner: (a, e, t) => {
508
+ a.injectRoot(e, t);
490
509
  }
491
510
  },
492
511
  toMarkdown: {
493
- match: (c) => c.type.name === "doc",
494
- runner: (c, e) => {
495
- c.openNode("root"), c.next(e.content);
512
+ match: (a) => a.type.name === "doc",
513
+ runner: (a, e) => {
514
+ a.openNode("root"), a.next(e.content);
496
515
  }
497
516
  }
498
517
  })
499
- })), ne = I("InsertHardbreak"), tt = new T("MILKDOWN_HARDBREAK_FILTER"), rt = w((c, e) => {
518
+ })), ae = y("InsertHardbreak"), lt = new T("MILKDOWN_HARDBREAK_FILTER"), ct = w((a, e) => {
500
519
  var r;
501
520
  const t = (r = e == null ? void 0 : e.notIn) != null ? r : ["table", "fence"];
502
521
  return {
@@ -506,11 +525,11 @@ const k = {
506
525
  group: "inline",
507
526
  selectable: !1,
508
527
  parseDOM: [{ tag: "br" }],
509
- toDOM: (n) => ["br", { class: c.getClassName(n.attrs, "hardbreak") }],
528
+ toDOM: (n) => ["br", { class: a.getClassName(n.attrs, "hardbreak") }],
510
529
  parseMarkdown: {
511
530
  match: ({ type: n }) => n === "break",
512
- runner: (n, o, a) => {
513
- n.addNode(a);
531
+ runner: (n, s, l) => {
532
+ n.addNode(l);
514
533
  }
515
534
  },
516
535
  toMarkdown: {
@@ -521,138 +540,140 @@ const k = {
521
540
  }
522
541
  }),
523
542
  commands: (n) => [
524
- M(ne, () => (o, a) => {
543
+ M(ae, () => (s, l) => {
525
544
  var i;
526
- const { selection: s, tr: l } = o;
527
- if (s.empty) {
528
- const u = s.$from.node();
545
+ const { selection: o, tr: c } = s;
546
+ if (o.empty) {
547
+ const u = o.$from.node();
529
548
  if (u.childCount > 0 && ((i = u.lastChild) == null ? void 0 : i.type.name) === "hardbreak")
530
- return a == null || a(l.replaceRangeWith(s.to - 1, s.to, o.schema.node("paragraph")).setSelection(Le.near(l.doc.resolve(s.to))).scrollIntoView()), !0;
549
+ return l == null || l(c.replaceRangeWith(o.to - 1, o.to, s.schema.node("paragraph")).setSelection(Le.near(c.doc.resolve(o.to))).scrollIntoView()), !0;
531
550
  }
532
- return a == null || a(l.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
551
+ return l == null || l(c.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
533
552
  })
534
553
  ],
535
554
  shortcuts: {
536
- [k.HardBreak]: h(ne, "Shift-Enter")
555
+ [k.HardBreak]: h(ae, "Shift-Enter")
537
556
  },
538
557
  prosePlugins: (n) => [
539
- new H({
540
- key: tt,
541
- filterTransaction: (o, a) => {
542
- const s = o.getMeta("hardbreak"), [l] = o.steps;
543
- if (s && l) {
544
- const { from: i } = l, u = a.doc.resolve(i);
545
- let g = u.depth, d = !0;
546
- for (; g > 0; )
547
- t.includes(u.node(g).type.name) && (d = !1), g--;
558
+ new x({
559
+ key: lt,
560
+ filterTransaction: (s, l) => {
561
+ const o = s.getMeta("hardbreak"), [c] = s.steps;
562
+ if (o && c) {
563
+ const { from: i } = c, u = l.doc.resolve(i);
564
+ let f = u.depth, d = !0;
565
+ for (; f > 0; )
566
+ t.includes(u.node(f).type.name) && (d = !1), f--;
548
567
  return d;
549
568
  }
550
569
  return !0;
551
570
  }
552
571
  }),
553
- new H({
572
+ new x({
554
573
  key: new T("MILKDOWN_HARDBREAK_MARKS"),
555
- appendTransaction: (o, a, s) => {
556
- if (!o.length)
574
+ appendTransaction: (s, l, o) => {
575
+ if (!s.length)
557
576
  return;
558
- const [l] = o;
559
- if (!l)
577
+ const [c] = s;
578
+ if (!c)
560
579
  return;
561
- const [i] = l.steps;
562
- if (l.getMeta("hardbreak")) {
563
- if (!(i instanceof $e))
580
+ const [i] = c.steps;
581
+ if (c.getMeta("hardbreak")) {
582
+ if (!(i instanceof qe))
564
583
  return;
565
584
  const { from: d } = i;
566
- return s.tr.setNodeMarkup(d, n, void 0, []);
585
+ return o.tr.setNodeMarkup(d, n, void 0, []);
567
586
  }
568
- if (i instanceof Se) {
569
- let d = s.tr;
570
- const { from: m, to: f } = i;
571
- return s.doc.nodesBetween(m, f, (p, b) => {
572
- p.type === n && (d = d.setNodeMarkup(b, n, void 0, []));
587
+ if (i instanceof Ke) {
588
+ let d = o.tr;
589
+ const { from: m, to: p } = i;
590
+ return o.doc.nodesBetween(m, p, (g, N) => {
591
+ g.type === n && (d = d.setNodeMarkup(N, n, void 0, []));
573
592
  }), d;
574
593
  }
575
594
  }
576
595
  })
577
596
  ]
578
597
  };
579
- }), ke = Array(6).fill(0).map((c, e) => e + 1), C = I("TurnIntoHeading"), Me = I("DowngradeHeading"), j = new T("MILKDOWN_HEADING_ID"), nt = new T("MILKDOWN_HEADING_HASH"), st = (c) => c.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), ot = (c, e, t) => {
598
+ }), ke = Array(6).fill(0).map((a, e) => e + 1), D = y("TurnIntoHeading"), Me = y("DowngradeHeading"), U = new T("MILKDOWN_HEADING_ID"), it = new T("MILKDOWN_HEADING_HASH"), ut = (a) => a.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), dt = (a, e, t) => {
580
599
  let r = !1;
581
- const n = (o, a) => {
582
- const s = o.tr;
583
- o.doc.descendants((l, i) => {
584
- if (l.type === e && !r) {
585
- if (l.textContent.trim().length === 0)
600
+ const n = (s, l) => {
601
+ const o = s.tr.setMeta("addToHistory", !1);
602
+ let c = !1;
603
+ s.doc.descendants((i, u) => {
604
+ if (i.type === e && !r) {
605
+ if (i.textContent.trim().length === 0)
586
606
  return;
587
- const u = l.attrs, g = t(l);
588
- u.id !== g && s.setMeta(j, !0).setNodeMarkup(i, void 0, {
589
- ...u,
590
- id: g
591
- });
607
+ const f = i.attrs, d = t(i);
608
+ f.id !== d && (c = !0, o.setMeta(U, !0).setNodeMarkup(u, void 0, {
609
+ ...f,
610
+ id: d
611
+ }));
592
612
  }
593
- }), a(s);
613
+ }), c && l(o);
594
614
  };
595
- return new H({
596
- key: j,
615
+ return new x({
616
+ key: U,
597
617
  props: {
598
618
  handleDOMEvents: {
599
619
  compositionstart: () => (r = !0, !1),
600
620
  compositionend: () => {
601
621
  r = !1;
602
- const o = c.get(B);
622
+ const s = a.get(A);
603
623
  return setTimeout(() => {
604
- n(o.state, (a) => o.dispatch(a));
624
+ n(s.state, (l) => s.dispatch(l));
605
625
  }, 0), !1;
606
626
  }
607
627
  }
608
628
  },
609
- appendTransaction: (o, a, s) => {
610
- let l = null;
611
- return o.every((i) => !i.getMeta(j)) && o.some((i) => i.docChanged) && n(s, (i) => {
612
- l = i;
613
- }), l;
629
+ appendTransaction: (s, l, o) => {
630
+ let c = null;
631
+ return s.every((i) => !i.getMeta(U)) && s.some((i) => i.docChanged) && n(o, (i) => {
632
+ c = i;
633
+ }), c;
614
634
  },
615
- view: (o) => {
616
- const a = o.state.doc;
617
- let s = o.state.tr;
618
- return a.descendants((l, i) => {
619
- l.type.name === "heading" && l.attrs.level && (l.attrs.id || (s = s.setNodeMarkup(i, void 0, {
620
- ...l.attrs,
621
- id: t(l)
635
+ view: (s) => {
636
+ const l = s.state.doc;
637
+ let o = s.state.tr.setMeta("addToHistory", !1);
638
+ return l.descendants((c, i) => {
639
+ c.type.name === "heading" && c.attrs.level && (c.attrs.id || (o = o.setNodeMarkup(i, void 0, {
640
+ ...c.attrs,
641
+ id: t(c)
622
642
  })));
623
- }), o.dispatch(s), {};
643
+ }), s.dispatch(o), {};
624
644
  }
625
645
  });
626
- }, at = (c, e, t) => new H({
627
- key: nt,
646
+ }, ft = (a, e, t) => new x({
647
+ key: it,
628
648
  state: {
629
649
  init: () => O.empty,
630
650
  apply: (r) => {
631
- const n = c.get(B);
632
- if (!n.hasFocus || !n.editable)
651
+ var f;
652
+ const n = a.get(A);
653
+ if (!((f = n.hasFocus) != null && f.call(n)) || !n.editable)
633
654
  return O.empty;
634
- const { $from: o } = r.selection, a = o.node();
635
- if (a.type !== e)
655
+ const { $from: s } = r.selection, l = s.node();
656
+ if (l.type !== e)
636
657
  return O.empty;
637
- const s = a.attrs.level, l = (g) => Array(g).fill(0).map((d) => "#").join(""), i = document.createElement("span");
638
- i.textContent = l(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
639
- const g = t.getStyle(({ css: d }) => {
640
- const m = Te(t.themeManager);
641
- return d`
658
+ const o = l.attrs.level, c = (d) => Array(d).fill(0).map((m) => "#").join(""), i = document.createElement("span");
659
+ i.textContent = c(o), i.contentEditable = "false", t.themeManager.onFlush(() => {
660
+ const d = t.getStyle(({ css: m }) => {
661
+ const p = Ae(t.themeManager);
662
+ return m`
642
663
  margin-right: 4px;
643
- color: ${m("primary")};
664
+ color: ${p("primary")};
644
665
  `;
645
666
  });
646
- g && (i.className = g);
667
+ d && (i.className = d);
647
668
  });
648
- const u = J.widget(o.before() + 1, i, { side: -1 });
669
+ const u = X.widget(s.before() + 1, i, { side: -1 });
649
670
  return O.create(r.doc, [u]);
650
671
  }
651
672
  },
652
673
  props: {
653
674
  handleDOMEvents: {
654
675
  focus: (r) => {
655
- const n = Ae(r.state.tr);
676
+ const n = Be(r.state.tr);
656
677
  return r.dispatch(n), !1;
657
678
  }
658
679
  },
@@ -660,9 +681,9 @@ const k = {
660
681
  return this.getState(r);
661
682
  }
662
683
  }
663
- }), lt = w((c, e) => {
664
- var o, a;
665
- const t = "heading", r = (o = e == null ? void 0 : e.getId) != null ? o : st, n = (a = e == null ? void 0 : e.displayHashtag) != null ? a : !0;
684
+ }), mt = w((a, e) => {
685
+ var s, l;
686
+ const t = "heading", r = (s = e == null ? void 0 : e.getId) != null ? s : ut, n = (l = e == null ? void 0 : e.displayHashtag) != null ? l : !0;
666
687
  return {
667
688
  id: t,
668
689
  schema: () => ({
@@ -677,46 +698,46 @@ const k = {
677
698
  default: 1
678
699
  }
679
700
  },
680
- parseDOM: ke.map((s) => ({
681
- tag: `h${s}`,
682
- getAttrs: (l) => {
683
- if (!(l instanceof HTMLElement))
684
- throw D(l);
685
- return { level: s, id: l.id };
701
+ parseDOM: ke.map((o) => ({
702
+ tag: `h${o}`,
703
+ getAttrs: (c) => {
704
+ if (!(c instanceof HTMLElement))
705
+ throw L(c);
706
+ return { level: o, id: c.id };
686
707
  }
687
708
  })),
688
- toDOM: (s) => [
689
- `h${s.attrs.level}`,
709
+ toDOM: (o) => [
710
+ `h${o.attrs.level}`,
690
711
  {
691
- id: s.attrs.id || r(s),
692
- class: c.getClassName(s.attrs, `heading h${s.attrs.level}`)
712
+ id: o.attrs.id || r(o),
713
+ class: a.getClassName(o.attrs, `heading h${o.attrs.level}`)
693
714
  },
694
715
  0
695
716
  ],
696
717
  parseMarkdown: {
697
- match: ({ type: s }) => s === t,
698
- runner: (s, l, i) => {
699
- const u = l.depth;
700
- s.openNode(i, { level: u }), s.next(l.children), s.closeNode();
718
+ match: ({ type: o }) => o === t,
719
+ runner: (o, c, i) => {
720
+ const u = c.depth;
721
+ o.openNode(i, { level: u }), o.next(c.children), o.closeNode();
701
722
  }
702
723
  },
703
724
  toMarkdown: {
704
- match: (s) => s.type.name === t,
705
- runner: (s, l) => {
725
+ match: (o) => o.type.name === t,
726
+ runner: (o, c) => {
706
727
  var u;
707
- if (s.openNode("heading", void 0, { depth: l.attrs.level }), l.childCount >= 1 && ((u = l.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
708
- const g = [];
709
- l.content.forEach((d, m, f) => {
710
- f !== l.childCount - 1 && g.push(d);
711
- }), s.next(ge.fromArray(g));
728
+ if (o.openNode("heading", void 0, { depth: c.attrs.level }), c.childCount >= 1 && ((u = c.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
729
+ const f = [];
730
+ c.content.forEach((d, m, p) => {
731
+ p !== c.childCount - 1 && f.push(d);
732
+ }), o.next(B.fromArray(f));
712
733
  } else
713
- s.next(l.content);
714
- s.closeNode();
734
+ o.next(c.content);
735
+ o.closeNode();
715
736
  }
716
737
  }
717
738
  }),
718
- inputRules: (s, l) => ke.map((i) => G(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
719
- const u = l.get(B), { $from: g } = u.state.selection, d = g.node();
739
+ inputRules: (o, c) => ke.map((i) => Q(new RegExp(`^(#{1,${i}})\\s$`), o, () => {
740
+ const u = c.get(A), { $from: f } = u.state.selection, d = f.node();
720
741
  if (d.type.name === "heading") {
721
742
  let m = Number(d.attrs.level) + Number(i);
722
743
  return m > 6 && (m = 6), {
@@ -727,39 +748,39 @@ const k = {
727
748
  level: i
728
749
  };
729
750
  })),
730
- commands: (s, l) => [
731
- M(C, (i = 1) => i < 1 ? E(i === 0 && l.get(A).nodes.paragraph || s) : E(i === 0 && l.get(A).nodes.paragraph || s, { level: i })),
732
- M(Me, () => (i, u, g) => {
751
+ commands: (o, c) => [
752
+ M(D, (i = 1) => i < 1 ? S(i === 0 && c.get(P).nodes.paragraph || o) : S(i === 0 && c.get(P).nodes.paragraph || o, { level: i })),
753
+ M(Me, () => (i, u, f) => {
733
754
  const { $from: d } = i.selection, m = d.node();
734
- if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
755
+ if (m.type !== o || !i.selection.empty || d.parentOffset !== 0)
735
756
  return !1;
736
- const f = m.attrs.level - 1;
737
- return f ? (u == null || u(i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
757
+ const p = m.attrs.level - 1;
758
+ return p ? (u == null || u(i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
738
759
  ...m.attrs,
739
- level: f
740
- })), !0) : E(l.get(A).nodes.paragraph || s)(i, u, g);
760
+ level: p
761
+ })), !0) : S(c.get(P).nodes.paragraph || o)(i, u, f);
741
762
  })
742
763
  ],
743
764
  shortcuts: {
744
- [k.H1]: h(C, "Mod-Alt-1", 1),
745
- [k.H2]: h(C, "Mod-Alt-2", 2),
746
- [k.H3]: h(C, "Mod-Alt-3", 3),
747
- [k.H4]: h(C, "Mod-Alt-4", 4),
748
- [k.H5]: h(C, "Mod-Alt-5", 5),
749
- [k.H6]: h(C, "Mod-Alt-6", 6),
765
+ [k.H1]: h(D, "Mod-Alt-1", 1),
766
+ [k.H2]: h(D, "Mod-Alt-2", 2),
767
+ [k.H3]: h(D, "Mod-Alt-3", 3),
768
+ [k.H4]: h(D, "Mod-Alt-4", 4),
769
+ [k.H5]: h(D, "Mod-Alt-5", 5),
770
+ [k.H6]: h(D, "Mod-Alt-6", 6),
750
771
  [k.DowngradeHeading]: h(Me, ["Backspace", "Delete"])
751
772
  },
752
- prosePlugins: (s, l) => {
753
- const i = [ot(l, s, r)];
754
- return n && i.push(at(l, s, c)), i;
773
+ prosePlugins: (o, c) => {
774
+ const i = [dt(c, o, r)];
775
+ return n && i.push(ft(c, o, a)), i;
755
776
  }
756
777
  };
757
- }), z = "hr", Ce = I("InsertHr"), ct = w((c) => ({
758
- id: z,
778
+ }), V = "hr", Te = y("InsertHr"), pt = w((a) => ({
779
+ id: V,
759
780
  schema: () => ({
760
781
  group: "block",
761
782
  parseDOM: [{ tag: "hr" }],
762
- toDOM: (e) => ["hr", { class: c.getClassName(e.attrs, z) }],
783
+ toDOM: (e) => ["hr", { class: a.getClassName(e.attrs, V) }],
763
784
  parseMarkdown: {
764
785
  match: ({ type: e }) => e === "thematicBreak",
765
786
  runner: (e, t, r) => {
@@ -767,30 +788,30 @@ const k = {
767
788
  }
768
789
  },
769
790
  toMarkdown: {
770
- match: (e) => e.type.name === z,
791
+ match: (e) => e.type.name === V,
771
792
  runner: (e) => {
772
793
  e.addNode("thematicBreak");
773
794
  }
774
795
  }
775
796
  }),
776
797
  inputRules: (e) => [
777
- new me(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, o) => {
778
- const { tr: a } = t;
779
- return r[0] && a.replaceWith(n - 1, o, e.create()), a;
798
+ new Ce(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, s) => {
799
+ const { tr: l } = t;
800
+ return r[0] && l.replaceWith(n - 1, s, e.create()), l;
780
801
  })
781
802
  ],
782
803
  commands: (e, t) => [
783
- M(Ce, () => (r, n) => {
804
+ M(Te, () => (r, n) => {
784
805
  if (!n)
785
806
  return !0;
786
- const o = t.get(A).node("paragraph"), { tr: a, selection: s } = r, { from: l } = s, i = e.create();
807
+ const s = t.get(P).node("paragraph"), { tr: l, selection: o } = r, { from: c } = o, i = e.create();
787
808
  if (!i)
788
809
  return !0;
789
- const u = a.replaceSelectionWith(i).insert(l, o), g = Le.findFrom(u.doc.resolve(l), 1, !0);
790
- return g && n(u.setSelection(g).scrollIntoView()), !0;
810
+ const u = l.replaceSelectionWith(i).insert(c, s), f = Le.findFrom(u.doc.resolve(c), 1, !0);
811
+ return f && n(u.setSelection(f).scrollIntoView()), !0;
791
812
  })
792
813
  ]
793
- })), se = I("ModifyImage"), De = I("InsertImage"), S = "image", it = new T("MILKDOWN_IMAGE_INPUT"), ut = w((c, e) => ({
814
+ })), le = y("ModifyImage"), He = y("InsertImage"), $ = "image", gt = new T("MILKDOWN_IMAGE_INPUT"), ht = w((a, e) => ({
794
815
  id: "image",
795
816
  schema: () => ({
796
817
  inline: !0,
@@ -803,20 +824,19 @@ const k = {
803
824
  isolating: !0,
804
825
  attrs: {
805
826
  src: { default: "" },
806
- alt: { default: null },
807
- title: { default: null }
827
+ alt: { default: "" },
828
+ title: { default: "" }
808
829
  },
809
830
  parseDOM: [
810
831
  {
811
832
  tag: "img[src]",
812
833
  getAttrs: (t) => {
813
834
  if (!(t instanceof HTMLElement))
814
- throw D(t);
835
+ throw L(t);
815
836
  return {
816
837
  src: t.getAttribute("src") || "",
817
- alt: t.getAttribute("alt"),
818
- title: t.getAttribute("title") || t.getAttribute("alt"),
819
- width: t.getAttribute("width")
838
+ alt: t.getAttribute("alt") || "",
839
+ title: t.getAttribute("title") || t.getAttribute("alt") || ""
820
840
  };
821
841
  }
822
842
  }
@@ -825,22 +845,22 @@ const k = {
825
845
  "img",
826
846
  {
827
847
  ...t.attrs,
828
- class: c.getClassName(t.attrs, S)
848
+ class: a.getClassName(t.attrs, $)
829
849
  }
830
850
  ],
831
851
  parseMarkdown: {
832
- match: ({ type: t }) => t === S,
852
+ match: ({ type: t }) => t === $,
833
853
  runner: (t, r, n) => {
834
- const o = r.url, a = r.alt, s = r.title;
854
+ const s = r.url, l = r.alt, o = r.title;
835
855
  t.addNode(n, {
836
- src: o,
837
- alt: a,
838
- title: s
856
+ src: s,
857
+ alt: l,
858
+ title: o
839
859
  });
840
860
  }
841
861
  },
842
862
  toMarkdown: {
843
- match: (t) => t.type.name === S,
863
+ match: (t) => t.type.name === $,
844
864
  runner: (t, r) => {
845
865
  t.addNode("image", void 0, void 0, {
846
866
  title: r.attrs.title,
@@ -851,112 +871,108 @@ const k = {
851
871
  }
852
872
  }),
853
873
  commands: (t) => [
854
- M(De, (r = "") => (n, o) => {
855
- if (!o)
856
- return !0;
857
- const { tr: a } = n, s = t.create({ src: r });
874
+ M(He, (r = "") => (n, s) => {
858
875
  if (!s)
859
876
  return !0;
860
- const l = a.replaceSelectionWith(s);
861
- return o(l.scrollIntoView()), !0;
877
+ const { tr: l } = n, o = t.create({ src: r });
878
+ if (!o)
879
+ return !0;
880
+ const c = l.replaceSelectionWith(o);
881
+ return s(c.scrollIntoView()), !0;
862
882
  }),
863
- M(se, (r = "") => (n, o) => {
864
- const a = K(n.selection, t);
865
- if (!a)
883
+ M(le, (r = "") => (n, s) => {
884
+ const l = K(n.selection, t);
885
+ if (!l)
866
886
  return !1;
867
- const { tr: s } = n;
868
- return o == null || o(s.setNodeMarkup(a.pos, void 0, { ...a.node.attrs, loading: !0, src: r }).scrollIntoView()), !0;
887
+ const { tr: o } = n;
888
+ return s == null || s(o.setNodeMarkup(l.pos, void 0, { ...l.node.attrs, loading: !0, src: r }).scrollIntoView()), !0;
869
889
  })
870
890
  ],
871
891
  inputRules: (t) => [
872
- new me(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/, (r, n, o, a) => {
873
- const [s, l, i = "", u] = n, { tr: g } = r;
874
- return s && g.replaceWith(o, a, t.create({ src: i, alt: l, title: u })), g;
892
+ new Ce(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/, (r, n, s, l) => {
893
+ const [o, c, i = "", u] = n, { tr: f } = r;
894
+ return o && f.replaceWith(s, l, t.create({ src: i, alt: c, title: u })), f;
875
895
  })
876
896
  ],
877
897
  view: () => (t) => {
878
898
  var i, u;
879
899
  let r = t;
880
- const n = (i = e == null ? void 0 : e.placeholder) != null ? i : "Add an Image", o = (u = e == null ? void 0 : e.isBlock) != null ? u : !1, a = c.themeManager.get("image", {
900
+ const n = (i = e == null ? void 0 : e.placeholder) != null ? i : "Add an Image", s = (u = e == null ? void 0 : e.isBlock) != null ? u : !1, l = a.themeManager.get("image", {
881
901
  placeholder: n,
882
- isBlock: o
902
+ isBlock: s
883
903
  });
884
- if (!a)
904
+ if (!l)
885
905
  return {};
886
- const { dom: s, onUpdate: l } = a;
887
- return l(r), {
888
- dom: s,
889
- update: (g) => g.type.name !== S ? !1 : (r = g, l(r), !0),
906
+ const { dom: o, onUpdate: c } = l;
907
+ return c(r), {
908
+ dom: o,
909
+ update: (f) => f.type.name !== $ ? !1 : (r = f, c(r), !0),
890
910
  selectNode: () => {
891
- s.classList.add("ProseMirror-selectednode");
911
+ o.classList.add("ProseMirror-selectednode");
892
912
  },
893
913
  deselectNode: () => {
894
- s.classList.remove("ProseMirror-selectednode");
914
+ o.classList.remove("ProseMirror-selectednode");
895
915
  }
896
916
  };
897
917
  },
898
918
  prosePlugins: (t, r) => [
899
- new H({
900
- key: it,
919
+ new x({
920
+ key: gt,
901
921
  view: (n) => {
902
- var i, u, g;
903
- const o = c.themeManager.get("input-chip", {
922
+ var i, u, f;
923
+ const s = a.themeManager.get("input-chip", {
904
924
  placeholder: (u = (i = e == null ? void 0 : e.input) == null ? void 0 : i.placeholder) != null ? u : "Input Image Link",
905
- buttonText: (g = e == null ? void 0 : e.input) == null ? void 0 : g.buttonText,
925
+ buttonText: (f = e == null ? void 0 : e.input) == null ? void 0 : f.buttonText,
906
926
  onUpdate: (d) => {
907
- r.get(we).call(se, d);
927
+ r.get(we).call(le, d);
908
928
  }
909
929
  });
910
- if (!o)
930
+ if (!s)
911
931
  return {};
912
- const a = (d) => Boolean(d.hasFocus() && t && K(d.state.selection, t)), s = (d) => {
932
+ const l = (d) => Boolean(d.hasFocus() && t && K(d.state.selection, t)), o = (d) => {
913
933
  const m = K(d.state.selection, t);
914
934
  return m ? m.node.attrs.src : void 0;
915
- }, l = (d) => {
935
+ }, c = (d) => {
916
936
  if (!d.editable)
917
937
  return;
918
- a(d) ? (o.show(d), o.update(s(d))) : o.hide();
938
+ l(d) ? (s.show(d), s.update(o(d))) : s.hide();
919
939
  };
920
- return o.init(n), l(n), {
940
+ return s.init(n), c(n), {
921
941
  update: (d, m) => {
922
- (m == null ? void 0 : m.doc.eq(d.state.doc)) && m.selection.eq(d.state.selection) || l(d);
942
+ (m == null ? void 0 : m.doc.eq(d.state.doc)) && m.selection.eq(d.state.selection) || c(d);
923
943
  },
924
944
  destroy: () => {
925
- o.destroy();
945
+ s.destroy();
926
946
  }
927
947
  };
928
948
  }
929
949
  })
930
950
  ]
931
- })), Ie = "list_item", oe = I("SplitListItem"), ae = I("SinkListItem"), le = I("LiftListItem"), dt = new T("MILKDOWN_KEEP_LIST_ORDER"), mt = (c) => {
951
+ })), ye = "list_item", ce = y("SplitListItem"), ie = y("SinkListItem"), ue = y("LiftListItem"), kt = new T("MILKDOWN_KEEP_LIST_ORDER"), Mt = (a) => {
932
952
  const e = (t, r) => {
933
- const n = Ee("ordered_list", t.schema);
934
- let o = t.tr;
935
- t.doc.descendants((a, s, l, i) => {
936
- if (a.type === c && (l == null ? void 0 : l.type) === n) {
953
+ const n = Re("ordered_list", t.schema);
954
+ let s = t.tr;
955
+ t.doc.descendants((l, o, c, i) => {
956
+ if (l.type === a && (c == null ? void 0 : c.type) === n) {
937
957
  let u = !1;
938
- const g = { ...a.attrs };
939
- a.attrs.listType !== "ordered" && (g.listType = "ordered", u = !0);
940
- const d = l == null ? void 0 : l.maybeChild(i - 1);
941
- if (d && d.type === c && d.attrs.listType === "ordered") {
942
- const m = d.attrs.label;
943
- g.label = `${Number(m.slice(0, -1)) + 1}.`, u = !0;
944
- }
945
- a.attrs.label === "\u2022" && (g.label = `${i + 1}.`, u = !0), u && (o = o.setNodeMarkup(s, void 0, g));
958
+ const f = { ...l.attrs };
959
+ l.attrs.listType !== "ordered" && (f.listType = "ordered", u = !0);
960
+ const d = c == null ? void 0 : c.maybeChild(0);
961
+ d && d.type === a && d.attrs.listType === "ordered" && (f.label = `${i + 1}.`, u = !0), l.attrs.label === "\u2022" && (f.label = `${i + 1}.`, u = !0), u && (s = s.setNodeMarkup(o, void 0, f));
946
962
  }
947
- }), r(o);
963
+ }), r(s);
948
964
  };
949
- return new H({
950
- key: dt,
965
+ return new x({
966
+ key: kt,
951
967
  appendTransaction: (t, r, n) => {
952
- let o = null;
953
- return t.some((a) => a.docChanged) && e(n, (a) => {
954
- o = a;
955
- }), o;
968
+ let s = null;
969
+ return t.some((l) => l.docChanged) && e(n, (l) => {
970
+ s = l;
971
+ }), s;
956
972
  }
957
973
  });
958
- }, gt = w((c) => ({
959
- id: Ie,
974
+ }, yt = w((a) => ({
975
+ id: ye,
960
976
  schema: () => ({
961
977
  group: "listItem",
962
978
  content: "paragraph block*",
@@ -966,6 +982,9 @@ const k = {
966
982
  },
967
983
  listType: {
968
984
  default: "bullet"
985
+ },
986
+ spread: {
987
+ default: "true"
969
988
  }
970
989
  },
971
990
  defining: !0,
@@ -974,60 +993,70 @@ const k = {
974
993
  tag: "li.list-item",
975
994
  getAttrs: (e) => {
976
995
  if (!(e instanceof HTMLElement))
977
- throw D(e);
996
+ throw L(e);
978
997
  return {
979
998
  label: e.dataset.label,
980
- listType: e.dataset["list-type"]
999
+ listType: e.dataset["list-type"],
1000
+ spread: e.dataset.spread
981
1001
  };
982
1002
  },
983
- contentElement: "div.list-item_body"
1003
+ contentElement: (e) => {
1004
+ if (!(e instanceof HTMLElement))
1005
+ throw L(e);
1006
+ const t = e.querySelector(".list-item_body");
1007
+ return t || e;
1008
+ }
984
1009
  },
985
1010
  { tag: "li" }
986
1011
  ],
987
1012
  toDOM: (e) => [
988
1013
  "li",
989
1014
  {
990
- class: c.getClassName(e.attrs, "list-item"),
1015
+ class: a.getClassName(e.attrs, "list-item"),
991
1016
  "data-label": e.attrs.label,
992
- "data-list-type": e.attrs.listType
1017
+ "data-list-type": e.attrs.listType,
1018
+ "data-spread": e.attrs.spread
993
1019
  },
994
- ["div", { class: c.getClassName(e.attrs, "list-item_label") }, e.attrs.label],
995
- ["div", { class: c.getClassName(e.attrs, "list-item_body") }, 0]
1020
+ ["div", { class: a.getClassName(e.attrs, "list-item_label") }, e.attrs.label],
1021
+ ["div", { class: a.getClassName(e.attrs, "list-item_body") }, 0]
996
1022
  ],
997
1023
  parseMarkdown: {
998
1024
  match: ({ type: e, checked: t }) => e === "listItem" && t === null,
999
1025
  runner: (e, t, r) => {
1000
- const n = t.label != null ? `${t.label}.` : "\u2022", o = t.label != null ? "ordered" : "bullet";
1001
- e.openNode(r, { label: n, listType: o }), e.next(t.children), e.closeNode();
1026
+ const n = t.label != null ? `${t.label}.` : "\u2022", s = t.label != null ? "ordered" : "bullet", l = t.spread != null ? `${t.spread}` : "true";
1027
+ e.openNode(r, { label: n, listType: s, spread: l }), e.next(t.children), e.closeNode();
1002
1028
  }
1003
1029
  },
1004
1030
  toMarkdown: {
1005
- match: (e) => e.type.name === Ie,
1031
+ match: (e) => e.type.name === ye,
1006
1032
  runner: (e, t) => {
1007
- e.openNode("listItem"), e.next(t.content), e.closeNode();
1033
+ e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
1008
1034
  }
1009
1035
  }
1010
1036
  }),
1011
1037
  inputRules: (e) => [W(/^\s*([-+*])\s$/, e)],
1012
1038
  commands: (e) => [
1013
- M(oe, () => Re(e)),
1014
- M(ae, () => Be(e)),
1015
- M(le, () => Pe(e))
1039
+ M(ce, () => Fe(e)),
1040
+ M(ie, () => je(e)),
1041
+ M(ue, () => ze(e))
1016
1042
  ],
1017
1043
  shortcuts: {
1018
- [k.NextListItem]: h(oe, "Enter"),
1019
- [k.SinkListItem]: h(ae, "Mod-]"),
1020
- [k.LiftListItem]: h(le, "Mod-[")
1044
+ [k.NextListItem]: h(ce, "Enter"),
1045
+ [k.SinkListItem]: h(ie, "Mod-]"),
1046
+ [k.LiftListItem]: h(ue, "Mod-[")
1021
1047
  },
1022
- prosePlugins: (e) => [mt(e)]
1023
- })), ce = I("WrapInOrderedList"), be = "ordered_list", ft = w((c) => ({
1024
- id: be,
1048
+ prosePlugins: (e) => [Mt(e)]
1049
+ })), de = y("WrapInOrderedList"), Ne = "ordered_list", Nt = w((a) => ({
1050
+ id: Ne,
1025
1051
  schema: () => ({
1026
1052
  content: "listItem+",
1027
1053
  group: "block",
1028
1054
  attrs: {
1029
1055
  order: {
1030
1056
  default: 1
1057
+ },
1058
+ spread: {
1059
+ default: !1
1031
1060
  }
1032
1061
  },
1033
1062
  parseDOM: [
@@ -1035,8 +1064,11 @@ const k = {
1035
1064
  tag: "ol",
1036
1065
  getAttrs: (e) => {
1037
1066
  if (!(e instanceof HTMLElement))
1038
- throw D(e);
1039
- return { order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1 };
1067
+ throw L(e);
1068
+ return {
1069
+ spread: e.dataset.spread,
1070
+ order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
1071
+ };
1040
1072
  }
1041
1073
  }
1042
1074
  ],
@@ -1044,37 +1076,39 @@ const k = {
1044
1076
  "ol",
1045
1077
  {
1046
1078
  ...e.attrs.order === 1 ? {} : e.attrs.order,
1047
- class: c.getClassName(e.attrs, "ordered-list")
1079
+ "data-spread": e.attrs.spread,
1080
+ class: a.getClassName(e.attrs, "ordered-list")
1048
1081
  },
1049
1082
  0
1050
1083
  ],
1051
1084
  parseMarkdown: {
1052
1085
  match: ({ type: e, ordered: t }) => e === "list" && !!t,
1053
1086
  runner: (e, t, r) => {
1054
- e.openNode(r).next(t.children).closeNode();
1087
+ const n = t.spread != null ? `${t.spread}` : "true";
1088
+ e.openNode(r, { spread: n }).next(t.children).closeNode();
1055
1089
  }
1056
1090
  },
1057
1091
  toMarkdown: {
1058
- match: (e) => e.type.name === be,
1092
+ match: (e) => e.type.name === Ne,
1059
1093
  runner: (e, t) => {
1060
- e.openNode("list", void 0, { ordered: !0, start: 1 }), e.next(t.content), e.closeNode();
1094
+ e.openNode("list", void 0, { ordered: !0, start: 1, spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
1061
1095
  }
1062
1096
  }
1063
1097
  }),
1064
1098
  inputRules: (e) => [
1065
1099
  W(/^(\d+)\.\s$/, e, (t) => ({ order: Number(t[1]) }), (t, r) => r.childCount + r.attrs.order === Number(t[1]))
1066
1100
  ],
1067
- commands: (e) => [M(ce, () => de(e))],
1101
+ commands: (e) => [M(de, () => pe(e))],
1068
1102
  shortcuts: {
1069
- [k.OrderedList]: h(ce, "Mod-Alt-7")
1103
+ [k.OrderedList]: h(de, "Mod-Alt-7")
1070
1104
  }
1071
- })), ie = I("TurnIntoText"), ye = "paragraph", pt = w((c) => ({
1072
- id: ye,
1105
+ })), fe = y("TurnIntoText"), Ie = "paragraph", It = w((a) => ({
1106
+ id: Ie,
1073
1107
  schema: () => ({
1074
1108
  content: "inline*",
1075
1109
  group: "block",
1076
1110
  parseDOM: [{ tag: "p" }],
1077
- toDOM: (e) => ["p", { class: c.getClassName(e.attrs, ye) }, 0],
1111
+ toDOM: (e) => ["p", { class: a.getClassName(e.attrs, Ie) }, 0],
1078
1112
  parseMarkdown: {
1079
1113
  match: (e) => e.type === "paragraph",
1080
1114
  runner: (e, t, r) => {
@@ -1086,198 +1120,318 @@ const k = {
1086
1120
  runner: (e, t) => {
1087
1121
  var n;
1088
1122
  if (e.openNode("paragraph"), t.childCount >= 1 && ((n = t.lastChild) == null ? void 0 : n.type.name) === "hardbreak") {
1089
- const o = [];
1090
- t.content.forEach((a, s, l) => {
1091
- l !== t.childCount - 1 && o.push(a);
1092
- }), e.next(ge.fromArray(o));
1123
+ const s = [];
1124
+ t.content.forEach((l, o, c) => {
1125
+ c !== t.childCount - 1 && s.push(l);
1126
+ }), e.next(B.fromArray(s));
1093
1127
  } else
1094
1128
  e.next(t.content);
1095
1129
  e.closeNode();
1096
1130
  }
1097
1131
  }
1098
1132
  }),
1099
- commands: (e) => [M(ie, () => E(e))],
1133
+ commands: (e) => [M(fe, () => S(e))],
1100
1134
  shortcuts: {
1101
- [k.Text]: h(ie, "Mod-Alt-0")
1135
+ [k.Text]: h(fe, "Mod-Alt-0")
1102
1136
  }
1103
- })), ht = w(() => ({
1137
+ })), bt = w(() => ({
1104
1138
  id: "text",
1105
1139
  schema: () => ({
1106
1140
  group: "inline",
1107
1141
  parseMarkdown: {
1108
- match: ({ type: c }) => c === "text",
1109
- runner: (c, e) => {
1110
- c.addText(e.value);
1142
+ match: ({ type: a }) => a === "text",
1143
+ runner: (a, e) => {
1144
+ a.addText(e.value);
1111
1145
  }
1112
1146
  },
1113
1147
  toMarkdown: {
1114
- match: (c) => c.type.name === "text",
1115
- runner: (c, e) => {
1116
- c.addNode("text", void 0, e.text);
1148
+ match: (a) => a.type.name === "text",
1149
+ runner: (a, e) => {
1150
+ a.addNode("text", void 0, e.text);
1117
1151
  }
1118
1152
  }
1119
1153
  })
1120
- })), kt = [
1154
+ })), wt = [
1155
+ at(),
1156
+ It(),
1157
+ ct(),
1121
1158
  et(),
1159
+ ot(),
1160
+ tt(),
1161
+ Nt(),
1162
+ yt(),
1163
+ mt(),
1122
1164
  pt(),
1123
- rt(),
1124
- Ge(),
1125
- Ze(),
1126
- Je(),
1127
- ft(),
1128
- gt(),
1129
- lt(),
1130
- ct(),
1131
- ut(),
1132
- ht()
1133
- ], Mt = () => {
1134
- function c(e) {
1135
- qe(e, "list", (t) => {
1165
+ ht(),
1166
+ bt()
1167
+ ], Lt = () => {
1168
+ function a(e) {
1169
+ Ve(e, "list", (t) => {
1136
1170
  var r;
1137
1171
  if (t.ordered) {
1138
1172
  const n = (r = t.start) != null ? r : 1;
1139
- t.children.forEach((o, a) => {
1140
- o.label = a + n;
1173
+ t.children.forEach((s, l) => {
1174
+ s.label = l + n;
1141
1175
  });
1142
1176
  return;
1143
1177
  }
1144
1178
  });
1145
1179
  }
1146
- return c;
1147
- }, It = (c) => !!c.children, bt = (c) => c.type === "html";
1148
- function yt(c, e) {
1149
- return t(c, 0, null)[0];
1150
- function t(r, n, o) {
1151
- if (It(r)) {
1152
- const a = [];
1153
- for (let s = 0, l = r.children.length; s < l; s++) {
1154
- const i = r.children[s];
1180
+ return a;
1181
+ }, Ct = (a) => !!a.children, xt = (a) => a.type === "html";
1182
+ function Tt(a, e) {
1183
+ return t(a, 0, null)[0];
1184
+ function t(r, n, s) {
1185
+ if (Ct(r)) {
1186
+ const l = [];
1187
+ for (let o = 0, c = r.children.length; o < c; o++) {
1188
+ const i = r.children[o];
1155
1189
  if (i) {
1156
- const u = t(i, s, r);
1190
+ const u = t(i, o, r);
1157
1191
  if (u)
1158
- for (let g = 0, d = u.length; g < d; g++) {
1159
- const m = u[g];
1160
- m && a.push(m);
1192
+ for (let f = 0, d = u.length; f < d; f++) {
1193
+ const m = u[f];
1194
+ m && l.push(m);
1161
1195
  }
1162
1196
  }
1163
1197
  }
1164
- r.children = a;
1198
+ r.children = l;
1165
1199
  }
1166
- return e(r, n, o);
1200
+ return e(r, n, s);
1167
1201
  }
1168
1202
  }
1169
- const Nt = () => {
1170
- function c(e) {
1171
- yt(e, (t) => bt(t) ? [] : [t]);
1203
+ const Ht = () => {
1204
+ function a(e) {
1205
+ Tt(e, (t) => xt(t) ? [] : [t]);
1172
1206
  }
1173
- return c;
1174
- }, wt = new T("MILKDOWN_INLINE_NODES_CURSOR"), ue = new H({
1175
- key: wt,
1176
- state: {
1177
- init() {
1178
- return !1;
1179
- },
1180
- apply(c) {
1181
- if (!c.selection.empty)
1182
- return !1;
1183
- const e = c.selection.$from, t = e.nodeBefore, r = e.nodeAfter;
1184
- return !!(t && r && t.isInline && !t.isText && r.isInline && !r.isText);
1185
- }
1186
- },
1187
- props: {
1188
- handleDOMEvents: {
1189
- beforeinput: (c, e) => {
1190
- if (ue.getState(c.state) && e instanceof InputEvent) {
1191
- const r = c.state.selection.from;
1192
- return e.preventDefault(), c.dispatch(c.state.tr.insertText(e.data || "", r)), !0;
1193
- }
1207
+ return a;
1208
+ }, Dt = new T("MILKDOWN_INLINE_NODES_CURSOR"), Ot = () => {
1209
+ let a = !1;
1210
+ const e = new x({
1211
+ key: Dt,
1212
+ state: {
1213
+ init() {
1194
1214
  return !1;
1215
+ },
1216
+ apply(t) {
1217
+ if (!t.selection.empty)
1218
+ return !1;
1219
+ const r = t.selection.$from, n = r.nodeBefore, s = r.nodeAfter;
1220
+ return !!(n && s && n.isInline && !n.isText && s.isInline && !s.isText);
1195
1221
  }
1196
1222
  },
1197
- decorations(c) {
1198
- if (ue.getState(c)) {
1199
- const r = c.selection.$from.pos, n = document.createElement("span"), o = J.widget(r, n, {
1200
- side: -1
1201
- }), a = document.createElement("span"), s = J.widget(r, a);
1202
- return setTimeout(() => {
1203
- n.contentEditable = "true", a.contentEditable = "true";
1204
- }), O.create(c.doc, [o, s]);
1223
+ props: {
1224
+ handleDOMEvents: {
1225
+ compositionend: (t, r) => a ? (a = !1, requestAnimationFrame(() => {
1226
+ if (e.getState(t.state)) {
1227
+ const s = t.state.selection.from;
1228
+ r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "", s));
1229
+ }
1230
+ }), !0) : !1,
1231
+ compositionstart: (t) => (e.getState(t.state) && (a = !0), !1),
1232
+ beforeinput: (t, r) => {
1233
+ if (e.getState(t.state) && r instanceof InputEvent && r.data && !a) {
1234
+ const s = t.state.selection.from;
1235
+ return r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "", s)), !0;
1236
+ }
1237
+ return !1;
1238
+ }
1239
+ },
1240
+ decorations(t) {
1241
+ if (e.getState(t)) {
1242
+ const s = t.selection.$from.pos, l = document.createElement("span"), o = X.widget(s, l, {
1243
+ side: -1
1244
+ }), c = document.createElement("span"), i = X.widget(s, c);
1245
+ return setTimeout(() => {
1246
+ l.contentEditable = "true", c.contentEditable = "true";
1247
+ }), O.create(t.doc, [o, i]);
1248
+ }
1249
+ return O.empty;
1205
1250
  }
1206
- return O.empty;
1251
+ }
1252
+ });
1253
+ return e;
1254
+ }, G = /\[(?<span>((www|https:\/\/|http:\/\/)\S+))]\((?<url>\S+)\)/, St = (a) => new RegExp(`\\\\(?=[^\\w\\s${a}\\\\]|_)`, "g"), At = (a) => {
1255
+ let e = a, t = e.match(G);
1256
+ for (; t && t.groups; ) {
1257
+ const { span: r } = t.groups;
1258
+ e = e.replace(G, r), t = e.match(G);
1259
+ }
1260
+ return e;
1261
+ }, Et = (a, e, t) => {
1262
+ const r = a.split(""), n = r[e];
1263
+ return r[e] && r[t] && (r[e] = r[t], r[t] = n), r.join("").toString();
1264
+ }, vt = (a) => (e) => e.replace(St(a), ""), _t = (a) => (e) => {
1265
+ const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1), s = /[^\w]|_/;
1266
+ return n ? r && s.test(r) && s.test(n) ? a.punctuation : a.char : a.punctuation;
1267
+ }, $t = (a, e, t) => {
1268
+ let r = e, n = !1;
1269
+ return a.descendants((s) => {
1270
+ var l;
1271
+ if (n)
1272
+ return !1;
1273
+ if (s.isText) {
1274
+ const o = (l = s.text) == null ? void 0 : l.indexOf(t);
1275
+ if (o != null && o >= 0)
1276
+ return n = !0, r += o, !1;
1277
+ }
1278
+ r += s.nodeSize;
1279
+ }), r;
1280
+ }, Pt = {
1281
+ placeholderConfig: {
1282
+ hole: "\u2205",
1283
+ punctuation: "\u2042",
1284
+ char: "\u2234"
1285
+ },
1286
+ globalNodes: ["footnote_definition"],
1287
+ shouldSyncNode: ({ prevNode: a, nextNode: e }) => a.inlineContent && e && a.type === e.type && !a.eq(e),
1288
+ movePlaceholder: (a, e) => {
1289
+ const t = ["*", "_"];
1290
+ let r = e.indexOf(a);
1291
+ for (; t.includes(e[r - 1] || "") && t.includes(e[r + 1] || ""); )
1292
+ e = Et(e, r, r + 1), r = r + 1;
1293
+ return e;
1294
+ }
1295
+ }, E = Ee(Pt, "inlineSyncConfig"), Bt = (a) => {
1296
+ const { selection: e } = a, { $from: t } = e;
1297
+ return t.node();
1298
+ }, Rt = (a, e, t, r) => {
1299
+ const n = a.get(ve), s = e.schema.topNodeType.create(void 0, [t, ...r]);
1300
+ return n(s);
1301
+ }, Wt = (a, e) => {
1302
+ const t = a.get(E), r = t.placeholderConfig.hole, [n = "", ...s] = e.split(`
1303
+
1304
+ `), l = (u) => t.movePlaceholder(r, u);
1305
+ let c = Oe(vt(r), l, At)(n);
1306
+ const i = _t(t.placeholderConfig)(c);
1307
+ return c = c.replace(r, i), c = [c, ...s].join(`
1308
+
1309
+ `), [c, i];
1310
+ }, qt = (a, e) => {
1311
+ const r = a.get(_e)(e);
1312
+ return r ? r.firstChild : null;
1313
+ }, Kt = (a, e) => {
1314
+ const { globalNodes: t } = a.get(E), r = [];
1315
+ return e.doc.descendants((n) => {
1316
+ if (t.includes(n.type.name) || t.includes(n.type))
1317
+ return r.push(n), !1;
1318
+ }), r;
1319
+ }, Ft = (a) => a.split(`
1320
+
1321
+ `)[0] || "", De = (a, e) => {
1322
+ try {
1323
+ const t = Kt(a, e), r = Bt(e), n = Rt(a, e, r, t), [s, l] = Wt(a, n), o = qt(a, s);
1324
+ return !o || r.type !== o.type ? null : (o.attrs = { ...r.attrs }, o.descendants((c) => {
1325
+ var f;
1326
+ const u = c.marks.find((d) => d.type.name === "link");
1327
+ u && ((f = c.text) == null ? void 0 : f.includes(l)) && u.attrs.href.includes(l) && (u.attrs.href = u.attrs.href.replace(l, ""));
1328
+ }), {
1329
+ text: Ft(s),
1330
+ prevNode: r,
1331
+ nextNode: o,
1332
+ placeholder: l
1333
+ });
1334
+ } catch {
1335
+ return null;
1336
+ }
1337
+ }, jt = (a, e, t, r, n) => {
1338
+ const { placeholderConfig: s } = a.get(E), l = s.hole;
1339
+ let o = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
1340
+ const c = t.apply(o), i = De(a, c);
1341
+ if (!i)
1342
+ return;
1343
+ const { $from: u } = c.selection, f = u.before(), d = u.after(), m = $t(i.nextNode, f, i.placeholder);
1344
+ o = o.replaceWith(f, d, i.nextNode).setNodeMarkup(f, void 0, n).delete(m + 1, m + 2), o = o.setSelection(J.near(o.doc.resolve(m + 1))), r(o);
1345
+ }, Y = new T("MILKDOWN_INLINE_SYNC"), zt = (a) => new x({
1346
+ key: Y,
1347
+ state: {
1348
+ init: () => null,
1349
+ apply: (t, r, n, s) => {
1350
+ if (!t.docChanged || t.getMeta(Y))
1351
+ return null;
1352
+ const o = De(a, s);
1353
+ if (!o)
1354
+ return null;
1355
+ const { prevNode: c, nextNode: i, text: u } = o, { shouldSyncNode: f } = a.get(E);
1356
+ return f({ prevNode: c, nextNode: i, ctx: a, tr: t, text: u }) && requestAnimationFrame(() => {
1357
+ const { dispatch: d, state: m } = a.get(A);
1358
+ jt(a, Y, m, d, c.attrs);
1359
+ }), null;
1207
1360
  }
1208
1361
  }
1209
- }), Lt = [
1210
- He(() => ({
1211
- prosePlugins: () => [ue],
1212
- remarkPlugins: () => [We, Nt, Mt]
1213
- }))()
1214
- ], xt = Ne.create([...kt, ...ze]), Pt = Ne.create([...Lt, ...xt]), Wt = {
1215
- ToggleInlineCode: Q,
1216
- ToggleItalic: X,
1362
+ }), Ut = [
1363
+ Se(() => ({
1364
+ prosePlugins: (a, e) => [Ot(), zt(e)],
1365
+ remarkPlugins: () => [Ue, Ht, Lt]
1366
+ }), [E])()
1367
+ ], Vt = be.create([...wt, ...Ze]), lr = be.create([...Ut, ...Vt]), cr = {
1368
+ ToggleInlineCode: Z,
1369
+ ToggleItalic: ee,
1217
1370
  ToggleLink: xe,
1218
- ToggleBold: Z,
1219
- ModifyLink: Y,
1220
- ModifyImage: se,
1221
- WrapInBlockquote: ee,
1222
- WrapInBulletList: te,
1223
- WrapInOrderedList: ce,
1224
- TurnIntoCodeFence: re,
1225
- TurnIntoHeading: C,
1226
- TurnIntoText: ie,
1227
- InsertHardbreak: ne,
1228
- InsertHr: Ce,
1229
- InsertImage: De,
1230
- SplitListItem: oe,
1231
- SinkListItem: ae,
1232
- LiftListItem: le
1371
+ ToggleBold: re,
1372
+ ModifyLink: te,
1373
+ ModifyImage: le,
1374
+ WrapInBlockquote: ne,
1375
+ WrapInBulletList: se,
1376
+ WrapInOrderedList: de,
1377
+ TurnIntoCodeFence: oe,
1378
+ TurnIntoHeading: D,
1379
+ TurnIntoText: fe,
1380
+ InsertHardbreak: ae,
1381
+ InsertHr: Te,
1382
+ InsertImage: He,
1383
+ SplitListItem: ce,
1384
+ SinkListItem: ie,
1385
+ LiftListItem: ue
1233
1386
  };
1234
1387
  export {
1235
1388
  Me as DowngradeHeading,
1236
- tt as HardbreakFilterPluginKey,
1237
- ne as InsertHardbreak,
1238
- Ce as InsertHr,
1239
- De as InsertImage,
1240
- le as LiftListItem,
1241
- se as ModifyImage,
1242
- Y as ModifyLink,
1243
- ae as SinkListItem,
1244
- oe as SplitListItem,
1389
+ lt as HardbreakFilterPluginKey,
1390
+ ae as InsertHardbreak,
1391
+ Te as InsertHr,
1392
+ He as InsertImage,
1393
+ ue as LiftListItem,
1394
+ le as ModifyImage,
1395
+ te as ModifyLink,
1396
+ ie as SinkListItem,
1397
+ ce as SplitListItem,
1245
1398
  k as SupportedKeys,
1246
- Z as ToggleBold,
1247
- Q as ToggleInlineCode,
1248
- X as ToggleItalic,
1399
+ re as ToggleBold,
1400
+ Z as ToggleInlineCode,
1401
+ ee as ToggleItalic,
1249
1402
  xe as ToggleLink,
1250
- re as TurnIntoCodeFence,
1251
- C as TurnIntoHeading,
1252
- ie as TurnIntoText,
1253
- ee as WrapInBlockquote,
1254
- te as WrapInBulletList,
1255
- ce as WrapInOrderedList,
1256
- Xe as backtickInputRegex,
1257
- Ge as blockquote,
1258
- Je as bulletList,
1259
- Ze as codeFence,
1260
- Ke as codeInline,
1261
- Wt as commands,
1262
- Pt as commonmark,
1263
- xt as commonmarkNodes,
1264
- Lt as commonmarkPlugins,
1265
- et as doc,
1266
- Fe as em,
1267
- rt as hardbreak,
1268
- lt as heading,
1269
- nt as headingHashPluginKey,
1270
- j as headingIdPluginKey,
1271
- ct as hr,
1272
- ut as image,
1273
- Ve as link,
1274
- gt as listItem,
1275
- ze as marks,
1276
- kt as nodes,
1277
- ft as orderedList,
1278
- pt as paragraph,
1279
- je as strong,
1280
- ht as text,
1281
- Ye as tildeInputRegex
1403
+ oe as TurnIntoCodeFence,
1404
+ D as TurnIntoHeading,
1405
+ fe as TurnIntoText,
1406
+ ne as WrapInBlockquote,
1407
+ se as WrapInBulletList,
1408
+ de as WrapInOrderedList,
1409
+ nt as backtickInputRegex,
1410
+ et as blockquote,
1411
+ tt as bulletList,
1412
+ ot as codeFence,
1413
+ Ge as codeInline,
1414
+ cr as commands,
1415
+ lr as commonmark,
1416
+ Vt as commonmarkNodes,
1417
+ Ut as commonmarkPlugins,
1418
+ at as doc,
1419
+ Ye as em,
1420
+ ct as hardbreak,
1421
+ mt as heading,
1422
+ it as headingHashPluginKey,
1423
+ U as headingIdPluginKey,
1424
+ pt as hr,
1425
+ ht as image,
1426
+ E as inlineSyncConfigCtx,
1427
+ Qe as link,
1428
+ yt as listItem,
1429
+ Ze as marks,
1430
+ wt as nodes,
1431
+ Nt as orderedList,
1432
+ It as paragraph,
1433
+ Xe as strong,
1434
+ bt as text,
1435
+ st as tildeInputRegex
1282
1436
  };
1283
1437
  //# sourceMappingURL=index.es.js.map