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