@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
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getToolbarMenuConfig,
|
|
3
3
|
getToolbarCellOptionsConfig,
|
|
4
|
-
} from '../../toolbar';
|
|
5
|
-
import { ToolbarMenuConfig, ToolbarMenuState } from '../../types';
|
|
6
|
-
import {
|
|
4
|
+
} from '../../plugins/table/toolbar';
|
|
5
|
+
import { ToolbarMenuConfig, ToolbarMenuState } from '../../plugins/table/types';
|
|
6
|
+
import {
|
|
7
|
+
createProsemirrorEditorFactory,
|
|
8
|
+
LightEditorPlugin,
|
|
9
|
+
Preset,
|
|
10
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
7
11
|
import {
|
|
8
12
|
doc,
|
|
9
13
|
p,
|
|
@@ -17,11 +21,13 @@ import type {
|
|
|
17
21
|
FloatingToolbarDropdown,
|
|
18
22
|
} from '@atlaskit/editor-common/types';
|
|
19
23
|
import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
20
|
-
import { canMergeCells } from '../../transforms';
|
|
24
|
+
import { canMergeCells } from '../../plugins/table/transforms';
|
|
21
25
|
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
26
|
+
import tablePlugin from '../../plugins/table';
|
|
27
|
+
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
22
28
|
|
|
23
29
|
jest.mock('@atlaskit/editor-tables/utils');
|
|
24
|
-
jest.mock('../../transforms');
|
|
30
|
+
jest.mock('../../plugins/table/transforms');
|
|
25
31
|
|
|
26
32
|
const formatMessage: (t: unknown) => string = (id) => 'Lorem ipsum';
|
|
27
33
|
const ctx = { formatMessage };
|
|
@@ -131,9 +137,16 @@ describe('getToolbarMenuConfig', () => {
|
|
|
131
137
|
});
|
|
132
138
|
|
|
133
139
|
describe('getToolbarCellOptionsConfig', () => {
|
|
134
|
-
const
|
|
140
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
141
|
+
const {
|
|
142
|
+
editorView: { state },
|
|
143
|
+
} = createEditor({
|
|
144
|
+
doc: doc(table()(row(td()(p('1{cursor}'))))),
|
|
145
|
+
preset: new Preset<LightEditorPlugin>().add(tablePlugin),
|
|
146
|
+
pluginKey,
|
|
147
|
+
});
|
|
135
148
|
const getEditorContainerWidth = () => ({ width: 500 });
|
|
136
|
-
|
|
149
|
+
|
|
137
150
|
const formatMessage: (t: { id: string }) => string = (message) =>
|
|
138
151
|
`${message.id}`;
|
|
139
152
|
const rect = new Rect(1, 1, 1, 1);
|
|
@@ -146,10 +159,6 @@ describe('getToolbarCellOptionsConfig', () => {
|
|
|
146
159
|
getEditorContainerWidth,
|
|
147
160
|
undefined,
|
|
148
161
|
);
|
|
149
|
-
//
|
|
150
|
-
it('is hidden by default', () => {
|
|
151
|
-
expect(cellOptionsMenu.hidden).toBe(true);
|
|
152
|
-
});
|
|
153
162
|
|
|
154
163
|
it('is a dropdown with the following dropdown items with the given order', () => {
|
|
155
164
|
const items = cellOptionsMenu.options as Array<DropdownOptionT<Command>>;
|
|
@@ -191,7 +200,7 @@ describe('getToolbarCellOptionsConfig', () => {
|
|
|
191
200
|
});
|
|
192
201
|
|
|
193
202
|
it('should have enabled merge cells when multiple cells are selected', () => {
|
|
194
|
-
(
|
|
203
|
+
(canMergeCells as Function as jest.Mock<{}>).mockImplementation(
|
|
195
204
|
() => () => true,
|
|
196
205
|
);
|
|
197
206
|
//
|
|
@@ -215,8 +224,8 @@ describe('getToolbarCellOptionsConfig', () => {
|
|
|
215
224
|
});
|
|
216
225
|
|
|
217
226
|
it('should have enabled split cell when cell can be splitted', () => {
|
|
218
|
-
(
|
|
219
|
-
true,
|
|
227
|
+
(splitCell as Function as jest.Mock<{}>).mockImplementation(
|
|
228
|
+
() => () => true,
|
|
220
229
|
);
|
|
221
230
|
//
|
|
222
231
|
const cellOptionsMenu = getToolbarCellOptionsConfig(
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { createIntl } from 'react-intl-next';
|
|
5
|
+
import {
|
|
6
|
+
createProsemirrorEditorFactory,
|
|
7
|
+
LightEditorPlugin,
|
|
8
|
+
Preset,
|
|
9
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
10
|
+
import {
|
|
11
|
+
doc,
|
|
12
|
+
p,
|
|
13
|
+
table,
|
|
14
|
+
tdCursor,
|
|
15
|
+
tdEmpty,
|
|
16
|
+
th,
|
|
17
|
+
tr,
|
|
18
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
19
|
+
import tablePlugin from '../../../plugins/table-plugin';
|
|
20
|
+
|
|
21
|
+
import { ContextualMenu } from '../../../plugins/table/ui/FloatingContextualMenu/ContextualMenu';
|
|
22
|
+
|
|
23
|
+
describe('ContextualMenu', () => {
|
|
24
|
+
const getEditorContainerWidth = () => ({ width: 500 });
|
|
25
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
26
|
+
describe('with right table cell position in plugin state', () => {
|
|
27
|
+
let editorView: EditorView;
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
({ editorView } = createEditor({
|
|
30
|
+
doc: doc(table()(tr(th()(p('')), th()(p(''))), tr(tdCursor, tdEmpty))),
|
|
31
|
+
preset: new Preset<LightEditorPlugin>().add([
|
|
32
|
+
tablePlugin,
|
|
33
|
+
{ tableOptions: { advanced: true } },
|
|
34
|
+
]),
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should render contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
|
|
39
|
+
const intl = createIntl({ locale: 'en' });
|
|
40
|
+
render(
|
|
41
|
+
<ContextualMenu
|
|
42
|
+
intl={intl}
|
|
43
|
+
editorView={editorView}
|
|
44
|
+
isOpen
|
|
45
|
+
selectionRect={{ bottom: 0, left: 0, right: 0, top: 0 }}
|
|
46
|
+
getEditorContainerWidth={getEditorContainerWidth}
|
|
47
|
+
/>,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(
|
|
51
|
+
screen.getByTestId('table-cell-contextual-menu'),
|
|
52
|
+
).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -2,7 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import { IntlProvider } from 'react-intl-next';
|
|
4
4
|
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createProsemirrorEditorFactory,
|
|
7
|
+
LightEditorPlugin,
|
|
8
|
+
Preset,
|
|
9
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
10
|
import {
|
|
7
11
|
doc,
|
|
8
12
|
table,
|
|
@@ -11,22 +15,18 @@ import {
|
|
|
11
15
|
DocBuilder,
|
|
12
16
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
13
17
|
|
|
14
|
-
import { TablePluginState } from '../../../plugins/table/types';
|
|
15
18
|
import { CornerControls } from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
|
|
16
19
|
import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
|
|
17
20
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
18
21
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
19
22
|
|
|
20
23
|
describe('CornerControls', () => {
|
|
21
|
-
const createEditor =
|
|
24
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
22
25
|
|
|
23
26
|
const editor = (doc: DocBuilder) =>
|
|
24
27
|
createEditor({
|
|
25
28
|
doc,
|
|
26
|
-
|
|
27
|
-
allowTables: false,
|
|
28
|
-
dangerouslyAppendPlugins: { __plugins: [tablePlugin()] },
|
|
29
|
-
},
|
|
29
|
+
preset: new Preset<LightEditorPlugin>().add(tablePlugin),
|
|
30
30
|
pluginKey,
|
|
31
31
|
});
|
|
32
32
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as prosemirrorUtils from 'prosemirror-utils';
|
|
2
|
+
import type { ContentNodeWithPos } from 'prosemirror-utils';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { IntlProvider } from 'react-intl-next';
|
|
3
5
|
import { EditorView } from 'prosemirror-view';
|
|
4
6
|
import React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
+
import {
|
|
8
|
+
createProsemirrorEditorFactory,
|
|
9
|
+
LightEditorPlugin,
|
|
10
|
+
Preset,
|
|
11
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
7
12
|
import {
|
|
8
13
|
doc,
|
|
9
14
|
table,
|
|
@@ -14,29 +19,23 @@ import {
|
|
|
14
19
|
DocBuilder,
|
|
15
20
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
16
21
|
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
17
|
-
import { TablePluginState } from '../../../plugins/table/types';
|
|
18
22
|
import FloatingContextualButton, {
|
|
19
23
|
Props as FloatingContextualButtonProps,
|
|
20
|
-
FloatingContextualButtonInner,
|
|
21
24
|
} from '../../../plugins/table/ui/FloatingContextualButton';
|
|
22
25
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
allowTables: false,
|
|
32
|
-
dangerouslyAppendPlugins: { __plugins: [tablePlugin()] },
|
|
33
|
-
},
|
|
34
|
-
createAnalyticsEvent,
|
|
35
|
-
});
|
|
27
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
28
|
+
let createAnalyticsEvent = jest.fn(() => ({ fire() {} } as UIAnalyticsEvent));
|
|
29
|
+
const editor = (doc: DocBuilder) =>
|
|
30
|
+
createEditor({
|
|
31
|
+
doc,
|
|
32
|
+
preset: new Preset<LightEditorPlugin>().add(tablePlugin),
|
|
33
|
+
});
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
describe('Floating Contextual Button', () => {
|
|
38
36
|
let editorView: EditorView;
|
|
39
37
|
let refs: { [name: string]: number };
|
|
38
|
+
let tableNode: ContentNodeWithPos | undefined;
|
|
40
39
|
|
|
41
40
|
beforeEach(() => {
|
|
42
41
|
({ editorView, refs } = editor(
|
|
@@ -49,47 +48,44 @@ describe('Floating Contextual Button', () => {
|
|
|
49
48
|
),
|
|
50
49
|
));
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
tableNode = prosemirrorUtils.findParentNodeOfTypeClosestToPos(
|
|
53
52
|
editorView.state.selection.$from,
|
|
54
53
|
editorView.state.schema.nodes.table,
|
|
55
54
|
);
|
|
55
|
+
});
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const component = (props: FloatingContextualButtonProps) =>
|
|
58
|
+
render(
|
|
59
|
+
<IntlProvider locale="en">
|
|
60
|
+
<FloatingContextualButton
|
|
61
|
+
tableNode={tableNode && tableNode.node}
|
|
62
|
+
dispatchAnalyticsEvent={createAnalyticsEvent}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
</IntlProvider>,
|
|
64
66
|
);
|
|
65
|
-
});
|
|
66
67
|
|
|
67
68
|
describe('when an error is thrown in the component', () => {
|
|
68
|
-
it('
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
)
|
|
69
|
+
it('renders', () => {
|
|
70
|
+
component({
|
|
71
|
+
editorView,
|
|
72
|
+
targetCellPosition: refs.firstCell,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(screen.getByLabelText('Cell options')).toBeInTheDocument();
|
|
73
76
|
});
|
|
74
77
|
|
|
75
78
|
it('dispatches an analytics event', () => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
expect(createAnalyticsEvent).toHaveBeenCalledWith({
|
|
80
|
-
action: 'unhandledErrorCaught',
|
|
81
|
-
actionSubject: 'floatingContextualButton',
|
|
82
|
-
eventType: 'operational',
|
|
83
|
-
attributes: {
|
|
84
|
-
error: new Error('Oh no!'),
|
|
85
|
-
errorInfo: expect.objectContaining({
|
|
86
|
-
componentStack: expect.stringContaining(
|
|
87
|
-
'in FloatingContextualButton',
|
|
88
|
-
),
|
|
89
|
-
}),
|
|
90
|
-
errorRethrown: false,
|
|
91
|
-
},
|
|
79
|
+
const mock = jest.spyOn(prosemirrorUtils, 'findDomRefAtPos');
|
|
80
|
+
mock.mockImplementation(() => {
|
|
81
|
+
throw new Error('Error message from mock');
|
|
92
82
|
});
|
|
83
|
+
component({
|
|
84
|
+
editorView,
|
|
85
|
+
targetCellPosition: refs.firstCell,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(createAnalyticsEvent).toHaveBeenCalled();
|
|
93
89
|
});
|
|
94
90
|
});
|
|
95
91
|
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { IntlProvider } from 'react-intl-next';
|
|
5
|
+
import {
|
|
6
|
+
createProsemirrorEditorFactory,
|
|
7
|
+
LightEditorPlugin,
|
|
8
|
+
Preset,
|
|
9
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
10
|
+
import {
|
|
11
|
+
doc,
|
|
12
|
+
p,
|
|
13
|
+
table,
|
|
14
|
+
tdCursor,
|
|
15
|
+
tdEmpty,
|
|
16
|
+
th,
|
|
17
|
+
tr,
|
|
18
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
19
|
+
|
|
20
|
+
import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
|
|
21
|
+
import FloatingContextualMenu from '../../../plugins/table/ui/FloatingContextualMenu';
|
|
22
|
+
import tablePlugin from '../../../plugins/table-plugin';
|
|
23
|
+
|
|
24
|
+
describe('FloatingContextualMenu', () => {
|
|
25
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
26
|
+
describe('with right position in plugin state', () => {
|
|
27
|
+
let editorView: EditorView;
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
({ editorView } = createEditor({
|
|
30
|
+
doc: doc(table()(tr(th()(p('')), th()(p(''))), tr(tdCursor, tdEmpty))),
|
|
31
|
+
preset: new Preset<LightEditorPlugin>().add(tablePlugin),
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should render floating contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
|
|
36
|
+
render(
|
|
37
|
+
<IntlProvider locale="en">
|
|
38
|
+
<FloatingContextualMenu
|
|
39
|
+
editorView={editorView}
|
|
40
|
+
isOpen
|
|
41
|
+
pluginConfig={getPluginState(editorView.state).pluginConfig}
|
|
42
|
+
getEditorContainerWidth={jest.fn()}
|
|
43
|
+
/>
|
|
44
|
+
</IntlProvider>,
|
|
45
|
+
);
|
|
46
|
+
expect(screen.getAllByLabelText('Popup').length).toBeGreaterThan(0);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
DocBuilder,
|
|
10
10
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
11
11
|
import { selectColumns, selectRows } from '@atlaskit/editor-test-helpers/table';
|
|
12
|
-
import { selectTable } from '@atlaskit/editor-tables/utils';
|
|
12
|
+
import { selectTable, getCellsInColumn } from '@atlaskit/editor-tables/utils';
|
|
13
13
|
import { EditorView } from 'prosemirror-view';
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import { render, screen } from '@testing-library/react';
|
|
15
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
16
16
|
import { IntlProvider } from 'react-intl-next';
|
|
17
17
|
import {
|
|
18
18
|
TablePluginState,
|
|
@@ -134,4 +134,32 @@ describe('Floating Delete Button', () => {
|
|
|
134
134
|
expect(screen.getAllByLabelText('Delete row').length).toBe(1);
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
|
+
describe('when deleting with the delete button', () => {
|
|
138
|
+
describe('Columns', () => {
|
|
139
|
+
it('should move cursor within the table after delete', () => {
|
|
140
|
+
selectColumns([0, 1])(editorView.state, editorView.dispatch);
|
|
141
|
+
component({ selection: editorView.state.selection, editorView });
|
|
142
|
+
const { tr } = editorView.state;
|
|
143
|
+
const { pos } = getCellsInColumn(2)(tr.selection)![2];
|
|
144
|
+
const lastCellPos = tr.doc.resolve(pos).pos + 1;
|
|
145
|
+
fireEvent.click(screen.getByLabelText('Delete column'));
|
|
146
|
+
expect(editorView.state.selection.from).toBeLessThanOrEqual(
|
|
147
|
+
lastCellPos,
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
describe('Rows', () => {
|
|
152
|
+
it('should move cursor within the table after delete', () => {
|
|
153
|
+
selectRows([0, 1])(editorView.state, editorView.dispatch);
|
|
154
|
+
component({ selection: editorView.state.selection, editorView });
|
|
155
|
+
const { tr } = editorView.state;
|
|
156
|
+
const { pos } = getCellsInColumn(2)(tr.selection)![2];
|
|
157
|
+
const lastCellPos = tr.doc.resolve(pos).pos + 1;
|
|
158
|
+
fireEvent.click(screen.getByLabelText('Delete row'));
|
|
159
|
+
expect(editorView.state.selection.from).toBeLessThanOrEqual(
|
|
160
|
+
lastCellPos,
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
137
165
|
});
|