@atlaskit/editor-plugin-table 7.31.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/dist/cjs/commands/insert.js +16 -19
- package/dist/cjs/commands-with-analytics.js +5 -7
- package/dist/cjs/event-handlers.js +12 -1
- package/dist/cjs/nodeviews/TableComponent.js +18 -15
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/cjs/nodeviews/lazy-node-views.js +2 -3
- package/dist/cjs/nodeviews/table.js +16 -12
- package/dist/cjs/plugin.js +22 -28
- package/dist/cjs/pm-plugins/keymap.js +9 -10
- package/dist/cjs/pm-plugins/main.js +3 -5
- package/dist/cjs/toolbar.js +10 -13
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -7
- package/dist/cjs/utils/drag-menu.js +6 -7
- package/dist/es2019/commands/insert.js +10 -10
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/event-handlers.js +12 -1
- package/dist/es2019/nodeviews/TableComponent.js +18 -15
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/es2019/nodeviews/lazy-node-views.js +2 -3
- package/dist/es2019/nodeviews/table.js +16 -12
- package/dist/es2019/plugin.js +22 -26
- package/dist/es2019/pm-plugins/keymap.js +5 -5
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/toolbar.js +6 -7
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -3
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +2 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +3 -6
- package/dist/es2019/utils/drag-menu.js +3 -3
- package/dist/esm/commands/insert.js +16 -19
- package/dist/esm/commands-with-analytics.js +5 -7
- package/dist/esm/event-handlers.js +12 -1
- package/dist/esm/nodeviews/TableComponent.js +18 -15
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/esm/nodeviews/lazy-node-views.js +2 -3
- package/dist/esm/nodeviews/table.js +16 -12
- package/dist/esm/plugin.js +22 -28
- package/dist/esm/pm-plugins/keymap.js +9 -10
- package/dist/esm/pm-plugins/main.js +3 -5
- package/dist/esm/toolbar.js +10 -13
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +2 -4
- package/dist/esm/ui/FloatingInsertButton/index.js +3 -7
- package/dist/esm/utils/drag-menu.js +6 -7
- package/dist/types/commands/insert.d.ts +5 -5
- package/dist/types/commands-with-analytics.d.ts +3 -4
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +3 -1
- package/dist/types/nodeviews/lazy-node-views.d.ts +0 -1
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +2 -2
- package/dist/types/plugin.d.ts +1 -3
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/toolbar.d.ts +1 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +5 -5
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -4
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +2 -2
- package/dist/types-ts4.5/plugin.d.ts +1 -3
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -3
- package/src/commands/insert.ts +3 -10
- package/src/commands-with-analytics.ts +7 -8
- package/src/event-handlers.ts +17 -1
- package/src/nodeviews/TableComponent.tsx +22 -16
- package/src/nodeviews/TableComponentWithSharedState.tsx +6 -1
- package/src/nodeviews/lazy-node-views.ts +0 -4
- package/src/nodeviews/table.tsx +13 -8
- package/src/nodeviews/types.ts +2 -2
- package/src/plugin.tsx +24 -35
- package/src/pm-plugins/keymap.ts +0 -5
- package/src/pm-plugins/main.ts +2 -6
- package/src/toolbar.tsx +1 -9
- package/src/types.ts +2 -1
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +7 -10
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -3
- package/src/ui/FloatingDragMenu/index.tsx +1 -3
- package/src/ui/FloatingInsertButton/index.tsx +5 -10
- package/src/utils/drag-menu.ts +4 -9
|
@@ -27,6 +27,8 @@ type TableComponentWithSharedStateProps = {
|
|
|
27
27
|
getPos: getPosHandlerNode;
|
|
28
28
|
allowColumnResizing?: boolean;
|
|
29
29
|
allowControls?: boolean;
|
|
30
|
+
allowTableAlignment?: boolean;
|
|
31
|
+
allowTableResizing?: boolean;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -44,6 +46,8 @@ export const TableComponentWithSharedState = ({
|
|
|
44
46
|
allowControls,
|
|
45
47
|
getPos,
|
|
46
48
|
forwardRef,
|
|
49
|
+
allowTableAlignment,
|
|
50
|
+
allowTableResizing,
|
|
47
51
|
}: TableComponentWithSharedStateProps) => {
|
|
48
52
|
const { widthState, tableState, mediaState } = useSharedPluginState(api, [
|
|
49
53
|
'width',
|
|
@@ -103,7 +107,8 @@ export const TableComponentWithSharedState = ({
|
|
|
103
107
|
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
104
108
|
isDragAndDropEnabled={options?.isDragAndDropEnabled}
|
|
105
109
|
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
106
|
-
|
|
110
|
+
allowTableAlignment={allowTableAlignment}
|
|
111
|
+
allowTableResizing={allowTableResizing}
|
|
107
112
|
tableActive={tableActive}
|
|
108
113
|
ordering={ordering}
|
|
109
114
|
isResizing={isResizing}
|
|
@@ -21,7 +21,6 @@ type TableViewOptions = {
|
|
|
21
21
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
22
22
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
23
23
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
|
-
isTableAlignmentEnabled?: boolean;
|
|
25
24
|
isCommentEditor?: boolean;
|
|
26
25
|
isChromelessEditor?: boolean;
|
|
27
26
|
};
|
|
@@ -39,7 +38,6 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
39
38
|
options.getEditorFeatureFlags,
|
|
40
39
|
options.dispatchAnalyticsEvent,
|
|
41
40
|
options.pluginInjectionApi,
|
|
42
|
-
options.isTableAlignmentEnabled,
|
|
43
41
|
options.isCommentEditor,
|
|
44
42
|
options.isChromelessEditor,
|
|
45
43
|
);
|
|
@@ -65,7 +63,6 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
65
63
|
getEditorFeatureFlags,
|
|
66
64
|
dispatchAnalyticsEvent,
|
|
67
65
|
pluginInjectionApi,
|
|
68
|
-
isTableAlignmentEnabled,
|
|
69
66
|
isCommentEditor,
|
|
70
67
|
isChromelessEditor,
|
|
71
68
|
} = getNodeViewOptions();
|
|
@@ -80,7 +77,6 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
80
77
|
getEditorFeatureFlags,
|
|
81
78
|
dispatchAnalyticsEvent,
|
|
82
79
|
pluginInjectionApi,
|
|
83
|
-
isTableAlignmentEnabled,
|
|
84
80
|
isCommentEditor,
|
|
85
81
|
isChromelessEditor,
|
|
86
82
|
);
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -53,15 +53,16 @@ const getInlineWidth = (
|
|
|
53
53
|
options: Props['options'],
|
|
54
54
|
state: EditorState,
|
|
55
55
|
pos: number | undefined,
|
|
56
|
+
allowTableResizing?: boolean,
|
|
56
57
|
): number | undefined => {
|
|
57
|
-
if (!node.attrs.width && options?.isCommentEditor &&
|
|
58
|
+
if (!node.attrs.width && options?.isCommentEditor && allowTableResizing) {
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
// provide a width for tables when custom table width is supported
|
|
62
63
|
// this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
|
|
63
64
|
// support screen size adjustments
|
|
64
|
-
const shouldHaveInlineWidth =
|
|
65
|
+
const shouldHaveInlineWidth = allowTableResizing && !isTableNested(state, pos);
|
|
65
66
|
|
|
66
67
|
let widthValue = getTableContainerWidth(node);
|
|
67
68
|
|
|
@@ -135,6 +136,7 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
135
136
|
this.reactComponentProps.options,
|
|
136
137
|
this.reactComponentProps.view.state,
|
|
137
138
|
this.reactComponentProps.getPos(),
|
|
139
|
+
this.reactComponentProps.allowTableResizing,
|
|
138
140
|
);
|
|
139
141
|
if (tableInlineWidth) {
|
|
140
142
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
@@ -167,6 +169,7 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
167
169
|
(this.reactComponentProps as Props).options,
|
|
168
170
|
this.view.state,
|
|
169
171
|
this.getPos(),
|
|
172
|
+
this.reactComponentProps.allowTableResizing,
|
|
170
173
|
);
|
|
171
174
|
|
|
172
175
|
const isTableResizing = tableWidthPluginKey.getState(this.view.state)?.resizing;
|
|
@@ -192,6 +195,8 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
192
195
|
eventDispatcher={props.eventDispatcher}
|
|
193
196
|
api={props.pluginInjectionApi}
|
|
194
197
|
allowColumnResizing={props.allowColumnResizing}
|
|
198
|
+
allowTableAlignment={props.allowTableAlignment}
|
|
199
|
+
allowTableResizing={props.allowTableResizing}
|
|
195
200
|
allowControls={props.allowControls}
|
|
196
201
|
getPos={props.getPos}
|
|
197
202
|
getEditorFeatureFlags={props.getEditorFeatureFlags}
|
|
@@ -266,7 +271,8 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
266
271
|
isHeaderColumnEnabled={pluginState!.isHeaderColumnEnabled}
|
|
267
272
|
isDragAndDropEnabled={pluginState!.isDragAndDropEnabled}
|
|
268
273
|
isTableScalingEnabled={props.options?.isTableScalingEnabled} // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
|
|
269
|
-
|
|
274
|
+
allowTableAlignment={props.allowTableAlignment}
|
|
275
|
+
allowTableResizing={props.allowTableResizing}
|
|
270
276
|
tableActive={tableActive}
|
|
271
277
|
ordering={pluginState!.ordering as TableColumnOrdering}
|
|
272
278
|
isResizing={isResizing}
|
|
@@ -366,7 +372,6 @@ export const createTableView = (
|
|
|
366
372
|
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
367
373
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent,
|
|
368
374
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
369
|
-
isTableAlignmentEnabled?: boolean,
|
|
370
375
|
isCommentEditor?: boolean,
|
|
371
376
|
isChromelessEditor?: boolean,
|
|
372
377
|
): NodeView => {
|
|
@@ -374,16 +379,18 @@ export const createTableView = (
|
|
|
374
379
|
pluginConfig,
|
|
375
380
|
isFullWidthModeEnabled,
|
|
376
381
|
wasFullWidthModeEnabled,
|
|
377
|
-
isTableResizingEnabled,
|
|
378
382
|
isDragAndDropEnabled,
|
|
379
383
|
isTableScalingEnabled, // same as options.isTableScalingEnabled
|
|
380
384
|
} = getPluginState(view.state);
|
|
381
|
-
const { allowColumnResizing, allowControls } =
|
|
385
|
+
const { allowColumnResizing, allowControls, allowTableResizing, allowTableAlignment } =
|
|
386
|
+
getPluginConfig(pluginConfig);
|
|
382
387
|
|
|
383
388
|
return new TableView({
|
|
384
389
|
node,
|
|
385
390
|
view,
|
|
386
391
|
allowColumnResizing,
|
|
392
|
+
allowTableResizing,
|
|
393
|
+
allowTableAlignment,
|
|
387
394
|
allowControls,
|
|
388
395
|
portalProviderAPI,
|
|
389
396
|
eventDispatcher,
|
|
@@ -391,10 +398,8 @@ export const createTableView = (
|
|
|
391
398
|
options: {
|
|
392
399
|
isFullWidthModeEnabled,
|
|
393
400
|
wasFullWidthModeEnabled,
|
|
394
|
-
isTableResizingEnabled,
|
|
395
401
|
isDragAndDropEnabled,
|
|
396
402
|
isTableScalingEnabled, // same as options.isTableScalingEnabled
|
|
397
|
-
isTableAlignmentEnabled,
|
|
398
403
|
isCommentEditor,
|
|
399
404
|
isChromelessEditor,
|
|
400
405
|
},
|
package/src/nodeviews/types.ts
CHANGED
|
@@ -10,10 +10,8 @@ import type { PluginInjectionAPI } from '../types';
|
|
|
10
10
|
export type TableOptions = {
|
|
11
11
|
isFullWidthModeEnabled?: boolean;
|
|
12
12
|
wasFullWidthModeEnabled?: boolean;
|
|
13
|
-
isTableResizingEnabled?: boolean;
|
|
14
13
|
isDragAndDropEnabled?: boolean;
|
|
15
14
|
isTableScalingEnabled?: boolean;
|
|
16
|
-
isTableAlignmentEnabled?: boolean;
|
|
17
15
|
isCommentEditor?: boolean;
|
|
18
16
|
isChromelessEditor?: boolean;
|
|
19
17
|
};
|
|
@@ -22,6 +20,8 @@ export interface Props {
|
|
|
22
20
|
node: PmNode;
|
|
23
21
|
view: EditorView;
|
|
24
22
|
allowColumnResizing?: boolean;
|
|
23
|
+
allowTableResizing?: boolean;
|
|
24
|
+
allowTableAlignment?: boolean;
|
|
25
25
|
allowControls?: boolean;
|
|
26
26
|
cellMinWidth?: number;
|
|
27
27
|
portalProviderAPI: PortalProviderAPI;
|
package/src/plugin.tsx
CHANGED
|
@@ -103,15 +103,15 @@ import { createTableWithWidth } from './utils';
|
|
|
103
103
|
|
|
104
104
|
export interface TablePluginOptions {
|
|
105
105
|
tableOptions: PluginConfig;
|
|
106
|
-
|
|
106
|
+
// this option will eventually be removed, and enabled by default
|
|
107
107
|
dragAndDropEnabled?: boolean;
|
|
108
|
+
// this option will eventually be removed, and enabled by default
|
|
109
|
+
isTableScalingEnabled?: boolean;
|
|
108
110
|
allowContextualMenu?: boolean;
|
|
109
111
|
// TODO these two need to be rethought
|
|
110
112
|
fullWidthEnabled?: boolean;
|
|
111
113
|
wasFullWidthEnabled?: boolean;
|
|
112
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
113
|
-
isTableScalingEnabled?: boolean;
|
|
114
|
-
isTableAlignmentEnabled?: boolean;
|
|
115
115
|
isNewColumnResizingEnabled?: boolean;
|
|
116
116
|
isCommentEditor?: boolean;
|
|
117
117
|
isChromelessEditor?: boolean;
|
|
@@ -188,9 +188,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
188
188
|
// When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
189
189
|
options?.isCommentEditor);
|
|
190
190
|
|
|
191
|
-
const isCellBackgroundDuplicated =
|
|
192
|
-
options?.getEditorFeatureFlags?.().tableDuplicateCellColouring || false;
|
|
193
|
-
|
|
194
191
|
return {
|
|
195
192
|
name: 'table',
|
|
196
193
|
|
|
@@ -233,11 +230,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
233
230
|
(state, dispatch) => {
|
|
234
231
|
const node = createTableWithWidth({
|
|
235
232
|
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
236
|
-
isTableAlignmentEnabled: options?.
|
|
233
|
+
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
237
234
|
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
238
235
|
isCommentEditor: options?.isCommentEditor,
|
|
239
236
|
isChromelessEditor: options?.isChromelessEditor,
|
|
240
|
-
isTableResizingEnabled: options?.
|
|
237
|
+
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
241
238
|
})(state.schema);
|
|
242
239
|
|
|
243
240
|
// If the cursor is inside a table
|
|
@@ -286,7 +283,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
286
283
|
insertTableWithSize: insertTableWithSize(
|
|
287
284
|
options?.fullWidthEnabled,
|
|
288
285
|
options?.isTableScalingEnabled,
|
|
289
|
-
options?.
|
|
286
|
+
options?.tableOptions.allowTableAlignment,
|
|
290
287
|
api?.analytics?.actions,
|
|
291
288
|
options?.isCommentEditor,
|
|
292
289
|
),
|
|
@@ -302,7 +299,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
302
299
|
name: 'table',
|
|
303
300
|
node: tableNodeSpecWithFixedToDOM({
|
|
304
301
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
305
|
-
tableResizingEnabled: Boolean(options?.
|
|
302
|
+
tableResizingEnabled: Boolean(options?.tableOptions.allowTableResizing),
|
|
306
303
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
307
304
|
isNestingSupported,
|
|
308
305
|
}),
|
|
@@ -316,7 +313,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
316
313
|
name: 'table',
|
|
317
314
|
node: tableNodeSpecWithFixedToDOM({
|
|
318
315
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
319
|
-
tableResizingEnabled: Boolean(options?.
|
|
316
|
+
tableResizingEnabled: Boolean(options?.tableOptions.allowTableResizing),
|
|
320
317
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
321
318
|
isNestingSupported,
|
|
322
319
|
}),
|
|
@@ -342,13 +339,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
342
339
|
const {
|
|
343
340
|
fullWidthEnabled,
|
|
344
341
|
wasFullWidthEnabled,
|
|
345
|
-
tableResizingEnabled,
|
|
346
|
-
|
|
347
342
|
tableOptions,
|
|
348
343
|
getEditorFeatureFlags,
|
|
349
344
|
dragAndDropEnabled,
|
|
350
345
|
isTableScalingEnabled,
|
|
351
|
-
isTableAlignmentEnabled,
|
|
352
346
|
isCommentEditor,
|
|
353
347
|
isChromelessEditor,
|
|
354
348
|
} = options || ({} as TablePluginOptions);
|
|
@@ -363,14 +357,12 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
363
357
|
defaultGetEditorContainerWidth,
|
|
364
358
|
getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
365
359
|
getIntl,
|
|
366
|
-
tableResizingEnabled,
|
|
367
360
|
fullWidthEnabled,
|
|
368
361
|
wasFullWidthEnabled,
|
|
369
362
|
dragAndDropEnabled,
|
|
370
363
|
editorAnalyticsAPI,
|
|
371
364
|
api,
|
|
372
365
|
isTableScalingEnabled,
|
|
373
|
-
isTableAlignmentEnabled,
|
|
374
366
|
shouldUseIncreasedScalingPercent,
|
|
375
367
|
isCommentEditor,
|
|
376
368
|
isChromelessEditor,
|
|
@@ -386,9 +378,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
386
378
|
getEditorFeatureFlags,
|
|
387
379
|
isTableScalingEnabled,
|
|
388
380
|
isNewColumnResizingEnabled,
|
|
389
|
-
isTableAlignmentEnabled,
|
|
390
381
|
} = options || ({} as TablePluginOptions);
|
|
391
|
-
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
382
|
+
const { allowColumnResizing, allowTableAlignment } = pluginConfig(tableOptions);
|
|
392
383
|
return allowColumnResizing
|
|
393
384
|
? createFlexiResizingPlugin(
|
|
394
385
|
dispatch,
|
|
@@ -402,7 +393,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
402
393
|
editorAnalyticsAPI,
|
|
403
394
|
isTableScalingEnabled || false,
|
|
404
395
|
isNewColumnResizingEnabled,
|
|
405
|
-
|
|
396
|
+
allowTableAlignment,
|
|
406
397
|
!!options?.isCommentEditor,
|
|
407
398
|
)
|
|
408
399
|
: undefined;
|
|
@@ -417,11 +408,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
417
408
|
const {
|
|
418
409
|
dragAndDropEnabled,
|
|
419
410
|
isTableScalingEnabled = false,
|
|
420
|
-
isTableAlignmentEnabled = false,
|
|
421
411
|
fullWidthEnabled = false,
|
|
422
412
|
isCommentEditor = false,
|
|
423
413
|
isChromelessEditor = false,
|
|
424
|
-
|
|
414
|
+
tableOptions,
|
|
425
415
|
} = options || ({} as TablePluginOptions);
|
|
426
416
|
|
|
427
417
|
return keymapPlugin(
|
|
@@ -431,16 +421,15 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
431
421
|
editorAnalyticsAPI,
|
|
432
422
|
dragAndDropEnabled,
|
|
433
423
|
isTableScalingEnabled,
|
|
434
|
-
|
|
424
|
+
tableOptions?.allowTableAlignment,
|
|
435
425
|
fullWidthEnabled,
|
|
436
426
|
api,
|
|
437
427
|
getIntl,
|
|
438
|
-
isCellBackgroundDuplicated,
|
|
439
428
|
isTableFixedColumnWidthsOptionEnabled,
|
|
440
429
|
shouldUseIncreasedScalingPercent,
|
|
441
430
|
isCommentEditor,
|
|
442
431
|
isChromelessEditor,
|
|
443
|
-
|
|
432
|
+
tableOptions?.allowTableResizing,
|
|
444
433
|
);
|
|
445
434
|
},
|
|
446
435
|
},
|
|
@@ -505,24 +494,24 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
505
494
|
{
|
|
506
495
|
name: 'tableWidth',
|
|
507
496
|
plugin: ({ dispatchAnalyticsEvent, dispatch }) =>
|
|
508
|
-
options?.
|
|
497
|
+
options?.tableOptions.allowTableResizing
|
|
509
498
|
? createTableWidthPlugin(
|
|
510
499
|
dispatch,
|
|
511
500
|
dispatchAnalyticsEvent,
|
|
512
|
-
options
|
|
513
|
-
options
|
|
514
|
-
options
|
|
515
|
-
options
|
|
501
|
+
options.fullWidthEnabled ?? false,
|
|
502
|
+
options.isTableScalingEnabled ?? false,
|
|
503
|
+
options.tableOptions.allowTableResizing ?? false,
|
|
504
|
+
options.isCommentEditor ?? false,
|
|
516
505
|
)
|
|
517
506
|
: undefined,
|
|
518
507
|
},
|
|
519
508
|
{
|
|
520
509
|
name: 'tableWidthInCommentFix',
|
|
521
510
|
plugin: ({ dispatch }) =>
|
|
522
|
-
options?.
|
|
511
|
+
options?.tableOptions.allowTableResizing && options?.isCommentEditor
|
|
523
512
|
? createTableWidthInCommentFixPlugin(
|
|
524
513
|
dispatch,
|
|
525
|
-
options
|
|
514
|
+
options.tableOptions.allowTableAlignment ?? false,
|
|
526
515
|
)
|
|
527
516
|
: undefined,
|
|
528
517
|
},
|
|
@@ -533,7 +522,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
533
522
|
createTableOverflowAnalyticsPlugin(
|
|
534
523
|
dispatch,
|
|
535
524
|
dispatchAnalyticsEvent,
|
|
536
|
-
options?.
|
|
525
|
+
options?.tableOptions.allowTableResizing ?? false,
|
|
537
526
|
),
|
|
538
527
|
},
|
|
539
528
|
{
|
|
@@ -735,7 +724,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
735
724
|
/>
|
|
736
725
|
)}
|
|
737
726
|
{(options?.isTableScalingEnabled ||
|
|
738
|
-
(options?.
|
|
727
|
+
(options?.tableOptions.allowTableResizing && options.isCommentEditor)) &&
|
|
739
728
|
isTableResizing &&
|
|
740
729
|
widthToWidest &&
|
|
741
730
|
resizingTableLocalId &&
|
|
@@ -776,11 +765,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
776
765
|
|
|
777
766
|
const tableNode = createTableWithWidth({
|
|
778
767
|
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
779
|
-
isTableAlignmentEnabled: options?.
|
|
768
|
+
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
780
769
|
isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
|
|
781
770
|
isCommentEditor: options?.isCommentEditor,
|
|
782
771
|
isChromelessEditor: options?.isChromelessEditor,
|
|
783
|
-
isTableResizingEnabled: options?.
|
|
772
|
+
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
784
773
|
})(state.schema);
|
|
785
774
|
|
|
786
775
|
let { tr } = state;
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -68,7 +68,6 @@ export function keymapPlugin(
|
|
|
68
68
|
isFullWidthEnabled?: boolean,
|
|
69
69
|
pluginInjectionApi?: PluginInjectionAPIWithA11y,
|
|
70
70
|
getIntl?: () => IntlShape,
|
|
71
|
-
isCellBackgroundDuplicated = false,
|
|
72
71
|
isTableFixedColumnWidthsOptionEnabled = false,
|
|
73
72
|
shouldUseIncreasedScalingPercent?: boolean,
|
|
74
73
|
isCommentEditor?: boolean,
|
|
@@ -130,7 +129,6 @@ export function keymapPlugin(
|
|
|
130
129
|
addColumnBeforeCommand(
|
|
131
130
|
api,
|
|
132
131
|
isTableScalingEnabled,
|
|
133
|
-
isCellBackgroundDuplicated,
|
|
134
132
|
isTableFixedColumnWidthsOptionEnabled,
|
|
135
133
|
shouldUseIncreasedScalingPercent,
|
|
136
134
|
),
|
|
@@ -142,7 +140,6 @@ export function keymapPlugin(
|
|
|
142
140
|
addColumnAfterCommand(
|
|
143
141
|
api,
|
|
144
142
|
isTableScalingEnabled,
|
|
145
|
-
isCellBackgroundDuplicated,
|
|
146
143
|
isTableFixedColumnWidthsOptionEnabled,
|
|
147
144
|
shouldUseIncreasedScalingPercent,
|
|
148
145
|
),
|
|
@@ -166,7 +163,6 @@ export function keymapPlugin(
|
|
|
166
163
|
addColumnBeforeCommand(
|
|
167
164
|
api,
|
|
168
165
|
isTableScalingEnabled,
|
|
169
|
-
isCellBackgroundDuplicated,
|
|
170
166
|
isTableFixedColumnWidthsOptionEnabled,
|
|
171
167
|
shouldUseIncreasedScalingPercent,
|
|
172
168
|
),
|
|
@@ -178,7 +174,6 @@ export function keymapPlugin(
|
|
|
178
174
|
addColumnAfterCommand(
|
|
179
175
|
api,
|
|
180
176
|
isTableScalingEnabled,
|
|
181
|
-
isCellBackgroundDuplicated,
|
|
182
177
|
isTableFixedColumnWidthsOptionEnabled,
|
|
183
178
|
shouldUseIncreasedScalingPercent,
|
|
184
179
|
),
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -85,14 +85,12 @@ export const createPlugin = (
|
|
|
85
85
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
86
86
|
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
87
87
|
getIntl: () => IntlShape,
|
|
88
|
-
tableResizingEnabled?: boolean,
|
|
89
88
|
fullWidthModeEnabled?: boolean,
|
|
90
89
|
previousFullWidthModeEnabled?: boolean,
|
|
91
90
|
dragAndDropEnabled?: boolean,
|
|
92
91
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
93
92
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
94
93
|
isTableScalingEnabled?: boolean,
|
|
95
|
-
isTableAlignmentEnabled?: boolean,
|
|
96
94
|
shouldUseIncreasedScalingPercent?: boolean,
|
|
97
95
|
isCommentEditor?: boolean,
|
|
98
96
|
isChromelessEditor?: boolean,
|
|
@@ -104,7 +102,6 @@ export const createPlugin = (
|
|
|
104
102
|
insertRowButtonIndex: undefined,
|
|
105
103
|
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
106
104
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
107
|
-
isTableResizingEnabled: tableResizingEnabled,
|
|
108
105
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
109
106
|
isHeaderColumnEnabled: false,
|
|
110
107
|
isDragAndDropEnabled: dragAndDropEnabled,
|
|
@@ -268,7 +265,7 @@ export const createPlugin = (
|
|
|
268
265
|
if (
|
|
269
266
|
!insideTable(editorState) &&
|
|
270
267
|
isCommentEditor &&
|
|
271
|
-
|
|
268
|
+
pluginConfig.allowTableAlignment &&
|
|
272
269
|
isTableScalingEnabled
|
|
273
270
|
) {
|
|
274
271
|
slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
|
|
@@ -369,7 +366,6 @@ export const createPlugin = (
|
|
|
369
366
|
getEditorFeatureFlags,
|
|
370
367
|
dispatchAnalyticsEvent,
|
|
371
368
|
pluginInjectionApi,
|
|
372
|
-
isTableAlignmentEnabled,
|
|
373
369
|
isCommentEditor,
|
|
374
370
|
isChromelessEditor,
|
|
375
371
|
}),
|
|
@@ -382,7 +378,7 @@ export const createPlugin = (
|
|
|
382
378
|
blur: handleBlur,
|
|
383
379
|
mousedown: withCellTracking(handleMouseDown),
|
|
384
380
|
mouseleave: handleMouseLeave,
|
|
385
|
-
mousemove: whenTableInFocus(handleMouseMove(nodeViewPortalProviderAPI)),
|
|
381
|
+
mousemove: whenTableInFocus(handleMouseMove(nodeViewPortalProviderAPI), pluginInjectionApi),
|
|
386
382
|
mouseenter: handleMouseEnter,
|
|
387
383
|
mouseup: whenTableInFocus(handleMouseUp),
|
|
388
384
|
click: withCellTracking(whenTableInFocus(handleClick)),
|
package/src/toolbar.tsx
CHANGED
|
@@ -206,7 +206,6 @@ export const getToolbarCellOptionsConfig = (
|
|
|
206
206
|
api: PluginInjectionAPI | undefined | null,
|
|
207
207
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
208
208
|
isTableScalingEnabled = false,
|
|
209
|
-
isCellBackgroundDuplicated = false,
|
|
210
209
|
isTableFixedColumnWidthsOptionEnabled = false,
|
|
211
210
|
shouldUseIncreasedScalingPercent = false,
|
|
212
211
|
isCommentEditor = false,
|
|
@@ -228,7 +227,6 @@ export const getToolbarCellOptionsConfig = (
|
|
|
228
227
|
api,
|
|
229
228
|
editorAnalyticsAPI,
|
|
230
229
|
isTableScalingEnabled,
|
|
231
|
-
isCellBackgroundDuplicated,
|
|
232
230
|
isTableFixedColumnWidthsOptionEnabled,
|
|
233
231
|
shouldUseIncreasedScalingPercent,
|
|
234
232
|
isCommentEditor,
|
|
@@ -539,7 +537,7 @@ export const getToolbarConfig =
|
|
|
539
537
|
);
|
|
540
538
|
|
|
541
539
|
const alignmentMenu =
|
|
542
|
-
|
|
540
|
+
config.allowTableAlignment && !isNested
|
|
543
541
|
? getAlignmentOptionsConfig(
|
|
544
542
|
state,
|
|
545
543
|
intl,
|
|
@@ -553,9 +551,6 @@ export const getToolbarConfig =
|
|
|
553
551
|
)
|
|
554
552
|
: [];
|
|
555
553
|
|
|
556
|
-
const isCellBackgroundDuplicated =
|
|
557
|
-
getEditorFeatureFlags().tableDuplicateCellColouring || false;
|
|
558
|
-
|
|
559
554
|
const cellItems = pluginState.isDragAndDropEnabled
|
|
560
555
|
? []
|
|
561
556
|
: getCellItems(
|
|
@@ -566,7 +561,6 @@ export const getToolbarConfig =
|
|
|
566
561
|
api,
|
|
567
562
|
editorAnalyticsAPI,
|
|
568
563
|
isTableScalingEnabled,
|
|
569
|
-
isCellBackgroundDuplicated,
|
|
570
564
|
isTableFixedColumnWidthsOptionEnabled,
|
|
571
565
|
shouldUseIncreasedScalingPercent,
|
|
572
566
|
options?.isCommentEditor,
|
|
@@ -681,7 +675,6 @@ const getCellItems = (
|
|
|
681
675
|
api: PluginInjectionAPI | undefined | null,
|
|
682
676
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
683
677
|
isTableScalingEnabled = false,
|
|
684
|
-
isCellBackgroundDuplicated = false,
|
|
685
678
|
isTableFixedColumnWidthsOptionEnabled = false,
|
|
686
679
|
shouldUseIncreasedScalingPercent = false,
|
|
687
680
|
isCommentEditor = false,
|
|
@@ -697,7 +690,6 @@ const getCellItems = (
|
|
|
697
690
|
api,
|
|
698
691
|
editorAnalyticsAPI,
|
|
699
692
|
isTableScalingEnabled,
|
|
700
|
-
isCellBackgroundDuplicated,
|
|
701
693
|
isTableFixedColumnWidthsOptionEnabled,
|
|
702
694
|
shouldUseIncreasedScalingPercent,
|
|
703
695
|
isCommentEditor,
|
package/src/types.ts
CHANGED
|
@@ -79,6 +79,8 @@ export interface PluginConfig {
|
|
|
79
79
|
advanced?: boolean;
|
|
80
80
|
allowBackgroundColor?: boolean;
|
|
81
81
|
allowColumnResizing?: boolean;
|
|
82
|
+
allowTableResizing?: boolean;
|
|
83
|
+
allowTableAlignment?: boolean;
|
|
82
84
|
allowHeaderColumn?: boolean;
|
|
83
85
|
allowHeaderRow?: boolean;
|
|
84
86
|
allowMergeCells?: boolean;
|
|
@@ -169,7 +171,6 @@ export interface TablePluginState {
|
|
|
169
171
|
getIntl: () => IntlShape;
|
|
170
172
|
|
|
171
173
|
wasFullWidthModeEnabled?: boolean;
|
|
172
|
-
isTableResizingEnabled?: boolean;
|
|
173
174
|
isDragAndDropEnabled?: boolean;
|
|
174
175
|
isTableHovered?: boolean;
|
|
175
176
|
|
|
@@ -653,8 +653,9 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
653
653
|
const { state, dispatch } = editorView;
|
|
654
654
|
const { targetCellPosition, isTableScalingEnabled = false } = getPluginState(state);
|
|
655
655
|
|
|
656
|
-
const {
|
|
657
|
-
|
|
656
|
+
const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags
|
|
657
|
+
? getEditorFeatureFlags()
|
|
658
|
+
: {};
|
|
658
659
|
// context menu opened by keyboard and any item except 'background' activated
|
|
659
660
|
// or color has been chosen from color palette
|
|
660
661
|
if (
|
|
@@ -735,7 +736,6 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
735
736
|
this.props.api,
|
|
736
737
|
editorAnalyticsAPI,
|
|
737
738
|
isTableScalingEnabled,
|
|
738
|
-
tableDuplicateCellColouring,
|
|
739
739
|
tableWithFixedColumnWidthsOption,
|
|
740
740
|
shouldUseIncreasedScalingPercent,
|
|
741
741
|
isCommentEditor,
|
|
@@ -743,13 +743,10 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
743
743
|
this.toggleOpen();
|
|
744
744
|
break;
|
|
745
745
|
case 'insert_row':
|
|
746
|
-
insertRowWithAnalytics(editorAnalyticsAPI,
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
moveCursorToInsertedRow: true,
|
|
751
|
-
},
|
|
752
|
-
)(state, dispatch);
|
|
746
|
+
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, {
|
|
747
|
+
index: selectionRect.bottom,
|
|
748
|
+
moveCursorToInsertedRow: true,
|
|
749
|
+
})(state, dispatch);
|
|
753
750
|
this.toggleOpen();
|
|
754
751
|
break;
|
|
755
752
|
case 'delete_column':
|
|
@@ -90,7 +90,6 @@ type DragMenuProps = {
|
|
|
90
90
|
boundariesElement?: HTMLElement;
|
|
91
91
|
scrollableElement?: HTMLElement;
|
|
92
92
|
isTableScalingEnabled?: boolean;
|
|
93
|
-
tableDuplicateCellColouring?: boolean;
|
|
94
93
|
shouldUseIncreasedScalingPercent?: boolean;
|
|
95
94
|
isTableFixedColumnWidthsOptionEnabled?: boolean;
|
|
96
95
|
ariaNotifyPlugin?: (
|
|
@@ -279,7 +278,6 @@ const DragMenu = React.memo(
|
|
|
279
278
|
scrollableElement,
|
|
280
279
|
boundariesElement,
|
|
281
280
|
isTableScalingEnabled,
|
|
282
|
-
tableDuplicateCellColouring,
|
|
283
281
|
shouldUseIncreasedScalingPercent,
|
|
284
282
|
isTableFixedColumnWidthsOptionEnabled,
|
|
285
283
|
ariaNotifyPlugin,
|
|
@@ -311,7 +309,6 @@ const DragMenu = React.memo(
|
|
|
311
309
|
editorAnalyticsAPI,
|
|
312
310
|
pluginConfig?.isHeaderRowRequired,
|
|
313
311
|
isTableScalingEnabled,
|
|
314
|
-
tableDuplicateCellColouring,
|
|
315
312
|
isTableFixedColumnWidthsOptionEnabled,
|
|
316
313
|
shouldUseIncreasedScalingPercent,
|
|
317
314
|
ariaNotifyPlugin,
|
|
@@ -79,8 +79,7 @@ const FloatingDragMenu = ({
|
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const {
|
|
83
|
-
getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
82
|
+
const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags?.() ?? {};
|
|
84
83
|
|
|
85
84
|
const shouldUseIncreasedScalingPercent =
|
|
86
85
|
isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
|
|
@@ -120,7 +119,6 @@ const FloatingDragMenu = ({
|
|
|
120
119
|
boundariesElement={boundariesElement}
|
|
121
120
|
scrollableElement={scrollableElement}
|
|
122
121
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
123
|
-
tableDuplicateCellColouring={tableDuplicateCellColouring}
|
|
124
122
|
shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
|
|
125
123
|
isTableFixedColumnWidthsOptionEnabled={tableWithFixedColumnWidthsOption}
|
|
126
124
|
ariaNotifyPlugin={ariaNotifyPlugin}
|
|
@@ -241,19 +241,14 @@ export class FloatingInsertButton extends React.Component<Props & WrappedCompone
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
private insertRow(event: React.SyntheticEvent) {
|
|
244
|
-
const { editorView, insertRowButtonIndex, editorAnalyticsAPI
|
|
245
|
-
this.props;
|
|
244
|
+
const { editorView, insertRowButtonIndex, editorAnalyticsAPI } = this.props;
|
|
246
245
|
|
|
247
246
|
if (typeof insertRowButtonIndex !== 'undefined') {
|
|
248
247
|
event.preventDefault();
|
|
249
248
|
|
|
250
249
|
const { state, dispatch } = editorView;
|
|
251
|
-
const featureFlags = !!getEditorFeatureFlags && getEditorFeatureFlags();
|
|
252
250
|
|
|
253
|
-
insertRowWithAnalytics(
|
|
254
|
-
editorAnalyticsAPI,
|
|
255
|
-
featureFlags && featureFlags.tableDuplicateCellColouring,
|
|
256
|
-
)(INPUT_METHOD.BUTTON, {
|
|
251
|
+
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, {
|
|
257
252
|
index: insertRowButtonIndex,
|
|
258
253
|
moveCursorToInsertedRow: true,
|
|
259
254
|
})(state, dispatch);
|
|
@@ -273,8 +268,9 @@ export class FloatingInsertButton extends React.Component<Props & WrappedCompone
|
|
|
273
268
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
274
269
|
event.preventDefault();
|
|
275
270
|
|
|
276
|
-
const {
|
|
277
|
-
|
|
271
|
+
const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags
|
|
272
|
+
? getEditorFeatureFlags()
|
|
273
|
+
: {};
|
|
278
274
|
|
|
279
275
|
const shouldUseIncreasedScalingPercent =
|
|
280
276
|
isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
|
|
@@ -284,7 +280,6 @@ export class FloatingInsertButton extends React.Component<Props & WrappedCompone
|
|
|
284
280
|
this.props.api,
|
|
285
281
|
editorAnalyticsAPI,
|
|
286
282
|
isTableScalingEnabled,
|
|
287
|
-
tableDuplicateCellColouring,
|
|
288
283
|
tableWithFixedColumnWidthsOption,
|
|
289
284
|
shouldUseIncreasedScalingPercent,
|
|
290
285
|
isCommentEditor,
|