@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
|
@@ -3,14 +3,11 @@ export var findStickyHeaderForTable = function findStickyHeaderForTable(state, t
|
|
|
3
3
|
if (!state || tablePos === undefined) {
|
|
4
4
|
return undefined;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
var rowInfo = state.find(function (rowInfo) {
|
|
8
7
|
return rowInfo.pos === tablePos + 1;
|
|
9
8
|
});
|
|
10
|
-
|
|
11
9
|
if (!rowInfo) {
|
|
12
10
|
return undefined;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
return rowInfo.sticky ? rowInfo : undefined;
|
|
16
13
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
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
|
/**
|
|
8
5
|
* A plugin for ensuring tables always have unique local IDs, and to
|
|
9
6
|
* preserve/not regenerate them when they are being cut and paste around the
|
|
@@ -16,31 +13,29 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
13
|
* TODO: https://product-fabric.atlassian.net/browse/ED-12714
|
|
17
14
|
*
|
|
18
15
|
*/
|
|
16
|
+
|
|
19
17
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
20
18
|
import { PluginKey } from 'prosemirror-state';
|
|
21
19
|
import rafSchedule from 'raf-schd';
|
|
22
20
|
import { uuid } from '@atlaskit/adf-schema';
|
|
23
21
|
import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
|
|
24
22
|
var pluginKey = new PluginKey('tableLocalIdPlugin');
|
|
25
|
-
|
|
26
23
|
var getPluginState = function getPluginState(state) {
|
|
27
24
|
return state && pluginKey.getState(state);
|
|
28
25
|
};
|
|
26
|
+
|
|
29
27
|
/**
|
|
30
28
|
* Traverses a transaction's steps to see if we're inserting any tables
|
|
31
29
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
30
|
var checkIsAddingTable = function checkIsAddingTable(transaction, nodeType) {
|
|
35
31
|
return transaction.steps.some(function (step) {
|
|
36
32
|
return stepAddsOneOf(step, new Set([nodeType]));
|
|
37
33
|
});
|
|
38
34
|
};
|
|
35
|
+
|
|
39
36
|
/**
|
|
40
37
|
* Ensures uniqueness of `localId`s on tables being created or edited
|
|
41
38
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
39
|
var createPlugin = function createPlugin(dispatch) {
|
|
45
40
|
return new SafePlugin({
|
|
46
41
|
key: pluginKey,
|
|
@@ -52,21 +47,17 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
52
47
|
},
|
|
53
48
|
apply: function apply(tr, pluginState) {
|
|
54
49
|
var meta = tr.getMeta(pluginKey);
|
|
55
|
-
|
|
56
50
|
if (meta) {
|
|
57
51
|
var keys = Object.keys(meta);
|
|
58
52
|
var changed = keys.some(function (key) {
|
|
59
53
|
return pluginState[key] !== meta[key];
|
|
60
54
|
});
|
|
61
|
-
|
|
62
55
|
if (changed) {
|
|
63
56
|
var newState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
64
|
-
|
|
65
57
|
dispatch(pluginKey, newState);
|
|
66
58
|
return newState;
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
|
-
|
|
70
61
|
return pluginState;
|
|
71
62
|
}
|
|
72
63
|
},
|
|
@@ -92,17 +83,13 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
92
83
|
update: function update(editorView) {
|
|
93
84
|
var state = editorView.state;
|
|
94
85
|
var pluginState = getPluginState(state);
|
|
95
|
-
|
|
96
86
|
if (!pluginState) {
|
|
97
87
|
return;
|
|
98
88
|
}
|
|
99
|
-
|
|
100
89
|
var parsed = pluginState.parsedForLocalIds;
|
|
101
|
-
|
|
102
90
|
if (parsed) {
|
|
103
91
|
return;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
var table = state.schema.nodes.table;
|
|
107
94
|
rafSchedule(function () {
|
|
108
95
|
var tr = state.tr;
|
|
@@ -110,7 +97,6 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
110
97
|
editorView.state.doc.descendants(function (node, pos) {
|
|
111
98
|
var isTable = node.type === table;
|
|
112
99
|
var localId = node.attrs.localId;
|
|
113
|
-
|
|
114
100
|
if (isTable && !localId) {
|
|
115
101
|
tableIdWasAdded = true;
|
|
116
102
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
@@ -122,11 +108,8 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
122
108
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
123
109
|
* expands/bodiedExtensions
|
|
124
110
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
111
|
return true;
|
|
128
112
|
});
|
|
129
|
-
|
|
130
113
|
if (tableIdWasAdded) {
|
|
131
114
|
tr.setMeta('addToHistory', false);
|
|
132
115
|
editorView.dispatch(tr);
|
|
@@ -146,58 +129,52 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
146
129
|
transactions.forEach(function (transaction) {
|
|
147
130
|
if (!transaction.docChanged) {
|
|
148
131
|
return;
|
|
149
|
-
}
|
|
150
|
-
// to handle any extra cut cases in this plugin
|
|
151
|
-
|
|
132
|
+
}
|
|
152
133
|
|
|
134
|
+
// Don't interfere with cut as it clashes with fixTables & we don't need
|
|
135
|
+
// to handle any extra cut cases in this plugin
|
|
153
136
|
var uiEvent = transaction.getMeta('uiEvent');
|
|
154
|
-
|
|
155
137
|
if (uiEvent === 'cut') {
|
|
156
138
|
return;
|
|
157
139
|
}
|
|
158
|
-
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
159
|
-
|
|
160
140
|
|
|
141
|
+
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
161
142
|
var isAddingTable = checkIsAddingTable(transaction, table);
|
|
162
|
-
|
|
163
143
|
if (!isAddingTable) {
|
|
164
144
|
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
145
|
+
}
|
|
167
146
|
|
|
147
|
+
// Can't simply look at changed nodes, as we could be adding a table
|
|
168
148
|
newState.doc.descendants(function (node, pos) {
|
|
169
149
|
var isTable = node.type === table;
|
|
170
|
-
var localId = node.attrs.localId;
|
|
150
|
+
var localId = node.attrs.localId;
|
|
171
151
|
|
|
152
|
+
// Dealing with a table - make sure it's a unique ID
|
|
172
153
|
if (isTable) {
|
|
173
154
|
if (localId && !idsObserved.has(localId)) {
|
|
174
|
-
idsObserved.add(localId);
|
|
155
|
+
idsObserved.add(localId);
|
|
156
|
+
// Also add a localId if it happens to not have one,
|
|
175
157
|
} else if (!localId || idsObserved.has(localId)) {
|
|
176
158
|
modified = true;
|
|
177
159
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
178
160
|
localId: uuid.generate()
|
|
179
161
|
}));
|
|
180
162
|
}
|
|
181
|
-
|
|
182
163
|
return false;
|
|
183
164
|
}
|
|
165
|
+
|
|
184
166
|
/**
|
|
185
167
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
186
168
|
* expands/bodiedExtensions
|
|
187
169
|
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
170
|
return true;
|
|
191
171
|
});
|
|
192
172
|
});
|
|
193
|
-
|
|
194
173
|
if (modified) {
|
|
195
174
|
return tr;
|
|
196
175
|
}
|
|
197
|
-
|
|
198
176
|
return;
|
|
199
177
|
}
|
|
200
178
|
});
|
|
201
179
|
};
|
|
202
|
-
|
|
203
180
|
export { createPlugin };
|
|
@@ -8,63 +8,54 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
|
8
8
|
if (!tableRef) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
var node = options.node,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
start = options.start,
|
|
13
|
+
parentWidth = options.parentWidth;
|
|
15
14
|
|
|
15
|
+
// If a table has not been resized yet, columns should be auto.
|
|
16
16
|
if (hasTableBeenResized(node) === false) {
|
|
17
17
|
// If its not a re-sized table, we still want to re-create cols
|
|
18
18
|
// To force reflow of columns upon delete.
|
|
19
19
|
recreateResizeColsByNode(tableRef, node);
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
var resizeState;
|
|
24
|
-
|
|
25
23
|
if (parentWidth) {
|
|
26
24
|
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos);
|
|
27
25
|
} else {
|
|
28
26
|
resizeState = scale(tableRef, options, domAtPos);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
if (resizeState) {
|
|
32
29
|
var _tr = state.tr;
|
|
33
30
|
_tr = updateColumnWidths(resizeState, node, start)(_tr);
|
|
34
|
-
|
|
35
31
|
if (_tr.docChanged && dispatch) {
|
|
36
|
-
_tr.setMeta('scrollIntoView', false);
|
|
32
|
+
_tr.setMeta('scrollIntoView', false);
|
|
33
|
+
// TODO: ED-8995
|
|
37
34
|
// We need to do this check to reduce the number of race conditions when working with tables.
|
|
38
35
|
// This metadata is been used in the sendTransaction function in the Collab plugin
|
|
39
|
-
|
|
40
|
-
|
|
41
36
|
_tr.setMeta('scaleTable', true);
|
|
42
|
-
|
|
43
37
|
dispatch(_tr);
|
|
44
38
|
return true;
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
return false;
|
|
49
42
|
};
|
|
50
43
|
};
|
|
51
44
|
export var evenColumns = function evenColumns(_ref) {
|
|
52
45
|
var resizeState = _ref.resizeState,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
table = _ref.table,
|
|
47
|
+
start = _ref.start,
|
|
48
|
+
event = _ref.event;
|
|
56
49
|
return function (state, dispatch) {
|
|
57
50
|
if (!isTableSelected(state.selection)) {
|
|
58
51
|
return false;
|
|
59
|
-
}
|
|
60
|
-
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
61
|
-
|
|
52
|
+
}
|
|
62
53
|
|
|
54
|
+
// double click detection logic
|
|
55
|
+
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
63
56
|
var _getPluginState = getPluginState(state),
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
lastClick = _getPluginState.lastClick;
|
|
66
58
|
var now = Date.now();
|
|
67
|
-
|
|
68
59
|
if (lastClick && now - lastClick.time < 500 && isClickNear(event, lastClick)) {
|
|
69
60
|
var newState = evenAllColumnsWidths(resizeState);
|
|
70
61
|
setLastClick(null, function (tr) {
|
|
@@ -72,7 +63,6 @@ export var evenColumns = function evenColumns(_ref) {
|
|
|
72
63
|
})(state, dispatch);
|
|
73
64
|
return true;
|
|
74
65
|
}
|
|
75
|
-
|
|
76
66
|
setLastClick({
|
|
77
67
|
x: event.clientX,
|
|
78
68
|
y: event.clientY,
|
|
@@ -85,10 +75,8 @@ export var distributeColumnsWidths = function distributeColumnsWidths(newResizeS
|
|
|
85
75
|
return function (state, dispatch) {
|
|
86
76
|
if (dispatch) {
|
|
87
77
|
var _tr2 = updateColumnWidths(newResizeState, table.node, table.start)(state.tr);
|
|
88
|
-
|
|
89
78
|
stopResizing(_tr2)(state, dispatch);
|
|
90
79
|
}
|
|
91
|
-
|
|
92
80
|
return true;
|
|
93
81
|
};
|
|
94
82
|
};
|
|
@@ -11,14 +11,12 @@ import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeCol
|
|
|
11
11
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
12
12
|
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
13
13
|
var state = view.state,
|
|
14
|
-
|
|
14
|
+
dispatch = view.dispatch;
|
|
15
15
|
var editorDisabled = !view.editable;
|
|
16
16
|
var domAtPos = view.domAtPos.bind(view);
|
|
17
|
-
|
|
18
17
|
if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
|
|
19
18
|
return false;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
event.preventDefault();
|
|
23
21
|
var mouseDownTime = event.timeStamp;
|
|
24
22
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
@@ -26,19 +24,15 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
26
24
|
var originalTable = $cell.node(-1);
|
|
27
25
|
var start = $cell.start(-1);
|
|
28
26
|
var dom = domAtPos(start).node;
|
|
29
|
-
|
|
30
27
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
31
28
|
dom = dom.closest('table');
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
var containerWidth = getEditorContainerWidth();
|
|
35
31
|
var parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
36
32
|
var maxSize = parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
37
|
-
|
|
38
33
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
39
34
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
var resizeState = getResizeState({
|
|
43
37
|
minWidth: tableCellMinWidth,
|
|
44
38
|
maxSize: maxSize,
|
|
@@ -47,7 +41,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
47
41
|
start: start,
|
|
48
42
|
domAtPos: domAtPos
|
|
49
43
|
});
|
|
50
|
-
|
|
51
44
|
if (evenColumns({
|
|
52
45
|
resizeState: resizeState,
|
|
53
46
|
table: originalTable,
|
|
@@ -57,59 +50,52 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
57
50
|
finish(event);
|
|
58
51
|
return true;
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
var width = currentColWidth(view, localResizeHandlePos, cell.attrs);
|
|
62
54
|
setDragging({
|
|
63
55
|
startX: event.clientX,
|
|
64
56
|
startWidth: width
|
|
65
57
|
})(state, dispatch);
|
|
66
|
-
|
|
67
58
|
function finish(event) {
|
|
68
59
|
window.removeEventListener('mouseup', finish);
|
|
69
60
|
window.removeEventListener('mousemove', move);
|
|
70
61
|
var clientX = event.clientX;
|
|
71
62
|
var state = view.state,
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
dispatch = view.dispatch;
|
|
74
64
|
var _getPluginState = getPluginState(state),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
dragging = _getPluginState.dragging,
|
|
66
|
+
resizeHandlePos = _getPluginState.resizeHandlePos;
|
|
78
67
|
if (resizeHandlePos === null) {
|
|
79
68
|
return stopResizing()(state, dispatch);
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
if (!pointsAtCell(state.doc.resolve(resizeHandlePos))) {
|
|
83
71
|
return;
|
|
84
|
-
}
|
|
72
|
+
}
|
|
73
|
+
// resizeHandlePos could be remapped via a collab change.
|
|
85
74
|
// Fetch a fresh reference of the table.
|
|
86
|
-
|
|
87
|
-
|
|
88
75
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
89
76
|
var start = $cell.start(-1);
|
|
90
|
-
var table = $cell.node(-1);
|
|
77
|
+
var table = $cell.node(-1);
|
|
91
78
|
|
|
79
|
+
// If we let go in the same place we started, dont need to do anything.
|
|
92
80
|
if (dragging && clientX === dragging.startX) {
|
|
93
81
|
return stopResizing()(state, dispatch);
|
|
94
82
|
}
|
|
95
|
-
|
|
96
83
|
var tr = state.tr;
|
|
97
|
-
|
|
98
84
|
if (dragging) {
|
|
99
|
-
var startX = dragging.startX;
|
|
85
|
+
var startX = dragging.startX;
|
|
86
|
+
|
|
87
|
+
// If the table has changed (via collab for example) don't apply column widths
|
|
100
88
|
// For example, if a table col is deleted we won't be able to reliably remap the new widths
|
|
101
89
|
// There may be a more elegant solution to this, to avoid a jarring experience.
|
|
102
|
-
|
|
103
90
|
if (table.eq(originalTable)) {
|
|
104
91
|
var map = TableMap.get(table);
|
|
105
92
|
var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
106
93
|
var selectionRect = getSelectionRect(state.selection);
|
|
107
|
-
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
108
|
-
|
|
94
|
+
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
95
|
+
// only selected (or selected - 1) columns should be distributed
|
|
109
96
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
110
97
|
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
111
98
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
112
|
-
|
|
113
99
|
if (colIndex === map.width - 1) {
|
|
114
100
|
var mouseUpTime = event.timeStamp;
|
|
115
101
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -126,24 +112,19 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
126
112
|
})(tr);
|
|
127
113
|
}
|
|
128
114
|
}
|
|
129
|
-
|
|
130
115
|
return stopResizing(tr)(state, dispatch);
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
|
-
|
|
134
118
|
function move(event) {
|
|
135
119
|
var clientX = event.clientX,
|
|
136
|
-
|
|
120
|
+
which = event.which;
|
|
137
121
|
var state = view.state;
|
|
138
|
-
|
|
139
122
|
var _getPluginState2 = getPluginState(state),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
123
|
+
dragging = _getPluginState2.dragging,
|
|
124
|
+
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
143
125
|
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos))) {
|
|
144
126
|
return finish(event);
|
|
145
127
|
}
|
|
146
|
-
|
|
147
128
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
148
129
|
var table = $cell.node(-1);
|
|
149
130
|
var map = TableMap.get(table);
|
|
@@ -152,7 +133,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
152
133
|
updateControls(getEditorFeatureFlags)(state);
|
|
153
134
|
updateResizeHandles(dom);
|
|
154
135
|
}
|
|
155
|
-
|
|
156
136
|
window.addEventListener('mouseup', finish);
|
|
157
137
|
window.addEventListener('mousemove', move);
|
|
158
138
|
return true;
|
|
@@ -1,23 +1,17 @@
|
|
|
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
6
|
import reducer from './reducer';
|
|
10
|
-
|
|
11
7
|
function mapping(tr, pluginState) {
|
|
12
8
|
if (pluginState && pluginState.resizeHandlePos !== null) {
|
|
13
9
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
14
10
|
resizeHandlePos: tr.mapping.map(pluginState.resizeHandlePos)
|
|
15
11
|
});
|
|
16
12
|
}
|
|
17
|
-
|
|
18
13
|
return pluginState;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
var factory = pluginFactory(pluginKey, reducer, {
|
|
22
16
|
mapping: mapping
|
|
23
17
|
});
|
|
@@ -9,7 +9,7 @@ import { pluginKey } from './plugin-key';
|
|
|
9
9
|
import { getResizeCellPos } from './utils';
|
|
10
10
|
export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
11
11
|
var _ref$lastColumnResiza = _ref.lastColumnResizable,
|
|
12
|
-
|
|
12
|
+
lastColumnResizable = _ref$lastColumnResiza === void 0 ? true : _ref$lastColumnResiza;
|
|
13
13
|
return new SafePlugin({
|
|
14
14
|
key: pluginKey,
|
|
15
15
|
state: createPluginState(dispatch, {
|
|
@@ -21,7 +21,6 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
|
|
|
21
21
|
props: {
|
|
22
22
|
attributes: function attributes(state) {
|
|
23
23
|
var _classnames;
|
|
24
|
-
|
|
25
24
|
var pluginState = getPluginState(state);
|
|
26
25
|
return {
|
|
27
26
|
class: classnames(ClassName.RESIZING_PLUGIN, (_classnames = {}, _defineProperty(_classnames, ClassName.RESIZE_CURSOR, pluginState.resizeHandlePos !== null), _defineProperty(_classnames, ClassName.IS_RESIZING, !!pluginState.dragging), _classnames))
|
|
@@ -30,20 +29,18 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
|
|
|
30
29
|
handleDOMEvents: {
|
|
31
30
|
mousedown: function mousedown(view, event) {
|
|
32
31
|
var state = view.state;
|
|
33
|
-
var resizeHandlePos =
|
|
32
|
+
var resizeHandlePos =
|
|
33
|
+
// we're setting `resizeHandlePos` via command in unit tests
|
|
34
34
|
getPluginState(state).resizeHandlePos || getResizeCellPos(view, event, lastColumnResizable);
|
|
35
|
-
|
|
36
35
|
var _getPluginState = getPluginState(state),
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
dragging = _getPluginState.dragging;
|
|
39
37
|
if (resizeHandlePos !== null && !dragging) {
|
|
40
38
|
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
|
|
41
39
|
var _state = view.state,
|
|
42
|
-
|
|
40
|
+
_dispatch = view.dispatch;
|
|
43
41
|
return setResizeHandlePos(resizeHandlePos)(_state, _dispatch);
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
return false;
|
|
48
45
|
}
|
|
49
46
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
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
|
export default (function (pluginState, action) {
|
|
8
5
|
switch (action.type) {
|
|
9
6
|
case 'STOP_RESIZING':
|
|
@@ -11,24 +8,20 @@ export default (function (pluginState, action) {
|
|
|
11
8
|
resizeHandlePos: null,
|
|
12
9
|
dragging: null
|
|
13
10
|
});
|
|
14
|
-
|
|
15
11
|
case 'SET_RESIZE_HANDLE_POSITION':
|
|
16
12
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
17
13
|
resizeHandlePos: action.data.resizeHandlePos
|
|
18
14
|
});
|
|
19
|
-
|
|
20
15
|
case 'SET_DRAGGING':
|
|
21
16
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
22
17
|
dragging: action.data.dragging
|
|
23
18
|
});
|
|
24
|
-
|
|
25
19
|
case 'SET_LAST_CLICK':
|
|
26
20
|
var lastClick = action.data.lastClick;
|
|
27
21
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
28
22
|
lastClick: lastClick,
|
|
29
23
|
resizeHandlePos: lastClick ? pluginState.resizeHandlePos : null
|
|
30
24
|
});
|
|
31
|
-
|
|
32
25
|
default:
|
|
33
26
|
return pluginState;
|
|
34
27
|
}
|
|
@@ -5,7 +5,6 @@ export var generateColgroup = function generateColgroup(table) {
|
|
|
5
5
|
var cols = [];
|
|
6
6
|
table.content.firstChild.content.forEach(function (cell) {
|
|
7
7
|
var colspan = cell.attrs.colspan || 1;
|
|
8
|
-
|
|
9
8
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
10
9
|
// We slice here to guard against our colwidth array having more entries
|
|
11
10
|
// Than the we actually span. We'll patch the document at a later point.
|
|
@@ -29,11 +28,9 @@ export var generateColgroup = function generateColgroup(table) {
|
|
|
29
28
|
};
|
|
30
29
|
export var insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
|
31
30
|
var colgroup = tableRef.querySelector('colgroup');
|
|
32
|
-
|
|
33
31
|
if (colgroup) {
|
|
34
32
|
tableRef.removeChild(colgroup);
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
colgroup = renderColgroupFromNode(table);
|
|
38
35
|
tableRef.insertBefore(colgroup, tableRef.firstChild);
|
|
39
36
|
return colgroup.children;
|
|
@@ -43,7 +40,6 @@ export var hasTableBeenResized = function hasTableBeenResized(table) {
|
|
|
43
40
|
return cell.attrs.colwidth;
|
|
44
41
|
});
|
|
45
42
|
};
|
|
46
|
-
|
|
47
43
|
function renderColgroupFromNode(table) {
|
|
48
44
|
var rendered = DOMSerializer.renderSpec(document, ['colgroup', {}].concat(_toConsumableArray(generateColgroup(table))));
|
|
49
45
|
return rendered.dom;
|
|
@@ -6,7 +6,8 @@ import { unitToNumber } from './unit-to-number';
|
|
|
6
6
|
// Reads `width` and `minWidth` of each column from DOM and returns `ColumnState` containing those values
|
|
7
7
|
export var getColumnStateFromDOM = function getColumnStateFromDOM(cells, index, minWidth) {
|
|
8
8
|
var width = calculateColumnWidth(cells, calculateColumnWidthCallback);
|
|
9
|
-
var minColumnWidth = width < minWidth ?
|
|
9
|
+
var minColumnWidth = width < minWidth ?
|
|
10
|
+
// for newly created column (where width < minWidth) we set minWidth = tableNewColumnMinWidth (140px atm)
|
|
10
11
|
tableNewColumnMinWidth : calculateColumnWidth(cells, calculateColumnMinWidthCallback(minWidth));
|
|
11
12
|
return {
|
|
12
13
|
index: index,
|
|
@@ -16,8 +17,9 @@ export var getColumnStateFromDOM = function getColumnStateFromDOM(cells, index,
|
|
|
16
17
|
};
|
|
17
18
|
export var getFreeSpace = function getFreeSpace(state) {
|
|
18
19
|
return Math.max(state.width - state.minWidth, 0);
|
|
19
|
-
};
|
|
20
|
+
};
|
|
20
21
|
|
|
22
|
+
// Returns DOM refs of all cells in a column by `columnIndex`
|
|
21
23
|
export var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, table, tableStart, domAtPos) {
|
|
22
24
|
var map = TableMap.get(table);
|
|
23
25
|
var cellsPositions = map.cellsInRect({
|
|
@@ -29,26 +31,24 @@ export var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, tab
|
|
|
29
31
|
var cells = [];
|
|
30
32
|
cellsPositions.forEach(function (pos) {
|
|
31
33
|
var col = findDomRefAtPos(pos + tableStart, domAtPos);
|
|
32
|
-
|
|
33
34
|
if (col) {
|
|
34
35
|
cells.push(col);
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
return cells;
|
|
38
|
-
};
|
|
39
|
+
};
|
|
39
40
|
|
|
41
|
+
// calculates column widths based on `cells` DOM refs
|
|
40
42
|
export var calculateColumnWidth = function calculateColumnWidth(cells, calculateColumnWidthCb) {
|
|
41
43
|
var maxColWidth = 0;
|
|
42
44
|
var colSpanWidth = 0;
|
|
43
45
|
cells.forEach(function (cellRef) {
|
|
44
46
|
var css = getComputedStyle(cellRef);
|
|
45
47
|
var colspan = Number(cellRef.getAttribute('colspan') || 1);
|
|
46
|
-
|
|
47
48
|
if (colspan > 1) {
|
|
48
49
|
colSpanWidth = calculateColumnWidthCb(css, cellRef, colspan);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
if (css) {
|
|
53
53
|
var colWidth = calculateColumnWidthCb(css, cellRef, colspan);
|
|
54
54
|
maxColWidth = Math.max(colWidth, maxColWidth);
|
|
@@ -59,22 +59,18 @@ export var calculateColumnWidth = function calculateColumnWidth(cells, calculate
|
|
|
59
59
|
export var addContainerLeftRightPadding = function addContainerLeftRightPadding(amount, css) {
|
|
60
60
|
return amount + unitToNumber(css.paddingLeft) + unitToNumber(css.paddingRight);
|
|
61
61
|
};
|
|
62
|
-
|
|
63
62
|
function calculateColumnWidthCallback(css) {
|
|
64
63
|
return unitToNumber(css.width);
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
function calculateColumnMinWidthCallback(minColumnWidth) {
|
|
68
66
|
return function (css, cellRef, colSpan) {
|
|
69
67
|
if (colSpan && colSpan > 1) {
|
|
70
68
|
return unitToNumber(css.width);
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
var _contentWidth = contentWidth(cellRef, cellRef),
|
|
74
|
-
|
|
71
|
+
minContentWidth = _contentWidth.minWidth;
|
|
72
|
+
// Override the min width, if there is content that can't collapse
|
|
75
73
|
// Past a certain width.
|
|
76
|
-
|
|
77
|
-
|
|
78
74
|
return Math.max(addContainerLeftRightPadding(minContentWidth, css), minContentWidth, minColumnWidth);
|
|
79
75
|
};
|
|
80
76
|
}
|