@atlaskit/editor-plugin-table 3.1.1 → 3.1.3
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 +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +7 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +12 -3
- package/dist/cjs/plugins/table/pm-plugins/main.js +5 -15
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +11 -1
- package/dist/es2019/plugins/table/nodeviews/table.js +12 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +5 -15
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +7 -1
- package/dist/esm/plugins/table/nodeviews/table.js +12 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +5 -15
- package/dist/types/plugins/table/nodeviews/table.d.ts +2 -2
- package/dist/types/plugins/table/types.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
- package/package.json +2 -2
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +43 -18
- package/src/plugins/table/nodeviews/TableResizer.tsx +7 -1
- package/src/plugins/table/nodeviews/table.tsx +14 -4
- package/src/plugins/table/pm-plugins/main.ts +4 -17
- package/src/plugins/table/types.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 3.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`5b783c0f957`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5b783c0f957) - Clean up resizing plugin state for table when deleted
|
|
8
|
+
|
|
9
|
+
## 3.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`866a47baae3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/866a47baae3) - Moved the cache FF variables from global to plugin state, to avoid other editor instances from overriding them
|
|
14
|
+
|
|
3
15
|
## 3.1.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -133,11 +133,17 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
133
133
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
134
134
|
// deleted this table
|
|
135
135
|
if (isResizing.current) {
|
|
136
|
+
var dispatch = editorView.dispatch,
|
|
137
|
+
_tr = editorView.state.tr;
|
|
136
138
|
displayGapCursor(true);
|
|
137
139
|
displayGuideline([]);
|
|
140
|
+
_tr.setMeta(_tableWidth.pluginKey, {
|
|
141
|
+
resizing: false
|
|
142
|
+
});
|
|
143
|
+
dispatch(_tr);
|
|
138
144
|
}
|
|
139
145
|
};
|
|
140
|
-
}, [displayGuideline, displayGapCursor]);
|
|
146
|
+
}, [editorView, displayGuideline, displayGapCursor]);
|
|
141
147
|
var handleResizeStart = (0, _react.useCallback)(function () {
|
|
142
148
|
startMeasure();
|
|
143
149
|
isResizing.current = true;
|
|
@@ -249,9 +249,13 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
249
249
|
return TableView;
|
|
250
250
|
}(_reactNodeView.default);
|
|
251
251
|
exports.default = TableView;
|
|
252
|
-
var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher,
|
|
252
|
+
var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
|
|
253
253
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
254
|
-
pluginConfig = _getPluginState2.pluginConfig
|
|
254
|
+
pluginConfig = _getPluginState2.pluginConfig,
|
|
255
|
+
isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
|
|
256
|
+
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
257
|
+
wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
|
|
258
|
+
isTableResizingEnabled = _getPluginState2.isTableResizingEnabled;
|
|
255
259
|
var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
|
|
256
260
|
allowColumnResizing = _getPluginConfig.allowColumnResizing;
|
|
257
261
|
var hasIntlContext = true;
|
|
@@ -262,7 +266,12 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
|
|
|
262
266
|
portalProviderAPI: portalProviderAPI,
|
|
263
267
|
eventDispatcher: eventDispatcher,
|
|
264
268
|
getPos: getPos,
|
|
265
|
-
options:
|
|
269
|
+
options: {
|
|
270
|
+
isBreakoutEnabled: isBreakoutEnabled,
|
|
271
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
272
|
+
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
273
|
+
isTableResizingEnabled: isTableResizingEnabled
|
|
274
|
+
},
|
|
266
275
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
267
276
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
268
277
|
hasIntlContext: hasIntlContext,
|
|
@@ -29,21 +29,16 @@ var _pluginFactory = require("./plugin-factory");
|
|
|
29
29
|
var _pluginKey = require("./plugin-key");
|
|
30
30
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
-
var isBreakoutEnabled;
|
|
33
|
-
var isFullWidthModeEnabled;
|
|
34
|
-
var wasFullWidthModeEnabled;
|
|
35
|
-
var isTableResizingEnabled;
|
|
36
32
|
var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
37
33
|
var _window;
|
|
38
|
-
isBreakoutEnabled = breakoutEnabled;
|
|
39
|
-
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
40
|
-
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
41
|
-
isTableResizingEnabled = tableResizingEnabled;
|
|
42
34
|
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread({
|
|
43
35
|
pluginConfig: pluginConfig,
|
|
44
36
|
insertColumnButtonIndex: undefined,
|
|
45
37
|
insertRowButtonIndex: undefined,
|
|
46
|
-
isFullWidthModeEnabled:
|
|
38
|
+
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
39
|
+
isBreakoutEnabled: breakoutEnabled,
|
|
40
|
+
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
41
|
+
isTableResizingEnabled: tableResizingEnabled,
|
|
47
42
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
48
43
|
isHeaderColumnEnabled: false
|
|
49
44
|
}, _defaultTableSelection.defaultTableSelection), {}, {
|
|
@@ -243,12 +238,7 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
|
|
|
243
238
|
},
|
|
244
239
|
nodeViews: _objectSpread(_objectSpread({}, tableCellNodeview), {}, {
|
|
245
240
|
table: function table(node, view, getPos) {
|
|
246
|
-
return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher,
|
|
247
|
-
isBreakoutEnabled: isBreakoutEnabled,
|
|
248
|
-
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
249
|
-
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
250
|
-
isTableResizingEnabled: isTableResizingEnabled
|
|
251
|
-
}, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
241
|
+
return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
252
242
|
}
|
|
253
243
|
}),
|
|
254
244
|
handleDOMEvents: {
|
|
@@ -119,11 +119,21 @@ export const TableResizer = ({
|
|
|
119
119
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
120
120
|
// deleted this table
|
|
121
121
|
if (isResizing.current) {
|
|
122
|
+
const {
|
|
123
|
+
dispatch,
|
|
124
|
+
state: {
|
|
125
|
+
tr
|
|
126
|
+
}
|
|
127
|
+
} = editorView;
|
|
122
128
|
displayGapCursor(true);
|
|
123
129
|
displayGuideline([]);
|
|
130
|
+
tr.setMeta(tableWidthPluginKey, {
|
|
131
|
+
resizing: false
|
|
132
|
+
});
|
|
133
|
+
dispatch(tr);
|
|
124
134
|
}
|
|
125
135
|
};
|
|
126
|
-
}, [displayGuideline, displayGapCursor]);
|
|
136
|
+
}, [editorView, displayGuideline, displayGapCursor]);
|
|
127
137
|
const handleResizeStart = useCallback(() => {
|
|
128
138
|
startMeasure();
|
|
129
139
|
isResizing.current = true;
|
|
@@ -216,9 +216,13 @@ export default class TableView extends ReactNodeView {
|
|
|
216
216
|
super.destroy();
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher,
|
|
219
|
+
export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) => {
|
|
220
220
|
const {
|
|
221
|
-
pluginConfig
|
|
221
|
+
pluginConfig,
|
|
222
|
+
isBreakoutEnabled,
|
|
223
|
+
isFullWidthModeEnabled,
|
|
224
|
+
wasFullWidthModeEnabled,
|
|
225
|
+
isTableResizingEnabled
|
|
222
226
|
} = getPluginState(view.state);
|
|
223
227
|
const {
|
|
224
228
|
allowColumnResizing
|
|
@@ -231,7 +235,12 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
231
235
|
portalProviderAPI,
|
|
232
236
|
eventDispatcher,
|
|
233
237
|
getPos: getPos,
|
|
234
|
-
options
|
|
238
|
+
options: {
|
|
239
|
+
isBreakoutEnabled,
|
|
240
|
+
isFullWidthModeEnabled,
|
|
241
|
+
wasFullWidthModeEnabled,
|
|
242
|
+
isTableResizingEnabled
|
|
243
|
+
},
|
|
235
244
|
getEditorContainerWidth,
|
|
236
245
|
getEditorFeatureFlags,
|
|
237
246
|
hasIntlContext,
|
|
@@ -19,21 +19,16 @@ import { isHeaderRowRequired } from '../utils/paste';
|
|
|
19
19
|
import { defaultTableSelection } from './default-table-selection';
|
|
20
20
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
21
21
|
import { pluginKey } from './plugin-key';
|
|
22
|
-
let isBreakoutEnabled;
|
|
23
|
-
let isFullWidthModeEnabled;
|
|
24
|
-
let wasFullWidthModeEnabled;
|
|
25
|
-
let isTableResizingEnabled;
|
|
26
22
|
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
|
|
27
23
|
var _window;
|
|
28
|
-
isBreakoutEnabled = breakoutEnabled;
|
|
29
|
-
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
30
|
-
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
31
|
-
isTableResizingEnabled = tableResizingEnabled;
|
|
32
24
|
const state = createPluginState(dispatch, {
|
|
33
25
|
pluginConfig,
|
|
34
26
|
insertColumnButtonIndex: undefined,
|
|
35
27
|
insertRowButtonIndex: undefined,
|
|
36
|
-
isFullWidthModeEnabled,
|
|
28
|
+
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
29
|
+
isBreakoutEnabled: breakoutEnabled,
|
|
30
|
+
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
31
|
+
isTableResizingEnabled: tableResizingEnabled,
|
|
37
32
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
38
33
|
isHeaderColumnEnabled: false,
|
|
39
34
|
...defaultTableSelection,
|
|
@@ -234,12 +229,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
234
229
|
},
|
|
235
230
|
nodeViews: {
|
|
236
231
|
...tableCellNodeview,
|
|
237
|
-
table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher,
|
|
238
|
-
isBreakoutEnabled,
|
|
239
|
-
isFullWidthModeEnabled,
|
|
240
|
-
wasFullWidthModeEnabled,
|
|
241
|
-
isTableResizingEnabled
|
|
242
|
-
}, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi)
|
|
232
|
+
table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi)
|
|
243
233
|
},
|
|
244
234
|
handleDOMEvents: {
|
|
245
235
|
focus: handleFocus,
|
|
@@ -123,11 +123,17 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
123
123
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
124
124
|
// deleted this table
|
|
125
125
|
if (isResizing.current) {
|
|
126
|
+
var dispatch = editorView.dispatch,
|
|
127
|
+
_tr = editorView.state.tr;
|
|
126
128
|
displayGapCursor(true);
|
|
127
129
|
displayGuideline([]);
|
|
130
|
+
_tr.setMeta(tableWidthPluginKey, {
|
|
131
|
+
resizing: false
|
|
132
|
+
});
|
|
133
|
+
dispatch(_tr);
|
|
128
134
|
}
|
|
129
135
|
};
|
|
130
|
-
}, [displayGuideline, displayGapCursor]);
|
|
136
|
+
}, [editorView, displayGuideline, displayGapCursor]);
|
|
131
137
|
var handleResizeStart = useCallback(function () {
|
|
132
138
|
startMeasure();
|
|
133
139
|
isResizing.current = true;
|
|
@@ -242,9 +242,13 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
242
242
|
return TableView;
|
|
243
243
|
}(ReactNodeView);
|
|
244
244
|
export { TableView as default };
|
|
245
|
-
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher,
|
|
245
|
+
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
|
|
246
246
|
var _getPluginState2 = getPluginState(view.state),
|
|
247
|
-
pluginConfig = _getPluginState2.pluginConfig
|
|
247
|
+
pluginConfig = _getPluginState2.pluginConfig,
|
|
248
|
+
isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
|
|
249
|
+
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
250
|
+
wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
|
|
251
|
+
isTableResizingEnabled = _getPluginState2.isTableResizingEnabled;
|
|
248
252
|
var _getPluginConfig = getPluginConfig(pluginConfig),
|
|
249
253
|
allowColumnResizing = _getPluginConfig.allowColumnResizing;
|
|
250
254
|
var hasIntlContext = true;
|
|
@@ -255,7 +259,12 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
255
259
|
portalProviderAPI: portalProviderAPI,
|
|
256
260
|
eventDispatcher: eventDispatcher,
|
|
257
261
|
getPos: getPos,
|
|
258
|
-
options:
|
|
262
|
+
options: {
|
|
263
|
+
isBreakoutEnabled: isBreakoutEnabled,
|
|
264
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
265
|
+
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
266
|
+
isTableResizingEnabled: isTableResizingEnabled
|
|
267
|
+
},
|
|
259
268
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
260
269
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
261
270
|
hasIntlContext: hasIntlContext,
|
|
@@ -22,21 +22,16 @@ import { isHeaderRowRequired } from '../utils/paste';
|
|
|
22
22
|
import { defaultTableSelection } from './default-table-selection';
|
|
23
23
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
24
24
|
import { pluginKey } from './plugin-key';
|
|
25
|
-
var isBreakoutEnabled;
|
|
26
|
-
var isFullWidthModeEnabled;
|
|
27
|
-
var wasFullWidthModeEnabled;
|
|
28
|
-
var isTableResizingEnabled;
|
|
29
25
|
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
30
26
|
var _window;
|
|
31
|
-
isBreakoutEnabled = breakoutEnabled;
|
|
32
|
-
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
33
|
-
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
34
|
-
isTableResizingEnabled = tableResizingEnabled;
|
|
35
27
|
var state = createPluginState(dispatch, _objectSpread(_objectSpread({
|
|
36
28
|
pluginConfig: pluginConfig,
|
|
37
29
|
insertColumnButtonIndex: undefined,
|
|
38
30
|
insertRowButtonIndex: undefined,
|
|
39
|
-
isFullWidthModeEnabled:
|
|
31
|
+
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
32
|
+
isBreakoutEnabled: breakoutEnabled,
|
|
33
|
+
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
34
|
+
isTableResizingEnabled: tableResizingEnabled,
|
|
40
35
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
41
36
|
isHeaderColumnEnabled: false
|
|
42
37
|
}, defaultTableSelection), {}, {
|
|
@@ -236,12 +231,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
236
231
|
},
|
|
237
232
|
nodeViews: _objectSpread(_objectSpread({}, tableCellNodeview), {}, {
|
|
238
233
|
table: function table(node, view, getPos) {
|
|
239
|
-
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher,
|
|
240
|
-
isBreakoutEnabled: isBreakoutEnabled,
|
|
241
|
-
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
242
|
-
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
243
|
-
isTableResizingEnabled: isTableResizingEnabled
|
|
244
|
-
}, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
234
|
+
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
245
235
|
}
|
|
246
236
|
}),
|
|
247
237
|
handleDOMEvents: {
|
|
@@ -6,7 +6,7 @@ import type { GetEditorContainerWidth, GetEditorFeatureFlags, getPosHandler, get
|
|
|
6
6
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import type { PluginInjectionAPI } from '../types';
|
|
9
|
-
import type { Props
|
|
9
|
+
import type { Props } from './types';
|
|
10
10
|
type ForwardRef = (node: HTMLElement | null) => void;
|
|
11
11
|
export default class TableView extends ReactNodeView<Props> {
|
|
12
12
|
private table;
|
|
@@ -29,5 +29,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
29
29
|
}): boolean;
|
|
30
30
|
destroy(): void;
|
|
31
31
|
}
|
|
32
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher,
|
|
32
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
33
33
|
export {};
|
|
@@ -70,6 +70,9 @@ export interface TablePluginState {
|
|
|
70
70
|
isTableCollapsed?: boolean;
|
|
71
71
|
canCollapseTable?: boolean;
|
|
72
72
|
getIntl: () => IntlShape;
|
|
73
|
+
isBreakoutEnabled?: boolean;
|
|
74
|
+
wasFullWidthModeEnabled?: boolean;
|
|
75
|
+
isTableResizingEnabled?: boolean;
|
|
73
76
|
}
|
|
74
77
|
export type TablePluginAction = {
|
|
75
78
|
type: 'SET_EDITOR_FOCUS';
|
|
@@ -6,7 +6,7 @@ import type { GetEditorContainerWidth, GetEditorFeatureFlags, getPosHandler, get
|
|
|
6
6
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import type { PluginInjectionAPI } from '../types';
|
|
9
|
-
import type { Props
|
|
9
|
+
import type { Props } from './types';
|
|
10
10
|
type ForwardRef = (node: HTMLElement | null) => void;
|
|
11
11
|
export default class TableView extends ReactNodeView<Props> {
|
|
12
12
|
private table;
|
|
@@ -29,5 +29,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
29
29
|
}): boolean;
|
|
30
30
|
destroy(): void;
|
|
31
31
|
}
|
|
32
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher,
|
|
32
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
33
33
|
export {};
|
|
@@ -70,6 +70,9 @@ export interface TablePluginState {
|
|
|
70
70
|
isTableCollapsed?: boolean;
|
|
71
71
|
canCollapseTable?: boolean;
|
|
72
72
|
getIntl: () => IntlShape;
|
|
73
|
+
isBreakoutEnabled?: boolean;
|
|
74
|
+
wasFullWidthModeEnabled?: boolean;
|
|
75
|
+
isTableResizingEnabled?: boolean;
|
|
73
76
|
}
|
|
74
77
|
export type TablePluginAction = {
|
|
75
78
|
type: 'SET_EDITOR_FOCUS';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^29.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^75.
|
|
31
|
+
"@atlaskit/editor-common": "^75.6.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
TableContainer,
|
|
30
30
|
} from '../../../plugins/table/nodeviews/TableContainer';
|
|
31
31
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
32
|
+
import { pluginKey as tableResizingPluginKey } from '../../../plugins/table/pm-plugins/table-width';
|
|
32
33
|
import type { TablePluginState } from '../../../plugins/table/types';
|
|
33
34
|
|
|
34
35
|
const mockStartMeasure = jest.fn();
|
|
@@ -66,9 +67,14 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
66
67
|
return createEditor({
|
|
67
68
|
doc,
|
|
68
69
|
editorProps: {
|
|
70
|
+
appearance: 'full-page',
|
|
69
71
|
allowTables: false,
|
|
70
72
|
dangerouslyAppendPlugins: {
|
|
71
|
-
__plugins: [
|
|
73
|
+
__plugins: [
|
|
74
|
+
tablePlugin({
|
|
75
|
+
config: { tableResizingEnabled: true, tableOptions: {} },
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
72
78
|
},
|
|
73
79
|
featureFlags,
|
|
74
80
|
},
|
|
@@ -228,21 +234,7 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
228
234
|
fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
|
|
229
235
|
fireEvent.mouseUp(container.querySelector('.resizer-handle.right')!);
|
|
230
236
|
|
|
231
|
-
expect(analyticsMock).
|
|
232
|
-
action: TABLE_ACTION.RESIZED,
|
|
233
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
234
|
-
eventType: EVENT_TYPE.TRACK,
|
|
235
|
-
attributes: {
|
|
236
|
-
width: undefined, // Can't get the events right to trigger re-resizeable
|
|
237
|
-
prevWidth: null,
|
|
238
|
-
nodeSize: 20,
|
|
239
|
-
totalTableWidth: null,
|
|
240
|
-
totalRowCount: 1,
|
|
241
|
-
totalColumnCount: 3,
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
expect(analyticsMock).toHaveBeenCalledWith({
|
|
237
|
+
expect(analyticsMock).toHaveBeenNthCalledWith(1, {
|
|
246
238
|
action: TABLE_ACTION.RESIZE_PERF_SAMPLING,
|
|
247
239
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
248
240
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
@@ -254,7 +246,7 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
254
246
|
},
|
|
255
247
|
});
|
|
256
248
|
|
|
257
|
-
expect(analyticsMock).
|
|
249
|
+
expect(analyticsMock).toHaveBeenNthCalledWith(2, {
|
|
258
250
|
action: TABLE_ACTION.RESIZE_PERF_SAMPLING,
|
|
259
251
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
260
252
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
@@ -266,6 +258,20 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
266
258
|
},
|
|
267
259
|
});
|
|
268
260
|
|
|
261
|
+
expect(analyticsMock).toHaveBeenNthCalledWith(3, {
|
|
262
|
+
action: TABLE_ACTION.RESIZED,
|
|
263
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
264
|
+
eventType: EVENT_TYPE.TRACK,
|
|
265
|
+
attributes: {
|
|
266
|
+
newWidth: 0, // Can't get the events right to trigger re-resizeable
|
|
267
|
+
prevWidth: 960,
|
|
268
|
+
nodeSize: 20,
|
|
269
|
+
totalTableWidth: null,
|
|
270
|
+
totalRowCount: 1,
|
|
271
|
+
totalColumnCount: 3,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
|
|
269
275
|
analyticsMock.mockReset();
|
|
270
276
|
});
|
|
271
277
|
|
|
@@ -378,7 +384,13 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
378
384
|
/>,
|
|
379
385
|
);
|
|
380
386
|
|
|
381
|
-
return {
|
|
387
|
+
return {
|
|
388
|
+
container,
|
|
389
|
+
unmount,
|
|
390
|
+
editorView,
|
|
391
|
+
selectionActionMock,
|
|
392
|
+
actualGuidelineMock,
|
|
393
|
+
};
|
|
382
394
|
};
|
|
383
395
|
|
|
384
396
|
afterEach(() => {
|
|
@@ -408,5 +420,18 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
408
420
|
unmount();
|
|
409
421
|
expect(actualGuidelineMock).toHaveBeenCalledWith({ guidelines: [] });
|
|
410
422
|
});
|
|
423
|
+
|
|
424
|
+
// this is testing logic inside TableResizer, targeting the clean up in the useEffect
|
|
425
|
+
it('should call restore resizing plugin state when removed', () => {
|
|
426
|
+
const { container, unmount, editorView } = buildContainer({});
|
|
427
|
+
|
|
428
|
+
fireEvent.mouseDown(container.querySelector('.resizer-handle.right')!);
|
|
429
|
+
fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
|
|
430
|
+
|
|
431
|
+
unmount();
|
|
432
|
+
expect(tableResizingPluginKey.getState(editorView.state)).toStrictEqual({
|
|
433
|
+
resizing: false,
|
|
434
|
+
});
|
|
435
|
+
});
|
|
411
436
|
});
|
|
412
437
|
});
|
|
@@ -201,11 +201,17 @@ export const TableResizer = ({
|
|
|
201
201
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
202
202
|
// deleted this table
|
|
203
203
|
if (isResizing.current) {
|
|
204
|
+
const {
|
|
205
|
+
dispatch,
|
|
206
|
+
state: { tr },
|
|
207
|
+
} = editorView;
|
|
204
208
|
displayGapCursor(true);
|
|
205
209
|
displayGuideline([]);
|
|
210
|
+
tr.setMeta(tableWidthPluginKey, { resizing: false });
|
|
211
|
+
dispatch(tr);
|
|
206
212
|
}
|
|
207
213
|
};
|
|
208
|
-
}, [displayGuideline, displayGapCursor]);
|
|
214
|
+
}, [editorView, displayGuideline, displayGapCursor]);
|
|
209
215
|
|
|
210
216
|
const handleResizeStart = useCallback(() => {
|
|
211
217
|
startMeasure();
|
|
@@ -35,7 +35,7 @@ import type { PluginInjectionAPI } from '../types';
|
|
|
35
35
|
import { isTableNested } from '../utils';
|
|
36
36
|
|
|
37
37
|
import TableComponent from './TableComponent';
|
|
38
|
-
import type { Props
|
|
38
|
+
import type { Props } from './types';
|
|
39
39
|
|
|
40
40
|
type ForwardRef = (node: HTMLElement | null) => void;
|
|
41
41
|
|
|
@@ -341,12 +341,17 @@ export const createTableView = (
|
|
|
341
341
|
getPos: getPosHandler,
|
|
342
342
|
portalProviderAPI: PortalProviderAPI,
|
|
343
343
|
eventDispatcher: EventDispatcher,
|
|
344
|
-
options: TableOptions,
|
|
345
344
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
346
345
|
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
347
346
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
348
347
|
): NodeView => {
|
|
349
|
-
const {
|
|
348
|
+
const {
|
|
349
|
+
pluginConfig,
|
|
350
|
+
isBreakoutEnabled,
|
|
351
|
+
isFullWidthModeEnabled,
|
|
352
|
+
wasFullWidthModeEnabled,
|
|
353
|
+
isTableResizingEnabled,
|
|
354
|
+
} = getPluginState(view.state);
|
|
350
355
|
const { allowColumnResizing } = getPluginConfig(pluginConfig);
|
|
351
356
|
const hasIntlContext = true;
|
|
352
357
|
|
|
@@ -357,7 +362,12 @@ export const createTableView = (
|
|
|
357
362
|
portalProviderAPI,
|
|
358
363
|
eventDispatcher,
|
|
359
364
|
getPos: getPos as getPosHandlerNode,
|
|
360
|
-
options
|
|
365
|
+
options: {
|
|
366
|
+
isBreakoutEnabled,
|
|
367
|
+
isFullWidthModeEnabled,
|
|
368
|
+
wasFullWidthModeEnabled,
|
|
369
|
+
isTableResizingEnabled,
|
|
370
|
+
},
|
|
361
371
|
getEditorContainerWidth,
|
|
362
372
|
getEditorFeatureFlags,
|
|
363
373
|
hasIntlContext,
|
|
@@ -90,11 +90,6 @@ import { defaultTableSelection } from './default-table-selection';
|
|
|
90
90
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
91
91
|
import { pluginKey } from './plugin-key';
|
|
92
92
|
|
|
93
|
-
let isBreakoutEnabled: boolean | undefined;
|
|
94
|
-
let isFullWidthModeEnabled: boolean | undefined;
|
|
95
|
-
let wasFullWidthModeEnabled: boolean | undefined;
|
|
96
|
-
let isTableResizingEnabled: boolean | undefined;
|
|
97
|
-
|
|
98
93
|
export const createPlugin = (
|
|
99
94
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent,
|
|
100
95
|
dispatch: Dispatch,
|
|
@@ -111,16 +106,14 @@ export const createPlugin = (
|
|
|
111
106
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
112
107
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
113
108
|
) => {
|
|
114
|
-
isBreakoutEnabled = breakoutEnabled;
|
|
115
|
-
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
116
|
-
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
117
|
-
isTableResizingEnabled = tableResizingEnabled;
|
|
118
|
-
|
|
119
109
|
const state = createPluginState(dispatch, {
|
|
120
110
|
pluginConfig,
|
|
121
111
|
insertColumnButtonIndex: undefined,
|
|
122
112
|
insertRowButtonIndex: undefined,
|
|
123
|
-
isFullWidthModeEnabled,
|
|
113
|
+
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
114
|
+
isBreakoutEnabled: breakoutEnabled,
|
|
115
|
+
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
116
|
+
isTableResizingEnabled: tableResizingEnabled,
|
|
124
117
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
125
118
|
isHeaderColumnEnabled: false,
|
|
126
119
|
...defaultTableSelection,
|
|
@@ -376,12 +369,6 @@ export const createPlugin = (
|
|
|
376
369
|
getPos,
|
|
377
370
|
portalProviderAPI,
|
|
378
371
|
eventDispatcher,
|
|
379
|
-
{
|
|
380
|
-
isBreakoutEnabled,
|
|
381
|
-
isFullWidthModeEnabled,
|
|
382
|
-
wasFullWidthModeEnabled,
|
|
383
|
-
isTableResizingEnabled,
|
|
384
|
-
},
|
|
385
372
|
getEditorContainerWidth,
|
|
386
373
|
getEditorFeatureFlags,
|
|
387
374
|
pluginInjectionApi,
|
|
@@ -117,6 +117,10 @@ export interface TablePluginState {
|
|
|
117
117
|
canCollapseTable?: boolean; // enabled/disabled state of collapse option
|
|
118
118
|
|
|
119
119
|
getIntl: () => IntlShape;
|
|
120
|
+
|
|
121
|
+
isBreakoutEnabled?: boolean;
|
|
122
|
+
wasFullWidthModeEnabled?: boolean;
|
|
123
|
+
isTableResizingEnabled?: boolean;
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
export type TablePluginAction =
|