@gravity-ui/markdown-editor 15.24.1 → 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/bundle/Editor.js +56 -23
- package/build/cjs/bundle/Editor.js.map +1 -1
- 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 +79 -11
- 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 +7 -0
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js +36 -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/markdown/Deflist/DeflistSpecs/const.d.ts +3 -0
- package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/const.js +4 -1
- package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/const.js.map +1 -1
- package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/parser.js +9 -1
- package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/parser.js.map +1 -1
- package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/schema.js +3 -2
- package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/const.d.ts +2 -1
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/const.js +1 -0
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/const.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/parser.js +4 -1
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/parser.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/schema.js +3 -2
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/markdown/Table/TableSpecs/const.d.ts +2 -1
- package/build/cjs/extensions/markdown/Table/TableSpecs/const.js +1 -0
- package/build/cjs/extensions/markdown/Table/TableSpecs/const.js.map +1 -1
- package/build/cjs/extensions/markdown/Table/TableSpecs/parser.js +9 -1
- package/build/cjs/extensions/markdown/Table/TableSpecs/parser.js.map +1 -1
- package/build/cjs/extensions/markdown/Table/TableSpecs/schema.js +3 -2
- package/build/cjs/extensions/markdown/Table/TableSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.d.ts +1 -0
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.js +1 -0
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.js.map +1 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +30 -17
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.js +1 -0
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/parser.js +14 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/parser.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.js +4 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmCut/const.d.ts +1 -1
- package/build/cjs/extensions/yfm/YfmCut/const.js +2 -1
- package/build/cjs/extensions/yfm/YfmCut/const.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js +10 -0
- package/build/cjs/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/const.d.ts +2 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/const.js +1 -0
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/const.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js +14 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/schema.js +3 -2
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/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/utils/index.d.ts +1 -0
- package/build/cjs/utils/index.js +1 -0
- package/build/cjs/utils/index.js.map +1 -1
- package/build/cjs/utils/node-descedants.d.ts +10 -0
- package/build/cjs/utils/node-descedants.js +23 -0
- package/build/cjs/utils/node-descedants.js.map +1 -0
- 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/bundle/Editor.js +56 -23
- package/build/esm/bundle/Editor.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 +80 -12
- 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 +7 -0
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js +36 -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/markdown/Deflist/DeflistSpecs/const.d.ts +3 -0
- package/build/esm/extensions/markdown/Deflist/DeflistSpecs/const.js +3 -0
- package/build/esm/extensions/markdown/Deflist/DeflistSpecs/const.js.map +1 -1
- package/build/esm/extensions/markdown/Deflist/DeflistSpecs/parser.js +10 -2
- package/build/esm/extensions/markdown/Deflist/DeflistSpecs/parser.js.map +1 -1
- package/build/esm/extensions/markdown/Deflist/DeflistSpecs/schema.js +4 -3
- package/build/esm/extensions/markdown/Deflist/DeflistSpecs/schema.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/ListsSpecs/const.d.ts +2 -1
- package/build/esm/extensions/markdown/Lists/ListsSpecs/const.js +1 -0
- package/build/esm/extensions/markdown/Lists/ListsSpecs/const.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/ListsSpecs/parser.js +4 -1
- package/build/esm/extensions/markdown/Lists/ListsSpecs/parser.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/ListsSpecs/schema.js +3 -2
- package/build/esm/extensions/markdown/Lists/ListsSpecs/schema.js.map +1 -1
- package/build/esm/extensions/markdown/Table/TableSpecs/const.d.ts +2 -1
- package/build/esm/extensions/markdown/Table/TableSpecs/const.js +1 -0
- package/build/esm/extensions/markdown/Table/TableSpecs/const.js.map +1 -1
- package/build/esm/extensions/markdown/Table/TableSpecs/parser.js +9 -1
- package/build/esm/extensions/markdown/Table/TableSpecs/parser.js.map +1 -1
- package/build/esm/extensions/markdown/Table/TableSpecs/schema.js +3 -2
- package/build/esm/extensions/markdown/Table/TableSpecs/schema.js.map +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.d.ts +1 -0
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.js +1 -0
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.js.map +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +30 -17
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js.map +1 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.js +1 -0
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.js.map +1 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/parser.js +14 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/parser.js.map +1 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.js +4 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.js.map +1 -1
- package/build/esm/extensions/yfm/YfmCut/const.d.ts +1 -1
- package/build/esm/extensions/yfm/YfmCut/const.js +1 -1
- package/build/esm/extensions/yfm/YfmCut/const.js.map +1 -1
- package/build/esm/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js +11 -1
- package/build/esm/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js.map +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/const.d.ts +2 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/const.js +1 -0
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/const.js.map +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js +15 -2
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js.map +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/schema.js +3 -2
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/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/utils/index.d.ts +1 -0
- package/build/esm/utils/index.js +1 -0
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/node-descedants.d.ts +10 -0
- package/build/esm/utils/node-descedants.js +19 -0
- package/build/esm/utils/node-descedants.js.map +1 -0
- 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,4 +1,4 @@
|
|
|
1
|
-
export { CutNode, cutType, cutTitleType, cutContentType } from "./YfmCutSpecs/const.js";
|
|
1
|
+
export { CutNode, CutAttr, cutType, cutTitleType, cutContentType } from "./YfmCutSpecs/const.js";
|
|
2
2
|
export declare const YfmCutClassName: {
|
|
3
3
|
readonly TitleInner: "g-md-yfm-cut-title-inner";
|
|
4
4
|
readonly Open: "yfm-cut-open";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YfmCutClassName = exports.cutContentType = exports.cutTitleType = exports.cutType = exports.CutNode = void 0;
|
|
3
|
+
exports.YfmCutClassName = exports.cutContentType = exports.cutTitleType = exports.cutType = exports.CutAttr = exports.CutNode = void 0;
|
|
4
4
|
const const_1 = require("./YfmCutSpecs/const.js");
|
|
5
5
|
var const_2 = require("./YfmCutSpecs/const.js");
|
|
6
6
|
Object.defineProperty(exports, "CutNode", { enumerable: true, get: function () { return const_2.CutNode; } });
|
|
7
|
+
Object.defineProperty(exports, "CutAttr", { enumerable: true, get: function () { return const_2.CutAttr; } });
|
|
7
8
|
Object.defineProperty(exports, "cutType", { enumerable: true, get: function () { return const_2.cutType; } });
|
|
8
9
|
Object.defineProperty(exports, "cutTitleType", { enumerable: true, get: function () { return const_2.cutTitleType; } });
|
|
9
10
|
Object.defineProperty(exports, "cutContentType", { enumerable: true, get: function () { return const_2.cutContentType; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"../../../../../src","sources":["extensions/yfm/YfmCut/const.ts"],"names":[],"mappings":";;;AAAA,kDAA4E;AAE5E,
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"../../../../../src","sources":["extensions/yfm/YfmCut/const.ts"],"names":[],"mappings":";;;AAAA,kDAA4E;AAE5E,gDAA4F;AAApF,gGAAA,OAAO,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,uGAAA,cAAc,OAAA;AAElD,QAAA,eAAe,GAAG;IAC3B,GAAG,uBAAoB;IACvB,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,gBAAgB;CAClB,CAAC","sourcesContent":["import {YfmCutClassName as YfmCutClassNameSpecs} from './YfmCutSpecs/const';\n\nexport {CutNode, CutAttr, cutType, cutTitleType, cutContentType} from './YfmCutSpecs/const';\n\nexport const YfmCutClassName = {\n ...YfmCutClassNameSpecs,\n TitleInner: 'g-md-yfm-cut-title-inner',\n Open: 'yfm-cut-open',\n Active: 'yfm-cut-active',\n} as const;\n"]}
|
|
@@ -12,6 +12,7 @@ class YfmCutTitleNodeView {
|
|
|
12
12
|
this.dom = document.createElement('div');
|
|
13
13
|
this.dom.classList.add(const_1.YfmCutClassName.Title);
|
|
14
14
|
this.dom.addEventListener('click', this._onTitleClick);
|
|
15
|
+
updateDomAttribute(this.dom, const_1.CutAttr.Line, node.attrs[const_1.CutAttr.Line]);
|
|
15
16
|
this.contentDOM = this.dom.appendChild(document.createElement('div'));
|
|
16
17
|
this.contentDOM.classList.add(const_1.YfmCutClassName.TitleInner);
|
|
17
18
|
this.contentDOM.addEventListener('click', this._onTitleInnerClick);
|
|
@@ -20,6 +21,7 @@ class YfmCutTitleNodeView {
|
|
|
20
21
|
if (this.node.type !== node.type)
|
|
21
22
|
return false;
|
|
22
23
|
this.node = node;
|
|
24
|
+
updateDomAttribute(this.dom, const_1.CutAttr.Line, node.attrs[const_1.CutAttr.Line]);
|
|
23
25
|
return true;
|
|
24
26
|
}
|
|
25
27
|
destroy() {
|
|
@@ -44,4 +46,12 @@ class YfmCutTitleNodeView {
|
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
exports.YfmCutTitleNodeView = YfmCutTitleNodeView;
|
|
49
|
+
function updateDomAttribute(elem, attr, value) {
|
|
50
|
+
if (value) {
|
|
51
|
+
elem.setAttribute(attr, value);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
elem.removeAttribute(attr);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
47
57
|
//# sourceMappingURL=yfm-cut-title.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yfm-cut-title.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmCut/nodeviews/yfm-cut-title.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"yfm-cut-title.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmCut/nodeviews/yfm-cut-title.ts"],"names":[],"mappings":";;;AAGA,uCAAkD;AAElD,+BAA8B;AAE9B,MAAa,mBAAmB;IACnB,GAAG,CAAc;IACjB,UAAU,CAAc;IAEzB,IAAI,CAAO;IAEnB,YAAY,IAAU;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAe,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACvD,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,eAAO,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,eAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAErE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,W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,2DAA2D;QAC3D,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC,CAAC;CACL;AAhDD,kDAgDC;AAED,SAAS,kBAAkB,CAAC,IAAa,EAAE,IAAY,EAAE,KAAgC;IACrF,IAAI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC","sourcesContent":["import type {Node} from '#pm/model';\nimport type {NodeView} from '#pm/view';\n\nimport {CutAttr, YfmCutClassName} from '../const';\n\nimport './yfm-cut-title.scss';\n\nexport class YfmCutTitleNodeView implements NodeView {\n readonly dom: HTMLElement;\n readonly contentDOM: HTMLElement;\n\n private node: Node;\n\n constructor(node: Node) {\n this.node = node;\n\n this.dom = document.createElement('div');\n this.dom.classList.add(YfmCutClassName.Title);\n this.dom.addEventListener('click', this._onTitleClick);\n updateDomAttribute(this.dom, CutAttr.Line, node.attrs[CutAttr.Line]);\n\n this.contentDOM = this.dom.appendChild(document.createElement('div'));\n this.contentDOM.classList.add(YfmCutClassName.TitleInner);\n this.contentDOM.addEventListener('click', this._onTitleInnerClick);\n }\n\n update(node: Node): boolean {\n if (this.node.type !== node.type) return false;\n this.node = node;\n updateDomAttribute(this.dom, CutAttr.Line, node.attrs[CutAttr.Line]);\n return true;\n }\n\n destroy() {\n this.dom.removeEventListener('click', this._onTitleClick);\n this.contentDOM.removeEventListener('click', this._onTitleInnerClick);\n }\n\n private _onTitleClick = (e: MouseEvent) => {\n const {currentTarget} = e;\n if (currentTarget instanceof HTMLElement) {\n const parent = currentTarget.parentElement;\n if (parent?.classList.contains(YfmCutClassName.Cut)) {\n // TODO: toggle open classname via prosemirror decoration\n parent.classList.toggle(YfmCutClassName.Open);\n }\n }\n };\n\n private _onTitleInnerClick = (e: MouseEvent) => {\n // ignore clicking on the title content\n // you can open/close yfm-cut by clicking on the arrow icon\n e.stopPropagation();\n e.preventDefault();\n };\n}\n\nfunction updateDomAttribute(elem: Element, attr: string, value: string | null | undefined) {\n if (value) {\n elem.setAttribute(attr, value);\n } else {\n elem.removeAttribute(attr);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/const.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,6BAAiB,CAAA;IACjB,wCAA4B,CAAA;IAC5B,4CAAgC,CAAA;AACpC,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/const.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,6BAAiB,CAAA;IACjB,wCAA4B,CAAA;IAC5B,4CAAgC,CAAA;AACpC,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,+BAAkB,CAAA;IAClB,+BAAkB,CAAA;AACtB,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB","sourcesContent":["export enum NoteNode {\n Note = 'yfm_note',\n NoteTitle = 'yfm_note_title',\n NoteContent = 'yfm_note_content',\n}\n\nexport enum NoteAttrs {\n Class = 'class',\n Type = 'note-type',\n Line = 'data-line',\n}\n"]}
|
|
@@ -8,7 +8,20 @@ exports.parserTokens = {
|
|
|
8
8
|
type: 'block',
|
|
9
9
|
getAttrs: (token) => (token.attrs ? Object.fromEntries(token.attrs) : {}),
|
|
10
10
|
},
|
|
11
|
-
[const_1.NoteNode.NoteTitle]: {
|
|
11
|
+
[const_1.NoteNode.NoteTitle]: {
|
|
12
|
+
name: const_1.NoteNode.NoteTitle,
|
|
13
|
+
type: 'block',
|
|
14
|
+
getAttrs: (token, tokens, index) => {
|
|
15
|
+
let dataLine = token.attrGet('data-line');
|
|
16
|
+
if (!dataLine) {
|
|
17
|
+
const prevToken = tokens[index - 1];
|
|
18
|
+
if (prevToken?.type === 'yfm_note_open') {
|
|
19
|
+
dataLine = prevToken.attrGet('data-line');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { [const_1.NoteAttrs.Line]: dataLine };
|
|
23
|
+
},
|
|
24
|
+
},
|
|
12
25
|
[const_1.NoteNode.NoteContent]: { name: const_1.NoteNode.NoteContent, type: 'block' },
|
|
13
26
|
};
|
|
14
27
|
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/parser.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/parser.ts"],"names":[],"mappings":";;;AAEA,sCAA4C;AAE/B,QAAA,YAAY,GAAkC;IACvD,CAAC,gBAAQ,CAAC,IAAI,CAAC,EAAE;QACb,IAAI,EAAE,gBAAQ,CAAC,IAAI;QACnB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E;IACD,CAAC,gBAAQ,CAAC,SAAS,CAAC,EAAE;QAClB,IAAI,EAAE,gBAAQ,CAAC,SAAS;QACxB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;YAC/B,IAAI,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACZ,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACpC,IAAI,SAAS,EAAE,IAAI,KAAK,eAAe,EAAE,CAAC;oBACtC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC9C,CAAC;YACL,CAAC;YACD,OAAO,EAAC,CAAC,iBAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAC,CAAC;QACxC,CAAC;KACJ;IACD,CAAC,gBAAQ,CAAC,WAAW,CAAC,EAAE,EAAC,IAAI,EAAE,gBAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAC;CACtE,CAAC","sourcesContent":["import type {ParserToken} from '../../../../core';\n\nimport {NoteAttrs, NoteNode} from './const';\n\nexport const parserTokens: Record<NoteNode, ParserToken> = {\n [NoteNode.Note]: {\n name: NoteNode.Note,\n type: 'block',\n getAttrs: (token) => (token.attrs ? Object.fromEntries(token.attrs) : {}),\n },\n [NoteNode.NoteTitle]: {\n name: NoteNode.NoteTitle,\n type: 'block',\n getAttrs: (token, tokens, index) => {\n let dataLine = token.attrGet('data-line');\n if (!dataLine) {\n const prevToken = tokens[index - 1];\n if (prevToken?.type === 'yfm_note_open') {\n dataLine = prevToken.attrGet('data-line');\n }\n }\n return {[NoteAttrs.Line]: dataLine};\n },\n },\n [NoteNode.NoteContent]: {name: NoteNode.NoteContent, type: 'block'},\n};\n"]}
|
|
@@ -30,6 +30,7 @@ const getSchemaSpecs = (opts, placeholder) => ({
|
|
|
30
30
|
complex: 'root',
|
|
31
31
|
},
|
|
32
32
|
[const_1.NoteNode.NoteTitle]: {
|
|
33
|
+
attrs: { [const_1.NoteAttrs.Line]: { default: null } },
|
|
33
34
|
content: 'inline*',
|
|
34
35
|
group: 'block yfm-note',
|
|
35
36
|
parseDOM: [
|
|
@@ -38,8 +39,8 @@ const getSchemaSpecs = (opts, placeholder) => ({
|
|
|
38
39
|
priority: 100,
|
|
39
40
|
},
|
|
40
41
|
],
|
|
41
|
-
toDOM() {
|
|
42
|
-
return ['p', { class: 'yfm-note-title' }, 0];
|
|
42
|
+
toDOM(node) {
|
|
43
|
+
return ['p', { class: 'yfm-note-title', ...node.attrs }, 0];
|
|
43
44
|
},
|
|
44
45
|
selectable: false,
|
|
45
46
|
allowSelection: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/schema.ts"],"names":[],"mappings":";;;AAIA,sCAA4C;AAI5C,MAAM,yBAAyB,GAAG,MAAM,CAAC;AACzC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE5C,MAAM,cAAc,GAAG,CAC1B,IAA0B,EAC1B,WAAgC,EACN,EAAE,CAAC,CAAC;IAC9B,CAAC,gBAAQ,CAAC,IAAI,CAAC,EAAE;QACb,KAAK,EAAE;YACH,CAAC,iBAAS,CAAC,KAAK,CAAC,EAAE,EAAC,OAAO,EAAE,0BAA0B,EAAC;YACxD,CAAC,iBAAS,CAAC,IAAI,CAAC,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC;SACtC;QACD,OAAO,EAAE,GAAG,gBAAQ,CAAC,SAAS,IAAI,gBAAQ,CAAC,WAAW,EAAE;QACxD,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE;YACN;gBACI,GAAG,EAAE,cAAc;gBACnB,QAAQ,EAAE,GAAG;gBACb,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACjB,CAAC,iBAAS,CAAC,KAAK,CAAC,EAAG,IAAgB,CAAC,YAAY,CAAC,iBAAS,CAAC,KAAK,CAAC,IAAI,EAAE;oBACxE,CAAC,iBAAS,CAAC,IAAI,CAAC,EAAG,IAAgB,CAAC,YAAY,CAAC,iBAAS,CAAC,IAAI,CAA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AAK,EAAE,kBAAkB,EAAC,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE;YACT,OAAO,EAAE,WAAW,EAAE,CAAC,gBAAQ,CAAC,WAAW,CAAC,IAAI,2BAA2B;YAC3E,aAAa,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,MAAM;KAClB;CACJ,CAAC,CAAC;AAzEU,QAAA,cAAc,kBAyExB","sourcesContent":["import type {NodeSpec} from 'prosemirror-model';\n\nimport type {PlaceholderOptions} from '../../../../utils/placeholder';\n\nimport {NoteAttrs, NoteNode} from './const';\n\nimport type {YfmNoteSpecsOptions} from './index';\n\nconst DEFAULT_TITLE_PLACEHOLDER = 'Note';\nconst DEFAULT_CONTENT_PLACEHOLDER = 'Note content';\n\nexport const getSchemaSpecs = (\n opts?: YfmNoteSpecsOptions,\n placeholder?: PlaceholderOptions,\n): Record<NoteNode, NodeSpec> => ({\n [NoteNode.Note]: {\n attrs: {\n [NoteAttrs.Class]: {default: 'yfm-note yfm-accent-info'},\n [NoteAttrs.Type]: {default: 'info'},\n },\n content: `${NoteNode.NoteTitle} ${NoteNode.NoteContent}`,\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'div.yfm-note',\n priority: 100,\n getAttrs: (node) => ({\n [NoteAttrs.Class]: (node as Element).getAttribute(NoteAttrs.Class) || '',\n [NoteAttrs.Type]: (node as Element).getAttribute(NoteAttrs.Type) || 'info',\n }),\n },\n ],\n toDOM(node) {\n return ['div', node.attrs, 0];\n },\n selectable: true,\n allowSelection: true,\n complex: 'root',\n },\n\n [NoteNode.NoteTitle]: {\n attrs: {[NoteAttrs.Line]: {default: null}},\n content: 'inline*',\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'p.yfm-note-title',\n priority: 100,\n },\n ],\n toDOM(node) {\n return ['p', {class: 'yfm-note-title', ...node.attrs}, 0];\n },\n selectable: false,\n allowSelection: false,\n placeholder: {\n content:\n placeholder?.[NoteNode.NoteTitle] ??\n opts?.yfmNoteTitlePlaceholder ??\n DEFAULT_TITLE_PLACEHOLDER,\n alwaysVisible: true,\n },\n complex: 'leaf',\n },\n [NoteNode.NoteContent]: {\n content: '(block | paragraph)+',\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'div.yfm-note-content',\n priority: 100,\n },\n ],\n toDOM() {\n return ['div', {class: 'yfm-note-content'}, 0];\n },\n selectable: false,\n allowSelection: false,\n placeholder: {\n content: placeholder?.[NoteNode.NoteContent] ?? DEFAULT_CONTENT_PLACEHOLDER,\n alwaysVisible: true,\n },\n complex: 'leaf',\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,iCAA+B;AAE/B,6CAAuF;AACvF,6CAO2B;AAE3B,2EAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"FloatingMenu.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.tsx"],"names":[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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 {};
|
|
@@ -7,7 +7,7 @@ const icons_1 = require("@gravity-ui/icons");
|
|
|
7
7
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
8
|
const yfm_table_1 = require("../../../../../../../i18n/yfm-table/index.js");
|
|
9
9
|
const FloatingMenu_1 = require("../FloatingMenu/FloatingMenu.js");
|
|
10
|
-
const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler,
|
|
10
|
+
const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, cellElement, tableElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
|
|
11
11
|
const dropdownItems = (0, react_1.useMemo)(() => [
|
|
12
12
|
[
|
|
13
13
|
{
|
|
@@ -55,7 +55,8 @@ const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multipl
|
|
|
55
55
|
onRemoveRangeClick,
|
|
56
56
|
onRemoveTableClick,
|
|
57
57
|
]);
|
|
58
|
-
|
|
58
|
+
const anchor = (0, react_1.useMemo)(() => getVirtualAnchor(type, tableElement, cellElement), [type, tableElement, cellElement]);
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(FloatingMenu_1.FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: anchor, switcherMouseProps: dndHandler
|
|
59
60
|
? {
|
|
60
61
|
onMouseLeave: dndHandler.control_handleMouseLeave,
|
|
61
62
|
onMouseDown: dndHandler.control_handleMouseDown,
|
|
@@ -65,4 +66,60 @@ const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multipl
|
|
|
65
66
|
: undefined, dropdownItems: dropdownItems }));
|
|
66
67
|
};
|
|
67
68
|
exports.FloatingMenuControl = FloatingMenuControl;
|
|
69
|
+
function getVirtualAnchor(type, tableElem, cellElem) {
|
|
70
|
+
if (type === 'row') {
|
|
71
|
+
return {
|
|
72
|
+
contextElement: cellElem,
|
|
73
|
+
getBoundingClientRect() {
|
|
74
|
+
const cellRect = cellElem.getBoundingClientRect();
|
|
75
|
+
const tableRect = tableElem.getBoundingClientRect().toJSON();
|
|
76
|
+
{
|
|
77
|
+
// fix table rect
|
|
78
|
+
tableRect.x += 1;
|
|
79
|
+
tableRect.width -= 2;
|
|
80
|
+
tableRect.left += 1;
|
|
81
|
+
tableRect.right -= 1;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
// from table
|
|
85
|
+
x: tableRect.x,
|
|
86
|
+
width: tableRect.width,
|
|
87
|
+
left: tableRect.left,
|
|
88
|
+
right: tableRect.right,
|
|
89
|
+
// from cell
|
|
90
|
+
y: cellRect.y,
|
|
91
|
+
height: cellRect.height,
|
|
92
|
+
top: cellRect.top,
|
|
93
|
+
bottom: cellRect.top,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (type === 'column') {
|
|
99
|
+
return {
|
|
100
|
+
contextElement: cellElem,
|
|
101
|
+
getBoundingClientRect() {
|
|
102
|
+
const cellRect = cellElem.getBoundingClientRect().toJSON();
|
|
103
|
+
const tableRect = tableElem.getBoundingClientRect();
|
|
104
|
+
const EDGE_OFFSET = 16;
|
|
105
|
+
const cellMiddle = cellRect.x + cellRect.width / 2;
|
|
106
|
+
// left border of table
|
|
107
|
+
if (cellMiddle - EDGE_OFFSET <= tableRect.left) {
|
|
108
|
+
const visible = cellRect.right - tableRect.left;
|
|
109
|
+
cellRect.width = (visible - EDGE_OFFSET) * 2;
|
|
110
|
+
cellRect.left = cellRect.right - cellRect.width;
|
|
111
|
+
cellRect.x = cellRect.left;
|
|
112
|
+
}
|
|
113
|
+
// right border of table
|
|
114
|
+
if (cellMiddle + EDGE_OFFSET >= tableRect.right) {
|
|
115
|
+
const visible = tableRect.right - cellRect.left;
|
|
116
|
+
cellRect.width = (visible - EDGE_OFFSET) * 2;
|
|
117
|
+
cellRect.right = cellRect.left + cellRect.width;
|
|
118
|
+
}
|
|
119
|
+
return cellRect;
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
throw new Error(`Unknown control type: ${type}`);
|
|
124
|
+
}
|
|
68
125
|
//# 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,iCAA8B;AAE9B,6CAQ2B;AAC3B,6CAAuC;AAEvC,4EAAwC;AAGxC,kEAAkF;AAe3E,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,IAAA,eAAO,EACzB,GAAG,EAAE,CACD;QACI;YACI;gBACI,IAAI,EAAE,IAAA,gBAAI,EAAC,GAAG,IAAI,aAAa,CAAC;gBAChC,EAAE,EAAE,6BAA6B,IAAI,SAAS;gBAC9C,MAAM,EAAE,mBAAmB;gBAC3B,SAAS,EAAE,uBAAC,YAAI,IAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,eAAO,CAAC,CAAC,CAAC,iBAAS,GAAI;aAClE;YACD;gBACI,IAAI,EAAE,IAAA,gBAAI,EAAC,GAAG,IAAI,YAAY,CAAC;gBAC/B,EAAE,EAAE,6BAA6B,IAAI,QAAQ;gBAC7C,MAAM,EAAE,kBAAkB;gBAC1B,SAAS,EAAE,uBAAC,YAAI,IAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,iBAAS,CAAC,CAAC,CAAC,kBAAU,GAAI;aACrE;SACJ;QACD;YACI;gBACI,IAAI,EAAE,IAAA,gBAAI,EAAC,aAAa,CAAC;gBACzB,EAAE,EAAE,kBAAkB,IAAI,cAAc;gBACxC,MAAM,EAAE,iBAAiB;gBACzB,SAAS,EAAE,uBAAC,YAAI,IAAC,IAAI,EAAE,mBA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roomMotion 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/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.tsx"],"names":[],"mappings":";;;;AAAA,iCAA8B;AAI9B,6CAQ2B;AAC3B,6CAAuC;AAEvC,4EAAwC;AAGxC,kEAAkF;AAkB3E,MAAM,mBAAmB,GAC5B,SAAS,2BAA2B,CAAC,EACjC,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACrB;IACG,MAAM,aAAa,GAAG,IAAA,eAAO,EACzB,GAAG,EAAE,CACD;QACI;YACI;gBACI,IAAI,EAAE,IAAA,gBAAI,EAAC,GAAG,IAAI,aAAa,CAAC;gBAChC,EAAE,EAAE,6BAA6B,IAAI,SAAS;gBAC9C,MAAM,EAAE,mBAAmB;gBAC3B,SAAS,EAAE,uBAAC,YAAI,IAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,eAAO,CAAC,CAAC,CAAC,iBAAS,GAAI;aACl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G,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>>;
|
|
@@ -18,9 +18,8 @@ const offsetByType = {
|
|
|
18
18
|
row: { alignmentAxis: -10 },
|
|
19
19
|
column: { alignmentAxis: -10 },
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
exports.FloatingPlusButton = (0, react_1.forwardRef)(function YfmTableFloatingPlusButton({ anchor, type, floatingStyles, ...btnProps }, ref) {
|
|
22
22
|
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FloatingPopup_1.FloatingPopup, { open: true, anchorElement: anchor, placement: placementByType[type], offset: offsetByType[type], style: styles, children: (0, jsx_runtime_1.jsx)(PlusButton_1.PlusButton, { ...btnProps, onHoverChange: setHovered, qa: `g-md-yfm-table-plus-${type}` }) }), hovered && (0, jsx_runtime_1.jsx)(InsertCursor_1.InsertCursor, { anchor: anchor, type: type })] }));
|
|
24
|
-
};
|
|
25
|
-
exports.FloatingPlusButton = FloatingPlusButton;
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FloatingPopup_1.FloatingPopup, { open: true, ref: ref, anchorElement: anchor, floatingStyles: floatingStyles, placement: placementByType[type], offset: offsetByType[type], style: styles, children: (0, jsx_runtime_1.jsx)(PlusButton_1.PlusButton, { ...btnProps, onHoverChange: setHovered, qa: `g-md-yfm-table-plus-${type}` }) }), hovered && (0, jsx_runtime_1.jsx)(InsertCursor_1.InsertCursor, { anchor: anchor, type: type })] }));
|
|
24
|
+
});
|
|
26
25
|
//# 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,
|
|
1
|
+
{"version":3,"file":"FloatingPlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2C;AAE3C,6DAA+F;AAE/F,oDAAoE;AACpE,gDAA8D;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;AAQW,QAAA,kBAAkB,GAAG,IAAA,kBAAU,EACxC,SAAS,0BAA0B,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAC,EAAE,GAAG;IAChF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,CACH,6DACI,uBAAC,6BAAa,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,uBAAC,uBAAU,OACH,QAAQ,EACZ,aAAa,EAAE,UAAU,EACzB,EAAE,EAAE,uBAAuB,IAAI,EAAE,GACnC,GACU,EACf,OAAO,IAAI,uBAAC,2BAAY,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 {};
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FloatingPlusControl = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const react_use_1 = require("react-use");
|
|
7
|
+
const use_raf_throttle_1 = require("../../hooks/use-raf-throttle.js");
|
|
6
8
|
const FloatingPlusButton_1 = require("../FloatingPlusButton/index.js");
|
|
7
9
|
exports.FloatingPlusControl = (0, react_1.memo)(function YfmTableRowFloatingPlusControl({ type, index, cellElem, tableElem, onClick }) {
|
|
8
10
|
const anchor = (0, react_1.useMemo)(() => ({
|
|
@@ -33,6 +35,39 @@ exports.FloatingPlusControl = (0, react_1.memo)(function YfmTableRowFloatingPlus
|
|
|
33
35
|
};
|
|
34
36
|
},
|
|
35
37
|
}), [cellElem, tableElem, type]);
|
|
36
|
-
|
|
38
|
+
const [visible, setVisible] = (0, react_1.useState)(() => shouldBeVisible(type, cellElem, tableElem));
|
|
39
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
40
|
+
const updateVisibility = () => {
|
|
41
|
+
const newVisible = shouldBeVisible(type, cellElem, tableElem);
|
|
42
|
+
if (visible !== newVisible)
|
|
43
|
+
setVisible(newVisible);
|
|
44
|
+
};
|
|
45
|
+
const onChange = (0, use_raf_throttle_1.useRafThrottle)(() => {
|
|
46
|
+
buttonRef.current?.forceUpdate();
|
|
47
|
+
updateVisibility();
|
|
48
|
+
});
|
|
49
|
+
// Update after first render
|
|
50
|
+
(0, react_use_1.useEffectOnce)(updateVisibility);
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
if (type !== 'column')
|
|
53
|
+
return undefined;
|
|
54
|
+
const observer = new ResizeObserver(onChange);
|
|
55
|
+
observer.observe(tableElem);
|
|
56
|
+
tableElem.addEventListener('scroll', onChange);
|
|
57
|
+
return () => {
|
|
58
|
+
observer.unobserve(tableElem);
|
|
59
|
+
tableElem.removeEventListener('scroll', onChange);
|
|
60
|
+
};
|
|
61
|
+
}, [tableElem, onChange, type]);
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(FloatingPlusButton_1.FloatingPlusButton, { ref: buttonRef, anchor: anchor, type: type, onClick: () => onClick(index), floatingStyles: visible ? undefined : { display: 'none' } }));
|
|
37
63
|
});
|
|
64
|
+
function shouldBeVisible(type, cellElem, tableElem) {
|
|
65
|
+
if (type !== 'column')
|
|
66
|
+
return true;
|
|
67
|
+
const THRESHOLD = 4; // px
|
|
68
|
+
const cellRect = cellElem.getBoundingClientRect();
|
|
69
|
+
const tableRect = tableElem.getBoundingClientRect();
|
|
70
|
+
return (tableRect.left - cellRect.right <= THRESHOLD &&
|
|
71
|
+
cellRect.right - tableRect.right <= THRESHOLD);
|
|
72
|
+
}
|
|
38
73
|
//# 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,
|
|
1
|
+
{"version":3,"file":"FloatingPlusControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.tsx"],"names":[],"mappings":";;;;AAAA,iCAAiE;AAIjE,yCAAwC;AAExC,sEAA4D;AAC5D,uEAI+B;AAYlB,QAAA,mBAAmB,GAAG,IAAA,YAAI,EACnC,SAAS,8BAA8B,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAC;IAC/E,MAAM,MAAM,GAAG,IAAA,eAAO,EAClB,GAAG,EAAE,CAAC,CAAC;QACH,cAAc,EAAE,SAAS;QACzB,qBAAqB;YACjB,MAAM,QAAQ,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAC;YAClD,MAAM,SAAS,GAAG,SAAS,CAA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SAAS,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;IAEpD,OAAO,CACH,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,IAAI,SAAS;QAC5C,QAAQ,CAAC,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>>;
|
|
@@ -13,29 +13,27 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
13
13
|
const classname_1 = require("../../../../../../../classname.js");
|
|
14
14
|
require("./FloatingPopup.css");
|
|
15
15
|
const b = (0, classname_1.cn)('yfm-table-floating-popup');
|
|
16
|
-
|
|
16
|
+
exports.FloatingPopup = (0, react_1.forwardRef)(function YfmTableFloatingPopup(props, ref) {
|
|
17
17
|
const { anchorElement, zIndex = 1000, style, className, qa, children, floatingStyles: floatingStylesFromProps, } = props;
|
|
18
18
|
const nodeId = (0, react_2.useFloatingNodeId)();
|
|
19
19
|
const parentId = (0, react_2.useFloatingParentNodeId)();
|
|
20
20
|
const middleware = (0, react_1.useMemo)(() => [(0, react_2.offset)(props.offset)], [props.offset]);
|
|
21
|
-
const { refs,
|
|
21
|
+
const { refs, floatingStyles, placement, context: { open }, update, } = (0, react_2.useFloating)({
|
|
22
22
|
nodeId,
|
|
23
23
|
open: props.open,
|
|
24
24
|
placement: props.placement,
|
|
25
25
|
middleware,
|
|
26
|
+
whileElementsMounted: react_2.autoUpdate,
|
|
26
27
|
});
|
|
28
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
29
|
+
forceUpdate: update,
|
|
30
|
+
}), [update]);
|
|
27
31
|
const { getFloatingProps } = (0, react_2.useInteractions)();
|
|
28
32
|
(0, react_1.useEffect)(() => {
|
|
29
33
|
if (anchorElement !== undefined && anchorElement !== refs.reference.current) {
|
|
30
34
|
refs.setReference(anchorElement);
|
|
31
35
|
}
|
|
32
36
|
}, [anchorElement, refs]);
|
|
33
|
-
(0, react_1.useEffect)(() => {
|
|
34
|
-
if (elements.reference && elements.floating) {
|
|
35
|
-
return (0, react_2.autoUpdate)(elements.reference, elements.floating, update);
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
}, [elements, update]);
|
|
39
37
|
function wrapper(node) {
|
|
40
38
|
if (parentId === null) {
|
|
41
39
|
return (0, jsx_runtime_1.jsx)(react_2.FloatingTree, { children: node });
|
|
@@ -53,6 +51,5 @@ const FloatingPopup = function YfmTableFloatingPopup(props) {
|
|
|
53
51
|
...floatingStylesFromProps,
|
|
54
52
|
...floatingStyles,
|
|
55
53
|
}, "data-floating-ui-placement": placement, ...getFloatingProps(), children: (0, jsx_runtime_1.jsx)("div", { className: b(null, className), style: style, "data-qa": qa, children: children }) }) })) : null }));
|
|
56
|
-
};
|
|
57
|
-
exports.FloatingPopup = FloatingPopup;
|
|
54
|
+
});
|
|
58
55
|
//# sourceMappingURL=FloatingPopup.js.map
|