@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
|
@@ -16,5 +16,5 @@ export declare const handleMouseMove: (nodeViewPortalProviderAPI: PortalProvider
|
|
|
16
16
|
export declare function handleTripleClick(view: EditorView, pos: number): boolean;
|
|
17
17
|
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView, isTableScalingEnabled?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => Transaction;
|
|
18
18
|
export declare const isTableInFocus: (view: EditorView) => boolean;
|
|
19
|
-
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event) => boolean) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
19
|
+
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event) => boolean, pluginInjectionApi?: PluginInjectionAPI) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
20
20
|
export declare const withCellTracking: (eventHandler: (view: EditorView, mouseEvent: Event) => boolean) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
@@ -18,12 +18,13 @@ interface ComponentProps {
|
|
|
18
18
|
contentDOM: (node: HTMLElement | null) => void;
|
|
19
19
|
containerWidth: EditorContainerWidth;
|
|
20
20
|
allowControls: boolean;
|
|
21
|
+
allowTableResizing?: boolean;
|
|
22
|
+
allowTableAlignment?: boolean;
|
|
21
23
|
isHeaderRowEnabled: boolean;
|
|
22
24
|
isHeaderColumnEnabled: boolean;
|
|
23
25
|
isMediaFullscreen?: boolean;
|
|
24
26
|
isDragAndDropEnabled?: boolean;
|
|
25
27
|
isTableScalingEnabled?: boolean;
|
|
26
|
-
isTableAlignmentEnabled?: boolean;
|
|
27
28
|
tableActive: boolean;
|
|
28
29
|
ordering?: TableColumnOrdering;
|
|
29
30
|
isResizing?: boolean;
|
|
@@ -19,9 +19,11 @@ type TableComponentWithSharedStateProps = {
|
|
|
19
19
|
getPos: getPosHandlerNode;
|
|
20
20
|
allowColumnResizing?: boolean;
|
|
21
21
|
allowControls?: boolean;
|
|
22
|
+
allowTableAlignment?: boolean;
|
|
23
|
+
allowTableResizing?: boolean;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
26
|
* Use useSharedPluginState to control re-renders from plugin dependencies
|
|
25
27
|
*/
|
|
26
|
-
export declare const TableComponentWithSharedState: ({ view, options, getNode, dispatchAnalyticsEvent, api, getEditorFeatureFlags, eventDispatcher, allowColumnResizing, allowControls, getPos, forwardRef, }: TableComponentWithSharedStateProps) => JSX.Element | null;
|
|
28
|
+
export declare const TableComponentWithSharedState: ({ view, options, getNode, dispatchAnalyticsEvent, api, getEditorFeatureFlags, eventDispatcher, allowColumnResizing, allowControls, getPos, forwardRef, allowTableAlignment, allowTableResizing, }: TableComponentWithSharedStateProps) => JSX.Element | null;
|
|
27
29
|
export {};
|
|
@@ -14,7 +14,6 @@ type TableViewOptions = {
|
|
|
14
14
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
15
15
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
16
16
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
17
|
-
isTableAlignmentEnabled?: boolean;
|
|
18
17
|
isCommentEditor?: boolean;
|
|
19
18
|
isChromelessEditor?: boolean;
|
|
20
19
|
};
|
|
@@ -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: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI,
|
|
35
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isCommentEditor?: boolean, isChromelessEditor?: boolean) => NodeView;
|
|
36
36
|
export {};
|
|
@@ -8,10 +8,8 @@ import type { PluginInjectionAPI } from '../types';
|
|
|
8
8
|
export type TableOptions = {
|
|
9
9
|
isFullWidthModeEnabled?: boolean;
|
|
10
10
|
wasFullWidthModeEnabled?: boolean;
|
|
11
|
-
isTableResizingEnabled?: boolean;
|
|
12
11
|
isDragAndDropEnabled?: boolean;
|
|
13
12
|
isTableScalingEnabled?: boolean;
|
|
14
|
-
isTableAlignmentEnabled?: boolean;
|
|
15
13
|
isCommentEditor?: boolean;
|
|
16
14
|
isChromelessEditor?: boolean;
|
|
17
15
|
};
|
|
@@ -19,6 +17,8 @@ export interface Props {
|
|
|
19
17
|
node: PmNode;
|
|
20
18
|
view: EditorView;
|
|
21
19
|
allowColumnResizing?: boolean;
|
|
20
|
+
allowTableResizing?: boolean;
|
|
21
|
+
allowTableAlignment?: boolean;
|
|
22
22
|
allowControls?: boolean;
|
|
23
23
|
cellMinWidth?: number;
|
|
24
24
|
portalProviderAPI: PortalProviderAPI;
|
|
@@ -13,14 +13,12 @@ import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
|
13
13
|
import type { PluginConfig, TableSharedState } from './types';
|
|
14
14
|
export interface TablePluginOptions {
|
|
15
15
|
tableOptions: PluginConfig;
|
|
16
|
-
tableResizingEnabled?: boolean;
|
|
17
16
|
dragAndDropEnabled?: boolean;
|
|
17
|
+
isTableScalingEnabled?: boolean;
|
|
18
18
|
allowContextualMenu?: boolean;
|
|
19
19
|
fullWidthEnabled?: boolean;
|
|
20
20
|
wasFullWidthEnabled?: boolean;
|
|
21
21
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
22
|
-
isTableScalingEnabled?: boolean;
|
|
23
|
-
isTableAlignmentEnabled?: boolean;
|
|
24
22
|
isNewColumnResizingEnabled?: boolean;
|
|
25
23
|
isCommentEditor?: boolean;
|
|
26
24
|
isChromelessEditor?: boolean;
|
|
@@ -5,4 +5,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { PluginConfig, PluginInjectionAPI } from '../types';
|
|
8
|
-
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, nodeViewPortalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape,
|
|
8
|
+
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, nodeViewPortalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, dragAndDropEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI, isTableScalingEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean, isChromelessEditor?: boolean) => SafePlugin<import("../types").TablePluginState>;
|
|
@@ -45,6 +45,8 @@ export interface PluginConfig {
|
|
|
45
45
|
advanced?: boolean;
|
|
46
46
|
allowBackgroundColor?: boolean;
|
|
47
47
|
allowColumnResizing?: boolean;
|
|
48
|
+
allowTableResizing?: boolean;
|
|
49
|
+
allowTableAlignment?: boolean;
|
|
48
50
|
allowHeaderColumn?: boolean;
|
|
49
51
|
allowHeaderRow?: boolean;
|
|
50
52
|
allowMergeCells?: boolean;
|
|
@@ -102,7 +104,6 @@ export interface TablePluginState {
|
|
|
102
104
|
widthToWidest?: WidthToWidest;
|
|
103
105
|
getIntl: () => IntlShape;
|
|
104
106
|
wasFullWidthModeEnabled?: boolean;
|
|
105
|
-
isTableResizingEnabled?: boolean;
|
|
106
107
|
isDragAndDropEnabled?: boolean;
|
|
107
108
|
isTableHovered?: boolean;
|
|
108
109
|
isTableScalingEnabled?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@atlaskit/adf-schema": "^44.2.0",
|
|
31
31
|
"@atlaskit/button": "^20.3.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.8.0",
|
|
33
|
-
"@atlaskit/editor-common": "^94.
|
|
33
|
+
"@atlaskit/editor-common": "^94.24.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.3",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
package/src/event-handlers.ts
CHANGED
|
@@ -537,12 +537,28 @@ export const isTableInFocus = (view: EditorView) => {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
export const whenTableInFocus =
|
|
540
|
-
(
|
|
540
|
+
(
|
|
541
|
+
eventHandler: (view: EditorView, mouseEvent: Event) => boolean,
|
|
542
|
+
pluginInjectionApi?: PluginInjectionAPI,
|
|
543
|
+
) =>
|
|
541
544
|
(view: EditorView, mouseEvent: Event): boolean => {
|
|
545
|
+
|
|
542
546
|
if (!isTableInFocus(view)) {
|
|
543
547
|
return false;
|
|
544
548
|
}
|
|
545
549
|
|
|
550
|
+
const isViewMode =
|
|
551
|
+
pluginInjectionApi?.editorViewMode?.sharedState.currentState()?.mode === 'view';
|
|
552
|
+
/**
|
|
553
|
+
* Table cannot be in focus if we are in view mode.
|
|
554
|
+
* This will prevent an infinite flow of adding and removing
|
|
555
|
+
* resize handle decorations in view mode that causes unpredictable
|
|
556
|
+
* selections.
|
|
557
|
+
*/
|
|
558
|
+
if (isViewMode) {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
|
|
546
562
|
return eventHandler(view, mouseEvent);
|
|
547
563
|
};
|
|
548
564
|
|
|
@@ -109,12 +109,15 @@ interface ComponentProps {
|
|
|
109
109
|
contentDOM: (node: HTMLElement | null) => void;
|
|
110
110
|
containerWidth: EditorContainerWidth;
|
|
111
111
|
allowControls: boolean;
|
|
112
|
+
|
|
113
|
+
allowTableResizing?: boolean;
|
|
114
|
+
allowTableAlignment?: boolean;
|
|
115
|
+
|
|
112
116
|
isHeaderRowEnabled: boolean;
|
|
113
117
|
isHeaderColumnEnabled: boolean;
|
|
114
118
|
isMediaFullscreen?: boolean;
|
|
115
119
|
isDragAndDropEnabled?: boolean;
|
|
116
120
|
isTableScalingEnabled?: boolean;
|
|
117
|
-
isTableAlignmentEnabled?: boolean;
|
|
118
121
|
tableActive: boolean;
|
|
119
122
|
ordering?: TableColumnOrdering;
|
|
120
123
|
isResizing?: boolean;
|
|
@@ -228,8 +231,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
228
231
|
componentDidMount() {
|
|
229
232
|
const {
|
|
230
233
|
allowColumnResizing,
|
|
234
|
+
allowTableResizing,
|
|
231
235
|
eventDispatcher,
|
|
232
|
-
options,
|
|
233
236
|
isDragAndDropEnabled,
|
|
234
237
|
getNode,
|
|
235
238
|
getEditorFeatureFlags,
|
|
@@ -290,7 +293,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
290
293
|
* We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
|
|
291
294
|
* Instead we use the resize event to only trigger updates when necessary.
|
|
292
295
|
*/
|
|
293
|
-
if (!
|
|
296
|
+
if (!allowTableResizing) {
|
|
294
297
|
window.addEventListener('resize', this.handleWindowResizeDebounced);
|
|
295
298
|
}
|
|
296
299
|
this.handleTableResizingDebounced();
|
|
@@ -313,7 +316,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
313
316
|
}
|
|
314
317
|
|
|
315
318
|
componentWillUnmount() {
|
|
316
|
-
const { allowColumnResizing,
|
|
319
|
+
const { allowColumnResizing, allowTableResizing, eventDispatcher, isDragAndDropEnabled } =
|
|
320
|
+
this.props;
|
|
317
321
|
if (this.wrapper && !isIE11) {
|
|
318
322
|
this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
|
|
319
323
|
}
|
|
@@ -333,11 +337,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
333
337
|
this.scaleTableDebounced.cancel();
|
|
334
338
|
this.handleTableResizingDebounced.cancel();
|
|
335
339
|
this.handleAutoSizeDebounced.cancel();
|
|
336
|
-
if (!
|
|
340
|
+
if (!allowTableResizing) {
|
|
337
341
|
this.handleWindowResizeDebounced.cancel();
|
|
338
342
|
}
|
|
339
343
|
|
|
340
|
-
if (!
|
|
344
|
+
if (!allowTableResizing && allowColumnResizing) {
|
|
341
345
|
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
342
346
|
}
|
|
343
347
|
|
|
@@ -530,6 +534,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
530
534
|
getNode,
|
|
531
535
|
isMediaFullscreen,
|
|
532
536
|
allowColumnResizing,
|
|
537
|
+
allowTableResizing,
|
|
533
538
|
isResizing,
|
|
534
539
|
options,
|
|
535
540
|
isTableScalingEnabled, // we could use options.isTableScalingEnabled here
|
|
@@ -578,7 +583,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
578
583
|
|
|
579
584
|
if (
|
|
580
585
|
this.props.options?.isCommentEditor &&
|
|
581
|
-
|
|
586
|
+
allowTableResizing &&
|
|
582
587
|
!options?.isTableScalingEnabled
|
|
583
588
|
) {
|
|
584
589
|
this.removeInlineTableWidth();
|
|
@@ -632,7 +637,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
632
637
|
if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
633
638
|
const { view } = this.props;
|
|
634
639
|
const shouldRecreateResizeCols =
|
|
635
|
-
!
|
|
640
|
+
!allowTableResizing || !isResizing || (isNoOfColumnsChanged && isResizing);
|
|
636
641
|
|
|
637
642
|
if (shouldRecreateResizeCols) {
|
|
638
643
|
const start = getPos() || 0;
|
|
@@ -745,7 +750,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
745
750
|
isDragAndDropEnabled,
|
|
746
751
|
getEditorFeatureFlags,
|
|
747
752
|
isTableScalingEnabled, // here we can use options.isTableScalingEnabled
|
|
748
|
-
|
|
753
|
+
allowTableResizing,
|
|
754
|
+
allowTableAlignment,
|
|
749
755
|
} = this.props;
|
|
750
756
|
|
|
751
757
|
let { isInDanger, hoveredRows, hoveredCell, isTableHovered, isWholeTableInDanger } = this.props;
|
|
@@ -873,12 +879,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
873
879
|
isNested={isNested}
|
|
874
880
|
pluginInjectionApi={pluginInjectionApi}
|
|
875
881
|
tableWrapperHeight={this.state.tableWrapperHeight}
|
|
876
|
-
isTableResizingEnabled={
|
|
882
|
+
isTableResizingEnabled={allowTableResizing}
|
|
877
883
|
isResizing={isResizing}
|
|
878
884
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
879
885
|
isTableWithFixedColumnWidthsOptionEnabled={tableWithFixedColumnWidthsOption}
|
|
880
886
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
881
|
-
isTableAlignmentEnabled={
|
|
887
|
+
isTableAlignmentEnabled={allowTableAlignment}
|
|
882
888
|
shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
|
|
883
889
|
isCommentEditor={options?.isCommentEditor}
|
|
884
890
|
isChromelessEditor={options?.isChromelessEditor}
|
|
@@ -1037,7 +1043,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
1037
1043
|
};
|
|
1038
1044
|
|
|
1039
1045
|
private handleTableResizing = () => {
|
|
1040
|
-
const { getNode, containerWidth, options } = this.props;
|
|
1046
|
+
const { getNode, containerWidth, options, allowTableResizing } = this.props;
|
|
1041
1047
|
const prevNode = this.node!;
|
|
1042
1048
|
const node = getNode();
|
|
1043
1049
|
const prevAttrs = prevNode.attrs;
|
|
@@ -1096,7 +1102,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
1096
1102
|
noOfColumnsChanged
|
|
1097
1103
|
) {
|
|
1098
1104
|
const shouldScaleTable =
|
|
1099
|
-
(!
|
|
1105
|
+
(!allowTableResizing || (allowTableResizing && isNested)) &&
|
|
1100
1106
|
!hasNumberedColumnChanged &&
|
|
1101
1107
|
!noOfColumnsChanged;
|
|
1102
1108
|
|
|
@@ -1111,7 +1117,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
1111
1117
|
}
|
|
1112
1118
|
|
|
1113
1119
|
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
1114
|
-
if (
|
|
1120
|
+
if (allowTableResizing && hasNumberedColumnChanged) {
|
|
1115
1121
|
if (!hasTableBeenResized(prevNode)) {
|
|
1116
1122
|
this.scaleTable(
|
|
1117
1123
|
{
|
|
@@ -1170,7 +1176,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
1170
1176
|
};
|
|
1171
1177
|
|
|
1172
1178
|
private setTimerToSendInitialOverflowCaptured = (isOverflowing: boolean) => {
|
|
1173
|
-
const { dispatchAnalyticsEvent, containerWidth,
|
|
1179
|
+
const { dispatchAnalyticsEvent, containerWidth, allowTableResizing } = this.props;
|
|
1174
1180
|
const parentWidth = this.state?.parentWidth || 0;
|
|
1175
1181
|
|
|
1176
1182
|
this.initialOverflowCaptureTimerId = setTimeout(() => {
|
|
@@ -1182,7 +1188,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
1182
1188
|
attributes: {
|
|
1183
1189
|
editorWidth: containerWidth.width || 0,
|
|
1184
1190
|
isOverflowing,
|
|
1185
|
-
tableResizingEnabled:
|
|
1191
|
+
tableResizingEnabled: allowTableResizing || false,
|
|
1186
1192
|
width: this.node.attrs.width || 0,
|
|
1187
1193
|
parentWidth,
|
|
1188
1194
|
},
|
|
@@ -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;
|