@atlaskit/editor-plugin-table 1.1.0 → 1.1.2
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 +12 -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 +82 -188
- 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 +12 -42
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -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 +0 -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 +15 -36
- 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 +15 -71
- 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 +12 -45
- 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 +6 -19
- 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 +27 -100
- 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 +7 -15
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -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 +0 -4
- 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 +10 -18
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
- 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 +16 -28
- 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 +6 -5
- 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 +82 -181
- 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 +12 -24
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -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 +0 -4
- 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 +15 -23
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
- 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 +12 -32
- 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 +6 -7
- 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/package.json +2 -2
- package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
|
@@ -8,25 +8,26 @@ import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '
|
|
|
8
8
|
import { updateStickyState } from '../commands';
|
|
9
9
|
import { getTop, getTree } from './dom';
|
|
10
10
|
import debounce from 'lodash/debounce';
|
|
11
|
-
import throttle from 'lodash/throttle';
|
|
11
|
+
import throttle from 'lodash/throttle';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// limit scroll event calls
|
|
14
|
+
const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
15
15
|
|
|
16
|
+
// timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
|
|
17
|
+
// if too short it would trigger too many dom updates.
|
|
16
18
|
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
17
|
-
|
|
18
19
|
const anyChildCellMergedAcrossRow = node => mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* Compare two table row nodes and return true if the two table rows have a
|
|
21
23
|
* different number of table cells or if table cell row spans are different
|
|
22
24
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
25
|
const rowHasDifferentMergedCells = (prevNode, incomingNode) => {
|
|
26
26
|
const incomingNodeChildrenRowSpan = mapChildren(prevNode, child => child.attrs.rowspan || 0);
|
|
27
27
|
const currentNodeChildrenRowSpan = mapChildren(incomingNode, child => child.attrs.rowspan || 0);
|
|
28
28
|
return incomingNodeChildrenRowSpan.length !== currentNodeChildrenRowSpan.length || currentNodeChildrenRowSpan.some((child, index) => child !== incomingNodeChildrenRowSpan[index]);
|
|
29
29
|
};
|
|
30
|
+
|
|
30
31
|
/**
|
|
31
32
|
* Check if a given node is a header row with this definition:
|
|
32
33
|
* - all children are tableHeader cells
|
|
@@ -35,8 +36,6 @@ const rowHasDifferentMergedCells = (prevNode, incomingNode) => {
|
|
|
35
36
|
* @param node ProseMirror node
|
|
36
37
|
* @return boolean if it meets definition
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
39
|
export const supportedHeaderRow = node => {
|
|
41
40
|
const allHeaders = mapChildren(node, child => child.type.name === 'tableHeader').every(Boolean);
|
|
42
41
|
const someMerged = anyChildCellMergedAcrossRow(node);
|
|
@@ -44,103 +43,89 @@ export const supportedHeaderRow = node => {
|
|
|
44
43
|
};
|
|
45
44
|
export class TableRowNodeView {
|
|
46
45
|
// this is the sticky header table row
|
|
46
|
+
|
|
47
47
|
get tree() {
|
|
48
48
|
return getTree(this.dom);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
50
|
constructor(node, view, getPos, eventDispatcher, getEditorFeatureFlags) {
|
|
52
51
|
_defineProperty(this, "colControlsOffset", 0);
|
|
53
|
-
|
|
54
52
|
_defineProperty(this, "focused", false);
|
|
55
|
-
|
|
56
53
|
_defineProperty(this, "topPosEditorElement", 0);
|
|
57
|
-
|
|
58
54
|
_defineProperty(this, "stickyHeadersOptimization", false);
|
|
59
|
-
|
|
60
55
|
_defineProperty(this, "sentinels", {});
|
|
61
|
-
|
|
62
56
|
_defineProperty(this, "listening", false);
|
|
63
|
-
|
|
64
57
|
_defineProperty(this, "headerRowMouseScrollEnd", debounce(() => {
|
|
65
58
|
this.dom.classList.remove('no-pointer-events');
|
|
66
59
|
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
|
|
67
|
-
|
|
68
60
|
_defineProperty(this, "headerRowMouseScroll", throttle(() => {
|
|
69
61
|
if (this.isSticky) {
|
|
70
62
|
this.dom.classList.add('no-pointer-events');
|
|
71
63
|
this.headerRowMouseScrollEnd();
|
|
72
64
|
}
|
|
73
65
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
74
|
-
|
|
75
66
|
_defineProperty(this, "onScroll", () => {
|
|
76
67
|
if (!this.tree) {
|
|
77
68
|
return;
|
|
78
69
|
}
|
|
70
|
+
this.latestDomTop = getTop(this.tree.wrapper);
|
|
79
71
|
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
// kick off rAF loop again if it hasn't already happened
|
|
82
73
|
if (!this.nextFrame) {
|
|
83
74
|
this.loop();
|
|
84
75
|
}
|
|
85
76
|
});
|
|
86
|
-
|
|
87
77
|
_defineProperty(this, "loop", () => {
|
|
88
78
|
this.nextFrame = window.requestAnimationFrame(() => {
|
|
89
79
|
if (this.previousDomTop === this.latestDomTop && this.previousPadding === this.padding) {
|
|
90
80
|
this.nextFrame = undefined;
|
|
91
81
|
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
82
|
+
}
|
|
94
83
|
|
|
84
|
+
// can't store these since React might re-render at any time
|
|
95
85
|
const tree = this.tree;
|
|
96
|
-
|
|
97
86
|
if (!tree) {
|
|
98
87
|
this.nextFrame = undefined;
|
|
99
88
|
return;
|
|
100
89
|
}
|
|
90
|
+
this.paint(tree);
|
|
101
91
|
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
// run again on next frame
|
|
104
93
|
this.previousPadding = this.padding;
|
|
105
94
|
this.previousDomTop = this.latestDomTop;
|
|
106
95
|
this.loop();
|
|
107
96
|
});
|
|
108
97
|
});
|
|
109
|
-
|
|
110
98
|
_defineProperty(this, "paint", tree => {
|
|
111
99
|
const {
|
|
112
100
|
table,
|
|
113
101
|
wrapper
|
|
114
|
-
} = tree;
|
|
115
|
-
// The jumpiness happen under that time and this is to avoid it.
|
|
102
|
+
} = tree;
|
|
116
103
|
|
|
104
|
+
// If the previous refresh is less than 10ms then don't do anything.
|
|
105
|
+
// The jumpiness happen under that time and this is to avoid it.
|
|
117
106
|
const timelapse = Math.abs(performance.now() - this.lastTimePainted);
|
|
118
|
-
|
|
119
107
|
if (timelapse < 10) {
|
|
120
108
|
return;
|
|
121
109
|
}
|
|
122
|
-
|
|
123
110
|
if (this.shouldHeaderStick(tree)) {
|
|
124
111
|
this.makeHeaderRowSticky(tree);
|
|
125
112
|
} else {
|
|
126
113
|
this.makeRowHeaderNotSticky(table);
|
|
127
|
-
}
|
|
128
|
-
|
|
114
|
+
}
|
|
129
115
|
|
|
116
|
+
// ensure scroll positions are locked
|
|
130
117
|
this.dom.scrollLeft = wrapper.scrollLeft;
|
|
131
118
|
this.lastTimePainted = performance.now();
|
|
132
119
|
});
|
|
133
|
-
|
|
134
120
|
_defineProperty(this, "onTablePluginState", state => {
|
|
135
121
|
const tableRef = state.tableRef;
|
|
136
122
|
let focusChanged = false;
|
|
137
123
|
const tree = this.tree;
|
|
138
|
-
|
|
139
124
|
if (!tree) {
|
|
140
125
|
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
126
|
+
}
|
|
143
127
|
|
|
128
|
+
// when header rows are toggled off - mark sentinels as unobserved
|
|
144
129
|
if (!state.isHeaderRowEnabled) {
|
|
145
130
|
[this.sentinels.top, this.sentinels.bottom].forEach(el => {
|
|
146
131
|
if (el) {
|
|
@@ -148,17 +133,15 @@ export class TableRowNodeView {
|
|
|
148
133
|
}
|
|
149
134
|
});
|
|
150
135
|
}
|
|
136
|
+
const isCurrentTableSelected = tableRef === tree.table;
|
|
151
137
|
|
|
152
|
-
|
|
153
|
-
|
|
138
|
+
// If current table selected and header row is toggled off, turn off sticky header
|
|
154
139
|
if (isCurrentTableSelected && !state.isHeaderRowEnabled && this.tree) {
|
|
155
140
|
this.makeRowHeaderNotSticky(this.tree.table);
|
|
156
141
|
}
|
|
157
|
-
|
|
158
142
|
if (isCurrentTableSelected !== this.focused) {
|
|
159
143
|
focusChanged = true;
|
|
160
144
|
}
|
|
161
|
-
|
|
162
145
|
this.focused = isCurrentTableSelected;
|
|
163
146
|
const {
|
|
164
147
|
wrapper
|
|
@@ -166,10 +149,8 @@ export class TableRowNodeView {
|
|
|
166
149
|
const tableContainer = wrapper.parentElement;
|
|
167
150
|
const tableContentWrapper = tableContainer.parentElement;
|
|
168
151
|
const layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
169
|
-
|
|
170
152
|
if (isCurrentTableSelected) {
|
|
171
153
|
this.colControlsOffset = tableControlsSpacing;
|
|
172
|
-
|
|
173
154
|
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
174
155
|
// move table a little out of the way
|
|
175
156
|
// to provide spacing for table controls
|
|
@@ -177,34 +158,28 @@ export class TableRowNodeView {
|
|
|
177
158
|
}
|
|
178
159
|
} else {
|
|
179
160
|
this.colControlsOffset = 0;
|
|
180
|
-
|
|
181
161
|
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
182
162
|
tableContentWrapper.style.removeProperty('padding-left');
|
|
183
163
|
}
|
|
184
|
-
}
|
|
185
|
-
|
|
164
|
+
}
|
|
186
165
|
|
|
166
|
+
// run after table style changes have been committed
|
|
187
167
|
setTimeout(() => {
|
|
188
168
|
// if focus changed while header is sticky - still repaint the positions will shift
|
|
189
169
|
if (!this.stickyHeadersOptimization || focusChanged && this.isSticky) {
|
|
190
170
|
this.paint(tree);
|
|
191
171
|
}
|
|
192
|
-
|
|
193
172
|
syncStickyRowToTable(tree.table);
|
|
194
173
|
}, 0);
|
|
195
174
|
});
|
|
196
|
-
|
|
197
175
|
_defineProperty(this, "onWidthPluginState", () => {
|
|
198
176
|
// table width might have changed, sync that back to sticky row
|
|
199
177
|
const tree = this.tree;
|
|
200
|
-
|
|
201
178
|
if (!tree) {
|
|
202
179
|
return;
|
|
203
180
|
}
|
|
204
|
-
|
|
205
181
|
syncStickyRowToTable(tree.table);
|
|
206
182
|
});
|
|
207
|
-
|
|
208
183
|
_defineProperty(this, "shouldHeaderStick", tree => {
|
|
209
184
|
const {
|
|
210
185
|
wrapper
|
|
@@ -214,62 +189,55 @@ export class TableRowNodeView {
|
|
|
214
189
|
const stickyHeaderRect = this.contentDOM.getBoundingClientRect();
|
|
215
190
|
const firstHeaderRow = !this.dom.previousElementSibling;
|
|
216
191
|
const subsequentRows = !!this.dom.nextElementSibling;
|
|
217
|
-
const isHeaderValid = firstHeaderRow && subsequentRows;
|
|
192
|
+
const isHeaderValid = firstHeaderRow && subsequentRows;
|
|
193
|
+
|
|
194
|
+
// if the table wrapper is less than the editor top pos then make it sticky
|
|
218
195
|
// Make header sticky if table wrapper top is outside viewport
|
|
219
196
|
// but bottom is still in the viewport.
|
|
220
|
-
|
|
221
197
|
if (tableWrapperRect.top < editorAreaRect.top && tableWrapperRect.bottom > editorAreaRect.top && isHeaderValid) {
|
|
222
198
|
return true;
|
|
223
|
-
}
|
|
224
|
-
|
|
199
|
+
}
|
|
225
200
|
|
|
201
|
+
// if the sticky header is below the editor area make it non-sticky
|
|
226
202
|
if (stickyHeaderRect.top > editorAreaRect.top) {
|
|
227
203
|
return false;
|
|
228
|
-
}
|
|
229
|
-
|
|
204
|
+
}
|
|
230
205
|
|
|
206
|
+
// otherwise make it non-sticky
|
|
231
207
|
return false;
|
|
232
208
|
});
|
|
233
|
-
|
|
234
209
|
_defineProperty(this, "makeHeaderRowSticky", tree => {
|
|
235
210
|
var _tbody$firstChild;
|
|
236
|
-
|
|
237
211
|
// If header row height is more than 50% of viewport height don't do this
|
|
238
212
|
if (this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
|
|
239
213
|
return;
|
|
240
214
|
}
|
|
241
|
-
|
|
242
215
|
const {
|
|
243
216
|
table
|
|
244
|
-
} = tree;
|
|
217
|
+
} = tree;
|
|
245
218
|
|
|
219
|
+
// ED-16035 Make sure sticky header is only applied to first row
|
|
246
220
|
const tbody = this.dom.parentElement;
|
|
247
221
|
const isFirstHeader = tbody === null || tbody === void 0 ? void 0 : (_tbody$firstChild = tbody.firstChild) === null || _tbody$firstChild === void 0 ? void 0 : _tbody$firstChild.isEqualNode(this.dom);
|
|
248
|
-
|
|
249
222
|
if (!isFirstHeader) {
|
|
250
223
|
return;
|
|
251
224
|
}
|
|
252
|
-
|
|
253
225
|
const currentTableTop = this.getCurrentTableTop(tree);
|
|
254
226
|
const domTop = currentTableTop > 0 ? this.topPosEditorElement : this.topPosEditorElement + currentTableTop;
|
|
255
|
-
|
|
256
227
|
if (!this.isSticky) {
|
|
257
228
|
syncStickyRowToTable(table);
|
|
258
229
|
this.dom.classList.add('sticky');
|
|
259
230
|
table.classList.add(ClassName.TABLE_STICKY);
|
|
260
231
|
this.isSticky = true;
|
|
261
232
|
}
|
|
262
|
-
|
|
263
233
|
this.dom.style.top = `${domTop}px`;
|
|
264
234
|
updateTableMargin(table);
|
|
265
235
|
this.emitOn(domTop, this.colControlsOffset);
|
|
266
236
|
});
|
|
267
|
-
|
|
268
237
|
_defineProperty(this, "makeRowHeaderNotSticky", (table, isEditorDestroyed = false) => {
|
|
269
238
|
if (!this.isSticky || !table || !this.dom) {
|
|
270
239
|
return;
|
|
271
240
|
}
|
|
272
|
-
|
|
273
241
|
this.dom.style.removeProperty('width');
|
|
274
242
|
this.dom.classList.remove('sticky');
|
|
275
243
|
table.classList.remove(ClassName.TABLE_STICKY);
|
|
@@ -278,27 +246,19 @@ export class TableRowNodeView {
|
|
|
278
246
|
table.style.removeProperty('margin-top');
|
|
279
247
|
this.emitOff(isEditorDestroyed);
|
|
280
248
|
});
|
|
281
|
-
|
|
282
249
|
_defineProperty(this, "getWrapperoffset", (inverse = false) => {
|
|
283
250
|
const focusValue = inverse ? !this.focused : this.focused;
|
|
284
251
|
return focusValue ? 0 : tableControlsSpacing;
|
|
285
252
|
});
|
|
286
|
-
|
|
287
253
|
_defineProperty(this, "getWrapperRefTop", wrapper => Math.round(getTop(wrapper)) + this.getWrapperoffset());
|
|
288
|
-
|
|
289
254
|
_defineProperty(this, "getScrolledTableTop", wrapper => this.getWrapperRefTop(wrapper) - this.topPosEditorElement);
|
|
290
|
-
|
|
291
255
|
_defineProperty(this, "getCurrentTableTop", tree => this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight);
|
|
292
|
-
|
|
293
256
|
_defineProperty(this, "padding", 0);
|
|
294
|
-
|
|
295
257
|
_defineProperty(this, "top", 0);
|
|
296
|
-
|
|
297
258
|
_defineProperty(this, "emitOn", (top, padding) => {
|
|
298
259
|
if (top === this.top && padding === this.padding) {
|
|
299
260
|
return;
|
|
300
261
|
}
|
|
301
|
-
|
|
302
262
|
this.top = top;
|
|
303
263
|
this.padding = padding;
|
|
304
264
|
updateStickyState({
|
|
@@ -308,15 +268,12 @@ export class TableRowNodeView {
|
|
|
308
268
|
padding
|
|
309
269
|
})(this.view.state, this.view.dispatch, this.view);
|
|
310
270
|
});
|
|
311
|
-
|
|
312
271
|
_defineProperty(this, "emitOff", isEditorDestroyed => {
|
|
313
272
|
if (this.top === 0 && this.padding === 0) {
|
|
314
273
|
return;
|
|
315
274
|
}
|
|
316
|
-
|
|
317
275
|
this.top = 0;
|
|
318
276
|
this.padding = 0;
|
|
319
|
-
|
|
320
277
|
if (!isEditorDestroyed) {
|
|
321
278
|
updateStickyState({
|
|
322
279
|
pos: this.getPos(),
|
|
@@ -326,7 +283,6 @@ export class TableRowNodeView {
|
|
|
326
283
|
})(this.view.state, this.view.dispatch, this.view);
|
|
327
284
|
}
|
|
328
285
|
});
|
|
329
|
-
|
|
330
286
|
this.view = view;
|
|
331
287
|
this.node = node;
|
|
332
288
|
this.getPos = getPos;
|
|
@@ -341,80 +297,66 @@ export class TableRowNodeView {
|
|
|
341
297
|
this.lastTimePainted = 0;
|
|
342
298
|
this.isHeaderRow = supportedHeaderRow(node);
|
|
343
299
|
this.isSticky = false;
|
|
344
|
-
|
|
345
300
|
if (this.isHeaderRow) {
|
|
346
301
|
this.dom.setAttribute('data-header-row', 'true');
|
|
347
302
|
this.subscribe();
|
|
348
303
|
}
|
|
349
304
|
}
|
|
350
|
-
/* external events */
|
|
351
305
|
|
|
306
|
+
/* external events */
|
|
352
307
|
|
|
353
308
|
subscribe() {
|
|
354
309
|
this.editorScrollableElement = findOverflowScrollParent(this.view.dom) || window;
|
|
355
|
-
|
|
356
310
|
if (this.editorScrollableElement) {
|
|
357
311
|
if (this.stickyHeadersOptimization) {
|
|
358
312
|
this.initObservers();
|
|
359
313
|
} else {
|
|
360
314
|
this.editorScrollableElement.addEventListener('scroll', this.onScroll);
|
|
361
315
|
}
|
|
362
|
-
|
|
363
316
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
364
317
|
}
|
|
365
|
-
|
|
366
318
|
this.eventDispatcher.on('widthPlugin', this.onWidthPluginState);
|
|
367
319
|
this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
|
|
368
320
|
this.listening = true;
|
|
369
321
|
this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this));
|
|
370
322
|
this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this));
|
|
371
323
|
}
|
|
372
|
-
|
|
373
324
|
unsubscribe() {
|
|
374
325
|
if (!this.listening) {
|
|
375
326
|
return;
|
|
376
327
|
}
|
|
377
|
-
|
|
378
328
|
if (this.intersectionObserver) {
|
|
379
329
|
this.intersectionObserver.disconnect();
|
|
380
330
|
}
|
|
381
|
-
|
|
382
331
|
if (this.resizeObserver) {
|
|
383
332
|
this.resizeObserver.disconnect();
|
|
384
333
|
}
|
|
385
|
-
|
|
386
334
|
if (this.editorScrollableElement && !this.stickyHeadersOptimization) {
|
|
387
335
|
this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
|
|
388
336
|
}
|
|
389
|
-
|
|
390
337
|
this.eventDispatcher.off('widthPlugin', this.onWidthPluginState);
|
|
391
338
|
this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
|
|
392
339
|
this.listening = false;
|
|
393
340
|
this.dom.removeEventListener('wheel', this.headerRowMouseScroll);
|
|
394
341
|
this.dom.removeEventListener('touchmove', this.headerRowMouseScroll);
|
|
395
|
-
}
|
|
396
|
-
|
|
342
|
+
}
|
|
397
343
|
|
|
344
|
+
// initialize intersection observer to track if table is within scroll area
|
|
398
345
|
initObservers() {
|
|
399
346
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
400
347
|
return;
|
|
401
348
|
}
|
|
402
|
-
|
|
403
349
|
this.dom.dataset.isObserved = 'true';
|
|
404
350
|
this.createIntersectionObserver();
|
|
405
351
|
this.createResizeObserver();
|
|
406
|
-
|
|
407
352
|
if (!this.intersectionObserver || !this.resizeObserver) {
|
|
408
353
|
return;
|
|
409
354
|
}
|
|
410
|
-
|
|
411
355
|
this.resizeObserver.observe(this.dom);
|
|
412
356
|
window.requestAnimationFrame(() => {
|
|
413
357
|
var _this$tree;
|
|
414
|
-
|
|
415
358
|
// we expect tree to be defined after animation frame
|
|
416
359
|
const tableContainer = (_this$tree = this.tree) === null || _this$tree === void 0 ? void 0 : _this$tree.wrapper.closest(`.${TableCssClassName.NODEVIEW_WRAPPER}`);
|
|
417
|
-
|
|
418
360
|
if (tableContainer) {
|
|
419
361
|
this.sentinels.top = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
|
|
420
362
|
this.sentinels.bottom = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
|
|
@@ -427,23 +369,22 @@ export class TableRowNodeView {
|
|
|
427
369
|
});
|
|
428
370
|
}
|
|
429
371
|
});
|
|
430
|
-
}
|
|
431
|
-
// to allocate for new header height
|
|
432
|
-
|
|
372
|
+
}
|
|
433
373
|
|
|
374
|
+
// updating bottom sentinel position if sticky header height changes
|
|
375
|
+
// to allocate for new header height
|
|
434
376
|
createResizeObserver() {
|
|
435
377
|
this.resizeObserver = new ResizeObserver(entries => {
|
|
436
378
|
if (!this.tree) {
|
|
437
379
|
return;
|
|
438
380
|
}
|
|
439
|
-
|
|
440
381
|
const {
|
|
441
382
|
table
|
|
442
383
|
} = this.tree;
|
|
443
384
|
entries.forEach(entry => {
|
|
444
385
|
const newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
|
|
445
|
-
|
|
446
|
-
|
|
386
|
+
if (this.sentinels.bottom &&
|
|
387
|
+
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
447
388
|
// So we adding this check to allow a 1px difference.
|
|
448
389
|
Math.abs(newHeight - (this.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
|
|
449
390
|
this.stickyRowHeight = newHeight;
|
|
@@ -453,42 +394,34 @@ export class TableRowNodeView {
|
|
|
453
394
|
});
|
|
454
395
|
});
|
|
455
396
|
}
|
|
456
|
-
|
|
457
397
|
createIntersectionObserver() {
|
|
458
398
|
this.intersectionObserver = new IntersectionObserver((entries, _) => {
|
|
459
399
|
if (!this.tree) {
|
|
460
400
|
return;
|
|
461
401
|
}
|
|
462
|
-
|
|
463
402
|
const {
|
|
464
403
|
table
|
|
465
404
|
} = this.tree;
|
|
466
405
|
entries.forEach(entry => {
|
|
467
406
|
var _entry$rootBounds;
|
|
407
|
+
const target = entry.target;
|
|
468
408
|
|
|
469
|
-
|
|
470
|
-
|
|
409
|
+
// if the rootBounds has 0 height, e.g. confluence preview mode, we do nothing.
|
|
471
410
|
if (((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.height) === 0) {
|
|
472
411
|
return;
|
|
473
412
|
}
|
|
474
|
-
|
|
475
413
|
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP)) {
|
|
476
414
|
var _entry$rootBounds2;
|
|
477
|
-
|
|
478
415
|
const sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
479
|
-
|
|
480
416
|
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
481
417
|
this.tree && this.makeHeaderRowSticky(this.tree);
|
|
482
418
|
} else {
|
|
483
419
|
table && this.makeRowHeaderNotSticky(table);
|
|
484
420
|
}
|
|
485
421
|
}
|
|
486
|
-
|
|
487
422
|
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
488
423
|
var _entry$rootBounds3;
|
|
489
|
-
|
|
490
424
|
const sentinelIsAboveScrollArea = entry.boundingClientRect.top - this.dom.offsetHeight < (((_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top) || 0);
|
|
491
|
-
|
|
492
425
|
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
493
426
|
this.makeRowHeaderNotSticky(table);
|
|
494
427
|
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
@@ -500,52 +433,48 @@ export class TableRowNodeView {
|
|
|
500
433
|
root: this.editorScrollableElement
|
|
501
434
|
});
|
|
502
435
|
}
|
|
503
|
-
/* paint/update loop */
|
|
504
436
|
|
|
437
|
+
/* paint/update loop */
|
|
505
438
|
|
|
506
439
|
/* nodeview lifecycle */
|
|
507
440
|
update(node, ..._args) {
|
|
508
441
|
// do nothing if nodes were identical
|
|
509
442
|
if (node === this.node) {
|
|
510
443
|
return true;
|
|
511
|
-
}
|
|
512
|
-
// changing away from one
|
|
513
|
-
|
|
444
|
+
}
|
|
514
445
|
|
|
446
|
+
// see if we're changing into a header row or
|
|
447
|
+
// changing away from one
|
|
515
448
|
const newNodeIsHeaderRow = supportedHeaderRow(node);
|
|
516
|
-
|
|
517
449
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
518
450
|
return false; // re-create nodeview
|
|
519
451
|
}
|
|
520
452
|
|
|
521
453
|
if (rowHasDifferentMergedCells(this.node, node)) {
|
|
522
454
|
return false;
|
|
523
|
-
}
|
|
524
|
-
|
|
455
|
+
}
|
|
525
456
|
|
|
526
|
-
|
|
457
|
+
// node is different but no need to re-create nodeview
|
|
458
|
+
this.node = node;
|
|
527
459
|
|
|
460
|
+
// don't do anything if we're just a regular tr
|
|
528
461
|
if (!this.isHeaderRow) {
|
|
529
462
|
return true;
|
|
530
|
-
}
|
|
531
|
-
|
|
463
|
+
}
|
|
532
464
|
|
|
465
|
+
// something changed, sync widths
|
|
533
466
|
const tbody = this.dom.parentElement;
|
|
534
467
|
const table = tbody && tbody.parentElement;
|
|
535
468
|
syncStickyRowToTable(table);
|
|
536
469
|
return true;
|
|
537
470
|
}
|
|
538
|
-
|
|
539
471
|
destroy() {
|
|
540
472
|
this.unsubscribe();
|
|
541
|
-
|
|
542
473
|
if (this.tree) {
|
|
543
474
|
this.makeRowHeaderNotSticky(this.tree.table, true);
|
|
544
475
|
}
|
|
545
|
-
|
|
546
476
|
this.emitOff(true);
|
|
547
477
|
}
|
|
548
|
-
|
|
549
478
|
ignoreMutation(mutationRecord) {
|
|
550
479
|
/* tableRows are not directly editable by the user
|
|
551
480
|
* so it should be safe to ignore mutations that we cause
|
|
@@ -563,16 +492,12 @@ export class TableRowNodeView {
|
|
|
563
492
|
* from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
|
|
564
493
|
* selection and insertion.
|
|
565
494
|
*/
|
|
566
|
-
|
|
567
495
|
const isNodeInsertion = mutationRecord.type === 'childList' && mutationRecord.target.nodeName === 'TR' && mutationRecord.addedNodes.length;
|
|
568
|
-
|
|
569
496
|
if (isTableSelection || isNodeInsertion) {
|
|
570
497
|
return false;
|
|
571
498
|
}
|
|
572
|
-
|
|
573
499
|
return true;
|
|
574
500
|
}
|
|
575
|
-
/* receive external events */
|
|
576
|
-
|
|
577
501
|
|
|
502
|
+
/* receive external events */
|
|
578
503
|
}
|
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import { pluginKey } from './plugin-key';
|
|
3
|
-
|
|
4
3
|
const reducer = (pluginState, action) => {
|
|
5
4
|
if (action.name === 'UPDATE') {
|
|
6
5
|
let updated = false;
|
|
7
6
|
const updatedState = pluginState.map(oldTableState => {
|
|
8
7
|
const replace = oldTableState.pos === action.state.pos;
|
|
9
|
-
|
|
10
8
|
if (replace) {
|
|
11
9
|
updated = true;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
return replace ? action.state : oldTableState;
|
|
15
12
|
});
|
|
16
|
-
|
|
17
13
|
if (!updated) {
|
|
18
14
|
// new, add it
|
|
19
15
|
updatedState.push(action.state);
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
return updatedState;
|
|
23
18
|
} else if (action.name === 'REMOVE') {
|
|
24
19
|
return pluginState.filter(rowState => rowState.pos !== action.pos);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
return pluginState;
|
|
28
22
|
};
|
|
29
|
-
|
|
30
23
|
const {
|
|
31
24
|
createPluginState,
|
|
32
25
|
createCommand
|
|
@@ -35,12 +28,12 @@ const {
|
|
|
35
28
|
if (tr.docChanged) {
|
|
36
29
|
return pluginState.map(rowInfo => {
|
|
37
30
|
const remapped = tr.mapping.mapResult(rowInfo.pos);
|
|
38
|
-
return remapped ? {
|
|
31
|
+
return remapped ? {
|
|
32
|
+
...rowInfo,
|
|
39
33
|
pos: remapped.pos
|
|
40
34
|
} : undefined;
|
|
41
35
|
}).filter(f => f !== undefined);
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
return pluginState;
|
|
45
38
|
}
|
|
46
39
|
});
|
|
@@ -3,12 +3,9 @@ export const findStickyHeaderForTable = (state, tablePos) => {
|
|
|
3
3
|
if (!state || tablePos === undefined) {
|
|
4
4
|
return undefined;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
const rowInfo = state.find(rowInfo => rowInfo.pos === tablePos + 1);
|
|
8
|
-
|
|
9
7
|
if (!rowInfo) {
|
|
10
8
|
return undefined;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
return rowInfo.sticky ? rowInfo : undefined;
|
|
14
11
|
};
|