@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,100 +1,80 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
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; }
|
|
5
|
-
|
|
6
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
5
|
import { Selection } from 'prosemirror-state';
|
|
9
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
8
|
import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
12
9
|
import { setMeta } from './metadata';
|
|
13
10
|
import { splitCellsInColumns } from './split';
|
|
14
|
-
|
|
15
11
|
var deleteColumnsCustomStep = function deleteColumnsCustomStep(rect) {
|
|
16
12
|
return function (tr) {
|
|
17
13
|
var table = findTable(tr.selection);
|
|
18
|
-
|
|
19
14
|
if (!table) {
|
|
20
15
|
return tr;
|
|
21
|
-
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Need to split all the merge in the ranges (this is the current behaviour)
|
|
22
19
|
// Maybe is better to split only the last column?
|
|
23
20
|
// TODO: After talking with Roto about this behaviour, he likes when we dont split the columns, I am keeping this for consistency of the current implementation.
|
|
21
|
+
splitCellsInColumns(tr, table.pos, rect.left, rect.right);
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
splitCellsInColumns(tr, table.pos, rect.left, rect.right); // Delete the columns
|
|
27
|
-
|
|
23
|
+
// Delete the columns
|
|
28
24
|
var mapStart = tr.mapping.maps.length;
|
|
29
25
|
var originalDoc = tr.doc;
|
|
30
26
|
var deletedColumns = [];
|
|
31
|
-
|
|
32
27
|
for (var i = rect.left; i < rect.right; i++) {
|
|
33
28
|
var step = AddColumnStep.create(originalDoc, table.pos, i, true);
|
|
34
29
|
deletedColumns.push(i);
|
|
35
30
|
tr.step(step.map(tr.mapping.slice(mapStart)));
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
var tablePosResult = tr.mapping.mapResult(table.pos);
|
|
39
|
-
|
|
40
33
|
if (tablePosResult.deleted) {
|
|
41
34
|
var pos = Math.min(tablePosResult.pos, tr.doc.nodeSize - 1);
|
|
42
35
|
tr.setSelection(Selection.near(tr.doc.resolve(pos)));
|
|
43
36
|
} else {
|
|
44
37
|
var newTable = tr.doc.nodeAt(tablePosResult.pos);
|
|
45
|
-
|
|
46
38
|
if (newTable) {
|
|
47
39
|
var cursorPos = getNextCursorPos(newTable, deletedColumns);
|
|
48
40
|
tr.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
|
|
49
41
|
}
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
return tr;
|
|
53
44
|
};
|
|
54
45
|
};
|
|
55
|
-
|
|
56
46
|
var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
57
47
|
return function (tr) {
|
|
58
48
|
var table = findTable(tr.selection);
|
|
59
|
-
|
|
60
49
|
if (!table) {
|
|
61
50
|
return tr;
|
|
62
51
|
}
|
|
63
|
-
|
|
64
52
|
var columnsToDelete = [];
|
|
65
|
-
|
|
66
53
|
for (var i = rect.left; i < rect.right; i++) {
|
|
67
54
|
columnsToDelete.push(i);
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
if (!columnsToDelete.length) {
|
|
71
57
|
return tr;
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
var map = TableMap.get(table.node);
|
|
75
60
|
var rows = [];
|
|
76
61
|
var seen = {};
|
|
77
62
|
var deletedCells = {};
|
|
78
|
-
|
|
79
63
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
80
64
|
var rowCells = [];
|
|
81
65
|
var row = table.node.child(rowIndex);
|
|
82
|
-
|
|
83
66
|
var _loop = function _loop(colIndex) {
|
|
84
67
|
var cellPos = map.map[rowIndex * map.width + colIndex];
|
|
85
68
|
var cell = table.node.nodeAt(cellPos);
|
|
86
|
-
|
|
87
69
|
if (!cell) {
|
|
88
70
|
return "continue";
|
|
89
71
|
}
|
|
90
|
-
|
|
91
72
|
var cellsInColumn = map.cellsInRect({
|
|
92
73
|
left: colIndex,
|
|
93
74
|
top: 0,
|
|
94
75
|
right: colIndex + 1,
|
|
95
76
|
bottom: map.height
|
|
96
77
|
});
|
|
97
|
-
|
|
98
78
|
if (columnsToDelete.indexOf(colIndex) === -1) {
|
|
99
79
|
// decrement colspans for col-spanning cells that overlap deleted columns
|
|
100
80
|
if (cellsInColumn.indexOf(cellPos) > -1 && !seen[cellPos]) {
|
|
@@ -104,12 +84,10 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
104
84
|
overlappingCols += 1;
|
|
105
85
|
}
|
|
106
86
|
});
|
|
107
|
-
|
|
108
87
|
if (overlappingCols > 0) {
|
|
109
88
|
var attrs = _objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
110
89
|
colspan: cell.attrs.colspan - overlappingCols
|
|
111
90
|
});
|
|
112
|
-
|
|
113
91
|
if (cell.attrs.colwidth) {
|
|
114
92
|
var minColIndex = Math.min.apply(Math, columnsToDelete);
|
|
115
93
|
var pos = minColIndex > 0 ? minColIndex - map.colCount(cellPos) : 0;
|
|
@@ -117,7 +95,6 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
117
95
|
colwidth.splice(pos, overlappingCols);
|
|
118
96
|
attrs.colwidth = colwidth;
|
|
119
97
|
}
|
|
120
|
-
|
|
121
98
|
var newCell = cell.type.createChecked(attrs, cell.content, cell.marks);
|
|
122
99
|
rowCells.push(newCell);
|
|
123
100
|
seen[cellPos] = true;
|
|
@@ -129,20 +106,16 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
129
106
|
colspan: 1,
|
|
130
107
|
rowspan: 1
|
|
131
108
|
});
|
|
132
|
-
|
|
133
109
|
if (cell.attrs.colwidth) {
|
|
134
110
|
var _pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
|
|
135
|
-
|
|
136
111
|
_attrs.colwidth = cell.attrs.colwidth.slice().splice(_pos, 1);
|
|
137
112
|
}
|
|
138
|
-
|
|
139
113
|
var _newCell = cell.type.createChecked(_attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
|
|
140
|
-
|
|
141
114
|
rowCells.push(_newCell);
|
|
142
115
|
return "continue";
|
|
143
|
-
}
|
|
144
|
-
|
|
116
|
+
}
|
|
145
117
|
|
|
118
|
+
// normal cells that we want to keep
|
|
146
119
|
if (!seen[cellPos]) {
|
|
147
120
|
seen[cellPos] = true;
|
|
148
121
|
rowCells.push(cell);
|
|
@@ -151,121 +124,97 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
151
124
|
deletedCells[cellPos] = true;
|
|
152
125
|
}
|
|
153
126
|
};
|
|
154
|
-
|
|
155
127
|
for (var colIndex = 0; colIndex < map.width; colIndex++) {
|
|
156
128
|
var _ret = _loop(colIndex);
|
|
157
|
-
|
|
158
129
|
if (_ret === "continue") continue;
|
|
159
130
|
}
|
|
160
|
-
|
|
161
131
|
if (rowCells.length) {
|
|
162
132
|
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
163
133
|
}
|
|
164
134
|
}
|
|
165
|
-
|
|
166
135
|
if (!rows.length) {
|
|
167
136
|
return setMeta({
|
|
168
137
|
type: 'DELETE_COLUMNS',
|
|
169
138
|
problem: 'EMPTY_TABLE'
|
|
170
139
|
})(tr);
|
|
171
140
|
}
|
|
172
|
-
|
|
173
141
|
var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
|
|
174
142
|
var fixedTable = fixRowSpans(newTable);
|
|
175
|
-
|
|
176
143
|
if (fixedTable === null) {
|
|
177
144
|
return setMeta({
|
|
178
145
|
type: 'DELETE_COLUMNS',
|
|
179
146
|
problem: 'FIX_ROWSPANS'
|
|
180
147
|
})(tr);
|
|
181
148
|
}
|
|
182
|
-
|
|
183
149
|
var cursorPos = getNextCursorPos(newTable, columnsToDelete);
|
|
184
150
|
return setMeta({
|
|
185
151
|
type: 'DELETE_COLUMNS'
|
|
186
|
-
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
152
|
+
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
153
|
+
// move cursor to the left of the deleted columns if possible, otherwise - to the first column
|
|
187
154
|
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
|
|
188
155
|
};
|
|
189
156
|
};
|
|
190
|
-
|
|
191
157
|
function getNextCursorPos(table, deletedColumns) {
|
|
192
158
|
var minColumn = Math.min.apply(Math, _toConsumableArray(deletedColumns));
|
|
193
159
|
var nextColumnWithCursor = minColumn > 0 ? minColumn - 1 : 0;
|
|
194
160
|
var map = TableMap.get(table);
|
|
195
161
|
return map.map[nextColumnWithCursor];
|
|
196
|
-
}
|
|
197
|
-
|
|
162
|
+
}
|
|
198
163
|
|
|
164
|
+
// returns an array of numbers, each number indicates the minimum rowSpan in each row
|
|
199
165
|
function getMinRowSpans(table) {
|
|
200
166
|
var minRowSpans = [];
|
|
201
|
-
|
|
202
167
|
for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
203
168
|
var rowSpans = [];
|
|
204
169
|
var row = table.child(rowIndex);
|
|
205
|
-
|
|
206
170
|
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
207
171
|
var cell = row.child(colIndex);
|
|
208
172
|
rowSpans.push(cell.attrs.rowspan);
|
|
209
173
|
}
|
|
210
|
-
|
|
211
174
|
minRowSpans[rowIndex] = Math.min.apply(Math, rowSpans);
|
|
212
175
|
}
|
|
213
|
-
|
|
214
176
|
return minRowSpans;
|
|
215
177
|
}
|
|
216
|
-
|
|
217
178
|
function fixRowSpans(table) {
|
|
218
179
|
var map = TableMap.get(table);
|
|
219
180
|
var minRowSpans = getMinRowSpans(table);
|
|
220
|
-
|
|
221
181
|
if (!minRowSpans.some(function (rowspan) {
|
|
222
182
|
return rowspan > 1;
|
|
223
183
|
})) {
|
|
224
184
|
return table;
|
|
225
185
|
}
|
|
226
|
-
|
|
227
186
|
var rows = [];
|
|
228
|
-
|
|
229
187
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
230
188
|
var row = table.child(rowIndex);
|
|
231
|
-
|
|
232
189
|
if (minRowSpans[rowIndex] === 1) {
|
|
233
190
|
rows.push(row);
|
|
234
191
|
} else {
|
|
235
192
|
var rowCells = [];
|
|
236
|
-
|
|
237
193
|
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
238
194
|
var cell = row.child(colIndex);
|
|
239
195
|
var rowspan = cell.attrs.rowspan - minRowSpans[rowIndex] + 1;
|
|
240
|
-
|
|
241
196
|
if (rowspan < 1) {
|
|
242
197
|
return null;
|
|
243
198
|
}
|
|
244
|
-
|
|
245
199
|
var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
246
200
|
rowspan: rowspan
|
|
247
201
|
}), cell.content, cell.marks);
|
|
248
202
|
rowCells.push(newCell);
|
|
249
203
|
}
|
|
250
|
-
|
|
251
204
|
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
252
205
|
}
|
|
253
206
|
}
|
|
254
|
-
|
|
255
207
|
if (!rows.length) {
|
|
256
208
|
return null;
|
|
257
209
|
}
|
|
258
|
-
|
|
259
210
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
260
211
|
}
|
|
261
|
-
|
|
262
212
|
export var deleteColumns = function deleteColumns(rect) {
|
|
263
213
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
264
214
|
return function (tr) {
|
|
265
215
|
if (allowAddColumnCustomStep) {
|
|
266
216
|
return deleteColumnsCustomStep(rect)(tr);
|
|
267
217
|
}
|
|
268
|
-
|
|
269
218
|
return deleteColumnsLegacy(rect)(tr);
|
|
270
219
|
};
|
|
271
220
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
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; }
|
|
5
|
-
|
|
6
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
5
|
import { Selection } from 'prosemirror-state';
|
|
9
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -14,19 +11,15 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
14
11
|
var isHeaderRowRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
15
12
|
return function (tr) {
|
|
16
13
|
var table = findTable(tr.selection);
|
|
17
|
-
|
|
18
14
|
if (!table) {
|
|
19
15
|
return tr;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
var rowsToDelete = [];
|
|
23
18
|
var map = TableMap.get(table.node);
|
|
24
|
-
|
|
25
19
|
for (var i = rect.top; i < rect.bottom; i++) {
|
|
26
20
|
// skip header row if its required
|
|
27
21
|
if (isHeaderRowRequired) {
|
|
28
22
|
var cell = table.node.nodeAt(map.map[i * map.width]);
|
|
29
|
-
|
|
30
23
|
if (cell && cell.type !== cell.type.schema.nodes.tableHeader) {
|
|
31
24
|
rowsToDelete.push(i);
|
|
32
25
|
}
|
|
@@ -34,34 +27,27 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
34
27
|
rowsToDelete.push(i);
|
|
35
28
|
}
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
if (!rowsToDelete.length) {
|
|
39
31
|
return tr;
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
var rows = [];
|
|
43
34
|
var seen = {};
|
|
44
35
|
var deletedCells = {};
|
|
45
|
-
|
|
46
36
|
var _loop = function _loop(rowIndex) {
|
|
47
37
|
var rowCells = [];
|
|
48
38
|
var row = table.node.child(rowIndex);
|
|
49
|
-
|
|
50
39
|
var _loop2 = function _loop2(colIndex) {
|
|
51
40
|
var cellPos = map.map[rowIndex * map.width + colIndex];
|
|
52
41
|
var cell = table.node.nodeAt(cellPos);
|
|
53
|
-
|
|
54
42
|
if (!cell) {
|
|
55
43
|
return "continue";
|
|
56
44
|
}
|
|
57
|
-
|
|
58
45
|
var cellsInRow = map.cellsInRect({
|
|
59
46
|
left: 0,
|
|
60
47
|
top: rowIndex,
|
|
61
48
|
right: map.width,
|
|
62
49
|
bottom: rowIndex + 1
|
|
63
50
|
});
|
|
64
|
-
|
|
65
51
|
if (rowsToDelete.indexOf(rowIndex) === -1 && !seen[cellPos]) {
|
|
66
52
|
// decrement rowspans for row-spanning cells that overlap deleted rows
|
|
67
53
|
if (cellsInRow.indexOf(cellPos) > -1) {
|
|
@@ -71,7 +57,6 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
71
57
|
overlappingRows += 1;
|
|
72
58
|
}
|
|
73
59
|
});
|
|
74
|
-
|
|
75
60
|
if (overlappingRows > 0) {
|
|
76
61
|
var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
77
62
|
rowspan: cell.attrs.rowspan - overlappingRows
|
|
@@ -86,19 +71,16 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
86
71
|
colspan: 1,
|
|
87
72
|
rowspan: 1
|
|
88
73
|
});
|
|
89
|
-
|
|
90
74
|
if (cell.attrs.colwidth) {
|
|
91
75
|
var pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
|
|
92
76
|
attrs.colwidth = cell.attrs.colwidth.slice().splice(pos, 1);
|
|
93
77
|
}
|
|
94
|
-
|
|
95
78
|
var _newCell = cell.type.createChecked(attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
|
|
96
|
-
|
|
97
79
|
rowCells.push(_newCell);
|
|
98
80
|
return "continue";
|
|
99
|
-
}
|
|
100
|
-
|
|
81
|
+
}
|
|
101
82
|
|
|
83
|
+
// normal cells that we want to keep
|
|
102
84
|
if (!seen[cellPos]) {
|
|
103
85
|
seen[cellPos] = true;
|
|
104
86
|
rowCells.push(cell);
|
|
@@ -107,47 +89,39 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
107
89
|
deletedCells[cellPos] = true;
|
|
108
90
|
}
|
|
109
91
|
};
|
|
110
|
-
|
|
111
92
|
for (var colIndex = 0; colIndex < map.width; colIndex++) {
|
|
112
93
|
var _ret = _loop2(colIndex);
|
|
113
|
-
|
|
114
94
|
if (_ret === "continue") continue;
|
|
115
95
|
}
|
|
116
|
-
|
|
117
96
|
if (rowCells.length) {
|
|
118
97
|
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
119
98
|
}
|
|
120
99
|
};
|
|
121
|
-
|
|
122
100
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
123
101
|
_loop(rowIndex);
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
if (!rows.length) {
|
|
127
104
|
return setMeta({
|
|
128
105
|
type: 'DELETE_ROWS',
|
|
129
106
|
problem: 'EMPTY_TABLE'
|
|
130
107
|
})(tr);
|
|
131
108
|
}
|
|
132
|
-
|
|
133
109
|
var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
|
|
134
110
|
var fixedTable = removeEmptyColumns(newTable);
|
|
135
|
-
|
|
136
111
|
if (fixedTable === null) {
|
|
137
112
|
return setMeta({
|
|
138
113
|
type: 'DELETE_ROWS',
|
|
139
114
|
problem: 'REMOVE_EMPTY_COLUMNS'
|
|
140
115
|
})(tr);
|
|
141
116
|
}
|
|
142
|
-
|
|
143
117
|
var cursorPos = getNextCursorPos(newTable, rowsToDelete);
|
|
144
118
|
return setMeta({
|
|
145
119
|
type: 'DELETE_ROWS'
|
|
146
|
-
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
120
|
+
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
121
|
+
// move cursor before the deleted rows if possible, otherwise - to the first row
|
|
147
122
|
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
|
|
148
123
|
};
|
|
149
124
|
};
|
|
150
|
-
|
|
151
125
|
function getNextCursorPos(table, deletedRows) {
|
|
152
126
|
var minRow = Math.min.apply(Math, _toConsumableArray(deletedRows));
|
|
153
127
|
var nextRowWithCursor = minRow > 0 ? minRow - 1 : 0;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
8
5
|
import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
9
6
|
import { sendLogs } from '@atlaskit/editor-common/utils';
|
|
@@ -21,12 +18,10 @@ export var fireAnalytics = function fireAnalytics() {
|
|
|
21
18
|
}]
|
|
22
19
|
});
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, reportInvalidTableCellSpanAttrs) {
|
|
26
22
|
var colspan = _ref.colspan,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
rowspan = _ref.rowspan,
|
|
24
|
+
tableLocalId = _ref.tableLocalId;
|
|
30
25
|
if (colspan && colspan < 0) {
|
|
31
26
|
reportInvalidTableCellSpanAttrs({
|
|
32
27
|
nodeType: 'tableCell',
|
|
@@ -36,7 +31,6 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
|
|
|
36
31
|
spanValue: colspan
|
|
37
32
|
});
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
if (rowspan && rowspan < 0) {
|
|
41
35
|
reportInvalidTableCellSpanAttrs({
|
|
42
36
|
nodeType: 'tableCell',
|
|
@@ -46,25 +40,23 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
|
|
|
46
40
|
spanValue: rowspan
|
|
47
41
|
});
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
return;
|
|
51
|
-
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// We attempt to patch the document when we have extra, unneeded, column widths
|
|
52
47
|
// Take this node for example:
|
|
53
48
|
//
|
|
54
49
|
// ['td', { colwidth: [100, 100, 100], colspan: 2 }]
|
|
55
50
|
//
|
|
56
51
|
// This row only spans two columns, yet it contains widths for 3.
|
|
57
52
|
// We remove the third width here, assumed duplicate content.
|
|
58
|
-
|
|
59
|
-
|
|
60
53
|
export var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(node, basePos, tr, reportInvalidTableCellSpanAttrs) {
|
|
61
54
|
var hasProblems = false;
|
|
62
55
|
tr = replaceCells(tr, node, basePos, function (cell) {
|
|
63
56
|
var _cell$attrs = cell.attrs,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
colwidth = _cell$attrs.colwidth,
|
|
58
|
+
colspan = _cell$attrs.colspan,
|
|
59
|
+
rowspan = _cell$attrs.rowspan;
|
|
68
60
|
if (reportInvalidTableCellSpanAttrs) {
|
|
69
61
|
validateTableCellNodeAttrs({
|
|
70
62
|
colspan: colspan,
|
|
@@ -72,24 +64,20 @@ export var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(
|
|
|
72
64
|
tableLocalId: node.attrs.localId
|
|
73
65
|
}, reportInvalidTableCellSpanAttrs);
|
|
74
66
|
}
|
|
75
|
-
|
|
76
67
|
if (colwidth && colwidth.length > colspan) {
|
|
77
68
|
hasProblems = true;
|
|
78
69
|
return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
79
70
|
colwidth: colwidth.slice(0, colspan)
|
|
80
71
|
}), cell.content, cell.marks);
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
return cell;
|
|
84
74
|
});
|
|
85
|
-
|
|
86
75
|
if (hasProblems) {
|
|
87
76
|
fireAnalytics({
|
|
88
77
|
message: 'removeExtraneousColumnWidths'
|
|
89
78
|
});
|
|
90
79
|
return true;
|
|
91
80
|
}
|
|
92
|
-
|
|
93
81
|
return false;
|
|
94
82
|
};
|
|
95
83
|
export var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
|
|
@@ -100,11 +88,12 @@ export var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
|
|
|
100
88
|
hasProblems = removeExtraneousColumnWidths(node, tr.mapping.map(pos), tr, reportInvalidTableCellSpanAttrs);
|
|
101
89
|
}
|
|
102
90
|
});
|
|
103
|
-
|
|
104
91
|
if (hasProblems) {
|
|
105
92
|
return tr;
|
|
106
93
|
}
|
|
107
|
-
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// When we get a table with an 'auto' attribute, we want to:
|
|
108
97
|
// 1. render with table-layout: auto
|
|
109
98
|
// 2. capture the column widths
|
|
110
99
|
// 3. set the column widths as attributes, and remove the 'auto' attribute,
|
|
@@ -115,7 +104,6 @@ export var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
|
|
|
115
104
|
//
|
|
116
105
|
// We use this when migrating TinyMCE tables for Confluence, for example:
|
|
117
106
|
// https://pug.jira-dev.com/wiki/spaces/AEC/pages/3362882215/How+do+we+map+TinyMCE+tables+to+Fabric+tables
|
|
118
|
-
|
|
119
107
|
export var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, tableRef, tablePos, opts) {
|
|
120
108
|
var tr = view.state.tr;
|
|
121
109
|
var domAtPos = view.domAtPos.bind(view);
|
|
@@ -125,16 +113,15 @@ export var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, table
|
|
|
125
113
|
return acc + current;
|
|
126
114
|
}, 0);
|
|
127
115
|
var tableLayout = getLayoutBasedOnWidth(totalContentWidth);
|
|
128
|
-
var maxLayoutSize = getLayoutSize(tableLayout, opts.containerWidth, {});
|
|
116
|
+
var maxLayoutSize = getLayoutSize(tableLayout, opts.containerWidth, {});
|
|
117
|
+
|
|
118
|
+
// Content width will generally not meet the constraints of the layout
|
|
129
119
|
// whether it be below or above, so we scale our columns widths
|
|
130
120
|
// to meet these requirements
|
|
131
|
-
|
|
132
121
|
var scale = 1;
|
|
133
|
-
|
|
134
122
|
if (totalContentWidth !== maxLayoutSize) {
|
|
135
123
|
scale = maxLayoutSize / totalContentWidth;
|
|
136
124
|
}
|
|
137
|
-
|
|
138
125
|
var scaledColumnWidths = colWidths.map(function (width) {
|
|
139
126
|
return Math.floor(width * scale);
|
|
140
127
|
});
|
|
@@ -143,14 +130,14 @@ export var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, table
|
|
|
143
130
|
return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
144
131
|
colwidth: newColWidths.length ? newColWidths : null
|
|
145
132
|
}), cell.content, cell.marks);
|
|
146
|
-
});
|
|
133
|
+
});
|
|
147
134
|
|
|
135
|
+
// clear autosizing on the table node
|
|
148
136
|
return tr.setNodeMarkup(tablePos, undefined, _objectSpread(_objectSpread({}, tableNode.attrs), {}, {
|
|
149
137
|
layout: tableLayout,
|
|
150
138
|
__autoSize: false
|
|
151
139
|
})).setMeta('addToHistory', false);
|
|
152
140
|
};
|
|
153
|
-
|
|
154
141
|
var getLayoutBasedOnWidth = function getLayoutBasedOnWidth(totalWidth) {
|
|
155
142
|
if (totalWidth > akEditorWideLayoutWidth) {
|
|
156
143
|
return 'full-width';
|
|
@@ -160,20 +147,15 @@ var getLayoutBasedOnWidth = function getLayoutBasedOnWidth(totalWidth) {
|
|
|
160
147
|
return 'default';
|
|
161
148
|
}
|
|
162
149
|
};
|
|
163
|
-
|
|
164
150
|
function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
|
|
165
151
|
var row = tableRef.querySelector('tr');
|
|
166
|
-
|
|
167
152
|
if (!row) {
|
|
168
153
|
return [];
|
|
169
154
|
}
|
|
170
|
-
|
|
171
155
|
var cols = [];
|
|
172
|
-
|
|
173
156
|
for (var col = 0; col < row.childElementCount; col++) {
|
|
174
157
|
var currentCol = row.children[col];
|
|
175
158
|
var colspan = Number(currentCol.getAttribute('colspan') || 1);
|
|
176
|
-
|
|
177
159
|
for (var span = 0; span < colspan; span++) {
|
|
178
160
|
var colIdx = col + span;
|
|
179
161
|
var cells = getCellsRefsInColumn(colIdx, tableNode, tableStart, domAtPos);
|
|
@@ -183,45 +165,38 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
|
|
|
183
165
|
cols[colIdx] = Math.max(colWidth, tableCellMinWidth);
|
|
184
166
|
}
|
|
185
167
|
}
|
|
186
|
-
|
|
187
168
|
return cols;
|
|
188
|
-
}
|
|
189
|
-
|
|
169
|
+
}
|
|
190
170
|
|
|
171
|
+
// TODO: move to prosemirror-utils
|
|
191
172
|
var replaceCells = function replaceCells(tr, table, tablePos, modifyCell) {
|
|
192
173
|
var rows = [];
|
|
193
174
|
var modifiedCells = 0;
|
|
194
|
-
|
|
195
175
|
for (var _rowIndex2 = 0; _rowIndex2 < table.childCount; _rowIndex2++) {
|
|
196
176
|
var row = table.child(_rowIndex2);
|
|
197
177
|
var cells = [];
|
|
198
|
-
|
|
199
178
|
for (var _colIndex = 0; _colIndex < row.childCount; _colIndex++) {
|
|
200
|
-
var _cell = row.child(_colIndex);
|
|
179
|
+
var _cell = row.child(_colIndex);
|
|
180
|
+
|
|
181
|
+
// FIXME
|
|
201
182
|
// The rowIndex and colIndex are not accurate in a merged cell scenario
|
|
202
183
|
// e.g. table with 5 columns might have only one cell in a row, colIndex will be 1, where it should be 4
|
|
203
|
-
|
|
204
|
-
|
|
205
184
|
var node = modifyCell(_cell, _rowIndex2, _colIndex);
|
|
206
|
-
|
|
207
185
|
if (node.sameMarkup(_cell) === false) {
|
|
208
186
|
modifiedCells++;
|
|
209
187
|
}
|
|
210
|
-
|
|
211
188
|
cells.push(node);
|
|
212
189
|
}
|
|
213
|
-
|
|
214
190
|
if (cells.length) {
|
|
215
191
|
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
216
192
|
}
|
|
217
|
-
}
|
|
218
|
-
// If no cells are modified our counter will be zero.
|
|
219
|
-
|
|
193
|
+
}
|
|
220
194
|
|
|
195
|
+
// Check if the table has changed before replacing.
|
|
196
|
+
// If no cells are modified our counter will be zero.
|
|
221
197
|
if (rows.length && modifiedCells !== 0) {
|
|
222
198
|
var newTable = table.type.createChecked(table.attrs, rows, table.marks);
|
|
223
199
|
return tr.replaceWith(tablePos, tablePos + table.nodeSize, newTable);
|
|
224
200
|
}
|
|
225
|
-
|
|
226
201
|
return tr;
|
|
227
202
|
};
|