@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
|
@@ -10,7 +10,6 @@ import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizin
|
|
|
10
10
|
import { generateColgroup } from '../pm-plugins/table-resizing/utils';
|
|
11
11
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
12
12
|
import TableComponent from './TableComponent';
|
|
13
|
-
|
|
14
13
|
const tableAttributes = node => {
|
|
15
14
|
return {
|
|
16
15
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
@@ -19,53 +18,40 @@ const tableAttributes = node => {
|
|
|
19
18
|
'data-table-local-id': node.attrs.localId || ''
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
|
-
|
|
23
21
|
const toDOM = (node, props) => {
|
|
24
22
|
let colgroup = '';
|
|
25
|
-
|
|
26
23
|
if (props.allowColumnResizing) {
|
|
27
24
|
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
return ['table', tableAttributes(node), colgroup, ['tbody', 0]];
|
|
31
27
|
};
|
|
32
|
-
|
|
33
28
|
export default class TableView extends ReactNodeView {
|
|
34
29
|
constructor(props) {
|
|
35
30
|
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined, undefined, props.hasIntlContext);
|
|
36
|
-
|
|
37
31
|
_defineProperty(this, "getNode", () => {
|
|
38
32
|
return this.node;
|
|
39
33
|
});
|
|
40
|
-
|
|
41
34
|
_defineProperty(this, "hasHoveredRows", false);
|
|
42
|
-
|
|
43
35
|
this.getPos = props.getPos;
|
|
44
36
|
this.tableRenderOptimization = props.tableRenderOptimization;
|
|
45
37
|
this.eventDispatcher = props.eventDispatcher;
|
|
46
38
|
}
|
|
47
|
-
|
|
48
39
|
getContentDOM() {
|
|
49
40
|
const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
50
|
-
|
|
51
41
|
if (rendered.dom) {
|
|
52
42
|
this.table = rendered.dom;
|
|
53
43
|
}
|
|
54
|
-
|
|
55
44
|
return rendered;
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
setDomAttrs(node) {
|
|
59
47
|
if (!this.table) {
|
|
60
48
|
return;
|
|
61
49
|
}
|
|
62
|
-
|
|
63
50
|
const attrs = tableAttributes(node);
|
|
64
51
|
Object.keys(attrs).forEach(attr => {
|
|
65
52
|
this.table.setAttribute(attr, attrs[attr]);
|
|
66
53
|
});
|
|
67
54
|
}
|
|
68
|
-
|
|
69
55
|
render(props, forwardRef) {
|
|
70
56
|
// TODO: ED-15663
|
|
71
57
|
// Please, do not copy or use this kind of code below
|
|
@@ -75,10 +61,11 @@ export default class TableView extends ReactNodeView {
|
|
|
75
61
|
getState: state => {
|
|
76
62
|
return state['widthPlugin$'];
|
|
77
63
|
}
|
|
78
|
-
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// TODO: ED-15663
|
|
79
67
|
// Please, do not copy or use this kind of code below
|
|
80
68
|
// @ts-ignore
|
|
81
|
-
|
|
82
69
|
const fakeMediaPluginKey = {
|
|
83
70
|
key: 'mediaPlugin$',
|
|
84
71
|
getState: state => {
|
|
@@ -123,47 +110,36 @@ export default class TableView extends ReactNodeView {
|
|
|
123
110
|
}
|
|
124
111
|
});
|
|
125
112
|
}
|
|
126
|
-
|
|
127
113
|
viewShouldUpdate(nextNode) {
|
|
128
114
|
if (this.tableRenderOptimization) {
|
|
129
115
|
const {
|
|
130
116
|
hoveredRows
|
|
131
117
|
} = getPluginState(this.view.state);
|
|
132
118
|
const hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
|
|
133
|
-
|
|
134
119
|
if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
|
|
135
120
|
this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
|
|
136
121
|
return true;
|
|
137
122
|
}
|
|
138
|
-
|
|
139
123
|
const node = this.getNode();
|
|
140
|
-
|
|
141
124
|
if (typeof node.attrs !== typeof nextNode.attrs) {
|
|
142
125
|
return true;
|
|
143
126
|
}
|
|
144
|
-
|
|
145
127
|
const attrKeys = Object.keys(node.attrs);
|
|
146
128
|
const nextAttrKeys = Object.keys(nextNode.attrs);
|
|
147
|
-
|
|
148
129
|
if (attrKeys.length !== nextAttrKeys.length) {
|
|
149
130
|
return true;
|
|
150
131
|
}
|
|
151
|
-
|
|
152
132
|
const tableMap = TableMap.get(node);
|
|
153
133
|
const nextTableMap = TableMap.get(nextNode);
|
|
154
|
-
|
|
155
134
|
if (tableMap.width !== nextTableMap.width) {
|
|
156
135
|
return true;
|
|
157
136
|
}
|
|
158
|
-
|
|
159
137
|
return attrKeys.some(key => {
|
|
160
138
|
return node.attrs[key] !== nextNode.attrs[key];
|
|
161
139
|
});
|
|
162
140
|
}
|
|
163
|
-
|
|
164
141
|
return super.viewShouldUpdate(nextNode);
|
|
165
142
|
}
|
|
166
|
-
|
|
167
143
|
ignoreMutation(mutation) {
|
|
168
144
|
const {
|
|
169
145
|
type,
|
|
@@ -172,25 +148,19 @@ export default class TableView extends ReactNodeView {
|
|
|
172
148
|
firstChild
|
|
173
149
|
}
|
|
174
150
|
} = mutation;
|
|
175
|
-
|
|
176
151
|
if (type === 'selection' && (nodeName === null || nodeName === void 0 ? void 0 : nodeName.toUpperCase()) === 'DIV' && (firstChild === null || firstChild === void 0 ? void 0 : firstChild.nodeName.toUpperCase()) === 'TABLE') {
|
|
177
152
|
return false;
|
|
178
153
|
}
|
|
179
|
-
|
|
180
154
|
return true;
|
|
181
155
|
}
|
|
182
|
-
|
|
183
156
|
destroy() {
|
|
184
157
|
var _this$eventDispatcher;
|
|
185
|
-
|
|
186
158
|
if (this.resizeObserver) {
|
|
187
159
|
this.resizeObserver.disconnect();
|
|
188
160
|
}
|
|
189
|
-
|
|
190
161
|
(_this$eventDispatcher = this.eventDispatcher) === null || _this$eventDispatcher === void 0 ? void 0 : _this$eventDispatcher.emit('TABLE_DELETED', this.node);
|
|
191
162
|
super.destroy();
|
|
192
163
|
}
|
|
193
|
-
|
|
194
164
|
}
|
|
195
165
|
export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags) => {
|
|
196
166
|
const {
|
|
@@ -17,7 +17,6 @@ export default class TableCellNodeView {
|
|
|
17
17
|
const {
|
|
18
18
|
mouseMoveOptimization
|
|
19
19
|
} = getEditorFeatureFlags();
|
|
20
|
-
|
|
21
20
|
if (mouseMoveOptimization && observer) {
|
|
22
21
|
this.contentDOM.id = uuid();
|
|
23
22
|
this.mouseMoveOptimization = mouseMoveOptimization;
|
|
@@ -25,56 +24,48 @@ export default class TableCellNodeView {
|
|
|
25
24
|
observer.observe(this.contentDOM);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
updateNodeView(node) {
|
|
30
28
|
if (this.node.type !== node.type) {
|
|
31
29
|
return false;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
const attrs = getCellDomAttrs(this.node);
|
|
35
32
|
const nextAttrs = getCellDomAttrs(node);
|
|
36
33
|
const {
|
|
37
34
|
colspan,
|
|
38
35
|
rowspan
|
|
39
|
-
} = getCellAttrs(this.dom);
|
|
40
|
-
// this can happen when undoing merge cells
|
|
36
|
+
} = getCellAttrs(this.dom);
|
|
41
37
|
|
|
38
|
+
// need to rerender when colspan/rowspan in dom are different from the node attrs
|
|
39
|
+
// this can happen when undoing merge cells
|
|
42
40
|
if (colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) || rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)) {
|
|
43
41
|
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
42
|
+
}
|
|
46
43
|
|
|
44
|
+
// added + changed attributes
|
|
47
45
|
const addedAttrs = Object.entries(nextAttrs).filter(([key, value]) => attrs[key] !== value);
|
|
48
46
|
const removedAttrs = Object.keys(attrs).filter(key => !nextAttrs.hasOwnProperty(key));
|
|
49
|
-
|
|
50
47
|
if (addedAttrs.length || removedAttrs.length) {
|
|
51
48
|
addedAttrs.forEach(([key, value]) => this.dom.setAttribute(key, value || ''));
|
|
52
49
|
removedAttrs.forEach(key => this.dom.removeAttribute(key));
|
|
53
50
|
return true;
|
|
54
|
-
}
|
|
55
|
-
|
|
51
|
+
}
|
|
56
52
|
|
|
53
|
+
// Return true to not re-render this node view
|
|
57
54
|
if (this.node.sameMarkup(node)) {
|
|
58
55
|
return true;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
return false;
|
|
62
58
|
}
|
|
63
|
-
|
|
64
59
|
update(node) {
|
|
65
60
|
const didUpdate = this.updateNodeView(node);
|
|
66
|
-
|
|
67
61
|
if (didUpdate) {
|
|
68
62
|
this.node = node;
|
|
69
63
|
}
|
|
70
|
-
|
|
71
64
|
return didUpdate;
|
|
72
65
|
}
|
|
73
|
-
|
|
74
66
|
destroy() {
|
|
75
67
|
if (this.mouseMoveOptimization && this.observer) {
|
|
76
68
|
this.observer.unobserve(this.contentDOM);
|
|
77
69
|
}
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
}
|
|
@@ -8,41 +8,34 @@ export const updateShadowListForStickyStyles = (heightStyle, shadows) => {
|
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
13
|
* Update overflow shadows for a given wrapper & table.
|
|
13
14
|
* if `overflowShadowOptimization` is enabled, this will exit early.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
export const updateOverflowShadows = getEditorFeatureFlags => (editorState, wrapper, table, rightShadows, leftShadows) => {
|
|
17
17
|
var _getEditorFeatureFlag;
|
|
18
|
-
|
|
19
18
|
if (((_getEditorFeatureFlag = getEditorFeatureFlags()) === null || _getEditorFeatureFlag === void 0 ? void 0 : _getEditorFeatureFlag.tableOverflowShadowsOptimization) === true) {
|
|
20
19
|
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
}
|
|
21
|
+
// Right shadow
|
|
24
22
|
if (table && wrapper) {
|
|
25
23
|
const stickyRow = wrapper.querySelector('tr.sticky');
|
|
26
24
|
const stickyCell = stickyRow && stickyRow.firstElementChild;
|
|
27
|
-
|
|
28
25
|
if (rightShadows) {
|
|
29
26
|
const diff = table.offsetWidth - wrapper.offsetWidth;
|
|
30
|
-
|
|
31
27
|
for (let i = 0; i < rightShadows.length; i++) {
|
|
32
28
|
const rightShadow = rightShadows[i];
|
|
33
29
|
rightShadow.style.display = diff > 0 && diff > wrapper.scrollLeft ? 'block' : 'none';
|
|
34
|
-
|
|
35
30
|
if (rightShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
|
|
36
31
|
rightShadow.style.height = `${stickyCell.clientHeight + 1}px`;
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
if (leftShadows) {
|
|
42
36
|
for (let i = 0; i < leftShadows.length; i++) {
|
|
43
37
|
const leftShadow = leftShadows[i];
|
|
44
38
|
leftShadow.style.display = wrapper.scrollLeft > 0 ? 'block' : 'none';
|
|
45
|
-
|
|
46
39
|
if (leftShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
|
|
47
40
|
leftShadow.style.height = `${stickyCell.clientHeight + 1}px`;
|
|
48
41
|
}
|
|
@@ -14,7 +14,6 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState) => {
|
|
|
14
14
|
});
|
|
15
15
|
} else if (tr.selectionSet) {
|
|
16
16
|
const isTransactionFromMouseClick = !tr.docChanged && tr.selectionSet && tr.getMeta('pointer');
|
|
17
|
-
|
|
18
17
|
if (isTransactionFromMouseClick || oldState.selection instanceof CellSelection) {
|
|
19
18
|
return maybeUpdateColumnControlsSelectedDecoration({
|
|
20
19
|
decorationSet,
|
|
@@ -22,7 +21,6 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState) => {
|
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
return decorationSet;
|
|
27
25
|
};
|
|
28
26
|
export const createPlugin = () => {
|
|
@@ -32,16 +30,13 @@ export const createPlugin = () => {
|
|
|
32
30
|
apply: (tr, decorationSet, oldState) => {
|
|
33
31
|
let pluginState = decorationSet;
|
|
34
32
|
const meta = tr.getMeta(tablePluginKey);
|
|
35
|
-
|
|
36
33
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
37
34
|
pluginState = meta.data.decorationSet;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
if (tr.docChanged || tr.selectionSet) {
|
|
41
37
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
42
38
|
return handleDocOrSelectionChanged(tr, pluginState, oldState);
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
return pluginState;
|
|
46
41
|
}
|
|
47
42
|
},
|
|
@@ -3,14 +3,12 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
3
3
|
import { TableDecorations } from '../../../types';
|
|
4
4
|
import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
|
|
5
5
|
import { composeDecorations } from './compose-decorations';
|
|
6
|
+
const isColumnSelected = tr => tr.selection instanceof CellSelection && tr.selection.isColSelection();
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// @see: https://product-fabric.atlassian.net/browse/ED-3796
|
|
10
9
|
const removeControlsHoverDecoration = ({
|
|
11
10
|
decorationSet
|
|
12
11
|
}) => decorationSet.remove(findControlsHoverDecoration(decorationSet));
|
|
13
|
-
|
|
14
12
|
const maybeUpdateColumnSelectedDecoration = ({
|
|
15
13
|
decorationSet,
|
|
16
14
|
tr
|
|
@@ -18,30 +16,24 @@ const maybeUpdateColumnSelectedDecoration = ({
|
|
|
18
16
|
if (!isColumnSelected(tr)) {
|
|
19
17
|
return decorationSet;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
return updateDecorations(tr.doc, decorationSet, createColumnSelectedDecoration(tr), TableDecorations.COLUMN_SELECTED);
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
const maybeUpdateColumnControlsDecoration = ({
|
|
26
22
|
decorationSet,
|
|
27
23
|
tr
|
|
28
24
|
}) => {
|
|
29
25
|
const table = findTable(tr.selection);
|
|
30
|
-
|
|
31
26
|
if (!table) {
|
|
32
27
|
return decorationSet;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
36
|
-
};
|
|
37
|
-
|
|
30
|
+
};
|
|
38
31
|
|
|
32
|
+
// @see: https://product-fabric.atlassian.net/browse/ED-7304
|
|
39
33
|
const removeColumnControlsSelectedDecoration = ({
|
|
40
34
|
decorationSet
|
|
41
35
|
}) => decorationSet.remove(findColumnControlSelectedDecoration(decorationSet));
|
|
42
|
-
|
|
43
36
|
const hasColumnSelectedDecorations = decorationSet => !!findColumnControlSelectedDecoration(decorationSet).length;
|
|
44
|
-
|
|
45
37
|
export const maybeUpdateColumnControlsSelectedDecoration = ({
|
|
46
38
|
decorationSet,
|
|
47
39
|
tr
|
|
@@ -49,7 +41,6 @@ export const maybeUpdateColumnControlsSelectedDecoration = ({
|
|
|
49
41
|
if (!hasColumnSelectedDecorations(decorationSet)) {
|
|
50
42
|
return decorationSet;
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
return removeColumnControlsSelectedDecoration({
|
|
54
45
|
decorationSet,
|
|
55
46
|
tr
|
|
@@ -2,17 +2,14 @@ import { TableDecorations } from '../../../types';
|
|
|
2
2
|
import { createResizeHandleDecoration, updateDecorations } from '../../../utils/decoration';
|
|
3
3
|
import { composeDecorations } from './compose-decorations';
|
|
4
4
|
const emptyDecorations = [[], []];
|
|
5
|
-
|
|
6
5
|
const updateColumnResizeHandle = columnResizesDecorations => ({
|
|
7
6
|
decorationSet,
|
|
8
7
|
tr
|
|
9
8
|
}) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE);
|
|
10
|
-
|
|
11
9
|
const updateLastCellElement = lastCellElementsDecorations => ({
|
|
12
10
|
decorationSet,
|
|
13
11
|
tr
|
|
14
12
|
}) => updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
|
|
15
|
-
|
|
16
13
|
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex) => ({
|
|
17
14
|
tr,
|
|
18
15
|
decorationSet
|
|
@@ -6,7 +6,6 @@ import { triggerUnlessTableHeader, createTable, goToNextCell, moveCursorBackward
|
|
|
6
6
|
import { addRowAroundSelection, emptyMultipleCellsWithAnalytics, deleteTableIfSelectedWithAnalytics } from '../commands-with-analytics';
|
|
7
7
|
import { addColumnAfter, addColumnBefore } from '../commands/insert';
|
|
8
8
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
9
|
-
|
|
10
9
|
const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
|
|
11
10
|
action: ACTION.INSERTED,
|
|
12
11
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -16,15 +15,15 @@ const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
|
|
|
16
15
|
},
|
|
17
16
|
eventType: EVENT_TYPE.TRACK
|
|
18
17
|
})(editorAnalyticsAPI)(createTable());
|
|
19
|
-
|
|
20
18
|
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
21
19
|
const list = {};
|
|
22
20
|
keymaps.bindKeymapWithCommand(keymaps.nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
|
|
23
21
|
keymaps.bindKeymapWithCommand(keymaps.previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
|
|
24
22
|
keymaps.bindKeymapWithCommand(keymaps.toggleTable.common, createTableWithAnalytics(editorAnalyticsAPI), list);
|
|
25
23
|
keymaps.bindKeymapWithCommand(keymaps.backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
|
|
26
|
-
keymaps.bindKeymapWithCommand(keymaps.backspace.common, moveCursorBackward, list);
|
|
24
|
+
keymaps.bindKeymapWithCommand(keymaps.backspace.common, moveCursorBackward, list);
|
|
27
25
|
|
|
26
|
+
// Add row/column shortcuts
|
|
28
27
|
keymaps.bindKeymapWithCommand(keymaps.addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
29
28
|
keymaps.bindKeymapWithCommand(keymaps.addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
30
29
|
keymaps.bindKeymapWithCommand(keymaps.addColumnBefore.common, triggerUnlessTableHeader(addColumnBefore(getEditorContainerWidth)), list);
|
|
@@ -26,7 +26,6 @@ let isFullWidthModeEnabled;
|
|
|
26
26
|
let wasFullWidthModeEnabled;
|
|
27
27
|
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI) => {
|
|
28
28
|
var _window;
|
|
29
|
-
|
|
30
29
|
isBreakoutEnabled = breakoutEnabled;
|
|
31
30
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
32
31
|
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
@@ -45,39 +44,33 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
45
44
|
if (!entry.target.id) {
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
elementContentRects[entry.target.id] = entry.contentRect;
|
|
50
48
|
});
|
|
51
49
|
}) : undefined;
|
|
52
50
|
const tableCellNodeview = {
|
|
53
51
|
tableCell: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer),
|
|
54
52
|
tableHeader: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer)
|
|
55
|
-
};
|
|
53
|
+
};
|
|
56
54
|
|
|
55
|
+
// Used to prevent invalid table cell spans being reported more than once per editor/document
|
|
57
56
|
const invalidTableIds = [];
|
|
58
57
|
let editorViewRef = null;
|
|
59
|
-
|
|
60
58
|
const getCurrentEditorState = () => {
|
|
61
59
|
const editorView = editorViewRef;
|
|
62
|
-
|
|
63
60
|
if (!editorView) {
|
|
64
61
|
return null;
|
|
65
62
|
}
|
|
66
|
-
|
|
67
63
|
return editorView.state;
|
|
68
64
|
};
|
|
69
|
-
|
|
70
65
|
return new SafePlugin({
|
|
71
66
|
state: state,
|
|
72
67
|
key: pluginKey,
|
|
73
68
|
appendTransaction: (transactions, oldState, newState) => {
|
|
74
69
|
const tr = transactions.find(tr => tr.getMeta('uiEvent') === 'cut');
|
|
75
|
-
|
|
76
70
|
function reportInvalidTableCellSpanAttrs(invalidNodeAttr) {
|
|
77
71
|
if (invalidTableIds.find(id => id === invalidNodeAttr.tableLocalId)) {
|
|
78
72
|
return;
|
|
79
73
|
}
|
|
80
|
-
|
|
81
74
|
invalidTableIds.push(invalidNodeAttr.tableLocalId);
|
|
82
75
|
dispatchAnalyticsEvent({
|
|
83
76
|
action: ACTION.INVALID_DOCUMENT_ENCOUNTERED,
|
|
@@ -91,13 +84,11 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
91
84
|
}
|
|
92
85
|
});
|
|
93
86
|
}
|
|
94
|
-
|
|
95
87
|
if (tr) {
|
|
96
88
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
97
89
|
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI);
|
|
98
90
|
return fixTables(updatedTr) || updatedTr;
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
if (transactions.find(tr => tr.docChanged)) {
|
|
102
93
|
return fixTables(newState.tr, reportInvalidTableCellSpanAttrs);
|
|
103
94
|
}
|
|
@@ -117,34 +108,26 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
117
108
|
const pluginState = getPluginState(state);
|
|
118
109
|
let tableRef;
|
|
119
110
|
let tableNode;
|
|
120
|
-
|
|
121
111
|
if (pluginState.editorHasFocus) {
|
|
122
112
|
const parent = findParentDomRefOfType(state.schema.nodes.table, domAtPos)(selection);
|
|
123
|
-
|
|
124
113
|
if (parent) {
|
|
125
114
|
tableRef = parent.querySelector('table') || undefined;
|
|
126
115
|
}
|
|
127
|
-
|
|
128
116
|
tableNode = findTable(state.selection);
|
|
129
117
|
}
|
|
130
|
-
|
|
131
118
|
if (pluginState.tableRef !== tableRef) {
|
|
132
119
|
setTableRef(tableRef)(state, dispatch);
|
|
133
120
|
}
|
|
134
|
-
|
|
135
121
|
if (pluginState.tableNode !== tableNode) {
|
|
136
122
|
updateResizeHandles(tableRef);
|
|
137
123
|
}
|
|
138
|
-
|
|
139
124
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
140
125
|
const {
|
|
141
126
|
$cursor
|
|
142
127
|
} = state.selection;
|
|
143
|
-
|
|
144
128
|
if ($cursor) {
|
|
145
129
|
// Only update bold when it's a cursor
|
|
146
130
|
const tableCellHeader = findParentNodeOfType(state.schema.nodes.tableHeader)(state.selection);
|
|
147
|
-
|
|
148
131
|
if (tableCellHeader) {
|
|
149
132
|
addBoldInEmptyHeaderCells(tableCellHeader)(state, dispatch);
|
|
150
133
|
}
|
|
@@ -161,70 +144,64 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
161
144
|
props: {
|
|
162
145
|
transformPasted(slice) {
|
|
163
146
|
const editorState = getCurrentEditorState();
|
|
164
|
-
|
|
165
147
|
if (!editorState) {
|
|
166
148
|
return slice;
|
|
167
149
|
}
|
|
168
|
-
|
|
169
150
|
const {
|
|
170
151
|
schema
|
|
171
|
-
} = editorState;
|
|
152
|
+
} = editorState;
|
|
153
|
+
|
|
154
|
+
// if we're pasting to outside a table or outside a table
|
|
172
155
|
// header, ensure that we apply any table headers to the first
|
|
173
156
|
// row of content we see, if required
|
|
174
|
-
|
|
175
157
|
if (!insideTable(editorState) && isHeaderRowRequired(editorState)) {
|
|
176
158
|
slice = transformSliceToAddTableHeaders(slice, schema);
|
|
177
159
|
}
|
|
160
|
+
slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
|
|
178
161
|
|
|
179
|
-
|
|
162
|
+
// We do this separately, so it also applies to drag/drop events
|
|
180
163
|
// This needs to go before `transformSliceToRemoveOpenExpand`
|
|
164
|
+
slice = transformSliceToRemoveOpenLayoutNodes(slice, schema);
|
|
181
165
|
|
|
182
|
-
|
|
166
|
+
// If a partial paste of expand, paste only the content
|
|
183
167
|
// This needs to go before `transformSliceToRemoveOpenTable`
|
|
184
|
-
|
|
185
168
|
slice = transformSliceToRemoveOpenExpand(slice, schema);
|
|
186
|
-
/** If a partial paste of table, paste only table's content */
|
|
187
169
|
|
|
170
|
+
/** If a partial paste of table, paste only table's content */
|
|
188
171
|
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
189
|
-
/** If a partial paste of bodied extension, paste only text */
|
|
190
172
|
|
|
173
|
+
/** If a partial paste of bodied extension, paste only text */
|
|
191
174
|
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
192
175
|
slice = transformSliceToCorrectEmptyTableCells(slice, schema);
|
|
193
|
-
|
|
194
176
|
if (!pluginConfig.allowColumnResizing) {
|
|
195
177
|
slice = transformSliceToRemoveColumnsWidths(slice, schema);
|
|
196
|
-
}
|
|
197
|
-
// from the paste slice
|
|
198
|
-
|
|
178
|
+
}
|
|
199
179
|
|
|
180
|
+
// If we don't allow background on cells, we need to remove it
|
|
181
|
+
// from the paste slice
|
|
200
182
|
if (!pluginConfig.allowBackgroundColor) {
|
|
201
183
|
slice = transformSliceRemoveCellBackgroundColor(slice, schema);
|
|
202
184
|
}
|
|
203
|
-
|
|
204
185
|
return slice;
|
|
205
186
|
},
|
|
206
|
-
|
|
207
187
|
handleClick: ({
|
|
208
188
|
state,
|
|
209
189
|
dispatch
|
|
210
190
|
}, _pos, event) => {
|
|
211
191
|
const decorationSet = decorationsPluginKey.getState(state);
|
|
212
|
-
|
|
213
192
|
if (findControlsHoverDecoration(decorationSet).length) {
|
|
214
193
|
clearHoverSelection()(state, dispatch);
|
|
215
|
-
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ED-6069: workaround for Chrome given a regression introduced in prosemirror-view@1.6.8
|
|
216
197
|
// Returning true prevents that updateSelection() is getting called in the commit below:
|
|
217
198
|
// @see https://github.com/ProseMirror/prosemirror-view/commit/33fe4a8b01584f6b4103c279033dcd33e8047b95
|
|
218
|
-
|
|
219
|
-
|
|
220
199
|
if (browser.chrome && event.target) {
|
|
221
200
|
const targetClassList = event.target.classList;
|
|
222
|
-
|
|
223
201
|
if (targetClassList.contains(ClassName.CONTROLS_BUTTON) || targetClassList.contains(ClassName.CONTEXTUAL_MENU_BUTTON)) {
|
|
224
202
|
return true;
|
|
225
203
|
}
|
|
226
204
|
}
|
|
227
|
-
|
|
228
205
|
return false;
|
|
229
206
|
},
|
|
230
207
|
handleScrollToSelection: view => {
|
|
@@ -242,15 +219,14 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
242
219
|
dispatch
|
|
243
220
|
}, from, to, text) => {
|
|
244
221
|
const tr = replaceSelectedTable(state, text, INPUT_METHOD.KEYBOARD, editorAnalyticsAPI);
|
|
245
|
-
|
|
246
222
|
if (tr.selectionSet) {
|
|
247
223
|
dispatch(tr);
|
|
248
224
|
return true;
|
|
249
225
|
}
|
|
250
|
-
|
|
251
226
|
return false;
|
|
252
227
|
},
|
|
253
|
-
nodeViews: {
|
|
228
|
+
nodeViews: {
|
|
229
|
+
//temporary flag to test tableCell optimisation
|
|
254
230
|
...tableCellNodeview,
|
|
255
231
|
table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
256
232
|
isBreakoutEnabled,
|
|
@@ -10,7 +10,6 @@ export const {
|
|
|
10
10
|
mapping: (tr, pluginState) => {
|
|
11
11
|
if (tr.docChanged) {
|
|
12
12
|
let updatedTargetCell = {};
|
|
13
|
-
|
|
14
13
|
if (pluginState.targetCellPosition) {
|
|
15
14
|
const {
|
|
16
15
|
pos,
|
|
@@ -20,9 +19,7 @@ export const {
|
|
|
20
19
|
targetCellPosition: deleted ? undefined : pos
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
let updatedTablePos = {};
|
|
25
|
-
|
|
26
23
|
if (pluginState.tablePos) {
|
|
27
24
|
const {
|
|
28
25
|
pos,
|
|
@@ -32,13 +29,12 @@ export const {
|
|
|
32
29
|
tablePos: deleted ? undefined : pos
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
return {
|
|
33
|
+
...pluginState,
|
|
37
34
|
...updatedTargetCell,
|
|
38
35
|
...updatedTablePos
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
return pluginState;
|
|
43
39
|
},
|
|
44
40
|
onDocChanged: handleDocOrSelectionChanged,
|