@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,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createProsemirrorEditorFactory,
|
|
3
|
-
LightEditorPlugin,
|
|
4
|
-
Preset,
|
|
5
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
|
-
import {
|
|
7
|
-
doc,
|
|
8
|
-
p,
|
|
9
|
-
table,
|
|
10
|
-
td,
|
|
11
|
-
tdCursor,
|
|
12
|
-
tdEmpty,
|
|
13
|
-
tr,
|
|
14
|
-
DocBuilder,
|
|
15
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
16
|
-
|
|
17
|
-
import tablePlugin from '../../../table';
|
|
18
|
-
import { handleMouseOut, handleMouseDown } from '../../event-handlers';
|
|
19
|
-
import { pluginKey } from '../../pm-plugins/plugin-key';
|
|
20
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
21
|
-
|
|
22
|
-
describe('table plugin: decorations', () => {
|
|
23
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
24
|
-
const editor = (doc: DocBuilder) =>
|
|
25
|
-
createEditor({
|
|
26
|
-
doc,
|
|
27
|
-
preset: new Preset<LightEditorPlugin>().add(tablePlugin),
|
|
28
|
-
pluginKey,
|
|
29
|
-
});
|
|
30
|
-
describe('#handleMouseDown', () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
jest.resetAllMocks();
|
|
33
|
-
});
|
|
34
|
-
it('should return true & prevent default behaviour for table wrappers: pm-table-contianer', () => {
|
|
35
|
-
const { editorView } = editor(
|
|
36
|
-
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
37
|
-
);
|
|
38
|
-
const tableContainer = document.createElement('div');
|
|
39
|
-
tableContainer.className = 'pm-table-container';
|
|
40
|
-
const event = new MouseEvent('mousedown');
|
|
41
|
-
Object.defineProperty(event, 'target', { value: tableContainer });
|
|
42
|
-
const preventDefaultSpy = jest.spyOn(
|
|
43
|
-
MouseEvent.prototype,
|
|
44
|
-
'preventDefault',
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
expect(handleMouseDown(editorView, event)).toEqual(true);
|
|
48
|
-
expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should return true & prevent default behaviour for table wrappers: pm-table-wrapper', () => {
|
|
52
|
-
const { editorView } = editor(
|
|
53
|
-
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
54
|
-
);
|
|
55
|
-
const tableContainer = document.createElement('div');
|
|
56
|
-
tableContainer.className = 'pm-table-wrapper';
|
|
57
|
-
const event = new MouseEvent('mousedown');
|
|
58
|
-
Object.defineProperty(event, 'target', { value: tableContainer });
|
|
59
|
-
const preventDefaultSpy = jest.spyOn(
|
|
60
|
-
MouseEvent.prototype,
|
|
61
|
-
'preventDefault',
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
expect(handleMouseDown(editorView, event)).toEqual(true);
|
|
65
|
-
expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should return false & not prevent default behaviour for editor content area: ak-editor-content-area', () => {
|
|
69
|
-
const { editorView } = editor(
|
|
70
|
-
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
71
|
-
);
|
|
72
|
-
const editorContentArea = document.createElement('div');
|
|
73
|
-
editorContentArea.className = 'ak-editor-content-area';
|
|
74
|
-
const event = new MouseEvent('mousedown');
|
|
75
|
-
Object.defineProperty(event, 'target', { value: editorContentArea });
|
|
76
|
-
const preventDefaultSpy = jest.spyOn(
|
|
77
|
-
MouseEvent.prototype,
|
|
78
|
-
'preventDefault',
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
expect(handleMouseDown(editorView, event)).toEqual(false);
|
|
82
|
-
expect(preventDefaultSpy).toHaveBeenCalledTimes(0);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('#handleMouseOut', () => {
|
|
86
|
-
describe('when the target is a resize handle column', () => {
|
|
87
|
-
it('should return true', () => {
|
|
88
|
-
const { editorView } = editor(
|
|
89
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(td()(p('{o}')), tdEmpty))),
|
|
90
|
-
);
|
|
91
|
-
const firstCell = document.createElement('div');
|
|
92
|
-
firstCell.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
93
|
-
|
|
94
|
-
// event.target = secondCell.node;
|
|
95
|
-
const spy = jest
|
|
96
|
-
.spyOn(MouseEvent.prototype, 'target', 'get')
|
|
97
|
-
.mockReturnValue(firstCell);
|
|
98
|
-
|
|
99
|
-
const event = new MouseEvent('opa');
|
|
100
|
-
|
|
101
|
-
expect(handleMouseOut(editorView, event)).toEqual(true);
|
|
102
|
-
spy.mockRestore();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('when the relatedTarget is a resize handle column too', () => {
|
|
107
|
-
it('should return false', () => {
|
|
108
|
-
const { editorView } = editor(
|
|
109
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(td()(p('{o}')), tdEmpty))),
|
|
110
|
-
);
|
|
111
|
-
const firstCell = document.createElement('div');
|
|
112
|
-
firstCell.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
113
|
-
const secondCell = document.createElement('div');
|
|
114
|
-
secondCell.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
115
|
-
|
|
116
|
-
// event.target = secondCell.node;
|
|
117
|
-
const spy = jest
|
|
118
|
-
.spyOn(MouseEvent.prototype, 'target', 'get')
|
|
119
|
-
.mockReturnValue(secondCell);
|
|
120
|
-
|
|
121
|
-
const event = new MouseEvent('opa', {
|
|
122
|
-
relatedTarget: firstCell,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
expect(handleMouseOut(editorView, event)).toEqual(false);
|
|
126
|
-
spy.mockRestore();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount, ReactWrapper, shallow } from 'enzyme';
|
|
3
|
-
import { replaceRaf } from 'raf-stub';
|
|
4
|
-
|
|
5
|
-
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
6
|
-
import tablePlugin from '../../../../table';
|
|
7
|
-
import {
|
|
8
|
-
doc,
|
|
9
|
-
p,
|
|
10
|
-
table,
|
|
11
|
-
tr,
|
|
12
|
-
td,
|
|
13
|
-
tdEmpty,
|
|
14
|
-
tdCursor,
|
|
15
|
-
DocBuilder,
|
|
16
|
-
thEmpty,
|
|
17
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
18
|
-
import { findTable, selectTable } from '@atlaskit/editor-tables/utils';
|
|
19
|
-
import {
|
|
20
|
-
TableCssClassName as ClassName,
|
|
21
|
-
TablePluginState,
|
|
22
|
-
} from '../../../types';
|
|
23
|
-
import TableComponent from '../../../nodeviews/TableComponent';
|
|
24
|
-
import { OverflowShadowsObserver } from '../../../nodeviews/OverflowShadowsObserver';
|
|
25
|
-
import { pluginKey } from '../../../pm-plugins/plugin-key';
|
|
26
|
-
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
27
|
-
import { toggleNumberColumn } from '../../../commands';
|
|
28
|
-
import {
|
|
29
|
-
pluginKey as stickyHeadersPluginKey,
|
|
30
|
-
StickyPluginState,
|
|
31
|
-
} from '../../../pm-plugins/sticky-headers';
|
|
32
|
-
import { tablesHaveDifferentColumnWidths } from '../../../utils/nodes';
|
|
33
|
-
|
|
34
|
-
jest.mock('../../../utils/nodes', () =>
|
|
35
|
-
Object.assign({}, jest.requireActual('../../../utils/nodes'), {
|
|
36
|
-
tablesHaveDifferentColumnWidths: jest.fn(),
|
|
37
|
-
}),
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// with this jest will load mocked class from the relative __mocks__ folder
|
|
41
|
-
jest.mock('../../../nodeviews/OverflowShadowsObserver');
|
|
42
|
-
|
|
43
|
-
replaceRaf();
|
|
44
|
-
const requestAnimationFrame = window.requestAnimationFrame as any;
|
|
45
|
-
|
|
46
|
-
describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
47
|
-
const createEditor = createEditorFactory<TablePluginState>();
|
|
48
|
-
//
|
|
49
|
-
const getEditorFeatureFlags = jest.fn();
|
|
50
|
-
//
|
|
51
|
-
const editor = (
|
|
52
|
-
doc: DocBuilder,
|
|
53
|
-
featureFlags?: { [featureFlag: string]: string | boolean },
|
|
54
|
-
) => {
|
|
55
|
-
getEditorFeatureFlags.mockReturnValue(featureFlags || {});
|
|
56
|
-
return createEditor({
|
|
57
|
-
doc,
|
|
58
|
-
editorProps: {
|
|
59
|
-
allowTables: false,
|
|
60
|
-
dangerouslyAppendPlugins: {
|
|
61
|
-
__plugins: [tablePlugin()],
|
|
62
|
-
},
|
|
63
|
-
featureFlags,
|
|
64
|
-
},
|
|
65
|
-
pluginKey,
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
//
|
|
69
|
-
afterEach(() => {
|
|
70
|
-
jest.clearAllMocks();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('when the table is selected', () => {
|
|
74
|
-
it('should add table selected css class', () => {
|
|
75
|
-
const { editorView } = editor(
|
|
76
|
-
doc(p('text'), table()(tr(tdEmpty, tdEmpty, tdCursor))),
|
|
77
|
-
{
|
|
78
|
-
tableCellOptimization: true,
|
|
79
|
-
tableRenderOptimization: true,
|
|
80
|
-
stickyHeadersOptimization: true,
|
|
81
|
-
initialRenderOptimization: true,
|
|
82
|
-
},
|
|
83
|
-
);
|
|
84
|
-
const { state, dispatch } = editorView;
|
|
85
|
-
dispatch(selectTable(state.tr));
|
|
86
|
-
requestAnimationFrame.step();
|
|
87
|
-
const tableContainer = document.querySelector(
|
|
88
|
-
`.${ClassName.TABLE_CONTAINER}`,
|
|
89
|
-
);
|
|
90
|
-
expect(
|
|
91
|
-
tableContainer!.classList.contains(ClassName.TABLE_SELECTED),
|
|
92
|
-
).toBeTruthy();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('when the numbered column attribute is changed', () => {
|
|
97
|
-
it('should not resize the columns', () => {
|
|
98
|
-
const { editorView } = editor(
|
|
99
|
-
doc(
|
|
100
|
-
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
101
|
-
tr(
|
|
102
|
-
td({ colwidth: [1400] })(p('{<>}')),
|
|
103
|
-
td({ colwidth: [48] })(p()),
|
|
104
|
-
td({ colwidth: [48] })(p()),
|
|
105
|
-
),
|
|
106
|
-
),
|
|
107
|
-
),
|
|
108
|
-
);
|
|
109
|
-
const { state, dispatch } = editorView;
|
|
110
|
-
const tableCell = state.schema.nodes.tableCell;
|
|
111
|
-
const columnWidths: number[][] = [];
|
|
112
|
-
|
|
113
|
-
toggleNumberColumn(state, dispatch);
|
|
114
|
-
requestAnimationFrame.step();
|
|
115
|
-
|
|
116
|
-
editorView.state.doc.nodesBetween(3, 14, (node) => {
|
|
117
|
-
if (node.type === tableCell) {
|
|
118
|
-
columnWidths.push(node.attrs.colwidth);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return node.type !== tableCell;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
expect(columnWidths).toEqual([[1400], [48], [48]]);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe('WITH_CONTROLS css class', () => {
|
|
129
|
-
it.each<[string, object, boolean]>([
|
|
130
|
-
[
|
|
131
|
-
'is added when allowControls is set',
|
|
132
|
-
{
|
|
133
|
-
allowControls: true,
|
|
134
|
-
tableActive: true,
|
|
135
|
-
},
|
|
136
|
-
true,
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
'is added by default when allowControls is not provided',
|
|
140
|
-
{
|
|
141
|
-
tableActive: true,
|
|
142
|
-
},
|
|
143
|
-
true,
|
|
144
|
-
],
|
|
145
|
-
[
|
|
146
|
-
'is not added when allowControls is false',
|
|
147
|
-
{
|
|
148
|
-
allowControls: false,
|
|
149
|
-
tableActive: true,
|
|
150
|
-
},
|
|
151
|
-
false,
|
|
152
|
-
],
|
|
153
|
-
[
|
|
154
|
-
'is not added when table is not active',
|
|
155
|
-
{
|
|
156
|
-
allowControls: true,
|
|
157
|
-
tableActive: false,
|
|
158
|
-
},
|
|
159
|
-
false,
|
|
160
|
-
],
|
|
161
|
-
])('%s', (_, props, expected) => {
|
|
162
|
-
const { editorView: view } = editor(
|
|
163
|
-
doc(p('text'), table()(tr(td()(p('{<>}text')), tdEmpty, tdEmpty))),
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const tableF = findTable(view.state.selection);
|
|
167
|
-
const getNode = () => tableF!.node;
|
|
168
|
-
const wrapper = shallow(
|
|
169
|
-
<TableComponent
|
|
170
|
-
view={view}
|
|
171
|
-
eventDispatcher={({ on: () => {} } as any) as EventDispatcher}
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
containerWidth={{}}
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
getNode={getNode}
|
|
176
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
177
|
-
{...props}
|
|
178
|
-
/>,
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
expect(wrapper.hasClass(ClassName.WITH_CONTROLS)).toBe(expected);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe('overflowShadowOptimization', () => {
|
|
186
|
-
let overflowShadowsConstructorSpy = jest.fn();
|
|
187
|
-
let updateStickyShadowsSpy = jest.fn();
|
|
188
|
-
let observeCellsSpy = jest.fn();
|
|
189
|
-
let disposeSpy = jest.fn();
|
|
190
|
-
beforeAll(() => {
|
|
191
|
-
(OverflowShadowsObserver as any).setMock('observeCells', observeCellsSpy);
|
|
192
|
-
(OverflowShadowsObserver as any).setMock('dispose', disposeSpy);
|
|
193
|
-
(OverflowShadowsObserver as any).setMock(
|
|
194
|
-
'updateStickyShadows',
|
|
195
|
-
updateStickyShadowsSpy,
|
|
196
|
-
);
|
|
197
|
-
(OverflowShadowsObserver as any).setMock(
|
|
198
|
-
'constructor',
|
|
199
|
-
overflowShadowsConstructorSpy,
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
afterAll(() => {
|
|
204
|
-
(OverflowShadowsObserver as any).resetMocks();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
let triggerDispatcherEvent: { [key: string]: any } = {};
|
|
208
|
-
const tablePos = 0;
|
|
209
|
-
|
|
210
|
-
function setupTable(tableOverflowShadowsOptimization: boolean = false) {
|
|
211
|
-
const editorData = editor(
|
|
212
|
-
doc(
|
|
213
|
-
table()(
|
|
214
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
215
|
-
tr(td()(p('{<>}text')), tdEmpty, tdEmpty),
|
|
216
|
-
),
|
|
217
|
-
),
|
|
218
|
-
{
|
|
219
|
-
tableOverflowShadowsOptimization,
|
|
220
|
-
},
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
const view = editorData.editorView;
|
|
224
|
-
const tableF = findTable(view.state.selection);
|
|
225
|
-
|
|
226
|
-
const getNode = () => view.state.doc.firstChild!;
|
|
227
|
-
const wrapper = mount(
|
|
228
|
-
<TableComponent
|
|
229
|
-
view={view}
|
|
230
|
-
eventDispatcher={
|
|
231
|
-
({
|
|
232
|
-
on: (key: string, action: Function) => {
|
|
233
|
-
triggerDispatcherEvent[key] = action;
|
|
234
|
-
},
|
|
235
|
-
off: jest.fn(),
|
|
236
|
-
} as any) as EventDispatcher
|
|
237
|
-
}
|
|
238
|
-
// @ts-ignore
|
|
239
|
-
containerWidth={{}}
|
|
240
|
-
pluginState={{
|
|
241
|
-
pluginConfig: {
|
|
242
|
-
allowControls: false,
|
|
243
|
-
},
|
|
244
|
-
}}
|
|
245
|
-
getPos={() => tablePos}
|
|
246
|
-
getNode={getNode}
|
|
247
|
-
node={tableF!.node}
|
|
248
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
249
|
-
const node = view.dom.getElementsByTagName('table')[0];
|
|
250
|
-
|
|
251
|
-
if (!wrapper?.firstChild) {
|
|
252
|
-
wrapper?.appendChild(node);
|
|
253
|
-
}
|
|
254
|
-
}}
|
|
255
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
256
|
-
/>,
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
return { wrapper, view };
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
describe('with optimization on', () => {
|
|
263
|
-
let wrapper: ReactWrapper;
|
|
264
|
-
beforeEach(() => {
|
|
265
|
-
wrapper = setupTable(true).wrapper;
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('inits overflow shadows observer', () => {
|
|
269
|
-
const tableWrapperNode = wrapper
|
|
270
|
-
.find(`.${ClassName.TABLE_NODE_WRAPPER}`)
|
|
271
|
-
.getDOMNode();
|
|
272
|
-
const tableNode = tableWrapperNode.querySelector('table');
|
|
273
|
-
wrapper.setProps({});
|
|
274
|
-
expect(overflowShadowsConstructorSpy).toHaveBeenCalledWith(
|
|
275
|
-
expect.any(Function),
|
|
276
|
-
tableNode,
|
|
277
|
-
tableWrapperNode,
|
|
278
|
-
);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('observes table cells on component update', () => {
|
|
282
|
-
expect(observeCellsSpy).not.toHaveBeenCalled();
|
|
283
|
-
wrapper.setProps({});
|
|
284
|
-
expect(observeCellsSpy).toHaveBeenCalledTimes(1);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('updates sticky shadows on sticky state changed', () => {
|
|
288
|
-
const newStickyState: StickyPluginState = [
|
|
289
|
-
{
|
|
290
|
-
pos: tablePos + 1,
|
|
291
|
-
top: 0,
|
|
292
|
-
padding: 10,
|
|
293
|
-
sticky: true,
|
|
294
|
-
},
|
|
295
|
-
];
|
|
296
|
-
triggerDispatcherEvent[(stickyHeadersPluginKey as any).key](
|
|
297
|
-
newStickyState,
|
|
298
|
-
);
|
|
299
|
-
expect(updateStickyShadowsSpy).toHaveBeenCalled();
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('disposes shadows observer on unmount', () => {
|
|
303
|
-
wrapper.setProps({});
|
|
304
|
-
wrapper.unmount();
|
|
305
|
-
expect(disposeSpy).toHaveBeenCalled();
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
describe('with optimization off', () => {
|
|
310
|
-
let wrapper: ReactWrapper;
|
|
311
|
-
beforeEach(() => {
|
|
312
|
-
wrapper = setupTable(false).wrapper;
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('does not init overflow shadows observer', () => {
|
|
316
|
-
wrapper.setProps({});
|
|
317
|
-
expect(overflowShadowsConstructorSpy).not.toHaveBeenCalled();
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe('when media fullscreen is changed', () => {
|
|
323
|
-
function setupTable(isMediaFullscreen: boolean) {
|
|
324
|
-
const editorData = editor(
|
|
325
|
-
doc(
|
|
326
|
-
table()(
|
|
327
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
328
|
-
tr(td()(p('{<>}text')), tdEmpty, tdEmpty),
|
|
329
|
-
),
|
|
330
|
-
),
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
const view = editorData.editorView;
|
|
334
|
-
const tableF = findTable(view.state.selection);
|
|
335
|
-
let triggerDispatcherEvent: { [key: string]: any } = {};
|
|
336
|
-
const getNode = () => view.state.doc.firstChild!;
|
|
337
|
-
const tablePos = 0;
|
|
338
|
-
|
|
339
|
-
const wrapper = mount(
|
|
340
|
-
<TableComponent
|
|
341
|
-
view={view}
|
|
342
|
-
eventDispatcher={
|
|
343
|
-
({
|
|
344
|
-
on: (key: string, action: Function) => {
|
|
345
|
-
triggerDispatcherEvent[key] = action;
|
|
346
|
-
},
|
|
347
|
-
off: jest.fn(),
|
|
348
|
-
} as any) as EventDispatcher
|
|
349
|
-
}
|
|
350
|
-
// @ts-ignore
|
|
351
|
-
containerWidth={{}}
|
|
352
|
-
pluginState={{
|
|
353
|
-
pluginConfig: {
|
|
354
|
-
allowControls: false,
|
|
355
|
-
},
|
|
356
|
-
}}
|
|
357
|
-
getPos={() => tablePos}
|
|
358
|
-
getNode={getNode}
|
|
359
|
-
node={tableF!.node}
|
|
360
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
361
|
-
const node = view.dom.getElementsByTagName('table')[0];
|
|
362
|
-
if (!wrapper?.firstChild) {
|
|
363
|
-
wrapper?.appendChild(node);
|
|
364
|
-
}
|
|
365
|
-
}}
|
|
366
|
-
isMediaFullscreen={isMediaFullscreen}
|
|
367
|
-
allowColumnResizing={true}
|
|
368
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
369
|
-
/>,
|
|
370
|
-
);
|
|
371
|
-
return { wrapper, view };
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
it('when media is not fullscreen', () => {
|
|
375
|
-
const wrapper = setupTable(false).wrapper;
|
|
376
|
-
wrapper.setProps({});
|
|
377
|
-
|
|
378
|
-
expect(tablesHaveDifferentColumnWidths).toHaveBeenCalled();
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('when media is fullscreen', () => {
|
|
382
|
-
const wrapper = setupTable(true).wrapper;
|
|
383
|
-
wrapper.setProps({});
|
|
384
|
-
|
|
385
|
-
expect(tablesHaveDifferentColumnWidths).not.toHaveBeenCalled();
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const sendLogs = (_a?: any) => {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
it.skip('TODO: restore unit', () => {});
|
|
2
|
-
|
|
3
|
-
// import React from 'react';
|
|
4
|
-
|
|
5
|
-
// import { EditorView } from 'prosemirror-view';
|
|
6
|
-
|
|
7
|
-
// import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
8
|
-
// import {
|
|
9
|
-
// doc,
|
|
10
|
-
// p,
|
|
11
|
-
// table,
|
|
12
|
-
// tdCursor,
|
|
13
|
-
// tdEmpty,
|
|
14
|
-
// th,
|
|
15
|
-
// tr,
|
|
16
|
-
// } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
17
|
-
|
|
18
|
-
// import DropdownMenuWrapper from '../../../../../ui/DropdownMenu';
|
|
19
|
-
// import { ContextualMenu } from '../ContextualMenu';
|
|
20
|
-
|
|
21
|
-
// import { shallow } from 'enzyme';
|
|
22
|
-
// import { createIntl } from 'react-intl-next';
|
|
23
|
-
|
|
24
|
-
// describe('ContextualMenu', () => {
|
|
25
|
-
// const getEditorContainerWidth = () => ({ width: 500 });
|
|
26
|
-
// const createEditor = createEditorFactory();
|
|
27
|
-
// describe('with right table cell position in plugin state', () => {
|
|
28
|
-
// let editorView: EditorView;
|
|
29
|
-
// beforeEach(() => {
|
|
30
|
-
// ({ editorView } = createEditor({
|
|
31
|
-
// doc: doc(table()(tr(th()(p('')), th()(p(''))), tr(tdCursor, tdEmpty))),
|
|
32
|
-
// editorProps: {
|
|
33
|
-
// allowTables: {
|
|
34
|
-
// advanced: true,
|
|
35
|
-
// },
|
|
36
|
-
// },
|
|
37
|
-
// }));
|
|
38
|
-
// });
|
|
39
|
-
|
|
40
|
-
// it('should render contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
|
|
41
|
-
// const intl = createIntl({ locale: 'en' });
|
|
42
|
-
// const wrapper = shallow(
|
|
43
|
-
// <ContextualMenu
|
|
44
|
-
// intl={intl}
|
|
45
|
-
// editorView={editorView}
|
|
46
|
-
// selectionRect={{ bottom: 0, left: 0, right: 0, top: 0 }}
|
|
47
|
-
// isOpen
|
|
48
|
-
// getEditorContainerWidth={getEditorContainerWidth}
|
|
49
|
-
// />,
|
|
50
|
-
// );
|
|
51
|
-
|
|
52
|
-
// expect(wrapper.find(DropdownMenuWrapper).length).toEqual(1);
|
|
53
|
-
// });
|
|
54
|
-
// });
|
|
55
|
-
// });
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
it.skip('TODO: restore unit', () => {});
|
|
2
|
-
|
|
3
|
-
// import React from 'react';
|
|
4
|
-
|
|
5
|
-
// import { EditorView } from 'prosemirror-view';
|
|
6
|
-
// import { shallow } from 'enzyme';
|
|
7
|
-
|
|
8
|
-
// import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
9
|
-
// import {
|
|
10
|
-
// doc,
|
|
11
|
-
// p,
|
|
12
|
-
// table,
|
|
13
|
-
// tdCursor,
|
|
14
|
-
// tdEmpty,
|
|
15
|
-
// th,
|
|
16
|
-
// tr,
|
|
17
|
-
// } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
18
|
-
|
|
19
|
-
// import { getPluginState } from '../../../pm-plugins/plugin-factory';
|
|
20
|
-
// import FloatingContextualMenu from '../index';
|
|
21
|
-
|
|
22
|
-
// describe('FloatingContextualMenu', () => {
|
|
23
|
-
// const createEditor = createEditorFactory();
|
|
24
|
-
// describe('with right position in plugin state', () => {
|
|
25
|
-
// let editorView: EditorView;
|
|
26
|
-
// beforeEach(() => {
|
|
27
|
-
// ({ editorView } = createEditor({
|
|
28
|
-
// doc: doc(table()(tr(th()(p('')), th()(p(''))), tr(tdCursor, tdEmpty))),
|
|
29
|
-
// editorProps: {
|
|
30
|
-
// allowTables: {
|
|
31
|
-
// advanced: true,
|
|
32
|
-
// },
|
|
33
|
-
// },
|
|
34
|
-
// }));
|
|
35
|
-
// });
|
|
36
|
-
|
|
37
|
-
// it('should render floating contextual menu when no tableCellPosition is passed but exist on editor state ', () => {
|
|
38
|
-
// const wrapper = shallow(
|
|
39
|
-
// <FloatingContextualMenu
|
|
40
|
-
// editorView={editorView}
|
|
41
|
-
// isOpen={true}
|
|
42
|
-
// pluginConfig={getPluginState(editorView.state).pluginConfig}
|
|
43
|
-
// getEditorContainerWidth={jest.fn()}
|
|
44
|
-
// />,
|
|
45
|
-
// );
|
|
46
|
-
// expect(wrapper.find('Popup').length).toEqual(1);
|
|
47
|
-
// });
|
|
48
|
-
// });
|
|
49
|
-
// });
|
package/src/types.ts
DELETED