@milkdown/preset-commonmark 6.5.2 → 6.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +228 -219
- package/lib/index.es.js.map +1 -1
- package/lib/mark/code-inline.d.ts +1 -1
- package/lib/mark/code-inline.d.ts.map +1 -1
- package/lib/mark/em.d.ts +1 -1
- package/lib/mark/em.d.ts.map +1 -1
- package/lib/mark/index.d.ts.map +1 -1
- package/lib/mark/link.d.ts +4 -3
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts +1 -1
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts +1 -1
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts +1 -1
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-fence.d.ts.map +1 -1
- package/lib/node/doc.d.ts +1 -1
- package/lib/node/doc.d.ts.map +1 -1
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/lib/node/heading.d.ts +2 -2
- package/lib/node/heading.d.ts.map +1 -1
- package/lib/node/hr.d.ts +1 -1
- package/lib/node/hr.d.ts.map +1 -1
- package/lib/node/image.d.ts +2 -2
- package/lib/node/image.d.ts.map +1 -1
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/list-item.d.ts +2 -2
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts +1 -1
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts +1 -1
- package/lib/node/paragraph.d.ts.map +1 -1
- package/lib/node/text.d.ts +1 -1
- package/lib/node/text.d.ts.map +1 -1
- package/lib/plugin/add-order-in-list.d.ts +1 -1
- package/lib/plugin/add-order-in-list.d.ts.map +1 -1
- package/lib/plugin/filter-html.d.ts +1 -1
- package/lib/plugin/filter-html.d.ts.map +1 -1
- package/lib/plugin/index.d.ts +1 -1
- package/lib/plugin/index.d.ts.map +1 -1
- package/lib/plugin/inline-nodes-cursor.d.ts.map +1 -1
- package/lib/plugin/inline-sync/config.d.ts +8 -8
- package/lib/plugin/inline-sync/config.d.ts.map +1 -1
- package/lib/plugin/inline-sync/context.d.ts +5 -5
- package/lib/plugin/inline-sync/context.d.ts.map +1 -1
- package/lib/plugin/inline-sync/index.d.ts +1 -1
- package/lib/plugin/inline-sync/index.d.ts.map +1 -1
- package/lib/plugin/inline-sync/regexp.d.ts.map +1 -1
- package/lib/plugin/inline-sync/replacer.d.ts +3 -3
- package/lib/plugin/inline-sync/replacer.d.ts.map +1 -1
- package/lib/plugin/inline-sync/utils.d.ts +2 -2
- package/lib/plugin/inline-sync/utils.d.ts.map +1 -1
- package/lib/supported-keys.d.ts +1 -1
- package/lib/supported-keys.d.ts.map +1 -1
- package/package.json +22 -17
- package/src/index.ts +52 -52
- package/src/mark/code-inline.ts +56 -55
- package/src/mark/em.ts +36 -36
- package/src/mark/index.ts +9 -9
- package/src/mark/link.ts +250 -223
- package/src/mark/strong.ts +37 -37
- package/src/node/blockquote.ts +35 -35
- package/src/node/bullet-list.ts +65 -65
- package/src/node/code-fence.ts +236 -229
- package/src/node/doc.ts +21 -21
- package/src/node/hardbreak.ts +108 -107
- package/src/node/heading.ts +275 -272
- package/src/node/hr.ts +55 -55
- package/src/node/image.ts +216 -210
- package/src/node/index.ts +38 -38
- package/src/node/list-item.ts +139 -140
- package/src/node/ordered-list.ts +71 -71
- package/src/node/paragraph.ts +55 -53
- package/src/node/text.ts +18 -18
- package/src/plugin/add-order-in-list.ts +15 -15
- package/src/plugin/filter-html.ts +31 -33
- package/src/plugin/index.ts +13 -13
- package/src/plugin/inline-nodes-cursor.ts +78 -79
- package/src/plugin/inline-sync/config.ts +46 -45
- package/src/plugin/inline-sync/context.ts +88 -83
- package/src/plugin/inline-sync/index.ts +46 -42
- package/src/plugin/inline-sync/regexp.ts +2 -2
- package/src/plugin/inline-sync/replacer.ts +33 -31
- package/src/plugin/inline-sync/utils.ts +53 -55
- package/src/supported-keys.ts +22 -21
package/lib/index.es.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { createMark as
|
|
2
|
-
import { createCmdKey as
|
|
3
|
-
import { toggleMark as
|
|
4
|
-
import { expectDomTypeError as
|
|
5
|
-
import { calculateTextPosition as Be, cloneTr as Re, findSelectedNodeOfType as
|
|
6
|
-
import { PluginKey as H, TextSelection as
|
|
7
|
-
import { wrappingInputRule as
|
|
8
|
-
import { Fragment as
|
|
1
|
+
import { createMark as q, createShortcut as M, createNode as C, pipe as Se, createPlugin as ve, AtomList as we } from "@milkdown/utils";
|
|
2
|
+
import { createCmdKey as I, createCmd as N, commandsCtx as Le, editorViewCtx as v, schemaCtx as R, getPalette as Ae, createSlice as Ee, serializerCtx as _e, parserCtx as $e } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as pe, wrapIn as ge, setBlockType as A } from "@milkdown/prose/commands";
|
|
4
|
+
import { expectDomTypeError as x, missingRootElement as Pe } from "@milkdown/exception";
|
|
5
|
+
import { calculateTextPosition as Be, cloneTr as Re, findSelectedNodeOfType as F, getNodeFromSchema as We } from "@milkdown/prose";
|
|
6
|
+
import { PluginKey as H, TextSelection as Q, Plugin as T, NodeSelection as qe, Selection as Ce } from "@milkdown/prose/state";
|
|
7
|
+
import { wrappingInputRule as K, textblockTypeInputRule as X, InputRule as xe } from "@milkdown/prose/inputrules";
|
|
8
|
+
import { Fragment as W } from "@milkdown/prose/model";
|
|
9
9
|
import { ReplaceStep as Ke, AddMarkStep as Fe } from "@milkdown/prose/transform";
|
|
10
|
-
import { DecorationSet as
|
|
10
|
+
import { DecorationSet as S, Decoration as Z } from "@milkdown/prose/view";
|
|
11
11
|
import { splitListItem as je, sinkListItem as ze, liftListItem as Ue } from "@milkdown/prose/schema-list";
|
|
12
12
|
import Ve from "remark-inline-links";
|
|
13
13
|
import { visit as Ge } from "unist-util-visit";
|
|
14
|
-
const
|
|
14
|
+
const y = {
|
|
15
15
|
HardBreak: "HardBreak",
|
|
16
16
|
Blockquote: "Blockquote",
|
|
17
17
|
BulletList: "BulletList",
|
|
@@ -31,7 +31,7 @@ const k = {
|
|
|
31
31
|
NextListItem: "NextListItem",
|
|
32
32
|
SinkListItem: "SinkListItem",
|
|
33
33
|
LiftListItem: "LiftListItem"
|
|
34
|
-
}, ke = "code_inline",
|
|
34
|
+
}, ke = "code_inline", ee = I("ToggleInlineCode"), Ye = q((a) => ({
|
|
35
35
|
id: ke,
|
|
36
36
|
schema: () => ({
|
|
37
37
|
priority: 100,
|
|
@@ -53,7 +53,7 @@ const k = {
|
|
|
53
53
|
}
|
|
54
54
|
}),
|
|
55
55
|
commands: (e) => [
|
|
56
|
-
|
|
56
|
+
N(ee, () => (t, r) => {
|
|
57
57
|
const { selection: n, tr: o } = t;
|
|
58
58
|
if (n.empty)
|
|
59
59
|
return !1;
|
|
@@ -64,10 +64,10 @@ const k = {
|
|
|
64
64
|
})
|
|
65
65
|
],
|
|
66
66
|
shortcuts: {
|
|
67
|
-
[
|
|
67
|
+
[y.CodeInline]: M(ee, "Mod-e")
|
|
68
68
|
}
|
|
69
|
-
})),
|
|
70
|
-
id:
|
|
69
|
+
})), j = "em", te = I("ToggleItalic"), Je = q((a) => ({
|
|
70
|
+
id: j,
|
|
71
71
|
schema: () => ({
|
|
72
72
|
inclusive: !1,
|
|
73
73
|
parseDOM: [
|
|
@@ -75,7 +75,7 @@ const k = {
|
|
|
75
75
|
{ tag: "em" },
|
|
76
76
|
{ style: "font-style", getAttrs: (e) => e === "italic" }
|
|
77
77
|
],
|
|
78
|
-
toDOM: (e) => ["em", { class: a.getClassName(e.attrs,
|
|
78
|
+
toDOM: (e) => ["em", { class: a.getClassName(e.attrs, j) }],
|
|
79
79
|
parseMarkdown: {
|
|
80
80
|
match: (e) => e.type === "emphasis",
|
|
81
81
|
runner: (e, t, r) => {
|
|
@@ -83,18 +83,18 @@ const k = {
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
toMarkdown: {
|
|
86
|
-
match: (e) => e.type.name ===
|
|
86
|
+
match: (e) => e.type.name === j,
|
|
87
87
|
runner: (e, t) => {
|
|
88
88
|
e.withMark(t, "emphasis");
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}),
|
|
92
|
-
commands: (e) => [
|
|
92
|
+
commands: (e) => [N(te, () => pe(e))],
|
|
93
93
|
shortcuts: {
|
|
94
|
-
[
|
|
94
|
+
[y.Em]: M(te, "Mod-i")
|
|
95
95
|
}
|
|
96
|
-
})), Qe = new H("MILKDOWN_LINK_INPUT"), Te =
|
|
97
|
-
id:
|
|
96
|
+
})), Qe = new H("MILKDOWN_LINK_INPUT"), Te = I("ToggleLink"), re = I("ModifyLink"), $ = "link", Xe = q((a, e) => ({
|
|
97
|
+
id: $,
|
|
98
98
|
schema: () => ({
|
|
99
99
|
attrs: {
|
|
100
100
|
href: {},
|
|
@@ -105,12 +105,12 @@ const k = {
|
|
|
105
105
|
tag: "a[href]",
|
|
106
106
|
getAttrs: (t) => {
|
|
107
107
|
if (!(t instanceof HTMLElement))
|
|
108
|
-
throw
|
|
108
|
+
throw x(t);
|
|
109
109
|
return { href: t.getAttribute("href"), title: t.getAttribute("title") };
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
],
|
|
113
|
-
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs,
|
|
113
|
+
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs, $) }],
|
|
114
114
|
parseMarkdown: {
|
|
115
115
|
match: (t) => t.type === "link",
|
|
116
116
|
runner: (t, r, n) => {
|
|
@@ -119,7 +119,7 @@ const k = {
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
toMarkdown: {
|
|
122
|
-
match: (t) => t.type.name ===
|
|
122
|
+
match: (t) => t.type.name === $,
|
|
123
123
|
runner: (t, r) => {
|
|
124
124
|
t.withMark(r, "link", void 0, {
|
|
125
125
|
title: r.attrs.title,
|
|
@@ -129,26 +129,26 @@ const k = {
|
|
|
129
129
|
}
|
|
130
130
|
}),
|
|
131
131
|
commands: (t) => [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var
|
|
132
|
+
N(Te, (r = "") => pe(t, { href: r })),
|
|
133
|
+
N(re, (r = "") => (n, o) => {
|
|
134
|
+
var k;
|
|
135
135
|
if (!o)
|
|
136
136
|
return !1;
|
|
137
137
|
const { marks: l } = n.schema;
|
|
138
138
|
let s, c = -1;
|
|
139
139
|
const { selection: i } = n, { from: u, to: f } = i;
|
|
140
|
-
if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b,
|
|
141
|
-
var
|
|
142
|
-
if ((
|
|
143
|
-
return s = b, c =
|
|
140
|
+
if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b, w) => {
|
|
141
|
+
var L;
|
|
142
|
+
if ((L = l.link) != null && L.isInSet(b.marks))
|
|
143
|
+
return s = b, c = w, !1;
|
|
144
144
|
}), !s)
|
|
145
145
|
return !1;
|
|
146
146
|
const d = s.marks.find(({ type: b }) => b === t);
|
|
147
147
|
if (!d)
|
|
148
148
|
return !1;
|
|
149
|
-
const m = c, p = c + s.nodeSize, { tr: g } = n,
|
|
150
|
-
return
|
|
151
|
-
g.removeMark(m, p, d).addMark(m, p,
|
|
149
|
+
const m = c, p = c + s.nodeSize, { tr: g } = n, h = (k = l.link) == null ? void 0 : k.create({ ...d.attrs, href: r });
|
|
150
|
+
return h ? (o(
|
|
151
|
+
g.removeMark(m, p, d).addMark(m, p, h).setSelection(new Q(g.selection.$anchor)).scrollIntoView()
|
|
152
152
|
), !0) : !1;
|
|
153
153
|
})
|
|
154
154
|
],
|
|
@@ -163,45 +163,54 @@ const k = {
|
|
|
163
163
|
placeholder: (f = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? f : "Input Web Link",
|
|
164
164
|
buttonText: (d = e == null ? void 0 : e.input) == null ? void 0 : d.buttonText,
|
|
165
165
|
onUpdate: (m) => {
|
|
166
|
-
r.get(Le).call(
|
|
166
|
+
r.get(Le).call(re, m);
|
|
167
167
|
},
|
|
168
168
|
calculatePosition: (m, p) => {
|
|
169
|
-
Be(m, p, (g,
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
169
|
+
Be(m, p, (g, h, k, b) => {
|
|
170
|
+
const w = m.dom.parentElement;
|
|
171
|
+
if (!w)
|
|
172
172
|
throw Pe();
|
|
173
|
-
const
|
|
174
|
-
let
|
|
175
|
-
n && (
|
|
176
|
-
const he =
|
|
177
|
-
return
|
|
173
|
+
const L = h.left - g.left;
|
|
174
|
+
let D = g.left - b.left - (k.width - L) / 2, _ = g.bottom - b.top + 14 + w.scrollTop;
|
|
175
|
+
n && (_ = g.top - b.top - k.height - 14 + w.scrollTop), D < 0 && (D = 0);
|
|
176
|
+
const he = w.clientWidth - (k.width + 4);
|
|
177
|
+
return D > he && (D = he), [_, D];
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
181
|
if (!l)
|
|
182
182
|
return {};
|
|
183
183
|
const s = (m) => {
|
|
184
|
-
|
|
184
|
+
var b;
|
|
185
|
+
const { selection: p, doc: g } = m.state, { from: h, to: k } = p;
|
|
185
186
|
if (!m.hasFocus())
|
|
186
187
|
return !1;
|
|
187
|
-
if (p
|
|
188
|
-
|
|
188
|
+
if (p instanceof Q && k < g.content.size && h < g.content.size && g.rangeHasMark(h, h === k ? k + 1 : k, t)) {
|
|
189
|
+
let w = p.empty;
|
|
190
|
+
if (((b = e == null ? void 0 : e.input) == null ? void 0 : b.displayWhenSelected) && !w && g.nodesBetween(h, h === k ? k + 1 : k, (L, D) => {
|
|
191
|
+
if (L.marks.some(
|
|
192
|
+
(_) => _.type === t && h >= D && k <= D + L.nodeSize
|
|
193
|
+
))
|
|
194
|
+
return w = !0, !1;
|
|
195
|
+
}), w)
|
|
196
|
+
return n = !1, !0;
|
|
197
|
+
}
|
|
189
198
|
if (p instanceof qe) {
|
|
190
|
-
const { node:
|
|
191
|
-
if (
|
|
199
|
+
const { node: w } = p;
|
|
200
|
+
if (w.type.name === "image" && w.marks.findIndex((L) => L.type.name === $) > -1)
|
|
192
201
|
return n = !0, !0;
|
|
193
202
|
}
|
|
194
203
|
return !1;
|
|
195
204
|
}, c = (m) => {
|
|
196
205
|
const { selection: p } = m.state;
|
|
197
206
|
let g;
|
|
198
|
-
const { from:
|
|
199
|
-
if (m.state.doc.nodesBetween(
|
|
200
|
-
if (t.isInSet(
|
|
201
|
-
return g =
|
|
207
|
+
const { from: h, to: k } = p;
|
|
208
|
+
if (m.state.doc.nodesBetween(h, h === k ? k + 1 : k, (L) => {
|
|
209
|
+
if (t.isInSet(L.marks))
|
|
210
|
+
return g = L, !1;
|
|
202
211
|
}), !g)
|
|
203
212
|
return;
|
|
204
|
-
const b = g.marks.find((
|
|
213
|
+
const b = g.marks.find((L) => L.type === t);
|
|
205
214
|
return b ? b.attrs.href : void 0;
|
|
206
215
|
}, i = (m) => {
|
|
207
216
|
if (!m.editable)
|
|
@@ -222,8 +231,8 @@ const k = {
|
|
|
222
231
|
})
|
|
223
232
|
];
|
|
224
233
|
}
|
|
225
|
-
})),
|
|
226
|
-
id:
|
|
234
|
+
})), z = "strong", ne = I("ToggleBold"), Ze = q((a) => ({
|
|
235
|
+
id: z,
|
|
227
236
|
schema: () => ({
|
|
228
237
|
inclusive: !1,
|
|
229
238
|
parseDOM: [
|
|
@@ -231,7 +240,7 @@ const k = {
|
|
|
231
240
|
{ tag: "strong" },
|
|
232
241
|
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
233
242
|
],
|
|
234
|
-
toDOM: (e) => ["strong", { class: a.getClassName(e.attrs,
|
|
243
|
+
toDOM: (e) => ["strong", { class: a.getClassName(e.attrs, z) }],
|
|
235
244
|
parseMarkdown: {
|
|
236
245
|
match: (e) => e.type === "strong",
|
|
237
246
|
runner: (e, t, r) => {
|
|
@@ -239,43 +248,43 @@ const k = {
|
|
|
239
248
|
}
|
|
240
249
|
},
|
|
241
250
|
toMarkdown: {
|
|
242
|
-
match: (e) => e.type.name ===
|
|
251
|
+
match: (e) => e.type.name === z,
|
|
243
252
|
runner: (e, t) => {
|
|
244
253
|
e.withMark(t, "strong");
|
|
245
254
|
}
|
|
246
255
|
}
|
|
247
256
|
}),
|
|
248
|
-
commands: (e) => [
|
|
257
|
+
commands: (e) => [N(ne, () => pe(e))],
|
|
249
258
|
shortcuts: {
|
|
250
|
-
[
|
|
259
|
+
[y.Bold]: M(ne, "Mod-b")
|
|
251
260
|
}
|
|
252
|
-
})), et = [Ye(), Je(), Ze(), Xe()],
|
|
253
|
-
id:
|
|
261
|
+
})), et = [Ye(), Je(), Ze(), Xe()], P = "blockquote", se = I("WrapInBlockquote"), tt = C((a) => ({
|
|
262
|
+
id: P,
|
|
254
263
|
schema: () => ({
|
|
255
264
|
content: "block+",
|
|
256
265
|
group: "block",
|
|
257
266
|
defining: !0,
|
|
258
267
|
parseDOM: [{ tag: "blockquote" }],
|
|
259
|
-
toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs,
|
|
268
|
+
toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs, P) }, 0],
|
|
260
269
|
parseMarkdown: {
|
|
261
|
-
match: ({ type: e }) => e ===
|
|
270
|
+
match: ({ type: e }) => e === P,
|
|
262
271
|
runner: (e, t, r) => {
|
|
263
272
|
e.openNode(r).next(t.children).closeNode();
|
|
264
273
|
}
|
|
265
274
|
},
|
|
266
275
|
toMarkdown: {
|
|
267
|
-
match: (e) => e.type.name ===
|
|
276
|
+
match: (e) => e.type.name === P,
|
|
268
277
|
runner: (e, t) => {
|
|
269
278
|
e.openNode("blockquote").next(t.content).closeNode();
|
|
270
279
|
}
|
|
271
280
|
}
|
|
272
281
|
}),
|
|
273
|
-
inputRules: (e) => [
|
|
274
|
-
commands: (e) => [
|
|
282
|
+
inputRules: (e) => [K(/^\s*>\s$/, e)],
|
|
283
|
+
commands: (e) => [N(se, () => ge(e))],
|
|
275
284
|
shortcuts: {
|
|
276
|
-
[
|
|
285
|
+
[y.Blockquote]: M(se, "Mod-Shift-b")
|
|
277
286
|
}
|
|
278
|
-
})),
|
|
287
|
+
})), oe = I("WrapInBulletList"), rt = C((a) => {
|
|
279
288
|
const e = "bullet_list";
|
|
280
289
|
return {
|
|
281
290
|
id: e,
|
|
@@ -292,7 +301,7 @@ const k = {
|
|
|
292
301
|
tag: "ul",
|
|
293
302
|
getAttrs: (t) => {
|
|
294
303
|
if (!(t instanceof HTMLElement))
|
|
295
|
-
throw
|
|
304
|
+
throw x(t);
|
|
296
305
|
return {
|
|
297
306
|
spread: t.dataset.spread
|
|
298
307
|
};
|
|
@@ -321,10 +330,10 @@ const k = {
|
|
|
321
330
|
}
|
|
322
331
|
}
|
|
323
332
|
}),
|
|
324
|
-
inputRules: (t) => [
|
|
325
|
-
commands: (t) => [
|
|
333
|
+
inputRules: (t) => [K(/^\s*([-+*])\s$/, t)],
|
|
334
|
+
commands: (t) => [N(oe, () => ge(t))],
|
|
326
335
|
shortcuts: {
|
|
327
|
-
[
|
|
336
|
+
[y.BulletList]: M(oe, "Mod-Alt-8")
|
|
328
337
|
}
|
|
329
338
|
};
|
|
330
339
|
}), nt = [
|
|
@@ -344,10 +353,10 @@ const k = {
|
|
|
344
353
|
"go",
|
|
345
354
|
"rust",
|
|
346
355
|
"markdown"
|
|
347
|
-
], st = /^```(?<language>[a-z]*)?[\s\n]$/, ot = /^~~~(?<language>[a-z]*)?[\s\n]$/,
|
|
356
|
+
], st = /^```(?<language>[a-z]*)?[\s\n]$/, ot = /^~~~(?<language>[a-z]*)?[\s\n]$/, ae = I("TurnIntoCodeFence"), U = "fence", at = C((a, e) => {
|
|
348
357
|
const t = (e == null ? void 0 : e.languageList) || nt;
|
|
349
358
|
return {
|
|
350
|
-
id:
|
|
359
|
+
id: U,
|
|
351
360
|
schema: (r) => ({
|
|
352
361
|
content: "text*",
|
|
353
362
|
group: "block",
|
|
@@ -369,18 +378,18 @@ const k = {
|
|
|
369
378
|
getAttrs: (n) => {
|
|
370
379
|
var o;
|
|
371
380
|
if (!(n instanceof HTMLElement))
|
|
372
|
-
throw
|
|
381
|
+
throw x(n);
|
|
373
382
|
return { language: (o = n.querySelector("pre")) == null ? void 0 : o.dataset.language };
|
|
374
383
|
},
|
|
375
384
|
getContent: (n, o) => {
|
|
376
385
|
var c, i;
|
|
377
386
|
if (!(n instanceof HTMLElement))
|
|
378
|
-
throw
|
|
387
|
+
throw x(n);
|
|
379
388
|
const l = (i = (c = n.querySelector("pre")) == null ? void 0 : c.textContent) != null ? i : "";
|
|
380
389
|
if (!l)
|
|
381
|
-
return
|
|
390
|
+
return W.empty;
|
|
382
391
|
const s = o.text(l);
|
|
383
|
-
return
|
|
392
|
+
return W.from(s);
|
|
384
393
|
}
|
|
385
394
|
},
|
|
386
395
|
{
|
|
@@ -388,7 +397,7 @@ const k = {
|
|
|
388
397
|
preserveWhitespace: "full",
|
|
389
398
|
getAttrs: (n) => {
|
|
390
399
|
if (!(n instanceof HTMLElement))
|
|
391
|
-
throw
|
|
400
|
+
throw x(n);
|
|
392
401
|
return { language: n.dataset.language };
|
|
393
402
|
}
|
|
394
403
|
}
|
|
@@ -402,7 +411,7 @@ const k = {
|
|
|
402
411
|
const s = l.target;
|
|
403
412
|
if (!(s instanceof HTMLSelectElement))
|
|
404
413
|
return;
|
|
405
|
-
const c = r.get(
|
|
414
|
+
const c = r.get(v);
|
|
406
415
|
if (!c.editable) {
|
|
407
416
|
s.value = n.attrs.language;
|
|
408
417
|
return;
|
|
@@ -441,7 +450,7 @@ const k = {
|
|
|
441
450
|
}
|
|
442
451
|
},
|
|
443
452
|
toMarkdown: {
|
|
444
|
-
match: (n) => n.type.name ===
|
|
453
|
+
match: (n) => n.type.name === U,
|
|
445
454
|
runner: (n, o) => {
|
|
446
455
|
var l;
|
|
447
456
|
n.addNode("code", void 0, ((l = o.content.firstChild) == null ? void 0 : l.text) || "", {
|
|
@@ -451,27 +460,27 @@ const k = {
|
|
|
451
460
|
}
|
|
452
461
|
}),
|
|
453
462
|
inputRules: (r) => [
|
|
454
|
-
|
|
463
|
+
X(st, r, (n) => {
|
|
455
464
|
const [o, l] = n;
|
|
456
465
|
if (!!o)
|
|
457
466
|
return { language: l };
|
|
458
467
|
}),
|
|
459
|
-
|
|
468
|
+
X(ot, r, (n) => {
|
|
460
469
|
const [o, l] = n;
|
|
461
470
|
if (!!o)
|
|
462
471
|
return { language: l };
|
|
463
472
|
})
|
|
464
473
|
],
|
|
465
|
-
commands: (r) => [
|
|
474
|
+
commands: (r) => [N(ae, () => A(r))],
|
|
466
475
|
shortcuts: {
|
|
467
|
-
[
|
|
476
|
+
[y.CodeFence]: M(ae, "Mod-Alt-c")
|
|
468
477
|
},
|
|
469
478
|
view: () => (r, n, o) => {
|
|
470
479
|
let l = r;
|
|
471
480
|
const s = (g) => {
|
|
472
|
-
const { tr:
|
|
481
|
+
const { tr: h } = n.state;
|
|
473
482
|
n.dispatch(
|
|
474
|
-
|
|
483
|
+
h.setNodeMarkup(o(), void 0, {
|
|
475
484
|
fold: !0,
|
|
476
485
|
language: g
|
|
477
486
|
})
|
|
@@ -493,6 +502,7 @@ const k = {
|
|
|
493
502
|
})
|
|
494
503
|
);
|
|
495
504
|
}, u = a.themeManager.get("code-fence", {
|
|
505
|
+
view: n,
|
|
496
506
|
onBlur: c,
|
|
497
507
|
onFocus: i,
|
|
498
508
|
onSelectLanguage: s,
|
|
@@ -505,12 +515,12 @@ const k = {
|
|
|
505
515
|
return m(l), {
|
|
506
516
|
dom: f,
|
|
507
517
|
contentDOM: d,
|
|
508
|
-
update: (g) => g.type.name !==
|
|
518
|
+
update: (g) => g.type.name !== U ? !1 : (l = g, m(l), !0),
|
|
509
519
|
destroy: p
|
|
510
520
|
};
|
|
511
521
|
}
|
|
512
522
|
};
|
|
513
|
-
}), lt =
|
|
523
|
+
}), lt = C(() => ({
|
|
514
524
|
id: "doc",
|
|
515
525
|
schema: () => ({
|
|
516
526
|
content: "block+",
|
|
@@ -527,7 +537,7 @@ const k = {
|
|
|
527
537
|
}
|
|
528
538
|
}
|
|
529
539
|
})
|
|
530
|
-
})),
|
|
540
|
+
})), le = I("InsertHardbreak"), ct = new H("MILKDOWN_HARDBREAK_FILTER"), it = C((a, e) => {
|
|
531
541
|
var r;
|
|
532
542
|
const t = (r = e == null ? void 0 : e.notIn) != null ? r : ["table", "fence"];
|
|
533
543
|
return {
|
|
@@ -552,7 +562,7 @@ const k = {
|
|
|
552
562
|
}
|
|
553
563
|
}),
|
|
554
564
|
commands: (n) => [
|
|
555
|
-
|
|
565
|
+
N(le, () => (o, l) => {
|
|
556
566
|
var i;
|
|
557
567
|
const { selection: s, tr: c } = o;
|
|
558
568
|
if (s.empty) {
|
|
@@ -566,7 +576,7 @@ const k = {
|
|
|
566
576
|
})
|
|
567
577
|
],
|
|
568
578
|
shortcuts: {
|
|
569
|
-
[
|
|
579
|
+
[y.HardBreak]: M(le, "Shift-Enter")
|
|
570
580
|
},
|
|
571
581
|
prosePlugins: (n) => [
|
|
572
582
|
new T({
|
|
@@ -601,15 +611,15 @@ const k = {
|
|
|
601
611
|
if (i instanceof Fe) {
|
|
602
612
|
let d = s.tr;
|
|
603
613
|
const { from: m, to: p } = i;
|
|
604
|
-
return s.doc.nodesBetween(m, p, (g,
|
|
605
|
-
g.type === n && (d = d.setNodeMarkup(
|
|
614
|
+
return s.doc.nodesBetween(m, p, (g, h) => {
|
|
615
|
+
g.type === n && (d = d.setNodeMarkup(h, n, void 0, []));
|
|
606
616
|
}), d;
|
|
607
617
|
}
|
|
608
618
|
}
|
|
609
619
|
})
|
|
610
620
|
]
|
|
611
621
|
};
|
|
612
|
-
}), Me = Array(6).fill(0).map((a, e) => e + 1),
|
|
622
|
+
}), Me = Array(6).fill(0).map((a, e) => e + 1), O = I("TurnIntoHeading"), ye = I("DowngradeHeading"), V = new H("MILKDOWN_HEADING_ID"), ut = new H("MILKDOWN_HEADING_HASH"), dt = (a) => a.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), ft = (a, e, t) => {
|
|
613
623
|
let r = !1;
|
|
614
624
|
const n = (o, l) => {
|
|
615
625
|
const s = o.tr.setMeta("addToHistory", !1);
|
|
@@ -619,7 +629,7 @@ const k = {
|
|
|
619
629
|
if (i.textContent.trim().length === 0)
|
|
620
630
|
return;
|
|
621
631
|
const f = i.attrs, d = t(i);
|
|
622
|
-
f.id !== d && (c = !0, s.setMeta(
|
|
632
|
+
f.id !== d && (c = !0, s.setMeta(V, !0).setNodeMarkup(u, void 0, {
|
|
623
633
|
...f,
|
|
624
634
|
id: d
|
|
625
635
|
}));
|
|
@@ -627,13 +637,13 @@ const k = {
|
|
|
627
637
|
}), c && l(s);
|
|
628
638
|
};
|
|
629
639
|
return new T({
|
|
630
|
-
key:
|
|
640
|
+
key: V,
|
|
631
641
|
props: {
|
|
632
642
|
handleDOMEvents: {
|
|
633
643
|
compositionstart: () => (r = !0, !1),
|
|
634
644
|
compositionend: () => {
|
|
635
645
|
r = !1;
|
|
636
|
-
const o = a.get(
|
|
646
|
+
const o = a.get(v);
|
|
637
647
|
return setTimeout(() => {
|
|
638
648
|
n(o.state, (l) => o.dispatch(l));
|
|
639
649
|
}, 0), !1;
|
|
@@ -642,7 +652,7 @@ const k = {
|
|
|
642
652
|
},
|
|
643
653
|
appendTransaction: (o, l, s) => {
|
|
644
654
|
let c = null;
|
|
645
|
-
return o.every((i) => !i.getMeta(
|
|
655
|
+
return o.every((i) => !i.getMeta(V)) && o.some((i) => i.docChanged) && n(s, (i) => {
|
|
646
656
|
c = i;
|
|
647
657
|
}), c;
|
|
648
658
|
},
|
|
@@ -660,19 +670,19 @@ const k = {
|
|
|
660
670
|
}, mt = (a, e, t) => new T({
|
|
661
671
|
key: ut,
|
|
662
672
|
state: {
|
|
663
|
-
init: () =>
|
|
673
|
+
init: () => S.empty,
|
|
664
674
|
apply: (r) => {
|
|
665
675
|
var f;
|
|
666
|
-
const n = a.get(
|
|
676
|
+
const n = a.get(v);
|
|
667
677
|
if (!((f = n.hasFocus) != null && f.call(n)) || !n.editable)
|
|
668
|
-
return
|
|
678
|
+
return S.empty;
|
|
669
679
|
const { $from: o } = r.selection, l = o.node();
|
|
670
680
|
if (l.type !== e)
|
|
671
|
-
return
|
|
681
|
+
return S.empty;
|
|
672
682
|
const s = l.attrs.level, c = (d) => Array(d).fill(0).map((m) => "#").join(""), i = document.createElement("span");
|
|
673
683
|
i.textContent = c(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
|
|
674
684
|
const d = t.getStyle(({ css: m }) => {
|
|
675
|
-
const p =
|
|
685
|
+
const p = Ae(t.themeManager);
|
|
676
686
|
return m`
|
|
677
687
|
margin-right: 4px;
|
|
678
688
|
color: ${p("primary")};
|
|
@@ -680,8 +690,8 @@ const k = {
|
|
|
680
690
|
});
|
|
681
691
|
d && (i.className = d);
|
|
682
692
|
});
|
|
683
|
-
const u =
|
|
684
|
-
return
|
|
693
|
+
const u = Z.widget(o.before() + 1, i, { side: -1 });
|
|
694
|
+
return S.create(r.doc, [u]);
|
|
685
695
|
}
|
|
686
696
|
},
|
|
687
697
|
props: {
|
|
@@ -695,7 +705,7 @@ const k = {
|
|
|
695
705
|
return this.getState(r);
|
|
696
706
|
}
|
|
697
707
|
}
|
|
698
|
-
}), pt =
|
|
708
|
+
}), pt = C(
|
|
699
709
|
(a, e) => {
|
|
700
710
|
var o, l;
|
|
701
711
|
const t = "heading", r = (o = e == null ? void 0 : e.getId) != null ? o : dt, n = (l = e == null ? void 0 : e.displayHashtag) != null ? l : !0;
|
|
@@ -717,7 +727,7 @@ const k = {
|
|
|
717
727
|
tag: `h${s}`,
|
|
718
728
|
getAttrs: (c) => {
|
|
719
729
|
if (!(c instanceof HTMLElement))
|
|
720
|
-
throw
|
|
730
|
+
throw x(c);
|
|
721
731
|
return { level: s, id: c.id };
|
|
722
732
|
}
|
|
723
733
|
})),
|
|
@@ -744,7 +754,7 @@ const k = {
|
|
|
744
754
|
const f = [];
|
|
745
755
|
c.content.forEach((d, m, p) => {
|
|
746
756
|
p !== c.childCount - 1 && f.push(d);
|
|
747
|
-
}), s.next(
|
|
757
|
+
}), s.next(W.fromArray(f));
|
|
748
758
|
} else
|
|
749
759
|
s.next(c.content);
|
|
750
760
|
s.closeNode();
|
|
@@ -752,8 +762,8 @@ const k = {
|
|
|
752
762
|
}
|
|
753
763
|
}),
|
|
754
764
|
inputRules: (s, c) => Me.map(
|
|
755
|
-
(i) =>
|
|
756
|
-
const u = c.get(
|
|
765
|
+
(i) => X(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
|
|
766
|
+
const u = c.get(v), { $from: f } = u.state.selection, d = f.node();
|
|
757
767
|
if (d.type.name === "heading") {
|
|
758
768
|
let m = Number(d.attrs.level) + Number(i);
|
|
759
769
|
return m > 6 && (m = 6), {
|
|
@@ -766,8 +776,8 @@ const k = {
|
|
|
766
776
|
})
|
|
767
777
|
),
|
|
768
778
|
commands: (s, c) => [
|
|
769
|
-
|
|
770
|
-
|
|
779
|
+
N(O, (i = 1) => i < 1 ? A(i === 0 && c.get(R).nodes.paragraph || s) : A(i === 0 && c.get(R).nodes.paragraph || s, { level: i })),
|
|
780
|
+
N(ye, () => (i, u, f) => {
|
|
771
781
|
const { $from: d } = i.selection, m = d.node();
|
|
772
782
|
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
773
783
|
return !1;
|
|
@@ -777,17 +787,17 @@ const k = {
|
|
|
777
787
|
...m.attrs,
|
|
778
788
|
level: p
|
|
779
789
|
})
|
|
780
|
-
), !0) :
|
|
790
|
+
), !0) : A(c.get(R).nodes.paragraph || s)(i, u, f);
|
|
781
791
|
})
|
|
782
792
|
],
|
|
783
793
|
shortcuts: {
|
|
784
|
-
[
|
|
785
|
-
[
|
|
786
|
-
[
|
|
787
|
-
[
|
|
788
|
-
[
|
|
789
|
-
[
|
|
790
|
-
[
|
|
794
|
+
[y.H1]: M(O, "Mod-Alt-1", 1),
|
|
795
|
+
[y.H2]: M(O, "Mod-Alt-2", 2),
|
|
796
|
+
[y.H3]: M(O, "Mod-Alt-3", 3),
|
|
797
|
+
[y.H4]: M(O, "Mod-Alt-4", 4),
|
|
798
|
+
[y.H5]: M(O, "Mod-Alt-5", 5),
|
|
799
|
+
[y.H6]: M(O, "Mod-Alt-6", 6),
|
|
800
|
+
[y.DowngradeHeading]: M(ye, ["Backspace", "Delete"])
|
|
791
801
|
},
|
|
792
802
|
prosePlugins: (s, c) => {
|
|
793
803
|
const i = [ft(c, s, r)];
|
|
@@ -795,12 +805,12 @@ const k = {
|
|
|
795
805
|
}
|
|
796
806
|
};
|
|
797
807
|
}
|
|
798
|
-
),
|
|
799
|
-
id:
|
|
808
|
+
), G = "hr", He = I("InsertHr"), gt = C((a) => ({
|
|
809
|
+
id: G,
|
|
800
810
|
schema: () => ({
|
|
801
811
|
group: "block",
|
|
802
812
|
parseDOM: [{ tag: "hr" }],
|
|
803
|
-
toDOM: (e) => ["hr", { class: a.getClassName(e.attrs,
|
|
813
|
+
toDOM: (e) => ["hr", { class: a.getClassName(e.attrs, G) }],
|
|
804
814
|
parseMarkdown: {
|
|
805
815
|
match: ({ type: e }) => e === "thematicBreak",
|
|
806
816
|
runner: (e, t, r) => {
|
|
@@ -808,7 +818,7 @@ const k = {
|
|
|
808
818
|
}
|
|
809
819
|
},
|
|
810
820
|
toMarkdown: {
|
|
811
|
-
match: (e) => e.type.name ===
|
|
821
|
+
match: (e) => e.type.name === G,
|
|
812
822
|
runner: (e) => {
|
|
813
823
|
e.addNode("thematicBreak");
|
|
814
824
|
}
|
|
@@ -821,17 +831,17 @@ const k = {
|
|
|
821
831
|
})
|
|
822
832
|
],
|
|
823
833
|
commands: (e, t) => [
|
|
824
|
-
|
|
834
|
+
N(He, () => (r, n) => {
|
|
825
835
|
if (!n)
|
|
826
836
|
return !0;
|
|
827
|
-
const o = t.get(
|
|
837
|
+
const o = t.get(R).node("paragraph"), { tr: l, selection: s } = r, { from: c } = s, i = e.create();
|
|
828
838
|
if (!i)
|
|
829
839
|
return !0;
|
|
830
840
|
const u = l.replaceSelectionWith(i).insert(c, o), f = Ce.findFrom(u.doc.resolve(c), 1, !0);
|
|
831
841
|
return f && n(u.setSelection(f).scrollIntoView()), !0;
|
|
832
842
|
})
|
|
833
843
|
]
|
|
834
|
-
})),
|
|
844
|
+
})), ce = I("ModifyImage"), De = I("InsertImage"), B = "image", ht = new H("MILKDOWN_IMAGE_INPUT"), kt = C((a, e) => ({
|
|
835
845
|
id: "image",
|
|
836
846
|
schema: () => ({
|
|
837
847
|
inline: !0,
|
|
@@ -852,7 +862,7 @@ const k = {
|
|
|
852
862
|
tag: "img[src]",
|
|
853
863
|
getAttrs: (t) => {
|
|
854
864
|
if (!(t instanceof HTMLElement))
|
|
855
|
-
throw
|
|
865
|
+
throw x(t);
|
|
856
866
|
return {
|
|
857
867
|
src: t.getAttribute("src") || "",
|
|
858
868
|
alt: t.getAttribute("alt") || "",
|
|
@@ -865,11 +875,11 @@ const k = {
|
|
|
865
875
|
"img",
|
|
866
876
|
{
|
|
867
877
|
...t.attrs,
|
|
868
|
-
class: a.getClassName(t.attrs,
|
|
878
|
+
class: a.getClassName(t.attrs, B)
|
|
869
879
|
}
|
|
870
880
|
],
|
|
871
881
|
parseMarkdown: {
|
|
872
|
-
match: ({ type: t }) => t ===
|
|
882
|
+
match: ({ type: t }) => t === B,
|
|
873
883
|
runner: (t, r, n) => {
|
|
874
884
|
const o = r.url, l = r.alt, s = r.title;
|
|
875
885
|
t.addNode(n, {
|
|
@@ -880,7 +890,7 @@ const k = {
|
|
|
880
890
|
}
|
|
881
891
|
},
|
|
882
892
|
toMarkdown: {
|
|
883
|
-
match: (t) => t.type.name ===
|
|
893
|
+
match: (t) => t.type.name === B,
|
|
884
894
|
runner: (t, r) => {
|
|
885
895
|
t.addNode("image", void 0, void 0, {
|
|
886
896
|
title: r.attrs.title,
|
|
@@ -891,7 +901,7 @@ const k = {
|
|
|
891
901
|
}
|
|
892
902
|
}),
|
|
893
903
|
commands: (t) => [
|
|
894
|
-
|
|
904
|
+
N(De, (r = "") => (n, o) => {
|
|
895
905
|
if (!o)
|
|
896
906
|
return !0;
|
|
897
907
|
const { tr: l } = n, s = t.create({ src: r });
|
|
@@ -900,8 +910,8 @@ const k = {
|
|
|
900
910
|
const c = l.replaceSelectionWith(s);
|
|
901
911
|
return o(c.scrollIntoView()), !0;
|
|
902
912
|
}),
|
|
903
|
-
|
|
904
|
-
const l =
|
|
913
|
+
N(ce, (r = "") => (n, o) => {
|
|
914
|
+
const l = F(n.selection, t);
|
|
905
915
|
if (!l)
|
|
906
916
|
return !1;
|
|
907
917
|
const { tr: s } = n;
|
|
@@ -931,7 +941,7 @@ const k = {
|
|
|
931
941
|
const { dom: s, onUpdate: c } = l;
|
|
932
942
|
return c(r), {
|
|
933
943
|
dom: s,
|
|
934
|
-
update: (f) => f.type.name !==
|
|
944
|
+
update: (f) => f.type.name !== B ? !1 : (r = f, c(r), !0),
|
|
935
945
|
selectNode: () => {
|
|
936
946
|
s.classList.add("ProseMirror-selectednode");
|
|
937
947
|
},
|
|
@@ -949,15 +959,15 @@ const k = {
|
|
|
949
959
|
placeholder: (u = (i = e == null ? void 0 : e.input) == null ? void 0 : i.placeholder) != null ? u : "Input Image Link",
|
|
950
960
|
buttonText: (f = e == null ? void 0 : e.input) == null ? void 0 : f.buttonText,
|
|
951
961
|
onUpdate: (d) => {
|
|
952
|
-
r.get(Le).call(
|
|
962
|
+
r.get(Le).call(ce, d);
|
|
953
963
|
}
|
|
954
964
|
});
|
|
955
965
|
if (!o)
|
|
956
966
|
return {};
|
|
957
967
|
const l = (d) => Boolean(
|
|
958
|
-
d.hasFocus() && t &&
|
|
968
|
+
d.hasFocus() && t && F(d.state.selection, t)
|
|
959
969
|
), s = (d) => {
|
|
960
|
-
const m =
|
|
970
|
+
const m = F(d.state.selection, t);
|
|
961
971
|
return m ? m.node.attrs.src : void 0;
|
|
962
972
|
}, c = (d) => {
|
|
963
973
|
if (!d.editable)
|
|
@@ -975,7 +985,7 @@ const k = {
|
|
|
975
985
|
}
|
|
976
986
|
})
|
|
977
987
|
]
|
|
978
|
-
})), Ne = "list_item",
|
|
988
|
+
})), Ne = "list_item", ie = I("SplitListItem"), ue = I("SinkListItem"), de = I("LiftListItem"), Mt = new H("MILKDOWN_KEEP_LIST_ORDER"), yt = (a) => {
|
|
979
989
|
const e = (t, r) => {
|
|
980
990
|
const n = We("ordered_list", t.schema);
|
|
981
991
|
let o = t.tr;
|
|
@@ -998,7 +1008,7 @@ const k = {
|
|
|
998
1008
|
}), o;
|
|
999
1009
|
}
|
|
1000
1010
|
});
|
|
1001
|
-
}, Nt =
|
|
1011
|
+
}, Nt = C((a) => ({
|
|
1002
1012
|
id: Ne,
|
|
1003
1013
|
schema: () => ({
|
|
1004
1014
|
group: "listItem",
|
|
@@ -1020,7 +1030,7 @@ const k = {
|
|
|
1020
1030
|
tag: "li.list-item",
|
|
1021
1031
|
getAttrs: (e) => {
|
|
1022
1032
|
if (!(e instanceof HTMLElement))
|
|
1023
|
-
throw
|
|
1033
|
+
throw x(e);
|
|
1024
1034
|
return {
|
|
1025
1035
|
label: e.dataset.label,
|
|
1026
1036
|
listType: e.dataset["list-type"],
|
|
@@ -1029,7 +1039,7 @@ const k = {
|
|
|
1029
1039
|
},
|
|
1030
1040
|
contentElement: (e) => {
|
|
1031
1041
|
if (!(e instanceof HTMLElement))
|
|
1032
|
-
throw
|
|
1042
|
+
throw x(e);
|
|
1033
1043
|
const t = e.querySelector(".list-item_body");
|
|
1034
1044
|
return t || e;
|
|
1035
1045
|
}
|
|
@@ -1061,19 +1071,19 @@ const k = {
|
|
|
1061
1071
|
}
|
|
1062
1072
|
}
|
|
1063
1073
|
}),
|
|
1064
|
-
inputRules: (e) => [
|
|
1074
|
+
inputRules: (e) => [K(/^\s*([-+*])\s$/, e)],
|
|
1065
1075
|
commands: (e) => [
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1076
|
+
N(ie, () => je(e)),
|
|
1077
|
+
N(ue, () => ze(e)),
|
|
1078
|
+
N(de, () => Ue(e))
|
|
1069
1079
|
],
|
|
1070
1080
|
shortcuts: {
|
|
1071
|
-
[
|
|
1072
|
-
[
|
|
1073
|
-
[
|
|
1081
|
+
[y.NextListItem]: M(ie, "Enter"),
|
|
1082
|
+
[y.SinkListItem]: M(ue, "Mod-]"),
|
|
1083
|
+
[y.LiftListItem]: M(de, "Mod-[")
|
|
1074
1084
|
},
|
|
1075
1085
|
prosePlugins: (e) => [yt(e)]
|
|
1076
|
-
})),
|
|
1086
|
+
})), fe = I("WrapInOrderedList"), Ie = "ordered_list", It = C((a) => ({
|
|
1077
1087
|
id: Ie,
|
|
1078
1088
|
schema: () => ({
|
|
1079
1089
|
content: "listItem+",
|
|
@@ -1091,7 +1101,7 @@ const k = {
|
|
|
1091
1101
|
tag: "ol",
|
|
1092
1102
|
getAttrs: (e) => {
|
|
1093
1103
|
if (!(e instanceof HTMLElement))
|
|
1094
|
-
throw
|
|
1104
|
+
throw x(e);
|
|
1095
1105
|
return {
|
|
1096
1106
|
spread: e.dataset.spread,
|
|
1097
1107
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1123,18 +1133,18 @@ const k = {
|
|
|
1123
1133
|
}
|
|
1124
1134
|
}),
|
|
1125
1135
|
inputRules: (e) => [
|
|
1126
|
-
|
|
1136
|
+
K(
|
|
1127
1137
|
/^(\d+)\.\s$/,
|
|
1128
1138
|
e,
|
|
1129
1139
|
(t) => ({ order: Number(t[1]) }),
|
|
1130
1140
|
(t, r) => r.childCount + r.attrs.order === Number(t[1])
|
|
1131
1141
|
)
|
|
1132
1142
|
],
|
|
1133
|
-
commands: (e) => [
|
|
1143
|
+
commands: (e) => [N(fe, () => ge(e))],
|
|
1134
1144
|
shortcuts: {
|
|
1135
|
-
[
|
|
1145
|
+
[y.OrderedList]: M(fe, "Mod-Alt-7")
|
|
1136
1146
|
}
|
|
1137
|
-
})),
|
|
1147
|
+
})), me = I("TurnIntoText"), be = "paragraph", bt = C((a) => ({
|
|
1138
1148
|
id: be,
|
|
1139
1149
|
schema: () => ({
|
|
1140
1150
|
content: "inline*",
|
|
@@ -1155,18 +1165,18 @@ const k = {
|
|
|
1155
1165
|
const o = [];
|
|
1156
1166
|
t.content.forEach((l, s, c) => {
|
|
1157
1167
|
c !== t.childCount - 1 && o.push(l);
|
|
1158
|
-
}), e.next(
|
|
1168
|
+
}), e.next(W.fromArray(o));
|
|
1159
1169
|
} else
|
|
1160
1170
|
e.next(t.content);
|
|
1161
1171
|
e.closeNode();
|
|
1162
1172
|
}
|
|
1163
1173
|
}
|
|
1164
1174
|
}),
|
|
1165
|
-
commands: (e) => [
|
|
1175
|
+
commands: (e) => [N(me, () => A(e))],
|
|
1166
1176
|
shortcuts: {
|
|
1167
|
-
[
|
|
1177
|
+
[y.Text]: M(me, "Mod-Alt-0")
|
|
1168
1178
|
}
|
|
1169
|
-
})), wt =
|
|
1179
|
+
})), wt = C(() => ({
|
|
1170
1180
|
id: "text",
|
|
1171
1181
|
schema: () => ({
|
|
1172
1182
|
group: "inline",
|
|
@@ -1205,7 +1215,6 @@ const k = {
|
|
|
1205
1215
|
t.children.forEach((o, l) => {
|
|
1206
1216
|
o.label = l + n;
|
|
1207
1217
|
});
|
|
1208
|
-
return;
|
|
1209
1218
|
}
|
|
1210
1219
|
});
|
|
1211
1220
|
}
|
|
@@ -1271,29 +1280,29 @@ const Dt = () => {
|
|
|
1271
1280
|
},
|
|
1272
1281
|
decorations(t) {
|
|
1273
1282
|
if (e.getState(t)) {
|
|
1274
|
-
const o = t.selection.$from.pos, l = document.createElement("span"), s =
|
|
1283
|
+
const o = t.selection.$from.pos, l = document.createElement("span"), s = Z.widget(o, l, {
|
|
1275
1284
|
side: -1
|
|
1276
|
-
}), c = document.createElement("span"), i =
|
|
1285
|
+
}), c = document.createElement("span"), i = Z.widget(o, c);
|
|
1277
1286
|
return setTimeout(() => {
|
|
1278
1287
|
l.contentEditable = "true", c.contentEditable = "true";
|
|
1279
|
-
}),
|
|
1288
|
+
}), S.create(t.doc, [s, i]);
|
|
1280
1289
|
}
|
|
1281
|
-
return
|
|
1290
|
+
return S.empty;
|
|
1282
1291
|
}
|
|
1283
1292
|
}
|
|
1284
1293
|
});
|
|
1285
1294
|
return e;
|
|
1286
|
-
},
|
|
1287
|
-
let e = a, t = e.match(
|
|
1295
|
+
}, Y = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, vt = (a) => new RegExp(`\\\\(?=[^\\w\\s${a}\\\\]|_)`, "g"), At = (a) => {
|
|
1296
|
+
let e = a, t = e.match(Y);
|
|
1288
1297
|
for (; t && t.groups; ) {
|
|
1289
1298
|
const { span: r } = t.groups;
|
|
1290
|
-
e = e.replace(
|
|
1299
|
+
e = e.replace(Y, r), t = e.match(Y);
|
|
1291
1300
|
}
|
|
1292
1301
|
return e;
|
|
1293
|
-
},
|
|
1302
|
+
}, Et = (a, e, t) => {
|
|
1294
1303
|
const r = a.split(""), n = r[e];
|
|
1295
1304
|
return r[e] && r[t] && (r[e] = r[t], r[t] = n), r.join("").toString();
|
|
1296
|
-
}, _t = (a) => (e) => e.replace(
|
|
1305
|
+
}, _t = (a) => (e) => e.replace(vt(a), ""), $t = (a) => (e) => {
|
|
1297
1306
|
const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1), o = /[^\w]|_/;
|
|
1298
1307
|
return n ? r && o.test(r) && o.test(n) ? a.punctuation : a.char : a.punctuation;
|
|
1299
1308
|
}, Pt = (a, e, t) => {
|
|
@@ -1321,20 +1330,20 @@ const Dt = () => {
|
|
|
1321
1330
|
const t = ["*", "_"];
|
|
1322
1331
|
let r = e.indexOf(a);
|
|
1323
1332
|
for (; t.includes(e[r - 1] || "") && t.includes(e[r + 1] || ""); )
|
|
1324
|
-
e =
|
|
1333
|
+
e = Et(e, r, r + 1), r = r + 1;
|
|
1325
1334
|
return e;
|
|
1326
1335
|
}
|
|
1327
|
-
},
|
|
1336
|
+
}, E = Ee(Bt, "inlineSyncConfig"), Rt = (a) => {
|
|
1328
1337
|
const { selection: e } = a, { $from: t } = e;
|
|
1329
1338
|
return t.node();
|
|
1330
1339
|
}, Wt = (a, e, t, r) => {
|
|
1331
1340
|
const n = a.get(_e), o = e.schema.topNodeType.create(void 0, [t, ...r]);
|
|
1332
1341
|
return n(o);
|
|
1333
1342
|
}, qt = (a, e) => {
|
|
1334
|
-
const t = a.get(
|
|
1343
|
+
const t = a.get(E), r = t.placeholderConfig.hole, [n = "", ...o] = e.split(`
|
|
1335
1344
|
|
|
1336
1345
|
`), l = (u) => t.movePlaceholder(r, u);
|
|
1337
|
-
let c = Se(_t(r), l,
|
|
1346
|
+
let c = Se(_t(r), l, At)(n);
|
|
1338
1347
|
const i = $t(t.placeholderConfig)(c);
|
|
1339
1348
|
return c = c.replace(r, i), c = [c, ...o].join(`
|
|
1340
1349
|
|
|
@@ -1343,7 +1352,7 @@ const Dt = () => {
|
|
|
1343
1352
|
const r = a.get($e)(e);
|
|
1344
1353
|
return r ? r.firstChild : null;
|
|
1345
1354
|
}, Ft = (a, e) => {
|
|
1346
|
-
const { globalNodes: t } = a.get(
|
|
1355
|
+
const { globalNodes: t } = a.get(E), r = [];
|
|
1347
1356
|
return e.doc.descendants((n) => {
|
|
1348
1357
|
if (t.includes(n.type.name) || t.includes(n.type))
|
|
1349
1358
|
return r.push(n), !1;
|
|
@@ -1367,85 +1376,85 @@ const Dt = () => {
|
|
|
1367
1376
|
return null;
|
|
1368
1377
|
}
|
|
1369
1378
|
}, zt = (a, e, t, r, n) => {
|
|
1370
|
-
const { placeholderConfig: o } = a.get(
|
|
1379
|
+
const { placeholderConfig: o } = a.get(E), l = o.hole;
|
|
1371
1380
|
let s = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
|
|
1372
1381
|
const c = t.apply(s), i = Oe(a, c);
|
|
1373
1382
|
if (!i)
|
|
1374
1383
|
return;
|
|
1375
1384
|
const { $from: u } = c.selection, f = u.before(), d = u.after(), m = Pt(i.nextNode, f, i.placeholder);
|
|
1376
|
-
s = s.replaceWith(f, d, i.nextNode).setNodeMarkup(f, void 0, n).delete(m + 1, m + 2), s = s.setSelection(
|
|
1377
|
-
},
|
|
1385
|
+
s = s.replaceWith(f, d, i.nextNode).setNodeMarkup(f, void 0, n).delete(m + 1, m + 2), s = s.setSelection(Q.near(s.doc.resolve(m + 1))), r(s);
|
|
1386
|
+
}, J = new H("MILKDOWN_INLINE_SYNC"), Ut = (a) => {
|
|
1378
1387
|
let e = null;
|
|
1379
1388
|
return new T({
|
|
1380
|
-
key:
|
|
1389
|
+
key: J,
|
|
1381
1390
|
state: {
|
|
1382
1391
|
init: () => null,
|
|
1383
1392
|
apply: (r, n, o, l) => {
|
|
1384
1393
|
var p;
|
|
1385
|
-
const s = a.get(
|
|
1386
|
-
if (!((p = s.hasFocus) != null && p.call(s)) || !s.editable || !r.docChanged || r.getMeta(
|
|
1394
|
+
const s = a.get(v);
|
|
1395
|
+
if (!((p = s.hasFocus) != null && p.call(s)) || !s.editable || !r.docChanged || r.getMeta(J))
|
|
1387
1396
|
return null;
|
|
1388
1397
|
const i = Oe(a, l);
|
|
1389
1398
|
if (!i)
|
|
1390
1399
|
return null;
|
|
1391
1400
|
e && (cancelAnimationFrame(e), e = null);
|
|
1392
|
-
const { prevNode: u, nextNode: f, text: d } = i, { shouldSyncNode: m } = a.get(
|
|
1401
|
+
const { prevNode: u, nextNode: f, text: d } = i, { shouldSyncNode: m } = a.get(E);
|
|
1393
1402
|
return m({ prevNode: u, nextNode: f, ctx: a, tr: r, text: d }) && (e = requestAnimationFrame(() => {
|
|
1394
1403
|
e = null;
|
|
1395
|
-
const { dispatch: g, state:
|
|
1396
|
-
zt(a,
|
|
1404
|
+
const { dispatch: g, state: h } = a.get(v);
|
|
1405
|
+
zt(a, J, h, g, u.attrs);
|
|
1397
1406
|
})), null;
|
|
1398
1407
|
}
|
|
1399
1408
|
}
|
|
1400
1409
|
});
|
|
1401
1410
|
}, Vt = [
|
|
1402
|
-
|
|
1403
|
-
injectSlices: [
|
|
1411
|
+
ve(() => ({
|
|
1412
|
+
injectSlices: [E],
|
|
1404
1413
|
prosePlugins: (a, e) => [St(), Ut(e)],
|
|
1405
1414
|
remarkPlugins: () => [Ve, Dt, Ct]
|
|
1406
1415
|
}))()
|
|
1407
1416
|
], Gt = we.create([...Lt, ...et]), cr = we.create([...Vt, ...Gt]), ir = {
|
|
1408
|
-
ToggleInlineCode:
|
|
1409
|
-
ToggleItalic:
|
|
1417
|
+
ToggleInlineCode: ee,
|
|
1418
|
+
ToggleItalic: te,
|
|
1410
1419
|
ToggleLink: Te,
|
|
1411
|
-
ToggleBold:
|
|
1412
|
-
ModifyLink:
|
|
1413
|
-
ModifyImage:
|
|
1414
|
-
WrapInBlockquote:
|
|
1415
|
-
WrapInBulletList:
|
|
1416
|
-
WrapInOrderedList:
|
|
1417
|
-
TurnIntoCodeFence:
|
|
1418
|
-
TurnIntoHeading:
|
|
1419
|
-
TurnIntoText:
|
|
1420
|
-
InsertHardbreak:
|
|
1420
|
+
ToggleBold: ne,
|
|
1421
|
+
ModifyLink: re,
|
|
1422
|
+
ModifyImage: ce,
|
|
1423
|
+
WrapInBlockquote: se,
|
|
1424
|
+
WrapInBulletList: oe,
|
|
1425
|
+
WrapInOrderedList: fe,
|
|
1426
|
+
TurnIntoCodeFence: ae,
|
|
1427
|
+
TurnIntoHeading: O,
|
|
1428
|
+
TurnIntoText: me,
|
|
1429
|
+
InsertHardbreak: le,
|
|
1421
1430
|
InsertHr: He,
|
|
1422
1431
|
InsertImage: De,
|
|
1423
|
-
SplitListItem:
|
|
1424
|
-
SinkListItem:
|
|
1425
|
-
LiftListItem:
|
|
1432
|
+
SplitListItem: ie,
|
|
1433
|
+
SinkListItem: ue,
|
|
1434
|
+
LiftListItem: de
|
|
1426
1435
|
};
|
|
1427
1436
|
export {
|
|
1428
1437
|
ye as DowngradeHeading,
|
|
1429
1438
|
ct as HardbreakFilterPluginKey,
|
|
1430
|
-
|
|
1439
|
+
le as InsertHardbreak,
|
|
1431
1440
|
He as InsertHr,
|
|
1432
1441
|
De as InsertImage,
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
+
de as LiftListItem,
|
|
1443
|
+
ce as ModifyImage,
|
|
1444
|
+
re as ModifyLink,
|
|
1445
|
+
ue as SinkListItem,
|
|
1446
|
+
ie as SplitListItem,
|
|
1447
|
+
y as SupportedKeys,
|
|
1448
|
+
ne as ToggleBold,
|
|
1449
|
+
ee as ToggleInlineCode,
|
|
1450
|
+
te as ToggleItalic,
|
|
1442
1451
|
Te as ToggleLink,
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1452
|
+
ae as TurnIntoCodeFence,
|
|
1453
|
+
O as TurnIntoHeading,
|
|
1454
|
+
me as TurnIntoText,
|
|
1455
|
+
se as WrapInBlockquote,
|
|
1456
|
+
oe as WrapInBulletList,
|
|
1457
|
+
fe as WrapInOrderedList,
|
|
1449
1458
|
st as backtickInputRegex,
|
|
1450
1459
|
tt as blockquote,
|
|
1451
1460
|
rt as bulletList,
|
|
@@ -1460,10 +1469,10 @@ export {
|
|
|
1460
1469
|
it as hardbreak,
|
|
1461
1470
|
pt as heading,
|
|
1462
1471
|
ut as headingHashPluginKey,
|
|
1463
|
-
|
|
1472
|
+
V as headingIdPluginKey,
|
|
1464
1473
|
gt as hr,
|
|
1465
1474
|
kt as image,
|
|
1466
|
-
|
|
1475
|
+
E as inlineSyncConfigCtx,
|
|
1467
1476
|
Xe as link,
|
|
1468
1477
|
Nt as listItem,
|
|
1469
1478
|
et as marks,
|