@atlaskit/editor-plugin-table 19.0.0 → 20.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 +37 -0
- package/dist/cjs/nodeviews/TableResizer.js +1 -1
- package/dist/cjs/nodeviews/table.js +18 -2
- package/dist/cjs/nodeviews/toDOM.js +18 -4
- package/dist/cjs/pm-plugins/keymap.js +12 -12
- package/dist/cjs/pm-plugins/main.js +41 -7
- package/dist/cjs/pm-plugins/table-width.js +10 -0
- package/dist/cjs/pm-plugins/transforms/content-mode.js +48 -0
- package/dist/cjs/pm-plugins/transforms/fix-tables.js +4 -35
- package/dist/cjs/pm-plugins/transforms/table-transform-utils.js +62 -0
- package/dist/cjs/pm-plugins/utils/tableMode.js +149 -0
- package/dist/cjs/tablePlugin.js +45 -40
- package/dist/cjs/ui/ContentComponent.js +1 -0
- package/dist/cjs/ui/event-handlers.js +3 -2
- package/dist/cjs/ui/global-styles.js +2 -1
- package/dist/cjs/ui/toolbar.js +36 -7
- package/dist/es2019/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/nodeviews/table.js +18 -2
- package/dist/es2019/nodeviews/toDOM.js +18 -4
- package/dist/es2019/pm-plugins/keymap.js +2 -2
- package/dist/es2019/pm-plugins/main.js +41 -7
- package/dist/es2019/pm-plugins/table-width.js +10 -0
- package/dist/es2019/pm-plugins/transforms/content-mode.js +39 -0
- package/dist/es2019/pm-plugins/transforms/fix-tables.js +2 -33
- package/dist/es2019/pm-plugins/transforms/table-transform-utils.js +56 -0
- package/dist/es2019/pm-plugins/utils/tableMode.js +148 -0
- package/dist/es2019/tablePlugin.js +10 -4
- package/dist/es2019/ui/ContentComponent.js +1 -0
- package/dist/es2019/ui/event-handlers.js +4 -3
- package/dist/es2019/ui/global-styles.js +2 -1
- package/dist/es2019/ui/toolbar.js +33 -6
- package/dist/esm/nodeviews/TableResizer.js +1 -1
- package/dist/esm/nodeviews/table.js +18 -2
- package/dist/esm/nodeviews/toDOM.js +18 -4
- package/dist/esm/pm-plugins/keymap.js +12 -12
- package/dist/esm/pm-plugins/main.js +41 -7
- package/dist/esm/pm-plugins/table-width.js +10 -0
- package/dist/esm/pm-plugins/transforms/content-mode.js +41 -0
- package/dist/esm/pm-plugins/transforms/fix-tables.js +2 -33
- package/dist/esm/pm-plugins/transforms/table-transform-utils.js +56 -0
- package/dist/esm/pm-plugins/utils/tableMode.js +143 -0
- package/dist/esm/tablePlugin.js +45 -40
- package/dist/esm/ui/ContentComponent.js +1 -0
- package/dist/esm/ui/event-handlers.js +4 -3
- package/dist/esm/ui/global-styles.js +2 -1
- package/dist/esm/ui/toolbar.js +36 -7
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/transforms/content-mode.d.ts +8 -0
- package/dist/types/pm-plugins/transforms/table-transform-utils.d.ts +11 -0
- package/dist/types/pm-plugins/utils/tableMode.d.ts +22 -0
- package/dist/types/tablePluginType.d.ts +6 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/ui/global-styles.d.ts +2 -1
- 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/pm-plugins/transforms/content-mode.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/transforms/table-transform-utils.d.ts +11 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +22 -0
- package/dist/types-ts4.5/tablePluginType.d.ts +6 -0
- package/dist/types-ts4.5/types/index.d.ts +3 -0
- package/dist/types-ts4.5/ui/global-styles.d.ts +2 -1
- package/package.json +21 -20
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isTableInContentMode = exports.isContentModeSupported = exports.hasTableBeenResized = exports.applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToAllTables = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
10
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
11
|
+
var _colgroup = require("../table-resizing/utils/colgroup");
|
|
12
|
+
var _contentMode = require("../transforms/content-mode");
|
|
13
|
+
var _alignment = require("./alignment");
|
|
14
|
+
var isTableInContentMode = exports.isTableInContentMode = function isTableInContentMode(_ref) {
|
|
15
|
+
var allowColumnResizing = _ref.allowColumnResizing,
|
|
16
|
+
allowTableResizing = _ref.allowTableResizing,
|
|
17
|
+
isFullPageEditor = _ref.isFullPageEditor,
|
|
18
|
+
isTableNested = _ref.isTableNested,
|
|
19
|
+
node = _ref.node;
|
|
20
|
+
if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (!node || isTableNested) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return isContentModeSupported({
|
|
27
|
+
allowColumnResizing: allowColumnResizing,
|
|
28
|
+
allowTableResizing: allowTableResizing,
|
|
29
|
+
isFullPageEditor: isFullPageEditor
|
|
30
|
+
}) && !hasTableBeenResized(node) && node.attrs.layout === _alignment.ALIGN_START;
|
|
31
|
+
};
|
|
32
|
+
var isContentModeSupported = exports.isContentModeSupported = function isContentModeSupported(_ref2) {
|
|
33
|
+
var allowColumnResizing = _ref2.allowColumnResizing,
|
|
34
|
+
allowTableResizing = _ref2.allowTableResizing,
|
|
35
|
+
isFullPageEditor = _ref2.isFullPageEditor;
|
|
36
|
+
return allowColumnResizing && allowTableResizing && isFullPageEditor;
|
|
37
|
+
};
|
|
38
|
+
var hasTableBeenResized = exports.hasTableBeenResized = function hasTableBeenResized(node) {
|
|
39
|
+
return node.attrs.width !== null || (0, _colgroup.hasTableColumnBeenResized)(node);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Iterates all top-level tables in the document, and for those in content mode,
|
|
44
|
+
* measures rendered column widths and sets colwidth + table width attributes
|
|
45
|
+
* in a single batched transaction.
|
|
46
|
+
*/
|
|
47
|
+
var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTables(view, pluginInjectionApi) {
|
|
48
|
+
var _view$state = view.state,
|
|
49
|
+
doc = _view$state.doc,
|
|
50
|
+
schema = _view$state.schema;
|
|
51
|
+
var tr = view.state.tr;
|
|
52
|
+
var table = schema.nodes.table;
|
|
53
|
+
var modified = false;
|
|
54
|
+
var measuredTables = [];
|
|
55
|
+
|
|
56
|
+
// modify only top-level tables
|
|
57
|
+
doc.forEach(function (node, offset) {
|
|
58
|
+
if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== _alignment.ALIGN_START) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var domNode = view.domAtPos(offset + 1).node;
|
|
62
|
+
var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
|
|
63
|
+
var tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
|
|
64
|
+
if (!tableRef) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
measuredTables.push({
|
|
68
|
+
node: node,
|
|
69
|
+
offset: offset,
|
|
70
|
+
measurement: (0, _contentMode.getTableMeasurement)(tableRef)
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
measuredTables.forEach(function (_ref3) {
|
|
74
|
+
var node = _ref3.node,
|
|
75
|
+
offset = _ref3.offset,
|
|
76
|
+
measurement = _ref3.measurement;
|
|
77
|
+
tr = (0, _contentMode.applyTableMeasurement)(tr, node, measurement, offset);
|
|
78
|
+
modified = true;
|
|
79
|
+
});
|
|
80
|
+
if (modified) {
|
|
81
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$w, _pluginInjectionApi$w2;
|
|
82
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.attachAnalyticsEvent({
|
|
83
|
+
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
|
|
84
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
85
|
+
actionSubjectId: null,
|
|
86
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
87
|
+
attributes: {
|
|
88
|
+
editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 || (_pluginInjectionApi$w2 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : _pluginInjectionApi$w2.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
|
|
89
|
+
totalTablesResized: measuredTables.length,
|
|
90
|
+
measurements: measuredTables.map(function (_ref4) {
|
|
91
|
+
var measurement = _ref4.measurement;
|
|
92
|
+
return {
|
|
93
|
+
tableWidth: measurement.tableWidth,
|
|
94
|
+
totalColumnCount: measurement.colWidths.length
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
})(tr);
|
|
99
|
+
view.dispatch(tr.setMeta('addToHistory', false));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
|
|
103
|
+
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
104
|
+
var tableObject = (0, _utils.findTable)(view.state.selection);
|
|
105
|
+
if (!tableObject) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
var node = tableObject.node,
|
|
109
|
+
pos = tableObject.pos;
|
|
110
|
+
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
111
|
+
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
var tableRef = tableState.tableRef;
|
|
115
|
+
|
|
116
|
+
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
117
|
+
// for a rAF to measure natural column widths, instea directly update the DOM elements and
|
|
118
|
+
// take a measurement.
|
|
119
|
+
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
120
|
+
var contentWrap = tableRef.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP));
|
|
121
|
+
var resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(".".concat(_styles.TableSharedCssClassName.TABLE_RESIZER_CONTAINER));
|
|
122
|
+
var resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
123
|
+
tableRef.style.width = '';
|
|
124
|
+
tableRef.style.tableLayout = 'auto';
|
|
125
|
+
cols.forEach(function (col) {
|
|
126
|
+
return col.style.width = '';
|
|
127
|
+
});
|
|
128
|
+
if (resizerContainer) {
|
|
129
|
+
resizerContainer.style.width = 'max-content';
|
|
130
|
+
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
131
|
+
}
|
|
132
|
+
if (resizerItem) {
|
|
133
|
+
resizerItem.style.width = 'max-content';
|
|
134
|
+
}
|
|
135
|
+
var measurement = (0, _contentMode.getTableMeasurement)(tableRef);
|
|
136
|
+
var tr = (0, _contentMode.applyTableMeasurement)(view.state.tr, node, measurement, pos);
|
|
137
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
|
|
138
|
+
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
|
139
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
140
|
+
actionSubjectId: null,
|
|
141
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
142
|
+
attributes: {
|
|
143
|
+
editorContainerWidth: (_api$width$sharedStat = api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 || (_api$width = _api$width.sharedState.currentState()) === null || _api$width === void 0 ? void 0 : _api$width.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0,
|
|
144
|
+
tableWidth: measurement.tableWidth,
|
|
145
|
+
totalColumnCount: measurement.colWidths.length
|
|
146
|
+
}
|
|
147
|
+
})(tr);
|
|
148
|
+
view.dispatch(tr);
|
|
149
|
+
};
|
package/dist/cjs/tablePlugin.js
CHANGED
|
@@ -75,6 +75,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
75
75
|
};
|
|
76
76
|
var options = _objectSpread(_objectSpread({}, config), {}, {
|
|
77
77
|
tableOptions: (_config$tableOptions = config === null || config === void 0 ? void 0 : config.tableOptions) !== null && _config$tableOptions !== void 0 ? _config$tableOptions : {},
|
|
78
|
+
dragAndDropEnabled: (config === null || config === void 0 ? void 0 : config.dragAndDropEnabled) || (0, _platformFeatureFlags.fg)('platform_editor_enable_table_dnd'),
|
|
78
79
|
isTableScalingEnabled: (config === null || config === void 0 ? void 0 : config.isTableScalingEnabled) || (0, _platformFeatureFlags.fg)('platform_editor_enable_table_scaling')
|
|
79
80
|
});
|
|
80
81
|
var defaultGetEditorContainerWidth = function defaultGetEditorContainerWidth() {
|
|
@@ -291,10 +292,11 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
291
292
|
wasFullWidthEnabled = _ref3.wasFullWidthEnabled,
|
|
292
293
|
tableOptions = _ref3.tableOptions,
|
|
293
294
|
getEditorFeatureFlags = _ref3.getEditorFeatureFlags,
|
|
295
|
+
dragAndDropEnabled = _ref3.dragAndDropEnabled,
|
|
294
296
|
isTableScalingEnabled = _ref3.isTableScalingEnabled,
|
|
295
297
|
isCommentEditor = _ref3.isCommentEditor,
|
|
296
298
|
isChromelessEditor = _ref3.isChromelessEditor;
|
|
297
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, options === null || options === void 0 ? void 0 : options.allowFixedColumnWidthOption);
|
|
299
|
+
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, options === null || options === void 0 ? void 0 : options.allowFixedColumnWidthOption);
|
|
298
300
|
}
|
|
299
301
|
}, {
|
|
300
302
|
name: 'tablePMColResizing',
|
|
@@ -326,6 +328,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
326
328
|
var getIntl = _ref6.getIntl,
|
|
327
329
|
nodeViewPortalProviderAPI = _ref6.nodeViewPortalProviderAPI;
|
|
328
330
|
var _ref7 = options || {},
|
|
331
|
+
dragAndDropEnabled = _ref7.dragAndDropEnabled,
|
|
329
332
|
_ref7$isTableScalingE = _ref7.isTableScalingEnabled,
|
|
330
333
|
isTableScalingEnabled = _ref7$isTableScalingE === void 0 ? false : _ref7$isTableScalingE,
|
|
331
334
|
_ref7$fullWidthEnable = _ref7.fullWidthEnabled,
|
|
@@ -335,7 +338,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
335
338
|
_ref7$isChromelessEdi = _ref7.isChromelessEditor,
|
|
336
339
|
isChromelessEditor = _ref7$isChromelessEdi === void 0 ? false : _ref7$isChromelessEdi,
|
|
337
340
|
tableOptions = _ref7.tableOptions;
|
|
338
|
-
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, 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);
|
|
341
|
+
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);
|
|
339
342
|
}
|
|
340
343
|
}, {
|
|
341
344
|
name: 'tableSelectionKeymap',
|
|
@@ -346,10 +349,12 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
346
349
|
}, {
|
|
347
350
|
name: 'tableEditing',
|
|
348
351
|
plugin: function plugin() {
|
|
352
|
+
var _ref9 = options || {},
|
|
353
|
+
dragAndDropEnabled = _ref9.dragAndDropEnabled;
|
|
349
354
|
return (0, _pmPlugins.tableEditing)({
|
|
350
|
-
reportFixedTable: function reportFixedTable(
|
|
351
|
-
var tr =
|
|
352
|
-
reason =
|
|
355
|
+
reportFixedTable: function reportFixedTable(_ref0) {
|
|
356
|
+
var tr = _ref0.tr,
|
|
357
|
+
reason = _ref0.reason;
|
|
353
358
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
354
359
|
action: _analytics.TABLE_ACTION.FIXED,
|
|
355
360
|
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
@@ -360,71 +365,71 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
360
365
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
361
366
|
})(tr);
|
|
362
367
|
},
|
|
363
|
-
dragAndDropEnabled:
|
|
368
|
+
dragAndDropEnabled: dragAndDropEnabled
|
|
364
369
|
});
|
|
365
370
|
}
|
|
366
371
|
}, {
|
|
367
372
|
name: 'tableStickyHeaders',
|
|
368
|
-
plugin: function plugin(
|
|
369
|
-
var dispatch =
|
|
373
|
+
plugin: function plugin(_ref1) {
|
|
374
|
+
var dispatch = _ref1.dispatch;
|
|
370
375
|
return options && options.tableOptions.stickyHeaders ? (0, _plugin4.createPlugin)(dispatch, function () {
|
|
371
376
|
return [];
|
|
372
377
|
}) : undefined;
|
|
373
378
|
}
|
|
374
379
|
}, {
|
|
375
380
|
name: 'tableDragAndDrop',
|
|
376
|
-
plugin: function plugin(
|
|
377
|
-
var dispatch =
|
|
378
|
-
return (0, _plugin3.createPlugin)(dispatch, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options.isCommentEditor, api);
|
|
381
|
+
plugin: function plugin(_ref10) {
|
|
382
|
+
var dispatch = _ref10.dispatch;
|
|
383
|
+
return options !== null && options !== void 0 && options.dragAndDropEnabled ? (0, _plugin3.createPlugin)(dispatch, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options.isCommentEditor, api) : undefined;
|
|
379
384
|
}
|
|
380
385
|
}, {
|
|
381
386
|
name: 'tableViewModeSort',
|
|
382
|
-
plugin: function plugin(
|
|
383
|
-
var nodeViewPortalProviderAPI =
|
|
387
|
+
plugin: function plugin(_ref11) {
|
|
388
|
+
var nodeViewPortalProviderAPI = _ref11.nodeViewPortalProviderAPI;
|
|
384
389
|
return api !== null && api !== void 0 && api.editorViewMode ? (0, _viewModeSort.createPlugin)(api, nodeViewPortalProviderAPI) : undefined;
|
|
385
390
|
}
|
|
386
391
|
}, {
|
|
387
392
|
name: 'tableLocalId',
|
|
388
|
-
plugin: function plugin(
|
|
389
|
-
var dispatch =
|
|
393
|
+
plugin: function plugin(_ref12) {
|
|
394
|
+
var dispatch = _ref12.dispatch;
|
|
390
395
|
return !(0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? (0, _tableLocalId.createPlugin)(dispatch) : undefined;
|
|
391
396
|
}
|
|
392
397
|
}, {
|
|
393
398
|
name: 'tableWidth',
|
|
394
|
-
plugin: function plugin(
|
|
399
|
+
plugin: function plugin(_ref13) {
|
|
395
400
|
var _options$fullWidthEna, _options$maxWidthEnab, _options$isTableScali, _options$tableOptions3, _options$isCommentEdi;
|
|
396
|
-
var dispatchAnalyticsEvent =
|
|
397
|
-
dispatch =
|
|
401
|
+
var dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent,
|
|
402
|
+
dispatch = _ref13.dispatch;
|
|
398
403
|
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$maxWidthEnab = options.maxWidthEnabled) !== null && _options$maxWidthEnab !== void 0 ? _options$maxWidthEnab : false, (_options$isTableScali = options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$tableOptions3 = options.tableOptions.allowTableResizing) !== null && _options$tableOptions3 !== void 0 ? _options$tableOptions3 : false, (_options$isCommentEdi = options.isCommentEditor) !== null && _options$isCommentEdi !== void 0 ? _options$isCommentEdi : false) : undefined;
|
|
399
404
|
}
|
|
400
405
|
}, {
|
|
401
406
|
name: 'tableWidthInCommentFix',
|
|
402
|
-
plugin: function plugin(
|
|
407
|
+
plugin: function plugin(_ref14) {
|
|
403
408
|
var _options$tableOptions4;
|
|
404
|
-
var dispatch =
|
|
409
|
+
var dispatch = _ref14.dispatch;
|
|
405
410
|
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing && options !== null && options !== void 0 && options.isCommentEditor ? (0, _tableWidthInCommentFix.createPlugin)(dispatch, (_options$tableOptions4 = options.tableOptions.allowTableAlignment) !== null && _options$tableOptions4 !== void 0 ? _options$tableOptions4 : false) : undefined;
|
|
406
411
|
}
|
|
407
412
|
},
|
|
408
413
|
// TODO: ED-26961 - should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
409
414
|
{
|
|
410
415
|
name: 'tableOverflowAnalyticsPlugin',
|
|
411
|
-
plugin: function plugin(
|
|
416
|
+
plugin: function plugin(_ref15) {
|
|
412
417
|
var _options$tableOptions5;
|
|
413
|
-
var dispatch =
|
|
414
|
-
dispatchAnalyticsEvent =
|
|
418
|
+
var dispatch = _ref15.dispatch,
|
|
419
|
+
dispatchAnalyticsEvent = _ref15.dispatchAnalyticsEvent;
|
|
415
420
|
return (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$tableOptions5 = options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) !== null && _options$tableOptions5 !== void 0 ? _options$tableOptions5 : false);
|
|
416
421
|
}
|
|
417
422
|
}, {
|
|
418
423
|
name: 'tableAnalyticsPlugin',
|
|
419
|
-
plugin: function plugin(
|
|
420
|
-
var dispatch =
|
|
421
|
-
dispatchAnalyticsEvent =
|
|
424
|
+
plugin: function plugin(_ref16) {
|
|
425
|
+
var dispatch = _ref16.dispatch,
|
|
426
|
+
dispatchAnalyticsEvent = _ref16.dispatchAnalyticsEvent;
|
|
422
427
|
return (0, _plugin.createPlugin)(dispatch, dispatchAnalyticsEvent);
|
|
423
428
|
}
|
|
424
429
|
}, {
|
|
425
430
|
name: 'tableGetEditorViewReferencePlugin',
|
|
426
|
-
plugin: function plugin(
|
|
427
|
-
var dispatchAnalyticsEvent =
|
|
431
|
+
plugin: function plugin(_ref17) {
|
|
432
|
+
var dispatchAnalyticsEvent = _ref17.dispatchAnalyticsEvent;
|
|
428
433
|
return new _safePlugin.SafePlugin({
|
|
429
434
|
view: function view(editorView) {
|
|
430
435
|
editorViewRef.current = editorView;
|
|
@@ -478,8 +483,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
478
483
|
}
|
|
479
484
|
}, {
|
|
480
485
|
name: 'tableSizeSelectorPlugin',
|
|
481
|
-
plugin: function plugin(
|
|
482
|
-
var dispatch =
|
|
486
|
+
plugin: function plugin(_ref18) {
|
|
487
|
+
var dispatch = _ref18.dispatch;
|
|
483
488
|
return isTableSelectorEnabled ? (0, _tableSizeSelector.createPlugin)(dispatch) : undefined;
|
|
484
489
|
}
|
|
485
490
|
}, {
|
|
@@ -510,12 +515,12 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
510
515
|
}
|
|
511
516
|
return plugins;
|
|
512
517
|
},
|
|
513
|
-
contentComponent: function contentComponent(
|
|
514
|
-
var editorView =
|
|
515
|
-
popupsMountPoint =
|
|
516
|
-
popupsBoundariesElement =
|
|
517
|
-
popupsScrollableElement =
|
|
518
|
-
dispatchAnalyticsEvent =
|
|
518
|
+
contentComponent: function contentComponent(_ref19) {
|
|
519
|
+
var editorView = _ref19.editorView,
|
|
520
|
+
popupsMountPoint = _ref19.popupsMountPoint,
|
|
521
|
+
popupsBoundariesElement = _ref19.popupsBoundariesElement,
|
|
522
|
+
popupsScrollableElement = _ref19.popupsScrollableElement,
|
|
523
|
+
dispatchAnalyticsEvent = _ref19.dispatchAnalyticsEvent;
|
|
519
524
|
return /*#__PURE__*/_react.default.createElement(_ContentComponent.ContentComponent, {
|
|
520
525
|
api: api,
|
|
521
526
|
editorView: editorView,
|
|
@@ -530,8 +535,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
530
535
|
});
|
|
531
536
|
},
|
|
532
537
|
pluginsOptions: {
|
|
533
|
-
quickInsert: function quickInsert(
|
|
534
|
-
var formatMessage =
|
|
538
|
+
quickInsert: function quickInsert(_ref20) {
|
|
539
|
+
var formatMessage = _ref20.formatMessage;
|
|
535
540
|
return [{
|
|
536
541
|
id: 'table',
|
|
537
542
|
title: formatMessage(_messages.toolbarInsertBlockMessages.table),
|
|
@@ -601,8 +606,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
601
606
|
return editorViewRef.current;
|
|
602
607
|
}, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
603
608
|
},
|
|
604
|
-
usePluginHook: function usePluginHook(
|
|
605
|
-
var editorView =
|
|
609
|
+
usePluginHook: function usePluginHook(_ref21) {
|
|
610
|
+
var editorView = _ref21.editorView;
|
|
606
611
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['editorViewMode'], function (states) {
|
|
607
612
|
var _states$editorViewMod;
|
|
608
613
|
return {
|
|
@@ -219,6 +219,7 @@ var ContentComponent = exports.ContentComponent = function ContentComponent(_ref
|
|
|
219
219
|
fallbackComponent: null
|
|
220
220
|
}, /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, {
|
|
221
221
|
featureFlags: api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState(),
|
|
222
|
+
isDragAndDropEnabledOption: options === null || options === void 0 ? void 0 : options.dragAndDropEnabled,
|
|
222
223
|
api: api
|
|
223
224
|
}), /*#__PURE__*/_react.default.createElement(ContentComponentInternal, {
|
|
224
225
|
api: api,
|
|
@@ -10,6 +10,7 @@ exports.withCellTracking = exports.whenTableInFocus = exports.isTableInFocus = v
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
13
14
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
16
|
var _state5 = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -48,7 +49,7 @@ var handleBlur = exports.handleBlur = function handleBlur(view, event) {
|
|
|
48
49
|
dispatch = view.dispatch;
|
|
49
50
|
// IE version check for ED-4665
|
|
50
51
|
// Calendar focus check for ED-10466
|
|
51
|
-
if (
|
|
52
|
+
if ((0, _browser.getBrowserInfo)().ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event)) {
|
|
52
53
|
(0, _commands.setEditorFocus)(false)(state, dispatch);
|
|
53
54
|
}
|
|
54
55
|
event.preventDefault();
|
|
@@ -358,7 +359,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(nodeVie
|
|
|
358
359
|
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
359
360
|
// in the deferred callback handler.
|
|
360
361
|
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
361
|
-
handleMouseMoveDebounce(nodeViewPortalProviderAPI)(view, event,
|
|
362
|
+
handleMouseMoveDebounce(nodeViewPortalProviderAPI)(view, event, (0, _browser.getBrowserInfo)().gecko ? event.offsetX : NaN);
|
|
362
363
|
return false;
|
|
363
364
|
};
|
|
364
365
|
};
|
|
@@ -15,6 +15,7 @@ var _commonStyles = require("./common-styles");
|
|
|
15
15
|
|
|
16
16
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
17
17
|
var featureFlags = _ref.featureFlags,
|
|
18
|
+
isDragAndDropEnabledOption = _ref.isDragAndDropEnabledOption,
|
|
18
19
|
api = _ref.api;
|
|
19
20
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['editorViewMode'], function (states) {
|
|
20
21
|
var _states$editorViewMod;
|
|
@@ -27,7 +28,7 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
|
|
|
27
28
|
return (0, _react.jsx)(_react.Global, {
|
|
28
29
|
styles: (0, _commonStyles.tableStyles)({
|
|
29
30
|
featureFlags: featureFlags,
|
|
30
|
-
isDragAndDropEnabled: !isLivePageViewMode
|
|
31
|
+
isDragAndDropEnabled: isDragAndDropEnabledOption && !isLivePageViewMode
|
|
31
32
|
})
|
|
32
33
|
});
|
|
33
34
|
};
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -33,6 +33,7 @@ var _alignImageLeft = _interopRequireDefault(require("@atlaskit/icon/core/align-
|
|
|
33
33
|
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
34
34
|
var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
|
|
35
35
|
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
36
|
+
var _shrinkHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/shrink-horizontal"));
|
|
36
37
|
var _tableColumnsDistribute = _interopRequireDefault(require("@atlaskit/icon/core/table-columns-distribute"));
|
|
37
38
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
38
39
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -49,6 +50,7 @@ var _alignment = require("../pm-plugins/utils/alignment");
|
|
|
49
50
|
var _nodes = require("../pm-plugins/utils/nodes");
|
|
50
51
|
var _selection = require("../pm-plugins/utils/selection");
|
|
51
52
|
var _table = require("../pm-plugins/utils/table");
|
|
53
|
+
var _tableMode = require("../pm-plugins/utils/tableMode");
|
|
52
54
|
var _types = require("../types");
|
|
53
55
|
var _FloatingAlignmentButtons = require("./FloatingAlignmentButtons/FloatingAlignmentButtons");
|
|
54
56
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -417,11 +419,17 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
417
419
|
var areAnyNewToolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
418
420
|
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
419
421
|
var _api$editorViewMode;
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
422
|
+
var isDragHandleMenuOpened = false;
|
|
423
|
+
var isTableRowOrColumnDragged = false;
|
|
424
|
+
if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
|
|
425
|
+
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(state),
|
|
426
|
+
_getDragDropPluginSta2 = _getDragDropPluginSta.isDragMenuOpen,
|
|
427
|
+
isDragMenuOpen = _getDragDropPluginSta2 === void 0 ? false : _getDragDropPluginSta2,
|
|
428
|
+
_getDragDropPluginSta3 = _getDragDropPluginSta.isDragging,
|
|
429
|
+
isDragging = _getDragDropPluginSta3 === void 0 ? false : _getDragDropPluginSta3;
|
|
430
|
+
isDragHandleMenuOpened = isDragMenuOpen;
|
|
431
|
+
isTableRowOrColumnDragged = isDragging;
|
|
432
|
+
}
|
|
425
433
|
var isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
|
|
426
434
|
var isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
|
|
427
435
|
var isTableState = isTableRowOrColumnDragged || isTableOrColumnResizing || isTableMenuOpened;
|
|
@@ -442,7 +450,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
442
450
|
// We don't want to show floating toolbar while resizing the table
|
|
443
451
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
444
452
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
445
|
-
var _api$limitedMode$shar, _api$limitedMode, _api$extension, _api$extension2;
|
|
453
|
+
var _api$limitedMode$shar, _api$limitedMode, _api$editorViewMode2, _api$extension, _api$extension2;
|
|
446
454
|
var isNested = pluginState.tablePos && (0, _nodes.isTableNested)(state, pluginState.tablePos);
|
|
447
455
|
var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
|
|
448
456
|
var areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
|
|
@@ -472,6 +480,27 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
472
480
|
var cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor, isLimitedModeEnabled);
|
|
473
481
|
var columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor, isLimitedModeEnabled) : [];
|
|
474
482
|
var colorPicker = !areAnyNewToolbarFlagsEnabled ? getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView) : [];
|
|
483
|
+
var fitToContentButton = (0, _tableMode.isContentModeSupported)({
|
|
484
|
+
allowColumnResizing: !!pluginState.pluginConfig.allowColumnResizing,
|
|
485
|
+
allowTableResizing: !!pluginState.pluginConfig.allowTableResizing,
|
|
486
|
+
isFullPageEditor: !pluginState.isChromelessEditor && !pluginState.isCommentEditor
|
|
487
|
+
}) && !isNested && (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) !== 'view' && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_on_demand', 'isEnabled', true) ? [{
|
|
488
|
+
id: 'editor.table.fitToContent',
|
|
489
|
+
type: 'button',
|
|
490
|
+
title: intl.formatMessage(_messages.tableMessages.fitToContent),
|
|
491
|
+
icon: function icon() {
|
|
492
|
+
return (0, _react.jsx)(_shrinkHorizontal.default, {
|
|
493
|
+
spacing: 'spacious',
|
|
494
|
+
label: ''
|
|
495
|
+
});
|
|
496
|
+
},
|
|
497
|
+
onClick: function onClick(_state, _dispatch, view) {
|
|
498
|
+
if (view) {
|
|
499
|
+
(0, _tableMode.applyMeasuredWidthToSelectedTable)(view, api !== null && api !== void 0 ? api : undefined);
|
|
500
|
+
}
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
}] : [];
|
|
475
504
|
|
|
476
505
|
// Check if we need to show confirm dialog for delete button
|
|
477
506
|
var confirmDialog;
|
|
@@ -550,7 +579,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
550
579
|
},
|
|
551
580
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
552
581
|
// Place the context menu slightly above the others
|
|
553
|
-
items: [menu].concat((0, _toConsumableArray2.default)(!areAnyNewToolbarFlagsEnabled ? [separator(menu.hidden)] : []), (0, _toConsumableArray2.default)(alignmentMenu), (0, _toConsumableArray2.default)(!areAnyNewToolbarFlagsEnabled ? [separator(alignmentMenu.length === 0)] : []), (0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), (0, _toConsumableArray2.default)(colorPicker), (0, _toConsumableArray2.default)(!areAnyNewToolbarFlagsEnabled ? [{
|
|
582
|
+
items: [menu].concat((0, _toConsumableArray2.default)(!areAnyNewToolbarFlagsEnabled ? [separator(menu.hidden)] : []), (0, _toConsumableArray2.default)(alignmentMenu), (0, _toConsumableArray2.default)(!areAnyNewToolbarFlagsEnabled ? [separator(alignmentMenu.length === 0)] : []), (0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), fitToContentButton, (0, _toConsumableArray2.default)(colorPicker), (0, _toConsumableArray2.default)(!areAnyNewToolbarFlagsEnabled ? [{
|
|
554
583
|
type: 'extensions-placeholder',
|
|
555
584
|
separator: 'end'
|
|
556
585
|
}, copyButton, {
|
|
@@ -513,7 +513,7 @@ export const TableResizer = ({
|
|
|
513
513
|
snap: guidelineSnaps,
|
|
514
514
|
handlePositioning: "adjacent",
|
|
515
515
|
isHandleVisible: isTableSelected,
|
|
516
|
-
needExtendedResizeZone:
|
|
516
|
+
needExtendedResizeZone: true,
|
|
517
517
|
appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
|
|
518
518
|
handleHighlight: "shadow"
|
|
519
519
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
@@ -8,10 +8,12 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
11
12
|
import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
|
|
12
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
14
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
14
15
|
import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/utils/nodes';
|
|
16
|
+
import { isTableInContentMode } from '../pm-plugins/utils/tableMode';
|
|
15
17
|
import { TableComponentWithSharedState } from './TableComponentWithSharedState';
|
|
16
18
|
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
17
19
|
const tableAttributes = node => {
|
|
@@ -176,17 +178,31 @@ export default class TableView extends ReactNodeView {
|
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
setDomAttrs(node) {
|
|
179
|
-
var _this$
|
|
181
|
+
var _this$reactComponentP8, _this$getEditorFeatur2, _this$options3, _this$options4;
|
|
180
182
|
if (!this.table) {
|
|
181
183
|
return; // width / attribute application to actual table will happen later when table is set
|
|
182
184
|
}
|
|
183
185
|
const attrs = tableAttributes(node);
|
|
186
|
+
if (expValEqualsNoExposure('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
|
|
187
|
+
var _this$reactComponentP6, _this$reactComponentP7;
|
|
188
|
+
if (isTableInContentMode({
|
|
189
|
+
node,
|
|
190
|
+
allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
|
|
191
|
+
allowTableResizing: !!this.reactComponentProps.allowTableResizing,
|
|
192
|
+
isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor),
|
|
193
|
+
isTableNested: isTableNested(this.view.state, this.getPos())
|
|
194
|
+
}) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
|
|
195
|
+
attrs['data-initial-width-mode'] = 'content';
|
|
196
|
+
} else {
|
|
197
|
+
this.table.removeAttribute('data-initial-width-mode');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
184
200
|
Object.keys(attrs).forEach(attr => {
|
|
185
201
|
// Ignored via go/ees005
|
|
186
202
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
187
203
|
this.table.setAttribute(attr, attrs[attr]);
|
|
188
204
|
});
|
|
189
|
-
const isTableFixedColumnWidthsOptionEnabled = (fg('platform_editor_table_fixed_column_width_prop') ? (_this$
|
|
205
|
+
const isTableFixedColumnWidthsOptionEnabled = (fg('platform_editor_table_fixed_column_width_prop') ? (_this$reactComponentP8 = this.reactComponentProps) === null || _this$reactComponentP8 === void 0 ? void 0 : _this$reactComponentP8.allowFixedColumnWidthOption : (_this$getEditorFeatur2 = this.getEditorFeatureFlags) === null || _this$getEditorFeatur2 === void 0 ? void 0 : _this$getEditorFeatur2.call(this).tableWithFixedColumnWidthsOption) || false;
|
|
190
206
|
// Preserve Table Width cannot have inline width set on the table
|
|
191
207
|
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled) || (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && node.attrs.displayMode === 'fixed') {
|
|
192
208
|
var _tableWidthPluginKey$;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
1
2
|
import kebabCase from 'lodash/kebabCase';
|
|
2
3
|
import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
|
|
3
4
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
@@ -5,15 +6,23 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
5
6
|
import { generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
6
7
|
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
|
|
7
8
|
import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
|
|
9
|
+
import { isTableInContentMode } from '../pm-plugins/utils/tableMode';
|
|
8
10
|
import { getAlignmentStyle } from './table-container-styles';
|
|
9
11
|
export const tableNodeSpecWithFixedToDOM = config => {
|
|
10
12
|
const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
11
13
|
return {
|
|
12
14
|
...tableNode,
|
|
13
15
|
toDOM: node => {
|
|
16
|
+
const isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
17
|
+
const isInContentMode = isTableInContentMode({
|
|
18
|
+
node,
|
|
19
|
+
allowColumnResizing: config.allowColumnResizing,
|
|
20
|
+
allowTableResizing: config.tableResizingEnabled,
|
|
21
|
+
isFullPageEditor,
|
|
22
|
+
isTableNested: config.isNested
|
|
23
|
+
}) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true);
|
|
14
24
|
const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
|
|
15
25
|
const tableMinWidth = getResizerMinWidth(node);
|
|
16
|
-
const isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
17
26
|
const attrs = {
|
|
18
27
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
19
28
|
'data-layout': node.attrs.layout,
|
|
@@ -23,6 +32,9 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
23
32
|
'data-ssr-placeholder': `table-${node.attrs.localId}`,
|
|
24
33
|
'data-ssr-placeholder-replace': `table-${node.attrs.localId}`
|
|
25
34
|
};
|
|
35
|
+
if (isInContentMode) {
|
|
36
|
+
attrs['data-initial-width-mode'] = 'content';
|
|
37
|
+
}
|
|
26
38
|
if (expValEquals('platform_editor_table_display_mode_in_to_dom', 'isEnabled', true)) {
|
|
27
39
|
attrs['data-table-display-mode'] = node.attrs.displayMode;
|
|
28
40
|
}
|
|
@@ -75,11 +87,13 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
75
87
|
class: 'pm-table-resizer-container',
|
|
76
88
|
style: convertToInlineCss({
|
|
77
89
|
'--ak-editor-table-gutter-padding': config.isTableScalingEnabled ? 'calc(var(--ak-editor--large-gutter-padding) * 2)' : 'calc(var(--ak-editor--large-gutter-padding) * 2 - var(--ak-editor-resizer-handle-spacing))',
|
|
78
|
-
'--ak-editor-table-width': resizableTableWidth,
|
|
90
|
+
'--ak-editor-table-width': isInContentMode ? 'max-content' : resizableTableWidth,
|
|
79
91
|
width: `var(--ak-editor-table-width)`
|
|
80
92
|
})
|
|
81
93
|
}, ['div', {
|
|
82
|
-
class: 'resizer-item display-handle',
|
|
94
|
+
class: expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true) ? 'resizer-item display-handle' : classNames('resizer-item', {
|
|
95
|
+
'display-handle': !isInContentMode
|
|
96
|
+
}),
|
|
83
97
|
style: convertToInlineCss({
|
|
84
98
|
position: 'relative',
|
|
85
99
|
userSelect: 'auto',
|
|
@@ -88,7 +102,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
88
102
|
'--ak-editor-table-min-width': `${tableMinWidth}px`,
|
|
89
103
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
90
104
|
maxWidth: getTableResizerContainerMaxWidthInCSS(config.isCommentEditor, config.isChromelessEditor, config.isTableScalingEnabled),
|
|
91
|
-
width: getTableResizerItemWidthInCSS(node, config.isCommentEditor, config.isChromelessEditor)
|
|
105
|
+
width: isInContentMode ? 'auto' : getTableResizerItemWidthInCSS(node, config.isCommentEditor, config.isChromelessEditor)
|
|
92
106
|
})
|
|
93
107
|
}, ['span', {
|
|
94
108
|
class: 'resizer-hover-zone'
|
|
@@ -10,7 +10,7 @@ import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardCol
|
|
|
10
10
|
import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from './commands/commands-with-analytics';
|
|
11
11
|
import { goToNextCellVertical } from './commands/go-to-next-cell';
|
|
12
12
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, insertTableWithNestingSupport } from './commands/insert';
|
|
13
|
-
export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, isTableResizingEnabled) {
|
|
13
|
+
export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, isTableResizingEnabled) {
|
|
14
14
|
var _pluginInjectionApi$a;
|
|
15
15
|
const list = {};
|
|
16
16
|
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
@@ -82,7 +82,7 @@ export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProvide
|
|
|
82
82
|
// Ignored via go/ees005
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
84
|
addColumnAfterVO.common, addColumnAfterCommand(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
85
|
-
if (moveRowDown.common && moveRowUp.common && moveColumnLeft.common && moveColumnRight.common) {
|
|
85
|
+
if (dragAndDropEnabled && moveRowDown.common && moveRowUp.common && moveColumnLeft.common && moveColumnRight.common) {
|
|
86
86
|
const isNewKeyMapExperiment = expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true);
|
|
87
87
|
// Move row/column shortcuts
|
|
88
88
|
/**
|