@atlaskit/editor-plugin-table 1.1.1 → 1.1.3
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/CHANGELOG.md +18 -0
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/plugins/table/commands/clear.js +4 -16
- package/dist/cjs/plugins/table/commands/collapse.js +0 -6
- package/dist/cjs/plugins/table/commands/go-to-next-cell.js +7 -18
- package/dist/cjs/plugins/table/commands/hover.js +7 -37
- package/dist/cjs/plugins/table/commands/index.js +0 -8
- package/dist/cjs/plugins/table/commands/insert.js +17 -56
- package/dist/cjs/plugins/table/commands/misc.js +36 -132
- package/dist/cjs/plugins/table/commands/referentiality.js +0 -4
- package/dist/cjs/plugins/table/commands/selection.js +21 -87
- package/dist/cjs/plugins/table/commands/sort.js +2 -23
- package/dist/cjs/plugins/table/commands/split-cell.js +3 -11
- package/dist/cjs/plugins/table/commands/toggle.js +8 -34
- package/dist/cjs/plugins/table/commands-with-analytics.js +50 -139
- package/dist/cjs/plugins/table/create-plugin-config.js +0 -6
- package/dist/cjs/plugins/table/event-handlers.js +58 -160
- package/dist/cjs/plugins/table/handlers.js +10 -39
- package/dist/cjs/plugins/table/index.js +47 -91
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -41
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +95 -191
- package/dist/cjs/plugins/table/nodeviews/table.js +12 -70
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +15 -39
- package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +3 -15
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +0 -18
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -27
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -20
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +0 -3
- package/dist/cjs/plugins/table/pm-plugins/keymap.js +2 -15
- package/dist/cjs/plugins/table/pm-plugins/main.js +20 -72
- package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +25 -42
- package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -8
- package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -23
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +0 -5
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +0 -5
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -13
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +56 -138
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -30
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +0 -6
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +0 -5
- package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +13 -44
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +18 -43
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -52
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -10
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +5 -19
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +0 -10
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +16 -15
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -28
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +3 -23
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -46
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +0 -9
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +51 -40
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +1 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +17 -73
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -82
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -36
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +0 -5
- package/dist/cjs/plugins/table/reducer.js +0 -24
- package/dist/cjs/plugins/table/toolbar.js +14 -94
- package/dist/cjs/plugins/table/transforms/column-width.js +58 -49
- package/dist/cjs/plugins/table/transforms/delete-columns.js +11 -76
- package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -42
- package/dist/cjs/plugins/table/transforms/fix-tables.js +24 -61
- package/dist/cjs/plugins/table/transforms/index.js +0 -7
- package/dist/cjs/plugins/table/transforms/merge.js +14 -90
- package/dist/cjs/plugins/table/transforms/metadata.js +0 -5
- package/dist/cjs/plugins/table/transforms/replace-table.js +2 -13
- package/dist/cjs/plugins/table/transforms/split.js +18 -32
- package/dist/cjs/plugins/table/types.js +0 -11
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -51
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +0 -12
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -145
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -35
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +0 -11
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -12
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -16
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +19 -89
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -31
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -22
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +25 -80
- package/dist/cjs/plugins/table/ui/LayoutButton/index.js +16 -64
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -47
- package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -48
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -43
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +33 -74
- package/dist/cjs/plugins/table/ui/common-styles.js +10 -22
- package/dist/cjs/plugins/table/ui/consts.js +3 -8
- package/dist/cjs/plugins/table/ui/messages.js +0 -3
- package/dist/cjs/plugins/table/ui/ui-styles.js +0 -32
- package/dist/cjs/plugins/table/utils/analytics.js +4 -19
- package/dist/cjs/plugins/table/utils/collapse.js +4 -21
- package/dist/cjs/plugins/table/utils/column-controls.js +25 -61
- package/dist/cjs/plugins/table/utils/decoration.js +46 -114
- package/dist/cjs/plugins/table/utils/dom.js +4 -51
- package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +0 -2
- package/dist/cjs/plugins/table/utils/index.js +0 -10
- package/dist/cjs/plugins/table/utils/nodes.js +5 -48
- package/dist/cjs/plugins/table/utils/paste.js +22 -47
- package/dist/cjs/plugins/table/utils/row-controls.js +6 -67
- package/dist/cjs/plugins/table/utils/selection.js +3 -36
- package/dist/cjs/plugins/table/utils/table.js +0 -11
- package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +0 -4
- package/dist/cjs/plugins/table-plugin.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/clear.js +3 -8
- package/dist/es2019/plugins/table/commands/collapse.js +0 -3
- package/dist/es2019/plugins/table/commands/go-to-next-cell.js +4 -7
- package/dist/es2019/plugins/table/commands/hover.js +7 -17
- package/dist/es2019/plugins/table/commands/insert.js +16 -36
- package/dist/es2019/plugins/table/commands/misc.js +37 -67
- package/dist/es2019/plugins/table/commands/selection.js +7 -62
- package/dist/es2019/plugins/table/commands/sort.js +0 -12
- package/dist/es2019/plugins/table/commands/split-cell.js +0 -4
- package/dist/es2019/plugins/table/commands/toggle.js +13 -15
- package/dist/es2019/plugins/table/commands-with-analytics.js +4 -14
- package/dist/es2019/plugins/table/event-handlers.js +14 -62
- package/dist/es2019/plugins/table/handlers.js +16 -26
- package/dist/es2019/plugins/table/index.js +12 -25
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -40
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +40 -103
- package/dist/es2019/plugins/table/nodeviews/table.js +3 -33
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +7 -16
- package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +0 -5
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +4 -13
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +0 -3
- package/dist/es2019/plugins/table/pm-plugins/keymap.js +2 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +19 -43
- package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +2 -6
- package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
- package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +0 -12
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +55 -130
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -9
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
- package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +20 -39
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +14 -17
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +13 -27
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +2 -5
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +8 -8
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +14 -3
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -11
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +4 -21
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -22
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +46 -21
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +31 -61
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +54 -51
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +9 -14
- package/dist/es2019/plugins/table/reducer.js +26 -30
- package/dist/es2019/plugins/table/toolbar.js +5 -48
- package/dist/es2019/plugins/table/transforms/column-width.js +60 -32
- package/dist/es2019/plugins/table/transforms/delete-columns.js +17 -58
- package/dist/es2019/plugins/table/transforms/delete-rows.js +8 -25
- package/dist/es2019/plugins/table/transforms/fix-tables.js +25 -42
- package/dist/es2019/plugins/table/transforms/merge.js +22 -70
- package/dist/es2019/plugins/table/transforms/metadata.js +3 -2
- package/dist/es2019/plugins/table/transforms/replace-table.js +0 -2
- package/dist/es2019/plugins/table/transforms/split.js +16 -19
- package/dist/es2019/plugins/table/types.js +2 -4
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -16
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +8 -54
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +4 -13
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +0 -2
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +2 -11
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +13 -49
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +0 -8
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +16 -24
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -31
- package/dist/es2019/plugins/table/ui/LayoutButton/index.js +2 -29
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +0 -12
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +6 -12
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +0 -9
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -19
- package/dist/es2019/plugins/table/ui/common-styles.js +11 -7
- package/dist/es2019/plugins/table/ui/consts.js +4 -3
- package/dist/es2019/plugins/table/ui/ui-styles.js +0 -10
- package/dist/es2019/plugins/table/utils/analytics.js +0 -8
- package/dist/es2019/plugins/table/utils/collapse.js +3 -14
- package/dist/es2019/plugins/table/utils/column-controls.js +22 -37
- package/dist/es2019/plugins/table/utils/decoration.js +13 -51
- package/dist/es2019/plugins/table/utils/dom.js +3 -19
- package/dist/es2019/plugins/table/utils/nodes.js +2 -15
- package/dist/es2019/plugins/table/utils/paste.js +17 -22
- package/dist/es2019/plugins/table/utils/row-controls.js +12 -45
- package/dist/es2019/plugins/table/utils/selection.js +0 -21
- package/dist/es2019/plugins/table/utils/table.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/clear.js +3 -8
- package/dist/esm/plugins/table/commands/collapse.js +0 -3
- package/dist/esm/plugins/table/commands/go-to-next-cell.js +6 -9
- package/dist/esm/plugins/table/commands/hover.js +8 -18
- package/dist/esm/plugins/table/commands/insert.js +16 -36
- package/dist/esm/plugins/table/commands/misc.js +39 -78
- package/dist/esm/plugins/table/commands/selection.js +21 -78
- package/dist/esm/plugins/table/commands/sort.js +2 -14
- package/dist/esm/plugins/table/commands/split-cell.js +3 -8
- package/dist/esm/plugins/table/commands/toggle.js +11 -20
- package/dist/esm/plugins/table/commands-with-analytics.js +50 -85
- package/dist/esm/plugins/table/create-plugin-config.js +0 -3
- package/dist/esm/plugins/table/event-handlers.js +58 -123
- package/dist/esm/plugins/table/handlers.js +11 -29
- package/dist/esm/plugins/table/index.js +47 -60
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -44
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +95 -184
- package/dist/esm/plugins/table/nodeviews/table.js +12 -52
- package/dist/esm/plugins/table/nodeviews/tableCell.js +15 -33
- package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +0 -5
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -19
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -13
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/keymap.js +2 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +20 -47
- package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +25 -37
- package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
- package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -15
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +58 -147
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -27
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
- package/dist/esm/plugins/table/pm-plugins/table-local-id.js +14 -37
- package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +18 -25
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -36
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -6
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +5 -8
- package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +0 -7
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +14 -3
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -12
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +5 -22
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -23
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +49 -26
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +17 -62
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -55
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -24
- package/dist/esm/plugins/table/reducer.js +0 -20
- package/dist/esm/plugins/table/toolbar.js +13 -63
- package/dist/esm/plugins/table/transforms/column-width.js +58 -36
- package/dist/esm/plugins/table/transforms/delete-columns.js +11 -62
- package/dist/esm/plugins/table/transforms/delete-rows.js +4 -30
- package/dist/esm/plugins/table/transforms/fix-tables.js +24 -49
- package/dist/esm/plugins/table/transforms/merge.js +16 -75
- package/dist/esm/plugins/table/transforms/metadata.js +3 -2
- package/dist/esm/plugins/table/transforms/replace-table.js +2 -6
- package/dist/esm/plugins/table/transforms/split.js +18 -29
- package/dist/esm/plugins/table/types.js +0 -6
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +10 -31
- package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -126
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +13 -24
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -7
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -13
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +19 -68
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -14
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -18
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +25 -57
- package/dist/esm/plugins/table/ui/LayoutButton/index.js +16 -47
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -35
- package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -38
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -29
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +33 -62
- package/dist/esm/plugins/table/ui/common-styles.js +9 -10
- package/dist/esm/plugins/table/ui/consts.js +4 -3
- package/dist/esm/plugins/table/ui/ui-styles.js +0 -12
- package/dist/esm/plugins/table/utils/analytics.js +4 -13
- package/dist/esm/plugins/table/utils/collapse.js +4 -15
- package/dist/esm/plugins/table/utils/column-controls.js +25 -41
- package/dist/esm/plugins/table/utils/decoration.js +46 -88
- package/dist/esm/plugins/table/utils/dom.js +4 -20
- package/dist/esm/plugins/table/utils/nodes.js +5 -18
- package/dist/esm/plugins/table/utils/paste.js +24 -29
- package/dist/esm/plugins/table/utils/row-controls.js +6 -46
- package/dist/esm/plugins/table/utils/selection.js +3 -26
- package/dist/esm/plugins/table/utils/table.js +0 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +7 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +2 -1
- package/dist/types/plugins/table/ui/common-styles.d.ts +1 -0
- package/package.json +8 -6
- package/src/__tests__/integration/__fixtures__/empty-layout.ts +35 -0
- package/src/__tests__/integration/__fixtures__/nested-in-expand.ts +129 -0
- package/src/__tests__/integration/horizontal-scroll.ts +489 -0
- package/src/__tests__/unit/commands/insert.ts +3 -3
- package/src/__tests__/unit/keymap.ts +3 -1
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +38 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +5 -2
- package/src/__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 +2 -2
- package/src/__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 +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +2 -2
- package/src/__tests__/visual-regression/sticky-header.ts +2 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +16 -3
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +6 -2
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +9 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +19 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +57 -5
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +2 -2
- package/src/plugins/table/transforms/column-width.ts +60 -6
- package/src/plugins/table/ui/common-styles.ts +5 -2
|
@@ -88,15 +88,15 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
88
88
|
hidden: options.every(option => option.hidden),
|
|
89
89
|
options
|
|
90
90
|
};
|
|
91
|
-
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Added these options for mobile. Mobile bridge translates this menu and
|
|
92
94
|
// relay it to the native mobile. Native mobile displays the menu
|
|
93
95
|
// with native widgets. It's enabled via a plugin config.
|
|
94
|
-
|
|
95
96
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
96
97
|
formatMessage
|
|
97
98
|
}, getEditorContainerWidth, editorAnalyticsAPI) => {
|
|
98
99
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
99
|
-
|
|
100
100
|
const {
|
|
101
101
|
top,
|
|
102
102
|
bottom,
|
|
@@ -112,11 +112,9 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
112
112
|
onClick: (state, dispatch, view) => {
|
|
113
113
|
const selectionRect = getClosestSelectionRect(state);
|
|
114
114
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
115
|
-
|
|
116
115
|
if (index) {
|
|
117
116
|
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
118
117
|
}
|
|
119
|
-
|
|
120
118
|
return true;
|
|
121
119
|
},
|
|
122
120
|
selected: false,
|
|
@@ -130,14 +128,12 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
130
128
|
onClick: (state, dispatch) => {
|
|
131
129
|
const selectionRect = getClosestSelectionRect(state);
|
|
132
130
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
|
|
133
|
-
|
|
134
131
|
if (index) {
|
|
135
132
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, {
|
|
136
133
|
index,
|
|
137
134
|
moveCursorToInsertedRow: true
|
|
138
135
|
})(state, dispatch);
|
|
139
136
|
}
|
|
140
|
-
|
|
141
137
|
return true;
|
|
142
138
|
},
|
|
143
139
|
selected: false,
|
|
@@ -152,11 +148,9 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
152
148
|
}),
|
|
153
149
|
onClick: (state, dispatch, view) => {
|
|
154
150
|
const selectionRect = getClosestSelectionRect(state);
|
|
155
|
-
|
|
156
151
|
if (selectionRect) {
|
|
157
152
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
158
153
|
}
|
|
159
|
-
|
|
160
154
|
return true;
|
|
161
155
|
},
|
|
162
156
|
onFocus: highlightColumnsHandler,
|
|
@@ -172,11 +166,9 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
172
166
|
}),
|
|
173
167
|
onClick: (state, dispatch) => {
|
|
174
168
|
const selectionRect = getClosestSelectionRect(state);
|
|
175
|
-
|
|
176
169
|
if (selectionRect) {
|
|
177
170
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect, false)(state, dispatch);
|
|
178
171
|
}
|
|
179
|
-
|
|
180
172
|
return true;
|
|
181
173
|
},
|
|
182
174
|
onFocus: highlightRowsHandler,
|
|
@@ -198,22 +190,17 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
198
190
|
selected: false,
|
|
199
191
|
disabled: !splitCell(editorState)
|
|
200
192
|
}];
|
|
201
|
-
|
|
202
193
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
203
194
|
var _newResizeStateWithAn;
|
|
204
|
-
|
|
205
195
|
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth) : undefined;
|
|
206
196
|
const wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
207
|
-
|
|
208
197
|
const distributeColumnWidths = (state, dispatch) => {
|
|
209
198
|
if (newResizeStateWithAnalytics) {
|
|
210
199
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
211
200
|
return true;
|
|
212
201
|
}
|
|
213
|
-
|
|
214
202
|
return false;
|
|
215
203
|
};
|
|
216
|
-
|
|
217
204
|
options.push({
|
|
218
205
|
id: 'editor.table.distributeColumns',
|
|
219
206
|
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
@@ -222,7 +209,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
222
209
|
disabled: !wouldChange
|
|
223
210
|
});
|
|
224
211
|
}
|
|
225
|
-
|
|
226
212
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
|
|
227
213
|
const hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
|
|
228
214
|
const warning = hasMergedCellsInTable ? formatMessage(ContextualMenuMessages.canNotSortTable) : undefined;
|
|
@@ -234,7 +220,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
234
220
|
hoverMergedCells()(state, dispatch);
|
|
235
221
|
return true;
|
|
236
222
|
}
|
|
237
|
-
|
|
238
223
|
return false;
|
|
239
224
|
},
|
|
240
225
|
onMouseOut: (state, dispatch) => {
|
|
@@ -257,7 +242,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
257
242
|
hoverMergedCells()(state, dispatch);
|
|
258
243
|
return true;
|
|
259
244
|
}
|
|
260
|
-
|
|
261
245
|
return false;
|
|
262
246
|
},
|
|
263
247
|
onMouseOut: (state, dispatch) => {
|
|
@@ -273,7 +257,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
273
257
|
tooltip: warning
|
|
274
258
|
});
|
|
275
259
|
}
|
|
276
|
-
|
|
277
260
|
options.push({
|
|
278
261
|
id: 'editor.table.clearCells',
|
|
279
262
|
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
@@ -303,17 +286,14 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
303
286
|
showSelected: false
|
|
304
287
|
};
|
|
305
288
|
};
|
|
306
|
-
|
|
307
289
|
const getClosestSelectionRect = state => {
|
|
308
290
|
const selection = state.selection;
|
|
309
291
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
310
292
|
};
|
|
311
|
-
|
|
312
293
|
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
|
|
313
294
|
const tableObject = findTable(state.selection);
|
|
314
295
|
const pluginState = getPluginState(state);
|
|
315
296
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
316
|
-
|
|
317
297
|
if (tableObject && pluginState.editorHasFocus) {
|
|
318
298
|
const nodeType = state.schema.nodes.table;
|
|
319
299
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
@@ -321,10 +301,10 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
321
301
|
tableCellOptionsInFloatingToolbar
|
|
322
302
|
} = getEditorFeatureFlags() || {};
|
|
323
303
|
const cellItems = getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
324
|
-
const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
304
|
+
const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
325
305
|
|
|
306
|
+
// Check if we need to show confirm dialog for delete button
|
|
326
307
|
let confirmDialog;
|
|
327
|
-
|
|
328
308
|
if (isReferencedSource(state, tableObject.node)) {
|
|
329
309
|
confirmDialog = () => ({
|
|
330
310
|
title: intl.formatMessage(tableMessages.deleteElementTitle),
|
|
@@ -339,23 +319,18 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
339
319
|
onConfirm: (isChecked = false) => clickWithCheckboxHandler(isChecked, tableObject.node)
|
|
340
320
|
});
|
|
341
321
|
}
|
|
342
|
-
|
|
343
322
|
const getDomRef = editorView => {
|
|
344
323
|
let element;
|
|
345
324
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
346
325
|
const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
347
|
-
|
|
348
326
|
if (parent) {
|
|
349
327
|
const tableRef = parent.querySelector('table') || undefined;
|
|
350
|
-
|
|
351
328
|
if (tableRef) {
|
|
352
329
|
element = closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
|
|
353
330
|
}
|
|
354
331
|
}
|
|
355
|
-
|
|
356
332
|
return element;
|
|
357
333
|
};
|
|
358
|
-
|
|
359
334
|
return {
|
|
360
335
|
title: 'Table floating controls',
|
|
361
336
|
getDomRef,
|
|
@@ -397,23 +372,19 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
397
372
|
scrollable: true
|
|
398
373
|
};
|
|
399
374
|
}
|
|
400
|
-
|
|
401
375
|
return;
|
|
402
376
|
};
|
|
403
|
-
|
|
404
377
|
const separator = hidden => {
|
|
405
378
|
return {
|
|
406
379
|
type: 'separator',
|
|
407
380
|
hidden: hidden
|
|
408
381
|
};
|
|
409
382
|
};
|
|
410
|
-
|
|
411
383
|
const getCellItems = (pluginConfig, state, view, {
|
|
412
384
|
formatMessage
|
|
413
385
|
}, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
|
|
414
386
|
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
415
387
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
416
|
-
|
|
417
388
|
if (initialSelectionRect) {
|
|
418
389
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
419
390
|
formatMessage
|
|
@@ -421,24 +392,19 @@ const getCellItems = (pluginConfig, state, view, {
|
|
|
421
392
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
422
393
|
}
|
|
423
394
|
}
|
|
424
|
-
|
|
425
395
|
return [];
|
|
426
396
|
};
|
|
427
|
-
|
|
428
397
|
const getColorPicker = (state, menu, {
|
|
429
398
|
formatMessage
|
|
430
399
|
}, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
|
|
431
400
|
var _node$attrs;
|
|
432
|
-
|
|
433
401
|
const {
|
|
434
402
|
targetCellPosition,
|
|
435
403
|
pluginConfig
|
|
436
404
|
} = getPluginState(state);
|
|
437
|
-
|
|
438
405
|
if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
|
|
439
406
|
return [];
|
|
440
407
|
}
|
|
441
|
-
|
|
442
408
|
const node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
|
|
443
409
|
const currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
444
410
|
const defaultPalette = cellBackgroundColorPalette.find(item => item.value === currentBackground) || {
|
|
@@ -456,39 +422,30 @@ const getColorPicker = (state, menu, {
|
|
|
456
422
|
onChange: option => setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition)
|
|
457
423
|
}, separator(menu.hidden)];
|
|
458
424
|
};
|
|
459
|
-
|
|
460
425
|
const clickWithCheckboxHandler = (isChecked, node, editorAnalyticsAPI) => (state, dispatch) => {
|
|
461
426
|
if (!node) {
|
|
462
427
|
return false;
|
|
463
428
|
}
|
|
464
|
-
|
|
465
429
|
if (!isChecked) {
|
|
466
430
|
return deleteTableWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
467
431
|
} else {
|
|
468
432
|
removeDescendantNodes(node)(state, dispatch);
|
|
469
433
|
}
|
|
470
|
-
|
|
471
434
|
return true;
|
|
472
435
|
};
|
|
473
|
-
|
|
474
436
|
const highlightRowsHandler = (state, dispatch) => {
|
|
475
437
|
const selectionRect = getClosestSelectionRect(state);
|
|
476
|
-
|
|
477
438
|
if (selectionRect) {
|
|
478
439
|
hoverRows(getSelectedRowIndexes(selectionRect), true)(state, dispatch);
|
|
479
440
|
return true;
|
|
480
441
|
}
|
|
481
|
-
|
|
482
442
|
return false;
|
|
483
443
|
};
|
|
484
|
-
|
|
485
444
|
const highlightColumnsHandler = (state, dispatch) => {
|
|
486
445
|
const selectionRect = getClosestSelectionRect(state);
|
|
487
|
-
|
|
488
446
|
if (selectionRect) {
|
|
489
447
|
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(state, dispatch);
|
|
490
448
|
return true;
|
|
491
449
|
}
|
|
492
|
-
|
|
493
450
|
return false;
|
|
494
451
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
2
|
import { tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
|
+
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
4
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
4
5
|
import { setMeta } from './metadata';
|
|
5
6
|
import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
6
7
|
import { getTableMaxWidth } from '../pm-plugins/table-resizing/utils/misc';
|
|
7
8
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
8
9
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
10
|
+
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
11
|
+
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
9
12
|
export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
10
13
|
const map = TableMap.get(table);
|
|
11
|
-
const updatedCellsAttrs = {};
|
|
14
|
+
const updatedCellsAttrs = {};
|
|
12
15
|
|
|
16
|
+
// calculating new attributes for each cell
|
|
13
17
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
14
18
|
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
15
19
|
const {
|
|
@@ -17,10 +21,10 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
17
21
|
} = resizeState.cols[columnIndex];
|
|
18
22
|
const mapIndex = rowIndex * map.width + columnIndex;
|
|
19
23
|
const cellPos = map.map[mapIndex];
|
|
20
|
-
const attrs = updatedCellsAttrs[cellPos] || {
|
|
24
|
+
const attrs = updatedCellsAttrs[cellPos] || {
|
|
25
|
+
...table.nodeAt(cellPos).attrs
|
|
21
26
|
};
|
|
22
27
|
const colspan = attrs.colspan || 1;
|
|
23
|
-
|
|
24
28
|
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
25
29
|
tr = setMeta({
|
|
26
30
|
type: 'UPDATE_COLUMN_WIDTHS',
|
|
@@ -31,24 +35,20 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
31
35
|
}
|
|
32
36
|
})(tr);
|
|
33
37
|
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
34
|
-
}
|
|
35
|
-
|
|
38
|
+
}
|
|
36
39
|
|
|
40
|
+
// Rowspanning cell that has already been handled
|
|
37
41
|
if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
|
|
38
42
|
continue;
|
|
39
43
|
}
|
|
40
|
-
|
|
41
44
|
const colspanIndex = colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
|
|
42
|
-
|
|
43
45
|
if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
|
|
44
46
|
continue;
|
|
45
47
|
}
|
|
46
|
-
|
|
47
48
|
let colwidths = attrs.colwidth ? attrs.colwidth.slice() : Array.from({
|
|
48
49
|
length: colspan
|
|
49
50
|
}, _ => 0);
|
|
50
51
|
colwidths[colspanIndex] = width;
|
|
51
|
-
|
|
52
52
|
if (colwidths.length > colspan) {
|
|
53
53
|
tr = setMeta({
|
|
54
54
|
type: 'UPDATE_COLUMN_WIDTHS',
|
|
@@ -60,35 +60,30 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
60
60
|
})(tr);
|
|
61
61
|
colwidths = colwidths.slice(0, colspan);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
updatedCellsAttrs[cellPos] = {
|
|
64
|
+
...attrs,
|
|
65
65
|
colwidth: colwidths.includes(0) ? undefined : colwidths
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
68
|
+
}
|
|
70
69
|
|
|
70
|
+
// updating all cells with new attributes
|
|
71
71
|
const rows = [];
|
|
72
72
|
const seen = {};
|
|
73
|
-
|
|
74
73
|
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
75
74
|
const row = table.child(rowIndex);
|
|
76
75
|
const cells = [];
|
|
77
|
-
|
|
78
76
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
79
77
|
const mapIndex = rowIndex * map.width + columnIndex;
|
|
80
78
|
const pos = map.map[mapIndex];
|
|
81
79
|
const cell = table.nodeAt(pos);
|
|
82
|
-
|
|
83
80
|
if (!seen[pos] && cell) {
|
|
84
81
|
cells.push(cell.type.createChecked(updatedCellsAttrs[pos] || cell.attrs, cell.content, cell.marks));
|
|
85
82
|
seen[pos] = true;
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
|
-
|
|
89
85
|
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
90
86
|
}
|
|
91
|
-
|
|
92
87
|
const tablePos = start - 1;
|
|
93
88
|
const selectionBookmark = tr.selection.getBookmark();
|
|
94
89
|
tr.replaceWith(tablePos, tablePos + table.nodeSize, table.type.createChecked(table.attrs, rows, table.marks));
|
|
@@ -102,9 +97,9 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
102
97
|
*
|
|
103
98
|
* @see https://github.com/ProseMirror/prosemirror/issues/645
|
|
104
99
|
*/
|
|
105
|
-
|
|
106
100
|
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
107
101
|
};
|
|
102
|
+
|
|
108
103
|
/**
|
|
109
104
|
* This function is called when user inserts/deletes a column in a table to;
|
|
110
105
|
* - rescale all columns (if the table did not overflow before the insertion)
|
|
@@ -115,27 +110,24 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
115
110
|
* @param view
|
|
116
111
|
* @returns Updated transaction with rescaled columns for a given table
|
|
117
112
|
*/
|
|
118
|
-
|
|
119
113
|
export const rescaleColumns = getEditorContainerWidth => (table, view) => tr => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (!view || !hasTableBeenResized(table.node)) {
|
|
114
|
+
var _tableRef$parentEleme;
|
|
115
|
+
if (!view) {
|
|
123
116
|
return tr;
|
|
124
117
|
}
|
|
125
|
-
|
|
118
|
+
const pos = table.pos;
|
|
119
|
+
const newTable = tr.doc.nodeAt(pos);
|
|
126
120
|
const {
|
|
127
121
|
state
|
|
128
122
|
} = view;
|
|
129
123
|
const domAtPos = view.domAtPos.bind(view);
|
|
130
124
|
const maybeTable = domAtPos(table.start).node;
|
|
131
125
|
const tableRef = maybeTable.closest('table');
|
|
132
|
-
|
|
133
|
-
if (!tableRef) {
|
|
126
|
+
if (!tableRef || !newTable) {
|
|
134
127
|
return tr;
|
|
135
128
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
const layout = normaliseTableLayout(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout);
|
|
130
|
+
// The is the width the table can reach before overflowing
|
|
139
131
|
const maxSize = getTableMaxWidth({
|
|
140
132
|
table: table.node,
|
|
141
133
|
tableStart: table.start,
|
|
@@ -143,6 +135,42 @@ export const rescaleColumns = getEditorContainerWidth => (table, view) => tr =>
|
|
|
143
135
|
layout,
|
|
144
136
|
getEditorContainerWidth
|
|
145
137
|
});
|
|
138
|
+
const tableWidth = tableRef.clientWidth || akEditorDefaultLayoutWidth;
|
|
139
|
+
let tableMaxWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0;
|
|
140
|
+
tableMaxWidth -= insertColumnButtonOffset;
|
|
141
|
+
const newTableMap = TableMap.get(newTable);
|
|
142
|
+
const noOfColumns = newTableMap.width;
|
|
143
|
+
if (!noOfColumns || noOfColumns <= 0) {
|
|
144
|
+
return tr;
|
|
145
|
+
}
|
|
146
|
+
const columnWidthUnresized = tableWidth / noOfColumns;
|
|
147
|
+
|
|
148
|
+
// If the table has not been resized, and the column width is bigger than the minimum column width
|
|
149
|
+
// we skip updating the size of columns here.
|
|
150
|
+
if (!hasTableBeenResized(table.node) && columnWidthUnresized > tableCellMinWidth) {
|
|
151
|
+
return tr;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// If the table has not been resized, and the column width is smaller than the minimum column width
|
|
155
|
+
// Or if the table has been resized, but each column width is either 48px or null
|
|
156
|
+
// we update the table to have 48px for each column
|
|
157
|
+
if (!hasTableBeenResized(table.node) && columnWidthUnresized <= tableCellMinWidth || hasTableBeenResized(table.node) && isMinCellWidthTable(table.node)) {
|
|
158
|
+
const widths = new Array(noOfColumns).fill(tableCellMinWidth);
|
|
159
|
+
const cols = widths.map((width, index) => ({
|
|
160
|
+
width: tableCellMinWidth,
|
|
161
|
+
minWidth: tableCellMinWidth,
|
|
162
|
+
index
|
|
163
|
+
}));
|
|
164
|
+
const overflow = tableWidth > maxSize;
|
|
165
|
+
const minWidthResizeState = {
|
|
166
|
+
cols,
|
|
167
|
+
widths,
|
|
168
|
+
maxSize,
|
|
169
|
+
tableWidth,
|
|
170
|
+
overflow
|
|
171
|
+
};
|
|
172
|
+
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
173
|
+
}
|
|
146
174
|
let resizeState = getResizeState({
|
|
147
175
|
minWidth: tableCellMinWidth,
|
|
148
176
|
table: table.node,
|
|
@@ -152,12 +180,12 @@ export const rescaleColumns = getEditorContainerWidth => (table, view) => tr =>
|
|
|
152
180
|
maxSize
|
|
153
181
|
});
|
|
154
182
|
const previousTableWidth = resizeState.tableWidth - tableNewColumnMinWidth;
|
|
155
|
-
const tableDidntPreviouslyOverflow = previousTableWidth <= maxSize;
|
|
156
|
-
// we resize the cells to avoid the overflow occuring
|
|
183
|
+
const tableDidntPreviouslyOverflow = previousTableWidth <= Math.max(maxSize, tableMaxWidth);
|
|
157
184
|
|
|
185
|
+
// If the new table width will result in the table going into an overflow state
|
|
186
|
+
// we resize the cells to avoid the overflow occuring
|
|
158
187
|
if (tableDidntPreviouslyOverflow && resizeState.overflow) {
|
|
159
188
|
resizeState = scaleTableTo(resizeState, maxSize);
|
|
160
189
|
}
|
|
161
|
-
|
|
162
190
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
163
191
|
};
|