@atlaskit/editor-plugin-table 7.16.1 → 7.16.2
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 +9 -0
- package/dist/cjs/commands/insert.js +14 -2
- package/dist/cjs/nodeviews/TableComponent.js +4 -2
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/cjs/nodeviews/TableContainer.js +72 -34
- package/dist/cjs/nodeviews/table.js +7 -4
- package/dist/cjs/plugin.js +12 -3
- package/dist/cjs/pm-plugins/keymap.js +1 -13
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/commands/insert.js +15 -3
- package/dist/es2019/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/es2019/nodeviews/TableContainer.js +51 -11
- package/dist/es2019/nodeviews/table.js +7 -4
- package/dist/es2019/plugin.js +11 -3
- package/dist/es2019/pm-plugins/keymap.js +4 -14
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/commands/insert.js +15 -3
- package/dist/esm/nodeviews/TableComponent.js +4 -2
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/esm/nodeviews/TableContainer.js +73 -35
- package/dist/esm/nodeviews/table.js +7 -4
- package/dist/esm/plugin.js +12 -3
- package/dist/esm/pm-plugins/keymap.js +4 -16
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/commands/insert.d.ts +3 -2
- package/dist/types/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/nodeviews/TableContainer.d.ts +7 -5
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/commands/insert.d.ts +3 -2
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -5
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/package.json +5 -5
- package/src/commands/insert.ts +26 -18
- package/src/nodeviews/TableComponent.tsx +3 -0
- package/src/nodeviews/TableComponentWithSharedState.tsx +1 -0
- package/src/nodeviews/TableContainer.tsx +75 -13
- package/src/nodeviews/table.tsx +4 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +18 -8
- package/src/pm-plugins/keymap.ts +4 -25
- package/src/pm-plugins/main.ts +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/custom-steps';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
@@ -134,11 +134,23 @@ export var insertRow = function insertRow(row, moveCursorToTheNewRow, isCellBack
|
|
|
134
134
|
return true;
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
|
-
export var createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled) {
|
|
137
|
+
export var createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
138
138
|
return function (state, dispatch) {
|
|
139
139
|
var table = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
|
|
140
140
|
if (dispatch) {
|
|
141
|
-
|
|
141
|
+
var tr = safeInsert(table)(state.tr).scrollIntoView();
|
|
142
|
+
if (editorAnalyticsAPI) {
|
|
143
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
144
|
+
action: ACTION.INSERTED,
|
|
145
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
146
|
+
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
147
|
+
attributes: {
|
|
148
|
+
inputMethod: INPUT_METHOD.SHORTCUT
|
|
149
|
+
},
|
|
150
|
+
eventType: EVENT_TYPE.TRACK
|
|
151
|
+
})(tr);
|
|
152
|
+
}
|
|
153
|
+
dispatch(tr);
|
|
142
154
|
}
|
|
143
155
|
return true;
|
|
144
156
|
};
|
|
@@ -645,7 +645,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
645
645
|
pluginInjectionApi = _this$props11.pluginInjectionApi,
|
|
646
646
|
isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
|
|
647
647
|
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
|
|
648
|
-
isTableScalingEnabled = _this$props11.isTableScalingEnabled
|
|
648
|
+
isTableScalingEnabled = _this$props11.isTableScalingEnabled,
|
|
649
|
+
isTableAlignmentEnabled = _this$props11.isTableAlignmentEnabled;
|
|
649
650
|
var _this$props12 = this.props,
|
|
650
651
|
isInDanger = _this$props12.isInDanger,
|
|
651
652
|
hoveredRows = _this$props12.hoveredRows,
|
|
@@ -754,7 +755,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
754
755
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
755
756
|
isResizing: isResizing,
|
|
756
757
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
757
|
-
isWholeTableInDanger: isWholeTableInDanger
|
|
758
|
+
isWholeTableInDanger: isWholeTableInDanger,
|
|
759
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
758
760
|
}, /*#__PURE__*/React.createElement("div", {
|
|
759
761
|
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
760
762
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -62,6 +62,7 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
|
|
|
62
62
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
63
63
|
isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
|
|
64
64
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
65
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
65
66
|
tableActive: tableActive,
|
|
66
67
|
ordering: ordering,
|
|
67
68
|
isResizing: isResizing,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { forwardRef, useCallback, useRef, useState } from 'react';
|
|
2
|
+
import React, { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
@@ -21,19 +21,57 @@ export var InnerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
21
21
|
"data-testid": "table-container"
|
|
22
22
|
}, children);
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
var centerAlignStyle = {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
justifyContent: 'center'
|
|
27
|
+
};
|
|
28
|
+
var leftAlignStyle = {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'flex-start'
|
|
31
|
+
};
|
|
32
|
+
var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
|
|
33
|
+
var node = _ref2.node,
|
|
34
|
+
children = _ref2.children;
|
|
35
|
+
var alignment = node.attrs.layout;
|
|
36
|
+
var style = useMemo(function () {
|
|
37
|
+
return alignment === 'align-start' ? leftAlignStyle : centerAlignStyle;
|
|
38
|
+
}, [alignment]);
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
"data-testid": "table-alignment-container",
|
|
41
|
+
style: style
|
|
42
|
+
}, children);
|
|
43
|
+
};
|
|
44
|
+
var AlignmentTableContainerWrapper = function AlignmentTableContainerWrapper(_ref3) {
|
|
45
|
+
var isTableAlignmentEnabled = _ref3.isTableAlignmentEnabled,
|
|
46
|
+
node = _ref3.node,
|
|
47
|
+
children = _ref3.children;
|
|
48
|
+
if (!isTableAlignmentEnabled) {
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
"data-testid": "table-alignment-container",
|
|
51
|
+
style: {
|
|
52
|
+
display: 'flex',
|
|
53
|
+
justifyContent: 'center'
|
|
54
|
+
}
|
|
55
|
+
}, children);
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/React.createElement(AlignmentTableContainer, {
|
|
58
|
+
node: node
|
|
59
|
+
}, children);
|
|
60
|
+
};
|
|
61
|
+
export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
|
|
62
|
+
var children = _ref4.children,
|
|
63
|
+
className = _ref4.className,
|
|
64
|
+
node = _ref4.node,
|
|
65
|
+
containerWidth = _ref4.containerWidth,
|
|
66
|
+
editorView = _ref4.editorView,
|
|
67
|
+
getPos = _ref4.getPos,
|
|
68
|
+
tableRef = _ref4.tableRef,
|
|
69
|
+
isResizing = _ref4.isResizing,
|
|
70
|
+
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
71
|
+
tableWrapperHeight = _ref4.tableWrapperHeight,
|
|
72
|
+
isWholeTableInDanger = _ref4.isWholeTableInDanger,
|
|
73
|
+
isTableScalingEnabled = _ref4.isTableScalingEnabled,
|
|
74
|
+
isTableAlignmentEnabled = _ref4.isTableAlignmentEnabled;
|
|
37
75
|
var containerRef = useRef(null);
|
|
38
76
|
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
39
77
|
var _useState = useState(false),
|
|
@@ -122,11 +160,9 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
122
160
|
onResizeStop: onResizeStop
|
|
123
161
|
};
|
|
124
162
|
var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
125
|
-
return /*#__PURE__*/React.createElement(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
justifyContent: 'center'
|
|
129
|
-
}
|
|
163
|
+
return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
|
|
164
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
165
|
+
node: node
|
|
130
166
|
}, /*#__PURE__*/React.createElement("div", {
|
|
131
167
|
style: {
|
|
132
168
|
width: tableWidthRef.current,
|
|
@@ -146,21 +182,22 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
146
182
|
node: node
|
|
147
183
|
}, children))));
|
|
148
184
|
});
|
|
149
|
-
export var TableContainer = function TableContainer(
|
|
150
|
-
var children =
|
|
151
|
-
node =
|
|
152
|
-
className =
|
|
153
|
-
editorWidth =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
185
|
+
export var TableContainer = function TableContainer(_ref5) {
|
|
186
|
+
var children = _ref5.children,
|
|
187
|
+
node = _ref5.node,
|
|
188
|
+
className = _ref5.className,
|
|
189
|
+
editorWidth = _ref5.containerWidth.width,
|
|
190
|
+
editorView = _ref5.editorView,
|
|
191
|
+
getPos = _ref5.getPos,
|
|
192
|
+
tableRef = _ref5.tableRef,
|
|
193
|
+
isNested = _ref5.isNested,
|
|
194
|
+
tableWrapperHeight = _ref5.tableWrapperHeight,
|
|
195
|
+
isResizing = _ref5.isResizing,
|
|
196
|
+
pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
197
|
+
isWholeTableInDanger = _ref5.isWholeTableInDanger,
|
|
198
|
+
isTableResizingEnabled = _ref5.isTableResizingEnabled,
|
|
199
|
+
isTableScalingEnabled = _ref5.isTableScalingEnabled,
|
|
200
|
+
isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled;
|
|
164
201
|
if (isTableResizingEnabled && !isNested) {
|
|
165
202
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
166
203
|
className: className,
|
|
@@ -173,7 +210,8 @@ export var TableContainer = function TableContainer(_ref3) {
|
|
|
173
210
|
isResizing: isResizing,
|
|
174
211
|
pluginInjectionApi: pluginInjectionApi,
|
|
175
212
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
176
|
-
isWholeTableInDanger: isWholeTableInDanger
|
|
213
|
+
isWholeTableInDanger: isWholeTableInDanger,
|
|
214
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
177
215
|
}, children);
|
|
178
216
|
}
|
|
179
217
|
return /*#__PURE__*/React.createElement(InnerContainer, {
|
|
@@ -169,7 +169,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
169
169
|
},
|
|
170
170
|
editorView: props.view,
|
|
171
171
|
render: function render(pluginStates) {
|
|
172
|
-
var _props$options;
|
|
172
|
+
var _props$options, _props$options2;
|
|
173
173
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
174
174
|
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
175
175
|
pluginState = pluginStates.pluginState,
|
|
@@ -201,8 +201,9 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
201
201
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
202
202
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
203
203
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
204
|
-
isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled
|
|
204
|
+
isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
|
|
205
205
|
,
|
|
206
|
+
isTableAlignmentEnabled: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.isTableAlignmentEnabled,
|
|
206
207
|
tableActive: tableActive,
|
|
207
208
|
ordering: pluginState.ordering,
|
|
208
209
|
isResizing: isResizing,
|
|
@@ -277,7 +278,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
277
278
|
return TableView;
|
|
278
279
|
}(ReactNodeView);
|
|
279
280
|
export { TableView as default };
|
|
280
|
-
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
|
|
281
|
+
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled) {
|
|
281
282
|
var _getPluginState2 = getPluginState(view.state),
|
|
282
283
|
pluginConfig = _getPluginState2.pluginConfig,
|
|
283
284
|
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
@@ -302,7 +303,9 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
302
303
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
303
304
|
isTableResizingEnabled: isTableResizingEnabled,
|
|
304
305
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
305
|
-
isTableScalingEnabled: isTableScalingEnabled
|
|
306
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
307
|
+
// same as options.isTableScalingEnabled
|
|
308
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
306
309
|
},
|
|
307
310
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
308
311
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
3
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
@@ -103,7 +106,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
103
106
|
node: node,
|
|
104
107
|
options: {
|
|
105
108
|
selectNodeInserted: false,
|
|
106
|
-
analyticsPayload: analyticsPayload
|
|
109
|
+
analyticsPayload: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
|
|
110
|
+
attributes: _objectSpread(_objectSpread({}, analyticsPayload.attributes), {}, {
|
|
111
|
+
localId: node.attrs.localId
|
|
112
|
+
})
|
|
113
|
+
})
|
|
107
114
|
}
|
|
108
115
|
})) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
|
|
109
116
|
};
|
|
@@ -428,13 +435,15 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
428
435
|
var _api$table;
|
|
429
436
|
// see comment on tablesPlugin.getSharedState on usage
|
|
430
437
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
431
|
-
var
|
|
438
|
+
var tableNode = createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema);
|
|
439
|
+
var tr = insert(tableNode);
|
|
432
440
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
433
441
|
action: ACTION.INSERTED,
|
|
434
442
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
435
443
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
436
444
|
attributes: {
|
|
437
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
445
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
446
|
+
localId: tableNode.attrs.localId
|
|
438
447
|
},
|
|
439
448
|
eventType: EVENT_TYPE.TRACK
|
|
440
449
|
})(tr);
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import {
|
|
6
|
+
import { goToNextCell, moveCursorBackward } from '../commands';
|
|
7
7
|
import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
8
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
|
-
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
|
|
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
|
-
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
12
|
-
var createTableWithAnalytics = function createTableWithAnalytics(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
13
|
-
return withEditorAnalyticsAPI({
|
|
14
|
-
action: ACTION.INSERTED,
|
|
15
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
16
|
-
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
17
|
-
attributes: {
|
|
18
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
19
|
-
},
|
|
20
|
-
eventType: EVENT_TYPE.TRACK
|
|
21
|
-
})(editorAnalyticsAPI)(createTable(isTableScalingEnabled, isFullWidthModeEnabled));
|
|
22
|
-
};
|
|
23
11
|
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
|
|
24
12
|
var _pluginInjectionApi$a;
|
|
25
13
|
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
@@ -30,7 +18,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
30
18
|
var ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
31
19
|
bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
|
|
32
20
|
bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
|
|
33
|
-
bindKeymapWithCommand(toggleTable.common,
|
|
21
|
+
bindKeymapWithCommand(toggleTable.common, createTable(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
|
|
34
22
|
bindKeymapWithCommand(backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
|
|
35
23
|
bindKeymapWithCommand(backspace.common, moveCursorBackward, list);
|
|
36
24
|
|
|
@@ -253,7 +253,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
253
253
|
},
|
|
254
254
|
nodeViews: {
|
|
255
255
|
table: function table(node, view, getPos) {
|
|
256
|
-
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi);
|
|
256
|
+
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled);
|
|
257
257
|
},
|
|
258
258
|
tableRow: function tableRow(node, view, getPos) {
|
|
259
259
|
return new TableRow(node, view, getPos, eventDispatcher);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -7,5 +8,5 @@ export declare const addColumnBefore: (isTableScalingEnabled?: boolean) => Comma
|
|
|
7
8
|
export declare const addColumnAfter: (isTableScalingEnabled?: boolean) => Command;
|
|
8
9
|
export declare const insertColumn: (isTableScalingEnabled?: boolean, isCellBackgroundDuplicated?: boolean) => (column: number) => Command;
|
|
9
10
|
export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean, isCellBackgroundDuplicated?: boolean) => Command;
|
|
10
|
-
export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean) => Command;
|
|
11
|
+
export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null) => Command;
|
|
11
12
|
export declare const insertTableWithSize: (isFullWidthModeEnabled?: boolean, isTableScalingEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER) => EditorCommand;
|
|
@@ -24,25 +24,27 @@ type ResizableTableContainerProps = {
|
|
|
24
24
|
tableRef: HTMLTableElement;
|
|
25
25
|
isResizing?: boolean;
|
|
26
26
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
27
|
-
isTableScalingEnabled?: boolean;
|
|
28
27
|
tableWrapperHeight?: number;
|
|
29
28
|
isWholeTableInDanger?: boolean;
|
|
29
|
+
isTableScalingEnabled?: boolean;
|
|
30
|
+
isTableAlignmentEnabled?: boolean;
|
|
30
31
|
};
|
|
31
|
-
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi,
|
|
32
|
+
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, tableWrapperHeight, isWholeTableInDanger, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
|
|
32
33
|
type TableContainerProps = {
|
|
33
34
|
node: PMNode;
|
|
34
35
|
className: string;
|
|
35
36
|
containerWidth: EditorContainerWidth;
|
|
36
|
-
isTableResizingEnabled: boolean | undefined;
|
|
37
37
|
editorView: EditorView;
|
|
38
38
|
getPos: () => number | undefined;
|
|
39
39
|
tableRef: HTMLTableElement;
|
|
40
40
|
isNested: boolean;
|
|
41
41
|
isResizing?: boolean;
|
|
42
42
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
43
|
-
isTableScalingEnabled?: boolean;
|
|
44
43
|
tableWrapperHeight?: number;
|
|
45
44
|
isWholeTableInDanger?: boolean;
|
|
45
|
+
isTableResizingEnabled: boolean | undefined;
|
|
46
|
+
isTableScalingEnabled?: boolean;
|
|
47
|
+
isTableAlignmentEnabled?: boolean;
|
|
46
48
|
};
|
|
47
|
-
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth },
|
|
49
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
48
50
|
export {};
|
|
@@ -32,5 +32,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
32
32
|
}): boolean;
|
|
33
33
|
destroy(): void;
|
|
34
34
|
}
|
|
35
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
35
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean) => NodeView;
|
|
36
36
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -7,5 +8,5 @@ export declare const addColumnBefore: (isTableScalingEnabled?: boolean) => Comma
|
|
|
7
8
|
export declare const addColumnAfter: (isTableScalingEnabled?: boolean) => Command;
|
|
8
9
|
export declare const insertColumn: (isTableScalingEnabled?: boolean, isCellBackgroundDuplicated?: boolean) => (column: number) => Command;
|
|
9
10
|
export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean, isCellBackgroundDuplicated?: boolean) => Command;
|
|
10
|
-
export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean) => Command;
|
|
11
|
+
export declare const createTable: (isTableScalingEnabled?: boolean, isFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null) => Command;
|
|
11
12
|
export declare const insertTableWithSize: (isFullWidthModeEnabled?: boolean, isTableScalingEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER) => EditorCommand;
|
|
@@ -24,25 +24,27 @@ type ResizableTableContainerProps = {
|
|
|
24
24
|
tableRef: HTMLTableElement;
|
|
25
25
|
isResizing?: boolean;
|
|
26
26
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
27
|
-
isTableScalingEnabled?: boolean;
|
|
28
27
|
tableWrapperHeight?: number;
|
|
29
28
|
isWholeTableInDanger?: boolean;
|
|
29
|
+
isTableScalingEnabled?: boolean;
|
|
30
|
+
isTableAlignmentEnabled?: boolean;
|
|
30
31
|
};
|
|
31
|
-
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi,
|
|
32
|
+
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, tableWrapperHeight, isWholeTableInDanger, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
|
|
32
33
|
type TableContainerProps = {
|
|
33
34
|
node: PMNode;
|
|
34
35
|
className: string;
|
|
35
36
|
containerWidth: EditorContainerWidth;
|
|
36
|
-
isTableResizingEnabled: boolean | undefined;
|
|
37
37
|
editorView: EditorView;
|
|
38
38
|
getPos: () => number | undefined;
|
|
39
39
|
tableRef: HTMLTableElement;
|
|
40
40
|
isNested: boolean;
|
|
41
41
|
isResizing?: boolean;
|
|
42
42
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
43
|
-
isTableScalingEnabled?: boolean;
|
|
44
43
|
tableWrapperHeight?: number;
|
|
45
44
|
isWholeTableInDanger?: boolean;
|
|
45
|
+
isTableResizingEnabled: boolean | undefined;
|
|
46
|
+
isTableScalingEnabled?: boolean;
|
|
47
|
+
isTableAlignmentEnabled?: boolean;
|
|
46
48
|
};
|
|
47
|
-
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth },
|
|
49
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableAlignmentEnabled, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
48
50
|
export {};
|
|
@@ -32,5 +32,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
32
32
|
}): boolean;
|
|
33
33
|
destroy(): void;
|
|
34
34
|
}
|
|
35
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
35
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean) => NodeView;
|
|
36
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.16.
|
|
3
|
+
"version": "7.16.2",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^36.8.0",
|
|
32
|
-
"@atlaskit/button": "^17.
|
|
32
|
+
"@atlaskit/button": "^17.15.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-common": "^80.4.0",
|
|
35
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^2.11.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.7.0",
|
|
46
|
-
"@atlaskit/icon": "^22.
|
|
46
|
+
"@atlaskit/icon": "^22.3.0",
|
|
47
47
|
"@atlaskit/menu": "^2.3.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
49
49
|
"@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
|
|
50
50
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
52
|
-
"@atlaskit/primitives": "^6.
|
|
52
|
+
"@atlaskit/primitives": "^6.3.0",
|
|
53
53
|
"@atlaskit/theme": "^12.8.0",
|
|
54
54
|
"@atlaskit/toggle": "^13.1.0",
|
|
55
|
-
"@atlaskit/tokens": "^1.
|
|
55
|
+
"@atlaskit/tokens": "^1.49.0",
|
|
56
56
|
"@atlaskit/tooltip": "^18.4.0",
|
|
57
57
|
"@babel/runtime": "^7.0.0",
|
|
58
58
|
"@emotion/react": "^11.7.1",
|
package/src/commands/insert.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/custom-steps';
|
|
3
|
-
import type {
|
|
4
|
-
EditorAnalyticsAPI,
|
|
5
|
-
INPUT_METHOD,
|
|
6
|
-
} from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
7
4
|
import {
|
|
8
5
|
ACTION,
|
|
9
6
|
ACTION_SUBJECT,
|
|
10
7
|
ACTION_SUBJECT_ID,
|
|
11
8
|
EVENT_TYPE,
|
|
9
|
+
INPUT_METHOD,
|
|
12
10
|
TABLE_OVERFLOW_CHANGE_TRIGGER,
|
|
13
11
|
} from '@atlaskit/editor-common/analytics';
|
|
14
12
|
import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
|
|
@@ -203,22 +201,32 @@ export const insertRow =
|
|
|
203
201
|
return true;
|
|
204
202
|
};
|
|
205
203
|
|
|
206
|
-
export const createTable =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)(state.schema);
|
|
204
|
+
export const createTable = (
|
|
205
|
+
isTableScalingEnabled?: boolean,
|
|
206
|
+
isFullWidthModeEnabled?: boolean,
|
|
207
|
+
editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null,
|
|
208
|
+
): Command => (state, dispatch) => {
|
|
209
|
+
const table = createTableWithWidth(
|
|
210
|
+
isTableScalingEnabled,
|
|
211
|
+
isFullWidthModeEnabled,
|
|
212
|
+
)(state.schema);
|
|
216
213
|
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
if (dispatch) {
|
|
215
|
+
const tr = safeInsert(table)(state.tr).scrollIntoView();
|
|
216
|
+
if (editorAnalyticsAPI) {
|
|
217
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
218
|
+
action: ACTION.INSERTED,
|
|
219
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
220
|
+
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
221
|
+
attributes: { inputMethod: INPUT_METHOD.SHORTCUT },
|
|
222
|
+
eventType: EVENT_TYPE.TRACK,
|
|
223
|
+
})(tr);
|
|
219
224
|
}
|
|
220
|
-
|
|
221
|
-
}
|
|
225
|
+
dispatch(tr);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
222
230
|
|
|
223
231
|
export const insertTableWithSize =
|
|
224
232
|
(
|
|
@@ -104,6 +104,7 @@ export interface ComponentProps {
|
|
|
104
104
|
isMediaFullscreen?: boolean;
|
|
105
105
|
isDragAndDropEnabled?: boolean;
|
|
106
106
|
isTableScalingEnabled?: boolean;
|
|
107
|
+
isTableAlignmentEnabled?: boolean;
|
|
107
108
|
tableActive: boolean;
|
|
108
109
|
ordering?: TableColumnOrdering;
|
|
109
110
|
isResizing?: boolean;
|
|
@@ -687,6 +688,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
687
688
|
isDragAndDropEnabled,
|
|
688
689
|
getEditorFeatureFlags,
|
|
689
690
|
isTableScalingEnabled, // here we can use options.isTableScalingEnabled
|
|
691
|
+
isTableAlignmentEnabled
|
|
690
692
|
} = this.props;
|
|
691
693
|
|
|
692
694
|
let {
|
|
@@ -820,6 +822,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
820
822
|
isResizing={isResizing}
|
|
821
823
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
822
824
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
825
|
+
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
823
826
|
>
|
|
824
827
|
<div
|
|
825
828
|
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
@@ -106,6 +106,7 @@ export const TableComponentWithSharedState = ({
|
|
|
106
106
|
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
107
107
|
isDragAndDropEnabled={options?.isDragAndDropEnabled}
|
|
108
108
|
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
109
|
+
isTableAlignmentEnabled={options?.isTableAlignmentEnabled}
|
|
109
110
|
tableActive={tableActive}
|
|
110
111
|
ordering={ordering}
|
|
111
112
|
isResizing={isResizing}
|