@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
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
isLastItemMediaGroup,
|
|
24
24
|
setNodeSelection,
|
|
25
25
|
} from '@atlaskit/editor-common/utils';
|
|
26
|
-
// import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
|
|
27
26
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
28
27
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
29
28
|
import {
|
|
@@ -180,9 +179,8 @@ export const handleMouseOver = (
|
|
|
180
179
|
}
|
|
181
180
|
const { state, dispatch } = view;
|
|
182
181
|
const target = mouseEvent.target;
|
|
183
|
-
const { insertColumnButtonIndex, insertRowButtonIndex } =
|
|
184
|
-
state
|
|
185
|
-
);
|
|
182
|
+
const { insertColumnButtonIndex, insertRowButtonIndex } =
|
|
183
|
+
getPluginState(state);
|
|
186
184
|
|
|
187
185
|
if (isInsertRowButton(target)) {
|
|
188
186
|
const [startIndex, endIndex] = getColumnOrRowIndex(target);
|
|
@@ -277,9 +275,8 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
|
|
|
277
275
|
}
|
|
278
276
|
|
|
279
277
|
const { state, dispatch } = view;
|
|
280
|
-
const { insertColumnButtonIndex, insertRowButtonIndex } =
|
|
281
|
-
state
|
|
282
|
-
);
|
|
278
|
+
const { insertColumnButtonIndex, insertRowButtonIndex } =
|
|
279
|
+
getPluginState(state);
|
|
283
280
|
|
|
284
281
|
const target = event.target;
|
|
285
282
|
if (isTableControlsButton(target)) {
|
|
@@ -297,99 +294,99 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
|
|
|
297
294
|
return false;
|
|
298
295
|
};
|
|
299
296
|
|
|
300
|
-
export const handleMouseMove =
|
|
301
|
-
getEditorFeatureFlags: GetEditorFeatureFlags
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
) => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (isColumnControlsDecorations(element)) {
|
|
314
|
-
const { state, dispatch } = view;
|
|
315
|
-
const { insertColumnButtonIndex } = getPluginState(state);
|
|
316
|
-
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
317
|
-
|
|
318
|
-
const positionColumn =
|
|
319
|
-
getMousePositionHorizontalRelativeByElement(
|
|
320
|
-
event as MouseEvent,
|
|
321
|
-
tableCellOptimization,
|
|
322
|
-
elementContentRects,
|
|
323
|
-
) === 'right'
|
|
324
|
-
? endIndex
|
|
325
|
-
: startIndex;
|
|
297
|
+
export const handleMouseMove =
|
|
298
|
+
(getEditorFeatureFlags: GetEditorFeatureFlags) =>
|
|
299
|
+
(
|
|
300
|
+
view: EditorView,
|
|
301
|
+
event: Event,
|
|
302
|
+
tableCellOptimization?: boolean,
|
|
303
|
+
elementContentRects?: ElementContentRects,
|
|
304
|
+
) => {
|
|
305
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
const element = event.target;
|
|
326
309
|
|
|
327
|
-
if (
|
|
328
|
-
|
|
310
|
+
if (isColumnControlsDecorations(element)) {
|
|
311
|
+
const { state, dispatch } = view;
|
|
312
|
+
const { insertColumnButtonIndex } = getPluginState(state);
|
|
313
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
314
|
+
|
|
315
|
+
const positionColumn =
|
|
316
|
+
getMousePositionHorizontalRelativeByElement(
|
|
317
|
+
event as MouseEvent,
|
|
318
|
+
tableCellOptimization,
|
|
319
|
+
elementContentRects,
|
|
320
|
+
) === 'right'
|
|
321
|
+
? endIndex
|
|
322
|
+
: startIndex;
|
|
323
|
+
|
|
324
|
+
if (positionColumn !== insertColumnButtonIndex) {
|
|
325
|
+
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
326
|
+
}
|
|
329
327
|
}
|
|
330
|
-
}
|
|
331
328
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
329
|
+
if (isRowControlsButton(element)) {
|
|
330
|
+
const { state, dispatch } = view;
|
|
331
|
+
const { insertRowButtonIndex } = getPluginState(state);
|
|
332
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
336
333
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
334
|
+
const positionRow =
|
|
335
|
+
getMousePositionVerticalRelativeByElement(event as MouseEvent) ===
|
|
336
|
+
'bottom'
|
|
337
|
+
? endIndex
|
|
338
|
+
: startIndex;
|
|
342
339
|
|
|
343
|
-
|
|
344
|
-
|
|
340
|
+
if (positionRow !== insertRowButtonIndex) {
|
|
341
|
+
return showInsertRowButton(positionRow)(state, dispatch);
|
|
342
|
+
}
|
|
345
343
|
}
|
|
346
|
-
}
|
|
347
344
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
355
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(
|
|
356
|
-
event as MouseEvent,
|
|
357
|
-
useMouseMoveOptimisation,
|
|
358
|
-
elementContentRects,
|
|
359
|
-
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
360
|
-
);
|
|
345
|
+
const { mouseMoveOptimization } = getEditorFeatureFlags();
|
|
346
|
+
// we only want to allow mouseMoveOptimisation when tableCellOptimization is enabled
|
|
347
|
+
// because it relies on tableCell node view that is added via tableCellOptimization
|
|
348
|
+
const useMouseMoveOptimisation =
|
|
349
|
+
tableCellOptimization && mouseMoveOptimization;
|
|
361
350
|
|
|
362
|
-
if (
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
) as HTMLTableCellElement;
|
|
369
|
-
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
370
|
-
const rect = findCellRectClosestToPos(
|
|
371
|
-
state.doc.resolve(cellStartPosition),
|
|
351
|
+
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
352
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(
|
|
353
|
+
event as MouseEvent,
|
|
354
|
+
useMouseMoveOptimisation,
|
|
355
|
+
elementContentRects,
|
|
356
|
+
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
372
357
|
);
|
|
373
358
|
|
|
374
|
-
if (
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
359
|
+
if (positionColumn !== null) {
|
|
360
|
+
const { state, dispatch } = view;
|
|
361
|
+
const { resizeHandleColumnIndex } = getPluginState(state);
|
|
362
|
+
const tableCell = closestElement(
|
|
363
|
+
element,
|
|
364
|
+
'td, th',
|
|
365
|
+
) as HTMLTableCellElement;
|
|
366
|
+
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
367
|
+
const rect = findCellRectClosestToPos(
|
|
368
|
+
state.doc.resolve(cellStartPosition),
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
if (rect) {
|
|
372
|
+
const columnEndIndexTarget =
|
|
373
|
+
positionColumn === 'left' ? rect.left : rect.right;
|
|
374
|
+
|
|
375
|
+
if (
|
|
376
|
+
columnEndIndexTarget !== resizeHandleColumnIndex ||
|
|
377
|
+
!hasResizeHandler({ target: element, columnEndIndexTarget })
|
|
378
|
+
) {
|
|
379
|
+
return addResizeHandleDecorations(columnEndIndexTarget)(
|
|
380
|
+
state,
|
|
381
|
+
dispatch,
|
|
382
|
+
);
|
|
383
|
+
}
|
|
386
384
|
}
|
|
387
385
|
}
|
|
388
386
|
}
|
|
389
|
-
}
|
|
390
387
|
|
|
391
|
-
|
|
392
|
-
};
|
|
388
|
+
return false;
|
|
389
|
+
};
|
|
393
390
|
|
|
394
391
|
export function handleTripleClick(view: EditorView, pos: number) {
|
|
395
392
|
const { state, dispatch } = view;
|
|
@@ -483,31 +480,33 @@ export const handleCut = (
|
|
|
483
480
|
return tr;
|
|
484
481
|
};
|
|
485
482
|
|
|
486
|
-
export const whenTableInFocus =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
483
|
+
export const whenTableInFocus =
|
|
484
|
+
(
|
|
485
|
+
eventHandler: (
|
|
486
|
+
view: EditorView,
|
|
487
|
+
mouseEvent: Event,
|
|
488
|
+
tableCellOptimization?: boolean,
|
|
489
|
+
elementContentRects?: ElementContentRects,
|
|
490
|
+
) => boolean,
|
|
491
491
|
elementContentRects?: ElementContentRects,
|
|
492
|
-
) =>
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
492
|
+
) =>
|
|
493
|
+
(view: EditorView, mouseEvent: Event): boolean => {
|
|
494
|
+
const tableResizePluginState = getResizePluginState(view.state);
|
|
495
|
+
const tablePluginState = getPluginState(view.state);
|
|
496
|
+
const isDragging =
|
|
497
|
+
tableResizePluginState && !!tableResizePluginState.dragging;
|
|
498
|
+
const hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
499
|
+
const tableCellOptimization =
|
|
500
|
+
tablePluginState?.pluginConfig?.tableCellOptimization;
|
|
501
|
+
|
|
502
|
+
if (!hasTableNode || isDragging) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
506
505
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
};
|
|
506
|
+
return eventHandler(
|
|
507
|
+
view,
|
|
508
|
+
mouseEvent,
|
|
509
|
+
tableCellOptimization,
|
|
510
|
+
elementContentRects,
|
|
511
|
+
);
|
|
512
|
+
};
|
|
@@ -3,7 +3,6 @@ import { Transaction, ReadonlyTransaction } from 'prosemirror-state';
|
|
|
3
3
|
import { ContentNodeWithPos, findParentNodeOfType } from 'prosemirror-utils';
|
|
4
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
|
|
6
|
-
// import { isTextInput } from '../../utils/is-text-input';
|
|
7
6
|
import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
8
7
|
import { isTableCollapsible } from './utils/collapse';
|
|
9
8
|
|
|
@@ -48,112 +47,113 @@ type BuilderTablePluginState = (props: {
|
|
|
48
47
|
table?: ContentNodeWithPos;
|
|
49
48
|
}) => (pluginState: TablePluginState) => TablePluginState;
|
|
50
49
|
|
|
51
|
-
const updateTargetCellPosition: BuilderTablePluginState =
|
|
52
|
-
|
|
53
|
-
) => {
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const updateTargetCellPosition: BuilderTablePluginState =
|
|
51
|
+
({ tr, table }) =>
|
|
52
|
+
(pluginState: TablePluginState) => {
|
|
53
|
+
const tableNode = table && table.node;
|
|
54
|
+
if (!tableNode) {
|
|
55
|
+
return {
|
|
56
|
+
...pluginState,
|
|
57
|
+
targetCellPosition: undefined,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { tableCell, tableHeader } = tr.doc.type.schema.nodes;
|
|
62
|
+
const cell = findParentNodeOfType([tableCell, tableHeader])(tr.selection);
|
|
63
|
+
const targetCellPosition = cell ? cell.pos : undefined;
|
|
64
|
+
|
|
65
|
+
if (pluginState.targetCellPosition === targetCellPosition) {
|
|
66
|
+
return pluginState;
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
return {
|
|
57
70
|
...pluginState,
|
|
58
|
-
targetCellPosition
|
|
71
|
+
targetCellPosition,
|
|
59
72
|
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const { tableCell, tableHeader } = tr.doc.type.schema.nodes;
|
|
63
|
-
const cell = findParentNodeOfType([tableCell, tableHeader])(tr.selection);
|
|
64
|
-
const targetCellPosition = cell ? cell.pos : undefined;
|
|
65
|
-
|
|
66
|
-
if (pluginState.targetCellPosition === targetCellPosition) {
|
|
67
|
-
return pluginState;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...pluginState,
|
|
72
|
-
targetCellPosition,
|
|
73
73
|
};
|
|
74
|
-
};
|
|
75
74
|
|
|
76
|
-
const updateTableNodePluginState: BuilderTablePluginState =
|
|
77
|
-
|
|
78
|
-
) => {
|
|
79
|
-
|
|
75
|
+
const updateTableNodePluginState: BuilderTablePluginState =
|
|
76
|
+
({ tr, table }) =>
|
|
77
|
+
(pluginState) => {
|
|
78
|
+
const tableNode = table && table.node;
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
if (!tableNode || isTextInput(tr)) {
|
|
81
|
+
return pluginState;
|
|
82
|
+
}
|
|
84
83
|
|
|
85
|
-
return {
|
|
86
|
-
...pluginState,
|
|
87
|
-
...defaultTableSelection,
|
|
88
|
-
tableNode,
|
|
89
|
-
ordering: nextTableSorting(tr, table),
|
|
90
|
-
resizeHandleColumnIndex: nextResizeHandleColumnIndex(
|
|
91
|
-
tr,
|
|
92
|
-
pluginState.resizeHandleColumnIndex,
|
|
93
|
-
),
|
|
94
|
-
isNumberColumnEnabled: checkIfNumberColumnEnabled(tr.selection),
|
|
95
|
-
isHeaderColumnEnabled: checkIfHeaderColumnEnabled(tr.selection),
|
|
96
|
-
isHeaderRowEnabled: checkIfHeaderRowEnabled(tr.selection),
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const updateCollapseHandler: BuilderTablePluginState = ({ tr, table }) => (
|
|
101
|
-
pluginState,
|
|
102
|
-
) => {
|
|
103
|
-
const tableNode = table && table.node;
|
|
104
|
-
const schema = tr.doc.type.schema;
|
|
105
|
-
const allowCollapse = pluginState.pluginConfig.allowCollapse;
|
|
106
|
-
const isExpandInSchema = schema.nodes.expand !== undefined;
|
|
107
|
-
const isCollapseEnabled = allowCollapse && isExpandInSchema;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* If we don't have focus, or collapse isn't allowed, or a table node doesn't
|
|
111
|
-
* exist, we don't need to waste extra checks below
|
|
112
|
-
*/
|
|
113
|
-
if (!pluginState.editorHasFocus || !isCollapseEnabled || !tableNode) {
|
|
114
|
-
return pluginState;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const expandNodeType = schema.nodes.expand as NodeType;
|
|
118
|
-
const isTableCollapsed =
|
|
119
|
-
expandNodeType && !!findParentNodeOfType(expandNodeType)(tr.selection);
|
|
120
|
-
|
|
121
|
-
const trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible;
|
|
122
|
-
|
|
123
|
-
// We're focused on a table + we're not inside an expand
|
|
124
|
-
const canCollapseTable: boolean =
|
|
125
|
-
!!pluginState.tableNode &&
|
|
126
|
-
// is it already collapsed?
|
|
127
|
-
!isTableCollapsed &&
|
|
128
|
-
!!trCanBeCollapsed;
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
pluginState.isTableCollapsed !== isTableCollapsed ||
|
|
132
|
-
pluginState.canCollapseTable !== canCollapseTable
|
|
133
|
-
) {
|
|
134
84
|
return {
|
|
135
85
|
...pluginState,
|
|
136
|
-
|
|
137
|
-
|
|
86
|
+
...defaultTableSelection,
|
|
87
|
+
tableNode,
|
|
88
|
+
ordering: nextTableSorting(tr, table),
|
|
89
|
+
resizeHandleColumnIndex: nextResizeHandleColumnIndex(
|
|
90
|
+
tr,
|
|
91
|
+
pluginState.resizeHandleColumnIndex,
|
|
92
|
+
),
|
|
93
|
+
isNumberColumnEnabled: checkIfNumberColumnEnabled(tr.selection),
|
|
94
|
+
isHeaderColumnEnabled: checkIfHeaderColumnEnabled(tr.selection),
|
|
95
|
+
isHeaderRowEnabled: checkIfHeaderRowEnabled(tr.selection),
|
|
138
96
|
};
|
|
139
|
-
}
|
|
97
|
+
};
|
|
140
98
|
|
|
141
|
-
|
|
142
|
-
}
|
|
99
|
+
const updateCollapseHandler: BuilderTablePluginState =
|
|
100
|
+
({ tr, table }) =>
|
|
101
|
+
(pluginState) => {
|
|
102
|
+
const tableNode = table && table.node;
|
|
103
|
+
const schema = tr.doc.type.schema;
|
|
104
|
+
const allowCollapse = pluginState.pluginConfig.allowCollapse;
|
|
105
|
+
const isExpandInSchema = schema.nodes.expand !== undefined;
|
|
106
|
+
const isCollapseEnabled = allowCollapse && isExpandInSchema;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* If we don't have focus, or collapse isn't allowed, or a table node doesn't
|
|
110
|
+
* exist, we don't need to waste extra checks below
|
|
111
|
+
*/
|
|
112
|
+
if (!pluginState.editorHasFocus || !isCollapseEnabled || !tableNode) {
|
|
113
|
+
return pluginState;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const expandNodeType = schema.nodes.expand as NodeType;
|
|
117
|
+
const isTableCollapsed =
|
|
118
|
+
expandNodeType && !!findParentNodeOfType(expandNodeType)(tr.selection);
|
|
119
|
+
|
|
120
|
+
const trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible;
|
|
121
|
+
|
|
122
|
+
// We're focused on a table + we're not inside an expand
|
|
123
|
+
const canCollapseTable: boolean =
|
|
124
|
+
!!pluginState.tableNode &&
|
|
125
|
+
// is it already collapsed?
|
|
126
|
+
!isTableCollapsed &&
|
|
127
|
+
!!trCanBeCollapsed;
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
pluginState.isTableCollapsed !== isTableCollapsed ||
|
|
131
|
+
pluginState.canCollapseTable !== canCollapseTable
|
|
132
|
+
) {
|
|
133
|
+
return {
|
|
134
|
+
...pluginState,
|
|
135
|
+
isTableCollapsed,
|
|
136
|
+
canCollapseTable,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
143
139
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
140
|
+
return pluginState;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const buildPluginState =
|
|
144
|
+
(builders: Array<BuilderTablePluginState>): BuilderTablePluginState =>
|
|
145
|
+
(props) =>
|
|
146
|
+
(pluginState) => {
|
|
147
|
+
if (!props.table) {
|
|
148
|
+
return pluginState.targetCellPosition
|
|
149
|
+
? { ...pluginState, targetCellPosition: undefined }
|
|
150
|
+
: pluginState;
|
|
151
|
+
}
|
|
152
|
+
return builders.reduce(
|
|
153
|
+
(_pluginState, transform) => transform(props)(_pluginState),
|
|
154
|
+
pluginState,
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
157
|
|
|
158
158
|
export const handleDocOrSelectionChanged = (
|
|
159
159
|
tr: Transaction | ReadonlyTransaction,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ACTION_SUBJECT_ID,
|
|
21
21
|
EVENT_TYPE,
|
|
22
22
|
INPUT_METHOD,
|
|
23
|
+
TABLE_ACTION,
|
|
23
24
|
} from '@atlaskit/editor-common/analytics';
|
|
24
25
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
25
26
|
|
|
@@ -59,6 +60,7 @@ import type {
|
|
|
59
60
|
GetEditorContainerWidth,
|
|
60
61
|
GetEditorFeatureFlags,
|
|
61
62
|
} from '@atlaskit/editor-common/types';
|
|
63
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
62
64
|
|
|
63
65
|
interface TablePluginOptions {
|
|
64
66
|
tableOptions: PluginConfig;
|
|
@@ -177,8 +179,31 @@ const tablesPlugin = (options?: TablePluginOptions): EditorPlugin => {
|
|
|
177
179
|
name: 'tableSelectionKeymap',
|
|
178
180
|
plugin: () => tableSelectionKeymapPlugin(options?.editorSelectionAPI),
|
|
179
181
|
},
|
|
180
|
-
{
|
|
181
|
-
|
|
182
|
+
{
|
|
183
|
+
name: 'tableEditing',
|
|
184
|
+
plugin: () =>
|
|
185
|
+
tableEditing({
|
|
186
|
+
reportFixedTable: ({
|
|
187
|
+
state,
|
|
188
|
+
tr,
|
|
189
|
+
reason,
|
|
190
|
+
}: {
|
|
191
|
+
state: EditorState;
|
|
192
|
+
tr: Transaction;
|
|
193
|
+
reason: string;
|
|
194
|
+
}) => {
|
|
195
|
+
options?.editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
196
|
+
action: TABLE_ACTION.FIXED,
|
|
197
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
198
|
+
actionSubjectId: null,
|
|
199
|
+
attributes: {
|
|
200
|
+
reason,
|
|
201
|
+
},
|
|
202
|
+
eventType: EVENT_TYPE.TRACK,
|
|
203
|
+
})(tr);
|
|
204
|
+
},
|
|
205
|
+
}) as SafePlugin,
|
|
206
|
+
},
|
|
182
207
|
{
|
|
183
208
|
name: 'tableStickyHeaders',
|
|
184
209
|
plugin: ({ dispatch, eventDispatcher }) =>
|
|
@@ -432,6 +457,7 @@ const tablesPlugin = (options?: TablePluginOptions): EditorPlugin => {
|
|
|
432
457
|
floatingToolbar: getToolbarConfig(
|
|
433
458
|
defaultGetEditorContainerWidth,
|
|
434
459
|
options?.editorAnalyticsAPI,
|
|
460
|
+
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
435
461
|
)(pluginConfig(options?.tableOptions)),
|
|
436
462
|
},
|
|
437
463
|
};
|
|
@@ -170,9 +170,10 @@ export class OverflowShadowsObserver {
|
|
|
170
170
|
}px`;
|
|
171
171
|
// Use getElementsByClassName here for a live node list to capture
|
|
172
172
|
// sticky shadows
|
|
173
|
-
const liveRightShadows =
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
const liveRightShadows =
|
|
174
|
+
this.wrapper?.parentElement?.getElementsByClassName(
|
|
175
|
+
`${ClassName.TABLE_RIGHT_SHADOW}`,
|
|
176
|
+
);
|
|
176
177
|
const liveLeftShadows = this.wrapper?.parentElement?.getElementsByClassName(
|
|
177
178
|
`${ClassName.TABLE_LEFT_SHADOW}`,
|
|
178
179
|
);
|
|
@@ -198,9 +198,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
198
198
|
componentDidUpdate(prevProps: ComponentProps) {
|
|
199
199
|
const { getNode, isMediaFullscreen, allowColumnResizing } = this.props;
|
|
200
200
|
|
|
201
|
-
const {
|
|
202
|
-
|
|
203
|
-
} = this.props.getEditorFeatureFlags();
|
|
201
|
+
const { tableOverflowShadowsOptimization } =
|
|
202
|
+
this.props.getEditorFeatureFlags();
|
|
204
203
|
|
|
205
204
|
if (!tableOverflowShadowsOptimization) {
|
|
206
205
|
this.updateShadows();
|
|
@@ -281,9 +280,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
281
280
|
};
|
|
282
281
|
|
|
283
282
|
onStickyState = (state: StickyPluginState) => {
|
|
284
|
-
const {
|
|
285
|
-
|
|
286
|
-
} = this.props.getEditorFeatureFlags();
|
|
283
|
+
const { tableOverflowShadowsOptimization } =
|
|
284
|
+
this.props.getEditorFeatureFlags();
|
|
287
285
|
|
|
288
286
|
const pos = this.props.getPos();
|
|
289
287
|
if (!isValidPosition(pos, this.props.view.state)) {
|
|
@@ -507,9 +505,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
507
505
|
}
|
|
508
506
|
}
|
|
509
507
|
|
|
510
|
-
const {
|
|
511
|
-
|
|
512
|
-
} = this.props.getEditorFeatureFlags();
|
|
508
|
+
const { tableOverflowShadowsOptimization } =
|
|
509
|
+
this.props.getEditorFeatureFlags();
|
|
513
510
|
|
|
514
511
|
if (!tableOverflowShadowsOptimization) {
|
|
515
512
|
this.updateShadows();
|