@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,43 +1,31 @@
|
|
|
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.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.isLayoutSupported = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
15
|
-
|
|
16
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
|
-
|
|
18
12
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
19
|
-
|
|
20
13
|
var isIsolating = function isIsolating(node) {
|
|
21
14
|
return !!node.type.spec.isolating;
|
|
22
15
|
};
|
|
23
|
-
|
|
24
16
|
exports.isIsolating = isIsolating;
|
|
25
|
-
|
|
26
17
|
var containsHeaderColumn = function containsHeaderColumn(table) {
|
|
27
|
-
var map = _tableMap.TableMap.get(table);
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
var map = _tableMap.TableMap.get(table);
|
|
19
|
+
// Get cell positions for first column.
|
|
30
20
|
var cellPositions = map.cellsInRect({
|
|
31
21
|
left: 0,
|
|
32
22
|
top: 0,
|
|
33
23
|
right: 1,
|
|
34
24
|
bottom: map.height
|
|
35
25
|
});
|
|
36
|
-
|
|
37
26
|
for (var i = 0; i < cellPositions.length; i++) {
|
|
38
27
|
try {
|
|
39
28
|
var cell = table.nodeAt(cellPositions[i]);
|
|
40
|
-
|
|
41
29
|
if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
|
|
42
30
|
return false;
|
|
43
31
|
}
|
|
@@ -45,109 +33,78 @@ var containsHeaderColumn = function containsHeaderColumn(table) {
|
|
|
45
33
|
return false;
|
|
46
34
|
}
|
|
47
35
|
}
|
|
48
|
-
|
|
49
36
|
return true;
|
|
50
37
|
};
|
|
51
|
-
|
|
52
38
|
exports.containsHeaderColumn = containsHeaderColumn;
|
|
53
|
-
|
|
54
39
|
var containsHeaderRow = function containsHeaderRow(table) {
|
|
55
40
|
var map = _tableMap.TableMap.get(table);
|
|
56
|
-
|
|
57
41
|
for (var i = 0; i < map.width; i++) {
|
|
58
42
|
var cell = table.nodeAt(map.map[i]);
|
|
59
|
-
|
|
60
43
|
if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
|
|
61
44
|
return false;
|
|
62
45
|
}
|
|
63
46
|
}
|
|
64
|
-
|
|
65
47
|
return true;
|
|
66
48
|
};
|
|
67
|
-
|
|
68
49
|
exports.containsHeaderRow = containsHeaderRow;
|
|
69
|
-
|
|
70
50
|
var checkIfHeaderColumnEnabled = function checkIfHeaderColumnEnabled(selection) {
|
|
71
51
|
return filterNearSelection(selection, _utils.findTable, containsHeaderColumn, false);
|
|
72
52
|
};
|
|
73
|
-
|
|
74
53
|
exports.checkIfHeaderColumnEnabled = checkIfHeaderColumnEnabled;
|
|
75
|
-
|
|
76
54
|
var checkIfHeaderRowEnabled = function checkIfHeaderRowEnabled(selection) {
|
|
77
55
|
return filterNearSelection(selection, _utils.findTable, containsHeaderRow, false);
|
|
78
56
|
};
|
|
79
|
-
|
|
80
57
|
exports.checkIfHeaderRowEnabled = checkIfHeaderRowEnabled;
|
|
81
|
-
|
|
82
58
|
var checkIfNumberColumnEnabled = function checkIfNumberColumnEnabled(selection) {
|
|
83
59
|
return filterNearSelection(selection, _utils.findTable, function (table) {
|
|
84
60
|
return !!table.attrs.isNumberColumnEnabled;
|
|
85
61
|
}, false);
|
|
86
62
|
};
|
|
87
|
-
|
|
88
63
|
exports.checkIfNumberColumnEnabled = checkIfNumberColumnEnabled;
|
|
89
|
-
|
|
90
64
|
var isLayoutSupported = function isLayoutSupported(state) {
|
|
91
65
|
var permittedLayouts = _pluginKey.pluginKey.getState(state).pluginConfig.permittedLayouts;
|
|
92
|
-
|
|
93
66
|
var _state$schema$nodes = state.schema.nodes,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
67
|
+
bodiedExtension = _state$schema$nodes.bodiedExtension,
|
|
68
|
+
layoutSection = _state$schema$nodes.layoutSection,
|
|
69
|
+
expand = _state$schema$nodes.expand;
|
|
97
70
|
return !(0, _prosemirrorUtils.hasParentNodeOfType)([expand, layoutSection, bodiedExtension])(state.selection) && permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-page') > -1);
|
|
98
71
|
};
|
|
99
|
-
|
|
100
72
|
exports.isLayoutSupported = isLayoutSupported;
|
|
101
|
-
|
|
102
73
|
var getTableWidth = function getTableWidth(node) {
|
|
103
74
|
return getTableWidths(node).reduce(function (acc, current) {
|
|
104
75
|
return acc + current;
|
|
105
76
|
}, 0);
|
|
106
77
|
};
|
|
107
|
-
|
|
108
78
|
exports.getTableWidth = getTableWidth;
|
|
109
|
-
|
|
110
79
|
var tablesHaveDifferentColumnWidths = function tablesHaveDifferentColumnWidths(currentTable, previousTable) {
|
|
111
80
|
var currentTableWidths = getTableWidths(currentTable);
|
|
112
81
|
var previousTableWidths = getTableWidths(previousTable);
|
|
113
|
-
|
|
114
82
|
if (currentTableWidths.length !== previousTableWidths.length) {
|
|
115
83
|
return true;
|
|
116
84
|
}
|
|
117
|
-
|
|
118
85
|
var sameWidths = currentTableWidths.every(function (value, index) {
|
|
119
86
|
return value === previousTableWidths[index];
|
|
120
87
|
});
|
|
121
88
|
return sameWidths === false;
|
|
122
89
|
};
|
|
123
|
-
|
|
124
90
|
exports.tablesHaveDifferentColumnWidths = tablesHaveDifferentColumnWidths;
|
|
125
|
-
|
|
126
91
|
var tablesHaveDifferentNoOfColumns = function tablesHaveDifferentNoOfColumns(currentTable, previousTable) {
|
|
127
92
|
var prevMap = _tableMap.TableMap.get(previousTable);
|
|
128
|
-
|
|
129
93
|
var currentMap = _tableMap.TableMap.get(currentTable);
|
|
130
|
-
|
|
131
94
|
return prevMap.width !== currentMap.width;
|
|
132
95
|
};
|
|
133
|
-
|
|
134
96
|
exports.tablesHaveDifferentNoOfColumns = tablesHaveDifferentNoOfColumns;
|
|
135
|
-
|
|
136
97
|
function filterNearSelection(selection, findNode, predicate, defaultValue) {
|
|
137
98
|
var found = findNode(selection);
|
|
138
|
-
|
|
139
99
|
if (!found) {
|
|
140
100
|
return defaultValue;
|
|
141
101
|
}
|
|
142
|
-
|
|
143
102
|
return predicate(found.node, found.pos);
|
|
144
103
|
}
|
|
145
|
-
|
|
146
104
|
function getTableWidths(node) {
|
|
147
105
|
if (!node.content.firstChild) {
|
|
148
106
|
return [];
|
|
149
107
|
}
|
|
150
|
-
|
|
151
108
|
var tableWidths = [];
|
|
152
109
|
node.content.firstChild.content.forEach(function (cell) {
|
|
153
110
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
@@ -1,146 +1,121 @@
|
|
|
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.isHeaderRowRequired = isHeaderRowRequired;
|
|
9
8
|
exports.unwrapContentFromTable = exports.transformSliceToRemoveOpenTable = exports.transformSliceToFixHardBreakProblemOnCopyFromCell = exports.transformSliceToCorrectEmptyTableCells = exports.removeTableFromLastChild = exports.removeTableFromFirstChild = void 0;
|
|
10
|
-
|
|
11
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
-
|
|
13
10
|
var _prosemirrorModel = require("prosemirror-model");
|
|
14
|
-
|
|
15
11
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
16
|
-
|
|
17
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
|
-
|
|
19
13
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
20
|
-
|
|
21
14
|
// lifts up the content of each cell, returning an array of nodes
|
|
22
15
|
var unwrapContentFromTable = function unwrapContentFromTable(maybeTable) {
|
|
23
16
|
var schema = maybeTable.type.schema;
|
|
24
|
-
|
|
25
17
|
if (maybeTable.type === schema.nodes.table) {
|
|
26
18
|
var content = [];
|
|
27
19
|
var _schema$nodes = schema.nodes,
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
tableCell = _schema$nodes.tableCell,
|
|
21
|
+
tableHeader = _schema$nodes.tableHeader;
|
|
30
22
|
maybeTable.descendants(function (maybeCell) {
|
|
31
23
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
32
24
|
content.push.apply(content, (0, _toConsumableArray2.default)((0, _prosemirrorUtils.flatten)(maybeCell, false).map(function (child) {
|
|
33
25
|
return child.node;
|
|
34
26
|
})));
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
return true;
|
|
38
29
|
});
|
|
39
30
|
return content;
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
return maybeTable;
|
|
43
33
|
};
|
|
44
|
-
|
|
45
34
|
exports.unwrapContentFromTable = unwrapContentFromTable;
|
|
46
|
-
|
|
47
35
|
var removeTableFromFirstChild = function removeTableFromFirstChild(node, i) {
|
|
48
36
|
return i === 0 ? unwrapContentFromTable(node) : node;
|
|
49
37
|
};
|
|
50
|
-
|
|
51
38
|
exports.removeTableFromFirstChild = removeTableFromFirstChild;
|
|
52
|
-
|
|
53
39
|
var removeTableFromLastChild = function removeTableFromLastChild(node, i, fragment) {
|
|
54
40
|
return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
|
|
55
41
|
};
|
|
42
|
+
|
|
56
43
|
/**
|
|
57
44
|
* When we copy from a table cell with a hardBreak at the end,
|
|
58
45
|
* the slice generated will come with a hardBreak outside of the table.
|
|
59
46
|
* This code will look for that pattern and fix it.
|
|
60
47
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
48
|
exports.removeTableFromLastChild = removeTableFromLastChild;
|
|
64
|
-
|
|
65
49
|
var transformSliceToFixHardBreakProblemOnCopyFromCell = function transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema) {
|
|
66
50
|
var _schema$nodes2 = schema.nodes,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
paragraph = _schema$nodes2.paragraph,
|
|
52
|
+
table = _schema$nodes2.table,
|
|
53
|
+
hardBreak = _schema$nodes2.hardBreak;
|
|
70
54
|
var emptyParagraphNode = paragraph.createAndFill();
|
|
71
55
|
var hardBreakNode = hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.createAndFill();
|
|
72
56
|
var paragraphNodeSize = emptyParagraphNode ? emptyParagraphNode.nodeSize : 0;
|
|
73
57
|
var hardBreakNodeSize = hardBreakNode ? hardBreakNode.nodeSize : 0;
|
|
74
58
|
var paragraphWithHardBreakSize = paragraphNodeSize + hardBreakNodeSize;
|
|
75
|
-
|
|
76
59
|
if (slice.content.childCount === 2 && slice.content.firstChild && slice.content.lastChild && slice.content.firstChild.type === table && slice.content.lastChild.type === paragraph && slice.content.lastChild.nodeSize === paragraphWithHardBreakSize) {
|
|
77
60
|
var nodes = unwrapContentFromTable(slice.content.firstChild);
|
|
78
|
-
|
|
79
61
|
if (nodes instanceof Array) {
|
|
80
|
-
return new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(
|
|
62
|
+
return new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(
|
|
63
|
+
// keep only the content and discard the hardBreak
|
|
81
64
|
nodes[0]), slice.openStart, slice.openEnd);
|
|
82
65
|
}
|
|
83
66
|
}
|
|
84
|
-
|
|
85
67
|
return slice;
|
|
86
68
|
};
|
|
87
|
-
|
|
88
69
|
exports.transformSliceToFixHardBreakProblemOnCopyFromCell = transformSliceToFixHardBreakProblemOnCopyFromCell;
|
|
89
|
-
|
|
90
70
|
var transformSliceToRemoveOpenTable = function transformSliceToRemoveOpenTable(slice, schema) {
|
|
91
71
|
var _slice$content$firstC6;
|
|
92
|
-
|
|
93
72
|
// we're removing the table, tableRow and tableCell reducing the open depth by 3
|
|
94
|
-
var depthDecrement = 3;
|
|
73
|
+
var depthDecrement = 3;
|
|
95
74
|
|
|
96
|
-
|
|
97
|
-
|
|
75
|
+
// Case 1: A slice entirely within a single CELL
|
|
76
|
+
if (
|
|
77
|
+
// starts and ends inside of a cell
|
|
78
|
+
slice.openStart >= 4 && slice.openEnd >= 4 &&
|
|
79
|
+
// slice is a table node
|
|
98
80
|
slice.content.childCount === 1 && slice.content.firstChild.type === schema.nodes.table) {
|
|
99
81
|
var _slice$content$firstC, _slice$content$firstC2, _slice$content$firstC3, _slice$content$firstC4, _slice$content$firstC5;
|
|
100
|
-
|
|
101
82
|
// prosemirror-view has a bug that it duplicates table entry when selecting multiple paragraphs in a table cell.
|
|
102
83
|
// https://github.com/ProseMirror/prosemirror/issues/1270
|
|
103
84
|
// The structure becomes
|
|
104
85
|
// table(genuine) > tableRow(genuine) > table(duplicated) > tableRow(duplicated) > tableCell/tableHeader(genuine) > contents(genuine)
|
|
105
86
|
// As we are removing wrapping table anyway, we keep duplicated table and tableRow for simplicity
|
|
106
87
|
var cleaned = slice;
|
|
107
|
-
|
|
108
88
|
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : (_slice$content$firstC2 = _slice$content$firstC.content) === null || _slice$content$firstC2 === void 0 ? void 0 : (_slice$content$firstC3 = _slice$content$firstC2.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : (_slice$content$firstC4 = _slice$content$firstC3.content) === null || _slice$content$firstC4 === void 0 ? void 0 : (_slice$content$firstC5 = _slice$content$firstC4.firstChild) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.type) === schema.nodes.table) {
|
|
109
89
|
cleaned = new _prosemirrorModel.Slice(slice.content.firstChild.content.firstChild.content, slice.openStart - 2, slice.openEnd - 2);
|
|
110
90
|
}
|
|
111
|
-
|
|
112
91
|
return new _prosemirrorModel.Slice((0, _utils.flatmap)(cleaned.content, unwrapContentFromTable), cleaned.openStart - depthDecrement, cleaned.openEnd - depthDecrement);
|
|
113
|
-
}
|
|
114
|
-
|
|
92
|
+
}
|
|
115
93
|
|
|
116
|
-
|
|
117
|
-
|
|
94
|
+
// Case 2: A slice starting within a CELL and ending outside the table
|
|
95
|
+
if (
|
|
96
|
+
// starts inside of a cell but ends outside of the starting table
|
|
97
|
+
slice.openStart >= 4 &&
|
|
98
|
+
// slice starts from a table node (and spans across more than one node)
|
|
118
99
|
slice.content.childCount > 1 && ((_slice$content$firstC6 = slice.content.firstChild) === null || _slice$content$firstC6 === void 0 ? void 0 : _slice$content$firstC6.type) === schema.nodes.table) {
|
|
119
100
|
// repoint the slice's cutting depth so that cell content where the slice starts
|
|
120
101
|
// does not get lifted out of the cell on paste
|
|
121
102
|
return new _prosemirrorModel.Slice(slice.content, 1, slice.openEnd);
|
|
122
103
|
}
|
|
123
|
-
|
|
124
104
|
return slice;
|
|
125
105
|
};
|
|
126
|
-
|
|
127
106
|
exports.transformSliceToRemoveOpenTable = transformSliceToRemoveOpenTable;
|
|
128
|
-
|
|
129
107
|
var transformSliceToCorrectEmptyTableCells = function transformSliceToCorrectEmptyTableCells(slice, schema) {
|
|
130
108
|
var _schema$nodes3 = schema.nodes,
|
|
131
|
-
|
|
132
|
-
|
|
109
|
+
tableCell = _schema$nodes3.tableCell,
|
|
110
|
+
tableHeader = _schema$nodes3.tableHeader;
|
|
133
111
|
return (0, _utils.mapSlice)(slice, function (node) {
|
|
134
112
|
if (node && (node.type === tableCell || node.type === tableHeader) && !node.content.childCount) {
|
|
135
113
|
return node.type.createAndFill(node.attrs) || node;
|
|
136
114
|
}
|
|
137
|
-
|
|
138
115
|
return node;
|
|
139
116
|
});
|
|
140
117
|
};
|
|
141
|
-
|
|
142
118
|
exports.transformSliceToCorrectEmptyTableCells = transformSliceToCorrectEmptyTableCells;
|
|
143
|
-
|
|
144
119
|
function isHeaderRowRequired(state) {
|
|
145
120
|
var tableState = (0, _pluginFactory.getPluginState)(state);
|
|
146
121
|
return tableState && tableState.pluginConfig.isHeaderRowRequired;
|
|
@@ -1,42 +1,29 @@
|
|
|
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.isRowDeleteButtonVisible = exports.getRowsParams = exports.getRowHeights = exports.getRowDeleteButtonParams = exports.getRowClassNames = exports.copyPreviousRow = 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 _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
15
|
-
|
|
16
11
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
17
|
-
|
|
18
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
19
|
-
|
|
20
13
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
21
|
-
|
|
22
14
|
var _types = require("../types");
|
|
23
|
-
|
|
24
15
|
var _consts = require("../ui/consts");
|
|
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 getRowHeights = function getRowHeights(tableRef) {
|
|
31
19
|
var heights = [];
|
|
32
|
-
|
|
33
20
|
if (tableRef.lastChild) {
|
|
34
21
|
var rows = tableRef.lastChild.childNodes;
|
|
35
|
-
|
|
36
22
|
for (var i = 0, count = rows.length; i < count; i++) {
|
|
37
23
|
var row = rows[i];
|
|
38
|
-
heights[i] = row.getBoundingClientRect().height + 1;
|
|
24
|
+
heights[i] = row.getBoundingClientRect().height + 1;
|
|
39
25
|
|
|
26
|
+
// padding only gets applied when the container has sticky
|
|
40
27
|
if (row.classList.contains('sticky') && i === 0) {
|
|
41
28
|
var styles = window.getComputedStyle(row);
|
|
42
29
|
var paddingTop = (0, _utils2.parsePx)(styles.paddingTop || '');
|
|
@@ -44,133 +31,99 @@ var getRowHeights = function getRowHeights(tableRef) {
|
|
|
44
31
|
}
|
|
45
32
|
}
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
return heights;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
exports.getRowHeights = getRowHeights;
|
|
52
|
-
|
|
53
37
|
var isRowDeleteButtonVisible = function isRowDeleteButtonVisible(selection) {
|
|
54
38
|
if (!(0, _utils.isTableSelected)(selection) && selection instanceof _cellSelection.CellSelection && selection.isRowSelection()) {
|
|
55
39
|
return true;
|
|
56
40
|
}
|
|
57
|
-
|
|
58
41
|
return false;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
exports.isRowDeleteButtonVisible = isRowDeleteButtonVisible;
|
|
62
|
-
|
|
63
44
|
var getRowDeleteButtonParams = function getRowDeleteButtonParams(rowsHeights, selection) {
|
|
64
45
|
var offsetTop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
65
46
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
66
|
-
|
|
67
47
|
if (!rect) {
|
|
68
48
|
return null;
|
|
69
49
|
}
|
|
70
|
-
|
|
71
50
|
var height = 0;
|
|
72
|
-
var offset = offsetTop;
|
|
73
|
-
|
|
51
|
+
var offset = offsetTop;
|
|
52
|
+
// find the rows before the selection
|
|
74
53
|
for (var i = 0; i < rect.top; i++) {
|
|
75
54
|
var rowHeight = rowsHeights[i];
|
|
76
|
-
|
|
77
55
|
if (rowHeight) {
|
|
78
56
|
offset += rowHeight - 1;
|
|
79
57
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
58
|
+
}
|
|
59
|
+
// these are the selected rows widths
|
|
83
60
|
var indexes = [];
|
|
84
|
-
|
|
85
61
|
for (var _i = rect.top; _i < rect.bottom; _i++) {
|
|
86
62
|
var _rowHeight = rowsHeights[_i];
|
|
87
|
-
|
|
88
63
|
if (_rowHeight) {
|
|
89
64
|
height += _rowHeight - 1;
|
|
90
65
|
indexes.push(_i);
|
|
91
66
|
}
|
|
92
67
|
}
|
|
93
|
-
|
|
94
68
|
var top = offset + height / 2 - _consts.tableDeleteButtonSize / 2;
|
|
95
69
|
return {
|
|
96
70
|
top: top,
|
|
97
71
|
indexes: indexes
|
|
98
72
|
};
|
|
99
73
|
};
|
|
100
|
-
|
|
101
74
|
exports.getRowDeleteButtonParams = getRowDeleteButtonParams;
|
|
102
|
-
|
|
103
75
|
var getRowsParams = function getRowsParams(rowsHeights) {
|
|
104
76
|
var rows = [];
|
|
105
|
-
|
|
106
77
|
for (var i = 0, count = rowsHeights.length; i < count; i++) {
|
|
107
78
|
var height = rowsHeights[i];
|
|
108
|
-
|
|
109
79
|
if (!height) {
|
|
110
80
|
continue;
|
|
111
81
|
}
|
|
112
|
-
|
|
113
82
|
var endIndex = rowsHeights.length;
|
|
114
|
-
|
|
115
83
|
for (var k = i + 1, _count = rowsHeights.length; k < _count; k++) {
|
|
116
84
|
if (rowsHeights[k]) {
|
|
117
85
|
endIndex = k;
|
|
118
86
|
break;
|
|
119
87
|
}
|
|
120
88
|
}
|
|
121
|
-
|
|
122
89
|
rows.push({
|
|
123
90
|
startIndex: i,
|
|
124
91
|
endIndex: endIndex,
|
|
125
92
|
height: height
|
|
126
93
|
});
|
|
127
94
|
}
|
|
128
|
-
|
|
129
95
|
return rows;
|
|
130
96
|
};
|
|
131
|
-
|
|
132
97
|
exports.getRowsParams = getRowsParams;
|
|
133
|
-
|
|
134
98
|
var getRowClassNames = function getRowClassNames(index, selection) {
|
|
135
99
|
var hoveredRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
136
100
|
var isInDanger = arguments.length > 3 ? arguments[3] : undefined;
|
|
137
101
|
var isResizing = arguments.length > 4 ? arguments[4] : undefined;
|
|
138
102
|
var classNames = [];
|
|
139
|
-
|
|
140
103
|
if ((0, _utils.isRowSelected)(index)(selection) || hoveredRows.indexOf(index) > -1 && !isResizing) {
|
|
141
104
|
classNames.push(_types.TableCssClassName.HOVERED_CELL_ACTIVE);
|
|
142
|
-
|
|
143
105
|
if (isInDanger) {
|
|
144
106
|
classNames.push(_types.TableCssClassName.HOVERED_CELL_IN_DANGER);
|
|
145
107
|
}
|
|
146
108
|
}
|
|
147
|
-
|
|
148
109
|
return classNames.join(' ');
|
|
149
110
|
};
|
|
150
|
-
|
|
151
111
|
exports.getRowClassNames = getRowClassNames;
|
|
152
|
-
|
|
153
112
|
var copyPreviousRow = function copyPreviousRow(schema) {
|
|
154
113
|
return function (insertNewRowIndex) {
|
|
155
114
|
return function (tr) {
|
|
156
115
|
var table = (0, _utils.findTable)(tr.selection);
|
|
157
|
-
|
|
158
116
|
if (!table) {
|
|
159
117
|
return tr;
|
|
160
118
|
}
|
|
161
|
-
|
|
162
119
|
var map = _tableMap.TableMap.get(table.node);
|
|
163
|
-
|
|
164
120
|
var copyPreviousRowIndex = insertNewRowIndex - 1;
|
|
165
|
-
|
|
166
121
|
if (insertNewRowIndex <= 0) {
|
|
167
122
|
throw Error("Row Index less or equal 0 isn't not allowed since there is not a previous to copy");
|
|
168
123
|
}
|
|
169
|
-
|
|
170
124
|
if (insertNewRowIndex > map.height) {
|
|
171
125
|
return tr;
|
|
172
126
|
}
|
|
173
|
-
|
|
174
127
|
var tableNode = table.node;
|
|
175
128
|
var tableRow = schema.nodes.tableRow;
|
|
176
129
|
var cellsInRow = map.cellsInRect({
|
|
@@ -185,27 +138,21 @@ var copyPreviousRow = function copyPreviousRow(schema) {
|
|
|
185
138
|
var cellsPositionsInNextRow = map.map.slice(offsetNextLineIndexPosition, offsetNextLineIndexPosition + map.width);
|
|
186
139
|
var cells = [];
|
|
187
140
|
var fixRowspans = [];
|
|
188
|
-
|
|
189
141
|
for (var i = 0; i < cellsPositionsInOriginalRow.length;) {
|
|
190
142
|
var pos = cellsPositionsInOriginalRow[i];
|
|
191
143
|
var documentCellPos = pos + table.start;
|
|
192
144
|
var node = tr.doc.nodeAt(documentCellPos);
|
|
193
|
-
|
|
194
145
|
if (!node) {
|
|
195
146
|
continue;
|
|
196
147
|
}
|
|
197
|
-
|
|
198
148
|
var attributes = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
199
149
|
colspan: 1,
|
|
200
150
|
rowspan: 1
|
|
201
151
|
});
|
|
202
|
-
|
|
203
152
|
var newCell = node.type.createAndFill(attributes);
|
|
204
|
-
|
|
205
153
|
if (!newCell) {
|
|
206
154
|
return tr;
|
|
207
155
|
}
|
|
208
|
-
|
|
209
156
|
if (cellsPositionsInNextRow.indexOf(pos) > -1) {
|
|
210
157
|
fixRowspans.push({
|
|
211
158
|
pos: documentCellPos,
|
|
@@ -216,24 +163,19 @@ var copyPreviousRow = function copyPreviousRow(schema) {
|
|
|
216
163
|
var newCellWithColspanFixed = node.type.createAndFill(_objectSpread(_objectSpread({}, attributes), {}, {
|
|
217
164
|
colspan: node.attrs.colspan
|
|
218
165
|
}));
|
|
219
|
-
|
|
220
166
|
if (!newCellWithColspanFixed) {
|
|
221
167
|
return tr;
|
|
222
168
|
}
|
|
223
|
-
|
|
224
169
|
cells.push(newCellWithColspanFixed);
|
|
225
170
|
i = i + node.attrs.colspan;
|
|
226
171
|
continue;
|
|
227
172
|
}
|
|
228
|
-
|
|
229
173
|
cells.push(newCell);
|
|
230
174
|
} else {
|
|
231
175
|
cells.push(newCell);
|
|
232
176
|
}
|
|
233
|
-
|
|
234
177
|
i++;
|
|
235
178
|
}
|
|
236
|
-
|
|
237
179
|
fixRowspans.forEach(function (cell) {
|
|
238
180
|
tr.setNodeMarkup(cell.pos, undefined, _objectSpread(_objectSpread({}, cell.node.attrs), {}, {
|
|
239
181
|
rowspan: cell.node.attrs.rowspan + 1
|
|
@@ -241,14 +183,11 @@ var copyPreviousRow = function copyPreviousRow(schema) {
|
|
|
241
183
|
});
|
|
242
184
|
var cloneRow = tableNode.child(copyPreviousRowIndex);
|
|
243
185
|
var rowPos = table.start;
|
|
244
|
-
|
|
245
186
|
for (var _i2 = 0; _i2 < insertNewRowIndex; _i2++) {
|
|
246
187
|
rowPos += tableNode.child(_i2).nodeSize;
|
|
247
188
|
}
|
|
248
|
-
|
|
249
189
|
return (0, _prosemirrorUtils.safeInsert)(tableRow.createChecked(cloneRow.attrs, cells, cloneRow.marks), rowPos)(tr);
|
|
250
190
|
};
|
|
251
191
|
};
|
|
252
192
|
};
|
|
253
|
-
|
|
254
193
|
exports.copyPreviousRow = copyPreviousRow;
|