@atlaskit/editor-plugin-table 7.16.3 → 7.16.5
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 +16 -0
- package/dist/cjs/commands/insert.js +15 -6
- package/dist/cjs/plugin.js +16 -6
- package/dist/cjs/pm-plugins/keymap.js +5 -4
- package/dist/cjs/pm-plugins/table-width.js +13 -6
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/cjs/utils/alignment.js +5 -2
- package/dist/cjs/utils/create.js +12 -7
- package/dist/es2019/commands/insert.js +15 -6
- package/dist/es2019/plugin.js +15 -6
- package/dist/es2019/pm-plugins/keymap.js +2 -2
- package/dist/es2019/pm-plugins/table-width.js +13 -6
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/es2019/utils/alignment.js +4 -1
- package/dist/es2019/utils/create.js +13 -7
- package/dist/esm/commands/insert.js +15 -6
- package/dist/esm/plugin.js +16 -6
- package/dist/esm/pm-plugins/keymap.js +5 -4
- package/dist/esm/pm-plugins/table-width.js +13 -6
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/esm/utils/alignment.js +4 -1
- package/dist/esm/utils/create.js +12 -7
- package/dist/types/commands/insert.d.ts +2 -2
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/table-width.d.ts +1 -1
- package/dist/types/utils/alignment.d.ts +2 -0
- package/dist/types/utils/create.d.ts +8 -3
- package/dist/types-ts4.5/commands/insert.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -1
- package/dist/types-ts4.5/utils/alignment.d.ts +2 -0
- package/dist/types-ts4.5/utils/create.d.ts +8 -3
- package/package.json +1 -1
- package/src/commands/insert.ts +28 -22
- package/src/plugin.tsx +14 -8
- package/src/pm-plugins/keymap.ts +2 -0
- package/src/pm-plugins/table-width.ts +19 -5
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +18 -7
- package/src/utils/alignment.ts +4 -1
- package/src/utils/create.ts +24 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.16.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102210](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102210)
|
|
8
|
+
[`fe0d7aa7668a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fe0d7aa7668a) -
|
|
9
|
+
Set layout attribute for tables to align-left when inserted in full width editor
|
|
10
|
+
|
|
11
|
+
## 7.16.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#102667](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102667)
|
|
16
|
+
[`ab69107b7352`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ab69107b7352) -
|
|
17
|
+
Force placeholder drag handle to be positioned in first column to avoid overflow
|
|
18
|
+
|
|
3
19
|
## 7.16.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -143,9 +143,13 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
|
|
|
143
143
|
return true;
|
|
144
144
|
};
|
|
145
145
|
};
|
|
146
|
-
var createTable = exports.createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
146
|
+
var createTable = exports.createTable = function createTable(isTableScalingEnabled, isTableAlignmentEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
147
147
|
return function (state, dispatch) {
|
|
148
|
-
var table = (0, _utils3.createTableWithWidth)(
|
|
148
|
+
var table = (0, _utils3.createTableWithWidth)({
|
|
149
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
150
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
151
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
152
|
+
})(state.schema);
|
|
149
153
|
if (dispatch) {
|
|
150
154
|
var tr = (0, _utils.safeInsert)(table)(state.tr).scrollIntoView();
|
|
151
155
|
if (editorAnalyticsAPI) {
|
|
@@ -164,13 +168,18 @@ var createTable = exports.createTable = function createTable(isTableScalingEnabl
|
|
|
164
168
|
return true;
|
|
165
169
|
};
|
|
166
170
|
};
|
|
167
|
-
var insertTableWithSize = exports.insertTableWithSize = function insertTableWithSize(isFullWidthModeEnabled, isTableScalingEnabled, editorAnalyticsAPI) {
|
|
171
|
+
var insertTableWithSize = exports.insertTableWithSize = function insertTableWithSize(isFullWidthModeEnabled, isTableScalingEnabled, isTableAlignmentEnabled, editorAnalyticsAPI) {
|
|
168
172
|
return function (rowsCount, colsCount, inputMethod) {
|
|
169
173
|
return function (_ref) {
|
|
170
174
|
var tr = _ref.tr;
|
|
171
|
-
var tableNode = (0, _utils3.createTableWithWidth)(
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
var tableNode = (0, _utils3.createTableWithWidth)({
|
|
176
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
177
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
178
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
179
|
+
createTableProps: {
|
|
180
|
+
rowsCount: rowsCount,
|
|
181
|
+
colsCount: colsCount
|
|
182
|
+
}
|
|
174
183
|
})(tr.doc.type.schema);
|
|
175
184
|
var newTr = (0, _utils.safeInsert)(tableNode)(tr).scrollIntoView();
|
|
176
185
|
if (inputMethod) {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -106,7 +106,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
106
106
|
insertTable: function insertTable(analyticsPayload) {
|
|
107
107
|
return function (state, dispatch) {
|
|
108
108
|
var _api$contentInsertion, _api$contentInsertion2;
|
|
109
|
-
var node = (0, _utils2.createTableWithWidth)(
|
|
109
|
+
var node = (0, _utils2.createTableWithWidth)({
|
|
110
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
111
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
112
|
+
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.fullWidthEnabled
|
|
113
|
+
})(state.schema);
|
|
110
114
|
return (_api$contentInsertion = api === null || api === void 0 || (_api$contentInsertion2 = api.contentInsertion) === null || _api$contentInsertion2 === void 0 || (_api$contentInsertion2 = _api$contentInsertion2.actions) === null || _api$contentInsertion2 === void 0 ? void 0 : _api$contentInsertion2.insert({
|
|
111
115
|
state: state,
|
|
112
116
|
dispatch: dispatch,
|
|
@@ -124,7 +128,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
124
128
|
}
|
|
125
129
|
},
|
|
126
130
|
commands: {
|
|
127
|
-
insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
131
|
+
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.isTableAlignmentEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
128
132
|
},
|
|
129
133
|
nodes: function nodes() {
|
|
130
134
|
return [{
|
|
@@ -192,9 +196,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
192
196
|
dragAndDropEnabled = _ref7.dragAndDropEnabled,
|
|
193
197
|
_ref7$isTableScalingE = _ref7.isTableScalingEnabled,
|
|
194
198
|
isTableScalingEnabled = _ref7$isTableScalingE === void 0 ? false : _ref7$isTableScalingE,
|
|
199
|
+
_ref7$isTableAlignmen = _ref7.isTableAlignmentEnabled,
|
|
200
|
+
isTableAlignmentEnabled = _ref7$isTableAlignmen === void 0 ? false : _ref7$isTableAlignmen,
|
|
195
201
|
_ref7$fullWidthEnable = _ref7.fullWidthEnabled,
|
|
196
202
|
fullWidthEnabled = _ref7$fullWidthEnable === void 0 ? false : _ref7$fullWidthEnable;
|
|
197
|
-
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, fullWidthEnabled, api, getIntl);
|
|
203
|
+
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl);
|
|
198
204
|
}
|
|
199
205
|
}, {
|
|
200
206
|
name: 'tableSelectionKeymap',
|
|
@@ -252,10 +258,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
252
258
|
}, {
|
|
253
259
|
name: 'tableWidth',
|
|
254
260
|
plugin: function plugin(_ref13) {
|
|
255
|
-
var _options$fullWidthEna, _options$isTableScali;
|
|
261
|
+
var _options$fullWidthEna, _options$isTableScali, _options$isTableAlign;
|
|
256
262
|
var dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent,
|
|
257
263
|
dispatch = _ref13.dispatch;
|
|
258
|
-
return options !== null && options !== void 0 && options.tableResizingEnabled ? (0, _tableWidth.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false) : undefined;
|
|
264
|
+
return options !== null && options !== void 0 && options.tableResizingEnabled ? (0, _tableWidth.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$isTableAlign = options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled) !== null && _options$isTableAlign !== void 0 ? _options$isTableAlign : false) : undefined;
|
|
259
265
|
}
|
|
260
266
|
},
|
|
261
267
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -442,7 +448,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
442
448
|
var _api$table;
|
|
443
449
|
// see comment on tablesPlugin.getSharedState on usage
|
|
444
450
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
445
|
-
var tableNode = (0, _utils2.createTableWithWidth)(
|
|
451
|
+
var tableNode = (0, _utils2.createTableWithWidth)({
|
|
452
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
453
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
454
|
+
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled
|
|
455
|
+
})(state.schema);
|
|
446
456
|
var tr = insert(tableNode);
|
|
447
457
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
448
458
|
action: _analytics.ACTION.INSERTED,
|
|
@@ -18,14 +18,15 @@ var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with
|
|
|
18
18
|
function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
|
|
19
19
|
var _pluginInjectionApi$a;
|
|
20
20
|
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
21
|
+
var isTableAlignmentEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
22
|
+
var isFullWidthEnabled = arguments.length > 5 ? arguments[5] : undefined;
|
|
23
|
+
var pluginInjectionApi = arguments.length > 6 ? arguments[6] : undefined;
|
|
24
|
+
var getIntl = arguments.length > 7 ? arguments[7] : undefined;
|
|
24
25
|
var list = {};
|
|
25
26
|
var ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
26
27
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.nextCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
|
|
27
28
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.previousCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
|
|
28
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, (0, _insert.createTable)(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
|
|
29
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, (0, _insert.createTable)(isTableScalingEnabled, isTableAlignmentEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
|
|
29
30
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, (0, _commands.chainCommands)((0, _commandsWithAnalytics.deleteTableIfSelectedWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD), (0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD)), list);
|
|
30
31
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, _commands2.moveCursorBackward, list);
|
|
31
32
|
|
|
@@ -14,6 +14,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
14
14
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
15
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
16
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
|
+
var _alignment = require("../utils/alignment");
|
|
17
18
|
var _utils2 = require("./table-resizing/utils");
|
|
18
19
|
var _excluded = ["width"];
|
|
19
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -23,7 +24,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
23
24
|
* Also holds resizing state to hide / show table controls
|
|
24
25
|
*/
|
|
25
26
|
var pluginKey = exports.pluginKey = new _state.PluginKey('tableWidthPlugin');
|
|
26
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled) {
|
|
27
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled) {
|
|
27
28
|
return new _safePlugin.SafePlugin({
|
|
28
29
|
key: pluginKey,
|
|
29
30
|
state: {
|
|
@@ -96,8 +97,9 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
96
97
|
var referentialityTr = transactions.find(function (tr) {
|
|
97
98
|
return tr.getMeta('referentialityTableInserted');
|
|
98
99
|
});
|
|
99
|
-
var
|
|
100
|
-
|
|
100
|
+
var shouldPatchTableWidth = fullWidthEnabled && isTableScalingEnabled;
|
|
101
|
+
var shouldPatchTableAlignment = fullWidthEnabled && isTableAlignmentEnabled;
|
|
102
|
+
if (!isReplaceDocumentOperation && (!shouldPatchTableWidth && !shouldPatchTableAlignment || !referentialityTr)) {
|
|
101
103
|
return null;
|
|
102
104
|
}
|
|
103
105
|
var table = newState.schema.nodes.table;
|
|
@@ -157,10 +159,15 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
157
159
|
}
|
|
158
160
|
if (referentialityTr) {
|
|
159
161
|
referentialityTr.steps.forEach(function (step) {
|
|
160
|
-
step.getMap().forEach(function (
|
|
162
|
+
step.getMap().forEach(function (_, __, newStart, newEnd) {
|
|
161
163
|
newState.doc.nodesBetween(newStart, newEnd, function (node, pos) {
|
|
162
|
-
if (node.type === table
|
|
163
|
-
|
|
164
|
+
if (node.type === table) {
|
|
165
|
+
if (shouldPatchTableWidth && node.attrs.width !== _utils2.TABLE_MAX_WIDTH) {
|
|
166
|
+
tr.setNodeAttribute(pos, 'width', _utils2.TABLE_MAX_WIDTH);
|
|
167
|
+
}
|
|
168
|
+
if (shouldPatchTableAlignment) {
|
|
169
|
+
tr.setNodeAttribute(pos, 'layout', _alignment.ALIGN_START);
|
|
170
|
+
}
|
|
164
171
|
}
|
|
165
172
|
});
|
|
166
173
|
});
|
|
@@ -126,6 +126,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
126
126
|
var generateHandleByType = function generateHandleByType(type, appearance, gridColumn, indexes) {
|
|
127
127
|
var _rowHeights$reduce, _colWidths$reduce;
|
|
128
128
|
var isHover = type === 'hover';
|
|
129
|
+
var isPlaceholder = appearance === 'placeholder';
|
|
129
130
|
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
130
131
|
return sum + cur;
|
|
131
132
|
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
@@ -147,7 +148,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
147
148
|
width: '100%',
|
|
148
149
|
position: 'relative'
|
|
149
150
|
},
|
|
150
|
-
"data-testid": "table-floating-column-".concat(isHover ? colIndex : selectedColIndexes[0], "-drag-handle")
|
|
151
|
+
"data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0], "-drag-handle")
|
|
151
152
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
152
153
|
isDragMenuTarget: !isHover,
|
|
153
154
|
direction: "column",
|
|
@@ -172,10 +173,13 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
172
173
|
if (!tableActive) {
|
|
173
174
|
return null;
|
|
174
175
|
}
|
|
176
|
+
var selectedAppearance = isColumnSelected && isEntireTableSelected ? isInDanger ? 'danger' : 'selected' : 'placeholder';
|
|
175
177
|
|
|
176
178
|
// placeholder / selected need to always render at least one handle
|
|
177
179
|
// so it can be focused via keyboard shortcuts
|
|
178
|
-
handles.push(generateHandleByType('selected',
|
|
180
|
+
handles.push(generateHandleByType('selected', selectedAppearance,
|
|
181
|
+
// always position placeholder in first column to avoid overflow issues
|
|
182
|
+
selectedAppearance === 'placeholder' ? '1 / span 1' : "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length), selectedColIndexes));
|
|
179
183
|
if (hoveredCell && isTableHovered && colIndex !== undefined && !selectedColIndexes.includes(colIndex)) {
|
|
180
184
|
handles.push(generateHandleByType('hover', 'default', "".concat(colIndex + 1, " / span 1"), colIndexes));
|
|
181
185
|
}
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.normaliseAlignment = void 0;
|
|
6
|
+
exports.normaliseAlignment = exports.ALIGN_START = exports.ALIGN_CENTER = void 0;
|
|
7
|
+
var ALIGN_START = exports.ALIGN_START = 'align-start';
|
|
8
|
+
var ALIGN_CENTER = exports.ALIGN_CENTER = 'center';
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
|
|
9
12
|
* center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
|
|
10
13
|
*/
|
|
11
14
|
var normaliseAlignment = exports.normaliseAlignment = function normaliseAlignment(layout) {
|
|
12
|
-
return layout ===
|
|
15
|
+
return layout === ALIGN_CENTER || layout === ALIGN_START ? layout : ALIGN_CENTER;
|
|
13
16
|
};
|
package/dist/cjs/utils/create.js
CHANGED
|
@@ -10,16 +10,21 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
10
10
|
var _utils2 = require("../pm-plugins/table-resizing/utils");
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(
|
|
13
|
+
var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(_ref) {
|
|
14
|
+
var isTableScalingEnabled = _ref.isTableScalingEnabled,
|
|
15
|
+
isTableAlignmentEnabled = _ref.isTableAlignmentEnabled,
|
|
16
|
+
isFullWidthModeEnabled = _ref.isFullWidthModeEnabled,
|
|
17
|
+
createTableProps = _ref.createTableProps;
|
|
14
18
|
return function (schema) {
|
|
19
|
+
var attrsOverrides = {};
|
|
15
20
|
if (isTableScalingEnabled && isFullWidthModeEnabled) {
|
|
16
|
-
|
|
17
|
-
schema: schema,
|
|
18
|
-
tableWidth: _utils2.TABLE_MAX_WIDTH
|
|
19
|
-
}, createTableProps));
|
|
21
|
+
attrsOverrides.tableWidth = _utils2.TABLE_MAX_WIDTH;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
if (isTableAlignmentEnabled && isFullWidthModeEnabled) {
|
|
24
|
+
attrsOverrides.layout = 'align-start';
|
|
25
|
+
}
|
|
26
|
+
return (0, _utils.createTable)(_objectSpread(_objectSpread({
|
|
22
27
|
schema: schema
|
|
23
|
-
}, createTableProps));
|
|
28
|
+
}, createTableProps), attrsOverrides));
|
|
24
29
|
};
|
|
25
30
|
};
|
|
@@ -119,8 +119,12 @@ export const insertRow = (row, moveCursorToTheNewRow, isCellBackgroundDuplicated
|
|
|
119
119
|
}
|
|
120
120
|
return true;
|
|
121
121
|
};
|
|
122
|
-
export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) => (state, dispatch) => {
|
|
123
|
-
const table = createTableWithWidth(
|
|
122
|
+
export const createTable = (isTableScalingEnabled, isTableAlignmentEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) => (state, dispatch) => {
|
|
123
|
+
const table = createTableWithWidth({
|
|
124
|
+
isTableScalingEnabled,
|
|
125
|
+
isTableAlignmentEnabled,
|
|
126
|
+
isFullWidthModeEnabled
|
|
127
|
+
})(state.schema);
|
|
124
128
|
if (dispatch) {
|
|
125
129
|
const tr = safeInsert(table)(state.tr).scrollIntoView();
|
|
126
130
|
if (editorAnalyticsAPI) {
|
|
@@ -138,13 +142,18 @@ export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled, edito
|
|
|
138
142
|
}
|
|
139
143
|
return true;
|
|
140
144
|
};
|
|
141
|
-
export const insertTableWithSize = (isFullWidthModeEnabled, isTableScalingEnabled, editorAnalyticsAPI) => (rowsCount, colsCount, inputMethod) => {
|
|
145
|
+
export const insertTableWithSize = (isFullWidthModeEnabled, isTableScalingEnabled, isTableAlignmentEnabled, editorAnalyticsAPI) => (rowsCount, colsCount, inputMethod) => {
|
|
142
146
|
return ({
|
|
143
147
|
tr
|
|
144
148
|
}) => {
|
|
145
|
-
const tableNode = createTableWithWidth(
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
const tableNode = createTableWithWidth({
|
|
150
|
+
isTableScalingEnabled,
|
|
151
|
+
isFullWidthModeEnabled,
|
|
152
|
+
isTableAlignmentEnabled,
|
|
153
|
+
createTableProps: {
|
|
154
|
+
rowsCount: rowsCount,
|
|
155
|
+
colsCount: colsCount
|
|
156
|
+
}
|
|
148
157
|
})(tr.doc.type.schema);
|
|
149
158
|
const newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
150
159
|
if (inputMethod) {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -94,7 +94,11 @@ const tablesPlugin = ({
|
|
|
94
94
|
actions: {
|
|
95
95
|
insertTable: analyticsPayload => (state, dispatch) => {
|
|
96
96
|
var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
|
|
97
|
-
const node = createTableWithWidth(
|
|
97
|
+
const node = createTableWithWidth({
|
|
98
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
99
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
100
|
+
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.fullWidthEnabled
|
|
101
|
+
})(state.schema);
|
|
98
102
|
return (_api$contentInsertion = api === null || api === void 0 ? void 0 : (_api$contentInsertion2 = api.contentInsertion) === null || _api$contentInsertion2 === void 0 ? void 0 : (_api$contentInsertion3 = _api$contentInsertion2.actions) === null || _api$contentInsertion3 === void 0 ? void 0 : _api$contentInsertion3.insert({
|
|
99
103
|
state,
|
|
100
104
|
dispatch,
|
|
@@ -113,7 +117,7 @@ const tablesPlugin = ({
|
|
|
113
117
|
}
|
|
114
118
|
},
|
|
115
119
|
commands: {
|
|
116
|
-
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
120
|
+
insertTableWithSize: 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.isTableAlignmentEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
117
121
|
},
|
|
118
122
|
nodes() {
|
|
119
123
|
return [{
|
|
@@ -184,9 +188,10 @@ const tablesPlugin = ({
|
|
|
184
188
|
const {
|
|
185
189
|
dragAndDropEnabled,
|
|
186
190
|
isTableScalingEnabled = false,
|
|
191
|
+
isTableAlignmentEnabled = false,
|
|
187
192
|
fullWidthEnabled = false
|
|
188
193
|
} = options || {};
|
|
189
|
-
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, fullWidthEnabled, api, getIntl);
|
|
194
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl);
|
|
190
195
|
}
|
|
191
196
|
}, {
|
|
192
197
|
name: 'tableSelectionKeymap',
|
|
@@ -244,8 +249,8 @@ const tablesPlugin = ({
|
|
|
244
249
|
dispatchAnalyticsEvent,
|
|
245
250
|
dispatch
|
|
246
251
|
}) => {
|
|
247
|
-
var _options$fullWidthEna, _options$isTableScali;
|
|
248
|
-
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false) : undefined;
|
|
252
|
+
var _options$fullWidthEna, _options$isTableScali, _options$isTableAlign;
|
|
253
|
+
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$isTableAlign = options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled) !== null && _options$isTableAlign !== void 0 ? _options$isTableAlign : false) : undefined;
|
|
249
254
|
}
|
|
250
255
|
},
|
|
251
256
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -435,7 +440,11 @@ const tablesPlugin = ({
|
|
|
435
440
|
var _api$table;
|
|
436
441
|
// see comment on tablesPlugin.getSharedState on usage
|
|
437
442
|
const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
438
|
-
const tableNode = createTableWithWidth(
|
|
443
|
+
const tableNode = createTableWithWidth({
|
|
444
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
445
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
446
|
+
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled
|
|
447
|
+
})(state.schema);
|
|
439
448
|
const tr = insert(tableNode);
|
|
440
449
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
441
450
|
action: ACTION.INSERTED,
|
|
@@ -8,13 +8,13 @@ import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSele
|
|
|
8
8
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
|
|
10
10
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
|
-
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl) {
|
|
11
|
+
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl) {
|
|
12
12
|
var _pluginInjectionApi$a;
|
|
13
13
|
const list = {};
|
|
14
14
|
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
15
15
|
bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
|
|
16
16
|
bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
|
|
17
|
-
bindKeymapWithCommand(toggleTable.common, createTable(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
|
|
17
|
+
bindKeymapWithCommand(toggleTable.common, createTable(isTableScalingEnabled, isTableAlignmentEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
|
|
18
18
|
bindKeymapWithCommand(backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
|
|
19
19
|
bindKeymapWithCommand(backspace.common, moveCursorBackward, list);
|
|
20
20
|
|
|
@@ -11,9 +11,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
11
11
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
12
12
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
14
|
+
import { ALIGN_START } from '../utils/alignment';
|
|
14
15
|
import { TABLE_MAX_WIDTH } from './table-resizing/utils';
|
|
15
16
|
export const pluginKey = new PluginKey('tableWidthPlugin');
|
|
16
|
-
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled) => {
|
|
17
|
+
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled) => {
|
|
17
18
|
return new SafePlugin({
|
|
18
19
|
key: pluginKey,
|
|
19
20
|
state: {
|
|
@@ -87,8 +88,9 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTabl
|
|
|
87
88
|
return hasStepReplacingEntireDocument;
|
|
88
89
|
});
|
|
89
90
|
const referentialityTr = transactions.find(tr => tr.getMeta('referentialityTableInserted'));
|
|
90
|
-
const
|
|
91
|
-
|
|
91
|
+
const shouldPatchTableWidth = fullWidthEnabled && isTableScalingEnabled;
|
|
92
|
+
const shouldPatchTableAlignment = fullWidthEnabled && isTableAlignmentEnabled;
|
|
93
|
+
if (!isReplaceDocumentOperation && (!shouldPatchTableWidth && !shouldPatchTableAlignment || !referentialityTr)) {
|
|
92
94
|
return null;
|
|
93
95
|
}
|
|
94
96
|
const {
|
|
@@ -152,10 +154,15 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTabl
|
|
|
152
154
|
}
|
|
153
155
|
if (referentialityTr) {
|
|
154
156
|
referentialityTr.steps.forEach(step => {
|
|
155
|
-
step.getMap().forEach((
|
|
157
|
+
step.getMap().forEach((_, __, newStart, newEnd) => {
|
|
156
158
|
newState.doc.nodesBetween(newStart, newEnd, (node, pos) => {
|
|
157
|
-
if (node.type === table
|
|
158
|
-
|
|
159
|
+
if (node.type === table) {
|
|
160
|
+
if (shouldPatchTableWidth && node.attrs.width !== TABLE_MAX_WIDTH) {
|
|
161
|
+
tr.setNodeAttribute(pos, 'width', TABLE_MAX_WIDTH);
|
|
162
|
+
}
|
|
163
|
+
if (shouldPatchTableAlignment) {
|
|
164
|
+
tr.setNodeAttribute(pos, 'layout', ALIGN_START);
|
|
165
|
+
}
|
|
159
166
|
}
|
|
160
167
|
});
|
|
161
168
|
});
|
|
@@ -126,6 +126,7 @@ export const ColumnControls = ({
|
|
|
126
126
|
const generateHandleByType = (type, appearance, gridColumn, indexes) => {
|
|
127
127
|
var _rowHeights$reduce, _colWidths$reduce;
|
|
128
128
|
const isHover = type === 'hover';
|
|
129
|
+
const isPlaceholder = appearance === 'placeholder';
|
|
129
130
|
const previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce((sum, cur) => sum + cur, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
130
131
|
const previewWidth = (_colWidths$reduce = colWidths === null || colWidths === void 0 ? void 0 : colWidths.reduce((sum, v, i) => sum + (v !== null && v !== void 0 ? v : tableCellMinWidth) * (indexes.includes(i) ? 1 : 0), 0)) !== null && _colWidths$reduce !== void 0 ? _colWidths$reduce : tableCellMinWidth;
|
|
131
132
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -143,7 +144,7 @@ export const ColumnControls = ({
|
|
|
143
144
|
width: '100%',
|
|
144
145
|
position: 'relative'
|
|
145
146
|
},
|
|
146
|
-
"data-testid": `table-floating-column-${isHover ? colIndex : selectedColIndexes[0]}-drag-handle`
|
|
147
|
+
"data-testid": `table-floating-column-${isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0]}-drag-handle`
|
|
147
148
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
148
149
|
isDragMenuTarget: !isHover,
|
|
149
150
|
direction: "column",
|
|
@@ -168,10 +169,13 @@ export const ColumnControls = ({
|
|
|
168
169
|
if (!tableActive) {
|
|
169
170
|
return null;
|
|
170
171
|
}
|
|
172
|
+
const selectedAppearance = isColumnSelected && isEntireTableSelected ? isInDanger ? 'danger' : 'selected' : 'placeholder';
|
|
171
173
|
|
|
172
174
|
// placeholder / selected need to always render at least one handle
|
|
173
175
|
// so it can be focused via keyboard shortcuts
|
|
174
|
-
handles.push(generateHandleByType('selected',
|
|
176
|
+
handles.push(generateHandleByType('selected', selectedAppearance,
|
|
177
|
+
// always position placeholder in first column to avoid overflow issues
|
|
178
|
+
selectedAppearance === 'placeholder' ? '1 / span 1' : `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}`, selectedColIndexes));
|
|
175
179
|
if (hoveredCell && isTableHovered && colIndex !== undefined && !selectedColIndexes.includes(colIndex)) {
|
|
176
180
|
handles.push(generateHandleByType('hover', 'default', `${colIndex + 1} / span 1`, colIndexes));
|
|
177
181
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export const ALIGN_START = 'align-start';
|
|
2
|
+
export const ALIGN_CENTER = 'center';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
|
|
3
6
|
* center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
|
|
4
7
|
*/
|
|
5
|
-
export const normaliseAlignment = layout => layout ===
|
|
8
|
+
export const normaliseAlignment = layout => layout === ALIGN_CENTER || layout === ALIGN_START ? layout : ALIGN_CENTER;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
2
2
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
3
|
-
export const createTableWithWidth = (
|
|
3
|
+
export const createTableWithWidth = ({
|
|
4
|
+
isTableScalingEnabled,
|
|
5
|
+
isTableAlignmentEnabled,
|
|
6
|
+
isFullWidthModeEnabled,
|
|
7
|
+
createTableProps
|
|
8
|
+
}) => schema => {
|
|
9
|
+
const attrsOverrides = {};
|
|
4
10
|
if (isTableScalingEnabled && isFullWidthModeEnabled) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
11
|
+
attrsOverrides.tableWidth = TABLE_MAX_WIDTH;
|
|
12
|
+
}
|
|
13
|
+
if (isTableAlignmentEnabled && isFullWidthModeEnabled) {
|
|
14
|
+
attrsOverrides.layout = 'align-start';
|
|
10
15
|
}
|
|
11
16
|
return createTable({
|
|
12
17
|
schema,
|
|
13
|
-
...createTableProps
|
|
18
|
+
...createTableProps,
|
|
19
|
+
...attrsOverrides
|
|
14
20
|
});
|
|
15
21
|
};
|
|
@@ -134,9 +134,13 @@ export var insertRow = function insertRow(row, moveCursorToTheNewRow, isCellBack
|
|
|
134
134
|
return true;
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
|
-
export var createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
137
|
+
export var createTable = function createTable(isTableScalingEnabled, isTableAlignmentEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
138
138
|
return function (state, dispatch) {
|
|
139
|
-
var table = createTableWithWidth(
|
|
139
|
+
var table = createTableWithWidth({
|
|
140
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
141
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
142
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
143
|
+
})(state.schema);
|
|
140
144
|
if (dispatch) {
|
|
141
145
|
var tr = safeInsert(table)(state.tr).scrollIntoView();
|
|
142
146
|
if (editorAnalyticsAPI) {
|
|
@@ -155,13 +159,18 @@ export var createTable = function createTable(isTableScalingEnabled, isFullWidth
|
|
|
155
159
|
return true;
|
|
156
160
|
};
|
|
157
161
|
};
|
|
158
|
-
export var insertTableWithSize = function insertTableWithSize(isFullWidthModeEnabled, isTableScalingEnabled, editorAnalyticsAPI) {
|
|
162
|
+
export var insertTableWithSize = function insertTableWithSize(isFullWidthModeEnabled, isTableScalingEnabled, isTableAlignmentEnabled, editorAnalyticsAPI) {
|
|
159
163
|
return function (rowsCount, colsCount, inputMethod) {
|
|
160
164
|
return function (_ref) {
|
|
161
165
|
var tr = _ref.tr;
|
|
162
|
-
var tableNode = createTableWithWidth(
|
|
163
|
-
|
|
164
|
-
|
|
166
|
+
var tableNode = createTableWithWidth({
|
|
167
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
168
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
169
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
170
|
+
createTableProps: {
|
|
171
|
+
rowsCount: rowsCount,
|
|
172
|
+
colsCount: colsCount
|
|
173
|
+
}
|
|
165
174
|
})(tr.doc.type.schema);
|
|
166
175
|
var newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
167
176
|
if (inputMethod) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -99,7 +99,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
99
99
|
insertTable: function insertTable(analyticsPayload) {
|
|
100
100
|
return function (state, dispatch) {
|
|
101
101
|
var _api$contentInsertion, _api$contentInsertion2;
|
|
102
|
-
var node = createTableWithWidth(
|
|
102
|
+
var node = createTableWithWidth({
|
|
103
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
104
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
105
|
+
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.fullWidthEnabled
|
|
106
|
+
})(state.schema);
|
|
103
107
|
return (_api$contentInsertion = api === null || api === void 0 || (_api$contentInsertion2 = api.contentInsertion) === null || _api$contentInsertion2 === void 0 || (_api$contentInsertion2 = _api$contentInsertion2.actions) === null || _api$contentInsertion2 === void 0 ? void 0 : _api$contentInsertion2.insert({
|
|
104
108
|
state: state,
|
|
105
109
|
dispatch: dispatch,
|
|
@@ -117,7 +121,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
117
121
|
}
|
|
118
122
|
},
|
|
119
123
|
commands: {
|
|
120
|
-
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
124
|
+
insertTableWithSize: 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.isTableAlignmentEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
121
125
|
},
|
|
122
126
|
nodes: function nodes() {
|
|
123
127
|
return [{
|
|
@@ -185,9 +189,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
185
189
|
dragAndDropEnabled = _ref7.dragAndDropEnabled,
|
|
186
190
|
_ref7$isTableScalingE = _ref7.isTableScalingEnabled,
|
|
187
191
|
isTableScalingEnabled = _ref7$isTableScalingE === void 0 ? false : _ref7$isTableScalingE,
|
|
192
|
+
_ref7$isTableAlignmen = _ref7.isTableAlignmentEnabled,
|
|
193
|
+
isTableAlignmentEnabled = _ref7$isTableAlignmen === void 0 ? false : _ref7$isTableAlignmen,
|
|
188
194
|
_ref7$fullWidthEnable = _ref7.fullWidthEnabled,
|
|
189
195
|
fullWidthEnabled = _ref7$fullWidthEnable === void 0 ? false : _ref7$fullWidthEnable;
|
|
190
|
-
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, fullWidthEnabled, api, getIntl);
|
|
196
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl);
|
|
191
197
|
}
|
|
192
198
|
}, {
|
|
193
199
|
name: 'tableSelectionKeymap',
|
|
@@ -245,10 +251,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
245
251
|
}, {
|
|
246
252
|
name: 'tableWidth',
|
|
247
253
|
plugin: function plugin(_ref13) {
|
|
248
|
-
var _options$fullWidthEna, _options$isTableScali;
|
|
254
|
+
var _options$fullWidthEna, _options$isTableScali, _options$isTableAlign;
|
|
249
255
|
var dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent,
|
|
250
256
|
dispatch = _ref13.dispatch;
|
|
251
|
-
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false) : undefined;
|
|
257
|
+
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$isTableAlign = options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled) !== null && _options$isTableAlign !== void 0 ? _options$isTableAlign : false) : undefined;
|
|
252
258
|
}
|
|
253
259
|
},
|
|
254
260
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -435,7 +441,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
435
441
|
var _api$table;
|
|
436
442
|
// see comment on tablesPlugin.getSharedState on usage
|
|
437
443
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
438
|
-
var tableNode = createTableWithWidth(
|
|
444
|
+
var tableNode = createTableWithWidth({
|
|
445
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
446
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
447
|
+
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled
|
|
448
|
+
})(state.schema);
|
|
439
449
|
var tr = insert(tableNode);
|
|
440
450
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
441
451
|
action: ACTION.INSERTED,
|