@gravity-ui/markdown-editor 15.21.0 → 15.22.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 (98) hide show
  1. package/build/cjs/extensions/additional/FoldingHeading/plugins/folding.css +12 -9
  2. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.d.ts +2 -0
  3. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js +11 -9
  4. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js.map +1 -1
  5. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/NodeView.d.ts +1 -0
  6. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/NodeView.js +3 -1
  7. package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/NodeView.js.map +1 -1
  8. package/build/cjs/extensions/additional/Mermaid/index.d.ts +4 -0
  9. package/build/cjs/extensions/additional/Mermaid/index.js +4 -4
  10. package/build/cjs/extensions/additional/Mermaid/index.js.map +1 -1
  11. package/build/cjs/extensions/additional/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +11 -8
  12. package/build/cjs/extensions/additional/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js.map +1 -1
  13. package/build/cjs/extensions/additional/YfmHtmlBlock/index.d.ts +4 -0
  14. package/build/cjs/extensions/additional/YfmHtmlBlock/index.js.map +1 -1
  15. package/build/cjs/extensions/base/BaseSchema/BaseSchemaSpecs/index.js +2 -1
  16. package/build/cjs/extensions/base/BaseSchema/BaseSchemaSpecs/index.js.map +1 -1
  17. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +1 -1
  18. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -1
  19. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +1 -0
  20. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -1
  21. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js +10 -7
  22. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js.map +1 -1
  23. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/const.d.ts +2 -2
  24. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js +2 -2
  25. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js.map +1 -1
  26. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.d.ts +31 -0
  27. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js +177 -0
  28. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js.map +1 -0
  29. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.css +71 -6
  30. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.d.ts +1 -0
  31. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +36 -22
  32. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
  33. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +4 -7
  34. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -1
  35. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.d.ts +13 -4
  36. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js +11 -9
  37. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js.map +1 -1
  38. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/utils.d.ts +4 -0
  39. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/utils.js +50 -0
  40. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/utils.js.map +1 -0
  41. package/build/cjs/react-utils/hooks/useAutoSave.d.ts +23 -0
  42. package/build/cjs/react-utils/hooks/useAutoSave.js +59 -0
  43. package/build/cjs/react-utils/hooks/useAutoSave.js.map +1 -0
  44. package/build/cjs/react-utils/hooks.d.ts +1 -1
  45. package/build/cjs/react-utils/hooks.js +3 -1
  46. package/build/cjs/react-utils/hooks.js.map +1 -1
  47. package/build/cjs/version.js +1 -1
  48. package/build/cjs/version.js.map +1 -1
  49. package/build/esm/extensions/additional/FoldingHeading/plugins/folding.css +12 -9
  50. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.d.ts +2 -0
  51. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js +12 -10
  52. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js.map +1 -1
  53. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/NodeView.d.ts +1 -0
  54. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/NodeView.js +3 -1
  55. package/build/esm/extensions/additional/Mermaid/MermaidNodeView/NodeView.js.map +1 -1
  56. package/build/esm/extensions/additional/Mermaid/index.d.ts +4 -0
  57. package/build/esm/extensions/additional/Mermaid/index.js +4 -4
  58. package/build/esm/extensions/additional/Mermaid/index.js.map +1 -1
  59. package/build/esm/extensions/additional/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +12 -9
  60. package/build/esm/extensions/additional/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js.map +1 -1
  61. package/build/esm/extensions/additional/YfmHtmlBlock/index.d.ts +4 -0
  62. package/build/esm/extensions/additional/YfmHtmlBlock/index.js.map +1 -1
  63. package/build/esm/extensions/base/BaseSchema/BaseSchemaSpecs/index.js +2 -1
  64. package/build/esm/extensions/base/BaseSchema/BaseSchemaSpecs/index.js.map +1 -1
  65. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +1 -1
  66. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -1
  67. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +1 -0
  68. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -1
  69. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js +10 -7
  70. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js.map +1 -1
  71. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/const.d.ts +2 -2
  72. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js +2 -2
  73. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js.map +1 -1
  74. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.d.ts +31 -0
  75. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js +173 -0
  76. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js.map +1 -0
  77. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.css +71 -6
  78. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.d.ts +1 -0
  79. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +37 -23
  80. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
  81. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +4 -7
  82. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -1
  83. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.d.ts +13 -4
  84. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js +11 -9
  85. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js.map +1 -1
  86. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/utils.d.ts +4 -0
  87. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/utils.js +46 -0
  88. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/utils.js.map +1 -0
  89. package/build/esm/react-utils/hooks/useAutoSave.d.ts +23 -0
  90. package/build/esm/react-utils/hooks/useAutoSave.js +55 -0
  91. package/build/esm/react-utils/hooks/useAutoSave.js.map +1 -0
  92. package/build/esm/react-utils/hooks.d.ts +1 -1
  93. package/build/esm/react-utils/hooks.js +1 -0
  94. package/build/esm/react-utils/hooks.js.map +1 -1
  95. package/build/esm/version.js +1 -1
  96. package/build/esm/version.js.map +1 -1
  97. package/build/styles.css +83 -15
  98. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/additional/YfmHtmlBlock/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,qBAAqB,EAAC,wCAA+B;AAC7D,OAAO,EAAC,iBAAiB,EAAC,qCAA4B;AACtD,OAAO,EAAC,kBAAkB,EAAC,qCAAkC;AAC7D,OAAO,EAAC,eAAe,EAAC,qBAAkB;AAO1C,MAAM,CAAC,MAAM,YAAY,GAAuC,CAC5D,OAAO,EACP,EAAC,SAAS,EAAE,CAAC,EAAE,GAAG,OAAO,EAAC,EAC5B,EAAE;IACA,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;QAC3B,QAAQ,EAAE,2BAA2B,CAAC,OAAO,CAAC;QAC9C,GAAG,OAAO;KACb,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAEmB,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAC1F,OAAO,IAAI,qBAAqB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import type {PluginOptions} from '@diplodoc/html-extension';\nimport type {IHTMLIFrameElementConfig} from '@diplodoc/html-extension/runtime';\n\nimport type {Action, ExtensionAuto, ExtensionDeps, NodeViewConstructor} from '../../../core';\n\nimport {WYfmHtmlBlockNodeView} from './YfmHtmlBlockNodeView';\nimport {YfmHtmlBlockSpecs} from './YfmHtmlBlockSpecs';\nimport {YfmHtmlBlockAction} from './YfmHtmlBlockSpecs/const';\nimport {addYfmHtmlBlock} from './actions';\n\nexport interface YfmHtmlBlockOptions\n extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle' | 'embeddingMode'> {\n useConfig?: () => IHTMLIFrameElementConfig | undefined;\n}\n\nexport const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions> = (\n builder,\n {useConfig: _, ...options},\n) => {\n builder.use(YfmHtmlBlockSpecs, {\n nodeView: YfmHtmlBlockNodeViewFactory(options),\n ...options,\n });\n\n builder.addAction(YfmHtmlBlockAction, () => addYfmHtmlBlock);\n};\n\nconst YfmHtmlBlockNodeViewFactory: (\n options: YfmHtmlBlockOptions,\n) => (deps: ExtensionDeps) => NodeViewConstructor = (options) => () => (node, view, getPos) => {\n return new WYfmHtmlBlockNodeView({node, view, getPos, options});\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [YfmHtmlBlockAction]: Action;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/additional/YfmHtmlBlock/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,qBAAqB,EAAC,wCAA+B;AAC7D,OAAO,EAAC,iBAAiB,EAAC,qCAA4B;AACtD,OAAO,EAAC,kBAAkB,EAAC,qCAAkC;AAC7D,OAAO,EAAC,eAAe,EAAC,qBAAkB;AAW1C,MAAM,CAAC,MAAM,YAAY,GAAuC,CAC5D,OAAO,EACP,EAAC,SAAS,EAAE,CAAC,EAAE,GAAG,OAAO,EAAC,EAC5B,EAAE;IACA,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;QAC3B,QAAQ,EAAE,2BAA2B,CAAC,OAAO,CAAC;QAC9C,GAAG,OAAO;KACb,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAEmB,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAC1F,OAAO,IAAI,qBAAqB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import type {PluginOptions} from '@diplodoc/html-extension';\nimport type {IHTMLIFrameElementConfig} from '@diplodoc/html-extension/runtime';\n\nimport type {Action, ExtensionAuto, ExtensionDeps, NodeViewConstructor} from '../../../core';\n\nimport {WYfmHtmlBlockNodeView} from './YfmHtmlBlockNodeView';\nimport {YfmHtmlBlockSpecs} from './YfmHtmlBlockSpecs';\nimport {YfmHtmlBlockAction} from './YfmHtmlBlockSpecs/const';\nimport {addYfmHtmlBlock} from './actions';\n\nexport interface YfmHtmlBlockOptions\n extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle' | 'embeddingMode'> {\n useConfig?: () => IHTMLIFrameElementConfig | undefined;\n autoSave?: {\n enabled: boolean;\n delay?: number; // по умолчанию 1000ms\n };\n}\n\nexport const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions> = (\n builder,\n {useConfig: _, ...options},\n) => {\n builder.use(YfmHtmlBlockSpecs, {\n nodeView: YfmHtmlBlockNodeViewFactory(options),\n ...options,\n });\n\n builder.addAction(YfmHtmlBlockAction, () => addYfmHtmlBlock);\n};\n\nconst YfmHtmlBlockNodeViewFactory: (\n options: YfmHtmlBlockOptions,\n) => (deps: ExtensionDeps) => NodeViewConstructor = (options) => () => (node, view, getPos) => {\n return new WYfmHtmlBlockNodeView({node, view, getPos, options});\n};\n\ndeclare global {\n namespace WysiwygEditor {\n interface Actions {\n [YfmHtmlBlockAction]: Action;\n }\n }\n}\n"]}
@@ -67,7 +67,8 @@ export const BaseSchemaSpecs = (builder, opts) => {
67
67
  }
68
68
  }
69
69
  if (!isParentEmpty) {
70
- state.write('&nbsp;\n\n');
70
+ state.write('&nbsp;\n');
71
+ state.write('\n');
71
72
  }
72
73
  }
73
74
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/base/BaseSchema/BaseSchemaSpecs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,mCAAkB;AAGxC,OAAO,EAAC,eAAe,EAAC,oCAAiC;AAEzD,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,uBAAW,CAAA;IACX,yBAAa,CAAA;IACb,mCAAuB,CAAA;AAC3B,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAE5C,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAQzD,MAAM,CAAC,MAAM,eAAe,GAA0C,CAAC,OAAO,EAAE,IAAI,E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AC,IAAI,CAAC,CAAC;gBACzB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACL,CAAC;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import type {NodeSpec} from 'prosemirror-model';\n\nimport {isEmptyString} from 'src/utils';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {nodeTypeFactory} from '../../../../utils/schema';\n\nexport enum BaseNode {\n Doc = 'doc',\n Text = 'text',\n Paragraph = 'paragraph',\n}\n\nconst paragraphLineNumberAttr = 'data-line';\n\nexport const pType = nodeTypeFactory(BaseNode.Paragraph);\n\nexport type BaseSchemaSpecsOptions = {\n // This cannot be passed through placeholder option of BehaviorPreset because BasePreset initializes first\n paragraphPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];\n preserveEmptyRows?: boolean;\n};\n\nexport const BaseSchemaSpecs: ExtensionAuto<BaseSchemaSpecsOptions> = (builder, opts) => {\n builder\n .addNode(BaseNode.Doc, () => ({\n spec: {\n content: 'block+',\n },\n fromMd: {tokenSpec: {name: BaseNode.Doc, type: 'block', ignore: true}},\n toMd: () => {\n throw new Error('Unexpected toMd() call on doc node');\n },\n }))\n .addNode(BaseNode.Text, () => ({\n spec: {\n group: 'inline',\n },\n fromMd: {tokenSpec: {name: BaseNode.Text, type: 'node', ignore: true}},\n toMd: (state, node, parent) => {\n const {escapeText} = parent.type.spec;\n state.text(node.text ?? '', escapeText ?? !state.isAutolink);\n },\n }))\n .addNode(BaseNode.Paragraph, () => ({\n spec: {\n attrs: {[paragraphLineNumberAttr]: {default: null}},\n content: 'inline*',\n group: 'block',\n parseDOM: [{tag: 'p'}],\n toDOM(node) {\n const lineNumber = node.attrs[paragraphLineNumberAttr];\n\n return [\n 'p',\n lineNumber === null ? {} : {[paragraphLineNumberAttr]: lineNumber},\n 0,\n ];\n },\n selectable: true,\n placeholder: opts.paragraphPlaceholder\n ? {\n content: opts.paragraphPlaceholder,\n alwaysVisible: false,\n }\n : undefined,\n },\n fromMd: {tokenSpec: {name: BaseNode.Paragraph, type: 'block'}},\n toMd: (state, node, parent) => {\n /*\n An empty line is added only if there is some content in the parent element.\n This is necessary in order to prevent an empty document with empty lines\n */\n if (opts.preserveEmptyRows && isEmptyString(node)) {\n let isParentEmpty = true;\n\n for (let index = 0; index < parent.content.childCount; index++) {\n const parentChild = parent.content.child(index);\n if (\n parentChild.content.size !== 0 ||\n parentChild.type.name !== 'paragraph'\n ) {\n isParentEmpty = false;\n }\n }\n\n if (!isParentEmpty) {\n state.write('&nbsp;\\n\\n');\n }\n } else {\n state.renderInline(node);\n state.closeBlock(node);\n }\n },\n }));\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/base/BaseSchema/BaseSchemaSpecs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,mCAAkB;AAGxC,OAAO,EAAC,eAAe,EAAC,oCAAiC;AAEzD,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,uBAAW,CAAA;IACX,yBAAa,CAAA;IACb,mCAAuB,CAAA;AAC3B,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAE5C,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAQzD,MAAM,CAAC,MAAM,eAAe,GAA0C,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IACpF,OAAO;SACF,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC1B,IAAI,EAAE;YACF,OAAO,EAAE,QAAQ;SACpB;QACD,MAAM,EAAE,EAAC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAC,EAAC;QACtE,IAAI,EAAE,GAAG,EAAE;YACP,M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oBACI,OAAO,EAAE,IAAI,CAAC,oBAAoB;oBAClC,aAAa,EAAE,KAAK;iBACvB;gBACH,CAAC,CAAC,SAAS;SAClB;QACD,MAAM,EAAE,EAAC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAC,EAAC;QAC9D,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;YAC1B;;;cAGE;YACF,IAAI,IAAI,CAAC,iBAAiB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChD,IAAI,aAAa,GAAG,IAAI,CAAC;gBAEzB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;oBAC7D,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBAChD,IACI,WAAW,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;wBAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,EACvC,CAAC;wBACC,aAAa,GAAG,KAAK,CAAC;oBAC1B,CAAC;gBACL,CAAC;gBAED,IAAI,CAAC,aAAa,EAAE,CAAC;oBACjB,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;oBACxB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBACzB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACL,CAAC;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import type {NodeSpec} from 'prosemirror-model';\n\nimport {isEmptyString} from 'src/utils';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {nodeTypeFactory} from '../../../../utils/schema';\n\nexport enum BaseNode {\n Doc = 'doc',\n Text = 'text',\n Paragraph = 'paragraph',\n}\n\nconst paragraphLineNumberAttr = 'data-line';\n\nexport const pType = nodeTypeFactory(BaseNode.Paragraph);\n\nexport type BaseSchemaSpecsOptions = {\n // This cannot be passed through placeholder option of BehaviorPreset because BasePreset initializes first\n paragraphPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];\n preserveEmptyRows?: boolean;\n};\n\nexport const BaseSchemaSpecs: ExtensionAuto<BaseSchemaSpecsOptions> = (builder, opts) => {\n builder\n .addNode(BaseNode.Doc, () => ({\n spec: {\n content: 'block+',\n },\n fromMd: {tokenSpec: {name: BaseNode.Doc, type: 'block', ignore: true}},\n toMd: () => {\n throw new Error('Unexpected toMd() call on doc node');\n },\n }))\n .addNode(BaseNode.Text, () => ({\n spec: {\n group: 'inline',\n },\n fromMd: {tokenSpec: {name: BaseNode.Text, type: 'node', ignore: true}},\n toMd: (state, node, parent) => {\n const {escapeText} = parent.type.spec;\n state.text(node.text ?? '', escapeText ?? !state.isAutolink);\n },\n }))\n .addNode(BaseNode.Paragraph, () => ({\n spec: {\n attrs: {[paragraphLineNumberAttr]: {default: null}},\n content: 'inline*',\n group: 'block',\n parseDOM: [{tag: 'p'}],\n toDOM(node) {\n const lineNumber = node.attrs[paragraphLineNumberAttr];\n\n return [\n 'p',\n lineNumber === null ? {} : {[paragraphLineNumberAttr]: lineNumber},\n 0,\n ];\n },\n selectable: true,\n placeholder: opts.paragraphPlaceholder\n ? {\n content: opts.paragraphPlaceholder,\n alwaysVisible: false,\n }\n : undefined,\n },\n fromMd: {tokenSpec: {name: BaseNode.Paragraph, type: 'block'}},\n toMd: (state, node, parent) => {\n /*\n An empty line is added only if there is some content in the parent element.\n This is necessary in order to prevent an empty document with empty lines\n */\n if (opts.preserveEmptyRows && isEmptyString(node)) {\n let isParentEmpty = true;\n\n for (let index = 0; index < parent.content.childCount; index++) {\n const parentChild = parent.content.child(index);\n if (\n parentChild.content.size !== 0 ||\n parentChild.type.name !== 'paragraph'\n ) {\n isParentEmpty = false;\n }\n }\n\n if (!isParentEmpty) {\n state.write('&nbsp;\\n');\n state.write('\\n');\n }\n } else {\n state.renderInline(node);\n state.closeBlock(node);\n }\n },\n }));\n};\n"]}
@@ -4,7 +4,7 @@ export type FloatingMenuProps = {
4
4
  canDrag: boolean;
5
5
  anchorElement: Element;
6
6
  dropdownItems: DropdownMenuProps<unknown>['items'];
7
- switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp'>;
7
+ switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp' | 'onMouseLeave'>;
8
8
  onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;
9
9
  };
10
10
  export declare const FloatingMenu: React.FC<FloatingMenuProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingMenu.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAE,cAAc,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACvF,OAAO,EACH,MAAM,EAEN,YAAY,EAEZ,IAAI,EACJ,IAAI,GACP,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,eAAe,EAAC,kDAAwB;AAEhD,OAAO,EAAC,aAAa,EAA0B,kCAAyB;AAExE,MAAM,WAAW,GAAiC;IAC9C,QAAQ,EAAE,CAAC,GAAG;CACjB,CAAC;AAWF,MAAM,CAAC,MAAM,YAAY,GAAgC,SAAS,oBAAoB,CAAC,KAAK;IACxF,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAC,GACpF,KAAK,CAAC;IAEV,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AAK;wBACvD,uBAAuB,EAAE,cAAc;4BACnC,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,gCAAgC;qBACzC,EACD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,EACnD,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,EACrD,IAAI,EAAC,IAAI,EACT,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,2BAA2B,KAClE,aAAa,KACb,kBAAkB,YAErB,cAAc,CAAC,CAAC,CAAC,CACd,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAI,CACpD,CAAC,CAAC,CAAC,CACA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW;qBACxC,GACI,GACN,CACV,EACD,UAAU,EAAE;gBACR,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc;aACxD,EACD,SAAS,EAAE,EAAC,EAAE,EAAE,kBAAkB,OAAO,OAAO,EAAC,EACjD,KAAK,EAAE,aAAa,GACtB,GACU,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useState} from 'react';\n\nimport {Ellipsis as DotsColumn, GripHorizontal as GripColumn} from '@gravity-ui/icons';\nimport {\n Button,\n type ButtonButtonProps,\n DropdownMenu,\n type DropdownMenuProps,\n Flex,\n Icon,\n} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nimport {FloatingPopup, type FloatingPopupProps} from '../FloatingPopup';\n\nconst popupOffset: FloatingPopupProps['offset'] = {\n mainAxis: -9.5,\n};\n\nexport type FloatingMenuProps = {\n dirtype: 'row' | 'column';\n canDrag: boolean;\n anchorElement: Element;\n dropdownItems: DropdownMenuProps<unknown>['items'];\n switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp'>;\n onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;\n};\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = function YfmTableFloatingMenu(props) {\n const {dirtype, canDrag, anchorElement, dropdownItems, switcherMouseProps, onOpenToggle} =\n props;\n\n const [isMenuOpened, setMenuOpened] = useState(false);\n const [isHovered, setHovered, unsetHovered] = useBooleanState(false);\n\n const showActionView = isMenuOpened || isHovered;\n const isRowType = dirtype === 'row';\n\n return (\n <FloatingPopup\n open\n offset={popupOffset}\n anchorElement={anchorElement}\n placement={isRowType ? 'left' : 'top'}\n floatingStyles={{\n lineHeight: 'initial',\n }}\n style={{\n backgroundColor: 'transparent',\n }}\n >\n <DropdownMenu\n onOpenToggle={(...args) => {\n setMenuOpened(...args);\n onOpenToggle(...args);\n }}\n renderSwitcher={(switcherProps) => (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n style={{\n borderRadius: 'var(--g-border-radius-xs)',\n backgroundColor: showActionView\n ? 'var(--g-color-base-background)'\n : undefined,\n }}\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n >\n <Button\n style={{\n cursor: canDrag ? 'grab' : undefined,\n transform: isRowType ? 'rotate(90deg)' : undefined,\n '--g-button-height': showActionView ? undefined : '5px',\n '--_--background-color': showActionView\n ? undefined\n : 'var(--g-color-base-background)',\n }}\n view={isMenuOpened ? 'outlined-action' : 'outlined'}\n pin={showActionView ? 'round-round' : 'circle-circle'}\n size=\"xs\"\n qa={isRowType ? 'g-md-yfm-table-row-btn' : 'g-md-yfm-table-column-btn'}\n {...switcherProps}\n {...switcherMouseProps}\n >\n {showActionView ? (\n <Icon data={canDrag ? GripColumn : DotsColumn} />\n ) : (\n String.fromCharCode(8194) // en space\n )}\n </Button>\n </Flex>\n )}\n popupProps={{\n zIndex: 1010,\n placement: isRowType ? 'right-start' : 'bottom-start',\n }}\n menuProps={{qa: `g-md-yfm-table-${dirtype}-menu`}}\n items={dropdownItems}\n />\n </FloatingPopup>\n );\n};\n"]}
1
+ {"version":3,"file":"FloatingMenu.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAE,cAAc,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACvF,OAAO,EACH,MAAM,EAEN,YAAY,EAEZ,IAAI,EACJ,IAAI,GACP,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,eAAe,EAAC,kDAAwB;AAEhD,OAAO,EAAC,aAAa,EAA0B,kCAAyB;AAExE,MAAM,WAAW,GAAiC;IAC9C,QAAQ,EAAE,CAAC,GAAG;CACjB,CAAC;AAcF,MAAM,CAAC,MAAM,YAAY,GAAgC,SAAS,oBAAoB,CAAC,KAAK;IACxF,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAC,GACpF,KAAK,CAAC;IAEV,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAErE,MAAM,cAAc,GAAG,YAAY,IAAI,SAAS,CAAC;IACjD,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,CAAC;IAEpC,OAAO,CACH,KAAC,aAAa,IACV,IAAI,QACJ,MAAM,EAAE,WAAW,EACnB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EACrC,cAAc,EAAE;YACZ,UAAU,EAAE,SAAS;SACx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,CAAC,UAAU,GAAI,CACpD,CAAC,CAAC,CAAC,CACA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW;qBACxC,GACI,GACN,CACV,EACD,UAAU,EAAE;gBACR,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc;aACxD,EACD,SAAS,EAAE,EAAC,EAAE,EAAE,kBAAkB,OAAO,OAAO,EAAC,EACjD,KAAK,EAAE,aAAa,GACtB,GACU,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useState} from 'react';\n\nimport {Ellipsis as DotsColumn, GripHorizontal as GripColumn} from '@gravity-ui/icons';\nimport {\n Button,\n type ButtonButtonProps,\n DropdownMenu,\n type DropdownMenuProps,\n Flex,\n Icon,\n} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nimport {FloatingPopup, type FloatingPopupProps} from '../FloatingPopup';\n\nconst popupOffset: FloatingPopupProps['offset'] = {\n mainAxis: -9.5,\n};\n\nexport type FloatingMenuProps = {\n dirtype: 'row' | 'column';\n canDrag: boolean;\n anchorElement: Element;\n dropdownItems: DropdownMenuProps<unknown>['items'];\n switcherMouseProps?: Pick<\n ButtonButtonProps,\n 'onMouseDown' | 'onMouseMove' | 'onMouseUp' | 'onMouseLeave'\n >;\n onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;\n};\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = function YfmTableFloatingMenu(props) {\n const {dirtype, canDrag, anchorElement, dropdownItems, switcherMouseProps, onOpenToggle} =\n props;\n\n const [isMenuOpened, setMenuOpened] = useState(false);\n const [isHovered, setHovered, unsetHovered] = useBooleanState(false);\n\n const showActionView = isMenuOpened || isHovered;\n const isRowType = dirtype === 'row';\n\n return (\n <FloatingPopup\n open\n offset={popupOffset}\n anchorElement={anchorElement}\n placement={isRowType ? 'left' : 'top'}\n floatingStyles={{\n lineHeight: 'initial',\n }}\n style={{\n backgroundColor: 'transparent',\n }}\n >\n <DropdownMenu\n onOpenToggle={(...args) => {\n setMenuOpened(...args);\n onOpenToggle(...args);\n }}\n renderSwitcher={(switcherProps) => (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n style={{\n borderRadius: 'var(--g-border-radius-xs)',\n backgroundColor: showActionView\n ? 'var(--g-color-base-background)'\n : undefined,\n }}\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n >\n <Button\n style={{\n cursor: canDrag ? 'grab' : undefined,\n transform: isRowType ? 'rotate(90deg)' : undefined,\n '--g-button-height': showActionView ? undefined : '5px',\n '--_--background-color': showActionView\n ? undefined\n : 'var(--g-color-base-background)',\n }}\n view={isMenuOpened ? 'outlined-action' : 'outlined'}\n pin={showActionView ? 'round-round' : 'circle-circle'}\n size=\"xs\"\n qa={isRowType ? 'g-md-yfm-table-row-btn' : 'g-md-yfm-table-column-btn'}\n {...switcherProps}\n {...switcherMouseProps}\n >\n {showActionView ? (\n <Icon data={canDrag ? GripColumn : DotsColumn} />\n ) : (\n String.fromCharCode(8194) // en space\n )}\n </Button>\n </Flex>\n )}\n popupProps={{\n zIndex: 1010,\n placement: isRowType ? 'right-start' : 'bottom-start',\n }}\n menuProps={{qa: `g-md-yfm-table-${dirtype}-menu`}}\n items={dropdownItems}\n />\n </FloatingPopup>\n );\n};\n"]}
@@ -54,6 +54,7 @@ export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type,
54
54
  ]);
55
55
  return (_jsx(FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: acnhorElement, switcherMouseProps: dndHandler
56
56
  ? {
57
+ onMouseLeave: dndHandler.control_handleMouseLeave,
57
58
  onMouseDown: dndHandler.control_handleMouseDown,
58
59
  onMouseMove: dndHandler.control_handleMouseMove,
59
60
  onMouseUp: dndHandler.control_handleMouseUp,
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingMenuControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,OAAO,EACH,SAAS,EACT,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW,IAAI,UAAU,EACzB,QAAQ,EACR,KAAK,GACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAC,IAAI,EAAC,qDAA2B;AAGxC,OAAO,EAAC,YAAY,EAAyB,wCAAqC;AAelF,MAAM,CAAC,MAAM,mBAAmB,GAC5B,SAAS,2BAA2B,CAAC,EACjC,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACrB;IACG,MAAM,aAAa,GAAG,OAAO,CACzB,GAAG,EAAE,CACD;QACI;YACI;gBACI,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,aAAa,CAAC;gBAChC,EAAE,EAAE,6BAA6B,IAAI,SAAS;gBAC9C,MAAM,EAAE,mBAAmB;gBAC3B,SAAS,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,GAAI;aAClE;YACD;gBACI,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC;gBAC/B,EAAE,EAAE,6BAA6B,IAAI,QAAQ;gBAC7C,MAAM,EAAE,kBAAkB;gBAC1B,SAAS,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAI;aACrE;SACJ;QACD;YACI;gBACI,IAAI,E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';\n\nimport {\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n BroomMotion as ClearCells,\n TrashBin,\n Xmark,\n} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\n\nimport {i18n} from 'src/i18n/yfm-table';\n\nimport type {DnDControlHandler} from '../../dnd/dnd';\nimport {FloatingMenu, type FloatingMenuProps} from '../FloatingMenu/FloatingMenu';\n\nexport type FloatingMenuControlProps = {\n acnhorElement: Element;\n multiple: boolean;\n type: FloatingMenuProps['dirtype'];\n dndHandler?: DnDControlHandler;\n onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];\n onClearCellsClick: () => void;\n onInsertBeforeClick: () => void;\n onInsertAfterClick: () => void;\n onRemoveRangeClick: () => void;\n onRemoveTableClick: () => void;\n};\n\nexport const FloatingMenuControl: React.FC<FloatingMenuControlProps> =\n function YfmTableFloatingMenuControl({\n type,\n multiple,\n dndHandler,\n acnhorElement,\n onMenuOpenToggle,\n onClearCellsClick,\n onInsertBeforeClick,\n onInsertAfterClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n }) {\n const dropdownItems = useMemo<FloatingMenuProps['dropdownItems']>(\n () =>\n [\n [\n {\n text: i18n(`${type}.add.before`),\n qa: `g-md-yfm-table-action-add-${type}-before`,\n action: onInsertBeforeClick,\n iconStart: <Icon data={type === 'row' ? ArrowUp : ArrowLeft} />,\n },\n {\n text: i18n(`${type}.add.after`),\n qa: `g-md-yfm-table-action-add-${type}-after`,\n action: onInsertAfterClick,\n iconStart: <Icon data={type === 'row' ? ArrowDown : ArrowRight} />,\n },\n ],\n [\n {\n text: i18n('cells.clear'),\n qa: `g-md-yfm-table-${type}-clear-cells`,\n action: onClearCellsClick,\n iconStart: <Icon data={ClearCells} />,\n },\n ],\n [\n {\n text: i18n(`${type}.remove${multiple ? '.multiple' : ''}`),\n qa: `g-md-yfm-table-action-remove-${type}`,\n action: onRemoveRangeClick,\n iconStart: <Icon data={Xmark} />,\n },\n {\n theme: 'danger',\n text: i18n('table.remove'),\n qa: 'g-md-yfm-table-action-remove-table',\n action: onRemoveTableClick,\n iconStart: <Icon data={TrashBin} />,\n },\n ],\n ] satisfies FloatingMenuProps['dropdownItems'],\n [\n type,\n multiple,\n onClearCellsClick,\n onInsertAfterClick,\n onInsertBeforeClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n ],\n );\n\n return (\n <FloatingMenu\n dirtype={type}\n canDrag={dndHandler ? dndHandler.canDrag() : false}\n onOpenToggle={onMenuOpenToggle}\n anchorElement={acnhorElement}\n switcherMouseProps={\n dndHandler\n ? {\n onMouseDown: dndHandler.control_handleMouseDown,\n onMouseMove: dndHandler.control_handleMouseMove,\n onMouseUp: dndHandler.control_handleMouseUp,\n }\n : undefined\n }\n dropdownItems={dropdownItems}\n />\n );\n };\n"]}
1
+ {"version":3,"file":"FloatingMenuControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,OAAO,EACH,SAAS,EACT,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW,IAAI,UAAU,EACzB,QAAQ,EACR,KAAK,GACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAC,IAAI,EAAC,qDAA2B;AAGxC,OAAO,EAAC,YAAY,EAAyB,wCAAqC;AAelF,MAAM,CAAC,MAAM,mBAAmB,GAC5B,SAAS,2BAA2B,CAAC,EACjC,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACrB;IACG,MAAM,aAAa,GAAG,OAAO,CACzB,GAAG,EAAE,CACD;QACI;YACI;gBACI,IAAI,EAAE,IAA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;QACnB,kBAAkB;QAClB,kBAAkB;KACrB,CACJ,CAAC;IAEF,OAAO,CACH,KAAC,YAAY,IACT,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,EAClD,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EACd,UAAU;YACN,CAAC,CAAC;gBACI,YAAY,EAAE,UAAU,CAAC,wBAAwB;gBACjD,WAAW,EAAE,UAAU,CAAC,uBAAuB;gBAC/C,WAAW,EAAE,UAAU,CAAC,uBAAuB;gBAC/C,SAAS,EAAE,UAAU,CAAC,qBAAqB;aAC9C;YACH,CAAC,CAAC,SAAS,EAEnB,aAAa,EAAE,aAAa,GAC9B,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useMemo} from 'react';\n\nimport {\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n BroomMotion as ClearCells,\n TrashBin,\n Xmark,\n} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\n\nimport {i18n} from 'src/i18n/yfm-table';\n\nimport type {DnDControlHandler} from '../../dnd/dnd';\nimport {FloatingMenu, type FloatingMenuProps} from '../FloatingMenu/FloatingMenu';\n\nexport type FloatingMenuControlProps = {\n acnhorElement: Element;\n multiple: boolean;\n type: FloatingMenuProps['dirtype'];\n dndHandler?: DnDControlHandler;\n onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];\n onClearCellsClick: () => void;\n onInsertBeforeClick: () => void;\n onInsertAfterClick: () => void;\n onRemoveRangeClick: () => void;\n onRemoveTableClick: () => void;\n};\n\nexport const FloatingMenuControl: React.FC<FloatingMenuControlProps> =\n function YfmTableFloatingMenuControl({\n type,\n multiple,\n dndHandler,\n acnhorElement,\n onMenuOpenToggle,\n onClearCellsClick,\n onInsertBeforeClick,\n onInsertAfterClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n }) {\n const dropdownItems = useMemo<FloatingMenuProps['dropdownItems']>(\n () =>\n [\n [\n {\n text: i18n(`${type}.add.before`),\n qa: `g-md-yfm-table-action-add-${type}-before`,\n action: onInsertBeforeClick,\n iconStart: <Icon data={type === 'row' ? ArrowUp : ArrowLeft} />,\n },\n {\n text: i18n(`${type}.add.after`),\n qa: `g-md-yfm-table-action-add-${type}-after`,\n action: onInsertAfterClick,\n iconStart: <Icon data={type === 'row' ? ArrowDown : ArrowRight} />,\n },\n ],\n [\n {\n text: i18n('cells.clear'),\n qa: `g-md-yfm-table-${type}-clear-cells`,\n action: onClearCellsClick,\n iconStart: <Icon data={ClearCells} />,\n },\n ],\n [\n {\n text: i18n(`${type}.remove${multiple ? '.multiple' : ''}`),\n qa: `g-md-yfm-table-action-remove-${type}`,\n action: onRemoveRangeClick,\n iconStart: <Icon data={Xmark} />,\n },\n {\n theme: 'danger',\n text: i18n('table.remove'),\n qa: 'g-md-yfm-table-action-remove-table',\n action: onRemoveTableClick,\n iconStart: <Icon data={TrashBin} />,\n },\n ],\n ] satisfies FloatingMenuProps['dropdownItems'],\n [\n type,\n multiple,\n onClearCellsClick,\n onInsertAfterClick,\n onInsertBeforeClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n ],\n );\n\n return (\n <FloatingMenu\n dirtype={type}\n canDrag={dndHandler ? dndHandler.canDrag() : false}\n onOpenToggle={onMenuOpenToggle}\n anchorElement={acnhorElement}\n switcherMouseProps={\n dndHandler\n ? {\n onMouseLeave: dndHandler.control_handleMouseLeave,\n onMouseDown: dndHandler.control_handleMouseDown,\n onMouseMove: dndHandler.control_handleMouseMove,\n onMouseUp: dndHandler.control_handleMouseUp,\n }\n : undefined\n }\n dropdownItems={dropdownItems}\n />\n );\n };\n"]}
@@ -11,12 +11,15 @@ export const PlusButton = function YfmTablePlusButton({ qa, onClick, onHoverChan
11
11
  return (_jsx(Flex, { centerContent: true, width: 20, height: 20, onMouseEnter: setHovered, onMouseLeave: unsetHovered, style: {
12
12
  borderRadius: '100px', // button circle border radius
13
13
  backgroundColor: hovered ? 'var(--g-color-base-background)' : undefined,
14
- }, children: _jsx(Button, { qa: qa, size: "xs", pin: "circle-circle", view: hovered ? 'outlined-action' : 'normal', onClick: onClick, style: {
15
- '--g-button-height': hovered ? undefined : '4px',
16
- '--_--background-color-hover': hovered
17
- ? 'var(--g-color-base-background)'
18
- : undefined,
19
- color: hovered ? undefined : 'var(--g-color-base-generic)',
20
- }, children: _jsx(Icon, { data: PlusIcon }) }) }));
14
+ }, children: _jsx(Button, { qa: qa, size: "xs", pin: "circle-circle", view: hovered ? 'outlined-action' : 'normal', onClick: onClick, style: hovered
15
+ ? {
16
+ '--g-button-background-color-hover': 'var(--g-color-base-background)',
17
+ }
18
+ : {
19
+ color: 'transparent',
20
+ '--g-button-height': '4px',
21
+ '--g-button-background-color': 'var(--g-color-line-generic-accent)',
22
+ '--g-button-border-color': 'var(--g-color-line-generic-accent)',
23
+ }, children: _jsx(Icon, { data: PlusIcon }) }) }));
21
24
  };
22
25
  //# sourceMappingURL=PlusButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAC,eAAe,EAAC,kDAAwB;AAOhD,MAAM,CAAC,MAAM,UAAU,GAA8B,SAAS,kBAAkB,CAAC,EAC7E,EAAE,EACF,OAAO,EACP,aAAa,GAChB;IACG,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACnE,SAAS,CAAC,GAAG,EAAE;QACX,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IAE7B,OAAO,CACH,KAAC,IAAI,IACD,aAAa,QACb,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE;YACH,YAAY,EAAE,OAAO,EAAE,8BAA8B;YACrD,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,SAAS;SAC1E,YAED,KAAC,MAAM,IACH,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,IAAI,EACT,GAAG,EAAC,eAAe,EACnB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,QAAQ,EAC5C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;gBACH,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;gBAChD,6BAA6B,EAAE,OAAO;oBAClC,CAAC,CAAC,gCAAgC;oBAClC,CAAC,CAAC,SAAS;gBACf,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,6BAA6B;aAC7D,YAED,KAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,GAAI,GACnB,GACN,CACV,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useEffect} from 'react';\n\nimport {Plus as PlusIcon} from '@gravity-ui/icons';\nimport {Button, Flex, Icon, type QAProps} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nexport type PlusButtonProps = QAProps & {\n onClick: () => void;\n onHoverChange: (hover: boolean) => void;\n};\n\nexport const PlusButton: React.FC<PlusButtonProps> = function YfmTablePlusButton({\n qa,\n onClick,\n onHoverChange,\n}) {\n const [hovered, setHovered, unsetHovered] = useBooleanState(false);\n useEffect(() => {\n onHoverChange(hovered);\n }, [hovered, onHoverChange]);\n\n return (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n style={{\n borderRadius: '100px', // button circle border radius\n backgroundColor: hovered ? 'var(--g-color-base-background)' : undefined,\n }}\n >\n <Button\n qa={qa}\n size=\"xs\"\n pin=\"circle-circle\"\n view={hovered ? 'outlined-action' : 'normal'}\n onClick={onClick}\n style={{\n '--g-button-height': hovered ? undefined : '4px',\n '--_--background-color-hover': hovered\n ? 'var(--g-color-base-background)'\n : undefined,\n color: hovered ? undefined : 'var(--g-color-base-generic)',\n }}\n >\n <Icon data={PlusIcon} />\n </Button>\n </Flex>\n );\n};\n"]}
1
+ {"version":3,"file":"PlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAC,eAAe,EAAC,kDAAwB;AAOhD,MAAM,CAAC,MAAM,UAAU,GAA8B,SAAS,kBAAkB,CAAC,EAC7E,EAAE,EACF,OAAO,EACP,aAAa,GAChB;IACG,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACnE,SAAS,CAAC,GAAG,EAAE;QACX,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IAE7B,OAAO,CACH,KAAC,IAAI,IACD,aAAa,QACb,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE;YACH,YAAY,EAAE,OAAO,EAAE,8BAA8B;YACrD,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,SAAS;SAC1E,YAED,KAAC,MAAM,IACH,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,IAAI,EACT,GAAG,EAAC,eAAe,EACnB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,QAAQ,EAC5C,OAAO,EAAE,OAAO,EAChB,KAAK,EACD,OAAO;gBACH,CAAC,CAAC;oBACI,mCAAmC,EAAE,gCAAgC;iBACxE;gBACH,CAAC,CAAC;oBACI,KAAK,EAAE,aAAa;oBACpB,mBAAmB,EAAE,KAAK;oBAC1B,6BAA6B,EAAE,oCAAoC;oBACnE,yBAAyB,EAAE,oCAAoC;iBAClE,YAGX,KAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,GAAI,GACnB,GACN,CACV,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useEffect} from 'react';\n\nimport {Plus as PlusIcon} from '@gravity-ui/icons';\nimport {Button, Flex, Icon, type QAProps} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nexport type PlusButtonProps = QAProps & {\n onClick: () => void;\n onHoverChange: (hover: boolean) => void;\n};\n\nexport const PlusButton: React.FC<PlusButtonProps> = function YfmTablePlusButton({\n qa,\n onClick,\n onHoverChange,\n}) {\n const [hovered, setHovered, unsetHovered] = useBooleanState(false);\n useEffect(() => {\n onHoverChange(hovered);\n }, [hovered, onHoverChange]);\n\n return (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n style={{\n borderRadius: '100px', // button circle border radius\n backgroundColor: hovered ? 'var(--g-color-base-background)' : undefined,\n }}\n >\n <Button\n qa={qa}\n size=\"xs\"\n pin=\"circle-circle\"\n view={hovered ? 'outlined-action' : 'normal'}\n onClick={onClick}\n style={\n hovered\n ? {\n '--g-button-background-color-hover': 'var(--g-color-base-background)',\n }\n : {\n color: 'transparent',\n '--g-button-height': '4px',\n '--g-button-background-color': 'var(--g-color-line-generic-accent)',\n '--g-button-border-color': 'var(--g-color-line-generic-accent)',\n }\n }\n >\n <Icon data={PlusIcon} />\n </Button>\n </Flex>\n );\n};\n"]}
@@ -6,8 +6,8 @@ export declare enum YfmTableDecorationType {
6
6
  ShowColumnControl = "cell--show-column-control",// to show the column control in the cell
7
7
  OpenRowMenu = "cell--open-row-menu",// sign of opening the row menu in the cell
8
8
  OpenColumnMenu = "cell--open-column-menu",// sign of opening the column menu in the cell
9
- ActivateRow = "row--active",
9
+ ActivateRowCells = "cell--active-row",
10
10
  ActivateColumnCells = "cell--active-column",
11
- ActivateDangerRow = "row--danger",
11
+ ActivateDangerRowCells = "cell--danger-row",
12
12
  ActivateDangerColumnCells = "cell--danger-column"
13
13
  }
@@ -7,9 +7,9 @@ export var YfmTableDecorationType;
7
7
  YfmTableDecorationType["ShowColumnControl"] = "cell--show-column-control";
8
8
  YfmTableDecorationType["OpenRowMenu"] = "cell--open-row-menu";
9
9
  YfmTableDecorationType["OpenColumnMenu"] = "cell--open-column-menu";
10
- YfmTableDecorationType["ActivateRow"] = "row--active";
10
+ YfmTableDecorationType["ActivateRowCells"] = "cell--active-row";
11
11
  YfmTableDecorationType["ActivateColumnCells"] = "cell--active-column";
12
- YfmTableDecorationType["ActivateDangerRow"] = "row--danger";
12
+ YfmTableDecorationType["ActivateDangerRowCells"] = "cell--danger-row";
13
13
  YfmTableDecorationType["ActivateDangerColumnCells"] = "cell--danger-column";
14
14
  })(YfmTableDecorationType || (YfmTableDecorationType = {}));
15
15
  //# sourceMappingURL=const.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAErE,MAAM,CAAN,IAAY,sBAcX;AAdD,WAAY,sBAAsB;IAC9B,qDAA2B,CAAA;IAE3B,mEAAyC,CAAA;IACzC,yEAA+C,CAAA;IAE/C,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IAEzC,qDAA2B,CAAA;IAC3B,qEAA2C,CAAA;IAE3C,2DAAiC,CAAA;IACjC,2EAAiD,CAAA;AACrD,CAAC,EAdW,sBAAsB,KAAtB,sBAAsB,QAcjC","sourcesContent":["export const YfmTableDecorationTypeKey = '__yfm-table-deco-type';\nexport const YfmTableDecorationUniqKey = '__yfm-table-deco-uniq-key';\n\nexport enum YfmTableDecorationType {\n FocusTable = 'table--focus',\n\n ShowRowControl = 'cell--show-row-control', // to show the row control in the cell\n ShowColumnControl = 'cell--show-column-control', // to show the column control in the cell\n\n OpenRowMenu = 'cell--open-row-menu', // sign of opening the row menu in the cell\n OpenColumnMenu = 'cell--open-column-menu', // sign of opening the column menu in the cell\n\n ActivateRow = 'row--active',\n ActivateColumnCells = 'cell--active-column',\n\n ActivateDangerRow = 'row--danger',\n ActivateDangerColumnCells = 'cell--danger-column',\n}\n"]}
1
+ {"version":3,"file":"const.js","sourceRoot":"../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAErE,MAAM,CAAN,IAAY,sBAcX;AAdD,WAAY,sBAAsB;IAC9B,qDAA2B,CAAA;IAE3B,mEAAyC,CAAA;IACzC,yEAA+C,CAAA;IAE/C,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IAEzC,+DAAqC,CAAA;IACrC,qEAA2C,CAAA;IAE3C,qEAA2C,CAAA;IAC3C,2EAAiD,CAAA;AACrD,CAAC,EAdW,sBAAsB,KAAtB,sBAAsB,QAcjC","sourcesContent":["export const YfmTableDecorationTypeKey = '__yfm-table-deco-type';\nexport const YfmTableDecorationUniqKey = '__yfm-table-deco-uniq-key';\n\nexport enum YfmTableDecorationType {\n FocusTable = 'table--focus',\n\n ShowRowControl = 'cell--show-row-control', // to show the row control in the cell\n ShowColumnControl = 'cell--show-column-control', // to show the column control in the cell\n\n OpenRowMenu = 'cell--open-row-menu', // sign of opening the row menu in the cell\n OpenColumnMenu = 'cell--open-column-menu', // sign of opening the column menu in the cell\n\n ActivateRowCells = 'cell--active-row',\n ActivateColumnCells = 'cell--active-column',\n\n ActivateDangerRowCells = 'cell--danger-row',\n ActivateDangerColumnCells = 'cell--danger-column',\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import type { EditorView } from "../../../../../../pm/view.js";
2
+ import type { TableDescBinded } from "../../../../../../table-utils/table-desc.js";
3
+ type Event = Pick<MouseEvent, 'clientX' | 'clientY' | 'target'>;
4
+ export type YfmTableDnDGhostParams = {
5
+ initial: Event;
6
+ type: 'row' | 'column';
7
+ rangeIdx: number;
8
+ tableDesc: TableDescBinded;
9
+ };
10
+ export declare class YfmTableDnDGhost {
11
+ private _x;
12
+ private _y;
13
+ private readonly _dndBackgroundElem;
14
+ private readonly _ghostTable;
15
+ private readonly _ghostButton;
16
+ private readonly _tblShiftX;
17
+ private readonly _tblShiftY;
18
+ private readonly _btnShiftX;
19
+ private readonly _btnShiftY;
20
+ private _rafId;
21
+ constructor(view: EditorView, params: YfmTableDnDGhostParams);
22
+ move(event: Event): void;
23
+ destroy(): void;
24
+ private _startAnimation;
25
+ private _updatePositions;
26
+ private _buildRowGhost;
27
+ private _buildColumnGhost;
28
+ private _buildGhostButton;
29
+ private _buildGhostContainer;
30
+ }
31
+ export {};
@@ -0,0 +1,173 @@
1
+ export class YfmTableDnDGhost {
2
+ _x;
3
+ _y;
4
+ _dndBackgroundElem;
5
+ _ghostTable;
6
+ _ghostButton = null;
7
+ _tblShiftX;
8
+ _tblShiftY;
9
+ _btnShiftX = 0;
10
+ _btnShiftY = 0;
11
+ _rafId;
12
+ constructor(view, params) {
13
+ this._x = params.initial.clientX;
14
+ this._y = params.initial.clientY;
15
+ const document = view.dom.ownerDocument;
16
+ this._dndBackgroundElem = document.createElement('div');
17
+ this._dndBackgroundElem.classList.add('g-md-yfm-table-dnd-cursor-background');
18
+ {
19
+ const res = this._buildGhostButton(params);
20
+ if (res) {
21
+ this._ghostButton = res.domElement;
22
+ this._btnShiftX = res.shiftX;
23
+ this._btnShiftY = res.shiftY;
24
+ this._dndBackgroundElem.appendChild(this._ghostButton);
25
+ }
26
+ }
27
+ {
28
+ const { domElement, shiftX, shiftY } = params.type === 'row'
29
+ ? this._buildRowGhost(view, params)
30
+ : this._buildColumnGhost(view, params);
31
+ this._ghostTable = domElement;
32
+ this._tblShiftX = shiftX;
33
+ this._tblShiftY = shiftY;
34
+ this._dndBackgroundElem.appendChild(this._ghostTable);
35
+ }
36
+ this._updatePositions();
37
+ this._rafId = requestAnimationFrame(() => {
38
+ document.body.append(this._dndBackgroundElem);
39
+ this._startAnimation();
40
+ });
41
+ }
42
+ move(event) {
43
+ this._x = event.clientX;
44
+ this._y = event.clientY;
45
+ }
46
+ destroy() {
47
+ cancelAnimationFrame(this._rafId);
48
+ this._dndBackgroundElem.remove();
49
+ }
50
+ _startAnimation() {
51
+ const self = this;
52
+ let last = { x: self._x, y: self._y };
53
+ self._rafId = requestAnimationFrame(function update() {
54
+ if (self._x !== last.x || self._y !== last.y) {
55
+ last = { x: self._x, y: self._y };
56
+ self._updatePositions();
57
+ }
58
+ self._rafId = requestAnimationFrame(update);
59
+ });
60
+ }
61
+ _updatePositions() {
62
+ {
63
+ const tx = this._x + this._tblShiftX;
64
+ const ty = this._y + this._tblShiftY;
65
+ this._ghostTable.style.transform = `translate(${tx}px, ${ty}px)`;
66
+ }
67
+ if (this._ghostButton) {
68
+ const tx = this._x + this._btnShiftX;
69
+ const ty = this._y + this._btnShiftY;
70
+ this._ghostButton.style.transform = `translate(${tx}px, ${ty}px)`;
71
+ }
72
+ }
73
+ _buildRowGhost(view, { tableDesc, rangeIdx }) {
74
+ let shiftX = 0;
75
+ let shiftY = 0;
76
+ const document = view.dom.ownerDocument;
77
+ const container = this._buildGhostContainer(view);
78
+ const table = container.appendChild(document.createElement('table'));
79
+ const tbody = table.appendChild(document.createElement('tbody'));
80
+ {
81
+ const tablePos = tableDesc.pos;
82
+ const tableNode = view.domAtPos(tablePos + 1).node;
83
+ const rect = tableNode.getBoundingClientRect();
84
+ table.style.width = rect.width + 'px';
85
+ }
86
+ const range = tableDesc.base.getRowRanges()[rangeIdx];
87
+ for (let rowIdx = range.startIdx; rowIdx <= range.endIdx; rowIdx++) {
88
+ const tr = tbody.appendChild(document.createElement('tr'));
89
+ for (let colIdx = 0; colIdx < tableDesc.cols; colIdx++) {
90
+ const cellPos = tableDesc.getPosForCell(rowIdx, colIdx);
91
+ if (cellPos.type === 'real') {
92
+ const origNode = view.domAtPos(cellPos.from + 1).node;
93
+ const cloned = tr.appendChild(origNode.cloneNode(true));
94
+ const rect = origNode.getBoundingClientRect();
95
+ cloned.style.width = rect.width + 'px';
96
+ cloned.style.height = rect.height + 'px';
97
+ if (rowIdx === range.startIdx && colIdx === 0) {
98
+ shiftX = rect.left - this._x;
99
+ shiftY = rect.top - this._y;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ removeIdAttributes(table);
105
+ return { domElement: container, shiftX, shiftY };
106
+ }
107
+ _buildColumnGhost(view, { tableDesc, rangeIdx }) {
108
+ let shiftX = 0;
109
+ let shiftY = 0;
110
+ const document = view.dom.ownerDocument;
111
+ const container = this._buildGhostContainer(view);
112
+ {
113
+ const tablePos = tableDesc.pos;
114
+ const table = view.domAtPos(tablePos + 1).node;
115
+ const rect = table.getBoundingClientRect();
116
+ container.style.height = rect.height + 'px';
117
+ }
118
+ const table = container.appendChild(document.createElement('table'));
119
+ const tbody = table.appendChild(document.createElement('tbody'));
120
+ const range = tableDesc.base.getColumnRanges()[rangeIdx];
121
+ for (let rowIdx = 0; rowIdx < tableDesc.rows; rowIdx++) {
122
+ const tr = tbody.appendChild(document.createElement('tr'));
123
+ for (let colIdx = range.startIdx; colIdx <= range.endIdx; colIdx++) {
124
+ const cellPos = tableDesc.getPosForCell(rowIdx, colIdx);
125
+ if (cellPos.type === 'real') {
126
+ const origNode = view.domAtPos(cellPos.from + 1).node;
127
+ const cloned = tr.appendChild(origNode.cloneNode(true));
128
+ const rect = origNode.getBoundingClientRect();
129
+ cloned.style.width = rect.width + 'px';
130
+ cloned.style.height = rect.height + 'px';
131
+ if (rowIdx === 0 && colIdx === range.startIdx) {
132
+ container.style.minWidth = rect.width + 'px';
133
+ shiftX = rect.left - this._x;
134
+ shiftY = rect.top - this._y;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ removeIdAttributes(table);
140
+ return { domElement: container, shiftX, shiftY };
141
+ }
142
+ _buildGhostButton({ initial: { target }, }) {
143
+ if (!(target instanceof Element))
144
+ return null;
145
+ const button = target.closest('.g-button');
146
+ if (!button)
147
+ return null;
148
+ const container = button.ownerDocument.createElement('div');
149
+ container.classList.add('g-md-yfm-table-dnd-ghost-button');
150
+ const rect = button.getBoundingClientRect();
151
+ const cloned = container.appendChild(button.cloneNode(true));
152
+ removeIdAttributes(cloned);
153
+ cloned.style.cursor = '';
154
+ cloned.style.pointerEvents = 'none';
155
+ return {
156
+ domElement: container,
157
+ shiftX: rect.left - this._x,
158
+ shiftY: rect.top - this._y,
159
+ };
160
+ }
161
+ _buildGhostContainer(view) {
162
+ const container = view.dom.ownerDocument.createElement('div');
163
+ container.setAttribute('aria-hidden', 'true');
164
+ const yfmClasses = Array.from(view.dom.classList).filter((val) => val.startsWith('yfm_'));
165
+ container.classList.add('g-md-yfm-table-dnd-ghost', 'yfm', ...yfmClasses);
166
+ return container;
167
+ }
168
+ }
169
+ function removeIdAttributes(elem) {
170
+ elem.removeAttribute('id');
171
+ elem.querySelectorAll('[id]').forEach((el) => el.removeAttribute('id'));
172
+ }
173
+ //# sourceMappingURL=dnd-ghost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnd-ghost.js","sourceRoot":"../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,gBAAgB;IACjB,EAAE,CAAS;IACX,EAAE,CAAS;IAEF,kBAAkB,CAAc;IAChC,WAAW,CAAc;IACzB,YAAY,GAAuB,IAAI,CAAC;IAExC,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IAEhC,MAAM,CAAS;IAEvB,YAAY,IAAgB,EAAE,MAA8B;QACxD,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAEjC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC;QAExC,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAE9E,CAAC;YACG,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC3C,IAAI,GAAG,EAAE,CAAC;gBACN,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,UAAU,CAAC;gBACnC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC;gBAC7B,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC;gBAC7B,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC3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AG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9D,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAE9C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1F,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;QAE1E,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAED,SAAS,kBAAkB,CAAC,IAAiB;IACzC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type {EditorView} from '#pm/view';\nimport type {TableDescBinded} from 'src/table-utils/table-desc';\n\ntype Event = Pick<MouseEvent, 'clientX' | 'clientY' | 'target'>;\n\ntype BuildGhostResult = {\n domElement: HTMLElement;\n shiftX: number;\n shiftY: number;\n};\n\nexport type YfmTableDnDGhostParams = {\n initial: Event;\n type: 'row' | 'column';\n rangeIdx: number;\n tableDesc: TableDescBinded;\n};\n\nexport class YfmTableDnDGhost {\n private _x: number;\n private _y: number;\n\n private readonly _dndBackgroundElem: HTMLElement;\n private readonly _ghostTable: HTMLElement;\n private readonly _ghostButton: HTMLElement | null = null;\n\n private readonly _tblShiftX: number;\n private readonly _tblShiftY: number;\n\n private readonly _btnShiftX: number = 0;\n private readonly _btnShiftY: number = 0;\n\n private _rafId: number;\n\n constructor(view: EditorView, params: YfmTableDnDGhostParams) {\n this._x = params.initial.clientX;\n this._y = params.initial.clientY;\n\n const document = view.dom.ownerDocument;\n\n this._dndBackgroundElem = document.createElement('div');\n this._dndBackgroundElem.classList.add('g-md-yfm-table-dnd-cursor-background');\n\n {\n const res = this._buildGhostButton(params);\n if (res) {\n this._ghostButton = res.domElement;\n this._btnShiftX = res.shiftX;\n this._btnShiftY = res.shiftY;\n this._dndBackgroundElem.appendChild(this._ghostButton);\n }\n }\n\n {\n const {domElement, shiftX, shiftY} =\n params.type === 'row'\n ? this._buildRowGhost(view, params)\n : this._buildColumnGhost(view, params);\n\n this._ghostTable = domElement;\n this._tblShiftX = shiftX;\n this._tblShiftY = shiftY;\n this._dndBackgroundElem.appendChild(this._ghostTable);\n }\n\n this._updatePositions();\n\n this._rafId = requestAnimationFrame(() => {\n document.body.append(this._dndBackgroundElem);\n this._startAnimation();\n });\n }\n\n move(event: Event) {\n this._x = event.clientX;\n this._y = event.clientY;\n }\n\n destroy() {\n cancelAnimationFrame(this._rafId);\n this._dndBackgroundElem.remove();\n }\n\n private _startAnimation() {\n const self = this;\n let last = {x: self._x, y: self._y};\n\n self._rafId = requestAnimationFrame(function update() {\n if (self._x !== last.x || self._y !== last.y) {\n last = {x: self._x, y: self._y};\n self._updatePositions();\n }\n self._rafId = requestAnimationFrame(update);\n });\n }\n\n private _updatePositions() {\n {\n const tx = this._x + this._tblShiftX;\n const ty = this._y + this._tblShiftY;\n this._ghostTable.style.transform = `translate(${tx}px, ${ty}px)`;\n }\n\n if (this._ghostButton) {\n const tx = this._x + this._btnShiftX;\n const ty = this._y + this._btnShiftY;\n this._ghostButton.style.transform = `translate(${tx}px, ${ty}px)`;\n }\n }\n\n private _buildRowGhost(\n view: EditorView,\n {tableDesc, rangeIdx}: YfmTableDnDGhostParams,\n ): BuildGhostResult {\n let shiftX = 0;\n let shiftY = 0;\n\n const document = view.dom.ownerDocument;\n const container = this._buildGhostContainer(view);\n\n const table = container.appendChild(document.createElement('table'));\n const tbody = table.appendChild(document.createElement('tbody'));\n\n {\n const tablePos = tableDesc.pos;\n const tableNode = view.domAtPos(tablePos + 1).node;\n const rect = (tableNode as Element).getBoundingClientRect();\n table.style.width = rect.width + 'px';\n }\n\n const range = tableDesc.base.getRowRanges()[rangeIdx];\n for (let rowIdx = range.startIdx; rowIdx <= range.endIdx; rowIdx++) {\n const tr = tbody.appendChild(document.createElement('tr'));\n\n for (let colIdx = 0; colIdx < tableDesc.cols; colIdx++) {\n const cellPos = tableDesc.getPosForCell(rowIdx, colIdx);\n if (cellPos.type === 'real') {\n const origNode = view.domAtPos(cellPos.from + 1).node as HTMLElement;\n const cloned = tr.appendChild(origNode.cloneNode(true));\n\n const rect = origNode.getBoundingClientRect();\n (cloned as HTMLElement).style.width = rect.width + 'px';\n (cloned as HTMLElement).style.height = rect.height + 'px';\n\n if (rowIdx === range.startIdx && colIdx === 0) {\n shiftX = rect.left - this._x;\n shiftY = rect.top - this._y;\n }\n }\n }\n }\n\n removeIdAttributes(table);\n\n return {domElement: container, shiftX, shiftY};\n }\n\n private _buildColumnGhost(\n view: EditorView,\n {tableDesc, rangeIdx}: YfmTableDnDGhostParams,\n ): BuildGhostResult {\n let shiftX = 0;\n let shiftY = 0;\n\n const document = view.dom.ownerDocument;\n const container = this._buildGhostContainer(view);\n\n {\n const tablePos = tableDesc.pos;\n const table = view.domAtPos(tablePos + 1).node;\n const rect = (table as Element).getBoundingClientRect();\n container.style.height = rect.height + 'px';\n }\n\n const table = container.appendChild(document.createElement('table'));\n const tbody = table.appendChild(document.createElement('tbody'));\n\n const range = tableDesc.base.getColumnRanges()[rangeIdx];\n for (let rowIdx = 0; rowIdx < tableDesc.rows; rowIdx++) {\n const tr = tbody.appendChild(document.createElement('tr'));\n\n for (let colIdx = range.startIdx; colIdx <= range.endIdx; colIdx++) {\n const cellPos = tableDesc.getPosForCell(rowIdx, colIdx);\n if (cellPos.type === 'real') {\n const origNode = view.domAtPos(cellPos.from + 1).node as HTMLElement;\n const cloned = tr.appendChild(origNode.cloneNode(true));\n\n const rect = origNode.getBoundingClientRect();\n (cloned as HTMLElement).style.width = rect.width + 'px';\n (cloned as HTMLElement).style.height = rect.height + 'px';\n\n if (rowIdx === 0 && colIdx === range.startIdx) {\n container.style.minWidth = rect.width + 'px';\n\n shiftX = rect.left - this._x;\n shiftY = rect.top - this._y;\n }\n }\n }\n }\n\n removeIdAttributes(table);\n\n return {domElement: container, shiftX, shiftY};\n }\n\n private _buildGhostButton({\n initial: {target},\n }: YfmTableDnDGhostParams): BuildGhostResult | null {\n if (!(target instanceof Element)) return null;\n\n const button = target.closest('.g-button');\n if (!button) return null;\n\n const container = button.ownerDocument.createElement('div');\n container.classList.add('g-md-yfm-table-dnd-ghost-button');\n\n const rect = button.getBoundingClientRect();\n const cloned = container.appendChild(button.cloneNode(true) as HTMLElement);\n\n removeIdAttributes(cloned);\n cloned.style.cursor = '';\n cloned.style.pointerEvents = 'none';\n\n return {\n domElement: container,\n shiftX: rect.left - this._x,\n shiftY: rect.top - this._y,\n };\n }\n\n private _buildGhostContainer(view: EditorView): HTMLElement {\n const container = view.dom.ownerDocument.createElement('div');\n container.setAttribute('aria-hidden', 'true');\n\n const yfmClasses = Array.from(view.dom.classList).filter((val) => val.startsWith('yfm_'));\n container.classList.add('g-md-yfm-table-dnd-ghost', 'yfm', ...yfmClasses);\n\n return container;\n }\n}\n\nfunction removeIdAttributes(elem: HTMLElement) {\n elem.removeAttribute('id');\n elem.querySelectorAll('[id]').forEach((el) => el.removeAttribute('id'));\n}\n"]}
@@ -7,13 +7,78 @@
7
7
  background: transparent;
8
8
  }
9
9
 
10
- .yfm.ProseMirror .g-md-yfm-table-dnd-dragged-row,
11
- .yfm.ProseMirror .g-md-yfm-table-dnd-dragged-column-cell {
12
- opacity: 0.3;
13
- background-color: var(--g-color-base-selection);
10
+ .yfm.g-md-yfm-table-dnd-ghost,
11
+ .g-md-yfm-table-dnd-ghost-button {
12
+ position: fixed;
13
+ cursor: grabbing;
14
+ pointer-events: none;
15
+ transition: none;
16
+ will-change: transform;
17
+ }
18
+
19
+ .yfm.g-md-yfm-table-dnd-ghost > table {
20
+ border-color: var(--g-color-line-brand);
21
+ box-shadow: 0 8px 20px 1px var(--g-color-sfx-shadow);
22
+ }
23
+ .yfm.g-md-yfm-table-dnd-ghost > table > tbody > tr > td {
24
+ border-color: var(--g-color-line-brand);
25
+ }
26
+
27
+ .g-md-yfm-table-dnd-ghost-button {
28
+ --g-button-background-color-hover: var(--g-color-base-background);
29
+ --g-button-background-color: var(--g-color-base-background);
30
+ --g-button-border-color: var(--g-color-line-brand);
31
+ --g-button-text-color: var(--g-color-text-brand);
32
+ z-index: 2;
14
33
  }
15
34
 
16
- .yfm.ProseMirror .g-md-yfm-table-active-row,
17
- .yfm.ProseMirror .g-md-yfm-table-active-column-cell {
35
+ .yfm.ProseMirror table td {
36
+ position: relative;
37
+ }
38
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell {
39
+ overflow: unset;
40
+ border-color: var(--g-color-line-brand);
18
41
  background-color: var(--g-color-base-selection);
42
+ }
43
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell::after {
44
+ position: absolute;
45
+ z-index: 2;
46
+ inset: -1px;
47
+ display: inline-block;
48
+ content: "";
49
+ pointer-events: none;
50
+ border: 1px solid var(--g-color-line-brand);
51
+ }
52
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_first-row::after {
53
+ top: 0;
54
+ }
55
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_last-row::after {
56
+ bottom: 0;
57
+ }
58
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_first-column::after {
59
+ left: 0;
60
+ }
61
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_last-column::after {
62
+ right: 0;
63
+ }
64
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_first-row.g-md-yfm-table-selected-cell_first-column::after {
65
+ border-top-left-radius: 8px;
66
+ }
67
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_first-row.g-md-yfm-table-selected-cell_last-column::after {
68
+ border-top-right-radius: 8px;
69
+ }
70
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_last-row.g-md-yfm-table-selected-cell_first-column::after {
71
+ border-bottom-left-radius: 8px;
72
+ }
73
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell_last-row.g-md-yfm-table-selected-cell_last-column::after {
74
+ border-bottom-right-radius: 8px;
75
+ }
76
+ .yfm.ProseMirror table td.g-md-yfm-table-selected-cell.dragged-cell::before {
77
+ position: absolute;
78
+ inset: 0;
79
+ display: inline-block;
80
+ content: "";
81
+ pointer-events: none;
82
+ opacity: 0.7;
83
+ background-color: var(--g-color-base-background);
19
84
  }
@@ -8,6 +8,7 @@ export type DnDControlHandler = {
8
8
  control_handleMouseDown: React.MouseEventHandler<HTMLButtonElement>;
9
9
  control_handleMouseMove: React.MouseEventHandler<HTMLButtonElement>;
10
10
  control_handleMouseUp: React.MouseEventHandler<HTMLButtonElement>;
11
+ control_handleMouseLeave: React.MouseEventHandler<HTMLButtonElement>;
11
12
  };
12
13
  interface TableHandler {
13
14
  update(node: Node): void;