@gravity-ui/markdown-editor 15.19.0 → 15.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/toolbar/ToolbarButtonWithPopupMenu.d.ts +2 -2
- package/build/cjs/bundle/toolbar/ToolbarButtonWithPopupMenu.js.map +1 -1
- package/build/cjs/bundle/toolbar/custom/ToolbarColors.js +1 -1
- package/build/cjs/bundle/toolbar/custom/ToolbarColors.js.map +1 -1
- package/build/cjs/bundle/wysiwyg-preset.js +5 -1
- package/build/cjs/bundle/wysiwyg-preset.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/schema.js +2 -3
- package/build/cjs/extensions/markdown/Lists/ListsSpecs/schema.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/index.d.ts +15 -1
- package/build/cjs/extensions/yfm/YfmTable/index.js +4 -2
- package/build/cjs/extensions/yfm/YfmTable/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js +5 -8
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/clear-cells.d.ts +7 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/clear-cells.js +41 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/clear-cells.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-column.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-column.js +59 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-column.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.js +54 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.js +77 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.js +74 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +10 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js +45 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.js +5 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.d.ts +15 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +67 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.js +5 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.d.ts +4 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js +26 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.js +68 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js +26 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/index.js +5 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/index.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.d.ts +9 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js +38 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/index.js +5 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/index.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.css +14 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.d.ts +13 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js +58 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/index.js +5 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/index.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/const.d.ts +13 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js +18 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.d.ts +36 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js +144 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.css +19 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.d.ts +31 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +467 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/index.d.ts +12 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/index.js +11 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/index.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.d.ts +6 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +288 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.css +4 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.d.ts +3 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.js +100 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.d.ts +23 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js +119 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.d.ts +17 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.js +158 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.js.map +1 -0
- package/build/cjs/i18n/yfm-table/en.json +3 -0
- package/build/cjs/i18n/yfm-table/index.d.ts +4 -1
- package/build/cjs/i18n/yfm-table/ru.json +3 -0
- package/build/cjs/icons/index.d.ts +2 -5
- package/build/cjs/icons/index.js +5 -8
- package/build/cjs/icons/index.js.map +1 -1
- package/build/cjs/lodash.d.ts +3 -1
- package/build/cjs/lodash.js +5 -1
- package/build/cjs/lodash.js.map +1 -1
- package/build/cjs/table-utils/table-desc.d.ts +50 -6
- package/build/cjs/table-utils/table-desc.js +196 -3
- package/build/cjs/table-utils/table-desc.js.map +1 -1
- package/build/cjs/toolbar/ToolbarButtonPopup.js +2 -2
- package/build/cjs/toolbar/ToolbarButtonPopup.js.map +1 -1
- package/build/cjs/toolbar/ToolbarListButton.js +1 -1
- package/build/cjs/toolbar/ToolbarListButton.js.map +1 -1
- package/build/cjs/version.js +1 -1
- package/build/cjs/version.js.map +1 -1
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/toolbar/ToolbarButtonWithPopupMenu.d.ts +2 -2
- package/build/esm/bundle/toolbar/ToolbarButtonWithPopupMenu.js.map +1 -1
- package/build/esm/bundle/toolbar/custom/ToolbarColors.js +1 -1
- package/build/esm/bundle/toolbar/custom/ToolbarColors.js.map +1 -1
- package/build/esm/bundle/wysiwyg-preset.js +5 -1
- package/build/esm/bundle/wysiwyg-preset.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/ListsSpecs/schema.js +2 -3
- package/build/esm/extensions/markdown/Lists/ListsSpecs/schema.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/index.d.ts +15 -1
- package/build/esm/extensions/yfm/YfmTable/index.js +4 -2
- package/build/esm/extensions/yfm/YfmTable/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.d.ts +7 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js +2 -6
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/clear-cells.d.ts +7 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/clear-cells.js +37 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/clear-cells.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-column.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-column.js +55 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-column.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.js +50 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.js +73 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.js +70 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +10 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js +41 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.js +2 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.d.ts +15 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +63 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.js +2 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.d.ts +4 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js +22 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.js +64 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js +22 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/PlusButton.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/index.js +2 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/index.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.d.ts +9 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js +35 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/index.js +2 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/index.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.css +14 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.d.ts +13 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js +54 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/index.js +2 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/index.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/const.d.ts +13 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js +15 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/const.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.d.ts +36 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js +139 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.css +19 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.d.ts +31 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +463 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/index.d.ts +12 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/index.js +7 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/index.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.d.ts +6 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +284 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.css +4 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.d.ts +3 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.js +96 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-view.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.d.ts +23 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js +108 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/dnd-plugin.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.d.ts +17 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.js +153 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.js.map +1 -0
- package/build/esm/i18n/yfm-table/en.json +3 -0
- package/build/esm/i18n/yfm-table/index.d.ts +4 -1
- package/build/esm/i18n/yfm-table/ru.json +3 -0
- package/build/esm/icons/index.d.ts +2 -5
- package/build/esm/icons/index.js +4 -7
- package/build/esm/icons/index.js.map +1 -1
- package/build/esm/lodash.d.ts +3 -1
- package/build/esm/lodash.js +3 -1
- package/build/esm/lodash.js.map +1 -1
- package/build/esm/table-utils/table-desc.d.ts +50 -6
- package/build/esm/table-utils/table-desc.js +196 -3
- package/build/esm/table-utils/table-desc.js.map +1 -1
- package/build/esm/toolbar/ToolbarButtonPopup.js +2 -2
- package/build/esm/toolbar/ToolbarButtonPopup.js.map +1 -1
- package/build/esm/toolbar/ToolbarListButton.js +1 -1
- package/build/esm/toolbar/ToolbarListButton.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/styles.css +31 -116
- package/package.json +2 -2
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/buttons.d.ts +0 -14
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/buttons.js +0 -97
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/buttons.js.map +0 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/view.css +0 -85
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/view.d.ts +0 -4
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/view.js +0 -62
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/view.js.map +0 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.css +0 -37
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.d.ts +0 -4
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.js +0 -212
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.js.map +0 -1
- package/build/cjs/icons/Mermaid.d.ts +0 -3
- package/build/cjs/icons/Mermaid.js +0 -11
- package/build/cjs/icons/Mermaid.js.map +0 -1
- package/build/cjs/icons/Mono.d.ts +0 -3
- package/build/cjs/icons/Mono.js +0 -6
- package/build/cjs/icons/Mono.js.map +0 -1
- package/build/cjs/icons/Tabs.d.ts +0 -3
- package/build/cjs/icons/Tabs.js +0 -6
- package/build/cjs/icons/Tabs.js.map +0 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/buttons.d.ts +0 -14
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/buttons.js +0 -95
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/buttons.js.map +0 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/view.css +0 -85
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/view.d.ts +0 -4
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/view.js +0 -58
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/view.js.map +0 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.css +0 -37
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.d.ts +0 -4
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.js +0 -208
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/yfmTableCellView.js.map +0 -1
- package/build/esm/icons/Mermaid.d.ts +0 -3
- package/build/esm/icons/Mermaid.js +0 -9
- package/build/esm/icons/Mermaid.js.map +0 -1
- package/build/esm/icons/Mono.d.ts +0 -3
- package/build/esm/icons/Mono.js +0 -4
- package/build/esm/icons/Mono.js.map +0 -1
- package/build/esm/icons/Tabs.d.ts +0 -3
- package/build/esm/icons/Tabs.js +0 -4
- package/build/esm/icons/Tabs.js.map +0 -1
package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertEmptyRow = void 0;
|
|
4
|
+
const state_1 = require("../../../../../../pm/state.js");
|
|
5
|
+
const lodash_1 = require("../../../../../../lodash.js");
|
|
6
|
+
const table_desc_1 = require("../../../../../../table-utils/table-desc.js");
|
|
7
|
+
const YfmTableSpecs_1 = require("../../../YfmTableSpecs/index.js");
|
|
8
|
+
const insertEmptyRow = (params) => {
|
|
9
|
+
return (state, dispatch) => {
|
|
10
|
+
const table = state.doc.nodeAt(params.tablePos);
|
|
11
|
+
const tableDesc = table && table_desc_1.TableDesc.create(table)?.bind(params.tablePos);
|
|
12
|
+
if (!tableDesc)
|
|
13
|
+
return false;
|
|
14
|
+
const rowIdx = Math.min(Math.max(params.rowIndex, 0), tableDesc.rows);
|
|
15
|
+
if (dispatch) {
|
|
16
|
+
let posToInsert;
|
|
17
|
+
let newCellsCount = tableDesc.cols;
|
|
18
|
+
const incrementRowspan = [];
|
|
19
|
+
if (rowIdx === 0 || rowIdx === tableDesc.rows) {
|
|
20
|
+
posToInsert =
|
|
21
|
+
rowIdx === 0
|
|
22
|
+
? tableDesc.getPosForRow(0).from
|
|
23
|
+
: tableDesc.getPosForRow(tableDesc.rows - 1).to;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
posToInsert = tableDesc.getPosForRow(rowIdx).from;
|
|
27
|
+
for (let colIdx = 0; colIdx < tableDesc.cols; colIdx++) {
|
|
28
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];
|
|
29
|
+
if (cell.type === 'virtual' && cell.rowspan) {
|
|
30
|
+
newCellsCount--;
|
|
31
|
+
incrementRowspan.push(cell.rowspan);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const { tr } = state;
|
|
36
|
+
for (const [rowIdx, colIdx] of (0, lodash_1.uniqWith)(incrementRowspan, lodash_1.isEqual)) {
|
|
37
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];
|
|
38
|
+
const cellPos = tableDesc.getPosForCell(rowIdx, colIdx);
|
|
39
|
+
tr.setNodeAttribute(cellPos.from, 'rowspan', cell.rowspan + 1);
|
|
40
|
+
}
|
|
41
|
+
tr.insert(posToInsert, createSimpleRow(state.schema, newCellsCount));
|
|
42
|
+
tr.setSelection(state_1.TextSelection.near(tr.doc.resolve(posToInsert), 1));
|
|
43
|
+
dispatch(tr.scrollIntoView());
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.insertEmptyRow = insertEmptyRow;
|
|
49
|
+
const createSimpleRow = (schema, cols) => {
|
|
50
|
+
const tr = (0, YfmTableSpecs_1.yfmTableRowType)(schema);
|
|
51
|
+
const td = (0, YfmTableSpecs_1.yfmTableCellType)(schema);
|
|
52
|
+
return tr.create(null, (0, lodash_1.range)(0, cols).map(() => td.createAndFill()));
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=insert-empty-row.js.map
|
package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-empty-row.js","sourceRoot":"../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/commands/insert-empty-row.ts"],"names":[],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,EAAE,GAAG,IAAA,+BAAe,EAAC,MAAM,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,IAAA,gCAAgB,EAAC,MAAM,CAAC,CAAC;IACpC,OAAO,EAAE,CAAC,MAAM,CACZ,IAAI,EACJ,IAAA,cAAK,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,aAAa,EAAG,CAAC,CAChD,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type {Schema} from '#pm/model';\nimport {type Command, TextSelection} from '#pm/state';\nimport {isEqual, range, uniqWith} from 'src/lodash';\nimport {type RealCellPos, type TableCellRealDesc, TableDesc} from 'src/table-utils/table-desc';\n\nimport {yfmTableCellType, yfmTableRowType} from '../../../YfmTableSpecs';\n\nexport type InsertEmptyRowParams = {\n tablePos: number;\n rowIndex: number;\n};\n\nexport const insertEmptyRow = (params: InsertEmptyRowParams): Command => {\n return (state, dispatch) => {\n const table = state.doc.nodeAt(params.tablePos);\n const tableDesc = table && TableDesc.create(table)?.bind(params.tablePos);\n if (!tableDesc) return false;\n\n const rowIdx = Math.min(Math.max(params.rowIndex, 0), tableDesc.rows);\n\n if (dispatch) {\n let posToInsert: number;\n let newCellsCount: number = tableDesc.cols;\n const incrementRowspan: [number, number][] = [];\n\n if (rowIdx === 0 || rowIdx === tableDesc.rows) {\n posToInsert =\n rowIdx === 0\n ? tableDesc.getPosForRow(0).from\n : tableDesc.getPosForRow(tableDesc.rows - 1).to;\n } else {\n posToInsert = tableDesc.getPosForRow(rowIdx).from;\n\n for (let colIdx = 0; colIdx < tableDesc.cols; colIdx++) {\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];\n if (cell.type === 'virtual' && cell.rowspan) {\n newCellsCount--;\n incrementRowspan.push(cell.rowspan);\n }\n }\n }\n\n const {tr} = state;\n for (const [rowIdx, colIdx] of uniqWith(incrementRowspan, isEqual)) {\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx] as TableCellRealDesc;\n const cellPos = tableDesc.getPosForCell(rowIdx, colIdx) as RealCellPos;\n tr.setNodeAttribute(cellPos.from, 'rowspan', cell.rowspan! + 1);\n }\n tr.insert(posToInsert, createSimpleRow(state.schema, newCellsCount));\n tr.setSelection(TextSelection.near(tr.doc.resolve(posToInsert), 1));\n dispatch(tr.scrollIntoView());\n }\n\n return true;\n };\n};\n\nconst createSimpleRow = (schema: Schema, cols: number) => {\n const tr = yfmTableRowType(schema);\n const td = yfmTableCellType(schema);\n return tr.create(\n null,\n range(0, cols).map(() => td.createAndFill()!),\n );\n};\n"]}
|
package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeColumnRange = void 0;
|
|
4
|
+
const model_1 = require("../../../../../../pm/model.js");
|
|
5
|
+
const table_desc_1 = require("../../../../../../table-utils/table-desc.js");
|
|
6
|
+
const utils_1 = require("../../../YfmTableSpecs/utils.js");
|
|
7
|
+
const removeColumnRange = (params) => {
|
|
8
|
+
return (state, dispatch) => {
|
|
9
|
+
const table = state.doc.nodeAt(params.tablePos);
|
|
10
|
+
const tableDesc = table && table_desc_1.TableDesc.create(table)?.bind(params.tablePos);
|
|
11
|
+
if (!tableDesc || tableDesc.cols < 2)
|
|
12
|
+
return false;
|
|
13
|
+
const range = tableDesc.base.getColumnRanges()[params.rangeIdx];
|
|
14
|
+
if (!range)
|
|
15
|
+
return false;
|
|
16
|
+
if (dispatch) {
|
|
17
|
+
const { tr } = state;
|
|
18
|
+
const diffColspan = {};
|
|
19
|
+
for (let rowIdx = 0; rowIdx < tableDesc.rows; rowIdx++) {
|
|
20
|
+
// calculate colspan diff for merged cells that end in this range
|
|
21
|
+
for (let colIdx = range.startIdx; colIdx <= range.endIdx; colIdx++) {
|
|
22
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];
|
|
23
|
+
if (cell.type === 'virtual' &&
|
|
24
|
+
cell.colspan?.[0] === rowIdx &&
|
|
25
|
+
cell.colspan[1] < range.startIdx) {
|
|
26
|
+
diffColspan[`${cell.colspan[0]},${cell.colspan[1]}`] ??= 0;
|
|
27
|
+
diffColspan[`${cell.colspan[0]},${cell.colspan[1]}`]--;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const from = getCellPos(tableDesc.getPosForCell(rowIdx, range.startIdx), 'start');
|
|
31
|
+
const to = getCellPos(tableDesc.getPosForCell(rowIdx, range.endIdx), 'end');
|
|
32
|
+
tr.replaceWith(tr.mapping.map(from), tr.mapping.map(to), model_1.Fragment.empty);
|
|
33
|
+
// insert new cells into the resulting gaps after current range
|
|
34
|
+
if (range.endIdx + 1 < tableDesc.cols) {
|
|
35
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[range.endIdx + 1];
|
|
36
|
+
if (cell.type === 'virtual' &&
|
|
37
|
+
cell.colspan?.[0] === rowIdx &&
|
|
38
|
+
cell.colspan[1] >= range.startIdx) {
|
|
39
|
+
const insertPos = tableDesc.getPosForCell(rowIdx, range.endIdx + 1).closestPos;
|
|
40
|
+
const realCell = tableDesc.base.rowsDesc[cell.colspan[0]].cells[cell.colspan[1]];
|
|
41
|
+
const newColspan = realCell.colspan - (range.endIdx + 1 - cell.colspan[1]);
|
|
42
|
+
tr.insert(tr.mapping.map(insertPos), (0, utils_1.yfmTableCellType)(state.schema).createAndFill({
|
|
43
|
+
colspan: newColspan > 1 ? newColspan : null,
|
|
44
|
+
rowspan: realCell.rowspan ? realCell.rowspan : null,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
updateColspan(tr, tableDesc, diffColspan);
|
|
50
|
+
dispatch(tr);
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.removeColumnRange = removeColumnRange;
|
|
56
|
+
function getCellPos(pos, dir) {
|
|
57
|
+
if (pos.type === 'virtual')
|
|
58
|
+
return pos.closestPos;
|
|
59
|
+
return dir === 'start' ? pos.from : pos.to;
|
|
60
|
+
}
|
|
61
|
+
function updateColspan(tr, tableDesc, diffMap) {
|
|
62
|
+
for (const key of keys(diffMap)) {
|
|
63
|
+
const [row, col] = key.split(',');
|
|
64
|
+
const rowIdx = Number.parseInt(row, 10);
|
|
65
|
+
const colIdx = Number.parseInt(col, 10);
|
|
66
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];
|
|
67
|
+
if (cell.type === 'real' && cell.colspan) {
|
|
68
|
+
const pos = tableDesc.getPosForCell(rowIdx, colIdx);
|
|
69
|
+
const newColspan = cell.colspan + diffMap[key];
|
|
70
|
+
tr.setNodeAttribute(tr.mapping.map(pos.from), 'colspan', newColspan > 1 ? newColspan : null);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function keys(obj) {
|
|
75
|
+
return Object.keys(obj);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=remove-column-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-column-range.js","sourceRoot":"../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-column-range.ts"],"names":[],"mappings":";;;AAAA,yDAAmC;AAEnC,4EAOoC;AAEpC,2DAA8D;AAOvD,MAAM,iBAAiB,GAAG,CAAC,MAA+B,EAAW,EAAE;IAC1E,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,KAAK,IAAI,sBAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1E,IAAI,CA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AAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,GAAG,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAgB,CAAC;YACnE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC/C,EAAE,CAAC,gBAAgB,CACf,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EACxB,SAAS,EACT,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACrC,CAAC;QACN,CAAC;IACL,CAAC;AACL,CAAC;AAED,SAAS,IAAI,CAAmB,GAAM;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAgB,CAAC;AAC3C,CAAC","sourcesContent":["import {Fragment} from '#pm/model';\nimport type {Command, Transaction} from '#pm/state';\nimport {\n type CellPos,\n type RealCellPos,\n type TableCellRealDesc,\n TableDesc,\n type TableDescBinded,\n type VirtualCellPos,\n} from 'src/table-utils/table-desc';\n\nimport {yfmTableCellType} from '../../../YfmTableSpecs/utils';\n\nexport type RemoveColumnRangeParams = {\n tablePos: number;\n rangeIdx: number;\n};\n\nexport const removeColumnRange = (params: RemoveColumnRangeParams): Command => {\n return (state, dispatch) => {\n const table = state.doc.nodeAt(params.tablePos);\n const tableDesc = table && TableDesc.create(table)?.bind(params.tablePos);\n if (!tableDesc || tableDesc.cols < 2) return false;\n\n const range = tableDesc.base.getColumnRanges()[params.rangeIdx];\n if (!range) return false;\n\n if (dispatch) {\n const {tr} = state;\n const diffColspan: Record<`${number},${number}`, number> = {};\n\n for (let rowIdx = 0; rowIdx < tableDesc.rows; rowIdx++) {\n // calculate colspan diff for merged cells that end in this range\n for (let colIdx = range.startIdx; colIdx <= range.endIdx; colIdx++) {\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];\n if (\n cell.type === 'virtual' &&\n cell.colspan?.[0] === rowIdx &&\n cell.colspan[1] < range.startIdx\n ) {\n diffColspan[`${cell.colspan[0]},${cell.colspan[1]}`] ??= 0;\n diffColspan[`${cell.colspan[0]},${cell.colspan[1]}`]--;\n }\n }\n\n const from = getCellPos(tableDesc.getPosForCell(rowIdx, range.startIdx), 'start');\n const to = getCellPos(tableDesc.getPosForCell(rowIdx, range.endIdx), 'end');\n tr.replaceWith(tr.mapping.map(from), tr.mapping.map(to), Fragment.empty);\n\n // insert new cells into the resulting gaps after current range\n if (range.endIdx + 1 < tableDesc.cols) {\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[range.endIdx + 1];\n if (\n cell.type === 'virtual' &&\n cell.colspan?.[0] === rowIdx &&\n cell.colspan[1] >= range.startIdx\n ) {\n const insertPos = (\n tableDesc.getPosForCell(rowIdx, range.endIdx + 1) as VirtualCellPos\n ).closestPos;\n const realCell = tableDesc.base.rowsDesc[cell.colspan[0]].cells[\n cell.colspan[1]\n ] as TableCellRealDesc;\n const newColspan = realCell.colspan! - (range.endIdx + 1 - cell.colspan[1]);\n tr.insert(\n tr.mapping.map(insertPos),\n yfmTableCellType(state.schema).createAndFill({\n colspan: newColspan > 1 ? newColspan : null,\n rowspan: realCell.rowspan ? realCell.rowspan : null,\n })!,\n );\n }\n }\n }\n\n updateColspan(tr, tableDesc, diffColspan);\n\n dispatch(tr);\n }\n\n return true;\n };\n};\n\nfunction getCellPos(pos: CellPos, dir: 'start' | 'end'): number {\n if (pos.type === 'virtual') return pos.closestPos;\n return dir === 'start' ? pos.from : pos.to;\n}\n\nfunction updateColspan(\n tr: Transaction,\n tableDesc: TableDescBinded,\n diffMap: Record<`${number},${number}`, number>,\n) {\n for (const key of keys(diffMap)) {\n const [row, col] = key.split(',');\n const rowIdx = Number.parseInt(row, 10);\n const colIdx = Number.parseInt(col, 10);\n\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];\n if (cell.type === 'real' && cell.colspan) {\n const pos = tableDesc.getPosForCell(rowIdx, colIdx) as RealCellPos;\n const newColspan = cell.colspan + diffMap[key];\n tr.setNodeAttribute(\n tr.mapping.map(pos.from),\n 'colspan',\n newColspan > 1 ? newColspan : null,\n );\n }\n }\n}\n\nfunction keys<O extends object>(obj: O): (keyof O)[] {\n return Object.keys(obj) as (keyof O)[];\n}\n"]}
|
package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeRowRange = void 0;
|
|
4
|
+
const model_1 = require("../../../../../../pm/model.js");
|
|
5
|
+
const table_desc_1 = require("../../../../../../table-utils/table-desc.js");
|
|
6
|
+
const utils_1 = require("../../../YfmTableSpecs/utils.js");
|
|
7
|
+
const removeRowRange = (params) => {
|
|
8
|
+
return (state, dispatch) => {
|
|
9
|
+
const table = state.doc.nodeAt(params.tablePos);
|
|
10
|
+
const tableDesc = table && table_desc_1.TableDesc.create(table)?.bind(params.tablePos);
|
|
11
|
+
if (!tableDesc || tableDesc.rows < 2)
|
|
12
|
+
return false;
|
|
13
|
+
const range = tableDesc.base.getRowRanges()[params.rangeIdx];
|
|
14
|
+
if (!range)
|
|
15
|
+
return false;
|
|
16
|
+
if (dispatch) {
|
|
17
|
+
const { tr } = state;
|
|
18
|
+
{
|
|
19
|
+
const from = tableDesc.getPosForRow(range.startIdx).from;
|
|
20
|
+
const to = tableDesc.getPosForRow(range.endIdx).to;
|
|
21
|
+
tr.replaceWith(from, to, model_1.Fragment.empty);
|
|
22
|
+
}
|
|
23
|
+
const diffRowspan = {};
|
|
24
|
+
for (let colIdx = 0; colIdx < tableDesc.cols; colIdx++) {
|
|
25
|
+
// calculate colspan diff for merged cells that end in this range
|
|
26
|
+
for (let rowIdx = range.startIdx; rowIdx <= range.endIdx; rowIdx++) {
|
|
27
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];
|
|
28
|
+
if (cell.type === 'virtual' &&
|
|
29
|
+
cell.rowspan?.[1] === colIdx &&
|
|
30
|
+
cell.rowspan[0] < range.startIdx) {
|
|
31
|
+
diffRowspan[`${cell.rowspan[0]},${cell.rowspan[1]}`] ??= 0;
|
|
32
|
+
diffRowspan[`${cell.rowspan[0]},${cell.rowspan[1]}`]--;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// insert new cells into the resulting gaps after current range
|
|
36
|
+
if (range.endIdx + 1 < tableDesc.rows) {
|
|
37
|
+
const cell = tableDesc.base.rowsDesc[range.endIdx + 1].cells[colIdx];
|
|
38
|
+
if (cell.type === 'virtual' &&
|
|
39
|
+
cell.rowspan?.[1] === colIdx &&
|
|
40
|
+
cell.rowspan[0] >= range.startIdx) {
|
|
41
|
+
const insertPos = tableDesc.getPosForCell(range.endIdx + 1, colIdx).closestPos;
|
|
42
|
+
const realCell = tableDesc.base.rowsDesc[cell.rowspan[0]].cells[cell.rowspan[1]];
|
|
43
|
+
const newRowspan = realCell.rowspan - (range.endIdx + 1 - cell.rowspan[0]);
|
|
44
|
+
tr.insert(tr.mapping.map(insertPos), (0, utils_1.yfmTableCellType)(state.schema).createAndFill({
|
|
45
|
+
rowspan: newRowspan > 1 ? newRowspan : null,
|
|
46
|
+
colspan: realCell.colspan ? realCell.colspan : null,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
updateRowspan(tr, tableDesc, diffRowspan);
|
|
52
|
+
dispatch(tr);
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.removeRowRange = removeRowRange;
|
|
58
|
+
function updateRowspan(tr, tableDesc, diffMap) {
|
|
59
|
+
for (const key of keys(diffMap)) {
|
|
60
|
+
const [row, col] = key.split(',');
|
|
61
|
+
const rowIdx = Number.parseInt(row, 10);
|
|
62
|
+
const colIdx = Number.parseInt(col, 10);
|
|
63
|
+
const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];
|
|
64
|
+
if (cell.type === 'real' && cell.rowspan) {
|
|
65
|
+
const pos = tableDesc.getPosForCell(rowIdx, colIdx);
|
|
66
|
+
const newRowspan = cell.rowspan + diffMap[key];
|
|
67
|
+
tr.setNodeAttribute(tr.mapping.map(pos.from), 'rowspan', newRowspan > 1 ? newRowspan : null);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function keys(obj) {
|
|
72
|
+
return Object.keys(obj);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=remove-row-range.js.map
|
package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-row-range.js","sourceRoot":"../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/commands/remove-row-range.ts"],"names":[],"mappings":";;;AAAA,yDAAmC;AAEnC,4EAMoC;AAEpC,2DAA8D;AAOvD,MAAM,cAAc,GAAG,CAAC,MAA4B,EAAW,EAAE;IACpE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,KAAK,IAAI,sBAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1E,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAEnD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK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AAG,CAAgB,CAAC;AAC3C,CAAC","sourcesContent":["import {Fragment} from '#pm/model';\nimport type {Command, Transaction} from '#pm/state';\nimport {\n type RealCellPos,\n type TableCellRealDesc,\n TableDesc,\n type TableDescBinded,\n type VirtualCellPos,\n} from 'src/table-utils/table-desc';\n\nimport {yfmTableCellType} from '../../../YfmTableSpecs/utils';\n\nexport type RemoveRowRangeParams = {\n tablePos: number;\n rangeIdx: number;\n};\n\nexport const removeRowRange = (params: RemoveRowRangeParams): Command => {\n return (state, dispatch) => {\n const table = state.doc.nodeAt(params.tablePos);\n const tableDesc = table && TableDesc.create(table)?.bind(params.tablePos);\n if (!tableDesc || tableDesc.rows < 2) return false;\n\n const range = tableDesc.base.getRowRanges()[params.rangeIdx];\n if (!range) return false;\n\n if (dispatch) {\n const {tr} = state;\n {\n const from = tableDesc.getPosForRow(range.startIdx).from;\n const to = tableDesc.getPosForRow(range.endIdx).to;\n tr.replaceWith(from, to, Fragment.empty);\n }\n\n const diffRowspan: Record<`${number},${number}`, number> = {};\n\n for (let colIdx = 0; colIdx < tableDesc.cols; colIdx++) {\n // calculate colspan diff for merged cells that end in this range\n for (let rowIdx = range.startIdx; rowIdx <= range.endIdx; rowIdx++) {\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];\n if (\n cell.type === 'virtual' &&\n cell.rowspan?.[1] === colIdx &&\n cell.rowspan[0] < range.startIdx\n ) {\n diffRowspan[`${cell.rowspan[0]},${cell.rowspan[1]}`] ??= 0;\n diffRowspan[`${cell.rowspan[0]},${cell.rowspan[1]}`]--;\n }\n }\n\n // insert new cells into the resulting gaps after current range\n if (range.endIdx + 1 < tableDesc.rows) {\n const cell = tableDesc.base.rowsDesc[range.endIdx + 1].cells[colIdx];\n if (\n cell.type === 'virtual' &&\n cell.rowspan?.[1] === colIdx &&\n cell.rowspan[0] >= range.startIdx\n ) {\n const insertPos = (\n tableDesc.getPosForCell(range.endIdx + 1, colIdx) as VirtualCellPos\n ).closestPos;\n const realCell = tableDesc.base.rowsDesc[cell.rowspan[0]].cells[\n cell.rowspan[1]\n ] as TableCellRealDesc;\n const newRowspan = realCell.rowspan! - (range.endIdx + 1 - cell.rowspan[0]);\n tr.insert(\n tr.mapping.map(insertPos),\n yfmTableCellType(state.schema).createAndFill({\n rowspan: newRowspan > 1 ? newRowspan : null,\n colspan: realCell.colspan ? realCell.colspan : null,\n })!,\n );\n }\n }\n }\n\n updateRowspan(tr, tableDesc, diffRowspan);\n\n dispatch(tr);\n }\n\n return true;\n };\n};\n\nfunction updateRowspan(\n tr: Transaction,\n tableDesc: TableDescBinded,\n diffMap: Record<`${number},${number}`, number>,\n) {\n for (const key of keys(diffMap)) {\n const [row, col] = key.split(',');\n const rowIdx = Number.parseInt(row, 10);\n const colIdx = Number.parseInt(col, 10);\n\n const cell = tableDesc.base.rowsDesc[rowIdx].cells[colIdx];\n if (cell.type === 'real' && cell.rowspan) {\n const pos = tableDesc.getPosForCell(rowIdx, colIdx) as RealCellPos;\n const newRowspan = cell.rowspan + diffMap[key];\n tr.setNodeAttribute(\n tr.mapping.map(pos.from),\n 'rowspan',\n newRowspan > 1 ? newRowspan : null,\n );\n }\n }\n}\nfunction keys<O extends object>(obj: O): (keyof O)[] {\n return Object.keys(obj) as (keyof O)[];\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ButtonButtonProps, type DropdownMenuProps } from '@gravity-ui/uikit';
|
|
2
|
+
export type FloatingMenuProps = {
|
|
3
|
+
dirtype: 'row' | 'column';
|
|
4
|
+
canDrag: boolean;
|
|
5
|
+
anchorElement: Element;
|
|
6
|
+
dropdownItems: DropdownMenuProps<unknown>['items'];
|
|
7
|
+
switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp'>;
|
|
8
|
+
onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;
|
|
9
|
+
};
|
|
10
|
+
export declare const FloatingMenu: React.FC<FloatingMenuProps>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FloatingMenu = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const icons_1 = require("@gravity-ui/icons");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const react_utils_1 = require("../../../../../../../react-utils/index.js");
|
|
9
|
+
const FloatingPopup_1 = require("../FloatingPopup/index.js");
|
|
10
|
+
const popupOffset = {
|
|
11
|
+
mainAxis: -9.5,
|
|
12
|
+
};
|
|
13
|
+
const FloatingMenu = function YfmTableFloatingMenu(props) {
|
|
14
|
+
const { dirtype, canDrag, anchorElement, dropdownItems, switcherMouseProps, onOpenToggle } = props;
|
|
15
|
+
const [isMenuOpened, setMenuOpened] = (0, react_1.useState)(false);
|
|
16
|
+
const [isHovered, setHovered, unsetHovered] = (0, react_utils_1.useBooleanState)(false);
|
|
17
|
+
const showActionView = isMenuOpened || isHovered;
|
|
18
|
+
const isRowType = dirtype === 'row';
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(FloatingPopup_1.FloatingPopup, { open: true, offset: popupOffset, anchorElement: anchorElement, placement: isRowType ? 'left' : 'top', floatingStyles: {
|
|
20
|
+
lineHeight: 'initial',
|
|
21
|
+
}, style: {
|
|
22
|
+
backgroundColor: 'transparent',
|
|
23
|
+
}, children: (0, jsx_runtime_1.jsx)(uikit_1.DropdownMenu, { onOpenToggle: (...args) => {
|
|
24
|
+
setMenuOpened(...args);
|
|
25
|
+
onOpenToggle(...args);
|
|
26
|
+
}, renderSwitcher: (switcherProps) => ((0, jsx_runtime_1.jsx)(uikit_1.Flex, { centerContent: true, width: 20, height: 20, style: {
|
|
27
|
+
borderRadius: 'var(--g-border-radius-xs)',
|
|
28
|
+
backgroundColor: showActionView
|
|
29
|
+
? 'var(--g-color-base-background)'
|
|
30
|
+
: undefined,
|
|
31
|
+
}, onMouseEnter: setHovered, onMouseLeave: unsetHovered, children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { style: {
|
|
32
|
+
cursor: canDrag ? 'grab' : undefined,
|
|
33
|
+
transform: isRowType ? 'rotate(90deg)' : undefined,
|
|
34
|
+
'--g-button-height': showActionView ? undefined : '5px',
|
|
35
|
+
'--_--background-color': showActionView
|
|
36
|
+
? undefined
|
|
37
|
+
: 'var(--g-color-base-background)',
|
|
38
|
+
}, view: isMenuOpened ? 'outlined-action' : 'outlined', pin: showActionView ? 'round-round' : 'circle-circle', size: "xs", qa: isRowType ? 'g-md-yfm-table-row-btn' : 'g-md-yfm-table-column-btn', ...switcherProps, ...switcherMouseProps, children: showActionView ? ((0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: canDrag ? icons_1.GripHorizontal : icons_1.Ellipsis })) : (String.fromCharCode(8194) // en space
|
|
39
|
+
) }) })), popupProps: {
|
|
40
|
+
zIndex: 1010,
|
|
41
|
+
placement: isRowType ? 'right-start' : 'bottom-start',
|
|
42
|
+
}, menuProps: { qa: `g-md-yfm-table-${dirtype}-menu` }, items: dropdownItems }) }));
|
|
43
|
+
};
|
|
44
|
+
exports.FloatingMenu = FloatingMenu;
|
|
45
|
+
//# sourceMappingURL=FloatingMenu.js.map
|
|
@@ -0,0 +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,6DAAwE;AAExE,MAAM,WAAW,GAAiC;IAC9C,QAAQ,EAAE,CAAC,GAAG;CACjB,CAAC;AAWK,MAAM,YAAY,GAAgC,SAAS,oBAAoB,CAAC,KAAK;IACxF,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,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,CAAC,SAAS;wBAClD,mBAAmB,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;wBACvD,uBAAuB,EAAE,cAAc;4BACnC,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,gCAAgC;qBACzC,EACD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,EACnD,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,EACrD,IAAI,EAAC,IAAI,EACT,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,2BAA2B,KAClE,aAAa,KACb,kBAAkB,YAErB,cAAc,CAAC,CAAC,CAAC,CACd,uBAAC,YAAI,IAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,sBAAU,CAAC,CAAC,CAAC,gBAAU,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;AA3EW,QAAA,YAAY,gBA2EvB","sourcesContent":["import {useState} from 'react';\n\nimport {Ellipsis as DotsColumn, GripHorizontal as GripColumn} from '@gravity-ui/icons';\nimport {\n Button,\n type ButtonButtonProps,\n DropdownMenu,\n type DropdownMenuProps,\n Flex,\n Icon,\n} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nimport {FloatingPopup, type FloatingPopupProps} from '../FloatingPopup';\n\nconst popupOffset: FloatingPopupProps['offset'] = {\n mainAxis: -9.5,\n};\n\nexport type FloatingMenuProps = {\n dirtype: 'row' | 'column';\n canDrag: boolean;\n anchorElement: Element;\n dropdownItems: DropdownMenuProps<unknown>['items'];\n switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp'>;\n onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;\n};\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = function YfmTableFloatingMenu(props) {\n const {dirtype, canDrag, anchorElement, dropdownItems, switcherMouseProps, onOpenToggle} =\n props;\n\n const [isMenuOpened, setMenuOpened] = useState(false);\n const [isHovered, setHovered, unsetHovered] = useBooleanState(false);\n\n const showActionView = isMenuOpened || isHovered;\n const isRowType = dirtype === 'row';\n\n return (\n <FloatingPopup\n open\n offset={popupOffset}\n anchorElement={anchorElement}\n placement={isRowType ? 'left' : 'top'}\n floatingStyles={{\n lineHeight: 'initial',\n }}\n style={{\n backgroundColor: 'transparent',\n }}\n >\n <DropdownMenu\n onOpenToggle={(...args) => {\n setMenuOpened(...args);\n onOpenToggle(...args);\n }}\n renderSwitcher={(switcherProps) => (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n style={{\n borderRadius: 'var(--g-border-radius-xs)',\n backgroundColor: showActionView\n ? 'var(--g-color-base-background)'\n : undefined,\n }}\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n >\n <Button\n style={{\n cursor: canDrag ? 'grab' : undefined,\n transform: isRowType ? 'rotate(90deg)' : undefined,\n '--g-button-height': showActionView ? undefined : '5px',\n '--_--background-color': showActionView\n ? undefined\n : 'var(--g-color-base-background)',\n }}\n view={isMenuOpened ? 'outlined-action' : 'outlined'}\n pin={showActionView ? 'round-round' : 'circle-circle'}\n size=\"xs\"\n qa={isRowType ? 'g-md-yfm-table-row-btn' : 'g-md-yfm-table-column-btn'}\n {...switcherProps}\n {...switcherMouseProps}\n >\n {showActionView ? (\n <Icon data={canDrag ? GripColumn : DotsColumn} />\n ) : (\n String.fromCharCode(8194) // en space\n )}\n </Button>\n </Flex>\n )}\n popupProps={{\n zIndex: 1010,\n placement: isRowType ? 'right-start' : 'bottom-start',\n }}\n menuProps={{qa: `g-md-yfm-table-${dirtype}-menu`}}\n items={dropdownItems}\n />\n </FloatingPopup>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FloatingMenu.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/index.ts"],"names":[],"mappings":";;;AAAA,4DAA+B","sourcesContent":["export * from './FloatingMenu';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DnDControlHandler } from "../../dnd/dnd.js";
|
|
2
|
+
import { type FloatingMenuProps } from "../FloatingMenu/FloatingMenu.js";
|
|
3
|
+
export type FloatingMenuControlProps = {
|
|
4
|
+
acnhorElement: Element;
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
type: FloatingMenuProps['dirtype'];
|
|
7
|
+
dndHandler?: DnDControlHandler;
|
|
8
|
+
onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];
|
|
9
|
+
onClearCellsClick: () => void;
|
|
10
|
+
onInsertBeforeClick: () => void;
|
|
11
|
+
onInsertAfterClick: () => void;
|
|
12
|
+
onRemoveRangeClick: () => void;
|
|
13
|
+
onRemoveTableClick: () => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const FloatingMenuControl: React.FC<FloatingMenuControlProps>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FloatingMenuControl = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const icons_1 = require("@gravity-ui/icons");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const yfm_table_1 = require("../../../../../../../i18n/yfm-table/index.js");
|
|
9
|
+
const FloatingMenu_1 = require("../FloatingMenu/FloatingMenu.js");
|
|
10
|
+
const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, acnhorElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
|
|
11
|
+
const dropdownItems = (0, react_1.useMemo)(() => [
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
text: (0, yfm_table_1.i18n)(`${type}.add.before`),
|
|
15
|
+
qa: `g-md-yfm-table-action-add-${type}-before`,
|
|
16
|
+
action: onInsertBeforeClick,
|
|
17
|
+
iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: type === 'row' ? icons_1.ArrowUp : icons_1.ArrowLeft }),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
text: (0, yfm_table_1.i18n)(`${type}.add.after`),
|
|
21
|
+
qa: `g-md-yfm-table-action-add-${type}-after`,
|
|
22
|
+
action: onInsertAfterClick,
|
|
23
|
+
iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: type === 'row' ? icons_1.ArrowDown : icons_1.ArrowRight }),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
{
|
|
28
|
+
text: (0, yfm_table_1.i18n)('cells.clear'),
|
|
29
|
+
qa: `g-md-yfm-table-${type}-clear-cells`,
|
|
30
|
+
action: onClearCellsClick,
|
|
31
|
+
iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.BroomMotion }),
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
{
|
|
36
|
+
text: (0, yfm_table_1.i18n)(`${type}.remove${multiple ? '.multiple' : ''}`),
|
|
37
|
+
qa: `g-md-yfm-table-action-remove-${type}`,
|
|
38
|
+
action: onRemoveRangeClick,
|
|
39
|
+
iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Xmark }),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
theme: 'danger',
|
|
43
|
+
text: (0, yfm_table_1.i18n)('table.remove'),
|
|
44
|
+
qa: 'g-md-yfm-table-action-remove-table',
|
|
45
|
+
action: onRemoveTableClick,
|
|
46
|
+
iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.TrashBin }),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
], [
|
|
50
|
+
type,
|
|
51
|
+
multiple,
|
|
52
|
+
onClearCellsClick,
|
|
53
|
+
onInsertAfterClick,
|
|
54
|
+
onInsertBeforeClick,
|
|
55
|
+
onRemoveRangeClick,
|
|
56
|
+
onRemoveTableClick,
|
|
57
|
+
]);
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(FloatingMenu_1.FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: acnhorElement, switcherMouseProps: dndHandler
|
|
59
|
+
? {
|
|
60
|
+
onMouseDown: dndHandler.control_handleMouseDown,
|
|
61
|
+
onMouseMove: dndHandler.control_handleMouseMove,
|
|
62
|
+
onMouseUp: dndHandler.control_handleMouseUp,
|
|
63
|
+
}
|
|
64
|
+
: undefined, dropdownItems: dropdownItems }));
|
|
65
|
+
};
|
|
66
|
+
exports.FloatingMenuControl = FloatingMenuControl;
|
|
67
|
+
//# sourceMappingURL=FloatingMenuControl.js.map
|
|
@@ -0,0 +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,MAA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AAE,aAAK,GAAI;aACnC;YACD;gBACI,KAAK,EAAE,QAAQ;gBACf,IAAI,EAAE,IAAA,gBAAI,EAAC,cAAc,CAAC;gBAC1B,EAAE,EAAE,oCAAoC;gBACxC,MAAM,EAAE,kBAAkB;gBAC1B,SAAS,EAAE,uBAAC,YAAI,IAAC,IAAI,EAAE,gBAAQ,GAAI;aACtC;SACJ;KACyC,EAClD;QACI,IAAI;QACJ,QAAQ;QACR,iBAAiB;QACjB,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,kBAAkB;KACrB,CACJ,CAAC;IAEF,OAAO,CACH,uBAAC,2BAAY,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,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;AAnFO,QAAA,mBAAmB,uBAmF1B","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 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FloatingMenuControl.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/index.ts"],"names":[],"mappings":";;;AAAA,mEAAsC","sourcesContent":["export * from './FloatingMenuControl';\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type InsertCursorProps } from "./InsertCursor.js";
|
|
2
|
+
import { type PlusButtonProps } from "./PlusButton.js";
|
|
3
|
+
export type FloatingPlusButtonProps = Pick<PlusButtonProps, 'onClick'> & Pick<InsertCursorProps, 'type' | 'anchor'>;
|
|
4
|
+
export declare const FloatingPlusButton: React.FC<FloatingPlusButtonProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FloatingPlusButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const FloatingPopup_1 = require("../FloatingPopup/index.js");
|
|
7
|
+
const InsertCursor_1 = require("./InsertCursor.js");
|
|
8
|
+
const PlusButton_1 = require("./PlusButton.js");
|
|
9
|
+
const styles = {
|
|
10
|
+
borderRadius: '100px', // button circle border radius
|
|
11
|
+
background: 'transparent',
|
|
12
|
+
};
|
|
13
|
+
const placementByType = {
|
|
14
|
+
row: 'left-end',
|
|
15
|
+
column: 'top-end',
|
|
16
|
+
};
|
|
17
|
+
const offsetByType = {
|
|
18
|
+
row: { alignmentAxis: -10 },
|
|
19
|
+
column: { alignmentAxis: -10 },
|
|
20
|
+
};
|
|
21
|
+
const FloatingPlusButton = function YfmTableFloatingPlusButton({ anchor, type, ...btnProps }) {
|
|
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;
|
|
26
|
+
//# sourceMappingURL=FloatingPlusButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloatingPlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.tsx"],"names":[],"mappings":";;;;AAAA,iCAA+B;AAE/B,6DAAwE;AAExE,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;AAKK,MAAM,kBAAkB,GAC3B,SAAS,0BAA0B,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAC;IAC3D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,CACH,6DACI,uBAAC,6BAAa,IACV,IAAI,QACJ,aAAa,EAAE,MAAM,EACrB,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,CAAC;AAtBO,QAAA,kBAAkB,sBAsBzB","sourcesContent":["import {useState} from 'react';\n\nimport {FloatingPopup, type FloatingPopupProps} 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 FloatingPlusButtonProps = Pick<PlusButtonProps, 'onClick'> &\n Pick<InsertCursorProps, 'type' | 'anchor'>;\n\nexport const FloatingPlusButton: React.FC<FloatingPlusButtonProps> =\n function YfmTableFloatingPlusButton({anchor, type, ...btnProps}) {\n const [hovered, setHovered] = useState(false);\n\n return (\n <>\n <FloatingPopup\n open\n anchorElement={anchor}\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"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsertCursor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
|
+
const dom_1 = require("@floating-ui/dom");
|
|
8
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
9
|
+
const react_use_1 = require("react-use");
|
|
10
|
+
const react_utils_1 = require("../../../../../../../react-utils/index.js");
|
|
11
|
+
const placementByType = {
|
|
12
|
+
row: 'bottom-start',
|
|
13
|
+
column: 'right-start',
|
|
14
|
+
};
|
|
15
|
+
const InsertCursor = function YfmTableInsertCursor({ type, anchor: referenceEl, }) {
|
|
16
|
+
const [floatingEl, setFloatingEl] = (0, react_utils_1.useElementState)();
|
|
17
|
+
const { width, height, updateRect } = useSize(type, () => referenceEl.getBoundingClientRect());
|
|
18
|
+
const widhtRef = (0, react_use_1.useLatest)(width);
|
|
19
|
+
const [floatingStyles, setFloatingStyles] = (0, react_1.useState)({ top: -9999, left: -9999 });
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
if (referenceEl && floatingEl) {
|
|
22
|
+
return (0, dom_1.autoUpdate)(referenceEl, floatingEl, () => {
|
|
23
|
+
updateRect(referenceEl.getBoundingClientRect());
|
|
24
|
+
(0, dom_1.computePosition)(referenceEl, floatingEl, {
|
|
25
|
+
placement: placementByType[type],
|
|
26
|
+
}).then(({ x, y }) => {
|
|
27
|
+
if (type === 'row')
|
|
28
|
+
setFloatingStyles({ left: x, top: y - 1 });
|
|
29
|
+
else
|
|
30
|
+
setFloatingStyles({ left: x - 1, top: y });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}, [referenceEl, floatingEl, widhtRef, type, updateRect]);
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(uikit_1.Portal, { children: (0, jsx_runtime_1.jsx)("div", { ref: setFloatingEl, style: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
zIndex: 1005,
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
pointerEvents: 'auto',
|
|
42
|
+
outline: 'none',
|
|
43
|
+
backgroundColor: 'var(--g-color-line-brand)',
|
|
44
|
+
...floatingStyles,
|
|
45
|
+
} }) }));
|
|
46
|
+
};
|
|
47
|
+
exports.InsertCursor = InsertCursor;
|
|
48
|
+
function useSize(type, getRect) {
|
|
49
|
+
const [size, setSize] = (0, react_1.useState)(() => getSize(type, getRect()));
|
|
50
|
+
const sizeRef = (0, react_use_1.useLatest)(size);
|
|
51
|
+
return {
|
|
52
|
+
width: size.width,
|
|
53
|
+
height: size.height,
|
|
54
|
+
updateRect: (0, react_1.useCallback)((rect) => {
|
|
55
|
+
const newSize = getSize(type, rect);
|
|
56
|
+
if (type === 'row' && newSize.width !== sizeRef.current.width)
|
|
57
|
+
setSize(newSize);
|
|
58
|
+
if (type === 'column' && newSize.height !== sizeRef.current.height)
|
|
59
|
+
setSize(newSize);
|
|
60
|
+
}, [sizeRef, type]),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function getSize(type, rect) {
|
|
64
|
+
if (type === 'row')
|
|
65
|
+
return { height: 2, width: rect.width };
|
|
66
|
+
return { width: 2, height: rect.height };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=InsertCursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InsertCursor.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/InsertCursor.tsx"],"names":[],"mappings":";;;;AAAA,iCAAuD;AAEvD,6DAA6D;AAC7D,0CAAoG;AACpG,6CAAyC;AACzC,yCAAoC;AAEpC,2EAAgD;AAEhD,MAAM,eAAe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;KACJ,CAAC;AACN,CAAC;AAED,SAAS,OAAO,CAAC,IAA+B,EAAE,IAAU;IACxD,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,EAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,CAAC;IAC1D,OAAO,EAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;AAC3C,CAAC","sourcesContent":["import {useCallback, useEffect, useState} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {type Placement, type ReferenceElement, autoUpdate, computePosition} from '@floating-ui/dom';\nimport {Portal} from '@gravity-ui/uikit';\nimport {useLatest} from 'react-use';\n\nimport {useElementState} from 'src/react-utils';\n\nconst placementByType: Record<InsertCursorProps['type'], Placement> = {\n row: 'bottom-start',\n column: 'right-start',\n};\n\nexport type InsertCursorProps = {\n anchor: ReferenceElement;\n type: 'row' | 'column';\n};\n\nexport const InsertCursor: React.FC<InsertCursorProps> = function YfmTableInsertCursor({\n type,\n anchor: referenceEl,\n}) {\n const [floatingEl, setFloatingEl] = useElementState();\n const {width, height, updateRect} = useSize(type, () => referenceEl.getBoundingClientRect());\n const widhtRef = useLatest(width);\n const [floatingStyles, setFloatingStyles] = useState({top: -9999, left: -9999});\n\n useEffect(() => {\n if (referenceEl && floatingEl) {\n return autoUpdate(referenceEl, floatingEl, () => {\n updateRect(referenceEl.getBoundingClientRect());\n\n computePosition(referenceEl, floatingEl, {\n placement: placementByType[type],\n }).then(({x, y}) => {\n if (type === 'row') setFloatingStyles({left: x, top: y - 1});\n else setFloatingStyles({left: x - 1, top: y});\n });\n });\n }\n return undefined;\n }, [referenceEl, floatingEl, widhtRef, type, updateRect]);\n\n return (\n <Portal>\n <div\n ref={setFloatingEl}\n style={{\n position: 'absolute',\n zIndex: 1005,\n width,\n height,\n pointerEvents: 'auto',\n outline: 'none',\n backgroundColor: 'var(--g-color-line-brand)',\n ...floatingStyles,\n }}\n />\n </Portal>\n );\n};\n\ntype Size = {\n width: number;\n height: number;\n};\n\nfunction useSize(type: InsertCursorProps['type'], getRect: () => Size) {\n const [size, setSize] = useState<Size>(() => getSize(type, getRect()));\n const sizeRef = useLatest(size);\n\n return {\n width: size.width,\n height: size.height,\n updateRect: useCallback(\n (rect: Size) => {\n const newSize = getSize(type, rect);\n if (type === 'row' && newSize.width !== sizeRef.current.width) setSize(newSize);\n if (type === 'column' && newSize.height !== sizeRef.current.height)\n setSize(newSize);\n },\n [sizeRef, type],\n ),\n };\n}\n\nfunction getSize(type: InsertCursorProps['type'], rect: Size): Size {\n if (type === 'row') return {height: 2, width: rect.width};\n return {width: 2, height: rect.height};\n}\n"]}
|