@atlaskit/editor-plugin-table 0.0.1 → 0.0.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 +6 -0
- package/dist/cjs/plugins/table/index.js +42 -15
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/index.js +287 -255
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/index.js +41 -15
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +1 -2
- package/package.json +1 -1
- package/report.api.md +61 -24
- package/src/plugins/table/__tests__/unit/commands/insert.ts +0 -1
- package/src/plugins/table/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
- package/src/plugins/table/index.tsx +322 -295
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 0.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b18bb5420cb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b18bb5420cb) - [ED-15731] Replace the GetEditorContainerWidth API with a workaround to grab with plugin state data
|
|
8
|
+
|
|
3
9
|
## 0.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -9,6 +9,8 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
+
|
|
12
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
15
|
|
|
14
16
|
var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
|
|
@@ -63,19 +65,31 @@ var _utils3 = require("./utils");
|
|
|
63
65
|
|
|
64
66
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
65
67
|
|
|
66
|
-
var defaultGetEditorContainerWidth = function defaultGetEditorContainerWidth() {
|
|
67
|
-
var _document, _document$body;
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
width: ((_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) || 500
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
68
|
var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
75
69
|
return {};
|
|
76
70
|
};
|
|
77
71
|
|
|
78
72
|
var tablesPlugin = function tablesPlugin(options) {
|
|
73
|
+
var editorViewRef = {
|
|
74
|
+
current: null
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var defaultGetEditorContainerWidth = function defaultGetEditorContainerWidth() {
|
|
78
|
+
if (!editorViewRef.current) {
|
|
79
|
+
var _document, _document$body;
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
width: ((_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) || 500
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var state = editorViewRef.current.state; // TODO: ED-15663
|
|
87
|
+
// Please, do not copy or use this kind of code below
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
|
|
90
|
+
return state['widthPlugin$'];
|
|
91
|
+
};
|
|
92
|
+
|
|
79
93
|
return {
|
|
80
94
|
name: 'table',
|
|
81
95
|
nodes: function nodes() {
|
|
@@ -110,7 +124,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
110
124
|
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
111
125
|
getEditorFeatureFlags = _ref2.getEditorFeatureFlags;
|
|
112
126
|
|
|
113
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
127
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
114
128
|
}
|
|
115
129
|
}, {
|
|
116
130
|
name: 'tablePMColResizing',
|
|
@@ -121,7 +135,6 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
121
135
|
fullWidthEnabled = _ref4.fullWidthEnabled,
|
|
122
136
|
tableOptions = _ref4.tableOptions,
|
|
123
137
|
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
124
|
-
getEditorContainerWidth = _ref4.getEditorContainerWidth,
|
|
125
138
|
getEditorFeatureFlags = _ref4.getEditorFeatureFlags;
|
|
126
139
|
|
|
127
140
|
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
@@ -129,7 +142,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
129
142
|
|
|
130
143
|
return allowColumnResizing ? (0, _tableResizing.createPlugin)(dispatch, {
|
|
131
144
|
lastColumnResizable: !fullWidthEnabled
|
|
132
|
-
},
|
|
145
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI) : undefined;
|
|
133
146
|
}
|
|
134
147
|
}, {
|
|
135
148
|
name: 'tableEditing',
|
|
@@ -141,7 +154,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
141
154
|
{
|
|
142
155
|
name: 'tableKeymap',
|
|
143
156
|
plugin: function plugin() {
|
|
144
|
-
return (0, _keymap.keymapPlugin)(
|
|
157
|
+
return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI);
|
|
145
158
|
}
|
|
146
159
|
}, {
|
|
147
160
|
name: 'tableSelectionKeymap',
|
|
@@ -168,6 +181,20 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
168
181
|
var dispatch = _ref6.dispatch;
|
|
169
182
|
return (0, _tableLocalId.createPlugin)(dispatch);
|
|
170
183
|
}
|
|
184
|
+
}, {
|
|
185
|
+
name: 'tableGetEditorViewReferencePlugin',
|
|
186
|
+
plugin: function plugin() {
|
|
187
|
+
return new _safePlugin.SafePlugin({
|
|
188
|
+
view: function view(editorView) {
|
|
189
|
+
editorViewRef.current = editorView;
|
|
190
|
+
return {
|
|
191
|
+
destroy: function destroy() {
|
|
192
|
+
editorViewRef.current = null;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
171
198
|
}]; // workaround for prosemirrors delayed dom selection syncing during pointer drag
|
|
172
199
|
// causing issues with table selections in Safari
|
|
173
200
|
// https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
|
|
@@ -258,7 +285,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
258
285
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
259
286
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
260
287
|
editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
|
|
261
|
-
getEditorContainerWidth:
|
|
288
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
262
289
|
}), /*#__PURE__*/_react.default.createElement(_FloatingContextualMenu.default, {
|
|
263
290
|
editorView: editorView,
|
|
264
291
|
mountPoint: popupsMountPoint,
|
|
@@ -267,7 +294,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
267
294
|
isOpen: Boolean(isContextualMenuOpen),
|
|
268
295
|
pluginConfig: pluginConfig,
|
|
269
296
|
editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
|
|
270
|
-
getEditorContainerWidth:
|
|
297
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
271
298
|
}), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
272
299
|
editorView: editorView,
|
|
273
300
|
selection: editorView.state.selection,
|
|
@@ -338,7 +365,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
338
365
|
}
|
|
339
366
|
}];
|
|
340
367
|
},
|
|
341
|
-
floatingToolbar: (0, _toolbar.getToolbarConfig)(
|
|
368
|
+
floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
342
369
|
}
|
|
343
370
|
};
|
|
344
371
|
};
|
package/dist/cjs/version.json
CHANGED