@atlaskit/editor-plugin-table 7.31.3 → 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 +83 -0
- 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 +21 -26
- package/dist/cjs/pm-plugins/main.js +3 -5
- package/dist/cjs/toolbar.js +1 -1
- 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 +21 -24
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/toolbar.js +1 -1
- 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 +21 -26
- package/dist/esm/pm-plugins/main.js +3 -5
- package/dist/esm/toolbar.js +1 -1
- 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/main.d.ts +1 -1
- package/dist/types/types.d.ts +2 -1
- 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/main.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/package.json +2 -2
- 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 -31
- package/src/pm-plugins/main.ts +2 -6
- package/src/toolbar.tsx +1 -1
- package/src/types.ts +2 -1
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;
|
|
@@ -230,11 +230,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
230
230
|
(state, dispatch) => {
|
|
231
231
|
const node = createTableWithWidth({
|
|
232
232
|
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
233
|
-
isTableAlignmentEnabled: options?.
|
|
233
|
+
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
234
234
|
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
235
235
|
isCommentEditor: options?.isCommentEditor,
|
|
236
236
|
isChromelessEditor: options?.isChromelessEditor,
|
|
237
|
-
isTableResizingEnabled: options?.
|
|
237
|
+
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
238
238
|
})(state.schema);
|
|
239
239
|
|
|
240
240
|
// If the cursor is inside a table
|
|
@@ -283,7 +283,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
283
283
|
insertTableWithSize: insertTableWithSize(
|
|
284
284
|
options?.fullWidthEnabled,
|
|
285
285
|
options?.isTableScalingEnabled,
|
|
286
|
-
options?.
|
|
286
|
+
options?.tableOptions.allowTableAlignment,
|
|
287
287
|
api?.analytics?.actions,
|
|
288
288
|
options?.isCommentEditor,
|
|
289
289
|
),
|
|
@@ -299,7 +299,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
299
299
|
name: 'table',
|
|
300
300
|
node: tableNodeSpecWithFixedToDOM({
|
|
301
301
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
302
|
-
tableResizingEnabled: Boolean(options?.
|
|
302
|
+
tableResizingEnabled: Boolean(options?.tableOptions.allowTableResizing),
|
|
303
303
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
304
304
|
isNestingSupported,
|
|
305
305
|
}),
|
|
@@ -313,7 +313,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
313
313
|
name: 'table',
|
|
314
314
|
node: tableNodeSpecWithFixedToDOM({
|
|
315
315
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
316
|
-
tableResizingEnabled: Boolean(options?.
|
|
316
|
+
tableResizingEnabled: Boolean(options?.tableOptions.allowTableResizing),
|
|
317
317
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
318
318
|
isNestingSupported,
|
|
319
319
|
}),
|
|
@@ -339,13 +339,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
339
339
|
const {
|
|
340
340
|
fullWidthEnabled,
|
|
341
341
|
wasFullWidthEnabled,
|
|
342
|
-
tableResizingEnabled,
|
|
343
|
-
|
|
344
342
|
tableOptions,
|
|
345
343
|
getEditorFeatureFlags,
|
|
346
344
|
dragAndDropEnabled,
|
|
347
345
|
isTableScalingEnabled,
|
|
348
|
-
isTableAlignmentEnabled,
|
|
349
346
|
isCommentEditor,
|
|
350
347
|
isChromelessEditor,
|
|
351
348
|
} = options || ({} as TablePluginOptions);
|
|
@@ -360,14 +357,12 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
360
357
|
defaultGetEditorContainerWidth,
|
|
361
358
|
getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
362
359
|
getIntl,
|
|
363
|
-
tableResizingEnabled,
|
|
364
360
|
fullWidthEnabled,
|
|
365
361
|
wasFullWidthEnabled,
|
|
366
362
|
dragAndDropEnabled,
|
|
367
363
|
editorAnalyticsAPI,
|
|
368
364
|
api,
|
|
369
365
|
isTableScalingEnabled,
|
|
370
|
-
isTableAlignmentEnabled,
|
|
371
366
|
shouldUseIncreasedScalingPercent,
|
|
372
367
|
isCommentEditor,
|
|
373
368
|
isChromelessEditor,
|
|
@@ -383,9 +378,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
383
378
|
getEditorFeatureFlags,
|
|
384
379
|
isTableScalingEnabled,
|
|
385
380
|
isNewColumnResizingEnabled,
|
|
386
|
-
isTableAlignmentEnabled,
|
|
387
381
|
} = options || ({} as TablePluginOptions);
|
|
388
|
-
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
382
|
+
const { allowColumnResizing, allowTableAlignment } = pluginConfig(tableOptions);
|
|
389
383
|
return allowColumnResizing
|
|
390
384
|
? createFlexiResizingPlugin(
|
|
391
385
|
dispatch,
|
|
@@ -399,7 +393,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
399
393
|
editorAnalyticsAPI,
|
|
400
394
|
isTableScalingEnabled || false,
|
|
401
395
|
isNewColumnResizingEnabled,
|
|
402
|
-
|
|
396
|
+
allowTableAlignment,
|
|
403
397
|
!!options?.isCommentEditor,
|
|
404
398
|
)
|
|
405
399
|
: undefined;
|
|
@@ -414,11 +408,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
414
408
|
const {
|
|
415
409
|
dragAndDropEnabled,
|
|
416
410
|
isTableScalingEnabled = false,
|
|
417
|
-
isTableAlignmentEnabled = false,
|
|
418
411
|
fullWidthEnabled = false,
|
|
419
412
|
isCommentEditor = false,
|
|
420
413
|
isChromelessEditor = false,
|
|
421
|
-
|
|
414
|
+
tableOptions,
|
|
422
415
|
} = options || ({} as TablePluginOptions);
|
|
423
416
|
|
|
424
417
|
return keymapPlugin(
|
|
@@ -428,7 +421,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
428
421
|
editorAnalyticsAPI,
|
|
429
422
|
dragAndDropEnabled,
|
|
430
423
|
isTableScalingEnabled,
|
|
431
|
-
|
|
424
|
+
tableOptions?.allowTableAlignment,
|
|
432
425
|
fullWidthEnabled,
|
|
433
426
|
api,
|
|
434
427
|
getIntl,
|
|
@@ -436,7 +429,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
436
429
|
shouldUseIncreasedScalingPercent,
|
|
437
430
|
isCommentEditor,
|
|
438
431
|
isChromelessEditor,
|
|
439
|
-
|
|
432
|
+
tableOptions?.allowTableResizing,
|
|
440
433
|
);
|
|
441
434
|
},
|
|
442
435
|
},
|
|
@@ -501,24 +494,24 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
501
494
|
{
|
|
502
495
|
name: 'tableWidth',
|
|
503
496
|
plugin: ({ dispatchAnalyticsEvent, dispatch }) =>
|
|
504
|
-
options?.
|
|
497
|
+
options?.tableOptions.allowTableResizing
|
|
505
498
|
? createTableWidthPlugin(
|
|
506
499
|
dispatch,
|
|
507
500
|
dispatchAnalyticsEvent,
|
|
508
|
-
options
|
|
509
|
-
options
|
|
510
|
-
options
|
|
511
|
-
options
|
|
501
|
+
options.fullWidthEnabled ?? false,
|
|
502
|
+
options.isTableScalingEnabled ?? false,
|
|
503
|
+
options.tableOptions.allowTableResizing ?? false,
|
|
504
|
+
options.isCommentEditor ?? false,
|
|
512
505
|
)
|
|
513
506
|
: undefined,
|
|
514
507
|
},
|
|
515
508
|
{
|
|
516
509
|
name: 'tableWidthInCommentFix',
|
|
517
510
|
plugin: ({ dispatch }) =>
|
|
518
|
-
options?.
|
|
511
|
+
options?.tableOptions.allowTableResizing && options?.isCommentEditor
|
|
519
512
|
? createTableWidthInCommentFixPlugin(
|
|
520
513
|
dispatch,
|
|
521
|
-
options
|
|
514
|
+
options.tableOptions.allowTableAlignment ?? false,
|
|
522
515
|
)
|
|
523
516
|
: undefined,
|
|
524
517
|
},
|
|
@@ -529,7 +522,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
529
522
|
createTableOverflowAnalyticsPlugin(
|
|
530
523
|
dispatch,
|
|
531
524
|
dispatchAnalyticsEvent,
|
|
532
|
-
options?.
|
|
525
|
+
options?.tableOptions.allowTableResizing ?? false,
|
|
533
526
|
),
|
|
534
527
|
},
|
|
535
528
|
{
|
|
@@ -731,7 +724,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
731
724
|
/>
|
|
732
725
|
)}
|
|
733
726
|
{(options?.isTableScalingEnabled ||
|
|
734
|
-
(options?.
|
|
727
|
+
(options?.tableOptions.allowTableResizing && options.isCommentEditor)) &&
|
|
735
728
|
isTableResizing &&
|
|
736
729
|
widthToWidest &&
|
|
737
730
|
resizingTableLocalId &&
|
|
@@ -772,11 +765,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
772
765
|
|
|
773
766
|
const tableNode = createTableWithWidth({
|
|
774
767
|
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
775
|
-
isTableAlignmentEnabled: options?.
|
|
768
|
+
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
776
769
|
isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
|
|
777
770
|
isCommentEditor: options?.isCommentEditor,
|
|
778
771
|
isChromelessEditor: options?.isChromelessEditor,
|
|
779
|
-
isTableResizingEnabled: options?.
|
|
772
|
+
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
780
773
|
})(state.schema);
|
|
781
774
|
|
|
782
775
|
let { tr } = state;
|
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
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
|
|