@gravity-ui/markdown-editor 15.19.1 → 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/wysiwyg-preset.js +5 -1
- package/build/cjs/bundle/wysiwyg-preset.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/wysiwyg-preset.js +5 -1
- package/build/esm/bundle/wysiwyg-preset.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 +1 -1
- 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
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { findParentNodeClosestToPos } from "../../../../../../pm/utils.js";
|
|
2
|
+
import { isTableCellNode, isTableNode } from "../../../../../../table-utils/index.js";
|
|
3
|
+
export class DropCursor {
|
|
4
|
+
editorView;
|
|
5
|
+
width;
|
|
6
|
+
color;
|
|
7
|
+
class;
|
|
8
|
+
cursorElem = null;
|
|
9
|
+
cursorPos = null;
|
|
10
|
+
constructor(editorView, params = {}) {
|
|
11
|
+
this.editorView = editorView;
|
|
12
|
+
this.width = params.width ?? 1;
|
|
13
|
+
this.color = params.color === false ? undefined : params.color || 'black';
|
|
14
|
+
this.class = params.class;
|
|
15
|
+
}
|
|
16
|
+
getPos() {
|
|
17
|
+
return this.cursorPos;
|
|
18
|
+
}
|
|
19
|
+
setPos(val) {
|
|
20
|
+
if (typeof val !== 'number' || isNaN(val))
|
|
21
|
+
throw new Error('"val" is not a number');
|
|
22
|
+
if (this.cursorPos === val)
|
|
23
|
+
return;
|
|
24
|
+
this.cursorPos = val;
|
|
25
|
+
this.update();
|
|
26
|
+
}
|
|
27
|
+
clear() {
|
|
28
|
+
this.cursorPos = null;
|
|
29
|
+
this.cursorElem?.remove();
|
|
30
|
+
this.cursorElem = null;
|
|
31
|
+
}
|
|
32
|
+
update() {
|
|
33
|
+
const { cursorPos } = this;
|
|
34
|
+
if (cursorPos === null)
|
|
35
|
+
return;
|
|
36
|
+
const $pos = this.editorView.state.doc.resolve(cursorPos);
|
|
37
|
+
const isBlock = !$pos.parent.inlineContent;
|
|
38
|
+
let rect;
|
|
39
|
+
if (isBlock) {
|
|
40
|
+
const before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
41
|
+
if (before || after) {
|
|
42
|
+
const node = this.editorView.nodeDOM(cursorPos - (before ? before.nodeSize : 0));
|
|
43
|
+
if (node) {
|
|
44
|
+
const nodeRect = node.getBoundingClientRect();
|
|
45
|
+
let top = before ? nodeRect.bottom : nodeRect.top;
|
|
46
|
+
if (before && after)
|
|
47
|
+
top =
|
|
48
|
+
(top +
|
|
49
|
+
this.editorView.nodeDOM(cursorPos).getBoundingClientRect().top) /
|
|
50
|
+
2;
|
|
51
|
+
rect = {
|
|
52
|
+
left: nodeRect.left,
|
|
53
|
+
right: nodeRect.right,
|
|
54
|
+
top: top - this.width / 2,
|
|
55
|
+
bottom: top + this.width / 2,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!rect) {
|
|
61
|
+
const coords = this.editorView.coordsAtPos(cursorPos);
|
|
62
|
+
rect = {
|
|
63
|
+
left: coords.left - this.width / 2,
|
|
64
|
+
right: coords.left + this.width / 2,
|
|
65
|
+
top: coords.top,
|
|
66
|
+
bottom: coords.bottom,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
this.render(rect, { isBlock });
|
|
70
|
+
}
|
|
71
|
+
render(rect, { isBlock }) {
|
|
72
|
+
const parent = this.editorView.dom.offsetParent;
|
|
73
|
+
if (!this.cursorElem) {
|
|
74
|
+
this.cursorElem = parent.appendChild(document.createElement('div'));
|
|
75
|
+
if (this.class)
|
|
76
|
+
this.cursorElem.className = this.class;
|
|
77
|
+
this.cursorElem.style.cssText =
|
|
78
|
+
'position: absolute; z-index: 50; pointer-events: none;';
|
|
79
|
+
if (this.color) {
|
|
80
|
+
this.cursorElem.style.backgroundColor = this.color;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.cursorElem.classList.toggle('prosemirror-dropcursor-block', isBlock);
|
|
84
|
+
this.cursorElem.classList.toggle('prosemirror-dropcursor-inline', !isBlock);
|
|
85
|
+
let parentLeft, parentTop;
|
|
86
|
+
if (!parent ||
|
|
87
|
+
(parent === document.body && getComputedStyle(parent).position === 'static')) {
|
|
88
|
+
parentLeft = -pageXOffset;
|
|
89
|
+
parentTop = -pageYOffset;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const rect = parent.getBoundingClientRect();
|
|
93
|
+
parentLeft = rect.left - parent.scrollLeft;
|
|
94
|
+
parentTop = rect.top - parent.scrollTop;
|
|
95
|
+
}
|
|
96
|
+
this.cursorElem.style.left = rect.left - parentLeft + 'px';
|
|
97
|
+
this.cursorElem.style.top = rect.top - parentTop + 'px';
|
|
98
|
+
this.cursorElem.style.width = rect.right - rect.left + 'px';
|
|
99
|
+
this.cursorElem.style.height = rect.bottom - rect.top + 'px';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export class TableColumnDropCursor extends DropCursor {
|
|
103
|
+
update() {
|
|
104
|
+
const cursorPos = this.getPos();
|
|
105
|
+
if (cursorPos === null)
|
|
106
|
+
return;
|
|
107
|
+
const $cursorPos = this.editorView.state.doc.resolve(cursorPos);
|
|
108
|
+
const parentTable = findParentNodeClosestToPos($cursorPos, isTableNode);
|
|
109
|
+
if (!parentTable)
|
|
110
|
+
return;
|
|
111
|
+
let side;
|
|
112
|
+
let tcellPos;
|
|
113
|
+
if ($cursorPos.nodeAfter && isTableCellNode($cursorPos.nodeAfter)) {
|
|
114
|
+
side = 'left';
|
|
115
|
+
tcellPos = cursorPos;
|
|
116
|
+
}
|
|
117
|
+
else if ($cursorPos.nodeBefore && isTableCellNode($cursorPos.nodeBefore)) {
|
|
118
|
+
side = 'right';
|
|
119
|
+
tcellPos = cursorPos - $cursorPos.nodeBefore.nodeSize;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.cursorElem?.remove();
|
|
123
|
+
this.cursorElem = null;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const tdElem = this.editorView.nodeDOM(tcellPos);
|
|
127
|
+
const tableElem = this.editorView.nodeDOM(parentTable.pos);
|
|
128
|
+
const tdRect = tdElem.getBoundingClientRect();
|
|
129
|
+
const tableRect = tableElem.getBoundingClientRect();
|
|
130
|
+
const rect = {
|
|
131
|
+
left: tdRect[side] - this.width / 2,
|
|
132
|
+
right: tdRect[side] + this.width / 2,
|
|
133
|
+
top: tableRect.top,
|
|
134
|
+
bottom: tableRect.bottom,
|
|
135
|
+
};
|
|
136
|
+
this.render(rect, { isBlock: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=dnd-drop-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dnd-drop-cursor.js","sourceRoot":"../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.ts"],"names":[],"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src/table-utils';\n\n/** Same as `DropCursorOptions` from _prosemirror-dropcursor_ package */\nexport type DropCursorParams = {\n /** The color of the cursor. Defaults to `black`. Use `false` to apply no color and rely only on class. */\n color?: string | false;\n\n /** The precise width of the cursor in pixels. Defaults to 1. */\n width?: number;\n\n /** A CSS class name to add to the cursor element. */\n class?: string;\n};\n\ntype Rect = {\n left: number;\n right: number;\n top: number;\n bottom: number;\n};\n\nexport class DropCursor {\n protected readonly editorView: EditorView;\n\n protected readonly width: number;\n protected readonly color: string | undefined;\n protected readonly class: string | undefined;\n\n protected cursorElem: HTMLElement | null = null;\n private cursorPos: number | null = null;\n\n constructor(editorView: EditorView, params: DropCursorParams = {}) {\n this.editorView = editorView;\n this.width = params.width ?? 1;\n this.color = params.color === false ? undefined : params.color || 'black';\n this.class = params.class;\n }\n\n getPos(): number | null {\n return this.cursorPos;\n }\n\n setPos(val: number) {\n if (typeof val !== 'number' || isNaN(val)) throw new Error('\"val\" is not a number');\n if (this.cursorPos === val) return;\n this.cursorPos = val;\n this.update();\n }\n\n clear() {\n this.cursorPos = null;\n this.cursorElem?.remove();\n this.cursorElem = null;\n }\n\n update() {\n const {cursorPos} = this;\n if (cursorPos === null) return;\n\n const $pos = this.editorView.state.doc.resolve(cursorPos);\n const isBlock = !$pos.parent.inlineContent;\n let rect: Rect | undefined;\n if (isBlock) {\n const before = $pos.nodeBefore,\n after = $pos.nodeAfter;\n if (before || after) {\n const node = this.editorView.nodeDOM(cursorPos - (before ? before.nodeSize : 0));\n if (node) {\n const nodeRect = (node as HTMLElement).getBoundingClientRect();\n let top = before ? nodeRect.bottom : nodeRect.top;\n if (before && after)\n top =\n (top +\n (\n this.editorView.nodeDOM(cursorPos) as HTMLElement\n ).getBoundingClientRect().top) /\n 2;\n rect = {\n left: nodeRect.left,\n right: nodeRect.right,\n top: top - this.width / 2,\n bottom: top + this.width / 2,\n };\n }\n }\n }\n if (!rect) {\n const coords = this.editorView.coordsAtPos(cursorPos);\n rect = {\n left: coords.left - this.width / 2,\n right: coords.left + this.width / 2,\n top: coords.top,\n bottom: coords.bottom,\n };\n }\n\n this.render(rect, {isBlock});\n }\n\n protected render(rect: Rect, {isBlock}: {isBlock: boolean}) {\n const parent = this.editorView.dom.offsetParent!;\n if (!this.cursorElem) {\n this.cursorElem = parent.appendChild(document.createElement('div'));\n if (this.class) this.cursorElem.className = this.class;\n this.cursorElem.style.cssText =\n 'position: absolute; z-index: 50; pointer-events: none;';\n if (this.color) {\n this.cursorElem.style.backgroundColor = this.color;\n }\n }\n this.cursorElem.classList.toggle('prosemirror-dropcursor-block', isBlock);\n this.cursorElem.classList.toggle('prosemirror-dropcursor-inline', !isBlock);\n let parentLeft, parentTop;\n if (\n !parent ||\n (parent === document.body && getComputedStyle(parent).position === 'static')\n ) {\n parentLeft = -pageXOffset;\n parentTop = -pageYOffset;\n } else {\n const rect = parent.getBoundingClientRect();\n parentLeft = rect.left - parent.scrollLeft;\n parentTop = rect.top - parent.scrollTop;\n }\n this.cursorElem.style.left = rect.left - parentLeft + 'px';\n this.cursorElem.style.top = rect.top - parentTop + 'px';\n this.cursorElem.style.width = rect.right - rect.left + 'px';\n this.cursorElem.style.height = rect.bottom - rect.top + 'px';\n }\n}\n\nexport class TableColumnDropCursor extends DropCursor {\n update() {\n const cursorPos = this.getPos();\n if (cursorPos === null) return;\n\n const $cursorPos = this.editorView.state.doc.resolve(cursorPos);\n const parentTable = findParentNodeClosestToPos($cursorPos, isTableNode);\n if (!parentTable) return;\n\n let side: 'left' | 'right';\n let tcellPos: number;\n if ($cursorPos.nodeAfter && isTableCellNode($cursorPos.nodeAfter)) {\n side = 'left';\n tcellPos = cursorPos;\n } else if ($cursorPos.nodeBefore && isTableCellNode($cursorPos.nodeBefore)) {\n side = 'right';\n tcellPos = cursorPos - $cursorPos.nodeBefore.nodeSize;\n } else {\n this.cursorElem?.remove();\n this.cursorElem = null;\n return;\n }\n\n const tdElem = this.editorView.nodeDOM(tcellPos);\n const tableElem = this.editorView.nodeDOM(parentTable.pos);\n\n const tdRect = (tdElem as HTMLElement).getBoundingClientRect();\n const tableRect = (tableElem as HTMLElement).getBoundingClientRect();\n\n const rect: Rect = {\n left: tdRect[side] - this.width / 2,\n right: tdRect[side] + this.width / 2,\n top: tableRect.top,\n bottom: tableRect.bottom,\n };\n this.render(rect, {isBlock: true});\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.g-md-yfm-table-dnd-cursor-background {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 100500;
|
|
4
|
+
inset: 0;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
cursor: grabbing;
|
|
7
|
+
background: transparent;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.yfm.ProseMirror .g-md-yfm-table-dnd-dragged-row,
|
|
11
|
+
.yfm.ProseMirror .g-md-yfm-table-dnd-dragged-column-cell {
|
|
12
|
+
opacity: 0.3;
|
|
13
|
+
background-color: var(--g-color-base-selection);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.yfm.ProseMirror .g-md-yfm-table-active-row,
|
|
17
|
+
.yfm.ProseMirror .g-md-yfm-table-active-column-cell {
|
|
18
|
+
background-color: var(--g-color-base-selection);
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Node } from "../../../../../../pm/model.js";
|
|
2
|
+
import type { EditorView } from "../../../../../../pm/view.js";
|
|
3
|
+
import type { Logger2 } from "../../../../../../logger.js";
|
|
4
|
+
import { type DropCursorParams } from "./dnd-drop-cursor.js";
|
|
5
|
+
import "./dnd.css";
|
|
6
|
+
export type DnDControlHandler = {
|
|
7
|
+
canDrag(): boolean;
|
|
8
|
+
control_handleMouseDown: React.MouseEventHandler<HTMLButtonElement>;
|
|
9
|
+
control_handleMouseMove: React.MouseEventHandler<HTMLButtonElement>;
|
|
10
|
+
control_handleMouseUp: React.MouseEventHandler<HTMLButtonElement>;
|
|
11
|
+
};
|
|
12
|
+
interface TableHandler {
|
|
13
|
+
update(node: Node): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
16
|
+
export type YfmTableDnDHandlerParams = {
|
|
17
|
+
cellNode: Node;
|
|
18
|
+
cellGetPos: () => number | undefined;
|
|
19
|
+
logger: Logger2.ILogger;
|
|
20
|
+
dropCursor?: DropCursorParams;
|
|
21
|
+
};
|
|
22
|
+
export declare class YfmTableDnDHandler implements TableHandler {
|
|
23
|
+
private readonly _rowHandler;
|
|
24
|
+
private readonly _columnHandler;
|
|
25
|
+
get row(): DnDControlHandler;
|
|
26
|
+
get column(): DnDControlHandler;
|
|
27
|
+
constructor(view: EditorView, params: YfmTableDnDHandlerParams);
|
|
28
|
+
update(node: Node): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { Slice } from "../../../../../../pm/model.js";
|
|
2
|
+
import { TextSelection } from "../../../../../../pm/state.js";
|
|
3
|
+
import { findParentNodeClosestToPos } from "../../../../../../pm/utils.js";
|
|
4
|
+
import { debounce, range as iterate } from "../../../../../../lodash.js";
|
|
5
|
+
import { isTableNode } from "../../../../../../table-utils/index.js";
|
|
6
|
+
import { TableDesc, } from "../../../../../../table-utils/table-desc.js";
|
|
7
|
+
import { YfmTableNode } from "../../../YfmTableSpecs/index.js";
|
|
8
|
+
import { clearAllSelections, selectDraggedColumn, selectDraggedRow } from "../plugins/dnd-plugin.js";
|
|
9
|
+
import { hideHoverDecos } from "../plugins/focus-plugin.js";
|
|
10
|
+
import { DropCursor as RowDropCursor, TableColumnDropCursor, } from "./dnd-drop-cursor.js";
|
|
11
|
+
import "./dnd.css";
|
|
12
|
+
const MOUSE_MOVE_DEBOUNCE = 100; // ms
|
|
13
|
+
const DRAG_START_THRESHOLD = 4; // px
|
|
14
|
+
export class YfmTableDnDHandler {
|
|
15
|
+
_rowHandler;
|
|
16
|
+
_columnHandler;
|
|
17
|
+
get row() {
|
|
18
|
+
return this._rowHandler;
|
|
19
|
+
}
|
|
20
|
+
get column() {
|
|
21
|
+
return this._columnHandler;
|
|
22
|
+
}
|
|
23
|
+
constructor(view, params) {
|
|
24
|
+
this._rowHandler = new YfmTableRowDnDHandler(view, params);
|
|
25
|
+
this._columnHandler = new YfmTableColumnDnDHandler(view, params);
|
|
26
|
+
}
|
|
27
|
+
update(node) {
|
|
28
|
+
this._rowHandler.update(node);
|
|
29
|
+
this._columnHandler.update(node);
|
|
30
|
+
}
|
|
31
|
+
destroy() {
|
|
32
|
+
this._rowHandler.destroy();
|
|
33
|
+
this._columnHandler.destroy();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class YfmTableDnDAbstractHandler {
|
|
37
|
+
_cellGetPos;
|
|
38
|
+
_editorView;
|
|
39
|
+
_logger;
|
|
40
|
+
_dropCursor;
|
|
41
|
+
__cellNode;
|
|
42
|
+
__dragging = false;
|
|
43
|
+
__destroyed = false;
|
|
44
|
+
__dragMouseDown = false;
|
|
45
|
+
constructor(view, params) {
|
|
46
|
+
this._editorView = view;
|
|
47
|
+
this.__cellNode = params.cellNode;
|
|
48
|
+
this._cellGetPos = params.cellGetPos;
|
|
49
|
+
this._logger = params.logger;
|
|
50
|
+
this._dropCursor = params.dropCursor;
|
|
51
|
+
}
|
|
52
|
+
update(cellnode) {
|
|
53
|
+
this.__cellNode = cellnode;
|
|
54
|
+
}
|
|
55
|
+
destroy() {
|
|
56
|
+
this.__destroyed = true;
|
|
57
|
+
this._clearDragging();
|
|
58
|
+
}
|
|
59
|
+
control_handleMouseDown = (event) => {
|
|
60
|
+
this.__dragMouseDown = { pageX: event.pageX, pageY: event.pageY };
|
|
61
|
+
this._dropCursor.clear();
|
|
62
|
+
};
|
|
63
|
+
control_handleMouseUp = () => {
|
|
64
|
+
this.__dragMouseDown = false;
|
|
65
|
+
};
|
|
66
|
+
control_handleMouseMove = (event) => {
|
|
67
|
+
if (!this._dragMouseDown || !isDragThresholdPassed(this._dragMouseDown, event))
|
|
68
|
+
return;
|
|
69
|
+
if (this._editorView.dragging || this._dragging)
|
|
70
|
+
return;
|
|
71
|
+
this._startDragging();
|
|
72
|
+
};
|
|
73
|
+
get _cellNode() {
|
|
74
|
+
return this.__cellNode;
|
|
75
|
+
}
|
|
76
|
+
get _dragging() {
|
|
77
|
+
return this.__dragging;
|
|
78
|
+
}
|
|
79
|
+
set _dragging(val) {
|
|
80
|
+
this.__dragging = val;
|
|
81
|
+
}
|
|
82
|
+
get _destroyed() {
|
|
83
|
+
return this.__destroyed;
|
|
84
|
+
}
|
|
85
|
+
get _dragMouseDown() {
|
|
86
|
+
return this.__dragMouseDown;
|
|
87
|
+
}
|
|
88
|
+
_getTableDescAndCellInfo() {
|
|
89
|
+
const tcellPos = this._cellGetPos();
|
|
90
|
+
const tableNode = tcellPos === undefined
|
|
91
|
+
? undefined
|
|
92
|
+
: findParentNodeClosestToPos(this._editorView.state.doc.resolve(tcellPos), isTableNode);
|
|
93
|
+
const tableDesc = tableNode && TableDesc.create(tableNode.node)?.bind(tableNode.pos);
|
|
94
|
+
const cellInfo = tableDesc?.base.getCellInfo(this._cellNode);
|
|
95
|
+
return cellInfo
|
|
96
|
+
? {
|
|
97
|
+
cellPos: tcellPos,
|
|
98
|
+
table: tableNode,
|
|
99
|
+
tableDesc: tableDesc,
|
|
100
|
+
cellInfo,
|
|
101
|
+
}
|
|
102
|
+
: null;
|
|
103
|
+
}
|
|
104
|
+
_clearDragging() {
|
|
105
|
+
this.__dragging = false;
|
|
106
|
+
this.__dragMouseDown = false;
|
|
107
|
+
this._dropCursor.clear();
|
|
108
|
+
this._editorView.dragging = null;
|
|
109
|
+
this._editorView.dispatch(clearAllSelections(this._editorView.state.tr));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
class YfmTableRowDnDHandler extends YfmTableDnDAbstractHandler {
|
|
113
|
+
constructor(view, params) {
|
|
114
|
+
super(view, {
|
|
115
|
+
...params,
|
|
116
|
+
logger: params.logger.nested({ component: 'row-dnd-handler' }),
|
|
117
|
+
dropCursor: new RowDropCursor(view, params.dropCursor),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
canDrag() {
|
|
121
|
+
const res = this._getTableDescAndCellInfo();
|
|
122
|
+
if (!res)
|
|
123
|
+
return false;
|
|
124
|
+
const rowRange = res.tableDesc.base.getRowRangeByRowIdx(res.cellInfo.row);
|
|
125
|
+
return rowRange.safeTopBoundary && rowRange.safeBottomBoundary;
|
|
126
|
+
}
|
|
127
|
+
_startDragging = () => {
|
|
128
|
+
const info = this._getTableDescAndCellInfo();
|
|
129
|
+
if (!info)
|
|
130
|
+
return;
|
|
131
|
+
const { tableDesc, cellInfo } = info;
|
|
132
|
+
const rowRanges = tableDesc.base.getRowRanges();
|
|
133
|
+
const currRowRange = tableDesc.base.getRowRangeByRowIdx(cellInfo.row);
|
|
134
|
+
if (!currRowRange.safeTopBoundary || !currRowRange.safeBottomBoundary)
|
|
135
|
+
return;
|
|
136
|
+
this._dragging = true;
|
|
137
|
+
this._logger.event({ event: 'row-drag-start' });
|
|
138
|
+
{
|
|
139
|
+
const { tr } = this._editorView.state;
|
|
140
|
+
hideHoverDecos(tr);
|
|
141
|
+
selectDraggedRow(tr, iterate(currRowRange.startIdx, currRowRange.endIdx + 1).map((rowIdx) => tableDesc.getPosForRow(rowIdx)));
|
|
142
|
+
this._editorView.dispatch(tr);
|
|
143
|
+
}
|
|
144
|
+
{
|
|
145
|
+
const from = tableDesc.getPosForRow(currRowRange.startIdx).from;
|
|
146
|
+
const to = tableDesc.getPosForRow(currRowRange.endIdx).to;
|
|
147
|
+
this._editorView.dragging = {
|
|
148
|
+
move: true,
|
|
149
|
+
slice: this._editorView.state.doc.slice(from, to, false),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const dndBackground = document.createElement('div');
|
|
153
|
+
dndBackground.classList.add('g-md-yfm-table-dnd-cursor-background');
|
|
154
|
+
document.body.append(dndBackground);
|
|
155
|
+
const draggedRangeIdx = rowRanges.indexOf(currRowRange);
|
|
156
|
+
const onMove = debounce((event) => {
|
|
157
|
+
this._moveDragging(event, {
|
|
158
|
+
rangeIdx: draggedRangeIdx,
|
|
159
|
+
tableDesc,
|
|
160
|
+
});
|
|
161
|
+
}, MOUSE_MOVE_DEBOUNCE, { maxWait: MOUSE_MOVE_DEBOUNCE });
|
|
162
|
+
document.addEventListener('mousemove', onMove);
|
|
163
|
+
document.addEventListener('mouseup', () => {
|
|
164
|
+
onMove.flush();
|
|
165
|
+
dndBackground.remove();
|
|
166
|
+
document.removeEventListener('mousemove', onMove);
|
|
167
|
+
this._endDragging(currRowRange, tableDesc);
|
|
168
|
+
}, { once: true });
|
|
169
|
+
};
|
|
170
|
+
_moveDragging(event, { rangeIdx, tableDesc: initialTableDesc, }) {
|
|
171
|
+
if (this._destroyed || !this._dragging)
|
|
172
|
+
return;
|
|
173
|
+
const info = this._getTableDescAndCellInfo();
|
|
174
|
+
if (!info || info.tableDesc.base !== initialTableDesc.base) {
|
|
175
|
+
this._clearDragging();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const { tableDesc } = info;
|
|
179
|
+
const ranges = tableDesc.base.getRowRanges();
|
|
180
|
+
const boxes = ranges.map((range) => {
|
|
181
|
+
const firstRowStartPos = tableDesc.getPosForRow(range.startIdx).from;
|
|
182
|
+
const lastRowPos = tableDesc.getPosForRow(range.endIdx);
|
|
183
|
+
const lastRowStartPos = lastRowPos.from;
|
|
184
|
+
const lastRowEndPos = lastRowPos.to;
|
|
185
|
+
const firstRowElem = this._editorView.domAtPos(firstRowStartPos + 1).node;
|
|
186
|
+
const firstRowBox = firstRowElem.getBoundingClientRect();
|
|
187
|
+
const lastRowElem = this._editorView.domAtPos(lastRowStartPos + 1).node;
|
|
188
|
+
const lastRowBox = lastRowElem.getBoundingClientRect();
|
|
189
|
+
return {
|
|
190
|
+
pos: { from: firstRowStartPos, to: lastRowEndPos },
|
|
191
|
+
rect: {
|
|
192
|
+
top: firstRowBox.top,
|
|
193
|
+
bottom: lastRowBox.bottom,
|
|
194
|
+
},
|
|
195
|
+
safeTopBoundary: range.safeTopBoundary,
|
|
196
|
+
safeBottomBoundary: range.safeBottomBoundary,
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
const pos = (() => {
|
|
200
|
+
const { clientY } = event;
|
|
201
|
+
const draggedRangeBox = boxes[rangeIdx];
|
|
202
|
+
const isDraggedFirst = rangeIdx === 0;
|
|
203
|
+
const isDraggedLast = rangeIdx === boxes.length - 1;
|
|
204
|
+
if (!isDraggedFirst && clientY < draggedRangeBox.rect.top) {
|
|
205
|
+
for (const box of boxes.slice(0, rangeIdx).reverse()) {
|
|
206
|
+
if (clientY < box.rect.top)
|
|
207
|
+
continue;
|
|
208
|
+
if (!box.safeTopBoundary)
|
|
209
|
+
continue;
|
|
210
|
+
return box.pos.from;
|
|
211
|
+
}
|
|
212
|
+
return boxes[0].pos.from;
|
|
213
|
+
}
|
|
214
|
+
if (!isDraggedLast && clientY > draggedRangeBox.rect.bottom) {
|
|
215
|
+
for (const box of boxes.slice(rangeIdx + 1)) {
|
|
216
|
+
if (clientY > box.rect.bottom)
|
|
217
|
+
continue;
|
|
218
|
+
if (!box.safeBottomBoundary)
|
|
219
|
+
continue;
|
|
220
|
+
return box.pos.to;
|
|
221
|
+
}
|
|
222
|
+
return boxes.at(-1).pos.to;
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
})();
|
|
226
|
+
if (typeof pos === 'number')
|
|
227
|
+
this._dropCursor.setPos(pos);
|
|
228
|
+
else
|
|
229
|
+
this._dropCursor.clear();
|
|
230
|
+
}
|
|
231
|
+
_endDragging(draggedRange, initialTableDesc) {
|
|
232
|
+
if (this._destroyed || !this._dragging)
|
|
233
|
+
return;
|
|
234
|
+
const point = this._dropCursor.getPos();
|
|
235
|
+
this._clearDragging();
|
|
236
|
+
this._logger.event({ event: 'row-drag-end' });
|
|
237
|
+
if (point === null) {
|
|
238
|
+
this._editorView.focus();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const info = this._getTableDescAndCellInfo();
|
|
242
|
+
if (!info || info.tableDesc.base !== initialTableDesc.base) {
|
|
243
|
+
this._editorView.focus();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const rangeFrom = info.tableDesc.getPosForRow(draggedRange.startIdx).from;
|
|
247
|
+
const rangeTo = info.tableDesc.getPosForRow(draggedRange.endIdx).to;
|
|
248
|
+
if (point === rangeFrom || point === rangeTo) {
|
|
249
|
+
this._editorView.focus();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const { tr } = this._editorView.state;
|
|
253
|
+
const fragment = tr.doc.slice(rangeFrom, rangeTo, false).content;
|
|
254
|
+
if (point > rangeFrom) {
|
|
255
|
+
tr.insert(point, fragment);
|
|
256
|
+
tr.delete(rangeFrom, rangeTo);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
tr.delete(rangeFrom, rangeTo);
|
|
260
|
+
tr.insert(point, fragment);
|
|
261
|
+
}
|
|
262
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(tr.mapping.map(point + 1)), 1));
|
|
263
|
+
tr.scrollIntoView();
|
|
264
|
+
this._editorView.dispatch(tr);
|
|
265
|
+
this._editorView.focus();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
class YfmTableColumnDnDHandler extends YfmTableDnDAbstractHandler {
|
|
269
|
+
constructor(view, params) {
|
|
270
|
+
super(view, {
|
|
271
|
+
...params,
|
|
272
|
+
logger: params.logger.nested({ component: 'column-dnd-handler' }),
|
|
273
|
+
dropCursor: new TableColumnDropCursor(view, params.dropCursor),
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
canDrag() {
|
|
277
|
+
const res = this._getTableDescAndCellInfo();
|
|
278
|
+
if (!res)
|
|
279
|
+
return false;
|
|
280
|
+
const rowRange = res.tableDesc.base.getColumnRangeByColumnIdx(res.cellInfo.column);
|
|
281
|
+
return rowRange.safeLeftBoundary && rowRange.safeRightBoundary;
|
|
282
|
+
}
|
|
283
|
+
_startDragging() {
|
|
284
|
+
const info = this._getTableDescAndCellInfo();
|
|
285
|
+
if (!info)
|
|
286
|
+
return;
|
|
287
|
+
const { tableDesc, cellInfo } = info;
|
|
288
|
+
const columnRanges = tableDesc.base.getColumnRanges();
|
|
289
|
+
const currColumnRange = tableDesc.base.getColumnRangeByColumnIdx(cellInfo.column);
|
|
290
|
+
if (!currColumnRange.safeLeftBoundary || !currColumnRange.safeRightBoundary)
|
|
291
|
+
return;
|
|
292
|
+
this._dragging = true;
|
|
293
|
+
this._logger.event({ event: 'column-drag-start' });
|
|
294
|
+
{
|
|
295
|
+
const columnCellsPos = [];
|
|
296
|
+
for (const i of iterate(currColumnRange.startIdx, currColumnRange.endIdx + 1)) {
|
|
297
|
+
columnCellsPos.push(...tableDesc.getPosForColumn(i));
|
|
298
|
+
}
|
|
299
|
+
const realPos = columnCellsPos.filter((cell) => cell.type === 'real');
|
|
300
|
+
const { tr } = this._editorView.state;
|
|
301
|
+
hideHoverDecos(tr);
|
|
302
|
+
selectDraggedColumn(tr, realPos);
|
|
303
|
+
this._editorView.dispatch(tr);
|
|
304
|
+
}
|
|
305
|
+
{
|
|
306
|
+
this._editorView.dragging = {
|
|
307
|
+
move: true,
|
|
308
|
+
slice: Slice.empty,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
const dndBackground = document.createElement('div');
|
|
312
|
+
dndBackground.classList.add('g-md-yfm-table-dnd-cursor-background');
|
|
313
|
+
document.body.append(dndBackground);
|
|
314
|
+
const draggedRangeIdx = columnRanges.indexOf(currColumnRange);
|
|
315
|
+
const onMove = debounce((event) => {
|
|
316
|
+
this._moveDragging(event, {
|
|
317
|
+
rangeIdx: draggedRangeIdx,
|
|
318
|
+
tableDesc,
|
|
319
|
+
});
|
|
320
|
+
}, MOUSE_MOVE_DEBOUNCE, { maxWait: MOUSE_MOVE_DEBOUNCE });
|
|
321
|
+
document.addEventListener('mousemove', onMove);
|
|
322
|
+
document.addEventListener('mouseup', () => {
|
|
323
|
+
onMove.flush();
|
|
324
|
+
dndBackground.remove();
|
|
325
|
+
document.removeEventListener('mousemove', onMove);
|
|
326
|
+
this._endDragging(currColumnRange, tableDesc);
|
|
327
|
+
}, { once: true });
|
|
328
|
+
}
|
|
329
|
+
_moveDragging(event, { rangeIdx, tableDesc: initialTableDesc, }) {
|
|
330
|
+
if (this._destroyed || !this._dragging)
|
|
331
|
+
return;
|
|
332
|
+
const info = this._getTableDescAndCellInfo();
|
|
333
|
+
if (!info || info.tableDesc.base !== initialTableDesc.base) {
|
|
334
|
+
this._clearDragging();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const { tableDesc } = info;
|
|
338
|
+
const ranges = tableDesc.base.getColumnRanges();
|
|
339
|
+
const boxes = ranges.map((range) => {
|
|
340
|
+
const firstColStartPos = getCellPos(tableDesc.getPosForCell(0, range.startIdx), 'start');
|
|
341
|
+
const lastColPos = tableDesc.getPosForCell(0, range.startIdx);
|
|
342
|
+
const lastColStartPos = getCellPos(lastColPos, 'start');
|
|
343
|
+
const lastColEndPos = getCellPos(lastColPos, 'end');
|
|
344
|
+
const firstColElem = this._editorView.domAtPos(firstColStartPos + 1).node;
|
|
345
|
+
const firstColBox = firstColElem.getBoundingClientRect();
|
|
346
|
+
const lastColElem = this._editorView.domAtPos(lastColStartPos + 1).node;
|
|
347
|
+
const lastColBox = lastColElem.getBoundingClientRect();
|
|
348
|
+
return {
|
|
349
|
+
pos: { from: firstColStartPos, to: lastColEndPos },
|
|
350
|
+
rect: {
|
|
351
|
+
left: firstColBox.left,
|
|
352
|
+
right: lastColBox.right,
|
|
353
|
+
},
|
|
354
|
+
safeLeftBoundary: range.safeLeftBoundary,
|
|
355
|
+
safeRightBoundary: range.safeRightBoundary,
|
|
356
|
+
};
|
|
357
|
+
});
|
|
358
|
+
const pos = (() => {
|
|
359
|
+
const { clientX } = event;
|
|
360
|
+
const draggedRangeBox = boxes[rangeIdx];
|
|
361
|
+
const isDraggedFirst = rangeIdx === 0;
|
|
362
|
+
const isDraggedLast = rangeIdx === boxes.length - 1;
|
|
363
|
+
if (!isDraggedFirst && clientX < draggedRangeBox.rect.left) {
|
|
364
|
+
for (const box of boxes.slice(0, rangeIdx).reverse()) {
|
|
365
|
+
if (clientX < box.rect.left)
|
|
366
|
+
continue;
|
|
367
|
+
if (!box.safeLeftBoundary)
|
|
368
|
+
continue;
|
|
369
|
+
return box.pos.from;
|
|
370
|
+
}
|
|
371
|
+
return boxes[0].pos.from;
|
|
372
|
+
}
|
|
373
|
+
if (!isDraggedLast && clientX > draggedRangeBox.rect.right) {
|
|
374
|
+
for (const box of boxes.slice(rangeIdx + 1)) {
|
|
375
|
+
if (clientX > box.rect.right)
|
|
376
|
+
continue;
|
|
377
|
+
if (!box.safeRightBoundary)
|
|
378
|
+
continue;
|
|
379
|
+
return box.pos.to;
|
|
380
|
+
}
|
|
381
|
+
return boxes.at(-1).pos.to;
|
|
382
|
+
}
|
|
383
|
+
return null;
|
|
384
|
+
})();
|
|
385
|
+
if (typeof pos === 'number')
|
|
386
|
+
this._dropCursor.setPos(pos);
|
|
387
|
+
else
|
|
388
|
+
this._dropCursor.clear();
|
|
389
|
+
}
|
|
390
|
+
_endDragging(draggedRange, initialTableDesc) {
|
|
391
|
+
if (this._destroyed || !this._dragging)
|
|
392
|
+
return;
|
|
393
|
+
const point = this._dropCursor.getPos();
|
|
394
|
+
this._clearDragging();
|
|
395
|
+
this._logger.event({ event: 'column-drag-end' });
|
|
396
|
+
if (point === null) {
|
|
397
|
+
this._editorView.focus();
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const info = this._getTableDescAndCellInfo();
|
|
401
|
+
if (!info || info.tableDesc.base !== initialTableDesc.base) {
|
|
402
|
+
this._editorView.focus();
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const currRangeFrom = info.tableDesc.getPosForCell(0, draggedRange.startIdx).from;
|
|
406
|
+
const currRangeTo = info.tableDesc.getPosForCell(0, draggedRange.endIdx)
|
|
407
|
+
.to;
|
|
408
|
+
if (point === currRangeFrom || point === currRangeTo)
|
|
409
|
+
return;
|
|
410
|
+
const targetColumnIndex = (() => {
|
|
411
|
+
if (point === info.tableDesc.getPosForRow(0).to - 1) {
|
|
412
|
+
return info.tableDesc.cols;
|
|
413
|
+
}
|
|
414
|
+
const cellNode = this._editorView.state.doc.nodeAt(point);
|
|
415
|
+
if (!cellNode || cellNode.type.name !== YfmTableNode.Cell)
|
|
416
|
+
return null;
|
|
417
|
+
const cellInfo = info.tableDesc.base.getCellInfo(cellNode);
|
|
418
|
+
if (!cellInfo)
|
|
419
|
+
return null;
|
|
420
|
+
return cellInfo.column;
|
|
421
|
+
})();
|
|
422
|
+
if (targetColumnIndex === null ||
|
|
423
|
+
targetColumnIndex === info.cellInfo.column ||
|
|
424
|
+
targetColumnIndex === info.cellInfo.column + 1) {
|
|
425
|
+
this._editorView.focus();
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const { tr } = this._editorView.state;
|
|
429
|
+
for (let rowIdx = 0; rowIdx < info.tableDesc.rows; rowIdx++) {
|
|
430
|
+
const from = getCellPos(info.tableDesc.getPosForCell(rowIdx, draggedRange.startIdx), 'start');
|
|
431
|
+
const to = getCellPos(info.tableDesc.getPosForCell(rowIdx, draggedRange.endIdx), 'end');
|
|
432
|
+
if (from === to)
|
|
433
|
+
continue;
|
|
434
|
+
let targetPos;
|
|
435
|
+
if (targetColumnIndex === info.tableDesc.cols) {
|
|
436
|
+
targetPos = info.tableDesc.getPosForRow(rowIdx).to - 1;
|
|
437
|
+
}
|
|
438
|
+
else if (targetColumnIndex === 0) {
|
|
439
|
+
targetPos = info.tableDesc.getPosForRow(rowIdx).from + 1;
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
targetPos = getCellPos(info.tableDesc.getPosForCell(rowIdx, targetColumnIndex), 'start');
|
|
443
|
+
}
|
|
444
|
+
if (targetPos !== from && targetPos !== to) {
|
|
445
|
+
const fragment = tr.doc.slice(from, to, false).content;
|
|
446
|
+
tr.insert(tr.mapping.map(targetPos), fragment);
|
|
447
|
+
tr.delete(tr.mapping.map(from), tr.mapping.map(to));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
this._editorView.dispatch(tr.scrollIntoView());
|
|
451
|
+
this._editorView.focus();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function getCellPos(pos, dir) {
|
|
455
|
+
if (pos.type === 'virtual')
|
|
456
|
+
return pos.closestPos;
|
|
457
|
+
return dir === 'start' ? pos.from : pos.to;
|
|
458
|
+
}
|
|
459
|
+
function isDragThresholdPassed(init, curr) {
|
|
460
|
+
return (Math.abs(init.pageX - curr.pageX) >= DRAG_START_THRESHOLD ||
|
|
461
|
+
Math.abs(init.pageY - curr.pageY) >= DRAG_START_THRESHOLD);
|
|
462
|
+
}
|
|
463
|
+
//# sourceMappingURL=dnd.js.map
|