@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
|
@@ -6,48 +6,34 @@ export class OverflowShadowsObserver {
|
|
|
6
6
|
// updateShadowState is a method to update shadow key
|
|
7
7
|
constructor(updateShadowState, _table, wrapper) {
|
|
8
8
|
_defineProperty(this, "firstCell", null);
|
|
9
|
-
|
|
10
9
|
_defineProperty(this, "lastCell", null);
|
|
11
|
-
|
|
12
10
|
_defineProperty(this, "getFirstCell", (isSticky, hasHeaderRow) => {
|
|
13
11
|
var _this$table;
|
|
14
|
-
|
|
15
12
|
return (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(isSticky || !hasHeaderRow ? 'table tbody tr td' : 'table tbody tr th');
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
_defineProperty(this, "getLastCell", (isSticky, hasHeaderRow) => {
|
|
19
15
|
var _this$table2;
|
|
20
|
-
|
|
21
16
|
return (_this$table2 = this.table) === null || _this$table2 === void 0 ? void 0 : _this$table2.querySelector(isSticky || !hasHeaderRow ? 'table tbody tr td:last-child' : 'table tbody tr th:last-child');
|
|
22
17
|
});
|
|
23
|
-
|
|
24
18
|
_defineProperty(this, "isSticky", false);
|
|
25
|
-
|
|
26
19
|
_defineProperty(this, "stickyRowHeight", 0);
|
|
27
|
-
|
|
28
20
|
_defineProperty(this, "init", () => {
|
|
29
21
|
const table = this.table;
|
|
30
|
-
|
|
31
22
|
if (!this.wrapper || !table) {
|
|
32
23
|
return;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
if (!this.tableIntersectionObserver) {
|
|
36
26
|
const intersectonOnbserverCallback = entry => {
|
|
37
27
|
var _entry$rootBounds, _entry$rootBounds2;
|
|
38
|
-
|
|
39
28
|
if (!((_entry$rootBounds = entry.rootBounds) !== null && _entry$rootBounds !== void 0 && _entry$rootBounds.height) && !((_entry$rootBounds2 = entry.rootBounds) !== null && _entry$rootBounds2 !== void 0 && _entry$rootBounds2.width)) {
|
|
40
29
|
return;
|
|
41
30
|
}
|
|
42
|
-
|
|
43
31
|
if (entry.target !== this.firstCell && entry.target !== this.lastCell) {
|
|
44
32
|
return;
|
|
45
33
|
}
|
|
46
|
-
|
|
47
34
|
this.updateStickyShadowsHeightIfChanged();
|
|
48
35
|
this.checkIntersectionEvent(entry, this.firstCell === entry.target ? ShadowEvent.SHOW_BEFORE_SHADOW : ShadowEvent.SHOW_AFTER_SHADOW);
|
|
49
36
|
};
|
|
50
|
-
|
|
51
37
|
this.tableIntersectionObserver = new IntersectionObserver((entries, _) => {
|
|
52
38
|
entries.forEach(entry => intersectonOnbserverCallback(entry));
|
|
53
39
|
}, {
|
|
@@ -58,102 +44,84 @@ export class OverflowShadowsObserver {
|
|
|
58
44
|
return;
|
|
59
45
|
}
|
|
60
46
|
});
|
|
61
|
-
|
|
62
47
|
_defineProperty(this, "checkIntersectionEvent", (entry, shadowKey) => {
|
|
63
|
-
if (
|
|
48
|
+
if (
|
|
49
|
+
// If it's in full view, don't show shadow.
|
|
64
50
|
entry.isIntersecting && entry.intersectionRatio === 1) {
|
|
65
51
|
this.updateShadowState(shadowKey, false);
|
|
66
|
-
} else if (
|
|
52
|
+
} else if (
|
|
53
|
+
// If it's in partial view, show a shadow
|
|
67
54
|
entry.intersectionRatio < 1) {
|
|
68
55
|
this.updateShadowState(shadowKey, true);
|
|
69
56
|
}
|
|
70
57
|
});
|
|
71
|
-
|
|
72
58
|
_defineProperty(this, "observeCells", (isSticky, hasHeaderRow) => {
|
|
73
59
|
const stickyChanged = !!isSticky !== this.isSticky;
|
|
74
|
-
this.isSticky = !!isSticky;
|
|
60
|
+
this.isSticky = !!isSticky;
|
|
75
61
|
|
|
62
|
+
// update sticky shadows
|
|
76
63
|
this.updateStickyShadowsHeightIfChanged();
|
|
77
|
-
|
|
78
64
|
if (!stickyChanged) {
|
|
79
65
|
const firstCell = this.getFirstCell(isSticky, hasHeaderRow);
|
|
80
66
|
const lastCell = this.getLastCell(isSticky, hasHeaderRow);
|
|
81
|
-
|
|
82
67
|
if (!firstCell || !lastCell || firstCell === this.firstCell && lastCell === this.lastCell) {
|
|
83
68
|
return;
|
|
84
69
|
}
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
this.firstCell = this.getFirstCell(isSticky, hasHeaderRow);
|
|
88
72
|
this.lastCell = this.getLastCell(isSticky, hasHeaderRow);
|
|
89
|
-
|
|
90
73
|
if (this.tableIntersectionObserver && this.firstCell && this.lastCell) {
|
|
91
74
|
this.tableIntersectionObserver.disconnect();
|
|
92
75
|
this.tableIntersectionObserver.observe(this.firstCell);
|
|
93
76
|
this.tableIntersectionObserver.observe(this.lastCell);
|
|
94
77
|
}
|
|
95
78
|
});
|
|
96
|
-
|
|
97
79
|
_defineProperty(this, "updateStickyShadows", stickyRowHeight => {
|
|
98
80
|
var _this$wrapper, _this$wrapper2, _this$wrapper2$parent, _this$wrapper3, _this$wrapper3$parent;
|
|
99
|
-
|
|
100
81
|
if (!this.isSticky) {
|
|
101
82
|
return;
|
|
102
83
|
}
|
|
103
|
-
|
|
104
84
|
const stickyCell = this.getStickyCell();
|
|
105
|
-
|
|
106
85
|
if (!stickyCell || !((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement)) {
|
|
107
86
|
return;
|
|
108
87
|
}
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
const heightStyleOrCompute = `${stickyRowHeight || stickyCell.clientHeight + 1}px`;
|
|
89
|
+
// Use getElementsByClassName here for a live node list to capture
|
|
111
90
|
// sticky shadows
|
|
112
|
-
|
|
113
91
|
const liveRightShadows = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : (_this$wrapper2$parent = _this$wrapper2.parentElement) === null || _this$wrapper2$parent === void 0 ? void 0 : _this$wrapper2$parent.getElementsByClassName(`${ClassName.TABLE_RIGHT_SHADOW}`);
|
|
114
92
|
const liveLeftShadows = (_this$wrapper3 = this.wrapper) === null || _this$wrapper3 === void 0 ? void 0 : (_this$wrapper3$parent = _this$wrapper3.parentElement) === null || _this$wrapper3$parent === void 0 ? void 0 : _this$wrapper3$parent.getElementsByClassName(`${ClassName.TABLE_LEFT_SHADOW}`);
|
|
115
93
|
updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
|
|
116
94
|
updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
|
|
117
95
|
});
|
|
118
|
-
|
|
119
96
|
this.updateShadowState = updateShadowState;
|
|
120
97
|
this.table = _table;
|
|
121
98
|
this.wrapper = wrapper;
|
|
122
99
|
this.init();
|
|
123
100
|
}
|
|
124
|
-
|
|
125
101
|
updateStickyShadowsHeightIfChanged() {
|
|
126
102
|
if (!this.isSticky) {
|
|
127
103
|
return;
|
|
128
104
|
}
|
|
129
|
-
|
|
130
105
|
const stickyCell = this.getStickyCell();
|
|
131
|
-
|
|
132
106
|
if (!stickyCell) {
|
|
133
107
|
return;
|
|
134
108
|
}
|
|
135
|
-
|
|
136
109
|
const newStickyRowHeight = stickyCell.clientHeight + 1;
|
|
137
|
-
|
|
138
110
|
if (newStickyRowHeight === this.stickyRowHeight) {
|
|
139
111
|
this.stickyRowHeight = newStickyRowHeight;
|
|
140
112
|
this.updateStickyShadows(this.stickyRowHeight);
|
|
141
113
|
}
|
|
142
114
|
}
|
|
143
|
-
|
|
144
115
|
getStickyCell() {
|
|
145
116
|
var _this$wrapper4;
|
|
146
|
-
|
|
147
117
|
const stickyRow = (_this$wrapper4 = this.wrapper) === null || _this$wrapper4 === void 0 ? void 0 : _this$wrapper4.querySelector('tr.sticky');
|
|
148
118
|
const stickyCell = stickyRow && stickyRow.firstElementChild;
|
|
149
119
|
return stickyCell;
|
|
150
120
|
}
|
|
151
|
-
|
|
152
121
|
dispose() {
|
|
153
122
|
if (this.tableIntersectionObserver) {
|
|
154
123
|
this.tableIntersectionObserver.disconnect();
|
|
155
124
|
this.tableIntersectionObserver = undefined;
|
|
156
125
|
}
|
|
157
126
|
}
|
|
158
|
-
|
|
159
127
|
}
|
|
@@ -21,14 +21,12 @@ import { containsHeaderRow, tablesHaveDifferentColumnWidths, tablesHaveDifferent
|
|
|
21
21
|
import { updateOverflowShadows } from './update-overflow-shadows';
|
|
22
22
|
import memoizeOne from 'memoize-one';
|
|
23
23
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
24
|
+
import { getParentWidthWithoutPadding } from '../pm-plugins/table-resizing/utils/misc';
|
|
24
25
|
const isIE11 = browser.ie_version === 11;
|
|
25
|
-
|
|
26
26
|
const NOOP = () => undefined;
|
|
27
|
-
|
|
28
27
|
class TableComponent extends React.Component {
|
|
29
28
|
constructor(props) {
|
|
30
29
|
super(props);
|
|
31
|
-
|
|
32
30
|
_defineProperty(this, "state", {
|
|
33
31
|
scroll: 0,
|
|
34
32
|
tableContainerWidth: 'inherit',
|
|
@@ -37,49 +35,39 @@ class TableComponent extends React.Component {
|
|
|
37
35
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: false,
|
|
38
36
|
[ShadowEvent.SHOW_AFTER_SHADOW]: false
|
|
39
37
|
});
|
|
40
|
-
|
|
41
38
|
_defineProperty(this, "updateShadowState", (shadowKey, value) => {
|
|
42
39
|
if (this.state[shadowKey] === value) {
|
|
43
40
|
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
}
|
|
42
|
+
// need this check to satisfy types for the setState argument
|
|
47
43
|
if (shadowKey === ShadowEvent.SHOW_BEFORE_SHADOW) {
|
|
48
44
|
return this.setState({
|
|
49
45
|
[shadowKey]: value
|
|
50
46
|
});
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
this.setState({
|
|
54
49
|
[shadowKey]: value
|
|
55
50
|
});
|
|
56
51
|
});
|
|
57
|
-
|
|
58
52
|
_defineProperty(this, "onStickyState", state => {
|
|
59
53
|
const {
|
|
60
54
|
tableOverflowShadowsOptimization
|
|
61
55
|
} = this.props.getEditorFeatureFlags();
|
|
62
56
|
const pos = this.props.getPos();
|
|
63
|
-
|
|
64
57
|
if (!isValidPosition(pos, this.props.view.state)) {
|
|
65
58
|
return;
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
const stickyHeader = findStickyHeaderForTable(state, pos);
|
|
69
|
-
|
|
70
61
|
if (stickyHeader !== this.state.stickyHeader) {
|
|
71
62
|
this.setState({
|
|
72
63
|
stickyHeader
|
|
73
64
|
});
|
|
74
|
-
|
|
75
65
|
if (tableOverflowShadowsOptimization && this.overflowShadowsObserver) {
|
|
76
66
|
this.overflowShadowsObserver.updateStickyShadows();
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
69
|
});
|
|
80
|
-
|
|
81
70
|
_defineProperty(this, "prevTableState", null);
|
|
82
|
-
|
|
83
71
|
_defineProperty(this, "getMarginLeft", tableContainerCssWidth => {
|
|
84
72
|
const {
|
|
85
73
|
containerWidth
|
|
@@ -88,43 +76,34 @@ class TableComponent extends React.Component {
|
|
|
88
76
|
lineLength
|
|
89
77
|
} = containerWidth;
|
|
90
78
|
let marginLeft;
|
|
91
|
-
|
|
92
79
|
if (tableContainerCssWidth !== 'inherit' && lineLength) {
|
|
93
80
|
const containerWidth = parsePx(tableContainerCssWidth);
|
|
94
|
-
|
|
95
81
|
if (containerWidth) {
|
|
96
82
|
marginLeft = (lineLength - containerWidth) / 2;
|
|
97
83
|
}
|
|
98
84
|
}
|
|
99
|
-
|
|
100
85
|
return marginLeft;
|
|
101
86
|
});
|
|
102
|
-
|
|
103
87
|
_defineProperty(this, "handleScroll", event => {
|
|
104
88
|
if (!this.wrapper || event.target !== this.wrapper) {
|
|
105
89
|
return;
|
|
106
90
|
}
|
|
107
|
-
|
|
108
91
|
if (this.table) {
|
|
109
92
|
// sync sticky header row to table scroll
|
|
110
93
|
const headers = this.table.querySelectorAll('tr[data-header-row]');
|
|
111
|
-
|
|
112
94
|
for (let i = 0; i < headers.length; i++) {
|
|
113
95
|
const header = headers[i];
|
|
114
96
|
header.scrollLeft = this.wrapper.scrollLeft;
|
|
115
97
|
header.style.marginRight = '2px';
|
|
116
98
|
}
|
|
117
99
|
}
|
|
118
|
-
|
|
119
100
|
const {
|
|
120
101
|
tableOverflowShadowsOptimization
|
|
121
102
|
} = this.props.getEditorFeatureFlags();
|
|
122
|
-
|
|
123
103
|
if (!tableOverflowShadowsOptimization) {
|
|
124
104
|
this.updateShadows();
|
|
125
105
|
}
|
|
126
106
|
});
|
|
127
|
-
|
|
128
107
|
_defineProperty(this, "handleTableResizing", () => {
|
|
129
108
|
const {
|
|
130
109
|
getNode,
|
|
@@ -133,20 +112,24 @@ class TableComponent extends React.Component {
|
|
|
133
112
|
} = this.props;
|
|
134
113
|
const prevNode = this.node;
|
|
135
114
|
const node = getNode();
|
|
136
|
-
const prevAttrs = prevNode.attrs;
|
|
115
|
+
const prevAttrs = prevNode.attrs;
|
|
137
116
|
|
|
117
|
+
// We only consider a layout change valid if it's done outside of an autoSize.
|
|
138
118
|
const layoutChanged = prevAttrs.layout !== node.attrs.layout && prevAttrs.__autoSize === node.attrs.__autoSize;
|
|
139
119
|
const parentWidth = this.getParentNodeWidth();
|
|
140
120
|
const parentWidthChanged = parentWidth && parentWidth !== this.state.parentWidth;
|
|
141
121
|
const layoutSize = this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
142
122
|
const hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
143
123
|
const noOfColumnsChanged = tablesHaveDifferentNoOfColumns(node, prevNode);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
layoutChanged ||
|
|
124
|
+
if (
|
|
125
|
+
// Breakout mode/layout changed
|
|
126
|
+
layoutChanged ||
|
|
127
|
+
// We need to react if our parent changes
|
|
147
128
|
// Scales the cols widths relative to the new parent width.
|
|
148
|
-
parentWidthChanged ||
|
|
149
|
-
|
|
129
|
+
parentWidthChanged ||
|
|
130
|
+
// Enabling / disabling this feature reduces or adds size to the table.
|
|
131
|
+
hasNumberedColumnChanged ||
|
|
132
|
+
// This last check is also to cater for dynamic text sizing changing the 'default' layout width
|
|
150
133
|
// Usually happens on window resize.
|
|
151
134
|
layoutSize !== this.layoutSize || noOfColumnsChanged) {
|
|
152
135
|
// If column has been inserted/deleted avoid multi dispatch
|
|
@@ -156,16 +139,13 @@ class TableComponent extends React.Component {
|
|
|
156
139
|
layoutChanged
|
|
157
140
|
});
|
|
158
141
|
}
|
|
159
|
-
|
|
160
142
|
this.updateParentWidth(parentWidth);
|
|
161
143
|
}
|
|
162
|
-
|
|
163
144
|
this.updateTableContainerWidth();
|
|
164
145
|
this.node = node;
|
|
165
146
|
this.containerWidth = containerWidth;
|
|
166
147
|
this.layoutSize = layoutSize;
|
|
167
148
|
});
|
|
168
|
-
|
|
169
149
|
_defineProperty(this, "scaleTable", scaleOptions => {
|
|
170
150
|
const {
|
|
171
151
|
view,
|
|
@@ -180,17 +160,16 @@ class TableComponent extends React.Component {
|
|
|
180
160
|
dispatch
|
|
181
161
|
} = view;
|
|
182
162
|
const pos = getPos();
|
|
183
|
-
|
|
184
163
|
if (!isValidPosition(pos, state)) {
|
|
185
164
|
return;
|
|
186
165
|
}
|
|
187
|
-
|
|
188
166
|
const domAtPos = view.domAtPos.bind(view);
|
|
189
167
|
const {
|
|
190
168
|
width
|
|
191
169
|
} = containerWidth;
|
|
192
170
|
this.scaleTableDebounced.cancel();
|
|
193
|
-
scaleTable(this.table, {
|
|
171
|
+
scaleTable(this.table, {
|
|
172
|
+
...scaleOptions,
|
|
194
173
|
node,
|
|
195
174
|
prevNode: this.node || node,
|
|
196
175
|
start: pos + 1,
|
|
@@ -199,7 +178,6 @@ class TableComponent extends React.Component {
|
|
|
199
178
|
...options
|
|
200
179
|
}, domAtPos)(state, dispatch);
|
|
201
180
|
});
|
|
202
|
-
|
|
203
181
|
_defineProperty(this, "handleAutoSize", () => {
|
|
204
182
|
if (this.table) {
|
|
205
183
|
const {
|
|
@@ -210,32 +188,34 @@ class TableComponent extends React.Component {
|
|
|
210
188
|
} = this.props;
|
|
211
189
|
const node = getNode();
|
|
212
190
|
const pos = getPos();
|
|
213
|
-
|
|
214
191
|
if (!isValidPosition(pos, view.state)) {
|
|
215
192
|
return;
|
|
216
193
|
}
|
|
217
|
-
|
|
218
194
|
autoSizeTable(view, node, this.table, pos, {
|
|
219
195
|
containerWidth: containerWidth.width
|
|
220
196
|
});
|
|
221
197
|
}
|
|
222
198
|
});
|
|
223
|
-
|
|
224
199
|
_defineProperty(this, "handleWindowResize", () => {
|
|
200
|
+
var _node$attrs, _node$attrs2;
|
|
225
201
|
const {
|
|
226
202
|
getNode,
|
|
227
203
|
containerWidth
|
|
228
204
|
} = this.props;
|
|
229
|
-
const
|
|
230
|
-
|
|
205
|
+
const node = getNode();
|
|
206
|
+
const prevNode = this.node;
|
|
207
|
+
const layoutSize = this.tableNodeLayoutSize(node);
|
|
208
|
+
const prevAttrs = prevNode === null || prevNode === void 0 ? void 0 : prevNode.attrs;
|
|
209
|
+
const layoutChanged = (prevAttrs === null || prevAttrs === void 0 ? void 0 : prevAttrs.layout) !== (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) && (prevAttrs === null || prevAttrs === void 0 ? void 0 : prevAttrs.__autoSize) === (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.__autoSize);
|
|
231
210
|
if (containerWidth.width > layoutSize) {
|
|
232
211
|
return;
|
|
233
212
|
}
|
|
234
|
-
|
|
235
213
|
const parentWidth = this.getParentNodeWidth();
|
|
236
|
-
this.scaleTableDebounced(
|
|
214
|
+
this.scaleTableDebounced({
|
|
215
|
+
layoutChanged: layoutChanged,
|
|
216
|
+
parentWidth: parentWidth
|
|
217
|
+
});
|
|
237
218
|
});
|
|
238
|
-
|
|
239
219
|
_defineProperty(this, "updateTableContainerWidth", () => {
|
|
240
220
|
const {
|
|
241
221
|
getNode,
|
|
@@ -243,30 +223,24 @@ class TableComponent extends React.Component {
|
|
|
243
223
|
options
|
|
244
224
|
} = this.props;
|
|
245
225
|
const node = getNode();
|
|
246
|
-
|
|
247
226
|
if (options && options.isBreakoutEnabled === false) {
|
|
248
227
|
return;
|
|
249
228
|
}
|
|
250
|
-
|
|
251
229
|
const tableContainerWidth = calcTableWidth(node.attrs.layout, containerWidth.width);
|
|
252
|
-
|
|
253
230
|
if (this.state.tableContainerWidth === tableContainerWidth) {
|
|
254
231
|
return null;
|
|
255
232
|
}
|
|
256
|
-
|
|
257
233
|
this.setState(prevState => {
|
|
258
234
|
if (options && options.isBreakoutEnabled === false && prevState.tableContainerWidth !== 'inherit') {
|
|
259
235
|
return {
|
|
260
236
|
tableContainerWidth: 'inherit'
|
|
261
237
|
};
|
|
262
238
|
}
|
|
263
|
-
|
|
264
239
|
return {
|
|
265
240
|
tableContainerWidth
|
|
266
241
|
};
|
|
267
242
|
});
|
|
268
243
|
});
|
|
269
|
-
|
|
270
244
|
_defineProperty(this, "getParentNodeWidth", () => {
|
|
271
245
|
const {
|
|
272
246
|
getPos,
|
|
@@ -277,32 +251,23 @@ class TableComponent extends React.Component {
|
|
|
277
251
|
}
|
|
278
252
|
} = this.props;
|
|
279
253
|
const pos = getPos();
|
|
280
|
-
|
|
281
254
|
if (!isValidPosition(pos, state)) {
|
|
282
255
|
return;
|
|
283
256
|
}
|
|
284
|
-
|
|
285
|
-
return
|
|
257
|
+
const parentNodeWith = getParentNodeWidth(pos, state, containerWidth, options && options.isFullWidthModeEnabled);
|
|
258
|
+
return getParentWidthWithoutPadding(parentNodeWith, pos, state);
|
|
286
259
|
});
|
|
287
|
-
|
|
288
260
|
_defineProperty(this, "updateParentWidth", width => {
|
|
289
261
|
this.setState({
|
|
290
262
|
parentWidth: width
|
|
291
263
|
});
|
|
292
264
|
});
|
|
293
|
-
|
|
294
265
|
_defineProperty(this, "tableNodeLayoutSize", (node, containerWidth, options) => getLayoutSize(node.attrs.layout, containerWidth || this.props.containerWidth.width, options || this.props.options || {}));
|
|
295
|
-
|
|
296
266
|
_defineProperty(this, "scaleTableDebounced", rafSchedule(this.scaleTable));
|
|
297
|
-
|
|
298
267
|
_defineProperty(this, "handleTableResizingDebounced", rafSchedule(this.handleTableResizing));
|
|
299
|
-
|
|
300
268
|
_defineProperty(this, "handleScrollDebounced", rafSchedule(this.handleScroll));
|
|
301
|
-
|
|
302
269
|
_defineProperty(this, "handleAutoSizeDebounced", rafSchedule(this.handleAutoSize));
|
|
303
|
-
|
|
304
270
|
_defineProperty(this, "handleWindowResizeDebounced", rafSchedule(this.handleWindowResize));
|
|
305
|
-
|
|
306
271
|
const {
|
|
307
272
|
options: _options,
|
|
308
273
|
containerWidth: _containerWidth,
|
|
@@ -310,14 +275,16 @@ class TableComponent extends React.Component {
|
|
|
310
275
|
getEditorFeatureFlags
|
|
311
276
|
} = props;
|
|
312
277
|
this.node = _getNode();
|
|
313
|
-
this.containerWidth = _containerWidth;
|
|
278
|
+
this.containerWidth = _containerWidth;
|
|
314
279
|
|
|
280
|
+
// store table size using previous full-width mode so can detect if it has changed
|
|
315
281
|
const isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
316
282
|
this.layoutSize = this.tableNodeLayoutSize(this.node, _containerWidth.width, {
|
|
317
283
|
isFullWidthModeEnabled
|
|
318
|
-
});
|
|
319
|
-
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
284
|
+
});
|
|
320
285
|
|
|
286
|
+
// Disable inline table editing and resizing controls in Firefox
|
|
287
|
+
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
321
288
|
if ('execCommand' in document) {
|
|
322
289
|
['enableObjectResizing', 'enableInlineTableEditing'].forEach(cmd => {
|
|
323
290
|
if (document.queryCommandSupported(cmd)) {
|
|
@@ -325,11 +292,9 @@ class TableComponent extends React.Component {
|
|
|
325
292
|
}
|
|
326
293
|
});
|
|
327
294
|
}
|
|
328
|
-
|
|
329
295
|
const {
|
|
330
296
|
initialRenderOptimization
|
|
331
297
|
} = getEditorFeatureFlags();
|
|
332
|
-
|
|
333
298
|
if (!initialRenderOptimization) {
|
|
334
299
|
// @see ED-7945
|
|
335
300
|
requestAnimationFrame(() => {
|
|
@@ -339,17 +304,14 @@ class TableComponent extends React.Component {
|
|
|
339
304
|
});
|
|
340
305
|
}
|
|
341
306
|
}
|
|
342
|
-
|
|
343
307
|
componentDidMount() {
|
|
344
308
|
const {
|
|
345
309
|
allowColumnResizing,
|
|
346
310
|
eventDispatcher
|
|
347
311
|
} = this.props;
|
|
348
|
-
|
|
349
312
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
350
313
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced);
|
|
351
314
|
}
|
|
352
|
-
|
|
353
315
|
if (allowColumnResizing) {
|
|
354
316
|
/**
|
|
355
317
|
* We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
|
|
@@ -359,38 +321,29 @@ class TableComponent extends React.Component {
|
|
|
359
321
|
this.updateTableContainerWidth();
|
|
360
322
|
this.handleTableResizingDebounced();
|
|
361
323
|
}
|
|
362
|
-
|
|
363
324
|
const currentStickyState = stickyHeadersPluginKey.getState(this.props.view.state);
|
|
364
|
-
|
|
365
325
|
if (currentStickyState) {
|
|
366
326
|
this.onStickyState(currentStickyState);
|
|
367
327
|
}
|
|
368
|
-
|
|
369
328
|
eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
|
|
370
329
|
}
|
|
371
|
-
|
|
372
330
|
componentWillUnmount() {
|
|
373
331
|
if (this.wrapper && !isIE11) {
|
|
374
332
|
this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
|
|
375
333
|
}
|
|
376
|
-
|
|
377
334
|
this.handleScrollDebounced.cancel();
|
|
378
335
|
this.scaleTableDebounced.cancel();
|
|
379
336
|
this.handleTableResizingDebounced.cancel();
|
|
380
337
|
this.handleAutoSizeDebounced.cancel();
|
|
381
338
|
this.handleWindowResizeDebounced.cancel();
|
|
382
|
-
|
|
383
339
|
if (this.props.allowColumnResizing) {
|
|
384
340
|
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
385
341
|
}
|
|
386
|
-
|
|
387
342
|
if (this.overflowShadowsObserver) {
|
|
388
343
|
this.overflowShadowsObserver.dispose();
|
|
389
344
|
}
|
|
390
|
-
|
|
391
345
|
this.props.eventDispatcher.off(stickyHeadersPluginKey.key, this.onStickyState);
|
|
392
346
|
}
|
|
393
|
-
|
|
394
347
|
componentDidUpdate(prevProps) {
|
|
395
348
|
const {
|
|
396
349
|
view,
|
|
@@ -402,43 +355,35 @@ class TableComponent extends React.Component {
|
|
|
402
355
|
isInDanger
|
|
403
356
|
} = getPluginState(view.state);
|
|
404
357
|
const table = findTable(view.state.selection);
|
|
405
|
-
|
|
406
358
|
if (isInDanger && !table) {
|
|
407
359
|
clearHoverSelection()(view.state, view.dispatch);
|
|
408
360
|
}
|
|
409
|
-
|
|
410
361
|
const {
|
|
411
362
|
tableOverflowShadowsOptimization
|
|
412
363
|
} = this.props.getEditorFeatureFlags();
|
|
413
|
-
|
|
414
364
|
if (!tableOverflowShadowsOptimization) {
|
|
415
365
|
this.updateShadows();
|
|
416
366
|
} else {
|
|
417
367
|
var _this$wrapper;
|
|
418
|
-
|
|
419
368
|
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
420
369
|
this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
421
370
|
}
|
|
422
|
-
|
|
423
371
|
if (this.overflowShadowsObserver) {
|
|
424
372
|
var _this$state$stickyHea;
|
|
425
|
-
|
|
426
373
|
this.overflowShadowsObserver.observeCells((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky, containsHeaderRow(getNode()));
|
|
427
374
|
}
|
|
428
375
|
}
|
|
429
|
-
|
|
430
376
|
const currentTable = getNode();
|
|
431
|
-
|
|
432
377
|
if (currentTable.attrs.__autoSize) {
|
|
433
378
|
// Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
|
|
434
379
|
this.handleAutoSizeDebounced();
|
|
435
|
-
}
|
|
380
|
+
}
|
|
381
|
+
// re-drawing will cause media component get unmounted that will exit fullscreen mode if media is in fullscreen mode
|
|
436
382
|
// see https://product-fabric.atlassian.net/browse/MEX-1290
|
|
437
383
|
else if (allowColumnResizing && this.table && !isMediaFullscreen) {
|
|
438
384
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
439
385
|
// re-draw colgroup.
|
|
440
386
|
const previousTable = this.node;
|
|
441
|
-
|
|
442
387
|
if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || tablesHaveDifferentNoOfColumns(currentTable, previousTable)) {
|
|
443
388
|
const {
|
|
444
389
|
view
|
|
@@ -446,23 +391,18 @@ class TableComponent extends React.Component {
|
|
|
446
391
|
recreateResizeColsByNode(this.table, currentTable);
|
|
447
392
|
updateControls(this.props.getEditorFeatureFlags)(view.state);
|
|
448
393
|
}
|
|
449
|
-
|
|
450
394
|
this.handleTableResizingDebounced();
|
|
451
395
|
}
|
|
452
396
|
}
|
|
453
|
-
|
|
454
397
|
updateShadows() {
|
|
455
398
|
var _this$wrapper2;
|
|
456
|
-
|
|
457
399
|
const parent = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.parentElement;
|
|
458
|
-
|
|
459
400
|
if (this.wrapper && parent) {
|
|
460
401
|
const rightShadows = parent.querySelectorAll(`.${ClassName.TABLE_RIGHT_SHADOW}`);
|
|
461
402
|
const leftShadows = parent.querySelectorAll(`.${ClassName.TABLE_LEFT_SHADOW}`);
|
|
462
403
|
updateOverflowShadows(this.props.getEditorFeatureFlags)(this.props.view.state, this.wrapper, this.table, rightShadows, leftShadows);
|
|
463
404
|
}
|
|
464
405
|
}
|
|
465
|
-
|
|
466
406
|
render() {
|
|
467
407
|
const {
|
|
468
408
|
view,
|
|
@@ -481,8 +421,8 @@ class TableComponent extends React.Component {
|
|
|
481
421
|
showBeforeShadow,
|
|
482
422
|
showAfterShadow
|
|
483
423
|
} = this.state;
|
|
484
|
-
const node = getNode();
|
|
485
|
-
|
|
424
|
+
const node = getNode();
|
|
425
|
+
// doesn't work well with WithPluginState
|
|
486
426
|
const {
|
|
487
427
|
isInDanger,
|
|
488
428
|
hoveredRows
|
|
@@ -495,8 +435,9 @@ class TableComponent extends React.Component {
|
|
|
495
435
|
} = this.props.getEditorFeatureFlags();
|
|
496
436
|
const tableRef = this.table || undefined;
|
|
497
437
|
const isResizing = !!tableResizingPluginState && !!tableResizingPluginState.dragging;
|
|
498
|
-
const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
438
|
+
const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
499
439
|
|
|
440
|
+
//dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
|
|
500
441
|
const tableHeight = tableRef && !tableRenderOptimization ? tableRef.offsetHeight : undefined;
|
|
501
442
|
const hasHeaderRow = containsHeaderRow(node);
|
|
502
443
|
const rowControls = /*#__PURE__*/React.createElement("div", {
|
|
@@ -512,7 +453,8 @@ class TableComponent extends React.Component {
|
|
|
512
453
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
513
454
|
ordering: ordering,
|
|
514
455
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
515
|
-
hasHeaderRow: hasHeaderRow
|
|
456
|
+
hasHeaderRow: hasHeaderRow
|
|
457
|
+
// pass `selection` and `tableHeight` to control re-render
|
|
516
458
|
,
|
|
517
459
|
selection: view.state.selection,
|
|
518
460
|
tableHeight: tableHeight,
|
|
@@ -554,11 +496,9 @@ class TableComponent extends React.Component {
|
|
|
554
496
|
className: classnames(ClassName.TABLE_NODE_WRAPPER),
|
|
555
497
|
ref: elem => {
|
|
556
498
|
this.wrapper = elem;
|
|
557
|
-
|
|
558
499
|
if (elem) {
|
|
559
500
|
this.props.contentDOM(elem);
|
|
560
501
|
const tableElement = elem.querySelector('table');
|
|
561
|
-
|
|
562
502
|
if (tableElement !== this.table) {
|
|
563
503
|
this.table = tableElement;
|
|
564
504
|
}
|
|
@@ -583,9 +523,6 @@ class TableComponent extends React.Component {
|
|
|
583
523
|
"data-testid": "sticky-sentinel-bottom"
|
|
584
524
|
}));
|
|
585
525
|
}
|
|
586
|
-
|
|
587
526
|
}
|
|
588
|
-
|
|
589
527
|
_defineProperty(TableComponent, "displayName", 'TableComponent');
|
|
590
|
-
|
|
591
528
|
export default TableComponent;
|