@krainovsd/markdown-editor 0.3.1 → 0.4.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.
Files changed (65) hide show
  1. package/lib/cjs/{index-DXevyHeZ.js → index-CXENq_0E.js} +10 -6
  2. package/lib/cjs/index-CXENq_0E.js.map +1 -0
  3. package/lib/cjs/{index-nRNnOuav.js → index-Dj0jRUGF.js} +465 -38
  4. package/lib/cjs/index-Dj0jRUGF.js.map +1 -0
  5. package/lib/cjs/index.js +2 -1
  6. package/lib/cjs/index.js.map +1 -1
  7. package/lib/esm/extensions/auto-completes/custom/tag-auto-complete.js +33 -0
  8. package/lib/esm/extensions/auto-completes/custom/tag-auto-complete.js.map +1 -0
  9. package/lib/esm/extensions/auto-completes/init-auto-complete.js +27 -0
  10. package/lib/esm/extensions/auto-completes/init-auto-complete.js.map +1 -0
  11. package/lib/esm/extensions/init-extensions.js +3 -1
  12. package/lib/esm/extensions/init-extensions.js.map +1 -1
  13. package/lib/esm/extensions/keymaps/custom/bold-key-map.js +56 -0
  14. package/lib/esm/extensions/keymaps/custom/bold-key-map.js.map +1 -0
  15. package/lib/esm/extensions/keymaps/custom/italic-key-map.js +57 -0
  16. package/lib/esm/extensions/keymaps/custom/italic-key-map.js.map +1 -0
  17. package/lib/esm/extensions/keymaps/custom/link-key-map.js +28 -0
  18. package/lib/esm/extensions/keymaps/custom/link-key-map.js.map +1 -0
  19. package/lib/esm/extensions/keymaps/init-key-map.js +4 -1
  20. package/lib/esm/extensions/keymaps/init-key-map.js.map +1 -1
  21. package/lib/esm/extensions/markdown/blockquote/blockquote-constants.js +1 -1
  22. package/lib/esm/extensions/markdown/blockquote/blockquote-constants.js.map +1 -1
  23. package/lib/esm/extensions/markdown/bold/bold-constants.js +1 -1
  24. package/lib/esm/extensions/markdown/bold/bold-constants.js.map +1 -1
  25. package/lib/esm/extensions/markdown/code/code-constants.js +3 -1
  26. package/lib/esm/extensions/markdown/code/code-constants.js.map +1 -1
  27. package/lib/esm/extensions/markdown/code/code-decoration.js +32 -1
  28. package/lib/esm/extensions/markdown/code/code-decoration.js.map +1 -1
  29. package/lib/esm/extensions/markdown/image/image-decoration.js +2 -3
  30. package/lib/esm/extensions/markdown/image/image-decoration.js.map +1 -1
  31. package/lib/esm/extensions/markdown/image/image-widget.js +47 -4
  32. package/lib/esm/extensions/markdown/image/image-widget.js.map +1 -1
  33. package/lib/esm/extensions/markdown/italic/italic-decoration.js +6 -4
  34. package/lib/esm/extensions/markdown/italic/italic-decoration.js.map +1 -1
  35. package/lib/esm/extensions/markdown/link/link-decoration.js +2 -2
  36. package/lib/esm/extensions/markdown/link/link-decoration.js.map +1 -1
  37. package/lib/esm/extensions/markdown/link/link-widget.js +23 -0
  38. package/lib/esm/extensions/markdown/link/link-widget.js.map +1 -1
  39. package/lib/esm/extensions/markdown/markdown-decoration.js +5 -10
  40. package/lib/esm/extensions/markdown/markdown-decoration.js.map +1 -1
  41. package/lib/esm/extensions/markdown/markdown-state.js +1 -5
  42. package/lib/esm/extensions/markdown/markdown-state.js.map +1 -1
  43. package/lib/esm/extensions/markdown/mention/mention-constants.js +4 -3
  44. package/lib/esm/extensions/markdown/mention/mention-constants.js.map +1 -1
  45. package/lib/esm/extensions/markdown/mention/mention-parser.js +8 -5
  46. package/lib/esm/extensions/markdown/mention/mention-parser.js.map +1 -1
  47. package/lib/esm/extensions/markdown/styles.module.scss.js +2 -2
  48. package/lib/esm/extensions/theme/theme-constants.js +2 -0
  49. package/lib/esm/extensions/theme/theme-constants.js.map +1 -1
  50. package/lib/esm/extensions/theme/themes/get-dark-theme.js +2 -0
  51. package/lib/esm/extensions/theme/themes/get-dark-theme.js.map +1 -1
  52. package/lib/esm/extensions/theme/themes/get-light-theme.js +2 -0
  53. package/lib/esm/extensions/theme/themes/get-light-theme.js.map +1 -1
  54. package/lib/esm/extensions/theme/themes/get-theme-template.js +6 -0
  55. package/lib/esm/extensions/theme/themes/get-theme-template.js.map +1 -1
  56. package/lib/esm/index.js +1 -0
  57. package/lib/esm/index.js.map +1 -1
  58. package/lib/esm/lib/utils/overlap-mark.js +148 -0
  59. package/lib/esm/lib/utils/overlap-mark.js.map +1 -0
  60. package/lib/esm/module/Editor/Editor.js +1 -0
  61. package/lib/esm/module/Editor/Editor.js.map +1 -1
  62. package/lib/index.d.ts +14 -1
  63. package/package.json +2 -1
  64. package/lib/cjs/index-DXevyHeZ.js.map +0 -1
  65. package/lib/cjs/index-nRNnOuav.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, forceActive, }) {
15
+ function getItalicSelectionDecorations({ decorations, node, view, forceActive, settings, }) {
16
16
  if (node.name !== NAME_OF_ITALIC) {
17
17
  return;
18
18
  }
19
- if (checkIsSeveralEmphasis({ decorations, node, view, forceActive })) {
20
- return void splitEmphasis({ decorations, node, view, forceActive });
19
+ if (checkIsSeveralEmphasis({ decorations, node, view, forceActive, settings })) {
20
+ return void splitEmphasis({ decorations, node, view, forceActive, settings });
21
21
  }
22
22
  let step = 1;
23
23
  const startText = view.state.doc.sliceString(node.from, node.from + 3);
@@ -46,7 +46,7 @@ function checkIsSeveralEmphasis({ node, view }) {
46
46
  return true;
47
47
  return false;
48
48
  }
49
- function splitEmphasis({ decorations, node, view, forceActive }) {
49
+ function splitEmphasis({ decorations, node, view, forceActive, settings, }) {
50
50
  const text = view.state.doc.sliceString(node.from, node.to);
51
51
  let marks = 0;
52
52
  let pos = 0;
@@ -60,12 +60,14 @@ function splitEmphasis({ decorations, node, view, forceActive }) {
60
60
  view,
61
61
  node: { ...node, name: node.name, from: node.from, to: node.from + pos },
62
62
  forceActive,
63
+ settings,
63
64
  });
64
65
  getItalicSelectionDecorations({
65
66
  decorations,
66
67
  view,
67
68
  node: { ...node, name: node.name, from: node.from + pos, to: node.to },
68
69
  forceActive,
70
+ settings,
69
71
  });
70
72
  }
71
73
  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 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,WAA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ensions/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 settings,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_ITALIC) {\n return;\n }\n\n if (checkIsSeveralEmphasis({ decorations, node, view, forceActive, settings })) {\n return void splitEmphasis({ decorations, node, view, forceActive, settings });\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({\n decorations,\n node,\n view,\n forceActive,\n settings,\n}: 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 settings,\n });\n getItalicSelectionDecorations({\n decorations,\n view,\n node: { ...node, name: node.name, from: node.from + pos, to: node.to },\n forceActive,\n settings,\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,EACX,QAAQ,GACsB,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,QAAQ,EAAE,CAAC,EAAE;AAC9E,QAAA,OAAO,KAAK,aAAa,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;IAG/E,IAAI,IAAI,GAAG,CAAC;IACZ,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,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7 @@ import { NAME_OF_LINK, CODE_OF_START_LINK_TEXT, CODE_OF_START_LINK_URL, CODE_OF_
5
5
  import { getLinkLabelSelectionDecoration } from './link-label-decoration.js';
6
6
  import { LinkWidget } from './link-widget.js';
7
7
 
8
- function getLinkSelectionDecorations({ decorations, node, view, forceActive, }) {
8
+ function getLinkSelectionDecorations({ decorations, node, view, forceActive, settings, }) {
9
9
  if (node.name !== NAME_OF_LINK) {
10
10
  return;
11
11
  }
@@ -32,7 +32,7 @@ function getLinkSelectionDecorations({ decorations, node, view, forceActive, })
32
32
  urlCoordinates.to = pos;
33
33
  }
34
34
  if (urlCoordinates.from === -1 || urlCoordinates.to === -1)
35
- return void getLinkLabelSelectionDecoration({ decorations, forceActive, node, view });
35
+ return void getLinkLabelSelectionDecoration({ decorations, forceActive, node, view, settings });
36
36
  const text = content.substring(textCoordinates.from, textCoordinates.to);
37
37
  const url = content.substring(urlCoordinates.from, urlCoordinates.to);
38
38
  const openedLink = view.state.field(markdownState).openedLink;
@@ -1 +1 @@
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 uniqueId = view.state.field(markdownState).uniqueId;\n const key = `${url}:${text}:${uniqueId}:${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, uniqueId, 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"],"names":["utils.getMarkDecoration","utils.isInRange","utils.getReplaceDecoration"],"mappings":";;;;;;;AAaA,SAAS,2BAA2B,CAAC,EACnC,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,GACmB,EAAA;AAC9B,IAAA,IAAI,I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AAE,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,QAAQ,EAAE,IAAI,CAAC;AACtE,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;;;;;"}
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 settings,\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, settings });\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 uniqueId = view.state.field(markdownState).uniqueId;\n const key = `${url}:${text}:${uniqueId}:${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, uniqueId, 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"],"names":["utils.getMarkDecoration","utils.isInRange","utils.getReplaceDecoration"],"mappings":";;;;;;;AAaA,SAAS,2BAA2B,CAAC,EACnC,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,QAAQ,GACsB,EAAA;AAC9B,IAAA,IAAI,IAAI,C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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,QAAQ,EAAE,IAAI,CAAC;AACtE,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;;;;;"}
@@ -6,6 +6,7 @@ import { CLASSES } from '../../theme/theme-constants.js';
6
6
  import { saveDispatch } from '../../../lib/utils/save-dispatch.js';
7
7
  import { openedLinkEffect } from '../markdown-state.js';
8
8
  import styles from '../styles.module.scss.js';
9
+ import { CODE_OF_START_LINK_URL } from './link-constants.js';
9
10
 
10
11
  const LINK_NODES = {};
11
12
  class LinkWidget extends WidgetType {
@@ -115,6 +116,28 @@ function isCorrectNode(text, link, node) {
115
116
  function selectLink({ link, node, selection, start }) {
116
117
  const startPosition = start ?? (node.textContent?.indexOf?.(link) || 0);
117
118
  const endPosition = startPosition + link.length;
119
+ if (startPosition === 0 && endPosition === 0) {
120
+ const content = node.textContent;
121
+ if (!content)
122
+ return;
123
+ let startPosition = 0;
124
+ let pos = 0;
125
+ while (pos < content.length) {
126
+ if (content.codePointAt(pos) !== CODE_OF_START_LINK_URL) {
127
+ pos++;
128
+ }
129
+ else {
130
+ startPosition = pos + 1;
131
+ break;
132
+ }
133
+ }
134
+ const range = document.createRange();
135
+ range.setStart(node, startPosition);
136
+ range.collapse(true);
137
+ selection.removeAllRanges();
138
+ selection.addRange(range);
139
+ return;
140
+ }
118
141
  const range = document.createRange();
119
142
  range.setStart(node, startPosition);
120
143
  range.setEnd(node, endPosition);
@@ -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 { 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 uniqueId: string,\n private view: EditorView,\n ) {\n super();\n }\n\n get key() {\n return `${this.link}:${this.text}:${this.uniqueId}:${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,QAAA;AACA,IAAA,IAAA;IANV,WACU,CAAA,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,EAAU,EACV,QAAgB,EAChB,IAAgB,EAAA;AAExB,QAAA,KAAK,EAAE;QAPC,IAAI,CAAA,IAAA,GAAJ,IAAI;QACJ,IAAI,CAAA,IAAA,GAAJ,IAAI;QACJ,IAAI,CAAA,IAAA,GAAJ,IAAI;QACJ,IAAE,CAAA,EAA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,EAAE,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;;;;"}
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\";\nimport { CODE_OF_START_LINK_URL } from \"./link-constants\";\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 uniqueId: string,\n private view: EditorView,\n ) {\n super();\n }\n\n get key() {\n return `${this.link}:${this.text}:${this.uniqueId}:${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 if (startPosition === 0 && endPosition === 0) {\n const content = node.textContent;\n if (!content) return;\n let startPosition = 0;\n let pos = 0;\n\n while (pos < content.length) {\n if (content.codePointAt(pos) !== CODE_OF_START_LINK_URL) {\n pos++;\n } else {\n startPosition = pos + 1;\n break;\n }\n }\n\n const range = document.createRange();\n range.setStart(node, startPosition);\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n\n return;\n }\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 });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I;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;;;;"}
@@ -12,7 +12,6 @@ import { italicDecorationPlugin } from './italic/italic-decoration.js';
12
12
  import { linkDecorationPlugin } from './link/link-decoration.js';
13
13
  import { autoLinkDecorationPlugin } from './link/auto-link-decoration.js';
14
14
  import { listDecorationPlugin } from './list/list-decoration.js';
15
- import { imageSrcGetterEffect } from './markdown-state.js';
16
15
  import { mentionDecorationPlugin } from './mention/mention-decoration.js';
17
16
  import { strikeThroughDecorationPlugin } from './strike-through/strike-through-decoration.js';
18
17
  import { todoDecorationPlugin } from './todo/todo-decoration.js';
@@ -57,7 +56,7 @@ const SKIP_MARKS = new Set([
57
56
  "HeaderMark",
58
57
  "TaskMarker",
59
58
  ]);
60
- function createDecorationsGetter() {
59
+ function createDecorationsGetter(settings) {
61
60
  let markdownDecorationsCache = [];
62
61
  let markdownSelectionDecorationsCache = [];
63
62
  function getDecorations(view, isChanged, mouseReleased) {
@@ -78,7 +77,7 @@ function createDecorationsGetter() {
78
77
  return;
79
78
  /** Decoration by change content */
80
79
  if (processDecorations)
81
- decorationFunctions.forEach((f) => f({ decorations, node, view }));
80
+ decorationFunctions.forEach((f) => f({ decorations, node, view, settings }));
82
81
  /** Decoration by selection content */
83
82
  if (processSelectionDecorations)
84
83
  selectionDecorationFunctions.forEach((f) => f({
@@ -86,6 +85,7 @@ function createDecorationsGetter() {
86
85
  node,
87
86
  view,
88
87
  forceActive: isReadonly,
88
+ settings,
89
89
  }));
90
90
  },
91
91
  });
@@ -100,7 +100,7 @@ function createDecorationsGetter() {
100
100
  }
101
101
  return getDecorations;
102
102
  }
103
- const markdownDecorationPlugin = (stateConfig) => {
103
+ const markdownDecorationPlugin = (settings) => {
104
104
  return ViewPlugin.fromClass(class DecorationMarkdown {
105
105
  decorations;
106
106
  mouseReleased = true;
@@ -108,17 +108,12 @@ const markdownDecorationPlugin = (stateConfig) => {
108
108
  view;
109
109
  decorationGetter;
110
110
  constructor(view) {
111
- this.decorationGetter = createDecorationsGetter();
111
+ this.decorationGetter = createDecorationsGetter(settings);
112
112
  this.decorations = this.decorationGetter(view, true, this.mouseReleased);
113
113
  this.dom = view.dom;
114
114
  this.view = view;
115
115
  document.addEventListener("mousedown", this.onMouseDown.bind(this));
116
116
  document.addEventListener("mouseup", this.onMouseUp.bind(this));
117
- saveDispatch(() => {
118
- this.view.dispatch(this.view.state.update({
119
- effects: [imageSrcGetterEffect.of(stateConfig.imageSrcGetter)],
120
- }));
121
- });
122
117
  }
123
118
  update(update) {
124
119
  const isDocumentChanged = update.docChanged ||
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-decoration.js","sources":["../../../../src/extensions/markdown/markdown-decoration.ts"],"sourcesContent":["import { syntaxTree } from \"@codemirror/language\";\nimport { type Range } from \"@codemirror/state\";\nimport {\n Decoration,\n type DecorationSet,\n type EditorView,\n ViewPlugin,\n type ViewUpdate,\n} from \"@codemirror/view\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { blockquoteDecorationPlugin } from \"./blockquote\";\nimport { boldDecorationPlugin } from \"./bold\";\nimport { codeDecorationPlugin } from \"./code\";\nimport { headerDecorationPlugin } from \"./header\";\nimport { horizontalDecorationPlugin } from \"./horizontal\";\nimport { imageDecorationPlugin } from \"./image/image-decoration\";\nimport { italicDecorationPlugin } from \"./italic\";\nimport { autoLinkDecorationPlugin, linkDecorationPlugin } from \"./link\";\nimport { listDecorationPlugin } from \"./list\";\nimport { imageSrcGetterEffect } from \"./markdown-state\";\nimport type {\n DecorationPlugin,\n GetDecorationFunction,\n GetSelectionDecorationFunction,\n MarkdownStateConfig,\n} from \"./markdown-types\";\nimport { mentionDecorationPlugin } from \"./mention/mention-decoration\";\nimport { strikeThroughDecorationPlugin } from \"./strike-through\";\nimport { todoDecorationPlugin } from \"./todo\";\n\nconst decorationPlugins: DecorationPlugin[] = [\n blockquoteDecorationPlugin,\n boldDecorationPlugin,\n codeDecorationPlugin,\n headerDecorationPlugin,\n horizontalDecorationPlugin,\n imageDecorationPlugin,\n italicDecorationPlugin,\n linkDecorationPlugin,\n listDecorationPlugin,\n autoLinkDecorationPlugin,\n mentionDecorationPlugin,\n strikeThroughDecorationPlugin,\n todoDecorationPlugin,\n];\n\nlet decorationFunctions: GetDecorationFunction[] = [];\nlet selectionDecorationFunctions: GetSelectionDecorationFunction[] = [];\n\nfor (const plugin of decorationPlugins) {\n if (plugin.decorations) decorationFunctions = decorationFunctions.concat(plugin.decorations);\n if (plugin.selectionDecorations)\n selectionDecorationFunctions = selectionDecorationFunctions.concat(plugin.selectionDecorations);\n}\n\nconst SKIP_MARKS = new Set([\n \"Document\",\n \"Paragraph\",\n \"EmphasisMark\",\n \"Blockquote\",\n \"StrikethroughMark\",\n \"BulletList\",\n \"OrderedList\",\n \"ListItem\",\n \"LinkMark\",\n \"URL\",\n \"CodeMark\",\n \"CodeInfo\",\n \"CodeText\",\n \"HeaderMark\",\n \"TaskMarker\",\n]);\n\nfunction createDecorationsGetter() {\n let markdownDecorationsCache: Range<Decoration>[] = [];\n let markdownSelectionDecorationsCache: Range<Decoration>[] = [];\n\n function getDecorations(view: EditorView, isChanged: boolean, mouseReleased: boolean) {\n const processDecorations = isChanged;\n const processSelectionDecorations = isChanged || mouseReleased;\n const decorations: Range<Decoration>[] = processDecorations ? [] : markdownDecorationsCache;\n const selectionDecorations: Range<Decoration>[] = processSelectionDecorations\n ? []\n : markdownSelectionDecorationsCache;\n\n const contentEditable = view.contentDOM.getAttribute(\"contenteditable\");\n const isReadonly = !contentEditable || contentEditable === \"false\";\n\n for (const { from: fromVisible, to: toVisible } of view.visibleRanges) {\n syntaxTree(view.state).iterate({\n from: fromVisible,\n to: toVisible,\n enter: (node) => {\n if (SKIP_MARKS.has(node.name)) return;\n /** Decoration by change content */\n if (processDecorations)\n decorationFunctions.forEach((f) => f({ decorations, node, view }));\n\n /** Decoration by selection content */\n if (processSelectionDecorations)\n selectionDecorationFunctions.forEach((f) =>\n f({\n decorations: selectionDecorations,\n node,\n view,\n forceActive: isReadonly,\n }),\n );\n },\n });\n }\n\n if (processDecorations) {\n markdownDecorationsCache = decorations;\n }\n if (processSelectionDecorations) {\n markdownSelectionDecorationsCache = selectionDecorations;\n }\n\n return Decoration.set([...decorations, ...selectionDecorations], true);\n }\n\n return getDecorations;\n}\n\nexport const markdownDecorationPlugin = (stateConfig: MarkdownStateConfig) => {\n return ViewPlugin.fromClass(\n class DecorationMarkdown {\n decorations: DecorationSet;\n\n mouseReleased: boolean = true;\n\n dom: HTMLElement;\n\n view: EditorView;\n\n decorationGetter: (\n view: EditorView,\n isChanged: boolean,\n mouseReleased: boolean,\n ) => DecorationSet;\n\n constructor(view: EditorView) {\n this.decorationGetter = createDecorationsGetter();\n this.decorations = this.decorationGetter(view, true, this.mouseReleased);\n this.dom = view.dom;\n this.view = view;\n document.addEventListener(\"mousedown\", this.onMouseDown.bind(this));\n document.addEventListener(\"mouseup\", this.onMouseUp.bind(this));\n\n saveDispatch(() => {\n this.view.dispatch(\n this.view.state.update({\n effects: [imageSrcGetterEffect.of(stateConfig.imageSrcGetter)],\n }),\n );\n });\n }\n\n update(update: ViewUpdate) {\n const isDocumentChanged =\n update.docChanged ||\n update.viewportChanged ||\n syntaxTree(update.startState) != syntaxTree(update.state);\n this.decorations = this.decorationGetter(\n update.view,\n isDocumentChanged,\n this.mouseReleased,\n );\n }\n\n destroy() {\n document.removeEventListener(\"mousedown\", this.onMouseDown.bind(this));\n document.removeEventListener(\"mouseup\", this.onMouseUp.bind(this));\n }\n\n onMouseDown(this: DecorationMarkdown) {\n this.mouseReleased = false;\n }\n\n onMouseUp(this: DecorationMarkdown) {\n this.mouseReleased = true;\n if (this.view.state.selection.ranges[0].from !== this.view.state.selection.ranges[0].to) {\n saveDispatch(() => {\n this.view.dispatch(this.view.state.update({}));\n });\n }\n }\n },\n {\n decorations: (plugin) => plugin.decorations,\n },\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,MAAM,iBAAiB,GAAuB;IAC5C,0BAA0B;IAC1B,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,0BAA0B;IAC1B,qBAAqB;IACrB,sBAAsB;IACtB,oBAAoB;IACpB,oBAAoB;IACpB,wBAAwB;IACxB,uBAAuB;IACvB,6BAA6B;IAC7B,oBAAoB;CACrB;AAED,IAAI,mBAAmB,GAA4B,EAAE;AACrD,IAAI,4BAA4B,GAAqC,EAAE;AAEvE,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;IACtC,IAAI,MAAM,CAAC,WAAW;QAAE,mBAAmB,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;IAC5F,IAAI,MAAM,CAAC,oBAAoB;QAC7B,4BAA4B,GAAG,4BAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC;AACnG;AAEA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,UAAU;IACV,WAAW;IACX,cAAc;IACd,YAAY;IACZ,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,UAAU;IACV,KAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU;IACV,YAAY;IACZ,YAAY;AACb,CAAA,CAAC;AAEF,SAAS,uBAAuB,GAAA;IAC9B,IAAI,wBAAwB,GAAwB,EAAE;IACtD,IAAI,iCAAiC,GAAwB,EAAE;AAE/D,IAAA,SAAS,cAAc,CAAC,IAAgB,EAAE,SAAkB,EAAE,aAAsB,EAAA;QAClF,MAAM,kBAAkB,GAAG,SAAS;AACpC,QAAA,MAAM,2BAA2B,GAAG,SAAS,IAAI,aAAa;QAC9D,MAAM,WAAW,GAAwB,kBAAkB,GAAG,E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I,EACX,iBAAiB,EACjB,IAAI,CAAC,aAAa,CACnB;;QAGH,OAAO,GAAA;AACL,YAAA,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtE,YAAA,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;QAGpE,WAAW,GAAA;AACT,YAAA,IAAI,CAAC,aAAa,GAAG,KAAK;;QAG5B,SAAS,GAAA;AACP,YAAA,IAAI,CAAC,aAAa,GAAG,IAAI;AACzB,YAAA,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;gBACvF,YAAY,CAAC,MAAK;AAChB,oBAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAChD,iBAAC,CAAC;;;KAGP,EACD;QACE,WAAW,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW;AAC5C,KAAA,CACF;AACH;;;;"}
1
+ {"version":3,"file":"markdown-decoration.js","sources":["../../../../src/extensions/markdown/markdown-decoration.ts"],"sourcesContent":["import { syntaxTree } from \"@codemirror/language\";\nimport { type Range } from \"@codemirror/state\";\nimport {\n Decoration,\n type DecorationSet,\n type EditorView,\n ViewPlugin,\n type ViewUpdate,\n} from \"@codemirror/view\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { blockquoteDecorationPlugin } from \"./blockquote\";\nimport { boldDecorationPlugin } from \"./bold\";\nimport { codeDecorationPlugin } from \"./code\";\nimport { headerDecorationPlugin } from \"./header\";\nimport { horizontalDecorationPlugin } from \"./horizontal\";\nimport { imageDecorationPlugin } from \"./image/image-decoration\";\nimport { italicDecorationPlugin } from \"./italic\";\nimport { autoLinkDecorationPlugin, linkDecorationPlugin } from \"./link\";\nimport { listDecorationPlugin } from \"./list\";\nimport type {\n DecorationPlugin,\n GetDecorationFunction,\n GetSelectionDecorationFunction,\n MarkdownDecorationSettings,\n} from \"./markdown-types\";\nimport { mentionDecorationPlugin } from \"./mention/mention-decoration\";\nimport { strikeThroughDecorationPlugin } from \"./strike-through\";\nimport { todoDecorationPlugin } from \"./todo\";\n\nconst decorationPlugins: DecorationPlugin[] = [\n blockquoteDecorationPlugin,\n boldDecorationPlugin,\n codeDecorationPlugin,\n headerDecorationPlugin,\n horizontalDecorationPlugin,\n imageDecorationPlugin,\n italicDecorationPlugin,\n linkDecorationPlugin,\n listDecorationPlugin,\n autoLinkDecorationPlugin,\n mentionDecorationPlugin,\n strikeThroughDecorationPlugin,\n todoDecorationPlugin,\n];\n\nlet decorationFunctions: GetDecorationFunction[] = [];\nlet selectionDecorationFunctions: GetSelectionDecorationFunction[] = [];\n\nfor (const plugin of decorationPlugins) {\n if (plugin.decorations) decorationFunctions = decorationFunctions.concat(plugin.decorations);\n if (plugin.selectionDecorations)\n selectionDecorationFunctions = selectionDecorationFunctions.concat(plugin.selectionDecorations);\n}\n\nconst SKIP_MARKS = new Set([\n \"Document\",\n \"Paragraph\",\n \"EmphasisMark\",\n \"Blockquote\",\n \"StrikethroughMark\",\n \"BulletList\",\n \"OrderedList\",\n \"ListItem\",\n \"LinkMark\",\n \"URL\",\n \"CodeMark\",\n \"CodeInfo\",\n \"CodeText\",\n \"HeaderMark\",\n \"TaskMarker\",\n]);\n\nfunction createDecorationsGetter(settings: MarkdownDecorationSettings) {\n let markdownDecorationsCache: Range<Decoration>[] = [];\n let markdownSelectionDecorationsCache: Range<Decoration>[] = [];\n\n function getDecorations(view: EditorView, isChanged: boolean, mouseReleased: boolean) {\n const processDecorations = isChanged;\n const processSelectionDecorations = isChanged || mouseReleased;\n const decorations: Range<Decoration>[] = processDecorations ? [] : markdownDecorationsCache;\n const selectionDecorations: Range<Decoration>[] = processSelectionDecorations\n ? []\n : markdownSelectionDecorationsCache;\n\n const contentEditable = view.contentDOM.getAttribute(\"contenteditable\");\n const isReadonly = !contentEditable || contentEditable === \"false\";\n\n for (const { from: fromVisible, to: toVisible } of view.visibleRanges) {\n syntaxTree(view.state).iterate({\n from: fromVisible,\n to: toVisible,\n enter: (node) => {\n if (SKIP_MARKS.has(node.name)) return;\n /** Decoration by change content */\n if (processDecorations)\n decorationFunctions.forEach((f) => f({ decorations, node, view, settings }));\n\n /** Decoration by selection content */\n if (processSelectionDecorations)\n selectionDecorationFunctions.forEach((f) =>\n f({\n decorations: selectionDecorations,\n node,\n view,\n forceActive: isReadonly,\n settings,\n }),\n );\n },\n });\n }\n\n if (processDecorations) {\n markdownDecorationsCache = decorations;\n }\n if (processSelectionDecorations) {\n markdownSelectionDecorationsCache = selectionDecorations;\n }\n\n return Decoration.set([...decorations, ...selectionDecorations], true);\n }\n\n return getDecorations;\n}\n\nexport const markdownDecorationPlugin = (settings: MarkdownDecorationSettings) => {\n return ViewPlugin.fromClass(\n class DecorationMarkdown {\n decorations: DecorationSet;\n\n mouseReleased: boolean = true;\n\n dom: HTMLElement;\n\n view: EditorView;\n\n decorationGetter: (\n view: EditorView,\n isChanged: boolean,\n mouseReleased: boolean,\n ) => DecorationSet;\n\n constructor(view: EditorView) {\n this.decorationGetter = createDecorationsGetter(settings);\n this.decorations = this.decorationGetter(view, true, this.mouseReleased);\n this.dom = view.dom;\n this.view = view;\n document.addEventListener(\"mousedown\", this.onMouseDown.bind(this));\n document.addEventListener(\"mouseup\", this.onMouseUp.bind(this));\n }\n\n update(update: ViewUpdate) {\n const isDocumentChanged =\n update.docChanged ||\n update.viewportChanged ||\n syntaxTree(update.startState) != syntaxTree(update.state);\n this.decorations = this.decorationGetter(\n update.view,\n isDocumentChanged,\n this.mouseReleased,\n );\n }\n\n destroy() {\n document.removeEventListener(\"mousedown\", this.onMouseDown.bind(this));\n document.removeEventListener(\"mouseup\", this.onMouseUp.bind(this));\n }\n\n onMouseDown(this: DecorationMarkdown) {\n this.mouseReleased = false;\n }\n\n onMouseUp(this: DecorationMarkdown) {\n this.mouseReleased = true;\n if (this.view.state.selection.ranges[0].from !== this.view.state.selection.ranges[0].to) {\n saveDispatch(() => {\n this.view.dispatch(this.view.state.update({}));\n });\n }\n }\n },\n {\n decorations: (plugin) => plugin.decorations,\n },\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,iBAAiB,GAAuB;IAC5C,0BAA0B;IAC1B,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,0BAA0B;IAC1B,qBAAqB;IACrB,sBAAsB;IACtB,oBAAoB;IACpB,oBAAoB;IACpB,wBAAwB;IACxB,uBAAuB;IACvB,6BAA6B;IAC7B,oBAAoB;CACrB;AAED,IAAI,mBAAmB,GAA4B,EAAE;AACrD,IAAI,4BAA4B,GAAqC,EAAE;AAEvE,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;IACtC,IAAI,MAAM,CAAC,WAAW;QAAE,mBAAmB,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;IAC5F,IAAI,MAAM,CAAC,oBAAoB;QAC7B,4BAA4B,GAAG,4BAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC;AACnG;AAEA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,UAAU;IACV,WAAW;IACX,cAAc;IACd,YAAY;IACZ,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,UAAU;IACV,KAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU;IACV,YAAY;IACZ,YAAY;AACb,CAAA,CAAC;AAEF,SAAS,uBAAuB,CAAC,QAAoC,EAAA;IACnE,IAAI,wBAAwB,GAAwB,EAAE;IACtD,IAAI,iCAAiC,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X,iBAAiB,EACjB,IAAI,CAAC,aAAa,CACnB;;QAGH,OAAO,GAAA;AACL,YAAA,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtE,YAAA,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;QAGpE,WAAW,GAAA;AACT,YAAA,IAAI,CAAC,aAAa,GAAG,KAAK;;QAG5B,SAAS,GAAA;AACP,YAAA,IAAI,CAAC,aAAa,GAAG,IAAI;AACzB,YAAA,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;gBACvF,YAAY,CAAC,MAAK;AAChB,oBAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAChD,iBAAC,CAAC;;;KAGP,EACD;QACE,WAAW,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW;AAC5C,KAAA,CACF;AACH;;;;"}
@@ -4,12 +4,10 @@ import { randomString } from '../../lib/utils/random-string.js';
4
4
 
5
5
  const openedImageEffect = StateEffect.define();
6
6
  const openedLinkEffect = StateEffect.define();
7
- const imageSrcGetterEffect = StateEffect.define();
8
7
  const markdownState = StateField.define({
9
8
  create() {
10
9
  return {
11
10
  openedImage: undefined,
12
- imageSrcGetter: undefined,
13
11
  openedLink: undefined,
14
12
  uniqueId: randomString(10),
15
13
  };
@@ -19,8 +17,6 @@ const markdownState = StateField.define({
19
17
  for (const effect of transaction.effects) {
20
18
  if (effect.is(openedImageEffect))
21
19
  newValue.openedImage = effect.value;
22
- if (effect.is(imageSrcGetterEffect))
23
- newValue.imageSrcGetter = effect.value;
24
20
  if (effect.is(openedLinkEffect))
25
21
  newValue.openedLink = effect.value;
26
22
  }
@@ -28,5 +24,5 @@ const markdownState = StateField.define({
28
24
  },
29
25
  });
30
26
 
31
- export { imageSrcGetterEffect, markdownState, openedImageEffect, openedLinkEffect };
27
+ export { markdownState, openedImageEffect, openedLinkEffect };
32
28
  //# sourceMappingURL=markdown-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-state.js","sources":["../../../../src/extensions/markdown/markdown-state.ts"],"sourcesContent":["import { StateEffect, StateField } from \"@codemirror/state\";\nimport { randomString } from \"@/lib/utils\";\nimport type { MarkdownState } from \"./markdown-types\";\n\nexport const openedImageEffect = StateEffect.define<string | undefined>();\nexport const openedLinkEffect = StateEffect.define<string | undefined>();\nexport const imageSrcGetterEffect = StateEffect.define<((src: string) => string) | undefined>();\n\nexport const markdownState = StateField.define<MarkdownState>({\n create() {\n return {\n openedImage: undefined,\n imageSrcGetter: undefined,\n openedLink: undefined,\n uniqueId: randomString(10),\n };\n },\n\n update(value, transaction) {\n const newValue = { ...value };\n\n for (const effect of transaction.effects) {\n if (effect.is(openedImageEffect)) newValue.openedImage = effect.value;\n if (effect.is(imageSrcGetterEffect)) newValue.imageSrcGetter = effect.value;\n if (effect.is(openedLinkEffect)) newValue.openedLink = effect.value;\n }\n\n return newValue;\n },\n});\n"],"names":[],"mappings":";;;;MAIa,iBAAiB,GAAG,WAAW,CAAC,MAAM;MACtC,gBAAgB,GAAG,WAAW,CAAC,MAAM;MACrC,oBAAoB,GAAG,WAAW,CAAC,MAAM;AAEzC,MAAA,aAAa,GAAG,UAAU,CAAC,MAAM,CAAgB;IAC5D,MAAM,GAAA;QACJ,OAAO;AACL,YAAA,WAAW,EAAE,SAAS;AACtB,YAAA,cAAc,EAAE,SAAS;AACzB,YAAA,UAAU,EAAE,SAAS;AACrB,YAAA,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;SAC3B;KACF;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAA;AACvB,QAAA,MAAM,QAAQ,GAAG,EAAE,GAAG,KAAK,EAAE;AAE7B,QAAA,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AACxC,YAAA,IAAI,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC;AAAE,gBAAA,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK;AACrE,YAAA,IAAI,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC;AAAE,gBAAA,QAAQ,CAAC,cAAc,GAAG,MAAM,CAAC,KAAK;AAC3E,YAAA,IAAI,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC;AAAE,gBAAA,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,KAAK;;AAGrE,QAAA,OAAO,QAAQ;KAChB;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"markdown-state.js","sources":["../../../../src/extensions/markdown/markdown-state.ts"],"sourcesContent":["import { StateEffect, StateField } from \"@codemirror/state\";\nimport { randomString } from \"@/lib/utils\";\nimport type { MarkdownState } from \"./markdown-types\";\n\nexport const openedImageEffect = StateEffect.define<string | undefined>();\nexport const openedLinkEffect = StateEffect.define<string | undefined>();\n\nexport const markdownState = StateField.define<MarkdownState>({\n create() {\n return {\n openedImage: undefined,\n openedLink: undefined,\n uniqueId: randomString(10),\n };\n },\n\n update(value, transaction) {\n const newValue = { ...value };\n\n for (const effect of transaction.effects) {\n if (effect.is(openedImageEffect)) newValue.openedImage = effect.value;\n if (effect.is(openedLinkEffect)) newValue.openedLink = effect.value;\n }\n\n return newValue;\n },\n});\n"],"names":[],"mappings":";;;;MAIa,iBAAiB,GAAG,WAAW,CAAC,MAAM;MACtC,gBAAgB,GAAG,WAAW,CAAC,MAAM;AAErC,MAAA,aAAa,GAAG,UAAU,CAAC,MAAM,CAAgB;IAC5D,MAAM,GAAA;QACJ,OAAO;AACL,YAAA,WAAW,EAAE,SAAS;AACtB,YAAA,UAAU,EAAE,SAAS;AACrB,YAAA,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;SAC3B;KACF;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAA;AACvB,QAAA,MAAM,QAAQ,GAAG,EAAE,GAAG,KAAK,EAAE;AAE7B,QAAA,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AACxC,YAAA,IAAI,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC;AAAE,gBAAA,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK;AACrE,YAAA,IAAI,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC;AAAE,gBAAA,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,KAAK;;AAGrE,QAAA,OAAO,QAAQ;KAChB;AACF,CAAA;;;;"}
@@ -1,6 +1,7 @@
1
- const CODE_OF_START_MENTION = 64; // @
2
- const CODE_OF_SPACE = 32;
1
+ const CODE_OF_START_MENTION = "@".codePointAt(0); // @
2
+ const CODE_OF_SPACE = " ".codePointAt(0);
3
+ const CODE_OF_LINE_BREAK = "\n".codePointAt(0);
3
4
  const NAME_OF_MENTION = "Mention";
4
5
 
5
- export { CODE_OF_SPACE, CODE_OF_START_MENTION, NAME_OF_MENTION };
6
+ export { CODE_OF_LINE_BREAK, CODE_OF_SPACE, CODE_OF_START_MENTION, NAME_OF_MENTION };
6
7
  //# sourceMappingURL=mention-constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mention-constants.js","sources":["../../../../../src/extensions/markdown/mention/mention-constants.ts"],"sourcesContent":["export const CODE_OF_START_MENTION = 64; // @\nexport const CODE_OF_SPACE = 32;\nexport const NAME_OF_MENTION = \"Mention\";\n"],"names":[],"mappings":"AAAa,MAAA,qBAAqB,GAAG,GAAG;AACjC,MAAM,aAAa,GAAG;AACtB,MAAM,eAAe,GAAG;;;;"}
1
+ {"version":3,"file":"mention-constants.js","sources":["../../../../../src/extensions/markdown/mention/mention-constants.ts"],"sourcesContent":["export const CODE_OF_START_MENTION = \"@\".codePointAt(0); // @\nexport const CODE_OF_SPACE = \" \".codePointAt(0);\nexport const CODE_OF_LINE_BREAK = \"\\n\".codePointAt(0);\nexport const NAME_OF_MENTION = \"Mention\";\n"],"names":[],"mappings":"AAAO,MAAM,qBAAqB,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;AAC3C,MAAA,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;AACjC,MAAA,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7C,MAAM,eAAe,GAAG;;;;"}
@@ -1,17 +1,20 @@
1
- import { NAME_OF_MENTION, CODE_OF_START_MENTION, CODE_OF_SPACE } from './mention-constants.js';
1
+ import { NAME_OF_MENTION, CODE_OF_START_MENTION, CODE_OF_SPACE, CODE_OF_LINE_BREAK } from './mention-constants.js';
2
2
 
3
3
  const mentionParser = {
4
4
  defineNodes: [{ name: NAME_OF_MENTION }],
5
5
  parseInline: [
6
6
  {
7
7
  name: NAME_OF_MENTION,
8
- parse(cx, next, pos) {
9
- if (next != CODE_OF_START_MENTION)
8
+ parse(cx, code, pos) {
9
+ if (code != CODE_OF_START_MENTION)
10
+ return -1;
11
+ const nextCode = cx.char(pos + 1);
12
+ if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)
10
13
  return -1;
11
14
  let end = pos + 1;
12
15
  for (let i = pos + 1; i < cx.end; i++) {
13
- const next = cx.char(i);
14
- if (next === CODE_OF_SPACE)
16
+ const nextCode = cx.char(i);
17
+ if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)
15
18
  break;
16
19
  end++;
17
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mention-parser.js","sources":["../../../../../src/extensions/markdown/mention/mention-parser.ts"],"sourcesContent":["import type { MarkdownConfig } from \"@lezer/markdown\";\nimport { CODE_OF_SPACE, CODE_OF_START_MENTION, NAME_OF_MENTION } from \"./mention-constants\";\n\nexport const mentionParser: MarkdownConfig = {\n defineNodes: [{ name: NAME_OF_MENTION }],\n parseInline: [\n {\n name: NAME_OF_MENTION,\n parse(cx, next, pos) {\n if (next != CODE_OF_START_MENTION) return -1;\n let end: number = pos + 1;\n for (let i = pos + 1; i < cx.end; i++) {\n const next = cx.char(i);\n if (next === CODE_OF_SPACE) break;\n end++;\n }\n\n return cx.addElement(cx.elt(NAME_OF_MENTION, pos, end));\n },\n },\n ],\n};\n"],"names":[],"mappings":";;AAGa,MAAA,aAAa,GAAmB;AAC3C,IAAA,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;AACxC,IAAA,WAAW,EAAE;AACX,QAAA;AACE,YAAA,IAAI,EAAE,eAAe;AACrB,YAAA,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAA;gBACjB,IAAI,IAAI,IAAI,qBAAqB;oBAAE,OAAO,CAAC,CAAC;AAC5C,gBAAA,IAAI,GAAG,GAAW,GAAG,GAAG,CAAC;AACzB,gBAAA,KAAK,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;oBACrC,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;oBACvB,IAAI,IAAI,KAAK,aAAa;wBAAE;AAC5B,oBAAA,GAAG,EAAE;;AAGP,gBAAA,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aACxD;AACF,SAAA;AACF,KAAA;;;;;"}
1
+ {"version":3,"file":"mention-parser.js","sources":["../../../../../src/extensions/markdown/mention/mention-parser.ts"],"sourcesContent":["import type { MarkdownConfig } from \"@lezer/markdown\";\nimport {\n CODE_OF_LINE_BREAK,\n CODE_OF_SPACE,\n CODE_OF_START_MENTION,\n NAME_OF_MENTION,\n} from \"./mention-constants\";\n\nexport const mentionParser: MarkdownConfig = {\n defineNodes: [{ name: NAME_OF_MENTION }],\n parseInline: [\n {\n name: NAME_OF_MENTION,\n parse(cx, code, pos) {\n if (code != CODE_OF_START_MENTION) return -1;\n const nextCode = cx.char(pos + 1);\n if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)\n return -1;\n\n let end: number = pos + 1;\n for (let i = pos + 1; i < cx.end; i++) {\n const nextCode = cx.char(i);\n if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)\n break;\n end++;\n }\n\n return cx.addElement(cx.elt(NAME_OF_MENTION, pos, end));\n },\n },\n ],\n};\n"],"names":[],"mappings":";;AAQa,MAAA,aAAa,GAAmB;AAC3C,IAAA,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;AACxC,IAAA,WAAW,EAAE;AACX,QAAA;AACE,YAAA,IAAI,EAAE,eAAe;AACrB,YAAA,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAA;gBACjB,IAAI,IAAI,IAAI,qBAAqB;oBAAE,OAAO,CAAC,CAAC;gBAC5C,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBACjC,IAAI,QAAQ,KAAK,CAAC,CAAC,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,kBAAkB;oBAClF,OAAO,CAAC,CAAC;AAEX,gBAAA,IAAI,GAAG,GAAW,GAAG,GAAG,CAAC;AACzB,gBAAA,KAAK,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;oBACrC,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC3B,IAAI,QAAQ,KAAK,CAAC,CAAC,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,kBAAkB;wBAClF;AACF,oBAAA,GAAG,EAAE;;AAGP,gBAAA,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aACxD;AACF,SAAA;AACF,KAAA;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import styleInject from '../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._header_XFwV5{font-weight:700}._header_XFwV5._level_1_-KPph{font-size:2rem}._header_XFwV5._level_2_ecHlB{font-size:1.8rem}._header_XFwV5._level_3_SYcVr{font-size:1.6rem}._header_XFwV5._level_4_V3o5m{font-size:1.4rem}._header_XFwV5._level_5_I7eVk{font-size:1.3rem}._header_XFwV5._level_6_A3lbK{font-size:1.2rem}._bold_I8DT-{font-weight:700}._italic_72qBe{font-style:italic}._blockquote_Xq6O4{border-left:3px solid;margin-left:5px}._blockquote__inner_mjT0h{margin-left:1px;padding-left:5px;position:relative}._blockquote__inner_mjT0h:before{border-left:3px solid;content:\"\";height:140%;left:0;position:absolute;top:-3px}._blockquote__inner-deep_s6tNj{margin-left:5px}._strike-through_U64jP{text-decoration:line-through}._list_MHIjT._common_0GdDi{position:relative;visibility:hidden}._list_MHIjT._common_0GdDi:after{border-radius:100%;content:\"\";height:5px;left:0;position:absolute;top:50%;transform:translateY(-50%);visibility:visible;width:5px}._link_7U9wl{text-decoration:none;text-decoration:underline}._link__label_dHGGf{font-size:12px;position:relative;top:-4px}._image_KmBM8{display:inline-flex}._code__line_m3IiO{padding:5px;position:relative}._code__line_m3IiO,._code__single_hbMte{font-family:monospace}._code__button_WwYE-{background-color:transparent;border:none;border-radius:4px;box-shadow:none;cursor:pointer;min-width:30px;outline:none;padding:4px 10px;position:absolute;right:5px;top:5px;transition:all .3s ease;z-index:1}._code__button_WwYE-._pending_fgHgD:before{animation:_loading-btn--fade-in_8z5an .33s ease,_loading-btn--rotation_QaopN .66s linear 0s infinite;border:2px solid hsla(0,0%,100%,.33);border-radius:50%;border-top-color:#000;content:\"\";display:inline-block;height:10.5px;left:50%;position:absolute;top:50%;width:10.5px}._code__button_WwYE-._success_kUPnO:after{animation:_loading-btn--fade-in_8z5an .6s ease;border-color:currentcolor;border-style:solid;border-width:0 0 1px 1px;content:\"\";display:inline-block;height:7px;left:50%;position:absolute;top:50%;transform:translate(-50%,-75%) rotate(-45deg);width:11px}._code__button_WwYE-._fail_cOpap:after,._code__button_WwYE-._fail_cOpap:before{content:\" \";height:13px;left:50%;position:absolute;top:50%;width:1px}._code__button_WwYE-._fail_cOpap:before{transform:translate(-50%,-50%) rotate(45deg)}._code__button_WwYE-._fail_cOpap:after{transform:translate(-50%,-50%) rotate(-45deg)}@keyframes _loading-btn--fade-in_8z5an{0%{opacity:0}to{opacity:1}}@keyframes _loading-btn--rotation_QaopN{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}._code__span_iSCmj{opacity:1;transition:opacity .3s ease}._code__span_iSCmj._hide_uqpax{opacity:0}._horizontal_J1jU-{border-bottom:1px solid;margin:0 5px;position:relative;width:calc(100% - 10px)}._todo_m6MIP{align-items:flex-end;display:inline-flex;height:100%;padding-left:3px;padding-right:3px}._todo_m6MIP>input{margin:0}._todo__checked_kemjy{text-decoration:line-through}._mention_cpzik{font-weight:700}";
4
- const styles = {"header":"_header_XFwV5","level_1":"_level_1_-KPph","level_2":"_level_2_ecHlB","level_3":"_level_3_SYcVr","level_4":"_level_4_V3o5m","level_5":"_level_5_I7eVk","level_6":"_level_6_A3lbK","bold":"_bold_I8DT-","italic":"_italic_72qBe","blockquote":"_blockquote_Xq6O4","blockquote__inner":"_blockquote__inner_mjT0h","blockquote__inner-deep":"_blockquote__inner-deep_s6tNj","strike-through":"_strike-through_U64jP","list":"_list_MHIjT","common":"_common_0GdDi","link":"_link_7U9wl","link__label":"_link__label_dHGGf","image":"_image_KmBM8","code__line":"_code__line_m3IiO","code__single":"_code__single_hbMte","code__button":"_code__button_WwYE-","pending":"_pending_fgHgD","loading-btn--fade-in":"_loading-btn--fade-in_8z5an","loading-btn--rotation":"_loading-btn--rotation_QaopN","success":"_success_kUPnO","fail":"_fail_cOpap","code__span":"_code__span_iSCmj","hide":"_hide_uqpax","horizontal":"_horizontal_J1jU-","todo":"_todo_m6MIP","todo__checked":"_todo__checked_kemjy","mention":"_mention_cpzik"};
3
+ var css_248z = "._header_XFwV5{font-weight:700}._header_XFwV5._level_1_-KPph{font-size:2em}._header_XFwV5._level_2_ecHlB{font-size:1.8em}._header_XFwV5._level_3_SYcVr{font-size:1.6em}._header_XFwV5._level_4_V3o5m{font-size:1.4em}._header_XFwV5._level_5_I7eVk{font-size:1.3em}._header_XFwV5._level_6_A3lbK{font-size:1.2em}._bold_I8DT-{font-weight:700}._italic_72qBe{font-style:italic}._blockquote_Xq6O4{border-left:3px solid;margin-left:5px}._blockquote__inner_mjT0h{margin-left:1px;padding-left:5px;position:relative}._blockquote__inner_mjT0h:before{border-left:3px solid;content:\"\";height:140%;left:0;position:absolute;top:-3px}._blockquote__inner-deep_s6tNj{margin-left:5px}._strike-through_U64jP{text-decoration:line-through}._list_MHIjT._common_0GdDi{position:relative;visibility:hidden}._list_MHIjT._common_0GdDi:after{border-radius:100%;content:\"\";height:5px;left:0;position:absolute;top:50%;transform:translateY(-50%);visibility:visible;width:5px}._link_7U9wl{text-decoration:none;text-decoration:underline}._link__label_dHGGf{font-size:12px;position:relative;top:-4px}._image_KmBM8{display:inline-flex}._code__line_m3IiO{padding:5px;position:relative}._code__line_m3IiO,._code__single_hbMte{font-family:monospace}._code__button_WwYE-{background-color:transparent;border:none;border-radius:4px;box-shadow:none;cursor:pointer;min-width:30px;outline:none;padding:4px 10px;position:absolute;right:5px;top:5px;transition:all .3s ease;z-index:1}._code__button_WwYE-._pending_fgHgD:before{animation:_loading-btn--fade-in_8z5an .33s ease,_loading-btn--rotation_QaopN .66s linear 0s infinite;border:2px solid hsla(0,0%,100%,.33);border-radius:50%;border-top-color:#000;content:\"\";display:inline-block;height:10.5px;left:50%;position:absolute;top:50%;width:10.5px}._code__button_WwYE-._success_kUPnO:after{animation:_loading-btn--fade-in_8z5an .6s ease;border-color:currentcolor;border-style:solid;border-width:0 0 1px 1px;content:\"\";display:inline-block;height:7px;left:50%;position:absolute;top:50%;transform:translate(-50%,-75%) rotate(-45deg);width:11px}._code__button_WwYE-._fail_cOpap:after,._code__button_WwYE-._fail_cOpap:before{content:\" \";height:13px;left:50%;position:absolute;top:50%;width:1px}._code__button_WwYE-._fail_cOpap:before{transform:translate(-50%,-50%) rotate(45deg)}._code__button_WwYE-._fail_cOpap:after{transform:translate(-50%,-50%) rotate(-45deg)}@keyframes _loading-btn--fade-in_8z5an{0%{opacity:0}to{opacity:1}}@keyframes _loading-btn--rotation_QaopN{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}._code__span_iSCmj{opacity:1;transition:opacity .3s ease}._code__span_iSCmj._hide_uqpax{opacity:0}._code__block_JehA4{padding:1px 5px}._code__block_line_U7lcQ{border-left:1px solid;margin-left:5px}._horizontal_J1jU-{border-bottom:1px solid;margin:0 5px;position:relative;width:calc(100% - 10px)}._todo_m6MIP{align-items:flex-end;display:inline-flex;height:100%;padding-left:3px;padding-right:3px}._todo_m6MIP>input{margin:0}._todo__checked_kemjy{text-decoration:line-through}._mention_cpzik{font-weight:700}";
4
+ const styles = {"header":"_header_XFwV5","level_1":"_level_1_-KPph","level_2":"_level_2_ecHlB","level_3":"_level_3_SYcVr","level_4":"_level_4_V3o5m","level_5":"_level_5_I7eVk","level_6":"_level_6_A3lbK","bold":"_bold_I8DT-","italic":"_italic_72qBe","blockquote":"_blockquote_Xq6O4","blockquote__inner":"_blockquote__inner_mjT0h","blockquote__inner-deep":"_blockquote__inner-deep_s6tNj","strike-through":"_strike-through_U64jP","list":"_list_MHIjT","common":"_common_0GdDi","link":"_link_7U9wl","link__label":"_link__label_dHGGf","image":"_image_KmBM8","code__line":"_code__line_m3IiO","code__single":"_code__single_hbMte","code__button":"_code__button_WwYE-","pending":"_pending_fgHgD","loading-btn--fade-in":"_loading-btn--fade-in_8z5an","loading-btn--rotation":"_loading-btn--rotation_QaopN","success":"_success_kUPnO","fail":"_fail_cOpap","code__span":"_code__span_iSCmj","hide":"_hide_uqpax","code__block":"_code__block_JehA4","code__block_line":"_code__block_line_U7lcQ","horizontal":"_horizontal_J1jU-","todo":"_todo_m6MIP","todo__checked":"_todo__checked_kemjy","mention":"_mention_cpzik"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { styles as default };
@@ -1,6 +1,8 @@
1
1
  const CLASSES = {
2
2
  listCommon: "cm-list-common",
3
3
  code: "cm-code",
4
+ codeBlockLine: "cm-code-block-line",
5
+ codeBlock: "cm-code-block",
4
6
  codeButton: "cm-code-button",
5
7
  codeButtonSuccess: "cm-code-button-success",
6
8
  codeButtonFail: "cm-code-button-fail",
@@ -1 +1 @@
1
- {"version":3,"file":"theme-constants.js","sources":["../../../../src/extensions/theme/theme-constants.ts"],"sourcesContent":["export const CLASSES = {\n listCommon: \"cm-list-common\",\n code: \"cm-code\",\n codeButton: \"cm-code-button\",\n codeButtonSuccess: \"cm-code-button-success\",\n codeButtonFail: \"cm-code-button-fail\",\n codeButtonPending: \"cm-code-button-pending\",\n codeButtonSpan: \"cm-code-span\",\n horizontal: \"cm-horizontal\",\n blockquote: \"cm-blockquote\",\n blockquoteInner: \"cm-blockquote-inner\",\n link: \"cm-link\",\n mention: \"cm-mention\",\n};\n"],"names":[],"mappings":"AAAa,MAAA,OAAO,GAAG;AACrB,IAAA,UAAU,EAAE,gBAAgB;AAC5B,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,UAAU,EAAE,gBAAgB;AAC5B,IAAA,iBAAiB,EAAE,wBAAwB;AAC3C,IAAA,cAAc,EAAE,qBAAqB;AACrC,IAAA,iBAAiB,EAAE,wBAAwB;AAC3C,IAAA,cAAc,EAAE,cAAc;AAC9B,IAAA,UAAU,EAAE,eAAe;AAC3B,IAAA,UAAU,EAAE,eAAe;AAC3B,IAAA,eAAe,EAAE,qBAAqB;AACtC,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,OAAO,EAAE,YAAY;;;;;"}
1
+ {"version":3,"file":"theme-constants.js","sources":["../../../../src/extensions/theme/theme-constants.ts"],"sourcesContent":["export const CLASSES = {\n listCommon: \"cm-list-common\",\n code: \"cm-code\",\n codeBlockLine: \"cm-code-block-line\",\n codeBlock: \"cm-code-block\",\n codeButton: \"cm-code-button\",\n codeButtonSuccess: \"cm-code-button-success\",\n codeButtonFail: \"cm-code-button-fail\",\n codeButtonPending: \"cm-code-button-pending\",\n codeButtonSpan: \"cm-code-span\",\n horizontal: \"cm-horizontal\",\n blockquote: \"cm-blockquote\",\n blockquoteInner: \"cm-blockquote-inner\",\n link: \"cm-link\",\n mention: \"cm-mention\",\n};\n"],"names":[],"mappings":"AAAa,MAAA,OAAO,GAAG;AACrB,IAAA,UAAU,EAAE,gBAAgB;AAC5B,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,aAAa,EAAE,oBAAoB;AACnC,IAAA,SAAS,EAAE,eAAe;AAC1B,IAAA,UAAU,EAAE,gBAAgB;AAC5B,IAAA,iBAAiB,EAAE,wBAAwB;AAC3C,IAAA,cAAc,EAAE,qBAAqB;AACrC,IAAA,iBAAiB,EAAE,wBAAwB;AAC3C,IAAA,cAAc,EAAE,cAAc;AAC9B,IAAA,UAAU,EAAE,eAAe;AAC3B,IAAA,UAAU,EAAE,eAAe;AAC3B,IAAA,eAAe,EAAE,qBAAqB;AACtC,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,OAAO,EAAE,YAAY;;;;;"}
@@ -29,6 +29,8 @@ const THEME_CONFIG = {
29
29
  mentionColor: "#8A5CF5",
30
30
  vimSelection: "#1A1919FF",
31
31
  vimSelectionFocused: "#2E4B4BFF",
32
+ codeBlockBorderColor: "#7b7e81",
33
+ codeBlockBackground: "#24292e",
32
34
  };
33
35
  function getDarkTheme({ dark }) {
34
36
  const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig || {}) };
@@ -1 +1 @@
1
- {"version":3,"file":"get-dark-theme.js","sources":["../../../../../src/extensions/theme/themes/get-dark-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#f97583\",\n variable: \"#ffab70\",\n function: \"#79b8ff\",\n string: \"#9ecbff\",\n constant: \"#79b8ff\",\n type: \"#79b8ff\",\n class: \"#b392f0\",\n number: \"#79b8ff\",\n comment: \"#6a737d\",\n heading: \"#79b8ff\",\n invalid: \"#f97583\",\n regexp: \"#9ecbff\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"#2E3235\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#24292e\",\n codeButtonBackground: \"#434C54FF\",\n codeButtonColor: \"#DDDDDD\",\n codeColor: \"#DDDDDD\",\n color: \"#DDDDDD\",\n fontFamily: \"Montserrat\",\n horizontalColor: \"#DDDDDD\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#1A1919FF\",\n vimSelectionFocused: \"#2E4B4BFF\",\n};\n\nexport function getDarkTheme({ dark }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig || {}) };\n const themeConfig = { ...THEME_CONFIG, ...(dark?.themeConfig || {}) };\n\n return [getThemeTemplate(true, themeConfig), getHighlightTemplate(highlightConfig)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAgB,GAA8B;AAClD,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE,SAAS;CAClB;AAED,MAAM,YAAY,GAA0B;AAC1C,IAAA,UAAU,EAAE,SAAS;IACrB,eAAe,EAAE,SAAS;AAC1B,IAAA,cAAc,EAAE,SAAS;AACzB,IAAA,oBAAoB,EAAE,WAAW;AACjC,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,YAAY,EAAE,WAAW;AACzB,IAAA,mBAAmB,EAAE,WAAW;CACjC;AAEe,SAAA,YAAY,CAAC,EAAE,IAAI,EAAoB,EAAA;AACrD,IAAA,MAAM,eAAe,GAAG,EAAE,GAAG,gBAAgB,EAAE,IAAI,IAAI,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE;AACjF,IAAA,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,IAAI,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE;AAErE,IAAA,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;AACrF;;;;"}
1
+ {"version":3,"file":"get-dark-theme.js","sources":["../../../../../src/extensions/theme/themes/get-dark-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#f97583\",\n variable: \"#ffab70\",\n function: \"#79b8ff\",\n string: \"#9ecbff\",\n constant: \"#79b8ff\",\n type: \"#79b8ff\",\n class: \"#b392f0\",\n number: \"#79b8ff\",\n comment: \"#6a737d\",\n heading: \"#79b8ff\",\n invalid: \"#f97583\",\n regexp: \"#9ecbff\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"#2E3235\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#24292e\",\n codeButtonBackground: \"#434C54FF\",\n codeButtonColor: \"#DDDDDD\",\n codeColor: \"#DDDDDD\",\n color: \"#DDDDDD\",\n fontFamily: \"Montserrat\",\n horizontalColor: \"#DDDDDD\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#1A1919FF\",\n vimSelectionFocused: \"#2E4B4BFF\",\n codeBlockBorderColor: \"#7b7e81\",\n codeBlockBackground: \"#24292e\",\n};\n\nexport function getDarkTheme({ dark }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig || {}) };\n const themeConfig = { ...THEME_CONFIG, ...(dark?.themeConfig || {}) };\n\n return [getThemeTemplate(true, themeConfig), getHighlightTemplate(highlightConfig)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAgB,GAA8B;AAClD,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE,SAAS;CAClB;AAED,MAAM,YAAY,GAA0B;AAC1C,IAAA,UAAU,EAAE,SAAS;IACrB,eAAe,EAAE,SAAS;AAC1B,IAAA,cAAc,EAAE,SAAS;AACzB,IAAA,oBAAoB,EAAE,WAAW;AACjC,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,YAAY,EAAE,WAAW;AACzB,IAAA,mBAAmB,EAAE,WAAW;AAChC,IAAA,oBAAoB,EAAE,SAAS;AAC/B,IAAA,mBAAmB,EAAE,SAAS;CAC/B;AAEe,SAAA,YAAY,CAAC,EAAE,IAAI,EAAoB,EAAA;AACrD,IAAA,MAAM,eAAe,GAAG,EAAE,GAAG,gBAAgB,EAAE,IAAI,IAAI,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE;AACjF,IAAA,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,IAAI,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE;AAErE,IAAA,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;AACrF;;;;"}
@@ -29,6 +29,8 @@ const THEME_CONFIG = {
29
29
  mentionColor: "#8A5CF5",
30
30
  vimSelection: "#d9d9d9",
31
31
  vimSelectionFocused: "#d7d4f0",
32
+ codeBlockBackground: "#e1e2e7",
33
+ codeBlockBorderColor: "##CCCCCDFF",
32
34
  };
33
35
  function getLightTheme({ light }) {
34
36
  const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig || {}) };
@@ -1 +1 @@
1
- {"version":3,"file":"get-light-theme.js","sources":["../../../../../src/extensions/theme/themes/get-light-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#9854f1\",\n variable: \"#3760bf\",\n function: \"#2e7de9\",\n string: \"#587539\",\n constant: \"#9854f1\",\n type: \"#07879d\",\n class: \"#3760bf\",\n number: \"#b15c00\",\n comment: \"#9da3c2\",\n heading: \"#006a83\",\n invalid: \"#ff3e64\",\n regexp: \"#2e5857\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"transparent\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#e1e2e7\",\n codeButtonBackground: \"#CCCCCDFF\",\n codeButtonColor: \"#000000\",\n codeColor: \"#000000\",\n color: \"#000000\",\n fontFamily: \"Montserrat\",\n horizontalColor: \"#000000\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#d9d9d9\",\n vimSelectionFocused: \"#d7d4f0\",\n};\n\nexport function getLightTheme({ light }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig || {}) };\n const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig || {}) };\n\n return [getThemeTemplate(false, themeConfig), getHighlightTemplate(highlightConfig)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAgB,GAA8B;AAClD,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE,SAAS;CAClB;AAED,MAAM,YAAY,GAA0B;AAC1C,IAAA,UAAU,EAAE,aAAa;IACzB,eAAe,EAAE,SAAS;AAC1B,IAAA,cAAc,EAAE,SAAS;AACzB,IAAA,oBAAoB,EAAE,WAAW;AACjC,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,mBAAmB,EAAE,SAAS;CAC/B;AAEe,SAAA,aAAa,CAAC,EAAE,KAAK,EAAoB,EAAA;AACvD,IAAA,MAAM,eAAe,GAAG,EAAE,GAAG,gBAAgB,EAAE,IAAI,KAAK,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE;AAClF,IAAA,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,IAAI,KAAK,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE;AAEtE,IAAA,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;AACtF;;;;"}
1
+ {"version":3,"file":"get-light-theme.js","sources":["../../../../../src/extensions/theme/themes/get-light-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#9854f1\",\n variable: \"#3760bf\",\n function: \"#2e7de9\",\n string: \"#587539\",\n constant: \"#9854f1\",\n type: \"#07879d\",\n class: \"#3760bf\",\n number: \"#b15c00\",\n comment: \"#9da3c2\",\n heading: \"#006a83\",\n invalid: \"#ff3e64\",\n regexp: \"#2e5857\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"transparent\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#e1e2e7\",\n codeButtonBackground: \"#CCCCCDFF\",\n codeButtonColor: \"#000000\",\n codeColor: \"#000000\",\n color: \"#000000\",\n fontFamily: \"Montserrat\",\n horizontalColor: \"#000000\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#d9d9d9\",\n vimSelectionFocused: \"#d7d4f0\",\n codeBlockBackground: \"#e1e2e7\",\n codeBlockBorderColor: \"##CCCCCDFF\",\n};\n\nexport function getLightTheme({ light }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig || {}) };\n const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig || {}) };\n\n return [getThemeTemplate(false, themeConfig), getHighlightTemplate(highlightConfig)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAgB,GAA8B;AAClD,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE,SAAS;CAClB;AAED,MAAM,YAAY,GAA0B;AAC1C,IAAA,UAAU,EAAE,aAAa;IACzB,eAAe,EAAE,SAAS;AAC1B,IAAA,cAAc,EAAE,SAAS;AACzB,IAAA,oBAAoB,EAAE,WAAW;AACjC,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,mBAAmB,EAAE,SAAS;AAC9B,IAAA,mBAAmB,EAAE,SAAS;AAC9B,IAAA,oBAAoB,EAAE,YAAY;CACnC;AAEe,SAAA,aAAa,CAAC,EAAE,KAAK,EAAoB,EAAA;AACvD,IAAA,MAAM,eAAe,GAAG,EAAE,GAAG,gBAAgB,EAAE,IAAI,KAAK,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE;AAClF,IAAA,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,IAAI,KAAK,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE;AAEtE,IAAA,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;AACtF;;;;"}
@@ -62,6 +62,12 @@ function getThemeTemplate(dark, config) {
62
62
  [`.${CLASSES.mention}`]: {
63
63
  color: config.mentionColor,
64
64
  },
65
+ [`.${CLASSES.codeBlockLine}`]: {
66
+ borderColor: config.codeBlockBorderColor,
67
+ },
68
+ [`.${CLASSES.codeBlock}`]: {
69
+ background: config.codeBlockBackground,
70
+ },
65
71
  }, { dark });
66
72
  }
67
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"get-theme-template.js","sources":["../../../../../src/extensions/theme/themes/get-theme-template.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { CLASSES } from \"../theme-constants\";\nimport type { ThemeConfig } from \"../theme-types\";\n\nexport function getThemeTemplate(dark: boolean, config: Required<ThemeConfig>) {\n return EditorView.theme(\n {\n \"&\": {\n color: config.color,\n backgroundColor: config.background,\n },\n \".cm-content\": {\n fontFamily: config.fontFamily || \"Montserrat\",\n },\n \"&.cm-focused > .cm-scroller > .cm-selectionLayer > .cm-selectionBackground\": {\n background: config.vimSelectionFocused,\n },\n \"& .cm-selectionBackground\": {\n background: config.vimSelection,\n },\n \"&.cm-editor.cm-focused\": { outline: \"none\" },\n \"&.cm-editor\": {\n height: \"100%\",\n width: \"100%\",\n },\n [`.${CLASSES.listCommon}:after`]: {\n background: config.color,\n },\n [`.${CLASSES.code}`]: {\n background: config.codeBackground,\n color: config.codeColor,\n },\n [`.${CLASSES.horizontal}`]: {\n borderBottomColor: config.horizontalColor,\n },\n [`.${CLASSES.link}`]: {\n color: config.linkColor,\n },\n [`.${CLASSES.blockquote}`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.blockquoteInner}:before`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.codeButton}`]: {\n color: config.codeButtonColor,\n },\n [`.${CLASSES.codeButton}:hover`]: {\n background: config.codeButtonBackground,\n },\n [`.${CLASSES.codeButtonSuccess}:after`]: {\n borderColor: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:after`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:before`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonPending}:before`]: {\n borderColor: config.codeBackground,\n borderTopColor: config.codeButtonColor,\n },\n [`.${CLASSES.mention}`]: {\n color: config.mentionColor,\n },\n },\n { dark },\n );\n}\n"],"names":[],"mappings":";;;AAIgB,SAAA,gBAAgB,CAAC,IAAa,EAAE,MAA6B,EAAA;IAC3E,OAAO,UAAU,CAAC,KAAK,CACrB;AACE,QAAA,GAAG,EAAE;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,eAAe,EAAE,MAAM,CAAC,UAAU;AACnC,SAAA;AACD,QAAA,aAAa,EAAE;AACb,YAAA,UAAU,EAA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EAAE,MAAM,CAAC,oBAAoB;AACxC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,iBAAiB,CAAA,MAAA,CAAQ,GAAG;YACvC,WAAW,EAAE,MAAM,CAAC,eAAe;AACpC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,cAAc,CAAA,MAAA,CAAQ,GAAG;YACpC,UAAU,EAAE,MAAM,CAAC,eAAe;AACnC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,cAAc,CAAA,OAAA,CAAS,GAAG;YACrC,UAAU,EAAE,MAAM,CAAC,eAAe;AACnC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,iBAAiB,CAAA,OAAA,CAAS,GAAG;YACxC,WAAW,EAAE,MAAM,CAAC,cAAc;YAClC,cAAc,EAAE,MAAM,CAAC,eAAe;AACvC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,OAAO,CAAA,CAAE,GAAG;YACvB,KAAK,EAAE,MAAM,CAAC,YAAY;AAC3B,SAAA;AACF,KAAA,EACD,EAAE,IAAI,EAAE,CACT;AACH;;;;"}
1
+ {"version":3,"file":"get-theme-template.js","sources":["../../../../../src/extensions/theme/themes/get-theme-template.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { CLASSES } from \"../theme-constants\";\nimport type { ThemeConfig } from \"../theme-types\";\n\nexport function getThemeTemplate(dark: boolean, config: Required<ThemeConfig>) {\n return EditorView.theme(\n {\n \"&\": {\n color: config.color,\n backgroundColor: config.background,\n },\n \".cm-content\": {\n fontFamily: config.fontFamily || \"Montserrat\",\n },\n \"&.cm-focused > .cm-scroller > .cm-selectionLayer > .cm-selectionBackground\": {\n background: config.vimSelectionFocused,\n },\n \"& .cm-selectionBackground\": {\n background: config.vimSelection,\n },\n \"&.cm-editor.cm-focused\": { outline: \"none\" },\n \"&.cm-editor\": {\n height: \"100%\",\n width: \"100%\",\n },\n [`.${CLASSES.listCommon}:after`]: {\n background: config.color,\n },\n [`.${CLASSES.code}`]: {\n background: config.codeBackground,\n color: config.codeColor,\n },\n [`.${CLASSES.horizontal}`]: {\n borderBottomColor: config.horizontalColor,\n },\n [`.${CLASSES.link}`]: {\n color: config.linkColor,\n },\n [`.${CLASSES.blockquote}`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.blockquoteInner}:before`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.codeButton}`]: {\n color: config.codeButtonColor,\n },\n [`.${CLASSES.codeButton}:hover`]: {\n background: config.codeButtonBackground,\n },\n [`.${CLASSES.codeButtonSuccess}:after`]: {\n borderColor: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:after`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:before`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonPending}:before`]: {\n borderColor: config.codeBackground,\n borderTopColor: config.codeButtonColor,\n },\n [`.${CLASSES.mention}`]: {\n color: config.mentionColor,\n },\n [`.${CLASSES.codeBlockLine}`]: {\n borderColor: config.codeBlockBorderColor,\n },\n [`.${CLASSES.codeBlock}`]: {\n background: config.codeBlockBackground,\n },\n },\n { dark },\n );\n}\n"],"names":[],"mappings":";;;AAIgB,SAAA,gBAAgB,CAAC,IAAa,EAAE,MAA6B,EAAA;IAC3E,OAAO,UAAU,CAAC,KAAK,CACrB;AACE,QAAA,GAAG,EAAE;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,eAAe,EAAE,MAAM,CAAC,UAAU;AACnC,SAAA;AACD,QAAA,aAAa,EAAE;AACb,YAAA,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,YAAY;AAC9C,SAAA;AACD,QAAA,4EAA4E,EAAE;YAC5E,UAAU,EAAE,MAAM,CAAC,mBAAmB;AACvC,SAAA;AACD,QAAA,2BAA2B,EAAE;YAC3B,UAAU,EAAE,MAAM,CAAC,YAAY;AAChC,SAAA;AACD,QAAA,wBAAwB,EAA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;YACpC,UAAU,EAAE,MAAM,CAAC,eAAe;AACnC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,cAAc,CAAA,OAAA,CAAS,GAAG;YACrC,UAAU,EAAE,MAAM,CAAC,eAAe;AACnC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,iBAAiB,CAAA,OAAA,CAAS,GAAG;YACxC,WAAW,EAAE,MAAM,CAAC,cAAc;YAClC,cAAc,EAAE,MAAM,CAAC,eAAe;AACvC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,OAAO,CAAA,CAAE,GAAG;YACvB,KAAK,EAAE,MAAM,CAAC,YAAY;AAC3B,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,aAAa,CAAA,CAAE,GAAG;YAC7B,WAAW,EAAE,MAAM,CAAC,oBAAoB;AACzC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,SAAS,CAAA,CAAE,GAAG;YACzB,UAAU,EAAE,MAAM,CAAC,mBAAmB;AACvC,SAAA;AACF,KAAA,EACD,EAAE,IAAI,EAAE,CACT;AACH;;;;"}
package/lib/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { Editor } from './module/Editor/Editor.js';
2
2
  import './extensions/compartments/index.js';
3
+ import '@codemirror/autocomplete';
3
4
  import '@codemirror/commands';
4
5
  import '@codemirror/view';
5
6
  import '@codemirror/language';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}