@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
|
@@ -1,61 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.messages = exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
8
|
var _react = require("@emotion/react");
|
|
13
|
-
|
|
14
9
|
var _reactIntlNext = require("react-intl-next");
|
|
15
|
-
|
|
16
10
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
17
|
-
|
|
18
11
|
var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
|
|
19
|
-
|
|
20
12
|
var _commands = require("./commands");
|
|
21
|
-
|
|
22
13
|
var _commandsWithAnalytics = require("./commands-with-analytics");
|
|
23
|
-
|
|
24
14
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
25
|
-
|
|
26
15
|
var _tableResizing = require("./pm-plugins/table-resizing");
|
|
27
|
-
|
|
28
16
|
var _types = require("./types");
|
|
29
|
-
|
|
30
17
|
var _utils = require("./utils");
|
|
31
|
-
|
|
32
18
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
33
|
-
|
|
34
19
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
35
|
-
|
|
36
20
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
37
|
-
|
|
38
21
|
var _transforms = require("./transforms");
|
|
39
|
-
|
|
40
22
|
var _messages2 = _interopRequireDefault(require("./ui/messages"));
|
|
41
|
-
|
|
42
23
|
var _ContextualMenu = require("./ui/FloatingContextualMenu/ContextualMenu");
|
|
43
|
-
|
|
44
24
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
45
|
-
|
|
46
25
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
47
|
-
|
|
48
26
|
var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
|
|
49
|
-
|
|
50
27
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
51
|
-
|
|
52
28
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
53
|
-
|
|
54
29
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
55
|
-
|
|
56
30
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
57
|
-
|
|
58
31
|
/** @jsx jsx */
|
|
32
|
+
|
|
59
33
|
var messages = (0, _reactIntlNext.defineMessages)({
|
|
60
34
|
tableOptions: {
|
|
61
35
|
id: 'fabric.editor.tableOptions',
|
|
@@ -84,7 +58,6 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
84
58
|
}
|
|
85
59
|
});
|
|
86
60
|
exports.messages = messages;
|
|
87
|
-
|
|
88
61
|
var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
|
|
89
62
|
var formatMessage = _ref.formatMessage;
|
|
90
63
|
var options = [{
|
|
@@ -123,21 +96,19 @@ var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, ed
|
|
|
123
96
|
}),
|
|
124
97
|
options: options
|
|
125
98
|
};
|
|
126
|
-
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Added these options for mobile. Mobile bridge translates this menu and
|
|
127
102
|
// relay it to the native mobile. Native mobile displays the menu
|
|
128
103
|
// with native widgets. It's enabled via a plugin config.
|
|
129
|
-
|
|
130
|
-
|
|
131
104
|
exports.getToolbarMenuConfig = getToolbarMenuConfig;
|
|
132
|
-
|
|
133
105
|
var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorState, editorView, initialSelectionRect, _ref2, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
134
106
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
135
|
-
|
|
136
107
|
var formatMessage = _ref2.formatMessage;
|
|
137
108
|
var top = initialSelectionRect.top,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
109
|
+
bottom = initialSelectionRect.bottom,
|
|
110
|
+
right = initialSelectionRect.right,
|
|
111
|
+
left = initialSelectionRect.left;
|
|
141
112
|
var numberOfColumns = right - left;
|
|
142
113
|
var numberOfRows = bottom - top;
|
|
143
114
|
var pluginState = (0, _pluginFactory.getPluginState)(editorState);
|
|
@@ -147,11 +118,9 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
147
118
|
onClick: function onClick(state, dispatch, view) {
|
|
148
119
|
var selectionRect = getClosestSelectionRect(state);
|
|
149
120
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
150
|
-
|
|
151
121
|
if (index) {
|
|
152
122
|
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
153
123
|
}
|
|
154
|
-
|
|
155
124
|
return true;
|
|
156
125
|
},
|
|
157
126
|
selected: false,
|
|
@@ -165,14 +134,12 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
165
134
|
onClick: function onClick(state, dispatch) {
|
|
166
135
|
var selectionRect = getClosestSelectionRect(state);
|
|
167
136
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
|
|
168
|
-
|
|
169
137
|
if (index) {
|
|
170
138
|
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, {
|
|
171
139
|
index: index,
|
|
172
140
|
moveCursorToInsertedRow: true
|
|
173
141
|
})(state, dispatch);
|
|
174
142
|
}
|
|
175
|
-
|
|
176
143
|
return true;
|
|
177
144
|
},
|
|
178
145
|
selected: false,
|
|
@@ -187,11 +154,9 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
187
154
|
}),
|
|
188
155
|
onClick: function onClick(state, dispatch, view) {
|
|
189
156
|
var selectionRect = getClosestSelectionRect(state);
|
|
190
|
-
|
|
191
157
|
if (selectionRect) {
|
|
192
158
|
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
193
159
|
}
|
|
194
|
-
|
|
195
160
|
return true;
|
|
196
161
|
},
|
|
197
162
|
onFocus: highlightColumnsHandler,
|
|
@@ -207,11 +172,9 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
207
172
|
}),
|
|
208
173
|
onClick: function onClick(state, dispatch) {
|
|
209
174
|
var selectionRect = getClosestSelectionRect(state);
|
|
210
|
-
|
|
211
175
|
if (selectionRect) {
|
|
212
176
|
(0, _commandsWithAnalytics.deleteRowsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, selectionRect, false)(state, dispatch);
|
|
213
177
|
}
|
|
214
|
-
|
|
215
178
|
return true;
|
|
216
179
|
},
|
|
217
180
|
onFocus: highlightRowsHandler,
|
|
@@ -233,22 +196,17 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
233
196
|
selected: false,
|
|
234
197
|
disabled: !(0, _utils3.splitCell)(editorState)
|
|
235
198
|
}];
|
|
236
|
-
|
|
237
199
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
238
200
|
var _newResizeStateWithAn;
|
|
239
|
-
|
|
240
201
|
var newResizeStateWithAnalytics = editorView ? (0, _resizeState.getNewResizeStateFromSelectedColumns)(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth) : undefined;
|
|
241
202
|
var wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
242
|
-
|
|
243
203
|
var distributeColumnWidths = function distributeColumnWidths(state, dispatch) {
|
|
244
204
|
if (newResizeStateWithAnalytics) {
|
|
245
205
|
(0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
246
206
|
return true;
|
|
247
207
|
}
|
|
248
|
-
|
|
249
208
|
return false;
|
|
250
209
|
};
|
|
251
|
-
|
|
252
210
|
options.push({
|
|
253
211
|
id: 'editor.table.distributeColumns',
|
|
254
212
|
title: formatMessage(_ContextualMenu.messages.distributeColumns),
|
|
@@ -257,7 +215,6 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
257
215
|
disabled: !wouldChange
|
|
258
216
|
});
|
|
259
217
|
}
|
|
260
|
-
|
|
261
218
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
|
|
262
219
|
var hasMergedCellsInTable = (0, _utils.getMergedCellsPositions)(editorState.tr).length > 0;
|
|
263
220
|
var warning = hasMergedCellsInTable ? formatMessage(_ContextualMenu.messages.canNotSortTable) : undefined;
|
|
@@ -269,7 +226,6 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
269
226
|
(0, _commands.hoverMergedCells)()(state, dispatch);
|
|
270
227
|
return true;
|
|
271
228
|
}
|
|
272
|
-
|
|
273
229
|
return false;
|
|
274
230
|
},
|
|
275
231
|
onMouseOut: function onMouseOut(state, dispatch) {
|
|
@@ -292,7 +248,6 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
292
248
|
(0, _commands.hoverMergedCells)()(state, dispatch);
|
|
293
249
|
return true;
|
|
294
250
|
}
|
|
295
|
-
|
|
296
251
|
return false;
|
|
297
252
|
},
|
|
298
253
|
onMouseOut: function onMouseOut(state, dispatch) {
|
|
@@ -308,7 +263,6 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
308
263
|
tooltip: warning
|
|
309
264
|
});
|
|
310
265
|
}
|
|
311
|
-
|
|
312
266
|
options.push({
|
|
313
267
|
id: 'editor.table.clearCells',
|
|
314
268
|
title: formatMessage(_ContextualMenu.messages.clearCells, {
|
|
@@ -316,8 +270,7 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
316
270
|
}),
|
|
317
271
|
onClick: function onClick(state, dispatch) {
|
|
318
272
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
319
|
-
|
|
320
|
-
|
|
273
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
321
274
|
(0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, targetCellPosition)(state, dispatch);
|
|
322
275
|
return true;
|
|
323
276
|
},
|
|
@@ -338,34 +291,27 @@ var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorSta
|
|
|
338
291
|
showSelected: false
|
|
339
292
|
};
|
|
340
293
|
};
|
|
341
|
-
|
|
342
294
|
exports.getToolbarCellOptionsConfig = getToolbarCellOptionsConfig;
|
|
343
|
-
|
|
344
295
|
var getClosestSelectionRect = function getClosestSelectionRect(state) {
|
|
345
296
|
var selection = state.selection;
|
|
346
297
|
return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : (0, _utils3.findCellRectClosestToPos)(selection.$from);
|
|
347
298
|
};
|
|
348
|
-
|
|
349
299
|
var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
|
|
350
300
|
return function (config) {
|
|
351
301
|
return function (state, intl) {
|
|
352
302
|
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
353
303
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
354
|
-
|
|
355
304
|
var resizeState = _tableResizing.pluginKey.getState(state);
|
|
356
|
-
|
|
357
305
|
if (tableObject && pluginState.editorHasFocus) {
|
|
358
306
|
var nodeType = state.schema.nodes.table;
|
|
359
307
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
360
|
-
|
|
361
308
|
var _ref3 = getEditorFeatureFlags() || {},
|
|
362
|
-
|
|
363
|
-
|
|
309
|
+
tableCellOptionsInFloatingToolbar = _ref3.tableCellOptionsInFloatingToolbar;
|
|
364
310
|
var cellItems = getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
365
|
-
var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
311
|
+
var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
366
312
|
|
|
313
|
+
// Check if we need to show confirm dialog for delete button
|
|
367
314
|
var confirmDialog;
|
|
368
|
-
|
|
369
315
|
if ((0, _utils2.isReferencedSource)(state, tableObject.node)) {
|
|
370
316
|
confirmDialog = function confirmDialog() {
|
|
371
317
|
return {
|
|
@@ -387,23 +333,18 @@ var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editor
|
|
|
387
333
|
};
|
|
388
334
|
};
|
|
389
335
|
}
|
|
390
|
-
|
|
391
336
|
var getDomRef = function getDomRef(editorView) {
|
|
392
337
|
var element;
|
|
393
338
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
394
339
|
var parent = (0, _prosemirrorUtils.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
|
|
395
|
-
|
|
396
340
|
if (parent) {
|
|
397
341
|
var tableRef = parent.querySelector('table') || undefined;
|
|
398
|
-
|
|
399
342
|
if (tableRef) {
|
|
400
343
|
element = (0, _utils2.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
401
344
|
}
|
|
402
345
|
}
|
|
403
|
-
|
|
404
346
|
return element;
|
|
405
347
|
};
|
|
406
|
-
|
|
407
348
|
return {
|
|
408
349
|
title: 'Table floating controls',
|
|
409
350
|
getDomRef: getDomRef,
|
|
@@ -411,7 +352,7 @@ var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editor
|
|
|
411
352
|
offset: [0, 3],
|
|
412
353
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
413
354
|
// Place the context menu slightly above the others
|
|
414
|
-
items: [menu, separator(menu.hidden)].concat(
|
|
355
|
+
items: [menu, separator(menu.hidden)].concat(cellItems, colorPicker, [{
|
|
415
356
|
type: 'extensions-placeholder',
|
|
416
357
|
separator: 'end'
|
|
417
358
|
}, {
|
|
@@ -445,27 +386,21 @@ var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editor
|
|
|
445
386
|
scrollable: true
|
|
446
387
|
};
|
|
447
388
|
}
|
|
448
|
-
|
|
449
389
|
return;
|
|
450
390
|
};
|
|
451
391
|
};
|
|
452
392
|
};
|
|
453
|
-
|
|
454
393
|
exports.getToolbarConfig = getToolbarConfig;
|
|
455
|
-
|
|
456
394
|
var separator = function separator(hidden) {
|
|
457
395
|
return {
|
|
458
396
|
type: 'separator',
|
|
459
397
|
hidden: hidden
|
|
460
398
|
};
|
|
461
399
|
};
|
|
462
|
-
|
|
463
400
|
var getCellItems = function getCellItems(pluginConfig, state, view, _ref4, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
464
401
|
var formatMessage = _ref4.formatMessage;
|
|
465
|
-
|
|
466
402
|
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
467
403
|
var initialSelectionRect = getClosestSelectionRect(state);
|
|
468
|
-
|
|
469
404
|
if (initialSelectionRect) {
|
|
470
405
|
var cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
471
406
|
formatMessage: formatMessage
|
|
@@ -473,23 +408,17 @@ var getCellItems = function getCellItems(pluginConfig, state, view, _ref4, getEd
|
|
|
473
408
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
474
409
|
}
|
|
475
410
|
}
|
|
476
|
-
|
|
477
411
|
return [];
|
|
478
412
|
};
|
|
479
|
-
|
|
480
413
|
var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
481
414
|
var _node$attrs;
|
|
482
|
-
|
|
483
415
|
var formatMessage = _ref5.formatMessage;
|
|
484
|
-
|
|
485
416
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
417
|
+
targetCellPosition = _getPluginState2.targetCellPosition,
|
|
418
|
+
pluginConfig = _getPluginState2.pluginConfig;
|
|
489
419
|
if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
|
|
490
420
|
return [];
|
|
491
421
|
}
|
|
492
|
-
|
|
493
422
|
var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
|
|
494
423
|
var currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
495
424
|
var defaultPalette = _uiColor.cellBackgroundColorPalette.find(function (item) {
|
|
@@ -511,41 +440,32 @@ var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContai
|
|
|
511
440
|
}
|
|
512
441
|
}, separator(menu.hidden)];
|
|
513
442
|
};
|
|
514
|
-
|
|
515
443
|
var clickWithCheckboxHandler = function clickWithCheckboxHandler(isChecked, node, editorAnalyticsAPI) {
|
|
516
444
|
return function (state, dispatch) {
|
|
517
445
|
if (!node) {
|
|
518
446
|
return false;
|
|
519
447
|
}
|
|
520
|
-
|
|
521
448
|
if (!isChecked) {
|
|
522
449
|
return (0, _commandsWithAnalytics.deleteTableWithAnalytics)(editorAnalyticsAPI)(state, dispatch);
|
|
523
450
|
} else {
|
|
524
451
|
(0, _commands.removeDescendantNodes)(node)(state, dispatch);
|
|
525
452
|
}
|
|
526
|
-
|
|
527
453
|
return true;
|
|
528
454
|
};
|
|
529
455
|
};
|
|
530
|
-
|
|
531
456
|
var highlightRowsHandler = function highlightRowsHandler(state, dispatch) {
|
|
532
457
|
var selectionRect = getClosestSelectionRect(state);
|
|
533
|
-
|
|
534
458
|
if (selectionRect) {
|
|
535
459
|
(0, _commands.hoverRows)((0, _utils.getSelectedRowIndexes)(selectionRect), true)(state, dispatch);
|
|
536
460
|
return true;
|
|
537
461
|
}
|
|
538
|
-
|
|
539
462
|
return false;
|
|
540
463
|
};
|
|
541
|
-
|
|
542
464
|
var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch) {
|
|
543
465
|
var selectionRect = getClosestSelectionRect(state);
|
|
544
|
-
|
|
545
466
|
if (selectionRect) {
|
|
546
467
|
(0, _commands.hoverColumns)((0, _utils.getSelectedColumnIndexes)(selectionRect), true)(state, dispatch);
|
|
547
468
|
return true;
|
|
548
469
|
}
|
|
549
|
-
|
|
550
470
|
return false;
|
|
551
471
|
};
|
|
@@ -1,48 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.updateColumnWidths = exports.rescaleColumns = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
15
|
-
|
|
16
11
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
17
|
-
|
|
18
12
|
var _metadata = require("./metadata");
|
|
19
|
-
|
|
20
13
|
var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
21
|
-
|
|
22
14
|
var _misc = require("../pm-plugins/table-resizing/utils/misc");
|
|
23
|
-
|
|
24
15
|
var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
|
|
25
|
-
|
|
26
16
|
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; }
|
|
27
|
-
|
|
28
17
|
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) { (0, _defineProperty2.default)(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; }
|
|
29
|
-
|
|
30
18
|
var updateColumnWidths = function updateColumnWidths(resizeState, table, start) {
|
|
31
19
|
return function (tr) {
|
|
32
20
|
var map = _tableMap.TableMap.get(table);
|
|
21
|
+
var updatedCellsAttrs = {};
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
// calculating new attributes for each cell
|
|
36
24
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
37
25
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
38
26
|
var width = resizeState.cols[columnIndex].width;
|
|
39
27
|
var mapIndex = rowIndex * map.width + columnIndex;
|
|
40
28
|
var cellPos = map.map[mapIndex];
|
|
41
|
-
|
|
42
29
|
var attrs = updatedCellsAttrs[cellPos] || _objectSpread({}, table.nodeAt(cellPos).attrs);
|
|
43
|
-
|
|
44
30
|
var colspan = attrs.colspan || 1;
|
|
45
|
-
|
|
46
31
|
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
47
32
|
tr = (0, _metadata.setMeta)({
|
|
48
33
|
type: 'UPDATE_COLUMN_WIDTHS',
|
|
@@ -53,26 +38,22 @@ var updateColumnWidths = function updateColumnWidths(resizeState, table, start)
|
|
|
53
38
|
}
|
|
54
39
|
})(tr);
|
|
55
40
|
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
56
|
-
}
|
|
57
|
-
|
|
41
|
+
}
|
|
58
42
|
|
|
43
|
+
// Rowspanning cell that has already been handled
|
|
59
44
|
if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
|
|
60
45
|
continue;
|
|
61
46
|
}
|
|
62
|
-
|
|
63
47
|
var colspanIndex = colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
|
|
64
|
-
|
|
65
48
|
if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
|
|
66
49
|
continue;
|
|
67
50
|
}
|
|
68
|
-
|
|
69
51
|
var colwidths = attrs.colwidth ? attrs.colwidth.slice() : Array.from({
|
|
70
52
|
length: colspan
|
|
71
53
|
}, function (_) {
|
|
72
54
|
return 0;
|
|
73
55
|
});
|
|
74
56
|
colwidths[colspanIndex] = width;
|
|
75
|
-
|
|
76
57
|
if (colwidths.length > colspan) {
|
|
77
58
|
tr = (0, _metadata.setMeta)({
|
|
78
59
|
type: 'UPDATE_COLUMN_WIDTHS',
|
|
@@ -84,36 +65,29 @@ var updateColumnWidths = function updateColumnWidths(resizeState, table, start)
|
|
|
84
65
|
})(tr);
|
|
85
66
|
colwidths = colwidths.slice(0, colspan);
|
|
86
67
|
}
|
|
87
|
-
|
|
88
68
|
updatedCellsAttrs[cellPos] = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
89
69
|
colwidth: colwidths.includes(0) ? undefined : colwidths
|
|
90
70
|
});
|
|
91
71
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
72
|
+
}
|
|
94
73
|
|
|
74
|
+
// updating all cells with new attributes
|
|
95
75
|
var rows = [];
|
|
96
76
|
var seen = {};
|
|
97
|
-
|
|
98
77
|
for (var _rowIndex = 0; _rowIndex < map.height; _rowIndex++) {
|
|
99
78
|
var row = table.child(_rowIndex);
|
|
100
79
|
var cells = [];
|
|
101
|
-
|
|
102
80
|
for (var _columnIndex = 0; _columnIndex < map.width; _columnIndex++) {
|
|
103
81
|
var _mapIndex = _rowIndex * map.width + _columnIndex;
|
|
104
|
-
|
|
105
82
|
var pos = map.map[_mapIndex];
|
|
106
83
|
var cell = table.nodeAt(pos);
|
|
107
|
-
|
|
108
84
|
if (!seen[pos] && cell) {
|
|
109
85
|
cells.push(cell.type.createChecked(updatedCellsAttrs[pos] || cell.attrs, cell.content, cell.marks));
|
|
110
86
|
seen[pos] = true;
|
|
111
87
|
}
|
|
112
88
|
}
|
|
113
|
-
|
|
114
89
|
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
115
90
|
}
|
|
116
|
-
|
|
117
91
|
var tablePos = start - 1;
|
|
118
92
|
var selectionBookmark = tr.selection.getBookmark();
|
|
119
93
|
tr.replaceWith(tablePos, tablePos + table.nodeSize, table.type.createChecked(table.attrs, rows, table.marks));
|
|
@@ -127,10 +101,10 @@ var updateColumnWidths = function updateColumnWidths(resizeState, table, start)
|
|
|
127
101
|
*
|
|
128
102
|
* @see https://github.com/ProseMirror/prosemirror/issues/645
|
|
129
103
|
*/
|
|
130
|
-
|
|
131
104
|
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
132
105
|
};
|
|
133
106
|
};
|
|
107
|
+
|
|
134
108
|
/**
|
|
135
109
|
* This function is called when user inserts/deletes a column in a table to;
|
|
136
110
|
* - rescale all columns (if the table did not overflow before the insertion)
|
|
@@ -141,10 +115,7 @@ var updateColumnWidths = function updateColumnWidths(resizeState, table, start)
|
|
|
141
115
|
* @param view
|
|
142
116
|
* @returns Updated transaction with rescaled columns for a given table
|
|
143
117
|
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
118
|
exports.updateColumnWidths = updateColumnWidths;
|
|
147
|
-
|
|
148
119
|
var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
149
120
|
return function (table, view) {
|
|
150
121
|
return function (tr) {
|
|
@@ -153,18 +124,15 @@ var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
|
153
124
|
if (!view || !(0, _utils.hasTableBeenResized)(table.node)) {
|
|
154
125
|
return tr;
|
|
155
126
|
}
|
|
156
|
-
|
|
157
127
|
var state = view.state;
|
|
158
128
|
var domAtPos = view.domAtPos.bind(view);
|
|
159
129
|
var maybeTable = domAtPos(table.start).node;
|
|
160
130
|
var tableRef = maybeTable.closest('table');
|
|
161
|
-
|
|
162
131
|
if (!tableRef) {
|
|
163
132
|
return tr;
|
|
164
133
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
134
|
+
var layout = (0, _resizeState.normaliseTableLayout)(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout);
|
|
135
|
+
// The is the width the table can reach before overflowing
|
|
168
136
|
var maxSize = (0, _misc.getTableMaxWidth)({
|
|
169
137
|
table: table.node,
|
|
170
138
|
tableStart: table.start,
|
|
@@ -181,16 +149,15 @@ var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
|
181
149
|
maxSize: maxSize
|
|
182
150
|
});
|
|
183
151
|
var previousTableWidth = resizeState.tableWidth - _styles.tableNewColumnMinWidth;
|
|
184
|
-
var tableDidntPreviouslyOverflow = previousTableWidth <= maxSize;
|
|
185
|
-
// we resize the cells to avoid the overflow occuring
|
|
152
|
+
var tableDidntPreviouslyOverflow = previousTableWidth <= maxSize;
|
|
186
153
|
|
|
154
|
+
// If the new table width will result in the table going into an overflow state
|
|
155
|
+
// we resize the cells to avoid the overflow occuring
|
|
187
156
|
if (tableDidntPreviouslyOverflow && resizeState.overflow) {
|
|
188
157
|
resizeState = (0, _scaleTable.scaleTableTo)(resizeState, maxSize);
|
|
189
158
|
}
|
|
190
|
-
|
|
191
159
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
192
160
|
};
|
|
193
161
|
};
|
|
194
162
|
};
|
|
195
|
-
|
|
196
163
|
exports.rescaleColumns = rescaleColumns;
|