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