@milkdown/preset-commonmark 6.4.0 → 6.4.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["../../src/node/list-item.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,aAAK,IAAI,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAI1G,eAAO,MAAM,aAAa,4CAAgC,CAAC;AAC3D,eAAO,MAAM,YAAY,4CAA+B,CAAC;AACzD,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAkDzD,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["../../src/node/list-item.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,aAAK,IAAI,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAI1G,eAAO,MAAM,aAAa,4CAAgC,CAAC;AAC3D,eAAO,MAAM,YAAY,4CAA+B,CAAC;AACzD,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAkDzD,eAAO,MAAM,QAAQ,sFAyFlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugin/inline-sync/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAiB,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAM1D,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,mBAAmB,gBAAwC,CAAC;AACzE,eAAO,MAAM,mBAAmB,QAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugin/inline-sync/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAiB,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAM1D,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,mBAAmB,gBAAwC,CAAC;AACzE,eAAO,MAAM,mBAAmB,QAAS,GAAG,iBA+C3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/preset-commonmark",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.es.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"commonmark"
|
|
18
18
|
],
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@milkdown/core": "6.4.
|
|
21
|
-
"@milkdown/prose": "6.4.
|
|
20
|
+
"@milkdown/core": "6.4.1",
|
|
21
|
+
"@milkdown/prose": "6.4.1",
|
|
22
22
|
"@types/unist": "^2.0.6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@milkdown/prose": "^6.0.1"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@milkdown/utils": "6.4.
|
|
30
|
-
"@milkdown/exception": "6.4.
|
|
29
|
+
"@milkdown/utils": "6.4.1",
|
|
30
|
+
"@milkdown/exception": "6.4.1",
|
|
31
31
|
"unist-util-visit": "^4.0.0",
|
|
32
32
|
"remark-inline-links": "^6.0.0",
|
|
33
33
|
"tslib": "^2.4.0"
|
package/src/node/list-item.ts
CHANGED
|
@@ -96,7 +96,17 @@ export const listItem = createNode<Keys>((utils) => ({
|
|
|
96
96
|
spread: dom.dataset['spread'],
|
|
97
97
|
};
|
|
98
98
|
},
|
|
99
|
-
contentElement:
|
|
99
|
+
contentElement: (dom) => {
|
|
100
|
+
if (!(dom instanceof HTMLElement)) {
|
|
101
|
+
throw expectDomTypeError(dom);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const body = dom.querySelector<HTMLElement>('.list-item_body');
|
|
105
|
+
if (!body) {
|
|
106
|
+
return dom;
|
|
107
|
+
}
|
|
108
|
+
return body;
|
|
109
|
+
},
|
|
100
110
|
},
|
|
101
111
|
{ tag: 'li' },
|
|
102
112
|
],
|
|
@@ -10,6 +10,7 @@ export * from './config';
|
|
|
10
10
|
|
|
11
11
|
export const inlineSyncPluginKey = new PluginKey('MILKDOWN_INLINE_SYNC');
|
|
12
12
|
export const getInlineSyncPlugin = (ctx: Ctx) => {
|
|
13
|
+
let requestId: number | null = null;
|
|
13
14
|
const inlineSyncPlugin = new Plugin<null>({
|
|
14
15
|
key: inlineSyncPluginKey,
|
|
15
16
|
state: {
|
|
@@ -17,6 +18,9 @@ export const getInlineSyncPlugin = (ctx: Ctx) => {
|
|
|
17
18
|
return null;
|
|
18
19
|
},
|
|
19
20
|
apply: (tr, _value, _oldState, newState) => {
|
|
21
|
+
const view = ctx.get(editorViewCtx);
|
|
22
|
+
if (!view.hasFocus?.() || !view.editable) return null;
|
|
23
|
+
|
|
20
24
|
if (!tr.docChanged) return null;
|
|
21
25
|
|
|
22
26
|
const meta = tr.getMeta(inlineSyncPluginKey);
|
|
@@ -27,13 +31,20 @@ export const getInlineSyncPlugin = (ctx: Ctx) => {
|
|
|
27
31
|
const context = getContextByState(ctx, newState);
|
|
28
32
|
if (!context) return null;
|
|
29
33
|
|
|
34
|
+
if (requestId) {
|
|
35
|
+
cancelAnimationFrame(requestId);
|
|
36
|
+
requestId = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
const { prevNode, nextNode, text } = context;
|
|
31
40
|
|
|
32
41
|
const { shouldSyncNode } = ctx.get(inlineSyncConfigCtx);
|
|
33
42
|
|
|
34
43
|
if (!shouldSyncNode({ prevNode, nextNode, ctx, tr, text })) return null;
|
|
35
44
|
|
|
36
|
-
requestAnimationFrame(() => {
|
|
45
|
+
requestId = requestAnimationFrame(() => {
|
|
46
|
+
requestId = null;
|
|
47
|
+
|
|
37
48
|
const { dispatch, state } = ctx.get(editorViewCtx);
|
|
38
49
|
|
|
39
50
|
runReplacer(ctx, inlineSyncPluginKey, state, dispatch, prevNode.attrs);
|