@milkdown/preset-commonmark 7.3.1 → 7.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/__internal__/serialize-text.d.ts +1 -1
- package/lib/__internal__/serialize-text.d.ts.map +1 -1
- package/lib/__internal__/with-meta.d.ts +1 -1
- package/lib/__internal__/with-meta.d.ts.map +1 -1
- package/lib/composed/plugins.d.ts.map +1 -1
- package/lib/composed/schema.d.ts.map +1 -1
- package/lib/index.es.js +74 -33
- package/lib/index.es.js.map +1 -1
- package/lib/mark/link.d.ts +2 -2
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/node/heading.d.ts +3 -1
- package/lib/node/heading.d.ts.map +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/list-item.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/context.d.ts +1 -1
- package/lib/plugin/inline-sync-plugin/context.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/regexp.d.ts +1 -1
- package/lib/plugin/inline-sync-plugin/regexp.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/replacer.d.ts +1 -1
- package/lib/plugin/inline-sync-plugin/replacer.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/utils.d.ts +6 -6
- package/lib/plugin/inline-sync-plugin/utils.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/__internal__/serialize-text.ts +1 -1
- package/src/__internal__/with-meta.ts +1 -4
- package/src/composed/plugins.ts +2 -1
- package/src/composed/schema.ts +2 -1
- package/src/mark/link.ts +1 -1
- package/src/node/code-block.ts +1 -1
- package/src/node/heading.ts +3 -2
- package/src/node/hr.ts +2 -1
- package/src/node/image.ts +1 -1
- package/src/node/list-item.ts +24 -22
- package/src/plugin/hardbreak-clear-mark-plugin.ts +1 -1
- package/src/plugin/inline-sync-plugin/config.ts +5 -5
- package/src/plugin/inline-sync-plugin/context.ts +7 -7
- package/src/plugin/inline-sync-plugin/regexp.ts +3 -2
- package/src/plugin/inline-sync-plugin/replacer.ts +1 -7
- package/src/plugin/inline-sync-plugin/utils.ts +24 -20
- package/src/plugin/remark-html-transformer.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SerializerState } from '@milkdown/transformer';
|
|
2
2
|
import type { Node } from '@milkdown/prose/model';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function serializeText(state: SerializerState, node: Node): void;
|
|
4
4
|
//# sourceMappingURL=serialize-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-text.d.ts","sourceRoot":"","sources":["../../src/__internal__/serialize-text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAGjD,
|
|
1
|
+
{"version":3,"file":"serialize-text.d.ts","sourceRoot":"","sources":["../../src/__internal__/serialize-text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAGjD,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,QAgB/D"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Meta, MilkdownPlugin } from '@milkdown/ctx';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function withMeta<T extends MilkdownPlugin>(plugin: T, meta: Partial<Meta> & Pick<Meta, 'displayName'>): T;
|
|
3
3
|
//# sourceMappingURL=with-meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-meta.d.ts","sourceRoot":"","sources":["../../src/__internal__/with-meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEzD,
|
|
1
|
+
{"version":3,"file":"with-meta.d.ts","sourceRoot":"","sources":["../../src/__internal__/with-meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEzD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAShH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/composed/plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/composed/plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAkBnD,eAAO,MAAM,OAAO,EAAE,cAAc,EAkB5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/composed/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/composed/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AA+BnD,eAAO,MAAM,MAAM,EAAE,cAAc,EAkD3B,CAAA"}
|
package/lib/index.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import { ReplaceStep as qt, AddMarkStep as Wt } from "@milkdown/prose/transform"
|
|
|
12
12
|
import { Decoration as at, DecorationSet as nt } from "@milkdown/prose/view";
|
|
13
13
|
import { visit as ie } from "unist-util-visit";
|
|
14
14
|
import Ft from "remark-inline-links";
|
|
15
|
-
|
|
15
|
+
function mt(t, e) {
|
|
16
16
|
var o;
|
|
17
17
|
if (!(e.childCount >= 1 && ((o = e.lastChild) == null ? void 0 : o.type.name) === "hardbreak")) {
|
|
18
18
|
t.next(e.content);
|
|
@@ -22,12 +22,16 @@ const mt = (t, e) => {
|
|
|
22
22
|
e.content.forEach((s, i, l) => {
|
|
23
23
|
l !== e.childCount - 1 && a.push(s);
|
|
24
24
|
}), t.next(Dt.fromArray(a));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
}
|
|
26
|
+
function n(t, e) {
|
|
27
|
+
return Object.assign(t, {
|
|
28
|
+
meta: {
|
|
29
|
+
package: "@milkdown/preset-commonmark",
|
|
30
|
+
...e
|
|
31
|
+
}
|
|
32
|
+
}), t;
|
|
33
|
+
}
|
|
34
|
+
const ce = V("emphasis");
|
|
31
35
|
n(ce, {
|
|
32
36
|
displayName: "Attr<emphasis>",
|
|
33
37
|
group: "Emphasis"
|
|
@@ -354,7 +358,11 @@ n(Ce.shortcuts, {
|
|
|
354
358
|
displayName: "Keymap<paragraph>",
|
|
355
359
|
group: "Paragraph"
|
|
356
360
|
});
|
|
357
|
-
const Gt = Array(6).fill(0).map((t, e) => e + 1)
|
|
361
|
+
const Gt = Array(6).fill(0).map((t, e) => e + 1);
|
|
362
|
+
function Vt(t) {
|
|
363
|
+
return Pt(t.textContent);
|
|
364
|
+
}
|
|
365
|
+
const Y = ne(Vt, "headingIdGenerator");
|
|
358
366
|
n(Y, {
|
|
359
367
|
displayName: "Ctx<HeadingIdGenerator>",
|
|
360
368
|
group: "Heading"
|
|
@@ -1155,16 +1163,19 @@ n(Ve, {
|
|
|
1155
1163
|
displayName: "Command<splitListItemCommand>",
|
|
1156
1164
|
group: "ListItem"
|
|
1157
1165
|
});
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1166
|
+
function Ut(t) {
|
|
1167
|
+
return (e, r, a) => {
|
|
1168
|
+
const { selection: o } = e;
|
|
1169
|
+
if (!(o instanceof $))
|
|
1170
|
+
return !1;
|
|
1171
|
+
const { empty: s, $from: i } = o;
|
|
1172
|
+
if (!s || i.parentOffset !== 0)
|
|
1173
|
+
return !1;
|
|
1174
|
+
const l = i.node(-1);
|
|
1175
|
+
return l.type !== M.type(t) || l.firstChild !== i.node() || i.node(-2).childCount > 1 ? !1 : dt(M.type(t))(e, r, a);
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
const je = y("LiftFirstListItem", (t) => () => Ut(t));
|
|
1168
1179
|
n(je, {
|
|
1169
1180
|
displayName: "Command<liftFirstListItemCommand>",
|
|
1170
1181
|
group: "ListItem"
|
|
@@ -1349,20 +1360,36 @@ const Yt = [
|
|
|
1349
1360
|
me,
|
|
1350
1361
|
ke,
|
|
1351
1362
|
ge
|
|
1352
|
-
].flat(), Xt = /\[([^\]]+)]\([^\s\]]+\)/, Q = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)
|
|
1363
|
+
].flat(), Xt = /\[([^\]]+)]\([^\s\]]+\)/, Q = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/;
|
|
1364
|
+
function er(t) {
|
|
1365
|
+
return new RegExp(`\\\\(?=[^\\w\\s${t}\\\\]|_)`, "g");
|
|
1366
|
+
}
|
|
1367
|
+
const Z = "", ee = `${Z}*`, te = `${Z}*`, re = `${Z}_`, ae = `${Z}⎽`;
|
|
1368
|
+
function tr(t) {
|
|
1353
1369
|
let e = t, r = e.match(Q);
|
|
1354
1370
|
for (; r && r.groups; ) {
|
|
1355
1371
|
const { span: a } = r.groups;
|
|
1356
1372
|
e = e.replace(Q, a), r = e.match(Q);
|
|
1357
1373
|
}
|
|
1358
1374
|
return e;
|
|
1359
|
-
}
|
|
1375
|
+
}
|
|
1376
|
+
function rr(t) {
|
|
1377
|
+
return t.replaceAll(/\\\\\*/g, ee).replaceAll(/\\\\_/g, re).replaceAll(ee, te).replaceAll(re, ae);
|
|
1378
|
+
}
|
|
1379
|
+
function ar(t, e, r) {
|
|
1360
1380
|
const a = t.split(""), o = a[e];
|
|
1361
1381
|
return a[e] && a[r] && (a[e] = a[r], a[r] = o), a.join("").toString();
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
return
|
|
1365
|
-
}
|
|
1382
|
+
}
|
|
1383
|
+
function nr(t) {
|
|
1384
|
+
return (e) => e.replace(er(t), "");
|
|
1385
|
+
}
|
|
1386
|
+
function or(t) {
|
|
1387
|
+
return (e) => {
|
|
1388
|
+
const r = e.indexOf(t.hole), a = e.charAt(r - 1), o = e.charAt(r + 1), s = /[^\w]|_/;
|
|
1389
|
+
return o ? a && s.test(a) && s.test(o) ? t.punctuation : t.char : t.punctuation;
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
function sr(t, e, r) {
|
|
1366
1393
|
let a = e, o = !1;
|
|
1367
1394
|
return t.descendants((s) => {
|
|
1368
1395
|
var i;
|
|
@@ -1377,7 +1404,8 @@ const Yt = [
|
|
|
1377
1404
|
}
|
|
1378
1405
|
return a += 1, !0;
|
|
1379
1406
|
}), a;
|
|
1380
|
-
}
|
|
1407
|
+
}
|
|
1408
|
+
const lr = {
|
|
1381
1409
|
placeholderConfig: {
|
|
1382
1410
|
hole: "∅",
|
|
1383
1411
|
punctuation: "⁂",
|
|
@@ -1397,10 +1425,14 @@ n(_, {
|
|
|
1397
1425
|
displayName: "Ctx<inlineSyncConfig>",
|
|
1398
1426
|
group: "Prose"
|
|
1399
1427
|
});
|
|
1400
|
-
|
|
1428
|
+
function ir(t) {
|
|
1429
|
+
return t.selection.$from.node();
|
|
1430
|
+
}
|
|
1431
|
+
function cr(t, e, r, a) {
|
|
1401
1432
|
const o = t.get(Rt), s = e.schema.topNodeType.create(void 0, [r, ...a]);
|
|
1402
1433
|
return o(s);
|
|
1403
|
-
}
|
|
1434
|
+
}
|
|
1435
|
+
function dr(t, e) {
|
|
1404
1436
|
const r = t.get(_.key), a = r.placeholderConfig.hole, [o = "", ...s] = e.split(`
|
|
1405
1437
|
|
|
1406
1438
|
`), i = (m) => r.movePlaceholder(a, m);
|
|
@@ -1409,18 +1441,25 @@ const ir = (t) => t.selection.$from.node(), cr = (t, e, r, a) => {
|
|
|
1409
1441
|
return c = c.replace(a, d), c = [c, ...s].join(`
|
|
1410
1442
|
|
|
1411
1443
|
`), [c, d];
|
|
1412
|
-
}
|
|
1444
|
+
}
|
|
1445
|
+
function mr(t, e) {
|
|
1413
1446
|
const a = t.get(Kt)(e);
|
|
1414
1447
|
return a ? a.firstChild : null;
|
|
1415
|
-
}
|
|
1448
|
+
}
|
|
1449
|
+
function ur(t, e) {
|
|
1416
1450
|
const { globalNodes: r } = t.get(_.key), a = [];
|
|
1417
1451
|
return e.doc.descendants((o) => {
|
|
1418
1452
|
if (r.includes(o.type.name) || r.includes(o.type))
|
|
1419
1453
|
return a.push(o), !1;
|
|
1420
1454
|
}), a;
|
|
1421
|
-
}
|
|
1455
|
+
}
|
|
1456
|
+
const pr = (t) => t.split(`
|
|
1422
1457
|
|
|
1423
|
-
`)[0] || ""
|
|
1458
|
+
`)[0] || "";
|
|
1459
|
+
function gr(t) {
|
|
1460
|
+
return t.childCount === 1 && t.child(0).type.name === "html";
|
|
1461
|
+
}
|
|
1462
|
+
function xt(t, e) {
|
|
1424
1463
|
try {
|
|
1425
1464
|
const r = ur(t, e), a = ir(e), o = cr(t, e, a, r), [s, i] = dr(t, o), l = mr(t, s);
|
|
1426
1465
|
return !l || a.type !== l.type || gr(l) ? null : (l.attrs = { ...a.attrs }, l.descendants((c) => {
|
|
@@ -1436,7 +1475,8 @@ const ir = (t) => t.selection.$from.node(), cr = (t, e, r, a) => {
|
|
|
1436
1475
|
} catch {
|
|
1437
1476
|
return null;
|
|
1438
1477
|
}
|
|
1439
|
-
}
|
|
1478
|
+
}
|
|
1479
|
+
function yr(t, e, r, a, o) {
|
|
1440
1480
|
var L;
|
|
1441
1481
|
const { placeholderConfig: s } = t.get(_.key), i = s.hole;
|
|
1442
1482
|
let l = r.tr.setMeta(e, !0).insertText(i, r.selection.from);
|
|
@@ -1447,7 +1487,8 @@ const ir = (t) => t.selection.$from.node(), cr = (t, e, r, a) => {
|
|
|
1447
1487
|
l = l.replaceWith(u, k, d.nextNode).setNodeMarkup(u, void 0, o).delete(p + 1, p + 2), l = l.setSelection($.near(l.doc.resolve(p + 1))), (Xt.test(m) || ["*", "_", "~"].includes(m.at(-1) || "")) && l.selection instanceof $ && (((L = l.selection.$cursor) == null ? void 0 : L.marks()) ?? []).forEach((J) => {
|
|
1448
1488
|
l = l.removeStoredMark(J.type);
|
|
1449
1489
|
}), a(l);
|
|
1450
|
-
}
|
|
1490
|
+
}
|
|
1491
|
+
const St = O((t) => {
|
|
1451
1492
|
let e = null;
|
|
1452
1493
|
const r = new T("MILKDOWN_INLINE_SYNC");
|
|
1453
1494
|
return new R({
|