@krainovsd/markdown-editor 0.1.2 → 0.2.0
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/cjs/index-CDtGUxs-.js +52 -0
- package/lib/cjs/index-CDtGUxs-.js.map +1 -0
- package/lib/cjs/{index-JTLnXX8Q.js → index-CiorogHq.js} +979 -372
- package/lib/cjs/index-CiorogHq.js.map +1 -0
- package/lib/cjs/index.js +6 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/extensions/init-extensions.js +6 -2
- package/lib/esm/extensions/init-extensions.js.map +1 -1
- package/lib/esm/extensions/listeners/get-focus-event.js +1 -0
- package/lib/esm/extensions/listeners/get-focus-event.js.map +1 -1
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js +2 -2
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/bold/bold-decoration.js +2 -2
- package/lib/esm/extensions/markdown/bold/bold-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/code/code-decoration.js +2 -2
- package/lib/esm/extensions/markdown/code/code-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/header/header-decoration.js +3 -3
- package/lib/esm/extensions/markdown/header/header-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/horizontal/horizontal-decoration.js +2 -2
- package/lib/esm/extensions/markdown/horizontal/horizontal-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/image/image-decoration.js +33 -26
- package/lib/esm/extensions/markdown/image/image-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/image/image-widget.js +82 -74
- package/lib/esm/extensions/markdown/image/image-widget.js.map +1 -1
- package/lib/esm/extensions/markdown/init-markdown.js +5 -2
- package/lib/esm/extensions/markdown/init-markdown.js.map +1 -1
- package/lib/esm/extensions/markdown/italic/italic-decoration.js +7 -7
- package/lib/esm/extensions/markdown/italic/italic-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/auto-link-decoration.js +24 -4
- package/lib/esm/extensions/markdown/link/auto-link-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-decoration.js +25 -5
- package/lib/esm/extensions/markdown/link/link-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-label-decoration.js +3 -2
- package/lib/esm/extensions/markdown/link/link-label-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-widget.js +137 -112
- package/lib/esm/extensions/markdown/link/link-widget.js.map +1 -1
- package/lib/esm/extensions/markdown/list/list-decoration.js +3 -3
- package/lib/esm/extensions/markdown/list/list-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/markdown-decoration.js +89 -44
- package/lib/esm/extensions/markdown/markdown-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/markdown-state.js +29 -0
- package/lib/esm/extensions/markdown/markdown-state.js.map +1 -0
- package/lib/esm/extensions/markdown/mention/mention-decoration.js +2 -2
- package/lib/esm/extensions/markdown/mention/mention-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/strike-through/strike-through-decoration.js +2 -2
- package/lib/esm/extensions/markdown/strike-through/strike-through-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/todo/todo-decoration.js +3 -3
- package/lib/esm/extensions/markdown/todo/todo-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/todo/todo-widget.js +1 -0
- package/lib/esm/extensions/markdown/todo/todo-widget.js.map +1 -1
- package/lib/esm/extensions/settings/init-settings.js +1 -0
- package/lib/esm/extensions/settings/init-settings.js.map +1 -1
- package/lib/esm/index.js +9 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/lib/utils/get-decoration.js +2 -1
- package/lib/esm/lib/utils/get-decoration.js.map +1 -1
- package/lib/esm/module/Editor/Editor.js +4 -0
- package/lib/esm/module/Editor/Editor.js.map +1 -1
- package/lib/esm/module/Editor/lib/init-editor.js +1 -0
- package/lib/esm/module/Editor/lib/init-editor.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/package.json +1 -1
- package/lib/cjs/index-JTLnXX8Q.js.map +0 -1
- package/lib/cjs/index-v4GhIAcy.js +0 -528
- package/lib/cjs/index-v4GhIAcy.js.map +0 -1
- package/lib/esm/lib/utils/tick.js +0 -22
- package/lib/esm/lib/utils/tick.js.map +0 -1
|
@@ -12,12 +12,12 @@ function getItalicDecorations({ decorations, node }) {
|
|
|
12
12
|
range: [node.from, node.to],
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
|
-
function getItalicSelectionDecorations({ decorations, node, view,
|
|
15
|
+
function getItalicSelectionDecorations({ decorations, node, view, forceActive, }) {
|
|
16
16
|
if (node.name !== NAME_OF_ITALIC) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
if (checkIsSeveralEmphasis({ decorations, node, view,
|
|
20
|
-
return void splitEmphasis({ decorations, node, view,
|
|
19
|
+
if (checkIsSeveralEmphasis({ decorations, node, view, forceActive })) {
|
|
20
|
+
return void splitEmphasis({ decorations, node, view, forceActive });
|
|
21
21
|
}
|
|
22
22
|
let step = 1;
|
|
23
23
|
const startText = view.state.doc.sliceString(node.from, node.from + 3);
|
|
@@ -25,7 +25,7 @@ function getItalicSelectionDecorations({ decorations, node, view, isReadonly, })
|
|
|
25
25
|
LIST_OF_ITALIC_MARKS.has(startText.charCodeAt(1)) &&
|
|
26
26
|
LIST_OF_ITALIC_MARKS.has(startText.charCodeAt(2)))
|
|
27
27
|
step = 3;
|
|
28
|
-
if (
|
|
28
|
+
if (forceActive ||
|
|
29
29
|
!view.hasFocus ||
|
|
30
30
|
!isInRange(view.state.selection.ranges, [node.from, node.to])) {
|
|
31
31
|
decorations.push(getHideDecoration({ range: [node.from, node.from + step] }));
|
|
@@ -46,7 +46,7 @@ function checkIsSeveralEmphasis({ node, view }) {
|
|
|
46
46
|
return true;
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
-
function splitEmphasis({ decorations, node, view,
|
|
49
|
+
function splitEmphasis({ decorations, node, view, forceActive }) {
|
|
50
50
|
const text = view.state.doc.sliceString(node.from, node.to);
|
|
51
51
|
let marks = 0;
|
|
52
52
|
let pos = 0;
|
|
@@ -59,13 +59,13 @@ function splitEmphasis({ decorations, node, view, isReadonly }) {
|
|
|
59
59
|
decorations,
|
|
60
60
|
view,
|
|
61
61
|
node: { ...node, name: node.name, from: node.from, to: node.from + pos },
|
|
62
|
-
|
|
62
|
+
forceActive,
|
|
63
63
|
});
|
|
64
64
|
getItalicSelectionDecorations({
|
|
65
65
|
decorations,
|
|
66
66
|
view,
|
|
67
67
|
node: { ...node, name: node.name, from: node.from + pos, to: node.to },
|
|
68
|
-
|
|
68
|
+
forceActive,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
const italicDecorationPlugin = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"italic-decoration.js","sources":["../../../../../src/extensions/markdown/italic/italic-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type {\n DecorationPlugin,\n GetDecorationOptions,\n GetSelectionDecorationOptions,\n} from \"../markdown-types\";\nimport styles from \"../styles.module.scss\";\nimport { LIST_OF_ITALIC_MARKS, NAME_OF_ITALIC } from \"./italic-constants\";\n\nfunction getItalicDecorations({ decorations, node }: GetDecorationOptions) {\n if (node.name !== NAME_OF_ITALIC) {\n return;\n }\n\n decorations.push(\n utils.getMarkDecoration({\n style: styles.italic,\n range: [node.from, node.to],\n }),\n );\n}\n\nfunction getItalicSelectionDecorations({\n decorations,\n node,\n view,\n
|
|
1
|
+
{"version":3,"file":"italic-decoration.js","sources":["../../../../../src/extensions/markdown/italic/italic-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type {\n DecorationPlugin,\n GetDecorationOptions,\n GetSelectionDecorationOptions,\n} from \"../markdown-types\";\nimport styles from \"../styles.module.scss\";\nimport { LIST_OF_ITALIC_MARKS, NAME_OF_ITALIC } from \"./italic-constants\";\n\nfunction getItalicDecorations({ decorations, node }: GetDecorationOptions) {\n if (node.name !== NAME_OF_ITALIC) {\n return;\n }\n\n decorations.push(\n utils.getMarkDecoration({\n style: styles.italic,\n range: [node.from, node.to],\n }),\n );\n}\n\nfunction getItalicSelectionDecorations({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_ITALIC) {\n return;\n }\n\n if (checkIsSeveralEmphasis({ decorations, node, view, forceActive })) {\n return void splitEmphasis({ decorations, node, view, forceActive });\n }\n\n let step = 1;\n const startText = view.state.doc.sliceString(node.from, node.from + 3);\n if (\n LIST_OF_ITALIC_MARKS.has(startText.charCodeAt(0)) &&\n LIST_OF_ITALIC_MARKS.has(startText.charCodeAt(1)) &&\n LIST_OF_ITALIC_MARKS.has(startText.charCodeAt(2))\n )\n step = 3;\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [node.from, node.to])\n ) {\n decorations.push(utils.getHideDecoration({ range: [node.from, node.from + step] }));\n decorations.push(utils.getHideDecoration({ range: [node.to - step, node.to] }));\n }\n}\n\n/** Fixed wide italic + italic */\nfunction checkIsSeveralEmphasis({ node, view }: GetSelectionDecorationOptions) {\n let marks = 0;\n let pos = 0;\n\n const text = view.state.doc.sliceString(node.from, node.to);\n\n while (pos <= text.length) {\n if (LIST_OF_ITALIC_MARKS.has(text.charCodeAt(pos))) marks++;\n pos++;\n }\n\n if (marks === 8) return true;\n\n return false;\n}\n\nfunction splitEmphasis({ decorations, node, view, forceActive }: GetSelectionDecorationOptions) {\n const text = view.state.doc.sliceString(node.from, node.to);\n let marks = 0;\n let pos = 0;\n\n while (pos <= text.length && marks < 6) {\n if (LIST_OF_ITALIC_MARKS.has(text.charCodeAt(pos))) marks++;\n pos++;\n }\n\n getItalicSelectionDecorations({\n decorations,\n view,\n node: { ...node, name: node.name, from: node.from, to: node.from + pos },\n forceActive,\n });\n getItalicSelectionDecorations({\n decorations,\n view,\n node: { ...node, name: node.name, from: node.from + pos, to: node.to },\n forceActive,\n });\n}\n\nexport const italicDecorationPlugin: DecorationPlugin = {\n decorations: [getItalicDecorations],\n selectionDecorations: [getItalicSelectionDecorations],\n};\n"],"names":["utils.getMarkDecoration","utils.isInRange","utils.getHideDecoration"],"mappings":";;;;;AASA,SAAS,oBAAoB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAwB,EAAA;AACvE,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE;QAChC;;AAGF,IAAA,WAAW,CAAC,IAAI,CACdA,iBAAuB,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;AAC5B,KAAA,CAAC,CACH;AACH;AAEA,SAAS,6BAA6B,CAAC,EACrC,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,GACmB,EAAA;AAC9B,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE;QAChC;;AAGF,IAAA,IAAI,sBAAsB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE;AACpE,QAAA,OAAO,KAAK,aAAa,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;;IAGrE,IAAI,IAAI,GAAG,CAAC;IACZ,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IACtE,IACE,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjD,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjD,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAEjD,IAAI,GAAG,CAAC;AAEV,IAAA,IACE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,GAAG,CAAC;IACb,IAAI,GAAG,GAAG,CAAC;IAEX,OAAO,GAAG,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE;QACtC,IAAI,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAAE,YAAA,KAAK,EAAE;AAC3D,QAAA,GAAG,EAAE;;AAGP,IAAA,6BAA6B,CAAC;QAC5B,WAAW;QACX,IAAI;QACJ,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE;QACxE,WAAW;AACZ,KAAA,CAAC;AACF,IAAA,6BAA6B,CAAC;QAC5B,WAAW;QACX,IAAI;QACJ,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;QACtE,WAAW;AACZ,KAAA,CAAC;AACJ;AAEa,MAAA,sBAAsB,GAAqB;IACtD,WAAW,EAAE,CAAC,oBAAoB,CAAC;IACnC,oBAAoB,EAAE,CAAC,6BAA6B,CAAC;;;;;"}
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
-
import { getReplaceDecoration } from '../../../lib/utils/get-decoration.js';
|
|
1
|
+
import { getMarkDecoration, getReplaceDecoration } from '../../../lib/utils/get-decoration.js';
|
|
2
2
|
import { isInRange } from '../../../lib/utils/is-in-range.js';
|
|
3
|
+
import { markdownState } from '../markdown-state.js';
|
|
3
4
|
import { NAME_OF_AUTO_LINK } from './link-constants.js';
|
|
4
5
|
import { LinkWidget } from './link-widget.js';
|
|
5
6
|
|
|
6
|
-
function getAutoLinkSelectionDecorations({ decorations, node, view,
|
|
7
|
+
function getAutoLinkSelectionDecorations({ decorations, node, view, forceActive, }) {
|
|
7
8
|
if (node.name !== NAME_OF_AUTO_LINK)
|
|
8
9
|
return;
|
|
9
10
|
const url = view.state.doc.sliceString(node.from + 1, node.to - 1);
|
|
10
|
-
|
|
11
|
+
const openedLink = view.state.field(markdownState).openedLink;
|
|
12
|
+
const key = `${url}:${url}:${node.from}:${node.to}`;
|
|
13
|
+
const isOpened = openedLink && openedLink === key;
|
|
14
|
+
if (isOpened) {
|
|
15
|
+
return void decorations.push(getMarkDecoration({
|
|
16
|
+
range: [node.from, node.to],
|
|
17
|
+
attributes: {
|
|
18
|
+
"data-id": key,
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
if (forceActive ||
|
|
11
23
|
!view.hasFocus ||
|
|
12
24
|
!isInRange(view.state.selection.ranges, [node.from, node.to])) {
|
|
13
25
|
decorations.push(getReplaceDecoration({
|
|
14
26
|
range: [node.from, node.to],
|
|
15
|
-
widget: new LinkWidget(url, url,
|
|
27
|
+
widget: new LinkWidget(url, url, node.from, node.to, view),
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
decorations.push(getMarkDecoration({
|
|
32
|
+
range: [node.from, node.to],
|
|
33
|
+
attributes: {
|
|
34
|
+
"data-id": key,
|
|
35
|
+
},
|
|
16
36
|
}));
|
|
17
37
|
}
|
|
18
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-link-decoration.js","sources":["../../../../../src/extensions/markdown/link/auto-link-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport { NAME_OF_AUTO_LINK } from \"./link-constants\";\nimport { LinkWidget } from \"./link-widget\";\n\nfunction getAutoLinkSelectionDecorations({\n decorations,\n node,\n view,\n
|
|
1
|
+
{"version":3,"file":"auto-link-decoration.js","sources":["../../../../../src/extensions/markdown/link/auto-link-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport { markdownState } from \"../markdown-state\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport { NAME_OF_AUTO_LINK } from \"./link-constants\";\nimport { LinkWidget } from \"./link-widget\";\n\nfunction getAutoLinkSelectionDecorations({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_AUTO_LINK) return;\n\n const url = view.state.doc.sliceString(node.from + 1, node.to - 1);\n const openedLink = view.state.field(markdownState).openedLink;\n const key = `${url}:${url}:${node.from}:${node.to}`;\n const isOpened = openedLink && openedLink === key;\n\n if (isOpened) {\n return void decorations.push(\n utils.getMarkDecoration({\n range: [node.from, node.to],\n attributes: {\n \"data-id\": key,\n },\n }),\n );\n }\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [node.from, node.to])\n ) {\n decorations.push(\n utils.getReplaceDecoration({\n range: [node.from, node.to],\n widget: new LinkWidget(url, url, node.from, node.to, view),\n }),\n );\n } else {\n decorations.push(\n utils.getMarkDecoration({\n range: [node.from, node.to],\n attributes: {\n \"data-id\": key,\n },\n }),\n );\n }\n}\n\nexport const autoLinkDecorationPlugin: DecorationPlugin = {\n selectionDecorations: [getAutoLinkSelectionDecorations],\n};\n"],"names":["utils.getMarkDecoration","utils.isInRange","utils.getReplaceDecoration"],"mappings":";;;;;;AAMA,SAAS,+BAA+B,CAAC,EACvC,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,GACmB,EAAA;AAC9B,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB;QAAE;IAErC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAClE,IAAA,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,a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
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { getReplaceDecoration } from '../../../lib/utils/get-decoration.js';
|
|
1
|
+
import { getMarkDecoration, getReplaceDecoration } from '../../../lib/utils/get-decoration.js';
|
|
2
2
|
import { isInRange } from '../../../lib/utils/is-in-range.js';
|
|
3
|
+
import { markdownState } from '../markdown-state.js';
|
|
3
4
|
import { NAME_OF_LINK, CODE_OF_START_LINK_TEXT, CODE_OF_START_LINK_URL, CODE_OF_END_LINK_TEXT, CODE_OF_END_LINK_URL } from './link-constants.js';
|
|
4
5
|
import { getLinkLabelSelectionDecoration } from './link-label-decoration.js';
|
|
5
6
|
import { LinkWidget } from './link-widget.js';
|
|
6
7
|
|
|
7
|
-
function getLinkSelectionDecorations({ decorations, node, view,
|
|
8
|
+
function getLinkSelectionDecorations({ decorations, node, view, forceActive, }) {
|
|
8
9
|
if (node.name !== NAME_OF_LINK) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
@@ -31,15 +32,34 @@ function getLinkSelectionDecorations({ decorations, node, view, isReadonly, }) {
|
|
|
31
32
|
urlCoordinates.to = pos;
|
|
32
33
|
}
|
|
33
34
|
if (urlCoordinates.from === -1 || urlCoordinates.to === -1)
|
|
34
|
-
return void getLinkLabelSelectionDecoration({ decorations,
|
|
35
|
+
return void getLinkLabelSelectionDecoration({ decorations, forceActive, node, view });
|
|
35
36
|
const text = content.substring(textCoordinates.from, textCoordinates.to);
|
|
36
37
|
const url = content.substring(urlCoordinates.from, urlCoordinates.to);
|
|
37
|
-
|
|
38
|
+
const openedLink = view.state.field(markdownState).openedLink;
|
|
39
|
+
const key = `${url}:${text}:${node.from}:${node.to}`;
|
|
40
|
+
const isOpened = openedLink && openedLink === key;
|
|
41
|
+
if (isOpened) {
|
|
42
|
+
return void decorations.push(getMarkDecoration({
|
|
43
|
+
range: [node.from, node.to],
|
|
44
|
+
attributes: {
|
|
45
|
+
"data-id": key,
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
if (forceActive ||
|
|
38
50
|
!view.hasFocus ||
|
|
39
51
|
!isInRange(view.state.selection.ranges, [node.from, node.to])) {
|
|
40
52
|
decorations.push(getReplaceDecoration({
|
|
41
53
|
range: [node.from, node.to],
|
|
42
|
-
widget: new LinkWidget(text, url,
|
|
54
|
+
widget: new LinkWidget(text, url, node.from, node.to, view),
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
decorations.push(getMarkDecoration({
|
|
59
|
+
range: [node.from, node.to],
|
|
60
|
+
attributes: {
|
|
61
|
+
"data-id": key,
|
|
62
|
+
},
|
|
43
63
|
}));
|
|
44
64
|
}
|
|
45
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-decoration.js","sources":["../../../../../src/extensions/markdown/link/link-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport {\n CODE_OF_END_LINK_TEXT,\n CODE_OF_END_LINK_URL,\n CODE_OF_START_LINK_TEXT,\n CODE_OF_START_LINK_URL,\n NAME_OF_LINK,\n} from \"./link-constants\";\nimport { getLinkLabelSelectionDecoration } from \"./link-label-decoration\";\nimport { LinkWidget } from \"./link-widget\";\n\nfunction getLinkSelectionDecorations({\n decorations,\n node,\n view,\n
|
|
1
|
+
{"version":3,"file":"link-decoration.js","sources":["../../../../../src/extensions/markdown/link/link-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport { markdownState } from \"../markdown-state\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport {\n CODE_OF_END_LINK_TEXT,\n CODE_OF_END_LINK_URL,\n CODE_OF_START_LINK_TEXT,\n CODE_OF_START_LINK_URL,\n NAME_OF_LINK,\n} from \"./link-constants\";\nimport { getLinkLabelSelectionDecoration } from \"./link-label-decoration\";\nimport { LinkWidget } from \"./link-widget\";\n\nfunction getLinkSelectionDecorations({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_LINK) {\n return;\n }\n\n const content = view.state.doc.sliceString(node.from, node.to);\n const textCoordinates = { from: -1, to: -1 };\n const urlCoordinates = { from: -1, to: -1 };\n let pos = -1;\n\n while (pos < content.length) {\n pos++;\n const code = content.charCodeAt(pos);\n\n if (textCoordinates.from === -1 && code === CODE_OF_START_LINK_TEXT)\n textCoordinates.from = pos + 1;\n else if (\n urlCoordinates.from === -1 &&\n textCoordinates.to !== -1 &&\n code === CODE_OF_START_LINK_URL\n )\n urlCoordinates.from = pos + 1;\n else if (\n textCoordinates.from !== -1 &&\n textCoordinates.to === -1 &&\n code === CODE_OF_END_LINK_TEXT\n )\n textCoordinates.to = pos;\n else if (\n urlCoordinates.from !== -1 &&\n urlCoordinates.to === -1 &&\n code === CODE_OF_END_LINK_URL\n )\n urlCoordinates.to = pos;\n }\n\n if (urlCoordinates.from === -1 || urlCoordinates.to === -1)\n return void getLinkLabelSelectionDecoration({ decorations, forceActive, node, view });\n\n const text = content.substring(textCoordinates.from, textCoordinates.to);\n const url = content.substring(urlCoordinates.from, urlCoordinates.to);\n\n const openedLink = view.state.field(markdownState).openedLink;\n const key = `${url}:${text}:${node.from}:${node.to}`;\n const isOpened = openedLink && openedLink === key;\n\n if (isOpened) {\n return void decorations.push(\n utils.getMarkDecoration({\n range: [node.from, node.to],\n attributes: {\n \"data-id\": key,\n },\n }),\n );\n }\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [node.from, node.to])\n ) {\n decorations.push(\n utils.getReplaceDecoration({\n range: [node.from, node.to],\n widget: new LinkWidget(text, url, node.from, node.to, view),\n }),\n );\n } else {\n decorations.push(\n utils.getMarkDecoration({\n range: [node.from, node.to],\n attributes: {\n \"data-id\": key,\n },\n }),\n );\n }\n}\n\nexport const linkDecorationPlugin: DecorationPlugin = {\n selectionDecorations: [getLinkSelectionDecorations],\n};\n"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IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,EACnE;AACA,QAAA,WAAW,CAAC,IAAI,CACdC,oBAA0B,CAAC;YACzB,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;AAC3B,YAAA,MAAM,EAAE,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC;AAC5D,SAAA,CAAC,CACH;;SACI;AACL,QAAA,WAAW,CAAC,IAAI,CACdF,iBAAuB,CAAC;YACtB,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;AAC3B,YAAA,UAAU,EAAE;AACV,gBAAA,SAAS,EAAE,GAAG;AACf,aAAA;AACF,SAAA,CAAC,CACH;;AAEL;AAEa,MAAA,oBAAoB,GAAqB;IACpD,oBAAoB,EAAE,CAAC,2BAA2B,CAAC;;;;;"}
|
|
@@ -3,10 +3,11 @@ import { isInRange } from '../../../lib/utils/is-in-range.js';
|
|
|
3
3
|
import styles from '../styles.module.scss.js';
|
|
4
4
|
import { CODE_OF_LINK_LABEL_END } from './link-constants.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// [label]:
|
|
7
|
+
function getLinkLabelSelectionDecoration({ decorations, node, view, forceActive, }) {
|
|
7
8
|
if (view.state.doc.sliceString(node.to, node.to + 1).charCodeAt(0) !== CODE_OF_LINK_LABEL_END)
|
|
8
9
|
return;
|
|
9
|
-
if (
|
|
10
|
+
if (forceActive ||
|
|
10
11
|
!view.hasFocus ||
|
|
11
12
|
!isInRange(view.state.selection.ranges, [node.from, node.to + 1])) {
|
|
12
13
|
decorations.push(getMarkDecoration({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-label-decoration.js","sources":["../../../../../src/extensions/markdown/link/link-label-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport { type GetSelectionDecorationOptions } from \"../markdown-types\";\nimport styles from \"../styles.module.scss\";\nimport { CODE_OF_LINK_LABEL_END } from \"./link-constants\";\n\nexport function getLinkLabelSelectionDecoration({\n decorations,\n node,\n view,\n
|
|
1
|
+
{"version":3,"file":"link-label-decoration.js","sources":["../../../../../src/extensions/markdown/link/link-label-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport { type GetSelectionDecorationOptions } from \"../markdown-types\";\nimport styles from \"../styles.module.scss\";\nimport { CODE_OF_LINK_LABEL_END } from \"./link-constants\";\n\n// [label]:\n\nexport function getLinkLabelSelectionDecoration({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (view.state.doc.sliceString(node.to, node.to + 1).charCodeAt(0) !== CODE_OF_LINK_LABEL_END)\n return;\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [node.from, node.to + 1])\n ) {\n decorations.push(\n utils.getMarkDecoration({\n range: [node.from, node.to + 1],\n style: styles.link__label,\n }),\n );\n decorations.push(utils.getHideDecoration({ range: [node.from, node.from + 1] }));\n decorations.push(utils.getHideDecoration({ range: [node.to - 1, node.to + 1] }));\n }\n}\n"],"names":["utils.isInRange","utils.getMarkDecoration","utils.getHideDecoration"],"mappings":";;;;;AAKA;AAEM,SAAU,+BAA+B,CAAC,EAC9C,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,GACmB,EAAA;IAC9B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,sBAAsB;QAC3F;AAEF,IAAA,IACE,WAAW;QACX,CAAC,IAAI,CAAC,QAAQ;QACd,CAACA,SAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EACvE;AACA,QAAA,WAAW,CAAC,IAAI,CACdC,iBAAuB,CAAC;YACtB,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC,WAAW;AAC1B,SAAA,CAAC,CACH;QACD,WAAW,CAAC,IAAI,CAACC,iBAAuB,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAChF,WAAW,CAAC,IAAI,CAACA,iBAAuB,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;;AAEpF;;;;"}
|
|
@@ -3,142 +3,167 @@ import '../../compartments/index.js';
|
|
|
3
3
|
import '@codemirror/language';
|
|
4
4
|
import '@lezer/highlight';
|
|
5
5
|
import { CLASSES } from '../../theme/theme-constants.js';
|
|
6
|
-
import {
|
|
6
|
+
import { saveDispatch } from '../../../lib/utils/save-dispatch.js';
|
|
7
|
+
import { openedLinkEffect } from '../markdown-state.js';
|
|
7
8
|
import styles from '../styles.module.scss.js';
|
|
8
9
|
|
|
10
|
+
const LINK_NODES = {};
|
|
9
11
|
class LinkWidget extends WidgetType {
|
|
10
12
|
text;
|
|
11
13
|
link;
|
|
12
|
-
|
|
14
|
+
from;
|
|
15
|
+
to;
|
|
13
16
|
view;
|
|
14
|
-
constructor(text, link,
|
|
17
|
+
constructor(text, link, from, to, view) {
|
|
15
18
|
super();
|
|
16
19
|
this.text = text;
|
|
17
20
|
this.link = link;
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
getTextNode(line) {
|
|
22
|
-
if (!line)
|
|
23
|
-
return null;
|
|
24
|
-
let textNode = null;
|
|
25
|
-
for (const node of Array.from(line.childNodes)) {
|
|
26
|
-
if (node.nodeType !== 3) {
|
|
27
|
-
const innerNode = this.getTextNode(node);
|
|
28
|
-
if (innerNode) {
|
|
29
|
-
textNode = innerNode;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const textContent = node.textContent;
|
|
35
|
-
if (textContent && textContent.includes(this.link)) {
|
|
36
|
-
textNode = node;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return textNode;
|
|
21
|
+
this.from = from;
|
|
22
|
+
this.to = to;
|
|
23
|
+
this.view = view;
|
|
41
24
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (this.type === "link")
|
|
45
|
-
startPosition = 3 + this.text.length;
|
|
46
|
-
if (this.type === "auto")
|
|
47
|
-
startPosition = 1;
|
|
48
|
-
const endPosition = startPosition + this.link.length;
|
|
49
|
-
return endPosition;
|
|
25
|
+
get key() {
|
|
26
|
+
return `${this.link}:${this.text}:${this.from}:${this.to}`;
|
|
50
27
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!
|
|
28
|
+
eq(widget) {
|
|
29
|
+
const anchor = LINK_NODES[this.key];
|
|
30
|
+
if (!anchor)
|
|
54
31
|
return false;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
32
|
+
delete LINK_NODES[this.key];
|
|
33
|
+
if (anchor.href !== widget.link)
|
|
34
|
+
anchor.href = widget.link;
|
|
35
|
+
if (anchor.textContent !== widget.text)
|
|
36
|
+
anchor.textContent = widget.text;
|
|
37
|
+
this.link = widget.link;
|
|
38
|
+
this.text = widget.text;
|
|
39
|
+
this.from = widget.from;
|
|
40
|
+
this.to = widget.to;
|
|
41
|
+
this.registerListeners(anchor);
|
|
42
|
+
LINK_NODES[this.key] = anchor;
|
|
43
|
+
return true;
|
|
58
44
|
}
|
|
59
|
-
|
|
60
|
-
const startPosition = node.textContent?.indexOf?.(this.link) || 0;
|
|
61
|
-
const endPosition = startPosition + this.link.length;
|
|
62
|
-
const range = document.createRange();
|
|
63
|
-
range.setStart(node, startPosition);
|
|
64
|
-
range.setEnd(node, endPosition);
|
|
65
|
-
selection.removeAllRanges();
|
|
66
|
-
selection.addRange(range);
|
|
67
|
-
}
|
|
68
|
-
handleClick(event) {
|
|
69
|
-
if (!this.view)
|
|
70
|
-
return;
|
|
71
|
-
/** open the link if has special key or the view is readonly */
|
|
72
|
-
const contentEditable = this.view.contentDOM.getAttribute("contenteditable");
|
|
73
|
-
const isReadonly = !contentEditable || contentEditable === "false";
|
|
74
|
-
if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey || isReadonly) {
|
|
75
|
-
if (event.type === "mousedown") {
|
|
76
|
-
const target = event.target;
|
|
77
|
-
window.open(target.href, "_blank");
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
event.stopPropagation();
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
const target = event.target;
|
|
84
|
-
const parent = target.parentNode;
|
|
85
|
-
let line = parent;
|
|
86
|
-
/** recursively find line that contains link */
|
|
87
|
-
while (line && !line.classList.contains("cm-line")) {
|
|
88
|
-
line = line.parentNode;
|
|
89
|
-
}
|
|
90
|
-
const editor = this.view.dom.querySelector(".cm-content");
|
|
91
|
-
const selection = window.getSelection();
|
|
92
|
-
if (!selection || !editor || !parent)
|
|
93
|
-
return;
|
|
94
|
-
const range = document.createRange();
|
|
95
|
-
range.selectNode(target);
|
|
96
|
-
range.collapse(true);
|
|
97
|
-
selection.removeAllRanges();
|
|
98
|
-
selection.addRange(range);
|
|
99
|
-
/** trick for correct select the link by click when the view is not focused */
|
|
100
|
-
void tick({ delay: 0 }).then(() => {
|
|
101
|
-
if (selection && selection.anchorNode?.nodeType !== 3) {
|
|
102
|
-
selection.removeAllRanges();
|
|
103
|
-
selection.addRange(range);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
/** wait for the widget to disappear and link will be visible */
|
|
107
|
-
void tick({
|
|
108
|
-
delay: 0,
|
|
109
|
-
maxDeep: 5,
|
|
110
|
-
delayGetter: (deep) => {
|
|
111
|
-
return deep > 1 ? 10 : 5;
|
|
112
|
-
},
|
|
113
|
-
recursiveCondition: () => {
|
|
114
|
-
const textNode = this.getTextNode(line);
|
|
115
|
-
return this.isCorrectNode(textNode);
|
|
116
|
-
},
|
|
117
|
-
})
|
|
118
|
-
.then(() => {
|
|
119
|
-
const textNode = this.getTextNode(line);
|
|
120
|
-
if (this.isCorrectNode(textNode))
|
|
121
|
-
this.selectLink(textNode, selection);
|
|
122
|
-
});
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
toDOM(view) {
|
|
126
|
-
this.view = view;
|
|
45
|
+
toDOM() {
|
|
127
46
|
const anchor = document.createElement("a");
|
|
128
47
|
anchor.classList.add(styles.link);
|
|
129
48
|
anchor.classList.add(CLASSES.link);
|
|
130
49
|
anchor.target = "_blank";
|
|
131
50
|
anchor.textContent = this.text;
|
|
132
51
|
anchor.href = this.link;
|
|
133
|
-
|
|
134
|
-
|
|
52
|
+
this.registerListeners(anchor);
|
|
53
|
+
LINK_NODES[this.key] = anchor;
|
|
135
54
|
return anchor;
|
|
136
55
|
}
|
|
137
56
|
destroy(dom) {
|
|
138
|
-
|
|
139
|
-
dom.
|
|
57
|
+
delete LINK_NODES[this.key];
|
|
58
|
+
dom.destroy?.();
|
|
59
|
+
}
|
|
60
|
+
registerListeners(anchor) {
|
|
61
|
+
anchor.clearListeners?.();
|
|
62
|
+
const abortController = new AbortController();
|
|
63
|
+
anchor.addEventListener("mousedown", (event) => handleClick(this.view, this.text, this.link, this.key, event), { signal: abortController.signal });
|
|
64
|
+
anchor.addEventListener("click", (e) => e.preventDefault(), { signal: abortController.signal });
|
|
65
|
+
anchor.clearListeners = () => {
|
|
66
|
+
abortController.abort();
|
|
67
|
+
};
|
|
68
|
+
anchor.destroy = () => {
|
|
69
|
+
anchor.clearListeners?.();
|
|
70
|
+
anchor.remove();
|
|
71
|
+
};
|
|
140
72
|
}
|
|
141
73
|
}
|
|
74
|
+
/** recursively find the link text node in line */
|
|
75
|
+
function getTextNode(text, link, key, line) {
|
|
76
|
+
if (!line)
|
|
77
|
+
return null;
|
|
78
|
+
const textNodeContainer = getTextNodeContainer(text, link, key, line);
|
|
79
|
+
if (!textNodeContainer)
|
|
80
|
+
return null;
|
|
81
|
+
for (const node of Array.from(textNodeContainer.childNodes)) {
|
|
82
|
+
if (isCorrectNode(text, link, node)) {
|
|
83
|
+
return node;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
function getTextNodeContainer(text, link, key, line) {
|
|
89
|
+
if (!line)
|
|
90
|
+
return null;
|
|
91
|
+
for (const node of Array.from(line.childNodes)) {
|
|
92
|
+
if (node instanceof HTMLElement && node.getAttribute("data-id") === key) {
|
|
93
|
+
return node;
|
|
94
|
+
}
|
|
95
|
+
if (node.nodeType !== 3) {
|
|
96
|
+
const inner = getTextNodeContainer(text, link, key, node);
|
|
97
|
+
if (inner)
|
|
98
|
+
return inner;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
function isCorrectNode(text, link, node) {
|
|
104
|
+
if (!node)
|
|
105
|
+
return false;
|
|
106
|
+
const textContent = node?.textContent;
|
|
107
|
+
return Boolean(node &&
|
|
108
|
+
textContent &&
|
|
109
|
+
node.nodeType === 3 &&
|
|
110
|
+
textContent.includes(link) &&
|
|
111
|
+
textContent.includes(text));
|
|
112
|
+
}
|
|
113
|
+
function selectLink({ link, node, selection, start }) {
|
|
114
|
+
const startPosition = start ?? (node.textContent?.indexOf?.(link) || 0);
|
|
115
|
+
const endPosition = startPosition + link.length;
|
|
116
|
+
const range = document.createRange();
|
|
117
|
+
range.setStart(node, startPosition);
|
|
118
|
+
range.setEnd(node, endPosition);
|
|
119
|
+
selection.removeAllRanges();
|
|
120
|
+
selection.addRange(range);
|
|
121
|
+
}
|
|
122
|
+
function handleClick(view, text, link, key, event) {
|
|
123
|
+
/** open the link if has special key or the view is readonly */
|
|
124
|
+
const contentEditable = view.contentDOM.getAttribute("contenteditable");
|
|
125
|
+
const forceActive = !contentEditable || contentEditable === "false";
|
|
126
|
+
if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey || forceActive) {
|
|
127
|
+
if (event.type === "mousedown") {
|
|
128
|
+
const target = event.target;
|
|
129
|
+
window.open(target.href, "_blank");
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
event.stopPropagation();
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
const target = event.target;
|
|
136
|
+
const parent = target.parentNode;
|
|
137
|
+
let line = parent;
|
|
138
|
+
/** recursively find line that contains link */
|
|
139
|
+
while (line && !line.classList.contains("cm-line")) {
|
|
140
|
+
line = line.parentNode;
|
|
141
|
+
}
|
|
142
|
+
const editor = Array.from(document.querySelectorAll(".cm-editor")).find((element) => element.contains(target));
|
|
143
|
+
const selection = window.getSelection();
|
|
144
|
+
if (!selection || !editor || !parent)
|
|
145
|
+
return;
|
|
146
|
+
const textNode = getTextNode(text, link, key, line);
|
|
147
|
+
if (textNode) {
|
|
148
|
+
return void selectLink({ selection, link, node: textNode });
|
|
149
|
+
}
|
|
150
|
+
saveDispatch(() => {
|
|
151
|
+
if (!view)
|
|
152
|
+
return;
|
|
153
|
+
view.dispatch(view.state.update({ effects: openedLinkEffect.of(key) }));
|
|
154
|
+
const textNode = getTextNode(text, link, key, line);
|
|
155
|
+
if (textNode) {
|
|
156
|
+
selectLink({ selection, link, node: textNode });
|
|
157
|
+
}
|
|
158
|
+
requestAnimationFrame(() => {
|
|
159
|
+
saveDispatch(() => {
|
|
160
|
+
if (view)
|
|
161
|
+
view.dispatch(view.state.update({ effects: openedLinkEffect.of(undefined) }));
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
142
167
|
|
|
143
168
|
export { LinkWidget };
|
|
144
169
|
//# sourceMappingURL=link-widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-widget.js","sources":["../../../../../src/extensions/markdown/link/link-widget.ts"],"sourcesContent":["import { type EditorView, WidgetType } from \"@codemirror/view\";\nimport { CLASSES } from \"@/extensions/theme\";\nimport { utils } from \"@/lib\";\nimport styles from \"../styles.module.scss\";\n\nexport class LinkWidget extends WidgetType {\n view: EditorView | undefined;\n\n constructor(\n private readonly text: string,\n private readonly link: string,\n private readonly type: \"link\" | \"auto\",\n ) {\n super();\n }\n\n /** recursively find the link text node in line */\n getTextNode(line: ChildNode | Node | null | undefined): ChildNode | null {\n if (!line) return null;\n\n let textNode: ChildNode | null = null;\n\n for (const node of Array.from(line.childNodes)) {\n if (node.nodeType !== 3) {\n const innerNode = this.getTextNode(node);\n if (innerNode) {\n textNode = innerNode;\n break;\n }\n\n continue;\n }\n\n const textContent = node.textContent;\n if (textContent && textContent.includes(this.link)) {\n textNode = node;\n break;\n }\n }\n\n return textNode;\n }\n\n getMinLength() {\n let startPosition: number = 0;\n if (this.type === \"link\") startPosition = 3 + this.text.length;\n if (this.type === \"auto\") startPosition = 1;\n const endPosition = startPosition + this.link.length;\n\n return endPosition;\n }\n\n /** check that the text node is correct node */\n isCorrectNode(node: ChildNode | Node | null | undefined): node is ChildNode | Node {\n if (!node) return false;\n\n const textContent = node.textContent;\n const minLength = this.getMinLength();\n\n return Boolean(textContent && node.nodeType === 3 && textContent.length >= minLength);\n }\n\n selectLink(node: ChildNode | Node, selection: Selection) {\n const startPosition = node.textContent?.indexOf?.(this.link) || 0;\n const endPosition = startPosition + this.link.length;\n\n const range = document.createRange();\n range.setStart(node, startPosition);\n range.setEnd(node, endPosition);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n\n handleClick(event: MouseEvent) {\n if (!this.view) return;\n\n /** open the link if has special key or the view is readonly */\n const contentEditable = this.view.contentDOM.getAttribute(\"contenteditable\");\n const isReadonly = !contentEditable || contentEditable === \"false\";\n if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey || isReadonly) {\n if (event.type === \"mousedown\") {\n const target = event.target as HTMLAnchorElement;\n window.open(target.href, \"_blank\");\n }\n\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n const target = event.target as HTMLAnchorElement;\n const parent = target.parentNode;\n let line: HTMLElement | null = parent as HTMLElement | null;\n\n /** recursively find line that contains link */\n while (line && !line.classList.contains(\"cm-line\")) {\n line = line.parentNode as HTMLElement | null;\n }\n\n const editor = this.view.dom.querySelector(\".cm-content\");\n const selection = window.getSelection();\n\n if (!selection || !editor || !parent) return;\n\n const range = document.createRange();\n range.selectNode(target);\n range.collapse(true);\n\n selection.removeAllRanges();\n selection.addRange(range);\n\n /** trick for correct select the link by click when the view is not focused */\n void utils.tick({ delay: 0 }).then(() => {\n if (selection && selection.anchorNode?.nodeType !== 3) {\n selection.removeAllRanges();\n selection.addRange(range);\n }\n });\n\n /** wait for the widget to disappear and link will be visible */\n void utils\n .tick({\n delay: 0,\n maxDeep: 5,\n delayGetter: (deep) => {\n return deep > 1 ? 10 : 5;\n },\n recursiveCondition: () => {\n const textNode = this.getTextNode(line);\n\n return this.isCorrectNode(textNode);\n },\n })\n .then(() => {\n const textNode = this.getTextNode(line);\n\n if (this.isCorrectNode(textNode)) this.selectLink(textNode, selection);\n });\n\n return false;\n }\n\n toDOM(view: EditorView): HTMLElement {\n this.view = view;\n const anchor = document.createElement(\"a\");\n anchor.classList.add(styles.link);\n anchor.classList.add(CLASSES.link);\n\n anchor.target = \"_blank\";\n anchor.textContent = this.text;\n anchor.href = this.link;\n\n anchor.addEventListener(\"mousedown\", this.handleClick.bind(this));\n anchor.addEventListener(\"click\", this.handleClick.bind(this));\n\n return anchor;\n }\n\n destroy(dom: HTMLElement): void {\n dom.removeEventListener(\"mousedown\", this.handleClick.bind(this));\n dom.removeEventListener(\"click\",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AA,OAAO,MAAM;;AAGf,IAAA,OAAO,CAAC,GAAgB,EAAA;AACtB,QAAA,GAAG,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjE,QAAA,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;AAEhE;;;;"}
|
|
1
|
+
{"version":3,"file":"link-widget.js","sources":["../../../../../src/extensions/markdown/link/link-widget.ts"],"sourcesContent":["import { type EditorView, WidgetType } from \"@codemirror/view\";\nimport { CLASSES } from \"@/extensions/theme\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { openedLinkEffect } from \"../markdown-state\";\nimport styles from \"../styles.module.scss\";\n\nconst LINK_NODES: Record<string, AnchorElement | undefined> = {};\n\ninterface AnchorElement extends HTMLAnchorElement {\n clearListeners?: () => void;\n destroy?: () => void;\n}\nexport class LinkWidget extends WidgetType {\n constructor(\n private text: string,\n private link: string,\n private from: number,\n private to: number,\n private view: EditorView,\n ) {\n super();\n }\n\n get key() {\n return `${this.link}:${this.text}:${this.from}:${this.to}`;\n }\n\n eq(widget: LinkWidget): boolean {\n const anchor = LINK_NODES[this.key];\n if (!anchor) return false;\n delete LINK_NODES[this.key];\n\n if (anchor.href !== widget.link) anchor.href = widget.link;\n if (anchor.textContent !== widget.text) anchor.textContent = widget.text;\n\n this.link = widget.link;\n this.text = widget.text;\n this.from = widget.from;\n this.to = widget.to;\n\n this.registerListeners(anchor);\n LINK_NODES[this.key] = anchor;\n\n return true;\n }\n\n toDOM(): HTMLElement {\n const anchor = document.createElement(\"a\") as AnchorElement;\n anchor.classList.add(styles.link);\n anchor.classList.add(CLASSES.link);\n\n anchor.target = \"_blank\";\n anchor.textContent = this.text;\n anchor.href = this.link;\n\n this.registerListeners(anchor);\n\n LINK_NODES[this.key] = anchor;\n\n return anchor;\n }\n\n destroy(dom: AnchorElement): void {\n delete LINK_NODES[this.key];\n dom.destroy?.();\n }\n\n registerListeners(anchor: AnchorElement) {\n anchor.clearListeners?.();\n const abortController = new AbortController();\n anchor.addEventListener(\n \"mousedown\",\n (event) => handleClick(this.view, this.text, this.link, this.key, event),\n { signal: abortController.signal },\n );\n anchor.addEventListener(\"click\", (e) => e.preventDefault(), { signal: abortController.signal });\n anchor.clearListeners = () => {\n abortController.abort();\n };\n anchor.destroy = () => {\n anchor.clearListeners?.();\n anchor.remove();\n };\n }\n}\n\n/** recursively find the link text node in line */\nfunction getTextNode(\n text: string,\n link: string,\n key: string,\n line: ChildNode | Node | null | undefined,\n): ChildNode | null {\n if (!line) return null;\n const textNodeContainer = getTextNodeContainer(text, link, key, line);\n if (!textNodeContainer) return null;\n\n for (const node of Array.from(textNodeContainer.childNodes)) {\n if (isCorrectNode(text, link, node)) {\n return node;\n }\n }\n\n return null;\n}\n\nfunction getTextNodeContainer(\n text: string,\n link: string,\n key: string,\n line: ChildNode | Node | null | undefined,\n): HTMLElement | null {\n if (!line) return null;\n\n for (const node of Array.from(line.childNodes)) {\n if (node instanceof HTMLElement && node.getAttribute(\"data-id\") === key) {\n return node;\n }\n\n if (node.nodeType !== 3) {\n const inner = getTextNodeContainer(text, link, key, node);\n if (inner) return inner;\n }\n }\n\n return null;\n}\n\nfunction isCorrectNode(\n text: string,\n link: string,\n node: ChildNode | Node | null | undefined,\n): node is ChildNode | Node {\n if (!node) return false;\n\n const textContent = node?.textContent;\n\n return Boolean(\n node &&\n textContent &&\n node.nodeType === 3 &&\n textContent.includes(link) &&\n textContent.includes(text),\n );\n}\n\ntype SelectLinkOptions = {\n node: ChildNode | Node;\n selection: Selection;\n start?: number;\n link: string;\n};\nfunction selectLink({ link, node, selection, start }: SelectLinkOptions) {\n const startPosition = start ?? (node.textContent?.indexOf?.(link) || 0);\n const endPosition = startPosition + link.length;\n\n const range = document.createRange();\n range.setStart(node, startPosition);\n range.setEnd(node, endPosition);\n selection.removeAllRanges();\n selection.addRange(range);\n}\n\nfunction handleClick(view: EditorView, text: string, link: string, key: string, event: MouseEvent) {\n /** open the link if has special key or the view is readonly */\n const contentEditable = view.contentDOM.getAttribute(\"contenteditable\");\n const forceActive = !contentEditable || contentEditable === \"false\";\n\n if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey || forceActive) {\n if (event.type === \"mousedown\") {\n const target = event.target as HTMLAnchorElement;\n window.open(target.href, \"_blank\");\n }\n\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n const target = event.target as HTMLImageElement;\n const parent = target.parentNode;\n let line: HTMLElement | null = parent as HTMLElement | null;\n\n /** recursively find line that contains link */\n while (line && !line.classList.contains(\"cm-line\")) {\n line = line.parentNode as HTMLElement | null;\n }\n\n const editor = Array.from(document.querySelectorAll(\".cm-editor\")).find((element) =>\n element.contains(target),\n );\n const selection = window.getSelection();\n\n if (!selection || !editor || !parent) return;\n\n const textNode = getTextNode(text, link, key, line);\n\n if (textNode) {\n return void selectLink({ selection, link, node: textNode });\n }\n\n saveDispatch(() => {\n if (!view) return;\n\n view.dispatch(view.state.update({ effects: openedLinkEffect.of(key) }));\n\n const textNode = getTextNode(text, link, key, line);\n if (textNode) {\n selectLink({ selection, link, node: textNode });\n }\n\n requestAnimationFrame(() => {\n saveDispatch(() => {\n if (view) view.dispatch(view.state.update({ effects: openedLinkEffect.of(undefined) }));\n });\n });\n });\n\n return false;\n}\n"],"names":[],"mappings":";;;;;;;;;AAMA,MAAM,UAAU,GAA8C,EAAE;AAM1D,MAAO,UAAW,SAAQ,UAAU,CAAA;AAE9B,IAAA,IAAA;AACA,IAAA,IAAA;AACA,IAAA,IAAA;AACA,IAAA,EAAA;AACA,IAAA,IAAA;IALV,WACU,CAAA,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,EAAU,EACV,IAAgB,EAAA;AAExB,QAAA,KAAK,EAAE;QANC,IAAI,CAAA,IAAA,GAAJ,IAAI;QACJ,IAAI,CAAA,IAAA,GAAJ,IAAI;QACJ,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AE,QAAQ,EAAE,CAAC;;QAGjD,qBAAqB,CAAC,MAAK;YACzB,YAAY,CAAC,MAAK;AAChB,gBAAA,IAAI,IAAI;oBAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACzF,aAAC,CAAC;AACJ,SAAC,CAAC;AACJ,KAAC,CAAC;AAEF,IAAA,OAAO,KAAK;AACd;;;;"}
|
|
@@ -3,7 +3,7 @@ import { isInRange } from '../../../lib/utils/is-in-range.js';
|
|
|
3
3
|
import { NAME_OF_LIST, LIST_OF_LIST_MARKS, CODE_OF_ORDERED_LIST_MARK, NAME_OF_TODO } from './list-constants.js';
|
|
4
4
|
import { ListPointWidget } from './list-widget.js';
|
|
5
5
|
|
|
6
|
-
function getListSelectionDecorations({ decorations, node, view,
|
|
6
|
+
function getListSelectionDecorations({ decorations, node, view, forceActive, }) {
|
|
7
7
|
if (node.name !== NAME_OF_LIST) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
@@ -14,14 +14,14 @@ function getListSelectionDecorations({ decorations, node, view, isReadonly, }) {
|
|
|
14
14
|
}
|
|
15
15
|
const nextSibling = node.node.nextSibling;
|
|
16
16
|
if (nextSibling && nextSibling.name === NAME_OF_TODO) {
|
|
17
|
-
if (
|
|
17
|
+
if (forceActive ||
|
|
18
18
|
!view.hasFocus ||
|
|
19
19
|
!isInRange(view.state.selection.ranges, [node.from, nextSibling.from + 3])) {
|
|
20
20
|
decorations.push(getHideDecoration({ range: [node.from, nextSibling.from] }));
|
|
21
21
|
}
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
if (
|
|
24
|
+
if (forceActive ||
|
|
25
25
|
!view.hasFocus ||
|
|
26
26
|
!isInRange(view.state.selection.ranges, [node.from, node.to])) {
|
|
27
27
|
decorations.push(getReplaceDecoration({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-decoration.js","sources":["../../../../../src/extensions/markdown/list/list-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport {\n CODE_OF_ORDERED_LIST_MARK,\n LIST_OF_LIST_MARKS,\n NAME_OF_LIST,\n NAME_OF_TODO,\n} from \"./list-constants\";\nimport { ListPointWidget } from \"./list-widget\";\n\nfunction getListSelectionDecorations({\n decorations,\n node,\n view,\n
|
|
1
|
+
{"version":3,"file":"list-decoration.js","sources":["../../../../../src/extensions/markdown/list/list-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport {\n CODE_OF_ORDERED_LIST_MARK,\n LIST_OF_LIST_MARKS,\n NAME_OF_LIST,\n NAME_OF_TODO,\n} from \"./list-constants\";\nimport { ListPointWidget } from \"./list-widget\";\n\nfunction getListSelectionDecorations({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_LIST) {\n return;\n }\n\n const content = view.state.doc.sliceString(node.from, node.to);\n const lastCodePoint = content.codePointAt(content.length - 1) || 0;\n if (!LIST_OF_LIST_MARKS.has(lastCodePoint) && CODE_OF_ORDERED_LIST_MARK !== lastCodePoint) {\n return;\n }\n\n const nextSibling = node.node.nextSibling;\n if (nextSibling && nextSibling.name === NAME_OF_TODO) {\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [node.from, nextSibling.from + 3])\n ) {\n decorations.push(utils.getHideDecoration({ range: [node.from, nextSibling.from] }));\n }\n\n return;\n }\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [node.from, node.to])\n ) {\n decorations.push(\n utils.getReplaceDecoration({\n range: [node.from, node.to],\n widget: new ListPointWidget(content, lastCodePoint),\n }),\n );\n }\n}\n\nexport const listDecorationPlugin: DecorationPlugin = {\n selectionDecorations: [getListSelectionDecorations],\n};\n"],"names":["utils.isInRange","utils.getHideDecoration","utils.getReplaceDecoration"],"mappings":";;;;;AAUA,SAAS,2BAA2B,CAAC,EACnC,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,GACmB,EAAA;AAC9B,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE;QAC9B;;AAGF,IAAA,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;AAC9D,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC;AAClE,IAAA,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,yBAAyB,KAAK,aAAa,EAAE;QACzF;;AAGF,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW;IACzC,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,YAAY,EAAE;AACpD,QAAA,IACE,WAAW;YACX,CAAC,IAAI,CAAC,QAAQ;YACd,CAACA,SAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAChF;YACA,WAAW,CAAC,IAAI,CAACC,iBAAuB,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;QAGrF;;AAGF,IAAA,IACE,WAAW;QACX,CAAC,IAAI,CAAC,QAAQ;QACd,CAACD,SAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,C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