@gravity-ui/markdown-editor 15.35.0 → 15.36.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 (101) hide show
  1. package/build/cjs/core/Editor.js +2 -0
  2. package/build/cjs/core/Editor.js.map +1 -1
  3. package/build/cjs/core/index.d.ts +1 -0
  4. package/build/cjs/core/index.js +3 -1
  5. package/build/cjs/core/index.js.map +1 -1
  6. package/build/cjs/core/markdown/MarkdownParser.d.ts +1 -0
  7. package/build/cjs/core/markdown/MarkdownParser.js +3 -0
  8. package/build/cjs/core/markdown/MarkdownParser.js.map +1 -1
  9. package/build/cjs/core/types/parser.d.ts +1 -0
  10. package/build/cjs/core/types/parser.js.map +1 -1
  11. package/build/cjs/core/utils/parser.d.ts +3 -0
  12. package/build/cjs/core/utils/parser.js +12 -0
  13. package/build/cjs/core/utils/parser.js.map +1 -0
  14. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js +11 -7
  15. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js.map +1 -1
  16. package/build/cjs/extensions/additional/Mermaid/index.d.ts +5 -0
  17. package/build/cjs/extensions/additional/Mermaid/index.js.map +1 -1
  18. package/build/cjs/extensions/behavior/SelectionContext/tooltip.js +3 -0
  19. package/build/cjs/extensions/behavior/SelectionContext/tooltip.js.map +1 -1
  20. package/build/cjs/extensions/markdown/Bold/index.js +1 -1
  21. package/build/cjs/extensions/markdown/Bold/index.js.map +1 -1
  22. package/build/cjs/extensions/markdown/Code/index.js +1 -1
  23. package/build/cjs/extensions/markdown/Code/index.js.map +1 -1
  24. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +75 -66
  25. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
  26. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/plugins/codeBlockLineNumbersPlugin.js +42 -22
  27. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/plugins/codeBlockLineNumbersPlugin.js.map +1 -1
  28. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/utils.js +20 -0
  29. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/utils.js.map +1 -1
  30. package/build/cjs/extensions/markdown/Italic/index.js +1 -1
  31. package/build/cjs/extensions/markdown/Italic/index.js.map +1 -1
  32. package/build/cjs/extensions/markdown/Mark/index.js +1 -1
  33. package/build/cjs/extensions/markdown/Mark/index.js.map +1 -1
  34. package/build/cjs/extensions/markdown/Strike/index.js +1 -1
  35. package/build/cjs/extensions/markdown/Strike/index.js.map +1 -1
  36. package/build/cjs/extensions/markdown/Underline/index.js +1 -1
  37. package/build/cjs/extensions/markdown/Underline/index.js.map +1 -1
  38. package/build/cjs/extensions/yfm/Monospace/index.js +1 -1
  39. package/build/cjs/extensions/yfm/Monospace/index.js.map +1 -1
  40. package/build/cjs/utils/actions.d.ts +6 -0
  41. package/build/cjs/utils/actions.js +24 -0
  42. package/build/cjs/utils/actions.js.map +1 -1
  43. package/build/cjs/utils/marks.d.ts +6 -0
  44. package/build/cjs/utils/marks.js +31 -0
  45. package/build/cjs/utils/marks.js.map +1 -1
  46. package/build/cjs/utils/transaction.d.ts +1 -0
  47. package/build/cjs/utils/transaction.js +40 -0
  48. package/build/cjs/utils/transaction.js.map +1 -0
  49. package/build/cjs/version.js +1 -1
  50. package/build/cjs/version.js.map +1 -1
  51. package/build/esm/core/Editor.js +2 -0
  52. package/build/esm/core/Editor.js.map +1 -1
  53. package/build/esm/core/index.d.ts +1 -0
  54. package/build/esm/core/index.js +1 -0
  55. package/build/esm/core/index.js.map +1 -1
  56. package/build/esm/core/markdown/MarkdownParser.d.ts +1 -0
  57. package/build/esm/core/markdown/MarkdownParser.js +3 -0
  58. package/build/esm/core/markdown/MarkdownParser.js.map +1 -1
  59. package/build/esm/core/types/parser.d.ts +1 -0
  60. package/build/esm/core/types/parser.js.map +1 -1
  61. package/build/esm/core/utils/parser.d.ts +3 -0
  62. package/build/esm/core/utils/parser.js +8 -0
  63. package/build/esm/core/utils/parser.js.map +1 -0
  64. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js +11 -7
  65. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js.map +1 -1
  66. package/build/esm/extensions/additional/Mermaid/index.d.ts +5 -0
  67. package/build/esm/extensions/additional/Mermaid/index.js.map +1 -1
  68. package/build/esm/extensions/behavior/SelectionContext/tooltip.js +3 -0
  69. package/build/esm/extensions/behavior/SelectionContext/tooltip.js.map +1 -1
  70. package/build/esm/extensions/markdown/Bold/index.js +2 -2
  71. package/build/esm/extensions/markdown/Bold/index.js.map +1 -1
  72. package/build/esm/extensions/markdown/Code/index.js +2 -2
  73. package/build/esm/extensions/markdown/Code/index.js.map +1 -1
  74. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +75 -66
  75. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
  76. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/plugins/codeBlockLineNumbersPlugin.js +43 -23
  77. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/plugins/codeBlockLineNumbersPlugin.js.map +1 -1
  78. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/utils.js +20 -1
  79. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/utils.js.map +1 -1
  80. package/build/esm/extensions/markdown/Italic/index.js +2 -2
  81. package/build/esm/extensions/markdown/Italic/index.js.map +1 -1
  82. package/build/esm/extensions/markdown/Mark/index.js +2 -2
  83. package/build/esm/extensions/markdown/Mark/index.js.map +1 -1
  84. package/build/esm/extensions/markdown/Strike/index.js +2 -2
  85. package/build/esm/extensions/markdown/Strike/index.js.map +1 -1
  86. package/build/esm/extensions/markdown/Underline/index.js +2 -2
  87. package/build/esm/extensions/markdown/Underline/index.js.map +1 -1
  88. package/build/esm/extensions/yfm/Monospace/index.js +2 -2
  89. package/build/esm/extensions/yfm/Monospace/index.js.map +1 -1
  90. package/build/esm/utils/actions.d.ts +6 -0
  91. package/build/esm/utils/actions.js +24 -1
  92. package/build/esm/utils/actions.js.map +1 -1
  93. package/build/esm/utils/marks.d.ts +6 -0
  94. package/build/esm/utils/marks.js +30 -0
  95. package/build/esm/utils/marks.js.map +1 -1
  96. package/build/esm/utils/transaction.d.ts +1 -0
  97. package/build/esm/utils/transaction.js +36 -0
  98. package/build/esm/utils/transaction.js.map +1 -0
  99. package/build/esm/version.js +1 -1
  100. package/build/esm/version.js.map +1 -1
  101. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { Plugin, PluginKey } from "../../../../../pm/state.js";
2
2
  import { findChildrenByType } from "../../../../../pm/utils.js";
3
3
  import { Decoration, DecorationSet } from "../../../../../pm/view.js";
4
4
  import { codeBlockType } from "../../CodeBlockSpecs/index.js";
5
- import { isLineNumbersVisible } from "../utils.js";
5
+ import { isLineNumbersVisible, processChangedCodeBlocks } from "../utils.js";
6
6
  const pluginKey = new PluginKey('code_block_line_numbers_decorations');
7
7
  /** @internal */
8
8
  export const codeBlockLineNumbersPlugin = () => {
@@ -10,42 +10,62 @@ export const codeBlockLineNumbersPlugin = () => {
10
10
  key: pluginKey,
11
11
  state: {
12
12
  init(_config, state) {
13
- return getDecorations(state.doc);
13
+ const cache = new WeakSet();
14
+ return { cache, decoSet: buildAllDecorations(state.doc, cache) };
14
15
  },
15
- apply(tr, decos) {
16
- if (tr.docChanged) {
17
- return getDecorations(tr.doc);
18
- }
19
- return decos.map(tr.mapping, tr.doc);
16
+ apply(tr, { cache, decoSet }) {
17
+ if (!tr.docChanged)
18
+ return { cache, decoSet };
19
+ decoSet = processChangedCodeBlocks(tr, decoSet, (node, pos, decoSet) => {
20
+ if (!isLineNumbersVisible(node)) {
21
+ return decoSet.remove(decoSet.find(pos, pos + node.nodeSize));
22
+ }
23
+ if (cache.has(node)) {
24
+ // node has not changed, but decorations may be missing (after undo/redo)
25
+ if (!decoSet.find(pos, pos + node.nodeSize).length) {
26
+ return decoSet.add(tr.doc, buildNodeDecorations(node, pos));
27
+ }
28
+ return decoSet;
29
+ }
30
+ decoSet = decoSet.remove(decoSet.find(pos, pos + node.nodeSize));
31
+ cache.add(node);
32
+ return decoSet.add(tr.doc, buildNodeDecorations(node, pos));
33
+ });
34
+ return { cache, decoSet };
20
35
  },
21
36
  },
22
37
  props: {
23
38
  decorations(state) {
24
- return pluginKey.getState(state);
39
+ return pluginKey.getState(state)?.decoSet;
25
40
  },
26
41
  },
27
42
  });
28
43
  };
29
- function getDecorations(doc) {
44
+ function buildAllDecorations(doc, cache) {
30
45
  const decos = [];
31
46
  for (const { node, pos } of findChildrenByType(doc, codeBlockType(doc.type.schema), true)) {
32
47
  if (!isLineNumbersVisible(node))
33
48
  continue;
34
- const codeContent = node.textContent;
35
- const contentByLines = codeContent.split('\n');
36
- const maxDigits = String(contentByLines.length).length;
37
- let shift = 0;
38
- for (let i = 0; i < contentByLines.length; i++) {
39
- const line = contentByLines[i];
40
- {
41
- const elem = document.createElement('span');
42
- elem.classList.add('yfm-line-number');
43
- elem.textContent = String(i + 1).padStart(maxDigits, ' ');
44
- decos.push(Decoration.widget(pos + shift + 1, elem, { side: 1, ignoreSelection: true }));
45
- }
46
- shift += line.length + 1;
47
- }
49
+ const nodeDecos = buildNodeDecorations(node, pos);
50
+ cache.add(node);
51
+ decos.push(...nodeDecos);
48
52
  }
49
53
  return DecorationSet.create(doc, decos);
50
54
  }
55
+ function buildNodeDecorations(node, pos) {
56
+ const decos = [];
57
+ const codeContent = node.textContent;
58
+ const contentByLines = codeContent.split('\n');
59
+ const maxDigits = String(contentByLines.length).length;
60
+ let shift = 0;
61
+ for (let i = 0; i < contentByLines.length; i++) {
62
+ const line = contentByLines[i];
63
+ const elem = document.createElement('span');
64
+ elem.classList.add('yfm-line-number');
65
+ elem.textContent = String(i + 1).padStart(maxDigits, ' ');
66
+ decos.push(Decoration.widget(pos + shift + 1, elem, { side: 1, ignoreSelection: true }));
67
+ shift += line.length + 1;
68
+ }
69
+ return decos;
70
+ }
51
71
  //# sourceMappingURL=codeBlockLineNumbersPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codeBlockLineNumbersPlugin.js","sourceRoot":"../../../../../../../src","sources":["extensions/markdown/CodeBlock/CodeBlockHighlight/plugins/codeBlockLineNumbersPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,mCAAkB;AAC5C,OAAO,EAAC,kBAAkB,EAAC,mCAAkB;AAC7C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,kCAAiB;AAEnD,OAAO,EAAC,aAAa,EAAC,sCAA6B;AACnD,OAAO,EAAC,oBAAoB,EAAC,oBAAiB;AAE9C,MAAM,SAAS,GAAG,IAAI,SAAS,CAAgB,qCAAqC,CAAC,CAAC;AAEtF,gBAAgB;AAChB,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,EAAE;IAC3C,OAAO,IAAI,MAAM,CAAgB;QAC7B,GAAG,EAAE,SAAS;QACd,KAAK,EAAE;YACH,IAAI,CAAC,OAAO,EAAE,KAAK;gBACf,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrC,CAAC;YACD,KAAK,CAAC,EAAE,EAAE,KAAK;gBACX,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;oBAChB,OAAO,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;gBAClC,CAAC;gBAED,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;YACzC,CAAC;SACJ;QACD,KAAK,EAAE;YACH,WAAW,CAAC,KAAK;gBACb,OAAO,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;SACJ;KACJ,CAAC,CAAC;AACP,CAAC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AAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type {Node} from '#pm/model';\nimport {Plugin, PluginKey} from '#pm/state';\nimport {findChildrenByType} from '#pm/utils';\nimport {Decoration, DecorationSet} from '#pm/view';\n\nimport {codeBlockType} from '../../CodeBlockSpecs';\nimport {isLineNumbersVisible} from '../utils';\n\nconst pluginKey = new PluginKey<DecorationSet>('code_block_line_numbers_decorations');\n\n/** @internal */\nexport const codeBlockLineNumbersPlugin = () => {\n return new Plugin<DecorationSet>({\n key: pluginKey,\n state: {\n init(_config, state) {\n return getDecorations(state.doc);\n },\n apply(tr, decos) {\n if (tr.docChanged) {\n return getDecorations(tr.doc);\n }\n\n return decos.map(tr.mapping, tr.doc);\n },\n },\n props: {\n decorations(state) {\n return pluginKey.getState(state);\n },\n },\n });\n};\n\nfunction getDecorations(doc: Node) {\n const decos: Decoration[] = [];\n\n for (const {node, pos} of findChildrenByType(doc, codeBlockType(doc.type.schema), true)) {\n if (!isLineNumbersVisible(node)) continue;\n\n const codeContent = node.textContent;\n const contentByLines = codeContent.split('\\n');\n\n const maxDigits = String(contentByLines.length).length;\n\n let shift = 0;\n for (let i = 0; i < contentByLines.length; i++) {\n const line = contentByLines[i];\n\n {\n const elem = document.createElement('span');\n elem.classList.add('yfm-line-number');\n elem.textContent = String(i + 1).padStart(maxDigits, ' ');\n\n decos.push(\n Decoration.widget(pos + shift + 1, elem, {side: 1, ignoreSelection: true}),\n );\n }\n\n shift += line.length + 1;\n }\n }\n\n return DecorationSet.create(doc, decos);\n}\n"]}
1
+ {"version":3,"file":"codeBlockLineNumbersPlugin.js","sourceRoot":"../../../../../../../src","sources":["extensions/markdown/CodeBlock/CodeBlockHighlight/plugins/codeBlockLineNumbersPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,mCAAkB;AAC5C,OAAO,EAAC,kBAAkB,EAAC,mCAAkB;AAC7C,OAAO,EAAC,UAAU,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AAU,EAAE,GAAW;IACjD,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrC,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAEvD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QAE/B,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAE1D,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;QAEvF,KAAK,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import type {Node} from '#pm/model';\nimport {Plugin, PluginKey} from '#pm/state';\nimport {findChildrenByType} from '#pm/utils';\nimport {Decoration, DecorationSet} from '#pm/view';\n\nimport {codeBlockType} from '../../CodeBlockSpecs';\nimport {isLineNumbersVisible, processChangedCodeBlocks} from '../utils';\n\ntype LineNumberCache = WeakSet<Node>;\n\ntype PluginState = {\n cache: LineNumberCache;\n decoSet: DecorationSet;\n};\n\nconst pluginKey = new PluginKey<PluginState>('code_block_line_numbers_decorations');\n\n/** @internal */\nexport const codeBlockLineNumbersPlugin = () => {\n return new Plugin<PluginState>({\n key: pluginKey,\n state: {\n init(_config, state) {\n const cache: LineNumberCache = new WeakSet();\n return {cache, decoSet: buildAllDecorations(state.doc, cache)};\n },\n apply(tr, {cache, decoSet}) {\n if (!tr.docChanged) return {cache, decoSet};\n\n decoSet = processChangedCodeBlocks(tr, decoSet, (node, pos, decoSet) => {\n if (!isLineNumbersVisible(node)) {\n return decoSet.remove(decoSet.find(pos, pos + node.nodeSize));\n }\n\n if (cache.has(node)) {\n // node has not changed, but decorations may be missing (after undo/redo)\n if (!decoSet.find(pos, pos + node.nodeSize).length) {\n return decoSet.add(tr.doc, buildNodeDecorations(node, pos));\n }\n return decoSet;\n }\n\n decoSet = decoSet.remove(decoSet.find(pos, pos + node.nodeSize));\n cache.add(node);\n return decoSet.add(tr.doc, buildNodeDecorations(node, pos));\n });\n\n return {cache, decoSet};\n },\n },\n props: {\n decorations(state) {\n return pluginKey.getState(state)?.decoSet;\n },\n },\n });\n};\n\nfunction buildAllDecorations(doc: Node, cache: LineNumberCache) {\n const decos: Decoration[] = [];\n\n for (const {node, pos} of findChildrenByType(doc, codeBlockType(doc.type.schema), true)) {\n if (!isLineNumbersVisible(node)) continue;\n\n const nodeDecos = buildNodeDecorations(node, pos);\n cache.add(node);\n decos.push(...nodeDecos);\n }\n\n return DecorationSet.create(doc, decos);\n}\n\nfunction buildNodeDecorations(node: Node, pos: number): Decoration[] {\n const decos: Decoration[] = [];\n const codeContent = node.textContent;\n const contentByLines = codeContent.split('\\n');\n const maxDigits = String(contentByLines.length).length;\n\n let shift = 0;\n for (let i = 0; i < contentByLines.length; i++) {\n const line = contentByLines[i];\n\n const elem = document.createElement('span');\n elem.classList.add('yfm-line-number');\n elem.textContent = String(i + 1).padStart(maxDigits, ' ');\n\n decos.push(Decoration.widget(pos + shift + 1, elem, {side: 1, ignoreSelection: true}));\n\n shift += line.length + 1;\n }\n\n return decos;\n}\n"]}
@@ -1,6 +1,25 @@
1
- import { CodeBlockNodeAttr } from "../CodeBlockSpecs/index.js";
1
+ import { forEachChangedNode } from "../../../../utils/transaction.js";
2
+ import { CodeBlockNodeAttr, codeBlockNodeName } from "../CodeBlockSpecs/index.js";
2
3
  /** @internal */
3
4
  export function isLineNumbersVisible(node) {
4
5
  return node.attrs[CodeBlockNodeAttr.ShowLineNumbers] === 'true';
5
6
  }
7
+ /** @internal */
8
+ export function processChangedCodeBlocks(tr, decoSet, onCodeBlock) {
9
+ decoSet = decoSet.map(tr.mapping, tr.doc);
10
+ forEachChangedNode(tr, (node, pos) => {
11
+ if (node.type.name !== codeBlockNodeName) {
12
+ if (node.isTextblock) {
13
+ // Remove stale decorations from non-code_block textblocks
14
+ // (e.g. when a code_block is converted to a paragraph)
15
+ decoSet = decoSet.remove(decoSet.find(pos, pos + node.nodeSize));
16
+ return false;
17
+ }
18
+ return true;
19
+ }
20
+ decoSet = onCodeBlock(node, pos, decoSet);
21
+ return false;
22
+ });
23
+ return decoSet;
24
+ }
6
25
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/CodeBlock/CodeBlockHighlight/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,iBAAiB,EAAC,mCAA0B;AAEpD,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;AACpE,CAAC","sourcesContent":["import type {Node} from '#pm/model';\n\nimport {CodeBlockNodeAttr} from '../CodeBlockSpecs';\n\n/** @internal */\nexport function isLineNumbersVisible(node: Node): boolean {\n return node.attrs[CodeBlockNodeAttr.ShowLineNumbers] === 'true';\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/CodeBlock/CodeBlockHighlight/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,kBAAkB,EAAC,yCAA8B;AAEzD,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,mCAA0B;AAEvE,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;AACpE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CACpC,EAAe,EACf,OAAsB,EACtB,WAA+E;IAE/E,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IAE1C,kBAAkB,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACjC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACnB,0DAA0D;gBAC1D,uDAAuD;gBACvD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACjE,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import type {Node} from '#pm/model';\nimport type {Transaction} from '#pm/state';\nimport type {DecorationSet} from '#pm/view';\nimport {forEachChangedNode} from 'src/utils/transaction';\n\nimport {CodeBlockNodeAttr, codeBlockNodeName} from '../CodeBlockSpecs';\n\n/** @internal */\nexport function isLineNumbersVisible(node: Node): boolean {\n return node.attrs[CodeBlockNodeAttr.ShowLineNumbers] === 'true';\n}\n\n/** @internal */\nexport function processChangedCodeBlocks(\n tr: Transaction,\n decoSet: DecorationSet,\n onCodeBlock: (node: Node, pos: number, decoSet: DecorationSet) => DecorationSet,\n): DecorationSet {\n decoSet = decoSet.map(tr.mapping, tr.doc);\n\n forEachChangedNode(tr, (node, pos) => {\n if (node.type.name !== codeBlockNodeName) {\n if (node.isTextblock) {\n // Remove stale decorations from non-code_block textblocks\n // (e.g. when a code_block is converted to a paragraph)\n decoSet = decoSet.remove(decoSet.find(pos, pos + node.nodeSize));\n return false;\n }\n return true;\n }\n decoSet = onCodeBlock(node, pos, decoSet);\n return false;\n });\n\n return decoSet;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { toggleMark } from 'prosemirror-commands';
2
- import { createToggleMarkAction } from "../../../utils/actions.js";
2
+ import { createMarkdownInlineMarkAction } from "../../../utils/actions.js";
3
3
  import { markInputRule } from "../../../utils/inputrules.js";
4
4
  import { withLogAction } from "../../../utils/keymap.js";
5
5
  import { ItalicSpecs, italicType } from "./ItalicSpecs/index.js";
@@ -7,7 +7,7 @@ export { italicMarkName, italicType } from "./ItalicSpecs/index.js";
7
7
  const iAction = 'italic';
8
8
  export const Italic = (builder, opts) => {
9
9
  builder.use(ItalicSpecs);
10
- builder.addAction(iAction, ({ schema }) => createToggleMarkAction(italicType(schema)));
10
+ builder.addAction(iAction, ({ schema }) => createMarkdownInlineMarkAction(italicType(schema)));
11
11
  builder.addInputRules(({ schema }) => ({
12
12
  rules: [
13
13
  markInputRule({ open: '*', close: '*', ignoreBetween: '*' }, italicType(schema)),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Italic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,sBAAsB,EAAC,kCAA+B;AAC9D,OAAO,EAAC,aAAa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to} from '../../../core';\nimport {createToggleMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\nimport {withLogAction} from '../../../utils/keymap';\n\nimport {ItalicSpecs, italicType} from './ItalicSpecs';\n\nexport {italicMarkName, italicType} from './ItalicSpecs';\nconst iAction = 'italic';\n\nexport type ItalicOptions = {\n italicKey?: string | null;\n};\n\nexport const Italic: ExtensionAuto<ItalicOptions> = (builder, opts) => {\n builder.use(ItalicSpecs);\n\n builder.addAction(iAction, ({schema}) => createToggleMarkAction(italicType(schema)));\n\n builder.addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '*', close: '*', ignoreBetween: '*'}, italicType(schema)),\n markInputRule({open: '_', close: '_', ignoreBetween: '_'}, italicType(schema)),\n ],\n }));\n\n if (opts?.italicKey) {\n const {italicKey} = opts;\n builder.addKeymap(({schema}) => ({\n [italicKey]: withLogAction('italic', toggleMark(italicType(schema))),\n }));\n }\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [iAction]: Action;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Italic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,8BAA8B,EAAC,kCAA+B;AACtE,OAAO,EAAC,aAAa,EAAC,qCAAkC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAEpD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,+BAAsB;AAEtD,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,+BAAsB;AACzD,MAAM,OAAO,GAAG,QAAQ,CAAC;AAMzB,MAAM,CAAC,MAAM,MAAM,GAAiC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEzB,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,8BAA8B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7F,OAAO,CAAC,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QACjC,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAC9E,aAAa,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;SACjF;KACJ,CAAC,CAAC,CAAC;IAEJ,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,MAAM,EAAC,SAAS,EAAC,GAAG,IAAI,CAAC;QACzB,OAAO,CAAC,SAAS,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACvE,CAAC,CAAC,CAAC;IACR,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {toggleMark} from 'prosemirror-commands';\n\nimport type {Action, ExtensionAuto} from '../../../core';\nimport {createMarkdownInlineMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\nimport {withLogAction} from '../../../utils/keymap';\n\nimport {ItalicSpecs, italicType} from './ItalicSpecs';\n\nexport {italicMarkName, italicType} from './ItalicSpecs';\nconst iAction = 'italic';\n\nexport type ItalicOptions = {\n italicKey?: string | null;\n};\n\nexport const Italic: ExtensionAuto<ItalicOptions> = (builder, opts) => {\n builder.use(ItalicSpecs);\n\n builder.addAction(iAction, ({schema}) => createMarkdownInlineMarkAction(italicType(schema)));\n\n builder.addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '*', close: '*', ignoreBetween: '*'}, italicType(schema)),\n markInputRule({open: '_', close: '_', ignoreBetween: '_'}, italicType(schema)),\n ],\n }));\n\n if (opts?.italicKey) {\n const {italicKey} = opts;\n builder.addKeymap(({schema}) => ({\n [italicKey]: withLogAction('italic', toggleMark(italicType(schema))),\n }));\n }\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [iAction]: Action;\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { createToggleMarkAction } from "../../../utils/actions.js";
1
+ import { createMarkdownInlineMarkAction } from "../../../utils/actions.js";
2
2
  import { markInputRule } from "../../../utils/inputrules.js";
3
3
  import { MarkSpecs, markMarkType } from "./MarkSpecs/index.js";
4
4
  export { markMarkName, markMarkType } from "./MarkSpecs/index.js";
@@ -6,7 +6,7 @@ const mAction = 'mark';
6
6
  export const Mark = (builder) => {
7
7
  builder.use(MarkSpecs);
8
8
  builder
9
- .addAction(mAction, ({ schema }) => createToggleMarkAction(markMarkType(schema)))
9
+ .addAction(mAction, ({ schema }) => createMarkdownInlineMarkAction(markMarkType(schema)))
10
10
  .addInputRules(({ schema }) => ({
11
11
  rules: [
12
12
  markInputRule({ open: '==', close: '==', ignoreBetween: '=' }, markMarkType(schema)),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Mark/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,kCAA+B;AAC9D,OAAO,EAAC,aAAa,EAAC,qCAAkC;AAExD,OAAO,EAAC,SAAS,EAAE,YAAY,EAAC,6BAAoB;AAEpD,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,6BAAoB;AACvD,MAAM,OAAO,GAAG,MAAM,CAAC;AAEvB,MAAM,CAAC,MAAM,IAAI,GAAkB,CAAC,OAAO,EAAE,EAAE;IAC3C,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAEvB,OAAO;SACF,SAAS,CAAC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;SAC9E,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;SACrF;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import type {Action, ExtensionAuto} from '../../../core';\nimport {createToggleMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\n\nimport {MarkSpecs, markMarkType} from './MarkSpecs';\n\nexport {markMarkName, markMarkType} from './MarkSpecs';\nconst mAction = 'mark';\n\nexport const Mark: ExtensionAuto = (builder) => {\n builder.use(MarkSpecs);\n\n builder\n .addAction(mAction, ({schema}) => createToggleMarkAction(markMarkType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '==', close: '==', ignoreBetween: '='}, markMarkType(schema)),\n ],\n }));\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [mAction]: Action;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Mark/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,8BAA8B,EAAC,kCAA+B;AACtE,OAAO,EAAC,aAAa,EAAC,qCAAkC;AAExD,OAAO,EAAC,SAAS,EAAE,YAAY,EAAC,6BAAoB;AAEpD,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,6BAAoB;AACvD,MAAM,OAAO,GAAG,MAAM,CAAC;AAEvB,MAAM,CAAC,MAAM,IAAI,GAAkB,CAAC,OAAO,EAAE,EAAE;IAC3C,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAEvB,OAAO;SACF,SAAS,CAAC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,8BAA8B,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;SACtF,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;SACrF;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import type {Action, ExtensionAuto} from '../../../core';\nimport {createMarkdownInlineMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\n\nimport {MarkSpecs, markMarkType} from './MarkSpecs';\n\nexport {markMarkName, markMarkType} from './MarkSpecs';\nconst mAction = 'mark';\n\nexport const Mark: ExtensionAuto = (builder) => {\n builder.use(MarkSpecs);\n\n builder\n .addAction(mAction, ({schema}) => createMarkdownInlineMarkAction(markMarkType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '==', close: '==', ignoreBetween: '='}, markMarkType(schema)),\n ],\n }));\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [mAction]: Action;\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { toggleMark } from 'prosemirror-commands';
2
- import { createToggleMarkAction } from "../../../utils/actions.js";
2
+ import { createMarkdownInlineMarkAction } from "../../../utils/actions.js";
3
3
  import { markInputRule } from "../../../utils/inputrules.js";
4
4
  import { withLogAction } from "../../../utils/keymap.js";
5
5
  import { StrikeSpecs, strikeType } from "./StrikeSpecs/index.js";
@@ -8,7 +8,7 @@ const sAction = 'strike';
8
8
  export const Strike = (builder, opts) => {
9
9
  builder.use(StrikeSpecs);
10
10
  builder
11
- .addAction(sAction, ({ schema }) => createToggleMarkAction(strikeType(schema)))
11
+ .addAction(sAction, ({ schema }) => createMarkdownInlineMarkAction(strikeType(schema)))
12
12
  .addInputRules(({ schema }) => ({
13
13
  rules: [
14
14
  markInputRule({ open: '~~', close: '~~', ignoreBetween: '~' }, strikeType(schema)),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Strike/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,sBAAsB,EAAC,kCAA+B;AAC9D,OAAO,EAAC,aAAa,EAAC,qCAAkC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAEpD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,+BAAsB;AAEtD,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,+BAAsB;AACzD,MAAM,OAAO,GAAG,QAAQ,CAAC;AAMzB,MAAM,CAAC,MAAM,MAAM,GAAiC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEzB,OAAO;SACF,SAAS,CAAC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SAC5E,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;SACnF;KACJ,CAAC,CAAC,CAAC;IAER,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,MAAM,EAAC,SAAS,EAAC,GAAG,IAAI,CAAC;QACzB,OAAO,CAAC,SAAS,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACvE,CAAC,CAAC,CAAC;IACR,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {toggleMark} from 'prosemirror-commands';\n\nimport type {Action, ExtensionAuto} from '../../../core';\nimport {createToggleMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\nimport {withLogAction} from '../../../utils/keymap';\n\nimport {StrikeSpecs, strikeType} from './StrikeSpecs';\n\nexport {strikeMarkName, strikeType} from './StrikeSpecs';\nconst sAction = 'strike';\n\nexport type StrikeOptions = {\n strikeKey?: string | null;\n};\n\nexport const Strike: ExtensionAuto<StrikeOptions> = (builder, opts) => {\n builder.use(StrikeSpecs);\n\n builder\n .addAction(sAction, ({schema}) => createToggleMarkAction(strikeType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '~~', close: '~~', ignoreBetween: '~'}, strikeType(schema)),\n ],\n }));\n\n if (opts?.strikeKey) {\n const {strikeKey} = opts;\n builder.addKeymap(({schema}) => ({\n [strikeKey]: withLogAction('strike', toggleMark(strikeType(schema))),\n }));\n }\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [sAction]: Action;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Strike/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,8BAA8B,EAAC,kCAA+B;AACtE,OAAO,EAAC,aAAa,EAAC,qCAAkC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAEpD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,+BAAsB;AAEtD,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,+BAAsB;AACzD,MAAM,OAAO,GAAG,QAAQ,CAAC;AAMzB,MAAM,CAAC,MAAM,MAAM,GAAiC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEzB,OAAO;SACF,SAAS,CAAC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,8BAA8B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACpF,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;SACnF;KACJ,CAAC,CAAC,CAAC;IAER,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,MAAM,EAAC,SAAS,EAAC,GAAG,IAAI,CAAC;QACzB,OAAO,CAAC,SAAS,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACvE,CAAC,CAAC,CAAC;IACR,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {toggleMark} from 'prosemirror-commands';\n\nimport type {Action, ExtensionAuto} from '../../../core';\nimport {createMarkdownInlineMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\nimport {withLogAction} from '../../../utils/keymap';\n\nimport {StrikeSpecs, strikeType} from './StrikeSpecs';\n\nexport {strikeMarkName, strikeType} from './StrikeSpecs';\nconst sAction = 'strike';\n\nexport type StrikeOptions = {\n strikeKey?: string | null;\n};\n\nexport const Strike: ExtensionAuto<StrikeOptions> = (builder, opts) => {\n builder.use(StrikeSpecs);\n\n builder\n .addAction(sAction, ({schema}) => createMarkdownInlineMarkAction(strikeType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '~~', close: '~~', ignoreBetween: '~'}, strikeType(schema)),\n ],\n }));\n\n if (opts?.strikeKey) {\n const {strikeKey} = opts;\n builder.addKeymap(({schema}) => ({\n [strikeKey]: withLogAction('strike', toggleMark(strikeType(schema))),\n }));\n }\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [sAction]: Action;\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { toggleMark } from 'prosemirror-commands';
2
- import { createToggleMarkAction } from "../../../utils/actions.js";
2
+ import { createMarkdownInlineMarkAction } from "../../../utils/actions.js";
3
3
  import { markInputRule } from "../../../utils/inputrules.js";
4
4
  import { withLogAction } from "../../../utils/keymap.js";
5
5
  import { UnderlineSpecs, underlineType } from "./UnderlineSpecs/index.js";
@@ -8,7 +8,7 @@ const undAction = 'underline';
8
8
  export const Underline = (builder, opts) => {
9
9
  builder.use(UnderlineSpecs);
10
10
  builder
11
- .addAction(undAction, ({ schema }) => createToggleMarkAction(underlineType(schema)))
11
+ .addAction(undAction, ({ schema }) => createMarkdownInlineMarkAction(underlineType(schema)))
12
12
  .addInputRules(({ schema }) => ({
13
13
  rules: [
14
14
  markInputRule({ open: '++', close: '++', ignoreBetween: '+' }, underlineType(schema)),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Underline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,sBAAsB,EAAC,kCAA+B;AAC9D,OAAO,EAAC,aAAa,EAAC,qCAAkC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAEpD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,kCAAyB;AAE/D,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAC,kCAAyB;AAClE,MAAM,SAAS,GAAG,WAAW,CAAC;AAM9B,MAAM,CAAC,MAAM,SAAS,GAAoC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IACxE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAE5B,OAAO;SACF,SAAS,CAAC,SAAS,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;SACjF,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACtF;KACJ,CAAC,CAAC,CAAC;IAER,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;QACrB,MAAM,EAAC,YAAY,EAAC,GAAG,IAAI,CAAC;QAC5B,OAAO,CAAC,SAAS,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;SAChF,CAAC,CAAC,CAAC;IACR,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {toggleMark} from 'prosemirror-commands';\n\nimport type {Action, ExtensionAuto} from '../../../core';\nimport {createToggleMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\nimport {withLogAction} from '../../../utils/keymap';\n\nimport {UnderlineSpecs, underlineType} from './UnderlineSpecs';\n\nexport {underlineMarkName, underlineType} from './UnderlineSpecs';\nconst undAction = 'underline';\n\nexport type UnderlineOptions = {\n underlineKey?: string | null;\n};\n\nexport const Underline: ExtensionAuto<UnderlineOptions> = (builder, opts) => {\n builder.use(UnderlineSpecs);\n\n builder\n .addAction(undAction, ({schema}) => createToggleMarkAction(underlineType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '++', close: '++', ignoreBetween: '+'}, underlineType(schema)),\n ],\n }));\n\n if (opts?.underlineKey) {\n const {underlineKey} = opts;\n builder.addKeymap(({schema}) => ({\n [underlineKey]: withLogAction('underline', toggleMark(underlineType(schema))),\n }));\n }\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [undAction]: Action;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Underline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,8BAA8B,EAAC,kCAA+B;AACtE,OAAO,EAAC,aAAa,EAAC,qCAAkC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAEpD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,kCAAyB;AAE/D,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAC,kCAAyB;AAClE,MAAM,SAAS,GAAG,WAAW,CAAC;AAM9B,MAAM,CAAC,MAAM,SAAS,GAAoC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IACxE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAE5B,OAAO;SACF,SAAS,CAAC,SAAS,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,8BAA8B,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;SACzF,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACtF;KACJ,CAAC,CAAC,CAAC;IAER,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;QACrB,MAAM,EAAC,YAAY,EAAC,GAAG,IAAI,CAAC;QAC5B,OAAO,CAAC,SAAS,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;SAChF,CAAC,CAAC,CAAC;IACR,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {toggleMark} from 'prosemirror-commands';\n\nimport type {Action, ExtensionAuto} from '../../../core';\nimport {createMarkdownInlineMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\nimport {withLogAction} from '../../../utils/keymap';\n\nimport {UnderlineSpecs, underlineType} from './UnderlineSpecs';\n\nexport {underlineMarkName, underlineType} from './UnderlineSpecs';\nconst undAction = 'underline';\n\nexport type UnderlineOptions = {\n underlineKey?: string | null;\n};\n\nexport const Underline: ExtensionAuto<UnderlineOptions> = (builder, opts) => {\n builder.use(UnderlineSpecs);\n\n builder\n .addAction(undAction, ({schema}) => createMarkdownInlineMarkAction(underlineType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '++', close: '++', ignoreBetween: '+'}, underlineType(schema)),\n ],\n }));\n\n if (opts?.underlineKey) {\n const {underlineKey} = opts;\n builder.addKeymap(({schema}) => ({\n [underlineKey]: withLogAction('underline', toggleMark(underlineType(schema))),\n }));\n }\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [undAction]: Action;\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { createToggleMarkAction } from "../../../utils/actions.js";
1
+ import { createMarkdownInlineMarkAction } from "../../../utils/actions.js";
2
2
  import { markInputRule } from "../../../utils/inputrules.js";
3
3
  import { MonospaceSpecs, monospaceType } from "./MonospaceSpecs/index.js";
4
4
  export { monospaceMarkName, monospaceType } from "./MonospaceSpecs/index.js";
@@ -6,7 +6,7 @@ const monoAction = 'mono';
6
6
  export const Monospace = (builder) => {
7
7
  builder.use(MonospaceSpecs);
8
8
  builder
9
- .addAction(monoAction, ({ schema }) => createToggleMarkAction(monospaceType(schema)))
9
+ .addAction(monoAction, ({ schema }) => createMarkdownInlineMarkAction(monospaceType(schema)))
10
10
  .addInputRules(({ schema }) => ({
11
11
  rules: [
12
12
  markInputRule({ open: '##', close: '##', ignoreBetween: '#' }, monospaceType(schema)),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/yfm/Monospace/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,kCAA+B;AAC9D,OAAO,EAAC,aAAa,EAAC,qCAAkC;AAExD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,kCAAyB;AAE/D,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAC,kCAAyB;AAClE,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,MAAM,CAAC,MAAM,SAAS,GAAkB,CAAC,OAAO,EAAE,EAAE;IAChD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAE5B,OAAO;SACF,SAAS,CAAC,UAAU,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;SAClF,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACtF;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import type {Action, ExtensionAuto} from '../../../core';\nimport {createToggleMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\n\nimport {MonospaceSpecs, monospaceType} from './MonospaceSpecs';\n\nexport {monospaceMarkName, monospaceType} from './MonospaceSpecs';\nconst monoAction = 'mono';\n\nexport const Monospace: ExtensionAuto = (builder) => {\n builder.use(MonospaceSpecs);\n\n builder\n .addAction(monoAction, ({schema}) => createToggleMarkAction(monospaceType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '##', close: '##', ignoreBetween: '#'}, monospaceType(schema)),\n ],\n }));\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [monoAction]: Action;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/yfm/Monospace/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,8BAA8B,EAAC,kCAA+B;AACtE,OAAO,EAAC,aAAa,EAAC,qCAAkC;AAExD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,kCAAyB;AAE/D,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAC,kCAAyB;AAClE,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,MAAM,CAAC,MAAM,SAAS,GAAkB,CAAC,OAAO,EAAE,EAAE;IAChD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAE5B,OAAO;SACF,SAAS,CAAC,UAAU,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,8BAA8B,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;SAC1F,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE;YACH,aAAa,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACtF;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import type {Action, ExtensionAuto} from '../../../core';\nimport {createMarkdownInlineMarkAction} from '../../../utils/actions';\nimport {markInputRule} from '../../../utils/inputrules';\n\nimport {MonospaceSpecs, monospaceType} from './MonospaceSpecs';\n\nexport {monospaceMarkName, monospaceType} from './MonospaceSpecs';\nconst monoAction = 'mono';\n\nexport const Monospace: ExtensionAuto = (builder) => {\n builder.use(MonospaceSpecs);\n\n builder\n .addAction(monoAction, ({schema}) => createMarkdownInlineMarkAction(monospaceType(schema)))\n .addInputRules(({schema}) => ({\n rules: [\n markInputRule({open: '##', close: '##', ignoreBetween: '#'}, monospaceType(schema)),\n ],\n }));\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [monoAction]: Action;\n }\n }\n}\n"]}
@@ -2,3 +2,9 @@ import type { MarkType } from 'prosemirror-model';
2
2
  import type { ActionSpec } from "../core/index.js";
3
3
  export declare function defineActions<Keys extends string>(actions: Record<Keys, ActionSpec>): Record<Keys, ActionSpec>;
4
4
  export declare function createToggleMarkAction(markType: MarkType): ActionSpec;
5
+ /**
6
+ * Like createToggleMarkAction, but blocks applying the mark when the selection
7
+ * boundaries would produce markdown that cannot round-trip (e.g. `word**,**`).
8
+ * Removing the mark (toggling off) is always allowed.
9
+ */
10
+ export declare function createMarkdownInlineMarkAction(markType: MarkType): ActionSpec;
@@ -1,5 +1,5 @@
1
1
  import { toggleMark } from 'prosemirror-commands';
2
- import { isMarkActive } from "./marks.js";
2
+ import { canApplyInlineMarkInMarkdown, isMarkActive } from "./marks.js";
3
3
  export function defineActions(actions) {
4
4
  return actions;
5
5
  }
@@ -11,4 +11,27 @@ export function createToggleMarkAction(markType) {
11
11
  run: command,
12
12
  };
13
13
  }
14
+ /**
15
+ * Like createToggleMarkAction, but blocks applying the mark when the selection
16
+ * boundaries would produce markdown that cannot round-trip (e.g. `word**,**`).
17
+ * Removing the mark (toggling off) is always allowed.
18
+ */
19
+ export function createMarkdownInlineMarkAction(markType) {
20
+ const base = createToggleMarkAction(markType);
21
+ return {
22
+ isActive: base.isActive,
23
+ isEnable: (state, dispatch, view, attrs) => {
24
+ const isBlocked = !isMarkActive(state, markType) && !canApplyInlineMarkInMarkdown(state);
25
+ if (isBlocked)
26
+ return false;
27
+ return base.isEnable(state, dispatch, view, attrs);
28
+ },
29
+ run: (state, dispatch, view, attrs) => {
30
+ const isBlocked = !isMarkActive(state, markType) && !canApplyInlineMarkInMarkdown(state);
31
+ if (isBlocked)
32
+ return;
33
+ base.run(state, dispatch, view, attrs);
34
+ },
35
+ };
36
+ }
14
37
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"../../../src","sources":["utils/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAKhD,OAAO,EAAC,YAAY,EAAC,mBAAgB;AAErC,MAAM,UAAU,aAAa,CAAsB,OAAiC;IAChF,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO;QACH,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3D,QAAQ,EAAE,OAAO;QACjB,GAAG,EAAE,OAAO;KACf,CAAC;AACN,CAAC","sourcesContent":["import {toggleMark} from 'prosemirror-commands';\nimport type {MarkType} from 'prosemirror-model';\n\nimport type {ActionSpec} from '../core';\n\nimport {isMarkActive} from './marks';\n\nexport function defineActions<Keys extends string>(actions: Record<Keys, ActionSpec>) {\n return actions;\n}\n\nexport function createToggleMarkAction(markType: MarkType): ActionSpec {\n const command = toggleMark(markType);\n return {\n isActive: (state) => Boolean(isMarkActive(state, markType)),\n isEnable: command,\n run: command,\n };\n}\n"]}
1
+ {"version":3,"file":"actions.js","sourceRoot":"../../../src","sources":["utils/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAKhD,OAAO,EAAC,4BAA4B,EAAE,YAAY,EAAC,mBAAgB;AAEnE,MAAM,UAAU,aAAa,CA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ror-model';\n\nimport type {ActionSpec} from '../core';\n\nimport {canApplyInlineMarkInMarkdown, isMarkActive} from './marks';\n\nexport function defineActions<Keys extends string>(actions: Record<Keys, ActionSpec>) {\n return actions;\n}\n\nexport function createToggleMarkAction(markType: MarkType): ActionSpec {\n const command = toggleMark(markType);\n return {\n isActive: (state) => Boolean(isMarkActive(state, markType)),\n isEnable: command,\n run: command,\n };\n}\n\n/**\n * Like createToggleMarkAction, but blocks applying the mark when the selection\n * boundaries would produce markdown that cannot round-trip (e.g. `word**,**`).\n * Removing the mark (toggling off) is always allowed.\n */\nexport function createMarkdownInlineMarkAction(markType: MarkType): ActionSpec {\n const base = createToggleMarkAction(markType);\n return {\n isActive: base.isActive,\n isEnable: (state, dispatch, view, attrs) => {\n const isBlocked =\n !isMarkActive(state, markType) && !canApplyInlineMarkInMarkdown(state);\n if (isBlocked) return false;\n return base.isEnable(state, dispatch, view, attrs);\n },\n run: (state, dispatch, view, attrs) => {\n const isBlocked =\n !isMarkActive(state, markType) && !canApplyInlineMarkInMarkdown(state);\n if (isBlocked) return;\n base.run(state, dispatch, view, attrs);\n },\n };\n}\n"]}
@@ -2,3 +2,9 @@ import type { Mark, MarkType, Node } from 'prosemirror-model';
2
2
  import type { EditorState } from 'prosemirror-state';
3
3
  export declare const findMark: (node: Node, markType: MarkType) => Mark | undefined;
4
4
  export declare function isMarkActive(state: EditorState, type: MarkType): boolean | Mark | undefined;
5
+ /**
6
+ * Returns `false` when the current selection cannot be wrapped in an inline mark
7
+ * without breaking markdown round-trip, per CommonMark flanking delimiter rules:
8
+ * https://spec.commonmark.org/0.31.2/#left-flanking-delimiter-run
9
+ */
10
+ export declare function canApplyInlineMarkInMarkdown(state: EditorState): boolean;
@@ -1,3 +1,4 @@
1
+ import { getParserFromState } from "../core/utils/parser.js";
1
2
  export const findMark = (node, markType) => {
2
3
  return node.marks.find((mark) => mark.type.name === markType.name);
3
4
  };
@@ -8,4 +9,33 @@ export function isMarkActive(state, type) {
8
9
  }
9
10
  return state.doc.rangeHasMark(from, to, type);
10
11
  }
12
+ /**
13
+ * Returns `false` when the current selection cannot be wrapped in an inline mark
14
+ * without breaking markdown round-trip, per CommonMark flanking delimiter rules:
15
+ * https://spec.commonmark.org/0.31.2/#left-flanking-delimiter-run
16
+ */
17
+ export function canApplyInlineMarkInMarkdown(state) {
18
+ const { from, to, empty } = state.selection;
19
+ if (empty) {
20
+ return true;
21
+ }
22
+ const text = state.doc.textBetween(from, to);
23
+ if (!text) {
24
+ return true;
25
+ }
26
+ const parser = getParserFromState(state);
27
+ const isPunct = (ch) => parser.isPunctChar(ch);
28
+ const isWordChar = (ch) => !/\s/.test(ch) && !isPunct(ch);
29
+ const chars = [...text];
30
+ const firstChar = chars[0];
31
+ const lastChar = chars.at(-1);
32
+ const charBefore = from > 0 ? state.doc.textBetween(from - 1, from) : '';
33
+ const charAfter = to < state.doc.content.size ? state.doc.textBetween(to, to + 1) : '';
34
+ // opening delimiter would not be left-flanking
35
+ if (isPunct(firstChar) && charBefore && isWordChar(charBefore)) {
36
+ return false;
37
+ }
38
+ // closing delimiter would not be right-flanking
39
+ return !(lastChar && isPunct(lastChar) && charAfter && isWordChar(charAfter));
40
+ }
11
41
  //# sourceMappingURL=marks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"marks.js","sourceRoot":"../../../src","sources":["utils/marks.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAE,QAAkB,EAAoB,EAAE;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,IAAc;IAC3D,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAEjD,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import type {Mark, MarkType, Node} from 'prosemirror-model';\nimport type {EditorState} from 'prosemirror-state';\n\nexport const findMark = (node: Node, markType: MarkType): Mark | undefined => {\n return node.marks.find((mark) => mark.type.name === markType.name);\n};\n\nexport function isMarkActive(state: EditorState, type: MarkType) {\n const {from, $from, to, empty} = state.selection;\n\n if (empty) {\n return type.isInSet(state.storedMarks || $from.marks());\n }\n\n return state.doc.rangeHasMark(from, to, type);\n}\n"]}
1
+ {"version":3,"file":"marks.js","sourceRoot":"../../../src","sources":["utils/marks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,kBAAkB,EAAC,gCAA6B;AAExD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAE,QAAkB,EAAoB,EAAE;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,IAAc;IAC3D,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAEjD,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,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AAC;IAEvF,+CAA+C;IAC/C,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,gDAAgD;IAChD,OAAO,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import type {Mark, MarkType, Node} from 'prosemirror-model';\nimport type {EditorState} from 'prosemirror-state';\n\nimport {getParserFromState} from '../core/utils/parser';\n\nexport const findMark = (node: Node, markType: MarkType): Mark | undefined => {\n return node.marks.find((mark) => mark.type.name === markType.name);\n};\n\nexport function isMarkActive(state: EditorState, type: MarkType) {\n const {from, $from, to, empty} = state.selection;\n\n if (empty) {\n return type.isInSet(state.storedMarks || $from.marks());\n }\n\n return state.doc.rangeHasMark(from, to, type);\n}\n\n/**\n * Returns `false` when the current selection cannot be wrapped in an inline mark\n * without breaking markdown round-trip, per CommonMark flanking delimiter rules:\n * https://spec.commonmark.org/0.31.2/#left-flanking-delimiter-run\n */\nexport function canApplyInlineMarkInMarkdown(state: EditorState): boolean {\n const {from, to, empty} = state.selection;\n if (empty) {\n return true;\n }\n\n const text = state.doc.textBetween(from, to);\n if (!text) {\n return true;\n }\n\n const parser = getParserFromState(state);\n const isPunct = (ch: string) => parser.isPunctChar(ch);\n const isWordChar = (ch: string) => !/\\s/.test(ch) && !isPunct(ch);\n\n const chars = [...text];\n const firstChar = chars[0];\n const lastChar = chars.at(-1);\n\n const charBefore = from > 0 ? state.doc.textBetween(from - 1, from) : '';\n const charAfter = to < state.doc.content.size ? state.doc.textBetween(to, to + 1) : '';\n\n // opening delimiter would not be left-flanking\n if (isPunct(firstChar) && charBefore && isWordChar(charBefore)) {\n return false;\n }\n\n // closing delimiter would not be right-flanking\n return !(lastChar && isPunct(lastChar) && charAfter && isWordChar(charAfter));\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { AttrStep } from "../pm/transform.js";
2
+ /** @internal */
3
+ export function getChangedRanges(tr) {
4
+ const ranges = [];
5
+ const { maps } = tr.mapping;
6
+ tr.steps.forEach((step, i) => {
7
+ if (step instanceof AttrStep) {
8
+ let pos = step.pos;
9
+ for (let j = i + 1; j < maps.length; j++) {
10
+ pos = maps[j].map(pos);
11
+ }
12
+ const node = tr.doc.nodeAt(pos);
13
+ if (node) {
14
+ ranges.push({ from: pos, to: pos + node.nodeSize });
15
+ }
16
+ return;
17
+ }
18
+ step.getMap().forEach((_oldStart, _oldEnd, newStart, newEnd) => {
19
+ let from = newStart;
20
+ let to = newEnd;
21
+ for (let j = i + 1; j < maps.length; j++) {
22
+ from = maps[j].map(from, -1);
23
+ to = maps[j].map(to, 1);
24
+ }
25
+ ranges.push({ from, to });
26
+ });
27
+ });
28
+ return ranges;
29
+ }
30
+ /** @internal */
31
+ export function forEachChangedNode(tr, callback) {
32
+ for (const { from, to } of getChangedRanges(tr)) {
33
+ tr.doc.nodesBetween(from, to, callback);
34
+ }
35
+ }
36
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"../../../src","sources":["utils/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,2BAAsB;AAEvC,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAe;IAC5C,MAAM,MAAM,GAAiC,EAAE,CAAC;IAChD,MAAM,EAAC,IAAI,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IAE1B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACzB,IAAI,IAAI,YAAY,QAAQ,EAAE,CAAC;YAC3B,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;YACnB,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,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AE,CAAC;QAC5C,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC","sourcesContent":["import type {Node} from '#pm/model';\nimport type {Transaction} from '#pm/state';\nimport {AttrStep} from '#pm/transform';\n\n/** @internal */\nexport function getChangedRanges(tr: Transaction): {from: number; to: number}[] {\n const ranges: {from: number; to: number}[] = [];\n const {maps} = tr.mapping;\n\n tr.steps.forEach((step, i) => {\n if (step instanceof AttrStep) {\n let pos = step.pos;\n for (let j = i + 1; j < maps.length; j++) {\n pos = maps[j].map(pos);\n }\n const node = tr.doc.nodeAt(pos);\n if (node) {\n ranges.push({from: pos, to: pos + node.nodeSize});\n }\n return;\n }\n\n step.getMap().forEach((_oldStart, _oldEnd, newStart, newEnd) => {\n let from = newStart;\n let to = newEnd;\n for (let j = i + 1; j < maps.length; j++) {\n from = maps[j].map(from, -1);\n to = maps[j].map(to, 1);\n }\n ranges.push({from, to});\n });\n });\n\n return ranges;\n}\n\n/** @internal */\nexport function forEachChangedNode(\n tr: Transaction,\n callback: (node: Node, pos: number, parent: Node | null, index: number) => boolean | void,\n): void {\n for (const {from, to} of getChangedRanges(tr)) {\n tr.doc.nodesBetween(from, to, callback);\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '15.35.0' !== 'undefined' ? '15.35.0' : 'unknown';
2
+ export const VERSION = typeof '15.36.0' !== 'undefined' ? '15.36.0' : 'unknown';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.35.0' !== 'undefined' ? '15.35.0' : 'unknown';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.36.0' !== 'undefined' ? '15.36.0' : 'unknown';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "15.35.0",
3
+ "version": "15.36.0",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {