@gravity-ui/markdown-editor 15.4.2 → 15.5.1

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 (168) hide show
  1. package/build/cjs/bundle/MarkdownEditorView.d.ts +3 -2
  2. package/build/cjs/bundle/MarkdownEditorView.js +3 -3
  3. package/build/cjs/bundle/MarkdownEditorView.js.map +1 -1
  4. package/build/cjs/bundle/MarkupEditorView.d.ts +2 -1
  5. package/build/cjs/bundle/MarkupEditorView.js +2 -2
  6. package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
  7. package/build/cjs/bundle/WysiwygEditorView.d.ts +2 -1
  8. package/build/cjs/bundle/WysiwygEditorView.js +2 -2
  9. package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
  10. package/build/cjs/bundle/config/action-names.d.ts +1 -1
  11. package/build/cjs/bundle/config/action-names.js +1 -0
  12. package/build/cjs/bundle/config/action-names.js.map +1 -1
  13. package/build/cjs/bundle/config/icons.d.ts +1 -1
  14. package/build/cjs/bundle/config/icons.js +1 -0
  15. package/build/cjs/bundle/config/icons.js.map +1 -1
  16. package/build/cjs/bundle/settings/index.js +3 -3
  17. package/build/cjs/bundle/settings/index.js.map +1 -1
  18. package/build/cjs/bundle/types.d.ts +6 -0
  19. package/build/cjs/bundle/types.js.map +1 -1
  20. package/build/cjs/bundle/useMarkdownEditor.js +1 -0
  21. package/build/cjs/bundle/useMarkdownEditor.js.map +1 -1
  22. package/build/cjs/bundle/wysiwyg-preset.d.ts +1 -0
  23. package/build/cjs/bundle/wysiwyg-preset.js +1 -0
  24. package/build/cjs/bundle/wysiwyg-preset.js.map +1 -1
  25. package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/commands.d.ts +3 -0
  26. package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/commands.js +10 -0
  27. package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/commands.js.map +1 -0
  28. package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.d.ts +16 -0
  29. package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js +72 -0
  30. package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js.map +1 -0
  31. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/index.d.ts +10 -0
  32. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js +71 -0
  33. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js.map +1 -0
  34. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.d.ts +2 -0
  35. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js +41 -0
  36. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js.map +1 -0
  37. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.d.ts +6 -0
  38. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js +24 -0
  39. package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js.map +1 -0
  40. package/build/cjs/extensions/additional/QuoteLink/commands.d.ts +4 -0
  41. package/build/cjs/extensions/additional/QuoteLink/commands.js +45 -0
  42. package/build/cjs/extensions/additional/QuoteLink/commands.js.map +1 -0
  43. package/build/cjs/extensions/additional/QuoteLink/index.css +36 -0
  44. package/build/cjs/extensions/additional/QuoteLink/index.d.ts +16 -0
  45. package/build/cjs/extensions/additional/QuoteLink/index.js +42 -0
  46. package/build/cjs/extensions/additional/QuoteLink/index.js.map +1 -0
  47. package/build/cjs/extensions/additional/YfmHtmlBlock/utils.js +2 -12
  48. package/build/cjs/extensions/additional/YfmHtmlBlock/utils.js.map +1 -1
  49. package/build/cjs/extensions/markdown/Html/schema.js +3 -3
  50. package/build/cjs/extensions/markdown/Html/schema.js.map +1 -1
  51. package/build/cjs/extensions/markdown/Lists/actions.js +2 -2
  52. package/build/cjs/extensions/markdown/Lists/actions.js.map +1 -1
  53. package/build/cjs/extensions/markdown/Lists/commands.d.ts +2 -1
  54. package/build/cjs/extensions/markdown/Lists/commands.js +64 -0
  55. package/build/cjs/extensions/markdown/Lists/commands.js.map +1 -1
  56. package/build/cjs/extensions/markdown/Lists/index.js +2 -2
  57. package/build/cjs/extensions/markdown/Lists/index.js.map +1 -1
  58. package/build/cjs/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.d.ts +2 -0
  59. package/build/cjs/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js +5 -2
  60. package/build/cjs/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js.map +1 -1
  61. package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.d.ts +1 -1
  62. package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js +2 -0
  63. package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js.map +1 -1
  64. package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.d.ts +9 -0
  65. package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js +46 -0
  66. package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js.map +1 -0
  67. package/build/cjs/i18n/menubar/en.json +1 -0
  68. package/build/cjs/i18n/menubar/index.d.ts +2 -1
  69. package/build/cjs/i18n/menubar/ru.json +1 -0
  70. package/build/cjs/icons/index.d.ts +1 -1
  71. package/build/cjs/icons/index.js +2 -1
  72. package/build/cjs/icons/index.js.map +1 -1
  73. package/build/cjs/markup/commands/blocks.d.ts +1 -0
  74. package/build/cjs/markup/commands/blocks.js +8 -1
  75. package/build/cjs/markup/commands/blocks.js.map +1 -1
  76. package/build/cjs/modules/toolbars/items.d.ts +3 -0
  77. package/build/cjs/modules/toolbars/items.js +22 -3
  78. package/build/cjs/modules/toolbars/items.js.map +1 -1
  79. package/build/cjs/utils/getSanitize.d.ts +4 -0
  80. package/build/cjs/utils/getSanitize.js +16 -0
  81. package/build/cjs/utils/getSanitize.js.map +1 -0
  82. package/build/cjs/version.js +1 -1
  83. package/build/cjs/version.js.map +1 -1
  84. package/build/esm/bundle/MarkdownEditorView.d.ts +3 -2
  85. package/build/esm/bundle/MarkdownEditorView.js +3 -3
  86. package/build/esm/bundle/MarkdownEditorView.js.map +1 -1
  87. package/build/esm/bundle/MarkupEditorView.d.ts +2 -1
  88. package/build/esm/bundle/MarkupEditorView.js +2 -2
  89. package/build/esm/bundle/MarkupEditorView.js.map +1 -1
  90. package/build/esm/bundle/WysiwygEditorView.d.ts +2 -1
  91. package/build/esm/bundle/WysiwygEditorView.js +2 -2
  92. package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
  93. package/build/esm/bundle/config/action-names.d.ts +1 -1
  94. package/build/esm/bundle/config/action-names.js +1 -0
  95. package/build/esm/bundle/config/action-names.js.map +1 -1
  96. package/build/esm/bundle/config/icons.d.ts +1 -1
  97. package/build/esm/bundle/config/icons.js +2 -1
  98. package/build/esm/bundle/config/icons.js.map +1 -1
  99. package/build/esm/bundle/settings/index.js +3 -3
  100. package/build/esm/bundle/settings/index.js.map +1 -1
  101. package/build/esm/bundle/types.d.ts +6 -0
  102. package/build/esm/bundle/types.js.map +1 -1
  103. package/build/esm/bundle/useMarkdownEditor.js +1 -0
  104. package/build/esm/bundle/useMarkdownEditor.js.map +1 -1
  105. package/build/esm/bundle/wysiwyg-preset.d.ts +1 -0
  106. package/build/esm/bundle/wysiwyg-preset.js +1 -0
  107. package/build/esm/bundle/wysiwyg-preset.js.map +1 -1
  108. package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/commands.d.ts +3 -0
  109. package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/commands.js +6 -0
  110. package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/commands.js.map +1 -0
  111. package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.d.ts +16 -0
  112. package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js +67 -0
  113. package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js.map +1 -0
  114. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/index.d.ts +10 -0
  115. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js +66 -0
  116. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js.map +1 -0
  117. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.d.ts +2 -0
  118. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js +37 -0
  119. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js.map +1 -0
  120. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.d.ts +6 -0
  121. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js +21 -0
  122. package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js.map +1 -0
  123. package/build/esm/extensions/additional/QuoteLink/commands.d.ts +4 -0
  124. package/build/esm/extensions/additional/QuoteLink/commands.js +41 -0
  125. package/build/esm/extensions/additional/QuoteLink/commands.js.map +1 -0
  126. package/build/esm/extensions/additional/QuoteLink/index.css +36 -0
  127. package/build/esm/extensions/additional/QuoteLink/index.d.ts +16 -0
  128. package/build/esm/extensions/additional/QuoteLink/index.js +38 -0
  129. package/build/esm/extensions/additional/QuoteLink/index.js.map +1 -0
  130. package/build/esm/extensions/additional/YfmHtmlBlock/utils.js +2 -11
  131. package/build/esm/extensions/additional/YfmHtmlBlock/utils.js.map +1 -1
  132. package/build/esm/extensions/markdown/Html/schema.js +2 -1
  133. package/build/esm/extensions/markdown/Html/schema.js.map +1 -1
  134. package/build/esm/extensions/markdown/Lists/actions.js +4 -4
  135. package/build/esm/extensions/markdown/Lists/actions.js.map +1 -1
  136. package/build/esm/extensions/markdown/Lists/commands.d.ts +2 -1
  137. package/build/esm/extensions/markdown/Lists/commands.js +63 -0
  138. package/build/esm/extensions/markdown/Lists/commands.js.map +1 -1
  139. package/build/esm/extensions/markdown/Lists/index.js +4 -4
  140. package/build/esm/extensions/markdown/Lists/index.js.map +1 -1
  141. package/build/esm/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.d.ts +2 -0
  142. package/build/esm/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js +5 -2
  143. package/build/esm/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js.map +1 -1
  144. package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.d.ts +1 -1
  145. package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js +2 -0
  146. package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js.map +1 -1
  147. package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.d.ts +9 -0
  148. package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js +42 -0
  149. package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js.map +1 -0
  150. package/build/esm/i18n/menubar/en.json +1 -0
  151. package/build/esm/i18n/menubar/index.d.ts +2 -1
  152. package/build/esm/i18n/menubar/ru.json +1 -0
  153. package/build/esm/icons/index.d.ts +1 -1
  154. package/build/esm/icons/index.js +1 -1
  155. package/build/esm/icons/index.js.map +1 -1
  156. package/build/esm/markup/commands/blocks.d.ts +1 -0
  157. package/build/esm/markup/commands/blocks.js +6 -0
  158. package/build/esm/markup/commands/blocks.js.map +1 -1
  159. package/build/esm/modules/toolbars/items.d.ts +3 -0
  160. package/build/esm/modules/toolbars/items.js +20 -1
  161. package/build/esm/modules/toolbars/items.js.map +1 -1
  162. package/build/esm/utils/getSanitize.d.ts +4 -0
  163. package/build/esm/utils/getSanitize.js +11 -0
  164. package/build/esm/utils/getSanitize.js.map +1 -0
  165. package/build/esm/version.js +1 -1
  166. package/build/esm/version.js.map +1 -1
  167. package/build/styles.css +36 -0
  168. package/package.json +9 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor.js","sourceRoot":"../../../../../../src","sources":["extensions/additional/QuoteLink/PlaceholderWidget/descriptor.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,oCAAoC;AACpC,OAAO,EAAC,oBAAoB,EAAE,gCAAgC,EAAC,MAAM,mBAAmB,CAAC;AAIzF,OAAO,EAAC,qBAAqB,EAAE,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,EAAC,0BAAuB;AACnG,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,mCAA2D;AAChG,OAAO,EACH,qBAAqB,GAExB,2DAA8D;AAC/D,OAAO,EAAC,eAAe,EAAC,mCAAkB;AAE1C,MAAM,OAAO,yBAA0B,SAAQ,qBAAqB;IAChE,QAAQ,CAAC;IACT,KAAK,CAAc;IACnB,OAAO,CAAgB;IACvB,OAAO,CAA2B;IAE1B,YAAY,CAAC;IAErB,YAAY,OAAe,EAAE,IAAmB;QAC5C,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,kBAAkB,CAAC,IAAgB,EAAE,MAAoB;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,OAAO,KAAC,qBAAqB,IAAC,QAAQ,EAAE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AE,IAAmB,EAAE,EAAE;IACnE,MAAM,aAAa,GACf,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzF,OAAO,IAAI,yBAAyB,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,CAC3F,EAAE,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type React from 'react';\n\nimport type {Fragment, Node} from 'prosemirror-model';\nimport type {Transaction} from 'prosemirror-state';\nimport {TextSelection} from 'prosemirror-state';\n// @ts-ignore // TODO: fix cjs build\nimport {findParentNodeOfType, findParentNodeOfTypeClosestToPos} from 'prosemirror-utils';\nimport type {EditorView} from 'prosemirror-view';\n\nimport type {ExtensionDeps} from '#core';\nimport {ReactWidgetDescriptor, normalizeUrlFactory, pType, removeDecoration} from 'src/extensions';\nimport {QuoteLinkAttr, quoteLinkType} from 'src/extensions/additional/QuoteLink/QuoteLinkSpecs';\nimport {\n LinkPlaceholderWidget,\n type LinkPlaceholderWidgetProps,\n} from 'src/extensions/markdown/Link/PlaceholderWidget/widget';\nimport {isTextSelection} from 'src/utils';\n\nexport class QuoteLinkWidgetDescriptor extends ReactWidgetDescriptor {\n #domElem;\n #view?: EditorView;\n #getPos?: () => number;\n #schema?: ExtensionDeps['schema'];\n\n private normalizeUrl;\n\n constructor(initPos: number, deps: ExtensionDeps) {\n super(initPos, 'quoteLink');\n this.#domElem = document.createElement('span');\n this.#schema = deps.schema;\n this.normalizeUrl = normalizeUrlFactory(deps);\n }\n\n getDomElem(): HTMLElement {\n return this.#domElem;\n }\n\n renderReactElement(view: EditorView, getPos: () => number): React.ReactElement {\n this.#view = view;\n this.#getPos = getPos;\n return <LinkPlaceholderWidget onCancel={this.onCancel} onSubmit={this.onSubmit} />;\n }\n\n onCancel: LinkPlaceholderWidgetProps['onCancel'] = () => {\n if (!this.#view) return;\n\n this.#view.dispatch(removeDecoration(this.#view.state.tr, this.id));\n this.#view.focus();\n };\n\n onSubmit: LinkPlaceholderWidgetProps['onSubmit'] = (params) => {\n const normalizeResult = this.normalizeUrl(params.url);\n if (!normalizeResult || !this.#view || !this.#getPos) return;\n\n let tr = this.#view.state.tr;\n\n const {url} = normalizeResult;\n const text = params.text.trim() || normalizeResult.text;\n\n const from = this.#getPos();\n const isAllSelected =\n from === 1 && (!isTextSelection(tr.selection) || !tr.selection.$cursor);\n\n const currentNodeWithPos = isAllSelected\n ? findParentNodeOfTypeClosestToPos(\n this.#view.state.doc.resolve(4),\n quoteLinkType(this.#view.state.schema),\n )\n : findParentNodeOfType(quoteLinkType(this.#view.state.schema))(\n this.#view.state.selection,\n );\n\n if (currentNodeWithPos) {\n let content: Fragment | Node | undefined = currentNodeWithPos.node.content;\n let contentSize = currentNodeWithPos.node.nodeSize - 4;\n\n if (currentNodeWithPos.node.nodeSize <= 4 && text) {\n content = pType(this.#view.state.schema).create(null, this.#schema?.text(text));\n contentSize = text.length;\n }\n\n tr = tr.replaceWith(\n currentNodeWithPos.pos,\n currentNodeWithPos.pos + currentNodeWithPos.node.nodeSize,\n quoteLinkType(this.#view.state.schema).create(\n {\n [QuoteLinkAttr.Cite]: url,\n [QuoteLinkAttr.DataContent]: text,\n },\n content,\n ),\n );\n\n tr.setSelection(TextSelection.create(tr.doc, from + contentSize));\n }\n\n this.#view.dispatch(tr);\n };\n}\n\nexport const addPlaceholder = (tr: Transaction, deps: ExtensionDeps) => {\n const isAllSelected =\n tr.selection.from === 0 && (!isTextSelection(tr.selection) || !tr.selection.$cursor);\n return new QuoteLinkWidgetDescriptor(tr.selection.from + (isAllSelected ? 1 : 0), deps).applyTo(\n tr,\n );\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Node } from 'prosemirror-model';
2
+ import type { ExtensionAuto } from "../../../../core/index.js";
3
+ export declare const quoteLinkNodeName = "yfm_quote-link";
4
+ export declare const quoteLinkType: (schema: import("prosemirror-model").Schema) => import("prosemirror-model").NodeType;
5
+ export declare const isQuoteLinkNode: (node: Node) => boolean;
6
+ export declare enum QuoteLinkAttr {
7
+ Cite = "cite",
8
+ DataContent = "data-content"
9
+ }
10
+ export declare const QuoteLinkSpecs: ExtensionAuto;
@@ -0,0 +1,66 @@
1
+ import { transform as quoteLink } from '@diplodoc/quote-link-extension';
2
+ import { nodeTypeFactory } from "../../../../utils/index.js";
3
+ import { moveLinkToQuoteAttributes } from "./md/moveLinkToQuoteAttributes.js";
4
+ export const quoteLinkNodeName = 'yfm_quote-link';
5
+ export const quoteLinkType = nodeTypeFactory(quoteLinkNodeName);
6
+ export const isQuoteLinkNode = (node) => node.type.name === quoteLinkNodeName;
7
+ export var QuoteLinkAttr;
8
+ (function (QuoteLinkAttr) {
9
+ QuoteLinkAttr["Cite"] = "cite";
10
+ QuoteLinkAttr["DataContent"] = "data-content";
11
+ })(QuoteLinkAttr || (QuoteLinkAttr = {}));
12
+ export const QuoteLinkSpecs = (builder) => {
13
+ builder
14
+ .configureMd((md) => md
15
+ .use(quoteLink({
16
+ bundle: false,
17
+ }))
18
+ .use(moveLinkToQuoteAttributes))
19
+ .addNode(quoteLinkNodeName, () => ({
20
+ spec: {
21
+ attrs: {
22
+ class: { default: 'yfm-quote-link' },
23
+ [QuoteLinkAttr.Cite]: { default: '' },
24
+ [QuoteLinkAttr.DataContent]: { default: '' },
25
+ },
26
+ content: 'block+',
27
+ group: 'block',
28
+ defining: true,
29
+ parseDOM: [
30
+ {
31
+ tag: '.yfm-quote-link',
32
+ getAttrs(dom) {
33
+ return {
34
+ [QuoteLinkAttr.Cite]: dom.getAttribute(QuoteLinkAttr.Cite),
35
+ [QuoteLinkAttr.DataContent]: dom.getAttribute(QuoteLinkAttr.DataContent),
36
+ };
37
+ },
38
+ priority: builder.Priority.VeryHigh,
39
+ },
40
+ ],
41
+ toDOM(node) {
42
+ return ['blockquote', node.attrs, 0];
43
+ },
44
+ selectable: true,
45
+ },
46
+ fromMd: {
47
+ tokenSpec: {
48
+ name: quoteLinkNodeName,
49
+ type: 'block',
50
+ getAttrs: (tok) => ({
51
+ [QuoteLinkAttr.Cite]: tok.attrGet('cite'),
52
+ [QuoteLinkAttr.DataContent]: tok.attrGet('data-content') || null,
53
+ }),
54
+ },
55
+ },
56
+ toMd: (state, node) => {
57
+ state.wrapBlock('> ', null, node, () => {
58
+ state.write(`[${node.attrs[QuoteLinkAttr.DataContent]}](${node.attrs[QuoteLinkAttr.Cite]}){data-quotelink=true}`);
59
+ state.write('\n');
60
+ state.write('\n');
61
+ state.renderContent(node);
62
+ });
63
+ },
64
+ }));
65
+ };
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/additional/QuoteLink/QuoteLinkSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,IAAI,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAItE,OAAO,EAAC,eAAe,EAAC,mCAAkB;AAE1C,OAAO,EAAC,yBAAyB,EAAC,0CAAuC;AAEzE,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,iBAAiB,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAEpF,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,6CAA4B,CAAA;AAChC,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,MAAM,CAAC,MAAM,cAAc,GAAkB,CAAC,OAAO,EAAE,EAAE;IACrD,OAAO;SACF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AM,CAAC;oBACzC,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,IAAI;iBACnE,CAAC;aACL;SACJ;QACD,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAClB,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;gBACnC,KAAK,CAAC,KAAK,CACP,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KACrC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CACjC,wBAAwB,CAC3B,CAAC;gBACF,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClB,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import {transform as quoteLink} from '@diplodoc/quote-link-extension';\nimport type {Node} from 'prosemirror-model';\n\nimport type {ExtensionAuto} from '#core';\nimport {nodeTypeFactory} from 'src/utils';\n\nimport {moveLinkToQuoteAttributes} from './md/moveLinkToQuoteAttributes';\n\nexport const quoteLinkNodeName = 'yfm_quote-link';\nexport const quoteLinkType = nodeTypeFactory(quoteLinkNodeName);\nexport const isQuoteLinkNode = (node: Node) => node.type.name === quoteLinkNodeName;\n\nexport enum QuoteLinkAttr {\n Cite = 'cite',\n DataContent = 'data-content',\n}\n\nexport const QuoteLinkSpecs: ExtensionAuto = (builder) => {\n builder\n .configureMd((md) =>\n md\n .use(\n quoteLink({\n bundle: false,\n }),\n )\n .use(moveLinkToQuoteAttributes),\n )\n .addNode(quoteLinkNodeName, () => ({\n spec: {\n attrs: {\n class: {default: 'yfm-quote-link'},\n [QuoteLinkAttr.Cite]: {default: ''},\n [QuoteLinkAttr.DataContent]: {default: ''},\n },\n content: 'block+',\n group: 'block',\n defining: true,\n parseDOM: [\n {\n tag: '.yfm-quote-link',\n getAttrs(dom) {\n return {\n [QuoteLinkAttr.Cite]: (dom as Element).getAttribute(\n QuoteLinkAttr.Cite,\n ),\n [QuoteLinkAttr.DataContent]: (dom as Element).getAttribute(\n QuoteLinkAttr.DataContent,\n ),\n };\n },\n priority: builder.Priority.VeryHigh,\n },\n ],\n toDOM(node) {\n return ['blockquote', node.attrs, 0];\n },\n selectable: true,\n },\n fromMd: {\n tokenSpec: {\n name: quoteLinkNodeName,\n type: 'block',\n getAttrs: (tok) => ({\n [QuoteLinkAttr.Cite]: tok.attrGet('cite'),\n [QuoteLinkAttr.DataContent]: tok.attrGet('data-content') || null,\n }),\n },\n },\n toMd: (state, node) => {\n state.wrapBlock('> ', null, node, () => {\n state.write(\n `[${node.attrs[QuoteLinkAttr.DataContent]}](${\n node.attrs[QuoteLinkAttr.Cite]\n }){data-quotelink=true}`,\n );\n state.write('\\n');\n state.write('\\n');\n state.renderContent(node);\n });\n },\n }));\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import type { PluginSimple } from 'markdown-it';
2
+ export declare const moveLinkToQuoteAttributes: PluginSimple;
@@ -0,0 +1,37 @@
1
+ import { matchLinkAtInlineStart } from "./utils.js";
2
+ import { QuoteLinkAttr } from "../index.js";
3
+ export const moveLinkToQuoteAttributes = (md) => {
4
+ md.core.ruler.push('move-link-to-quote-attributes', (state) => {
5
+ const { tokens } = state;
6
+ let i = 0;
7
+ while (i < tokens.length) {
8
+ const token = tokens[i];
9
+ if (token.type === 'yfm_quote-link_open') {
10
+ const inlineToken = tokens[i + 2];
11
+ const linkMatch = matchLinkAtInlineStart(inlineToken);
12
+ if (linkMatch?.openToken.attrIndex('data-quotelink') !== -1 &&
13
+ linkMatch?.closeTokenIndex) {
14
+ token.attrSet(QuoteLinkAttr.Cite, linkMatch?.openToken.attrGet('href') ?? '');
15
+ const content = inlineToken.children
16
+ ?.slice(1, linkMatch.closeTokenIndex)
17
+ .reduce((result, item) => result + item.content, '')
18
+ .trim();
19
+ if (content) {
20
+ token.attrSet(QuoteLinkAttr.DataContent, content);
21
+ }
22
+ if (linkMatch.closeTokenIndex === (inlineToken.children?.length ?? 0) - 1) {
23
+ tokens.splice(i + 1, 3);
24
+ }
25
+ else {
26
+ inlineToken.children?.splice(0, linkMatch.closeTokenIndex + 1);
27
+ if (inlineToken.children?.every((childToken) => !childToken.content)) {
28
+ tokens.splice(i + 1, 3);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ i++;
34
+ }
35
+ });
36
+ };
37
+ //# sourceMappingURL=moveLinkToQuoteAttributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moveLinkToQuoteAttributes.js","sourceRoot":"../../../../../../../src","sources":["extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,sBAAsB,EAAC,mBAAoE;AAEnG,OAAO,EAAC,aAAa,EAAC,oBAAW;AAEjC,MAAM,CAAC,MAAM,yBAAyB,GAAiB,CAAC,EAAE,EAAE,EAAE;IAC1D,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,+BAA+B,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1D,MAAM,EAAC,MAAM,EAAC,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;gBACvC,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBAClC,MAAM,SAAS,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;gBAEtD,IACI,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,gBA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inkAtInlineStart} from 'src/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils';\n\nimport {QuoteLinkAttr} from '..';\n\nexport const moveLinkToQuoteAttributes: PluginSimple = (md) => {\n md.core.ruler.push('move-link-to-quote-attributes', (state) => {\n const {tokens} = state;\n\n let i = 0;\n\n while (i < tokens.length) {\n const token = tokens[i];\n if (token.type === 'yfm_quote-link_open') {\n const inlineToken = tokens[i + 2];\n const linkMatch = matchLinkAtInlineStart(inlineToken);\n\n if (\n linkMatch?.openToken.attrIndex('data-quotelink') !== -1 &&\n linkMatch?.closeTokenIndex\n ) {\n token.attrSet(QuoteLinkAttr.Cite, linkMatch?.openToken.attrGet('href') ?? '');\n const content = inlineToken.children\n ?.slice(1, linkMatch.closeTokenIndex)\n .reduce((result, item) => result + item.content, '')\n .trim();\n if (content) {\n token.attrSet(QuoteLinkAttr.DataContent, content);\n }\n\n if (linkMatch.closeTokenIndex === (inlineToken.children?.length ?? 0) - 1) {\n tokens.splice(i + 1, 3);\n } else {\n inlineToken.children?.splice(0, linkMatch.closeTokenIndex + 1);\n if (inlineToken.children?.every((childToken) => !childToken.content)) {\n tokens.splice(i + 1, 3);\n }\n }\n }\n }\n\n i++;\n }\n });\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import type Token from 'markdown-it/lib/token';
2
+ export declare function matchLinkAtInlineStart(inlineToken: Token): {
3
+ openToken: Token;
4
+ closeToken: Token;
5
+ closeTokenIndex: number;
6
+ } | null;
@@ -0,0 +1,21 @@
1
+ export function matchLinkAtInlineStart(inlineToken) {
2
+ if (inlineToken.type !== 'inline' || !inlineToken.children?.length) {
3
+ return null;
4
+ }
5
+ const { children: tokens } = inlineToken;
6
+ if (tokens[0].type !== 'link_open') {
7
+ return null;
8
+ }
9
+ for (let i = 0; i < tokens.length; i++) {
10
+ const token = tokens[i];
11
+ if (token.type === 'link_close') {
12
+ return {
13
+ openToken: tokens[0],
14
+ closeToken: token,
15
+ closeTokenIndex: i,
16
+ };
17
+ }
18
+ }
19
+ return null;
20
+ }
21
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"../../../../../../../src","sources":["extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,WAAkB;IACrD,IAAI,WAAW,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACjE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,WAAW,CAAC;IACvC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAC9B,OAAO;gBACH,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;gBACpB,UAAU,EAAE,KAAK;gBACjB,eAAe,EAAE,CAAC;aACrB,CAAC;QACN,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import type Token from 'markdown-it/lib/token';\n\nexport function matchLinkAtInlineStart(inlineToken: Token) {\n if (inlineToken.type !== 'inline' || !inlineToken.children?.length) {\n return null;\n }\n\n const {children: tokens} = inlineToken;\n if (tokens[0].type !== 'link_open') {\n return null;\n }\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token.type === 'link_close') {\n return {\n openToken: tokens[0],\n closeToken: token,\n closeTokenIndex: i,\n };\n }\n }\n\n return null;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'prosemirror-state';
2
+ import "../../../types/spec.js";
3
+ export declare const toggleQuote: Command;
4
+ export declare const addQuoteLink: (deps: import("../../../index.js").ExtensionDeps) => Command;
@@ -0,0 +1,41 @@
1
+ import { wrapIn } from 'prosemirror-commands';
2
+ import { isTextSelection } from "../../../utils/index.js";
3
+ import "../../../types/spec.js";
4
+ import { addQuoteLinkPlaceholder } from "./PlaceholderWidget/commands.js";
5
+ import { isQuoteLinkNode, quoteLinkType } from "./QuoteLinkSpecs/index.js";
6
+ export const toggleQuote = (state, dispatch) => {
7
+ const { selection } = state;
8
+ const qType = quoteLinkType(state.schema);
9
+ if (!isTextSelection(selection) || !selection.$cursor)
10
+ return wrapIn(qType)(state, dispatch);
11
+ const { $cursor } = selection;
12
+ let { depth } = $cursor;
13
+ while (depth > 0) {
14
+ const node = $cursor.node(depth);
15
+ const nodeSpec = node.type.spec;
16
+ if (!nodeSpec.complex || nodeSpec.complex === 'root') {
17
+ const targetDepth = depth - 1;
18
+ const range = getBlockRange($cursor, depth);
19
+ let tr = state.tr;
20
+ if (isQuoteLinkNode($cursor.node(targetDepth))) {
21
+ tr = tr.lift(range, targetDepth - 1).scrollIntoView();
22
+ dispatch?.(tr);
23
+ }
24
+ else {
25
+ tr = tr.wrap(range, [{ type: qType }]).scrollIntoView();
26
+ dispatch?.(tr);
27
+ }
28
+ return true;
29
+ }
30
+ depth--;
31
+ }
32
+ return false;
33
+ };
34
+ function getBlockRange($pos, depth) {
35
+ const { doc } = $pos;
36
+ const $before = doc.resolve($pos.before(depth));
37
+ const $after = doc.resolve($pos.after(depth));
38
+ return $before.blockRange($after);
39
+ }
40
+ export const addQuoteLink = addQuoteLinkPlaceholder;
41
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"../../../../../src","sources":["extensions/additional/QuoteLink/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAI5C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AAC;iBAAM,CAAC;gBACJ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAM,EAAE,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;gBACvD,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;YACnB,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,SAAS,aAAa,CAAC,IAAiB,EAAE,KAAc;IACpD,MAAM,EAAC,GAAG,EAAC,GAAG,IAAI,CAAC;IACnB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAC","sourcesContent":["import {wrapIn} from 'prosemirror-commands';\nimport type {ResolvedPos} from 'prosemirror-model';\nimport type {Command} from 'prosemirror-state';\n\nimport {isTextSelection} from 'src/utils';\n\nimport '../../../types/spec';\n\nimport {addQuoteLinkPlaceholder} from './PlaceholderWidget/commands';\nimport {isQuoteLinkNode, quoteLinkType} from './QuoteLinkSpecs';\n\nexport const toggleQuote: Command = (state, dispatch) => {\n const {selection} = state;\n const qType = quoteLinkType(state.schema);\n if (!isTextSelection(selection) || !selection.$cursor) return wrapIn(qType)(state, dispatch);\n const {$cursor} = selection;\n let {depth} = $cursor;\n while (depth > 0) {\n const node = $cursor.node(depth);\n const nodeSpec = node.type.spec;\n if (!nodeSpec.complex || nodeSpec.complex === 'root') {\n const targetDepth = depth - 1;\n const range = getBlockRange($cursor, depth);\n let tr = state.tr;\n if (isQuoteLinkNode($cursor.node(targetDepth))) {\n tr = tr.lift(range!, targetDepth - 1).scrollIntoView();\n dispatch?.(tr);\n } else {\n tr = tr.wrap(range!, [{type: qType}]).scrollIntoView();\n dispatch?.(tr);\n }\n\n return true;\n }\n depth--;\n }\n\n return false;\n};\n\nfunction getBlockRange($pos: ResolvedPos, depth?: number) {\n const {doc} = $pos;\n const $before = doc.resolve($pos.before(depth));\n const $after = doc.resolve($pos.after(depth));\n return $before.blockRange($after);\n}\n\nexport const addQuoteLink = addQuoteLinkPlaceholder;\n"]}
@@ -0,0 +1,36 @@
1
+ .yfm-quote-link {
2
+ --yfm-quote-link-background: var(--g-color-private-black-50-solid);
3
+ --yfm-quote-link-background-hover: var(--g-color-base-simple-hover);
4
+ }
5
+ .yfm-quote-link * {
6
+ position: relative;
7
+ z-index: 1;
8
+ }
9
+
10
+ .g-root_theme_dark .yfm-quote-link,
11
+ .g-root_theme_dark-hc .yfm-quote-link {
12
+ --yfm-quote-link-background: var(--g-color-private-white-100-solid);
13
+ }
14
+
15
+ .yfm-cut:not(.yfm-cut-active) .yfm-cut-content:has(> .yfm-quote-link) {
16
+ padding: 0;
17
+ }
18
+ .yfm-cut:not(.yfm-cut-active) .yfm-cut-content:has(> .yfm-quote-link) > .yfm-quote-link {
19
+ padding-top: var(--g-spacing-2);
20
+ padding-left: var(--g-spacing-7);
21
+ }
22
+
23
+ .yfm-editor .yfm-quote-link {
24
+ background-color: var(--yfm-quote-link-background);
25
+ }
26
+ .yfm-editor .yfm-quote-link .g-md-img-settings-button,
27
+ .yfm-editor .yfm-quote-link .yfm-clipboard-button {
28
+ position: absolute;
29
+ z-index: 2;
30
+ }
31
+ .yfm-editor .yfm-quote-link .g-button__icon-inner {
32
+ position: absolute;
33
+ }
34
+ .yfm-editor .yfm-quote-link p {
35
+ max-width: unset;
36
+ }
@@ -0,0 +1,16 @@
1
+ import '@diplodoc/quote-link-extension/runtime';
2
+ import type { Action, ExtensionAuto } from "../../../core/index.js";
3
+ import "./index.css";
4
+ import '@diplodoc/quote-link-extension/runtime/styles.css';
5
+ declare const quoteLinkAction = "quoteLink";
6
+ declare const addLinkToQuoteLinkAction = "addLinkToQuoteLink";
7
+ export declare const QuoteLink: ExtensionAuto;
8
+ declare global {
9
+ namespace WysiwygEditor {
10
+ interface Actions {
11
+ [quoteLinkAction]: Action;
12
+ [addLinkToQuoteLinkAction]: Action;
13
+ }
14
+ }
15
+ }
16
+ export {};
@@ -0,0 +1,38 @@
1
+ import '@diplodoc/quote-link-extension/runtime';
2
+ // @ts-ignore // TODO: fix cjs build
3
+ import { hasParentNodeOfType } from 'prosemirror-utils';
4
+ import { linkType } from "../../index.js";
5
+ import { isMarkActive, wrappingInputRule } from "../../../utils/index.js";
6
+ import { QuoteLinkSpecs, quoteLinkType } from "./QuoteLinkSpecs/index.js";
7
+ import { addQuoteLink, toggleQuote } from "./commands.js";
8
+ import "./index.css";
9
+ import '@diplodoc/quote-link-extension/runtime/styles.css';
10
+ const quoteLinkAction = 'quoteLink';
11
+ const addLinkToQuoteLinkAction = 'addLinkToQuoteLink';
12
+ export const QuoteLink = (builder) => {
13
+ builder.use(QuoteLinkSpecs);
14
+ builder.addInputRules(({ schema }) => ({
15
+ rules: [quoteLinkInputRule(quoteLinkType(schema))],
16
+ }));
17
+ builder.addAction(quoteLinkAction, ({ schema }) => {
18
+ const quoteLink = quoteLinkType(schema);
19
+ return {
20
+ isActive: (state) => hasParentNodeOfType(quoteLink)(state.selection),
21
+ isEnable: toggleQuote,
22
+ run: toggleQuote,
23
+ };
24
+ });
25
+ builder.addAction(addLinkToQuoteLinkAction, (deps) => ({
26
+ isActive: (state) => Boolean(isMarkActive(state, linkType(state.schema))),
27
+ isEnable: addQuoteLink(deps),
28
+ run: addQuoteLink(deps),
29
+ }));
30
+ };
31
+ /**
32
+ * Given a quoteLink node type, returns an input rule that turns `"> "`
33
+ * at the start of a textblock into a quoteLink.
34
+ */
35
+ function quoteLinkInputRule(nodeType) {
36
+ return wrappingInputRule(/^\s*>\s$/, nodeType);
37
+ }
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/additional/QuoteLink/index.ts"],"names":[],"mappings":"AAAA,OAAO,wCAAwC,CAAC;AAEhD,oCAAoC;AACpC,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAC,QAAQ,EAAC,uBAAuB;AACxC,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAC,gCAAkB;AAE1D,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,kCAAyB;AAC/D,OAAO,EAAC,YAAY,EAAE,WAAW,EAAC,sBAAmB;AAErD,qBAAsB;AACtB,OAAO,mDAAmD,CAAC;AAE3D,MAAM,eAAe,GAAG,WAAW,CAAC;AAEpC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAkB,CAAC,OAAO,EAAE,EAAE;IAChD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAE5B,OAAO,CAAC,aAAa,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC;QACjC,KAAK,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;KACrD,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE;QAC5C,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QAExC,OAAO;YACH,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;YACpE,QAAQ,EAAE,WAAW;YACrB,GAAG,EAAE,WAAW;SACnB,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,CAAC,wBAAwB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACzE,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC;QAC5B,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC;KAC1B,CAAC,CAAC,CAAC;AACR,CAAC,CAAC;AAEF;;;GAGG;AACH,SAAS,kBAAkB,CAAC,QAAkB;IAC1C,OAAO,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import '@diplodoc/quote-link-extension/runtime';\nimport type {NodeType} from 'prosemirror-model';\n// @ts-ignore // TODO: fix cjs build\nimport {hasParentNodeOfType} from 'prosemirror-utils';\n\nimport type {Action, ExtensionAuto} from '#core';\nimport {linkType} from 'src/extensions';\nimport {isMarkActive, wrappingInputRule} from 'src/utils';\n\nimport {QuoteLinkSpecs, quoteLinkType} from './QuoteLinkSpecs';\nimport {addQuoteLink, toggleQuote} from './commands';\n\nimport './index.scss';\nimport '@diplodoc/quote-link-extension/runtime/styles.css';\n\nconst quoteLinkAction = 'quoteLink';\n\nconst addLinkToQuoteLinkAction = 'addLinkToQuoteLink';\n\nexport const QuoteLink: ExtensionAuto = (builder) => {\n builder.use(QuoteLinkSpecs);\n\n builder.addInputRules(({schema}) => ({\n rules: [quoteLinkInputRule(quoteLinkType(schema))],\n }));\n\n builder.addAction(quoteLinkAction, ({schema}) => {\n const quoteLink = quoteLinkType(schema);\n\n return {\n isActive: (state) => hasParentNodeOfType(quoteLink)(state.selection),\n isEnable: toggleQuote,\n run: toggleQuote,\n };\n });\n\n builder.addAction(addLinkToQuoteLinkAction, (deps) => ({\n isActive: (state) => Boolean(isMarkActive(state, linkType(state.schema))),\n isEnable: addQuoteLink(deps),\n run: addQuoteLink(deps),\n }));\n};\n\n/**\n * Given a quoteLink node type, returns an input rule that turns `\"> \"`\n * at the start of a textblock into a quoteLink.\n */\nfunction quoteLinkInputRule(nodeType: NodeType) {\n return wrappingInputRule(/^\\s*>\\s$/, nodeType);\n}\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [quoteLinkAction]: Action;\n [addLinkToQuoteLinkAction]: Action;\n }\n }\n}\n"]}
@@ -1,15 +1,6 @@
1
- import * as sanitizeModule from '@diplodoc/transform/lib/sanitize.js';
2
- const sanitizeAll = () => {
3
- console.warn('[YfmHtmlBlock]: sanitize function not found');
4
- return '';
5
- };
6
- const getSanitizeFunction = () => {
7
- const module = sanitizeModule;
8
- const sanitize = 'sanitize' in module && module.sanitize ? module.sanitize : module.default;
9
- return sanitize instanceof Function ? sanitize : sanitizeAll;
10
- };
1
+ import { getSanitize } from "../../../utils/getSanitize.js";
11
2
  // MAJOR: use `import {sanitize} from '@diplodoc/transform/lib/sanitize.js'`
12
- const diplodocSanitize = getSanitizeFunction();
3
+ const diplodocSanitize = getSanitize('YfmHtmlBlock');
13
4
  // yfmHtmlBlock additional css properties white list
14
5
  const getYfmHtmlBlockWhiteList = () => {
15
6
  const whiteList = {};
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"../../../../../src","sources":["extensions/additional/YfmHtmlBlock/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,qCAAqC,CAAC;AAatE,MAAM,WAAW,GAAG,GAAG,EAAE;IACrB,OAAO,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC5D,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AACF,MAAM,mBAAmB,GAAG,GAAe,EAAE;IACzC,MAAM,MAAM,GAAG,cAAgC,CAAC;IAChD,MAAM,QAAQ,GAAG,UAAU,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IA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AwB,EAAE;SAChC;KACJ,CAAC;AACN,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,uBAAuB,GAChC,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,gBAAgB,EAA8B,EAAE,EAAE,CACxE,CAAC,OAAe,EAAE,EAAE,CAChB,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC","sourcesContent":["import type {SanitizeOptions} from '@diplodoc/transform/lib/sanitize.js';\nimport * as sanitizeModule from '@diplodoc/transform/lib/sanitize.js';\n\ntype SanitizeFn = (\n html: string,\n options?: SanitizeOptions,\n additionalOptions?: SanitizeOptions,\n) => string;\n\ninterface SanitizeModule {\n sanitize?: SanitizeFn;\n default?: SanitizeFn;\n}\n\nconst sanitizeAll = () => {\n console.warn('[YfmHtmlBlock]: sanitize function not found');\n return '';\n};\nconst getSanitizeFunction = (): SanitizeFn => {\n const module = sanitizeModule as SanitizeModule;\n const sanitize = 'sanitize' in module && module.sanitize ? module.sanitize : module.default;\n return sanitize instanceof Function ? sanitize : sanitizeAll;\n};\n\n// MAJOR: use `import {sanitize} from '@diplodoc/transform/lib/sanitize.js'`\nconst diplodocSanitize = getSanitizeFunction();\n\n// yfmHtmlBlock additional css properties white list\nconst getYfmHtmlBlockWhiteList = () => {\n const whiteList: Record<string, boolean> = {};\n\n // flex, grid, column\n whiteList['align-content'] = true; // default: auto\n whiteList['align-items'] = true; // default: auto\n whiteList['align-self'] = true; // default: auto\n whiteList.columns = true; // default: depending on individual properties\n whiteList['column-count'] = true; // default: auto\n whiteList['column-fill'] = true; // default: balance\n whiteList['column-gap'] = true; // default: normal\n whiteList['column-rule'] = true; // default: depending on individual properties\n whiteList['column-rule-color'] = true; // default: current color\n whiteList['column-rule-style'] = true; // default: medium\n whiteList['column-rule-width'] = true; // default: medium\n whiteList['column-span'] = true; // default: none\n whiteList['column-width'] = true; // default: auto\n whiteList.flex = true; // default: depending on individual properties\n whiteList['flex-basis'] = true; // default: auto\n whiteList['flex-direction'] = true; // default: row\n whiteList['flex-flow'] = true; // default: depending on individual properties\n whiteList['flex-grow'] = true; // default: 0\n whiteList['flex-shrink'] = true; // default: 1\n whiteList['flex-wrap'] = true; // default: nowrap\n whiteList.gap = true; // default: normal normal\n whiteList.grid = true; // default: depending on individual properties\n whiteList['grid-area'] = true; // default: depending on individual properties\n whiteList['grid-auto-columns'] = true; // default: auto\n whiteList['grid-auto-flow'] = true; // default: none\n whiteList['grid-auto-rows'] = true; // default: auto\n whiteList['grid-column'] = true; // default: depending on individual properties\n whiteList['grid-column-end'] = true; // default: auto\n whiteList['grid-column-start'] = true; // default: auto\n whiteList['grid-row'] = true; // default: depending on individual properties\n whiteList['grid-row-end'] = true; // default: auto\n whiteList['grid-row-start'] = true; // default: auto\n whiteList['grid-template'] = true; // default: depending on individual properties\n whiteList['grid-template-areas'] = true; // default: none\n whiteList['grid-template-columns'] = true; // default: none\n whiteList['grid-template-rows'] = true; // default: none\n whiteList['justify-content'] = true; // default: auto\n whiteList['justify-items'] = true; // default: auto\n whiteList['justify-self'] = true; // default: auto\n whiteList['line-height'] = true; // default: normal\n whiteList['object-fit'] = true; // default: fill\n whiteList['object-position'] = true; // default: 50% 50%\n whiteList.order = true; // default: 0\n whiteList.orphans = true; // default: 2\n whiteList['row-gap'] = true;\n\n // position, opacity, overflow\n whiteList['all'] = true; // default: depending on individual properties\n whiteList['bottom'] = true; // default: auto\n whiteList['content'] = true; // default: normal\n whiteList['cursor'] = true; // default: auto\n whiteList['direction'] = true; // default: ltr\n whiteList['left'] = true; // default: auto\n whiteList['line-break'] = true; // default: auto\n whiteList['opacity'] = true; // default: 1\n whiteList['overflow'] = true; // default: depending on individual properties\n whiteList['overflow-wrap'] = true; // default: normal\n whiteList['overflow-x'] = true; // default: visible\n whiteList['overflow-y'] = true; // default: visible\n whiteList['position'] = true; // default: static\n whiteList['right'] = true; // default: auto\n whiteList['top'] = true; // default: auto\n whiteList['white-space'] = true; // default: normal\n whiteList['z-index'] = true; // default: auto\n\n return whiteList;\n};\n\n// yfmHtmlBlock additional allowedTags\nconst yfmHtmlBlockAllowedTags = ['link', 'base', 'style'];\n\n// yfmHtmlBlock additional allowedTags\nconst yfmHtmlBlockAllowedAttributes = {\n link: ['rel', 'href'],\n base: ['target'],\n style: [],\n};\n\nexport const getYfmHtmlBlockOptions = (defaultOptions: SanitizeOptions): SanitizeOptions => {\n type AllowedAttributesType = Record<\n string,\n (string | {name: string; multiple?: boolean | undefined; values: string[]})[]\n >;\n const defaultAllowedAttributes = defaultOptions.allowedAttributes as AllowedAttributesType;\n\n return {\n ...defaultOptions,\n allowedAttributes: {\n ...defaultAllowedAttributes,\n ...yfmHtmlBlockAllowedAttributes,\n },\n allowedTags:\n typeof defaultOptions.allowedTags === 'boolean'\n ? defaultOptions.allowedTags\n : [...(defaultOptions.allowedTags ?? []), ...yfmHtmlBlockAllowedTags],\n cssWhiteList: {\n ...defaultOptions.cssWhiteList,\n ...getYfmHtmlBlockWhiteList(),\n },\n };\n};\n\nexport interface GetSanitizeYfmHtmlBlockArgs {\n options: SanitizeOptions;\n sanitize?: (html: string, options?: SanitizeOptions) => string;\n}\nexport const getSanitizeYfmHtmlBlock =\n ({options, sanitize = diplodocSanitize}: GetSanitizeYfmHtmlBlockArgs) =>\n (content: string) =>\n sanitize(content, getYfmHtmlBlockOptions(options));\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"../../../../../src","sources":["extensions/additional/YfmHtmlBlock/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,sCAA8B;AAElD,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;AAErD,oDAAoD;AACpD,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAClC,MAAM,SAAS,GAA4B,EAAE,CAAC;IAE9C,qBAAqB;IACrB,SAAS,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC,gBAAgB;IACnD,SAAS,CAAC,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AC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC,kBAAkB;IACnD,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,gBAAgB;IAE7C,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,sCAAsC;AACtC,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1D,sCAAsC;AACtC,MAAM,6BAA6B,GAAG;IAClC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,cAA+B,EAAmB,EAAE;IAKvF,MAAM,wBAAwB,GAAG,cAAc,CAAC,iBAA0C,CAAC;IAE3F,OAAO;QACH,GAAG,cAAc;QACjB,iBAAiB,EAAE;YACf,GAAG,wBAAwB;YAC3B,GAAG,6BAA6B;SACnC;QACD,WAAW,EACP,OAAO,cAAc,CAAC,WAAW,KAAK,SAAS;YAC3C,CAAC,CAAC,cAAc,CAAC,WAAW;YAC5B,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,GAAG,uBAAuB,CAAC;QAC7E,YAAY,EAAE;YACV,GAAG,cAAc,CAAC,YAAY;YAC9B,GAAG,wBAAwB,EAAE;SAChC;KACJ,CAAC;AACN,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,uBAAuB,GAChC,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,gBAAgB,EAA8B,EAAE,EAAE,CACxE,CAAC,OAAe,EAAE,EAAE,CAChB,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC","sourcesContent":["import type {SanitizeOptions} from '@diplodoc/transform/lib/sanitize.js';\n\nimport {getSanitize} from 'src/utils/getSanitize';\n\n// MAJOR: use `import {sanitize} from '@diplodoc/transform/lib/sanitize.js'`\nconst diplodocSanitize = getSanitize('YfmHtmlBlock');\n\n// yfmHtmlBlock additional css properties white list\nconst getYfmHtmlBlockWhiteList = () => {\n const whiteList: Record<string, boolean> = {};\n\n // flex, grid, column\n whiteList['align-content'] = true; // default: auto\n whiteList['align-items'] = true; // default: auto\n whiteList['align-self'] = true; // default: auto\n whiteList.columns = true; // default: depending on individual properties\n whiteList['column-count'] = true; // default: auto\n whiteList['column-fill'] = true; // default: balance\n whiteList['column-gap'] = true; // default: normal\n whiteList['column-rule'] = true; // default: depending on individual properties\n whiteList['column-rule-color'] = true; // default: current color\n whiteList['column-rule-style'] = true; // default: medium\n whiteList['column-rule-width'] = true; // default: medium\n whiteList['column-span'] = true; // default: none\n whiteList['column-width'] = true; // default: auto\n whiteList.flex = true; // default: depending on individual properties\n whiteList['flex-basis'] = true; // default: auto\n whiteList['flex-direction'] = true; // default: row\n whiteList['flex-flow'] = true; // default: depending on individual properties\n whiteList['flex-grow'] = true; // default: 0\n whiteList['flex-shrink'] = true; // default: 1\n whiteList['flex-wrap'] = true; // default: nowrap\n whiteList.gap = true; // default: normal normal\n whiteList.grid = true; // default: depending on individual properties\n whiteList['grid-area'] = true; // default: depending on individual properties\n whiteList['grid-auto-columns'] = true; // default: auto\n whiteList['grid-auto-flow'] = true; // default: none\n whiteList['grid-auto-rows'] = true; // default: auto\n whiteList['grid-column'] = true; // default: depending on individual properties\n whiteList['grid-column-end'] = true; // default: auto\n whiteList['grid-column-start'] = true; // default: auto\n whiteList['grid-row'] = true; // default: depending on individual properties\n whiteList['grid-row-end'] = true; // default: auto\n whiteList['grid-row-start'] = true; // default: auto\n whiteList['grid-template'] = true; // default: depending on individual properties\n whiteList['grid-template-areas'] = true; // default: none\n whiteList['grid-template-columns'] = true; // default: none\n whiteList['grid-template-rows'] = true; // default: none\n whiteList['justify-content'] = true; // default: auto\n whiteList['justify-items'] = true; // default: auto\n whiteList['justify-self'] = true; // default: auto\n whiteList['line-height'] = true; // default: normal\n whiteList['object-fit'] = true; // default: fill\n whiteList['object-position'] = true; // default: 50% 50%\n whiteList.order = true; // default: 0\n whiteList.orphans = true; // default: 2\n whiteList['row-gap'] = true;\n\n // position, opacity, overflow\n whiteList['all'] = true; // default: depending on individual properties\n whiteList['bottom'] = true; // default: auto\n whiteList['content'] = true; // default: normal\n whiteList['cursor'] = true; // default: auto\n whiteList['direction'] = true; // default: ltr\n whiteList['left'] = true; // default: auto\n whiteList['line-break'] = true; // default: auto\n whiteList['opacity'] = true; // default: 1\n whiteList['overflow'] = true; // default: depending on individual properties\n whiteList['overflow-wrap'] = true; // default: normal\n whiteList['overflow-x'] = true; // default: visible\n whiteList['overflow-y'] = true; // default: visible\n whiteList['position'] = true; // default: static\n whiteList['right'] = true; // default: auto\n whiteList['top'] = true; // default: auto\n whiteList['white-space'] = true; // default: normal\n whiteList['z-index'] = true; // default: auto\n\n return whiteList;\n};\n\n// yfmHtmlBlock additional allowedTags\nconst yfmHtmlBlockAllowedTags = ['link', 'base', 'style'];\n\n// yfmHtmlBlock additional allowedTags\nconst yfmHtmlBlockAllowedAttributes = {\n link: ['rel', 'href'],\n base: ['target'],\n style: [],\n};\n\nexport const getYfmHtmlBlockOptions = (defaultOptions: SanitizeOptions): SanitizeOptions => {\n type AllowedAttributesType = Record<\n string,\n (string | {name: string; multiple?: boolean | undefined; values: string[]})[]\n >;\n const defaultAllowedAttributes = defaultOptions.allowedAttributes as AllowedAttributesType;\n\n return {\n ...defaultOptions,\n allowedAttributes: {\n ...defaultAllowedAttributes,\n ...yfmHtmlBlockAllowedAttributes,\n },\n allowedTags:\n typeof defaultOptions.allowedTags === 'boolean'\n ? defaultOptions.allowedTags\n : [...(defaultOptions.allowedTags ?? []), ...yfmHtmlBlockAllowedTags],\n cssWhiteList: {\n ...defaultOptions.cssWhiteList,\n ...getYfmHtmlBlockWhiteList(),\n },\n };\n};\n\nexport interface GetSanitizeYfmHtmlBlockArgs {\n options: SanitizeOptions;\n sanitize?: (html: string, options?: SanitizeOptions) => string;\n}\nexport const getSanitizeYfmHtmlBlock =\n ({options, sanitize = diplodocSanitize}: GetSanitizeYfmHtmlBlockArgs) =>\n (content: string) =>\n sanitize(content, getYfmHtmlBlockOptions(options));\n"]}
@@ -1,10 +1,11 @@
1
- import sanitize from '@diplodoc/transform/lib/sanitize.js';
1
+ import { getSanitize } from "../../../utils/getSanitize.js";
2
2
  import { HtmlAttr, HtmlNode } from "./const.js";
3
3
  var DomAttr;
4
4
  (function (DomAttr) {
5
5
  DomAttr["Html"] = "data-html";
6
6
  DomAttr["HtmlRaw"] = "data-html-raw";
7
7
  })(DomAttr || (DomAttr = {}));
8
+ const sanitize = getSanitize('Html');
8
9
  export const schemaSpecs = {
9
10
  [HtmlNode.Block]: {
10
11
  atom: true,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Html/schema.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qCAAqC,CAAC;AAG3D,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,mBAAgB;AAE3C,IAAK,OAGJ;AAHD,WAAK,OAAO;IACR,6BAAkB,CAAA;IAClB,oCAAyB,CAAA;AAC7B,CAAC,EAHI,OAAO,KAAP,OAAO,QAGX;AAED,MAAM,CAAC,MAAM,WAAW,GAA+B;IACnD,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACd,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,EAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAAC;QAC/B,QAAQ,EAAE;YACN;gBACI,GAAG,EAAE,OAAO,OAAO,CAAC,IAAI,GAAG;gBAC3B,QAAQ,CAAC,GAAG;oBACR,MAAM,IAAI,GAAG,GAAkB,CAAC;oBAChC,OAAO;wBACH,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,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,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ;CACJ,CAAC","sourcesContent":["import sanitize from '@diplodoc/transform/lib/sanitize.js';\nimport type {NodeSpec} from 'prosemirror-model';\n\nimport {HtmlAttr, HtmlNode} from './const';\n\nenum DomAttr {\n Html = 'data-html',\n HtmlRaw = 'data-html-raw',\n}\n\nexport const schemaSpecs: Record<HtmlNode, NodeSpec> = {\n [HtmlNode.Block]: {\n atom: true,\n group: 'block',\n attrs: {[HtmlAttr.Content]: {}},\n parseDOM: [\n {\n tag: `div[${DomAttr.Html}]`,\n getAttrs(dom) {\n const dom_ = dom as HTMLElement;\n return {\n [HtmlAttr.Content]: dom_.getAttribute(DomAttr.HtmlRaw) || dom_.innerHTML,\n };\n },\n },\n ],\n toDOM(node) {\n const htmlContent = node.attrs[HtmlAttr.Content] as string;\n const elem = document.createElement('div');\n elem.setAttribute(DomAttr.Html, '');\n elem.setAttribute(DomAttr.HtmlRaw, htmlContent);\n elem.contentEditable = 'false';\n elem.innerHTML = sanitize(htmlContent);\n return elem;\n },\n },\n\n [HtmlNode.Inline]: {\n atom: true,\n inline: true,\n group: 'inline',\n attrs: {[HtmlAttr.Content]: {}},\n parseDOM: [\n {\n tag: `span[${DomAttr.Html}]`,\n getAttrs(dom) {\n return {[HtmlAttr.Content]: (dom as HTMLElement).textContent};\n },\n },\n ],\n toDOM(node) {\n const elem = document.createElement('span');\n elem.setAttribute(DomAttr.Html, '');\n elem.contentEditable = 'false';\n elem.textContent = node.attrs[HtmlAttr.Content];\n return elem;\n },\n },\n};\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Html/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,sCAA8B;AAElD,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,mBAAgB;AAE3C,IAAK,OAGJ;AAHD,WAAK,OAAO;IACR,6BAAkB,CAAA;IAClB,oCAAyB,CAAA;AAC7B,CAAC,EAH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QAC/B,QAAQ,EAAE;YACN;gBACI,GAAG,EAAE,QAAQ,OAAO,CAAC,IAAI,GAAG;gBAC5B,QAAQ,CAAC,GAAG;oBACR,OAAO,EAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAG,GAAmB,CAAC,WAAW,EAAC,CAAC;gBAClE,CAAC;aACJ;SACJ;QACD,KAAK,CAAC,IAAI;YACN,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC5C,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;YAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ;CACJ,CAAC","sourcesContent":["import type {NodeSpec} from 'prosemirror-model';\n\nimport {getSanitize} from 'src/utils/getSanitize';\n\nimport {HtmlAttr, HtmlNode} from './const';\n\nenum DomAttr {\n Html = 'data-html',\n HtmlRaw = 'data-html-raw',\n}\n\nconst sanitize = getSanitize('Html');\n\nexport const schemaSpecs: Record<HtmlNode, NodeSpec> = {\n [HtmlNode.Block]: {\n atom: true,\n group: 'block',\n attrs: {[HtmlAttr.Content]: {}},\n parseDOM: [\n {\n tag: `div[${DomAttr.Html}]`,\n getAttrs(dom) {\n const dom_ = dom as HTMLElement;\n return {\n [HtmlAttr.Content]: dom_.getAttribute(DomAttr.HtmlRaw) || dom_.innerHTML,\n };\n },\n },\n ],\n toDOM(node) {\n const htmlContent = node.attrs[HtmlAttr.Content] as string;\n const elem = document.createElement('div');\n elem.setAttribute(DomAttr.Html, '');\n elem.setAttribute(DomAttr.HtmlRaw, htmlContent);\n elem.contentEditable = 'false';\n elem.innerHTML = sanitize(htmlContent);\n return elem;\n },\n },\n\n [HtmlNode.Inline]: {\n atom: true,\n inline: true,\n group: 'inline',\n attrs: {[HtmlAttr.Content]: {}},\n parseDOM: [\n {\n tag: `span[${DomAttr.Html}]`,\n getAttrs(dom) {\n return {[HtmlAttr.Content]: (dom as HTMLElement).textContent};\n },\n },\n ],\n toDOM(node) {\n const elem = document.createElement('span');\n elem.setAttribute(DomAttr.Html, '');\n elem.contentEditable = 'false';\n elem.textContent = node.attrs[HtmlAttr.Content];\n return elem;\n },\n },\n};\n"]}
@@ -1,5 +1,5 @@
1
- import { liftListItem, sinkListItem } from 'prosemirror-schema-list';
2
- import { toList } from "./commands.js";
1
+ import { liftListItem } from 'prosemirror-schema-list';
2
+ import { sinkOnlySelectedListItem, toList } from "./commands.js";
3
3
  import { ListNode } from "./const.js";
4
4
  import { blType, isIntoListOfType, liType, olType } from "./utils.js";
5
5
  export const actions = {
@@ -27,8 +27,8 @@ export const actions = {
27
27
  },
28
28
  sinkListItem: ({ schema }) => {
29
29
  return {
30
- isEnable: sinkListItem(liType(schema)),
31
- run: sinkListItem(liType(schema)),
30
+ isEnable: sinkOnlySelectedListItem(liType(schema)),
31
+ run: sinkOnlySelectedListItem(liType(schema)),
32
32
  };
33
33
  },
34
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Lists/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAC,MAAM,EAAC,sBAAmB;AAClC,OAAO,EAAC,QAAQ,EAAC,mBAAgB;AACjC,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAC,mBAAgB;AAEjE,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,YAAY,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QAClD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5C,OAAO;YACH,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC/C,QAAQ,EAAE,YAAY;YACtB,GAAG,EAAE,YAAY;SACpB,CAAC;IACN,CAAC;IAED,aAAa,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QACnD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,OAAO;YACH,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;YAChD,QAAQ,EAAE,aAAa;YACvB,GAAG,EAAE,aAAa;SACrB,CAAC;IACN,CAAC;IAED,YAAY,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QAClD,OAAO;YACH,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACtC,GAAG,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACpC,CAAC;IACN,CAAC;IAED,YAAY,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QAClD,OAAO;YACH,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACtC,GAAG,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACpC,CAAC;IACN,CAAC;CACJ,CAAC","sourcesContent":["import {liftListItem, sinkListItem} from 'prosemirror-schema-list';\n\nimport type {ActionSpec, ExtensionDeps} from '../../../core';\n\nimport {toList} from './commands';\nimport {ListNode} from './const';\nimport {blType, isIntoListOfType, liType, olType} from './utils';\n\nexport const actions = {\n toBulletList: ({schema}: ExtensionDeps): ActionSpec => {\n const toBulletList = toList(blType(schema));\n return {\n isActive: isIntoListOfType(ListNode.BulletList),\n isEnable: toBulletList,\n run: toBulletList,\n };\n },\n\n toOrderedList: ({schema}: ExtensionDeps): ActionSpec => {\n const toOrderedList = toList(olType(schema));\n return {\n isActive: isIntoListOfType(ListNode.OrderedList),\n isEnable: toOrderedList,\n run: toOrderedList,\n };\n },\n\n liftListItem: ({schema}: ExtensionDeps): ActionSpec => {\n return {\n isEnable: liftListItem(liType(schema)),\n run: liftListItem(liType(schema)),\n };\n },\n\n sinkListItem: ({schema}: ExtensionDeps): ActionSpec => {\n return {\n isEnable: sinkListItem(liType(schema)),\n run: sinkListItem(liType(schema)),\n };\n },\n};\n"]}
1
+ {"version":3,"file":"actions.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Lists/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAC,wBAAwB,EAAE,MAAM,EAAC,sBAAmB;AAC5D,OAAO,EAAC,QAAQ,EAAC,mBAAgB;AACjC,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAC,mBAAgB;AAEjE,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,YAAY,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QAClD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5C,OAAO;YACH,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC/C,QAAQ,EAAE,YAAY;YACtB,GAAG,EAAE,YAAY;SACpB,CAAC;IACN,CAAC;IAED,aAAa,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QACnD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,OAAO;YACH,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;YAChD,QAAQ,EAAE,aAAa;YACvB,GAAG,EAAE,aAAa;SACrB,CAAC;IACN,CAAC;IAED,YAAY,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QAClD,OAAO;YACH,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACtC,GAAG,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACpC,CAAC;IACN,CAAC;IAED,YAAY,EAAE,CAAC,EAAC,MAAM,EAAgB,EAAc,EAAE;QAClD,OAAO;YACH,QAAQ,EAAE,wBAAwB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClD,GAAG,EAAE,wBAAwB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAChD,CAAC;IACN,CAAC;CACJ,CAAC","sourcesContent":["import {liftListItem} from 'prosemirror-schema-list';\n\nimport type {ActionSpec, ExtensionDeps} from '../../../core';\n\nimport {sinkOnlySelectedListItem, toList} from './commands';\nimport {ListNode} from './const';\nimport {blType, isIntoListOfType, liType, olType} from './utils';\n\nexport const actions = {\n toBulletList: ({schema}: ExtensionDeps): ActionSpec => {\n const toBulletList = toList(blType(schema));\n return {\n isActive: isIntoListOfType(ListNode.BulletList),\n isEnable: toBulletList,\n run: toBulletList,\n };\n },\n\n toOrderedList: ({schema}: ExtensionDeps): ActionSpec => {\n const toOrderedList = toList(olType(schema));\n return {\n isActive: isIntoListOfType(ListNode.OrderedList),\n isEnable: toOrderedList,\n run: toOrderedList,\n };\n },\n\n liftListItem: ({schema}: ExtensionDeps): ActionSpec => {\n return {\n isEnable: liftListItem(liType(schema)),\n run: liftListItem(liType(schema)),\n };\n },\n\n sinkListItem: ({schema}: ExtensionDeps): ActionSpec => {\n return {\n isEnable: sinkOnlySelectedListItem(liType(schema)),\n run: sinkOnlySelectedListItem(liType(schema)),\n };\n },\n};\n"]}
@@ -1,4 +1,5 @@
1
- import type { NodeType } from 'prosemirror-model';
1
+ import { type NodeType } from 'prosemirror-model';
2
2
  import type { Command } from 'prosemirror-state';
3
3
  export declare function toList(listType: NodeType): Command;
4
4
  export declare const joinPrevList: Command;
5
+ export declare function sinkOnlySelectedListItem(itemType: NodeType): Command;
@@ -1,4 +1,6 @@
1
+ import { Fragment, Slice } from 'prosemirror-model';
1
2
  import { wrapInList } from 'prosemirror-schema-list';
3
+ import { ReplaceAroundStep, liftTarget } from 'prosemirror-transform';
2
4
  import { joinPreviousBlock } from "../../../commands/join.js";
3
5
  import { findAnyParentList, isListNode, isListOrItemNode } from "./utils.js";
4
6
  export function toList(listType) {
@@ -17,4 +19,65 @@ export const joinPrevList = joinPreviousBlock({
17
19
  checkPrevNode: isListNode,
18
20
  skipNode: isListOrItemNode,
19
21
  });
22
+ /*
23
+ Simplified `sinkListItem` from `prosemirror-schema-list` without `state`/`dispatch`,
24
+ sinks list items deeper.
25
+ */
26
+ const sink = (tr, range, itemType) => {
27
+ const before = tr.mapping.map(range.start);
28
+ const after = tr.mapping.map(range.end);
29
+ const startIndex = tr.mapping.map(range.startIndex);
30
+ const parent = range.parent;
31
+ const nodeBefore = parent.child(startIndex - 1);
32
+ const nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type === parent.type;
33
+ const inner = Fragment.from(nestedBefore ? itemType.create() : null);
34
+ const slice = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
35
+ tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true));
36
+ return true;
37
+ };
38
+ export function sinkOnlySelectedListItem(itemType) {
39
+ return ({ tr, selection }, dispatch) => {
40
+ const { $from, $to } = selection;
41
+ const selectionRange = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type === itemType);
42
+ if (!selectionRange) {
43
+ return false;
44
+ }
45
+ const { startIndex, parent, start, end } = selectionRange;
46
+ if (startIndex === 0) {
47
+ return false;
48
+ }
49
+ const nodeBefore = parent.child(startIndex - 1);
50
+ if (nodeBefore.type !== itemType) {
51
+ return false;
52
+ }
53
+ if (dispatch) {
54
+ // lifts following list items sequentially to prepare correct nesting structure
55
+ let currentEnd = end - 1;
56
+ while (currentEnd > start) {
57
+ const selectionEnd = tr.mapping.map($to.pos);
58
+ const $candidateBlockEnd = tr.doc.resolve(currentEnd);
59
+ const candidateBlockStartPos = $candidateBlockEnd.before($candidateBlockEnd.depth);
60
+ const $candidateBlockStart = tr.doc.resolve(candidateBlockStartPos);
61
+ const candidateBlockRange = $candidateBlockStart.blockRange($candidateBlockEnd);
62
+ if (candidateBlockRange?.start) {
63
+ const $rangeStart = tr.doc.resolve(candidateBlockRange.start);
64
+ const shouldLift = candidateBlockRange.start > selectionEnd && isListNode($rangeStart.parent);
65
+ if (shouldLift) {
66
+ currentEnd = candidateBlockRange.start;
67
+ const targetDepth = liftTarget(candidateBlockRange);
68
+ if (targetDepth !== null) {
69
+ tr.lift(candidateBlockRange, targetDepth);
70
+ }
71
+ }
72
+ }
73
+ currentEnd--;
74
+ }
75
+ // sinks the selected list item deeper into the list hierarchy
76
+ sink(tr, selectionRange, itemType);
77
+ dispatch(tr.scrollIntoView());
78
+ return true;
79
+ }
80
+ return false;
81
+ };
82
+ }
20
83
  //# sourceMappingURL=commands.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Lists/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAGnD,OAAO,EAAC,iBAAiB,EAAC,kCAA+B;AAEzD,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAC,mBAAgB;AAExE,MAAM,UAAU,MAAM,CAAC,QAAkB;IACrC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QACvB,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACpE,IAAI,UAAU,EAAE,CAAC;YACb,IAAI,QAAQ,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YAEnD,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,CAAC;AACN,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC;IAC1C,aAAa,EAAE,UAAU;IACzB,QAAQ,EAAE,gBAAgB;CAC7B,CAAC,CAAC","sourcesContent":["import type {NodeType} from 'prosemirror-model';\nimport {wrapInList} from 'prosemirror-schema-list';\nimport type {Command} from 'prosemirror-state';\n\nimport {joinPreviousBlock} from '../../../commands/join';\n\nimport {findAnyParentList, isListNode, isListOrItemNode} from './utils';\n\nexport function toList(listType: NodeType): Command {\n return (state, dispatch) => {\n const parentList = findAnyParentList(state.schema)(state.selection);\n if (parentList) {\n if (listType === parentList.node.type) return true;\n\n dispatch?.(state.tr.setNodeMarkup(parentList.pos, listType));\n return true;\n }\n return wrapInList(listType)(state, dispatch);\n };\n}\n\nexport const joinPrevList = joinPreviousBlock({\n checkPrevNode: isListNode,\n skipNode: isListOrItemNode,\n});\n"]}
1
+ {"version":3,"file":"commands.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/Lists/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAiC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAC,iBAAiB,EAAC,kCAA+B;AAEzD,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAC,mBAAgB;AAExE,MAAM,UAAU,MAAM,CAAC,QAAkB;IACrC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QACvB,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,SAA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,cAAc,EAAE,QAAQ,CAAC,CAAC;YAEnC,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;YAC9B,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {Fragment, type NodeRange, type NodeType, Slice} from 'prosemirror-model';\nimport {wrapInList} from 'prosemirror-schema-list';\nimport type {Command, Transaction} from 'prosemirror-state';\nimport {ReplaceAroundStep, liftTarget} from 'prosemirror-transform';\n\nimport {joinPreviousBlock} from '../../../commands/join';\n\nimport {findAnyParentList, isListNode, isListOrItemNode} from './utils';\n\nexport function toList(listType: NodeType): Command {\n return (state, dispatch) => {\n const parentList = findAnyParentList(state.schema)(state.selection);\n if (parentList) {\n if (listType === parentList.node.type) return true;\n\n dispatch?.(state.tr.setNodeMarkup(parentList.pos, listType));\n return true;\n }\n return wrapInList(listType)(state, dispatch);\n };\n}\n\nexport const joinPrevList = joinPreviousBlock({\n checkPrevNode: isListNode,\n skipNode: isListOrItemNode,\n});\n\n/*\n Simplified `sinkListItem` from `prosemirror-schema-list` without `state`/`dispatch`,\n sinks list items deeper.\n */\nconst sink = (tr: Transaction, range: NodeRange, itemType: NodeType) => {\n const before = tr.mapping.map(range.start);\n const after = tr.mapping.map(range.end);\n const startIndex = tr.mapping.map(range.startIndex);\n\n const parent = range.parent;\n const nodeBefore = parent.child(startIndex - 1);\n\n const nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type === parent.type;\n const inner = Fragment.from(nestedBefore ? itemType.create() : null);\n const slice = new Slice(\n Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))),\n nestedBefore ? 3 : 1,\n 0,\n );\n\n tr.step(\n new ReplaceAroundStep(\n before - (nestedBefore ? 3 : 1),\n after,\n before,\n after,\n slice,\n 1,\n true,\n ),\n );\n return true;\n};\n\nexport function sinkOnlySelectedListItem(itemType: NodeType): Command {\n return ({tr, selection}, dispatch) => {\n const {$from, $to} = selection;\n const selectionRange = $from.blockRange(\n $to,\n (node) => node.childCount > 0 && node.firstChild!.type === itemType,\n );\n if (!selectionRange) {\n return false;\n }\n\n const {startIndex, parent, start, end} = selectionRange;\n if (startIndex === 0) {\n return false;\n }\n\n const nodeBefore = parent.child(startIndex - 1);\n if (nodeBefore.type !== itemType) {\n return false;\n }\n\n if (dispatch) {\n // lifts following list items sequentially to prepare correct nesting structure\n let currentEnd = end - 1;\n while (currentEnd > start) {\n const selectionEnd = tr.mapping.map($to.pos);\n\n const $candidateBlockEnd = tr.doc.resolve(currentEnd);\n const candidateBlockStartPos = $candidateBlockEnd.before($candidateBlockEnd.depth);\n const $candidateBlockStart = tr.doc.resolve(candidateBlockStartPos);\n const candidateBlockRange = $candidateBlockStart.blockRange($candidateBlockEnd);\n\n if (candidateBlockRange?.start) {\n const $rangeStart = tr.doc.resolve(candidateBlockRange.start);\n const shouldLift =\n candidateBlockRange.start > selectionEnd && isListNode($rangeStart.parent);\n\n if (shouldLift) {\n currentEnd = candidateBlockRange.start;\n\n const targetDepth = liftTarget(candidateBlockRange);\n if (targetDepth !== null) {\n tr.lift(candidateBlockRange, targetDepth);\n }\n }\n }\n\n currentEnd--;\n }\n\n // sinks the selected list item deeper into the list hierarchy\n sink(tr, selectionRange, itemType);\n\n dispatch(tr.scrollIntoView());\n return true;\n }\n return false;\n };\n}\n"]}