@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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
|
|
3
1
|
/** @jsx jsx */
|
|
4
2
|
import { jsx } from '@emotion/react';
|
|
5
3
|
import { defineMessages } from 'react-intl-next';
|
|
@@ -91,18 +89,18 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
|
|
|
91
89
|
}),
|
|
92
90
|
options: options
|
|
93
91
|
};
|
|
94
|
-
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Added these options for mobile. Mobile bridge translates this menu and
|
|
95
95
|
// relay it to the native mobile. Native mobile displays the menu
|
|
96
96
|
// with native widgets. It's enabled via a plugin config.
|
|
97
|
-
|
|
98
97
|
export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorState, editorView, initialSelectionRect, _ref2, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
99
98
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
100
|
-
|
|
101
99
|
var formatMessage = _ref2.formatMessage;
|
|
102
100
|
var top = initialSelectionRect.top,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
bottom = initialSelectionRect.bottom,
|
|
102
|
+
right = initialSelectionRect.right,
|
|
103
|
+
left = initialSelectionRect.left;
|
|
106
104
|
var numberOfColumns = right - left;
|
|
107
105
|
var numberOfRows = bottom - top;
|
|
108
106
|
var pluginState = getPluginState(editorState);
|
|
@@ -112,11 +110,9 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
112
110
|
onClick: function onClick(state, dispatch, view) {
|
|
113
111
|
var selectionRect = getClosestSelectionRect(state);
|
|
114
112
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
115
|
-
|
|
116
113
|
if (index) {
|
|
117
114
|
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
118
115
|
}
|
|
119
|
-
|
|
120
116
|
return true;
|
|
121
117
|
},
|
|
122
118
|
selected: false,
|
|
@@ -130,14 +126,12 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
130
126
|
onClick: function onClick(state, dispatch) {
|
|
131
127
|
var selectionRect = getClosestSelectionRect(state);
|
|
132
128
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
|
|
133
|
-
|
|
134
129
|
if (index) {
|
|
135
130
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, {
|
|
136
131
|
index: index,
|
|
137
132
|
moveCursorToInsertedRow: true
|
|
138
133
|
})(state, dispatch);
|
|
139
134
|
}
|
|
140
|
-
|
|
141
135
|
return true;
|
|
142
136
|
},
|
|
143
137
|
selected: false,
|
|
@@ -152,11 +146,9 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
152
146
|
}),
|
|
153
147
|
onClick: function onClick(state, dispatch, view) {
|
|
154
148
|
var selectionRect = getClosestSelectionRect(state);
|
|
155
|
-
|
|
156
149
|
if (selectionRect) {
|
|
157
150
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
158
151
|
}
|
|
159
|
-
|
|
160
152
|
return true;
|
|
161
153
|
},
|
|
162
154
|
onFocus: highlightColumnsHandler,
|
|
@@ -172,11 +164,9 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
172
164
|
}),
|
|
173
165
|
onClick: function onClick(state, dispatch) {
|
|
174
166
|
var selectionRect = getClosestSelectionRect(state);
|
|
175
|
-
|
|
176
167
|
if (selectionRect) {
|
|
177
168
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect, false)(state, dispatch);
|
|
178
169
|
}
|
|
179
|
-
|
|
180
170
|
return true;
|
|
181
171
|
},
|
|
182
172
|
onFocus: highlightRowsHandler,
|
|
@@ -198,22 +188,17 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
198
188
|
selected: false,
|
|
199
189
|
disabled: !splitCell(editorState)
|
|
200
190
|
}];
|
|
201
|
-
|
|
202
191
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
203
192
|
var _newResizeStateWithAn;
|
|
204
|
-
|
|
205
193
|
var newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth) : undefined;
|
|
206
194
|
var wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
207
|
-
|
|
208
195
|
var distributeColumnWidths = function distributeColumnWidths(state, dispatch) {
|
|
209
196
|
if (newResizeStateWithAnalytics) {
|
|
210
197
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
211
198
|
return true;
|
|
212
199
|
}
|
|
213
|
-
|
|
214
200
|
return false;
|
|
215
201
|
};
|
|
216
|
-
|
|
217
202
|
options.push({
|
|
218
203
|
id: 'editor.table.distributeColumns',
|
|
219
204
|
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
@@ -222,7 +207,6 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
222
207
|
disabled: !wouldChange
|
|
223
208
|
});
|
|
224
209
|
}
|
|
225
|
-
|
|
226
210
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
|
|
227
211
|
var hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
|
|
228
212
|
var warning = hasMergedCellsInTable ? formatMessage(ContextualMenuMessages.canNotSortTable) : undefined;
|
|
@@ -234,7 +218,6 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
234
218
|
hoverMergedCells()(state, dispatch);
|
|
235
219
|
return true;
|
|
236
220
|
}
|
|
237
|
-
|
|
238
221
|
return false;
|
|
239
222
|
},
|
|
240
223
|
onMouseOut: function onMouseOut(state, dispatch) {
|
|
@@ -257,7 +240,6 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
257
240
|
hoverMergedCells()(state, dispatch);
|
|
258
241
|
return true;
|
|
259
242
|
}
|
|
260
|
-
|
|
261
243
|
return false;
|
|
262
244
|
},
|
|
263
245
|
onMouseOut: function onMouseOut(state, dispatch) {
|
|
@@ -273,7 +255,6 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
273
255
|
tooltip: warning
|
|
274
256
|
});
|
|
275
257
|
}
|
|
276
|
-
|
|
277
258
|
options.push({
|
|
278
259
|
id: 'editor.table.clearCells',
|
|
279
260
|
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
@@ -281,8 +262,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
281
262
|
}),
|
|
282
263
|
onClick: function onClick(state, dispatch) {
|
|
283
264
|
var _getPluginState = getPluginState(state),
|
|
284
|
-
|
|
285
|
-
|
|
265
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
286
266
|
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, targetCellPosition)(state, dispatch);
|
|
287
267
|
return true;
|
|
288
268
|
},
|
|
@@ -303,31 +283,26 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
303
283
|
showSelected: false
|
|
304
284
|
};
|
|
305
285
|
};
|
|
306
|
-
|
|
307
286
|
var getClosestSelectionRect = function getClosestSelectionRect(state) {
|
|
308
287
|
var selection = state.selection;
|
|
309
288
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
310
289
|
};
|
|
311
|
-
|
|
312
290
|
export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
|
|
313
291
|
return function (config) {
|
|
314
292
|
return function (state, intl) {
|
|
315
293
|
var tableObject = findTable(state.selection);
|
|
316
294
|
var pluginState = getPluginState(state);
|
|
317
295
|
var resizeState = tableResizingPluginKey.getState(state);
|
|
318
|
-
|
|
319
296
|
if (tableObject && pluginState.editorHasFocus) {
|
|
320
297
|
var nodeType = state.schema.nodes.table;
|
|
321
298
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
322
|
-
|
|
323
299
|
var _ref3 = getEditorFeatureFlags() || {},
|
|
324
|
-
|
|
325
|
-
|
|
300
|
+
tableCellOptionsInFloatingToolbar = _ref3.tableCellOptionsInFloatingToolbar;
|
|
326
301
|
var cellItems = getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
327
|
-
var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
302
|
+
var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
328
303
|
|
|
304
|
+
// Check if we need to show confirm dialog for delete button
|
|
329
305
|
var confirmDialog;
|
|
330
|
-
|
|
331
306
|
if (isReferencedSource(state, tableObject.node)) {
|
|
332
307
|
confirmDialog = function confirmDialog() {
|
|
333
308
|
return {
|
|
@@ -349,23 +324,18 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
349
324
|
};
|
|
350
325
|
};
|
|
351
326
|
}
|
|
352
|
-
|
|
353
327
|
var getDomRef = function getDomRef(editorView) {
|
|
354
328
|
var element;
|
|
355
329
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
356
330
|
var parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
357
|
-
|
|
358
331
|
if (parent) {
|
|
359
332
|
var tableRef = parent.querySelector('table') || undefined;
|
|
360
|
-
|
|
361
333
|
if (tableRef) {
|
|
362
334
|
element = closestElement(tableRef, ".".concat(TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
363
335
|
}
|
|
364
336
|
}
|
|
365
|
-
|
|
366
337
|
return element;
|
|
367
338
|
};
|
|
368
|
-
|
|
369
339
|
return {
|
|
370
340
|
title: 'Table floating controls',
|
|
371
341
|
getDomRef: getDomRef,
|
|
@@ -373,7 +343,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
373
343
|
offset: [0, 3],
|
|
374
344
|
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
375
345
|
// Place the context menu slightly above the others
|
|
376
|
-
items: [menu, separator(menu.hidden)].concat(
|
|
346
|
+
items: [menu, separator(menu.hidden)].concat(cellItems, colorPicker, [{
|
|
377
347
|
type: 'extensions-placeholder',
|
|
378
348
|
separator: 'end'
|
|
379
349
|
}, {
|
|
@@ -407,25 +377,20 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
407
377
|
scrollable: true
|
|
408
378
|
};
|
|
409
379
|
}
|
|
410
|
-
|
|
411
380
|
return;
|
|
412
381
|
};
|
|
413
382
|
};
|
|
414
383
|
};
|
|
415
|
-
|
|
416
384
|
var separator = function separator(hidden) {
|
|
417
385
|
return {
|
|
418
386
|
type: 'separator',
|
|
419
387
|
hidden: hidden
|
|
420
388
|
};
|
|
421
389
|
};
|
|
422
|
-
|
|
423
390
|
var getCellItems = function getCellItems(pluginConfig, state, view, _ref4, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
424
391
|
var formatMessage = _ref4.formatMessage;
|
|
425
|
-
|
|
426
392
|
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
427
393
|
var initialSelectionRect = getClosestSelectionRect(state);
|
|
428
|
-
|
|
429
394
|
if (initialSelectionRect) {
|
|
430
395
|
var cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
431
396
|
formatMessage: formatMessage
|
|
@@ -433,23 +398,17 @@ var getCellItems = function getCellItems(pluginConfig, state, view, _ref4, getEd
|
|
|
433
398
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
434
399
|
}
|
|
435
400
|
}
|
|
436
|
-
|
|
437
401
|
return [];
|
|
438
402
|
};
|
|
439
|
-
|
|
440
403
|
var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
441
404
|
var _node$attrs;
|
|
442
|
-
|
|
443
405
|
var formatMessage = _ref5.formatMessage;
|
|
444
|
-
|
|
445
406
|
var _getPluginState2 = getPluginState(state),
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
407
|
+
targetCellPosition = _getPluginState2.targetCellPosition,
|
|
408
|
+
pluginConfig = _getPluginState2.pluginConfig;
|
|
449
409
|
if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
|
|
450
410
|
return [];
|
|
451
411
|
}
|
|
452
|
-
|
|
453
412
|
var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
|
|
454
413
|
var currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
455
414
|
var defaultPalette = cellBackgroundColorPalette.find(function (item) {
|
|
@@ -471,41 +430,32 @@ var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContai
|
|
|
471
430
|
}
|
|
472
431
|
}, separator(menu.hidden)];
|
|
473
432
|
};
|
|
474
|
-
|
|
475
433
|
var clickWithCheckboxHandler = function clickWithCheckboxHandler(isChecked, node, editorAnalyticsAPI) {
|
|
476
434
|
return function (state, dispatch) {
|
|
477
435
|
if (!node) {
|
|
478
436
|
return false;
|
|
479
437
|
}
|
|
480
|
-
|
|
481
438
|
if (!isChecked) {
|
|
482
439
|
return deleteTableWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
483
440
|
} else {
|
|
484
441
|
removeDescendantNodes(node)(state, dispatch);
|
|
485
442
|
}
|
|
486
|
-
|
|
487
443
|
return true;
|
|
488
444
|
};
|
|
489
445
|
};
|
|
490
|
-
|
|
491
446
|
var highlightRowsHandler = function highlightRowsHandler(state, dispatch) {
|
|
492
447
|
var selectionRect = getClosestSelectionRect(state);
|
|
493
|
-
|
|
494
448
|
if (selectionRect) {
|
|
495
449
|
hoverRows(getSelectedRowIndexes(selectionRect), true)(state, dispatch);
|
|
496
450
|
return true;
|
|
497
451
|
}
|
|
498
|
-
|
|
499
452
|
return false;
|
|
500
453
|
};
|
|
501
|
-
|
|
502
454
|
var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch) {
|
|
503
455
|
var selectionRect = getClosestSelectionRect(state);
|
|
504
|
-
|
|
505
456
|
if (selectionRect) {
|
|
506
457
|
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(state, dispatch);
|
|
507
458
|
return true;
|
|
508
459
|
}
|
|
509
|
-
|
|
510
460
|
return false;
|
|
511
461
|
};
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
5
|
import { tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
9
7
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
10
8
|
import { setMeta } from './metadata';
|
|
11
9
|
import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
12
10
|
import { getTableMaxWidth } from '../pm-plugins/table-resizing/utils/misc';
|
|
13
11
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
14
12
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
13
|
+
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
14
|
+
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
15
15
|
export var updateColumnWidths = function updateColumnWidths(resizeState, table, start) {
|
|
16
16
|
return function (tr) {
|
|
17
17
|
var map = TableMap.get(table);
|
|
18
|
-
var updatedCellsAttrs = {};
|
|
18
|
+
var updatedCellsAttrs = {};
|
|
19
19
|
|
|
20
|
+
// calculating new attributes for each cell
|
|
20
21
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
21
22
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
22
23
|
var width = resizeState.cols[columnIndex].width;
|
|
23
24
|
var mapIndex = rowIndex * map.width + columnIndex;
|
|
24
25
|
var cellPos = map.map[mapIndex];
|
|
25
|
-
|
|
26
26
|
var attrs = updatedCellsAttrs[cellPos] || _objectSpread({}, table.nodeAt(cellPos).attrs);
|
|
27
|
-
|
|
28
27
|
var colspan = attrs.colspan || 1;
|
|
29
|
-
|
|
30
28
|
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
31
29
|
tr = setMeta({
|
|
32
30
|
type: 'UPDATE_COLUMN_WIDTHS',
|
|
@@ -37,26 +35,22 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
37
35
|
}
|
|
38
36
|
})(tr);
|
|
39
37
|
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
40
|
-
}
|
|
41
|
-
|
|
38
|
+
}
|
|
42
39
|
|
|
40
|
+
// Rowspanning cell that has already been handled
|
|
43
41
|
if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
|
|
44
42
|
continue;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
var colspanIndex = colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
|
|
48
|
-
|
|
49
45
|
if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
|
|
50
46
|
continue;
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
var colwidths = attrs.colwidth ? attrs.colwidth.slice() : Array.from({
|
|
54
49
|
length: colspan
|
|
55
50
|
}, function (_) {
|
|
56
51
|
return 0;
|
|
57
52
|
});
|
|
58
53
|
colwidths[colspanIndex] = width;
|
|
59
|
-
|
|
60
54
|
if (colwidths.length > colspan) {
|
|
61
55
|
tr = setMeta({
|
|
62
56
|
type: 'UPDATE_COLUMN_WIDTHS',
|
|
@@ -68,36 +62,29 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
68
62
|
})(tr);
|
|
69
63
|
colwidths = colwidths.slice(0, colspan);
|
|
70
64
|
}
|
|
71
|
-
|
|
72
65
|
updatedCellsAttrs[cellPos] = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
73
66
|
colwidth: colwidths.includes(0) ? undefined : colwidths
|
|
74
67
|
});
|
|
75
68
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
69
|
+
}
|
|
78
70
|
|
|
71
|
+
// updating all cells with new attributes
|
|
79
72
|
var rows = [];
|
|
80
73
|
var seen = {};
|
|
81
|
-
|
|
82
74
|
for (var _rowIndex = 0; _rowIndex < map.height; _rowIndex++) {
|
|
83
75
|
var row = table.child(_rowIndex);
|
|
84
76
|
var cells = [];
|
|
85
|
-
|
|
86
77
|
for (var _columnIndex = 0; _columnIndex < map.width; _columnIndex++) {
|
|
87
78
|
var _mapIndex = _rowIndex * map.width + _columnIndex;
|
|
88
|
-
|
|
89
79
|
var pos = map.map[_mapIndex];
|
|
90
80
|
var cell = table.nodeAt(pos);
|
|
91
|
-
|
|
92
81
|
if (!seen[pos] && cell) {
|
|
93
82
|
cells.push(cell.type.createChecked(updatedCellsAttrs[pos] || cell.attrs, cell.content, cell.marks));
|
|
94
83
|
seen[pos] = true;
|
|
95
84
|
}
|
|
96
85
|
}
|
|
97
|
-
|
|
98
86
|
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
99
87
|
}
|
|
100
|
-
|
|
101
88
|
var tablePos = start - 1;
|
|
102
89
|
var selectionBookmark = tr.selection.getBookmark();
|
|
103
90
|
tr.replaceWith(tablePos, tablePos + table.nodeSize, table.type.createChecked(table.attrs, rows, table.marks));
|
|
@@ -111,10 +98,10 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
111
98
|
*
|
|
112
99
|
* @see https://github.com/ProseMirror/prosemirror/issues/645
|
|
113
100
|
*/
|
|
114
|
-
|
|
115
101
|
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
116
102
|
};
|
|
117
103
|
};
|
|
104
|
+
|
|
118
105
|
/**
|
|
119
106
|
* This function is called when user inserts/deletes a column in a table to;
|
|
120
107
|
* - rescale all columns (if the table did not overflow before the insertion)
|
|
@@ -125,27 +112,24 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
125
112
|
* @param view
|
|
126
113
|
* @returns Updated transaction with rescaled columns for a given table
|
|
127
114
|
*/
|
|
128
|
-
|
|
129
115
|
export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
130
116
|
return function (table, view) {
|
|
131
117
|
return function (tr) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (!view || !hasTableBeenResized(table.node)) {
|
|
118
|
+
var _tableRef$parentEleme;
|
|
119
|
+
if (!view) {
|
|
135
120
|
return tr;
|
|
136
121
|
}
|
|
137
|
-
|
|
122
|
+
var pos = table.pos;
|
|
123
|
+
var newTable = tr.doc.nodeAt(pos);
|
|
138
124
|
var state = view.state;
|
|
139
125
|
var domAtPos = view.domAtPos.bind(view);
|
|
140
126
|
var maybeTable = domAtPos(table.start).node;
|
|
141
127
|
var tableRef = maybeTable.closest('table');
|
|
142
|
-
|
|
143
|
-
if (!tableRef) {
|
|
128
|
+
if (!tableRef || !newTable) {
|
|
144
129
|
return tr;
|
|
145
130
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
131
|
+
var layout = normaliseTableLayout(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout);
|
|
132
|
+
// The is the width the table can reach before overflowing
|
|
149
133
|
var maxSize = getTableMaxWidth({
|
|
150
134
|
table: table.node,
|
|
151
135
|
tableStart: table.start,
|
|
@@ -153,6 +137,44 @@ export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
|
153
137
|
layout: layout,
|
|
154
138
|
getEditorContainerWidth: getEditorContainerWidth
|
|
155
139
|
});
|
|
140
|
+
var tableWidth = tableRef.clientWidth || akEditorDefaultLayoutWidth;
|
|
141
|
+
var tableMaxWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0;
|
|
142
|
+
tableMaxWidth -= insertColumnButtonOffset;
|
|
143
|
+
var newTableMap = TableMap.get(newTable);
|
|
144
|
+
var noOfColumns = newTableMap.width;
|
|
145
|
+
if (!noOfColumns || noOfColumns <= 0) {
|
|
146
|
+
return tr;
|
|
147
|
+
}
|
|
148
|
+
var columnWidthUnresized = tableWidth / noOfColumns;
|
|
149
|
+
|
|
150
|
+
// If the table has not been resized, and the column width is bigger than the minimum column width
|
|
151
|
+
// we skip updating the size of columns here.
|
|
152
|
+
if (!hasTableBeenResized(table.node) && columnWidthUnresized > tableCellMinWidth) {
|
|
153
|
+
return tr;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// If the table has not been resized, and the column width is smaller than the minimum column width
|
|
157
|
+
// Or if the table has been resized, but each column width is either 48px or null
|
|
158
|
+
// we update the table to have 48px for each column
|
|
159
|
+
if (!hasTableBeenResized(table.node) && columnWidthUnresized <= tableCellMinWidth || hasTableBeenResized(table.node) && isMinCellWidthTable(table.node)) {
|
|
160
|
+
var widths = new Array(noOfColumns).fill(tableCellMinWidth);
|
|
161
|
+
var cols = widths.map(function (width, index) {
|
|
162
|
+
return {
|
|
163
|
+
width: tableCellMinWidth,
|
|
164
|
+
minWidth: tableCellMinWidth,
|
|
165
|
+
index: index
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
var overflow = tableWidth > maxSize;
|
|
169
|
+
var minWidthResizeState = {
|
|
170
|
+
cols: cols,
|
|
171
|
+
widths: widths,
|
|
172
|
+
maxSize: maxSize,
|
|
173
|
+
tableWidth: tableWidth,
|
|
174
|
+
overflow: overflow
|
|
175
|
+
};
|
|
176
|
+
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
177
|
+
}
|
|
156
178
|
var resizeState = getResizeState({
|
|
157
179
|
minWidth: tableCellMinWidth,
|
|
158
180
|
table: table.node,
|
|
@@ -162,13 +184,13 @@ export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
|
162
184
|
maxSize: maxSize
|
|
163
185
|
});
|
|
164
186
|
var previousTableWidth = resizeState.tableWidth - tableNewColumnMinWidth;
|
|
165
|
-
var tableDidntPreviouslyOverflow = previousTableWidth <= maxSize;
|
|
166
|
-
// we resize the cells to avoid the overflow occuring
|
|
187
|
+
var tableDidntPreviouslyOverflow = previousTableWidth <= Math.max(maxSize, tableMaxWidth);
|
|
167
188
|
|
|
189
|
+
// If the new table width will result in the table going into an overflow state
|
|
190
|
+
// we resize the cells to avoid the overflow occuring
|
|
168
191
|
if (tableDidntPreviouslyOverflow && resizeState.overflow) {
|
|
169
192
|
resizeState = scaleTableTo(resizeState, maxSize);
|
|
170
193
|
}
|
|
171
|
-
|
|
172
194
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
173
195
|
};
|
|
174
196
|
};
|