@atlaskit/editor-plugin-table 5.4.6 → 5.4.8
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/plugins/table/commands/insert.js +12 -2
- package/dist/cjs/plugins/table/commands/misc.js +63 -13
- package/dist/cjs/plugins/table/index.js +46 -35
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +14 -20
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +3 -1
- package/dist/cjs/plugins/table/pm-plugins/analytics/actions.js +14 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/commands.js +45 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin-factory.js +13 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin-key.js +8 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin.js +74 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/reducer.js +26 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/types.js +13 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/utils/moved-event.js +38 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-analytics.js +1 -1
- package/dist/cjs/plugins/table/types.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +6 -9
- package/dist/cjs/plugins/table/ui/ui-styles.js +12 -16
- package/dist/cjs/plugins/table/utils/decoration.js +20 -25
- package/dist/es2019/plugins/table/commands/insert.js +12 -3
- package/dist/es2019/plugins/table/commands/misc.js +54 -4
- package/dist/es2019/plugins/table/index.js +14 -4
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +15 -21
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/table.js +3 -1
- package/dist/es2019/plugins/table/pm-plugins/analytics/actions.js +8 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/commands.js +33 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin-factory.js +8 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin.js +72 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/reducer.js +21 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/types.js +7 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/utils/moved-event.js +30 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +1 -1
- package/dist/es2019/plugins/table/types.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +20 -20
- package/dist/es2019/plugins/table/ui/ui-styles.js +18 -21
- package/dist/es2019/plugins/table/utils/decoration.js +20 -25
- package/dist/esm/plugins/table/commands/insert.js +12 -3
- package/dist/esm/plugins/table/commands/misc.js +61 -13
- package/dist/esm/plugins/table/index.js +43 -32
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +15 -21
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +1 -1
- package/dist/esm/plugins/table/nodeviews/table.js +3 -1
- package/dist/esm/plugins/table/pm-plugins/analytics/actions.js +8 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/commands.js +39 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin-factory.js +8 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin.js +68 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/reducer.js +19 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/types.js +7 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/utils/moved-event.js +31 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-analytics.js +1 -1
- package/dist/esm/plugins/table/types.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/esm/plugins/table/ui/common-styles.js +6 -9
- package/dist/esm/plugins/table/ui/ui-styles.js +12 -16
- package/dist/esm/plugins/table/utils/decoration.js +20 -25
- package/dist/types/plugins/table/commands/misc.d.ts +5 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -0
- package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/analytics/actions.d.ts +17 -0
- package/dist/types/plugins/table/pm-plugins/analytics/commands.d.ts +5 -0
- package/dist/types/plugins/table/pm-plugins/analytics/plugin-factory.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/analytics/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/analytics/plugin.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/analytics/reducer.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/analytics/types.d.ts +11 -0
- package/dist/types/plugins/table/pm-plugins/analytics/utils/moved-event.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types/plugins/table/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/actions.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/commands.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin-factory.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/reducer.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/types.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/utils/moved-event.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -1
- package/package.json +4 -1
- package/src/__tests__/unit/event-handlers.ts +37 -38
- package/src/__tests__/unit/index-with-fake-timers.ts +1 -0
- package/src/__tests__/unit/nodeviews/table.ts +1 -0
- package/src/__tests__/unit/pm-plugins/analytics.ts +327 -0
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -36
- package/src/plugins/table/commands/insert.ts +23 -2
- package/src/plugins/table/commands/misc.ts +93 -8
- package/src/plugins/table/index.tsx +13 -6
- package/src/plugins/table/nodeviews/TableComponent.tsx +35 -44
- package/src/plugins/table/nodeviews/TableResizer.tsx +1 -2
- package/src/plugins/table/nodeviews/table.tsx +4 -0
- package/src/plugins/table/nodeviews/types.ts +2 -0
- package/src/plugins/table/pm-plugins/analytics/actions.ts +23 -0
- package/src/plugins/table/pm-plugins/analytics/commands.ts +53 -0
- package/src/plugins/table/pm-plugins/analytics/plugin-factory.ts +7 -0
- package/src/plugins/table/pm-plugins/analytics/plugin-key.ts +7 -0
- package/src/plugins/table/pm-plugins/analytics/plugin.ts +98 -0
- package/src/plugins/table/pm-plugins/analytics/reducer.ts +27 -0
- package/src/plugins/table/pm-plugins/analytics/types.ts +20 -0
- package/src/plugins/table/pm-plugins/analytics/utils/moved-event.ts +51 -0
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +7 -2
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +20 -11
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +2 -4
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +14 -7
- package/src/plugins/table/pm-plugins/main.ts +1 -0
- package/src/plugins/table/pm-plugins/table-analytics.ts +1 -1
- package/src/plugins/table/types.ts +2 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +73 -67
- package/src/plugins/table/ui/common-styles.ts +20 -23
- package/src/plugins/table/ui/ui-styles.ts +18 -21
- package/src/plugins/table/utils/decoration.ts +27 -32
- package/tsconfig.dev.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.4.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#57815](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/57815) [`5cd97624a19d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5cd97624a19d) - Replace getBooleanFF calls inside stylesheets and replace with isDragAndDrop table option - fixes column controls not rendering in comments
|
|
8
|
+
|
|
9
|
+
## 5.4.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#56725](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/56725) [`4401801c484b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4401801c484b) - Add new rowOrColumnMoved event to table plugin, behind a feature flag
|
|
14
|
+
|
|
3
15
|
## 5.4.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -12,14 +12,14 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
12
12
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
13
13
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
+
var _commands = require("../pm-plugins/analytics/commands");
|
|
15
17
|
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
16
18
|
var _columnWidth = require("../transforms/column-width");
|
|
17
19
|
var _utils3 = require("../utils");
|
|
18
20
|
var _getAllowAddColumnCustomStep = require("../utils/get-allow-add-column-custom-step");
|
|
19
21
|
// #region Imports
|
|
20
22
|
|
|
21
|
-
// #endregion
|
|
22
|
-
|
|
23
23
|
function addColumnAtCustomStep(column) {
|
|
24
24
|
return function (tr) {
|
|
25
25
|
var table = (0, _utils2.findTable)(tr.selection);
|
|
@@ -45,6 +45,11 @@ function addColumnAt(getEditorContainerWidth) {
|
|
|
45
45
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
46
46
|
updatedTr = (0, _columnWidth.rescaleColumns)(getEditorContainerWidth)(table, view)(updatedTr);
|
|
47
47
|
}
|
|
48
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event') && view) {
|
|
49
|
+
updatedTr = (0, _commands.updateRowOrColumnMovedTransform)({
|
|
50
|
+
type: 'column'
|
|
51
|
+
}, 'addRowOrColumn')(view.state, updatedTr);
|
|
52
|
+
}
|
|
48
53
|
updatedTr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
49
54
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.ADDED_COLUMN
|
|
50
55
|
});
|
|
@@ -128,6 +133,11 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
|
|
|
128
133
|
} else {
|
|
129
134
|
tr.setSelection(selection.map(tr.doc, tr.mapping));
|
|
130
135
|
}
|
|
136
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event')) {
|
|
137
|
+
(0, _commands.updateRowOrColumnMovedTransform)({
|
|
138
|
+
type: 'row'
|
|
139
|
+
}, 'addRowOrColumn')(state, tr);
|
|
140
|
+
}
|
|
131
141
|
dispatch(tr);
|
|
132
142
|
}
|
|
133
143
|
return true;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.hideInsertColumnOrRowButton = exports.deleteTableIfSelected = exports.deleteTable = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
7
|
+
exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -20,7 +20,7 @@ var _decoration = require("../utils/decoration");
|
|
|
20
20
|
var _nodes = require("../utils/nodes");
|
|
21
21
|
var _updatePluginStateDecorations = require("../utils/update-plugin-state-decorations");
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
24
|
var setEditorFocus = exports.setEditorFocus = function setEditorFocus(editorHasFocus) {
|
|
25
25
|
return (0, _pluginFactory.createCommand)({
|
|
26
26
|
type: 'SET_EDITOR_FOCUS',
|
|
@@ -37,7 +37,8 @@ var setTableRef = exports.setTableRef = function setTableRef(ref) {
|
|
|
37
37
|
var tablePos = ref && foundTable ? foundTable.pos : undefined;
|
|
38
38
|
var tableWrapperTarget = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
39
39
|
var layout = tableNode ? tableNode.attrs.layout : undefined;
|
|
40
|
-
var
|
|
40
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
41
|
+
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
41
42
|
return {
|
|
42
43
|
type: 'SET_TABLE_REF',
|
|
43
44
|
data: {
|
|
@@ -49,7 +50,8 @@ var setTableRef = exports.setTableRef = function setTableRef(ref) {
|
|
|
49
50
|
isNumberColumnEnabled: (0, _nodes.checkIfNumberColumnEnabled)(state.selection),
|
|
50
51
|
isHeaderRowEnabled: (0, _nodes.checkIfHeaderRowEnabled)(state.selection),
|
|
51
52
|
isHeaderColumnEnabled: (0, _nodes.checkIfHeaderColumnEnabled)(state.selection),
|
|
52
|
-
|
|
53
|
+
// decoration set is drawn by the decoration plugin, skip this for DnD as all controls are floating
|
|
54
|
+
decorationSet: !isDragAndDropEnabled ? (0, _updatePluginStateDecorations.updatePluginStateDecorations)(state, (0, _decoration.createColumnControlsDecoration)(state.selection), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS) : undefined,
|
|
53
55
|
resizeHandleRowIndex: undefined,
|
|
54
56
|
resizeHandleColumnIndex: undefined
|
|
55
57
|
}
|
|
@@ -157,6 +159,54 @@ var transformSliceToRemoveColumnsWidths = exports.transformSliceToRemoveColumnsW
|
|
|
157
159
|
return maybeCell;
|
|
158
160
|
});
|
|
159
161
|
};
|
|
162
|
+
var countCellsInSlice = exports.countCellsInSlice = function countCellsInSlice(slice, schema, type) {
|
|
163
|
+
var _schema$nodes4 = schema.nodes,
|
|
164
|
+
tableHeader = _schema$nodes4.tableHeader,
|
|
165
|
+
tableCell = _schema$nodes4.tableCell;
|
|
166
|
+
var count = 0;
|
|
167
|
+
if (!type) {
|
|
168
|
+
return count;
|
|
169
|
+
}
|
|
170
|
+
slice.content.descendants(function (maybeCell) {
|
|
171
|
+
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
172
|
+
count += type === 'row' ? maybeCell.attrs.colspan : maybeCell.attrs.rowspan;
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return count;
|
|
177
|
+
};
|
|
178
|
+
var getTableSelectionType = exports.getTableSelectionType = function getTableSelectionType(selection) {
|
|
179
|
+
if (selection instanceof _cellSelection.CellSelection) {
|
|
180
|
+
return selection.isRowSelection() ? 'row' : selection.isColSelection() ? 'column' : undefined;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
var getTableElementMoveTypeBySlice = exports.getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySlice(slice, state) {
|
|
184
|
+
if (!slice.content.firstChild) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
var schema = state.schema;
|
|
188
|
+
|
|
189
|
+
// if the slice only contains one table row, assume it's a row
|
|
190
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === schema.nodes.tableRow) {
|
|
191
|
+
return 'row';
|
|
192
|
+
}
|
|
193
|
+
var table = (0, _utils2.findTable)(state.tr.selection);
|
|
194
|
+
var map = _tableMap.TableMap.get(table.node);
|
|
195
|
+
var slicedMap = _tableMap.TableMap.get(slice.content.firstChild);
|
|
196
|
+
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
197
|
+
};
|
|
198
|
+
var isInsideFirstCellOfRowOrColumn = exports.isInsideFirstCellOfRowOrColumn = function isInsideFirstCellOfRowOrColumn(selection, type) {
|
|
199
|
+
var table = (0, _utils2.findTable)(selection);
|
|
200
|
+
if (!table || !type) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
var map = _tableMap.TableMap.get(table.node);
|
|
204
|
+
var cell = (0, _utils2.selectionCell)(selection);
|
|
205
|
+
var index = map.map.findIndex(function (value) {
|
|
206
|
+
return value === cell.pos - 1;
|
|
207
|
+
});
|
|
208
|
+
return type === 'row' ? index % map.width === 0 : index < map.width;
|
|
209
|
+
};
|
|
160
210
|
var deleteTable = exports.deleteTable = function deleteTable(state, dispatch) {
|
|
161
211
|
if (dispatch) {
|
|
162
212
|
dispatch((0, _utils2.removeTable)(state.tr));
|
|
@@ -338,9 +388,9 @@ var hideInsertColumnOrRowButton = exports.hideInsertColumnOrRowButton = function
|
|
|
338
388
|
var addResizeHandleDecorations = exports.addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
339
389
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
340
390
|
var tableNode = (0, _utils2.findTable)(state.selection);
|
|
341
|
-
var
|
|
342
|
-
allowColumnResizing =
|
|
343
|
-
getIntl =
|
|
391
|
+
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
392
|
+
allowColumnResizing = _getPluginState2.pluginConfig.allowColumnResizing,
|
|
393
|
+
getIntl = _getPluginState2.getIntl;
|
|
344
394
|
if (!tableNode || !allowColumnResizing) {
|
|
345
395
|
return false;
|
|
346
396
|
}
|
|
@@ -363,12 +413,12 @@ var addResizeHandleDecorations = exports.addResizeHandleDecorations = function a
|
|
|
363
413
|
var updateResizeHandleDecorations = exports.updateResizeHandleDecorations = function updateResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
364
414
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
365
415
|
var tableNode = (0, _utils2.findTable)(state.selection);
|
|
366
|
-
var
|
|
367
|
-
resizeHandleRowIndex =
|
|
368
|
-
resizeHandleColumnIndex =
|
|
369
|
-
resizeHandleIncludeTooltip =
|
|
370
|
-
allowColumnResizing =
|
|
371
|
-
getIntl =
|
|
416
|
+
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
417
|
+
resizeHandleRowIndex = _getPluginState3.resizeHandleRowIndex,
|
|
418
|
+
resizeHandleColumnIndex = _getPluginState3.resizeHandleColumnIndex,
|
|
419
|
+
resizeHandleIncludeTooltip = _getPluginState3.resizeHandleIncludeTooltip,
|
|
420
|
+
allowColumnResizing = _getPluginState3.pluginConfig.allowColumnResizing,
|
|
421
|
+
getIntl = _getPluginState3.getIntl;
|
|
372
422
|
if (!tableNode || !allowColumnResizing) {
|
|
373
423
|
return false;
|
|
374
424
|
}
|
|
@@ -19,11 +19,13 @@ var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
|
|
|
19
19
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
21
|
var _createPluginConfig = require("./create-plugin-config");
|
|
22
|
-
var _plugin = require("./pm-plugins/
|
|
22
|
+
var _plugin = require("./pm-plugins/analytics/plugin");
|
|
23
|
+
var _pluginKey = require("./pm-plugins/analytics/plugin-key");
|
|
24
|
+
var _plugin2 = require("./pm-plugins/decorations/plugin");
|
|
23
25
|
var _dragAndDrop = require("./pm-plugins/drag-and-drop");
|
|
24
26
|
var _keymap = require("./pm-plugins/keymap");
|
|
25
27
|
var _main = require("./pm-plugins/main");
|
|
26
|
-
var
|
|
28
|
+
var _pluginKey2 = require("./pm-plugins/plugin-key");
|
|
27
29
|
var _safariDeleteCompositionTextIssueWorkaround = require("./pm-plugins/safari-delete-composition-text-issue-workaround");
|
|
28
30
|
var _stickyHeaders = require("./pm-plugins/sticky-headers");
|
|
29
31
|
var _tableAnalytics = require("./pm-plugins/table-analytics");
|
|
@@ -134,7 +136,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
134
136
|
}, {
|
|
135
137
|
name: 'tableEditing',
|
|
136
138
|
plugin: function plugin() {
|
|
137
|
-
return (0,
|
|
139
|
+
return (0, _plugin2.createPlugin)();
|
|
138
140
|
}
|
|
139
141
|
},
|
|
140
142
|
// Needs to be lower priority than editor-tables.tableEditing
|
|
@@ -198,14 +200,23 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
198
200
|
dispatch = _ref10.dispatch;
|
|
199
201
|
return options !== null && options !== void 0 && options.tableResizingEnabled ? (0, _tableWidth.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
200
202
|
}
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
+
},
|
|
204
|
+
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
205
|
+
{
|
|
206
|
+
name: 'tableOverflowAnalyticsPlugin',
|
|
203
207
|
plugin: function plugin(_ref11) {
|
|
204
208
|
var _options$tableResizin;
|
|
205
209
|
var dispatch = _ref11.dispatch,
|
|
206
210
|
dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent;
|
|
207
211
|
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.overflow-state-analytics') ? (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false) : undefined;
|
|
208
212
|
}
|
|
213
|
+
}, {
|
|
214
|
+
name: 'tableAnalyticsPlugin',
|
|
215
|
+
plugin: function plugin(_ref12) {
|
|
216
|
+
var dispatch = _ref12.dispatch,
|
|
217
|
+
dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
|
|
218
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event') ? (0, _plugin.createPlugin)(dispatch, dispatchAnalyticsEvent) : undefined;
|
|
219
|
+
}
|
|
209
220
|
}, {
|
|
210
221
|
name: 'tableGetEditorViewReferencePlugin',
|
|
211
222
|
plugin: function plugin() {
|
|
@@ -234,49 +245,49 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
234
245
|
}
|
|
235
246
|
return plugins;
|
|
236
247
|
},
|
|
237
|
-
contentComponent: function contentComponent(
|
|
238
|
-
var editorView =
|
|
239
|
-
popupsMountPoint =
|
|
240
|
-
popupsBoundariesElement =
|
|
241
|
-
popupsScrollableElement =
|
|
242
|
-
dispatchAnalyticsEvent =
|
|
248
|
+
contentComponent: function contentComponent(_ref13) {
|
|
249
|
+
var editorView = _ref13.editorView,
|
|
250
|
+
popupsMountPoint = _ref13.popupsMountPoint,
|
|
251
|
+
popupsBoundariesElement = _ref13.popupsBoundariesElement,
|
|
252
|
+
popupsScrollableElement = _ref13.popupsScrollableElement,
|
|
253
|
+
dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent;
|
|
243
254
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
244
255
|
component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
|
|
245
256
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
246
257
|
fallbackComponent: null
|
|
247
258
|
}, /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
248
259
|
plugins: {
|
|
249
|
-
tableAnalyticsPluginState:
|
|
250
|
-
tablePluginState:
|
|
260
|
+
tableAnalyticsPluginState: _pluginKey.pluginKey,
|
|
261
|
+
tablePluginState: _pluginKey2.pluginKey,
|
|
251
262
|
tableWidthPluginState: _tableWidth.pluginKey,
|
|
252
263
|
tableResizingPluginState: _tableResizing.pluginKey,
|
|
253
264
|
stickyHeadersState: _stickyHeaders.pluginKey,
|
|
254
265
|
dragAndDropState: _dragAndDrop.pluginKey
|
|
255
266
|
},
|
|
256
|
-
render: function render(
|
|
257
|
-
var resizingPluginState =
|
|
258
|
-
stickyHeadersState =
|
|
259
|
-
tablePluginState =
|
|
260
|
-
tableWidthPluginState =
|
|
261
|
-
dragAndDropState =
|
|
267
|
+
render: function render(_ref14) {
|
|
268
|
+
var resizingPluginState = _ref14.tableResizingPluginState,
|
|
269
|
+
stickyHeadersState = _ref14.stickyHeadersState,
|
|
270
|
+
tablePluginState = _ref14.tablePluginState,
|
|
271
|
+
tableWidthPluginState = _ref14.tableWidthPluginState,
|
|
272
|
+
dragAndDropState = _ref14.dragAndDropState;
|
|
262
273
|
var state = editorView.state;
|
|
263
274
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
264
275
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
265
276
|
var isResizing = isColumnResizing || isTableResizing;
|
|
266
|
-
var
|
|
267
|
-
tableNode =
|
|
268
|
-
tablePos =
|
|
269
|
-
targetCellPosition =
|
|
270
|
-
isContextualMenuOpen =
|
|
271
|
-
layout =
|
|
272
|
-
tableRef =
|
|
273
|
-
pluginConfig =
|
|
274
|
-
insertColumnButtonIndex =
|
|
275
|
-
insertRowButtonIndex =
|
|
276
|
-
isHeaderColumnEnabled =
|
|
277
|
-
isHeaderRowEnabled =
|
|
278
|
-
isDragAndDropEnabled =
|
|
279
|
-
tableWrapperTarget =
|
|
277
|
+
var _ref15 = tablePluginState,
|
|
278
|
+
tableNode = _ref15.tableNode,
|
|
279
|
+
tablePos = _ref15.tablePos,
|
|
280
|
+
targetCellPosition = _ref15.targetCellPosition,
|
|
281
|
+
isContextualMenuOpen = _ref15.isContextualMenuOpen,
|
|
282
|
+
layout = _ref15.layout,
|
|
283
|
+
tableRef = _ref15.tableRef,
|
|
284
|
+
pluginConfig = _ref15.pluginConfig,
|
|
285
|
+
insertColumnButtonIndex = _ref15.insertColumnButtonIndex,
|
|
286
|
+
insertRowButtonIndex = _ref15.insertRowButtonIndex,
|
|
287
|
+
isHeaderColumnEnabled = _ref15.isHeaderColumnEnabled,
|
|
288
|
+
isHeaderRowEnabled = _ref15.isHeaderRowEnabled,
|
|
289
|
+
isDragAndDropEnabled = _ref15.isDragAndDropEnabled,
|
|
290
|
+
tableWrapperTarget = _ref15.tableWrapperTarget;
|
|
280
291
|
var allowControls = pluginConfig.allowControls;
|
|
281
292
|
var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
282
293
|
var LayoutContent = options && !options.tableResizingEnabled && (0, _utils3.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
@@ -354,8 +365,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
354
365
|
}));
|
|
355
366
|
},
|
|
356
367
|
pluginsOptions: {
|
|
357
|
-
quickInsert: function quickInsert(
|
|
358
|
-
var formatMessage =
|
|
368
|
+
quickInsert: function quickInsert(_ref16) {
|
|
369
|
+
var formatMessage = _ref16.formatMessage;
|
|
359
370
|
return [{
|
|
360
371
|
id: 'table',
|
|
361
372
|
title: formatMessage(_messages.toolbarInsertBlockMessages.table),
|
|
@@ -17,7 +17,6 @@ var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
|
17
17
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
18
18
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
19
19
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
20
|
-
var _eventDispatcher = require("@atlaskit/editor-common/event-dispatcher");
|
|
21
20
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
22
21
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
23
22
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -197,25 +196,22 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
197
196
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
|
|
198
197
|
var _this$state;
|
|
199
198
|
var _this$props3 = _this.props,
|
|
200
|
-
|
|
199
|
+
dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
|
|
201
200
|
containerWidth = _this$props3.containerWidth,
|
|
202
201
|
options = _this$props3.options;
|
|
203
|
-
var dispatch = (0, _eventDispatcher.createDispatch)(eventDispatcher);
|
|
204
202
|
var parentWidth = ((_this$state = _this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
|
|
205
203
|
_this.initialOverflowCaptureTimerId = setTimeout(function () {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
parentWidth: parentWidth
|
|
218
|
-
}
|
|
204
|
+
dispatchAnalyticsEvent({
|
|
205
|
+
action: _analytics.TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
|
|
206
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
207
|
+
actionSubjectId: null,
|
|
208
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
209
|
+
attributes: {
|
|
210
|
+
editorWidth: containerWidth.width || 0,
|
|
211
|
+
isOverflowing: isOverflowing,
|
|
212
|
+
tableResizingEnabled: (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) || false,
|
|
213
|
+
width: _this.node.attrs.width || 0,
|
|
214
|
+
parentWidth: parentWidth
|
|
219
215
|
}
|
|
220
216
|
});
|
|
221
217
|
_this.isInitialOverflowSent = true;
|
|
@@ -535,9 +531,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
535
531
|
var tableRef = this.table || undefined;
|
|
536
532
|
var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
537
533
|
var hasHeaderRow = (0, _utils4.containsHeaderRow)(node);
|
|
538
|
-
var rowControls = /*#__PURE__*/_react.default.createElement(
|
|
539
|
-
className: _types.TableCssClassName.ROW_CONTROLS_WRAPPER
|
|
540
|
-
}, /*#__PURE__*/_react.default.createElement(_TableFloatingControls.default, {
|
|
534
|
+
var rowControls = /*#__PURE__*/_react.default.createElement(_TableFloatingControls.default, {
|
|
541
535
|
editorView: view,
|
|
542
536
|
tableRef: tableRef,
|
|
543
537
|
tableNode: node,
|
|
@@ -557,7 +551,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
557
551
|
selection: view.state.selection,
|
|
558
552
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
559
553
|
stickyHeader: this.state.stickyHeader
|
|
560
|
-
})
|
|
554
|
+
});
|
|
561
555
|
var colControls = isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_TableFloatingColumnControls.default, {
|
|
562
556
|
editorView: view,
|
|
563
557
|
tableRef: tableRef,
|
|
@@ -145,10 +145,10 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
145
145
|
isResizing.current = true;
|
|
146
146
|
var dispatch = editorView.dispatch,
|
|
147
147
|
tr = editorView.state.tr;
|
|
148
|
+
displayGapCursor(false);
|
|
148
149
|
tr.setMeta(_tableWidth.pluginKey, {
|
|
149
150
|
resizing: true
|
|
150
151
|
});
|
|
151
|
-
displayGapCursor(false);
|
|
152
152
|
tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
153
153
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
154
154
|
});
|
|
@@ -184,6 +184,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
184
184
|
containerWidth: containerWidth,
|
|
185
185
|
contentDOM: forwardRef,
|
|
186
186
|
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
187
|
+
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
187
188
|
pluginInjectionApi: props.pluginInjectionApi
|
|
188
189
|
});
|
|
189
190
|
}
|
|
@@ -249,7 +250,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
249
250
|
}]);
|
|
250
251
|
return TableView;
|
|
251
252
|
}(_reactNodeView.default);
|
|
252
|
-
var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
|
|
253
|
+
var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
|
|
253
254
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
254
255
|
pluginConfig = _getPluginState2.pluginConfig,
|
|
255
256
|
isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
|
|
@@ -276,6 +277,7 @@ var createTableView = exports.createTableView = function createTableView(node, v
|
|
|
276
277
|
},
|
|
277
278
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
278
279
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
280
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
279
281
|
hasIntlContext: hasIntlContext,
|
|
280
282
|
pluginInjectionApi: pluginInjectionApi
|
|
281
283
|
}).init();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AnalyticPluginTypes = void 0;
|
|
7
|
+
var AnalyticPluginTypes = exports.AnalyticPluginTypes = /*#__PURE__*/function (AnalyticPluginTypes) {
|
|
8
|
+
AnalyticPluginTypes[AnalyticPluginTypes["UpdateOverflowTriggerNameAction"] = 0] = "UpdateOverflowTriggerNameAction";
|
|
9
|
+
AnalyticPluginTypes[AnalyticPluginTypes["UpdateRowOrColumnMovedAction"] = 1] = "UpdateRowOrColumnMovedAction";
|
|
10
|
+
AnalyticPluginTypes[AnalyticPluginTypes["RemoveRowOrColumnMovedAction"] = 2] = "RemoveRowOrColumnMovedAction";
|
|
11
|
+
AnalyticPluginTypes[AnalyticPluginTypes["RemoveOverFlowTriggerNameAction"] = 3] = "RemoveOverFlowTriggerNameAction";
|
|
12
|
+
AnalyticPluginTypes[AnalyticPluginTypes["UpdateRowOrColumnMovedAndOverflowTrigger"] = 4] = "UpdateRowOrColumnMovedAndOverflowTrigger";
|
|
13
|
+
return AnalyticPluginTypes;
|
|
14
|
+
}({});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateRowOrColumnMovedTransform = exports.updateRowOrColumnMoved = exports.resetRowOrColumnMovedTransform = void 0;
|
|
7
|
+
var _actions = require("./actions");
|
|
8
|
+
var _pluginFactory = require("./plugin-factory");
|
|
9
|
+
var _pluginKey = require("./plugin-key");
|
|
10
|
+
var _movedEvent = require("./utils/moved-event");
|
|
11
|
+
var updateRowOrColumnMoved = exports.updateRowOrColumnMoved = function updateRowOrColumnMoved(nextState, nextAction) {
|
|
12
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
13
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
14
|
+
rowOrColumnMoved = _getPluginState.rowOrColumnMoved;
|
|
15
|
+
var data = (0, _movedEvent.getMovedPayload)(nextState, nextAction, rowOrColumnMoved);
|
|
16
|
+
return {
|
|
17
|
+
type: _actions.AnalyticPluginTypes.UpdateRowOrColumnMovedAction,
|
|
18
|
+
data: data
|
|
19
|
+
};
|
|
20
|
+
}, function (tr) {
|
|
21
|
+
return tr.setMeta('addToHistory', false);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// --- transforms, prefer these over commands to avoid an extra 'dispatch'
|
|
26
|
+
var resetRowOrColumnMovedTransform = exports.resetRowOrColumnMovedTransform = function resetRowOrColumnMovedTransform() {
|
|
27
|
+
return function (tr) {
|
|
28
|
+
var payload = {
|
|
29
|
+
type: _actions.AnalyticPluginTypes.RemoveRowOrColumnMovedAction
|
|
30
|
+
};
|
|
31
|
+
return tr.setMeta(_pluginKey.pluginKey, payload);
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
var updateRowOrColumnMovedTransform = exports.updateRowOrColumnMovedTransform = function updateRowOrColumnMovedTransform(nextState, nextAction) {
|
|
35
|
+
return function (state, tr) {
|
|
36
|
+
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
37
|
+
rowOrColumnMoved = _getPluginState2.rowOrColumnMoved;
|
|
38
|
+
var data = (0, _movedEvent.getMovedPayload)(nextState, nextAction, rowOrColumnMoved);
|
|
39
|
+
var payload = {
|
|
40
|
+
type: _actions.AnalyticPluginTypes.UpdateRowOrColumnMovedAction,
|
|
41
|
+
data: data
|
|
42
|
+
};
|
|
43
|
+
return tr.setMeta(_pluginKey.pluginKey, payload);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var _pluginKey = require("./plugin-key");
|
|
9
|
+
var _reducer = require("./reducer");
|
|
10
|
+
var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, _reducer.reducer),
|
|
11
|
+
createPluginState = exports.createPluginState = _pluginFactory.createPluginState,
|
|
12
|
+
createCommand = exports.createCommand = _pluginFactory.createCommand,
|
|
13
|
+
getPluginState = exports.getPluginState = _pluginFactory.getPluginState;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPlugin = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _misc = require("../../commands/misc");
|
|
11
|
+
var _commands = require("./commands");
|
|
12
|
+
var _pluginFactory = require("./plugin-factory");
|
|
13
|
+
var _pluginKey = require("./plugin-key");
|
|
14
|
+
var _types = require("./types");
|
|
15
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent) {
|
|
16
|
+
return new _safePlugin.SafePlugin({
|
|
17
|
+
key: _pluginKey.pluginKey,
|
|
18
|
+
state: (0, _pluginFactory.createPluginState)(dispatch, _types.defaultState),
|
|
19
|
+
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
20
|
+
var tr = transactions.find(function (tr) {
|
|
21
|
+
var _tr$getMeta;
|
|
22
|
+
return (_tr$getMeta = tr.getMeta(_pluginKey.pluginKey)) === null || _tr$getMeta === void 0 || (_tr$getMeta = _tr$getMeta.data) === null || _tr$getMeta === void 0 || (_tr$getMeta = _tr$getMeta.currentActions) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.includes('pasted');
|
|
23
|
+
});
|
|
24
|
+
if (tr) {
|
|
25
|
+
var _tr$getMeta2;
|
|
26
|
+
dispatchAnalyticsEvent({
|
|
27
|
+
action: _analytics.TABLE_ACTION.ROW_OR_COLUMN_MOVED,
|
|
28
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
29
|
+
actionSubjectId: null,
|
|
30
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
31
|
+
attributes: {
|
|
32
|
+
type: (_tr$getMeta2 = tr.getMeta(_pluginKey.pluginKey)) === null || _tr$getMeta2 === void 0 || (_tr$getMeta2 = _tr$getMeta2.data) === null || _tr$getMeta2 === void 0 ? void 0 : _tr$getMeta2.type
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return (0, _commands.resetRowOrColumnMovedTransform)()(tr);
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
},
|
|
39
|
+
props: {
|
|
40
|
+
handlePaste: function handlePaste(_ref, event, slice) {
|
|
41
|
+
var state = _ref.state,
|
|
42
|
+
dispatch = _ref.dispatch;
|
|
43
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event')) {
|
|
44
|
+
var schema = state.schema;
|
|
45
|
+
var type = (0, _misc.getTableElementMoveTypeBySlice)(slice, state);
|
|
46
|
+
|
|
47
|
+
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
48
|
+
if (!(0, _misc.isInsideFirstCellOfRowOrColumn)(state.selection, type)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
var count = (0, _misc.countCellsInSlice)(slice, schema, type);
|
|
52
|
+
(0, _commands.updateRowOrColumnMoved)({
|
|
53
|
+
numberOfCells: count,
|
|
54
|
+
type: type
|
|
55
|
+
}, 'pasted')(state, dispatch);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
transformCopied: function transformCopied(slice, _ref2) {
|
|
59
|
+
var state = _ref2.state,
|
|
60
|
+
dispatch = _ref2.dispatch;
|
|
61
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event')) {
|
|
62
|
+
var schema = state.schema;
|
|
63
|
+
var type = (0, _misc.getTableSelectionType)(state.selection);
|
|
64
|
+
var count = (0, _misc.countCellsInSlice)(slice, schema, type);
|
|
65
|
+
(0, _commands.updateRowOrColumnMoved)({
|
|
66
|
+
numberOfCells: count,
|
|
67
|
+
type: type
|
|
68
|
+
}, 'copyOrCut')(state, dispatch);
|
|
69
|
+
}
|
|
70
|
+
return slice;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.reducer = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _actions = require("./actions");
|
|
10
|
+
var _types = require("./types");
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
var reducer = exports.reducer = function reducer(state, action) {
|
|
14
|
+
switch (action.type) {
|
|
15
|
+
case _actions.AnalyticPluginTypes.UpdateRowOrColumnMovedAction:
|
|
16
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
17
|
+
rowOrColumnMoved: _objectSpread(_objectSpread({}, state.rowOrColumnMoved), action.data)
|
|
18
|
+
});
|
|
19
|
+
case _actions.AnalyticPluginTypes.RemoveRowOrColumnMovedAction:
|
|
20
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
21
|
+
rowOrColumnMoved: _types.defaultState.rowOrColumnMoved
|
|
22
|
+
});
|
|
23
|
+
default:
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultState = void 0;
|
|
7
|
+
var defaultState = exports.defaultState = {
|
|
8
|
+
rowOrColumnMoved: {
|
|
9
|
+
type: undefined,
|
|
10
|
+
numberOfCells: undefined,
|
|
11
|
+
currentActions: []
|
|
12
|
+
}
|
|
13
|
+
};
|