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