@milkdown/preset-commonmark 6.3.0 → 6.4.0

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