@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
|
@@ -20,61 +20,60 @@ import { getRowHeights } from '../../../utils/row-controls';
|
|
|
20
20
|
import { colWidthsForRow } from '../../../utils/column-controls';
|
|
21
21
|
import { getPluginState as getMainPluginState } from '../../plugin-factory';
|
|
22
22
|
|
|
23
|
-
export const updateControls =
|
|
24
|
-
getEditorFeatureFlags: GetEditorFeatureFlags
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
23
|
+
export const updateControls =
|
|
24
|
+
(getEditorFeatureFlags: GetEditorFeatureFlags) => (state: EditorState) => {
|
|
25
|
+
const { tableRef } = getMainPluginState(state);
|
|
26
|
+
if (!tableRef) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const tr = tableRef.querySelector('tr');
|
|
30
|
+
if (!tr) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const wrapper = tableRef.parentElement;
|
|
34
|
+
if (!(wrapper && wrapper.parentElement)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const rowControls = wrapper.parentElement.querySelectorAll<HTMLElement>(
|
|
39
|
+
`.${ClassName.ROW_CONTROLS_BUTTON_WRAP}`,
|
|
40
|
+
);
|
|
41
|
+
const numberedRows = wrapper.parentElement.querySelectorAll<HTMLElement>(
|
|
42
|
+
ClassName.NUMBERED_COLUMN_BUTTON,
|
|
43
|
+
);
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
syncStickyRowToTable(tableRef);
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
const rowHeights = getRowHeights(tableRef);
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
// update rows controls height on resize
|
|
50
|
+
for (let i = 0, count = rowControls.length; i < count; i++) {
|
|
51
|
+
const height = rowHeights[i];
|
|
52
|
+
if (height) {
|
|
53
|
+
rowControls[i].style.height = `${height}px`;
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if (numberedRows.length) {
|
|
56
|
+
numberedRows[i].style.height = `${height}px`;
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
}
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
61
|
+
const rightShadows = wrapper.parentElement.querySelectorAll<HTMLElement>(
|
|
62
|
+
`.${ClassName.TABLE_RIGHT_SHADOW}`,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const leftShadows = wrapper.parentElement.querySelectorAll<HTMLElement>(
|
|
66
|
+
`.${ClassName.TABLE_LEFT_SHADOW}`,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
updateOverflowShadows(getEditorFeatureFlags)(
|
|
70
|
+
state,
|
|
71
|
+
wrapper,
|
|
72
|
+
tableRef,
|
|
73
|
+
rightShadows,
|
|
74
|
+
leftShadows,
|
|
75
|
+
);
|
|
76
|
+
};
|
|
78
77
|
|
|
79
78
|
export const isClickNear = (
|
|
80
79
|
event: MouseEvent,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
1
3
|
import { defineMessages } from 'react-intl-next';
|
|
2
4
|
|
|
3
5
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
@@ -8,6 +10,7 @@ import type {
|
|
|
8
10
|
FloatingToolbarDropdown,
|
|
9
11
|
FloatingToolbarHandler,
|
|
10
12
|
FloatingToolbarItem,
|
|
13
|
+
GetEditorFeatureFlags,
|
|
11
14
|
} from '@atlaskit/editor-common/types';
|
|
12
15
|
|
|
13
16
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
@@ -26,6 +29,9 @@ import {
|
|
|
26
29
|
emptyMultipleCellsWithAnalytics,
|
|
27
30
|
insertColumnWithAnalytics,
|
|
28
31
|
wrapTableInExpandWithAnalytics,
|
|
32
|
+
sortColumnWithAnalytics,
|
|
33
|
+
setColorWithAnalytics,
|
|
34
|
+
distributeColumnsWidthsWithAnalytics,
|
|
29
35
|
} from './commands-with-analytics';
|
|
30
36
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
31
37
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
@@ -37,6 +43,7 @@ import {
|
|
|
37
43
|
PluginConfig,
|
|
38
44
|
TableCssClassName,
|
|
39
45
|
} from './types';
|
|
46
|
+
import { getMergedCellsPositions } from './utils';
|
|
40
47
|
import { isReferencedSource } from './utils/referentiality';
|
|
41
48
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
42
49
|
import {
|
|
@@ -56,6 +63,19 @@ import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
|
56
63
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
57
64
|
import { EditorView } from 'prosemirror-view';
|
|
58
65
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
66
|
+
import {
|
|
67
|
+
addColumnAfter,
|
|
68
|
+
addRowAfter,
|
|
69
|
+
tooltip,
|
|
70
|
+
backspace,
|
|
71
|
+
} from '@atlaskit/editor-common/keymaps';
|
|
72
|
+
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
73
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
74
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
75
|
+
import {
|
|
76
|
+
cellBackgroundColorPalette,
|
|
77
|
+
DEFAULT_BORDER_COLOR,
|
|
78
|
+
} from '@atlaskit/editor-common/ui-color';
|
|
59
79
|
|
|
60
80
|
export const messages = defineMessages({
|
|
61
81
|
tableOptions: {
|
|
@@ -145,6 +165,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
145
165
|
const { top, bottom, right, left } = initialSelectionRect;
|
|
146
166
|
const numberOfColumns = right - left;
|
|
147
167
|
const numberOfRows = bottom - top;
|
|
168
|
+
const pluginState = getPluginState(editorState);
|
|
148
169
|
|
|
149
170
|
const options = [
|
|
150
171
|
{
|
|
@@ -167,6 +188,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
167
188
|
},
|
|
168
189
|
selected: false,
|
|
169
190
|
disabled: false,
|
|
191
|
+
elemAfter: <div css={shortcutStyle}>{tooltip(addColumnAfter)}</div>,
|
|
170
192
|
},
|
|
171
193
|
{
|
|
172
194
|
id: 'editor.table.insertRow',
|
|
@@ -184,6 +206,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
184
206
|
},
|
|
185
207
|
selected: false,
|
|
186
208
|
disabled: false,
|
|
209
|
+
elemAfter: <div css={shortcutStyle}>{tooltip(addRowAfter)}</div>,
|
|
187
210
|
},
|
|
188
211
|
{
|
|
189
212
|
id: 'editor.table.removeColumns',
|
|
@@ -229,41 +252,114 @@ export const getToolbarCellOptionsConfig = (
|
|
|
229
252
|
{
|
|
230
253
|
id: 'editor.table.mergeCells',
|
|
231
254
|
title: formatMessage(ContextualMenuMessages.mergeCells),
|
|
232
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)
|
|
255
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(
|
|
256
|
+
INPUT_METHOD.FLOATING_TB,
|
|
257
|
+
),
|
|
233
258
|
selected: false,
|
|
234
259
|
disabled: !canMergeCells(editorState.tr),
|
|
235
260
|
},
|
|
236
261
|
{
|
|
237
262
|
id: 'editor.table.splitCell',
|
|
238
263
|
title: formatMessage(ContextualMenuMessages.splitCell),
|
|
239
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI)
|
|
264
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(
|
|
265
|
+
INPUT_METHOD.FLOATING_TB,
|
|
266
|
+
),
|
|
240
267
|
selected: false,
|
|
241
268
|
disabled: !splitCell(editorState),
|
|
242
269
|
},
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
270
|
+
];
|
|
271
|
+
|
|
272
|
+
if (pluginState?.pluginConfig?.allowDistributeColumns) {
|
|
273
|
+
const distributeColumnWidths: Command = (state, dispatch, view) => {
|
|
274
|
+
const newResizeStateWithAnalytics = view
|
|
275
|
+
? getNewResizeStateFromSelectedColumns(
|
|
276
|
+
initialSelectionRect,
|
|
277
|
+
editorState,
|
|
278
|
+
view.domAtPos.bind(view),
|
|
279
|
+
getEditorContainerWidth,
|
|
280
|
+
)
|
|
281
|
+
: undefined;
|
|
282
|
+
|
|
283
|
+
if (newResizeStateWithAnalytics) {
|
|
284
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(
|
|
285
|
+
INPUT_METHOD.FLOATING_TB,
|
|
286
|
+
newResizeStateWithAnalytics,
|
|
287
|
+
)(state, dispatch);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
options.push({
|
|
294
|
+
id: 'editor.table.distributeColumns',
|
|
295
|
+
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
296
|
+
onClick: distributeColumnWidths,
|
|
297
|
+
selected: false,
|
|
298
|
+
disabled: numberOfColumns <= 1,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (pluginState?.pluginConfig?.allowColumnSorting) {
|
|
303
|
+
const hasMergedCellsInTable =
|
|
304
|
+
getMergedCellsPositions(editorState.tr).length > 0;
|
|
305
|
+
|
|
306
|
+
options.push({
|
|
307
|
+
id: 'editor.table.sortColumnAsc',
|
|
308
|
+
title: formatMessage(ContextualMenuMessages.sortColumnASC),
|
|
248
309
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
249
|
-
|
|
250
|
-
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(
|
|
310
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
251
311
|
INPUT_METHOD.FLOATING_TB,
|
|
252
|
-
|
|
312
|
+
initialSelectionRect.left,
|
|
313
|
+
SortOrder.ASC,
|
|
253
314
|
)(state, dispatch);
|
|
254
315
|
return true;
|
|
255
316
|
},
|
|
256
317
|
selected: false,
|
|
257
|
-
disabled:
|
|
318
|
+
disabled: hasMergedCellsInTable,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
options.push({
|
|
322
|
+
id: 'editor.table.sortColumnDesc',
|
|
323
|
+
title: formatMessage(ContextualMenuMessages.sortColumnDESC),
|
|
324
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
325
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
326
|
+
INPUT_METHOD.FLOATING_TB,
|
|
327
|
+
initialSelectionRect.left,
|
|
328
|
+
SortOrder.DESC,
|
|
329
|
+
)(state, dispatch);
|
|
330
|
+
return true;
|
|
331
|
+
},
|
|
332
|
+
selected: false,
|
|
333
|
+
disabled: hasMergedCellsInTable,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
options.push({
|
|
338
|
+
id: 'editor.table.clearCells',
|
|
339
|
+
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
340
|
+
0: Math.max(numberOfColumns, numberOfRows),
|
|
341
|
+
}),
|
|
342
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
343
|
+
const { targetCellPosition } = getPluginState(state);
|
|
344
|
+
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(
|
|
345
|
+
INPUT_METHOD.FLOATING_TB,
|
|
346
|
+
targetCellPosition,
|
|
347
|
+
)(state, dispatch);
|
|
348
|
+
return true;
|
|
258
349
|
},
|
|
259
|
-
|
|
350
|
+
selected: false,
|
|
351
|
+
disabled: false,
|
|
352
|
+
elemAfter: <div css={shortcutStyle}>{tooltip(backspace)}</div>,
|
|
353
|
+
});
|
|
260
354
|
|
|
261
355
|
return {
|
|
262
356
|
id: 'editor.table.cellOptions',
|
|
263
357
|
type: 'dropdown',
|
|
264
358
|
title: formatMessage(tableMessages.cellOptions),
|
|
265
|
-
hidden: true,
|
|
266
359
|
options,
|
|
360
|
+
// Increased dropdown item width to prevent labels from being truncated
|
|
361
|
+
dropdownWidth: 230,
|
|
362
|
+
showSelected: false,
|
|
267
363
|
};
|
|
268
364
|
};
|
|
269
365
|
|
|
@@ -274,100 +370,129 @@ const getClosestSelectionRect = (state: EditorState): Rect | undefined => {
|
|
|
274
370
|
: findCellRectClosestToPos(selection.$from);
|
|
275
371
|
};
|
|
276
372
|
|
|
277
|
-
export const getToolbarConfig =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
373
|
+
export const getToolbarConfig =
|
|
374
|
+
(
|
|
375
|
+
getEditorContainerWidth: GetEditorContainerWidth,
|
|
376
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
377
|
+
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
378
|
+
) =>
|
|
379
|
+
(config: PluginConfig): FloatingToolbarHandler =>
|
|
380
|
+
(state, intl) => {
|
|
381
|
+
const tableObject = findTable(state.selection);
|
|
382
|
+
const pluginState = getPluginState(state);
|
|
383
|
+
const resizeState: ColumnResizingPluginState | undefined =
|
|
384
|
+
tableResizingPluginKey.getState(state);
|
|
385
|
+
if (tableObject && pluginState.editorHasFocus) {
|
|
386
|
+
const nodeType = state.schema.nodes.table;
|
|
387
|
+
const menu = getToolbarMenuConfig(
|
|
388
|
+
config,
|
|
389
|
+
pluginState,
|
|
390
|
+
intl,
|
|
391
|
+
editorAnalyticsAPI,
|
|
392
|
+
);
|
|
294
393
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
394
|
+
const { tableCellOptionsInFloatingToolbar } =
|
|
395
|
+
getEditorFeatureFlags() || {};
|
|
396
|
+
const cellItems = getCellItems(
|
|
397
|
+
config,
|
|
398
|
+
state,
|
|
399
|
+
intl,
|
|
400
|
+
getEditorContainerWidth,
|
|
401
|
+
editorAnalyticsAPI,
|
|
402
|
+
tableCellOptionsInFloatingToolbar,
|
|
403
|
+
);
|
|
404
|
+
const colorPicker = getColorPicker(
|
|
405
|
+
state,
|
|
406
|
+
menu,
|
|
407
|
+
intl,
|
|
408
|
+
getEditorContainerWidth,
|
|
409
|
+
editorAnalyticsAPI,
|
|
410
|
+
tableCellOptionsInFloatingToolbar,
|
|
411
|
+
);
|
|
302
412
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
413
|
+
// Check if we need to show confirm dialog for delete button
|
|
414
|
+
let confirmDialog;
|
|
415
|
+
const localId: string | undefined = tableObject.node.attrs.localId;
|
|
306
416
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
417
|
+
if (localId && isReferencedSource(state, localId)) {
|
|
418
|
+
confirmDialog = {
|
|
419
|
+
okButtonLabel: intl.formatMessage(
|
|
420
|
+
tableMessages.confirmDeleteLinkedModalOKButton,
|
|
421
|
+
),
|
|
422
|
+
message: intl.formatMessage(
|
|
423
|
+
tableMessages.confirmDeleteLinkedModalMessage,
|
|
424
|
+
),
|
|
425
|
+
};
|
|
426
|
+
}
|
|
317
427
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
428
|
+
const getDomRef = (editorView: EditorView) => {
|
|
429
|
+
let element: HTMLElement | undefined;
|
|
430
|
+
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
431
|
+
const parent = findParentDomRefOfType(
|
|
432
|
+
nodeType,
|
|
433
|
+
domAtPos,
|
|
434
|
+
)(state.selection);
|
|
435
|
+
if (parent) {
|
|
436
|
+
const tableRef =
|
|
437
|
+
(parent as HTMLElement).querySelector<HTMLTableElement>('table') ||
|
|
438
|
+
undefined;
|
|
439
|
+
if (tableRef) {
|
|
440
|
+
element =
|
|
441
|
+
closestElement(
|
|
442
|
+
tableRef,
|
|
443
|
+
`.${TableCssClassName.TABLE_NODE_WRAPPER}`,
|
|
444
|
+
) || undefined;
|
|
445
|
+
}
|
|
335
446
|
}
|
|
336
|
-
}
|
|
337
447
|
|
|
338
|
-
|
|
339
|
-
|
|
448
|
+
return element;
|
|
449
|
+
};
|
|
340
450
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
451
|
+
return {
|
|
452
|
+
title: 'Table floating controls',
|
|
453
|
+
getDomRef,
|
|
454
|
+
nodeType,
|
|
455
|
+
offset: [0, 3],
|
|
456
|
+
items: [
|
|
457
|
+
menu,
|
|
458
|
+
separator(menu.hidden),
|
|
459
|
+
...cellItems,
|
|
460
|
+
...colorPicker,
|
|
461
|
+
{
|
|
462
|
+
type: 'extensions-placeholder',
|
|
463
|
+
separator: 'end',
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
type: 'copy-button',
|
|
467
|
+
items: [
|
|
468
|
+
{
|
|
469
|
+
state,
|
|
470
|
+
formatMessage: intl.formatMessage,
|
|
471
|
+
nodeType,
|
|
472
|
+
onMouseEnter: hoverTable(false, true),
|
|
473
|
+
onMouseLeave: clearHoverSelection(),
|
|
474
|
+
},
|
|
475
|
+
{ type: 'separator' },
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
id: 'editor.table.delete',
|
|
480
|
+
type: 'button',
|
|
481
|
+
appearance: 'danger',
|
|
482
|
+
icon: RemoveIcon,
|
|
483
|
+
onClick: deleteTableWithAnalytics(editorAnalyticsAPI),
|
|
484
|
+
disabled: !!resizeState && !!resizeState.dragging,
|
|
485
|
+
onMouseEnter: hoverTable(true),
|
|
486
|
+
onMouseLeave: clearHoverSelection(),
|
|
487
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
488
|
+
confirmDialog,
|
|
489
|
+
},
|
|
490
|
+
],
|
|
491
|
+
scrollable: true,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
return;
|
|
495
|
+
};
|
|
371
496
|
|
|
372
497
|
const separator = (hidden?: boolean): FloatingToolbarItem<Command> => {
|
|
373
498
|
return {
|
|
@@ -382,8 +507,12 @@ const getCellItems = (
|
|
|
382
507
|
{ formatMessage }: ToolbarMenuContext,
|
|
383
508
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
384
509
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
510
|
+
tableCellOptionsInFloatingToolbar?: boolean,
|
|
385
511
|
): Array<FloatingToolbarItem<Command>> => {
|
|
386
|
-
if (
|
|
512
|
+
if (
|
|
513
|
+
pluginConfig.allowCellOptionsInFloatingToolbar ||
|
|
514
|
+
tableCellOptionsInFloatingToolbar
|
|
515
|
+
) {
|
|
387
516
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
388
517
|
if (initialSelectionRect) {
|
|
389
518
|
const cellOptions = getToolbarCellOptionsConfig(
|
|
@@ -398,3 +527,49 @@ const getCellItems = (
|
|
|
398
527
|
}
|
|
399
528
|
return [];
|
|
400
529
|
};
|
|
530
|
+
|
|
531
|
+
const getColorPicker = (
|
|
532
|
+
state: EditorState,
|
|
533
|
+
menu: FloatingToolbarItem<Command>,
|
|
534
|
+
{ formatMessage }: ToolbarMenuContext,
|
|
535
|
+
getEditorContainerWidth: GetEditorContainerWidth,
|
|
536
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined,
|
|
537
|
+
tableCellOptionsInFloatingToolbar?: boolean,
|
|
538
|
+
): Array<FloatingToolbarItem<Command>> => {
|
|
539
|
+
const { targetCellPosition, pluginConfig } = getPluginState(state);
|
|
540
|
+
if (
|
|
541
|
+
!pluginConfig.allowBackgroundColor ||
|
|
542
|
+
!tableCellOptionsInFloatingToolbar
|
|
543
|
+
) {
|
|
544
|
+
return [];
|
|
545
|
+
}
|
|
546
|
+
const node = targetCellPosition
|
|
547
|
+
? state.doc.nodeAt(targetCellPosition)
|
|
548
|
+
: undefined;
|
|
549
|
+
const currentBackground = node?.attrs?.background || '#ffffff';
|
|
550
|
+
const defaultPalette = cellBackgroundColorPalette.find(
|
|
551
|
+
(item) => item.value === currentBackground,
|
|
552
|
+
) || {
|
|
553
|
+
label: 'Custom',
|
|
554
|
+
value: currentBackground,
|
|
555
|
+
border: DEFAULT_BORDER_COLOR,
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
return [
|
|
559
|
+
{
|
|
560
|
+
id: 'editor.panel.colorPicker',
|
|
561
|
+
title: formatMessage(ContextualMenuMessages.cellBackground),
|
|
562
|
+
type: 'select',
|
|
563
|
+
selectType: 'color',
|
|
564
|
+
defaultValue: defaultPalette,
|
|
565
|
+
options: cellBackgroundColorPalette,
|
|
566
|
+
onChange: (option: any) =>
|
|
567
|
+
setColorWithAnalytics(editorAnalyticsAPI)(
|
|
568
|
+
INPUT_METHOD.FLOATING_TB,
|
|
569
|
+
option.value,
|
|
570
|
+
targetCellPosition,
|
|
571
|
+
),
|
|
572
|
+
},
|
|
573
|
+
separator(menu.hidden),
|
|
574
|
+
];
|
|
575
|
+
};
|