@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
|
@@ -22,109 +22,107 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
22
22
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
23
23
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
24
24
|
|
|
25
|
-
export const updateColumnWidths =
|
|
26
|
-
resizeState: ResizeState,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const map = TableMap.get(table);
|
|
31
|
-
const updatedCellsAttrs: { [key: number]: CellAttributes } = {};
|
|
32
|
-
|
|
33
|
-
// calculating new attributes for each cell
|
|
34
|
-
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
35
|
-
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
36
|
-
const { width } = resizeState.cols[columnIndex];
|
|
37
|
-
const mapIndex = rowIndex * map.width + columnIndex;
|
|
38
|
-
const cellPos = map.map[mapIndex];
|
|
39
|
-
const attrs = updatedCellsAttrs[cellPos] || {
|
|
40
|
-
...table.nodeAt(cellPos)!.attrs,
|
|
41
|
-
};
|
|
42
|
-
const colspan = attrs.colspan || 1;
|
|
43
|
-
|
|
44
|
-
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
45
|
-
tr = setMeta({
|
|
46
|
-
type: 'UPDATE_COLUMN_WIDTHS',
|
|
47
|
-
problem: 'COLWIDTHS_BEFORE_UPDATE',
|
|
48
|
-
data: { colwidths: attrs.colwidth, colspan },
|
|
49
|
-
})(tr);
|
|
50
|
-
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Rowspanning cell that has already been handled
|
|
54
|
-
if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const colspanIndex =
|
|
58
|
-
colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
|
|
59
|
-
if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
25
|
+
export const updateColumnWidths =
|
|
26
|
+
(resizeState: ResizeState, table: PMNode, start: number) =>
|
|
27
|
+
(tr: Transaction): Transaction => {
|
|
28
|
+
const map = TableMap.get(table);
|
|
29
|
+
const updatedCellsAttrs: { [key: number]: CellAttributes } = {};
|
|
62
30
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
31
|
+
// calculating new attributes for each cell
|
|
32
|
+
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
33
|
+
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
34
|
+
const { width } = resizeState.cols[columnIndex];
|
|
35
|
+
const mapIndex = rowIndex * map.width + columnIndex;
|
|
36
|
+
const cellPos = map.map[mapIndex];
|
|
37
|
+
const attrs = updatedCellsAttrs[cellPos] || {
|
|
38
|
+
...table.nodeAt(cellPos)!.attrs,
|
|
39
|
+
};
|
|
40
|
+
const colspan = attrs.colspan || 1;
|
|
41
|
+
|
|
42
|
+
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
43
|
+
tr = setMeta({
|
|
44
|
+
type: 'UPDATE_COLUMN_WIDTHS',
|
|
45
|
+
problem: 'COLWIDTHS_BEFORE_UPDATE',
|
|
46
|
+
data: { colwidths: attrs.colwidth, colspan },
|
|
47
|
+
})(tr);
|
|
48
|
+
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Rowspanning cell that has already been handled
|
|
52
|
+
if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const colspanIndex =
|
|
56
|
+
colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
|
|
57
|
+
if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let colwidths = attrs.colwidth
|
|
62
|
+
? attrs.colwidth.slice()
|
|
63
|
+
: Array.from({ length: colspan }, (_) => 0);
|
|
64
|
+
|
|
65
|
+
colwidths[colspanIndex] = width;
|
|
66
|
+
if (colwidths.length > colspan) {
|
|
67
|
+
tr = setMeta({
|
|
68
|
+
type: 'UPDATE_COLUMN_WIDTHS',
|
|
69
|
+
problem: 'COLWIDTHS_AFTER_UPDATE',
|
|
70
|
+
data: { colwidths, colspan },
|
|
71
|
+
})(tr);
|
|
72
|
+
colwidths = colwidths.slice(0, colspan);
|
|
73
|
+
}
|
|
74
|
+
updatedCellsAttrs[cellPos] = {
|
|
75
|
+
...attrs,
|
|
76
|
+
colwidth: colwidths.includes(0) ? undefined : colwidths,
|
|
77
|
+
};
|
|
75
78
|
}
|
|
76
|
-
updatedCellsAttrs[cellPos] = {
|
|
77
|
-
...attrs,
|
|
78
|
-
colwidth: colwidths.includes(0) ? undefined : colwidths,
|
|
79
|
-
};
|
|
80
79
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// updating all cells with new attributes
|
|
84
|
-
const rows: PMNode[] = [];
|
|
85
|
-
const seen: { [key: number]: boolean } = {};
|
|
86
|
-
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
87
|
-
const row = table.child(rowIndex);
|
|
88
|
-
const cells: PMNode[] = [];
|
|
89
80
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)
|
|
102
|
-
|
|
81
|
+
// updating all cells with new attributes
|
|
82
|
+
const rows: PMNode[] = [];
|
|
83
|
+
const seen: { [key: number]: boolean } = {};
|
|
84
|
+
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
85
|
+
const row = table.child(rowIndex);
|
|
86
|
+
const cells: PMNode[] = [];
|
|
87
|
+
|
|
88
|
+
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
89
|
+
const mapIndex = rowIndex * map.width + columnIndex;
|
|
90
|
+
const pos = map.map[mapIndex];
|
|
91
|
+
const cell = table.nodeAt(pos);
|
|
92
|
+
if (!seen[pos] && cell) {
|
|
93
|
+
cells.push(
|
|
94
|
+
cell.type.createChecked(
|
|
95
|
+
updatedCellsAttrs[pos] || cell.attrs,
|
|
96
|
+
cell.content,
|
|
97
|
+
cell.marks,
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
seen[pos] = true;
|
|
101
|
+
}
|
|
103
102
|
}
|
|
103
|
+
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
127
|
-
};
|
|
105
|
+
|
|
106
|
+
const tablePos = start - 1;
|
|
107
|
+
const selectionBookmark = tr.selection.getBookmark();
|
|
108
|
+
|
|
109
|
+
tr.replaceWith(
|
|
110
|
+
tablePos,
|
|
111
|
+
tablePos + table.nodeSize,
|
|
112
|
+
table.type.createChecked(table.attrs, rows, table.marks),
|
|
113
|
+
);
|
|
114
|
+
/**
|
|
115
|
+
* We want to restore to the original selection but w/o applying the mapping. Function
|
|
116
|
+
* tr.replaceWith puts the selection after the inserted content. We need to manually
|
|
117
|
+
* set the selection back to original state. Mapping in this case doesn't quite work
|
|
118
|
+
* e.g. if we change the content before a selection. This is because mapping
|
|
119
|
+
* means moving it if the content in front of it changed. Instead we can get
|
|
120
|
+
* bookmark of selection.
|
|
121
|
+
*
|
|
122
|
+
* @see https://github.com/ProseMirror/prosemirror/issues/645
|
|
123
|
+
*/
|
|
124
|
+
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
125
|
+
};
|
|
128
126
|
|
|
129
127
|
/**
|
|
130
128
|
* This function is called when user inserts/deletes a column in a table to;
|
|
@@ -136,52 +134,51 @@ export const updateColumnWidths = (
|
|
|
136
134
|
* @param view
|
|
137
135
|
* @returns Updated transaction with rescaled columns for a given table
|
|
138
136
|
*/
|
|
139
|
-
export const rescaleColumns =
|
|
140
|
-
getEditorContainerWidth: GetEditorContainerWidth
|
|
141
|
-
|
|
142
|
-
tr: Transaction
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
};
|
|
137
|
+
export const rescaleColumns =
|
|
138
|
+
(getEditorContainerWidth: GetEditorContainerWidth) =>
|
|
139
|
+
(table: ContentNodeWithPos, view: EditorView | undefined) =>
|
|
140
|
+
(tr: Transaction): Transaction => {
|
|
141
|
+
// If the table has been not been resized we skip updating the size
|
|
142
|
+
// of columns here.
|
|
143
|
+
if (!view || !hasTableBeenResized(table.node)) {
|
|
144
|
+
return tr;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const { state } = view;
|
|
148
|
+
const domAtPos = view.domAtPos.bind(view);
|
|
149
|
+
|
|
150
|
+
const maybeTable = domAtPos(table.start).node as HTMLElement;
|
|
151
|
+
const tableRef = maybeTable.closest('table');
|
|
152
|
+
|
|
153
|
+
if (!tableRef) {
|
|
154
|
+
return tr;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const layout = normaliseTableLayout(tableRef?.dataset.layout);
|
|
158
|
+
// The is the width the table can reach before overflowing
|
|
159
|
+
const maxSize = getTableMaxWidth({
|
|
160
|
+
table: table.node,
|
|
161
|
+
tableStart: table.start,
|
|
162
|
+
state,
|
|
163
|
+
layout,
|
|
164
|
+
getEditorContainerWidth,
|
|
165
|
+
});
|
|
166
|
+
let resizeState = getResizeState({
|
|
167
|
+
minWidth: tableCellMinWidth,
|
|
168
|
+
table: table.node,
|
|
169
|
+
start: table.start,
|
|
170
|
+
tableRef,
|
|
171
|
+
domAtPos,
|
|
172
|
+
maxSize,
|
|
173
|
+
});
|
|
174
|
+
const previousTableWidth = resizeState.tableWidth - tableNewColumnMinWidth;
|
|
175
|
+
const tableDidntPreviouslyOverflow = previousTableWidth <= maxSize;
|
|
176
|
+
|
|
177
|
+
// If the new table width will result in the table going into an overflow state
|
|
178
|
+
// we resize the cells to avoid the overflow occuring
|
|
179
|
+
if (tableDidntPreviouslyOverflow && resizeState.overflow) {
|
|
180
|
+
resizeState = scaleTableTo(resizeState, maxSize);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
184
|
+
};
|
|
@@ -9,173 +9,175 @@ import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
|
9
9
|
import { setMeta } from './metadata';
|
|
10
10
|
import { splitCellsInColumns } from './split';
|
|
11
11
|
|
|
12
|
-
const deleteColumnsCustomStep =
|
|
13
|
-
|
|
14
|
-
): Transaction => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Need to split all the merge in the ranges (this is the current behaviour)
|
|
21
|
-
// Maybe is better to split only the last column?
|
|
22
|
-
// TODO: After talking with Roto about this behaviour, he likes when we dont split the columns, I am keeping this for consistency of the current implementation.
|
|
23
|
-
splitCellsInColumns(tr, table.pos, rect.left, rect.right);
|
|
24
|
-
|
|
25
|
-
// Delete the columns
|
|
26
|
-
let mapStart = tr.mapping.maps.length;
|
|
27
|
-
const originalDoc = tr.doc;
|
|
28
|
-
const deletedColumns = [];
|
|
29
|
-
for (let i = rect.left; i < rect.right; i++) {
|
|
30
|
-
const step = AddColumnStep.create(originalDoc, table.pos, i, true);
|
|
31
|
-
deletedColumns.push(i);
|
|
32
|
-
tr.step(step.map(tr.mapping.slice(mapStart))!);
|
|
33
|
-
}
|
|
12
|
+
const deleteColumnsCustomStep =
|
|
13
|
+
(rect: Rect) =>
|
|
14
|
+
(tr: Transaction): Transaction => {
|
|
15
|
+
const table = findTable(tr.selection);
|
|
16
|
+
if (!table) {
|
|
17
|
+
return tr;
|
|
18
|
+
}
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
tr.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
// Need to split all the merge in the ranges (this is the current behaviour)
|
|
21
|
+
// Maybe is better to split only the last column?
|
|
22
|
+
// TODO: After talking with Roto about this behaviour, he likes when we dont split the columns, I am keeping this for consistency of the current implementation.
|
|
23
|
+
splitCellsInColumns(tr, table.pos, rect.left, rect.right);
|
|
24
|
+
|
|
25
|
+
// Delete the columns
|
|
26
|
+
let mapStart = tr.mapping.maps.length;
|
|
27
|
+
const originalDoc = tr.doc;
|
|
28
|
+
const deletedColumns = [];
|
|
29
|
+
for (let i = rect.left; i < rect.right; i++) {
|
|
30
|
+
const step = AddColumnStep.create(originalDoc, table.pos, i, true);
|
|
31
|
+
deletedColumns.push(i);
|
|
32
|
+
tr.step(step.map(tr.mapping.slice(mapStart))!);
|
|
44
33
|
}
|
|
45
|
-
}
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
const tablePosResult = tr.mapping.mapResult(table.pos);
|
|
36
|
+
if (tablePosResult.deleted) {
|
|
37
|
+
const pos = Math.min(tablePosResult.pos, tr.doc.nodeSize - 1);
|
|
38
|
+
tr.setSelection(Selection.near(tr.doc.resolve(pos)));
|
|
39
|
+
} else {
|
|
40
|
+
const newTable = tr.doc.nodeAt(tablePosResult.pos);
|
|
41
|
+
if (newTable) {
|
|
42
|
+
const cursorPos = getNextCursorPos(newTable, deletedColumns);
|
|
43
|
+
tr.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
49
46
|
|
|
50
|
-
const deleteColumnsLegacy = (rect: Rect) => (tr: Transaction): Transaction => {
|
|
51
|
-
const table = findTable(tr.selection);
|
|
52
|
-
if (!table) {
|
|
53
47
|
return tr;
|
|
54
|
-
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const deleteColumnsLegacy =
|
|
51
|
+
(rect: Rect) =>
|
|
52
|
+
(tr: Transaction): Transaction => {
|
|
53
|
+
const table = findTable(tr.selection);
|
|
54
|
+
if (!table) {
|
|
55
|
+
return tr;
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const columnsToDelete: number[] = [];
|
|
59
|
+
for (let i = rect.left; i < rect.right; i++) {
|
|
60
|
+
columnsToDelete.push(i);
|
|
61
|
+
}
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (!columnsToDelete.length) {
|
|
64
|
+
return tr;
|
|
65
|
+
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const map = TableMap.get(table.node);
|
|
68
|
+
const rows: PMNode[] = [];
|
|
69
|
+
const seen: { [key: string]: boolean } = {};
|
|
70
|
+
const deletedCells: { [key: string]: boolean } = {};
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
72
|
+
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
73
|
+
const rowCells: PMNode[] = [];
|
|
74
|
+
const row = table.node.child(rowIndex);
|
|
75
|
+
|
|
76
|
+
for (let colIndex = 0; colIndex < map.width; colIndex++) {
|
|
77
|
+
const cellPos = map.map[rowIndex * map.width + colIndex];
|
|
78
|
+
const cell = table.node.nodeAt(cellPos);
|
|
79
|
+
if (!cell) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const cellsInColumn = map.cellsInRect({
|
|
83
|
+
left: colIndex,
|
|
84
|
+
top: 0,
|
|
85
|
+
right: colIndex + 1,
|
|
86
|
+
bottom: map.height,
|
|
87
|
+
});
|
|
88
|
+
if (columnsToDelete.indexOf(colIndex) === -1) {
|
|
89
|
+
// decrement colspans for col-spanning cells that overlap deleted columns
|
|
90
|
+
if (cellsInColumn.indexOf(cellPos) > -1 && !seen[cellPos]) {
|
|
91
|
+
let overlappingCols = 0;
|
|
92
|
+
columnsToDelete.forEach((colIndexToDelete) => {
|
|
93
|
+
if (
|
|
94
|
+
colIndex < colIndexToDelete &&
|
|
95
|
+
cell.attrs.colspan + colIndex - 1 >= colIndexToDelete
|
|
96
|
+
) {
|
|
97
|
+
overlappingCols += 1;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (overlappingCols > 0) {
|
|
101
|
+
const attrs: CellAttributes = {
|
|
102
|
+
...cell.attrs,
|
|
103
|
+
colspan: cell.attrs.colspan - overlappingCols,
|
|
104
|
+
};
|
|
105
|
+
if (cell.attrs.colwidth) {
|
|
106
|
+
const minColIndex = Math.min(...columnsToDelete);
|
|
107
|
+
const pos =
|
|
108
|
+
minColIndex > 0 ? minColIndex - map.colCount(cellPos) : 0;
|
|
109
|
+
const colwidth = cell.attrs.colwidth.slice() || [];
|
|
110
|
+
colwidth.splice(pos, overlappingCols);
|
|
111
|
+
attrs.colwidth = colwidth;
|
|
112
|
+
}
|
|
113
|
+
const newCell = cell.type.createChecked(
|
|
114
|
+
attrs,
|
|
115
|
+
cell.content,
|
|
116
|
+
cell.marks,
|
|
117
|
+
);
|
|
118
|
+
rowCells.push(newCell);
|
|
119
|
+
seen[cellPos] = true;
|
|
120
|
+
continue;
|
|
96
121
|
}
|
|
97
|
-
})
|
|
98
|
-
|
|
122
|
+
} else if (deletedCells[cellPos]) {
|
|
123
|
+
// if we're removing a col-spanning cell, we need to add missing cells to columns to the right
|
|
99
124
|
const attrs: CellAttributes = {
|
|
100
125
|
...cell.attrs,
|
|
101
|
-
colspan:
|
|
126
|
+
colspan: 1,
|
|
127
|
+
rowspan: 1,
|
|
102
128
|
};
|
|
103
129
|
if (cell.attrs.colwidth) {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
minColIndex > 0 ? minColIndex - map.colCount(cellPos) : 0;
|
|
107
|
-
const colwidth = cell.attrs.colwidth.slice() || [];
|
|
108
|
-
colwidth.splice(pos, overlappingCols);
|
|
109
|
-
attrs.colwidth = colwidth;
|
|
130
|
+
const pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
|
|
131
|
+
attrs.colwidth = cell.attrs.colwidth.slice().splice(pos, 1);
|
|
110
132
|
}
|
|
111
133
|
const newCell = cell.type.createChecked(
|
|
112
134
|
attrs,
|
|
113
|
-
cell.
|
|
135
|
+
cell.type.schema.nodes.paragraph.createChecked(),
|
|
114
136
|
cell.marks,
|
|
115
137
|
);
|
|
116
138
|
rowCells.push(newCell);
|
|
117
|
-
seen[cellPos] = true;
|
|
118
139
|
continue;
|
|
119
140
|
}
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
rowspan: 1,
|
|
126
|
-
};
|
|
127
|
-
if (cell.attrs.colwidth) {
|
|
128
|
-
const pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
|
|
129
|
-
attrs.colwidth = cell.attrs.colwidth.slice().splice(pos, 1);
|
|
141
|
+
|
|
142
|
+
// normal cells that we want to keep
|
|
143
|
+
if (!seen[cellPos]) {
|
|
144
|
+
seen[cellPos] = true;
|
|
145
|
+
rowCells.push(cell);
|
|
130
146
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
cell.type.schema.nodes.paragraph.createChecked(),
|
|
134
|
-
cell.marks,
|
|
135
|
-
);
|
|
136
|
-
rowCells.push(newCell);
|
|
137
|
-
continue;
|
|
147
|
+
} else if (cellsInColumn.indexOf(cellPos) > -1) {
|
|
148
|
+
deletedCells[cellPos] = true;
|
|
138
149
|
}
|
|
150
|
+
}
|
|
139
151
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
seen[cellPos] = true;
|
|
143
|
-
rowCells.push(cell);
|
|
144
|
-
}
|
|
145
|
-
} else if (cellsInColumn.indexOf(cellPos) > -1) {
|
|
146
|
-
deletedCells[cellPos] = true;
|
|
152
|
+
if (rowCells.length) {
|
|
153
|
+
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
156
|
|
|
150
|
-
if (
|
|
151
|
-
|
|
157
|
+
if (!rows.length) {
|
|
158
|
+
return setMeta({ type: 'DELETE_COLUMNS', problem: 'EMPTY_TABLE' })(tr);
|
|
152
159
|
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (!rows.length) {
|
|
156
|
-
return setMeta({ type: 'DELETE_COLUMNS', problem: 'EMPTY_TABLE' })(tr);
|
|
157
|
-
}
|
|
158
160
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
const newTable = table.node.type.createChecked(
|
|
162
|
+
table.node.attrs,
|
|
163
|
+
rows,
|
|
164
|
+
table.node.marks,
|
|
165
|
+
);
|
|
164
166
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
const fixedTable = fixRowSpans(newTable);
|
|
168
|
+
if (fixedTable === null) {
|
|
169
|
+
return setMeta({ type: 'DELETE_COLUMNS', problem: 'FIX_ROWSPANS' })(tr);
|
|
170
|
+
}
|
|
169
171
|
|
|
170
|
-
|
|
172
|
+
const cursorPos = getNextCursorPos(newTable, columnsToDelete);
|
|
171
173
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
174
|
+
return setMeta({ type: 'DELETE_COLUMNS' })(
|
|
175
|
+
tr
|
|
176
|
+
.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
177
|
+
// move cursor to the left of the deleted columns if possible, otherwise - to the first column
|
|
178
|
+
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))),
|
|
179
|
+
);
|
|
180
|
+
};
|
|
179
181
|
|
|
180
182
|
function getNextCursorPos(table: PMNode, deletedColumns: number[]): number {
|
|
181
183
|
const minColumn = Math.min(...deletedColumns);
|
|
@@ -241,11 +243,11 @@ function fixRowSpans(table: PMNode): PMNode | null {
|
|
|
241
243
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
242
244
|
}
|
|
243
245
|
|
|
244
|
-
export const deleteColumns =
|
|
245
|
-
|
|
246
|
-
): Transaction => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
};
|
|
246
|
+
export const deleteColumns =
|
|
247
|
+
(rect: Rect, allowAddColumnCustomStep = false) =>
|
|
248
|
+
(tr: Transaction): Transaction => {
|
|
249
|
+
if (allowAddColumnCustomStep) {
|
|
250
|
+
return deleteColumnsCustomStep(rect)(tr);
|
|
251
|
+
}
|
|
252
|
+
return deleteColumnsLegacy(rect)(tr);
|
|
253
|
+
};
|