@gravity-ui/markdown-editor 15.25.0 → 15.26.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.
- package/build/cjs/extensions/additional/Math/const.d.ts +1 -0
- package/build/cjs/extensions/additional/Math/const.js +11 -1
- package/build/cjs/extensions/additional/Math/const.js.map +1 -1
- package/build/cjs/extensions/additional/Math/index.d.ts +1 -0
- package/build/cjs/extensions/additional/Math/index.js +6 -1
- package/build/cjs/extensions/additional/Math/index.js.map +1 -1
- package/build/cjs/extensions/additional/Math/latex-paste-plugin.d.ts +2 -0
- package/build/cjs/extensions/additional/Math/latex-paste-plugin.js +54 -0
- package/build/cjs/extensions/additional/Math/latex-paste-plugin.js.map +1 -0
- package/build/cjs/extensions/additional/Math/utils.d.ts +7 -0
- package/build/cjs/extensions/additional/Math/utils.js +45 -0
- package/build/cjs/extensions/additional/Math/utils.js.map +1 -0
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.css +8 -0
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.d.ts +3 -0
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +68 -7
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/TooltipView.css +4 -0
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.d.ts +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js +53 -28
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js.map +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.d.ts +6 -0
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js +28 -2
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js.map +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/index.d.ts +2 -1
- package/build/cjs/extensions/markdown/CodeBlock/index.js +21 -6
- package/build/cjs/extensions/markdown/CodeBlock/index.js.map +1 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +29 -17
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +2 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.d.ts +5 -2
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +59 -2
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.d.ts +4 -2
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js +3 -4
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.d.ts +3 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js +36 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.d.ts +13 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js +7 -10
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.d.ts +3 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js +39 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js +9 -4
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js +25 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +4 -2
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -1
- package/build/cjs/i18n/codeblock/en.json +2 -1
- package/build/cjs/i18n/codeblock/index.d.ts +2 -1
- package/build/cjs/i18n/codeblock/ru.json +2 -1
- package/build/cjs/styles/styles.css +289 -0
- package/build/cjs/styles/yfm-themes.css +288 -0
- package/build/cjs/table-utils/table-desc.d.ts +1 -0
- package/build/cjs/table-utils/table-desc.js +3 -0
- package/build/cjs/table-utils/table-desc.js.map +1 -1
- package/build/cjs/version.js +1 -1
- package/build/cjs/version.js.map +1 -1
- package/build/cjs/view/hocs/withYfmHtml/index.d.ts +1 -0
- package/build/cjs/view/hocs/withYfmHtml/index.js +3 -0
- package/build/cjs/view/hocs/withYfmHtml/index.js.map +1 -1
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.d.ts +5 -1
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +8 -1
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js.map +1 -1
- package/build/esm/extensions/additional/Math/const.d.ts +1 -0
- package/build/esm/extensions/additional/Math/const.js +10 -0
- package/build/esm/extensions/additional/Math/const.js.map +1 -1
- package/build/esm/extensions/additional/Math/index.d.ts +1 -0
- package/build/esm/extensions/additional/Math/index.js +3 -0
- package/build/esm/extensions/additional/Math/index.js.map +1 -1
- package/build/esm/extensions/additional/Math/latex-paste-plugin.d.ts +2 -0
- package/build/esm/extensions/additional/Math/latex-paste-plugin.js +50 -0
- package/build/esm/extensions/additional/Math/latex-paste-plugin.js.map +1 -0
- package/build/esm/extensions/additional/Math/utils.d.ts +7 -0
- package/build/esm/extensions/additional/Math/utils.js +39 -0
- package/build/esm/extensions/additional/Math/utils.js.map +1 -0
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.css +8 -0
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.d.ts +3 -0
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +69 -8
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/TooltipView.css +4 -0
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.d.ts +1 -1
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js +54 -29
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js.map +1 -1
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.d.ts +6 -0
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js +28 -2
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js.map +1 -1
- package/build/esm/extensions/markdown/CodeBlock/index.d.ts +2 -1
- package/build/esm/extensions/markdown/CodeBlock/index.js +21 -6
- package/build/esm/extensions/markdown/CodeBlock/index.js.map +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +29 -17
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +2 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.d.ts +5 -2
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +59 -2
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.d.ts +4 -2
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js +4 -4
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.d.ts +3 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js +38 -3
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.d.ts +13 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js +8 -10
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.d.ts +3 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js +38 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js +9 -4
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +2 -2
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js +22 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +4 -2
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -1
- package/build/esm/i18n/codeblock/en.json +2 -1
- package/build/esm/i18n/codeblock/index.d.ts +2 -1
- package/build/esm/i18n/codeblock/ru.json +2 -1
- package/build/esm/styles/styles.css +289 -0
- package/build/esm/styles/yfm-themes.css +288 -0
- package/build/esm/table-utils/table-desc.d.ts +1 -0
- package/build/esm/table-utils/table-desc.js +3 -0
- package/build/esm/table-utils/table-desc.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esm/view/hocs/withYfmHtml/index.d.ts +1 -0
- package/build/esm/view/hocs/withYfmHtml/index.js +1 -0
- package/build/esm/view/hocs/withYfmHtml/index.js.map +1 -1
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.d.ts +5 -1
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +7 -1
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js.map +1 -1
- package/build/styles.css +589 -0
- package/package.json +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Checkbox/CheckboxSpecs/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Checkbox/CheckboxSpecs/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAA6B,MAAM,mBAAmB,CAAC;AAIvE,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAC,mBAAgB;AAI5F,MAAM,yBAAyB,GAAG,UAAU,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,IAA6D,EAC7D,WAAgC,EACF,EAAE,CAAC,CAAC;IAClC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;QACrB,KAAK,EAAE,gBAAgB;QACvB,OAAO,EAAE,GAAG,YAAY,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,EAAE;QACtD,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,KAAK;QACrB,KAAK,EAAE;YACH,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,EAAC,OAAO,EA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EAAE,CAAC,CAAC,OAAO,CAAC,EAAC,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,MAAM;KAClB;CACJ,CAAC,CAAC;AAEH,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,OAAyB;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAC/C,OAAO,WAAW,YAAY,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAyB;IAChD,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,sBAAsB,CAC3B,MAAwB,EACxB,OAAuB,EACvB,SAAoC;IAEpC,OAAO,QAAQ,CAAC,IAAI,CAAC;QACjB,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAC,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAC,CAAC;QACnF,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACpF,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {Fragment, type NodeSpec, type Schema} from 'prosemirror-model';\n\nimport type {PlaceholderOptions} from '../../../../utils/placeholder';\n\nimport {CheckboxAttr, CheckboxNode, b, checkboxInputType, checkboxLabelType} from './const';\n\nimport type {CheckboxSpecsOptions} from './index';\n\nconst DEFAULT_LABEL_PLACEHOLDER = 'Checkbox';\n\nexport const getSchemaSpecs = (\n opts?: Pick<CheckboxSpecsOptions, 'checkboxLabelPlaceholder'>,\n placeholder?: PlaceholderOptions,\n): Record<CheckboxNode, NodeSpec> => ({\n [CheckboxNode.Checkbox]: {\n group: 'block checkbox',\n content: `${CheckboxNode.Input} ${CheckboxNode.Label}`,\n selectable: true,\n allowSelection: false,\n attrs: {\n [CheckboxAttr.Class]: {default: b()},\n [CheckboxAttr.Line]: {default: null},\n },\n parseDOM: [\n {\n tag: 'div.checkbox',\n priority: 100,\n getContent(node, schema) {\n if (node instanceof HTMLElement) {\n const input = node.querySelector<HTMLInputElement>('input[type=checkbox]');\n\n if (input && input instanceof HTMLInputElement) {\n const label = findLabelForInput(input);\n return createCheckboxFragment(\n schema,\n input.checked,\n label?.textContent,\n );\n }\n }\n return Fragment.empty;\n },\n },\n {\n tag: 'input[type=checkbox]',\n priority: 50,\n getContent(input, schema) {\n if (input instanceof HTMLInputElement) {\n const label = findLabelForInput(input);\n return createCheckboxFragment(schema, input.checked, label?.textContent);\n }\n return Fragment.empty;\n },\n },\n ],\n toDOM(node) {\n return ['div', node.attrs, 0];\n },\n complex: 'root',\n },\n\n [CheckboxNode.Input]: {\n group: 'block checkbox',\n parseDOM: [],\n attrs: {\n [CheckboxAttr.Type]: {default: 'checkbox'},\n [CheckboxAttr.Id]: {default: null},\n [CheckboxAttr.Checked]: {default: null},\n },\n toDOM(node) {\n return ['div', node.attrs];\n },\n selectable: false,\n allowSelection: false,\n complex: 'leaf',\n },\n\n [CheckboxNode.Label]: {\n content: 'inline*',\n group: 'block checkbox',\n parseDOM: [\n {\n tag: `span[class=\"${b('label')}\"]`,\n getAttrs: (node) => ({\n [CheckboxAttr.For]: (node as Element).getAttribute(CheckboxAttr.For) || '',\n }),\n },\n {\n // input handled by checkbox node parse rule\n // ignore label\n tag: 'input[type=checkbox] ~ label',\n ignore: true,\n consuming: true,\n },\n ],\n attrs: {\n [CheckboxAttr.For]: {default: null},\n },\n escapeText: false,\n placeholder: {\n content:\n placeholder?.[CheckboxNode.Label] ??\n opts?.checkboxLabelPlaceholder ??\n DEFAULT_LABEL_PLACEHOLDER,\n alwaysVisible: true,\n },\n toDOM(node) {\n return ['span', {...node.attrs, class: b('label')}, 0];\n },\n selectable: false,\n allowSelection: false,\n disableGapCursor: true,\n complex: 'leaf',\n },\n});\n\n// fallback for invalid HTML (input without id + label without for)\nfunction findNextSiblingLabel(element: HTMLInputElement): HTMLLabelElement | null {\n const nextSibling = element.nextElementSibling;\n return nextSibling instanceof HTMLLabelElement ? nextSibling : null;\n}\n\nfunction findLabelForInput(element: HTMLInputElement): HTMLLabelElement | null {\n return element.labels?.[0] || findNextSiblingLabel(element);\n}\n\nfunction createCheckboxFragment(\n schema: Schema<any, any>,\n checked: boolean | null,\n labelText: string | null | undefined,\n): Fragment {\n return Fragment.from([\n checkboxInputType(schema).create({[CheckboxAttr.Checked]: checked ? 'true' : null}),\n checkboxLabelType(schema).create(null, labelText ? schema.text(labelText) : null),\n ]);\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type ButtonButtonProps, type DropdownMenuProps } from '@gravity-ui/uikit';
|
|
2
|
+
import { type ReferenceType } from "../FloatingPopup/index.js";
|
|
2
3
|
export type FloatingMenuProps = {
|
|
3
4
|
dirtype: 'row' | 'column';
|
|
4
5
|
canDrag: boolean;
|
|
5
|
-
anchorElement:
|
|
6
|
+
anchorElement: ReferenceType;
|
|
6
7
|
dropdownItems: DropdownMenuProps<unknown>['items'];
|
|
7
8
|
switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp' | 'onMouseLeave'>;
|
|
8
9
|
onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;
|
|
@@ -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,
|
|
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,EAA8C,kCAAyB;AAE5F,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,a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AAC,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, type ReferenceType} 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: ReferenceType;\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"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { DnDControlHandler } from "../../dnd/dnd.js";
|
|
2
2
|
import { type FloatingMenuProps } from "../FloatingMenu/FloatingMenu.js";
|
|
3
|
+
type ControlType = FloatingMenuProps['dirtype'];
|
|
3
4
|
export type FloatingMenuControlProps = {
|
|
4
|
-
|
|
5
|
+
cellElement: Element;
|
|
6
|
+
tableElement: Element;
|
|
5
7
|
multiple: boolean;
|
|
6
|
-
type:
|
|
8
|
+
type: ControlType;
|
|
7
9
|
dndHandler?: DnDControlHandler;
|
|
8
10
|
onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];
|
|
9
11
|
onClearCellsClick: () => void;
|
|
@@ -13,3 +15,4 @@ export type FloatingMenuControlProps = {
|
|
|
13
15
|
onRemoveTableClick: () => void;
|
|
14
16
|
};
|
|
15
17
|
export declare const FloatingMenuControl: React.FC<FloatingMenuControlProps>;
|
|
18
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, BroomMotion as ClearCells, T
|
|
|
4
4
|
import { Icon } from '@gravity-ui/uikit';
|
|
5
5
|
import { i18n } from "../../../../../../../i18n/yfm-table/index.js";
|
|
6
6
|
import { FloatingMenu } from "../FloatingMenu/FloatingMenu.js";
|
|
7
|
-
export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler,
|
|
7
|
+
export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, cellElement, tableElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
|
|
8
8
|
const dropdownItems = useMemo(() => [
|
|
9
9
|
[
|
|
10
10
|
{
|
|
@@ -52,7 +52,8 @@ export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type,
|
|
|
52
52
|
onRemoveRangeClick,
|
|
53
53
|
onRemoveTableClick,
|
|
54
54
|
]);
|
|
55
|
-
|
|
55
|
+
const anchor = useMemo(() => getVirtualAnchor(type, tableElement, cellElement), [type, tableElement, cellElement]);
|
|
56
|
+
return (_jsx(FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: anchor, switcherMouseProps: dndHandler
|
|
56
57
|
? {
|
|
57
58
|
onMouseLeave: dndHandler.control_handleMouseLeave,
|
|
58
59
|
onMouseDown: dndHandler.control_handleMouseDown,
|
|
@@ -61,4 +62,60 @@ export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type,
|
|
|
61
62
|
}
|
|
62
63
|
: undefined, dropdownItems: dropdownItems }));
|
|
63
64
|
};
|
|
65
|
+
function getVirtualAnchor(type, tableElem, cellElem) {
|
|
66
|
+
if (type === 'row') {
|
|
67
|
+
return {
|
|
68
|
+
contextElement: cellElem,
|
|
69
|
+
getBoundingClientRect() {
|
|
70
|
+
const cellRect = cellElem.getBoundingClientRect();
|
|
71
|
+
const tableRect = tableElem.getBoundingClientRect().toJSON();
|
|
72
|
+
{
|
|
73
|
+
// fix table rect
|
|
74
|
+
tableRect.x += 1;
|
|
75
|
+
tableRect.width -= 2;
|
|
76
|
+
tableRect.left += 1;
|
|
77
|
+
tableRect.right -= 1;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
// from table
|
|
81
|
+
x: tableRect.x,
|
|
82
|
+
width: tableRect.width,
|
|
83
|
+
left: tableRect.left,
|
|
84
|
+
right: tableRect.right,
|
|
85
|
+
// from cell
|
|
86
|
+
y: cellRect.y,
|
|
87
|
+
height: cellRect.height,
|
|
88
|
+
top: cellRect.top,
|
|
89
|
+
bottom: cellRect.top,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (type === 'column') {
|
|
95
|
+
return {
|
|
96
|
+
contextElement: cellElem,
|
|
97
|
+
getBoundingClientRect() {
|
|
98
|
+
const cellRect = cellElem.getBoundingClientRect().toJSON();
|
|
99
|
+
const tableRect = tableElem.getBoundingClientRect();
|
|
100
|
+
const EDGE_OFFSET = 16;
|
|
101
|
+
const cellMiddle = cellRect.x + cellRect.width / 2;
|
|
102
|
+
// left border of table
|
|
103
|
+
if (cellMiddle - EDGE_OFFSET <= tableRect.left) {
|
|
104
|
+
const visible = cellRect.right - tableRect.left;
|
|
105
|
+
cellRect.width = (visible - EDGE_OFFSET) * 2;
|
|
106
|
+
cellRect.left = cellRect.right - cellRect.width;
|
|
107
|
+
cellRect.x = cellRect.left;
|
|
108
|
+
}
|
|
109
|
+
// right border of table
|
|
110
|
+
if (cellMiddle + EDGE_OFFSET >= tableRect.right) {
|
|
111
|
+
const visible = tableRect.right - cellRect.left;
|
|
112
|
+
cellRect.width = (visible - EDGE_OFFSET) * 2;
|
|
113
|
+
cellRect.right = cellRect.left + cellRect.width;
|
|
114
|
+
}
|
|
115
|
+
return cellRect;
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
throw new Error(`Unknown control type: ${type}`);
|
|
120
|
+
}
|
|
64
121
|
//# sourceMappingURL=FloatingMenuControl.js.map
|
|
@@ -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,G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AAQ;QACR,iBAAiB;QACjB,kBAAkB;QAClB,mBAAmB;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"]}
|
|
1
|
+
{"version":3,"file":"FloatingMenuControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/Yf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,EAAE,CAAC;gBAEpD,MAAM,WAAW,GAAG,EAAE,CAAC;gBAEvB,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;gBAEnD,uBAAuB;gBACvB,IAAI,UAAU,GAAG,WAAW,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;oBAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC;oBAChD,QAAQ,CAAC,KAAK,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;oBAC7C,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;oBAChD,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;gBAC/B,CAAC;gBAED,wBAAwB;gBACxB,IAAI,UAAU,GAAG,WAAW,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;oBAC9C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC;oBAChD,QAAQ,CAAC,KAAK,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;oBAC7C,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC;gBACpD,CAAC;gBAED,OAAO,QAAQ,CAAC;YACpB,CAAC;SACJ,CAAC;IACN,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import {useMemo} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type {ClientRectObject, VirtualElement} from '@floating-ui/dom';\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\ntype ControlType = FloatingMenuProps['dirtype'];\n\nexport type FloatingMenuControlProps = {\n cellElement: Element;\n tableElement: Element;\n multiple: boolean;\n type: ControlType;\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 cellElement,\n tableElement,\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 const anchor = useMemo(\n () => getVirtualAnchor(type, tableElement, cellElement),\n [type, tableElement, cellElement],\n );\n\n return (\n <FloatingMenu\n dirtype={type}\n canDrag={dndHandler ? dndHandler.canDrag() : false}\n onOpenToggle={onMenuOpenToggle}\n anchorElement={anchor}\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\nfunction getVirtualAnchor(\n type: ControlType,\n tableElem: Element,\n cellElem: Element,\n): VirtualElement {\n if (type === 'row') {\n return {\n contextElement: cellElem,\n getBoundingClientRect() {\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect: ClientRectObject = tableElem.getBoundingClientRect().toJSON();\n\n {\n // fix table rect\n tableRect.x += 1;\n tableRect.width -= 2;\n tableRect.left += 1;\n tableRect.right -= 1;\n }\n\n return {\n // from table\n x: tableRect.x,\n width: tableRect.width,\n left: tableRect.left,\n right: tableRect.right,\n // from cell\n y: cellRect.y,\n height: cellRect.height,\n top: cellRect.top,\n bottom: cellRect.top,\n };\n },\n };\n }\n\n if (type === 'column') {\n return {\n contextElement: cellElem,\n getBoundingClientRect() {\n const cellRect: ClientRectObject = cellElem.getBoundingClientRect().toJSON();\n const tableRect = tableElem.getBoundingClientRect();\n\n const EDGE_OFFSET = 16;\n\n const cellMiddle = cellRect.x + cellRect.width / 2;\n\n // left border of table\n if (cellMiddle - EDGE_OFFSET <= tableRect.left) {\n const visible = cellRect.right - tableRect.left;\n cellRect.width = (visible - EDGE_OFFSET) * 2;\n cellRect.left = cellRect.right - cellRect.width;\n cellRect.x = cellRect.left;\n }\n\n // right border of table\n if (cellMiddle + EDGE_OFFSET >= tableRect.right) {\n const visible = tableRect.right - cellRect.left;\n cellRect.width = (visible - EDGE_OFFSET) * 2;\n cellRect.right = cellRect.left + cellRect.width;\n }\n\n return cellRect;\n },\n };\n }\n\n throw new Error(`Unknown control type: ${type}`);\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type FloatingPopupProps, type FloatingPopupRef } from "../FloatingPopup/index.js";
|
|
1
2
|
import { type InsertCursorProps } from "./InsertCursor.js";
|
|
2
3
|
import { type PlusButtonProps } from "./PlusButton.js";
|
|
3
|
-
export type
|
|
4
|
-
export
|
|
4
|
+
export type FloatingPlusButtonRef = FloatingPopupRef & {};
|
|
5
|
+
export type FloatingPlusButtonProps = Pick<FloatingPopupProps, 'floatingStyles'> & Pick<PlusButtonProps, 'onClick'> & Pick<InsertCursorProps, 'type' | 'anchor'>;
|
|
6
|
+
export declare const FloatingPlusButton: import("react").ForwardRefExoticComponent<Pick<FloatingPopupProps, "floatingStyles"> & Pick<PlusButtonProps, "onClick"> & Pick<InsertCursorProps, "type" | "anchor"> & import("react").RefAttributes<FloatingPopupRef>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { forwardRef, useState } from 'react';
|
|
3
3
|
import { FloatingPopup } from "../FloatingPopup/index.js";
|
|
4
4
|
import { InsertCursor } from "./InsertCursor.js";
|
|
5
5
|
import { PlusButton } from "./PlusButton.js";
|
|
@@ -15,8 +15,8 @@ const offsetByType = {
|
|
|
15
15
|
row: { alignmentAxis: -10 },
|
|
16
16
|
column: { alignmentAxis: -10 },
|
|
17
17
|
};
|
|
18
|
-
export const FloatingPlusButton = function YfmTableFloatingPlusButton({ anchor, type, ...btnProps }) {
|
|
18
|
+
export const FloatingPlusButton = forwardRef(function YfmTableFloatingPlusButton({ anchor, type, floatingStyles, ...btnProps }, ref) {
|
|
19
19
|
const [hovered, setHovered] = useState(false);
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsx(FloatingPopup, { open: true, anchorElement: anchor, placement: placementByType[type], offset: offsetByType[type], style: styles, children: _jsx(PlusButton, { ...btnProps, onHoverChange: setHovered, qa: `g-md-yfm-table-plus-${type}` }) }), hovered && _jsx(InsertCursor, { anchor: anchor, type: type })] }));
|
|
21
|
-
};
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx(FloatingPopup, { open: true, ref: ref, anchorElement: anchor, floatingStyles: floatingStyles, placement: placementByType[type], offset: offsetByType[type], style: styles, children: _jsx(PlusButton, { ...btnProps, onHoverChange: setHovered, qa: `g-md-yfm-table-plus-${type}` }) }), hovered && _jsx(InsertCursor, { anchor: anchor, type: type })] }));
|
|
21
|
+
});
|
|
22
22
|
//# sourceMappingURL=FloatingPlusButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingPlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FloatingPlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAC,aAAa,EAAiD,kCAAyB;AAE/F,OAAO,EAAC,YAAY,EAAyB,0BAAuB;AACpE,OAAO,EAAC,UAAU,EAAuB,wBAAqB;AAE9D,MAAM,MAAM,GAAwB;IAChC,YAAY,EAAE,OAAO,EAAE,8BAA8B;IACrD,UAAU,EAAE,aAAa;CAC5B,CAAC;AACF,MAAM,eAAe,GAAuE;IACxF,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,SAAS;CACpB,CAAC;AACF,MAAM,YAAY,GAAoE;IAClF,GAAG,EAAE,EAAC,aAAa,EAAE,CAAC,EAAE,EAAC;IACzB,MAAM,EAAE,EAAC,aAAa,EAAE,CAAC,EAAE,EAAC;CAC/B,CAAC;AAQF,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CACxC,SAAS,0BAA0B,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAC,EAAE,GAAG;IAChF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,CACH,8BACI,KAAC,aAAa,IACV,IAAI,QACJ,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,EAChC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,EAC1B,KAAK,EAAE,MAAM,YAEb,KAAC,UAAU,OACH,QAAQ,EACZ,aAAa,EAAE,UAAU,EACzB,EAAE,EAAE,uBAAuB,IAAI,EAAE,GACnC,GACU,EACf,OAAO,IAAI,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAI,IACzD,CACN,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import {forwardRef, useState} from 'react';\n\nimport {FloatingPopup, type FloatingPopupProps, type FloatingPopupRef} from '../FloatingPopup';\n\nimport {InsertCursor, type InsertCursorProps} from './InsertCursor';\nimport {PlusButton, type PlusButtonProps} from './PlusButton';\n\nconst styles: React.CSSProperties = {\n borderRadius: '100px', // button circle border radius\n background: 'transparent',\n};\nconst placementByType: Record<InsertCursorProps['type'], FloatingPopupProps['placement']> = {\n row: 'left-end',\n column: 'top-end',\n};\nconst offsetByType: Record<InsertCursorProps['type'], FloatingPopupProps['offset']> = {\n row: {alignmentAxis: -10},\n column: {alignmentAxis: -10},\n};\n\nexport type FloatingPlusButtonRef = FloatingPopupRef & {};\n\nexport type FloatingPlusButtonProps = Pick<FloatingPopupProps, 'floatingStyles'> &\n Pick<PlusButtonProps, 'onClick'> &\n Pick<InsertCursorProps, 'type' | 'anchor'>;\n\nexport const FloatingPlusButton = forwardRef<FloatingPlusButtonRef, FloatingPlusButtonProps>(\n function YfmTableFloatingPlusButton({anchor, type, floatingStyles, ...btnProps}, ref) {\n const [hovered, setHovered] = useState(false);\n\n return (\n <>\n <FloatingPopup\n open\n ref={ref}\n anchorElement={anchor}\n floatingStyles={floatingStyles}\n placement={placementByType[type]}\n offset={offsetByType[type]}\n style={styles}\n >\n <PlusButton\n {...btnProps}\n onHoverChange={setHovered}\n qa={`g-md-yfm-table-plus-${type}`}\n />\n </FloatingPopup>\n {hovered && <InsertCursor anchor={anchor} type={type} />}\n </>\n );\n },\n);\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type FloatingPlusButtonProps } from "../FloatingPlusButton/index.js";
|
|
2
|
+
type ControlType = FloatingPlusButtonProps['type'];
|
|
2
3
|
export type FloatingPlusControlProps = {
|
|
3
|
-
type:
|
|
4
|
+
type: ControlType;
|
|
4
5
|
index: number;
|
|
5
6
|
cellElem: Element;
|
|
6
7
|
tableElem: Element;
|
|
7
8
|
onClick: (rowIdx: number) => void;
|
|
8
9
|
};
|
|
9
10
|
export declare const FloatingPlusControl: import("react").NamedExoticComponent<FloatingPlusControlProps>;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo } from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { useEffectOnce } from 'react-use';
|
|
4
|
+
import { useRafThrottle } from "../../hooks/use-raf-throttle.js";
|
|
5
|
+
import { FloatingPlusButton, } from "../FloatingPlusButton/index.js";
|
|
4
6
|
export const FloatingPlusControl = memo(function YfmTableRowFloatingPlusControl({ type, index, cellElem, tableElem, onClick }) {
|
|
5
7
|
const anchor = useMemo(() => ({
|
|
6
8
|
contextElement: tableElem,
|
|
@@ -30,6 +32,39 @@ export const FloatingPlusControl = memo(function YfmTableRowFloatingPlusControl(
|
|
|
30
32
|
};
|
|
31
33
|
},
|
|
32
34
|
}), [cellElem, tableElem, type]);
|
|
33
|
-
|
|
35
|
+
const [visible, setVisible] = useState(() => shouldBeVisible(type, cellElem, tableElem));
|
|
36
|
+
const buttonRef = useRef(null);
|
|
37
|
+
const updateVisibility = () => {
|
|
38
|
+
const newVisible = shouldBeVisible(type, cellElem, tableElem);
|
|
39
|
+
if (visible !== newVisible)
|
|
40
|
+
setVisible(newVisible);
|
|
41
|
+
};
|
|
42
|
+
const onChange = useRafThrottle(() => {
|
|
43
|
+
buttonRef.current?.forceUpdate();
|
|
44
|
+
updateVisibility();
|
|
45
|
+
});
|
|
46
|
+
// Update after first render
|
|
47
|
+
useEffectOnce(updateVisibility);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (type !== 'column')
|
|
50
|
+
return undefined;
|
|
51
|
+
const observer = new ResizeObserver(onChange);
|
|
52
|
+
observer.observe(tableElem);
|
|
53
|
+
tableElem.addEventListener('scroll', onChange);
|
|
54
|
+
return () => {
|
|
55
|
+
observer.unobserve(tableElem);
|
|
56
|
+
tableElem.removeEventListener('scroll', onChange);
|
|
57
|
+
};
|
|
58
|
+
}, [tableElem, onChange, type]);
|
|
59
|
+
return (_jsx(FloatingPlusButton, { ref: buttonRef, anchor: anchor, type: type, onClick: () => onClick(index), floatingStyles: visible ? undefined : { display: 'none' } }));
|
|
34
60
|
});
|
|
61
|
+
function shouldBeVisible(type, cellElem, tableElem) {
|
|
62
|
+
if (type !== 'column')
|
|
63
|
+
return true;
|
|
64
|
+
const THRESHOLD = 4; // px
|
|
65
|
+
const cellRect = cellElem.getBoundingClientRect();
|
|
66
|
+
const tableRect = tableElem.getBoundingClientRect();
|
|
67
|
+
return (tableRect.left - cellRect.right <= THRESHOLD &&
|
|
68
|
+
cellRect.right - tableRect.right <= THRESHOLD);
|
|
69
|
+
}
|
|
35
70
|
//# sourceMappingURL=FloatingPlusControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingPlusControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FloatingPlusControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AAExC,OAAO,EAAC,cAAc,EAAC,wCAAqC;AAC5D,OAAO,EACH,kBAAkB,GAGrB,uCAA8B;AAY/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CACnC,SAAS,8BAA8B,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAC;IAC/E,MAAM,MAAM,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACH,cAAc,EAAE,SAAS;QACzB,qBAAqB;YACjB,MAAM,QAAQ,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAC;YAClD,MAAM,SAAS,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;YAEpD,OAAO,IAAI,KAAK,KAAK;gBACjB,CAAC,CAAC;oBACI,CAAC,EAAE,SAAS,CA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C,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,SAAS,CAChD,CAAC;AACN,CAAC","sourcesContent":["import {memo, useEffect, useMemo, useRef, useState} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type {VirtualElement} from '@floating-ui/dom';\nimport {useEffectOnce} from 'react-use';\n\nimport {useRafThrottle} from '../../hooks/use-raf-throttle';\nimport {\n FloatingPlusButton,\n type FloatingPlusButtonProps,\n type FloatingPlusButtonRef,\n} from '../FloatingPlusButton';\n\ntype ControlType = FloatingPlusButtonProps['type'];\n\nexport type FloatingPlusControlProps = {\n type: ControlType;\n index: number;\n cellElem: Element;\n tableElem: Element;\n onClick: (rowIdx: number) => void;\n};\n\nexport const FloatingPlusControl = memo<FloatingPlusControlProps>(\n function YfmTableRowFloatingPlusControl({type, index, cellElem, tableElem, onClick}) {\n const anchor = useMemo<VirtualElement>(\n () => ({\n contextElement: tableElem,\n getBoundingClientRect() {\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect = tableElem.getBoundingClientRect();\n\n return type === 'row'\n ? {\n x: tableRect.x,\n y: cellRect.y,\n width: tableRect.width,\n height: cellRect.height,\n top: cellRect.top,\n left: tableRect.left,\n right: tableRect.right,\n bottom: cellRect.top,\n }\n : {\n x: cellRect.x,\n y: tableRect.y,\n width: cellRect.width,\n height: tableRect.height,\n top: tableRect.top,\n left: cellRect.left,\n right: cellRect.right,\n bottom: tableRect.top,\n };\n },\n }),\n [cellElem, tableElem, type],\n );\n\n const [visible, setVisible] = useState(() => shouldBeVisible(type, cellElem, tableElem));\n const buttonRef = useRef<FloatingPlusButtonRef>(null);\n\n const updateVisibility = () => {\n const newVisible = shouldBeVisible(type, cellElem, tableElem);\n if (visible !== newVisible) setVisible(newVisible);\n };\n\n const onChange = useRafThrottle(() => {\n buttonRef.current?.forceUpdate();\n updateVisibility();\n });\n\n // Update after first render\n useEffectOnce(updateVisibility);\n\n useEffect(() => {\n if (type !== 'column') return undefined;\n\n const observer = new ResizeObserver(onChange);\n observer.observe(tableElem);\n tableElem.addEventListener('scroll', onChange);\n\n return () => {\n observer.unobserve(tableElem);\n tableElem.removeEventListener('scroll', onChange);\n };\n }, [tableElem, onChange, type]);\n\n return (\n <FloatingPlusButton\n ref={buttonRef}\n anchor={anchor}\n type={type}\n onClick={() => onClick(index)}\n floatingStyles={visible ? undefined : {display: 'none'}}\n />\n );\n },\n);\n\nfunction shouldBeVisible(type: ControlType, cellElem: Element, tableElem: Element): boolean {\n if (type !== 'column') return true;\n\n const THRESHOLD = 4; // px\n\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect = tableElem.getBoundingClientRect();\n\n return (\n tableRect.left - cellRect.right <= THRESHOLD &&\n cellRect.right - tableRect.right <= THRESHOLD\n );\n}\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type OffsetOptions, type Placement, type ReferenceType } from '@floating-ui/react';
|
|
2
2
|
import { type DOMProps, type QAProps } from '@gravity-ui/uikit';
|
|
3
3
|
import "./FloatingPopup.css";
|
|
4
|
+
export type { ReferenceType };
|
|
5
|
+
export type FloatingPopupRef = {
|
|
6
|
+
forceUpdate: () => void;
|
|
7
|
+
};
|
|
4
8
|
export type FloatingPopupProps = QAProps & DOMProps & {
|
|
5
9
|
open?: boolean;
|
|
6
10
|
zIndex?: number;
|
|
@@ -10,4 +14,12 @@ export type FloatingPopupProps = QAProps & DOMProps & {
|
|
|
10
14
|
children: React.ReactNode;
|
|
11
15
|
floatingStyles?: React.CSSProperties;
|
|
12
16
|
};
|
|
13
|
-
export declare const FloatingPopup:
|
|
17
|
+
export declare const FloatingPopup: import("react").ForwardRefExoticComponent<QAProps & DOMProps & {
|
|
18
|
+
open?: boolean;
|
|
19
|
+
zIndex?: number;
|
|
20
|
+
placement: Placement;
|
|
21
|
+
offset?: OffsetOptions;
|
|
22
|
+
anchorElement: ReferenceType | undefined | null;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
floatingStyles?: React.CSSProperties;
|
|
25
|
+
} & import("react").RefAttributes<FloatingPopupRef>>;
|
|
@@ -3,36 +3,34 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
/// Fork of Popup component from @gravity-ui/uikit
|
|
4
4
|
/// This fork does not use floating focus manager
|
|
5
5
|
///
|
|
6
|
-
import { useEffect, useMemo } from 'react';
|
|
6
|
+
import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
|
|
7
7
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
8
|
import { FloatingNode, FloatingTree, autoUpdate, offset as offsetMiddleware, useFloating, useFloatingNodeId, useFloatingParentNodeId, useInteractions, } from '@floating-ui/react';
|
|
9
9
|
import { Portal } from '@gravity-ui/uikit';
|
|
10
10
|
import { cn } from "../../../../../../../classname.js";
|
|
11
11
|
import "./FloatingPopup.css";
|
|
12
12
|
const b = cn('yfm-table-floating-popup');
|
|
13
|
-
export const FloatingPopup = function YfmTableFloatingPopup(props) {
|
|
13
|
+
export const FloatingPopup = forwardRef(function YfmTableFloatingPopup(props, ref) {
|
|
14
14
|
const { anchorElement, zIndex = 1000, style, className, qa, children, floatingStyles: floatingStylesFromProps, } = props;
|
|
15
15
|
const nodeId = useFloatingNodeId();
|
|
16
16
|
const parentId = useFloatingParentNodeId();
|
|
17
17
|
const middleware = useMemo(() => [offsetMiddleware(props.offset)], [props.offset]);
|
|
18
|
-
const { refs,
|
|
18
|
+
const { refs, floatingStyles, placement, context: { open }, update, } = useFloating({
|
|
19
19
|
nodeId,
|
|
20
20
|
open: props.open,
|
|
21
21
|
placement: props.placement,
|
|
22
22
|
middleware,
|
|
23
|
+
whileElementsMounted: autoUpdate,
|
|
23
24
|
});
|
|
25
|
+
useImperativeHandle(ref, () => ({
|
|
26
|
+
forceUpdate: update,
|
|
27
|
+
}), [update]);
|
|
24
28
|
const { getFloatingProps } = useInteractions();
|
|
25
29
|
useEffect(() => {
|
|
26
30
|
if (anchorElement !== undefined && anchorElement !== refs.reference.current) {
|
|
27
31
|
refs.setReference(anchorElement);
|
|
28
32
|
}
|
|
29
33
|
}, [anchorElement, refs]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (elements.reference && elements.floating) {
|
|
32
|
-
return autoUpdate(elements.reference, elements.floating, update);
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}, [elements, update]);
|
|
36
34
|
function wrapper(node) {
|
|
37
35
|
if (parentId === null) {
|
|
38
36
|
return _jsx(FloatingTree, { children: node });
|
|
@@ -50,5 +48,5 @@ export const FloatingPopup = function YfmTableFloatingPopup(props) {
|
|
|
50
48
|
...floatingStylesFromProps,
|
|
51
49
|
...floatingStyles,
|
|
52
50
|
}, "data-floating-ui-placement": placement, ...getFloatingProps(), children: _jsx("div", { className: b(null, className), style: style, "data-qa": qa, children: children }) }) })) : null }));
|
|
53
|
-
};
|
|
51
|
+
});
|
|
54
52
|
//# sourceMappingURL=FloatingPopup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingPopup.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.tsx"],"names":[],"mappings":";AAAA,GAAG;AACH,kDAAkD;AAClD,iDAAiD;AACjD,GAAG;AAEH,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FloatingPopup.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.tsx"],"names":[],"mappings":";AAAA,GAAG;AACH,kDAAkD;AAClD,iDAAiD;AACjD,GAAG;AAEH,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAE1E,6DAA6D;AAC7D,OAAO,EACH,YAAY,EACZ,YAAY,EAIZ,UAAU,EACV,MAAM,IAAI,gBAAgB,EAC1B,WAAW,EACX,iB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AC,OAAO,EAAE,CAAC;YAC1E,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC;IAE1B,SAAS,OAAO,CAAC,IAAiB;QAC9B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,KAAC,YAAY,cAAE,IAAI,GAAgB,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CACV,KAAC,YAAY,IAAC,EAAE,EAAE,MAAM,YACnB,IAAI,CAAC,CAAC,CAAC,CACJ,KAAC,MAAM,cACH,cACI,GAAG,EAAE,IAAI,CAAC,WAAW,EACrB,KAAK,EAAE;oBACH,QAAQ,EAAE,UAAU;oBACpB,GAAG,EAAE,CAAC;oBACN,IAAI,EAAE,CAAC;oBACP,MAAM;oBACN,KAAK,EAAE,aAAa;oBACpB,aAAa,EAAE,MAAM;oBACrB,OAAO,EAAE,MAAM;oBACf,GAAG,uBAAuB;oBAC1B,GAAG,cAAc;iBACpB,gCAC2B,SAAS,KACjC,gBAAgB,EAAE,YAEtB,cAAK,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,aAAW,EAAE,YACxD,QAAQ,GACP,GACJ,GACD,CACZ,CAAC,CAAC,CAAC,IAAI,GACG,CAClB,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["///\n/// Fork of Popup component from @gravity-ui/uikit\n/// This fork does not use floating focus manager\n///\n\nimport {forwardRef, useEffect, useImperativeHandle, useMemo} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n FloatingNode,\n FloatingTree,\n type OffsetOptions,\n type Placement,\n type ReferenceType,\n autoUpdate,\n offset as offsetMiddleware,\n useFloating,\n useFloatingNodeId,\n useFloatingParentNodeId,\n useInteractions,\n} from '@floating-ui/react';\nimport {type DOMProps, Portal, type QAProps} from '@gravity-ui/uikit';\n\nimport {cn} from 'src/classname';\n\nimport './FloatingPopup.scss';\n\nconst b = cn('yfm-table-floating-popup');\n\nexport type {ReferenceType};\n\nexport type FloatingPopupRef = {\n forceUpdate: () => void;\n};\n\nexport type FloatingPopupProps = QAProps &\n DOMProps & {\n open?: boolean;\n zIndex?: number;\n placement: Placement;\n offset?: OffsetOptions;\n anchorElement: ReferenceType | undefined | null;\n children: React.ReactNode;\n floatingStyles?: React.CSSProperties;\n };\n\nexport const FloatingPopup = forwardRef<FloatingPopupRef, FloatingPopupProps>(\n function YfmTableFloatingPopup(props, ref) {\n const {\n anchorElement,\n zIndex = 1000,\n style,\n className,\n qa,\n children,\n floatingStyles: floatingStylesFromProps,\n } = props;\n\n const nodeId = useFloatingNodeId();\n const parentId = useFloatingParentNodeId();\n\n const middleware = useMemo(() => [offsetMiddleware(props.offset)], [props.offset]);\n\n const {\n refs,\n floatingStyles,\n placement,\n context: {open},\n update,\n } = useFloating({\n nodeId,\n open: props.open,\n placement: props.placement,\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n useImperativeHandle<FloatingPopupRef, FloatingPopupRef>(\n ref,\n () => ({\n forceUpdate: update,\n }),\n [update],\n );\n\n const {getFloatingProps} = useInteractions();\n\n useEffect(() => {\n if (anchorElement !== undefined && anchorElement !== refs.reference.current) {\n refs.setReference(anchorElement);\n }\n }, [anchorElement, refs]);\n\n function wrapper(node: JSX.Element) {\n if (parentId === null) {\n return <FloatingTree>{node}</FloatingTree>;\n }\n\n return node;\n }\n\n return wrapper(\n <FloatingNode id={nodeId}>\n {open ? (\n <Portal>\n <div\n ref={refs.setFloating}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex,\n width: 'max-content',\n pointerEvents: 'auto',\n outline: 'none',\n ...floatingStylesFromProps,\n ...floatingStyles,\n }}\n data-floating-ui-placement={placement}\n {...getFloatingProps()}\n >\n <div className={b(null, className)} style={style} data-qa={qa}>\n {children}\n </div>\n </div>\n </Portal>\n ) : null}\n </FloatingNode>,\n );\n },\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findParentNodeClosestToPos } from "../../../../../../pm/utils.js";
|
|
2
|
-
import { isTableCellNode, isTableNode } from "../../../../../../table-utils/index.js";
|
|
2
|
+
import { isTableCellNode, isTableNode, isTableRowNode } from "../../../../../../table-utils/index.js";
|
|
3
3
|
export class DropCursor {
|
|
4
4
|
editorView;
|
|
5
5
|
width;
|
|
@@ -99,6 +99,43 @@ export class DropCursor {
|
|
|
99
99
|
this.cursorElem.style.height = rect.bottom - rect.top + 'px';
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
export class TableRowDropCursor extends DropCursor {
|
|
103
|
+
update() {
|
|
104
|
+
const cursorPos = this.getPos();
|
|
105
|
+
if (cursorPos === null)
|
|
106
|
+
return;
|
|
107
|
+
const $cursorPos = this.editorView.state.doc.resolve(cursorPos);
|
|
108
|
+
const parentTable = findParentNodeClosestToPos($cursorPos, isTableNode);
|
|
109
|
+
if (!parentTable)
|
|
110
|
+
return;
|
|
111
|
+
let side;
|
|
112
|
+
let trowPos;
|
|
113
|
+
if ($cursorPos.nodeAfter && isTableRowNode($cursorPos.nodeAfter)) {
|
|
114
|
+
side = 'top';
|
|
115
|
+
trowPos = cursorPos;
|
|
116
|
+
}
|
|
117
|
+
else if ($cursorPos.nodeBefore && isTableRowNode($cursorPos.nodeBefore)) {
|
|
118
|
+
side = 'bottom';
|
|
119
|
+
trowPos = cursorPos - $cursorPos.nodeBefore.nodeSize;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.cursorElem?.remove();
|
|
123
|
+
this.cursorElem = null;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const trElem = this.editorView.nodeDOM(trowPos);
|
|
127
|
+
const tableElem = this.editorView.nodeDOM(parentTable.pos);
|
|
128
|
+
const trRect = trElem.getBoundingClientRect();
|
|
129
|
+
const tableRect = tableElem.getBoundingClientRect();
|
|
130
|
+
const rect = {
|
|
131
|
+
top: trRect[side] - this.width / 2,
|
|
132
|
+
bottom: trRect[side] + this.width / 2,
|
|
133
|
+
left: tableRect.left,
|
|
134
|
+
right: tableRect.right,
|
|
135
|
+
};
|
|
136
|
+
this.render(rect, { isBlock: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
102
139
|
export class TableColumnDropCursor extends DropCursor {
|
|
103
140
|
update() {
|
|
104
141
|
const cursorPos = this.getPos();
|