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