@atlaskit/editor-plugin-table 5.4.9 → 5.4.11
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/misc.js +9 -5
- package/dist/cjs/plugins/table/index.js +52 -49
- package/dist/es2019/plugins/table/commands/misc.js +14 -7
- package/dist/es2019/plugins/table/index.js +22 -16
- package/dist/esm/plugins/table/commands/misc.js +9 -5
- package/dist/esm/plugins/table/index.js +52 -49
- package/package.json +1 -1
- package/src/plugins/table/commands/misc.ts +15 -6
- package/src/plugins/table/index.tsx +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.4.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#58433](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58433) [`4d8e164d7760`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4d8e164d7760) - fix shift + click to expand column / row selection bug when `platform.editor.table.drag-and-drop` is enabled
|
|
8
|
+
|
|
9
|
+
## 5.4.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#58174](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58174) [`b409282ab2b8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b409282ab2b8) - Check pasted slice is a table element before trying to access table map
|
|
14
|
+
|
|
3
15
|
## 5.4.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -181,17 +181,21 @@ var getTableSelectionType = exports.getTableSelectionType = function getTableSel
|
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
var getTableElementMoveTypeBySlice = exports.getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySlice(slice, state) {
|
|
184
|
-
|
|
184
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
185
|
+
tableRow = _state$schema$nodes.tableRow,
|
|
186
|
+
table = _state$schema$nodes.table;
|
|
187
|
+
|
|
188
|
+
// check if copied slice is a table or table row
|
|
189
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
185
190
|
return;
|
|
186
191
|
}
|
|
187
|
-
var schema = state.schema;
|
|
188
192
|
|
|
189
193
|
// if the slice only contains one table row, assume it's a row
|
|
190
|
-
if (slice.content.childCount === 1 && slice.content.firstChild.type ===
|
|
194
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
191
195
|
return 'row';
|
|
192
196
|
}
|
|
193
|
-
var
|
|
194
|
-
var map = _tableMap.TableMap.get(
|
|
197
|
+
var currentTable = (0, _utils2.findTable)(state.tr.selection);
|
|
198
|
+
var map = _tableMap.TableMap.get(currentTable.node);
|
|
195
199
|
var slicedMap = _tableMap.TableMap.get(slice.content.firstChild);
|
|
196
200
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
197
201
|
};
|
|
@@ -154,10 +154,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
154
154
|
}, {
|
|
155
155
|
name: 'tableEditing',
|
|
156
156
|
plugin: function plugin() {
|
|
157
|
+
var _ref6 = options || {},
|
|
158
|
+
dragAndDropEnabled = _ref6.dragAndDropEnabled;
|
|
157
159
|
return (0, _pmPlugins.tableEditing)({
|
|
158
|
-
reportFixedTable: function reportFixedTable(
|
|
159
|
-
var tr =
|
|
160
|
-
reason =
|
|
160
|
+
reportFixedTable: function reportFixedTable(_ref7) {
|
|
161
|
+
var tr = _ref7.tr,
|
|
162
|
+
reason = _ref7.reason;
|
|
161
163
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
162
164
|
action: _analytics.TABLE_ACTION.FIXED,
|
|
163
165
|
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
@@ -167,54 +169,55 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
167
169
|
},
|
|
168
170
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
169
171
|
})(tr);
|
|
170
|
-
}
|
|
172
|
+
},
|
|
173
|
+
dragAndDropEnabled: dragAndDropEnabled
|
|
171
174
|
});
|
|
172
175
|
}
|
|
173
176
|
}, {
|
|
174
177
|
name: 'tableStickyHeaders',
|
|
175
|
-
plugin: function plugin(
|
|
176
|
-
var dispatch =
|
|
177
|
-
eventDispatcher =
|
|
178
|
+
plugin: function plugin(_ref8) {
|
|
179
|
+
var dispatch = _ref8.dispatch,
|
|
180
|
+
eventDispatcher = _ref8.eventDispatcher;
|
|
178
181
|
return options && options.tableOptions.stickyHeaders ? (0, _stickyHeaders.createPlugin)(dispatch, eventDispatcher, function () {
|
|
179
182
|
return [];
|
|
180
183
|
}, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
|
|
181
184
|
}
|
|
182
185
|
}, {
|
|
183
186
|
name: 'tableDragAndDrop',
|
|
184
|
-
plugin: function plugin(
|
|
185
|
-
var dispatch =
|
|
186
|
-
eventDispatcher =
|
|
187
|
+
plugin: function plugin(_ref9) {
|
|
188
|
+
var dispatch = _ref9.dispatch,
|
|
189
|
+
eventDispatcher = _ref9.eventDispatcher;
|
|
187
190
|
return options !== null && options !== void 0 && options.dragAndDropEnabled ? (0, _dragAndDrop.createPlugin)(dispatch, eventDispatcher) : undefined;
|
|
188
191
|
}
|
|
189
192
|
}, {
|
|
190
193
|
name: 'tableLocalId',
|
|
191
|
-
plugin: function plugin(
|
|
192
|
-
var dispatch =
|
|
194
|
+
plugin: function plugin(_ref10) {
|
|
195
|
+
var dispatch = _ref10.dispatch;
|
|
193
196
|
return (0, _tableLocalId.createPlugin)(dispatch);
|
|
194
197
|
}
|
|
195
198
|
}, {
|
|
196
199
|
name: 'tableWidth',
|
|
197
|
-
plugin: function plugin(
|
|
200
|
+
plugin: function plugin(_ref11) {
|
|
198
201
|
var _options$fullWidthEna;
|
|
199
|
-
var dispatchAnalyticsEvent =
|
|
200
|
-
dispatch =
|
|
202
|
+
var dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent,
|
|
203
|
+
dispatch = _ref11.dispatch;
|
|
201
204
|
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;
|
|
202
205
|
}
|
|
203
206
|
},
|
|
204
207
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
205
208
|
{
|
|
206
209
|
name: 'tableOverflowAnalyticsPlugin',
|
|
207
|
-
plugin: function plugin(
|
|
210
|
+
plugin: function plugin(_ref12) {
|
|
208
211
|
var _options$tableResizin;
|
|
209
|
-
var dispatch =
|
|
210
|
-
dispatchAnalyticsEvent =
|
|
212
|
+
var dispatch = _ref12.dispatch,
|
|
213
|
+
dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
|
|
211
214
|
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;
|
|
212
215
|
}
|
|
213
216
|
}, {
|
|
214
217
|
name: 'tableAnalyticsPlugin',
|
|
215
|
-
plugin: function plugin(
|
|
216
|
-
var dispatch =
|
|
217
|
-
dispatchAnalyticsEvent =
|
|
218
|
+
plugin: function plugin(_ref13) {
|
|
219
|
+
var dispatch = _ref13.dispatch,
|
|
220
|
+
dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent;
|
|
218
221
|
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.analytics-plugin-moved-event') ? (0, _plugin.createPlugin)(dispatch, dispatchAnalyticsEvent) : undefined;
|
|
219
222
|
}
|
|
220
223
|
}, {
|
|
@@ -245,12 +248,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
245
248
|
}
|
|
246
249
|
return plugins;
|
|
247
250
|
},
|
|
248
|
-
contentComponent: function contentComponent(
|
|
249
|
-
var editorView =
|
|
250
|
-
popupsMountPoint =
|
|
251
|
-
popupsBoundariesElement =
|
|
252
|
-
popupsScrollableElement =
|
|
253
|
-
dispatchAnalyticsEvent =
|
|
251
|
+
contentComponent: function contentComponent(_ref14) {
|
|
252
|
+
var editorView = _ref14.editorView,
|
|
253
|
+
popupsMountPoint = _ref14.popupsMountPoint,
|
|
254
|
+
popupsBoundariesElement = _ref14.popupsBoundariesElement,
|
|
255
|
+
popupsScrollableElement = _ref14.popupsScrollableElement,
|
|
256
|
+
dispatchAnalyticsEvent = _ref14.dispatchAnalyticsEvent;
|
|
254
257
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
255
258
|
component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
|
|
256
259
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -264,30 +267,30 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
264
267
|
stickyHeadersState: _stickyHeaders.pluginKey,
|
|
265
268
|
dragAndDropState: _dragAndDrop.pluginKey
|
|
266
269
|
},
|
|
267
|
-
render: function render(
|
|
268
|
-
var resizingPluginState =
|
|
269
|
-
stickyHeadersState =
|
|
270
|
-
tablePluginState =
|
|
271
|
-
tableWidthPluginState =
|
|
272
|
-
dragAndDropState =
|
|
270
|
+
render: function render(_ref15) {
|
|
271
|
+
var resizingPluginState = _ref15.tableResizingPluginState,
|
|
272
|
+
stickyHeadersState = _ref15.stickyHeadersState,
|
|
273
|
+
tablePluginState = _ref15.tablePluginState,
|
|
274
|
+
tableWidthPluginState = _ref15.tableWidthPluginState,
|
|
275
|
+
dragAndDropState = _ref15.dragAndDropState;
|
|
273
276
|
var state = editorView.state;
|
|
274
277
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
275
278
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
276
279
|
var isResizing = isColumnResizing || isTableResizing;
|
|
277
|
-
var
|
|
278
|
-
tableNode =
|
|
279
|
-
tablePos =
|
|
280
|
-
targetCellPosition =
|
|
281
|
-
isContextualMenuOpen =
|
|
282
|
-
layout =
|
|
283
|
-
tableRef =
|
|
284
|
-
pluginConfig =
|
|
285
|
-
insertColumnButtonIndex =
|
|
286
|
-
insertRowButtonIndex =
|
|
287
|
-
isHeaderColumnEnabled =
|
|
288
|
-
isHeaderRowEnabled =
|
|
289
|
-
isDragAndDropEnabled =
|
|
290
|
-
tableWrapperTarget =
|
|
280
|
+
var _ref16 = tablePluginState,
|
|
281
|
+
tableNode = _ref16.tableNode,
|
|
282
|
+
tablePos = _ref16.tablePos,
|
|
283
|
+
targetCellPosition = _ref16.targetCellPosition,
|
|
284
|
+
isContextualMenuOpen = _ref16.isContextualMenuOpen,
|
|
285
|
+
layout = _ref16.layout,
|
|
286
|
+
tableRef = _ref16.tableRef,
|
|
287
|
+
pluginConfig = _ref16.pluginConfig,
|
|
288
|
+
insertColumnButtonIndex = _ref16.insertColumnButtonIndex,
|
|
289
|
+
insertRowButtonIndex = _ref16.insertRowButtonIndex,
|
|
290
|
+
isHeaderColumnEnabled = _ref16.isHeaderColumnEnabled,
|
|
291
|
+
isHeaderRowEnabled = _ref16.isHeaderRowEnabled,
|
|
292
|
+
isDragAndDropEnabled = _ref16.isDragAndDropEnabled,
|
|
293
|
+
tableWrapperTarget = _ref16.tableWrapperTarget;
|
|
291
294
|
var allowControls = pluginConfig.allowControls;
|
|
292
295
|
var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
293
296
|
var LayoutContent = options && !options.tableResizingEnabled && (0, _utils3.isLayoutSupported)(state) && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
@@ -365,8 +368,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
365
368
|
}));
|
|
366
369
|
},
|
|
367
370
|
pluginsOptions: {
|
|
368
|
-
quickInsert: function quickInsert(
|
|
369
|
-
var formatMessage =
|
|
371
|
+
quickInsert: function quickInsert(_ref17) {
|
|
372
|
+
var formatMessage = _ref17.formatMessage;
|
|
370
373
|
return [{
|
|
371
374
|
id: 'table',
|
|
372
375
|
title: formatMessage(_messages.toolbarInsertBlockMessages.table),
|
|
@@ -183,19 +183,26 @@ export const getTableSelectionType = selection => {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
export const getTableElementMoveTypeBySlice = (slice, state) => {
|
|
186
|
-
if (!slice.content.firstChild) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
186
|
const {
|
|
190
|
-
schema
|
|
187
|
+
schema: {
|
|
188
|
+
nodes: {
|
|
189
|
+
tableRow,
|
|
190
|
+
table
|
|
191
|
+
}
|
|
192
|
+
}
|
|
191
193
|
} = state;
|
|
192
194
|
|
|
195
|
+
// check if copied slice is a table or table row
|
|
196
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
193
200
|
// if the slice only contains one table row, assume it's a row
|
|
194
|
-
if (slice.content.childCount === 1 && slice.content.firstChild.type ===
|
|
201
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
195
202
|
return 'row';
|
|
196
203
|
}
|
|
197
|
-
const
|
|
198
|
-
const map = TableMap.get(
|
|
204
|
+
const currentTable = findTable(state.tr.selection);
|
|
205
|
+
const map = TableMap.get(currentTable.node);
|
|
199
206
|
const slicedMap = TableMap.get(slice.content.firstChild);
|
|
200
207
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
201
208
|
};
|
|
@@ -142,22 +142,28 @@ const tablesPlugin = ({
|
|
|
142
142
|
plugin: () => tableSelectionKeymapPlugin(api === null || api === void 0 ? void 0 : api.selection)
|
|
143
143
|
}, {
|
|
144
144
|
name: 'tableEditing',
|
|
145
|
-
plugin: () =>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
plugin: () => {
|
|
146
|
+
const {
|
|
147
|
+
dragAndDropEnabled
|
|
148
|
+
} = options || {};
|
|
149
|
+
return tableEditing({
|
|
150
|
+
reportFixedTable: ({
|
|
151
|
+
tr,
|
|
152
|
+
reason
|
|
153
|
+
}) => {
|
|
154
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
155
|
+
action: TABLE_ACTION.FIXED,
|
|
156
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
157
|
+
actionSubjectId: null,
|
|
158
|
+
attributes: {
|
|
159
|
+
reason
|
|
160
|
+
},
|
|
161
|
+
eventType: EVENT_TYPE.TRACK
|
|
162
|
+
})(tr);
|
|
163
|
+
},
|
|
164
|
+
dragAndDropEnabled
|
|
165
|
+
});
|
|
166
|
+
}
|
|
161
167
|
}, {
|
|
162
168
|
name: 'tableStickyHeaders',
|
|
163
169
|
plugin: ({
|
|
@@ -174,17 +174,21 @@ export var getTableSelectionType = function getTableSelectionType(selection) {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
export var getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySlice(slice, state) {
|
|
177
|
-
|
|
177
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
178
|
+
tableRow = _state$schema$nodes.tableRow,
|
|
179
|
+
table = _state$schema$nodes.table;
|
|
180
|
+
|
|
181
|
+
// check if copied slice is a table or table row
|
|
182
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
178
183
|
return;
|
|
179
184
|
}
|
|
180
|
-
var schema = state.schema;
|
|
181
185
|
|
|
182
186
|
// if the slice only contains one table row, assume it's a row
|
|
183
|
-
if (slice.content.childCount === 1 && slice.content.firstChild.type ===
|
|
187
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
184
188
|
return 'row';
|
|
185
189
|
}
|
|
186
|
-
var
|
|
187
|
-
var map = TableMap.get(
|
|
190
|
+
var currentTable = findTable(state.tr.selection);
|
|
191
|
+
var map = TableMap.get(currentTable.node);
|
|
188
192
|
var slicedMap = TableMap.get(slice.content.firstChild);
|
|
189
193
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
190
194
|
};
|
|
@@ -147,10 +147,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
147
147
|
}, {
|
|
148
148
|
name: 'tableEditing',
|
|
149
149
|
plugin: function plugin() {
|
|
150
|
+
var _ref6 = options || {},
|
|
151
|
+
dragAndDropEnabled = _ref6.dragAndDropEnabled;
|
|
150
152
|
return tableEditing({
|
|
151
|
-
reportFixedTable: function reportFixedTable(
|
|
152
|
-
var tr =
|
|
153
|
-
reason =
|
|
153
|
+
reportFixedTable: function reportFixedTable(_ref7) {
|
|
154
|
+
var tr = _ref7.tr,
|
|
155
|
+
reason = _ref7.reason;
|
|
154
156
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
155
157
|
action: TABLE_ACTION.FIXED,
|
|
156
158
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -160,54 +162,55 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
160
162
|
},
|
|
161
163
|
eventType: EVENT_TYPE.TRACK
|
|
162
164
|
})(tr);
|
|
163
|
-
}
|
|
165
|
+
},
|
|
166
|
+
dragAndDropEnabled: dragAndDropEnabled
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
169
|
}, {
|
|
167
170
|
name: 'tableStickyHeaders',
|
|
168
|
-
plugin: function plugin(
|
|
169
|
-
var dispatch =
|
|
170
|
-
eventDispatcher =
|
|
171
|
+
plugin: function plugin(_ref8) {
|
|
172
|
+
var dispatch = _ref8.dispatch,
|
|
173
|
+
eventDispatcher = _ref8.eventDispatcher;
|
|
171
174
|
return options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, function () {
|
|
172
175
|
return [];
|
|
173
176
|
}, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
|
|
174
177
|
}
|
|
175
178
|
}, {
|
|
176
179
|
name: 'tableDragAndDrop',
|
|
177
|
-
plugin: function plugin(
|
|
178
|
-
var dispatch =
|
|
179
|
-
eventDispatcher =
|
|
180
|
+
plugin: function plugin(_ref9) {
|
|
181
|
+
var dispatch = _ref9.dispatch,
|
|
182
|
+
eventDispatcher = _ref9.eventDispatcher;
|
|
180
183
|
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, eventDispatcher) : undefined;
|
|
181
184
|
}
|
|
182
185
|
}, {
|
|
183
186
|
name: 'tableLocalId',
|
|
184
|
-
plugin: function plugin(
|
|
185
|
-
var dispatch =
|
|
187
|
+
plugin: function plugin(_ref10) {
|
|
188
|
+
var dispatch = _ref10.dispatch;
|
|
186
189
|
return createTableLocalIdPlugin(dispatch);
|
|
187
190
|
}
|
|
188
191
|
}, {
|
|
189
192
|
name: 'tableWidth',
|
|
190
|
-
plugin: function plugin(
|
|
193
|
+
plugin: function plugin(_ref11) {
|
|
191
194
|
var _options$fullWidthEna;
|
|
192
|
-
var dispatchAnalyticsEvent =
|
|
193
|
-
dispatch =
|
|
195
|
+
var dispatchAnalyticsEvent = _ref11.dispatchAnalyticsEvent,
|
|
196
|
+
dispatch = _ref11.dispatch;
|
|
194
197
|
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
195
198
|
}
|
|
196
199
|
},
|
|
197
200
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
198
201
|
{
|
|
199
202
|
name: 'tableOverflowAnalyticsPlugin',
|
|
200
|
-
plugin: function plugin(
|
|
203
|
+
plugin: function plugin(_ref12) {
|
|
201
204
|
var _options$tableResizin;
|
|
202
|
-
var dispatch =
|
|
203
|
-
dispatchAnalyticsEvent =
|
|
205
|
+
var dispatch = _ref12.dispatch,
|
|
206
|
+
dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
|
|
204
207
|
return getBooleanFF('platform.editor.table.overflow-state-analytics') ? createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false) : undefined;
|
|
205
208
|
}
|
|
206
209
|
}, {
|
|
207
210
|
name: 'tableAnalyticsPlugin',
|
|
208
|
-
plugin: function plugin(
|
|
209
|
-
var dispatch =
|
|
210
|
-
dispatchAnalyticsEvent =
|
|
211
|
+
plugin: function plugin(_ref13) {
|
|
212
|
+
var dispatch = _ref13.dispatch,
|
|
213
|
+
dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent;
|
|
211
214
|
return getBooleanFF('platform.editor.table.analytics-plugin-moved-event') ? createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent) : undefined;
|
|
212
215
|
}
|
|
213
216
|
}, {
|
|
@@ -238,12 +241,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
238
241
|
}
|
|
239
242
|
return plugins;
|
|
240
243
|
},
|
|
241
|
-
contentComponent: function contentComponent(
|
|
242
|
-
var editorView =
|
|
243
|
-
popupsMountPoint =
|
|
244
|
-
popupsBoundariesElement =
|
|
245
|
-
popupsScrollableElement =
|
|
246
|
-
dispatchAnalyticsEvent =
|
|
244
|
+
contentComponent: function contentComponent(_ref14) {
|
|
245
|
+
var editorView = _ref14.editorView,
|
|
246
|
+
popupsMountPoint = _ref14.popupsMountPoint,
|
|
247
|
+
popupsBoundariesElement = _ref14.popupsBoundariesElement,
|
|
248
|
+
popupsScrollableElement = _ref14.popupsScrollableElement,
|
|
249
|
+
dispatchAnalyticsEvent = _ref14.dispatchAnalyticsEvent;
|
|
247
250
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
248
251
|
component: ACTION_SUBJECT.TABLES_PLUGIN,
|
|
249
252
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -257,30 +260,30 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
257
260
|
stickyHeadersState: stickyHeadersPluginKey,
|
|
258
261
|
dragAndDropState: dragAndDropPluginKey
|
|
259
262
|
},
|
|
260
|
-
render: function render(
|
|
261
|
-
var resizingPluginState =
|
|
262
|
-
stickyHeadersState =
|
|
263
|
-
tablePluginState =
|
|
264
|
-
tableWidthPluginState =
|
|
265
|
-
dragAndDropState =
|
|
263
|
+
render: function render(_ref15) {
|
|
264
|
+
var resizingPluginState = _ref15.tableResizingPluginState,
|
|
265
|
+
stickyHeadersState = _ref15.stickyHeadersState,
|
|
266
|
+
tablePluginState = _ref15.tablePluginState,
|
|
267
|
+
tableWidthPluginState = _ref15.tableWidthPluginState,
|
|
268
|
+
dragAndDropState = _ref15.dragAndDropState;
|
|
266
269
|
var state = editorView.state;
|
|
267
270
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
268
271
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
269
272
|
var isResizing = isColumnResizing || isTableResizing;
|
|
270
|
-
var
|
|
271
|
-
tableNode =
|
|
272
|
-
tablePos =
|
|
273
|
-
targetCellPosition =
|
|
274
|
-
isContextualMenuOpen =
|
|
275
|
-
layout =
|
|
276
|
-
tableRef =
|
|
277
|
-
pluginConfig =
|
|
278
|
-
insertColumnButtonIndex =
|
|
279
|
-
insertRowButtonIndex =
|
|
280
|
-
isHeaderColumnEnabled =
|
|
281
|
-
isHeaderRowEnabled =
|
|
282
|
-
isDragAndDropEnabled =
|
|
283
|
-
tableWrapperTarget =
|
|
273
|
+
var _ref16 = tablePluginState,
|
|
274
|
+
tableNode = _ref16.tableNode,
|
|
275
|
+
tablePos = _ref16.tablePos,
|
|
276
|
+
targetCellPosition = _ref16.targetCellPosition,
|
|
277
|
+
isContextualMenuOpen = _ref16.isContextualMenuOpen,
|
|
278
|
+
layout = _ref16.layout,
|
|
279
|
+
tableRef = _ref16.tableRef,
|
|
280
|
+
pluginConfig = _ref16.pluginConfig,
|
|
281
|
+
insertColumnButtonIndex = _ref16.insertColumnButtonIndex,
|
|
282
|
+
insertRowButtonIndex = _ref16.insertRowButtonIndex,
|
|
283
|
+
isHeaderColumnEnabled = _ref16.isHeaderColumnEnabled,
|
|
284
|
+
isHeaderRowEnabled = _ref16.isHeaderRowEnabled,
|
|
285
|
+
isDragAndDropEnabled = _ref16.isDragAndDropEnabled,
|
|
286
|
+
tableWrapperTarget = _ref16.tableWrapperTarget;
|
|
284
287
|
var allowControls = pluginConfig.allowControls;
|
|
285
288
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
286
289
|
var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
|
|
@@ -358,8 +361,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
358
361
|
}));
|
|
359
362
|
},
|
|
360
363
|
pluginsOptions: {
|
|
361
|
-
quickInsert: function quickInsert(
|
|
362
|
-
var formatMessage =
|
|
364
|
+
quickInsert: function quickInsert(_ref17) {
|
|
365
|
+
var formatMessage = _ref17.formatMessage;
|
|
363
366
|
return [{
|
|
364
367
|
id: 'table',
|
|
365
368
|
title: formatMessage(messages.table),
|
package/package.json
CHANGED
|
@@ -276,22 +276,31 @@ export const getTableElementMoveTypeBySlice = (
|
|
|
276
276
|
slice: Slice,
|
|
277
277
|
state: EditorState,
|
|
278
278
|
) => {
|
|
279
|
-
|
|
279
|
+
const {
|
|
280
|
+
schema: {
|
|
281
|
+
nodes: { tableRow, table },
|
|
282
|
+
},
|
|
283
|
+
} = state;
|
|
284
|
+
|
|
285
|
+
// check if copied slice is a table or table row
|
|
286
|
+
if (
|
|
287
|
+
!slice.content.firstChild ||
|
|
288
|
+
(slice.content.firstChild.type !== table &&
|
|
289
|
+
slice.content.firstChild.type !== tableRow)
|
|
290
|
+
) {
|
|
280
291
|
return;
|
|
281
292
|
}
|
|
282
293
|
|
|
283
|
-
const { schema } = state;
|
|
284
|
-
|
|
285
294
|
// if the slice only contains one table row, assume it's a row
|
|
286
295
|
if (
|
|
287
296
|
slice.content.childCount === 1 &&
|
|
288
|
-
slice.content.firstChild.type ===
|
|
297
|
+
slice.content.firstChild.type === tableRow
|
|
289
298
|
) {
|
|
290
299
|
return 'row';
|
|
291
300
|
}
|
|
292
301
|
|
|
293
|
-
const
|
|
294
|
-
const map = TableMap.get(
|
|
302
|
+
const currentTable = findTable(state.tr.selection)!;
|
|
303
|
+
const map = TableMap.get(currentTable.node);
|
|
295
304
|
const slicedMap = TableMap.get(slice.content.firstChild);
|
|
296
305
|
|
|
297
306
|
return map.width === slicedMap.width
|
|
@@ -238,8 +238,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
name: 'tableEditing',
|
|
241
|
-
plugin: () =>
|
|
242
|
-
|
|
241
|
+
plugin: () => {
|
|
242
|
+
const { dragAndDropEnabled } =
|
|
243
|
+
options || ({} as TablePluginOptions);
|
|
244
|
+
|
|
245
|
+
return tableEditing({
|
|
243
246
|
reportFixedTable: ({
|
|
244
247
|
tr,
|
|
245
248
|
reason,
|
|
@@ -257,7 +260,9 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
257
260
|
eventType: EVENT_TYPE.TRACK,
|
|
258
261
|
})(tr);
|
|
259
262
|
},
|
|
260
|
-
|
|
263
|
+
dragAndDropEnabled,
|
|
264
|
+
}) as SafePlugin;
|
|
265
|
+
},
|
|
261
266
|
},
|
|
262
267
|
{
|
|
263
268
|
name: 'tableStickyHeaders',
|