@atlaskit/editor-plugin-table 0.0.10 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +35 -0
- package/CHANGELOG.md +31 -0
- package/commands/package.json +14 -0
- package/dist/cjs/plugins/table/commands/hover.js +4 -4
- package/dist/cjs/plugins/table/commands-with-analytics.js +59 -58
- package/dist/cjs/plugins/table/event-handlers.js +0 -1
- package/dist/cjs/plugins/table/index.js +54 -37
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +9 -1
- package/dist/cjs/plugins/table/toolbar.js +150 -22
- package/dist/cjs/plugins/table/transforms/fix-tables.js +7 -7
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +1 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/cjs/plugins/table/ui/LayoutButton/index.js +3 -5
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/cjs/plugins/table/utils/column-controls.js +0 -1
- package/dist/cjs/plugins/table/utils/decoration.js +53 -4
- package/dist/cjs/plugins/table/utils/dom.js +0 -2
- package/dist/cjs/plugins/table/utils/paste.js +0 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/hover.js +4 -4
- package/dist/es2019/plugins/table/commands-with-analytics.js +6 -9
- package/dist/es2019/plugins/table/event-handlers.js +1 -2
- package/dist/es2019/plugins/table/handlers.js +1 -2
- package/dist/es2019/plugins/table/index.js +23 -5
- package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +2 -1
- package/dist/es2019/plugins/table/toolbar.js +133 -16
- package/dist/es2019/plugins/table/transforms/fix-tables.js +2 -4
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +1 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +3 -3
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -2
- package/dist/es2019/plugins/table/ui/LayoutButton/index.js +3 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/es2019/plugins/table/utils/column-controls.js +0 -1
- package/dist/es2019/plugins/table/utils/decoration.js +60 -25
- package/dist/es2019/plugins/table/utils/dom.js +0 -2
- package/dist/es2019/plugins/table/utils/paste.js +1 -2
- package/dist/es2019/plugins/table/utils/row-controls.js +1 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/hover.js +4 -4
- package/dist/esm/plugins/table/commands-with-analytics.js +56 -55
- package/dist/esm/plugins/table/event-handlers.js +1 -2
- package/dist/esm/plugins/table/handlers.js +1 -2
- package/dist/esm/plugins/table/index.js +55 -38
- package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-local-id.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +2 -1
- package/dist/esm/plugins/table/toolbar.js +139 -17
- package/dist/esm/plugins/table/transforms/fix-tables.js +2 -4
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +1 -2
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +3 -3
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -2
- package/dist/esm/plugins/table/ui/LayoutButton/index.js +3 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/esm/plugins/table/utils/column-controls.js +0 -1
- package/dist/esm/plugins/table/utils/decoration.js +50 -4
- package/dist/esm/plugins/table/utils/dom.js +0 -2
- package/dist/esm/plugins/table/utils/paste.js +1 -2
- package/dist/esm/plugins/table/utils/row-controls.js +1 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
- package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
- package/dist/types/plugins/table/toolbar.d.ts +2 -2
- package/dist/types/plugins/table/transforms/fix-tables.d.ts +1 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/examples/99-testing.tsx +35 -30
- package/examples/config.jsonc +14 -0
- package/package.json +14 -19
- package/plugin-key/package.json +14 -0
- package/report.api.md +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/auto-size-documents.ts +5 -10
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/basic-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/empty-paragraph-underneath-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/even-columns.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/layout-documents.ts +1 -2
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/merged-rows-and-cols-document.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/nested-in-extension.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/paragraph-and-table-adf.json +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/resize-documents.ts +5 -10
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/scale.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-inside-layout.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-min-width-columns-document.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-multiline-date.adf.json +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-text-and-empty-row.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/auto-size.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/change-date-inside-table.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/copy-button.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-columns.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-rows.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-table-when-selected.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/even-columns.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-row-inside-layout.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/layout.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/resize.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/scale.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/arrow-down-into-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/auto-size.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/block-node-selection.ts +1 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/cell-selection.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/change-date-inside-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/copy-button.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-columns.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-in-full-width.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-with-empty-action.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-row-with-empty-action.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-rows.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-table-when-selected.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/deleting-empty-paragraph-under-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/even-columns.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/insert-cell-header-with-strong-mark.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/insert-long-smart-link.ts +1 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/insert-row-inside-layout.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/layout.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/resize-handler.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/resize.ts +2 -3
- package/src/{plugins/table/__tests__ → __tests__}/integration/scale.ts +0 -0
- package/src/__tests__/integration/table-controls-selection.ts +71 -0
- package/src/__tests__/unit/analytics.ts +41 -41
- package/src/__tests__/unit/collab.ts +12 -9
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands/go-to-next-cell.ts +4 -4
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands/insert.ts +4 -4
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands/misc.ts +12 -6
- package/src/__tests__/unit/commands/sort.ts +28 -28
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands.ts +7 -7
- package/src/__tests__/unit/copy-button.ts +22 -0
- package/src/__tests__/unit/copy-paste.ts +6 -8
- package/src/__tests__/unit/event-handlers.ts +127 -11
- package/src/__tests__/unit/fix-tables.ts +17 -23
- package/src/{plugins/table/__tests__ → __tests__}/unit/get-toolbar-config.ts +8 -8
- package/src/__tests__/unit/hover-selection.ts +1 -66
- package/src/__tests__/unit/index-with-fake-timers.ts +1 -1
- package/src/__tests__/unit/index.ts +5 -5
- package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/OverflowShadowsObserver.ts +2 -2
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +181 -0
- package/src/__tests__/unit/nodeviews/cell.ts +12 -10
- package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/table.ts +29 -30
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-controls.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-resizing.ts +9 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/plugin.ts +5 -5
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main-with-allow-collapse.ts +4 -4
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main.ts +6 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +12 -9
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/sticky-headers/tableRow.tsx +27 -25
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-local-id.ts +3 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/colgroup.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/event-handlers.ts +3 -3
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-selection-keymap.ts +3 -3
- package/src/{plugins/table/__tests__ → __tests__}/unit/toolbar.ts +23 -14
- package/src/__tests__/unit/ui/ContextualMenu.tsx +55 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +7 -7
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +45 -49
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +49 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +30 -2
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +143 -111
- package/src/__tests__/unit/ui/RowControls.tsx +112 -141
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +18 -15
- package/src/__tests__/unit/undo-redo.ts +10 -9
- package/src/{plugins/table/__tests__ → __tests__}/unit/utils/collapse.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/unit/utils/column-controls.ts +1 -1
- package/src/__tests__/unit/utils/nodes.ts +8 -4
- package/src/__tests__/unit/utils/row-controls.ts +8 -4
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/cell-options-menu.ts +2 -0
- package/src/__tests__/visual-regression/copy-button.ts +181 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/index.ts +3 -1
- package/src/plugins/table/commands/clear.ts +30 -29
- package/src/plugins/table/commands/go-to-next-cell.ts +41 -38
- package/src/plugins/table/commands/hover.ts +4 -1
- package/src/plugins/table/commands/insert.ts +91 -91
- package/src/plugins/table/commands/misc.ts +123 -125
- package/src/plugins/table/commands/selection.ts +329 -319
- package/src/plugins/table/commands-with-analytics.ts +299 -290
- package/src/plugins/table/event-handlers.ts +111 -112
- package/src/plugins/table/handlers.ts +95 -95
- package/src/plugins/table/index.tsx +28 -2
- package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +4 -3
- package/src/plugins/table/nodeviews/TableComponent.tsx +6 -9
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +39 -39
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +7 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +30 -30
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +7 -7
- package/src/plugins/table/pm-plugins/keymap.ts +1 -1
- package/src/plugins/table/pm-plugins/plugin-factory.ts +33 -33
- package/src/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.ts +6 -9
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +3 -2
- package/src/plugins/table/pm-plugins/table-local-id.ts +0 -2
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +98 -90
- package/src/plugins/table/pm-plugins/table-resizing/index.ts +1 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +46 -47
- package/src/plugins/table/{toolbar.ts → toolbar.tsx} +276 -101
- package/src/plugins/table/transforms/column-width.ts +143 -146
- package/src/plugins/table/transforms/delete-columns.ts +144 -142
- package/src/plugins/table/transforms/delete-rows.ts +110 -111
- package/src/plugins/table/transforms/fix-tables.ts +2 -3
- package/src/plugins/table/transforms/metadata.ts +9 -9
- package/src/plugins/table/ui/FloatingContextualButton/index.tsx +0 -1
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -16
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +3 -3
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +2 -6
- package/src/plugins/table/ui/LayoutButton/index.tsx +4 -10
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +1 -0
- package/src/plugins/table/ui/common-styles.ts +1 -3
- package/src/plugins/table/utils/analytics.ts +24 -25
- package/src/plugins/table/utils/column-controls.ts +0 -1
- package/src/plugins/table/utils/decoration.ts +44 -5
- package/src/plugins/table/utils/dom.ts +3 -5
- package/src/plugins/table/utils/paste.ts +0 -1
- package/src/plugins/table/utils/row-controls.ts +92 -94
- package/types/package.json +5 -5
- package/ui/common-styles/package.json +14 -0
- package/ui/consts/package.json +14 -0
- package/dist/cjs/plugins/plugin-key.js +0 -17
- package/dist/cjs/plugins/table/todo-stubs.js +0 -10
- package/dist/cjs/types.js +0 -5
- package/dist/es2019/plugins/plugin-key.js +0 -3
- package/dist/es2019/plugins/table/todo-stubs.js +0 -1
- package/dist/es2019/types.js +0 -1
- package/dist/esm/plugins/plugin-key.js +0 -5
- package/dist/esm/plugins/table/todo-stubs.js +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/types/plugins/plugin-key.d.ts +0 -4
- package/dist/types/plugins/table/todo-stubs.d.ts +0 -1
- package/dist/types/types.d.ts +0 -3
- package/dist/types-ts4.0/index.d.ts +0 -1
- package/dist/types-ts4.0/plugins/plugin-key.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/commands/clear.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/commands/collapse.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/commands/go-to-next-cell.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/commands/hover.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/commands/index.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/commands/insert.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/commands/misc.d.ts +0 -27
- package/dist/types-ts4.0/plugins/table/commands/selection.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/commands/sort.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/commands/split-cell.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/commands/toggle.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +0 -26
- package/dist/types-ts4.0/plugins/table/create-plugin-config.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/event-handlers.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/handlers.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/index.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +0 -26
- package/dist/types-ts4.0/plugins/table/nodeviews/TableComponent.d.ts +0 -72
- package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/nodeviews/table.d.ts +0 -31
- package/dist/types-ts4.0/plugins/table/nodeviews/tableCell.d.ts +0 -19
- package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +0 -24
- package/dist/types-ts4.0/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/plugin.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/index.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/types.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/default-table-selection.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/keymap.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/main.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-factory.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -15
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/commands.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -65
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/types.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/util.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-local-id.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/commands.d.ts +0 -25
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/reducer.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +0 -13
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-selection-keymap.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/reducer.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/todo-stubs.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/toolbar.d.ts +0 -36
- package/dist/types-ts4.0/plugins/table/transforms/column-width.d.ts +0 -18
- package/dist/types-ts4.0/plugins/table/transforms/delete-columns.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/transforms/delete-rows.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/transforms/index.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/transforms/merge.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/transforms/metadata.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/transforms/replace-table.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/transforms/split.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/types.d.ts +0 -328
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/index.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/styles.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +0 -87
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/index.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/styles.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/index.d.ts +0 -54
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/types.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/index.d.ts +0 -35
- package/dist/types-ts4.0/plugins/table/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/index.d.ts +0 -40
- package/dist/types-ts4.0/plugins/table/ui/common-styles.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/ui/consts.d.ts +0 -39
- package/dist/types-ts4.0/plugins/table/ui/messages.d.ts +0 -38
- package/dist/types-ts4.0/plugins/table/ui/ui-styles.d.ts +0 -15
- package/dist/types-ts4.0/plugins/table/utils/analytics.d.ts +0 -18
- package/dist/types-ts4.0/plugins/table/utils/collapse.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/utils/column-controls.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/utils/dom.d.ts +0 -20
- package/dist/types-ts4.0/plugins/table/utils/get-allow-add-column-custom-step.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/utils/index.d.ts +0 -11
- package/dist/types-ts4.0/plugins/table/utils/nodes.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/utils/paste.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/utils/referentiality.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/utils/row-controls.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/utils/selection.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/utils/table.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/utils/update-plugin-state-decorations.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table-plugin.d.ts +0 -2
- package/dist/types-ts4.0/types.d.ts +0 -3
- package/src/plugins/plugin-key.ts +0 -7
- package/src/plugins/table/__tests__/integration/table-controls-selection.ts +0 -70
- package/src/plugins/table/__tests__/unit/event-handlers.ts +0 -130
- package/src/plugins/table/__tests__/unit/nodeviews/TableComponent.tsx +0 -388
- package/src/plugins/table/todo-stubs.ts +0 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +0 -55
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +0 -49
- package/src/types.ts +0 -3
- package/tmp/api-report-tmp.d.ts +0 -91
|
@@ -18,223 +18,227 @@ export enum TableSelectionDirection {
|
|
|
18
18
|
BottomToTop = 'BottomToTop',
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const arrowLeftFromTable =
|
|
22
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dispatch,
|
|
29
|
-
);
|
|
30
|
-
} else if (selection instanceof GapCursorSelection) {
|
|
31
|
-
return arrowLeftFromGapCursor(editorSelectionAPI)(selection)(
|
|
32
|
-
state,
|
|
33
|
-
dispatch,
|
|
34
|
-
);
|
|
35
|
-
} else if (selection instanceof TextSelection) {
|
|
36
|
-
return arrowLeftFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const arrowRightFromTable = (
|
|
42
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null,
|
|
43
|
-
) => (): Command => (state, dispatch) => {
|
|
44
|
-
const { selection } = state;
|
|
45
|
-
|
|
46
|
-
if (selection instanceof CellSelection) {
|
|
47
|
-
return arrowRightFromCellSelection(editorSelectionAPI)(selection)(
|
|
48
|
-
state,
|
|
49
|
-
dispatch,
|
|
50
|
-
);
|
|
51
|
-
} else if (selection instanceof GapCursorSelection) {
|
|
52
|
-
return arrowRightFromGapCursor(editorSelectionAPI)(selection)(
|
|
53
|
-
state,
|
|
54
|
-
dispatch,
|
|
55
|
-
);
|
|
56
|
-
} else if (selection instanceof TextSelection) {
|
|
57
|
-
return arrowRightFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const arrowLeftFromCellSelection = (
|
|
63
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null,
|
|
64
|
-
) => (selection: CellSelection): Command => (state, dispatch) => {
|
|
65
|
-
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
66
|
-
const {
|
|
67
|
-
selectionRelativeToNode,
|
|
68
|
-
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
69
|
-
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
70
|
-
// we have full table cell selection and want to set gap cursor selection before table
|
|
71
|
-
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
72
|
-
} else if (selectionRelativeToNode === RelativeSelectionPos.End) {
|
|
73
|
-
// we have full table cell selection and want to set selection at end of last cell
|
|
74
|
-
return setSelectionAtEndOfLastCell(editorSelectionAPI)(selection)(
|
|
21
|
+
export const arrowLeftFromTable =
|
|
22
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
23
|
+
(): Command =>
|
|
24
|
+
(state, dispatch) => {
|
|
25
|
+
const { selection } = state;
|
|
26
|
+
if (selection instanceof CellSelection) {
|
|
27
|
+
return arrowLeftFromCellSelection(editorSelectionAPI)(selection)(
|
|
75
28
|
state,
|
|
76
29
|
dispatch,
|
|
77
30
|
);
|
|
78
|
-
} else if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
31
|
+
} else if (selection instanceof GapCursorSelection) {
|
|
32
|
+
return arrowLeftFromGapCursor(editorSelectionAPI)(selection)(
|
|
33
|
+
state,
|
|
34
|
+
dispatch,
|
|
35
|
+
);
|
|
36
|
+
} else if (selection instanceof TextSelection) {
|
|
37
|
+
return arrowLeftFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
84
38
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
88
41
|
|
|
89
|
-
const
|
|
90
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const {
|
|
94
|
-
selectionRelativeToNode,
|
|
95
|
-
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
42
|
+
export const arrowRightFromTable =
|
|
43
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
44
|
+
(): Command =>
|
|
45
|
+
(state, dispatch) => {
|
|
46
|
+
const { selection } = state;
|
|
96
47
|
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection)(
|
|
48
|
+
if (selection instanceof CellSelection) {
|
|
49
|
+
return arrowRightFromCellSelection(editorSelectionAPI)(selection)(
|
|
100
50
|
state,
|
|
101
51
|
dispatch,
|
|
102
52
|
);
|
|
103
|
-
} else if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
53
|
+
} else if (selection instanceof GapCursorSelection) {
|
|
54
|
+
return arrowRightFromGapCursor(editorSelectionAPI)(selection)(
|
|
55
|
+
state,
|
|
56
|
+
dispatch,
|
|
57
|
+
);
|
|
58
|
+
} else if (selection instanceof TextSelection) {
|
|
59
|
+
return arrowRightFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const arrowLeftFromCellSelection =
|
|
65
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
66
|
+
(selection: CellSelection): Command =>
|
|
67
|
+
(state, dispatch) => {
|
|
68
|
+
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
69
|
+
const { selectionRelativeToNode } =
|
|
70
|
+
editorSelectionAPI.getSelectionPluginState(state);
|
|
71
|
+
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
72
|
+
// we have full table cell selection and want to set gap cursor selection before table
|
|
73
|
+
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
74
|
+
} else if (selectionRelativeToNode === RelativeSelectionPos.End) {
|
|
75
|
+
// we have full table cell selection and want to set selection at end of last cell
|
|
76
|
+
return setSelectionAtEndOfLastCell(editorSelectionAPI)(selection)(
|
|
77
|
+
state,
|
|
78
|
+
dispatch,
|
|
79
|
+
);
|
|
80
|
+
} else if (selectionRelativeToNode === undefined) {
|
|
81
|
+
// we have full table cell selection and want to set selection at start of first cell
|
|
82
|
+
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(
|
|
83
|
+
selection,
|
|
84
|
+
RelativeSelectionPos.Before,
|
|
85
|
+
)(state, dispatch);
|
|
86
|
+
}
|
|
109
87
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
88
|
+
return false;
|
|
89
|
+
};
|
|
113
90
|
|
|
114
|
-
const
|
|
115
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
91
|
+
const arrowRightFromCellSelection =
|
|
92
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
93
|
+
(selection: CellSelection): Command =>
|
|
94
|
+
(state, dispatch) => {
|
|
95
|
+
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
96
|
+
const { selectionRelativeToNode } =
|
|
97
|
+
editorSelectionAPI.getSelectionPluginState(state);
|
|
119
98
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
99
|
+
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
100
|
+
// we have full table cell selection and want to set selection at start of first cell
|
|
101
|
+
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection)(
|
|
102
|
+
state,
|
|
103
|
+
dispatch,
|
|
104
|
+
);
|
|
105
|
+
} else if (
|
|
106
|
+
selectionRelativeToNode === RelativeSelectionPos.End ||
|
|
107
|
+
selectionRelativeToNode === undefined
|
|
108
|
+
) {
|
|
109
|
+
// we have full table cell selection and want to set gap cursor selection after table
|
|
110
|
+
return setGapCursorAfterTable(editorSelectionAPI)()(state, dispatch);
|
|
111
|
+
}
|
|
128
112
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} else {
|
|
143
|
-
// we have a gap cursor at start of first table cell and want to set a full table cell selection
|
|
113
|
+
return false;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const arrowLeftFromGapCursor =
|
|
117
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
118
|
+
(selection: GapCursorSelection): Command =>
|
|
119
|
+
(state, dispatch) => {
|
|
120
|
+
const { doc } = state;
|
|
121
|
+
const { $from, from, side } = selection;
|
|
122
|
+
|
|
123
|
+
if (side === Side.RIGHT) {
|
|
124
|
+
if ($from.nodeBefore && $from.nodeBefore.type.name === 'table') {
|
|
125
|
+
// we have a gap cursor after a table node and want to set a full table cell selection
|
|
144
126
|
return selectFullTable(editorSelectionAPI)({
|
|
145
|
-
node:
|
|
146
|
-
startPos:
|
|
147
|
-
dir: TableSelectionDirection.
|
|
127
|
+
node: $from.nodeBefore,
|
|
128
|
+
startPos: doc.resolve(from - 1).start($from.depth + 1),
|
|
129
|
+
dir: TableSelectionDirection.TopToBottom,
|
|
148
130
|
})(state, dispatch);
|
|
149
131
|
}
|
|
132
|
+
} else if (side === Side.LEFT) {
|
|
133
|
+
const table = findTable(selection);
|
|
134
|
+
if (
|
|
135
|
+
table &&
|
|
136
|
+
isSelectionAtStartOfTable($from, selection) &&
|
|
137
|
+
editorSelectionAPI
|
|
138
|
+
) {
|
|
139
|
+
const { selectionRelativeToNode } =
|
|
140
|
+
editorSelectionAPI.getSelectionPluginState(state);
|
|
141
|
+
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
142
|
+
// we have a gap cursor at start of first table cell and want to set a gap cursor selection before table
|
|
143
|
+
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
144
|
+
} else {
|
|
145
|
+
// we have a gap cursor at start of first table cell and want to set a full table cell selection
|
|
146
|
+
return selectFullTable(editorSelectionAPI)({
|
|
147
|
+
node: table.node,
|
|
148
|
+
startPos: table.start,
|
|
149
|
+
dir: TableSelectionDirection.BottomToTop,
|
|
150
|
+
})(state, dispatch);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
};
|
|
154
|
+
return false;
|
|
155
|
+
};
|
|
154
156
|
|
|
155
|
-
const arrowRightFromGapCursor =
|
|
156
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
const arrowRightFromGapCursor =
|
|
158
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
159
|
+
(selection: GapCursorSelection): Command =>
|
|
160
|
+
(state, dispatch) => {
|
|
161
|
+
const { $from, from, $to, side } = selection;
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
if (side === Side.LEFT) {
|
|
164
|
+
if ($from.nodeAfter && $from.nodeAfter.type.name === 'table') {
|
|
165
|
+
// we have a gap cursor before a table node and want to set a full table cell selection
|
|
166
|
+
return selectFullTable(editorSelectionAPI)({
|
|
167
|
+
node: $from.nodeAfter,
|
|
168
|
+
startPos: from + 1,
|
|
169
|
+
dir: TableSelectionDirection.BottomToTop,
|
|
170
|
+
})(state, dispatch);
|
|
171
|
+
}
|
|
172
|
+
} else if (side === Side.RIGHT) {
|
|
173
|
+
const table = findTable(selection);
|
|
174
|
+
if (table && isSelectionAtEndOfTable($to, selection)) {
|
|
175
|
+
// we have a gap cursor at end of last table cell and want to set a full table cell selection
|
|
176
|
+
return selectFullTable(editorSelectionAPI)({
|
|
177
|
+
node: table.node,
|
|
178
|
+
startPos: table.start,
|
|
179
|
+
dir: TableSelectionDirection.TopToBottom,
|
|
180
|
+
})(state, dispatch);
|
|
181
|
+
}
|
|
168
182
|
}
|
|
169
|
-
|
|
183
|
+
return false;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const arrowLeftFromText =
|
|
187
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
188
|
+
(selection: TextSelection): Command =>
|
|
189
|
+
(state, dispatch) => {
|
|
170
190
|
const table = findTable(selection);
|
|
171
|
-
if (table
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
if (table) {
|
|
192
|
+
const { $from } = selection;
|
|
193
|
+
if (
|
|
194
|
+
isSelectionAtStartOfTable($from, selection) &&
|
|
195
|
+
$from.parent.type.name === 'paragraph' &&
|
|
196
|
+
$from.depth === table.depth + 3 && // + 3 for: row, cell & paragraph nodes
|
|
197
|
+
editorSelectionAPI
|
|
198
|
+
) {
|
|
199
|
+
const { selectionRelativeToNode } =
|
|
200
|
+
editorSelectionAPI.getSelectionPluginState(state);
|
|
201
|
+
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
202
|
+
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
203
|
+
// and want to set gap cursor selection before table
|
|
204
|
+
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
205
|
+
} else {
|
|
206
|
+
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
207
|
+
// and want to set a full table cell selection
|
|
208
|
+
return selectFullTable(editorSelectionAPI)({
|
|
209
|
+
node: table.node,
|
|
210
|
+
startPos: table.start,
|
|
211
|
+
dir: TableSelectionDirection.BottomToTop,
|
|
212
|
+
})(state, dispatch);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
178
215
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
};
|
|
216
|
+
return false;
|
|
217
|
+
};
|
|
182
218
|
|
|
183
|
-
const
|
|
184
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
selectionRelativeToNode,
|
|
197
|
-
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
198
|
-
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
199
|
-
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
200
|
-
// and want to set gap cursor selection before table
|
|
201
|
-
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
202
|
-
} else {
|
|
203
|
-
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
219
|
+
const arrowRightFromText =
|
|
220
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
221
|
+
(selection: TextSelection): Command =>
|
|
222
|
+
(state, dispatch) => {
|
|
223
|
+
const table = findTable(selection);
|
|
224
|
+
if (table) {
|
|
225
|
+
const { $to } = selection;
|
|
226
|
+
if (
|
|
227
|
+
isSelectionAtEndOfTable($to, selection) &&
|
|
228
|
+
$to.parent.type.name === 'paragraph' &&
|
|
229
|
+
$to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
230
|
+
) {
|
|
231
|
+
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
204
232
|
// and want to set a full table cell selection
|
|
205
233
|
return selectFullTable(editorSelectionAPI)({
|
|
206
234
|
node: table.node,
|
|
207
235
|
startPos: table.start,
|
|
208
|
-
dir: TableSelectionDirection.
|
|
236
|
+
dir: TableSelectionDirection.TopToBottom,
|
|
209
237
|
})(state, dispatch);
|
|
210
238
|
}
|
|
211
239
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const arrowRightFromText = (
|
|
217
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null,
|
|
218
|
-
) => (selection: TextSelection): Command => (state, dispatch) => {
|
|
219
|
-
const table = findTable(selection);
|
|
220
|
-
if (table) {
|
|
221
|
-
const { $to } = selection;
|
|
222
|
-
if (
|
|
223
|
-
isSelectionAtEndOfTable($to, selection) &&
|
|
224
|
-
$to.parent.type.name === 'paragraph' &&
|
|
225
|
-
$to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
226
|
-
) {
|
|
227
|
-
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
228
|
-
// and want to set a full table cell selection
|
|
229
|
-
return selectFullTable(editorSelectionAPI)({
|
|
230
|
-
node: table.node,
|
|
231
|
-
startPos: table.start,
|
|
232
|
-
dir: TableSelectionDirection.TopToBottom,
|
|
233
|
-
})(state, dispatch);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return false;
|
|
237
|
-
};
|
|
240
|
+
return false;
|
|
241
|
+
};
|
|
238
242
|
|
|
239
243
|
/**
|
|
240
244
|
* Sets a cell selection over all the cells in the table node
|
|
@@ -242,162 +246,168 @@ const arrowRightFromText = (
|
|
|
242
246
|
* cell is the anchor and which is the head, and also so we can set the relative selection
|
|
243
247
|
* pos in the selection plugin
|
|
244
248
|
*/
|
|
245
|
-
const selectFullTable =
|
|
246
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}: {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}): Command =>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
249
|
+
const selectFullTable =
|
|
250
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
251
|
+
({
|
|
252
|
+
node,
|
|
253
|
+
startPos,
|
|
254
|
+
dir,
|
|
255
|
+
}: {
|
|
256
|
+
node: PmNode;
|
|
257
|
+
startPos: number;
|
|
258
|
+
dir: TableSelectionDirection;
|
|
259
|
+
}): Command =>
|
|
260
|
+
(state, dispatch) => {
|
|
261
|
+
const { doc } = state;
|
|
262
|
+
const { map } = TableMap.get(node);
|
|
263
|
+
const $firstCell = doc.resolve(startPos + map[0]);
|
|
264
|
+
const $lastCell = doc.resolve(startPos + map[map.length - 1]);
|
|
260
265
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
266
|
+
let fullTableSelection: Selection;
|
|
267
|
+
let selectionRelativeToNode: RelativeSelectionPos;
|
|
268
|
+
if (dir === TableSelectionDirection.TopToBottom) {
|
|
269
|
+
fullTableSelection = new CellSelection($firstCell, $lastCell) as any;
|
|
270
|
+
selectionRelativeToNode = RelativeSelectionPos.End;
|
|
271
|
+
} else {
|
|
272
|
+
fullTableSelection = new CellSelection($lastCell, $firstCell) as any;
|
|
273
|
+
selectionRelativeToNode = RelativeSelectionPos.Start;
|
|
274
|
+
}
|
|
275
|
+
if (editorSelectionAPI) {
|
|
276
|
+
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
277
|
+
selectionRelativeToNode,
|
|
278
|
+
selection: fullTableSelection,
|
|
279
|
+
})(state);
|
|
275
280
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
281
|
+
if (dispatch) {
|
|
282
|
+
dispatch(tr);
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
279
285
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
};
|
|
286
|
+
return false;
|
|
287
|
+
};
|
|
283
288
|
|
|
284
|
-
const setSelectionAtStartOfFirstCell =
|
|
285
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
): Command =>
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
const setSelectionAtStartOfFirstCell =
|
|
290
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
291
|
+
(
|
|
292
|
+
selection: CellSelection,
|
|
293
|
+
selectionRelativeToNode?: RelativeSelectionPos,
|
|
294
|
+
): Command =>
|
|
295
|
+
(state, dispatch) => {
|
|
296
|
+
const { $anchorCell, $headCell } = selection;
|
|
297
|
+
const $firstCell =
|
|
298
|
+
$anchorCell.pos < $headCell.pos ? $anchorCell : $headCell;
|
|
299
|
+
const $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
|
|
293
300
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
301
|
+
// check if first pos should have a gap cursor, otherwise find closest text selection
|
|
302
|
+
const selectionAtStartOfCell = GapCursorSelection.valid($firstPosInsideCell)
|
|
303
|
+
? new GapCursorSelection($firstPosInsideCell, Side.LEFT)
|
|
304
|
+
: Selection.findFrom($firstPosInsideCell, 1);
|
|
298
305
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
306
|
+
if (editorSelectionAPI) {
|
|
307
|
+
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
308
|
+
selectionRelativeToNode,
|
|
309
|
+
selection: selectionAtStartOfCell,
|
|
310
|
+
})(state);
|
|
304
311
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
if (dispatch) {
|
|
313
|
+
dispatch(tr);
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
308
316
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
};
|
|
317
|
+
return false;
|
|
318
|
+
};
|
|
312
319
|
|
|
313
|
-
const setSelectionAtEndOfLastCell =
|
|
314
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
): Command =>
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
320
|
+
const setSelectionAtEndOfLastCell =
|
|
321
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
322
|
+
(
|
|
323
|
+
selection: CellSelection,
|
|
324
|
+
selectionRelativeToNode?: RelativeSelectionPos,
|
|
325
|
+
): Command =>
|
|
326
|
+
(state, dispatch) => {
|
|
327
|
+
const { $anchorCell, $headCell } = selection;
|
|
328
|
+
const $lastCell = $anchorCell.pos > $headCell.pos ? $anchorCell : $headCell;
|
|
329
|
+
const lastPosInsideCell =
|
|
330
|
+
$lastCell.pos +
|
|
331
|
+
($lastCell.nodeAfter ? $lastCell.nodeAfter.content.size : 0) +
|
|
332
|
+
1;
|
|
333
|
+
const $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
|
|
326
334
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
335
|
+
// check if last pos should have a gap cursor, otherwise find closest text selection
|
|
336
|
+
const selectionAtEndOfCell = GapCursorSelection.valid($lastPosInsideCell)
|
|
337
|
+
? new GapCursorSelection($lastPosInsideCell, Side.RIGHT)
|
|
338
|
+
: Selection.findFrom($lastPosInsideCell, -1);
|
|
331
339
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
340
|
+
if (editorSelectionAPI) {
|
|
341
|
+
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
342
|
+
selectionRelativeToNode,
|
|
343
|
+
selection: selectionAtEndOfCell,
|
|
344
|
+
})(state);
|
|
337
345
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
346
|
+
if (dispatch) {
|
|
347
|
+
dispatch(tr);
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
341
350
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
351
|
+
return false;
|
|
352
|
+
};
|
|
345
353
|
|
|
346
|
-
const setGapCursorBeforeTable =
|
|
347
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
354
|
+
const setGapCursorBeforeTable =
|
|
355
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
356
|
+
(): Command =>
|
|
357
|
+
(state, dispatch) => {
|
|
358
|
+
const table = findTable(state.selection);
|
|
359
|
+
if (table) {
|
|
360
|
+
const $beforeTablePos = state.doc.resolve(table.pos);
|
|
361
|
+
if (GapCursorSelection.valid($beforeTablePos)) {
|
|
362
|
+
const selectionBeforeTable = new GapCursorSelection(
|
|
363
|
+
$beforeTablePos,
|
|
364
|
+
Side.LEFT,
|
|
365
|
+
);
|
|
366
|
+
if (editorSelectionAPI) {
|
|
367
|
+
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
368
|
+
selectionRelativeToNode: undefined,
|
|
369
|
+
selection: selectionBeforeTable,
|
|
370
|
+
})(state);
|
|
362
371
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
372
|
+
if (dispatch) {
|
|
373
|
+
dispatch(tr);
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
366
376
|
}
|
|
367
377
|
}
|
|
368
378
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
};
|
|
379
|
+
return false;
|
|
380
|
+
};
|
|
372
381
|
|
|
373
|
-
const setGapCursorAfterTable =
|
|
374
|
-
editorSelectionAPI: EditorSelectionAPI | undefined | null
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
const setGapCursorAfterTable =
|
|
383
|
+
(editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
|
|
384
|
+
(): Command =>
|
|
385
|
+
(state, dispatch) => {
|
|
386
|
+
const table = findTable(state.selection);
|
|
387
|
+
if (table) {
|
|
388
|
+
const $afterTablePos = state.doc.resolve(table.pos + table.node.nodeSize);
|
|
389
|
+
if (GapCursorSelection.valid($afterTablePos)) {
|
|
390
|
+
const selectionAfterTable = new GapCursorSelection(
|
|
391
|
+
$afterTablePos,
|
|
392
|
+
Side.RIGHT,
|
|
393
|
+
);
|
|
384
394
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
395
|
+
if (editorSelectionAPI) {
|
|
396
|
+
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
397
|
+
selectionRelativeToNode: undefined,
|
|
398
|
+
selection: selectionAfterTable,
|
|
399
|
+
})(state);
|
|
390
400
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
401
|
+
if (dispatch) {
|
|
402
|
+
dispatch(tr);
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
394
405
|
}
|
|
406
|
+
return false;
|
|
395
407
|
}
|
|
396
|
-
return false;
|
|
397
408
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
};
|
|
409
|
+
return false;
|
|
410
|
+
};
|
|
401
411
|
|
|
402
412
|
const isSelectionAtStartOfTable = ($pos: ResolvedPos, selection: Selection) =>
|
|
403
413
|
isSelectionAtStartOfNode($pos, findTable(selection));
|