@milkdown/preset-commonmark 6.5.1 → 6.5.3
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 +453 -412
- 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 +17 -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 -218
- 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
|
|
6
|
-
import { PluginKey as
|
|
7
|
-
import { wrappingInputRule as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import { ReplaceStep as
|
|
10
|
-
import { DecorationSet as
|
|
11
|
-
import { splitListItem as
|
|
12
|
-
import
|
|
13
|
-
import { visit as
|
|
14
|
-
const
|
|
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
|
+
import { ReplaceStep as Ke, AddMarkStep as Fe } from "@milkdown/prose/transform";
|
|
10
|
+
import { DecorationSet as S, Decoration as Z } from "@milkdown/prose/view";
|
|
11
|
+
import { splitListItem as je, sinkListItem as ze, liftListItem as Ue } from "@milkdown/prose/schema-list";
|
|
12
|
+
import Ve from "remark-inline-links";
|
|
13
|
+
import { visit as Ge } from "unist-util-visit";
|
|
14
|
+
const y = {
|
|
15
15
|
HardBreak: "HardBreak",
|
|
16
16
|
Blockquote: "Blockquote",
|
|
17
17
|
BulletList: "BulletList",
|
|
@@ -31,8 +31,8 @@ const k = {
|
|
|
31
31
|
NextListItem: "NextListItem",
|
|
32
32
|
SinkListItem: "SinkListItem",
|
|
33
33
|
LiftListItem: "LiftListItem"
|
|
34
|
-
},
|
|
35
|
-
id:
|
|
34
|
+
}, ke = "code_inline", ee = I("ToggleInlineCode"), Ye = q((a) => ({
|
|
35
|
+
id: ke,
|
|
36
36
|
schema: () => ({
|
|
37
37
|
priority: 100,
|
|
38
38
|
code: !0,
|
|
@@ -46,14 +46,14 @@ const k = {
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
toMarkdown: {
|
|
49
|
-
match: (e) => e.type.name ===
|
|
49
|
+
match: (e) => e.type.name === ke,
|
|
50
50
|
runner: (e, t, r) => {
|
|
51
51
|
e.withMark(t, "inlineCode", r.text || "");
|
|
52
52
|
}
|
|
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
|
-
})),
|
|
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,75 +129,88 @@ 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
|
|
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
|
+
), !0) : !1;
|
|
151
153
|
})
|
|
152
154
|
],
|
|
153
155
|
prosePlugins: (t, r) => {
|
|
154
156
|
let n = !1;
|
|
155
157
|
return [
|
|
156
|
-
new
|
|
157
|
-
key:
|
|
158
|
+
new T({
|
|
159
|
+
key: Qe,
|
|
158
160
|
view: (o) => {
|
|
159
161
|
var u, f, d;
|
|
160
162
|
const l = a.themeManager.get("input-chip", {
|
|
161
163
|
placeholder: (f = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? f : "Input Web Link",
|
|
162
164
|
buttonText: (d = e == null ? void 0 : e.input) == null ? void 0 : d.buttonText,
|
|
163
165
|
onUpdate: (m) => {
|
|
164
|
-
r.get(
|
|
166
|
+
r.get(Le).call(re, m);
|
|
165
167
|
},
|
|
166
168
|
calculatePosition: (m, p) => {
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
170
|
-
throw
|
|
171
|
-
const
|
|
172
|
-
let
|
|
173
|
-
|
|
169
|
+
Be(m, p, (g, h, k, b) => {
|
|
170
|
+
const w = m.dom.parentElement;
|
|
171
|
+
if (!w)
|
|
172
|
+
throw Pe();
|
|
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];
|
|
174
178
|
});
|
|
175
179
|
}
|
|
176
180
|
});
|
|
177
181
|
if (!l)
|
|
178
182
|
return {};
|
|
179
183
|
const s = (m) => {
|
|
180
|
-
|
|
184
|
+
var b;
|
|
185
|
+
const { selection: p, doc: g } = m.state, { from: h, to: k } = p;
|
|
181
186
|
if (!m.hasFocus())
|
|
182
187
|
return !1;
|
|
183
|
-
if (p
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
+
}
|
|
198
|
+
if (p instanceof qe) {
|
|
199
|
+
const { node: w } = p;
|
|
200
|
+
if (w.type.name === "image" && w.marks.findIndex((L) => L.type.name === $) > -1)
|
|
188
201
|
return n = !0, !0;
|
|
189
202
|
}
|
|
190
203
|
return !1;
|
|
191
204
|
}, c = (m) => {
|
|
192
205
|
const { selection: p } = m.state;
|
|
193
206
|
let g;
|
|
194
|
-
const { from:
|
|
195
|
-
if (m.state.doc.nodesBetween(
|
|
196
|
-
if (t.isInSet(
|
|
197
|
-
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;
|
|
198
211
|
}), !g)
|
|
199
212
|
return;
|
|
200
|
-
const b = g.marks.find((
|
|
213
|
+
const b = g.marks.find((L) => L.type === t);
|
|
201
214
|
return b ? b.attrs.href : void 0;
|
|
202
215
|
}, i = (m) => {
|
|
203
216
|
if (!m.editable)
|
|
@@ -218,8 +231,8 @@ const k = {
|
|
|
218
231
|
})
|
|
219
232
|
];
|
|
220
233
|
}
|
|
221
|
-
})),
|
|
222
|
-
id:
|
|
234
|
+
})), z = "strong", ne = I("ToggleBold"), Ze = q((a) => ({
|
|
235
|
+
id: z,
|
|
223
236
|
schema: () => ({
|
|
224
237
|
inclusive: !1,
|
|
225
238
|
parseDOM: [
|
|
@@ -227,7 +240,7 @@ const k = {
|
|
|
227
240
|
{ tag: "strong" },
|
|
228
241
|
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
229
242
|
],
|
|
230
|
-
toDOM: (e) => ["strong", { class: a.getClassName(e.attrs,
|
|
243
|
+
toDOM: (e) => ["strong", { class: a.getClassName(e.attrs, z) }],
|
|
231
244
|
parseMarkdown: {
|
|
232
245
|
match: (e) => e.type === "strong",
|
|
233
246
|
runner: (e, t, r) => {
|
|
@@ -235,43 +248,43 @@ const k = {
|
|
|
235
248
|
}
|
|
236
249
|
},
|
|
237
250
|
toMarkdown: {
|
|
238
|
-
match: (e) => e.type.name ===
|
|
251
|
+
match: (e) => e.type.name === z,
|
|
239
252
|
runner: (e, t) => {
|
|
240
253
|
e.withMark(t, "strong");
|
|
241
254
|
}
|
|
242
255
|
}
|
|
243
256
|
}),
|
|
244
|
-
commands: (e) => [
|
|
257
|
+
commands: (e) => [N(ne, () => pe(e))],
|
|
245
258
|
shortcuts: {
|
|
246
|
-
[
|
|
259
|
+
[y.Bold]: M(ne, "Mod-b")
|
|
247
260
|
}
|
|
248
|
-
})),
|
|
249
|
-
id:
|
|
261
|
+
})), et = [Ye(), Je(), Ze(), Xe()], P = "blockquote", se = I("WrapInBlockquote"), tt = C((a) => ({
|
|
262
|
+
id: P,
|
|
250
263
|
schema: () => ({
|
|
251
264
|
content: "block+",
|
|
252
265
|
group: "block",
|
|
253
266
|
defining: !0,
|
|
254
267
|
parseDOM: [{ tag: "blockquote" }],
|
|
255
|
-
toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs,
|
|
268
|
+
toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs, P) }, 0],
|
|
256
269
|
parseMarkdown: {
|
|
257
|
-
match: ({ type: e }) => e ===
|
|
270
|
+
match: ({ type: e }) => e === P,
|
|
258
271
|
runner: (e, t, r) => {
|
|
259
272
|
e.openNode(r).next(t.children).closeNode();
|
|
260
273
|
}
|
|
261
274
|
},
|
|
262
275
|
toMarkdown: {
|
|
263
|
-
match: (e) => e.type.name ===
|
|
276
|
+
match: (e) => e.type.name === P,
|
|
264
277
|
runner: (e, t) => {
|
|
265
278
|
e.openNode("blockquote").next(t.content).closeNode();
|
|
266
279
|
}
|
|
267
280
|
}
|
|
268
281
|
}),
|
|
269
|
-
inputRules: (e) => [
|
|
270
|
-
commands: (e) => [
|
|
282
|
+
inputRules: (e) => [K(/^\s*>\s$/, e)],
|
|
283
|
+
commands: (e) => [N(se, () => ge(e))],
|
|
271
284
|
shortcuts: {
|
|
272
|
-
[
|
|
285
|
+
[y.Blockquote]: M(se, "Mod-Shift-b")
|
|
273
286
|
}
|
|
274
|
-
})),
|
|
287
|
+
})), oe = I("WrapInBulletList"), rt = C((a) => {
|
|
275
288
|
const e = "bullet_list";
|
|
276
289
|
return {
|
|
277
290
|
id: e,
|
|
@@ -288,7 +301,7 @@ const k = {
|
|
|
288
301
|
tag: "ul",
|
|
289
302
|
getAttrs: (t) => {
|
|
290
303
|
if (!(t instanceof HTMLElement))
|
|
291
|
-
throw
|
|
304
|
+
throw x(t);
|
|
292
305
|
return {
|
|
293
306
|
spread: t.dataset.spread
|
|
294
307
|
};
|
|
@@ -317,13 +330,13 @@ const k = {
|
|
|
317
330
|
}
|
|
318
331
|
}
|
|
319
332
|
}),
|
|
320
|
-
inputRules: (t) => [
|
|
321
|
-
commands: (t) => [
|
|
333
|
+
inputRules: (t) => [K(/^\s*([-+*])\s$/, t)],
|
|
334
|
+
commands: (t) => [N(oe, () => ge(t))],
|
|
322
335
|
shortcuts: {
|
|
323
|
-
[
|
|
336
|
+
[y.BulletList]: M(oe, "Mod-Alt-8")
|
|
324
337
|
}
|
|
325
338
|
};
|
|
326
|
-
}),
|
|
339
|
+
}), nt = [
|
|
327
340
|
"",
|
|
328
341
|
"javascript",
|
|
329
342
|
"typescript",
|
|
@@ -340,10 +353,10 @@ const k = {
|
|
|
340
353
|
"go",
|
|
341
354
|
"rust",
|
|
342
355
|
"markdown"
|
|
343
|
-
],
|
|
344
|
-
const t = (e == null ? void 0 : e.languageList) ||
|
|
356
|
+
], st = /^```(?<language>[a-z]*)?[\s\n]$/, ot = /^~~~(?<language>[a-z]*)?[\s\n]$/, ae = I("TurnIntoCodeFence"), U = "fence", at = C((a, e) => {
|
|
357
|
+
const t = (e == null ? void 0 : e.languageList) || nt;
|
|
345
358
|
return {
|
|
346
|
-
id:
|
|
359
|
+
id: U,
|
|
347
360
|
schema: (r) => ({
|
|
348
361
|
content: "text*",
|
|
349
362
|
group: "block",
|
|
@@ -365,18 +378,18 @@ const k = {
|
|
|
365
378
|
getAttrs: (n) => {
|
|
366
379
|
var o;
|
|
367
380
|
if (!(n instanceof HTMLElement))
|
|
368
|
-
throw
|
|
381
|
+
throw x(n);
|
|
369
382
|
return { language: (o = n.querySelector("pre")) == null ? void 0 : o.dataset.language };
|
|
370
383
|
},
|
|
371
384
|
getContent: (n, o) => {
|
|
372
385
|
var c, i;
|
|
373
386
|
if (!(n instanceof HTMLElement))
|
|
374
|
-
throw
|
|
387
|
+
throw x(n);
|
|
375
388
|
const l = (i = (c = n.querySelector("pre")) == null ? void 0 : c.textContent) != null ? i : "";
|
|
376
389
|
if (!l)
|
|
377
|
-
return
|
|
390
|
+
return W.empty;
|
|
378
391
|
const s = o.text(l);
|
|
379
|
-
return
|
|
392
|
+
return W.from(s);
|
|
380
393
|
}
|
|
381
394
|
},
|
|
382
395
|
{
|
|
@@ -384,7 +397,7 @@ const k = {
|
|
|
384
397
|
preserveWhitespace: "full",
|
|
385
398
|
getAttrs: (n) => {
|
|
386
399
|
if (!(n instanceof HTMLElement))
|
|
387
|
-
throw
|
|
400
|
+
throw x(n);
|
|
388
401
|
return { language: n.dataset.language };
|
|
389
402
|
}
|
|
390
403
|
}
|
|
@@ -398,7 +411,7 @@ const k = {
|
|
|
398
411
|
const s = l.target;
|
|
399
412
|
if (!(s instanceof HTMLSelectElement))
|
|
400
413
|
return;
|
|
401
|
-
const c = r.get(
|
|
414
|
+
const c = r.get(v);
|
|
402
415
|
if (!c.editable) {
|
|
403
416
|
s.value = n.attrs.language;
|
|
404
417
|
return;
|
|
@@ -407,10 +420,12 @@ const k = {
|
|
|
407
420
|
if (!f)
|
|
408
421
|
return;
|
|
409
422
|
const { tr: d } = c.state;
|
|
410
|
-
c.dispatch(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
423
|
+
c.dispatch(
|
|
424
|
+
d.setNodeMarkup(f.inside, void 0, {
|
|
425
|
+
...n.attrs,
|
|
426
|
+
language: s.value
|
|
427
|
+
})
|
|
428
|
+
);
|
|
414
429
|
}, [
|
|
415
430
|
"div",
|
|
416
431
|
{
|
|
@@ -435,7 +450,7 @@ const k = {
|
|
|
435
450
|
}
|
|
436
451
|
},
|
|
437
452
|
toMarkdown: {
|
|
438
|
-
match: (n) => n.type.name ===
|
|
453
|
+
match: (n) => n.type.name === U,
|
|
439
454
|
runner: (n, o) => {
|
|
440
455
|
var l;
|
|
441
456
|
n.addNode("code", void 0, ((l = o.content.firstChild) == null ? void 0 : l.text) || "", {
|
|
@@ -445,42 +460,49 @@ const k = {
|
|
|
445
460
|
}
|
|
446
461
|
}),
|
|
447
462
|
inputRules: (r) => [
|
|
448
|
-
|
|
463
|
+
X(st, r, (n) => {
|
|
449
464
|
const [o, l] = n;
|
|
450
465
|
if (!!o)
|
|
451
466
|
return { language: l };
|
|
452
467
|
}),
|
|
453
|
-
|
|
468
|
+
X(ot, r, (n) => {
|
|
454
469
|
const [o, l] = n;
|
|
455
470
|
if (!!o)
|
|
456
471
|
return { language: l };
|
|
457
472
|
})
|
|
458
473
|
],
|
|
459
|
-
commands: (r) => [
|
|
474
|
+
commands: (r) => [N(ae, () => A(r))],
|
|
460
475
|
shortcuts: {
|
|
461
|
-
[
|
|
476
|
+
[y.CodeFence]: M(ae, "Mod-Alt-c")
|
|
462
477
|
},
|
|
463
478
|
view: () => (r, n, o) => {
|
|
464
479
|
let l = r;
|
|
465
480
|
const s = (g) => {
|
|
466
|
-
const { tr:
|
|
467
|
-
n.dispatch(
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
481
|
+
const { tr: h } = n.state;
|
|
482
|
+
n.dispatch(
|
|
483
|
+
h.setNodeMarkup(o(), void 0, {
|
|
484
|
+
fold: !0,
|
|
485
|
+
language: g
|
|
486
|
+
})
|
|
487
|
+
);
|
|
471
488
|
}, c = () => {
|
|
472
489
|
const { tr: g } = n.state;
|
|
473
|
-
n.dispatch(
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
490
|
+
n.dispatch(
|
|
491
|
+
g.setNodeMarkup(o(), void 0, {
|
|
492
|
+
...l.attrs,
|
|
493
|
+
fold: !0
|
|
494
|
+
})
|
|
495
|
+
);
|
|
477
496
|
}, i = () => {
|
|
478
497
|
const { tr: g } = n.state;
|
|
479
|
-
n.dispatch(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
498
|
+
n.dispatch(
|
|
499
|
+
g.setNodeMarkup(o(), void 0, {
|
|
500
|
+
...l.attrs,
|
|
501
|
+
fold: !1
|
|
502
|
+
})
|
|
503
|
+
);
|
|
483
504
|
}, u = a.themeManager.get("code-fence", {
|
|
505
|
+
view: n,
|
|
484
506
|
onBlur: c,
|
|
485
507
|
onFocus: i,
|
|
486
508
|
onSelectLanguage: s,
|
|
@@ -493,12 +515,12 @@ const k = {
|
|
|
493
515
|
return m(l), {
|
|
494
516
|
dom: f,
|
|
495
517
|
contentDOM: d,
|
|
496
|
-
update: (g) => g.type.name !==
|
|
518
|
+
update: (g) => g.type.name !== U ? !1 : (l = g, m(l), !0),
|
|
497
519
|
destroy: p
|
|
498
520
|
};
|
|
499
521
|
}
|
|
500
522
|
};
|
|
501
|
-
}),
|
|
523
|
+
}), lt = C(() => ({
|
|
502
524
|
id: "doc",
|
|
503
525
|
schema: () => ({
|
|
504
526
|
content: "block+",
|
|
@@ -515,7 +537,7 @@ const k = {
|
|
|
515
537
|
}
|
|
516
538
|
}
|
|
517
539
|
})
|
|
518
|
-
})),
|
|
540
|
+
})), le = I("InsertHardbreak"), ct = new H("MILKDOWN_HARDBREAK_FILTER"), it = C((a, e) => {
|
|
519
541
|
var r;
|
|
520
542
|
const t = (r = e == null ? void 0 : e.notIn) != null ? r : ["table", "fence"];
|
|
521
543
|
return {
|
|
@@ -540,23 +562,25 @@ const k = {
|
|
|
540
562
|
}
|
|
541
563
|
}),
|
|
542
564
|
commands: (n) => [
|
|
543
|
-
|
|
565
|
+
N(le, () => (o, l) => {
|
|
544
566
|
var i;
|
|
545
567
|
const { selection: s, tr: c } = o;
|
|
546
568
|
if (s.empty) {
|
|
547
569
|
const u = s.$from.node();
|
|
548
570
|
if (u.childCount > 0 && ((i = u.lastChild) == null ? void 0 : i.type.name) === "hardbreak")
|
|
549
|
-
return l == null || l(
|
|
571
|
+
return l == null || l(
|
|
572
|
+
c.replaceRangeWith(s.to - 1, s.to, o.schema.node("paragraph")).setSelection(Ce.near(c.doc.resolve(s.to))).scrollIntoView()
|
|
573
|
+
), !0;
|
|
550
574
|
}
|
|
551
575
|
return l == null || l(c.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
|
|
552
576
|
})
|
|
553
577
|
],
|
|
554
578
|
shortcuts: {
|
|
555
|
-
[
|
|
579
|
+
[y.HardBreak]: M(le, "Shift-Enter")
|
|
556
580
|
},
|
|
557
581
|
prosePlugins: (n) => [
|
|
558
|
-
new
|
|
559
|
-
key:
|
|
582
|
+
new T({
|
|
583
|
+
key: ct,
|
|
560
584
|
filterTransaction: (o, l) => {
|
|
561
585
|
const s = o.getMeta("hardbreak"), [c] = o.steps;
|
|
562
586
|
if (s && c) {
|
|
@@ -569,8 +593,8 @@ const k = {
|
|
|
569
593
|
return !0;
|
|
570
594
|
}
|
|
571
595
|
}),
|
|
572
|
-
new
|
|
573
|
-
key: new
|
|
596
|
+
new T({
|
|
597
|
+
key: new H("MILKDOWN_HARDBREAK_MARKS"),
|
|
574
598
|
appendTransaction: (o, l, s) => {
|
|
575
599
|
if (!o.length)
|
|
576
600
|
return;
|
|
@@ -579,23 +603,23 @@ const k = {
|
|
|
579
603
|
return;
|
|
580
604
|
const [i] = c.steps;
|
|
581
605
|
if (c.getMeta("hardbreak")) {
|
|
582
|
-
if (!(i instanceof
|
|
606
|
+
if (!(i instanceof Ke))
|
|
583
607
|
return;
|
|
584
608
|
const { from: d } = i;
|
|
585
609
|
return s.tr.setNodeMarkup(d, n, void 0, []);
|
|
586
610
|
}
|
|
587
|
-
if (i instanceof
|
|
611
|
+
if (i instanceof Fe) {
|
|
588
612
|
let d = s.tr;
|
|
589
613
|
const { from: m, to: p } = i;
|
|
590
|
-
return s.doc.nodesBetween(m, p, (g,
|
|
591
|
-
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, []));
|
|
592
616
|
}), d;
|
|
593
617
|
}
|
|
594
618
|
}
|
|
595
619
|
})
|
|
596
620
|
]
|
|
597
621
|
};
|
|
598
|
-
}),
|
|
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) => {
|
|
599
623
|
let r = !1;
|
|
600
624
|
const n = (o, l) => {
|
|
601
625
|
const s = o.tr.setMeta("addToHistory", !1);
|
|
@@ -605,21 +629,21 @@ const k = {
|
|
|
605
629
|
if (i.textContent.trim().length === 0)
|
|
606
630
|
return;
|
|
607
631
|
const f = i.attrs, d = t(i);
|
|
608
|
-
f.id !== d && (c = !0, s.setMeta(
|
|
632
|
+
f.id !== d && (c = !0, s.setMeta(V, !0).setNodeMarkup(u, void 0, {
|
|
609
633
|
...f,
|
|
610
634
|
id: d
|
|
611
635
|
}));
|
|
612
636
|
}
|
|
613
637
|
}), c && l(s);
|
|
614
638
|
};
|
|
615
|
-
return new
|
|
616
|
-
key:
|
|
639
|
+
return new T({
|
|
640
|
+
key: V,
|
|
617
641
|
props: {
|
|
618
642
|
handleDOMEvents: {
|
|
619
643
|
compositionstart: () => (r = !0, !1),
|
|
620
644
|
compositionend: () => {
|
|
621
645
|
r = !1;
|
|
622
|
-
const o = a.get(
|
|
646
|
+
const o = a.get(v);
|
|
623
647
|
return setTimeout(() => {
|
|
624
648
|
n(o.state, (l) => o.dispatch(l));
|
|
625
649
|
}, 0), !1;
|
|
@@ -628,7 +652,7 @@ const k = {
|
|
|
628
652
|
},
|
|
629
653
|
appendTransaction: (o, l, s) => {
|
|
630
654
|
let c = null;
|
|
631
|
-
return o.every((i) => !i.getMeta(
|
|
655
|
+
return o.every((i) => !i.getMeta(V)) && o.some((i) => i.docChanged) && n(s, (i) => {
|
|
632
656
|
c = i;
|
|
633
657
|
}), c;
|
|
634
658
|
},
|
|
@@ -643,18 +667,18 @@ const k = {
|
|
|
643
667
|
}), o.dispatch(s), {};
|
|
644
668
|
}
|
|
645
669
|
});
|
|
646
|
-
},
|
|
647
|
-
key:
|
|
670
|
+
}, mt = (a, e, t) => new T({
|
|
671
|
+
key: ut,
|
|
648
672
|
state: {
|
|
649
|
-
init: () =>
|
|
673
|
+
init: () => S.empty,
|
|
650
674
|
apply: (r) => {
|
|
651
675
|
var f;
|
|
652
|
-
const n = a.get(
|
|
676
|
+
const n = a.get(v);
|
|
653
677
|
if (!((f = n.hasFocus) != null && f.call(n)) || !n.editable)
|
|
654
|
-
return
|
|
678
|
+
return S.empty;
|
|
655
679
|
const { $from: o } = r.selection, l = o.node();
|
|
656
680
|
if (l.type !== e)
|
|
657
|
-
return
|
|
681
|
+
return S.empty;
|
|
658
682
|
const s = l.attrs.level, c = (d) => Array(d).fill(0).map((m) => "#").join(""), i = document.createElement("span");
|
|
659
683
|
i.textContent = c(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
|
|
660
684
|
const d = t.getStyle(({ css: m }) => {
|
|
@@ -666,14 +690,14 @@ const k = {
|
|
|
666
690
|
});
|
|
667
691
|
d && (i.className = d);
|
|
668
692
|
});
|
|
669
|
-
const u =
|
|
670
|
-
return
|
|
693
|
+
const u = Z.widget(o.before() + 1, i, { side: -1 });
|
|
694
|
+
return S.create(r.doc, [u]);
|
|
671
695
|
}
|
|
672
696
|
},
|
|
673
697
|
props: {
|
|
674
698
|
handleDOMEvents: {
|
|
675
699
|
focus: (r) => {
|
|
676
|
-
const n =
|
|
700
|
+
const n = Re(r.state.tr);
|
|
677
701
|
return r.dispatch(n), !1;
|
|
678
702
|
}
|
|
679
703
|
},
|
|
@@ -681,106 +705,112 @@ const k = {
|
|
|
681
705
|
return this.getState(r);
|
|
682
706
|
}
|
|
683
707
|
}
|
|
684
|
-
}),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
708
|
+
}), pt = C(
|
|
709
|
+
(a, e) => {
|
|
710
|
+
var o, l;
|
|
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;
|
|
712
|
+
return {
|
|
713
|
+
id: t,
|
|
714
|
+
schema: () => ({
|
|
715
|
+
content: "inline*",
|
|
716
|
+
group: "block",
|
|
717
|
+
defining: !0,
|
|
718
|
+
attrs: {
|
|
719
|
+
id: {
|
|
720
|
+
default: ""
|
|
721
|
+
},
|
|
722
|
+
level: {
|
|
723
|
+
default: 1
|
|
724
|
+
}
|
|
696
725
|
},
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
726
|
+
parseDOM: Me.map((s) => ({
|
|
727
|
+
tag: `h${s}`,
|
|
728
|
+
getAttrs: (c) => {
|
|
729
|
+
if (!(c instanceof HTMLElement))
|
|
730
|
+
throw x(c);
|
|
731
|
+
return { level: s, id: c.id };
|
|
732
|
+
}
|
|
733
|
+
})),
|
|
734
|
+
toDOM: (s) => [
|
|
735
|
+
`h${s.attrs.level}`,
|
|
736
|
+
{
|
|
737
|
+
id: s.attrs.id || r(s),
|
|
738
|
+
class: a.getClassName(s.attrs, `heading h${s.attrs.level}`)
|
|
739
|
+
},
|
|
740
|
+
0
|
|
741
|
+
],
|
|
742
|
+
parseMarkdown: {
|
|
743
|
+
match: ({ type: s }) => s === t,
|
|
744
|
+
runner: (s, c, i) => {
|
|
745
|
+
const u = c.depth;
|
|
746
|
+
s.openNode(i, { level: u }), s.next(c.children), s.closeNode();
|
|
747
|
+
}
|
|
714
748
|
},
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
749
|
+
toMarkdown: {
|
|
750
|
+
match: (s) => s.type.name === t,
|
|
751
|
+
runner: (s, c) => {
|
|
752
|
+
var u;
|
|
753
|
+
if (s.openNode("heading", void 0, { depth: c.attrs.level }), c.childCount >= 1 && ((u = c.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
|
|
754
|
+
const f = [];
|
|
755
|
+
c.content.forEach((d, m, p) => {
|
|
756
|
+
p !== c.childCount - 1 && f.push(d);
|
|
757
|
+
}), s.next(W.fromArray(f));
|
|
758
|
+
} else
|
|
759
|
+
s.next(c.content);
|
|
760
|
+
s.closeNode();
|
|
761
|
+
}
|
|
722
762
|
}
|
|
763
|
+
}),
|
|
764
|
+
inputRules: (s, c) => Me.map(
|
|
765
|
+
(i) => X(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
|
|
766
|
+
const u = c.get(v), { $from: f } = u.state.selection, d = f.node();
|
|
767
|
+
if (d.type.name === "heading") {
|
|
768
|
+
let m = Number(d.attrs.level) + Number(i);
|
|
769
|
+
return m > 6 && (m = 6), {
|
|
770
|
+
level: m
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
return {
|
|
774
|
+
level: i
|
|
775
|
+
};
|
|
776
|
+
})
|
|
777
|
+
),
|
|
778
|
+
commands: (s, c) => [
|
|
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) => {
|
|
781
|
+
const { $from: d } = i.selection, m = d.node();
|
|
782
|
+
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
783
|
+
return !1;
|
|
784
|
+
const p = m.attrs.level - 1;
|
|
785
|
+
return p ? (u == null || u(
|
|
786
|
+
i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
787
|
+
...m.attrs,
|
|
788
|
+
level: p
|
|
789
|
+
})
|
|
790
|
+
), !0) : A(c.get(R).nodes.paragraph || s)(i, u, f);
|
|
791
|
+
})
|
|
792
|
+
],
|
|
793
|
+
shortcuts: {
|
|
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"])
|
|
723
801
|
},
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
var u;
|
|
728
|
-
if (s.openNode("heading", void 0, { depth: c.attrs.level }), c.childCount >= 1 && ((u = c.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
|
|
729
|
-
const f = [];
|
|
730
|
-
c.content.forEach((d, m, p) => {
|
|
731
|
-
p !== c.childCount - 1 && f.push(d);
|
|
732
|
-
}), s.next(B.fromArray(f));
|
|
733
|
-
} else
|
|
734
|
-
s.next(c.content);
|
|
735
|
-
s.closeNode();
|
|
736
|
-
}
|
|
802
|
+
prosePlugins: (s, c) => {
|
|
803
|
+
const i = [ft(c, s, r)];
|
|
804
|
+
return n && i.push(mt(c, s, a)), i;
|
|
737
805
|
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
let m = Number(d.attrs.level) + Number(i);
|
|
743
|
-
return m > 6 && (m = 6), {
|
|
744
|
-
level: m
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
return {
|
|
748
|
-
level: i
|
|
749
|
-
};
|
|
750
|
-
})),
|
|
751
|
-
commands: (s, c) => [
|
|
752
|
-
M(D, (i = 1) => i < 1 ? A(i === 0 && c.get(P).nodes.paragraph || s) : A(i === 0 && c.get(P).nodes.paragraph || s, { level: i })),
|
|
753
|
-
M(Me, () => (i, u, f) => {
|
|
754
|
-
const { $from: d } = i.selection, m = d.node();
|
|
755
|
-
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
756
|
-
return !1;
|
|
757
|
-
const p = m.attrs.level - 1;
|
|
758
|
-
return p ? (u == null || u(i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
759
|
-
...m.attrs,
|
|
760
|
-
level: p
|
|
761
|
-
})), !0) : A(c.get(P).nodes.paragraph || s)(i, u, f);
|
|
762
|
-
})
|
|
763
|
-
],
|
|
764
|
-
shortcuts: {
|
|
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"])
|
|
772
|
-
},
|
|
773
|
-
prosePlugins: (s, c) => {
|
|
774
|
-
const i = [dt(c, s, r)];
|
|
775
|
-
return n && i.push(ft(c, s, a)), i;
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
}), V = "hr", Te = y("InsertHr"), pt = w((a) => ({
|
|
779
|
-
id: V,
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
), G = "hr", He = I("InsertHr"), gt = C((a) => ({
|
|
809
|
+
id: G,
|
|
780
810
|
schema: () => ({
|
|
781
811
|
group: "block",
|
|
782
812
|
parseDOM: [{ tag: "hr" }],
|
|
783
|
-
toDOM: (e) => ["hr", { class: a.getClassName(e.attrs,
|
|
813
|
+
toDOM: (e) => ["hr", { class: a.getClassName(e.attrs, G) }],
|
|
784
814
|
parseMarkdown: {
|
|
785
815
|
match: ({ type: e }) => e === "thematicBreak",
|
|
786
816
|
runner: (e, t, r) => {
|
|
@@ -788,30 +818,30 @@ const k = {
|
|
|
788
818
|
}
|
|
789
819
|
},
|
|
790
820
|
toMarkdown: {
|
|
791
|
-
match: (e) => e.type.name ===
|
|
821
|
+
match: (e) => e.type.name === G,
|
|
792
822
|
runner: (e) => {
|
|
793
823
|
e.addNode("thematicBreak");
|
|
794
824
|
}
|
|
795
825
|
}
|
|
796
826
|
}),
|
|
797
827
|
inputRules: (e) => [
|
|
798
|
-
new
|
|
828
|
+
new xe(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, o) => {
|
|
799
829
|
const { tr: l } = t;
|
|
800
830
|
return r[0] && l.replaceWith(n - 1, o, e.create()), l;
|
|
801
831
|
})
|
|
802
832
|
],
|
|
803
833
|
commands: (e, t) => [
|
|
804
|
-
|
|
834
|
+
N(He, () => (r, n) => {
|
|
805
835
|
if (!n)
|
|
806
836
|
return !0;
|
|
807
|
-
const o = t.get(
|
|
837
|
+
const o = t.get(R).node("paragraph"), { tr: l, selection: s } = r, { from: c } = s, i = e.create();
|
|
808
838
|
if (!i)
|
|
809
839
|
return !0;
|
|
810
|
-
const u = l.replaceSelectionWith(i).insert(c, o), f =
|
|
840
|
+
const u = l.replaceSelectionWith(i).insert(c, o), f = Ce.findFrom(u.doc.resolve(c), 1, !0);
|
|
811
841
|
return f && n(u.setSelection(f).scrollIntoView()), !0;
|
|
812
842
|
})
|
|
813
843
|
]
|
|
814
|
-
})),
|
|
844
|
+
})), ce = I("ModifyImage"), De = I("InsertImage"), B = "image", ht = new H("MILKDOWN_IMAGE_INPUT"), kt = C((a, e) => ({
|
|
815
845
|
id: "image",
|
|
816
846
|
schema: () => ({
|
|
817
847
|
inline: !0,
|
|
@@ -832,7 +862,7 @@ const k = {
|
|
|
832
862
|
tag: "img[src]",
|
|
833
863
|
getAttrs: (t) => {
|
|
834
864
|
if (!(t instanceof HTMLElement))
|
|
835
|
-
throw
|
|
865
|
+
throw x(t);
|
|
836
866
|
return {
|
|
837
867
|
src: t.getAttribute("src") || "",
|
|
838
868
|
alt: t.getAttribute("alt") || "",
|
|
@@ -845,11 +875,11 @@ const k = {
|
|
|
845
875
|
"img",
|
|
846
876
|
{
|
|
847
877
|
...t.attrs,
|
|
848
|
-
class: a.getClassName(t.attrs,
|
|
878
|
+
class: a.getClassName(t.attrs, B)
|
|
849
879
|
}
|
|
850
880
|
],
|
|
851
881
|
parseMarkdown: {
|
|
852
|
-
match: ({ type: t }) => t ===
|
|
882
|
+
match: ({ type: t }) => t === B,
|
|
853
883
|
runner: (t, r, n) => {
|
|
854
884
|
const o = r.url, l = r.alt, s = r.title;
|
|
855
885
|
t.addNode(n, {
|
|
@@ -860,7 +890,7 @@ const k = {
|
|
|
860
890
|
}
|
|
861
891
|
},
|
|
862
892
|
toMarkdown: {
|
|
863
|
-
match: (t) => t.type.name ===
|
|
893
|
+
match: (t) => t.type.name === B,
|
|
864
894
|
runner: (t, r) => {
|
|
865
895
|
t.addNode("image", void 0, void 0, {
|
|
866
896
|
title: r.attrs.title,
|
|
@@ -871,7 +901,7 @@ const k = {
|
|
|
871
901
|
}
|
|
872
902
|
}),
|
|
873
903
|
commands: (t) => [
|
|
874
|
-
|
|
904
|
+
N(De, (r = "") => (n, o) => {
|
|
875
905
|
if (!o)
|
|
876
906
|
return !0;
|
|
877
907
|
const { tr: l } = n, s = t.create({ src: r });
|
|
@@ -880,19 +910,24 @@ const k = {
|
|
|
880
910
|
const c = l.replaceSelectionWith(s);
|
|
881
911
|
return o(c.scrollIntoView()), !0;
|
|
882
912
|
}),
|
|
883
|
-
|
|
884
|
-
const l =
|
|
913
|
+
N(ce, (r = "") => (n, o) => {
|
|
914
|
+
const l = F(n.selection, t);
|
|
885
915
|
if (!l)
|
|
886
916
|
return !1;
|
|
887
917
|
const { tr: s } = n;
|
|
888
|
-
return o == null || o(
|
|
918
|
+
return o == null || o(
|
|
919
|
+
s.setNodeMarkup(l.pos, void 0, { ...l.node.attrs, loading: !0, src: r }).scrollIntoView()
|
|
920
|
+
), !0;
|
|
889
921
|
})
|
|
890
922
|
],
|
|
891
923
|
inputRules: (t) => [
|
|
892
|
-
new
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
924
|
+
new xe(
|
|
925
|
+
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
926
|
+
(r, n, o, l) => {
|
|
927
|
+
const [s, c, i = "", u] = n, { tr: f } = r;
|
|
928
|
+
return s && f.replaceWith(o, l, t.create({ src: i, alt: c, title: u })), f;
|
|
929
|
+
}
|
|
930
|
+
)
|
|
896
931
|
],
|
|
897
932
|
view: () => (t) => {
|
|
898
933
|
var i, u;
|
|
@@ -906,7 +941,7 @@ const k = {
|
|
|
906
941
|
const { dom: s, onUpdate: c } = l;
|
|
907
942
|
return c(r), {
|
|
908
943
|
dom: s,
|
|
909
|
-
update: (f) => f.type.name !==
|
|
944
|
+
update: (f) => f.type.name !== B ? !1 : (r = f, c(r), !0),
|
|
910
945
|
selectNode: () => {
|
|
911
946
|
s.classList.add("ProseMirror-selectednode");
|
|
912
947
|
},
|
|
@@ -916,21 +951,23 @@ const k = {
|
|
|
916
951
|
};
|
|
917
952
|
},
|
|
918
953
|
prosePlugins: (t, r) => [
|
|
919
|
-
new
|
|
920
|
-
key:
|
|
954
|
+
new T({
|
|
955
|
+
key: ht,
|
|
921
956
|
view: (n) => {
|
|
922
957
|
var i, u, f;
|
|
923
958
|
const o = a.themeManager.get("input-chip", {
|
|
924
959
|
placeholder: (u = (i = e == null ? void 0 : e.input) == null ? void 0 : i.placeholder) != null ? u : "Input Image Link",
|
|
925
960
|
buttonText: (f = e == null ? void 0 : e.input) == null ? void 0 : f.buttonText,
|
|
926
961
|
onUpdate: (d) => {
|
|
927
|
-
r.get(
|
|
962
|
+
r.get(Le).call(ce, d);
|
|
928
963
|
}
|
|
929
964
|
});
|
|
930
965
|
if (!o)
|
|
931
966
|
return {};
|
|
932
|
-
const l = (d) => Boolean(
|
|
933
|
-
|
|
967
|
+
const l = (d) => Boolean(
|
|
968
|
+
d.hasFocus() && t && F(d.state.selection, t)
|
|
969
|
+
), s = (d) => {
|
|
970
|
+
const m = F(d.state.selection, t);
|
|
934
971
|
return m ? m.node.attrs.src : void 0;
|
|
935
972
|
}, c = (d) => {
|
|
936
973
|
if (!d.editable)
|
|
@@ -948,9 +985,9 @@ const k = {
|
|
|
948
985
|
}
|
|
949
986
|
})
|
|
950
987
|
]
|
|
951
|
-
})),
|
|
988
|
+
})), Ne = "list_item", ie = I("SplitListItem"), ue = I("SinkListItem"), de = I("LiftListItem"), Mt = new H("MILKDOWN_KEEP_LIST_ORDER"), yt = (a) => {
|
|
952
989
|
const e = (t, r) => {
|
|
953
|
-
const n =
|
|
990
|
+
const n = We("ordered_list", t.schema);
|
|
954
991
|
let o = t.tr;
|
|
955
992
|
t.doc.descendants((l, s, c, i) => {
|
|
956
993
|
if (l.type === a && (c == null ? void 0 : c.type) === n) {
|
|
@@ -962,8 +999,8 @@ const k = {
|
|
|
962
999
|
}
|
|
963
1000
|
}), r(o);
|
|
964
1001
|
};
|
|
965
|
-
return new
|
|
966
|
-
key:
|
|
1002
|
+
return new T({
|
|
1003
|
+
key: Mt,
|
|
967
1004
|
appendTransaction: (t, r, n) => {
|
|
968
1005
|
let o = null;
|
|
969
1006
|
return t.some((l) => l.docChanged) && e(n, (l) => {
|
|
@@ -971,8 +1008,8 @@ const k = {
|
|
|
971
1008
|
}), o;
|
|
972
1009
|
}
|
|
973
1010
|
});
|
|
974
|
-
},
|
|
975
|
-
id:
|
|
1011
|
+
}, Nt = C((a) => ({
|
|
1012
|
+
id: Ne,
|
|
976
1013
|
schema: () => ({
|
|
977
1014
|
group: "listItem",
|
|
978
1015
|
content: "paragraph block*",
|
|
@@ -993,7 +1030,7 @@ const k = {
|
|
|
993
1030
|
tag: "li.list-item",
|
|
994
1031
|
getAttrs: (e) => {
|
|
995
1032
|
if (!(e instanceof HTMLElement))
|
|
996
|
-
throw
|
|
1033
|
+
throw x(e);
|
|
997
1034
|
return {
|
|
998
1035
|
label: e.dataset.label,
|
|
999
1036
|
listType: e.dataset["list-type"],
|
|
@@ -1002,7 +1039,7 @@ const k = {
|
|
|
1002
1039
|
},
|
|
1003
1040
|
contentElement: (e) => {
|
|
1004
1041
|
if (!(e instanceof HTMLElement))
|
|
1005
|
-
throw
|
|
1042
|
+
throw x(e);
|
|
1006
1043
|
const t = e.querySelector(".list-item_body");
|
|
1007
1044
|
return t || e;
|
|
1008
1045
|
}
|
|
@@ -1028,26 +1065,26 @@ const k = {
|
|
|
1028
1065
|
}
|
|
1029
1066
|
},
|
|
1030
1067
|
toMarkdown: {
|
|
1031
|
-
match: (e) => e.type.name ===
|
|
1068
|
+
match: (e) => e.type.name === Ne,
|
|
1032
1069
|
runner: (e, t) => {
|
|
1033
1070
|
e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
1034
1071
|
}
|
|
1035
1072
|
}
|
|
1036
1073
|
}),
|
|
1037
|
-
inputRules: (e) => [
|
|
1074
|
+
inputRules: (e) => [K(/^\s*([-+*])\s$/, e)],
|
|
1038
1075
|
commands: (e) => [
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1076
|
+
N(ie, () => je(e)),
|
|
1077
|
+
N(ue, () => ze(e)),
|
|
1078
|
+
N(de, () => Ue(e))
|
|
1042
1079
|
],
|
|
1043
1080
|
shortcuts: {
|
|
1044
|
-
[
|
|
1045
|
-
[
|
|
1046
|
-
[
|
|
1081
|
+
[y.NextListItem]: M(ie, "Enter"),
|
|
1082
|
+
[y.SinkListItem]: M(ue, "Mod-]"),
|
|
1083
|
+
[y.LiftListItem]: M(de, "Mod-[")
|
|
1047
1084
|
},
|
|
1048
|
-
prosePlugins: (e) => [
|
|
1049
|
-
})),
|
|
1050
|
-
id:
|
|
1085
|
+
prosePlugins: (e) => [yt(e)]
|
|
1086
|
+
})), fe = I("WrapInOrderedList"), Ie = "ordered_list", It = C((a) => ({
|
|
1087
|
+
id: Ie,
|
|
1051
1088
|
schema: () => ({
|
|
1052
1089
|
content: "listItem+",
|
|
1053
1090
|
group: "block",
|
|
@@ -1064,7 +1101,7 @@ const k = {
|
|
|
1064
1101
|
tag: "ol",
|
|
1065
1102
|
getAttrs: (e) => {
|
|
1066
1103
|
if (!(e instanceof HTMLElement))
|
|
1067
|
-
throw
|
|
1104
|
+
throw x(e);
|
|
1068
1105
|
return {
|
|
1069
1106
|
spread: e.dataset.spread,
|
|
1070
1107
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1089,26 +1126,31 @@ const k = {
|
|
|
1089
1126
|
}
|
|
1090
1127
|
},
|
|
1091
1128
|
toMarkdown: {
|
|
1092
|
-
match: (e) => e.type.name ===
|
|
1129
|
+
match: (e) => e.type.name === Ie,
|
|
1093
1130
|
runner: (e, t) => {
|
|
1094
1131
|
e.openNode("list", void 0, { ordered: !0, start: 1, spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
1095
1132
|
}
|
|
1096
1133
|
}
|
|
1097
1134
|
}),
|
|
1098
1135
|
inputRules: (e) => [
|
|
1099
|
-
|
|
1136
|
+
K(
|
|
1137
|
+
/^(\d+)\.\s$/,
|
|
1138
|
+
e,
|
|
1139
|
+
(t) => ({ order: Number(t[1]) }),
|
|
1140
|
+
(t, r) => r.childCount + r.attrs.order === Number(t[1])
|
|
1141
|
+
)
|
|
1100
1142
|
],
|
|
1101
|
-
commands: (e) => [
|
|
1143
|
+
commands: (e) => [N(fe, () => ge(e))],
|
|
1102
1144
|
shortcuts: {
|
|
1103
|
-
[
|
|
1145
|
+
[y.OrderedList]: M(fe, "Mod-Alt-7")
|
|
1104
1146
|
}
|
|
1105
|
-
})),
|
|
1106
|
-
id:
|
|
1147
|
+
})), me = I("TurnIntoText"), be = "paragraph", bt = C((a) => ({
|
|
1148
|
+
id: be,
|
|
1107
1149
|
schema: () => ({
|
|
1108
1150
|
content: "inline*",
|
|
1109
1151
|
group: "block",
|
|
1110
1152
|
parseDOM: [{ tag: "p" }],
|
|
1111
|
-
toDOM: (e) => ["p", { class: a.getClassName(e.attrs,
|
|
1153
|
+
toDOM: (e) => ["p", { class: a.getClassName(e.attrs, be) }, 0],
|
|
1112
1154
|
parseMarkdown: {
|
|
1113
1155
|
match: (e) => e.type === "paragraph",
|
|
1114
1156
|
runner: (e, t, r) => {
|
|
@@ -1123,18 +1165,18 @@ const k = {
|
|
|
1123
1165
|
const o = [];
|
|
1124
1166
|
t.content.forEach((l, s, c) => {
|
|
1125
1167
|
c !== t.childCount - 1 && o.push(l);
|
|
1126
|
-
}), e.next(
|
|
1168
|
+
}), e.next(W.fromArray(o));
|
|
1127
1169
|
} else
|
|
1128
1170
|
e.next(t.content);
|
|
1129
1171
|
e.closeNode();
|
|
1130
1172
|
}
|
|
1131
1173
|
}
|
|
1132
1174
|
}),
|
|
1133
|
-
commands: (e) => [
|
|
1175
|
+
commands: (e) => [N(me, () => A(e))],
|
|
1134
1176
|
shortcuts: {
|
|
1135
|
-
[
|
|
1177
|
+
[y.Text]: M(me, "Mod-Alt-0")
|
|
1136
1178
|
}
|
|
1137
|
-
})),
|
|
1179
|
+
})), wt = C(() => ({
|
|
1138
1180
|
id: "text",
|
|
1139
1181
|
schema: () => ({
|
|
1140
1182
|
group: "inline",
|
|
@@ -1151,38 +1193,37 @@ const k = {
|
|
|
1151
1193
|
}
|
|
1152
1194
|
}
|
|
1153
1195
|
})
|
|
1154
|
-
})),
|
|
1196
|
+
})), Lt = [
|
|
1197
|
+
lt(),
|
|
1198
|
+
bt(),
|
|
1199
|
+
it(),
|
|
1200
|
+
tt(),
|
|
1155
1201
|
at(),
|
|
1202
|
+
rt(),
|
|
1156
1203
|
It(),
|
|
1157
|
-
ct(),
|
|
1158
|
-
et(),
|
|
1159
|
-
ot(),
|
|
1160
|
-
tt(),
|
|
1161
1204
|
Nt(),
|
|
1162
|
-
yt(),
|
|
1163
|
-
mt(),
|
|
1164
1205
|
pt(),
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1206
|
+
gt(),
|
|
1207
|
+
kt(),
|
|
1208
|
+
wt()
|
|
1209
|
+
], Ct = () => {
|
|
1168
1210
|
function a(e) {
|
|
1169
|
-
|
|
1211
|
+
Ge(e, "list", (t) => {
|
|
1170
1212
|
var r;
|
|
1171
1213
|
if (t.ordered) {
|
|
1172
1214
|
const n = (r = t.start) != null ? r : 1;
|
|
1173
1215
|
t.children.forEach((o, l) => {
|
|
1174
1216
|
o.label = l + n;
|
|
1175
1217
|
});
|
|
1176
|
-
return;
|
|
1177
1218
|
}
|
|
1178
1219
|
});
|
|
1179
1220
|
}
|
|
1180
1221
|
return a;
|
|
1181
|
-
},
|
|
1182
|
-
function
|
|
1222
|
+
}, xt = (a) => !!a.children, Tt = (a) => a.type === "html";
|
|
1223
|
+
function Ht(a, e) {
|
|
1183
1224
|
return t(a, 0, null)[0];
|
|
1184
1225
|
function t(r, n, o) {
|
|
1185
|
-
if (
|
|
1226
|
+
if (xt(r)) {
|
|
1186
1227
|
const l = [];
|
|
1187
1228
|
for (let s = 0, c = r.children.length; s < c; s++) {
|
|
1188
1229
|
const i = r.children[s];
|
|
@@ -1200,15 +1241,15 @@ function Tt(a, e) {
|
|
|
1200
1241
|
return e(r, n, o);
|
|
1201
1242
|
}
|
|
1202
1243
|
}
|
|
1203
|
-
const
|
|
1244
|
+
const Dt = () => {
|
|
1204
1245
|
function a(e) {
|
|
1205
|
-
|
|
1246
|
+
Ht(e, (t) => Tt(t) ? [] : [t]);
|
|
1206
1247
|
}
|
|
1207
1248
|
return a;
|
|
1208
|
-
},
|
|
1249
|
+
}, Ot = new H("MILKDOWN_INLINE_NODES_CURSOR"), St = () => {
|
|
1209
1250
|
let a = !1;
|
|
1210
|
-
const e = new
|
|
1211
|
-
key:
|
|
1251
|
+
const e = new T({
|
|
1252
|
+
key: Ot,
|
|
1212
1253
|
state: {
|
|
1213
1254
|
init() {
|
|
1214
1255
|
return !1;
|
|
@@ -1239,32 +1280,32 @@ const Ht = () => {
|
|
|
1239
1280
|
},
|
|
1240
1281
|
decorations(t) {
|
|
1241
1282
|
if (e.getState(t)) {
|
|
1242
|
-
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, {
|
|
1243
1284
|
side: -1
|
|
1244
|
-
}), c = document.createElement("span"), i =
|
|
1285
|
+
}), c = document.createElement("span"), i = Z.widget(o, c);
|
|
1245
1286
|
return setTimeout(() => {
|
|
1246
1287
|
l.contentEditable = "true", c.contentEditable = "true";
|
|
1247
|
-
}),
|
|
1288
|
+
}), S.create(t.doc, [s, i]);
|
|
1248
1289
|
}
|
|
1249
|
-
return
|
|
1290
|
+
return S.empty;
|
|
1250
1291
|
}
|
|
1251
1292
|
}
|
|
1252
1293
|
});
|
|
1253
1294
|
return e;
|
|
1254
|
-
},
|
|
1255
|
-
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);
|
|
1256
1297
|
for (; t && t.groups; ) {
|
|
1257
1298
|
const { span: r } = t.groups;
|
|
1258
|
-
e = e.replace(
|
|
1299
|
+
e = e.replace(Y, r), t = e.match(Y);
|
|
1259
1300
|
}
|
|
1260
1301
|
return e;
|
|
1261
1302
|
}, Et = (a, e, t) => {
|
|
1262
1303
|
const r = a.split(""), n = r[e];
|
|
1263
1304
|
return r[e] && r[t] && (r[e] = r[t], r[t] = n), r.join("").toString();
|
|
1264
|
-
},
|
|
1305
|
+
}, _t = (a) => (e) => e.replace(vt(a), ""), $t = (a) => (e) => {
|
|
1265
1306
|
const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1), o = /[^\w]|_/;
|
|
1266
1307
|
return n ? r && o.test(r) && o.test(n) ? a.punctuation : a.char : a.punctuation;
|
|
1267
|
-
},
|
|
1308
|
+
}, Pt = (a, e, t) => {
|
|
1268
1309
|
let r = e, n = !1;
|
|
1269
1310
|
return a.descendants((o) => {
|
|
1270
1311
|
var l;
|
|
@@ -1277,7 +1318,7 @@ const Ht = () => {
|
|
|
1277
1318
|
}
|
|
1278
1319
|
r += o.nodeSize;
|
|
1279
1320
|
}), r;
|
|
1280
|
-
},
|
|
1321
|
+
}, Bt = {
|
|
1281
1322
|
placeholderConfig: {
|
|
1282
1323
|
hole: "\u2205",
|
|
1283
1324
|
punctuation: "\u2042",
|
|
@@ -1292,41 +1333,41 @@ const Ht = () => {
|
|
|
1292
1333
|
e = Et(e, r, r + 1), r = r + 1;
|
|
1293
1334
|
return e;
|
|
1294
1335
|
}
|
|
1295
|
-
}, E = Ee(
|
|
1336
|
+
}, E = Ee(Bt, "inlineSyncConfig"), Rt = (a) => {
|
|
1296
1337
|
const { selection: e } = a, { $from: t } = e;
|
|
1297
1338
|
return t.node();
|
|
1298
|
-
},
|
|
1299
|
-
const n = a.get(
|
|
1339
|
+
}, Wt = (a, e, t, r) => {
|
|
1340
|
+
const n = a.get(_e), o = e.schema.topNodeType.create(void 0, [t, ...r]);
|
|
1300
1341
|
return n(o);
|
|
1301
|
-
},
|
|
1342
|
+
}, qt = (a, e) => {
|
|
1302
1343
|
const t = a.get(E), r = t.placeholderConfig.hole, [n = "", ...o] = e.split(`
|
|
1303
1344
|
|
|
1304
1345
|
`), l = (u) => t.movePlaceholder(r, u);
|
|
1305
|
-
let c =
|
|
1306
|
-
const i =
|
|
1346
|
+
let c = Se(_t(r), l, At)(n);
|
|
1347
|
+
const i = $t(t.placeholderConfig)(c);
|
|
1307
1348
|
return c = c.replace(r, i), c = [c, ...o].join(`
|
|
1308
1349
|
|
|
1309
1350
|
`), [c, i];
|
|
1310
|
-
}, qt = (a, e) => {
|
|
1311
|
-
const r = a.get(_e)(e);
|
|
1312
|
-
return r ? r.firstChild : null;
|
|
1313
1351
|
}, Kt = (a, e) => {
|
|
1352
|
+
const r = a.get($e)(e);
|
|
1353
|
+
return r ? r.firstChild : null;
|
|
1354
|
+
}, Ft = (a, e) => {
|
|
1314
1355
|
const { globalNodes: t } = a.get(E), r = [];
|
|
1315
1356
|
return e.doc.descendants((n) => {
|
|
1316
1357
|
if (t.includes(n.type.name) || t.includes(n.type))
|
|
1317
1358
|
return r.push(n), !1;
|
|
1318
1359
|
}), r;
|
|
1319
|
-
},
|
|
1360
|
+
}, jt = (a) => a.split(`
|
|
1320
1361
|
|
|
1321
|
-
`)[0] || "",
|
|
1362
|
+
`)[0] || "", Oe = (a, e) => {
|
|
1322
1363
|
try {
|
|
1323
|
-
const t =
|
|
1364
|
+
const t = Ft(a, e), r = Rt(e), n = Wt(a, e, r, t), [o, l] = qt(a, n), s = Kt(a, o);
|
|
1324
1365
|
return !s || r.type !== s.type ? null : (s.attrs = { ...r.attrs }, s.descendants((c) => {
|
|
1325
1366
|
var f;
|
|
1326
1367
|
const u = c.marks.find((d) => d.type.name === "link");
|
|
1327
1368
|
u && ((f = c.text) == null ? void 0 : f.includes(l)) && u.attrs.href.includes(l) && (u.attrs.href = u.attrs.href.replace(l, ""));
|
|
1328
1369
|
}), {
|
|
1329
|
-
text:
|
|
1370
|
+
text: jt(o),
|
|
1330
1371
|
prevNode: r,
|
|
1331
1372
|
nextNode: s,
|
|
1332
1373
|
placeholder: l
|
|
@@ -1334,112 +1375,112 @@ const Ht = () => {
|
|
|
1334
1375
|
} catch {
|
|
1335
1376
|
return null;
|
|
1336
1377
|
}
|
|
1337
|
-
},
|
|
1378
|
+
}, zt = (a, e, t, r, n) => {
|
|
1338
1379
|
const { placeholderConfig: o } = a.get(E), l = o.hole;
|
|
1339
1380
|
let s = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
|
|
1340
|
-
const c = t.apply(s), i =
|
|
1381
|
+
const c = t.apply(s), i = Oe(a, c);
|
|
1341
1382
|
if (!i)
|
|
1342
1383
|
return;
|
|
1343
|
-
const { $from: u } = c.selection, f = u.before(), d = u.after(), m =
|
|
1344
|
-
s = s.replaceWith(f, d, i.nextNode).setNodeMarkup(f, void 0, n).delete(m + 1, m + 2), s = s.setSelection(
|
|
1345
|
-
},
|
|
1384
|
+
const { $from: u } = c.selection, f = u.before(), d = u.after(), m = Pt(i.nextNode, f, i.placeholder);
|
|
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) => {
|
|
1346
1387
|
let e = null;
|
|
1347
|
-
return new
|
|
1348
|
-
key:
|
|
1388
|
+
return new T({
|
|
1389
|
+
key: J,
|
|
1349
1390
|
state: {
|
|
1350
1391
|
init: () => null,
|
|
1351
1392
|
apply: (r, n, o, l) => {
|
|
1352
1393
|
var p;
|
|
1353
|
-
const s = a.get(
|
|
1354
|
-
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))
|
|
1355
1396
|
return null;
|
|
1356
|
-
const i =
|
|
1397
|
+
const i = Oe(a, l);
|
|
1357
1398
|
if (!i)
|
|
1358
1399
|
return null;
|
|
1359
1400
|
e && (cancelAnimationFrame(e), e = null);
|
|
1360
1401
|
const { prevNode: u, nextNode: f, text: d } = i, { shouldSyncNode: m } = a.get(E);
|
|
1361
1402
|
return m({ prevNode: u, nextNode: f, ctx: a, tr: r, text: d }) && (e = requestAnimationFrame(() => {
|
|
1362
1403
|
e = null;
|
|
1363
|
-
const { dispatch: g, state:
|
|
1364
|
-
|
|
1404
|
+
const { dispatch: g, state: h } = a.get(v);
|
|
1405
|
+
zt(a, J, h, g, u.attrs);
|
|
1365
1406
|
})), null;
|
|
1366
1407
|
}
|
|
1367
1408
|
}
|
|
1368
1409
|
});
|
|
1369
|
-
},
|
|
1370
|
-
|
|
1410
|
+
}, Vt = [
|
|
1411
|
+
ve(() => ({
|
|
1371
1412
|
injectSlices: [E],
|
|
1372
|
-
prosePlugins: (a, e) => [
|
|
1373
|
-
remarkPlugins: () => [
|
|
1413
|
+
prosePlugins: (a, e) => [St(), Ut(e)],
|
|
1414
|
+
remarkPlugins: () => [Ve, Dt, Ct]
|
|
1374
1415
|
}))()
|
|
1375
|
-
],
|
|
1376
|
-
ToggleInlineCode:
|
|
1377
|
-
ToggleItalic:
|
|
1378
|
-
ToggleLink:
|
|
1379
|
-
ToggleBold:
|
|
1380
|
-
ModifyLink:
|
|
1381
|
-
ModifyImage:
|
|
1382
|
-
WrapInBlockquote:
|
|
1383
|
-
WrapInBulletList:
|
|
1384
|
-
WrapInOrderedList:
|
|
1385
|
-
TurnIntoCodeFence:
|
|
1386
|
-
TurnIntoHeading:
|
|
1387
|
-
TurnIntoText:
|
|
1388
|
-
InsertHardbreak:
|
|
1389
|
-
InsertHr:
|
|
1390
|
-
InsertImage:
|
|
1391
|
-
SplitListItem:
|
|
1392
|
-
SinkListItem:
|
|
1393
|
-
LiftListItem:
|
|
1416
|
+
], Gt = we.create([...Lt, ...et]), cr = we.create([...Vt, ...Gt]), ir = {
|
|
1417
|
+
ToggleInlineCode: ee,
|
|
1418
|
+
ToggleItalic: te,
|
|
1419
|
+
ToggleLink: Te,
|
|
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,
|
|
1430
|
+
InsertHr: He,
|
|
1431
|
+
InsertImage: De,
|
|
1432
|
+
SplitListItem: ie,
|
|
1433
|
+
SinkListItem: ue,
|
|
1434
|
+
LiftListItem: de
|
|
1394
1435
|
};
|
|
1395
1436
|
export {
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1437
|
+
ye as DowngradeHeading,
|
|
1438
|
+
ct as HardbreakFilterPluginKey,
|
|
1439
|
+
le as InsertHardbreak,
|
|
1440
|
+
He as InsertHr,
|
|
1441
|
+
De as InsertImage,
|
|
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,
|
|
1451
|
+
Te as ToggleLink,
|
|
1452
|
+
ae as TurnIntoCodeFence,
|
|
1453
|
+
O as TurnIntoHeading,
|
|
1454
|
+
me as TurnIntoText,
|
|
1455
|
+
se as WrapInBlockquote,
|
|
1456
|
+
oe as WrapInBulletList,
|
|
1457
|
+
fe as WrapInOrderedList,
|
|
1458
|
+
st as backtickInputRegex,
|
|
1459
|
+
tt as blockquote,
|
|
1460
|
+
rt as bulletList,
|
|
1461
|
+
at as codeFence,
|
|
1462
|
+
Ye as codeInline,
|
|
1463
|
+
ir as commands,
|
|
1464
|
+
cr as commonmark,
|
|
1465
|
+
Gt as commonmarkNodes,
|
|
1466
|
+
Vt as commonmarkPlugins,
|
|
1467
|
+
lt as doc,
|
|
1468
|
+
Je as em,
|
|
1469
|
+
it as hardbreak,
|
|
1470
|
+
pt as heading,
|
|
1471
|
+
ut as headingHashPluginKey,
|
|
1472
|
+
V as headingIdPluginKey,
|
|
1473
|
+
gt as hr,
|
|
1474
|
+
kt as image,
|
|
1434
1475
|
E as inlineSyncConfigCtx,
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1476
|
+
Xe as link,
|
|
1477
|
+
Nt as listItem,
|
|
1478
|
+
et as marks,
|
|
1479
|
+
Lt as nodes,
|
|
1480
|
+
It as orderedList,
|
|
1481
|
+
bt as paragraph,
|
|
1482
|
+
Ze as strong,
|
|
1483
|
+
wt as text,
|
|
1484
|
+
ot as tildeInputRegex
|
|
1444
1485
|
};
|
|
1445
1486
|
//# sourceMappingURL=index.es.js.map
|