@atlaskit/editor-plugin-table 7.31.2 → 8.0.0
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 +92 -0
- package/dist/cjs/commands/insert.js +16 -19
- package/dist/cjs/commands-with-analytics.js +5 -7
- package/dist/cjs/event-handlers.js +12 -1
- package/dist/cjs/nodeviews/TableComponent.js +18 -15
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/cjs/nodeviews/lazy-node-views.js +2 -3
- package/dist/cjs/nodeviews/table.js +16 -12
- package/dist/cjs/plugin.js +22 -28
- package/dist/cjs/pm-plugins/keymap.js +9 -10
- package/dist/cjs/pm-plugins/main.js +3 -5
- package/dist/cjs/toolbar.js +10 -13
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -7
- package/dist/cjs/utils/drag-menu.js +6 -7
- package/dist/es2019/commands/insert.js +10 -10
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/event-handlers.js +12 -1
- package/dist/es2019/nodeviews/TableComponent.js +18 -15
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/es2019/nodeviews/lazy-node-views.js +2 -3
- package/dist/es2019/nodeviews/table.js +16 -12
- package/dist/es2019/plugin.js +22 -26
- package/dist/es2019/pm-plugins/keymap.js +5 -5
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/toolbar.js +6 -7
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -3
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +2 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +3 -6
- package/dist/es2019/utils/drag-menu.js +3 -3
- package/dist/esm/commands/insert.js +16 -19
- package/dist/esm/commands-with-analytics.js +5 -7
- package/dist/esm/event-handlers.js +12 -1
- package/dist/esm/nodeviews/TableComponent.js +18 -15
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/esm/nodeviews/lazy-node-views.js +2 -3
- package/dist/esm/nodeviews/table.js +16 -12
- package/dist/esm/plugin.js +22 -28
- package/dist/esm/pm-plugins/keymap.js +9 -10
- package/dist/esm/pm-plugins/main.js +3 -5
- package/dist/esm/toolbar.js +10 -13
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +2 -4
- package/dist/esm/ui/FloatingInsertButton/index.js +3 -7
- package/dist/esm/utils/drag-menu.js +6 -7
- package/dist/types/commands/insert.d.ts +5 -5
- package/dist/types/commands-with-analytics.d.ts +3 -4
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +3 -1
- package/dist/types/nodeviews/lazy-node-views.d.ts +0 -1
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +2 -2
- package/dist/types/plugin.d.ts +1 -3
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/toolbar.d.ts +1 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +5 -5
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -4
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +2 -2
- package/dist/types-ts4.5/plugin.d.ts +1 -3
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -3
- package/src/commands/insert.ts +3 -10
- package/src/commands-with-analytics.ts +7 -8
- package/src/event-handlers.ts +17 -1
- package/src/nodeviews/TableComponent.tsx +22 -16
- package/src/nodeviews/TableComponentWithSharedState.tsx +6 -1
- package/src/nodeviews/lazy-node-views.ts +0 -4
- package/src/nodeviews/table.tsx +13 -8
- package/src/nodeviews/types.ts +2 -2
- package/src/plugin.tsx +24 -35
- package/src/pm-plugins/keymap.ts +0 -5
- package/src/pm-plugins/main.ts +2 -6
- package/src/toolbar.tsx +1 -9
- package/src/types.ts +2 -1
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +7 -10
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -3
- package/src/ui/FloatingDragMenu/index.tsx +1 -3
- package/src/ui/FloatingInsertButton/index.tsx +5 -10
- package/src/utils/drag-menu.ts +4 -9
package/dist/cjs/plugin.js
CHANGED
|
@@ -66,7 +66,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
66
66
|
* from `@atlaskit/editor-core`.
|
|
67
67
|
*/
|
|
68
68
|
var tablesPlugin = function tablesPlugin(_ref) {
|
|
69
|
-
var _api$analytics, _api$accessibilityUti, _options$getEditorFea,
|
|
69
|
+
var _api$analytics, _api$accessibilityUti, _options$getEditorFea, _api$analytics2;
|
|
70
70
|
var options = _ref.config,
|
|
71
71
|
api = _ref.api;
|
|
72
72
|
var editorViewRef = {
|
|
@@ -83,7 +83,6 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
83
83
|
var isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 || (_options$getEditorFea = options.getEditorFeatureFlags) === null || _options$getEditorFea === void 0 ? void 0 : _options$getEditorFea.call(options).tableWithFixedColumnWidthsOption) || false;
|
|
84
84
|
var shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (isTableFixedColumnWidthsOptionEnabled || ( // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
85
85
|
options === null || options === void 0 ? void 0 : options.isCommentEditor));
|
|
86
|
-
var isCellBackgroundDuplicated = (options === null || options === void 0 || (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableDuplicateCellColouring) || false;
|
|
87
86
|
return {
|
|
88
87
|
name: 'table',
|
|
89
88
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
@@ -120,11 +119,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
120
119
|
var _api$contentInsertion, _api$contentInsertion2;
|
|
121
120
|
var node = (0, _utils2.createTableWithWidth)({
|
|
122
121
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
123
|
-
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.
|
|
122
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
124
123
|
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.fullWidthEnabled,
|
|
125
124
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
126
125
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
127
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.
|
|
126
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing
|
|
128
127
|
})(state.schema);
|
|
129
128
|
|
|
130
129
|
// If the cursor is inside a table
|
|
@@ -159,7 +158,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
159
158
|
}
|
|
160
159
|
},
|
|
161
160
|
commands: {
|
|
162
|
-
insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.
|
|
161
|
+
insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
163
162
|
},
|
|
164
163
|
nodes: function nodes() {
|
|
165
164
|
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions),
|
|
@@ -169,7 +168,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
169
168
|
name: 'table',
|
|
170
169
|
node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
|
|
171
170
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
172
|
-
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.
|
|
171
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
173
172
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
174
173
|
isNestingSupported: isNestingSupported
|
|
175
174
|
})
|
|
@@ -186,7 +185,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
186
185
|
name: 'table',
|
|
187
186
|
node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
|
|
188
187
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
189
|
-
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.
|
|
188
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
190
189
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
191
190
|
isNestingSupported: isNestingSupported
|
|
192
191
|
})
|
|
@@ -214,15 +213,13 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
214
213
|
var _ref3 = options || {},
|
|
215
214
|
fullWidthEnabled = _ref3.fullWidthEnabled,
|
|
216
215
|
wasFullWidthEnabled = _ref3.wasFullWidthEnabled,
|
|
217
|
-
tableResizingEnabled = _ref3.tableResizingEnabled,
|
|
218
216
|
tableOptions = _ref3.tableOptions,
|
|
219
217
|
getEditorFeatureFlags = _ref3.getEditorFeatureFlags,
|
|
220
218
|
dragAndDropEnabled = _ref3.dragAndDropEnabled,
|
|
221
219
|
isTableScalingEnabled = _ref3.isTableScalingEnabled,
|
|
222
|
-
isTableAlignmentEnabled = _ref3.isTableAlignmentEnabled,
|
|
223
220
|
isCommentEditor = _ref3.isCommentEditor,
|
|
224
221
|
isChromelessEditor = _ref3.isChromelessEditor;
|
|
225
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl,
|
|
222
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor);
|
|
226
223
|
}
|
|
227
224
|
}, {
|
|
228
225
|
name: 'tablePMColResizing',
|
|
@@ -234,13 +231,13 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
234
231
|
tableOptions = _ref5.tableOptions,
|
|
235
232
|
getEditorFeatureFlags = _ref5.getEditorFeatureFlags,
|
|
236
233
|
isTableScalingEnabled = _ref5.isTableScalingEnabled,
|
|
237
|
-
isNewColumnResizingEnabled = _ref5.isNewColumnResizingEnabled
|
|
238
|
-
isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled;
|
|
234
|
+
isNewColumnResizingEnabled = _ref5.isNewColumnResizingEnabled;
|
|
239
235
|
var _pluginConfig2 = (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
240
|
-
allowColumnResizing = _pluginConfig2.allowColumnResizing
|
|
236
|
+
allowColumnResizing = _pluginConfig2.allowColumnResizing,
|
|
237
|
+
allowTableAlignment = _pluginConfig2.allowTableAlignment;
|
|
241
238
|
return allowColumnResizing ? (0, _tableResizing.createPlugin)(dispatch, {
|
|
242
239
|
lastColumnResizable: !fullWidthEnabled
|
|
243
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled,
|
|
240
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, allowTableAlignment, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
244
241
|
}
|
|
245
242
|
}, {
|
|
246
243
|
name: 'tableEditing',
|
|
@@ -259,17 +256,14 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
259
256
|
dragAndDropEnabled = _ref7.dragAndDropEnabled,
|
|
260
257
|
_ref7$isTableScalingE = _ref7.isTableScalingEnabled,
|
|
261
258
|
isTableScalingEnabled = _ref7$isTableScalingE === void 0 ? false : _ref7$isTableScalingE,
|
|
262
|
-
_ref7$isTableAlignmen = _ref7.isTableAlignmentEnabled,
|
|
263
|
-
isTableAlignmentEnabled = _ref7$isTableAlignmen === void 0 ? false : _ref7$isTableAlignmen,
|
|
264
259
|
_ref7$fullWidthEnable = _ref7.fullWidthEnabled,
|
|
265
260
|
fullWidthEnabled = _ref7$fullWidthEnable === void 0 ? false : _ref7$fullWidthEnable,
|
|
266
261
|
_ref7$isCommentEditor = _ref7.isCommentEditor,
|
|
267
262
|
isCommentEditor = _ref7$isCommentEditor === void 0 ? false : _ref7$isCommentEditor,
|
|
268
263
|
_ref7$isChromelessEdi = _ref7.isChromelessEditor,
|
|
269
264
|
isChromelessEditor = _ref7$isChromelessEdi === void 0 ? false : _ref7$isChromelessEdi,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, tableResizingEnabled);
|
|
265
|
+
tableOptions = _ref7.tableOptions;
|
|
266
|
+
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.allowTableAlignment, fullWidthEnabled, api, getIntl, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.allowTableResizing);
|
|
273
267
|
}
|
|
274
268
|
}, {
|
|
275
269
|
name: 'tableSelectionKeymap',
|
|
@@ -329,27 +323,27 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
329
323
|
}, {
|
|
330
324
|
name: 'tableWidth',
|
|
331
325
|
plugin: function plugin(_ref15) {
|
|
332
|
-
var _options$fullWidthEna, _options$isTableScali, _options$
|
|
326
|
+
var _options$fullWidthEna, _options$isTableScali, _options$tableOptions, _options$isCommentEdi;
|
|
333
327
|
var dispatchAnalyticsEvent = _ref15.dispatchAnalyticsEvent,
|
|
334
328
|
dispatch = _ref15.dispatch;
|
|
335
|
-
return options !== null && options !== void 0 && options.
|
|
329
|
+
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing ? (0, _tableWidth.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$tableOptions = options.tableOptions.allowTableResizing) !== null && _options$tableOptions !== void 0 ? _options$tableOptions : false, (_options$isCommentEdi = options.isCommentEditor) !== null && _options$isCommentEdi !== void 0 ? _options$isCommentEdi : false) : undefined;
|
|
336
330
|
}
|
|
337
331
|
}, {
|
|
338
332
|
name: 'tableWidthInCommentFix',
|
|
339
333
|
plugin: function plugin(_ref16) {
|
|
340
|
-
var _options$
|
|
334
|
+
var _options$tableOptions2;
|
|
341
335
|
var dispatch = _ref16.dispatch;
|
|
342
|
-
return options !== null && options !== void 0 && options.
|
|
336
|
+
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing && options !== null && options !== void 0 && options.isCommentEditor ? (0, _tableWidthInCommentFix.createPlugin)(dispatch, (_options$tableOptions2 = options.tableOptions.allowTableAlignment) !== null && _options$tableOptions2 !== void 0 ? _options$tableOptions2 : false) : undefined;
|
|
343
337
|
}
|
|
344
338
|
},
|
|
345
339
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
346
340
|
{
|
|
347
341
|
name: 'tableOverflowAnalyticsPlugin',
|
|
348
342
|
plugin: function plugin(_ref17) {
|
|
349
|
-
var _options$
|
|
343
|
+
var _options$tableOptions3;
|
|
350
344
|
var dispatch = _ref17.dispatch,
|
|
351
345
|
dispatchAnalyticsEvent = _ref17.dispatchAnalyticsEvent;
|
|
352
|
-
return (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$
|
|
346
|
+
return (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$tableOptions3 = options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) !== null && _options$tableOptions3 !== void 0 ? _options$tableOptions3 : false);
|
|
353
347
|
}
|
|
354
348
|
}, {
|
|
355
349
|
name: 'tableAnalyticsPlugin',
|
|
@@ -512,7 +506,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
512
506
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
513
507
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
514
508
|
api: api
|
|
515
|
-
}), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.
|
|
509
|
+
}), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) && options.isCommentEditor) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/_react.default.createElement(_FloatingToolbarLabel.FloatingToolbarLabel, {
|
|
516
510
|
target: resizingTableRef,
|
|
517
511
|
content: /*#__PURE__*/_react.default.createElement(_TableFullWidthLabel.FullWidthDisplay, null),
|
|
518
512
|
alignX: 'center',
|
|
@@ -544,11 +538,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
544
538
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
545
539
|
var tableNode = (0, _utils2.createTableWithWidth)({
|
|
546
540
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
547
|
-
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.
|
|
541
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
548
542
|
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
|
|
549
543
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
550
544
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
551
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.
|
|
545
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing
|
|
552
546
|
})(state.schema);
|
|
553
547
|
var tr = state.tr;
|
|
554
548
|
// If the cursor is inside a table
|
|
@@ -21,12 +21,11 @@ function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, e
|
|
|
21
21
|
var isFullWidthEnabled = arguments.length > 7 ? arguments[7] : undefined;
|
|
22
22
|
var pluginInjectionApi = arguments.length > 8 ? arguments[8] : undefined;
|
|
23
23
|
var getIntl = arguments.length > 9 ? arguments[9] : undefined;
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var isTableResizingEnabled = arguments.length > 15 ? arguments[15] : undefined;
|
|
24
|
+
var isTableFixedColumnWidthsOptionEnabled = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
25
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 11 ? arguments[11] : undefined;
|
|
26
|
+
var isCommentEditor = arguments.length > 12 ? arguments[12] : undefined;
|
|
27
|
+
var isChromelessEditor = arguments.length > 13 ? arguments[13] : undefined;
|
|
28
|
+
var isTableResizingEnabled = arguments.length > 14 ? arguments[14] : undefined;
|
|
30
29
|
var list = {};
|
|
31
30
|
var ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
32
31
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.nextCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
|
|
@@ -38,12 +37,12 @@ function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, e
|
|
|
38
37
|
// Add row/column shortcuts
|
|
39
38
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowBefore.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('TOP'), list);
|
|
40
39
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowAfter.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('BOTTOM'), list);
|
|
41
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnBefore.common, (0, _insert.addColumnBefore)(api, isTableScalingEnabled,
|
|
42
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfter.common, (0, _insert.addColumnAfter)(api, isTableScalingEnabled,
|
|
40
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnBefore.common, (0, _insert.addColumnBefore)(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
41
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfter.common, (0, _insert.addColumnAfter)(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
43
42
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowBeforeVO.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('TOP'), list);
|
|
44
43
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowAfterVO.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('BOTTOM'), list);
|
|
45
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnBeforeVO.common, (0, _insert.addColumnBefore)(api, isTableScalingEnabled,
|
|
46
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfterVO.common, (0, _insert.addColumnAfter)(api, isTableScalingEnabled,
|
|
44
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnBeforeVO.common, (0, _insert.addColumnBefore)(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
45
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfterVO.common, (0, _insert.addColumnAfter)(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
47
46
|
if (dragAndDropEnabled) {
|
|
48
47
|
// Move row/column shortcuts
|
|
49
48
|
/**
|
|
@@ -29,7 +29,7 @@ var _pluginFactory = require("./plugin-factory");
|
|
|
29
29
|
var _pluginKey = require("./plugin-key");
|
|
30
30
|
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; }
|
|
31
31
|
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; }
|
|
32
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl,
|
|
32
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor) {
|
|
33
33
|
var _accessibilityUtils;
|
|
34
34
|
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread(_objectSpread({
|
|
35
35
|
pluginConfig: pluginConfig,
|
|
@@ -38,7 +38,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
38
38
|
insertRowButtonIndex: undefined,
|
|
39
39
|
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
40
40
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
41
|
-
isTableResizingEnabled: tableResizingEnabled,
|
|
42
41
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
43
42
|
isHeaderColumnEnabled: false,
|
|
44
43
|
isDragAndDropEnabled: dragAndDropEnabled,
|
|
@@ -176,7 +175,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
176
175
|
|
|
177
176
|
// fix for when pasting a table with default layout into comment editor
|
|
178
177
|
// table lose width and expand to full width
|
|
179
|
-
if (!(0, _coreUtils.insideTable)(editorState) && isCommentEditor &&
|
|
178
|
+
if (!(0, _coreUtils.insideTable)(editorState) && isCommentEditor && pluginConfig.allowTableAlignment && isTableScalingEnabled) {
|
|
180
179
|
slice = (0, _paste.transformSliceTableLayoutDefaultToCenter)(slice, schema);
|
|
181
180
|
}
|
|
182
181
|
slice = (0, _utils4.transformSliceToFixHardBreakProblemOnCopyFromCell)(slice, schema);
|
|
@@ -264,7 +263,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
264
263
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
265
264
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
266
265
|
pluginInjectionApi: pluginInjectionApi,
|
|
267
|
-
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
268
266
|
isCommentEditor: isCommentEditor,
|
|
269
267
|
isChromelessEditor: isChromelessEditor
|
|
270
268
|
}),
|
|
@@ -285,7 +283,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
285
283
|
blur: _eventHandlers.handleBlur,
|
|
286
284
|
mousedown: (0, _eventHandlers.withCellTracking)(_eventHandlers.handleMouseDown),
|
|
287
285
|
mouseleave: _eventHandlers.handleMouseLeave,
|
|
288
|
-
mousemove: (0, _eventHandlers.whenTableInFocus)((0, _eventHandlers.handleMouseMove)(nodeViewPortalProviderAPI)),
|
|
286
|
+
mousemove: (0, _eventHandlers.whenTableInFocus)((0, _eventHandlers.handleMouseMove)(nodeViewPortalProviderAPI), pluginInjectionApi),
|
|
289
287
|
mouseenter: _eventHandlers.handleMouseEnter,
|
|
290
288
|
mouseup: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseUp),
|
|
291
289
|
click: (0, _eventHandlers.withCellTracking)((0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleClick))
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -143,10 +143,9 @@ var getToolbarCellOptionsConfig = exports.getToolbarCellOptionsConfig = function
|
|
|
143
143
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
144
144
|
var formatMessage = _ref2.formatMessage;
|
|
145
145
|
var isTableScalingEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
146
|
-
var
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
var isCommentEditor = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : false;
|
|
146
|
+
var isTableFixedColumnWidthsOptionEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
147
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
148
|
+
var isCommentEditor = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
150
149
|
var top = initialSelectionRect.top,
|
|
151
150
|
bottom = initialSelectionRect.bottom,
|
|
152
151
|
right = initialSelectionRect.right,
|
|
@@ -161,7 +160,7 @@ var getToolbarCellOptionsConfig = exports.getToolbarCellOptionsConfig = function
|
|
|
161
160
|
var selectionRect = getClosestSelectionRect(state);
|
|
162
161
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
163
162
|
if (index) {
|
|
164
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
163
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(_analytics.INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
165
164
|
}
|
|
166
165
|
return true;
|
|
167
166
|
},
|
|
@@ -388,9 +387,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
388
387
|
return element;
|
|
389
388
|
};
|
|
390
389
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
391
|
-
var alignmentMenu =
|
|
392
|
-
var
|
|
393
|
-
var cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
390
|
+
var alignmentMenu = config.allowTableAlignment && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
391
|
+
var cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
394
392
|
var columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
395
393
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
396
394
|
|
|
@@ -477,15 +475,14 @@ var separator = function separator(hidden) {
|
|
|
477
475
|
var getCellItems = function getCellItems(state, view, _ref3, getEditorContainerWidth, api, editorAnalyticsAPI) {
|
|
478
476
|
var formatMessage = _ref3.formatMessage;
|
|
479
477
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
480
|
-
var
|
|
481
|
-
var
|
|
482
|
-
var
|
|
483
|
-
var isCommentEditor = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
478
|
+
var isTableFixedColumnWidthsOptionEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
479
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
480
|
+
var isCommentEditor = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
484
481
|
var initialSelectionRect = getClosestSelectionRect(state);
|
|
485
482
|
if (initialSelectionRect) {
|
|
486
483
|
var cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
487
484
|
formatMessage: formatMessage
|
|
488
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
485
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor);
|
|
489
486
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
490
487
|
}
|
|
491
488
|
return [];
|
|
@@ -482,8 +482,6 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
482
482
|
_getPluginState11$isT = _getPluginState11.isTableScalingEnabled,
|
|
483
483
|
isTableScalingEnabled = _getPluginState11$isT === void 0 ? false : _getPluginState11$isT;
|
|
484
484
|
var _ref3 = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
485
|
-
_ref3$tableDuplicateC = _ref3.tableDuplicateCellColouring,
|
|
486
|
-
tableDuplicateCellColouring = _ref3$tableDuplicateC === void 0 ? false : _ref3$tableDuplicateC,
|
|
487
485
|
_ref3$tableWithFixedC = _ref3.tableWithFixedColumnWidthsOption,
|
|
488
486
|
tableWithFixedColumnWidthsOption = _ref3$tableWithFixedC === void 0 ? false : _ref3$tableWithFixedC;
|
|
489
487
|
// context menu opened by keyboard and any item except 'background' activated
|
|
@@ -531,11 +529,11 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
531
529
|
_this.toggleOpen();
|
|
532
530
|
break;
|
|
533
531
|
case 'insert_column':
|
|
534
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(_this.props.api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
532
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(_this.props.api, editorAnalyticsAPI, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent, isCommentEditor)(_analytics.INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
535
533
|
_this.toggleOpen();
|
|
536
534
|
break;
|
|
537
535
|
case 'insert_row':
|
|
538
|
-
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI
|
|
536
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.CONTEXT_MENU, {
|
|
539
537
|
index: selectionRect.bottom,
|
|
540
538
|
moveCursorToInsertedRow: true
|
|
541
539
|
})(state, dispatch);
|
|
@@ -211,7 +211,6 @@ var DragMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
211
211
|
scrollableElement = _ref.scrollableElement,
|
|
212
212
|
boundariesElement = _ref.boundariesElement,
|
|
213
213
|
isTableScalingEnabled = _ref.isTableScalingEnabled,
|
|
214
|
-
tableDuplicateCellColouring = _ref.tableDuplicateCellColouring,
|
|
215
214
|
shouldUseIncreasedScalingPercent = _ref.shouldUseIncreasedScalingPercent,
|
|
216
215
|
isTableFixedColumnWidthsOptionEnabled = _ref.isTableFixedColumnWidthsOptionEnabled,
|
|
217
216
|
ariaNotifyPlugin = _ref.ariaNotifyPlugin,
|
|
@@ -229,7 +228,7 @@ var DragMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
229
228
|
var selectionRect = (0, _utils2.isSelectionType)(selection, 'cell') ? (0, _utils2.getSelectionRect)(selection) : (0, _utils2.findCellRectClosestToPos)(selection.$from);
|
|
230
229
|
var hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
|
|
231
230
|
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
232
|
-
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled,
|
|
231
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, ariaNotifyPlugin, isCommentEditor);
|
|
233
232
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
|
|
234
233
|
menuItems = _convertToDropdownIte.menuItems,
|
|
235
234
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -12,6 +12,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
|
12
12
|
var _consts = require("../consts");
|
|
13
13
|
var _DragMenu = _interopRequireDefault(require("./DragMenu"));
|
|
14
14
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
15
|
+
var _getEditorFeatureFlag;
|
|
15
16
|
var mountPoint = _ref.mountPoint,
|
|
16
17
|
boundariesElement = _ref.boundariesElement,
|
|
17
18
|
scrollableElement = _ref.scrollableElement,
|
|
@@ -39,9 +40,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
39
40
|
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
|
-
var _ref2 = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
43
|
-
_ref2$tableDuplicateC = _ref2.tableDuplicateCellColouring,
|
|
44
|
-
tableDuplicateCellColouring = _ref2$tableDuplicateC === void 0 ? false : _ref2$tableDuplicateC,
|
|
43
|
+
var _ref2 = (_getEditorFeatureFlag = getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) !== null && _getEditorFeatureFlag !== void 0 ? _getEditorFeatureFlag : {},
|
|
45
44
|
_ref2$tableWithFixedC = _ref2.tableWithFixedColumnWidthsOption,
|
|
46
45
|
tableWithFixedColumnWidthsOption = _ref2$tableWithFixedC === void 0 ? false : _ref2$tableWithFixedC;
|
|
47
46
|
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
|
|
@@ -79,7 +78,6 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
79
78
|
boundariesElement: boundariesElement,
|
|
80
79
|
scrollableElement: scrollableElement,
|
|
81
80
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
82
|
-
tableDuplicateCellColouring: tableDuplicateCellColouring,
|
|
83
81
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
84
82
|
isTableFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
|
|
85
83
|
ariaNotifyPlugin: ariaNotifyPlugin,
|
|
@@ -180,14 +180,12 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
180
180
|
var _this$props3 = this.props,
|
|
181
181
|
editorView = _this$props3.editorView,
|
|
182
182
|
insertRowButtonIndex = _this$props3.insertRowButtonIndex,
|
|
183
|
-
editorAnalyticsAPI = _this$props3.editorAnalyticsAPI
|
|
184
|
-
getEditorFeatureFlags = _this$props3.getEditorFeatureFlags;
|
|
183
|
+
editorAnalyticsAPI = _this$props3.editorAnalyticsAPI;
|
|
185
184
|
if (typeof insertRowButtonIndex !== 'undefined') {
|
|
186
185
|
event.preventDefault();
|
|
187
186
|
var state = editorView.state,
|
|
188
187
|
dispatch = editorView.dispatch;
|
|
189
|
-
|
|
190
|
-
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI, featureFlags && featureFlags.tableDuplicateCellColouring)(_analytics.INPUT_METHOD.BUTTON, {
|
|
188
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.BUTTON, {
|
|
191
189
|
index: insertRowButtonIndex,
|
|
192
190
|
moveCursorToInsertedRow: true
|
|
193
191
|
})(state, dispatch);
|
|
@@ -206,14 +204,12 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
206
204
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
207
205
|
event.preventDefault();
|
|
208
206
|
var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
209
|
-
_ref$tableDuplicateCe = _ref.tableDuplicateCellColouring,
|
|
210
|
-
tableDuplicateCellColouring = _ref$tableDuplicateCe === void 0 ? false : _ref$tableDuplicateCe,
|
|
211
207
|
_ref$tableWithFixedCo = _ref.tableWithFixedColumnWidthsOption,
|
|
212
208
|
tableWithFixedColumnWidthsOption = _ref$tableWithFixedCo === void 0 ? false : _ref$tableWithFixedCo;
|
|
213
209
|
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
|
|
214
210
|
var state = editorView.state,
|
|
215
211
|
dispatch = editorView.dispatch;
|
|
216
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(this.props.api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
212
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(this.props.api, editorAnalyticsAPI, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent, isCommentEditor)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
217
213
|
}
|
|
218
214
|
}
|
|
219
215
|
}]);
|
|
@@ -85,11 +85,10 @@ var defaultSelectionRect = {
|
|
|
85
85
|
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) {
|
|
86
86
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
87
87
|
var isTableScalingEnabled = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : false;
|
|
88
|
-
var
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var isCommentEditor = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : false;
|
|
88
|
+
var isTableFixedColumnWidthsOptionEnabled = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : false;
|
|
89
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : false;
|
|
90
|
+
var ariaNotifyPlugin = arguments.length > 14 ? arguments[14] : undefined;
|
|
91
|
+
var isCommentEditor = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : false;
|
|
93
92
|
var selection = editorView.state.selection;
|
|
94
93
|
var _getTablePluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
95
94
|
getIntl = _getTablePluginState.getIntl;
|
|
@@ -200,12 +199,12 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
200
199
|
iconFallback: iconFallback,
|
|
201
200
|
onClick: function onClick(state, dispatch) {
|
|
202
201
|
if (direction === 'row') {
|
|
203
|
-
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI
|
|
202
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
204
203
|
index: (index !== null && index !== void 0 ? index : 0) + offset,
|
|
205
204
|
moveCursorToInsertedRow: true
|
|
206
205
|
})(state, dispatch);
|
|
207
206
|
} else {
|
|
208
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
207
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
209
208
|
}
|
|
210
209
|
return true;
|
|
211
210
|
},
|
|
@@ -19,14 +19,14 @@ function addColumnAtCustomStep(column) {
|
|
|
19
19
|
return tr;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export function addColumnAt(api, isTableScalingEnabled = false,
|
|
22
|
+
export function addColumnAt(api, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor) {
|
|
23
23
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
24
24
|
return tr => {
|
|
25
25
|
let updatedTr = tr;
|
|
26
26
|
if (allowAddColumnCustomStep) {
|
|
27
27
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
28
28
|
} else {
|
|
29
|
-
updatedTr = addColumnAtPMUtils(column
|
|
29
|
+
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
30
30
|
}
|
|
31
31
|
const table = findTable(updatedTr.selection);
|
|
32
32
|
if (table) {
|
|
@@ -48,33 +48,33 @@ export function addColumnAt(api, isTableScalingEnabled = false, isCellBackground
|
|
|
48
48
|
|
|
49
49
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
50
50
|
// Command to add a column before the column with the selection.
|
|
51
|
-
export const addColumnBefore = (api, isTableScalingEnabled = false,
|
|
51
|
+
export const addColumnBefore = (api, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => (state, dispatch, view) => {
|
|
52
52
|
const table = findTable(state.selection);
|
|
53
53
|
if (!table) {
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
if (dispatch) {
|
|
57
57
|
let rect = selectedRect(state);
|
|
58
|
-
dispatch(addColumnAt(api, isTableScalingEnabled,
|
|
58
|
+
dispatch(addColumnAt(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
59
59
|
}
|
|
60
60
|
return true;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
64
64
|
// Command to add a column after the column with the selection.
|
|
65
|
-
export const addColumnAfter = (api, isTableScalingEnabled,
|
|
65
|
+
export const addColumnAfter = (api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor) => (state, dispatch, view) => {
|
|
66
66
|
const table = findTable(state.selection);
|
|
67
67
|
if (!table) {
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
70
|
if (dispatch) {
|
|
71
71
|
let rect = selectedRect(state);
|
|
72
|
-
dispatch(addColumnAt(api, isTableScalingEnabled,
|
|
72
|
+
dispatch(addColumnAt(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
73
73
|
}
|
|
74
74
|
return true;
|
|
75
75
|
};
|
|
76
|
-
export const insertColumn = (api, isTableScalingEnabled = false,
|
|
77
|
-
let tr = addColumnAt(api, isTableScalingEnabled,
|
|
76
|
+
export const insertColumn = (api, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor) => column => (state, dispatch, view) => {
|
|
77
|
+
let tr = addColumnAt(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
78
78
|
const table = findTable(tr.selection);
|
|
79
79
|
if (!table) {
|
|
80
80
|
return false;
|
|
@@ -86,7 +86,7 @@ export const insertColumn = (api, isTableScalingEnabled = false, isCellBackgroun
|
|
|
86
86
|
}
|
|
87
87
|
return true;
|
|
88
88
|
};
|
|
89
|
-
export const insertRow = (row, moveCursorToTheNewRow
|
|
89
|
+
export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
90
90
|
// Don't clone the header row
|
|
91
91
|
const headerRowEnabled = checkIfHeaderRowEnabled(state.selection);
|
|
92
92
|
const clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
@@ -96,7 +96,7 @@ export const insertRow = (row, moveCursorToTheNewRow, isCellBackgroundDuplicated
|
|
|
96
96
|
if (row === 0 && headerRowEnabled) {
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
|
-
const tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row, undefined
|
|
99
|
+
const tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row, undefined)(state.tr);
|
|
100
100
|
const table = findTable(tr.selection);
|
|
101
101
|
if (!table) {
|
|
102
102
|
return false;
|
|
@@ -148,7 +148,7 @@ export const addRowAroundSelection = editorAnalyticsAPI => side => (state, dispa
|
|
|
148
148
|
moveCursorToInsertedRow: false
|
|
149
149
|
})(state, dispatch);
|
|
150
150
|
};
|
|
151
|
-
export const insertRowWithAnalytics =
|
|
151
|
+
export const insertRowWithAnalytics = editorAnalyticsAPI => (inputMethod, options) => withEditorAnalyticsAPI(state => {
|
|
152
152
|
const {
|
|
153
153
|
totalRowCount,
|
|
154
154
|
totalColumnCount
|
|
@@ -165,7 +165,7 @@ export const insertRowWithAnalytics = (editorAnalyticsAPI, isCellbackgroundDupli
|
|
|
165
165
|
},
|
|
166
166
|
eventType: EVENT_TYPE.TRACK
|
|
167
167
|
};
|
|
168
|
-
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow
|
|
168
|
+
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
|
|
169
169
|
export const changeColumnWidthByStepWithAnalytics = (editorAnalyticsAPI, api) => (stepSize, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor, inputMethod, ariaNotify, getIntl) => withEditorAnalyticsAPI(state => {
|
|
170
170
|
const {
|
|
171
171
|
table,
|
|
@@ -201,7 +201,7 @@ export const changeColumnWidthByStepWithAnalytics = (editorAnalyticsAPI, api) =>
|
|
|
201
201
|
getIntl: getIntl,
|
|
202
202
|
api
|
|
203
203
|
}));
|
|
204
|
-
export const insertColumnWithAnalytics = (api, editorAnalyticsAPI, isTableScalingEnabled = false,
|
|
204
|
+
export const insertColumnWithAnalytics = (api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
205
205
|
const {
|
|
206
206
|
totalRowCount,
|
|
207
207
|
totalColumnCount
|
|
@@ -218,7 +218,7 @@ export const insertColumnWithAnalytics = (api, editorAnalyticsAPI, isTableScalin
|
|
|
218
218
|
},
|
|
219
219
|
eventType: EVENT_TYPE.TRACK
|
|
220
220
|
};
|
|
221
|
-
})(editorAnalyticsAPI)(insertColumn(api, isTableScalingEnabled,
|
|
221
|
+
})(editorAnalyticsAPI)(insertColumn(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(position));
|
|
222
222
|
export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect, isHeaderRowRequired) => withEditorAnalyticsAPI(({
|
|
223
223
|
selection
|
|
224
224
|
}) => {
|
|
@@ -414,10 +414,21 @@ export const isTableInFocus = view => {
|
|
|
414
414
|
var _getPluginState, _getResizePluginState;
|
|
415
415
|
return !!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
416
416
|
};
|
|
417
|
-
export const whenTableInFocus = eventHandler => (view, mouseEvent) => {
|
|
417
|
+
export const whenTableInFocus = (eventHandler, pluginInjectionApi) => (view, mouseEvent) => {
|
|
418
|
+
var _pluginInjectionApi$e, _pluginInjectionApi$e2;
|
|
418
419
|
if (!isTableInFocus(view)) {
|
|
419
420
|
return false;
|
|
420
421
|
}
|
|
422
|
+
const isViewMode = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : (_pluginInjectionApi$e2 = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) === 'view';
|
|
423
|
+
/**
|
|
424
|
+
* Table cannot be in focus if we are in view mode.
|
|
425
|
+
* This will prevent an infinite flow of adding and removing
|
|
426
|
+
* resize handle decorations in view mode that causes unpredictable
|
|
427
|
+
* selections.
|
|
428
|
+
*/
|
|
429
|
+
if (isViewMode) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
421
432
|
return eventHandler(view, mouseEvent);
|
|
422
433
|
};
|
|
423
434
|
const trackCellLocation = (view, mouseEvent) => {
|