@atlaskit/editor-plugin-table 7.5.3 → 7.5.5
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 +14 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +2 -2
- package/dist/cjs/nodeviews/TableComponent.js +46 -59
- package/dist/cjs/nodeviews/TableContainer.js +5 -5
- package/dist/cjs/nodeviews/TableResizer.js +12 -12
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +58 -56
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +4 -6
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/ColumnResizeWidget/index.js +4 -5
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/cjs/utils/guidelines.js +5 -2
- package/dist/cjs/utils/snapping.js +14 -1
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +25 -36
- package/dist/es2019/nodeviews/TableContainer.js +6 -6
- package/dist/es2019/nodeviews/TableResizer.js +14 -14
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +17 -17
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/es2019/utils/guidelines.js +3 -2
- package/dist/es2019/utils/snapping.js +12 -1
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +2 -2
- package/dist/esm/nodeviews/TableComponent.js +45 -58
- package/dist/esm/nodeviews/TableContainer.js +6 -6
- package/dist/esm/nodeviews/TableResizer.js +14 -14
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +58 -56
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +4 -6
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/drag-menu.js +4 -4
- package/dist/esm/utils/guidelines.js +5 -2
- package/dist/esm/utils/snapping.js +14 -1
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +2 -3
- package/dist/types/nodeviews/TableContainer.d.ts +4 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types/utils/create.d.ts +1 -2
- package/dist/types/utils/drag-menu.d.ts +2 -2
- package/dist/types/utils/guidelines.d.ts +1 -0
- package/dist/types/utils/snapping.d.ts +2 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +7 -7
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +2 -2
- package/dist/types-ts4.5/utils/guidelines.d.ts +1 -0
- package/dist/types-ts4.5/utils/snapping.d.ts +2 -0
- package/package.json +2 -2
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +2 -2
- package/src/nodeviews/TableComponent.tsx +31 -46
- package/src/nodeviews/TableContainer.tsx +16 -7
- package/src/nodeviews/TableResizer.tsx +44 -24
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +12 -28
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +3 -3
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -0
- package/src/ui/ColumnResizeWidget/index.tsx +2 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
- package/src/utils/create.ts +2 -5
- package/src/utils/drag-menu.ts +8 -13
- package/src/utils/guidelines.ts +12 -1
- package/src/utils/snapping.ts +36 -0
|
@@ -16,8 +16,8 @@ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTa
|
|
|
16
16
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
17
17
|
import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
18
18
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
19
|
-
import { defaultGuidelines } from '../utils/guidelines';
|
|
20
|
-
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
19
|
+
import { defaultGuidelines, defaultGuidelinesForPreserveTable } from '../utils/guidelines';
|
|
20
|
+
import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
21
21
|
const DEBOUNCE_TIME_FOR_SCREEN_READER_ANNOUNCER = 1000;
|
|
22
22
|
const RESIZE_STEP_VALUE = 10;
|
|
23
23
|
const handles = {
|
|
@@ -83,7 +83,7 @@ export const TableResizer = ({
|
|
|
83
83
|
displayGuideline,
|
|
84
84
|
attachAnalyticsEvent,
|
|
85
85
|
displayGapCursor,
|
|
86
|
-
|
|
86
|
+
isTableScalingEnabled
|
|
87
87
|
}) => {
|
|
88
88
|
var _findTable, _editorView$state;
|
|
89
89
|
const currentGap = useRef(0);
|
|
@@ -130,13 +130,13 @@ export const TableResizer = ({
|
|
|
130
130
|
}) => {
|
|
131
131
|
if (gap !== currentGap.current) {
|
|
132
132
|
currentGap.current = gap;
|
|
133
|
-
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
133
|
+
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
134
134
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
135
135
|
}
|
|
136
|
-
}, [
|
|
136
|
+
}, [isTableScalingEnabled, containerWidth, displayGuideline]);
|
|
137
137
|
const guidelineSnaps = useMemo(() => snappingEnabled ? {
|
|
138
|
-
x: defaultSnappingWidths
|
|
139
|
-
} : undefined, [snappingEnabled]);
|
|
138
|
+
x: isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
|
|
139
|
+
} : undefined, [snappingEnabled, isTableScalingEnabled, containerWidth]);
|
|
140
140
|
useEffect(() => {
|
|
141
141
|
return () => {
|
|
142
142
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -174,12 +174,12 @@ export const TableResizer = ({
|
|
|
174
174
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
175
175
|
});
|
|
176
176
|
dispatch(tr);
|
|
177
|
-
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
177
|
+
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
178
178
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
179
179
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
180
180
|
onResizeStart();
|
|
181
181
|
}
|
|
182
|
-
}, [displayGapCursor,
|
|
182
|
+
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
183
183
|
const handleResize = useCallback((originalState, delta) => {
|
|
184
184
|
countFrames();
|
|
185
185
|
const newWidth = originalState.width + delta.width;
|
|
@@ -197,11 +197,11 @@ export const TableResizer = ({
|
|
|
197
197
|
prevNode: node,
|
|
198
198
|
start: pos + 1,
|
|
199
199
|
parentWidth: newWidth
|
|
200
|
-
}, editorView.domAtPos.bind(editorView),
|
|
201
|
-
updateActiveGuidelines(findClosestSnap(newWidth, defaultSnappingWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
200
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
201
|
+
updateActiveGuidelines(findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
202
202
|
updateWidth(newWidth);
|
|
203
203
|
return newWidth;
|
|
204
|
-
}, [
|
|
204
|
+
}, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
205
205
|
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
206
206
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
207
207
|
isResizing.current = false;
|
|
@@ -238,7 +238,7 @@ export const TableResizer = ({
|
|
|
238
238
|
prevNode: node,
|
|
239
239
|
start: pos + 1,
|
|
240
240
|
parentWidth: newWidth
|
|
241
|
-
}, editorView.domAtPos.bind(editorView),
|
|
241
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled)(tr);
|
|
242
242
|
const scaledNode = tr.doc.nodeAt(pos);
|
|
243
243
|
(_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
|
|
244
244
|
originalNode: node,
|
|
@@ -256,7 +256,7 @@ export const TableResizer = ({
|
|
|
256
256
|
onResizeStop();
|
|
257
257
|
}
|
|
258
258
|
return newWidth;
|
|
259
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop,
|
|
259
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
|
|
260
260
|
const handleTableSizeChangeOnKeypress = useCallback(step => {
|
|
261
261
|
const newWidth = width + step;
|
|
262
262
|
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|
|
@@ -57,17 +57,15 @@ export default class TableView extends ReactNodeView {
|
|
|
57
57
|
_defineProperty(this, "hasHoveredRows", false);
|
|
58
58
|
this.getPos = props.getPos;
|
|
59
59
|
this.eventDispatcher = props.eventDispatcher;
|
|
60
|
-
this.
|
|
60
|
+
this.options = props.options;
|
|
61
61
|
}
|
|
62
62
|
getContentDOM() {
|
|
63
63
|
const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
64
64
|
if (rendered.dom) {
|
|
65
|
+
var _this$options;
|
|
65
66
|
this.table = rendered.dom;
|
|
66
|
-
const {
|
|
67
|
-
tablePreserveWidth = false
|
|
68
|
-
} = this.getEditorFeatureFlags();
|
|
69
67
|
// Preserve Table Width cannot have inline width set on the table
|
|
70
|
-
if (!
|
|
68
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled)) {
|
|
71
69
|
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
72
70
|
if (tableInlineWidth) {
|
|
73
71
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
@@ -157,6 +155,7 @@ export default class TableView extends ReactNodeView {
|
|
|
157
155
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
158
156
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
159
157
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
158
|
+
isTableScalingEnabled: pluginState.isTableScalingEnabled,
|
|
160
159
|
tableActive: tableActive,
|
|
161
160
|
ordering: pluginState.ordering,
|
|
162
161
|
isResizing: isResizing,
|
|
@@ -165,8 +164,7 @@ export default class TableView extends ReactNodeView {
|
|
|
165
164
|
contentDOM: forwardRef,
|
|
166
165
|
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
167
166
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
168
|
-
pluginInjectionApi: props.pluginInjectionApi
|
|
169
|
-
tableRef: this.table
|
|
167
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
170
168
|
});
|
|
171
169
|
}
|
|
172
170
|
});
|
|
@@ -234,7 +232,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
234
232
|
isFullWidthModeEnabled,
|
|
235
233
|
wasFullWidthModeEnabled,
|
|
236
234
|
isTableResizingEnabled,
|
|
237
|
-
isDragAndDropEnabled
|
|
235
|
+
isDragAndDropEnabled,
|
|
236
|
+
isTableScalingEnabled
|
|
238
237
|
} = getPluginState(view.state);
|
|
239
238
|
const {
|
|
240
239
|
allowColumnResizing
|
|
@@ -252,7 +251,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
252
251
|
isFullWidthModeEnabled,
|
|
253
252
|
wasFullWidthModeEnabled,
|
|
254
253
|
isTableResizingEnabled,
|
|
255
|
-
isDragAndDropEnabled
|
|
254
|
+
isDragAndDropEnabled,
|
|
255
|
+
isTableScalingEnabled
|
|
256
256
|
},
|
|
257
257
|
getEditorContainerWidth,
|
|
258
258
|
getEditorFeatureFlags,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -18,6 +18,7 @@ import { createPlugin as createDecorationsPlugin } from './pm-plugins/decoration
|
|
|
18
18
|
import { createPlugin as createDragAndDropPlugin, pluginKey as dragAndDropPluginKey } from './pm-plugins/drag-and-drop';
|
|
19
19
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
20
20
|
import { createPlugin } from './pm-plugins/main';
|
|
21
|
+
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
21
22
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
22
23
|
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
23
24
|
import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers';
|
|
@@ -68,7 +69,7 @@ const tablesPlugin = ({
|
|
|
68
69
|
actions: {
|
|
69
70
|
insertTable: analyticsPayload => (state, dispatch) => {
|
|
70
71
|
var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
|
|
71
|
-
const node = createTableWithWidth(options === null || options === void 0 ? void 0 : options.
|
|
72
|
+
const node = createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.fullWidthEnabled)(state.schema);
|
|
72
73
|
return (_api$contentInsertion = api === null || api === void 0 ? void 0 : (_api$contentInsertion2 = api.contentInsertion) === null || _api$contentInsertion2 === void 0 ? void 0 : (_api$contentInsertion3 = _api$contentInsertion2.actions) === null || _api$contentInsertion3 === void 0 ? void 0 : _api$contentInsertion3.insert({
|
|
73
74
|
state,
|
|
74
75
|
dispatch,
|
|
@@ -81,7 +82,7 @@ const tablesPlugin = ({
|
|
|
81
82
|
}
|
|
82
83
|
},
|
|
83
84
|
commands: {
|
|
84
|
-
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.
|
|
85
|
+
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
85
86
|
},
|
|
86
87
|
nodes() {
|
|
87
88
|
const tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
|
|
@@ -116,9 +117,10 @@ const tablesPlugin = ({
|
|
|
116
117
|
breakoutEnabled,
|
|
117
118
|
tableOptions,
|
|
118
119
|
getEditorFeatureFlags,
|
|
119
|
-
dragAndDropEnabled
|
|
120
|
+
dragAndDropEnabled,
|
|
121
|
+
isTableScalingEnabled
|
|
120
122
|
} = options || {};
|
|
121
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
|
|
123
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled);
|
|
122
124
|
}
|
|
123
125
|
}, {
|
|
124
126
|
name: 'tablePMColResizing',
|
|
@@ -148,9 +150,9 @@ const tablesPlugin = ({
|
|
|
148
150
|
plugin: () => {
|
|
149
151
|
const {
|
|
150
152
|
dragAndDropEnabled,
|
|
151
|
-
|
|
153
|
+
isTableScalingEnabled = false
|
|
152
154
|
} = options || {};
|
|
153
|
-
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI,
|
|
155
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled);
|
|
154
156
|
}
|
|
155
157
|
}, {
|
|
156
158
|
name: 'tableSelectionKeymap',
|
|
@@ -184,16 +186,13 @@ const tablesPlugin = ({
|
|
|
184
186
|
plugin: ({
|
|
185
187
|
dispatch,
|
|
186
188
|
eventDispatcher
|
|
187
|
-
}) => options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch,
|
|
189
|
+
}) => options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, () => []) : undefined
|
|
188
190
|
}, {
|
|
189
191
|
name: 'tableDragAndDrop',
|
|
190
192
|
plugin: ({
|
|
191
193
|
dispatch
|
|
192
194
|
}) => {
|
|
193
|
-
|
|
194
|
-
getEditorFeatureFlags
|
|
195
|
-
} = options || {};
|
|
196
|
-
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) : undefined;
|
|
195
|
+
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, editorAnalyticsAPI) : undefined;
|
|
197
196
|
}
|
|
198
197
|
}, {
|
|
199
198
|
name: 'tableLocalId',
|
|
@@ -207,7 +206,7 @@ const tablesPlugin = ({
|
|
|
207
206
|
dispatch
|
|
208
207
|
}) => {
|
|
209
208
|
var _options$fullWidthEna;
|
|
210
|
-
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false
|
|
209
|
+
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
211
210
|
}
|
|
212
211
|
},
|
|
213
212
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -344,8 +343,7 @@ const tablesPlugin = ({
|
|
|
344
343
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
345
344
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
346
345
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
347
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
348
|
-
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
346
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
349
347
|
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
350
348
|
editorView: editorView,
|
|
351
349
|
mountPoint: popupsMountPoint,
|
|
@@ -369,8 +367,7 @@ const tablesPlugin = ({
|
|
|
369
367
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
370
368
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
371
369
|
stickyHeaders: stickyHeader,
|
|
372
|
-
pluginConfig: pluginConfig
|
|
373
|
-
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
370
|
+
pluginConfig: pluginConfig
|
|
374
371
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
375
372
|
editorView: editorView,
|
|
376
373
|
selection: editorView.state.selection,
|
|
@@ -400,7 +397,10 @@ const tablesPlugin = ({
|
|
|
400
397
|
var _api$table;
|
|
401
398
|
// see comment on tablesPlugin.getSharedState on usage
|
|
402
399
|
const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
403
|
-
const
|
|
400
|
+
const {
|
|
401
|
+
isTableScalingEnabled = false
|
|
402
|
+
} = getPluginState(state);
|
|
403
|
+
const tr = insert(createTableWithWidth(isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
|
|
404
404
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
405
405
|
action: ACTION.INSERTED,
|
|
406
406
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -17,7 +17,7 @@ import { DropTargetType } from './consts';
|
|
|
17
17
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
18
18
|
import { pluginKey } from './plugin-key';
|
|
19
19
|
import { getDraggableDataFromEvent } from './utils/monitor';
|
|
20
|
-
const destroyFn = (editorView, editorAnalyticsAPI
|
|
20
|
+
const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
21
21
|
const editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
22
22
|
const rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
|
|
23
23
|
canMonitor({
|
|
@@ -162,9 +162,9 @@ const destroyFn = (editorView, editorAnalyticsAPI, getEditorFeatureFlags) => {
|
|
|
162
162
|
} = getTablePluginState(editorView.state);
|
|
163
163
|
if (tableRef && tableNode) {
|
|
164
164
|
const {
|
|
165
|
-
|
|
166
|
-
} = (
|
|
167
|
-
insertColgroupFromNode(tableRef, tableNode,
|
|
165
|
+
isTableScalingEnabled = false
|
|
166
|
+
} = getTablePluginState(editorView.state);
|
|
167
|
+
insertColgroupFromNode(tableRef, tableNode, isTableScalingEnabled);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
editorView.focus();
|
|
@@ -172,7 +172,7 @@ const destroyFn = (editorView, editorAnalyticsAPI, getEditorFeatureFlags) => {
|
|
|
172
172
|
}
|
|
173
173
|
}));
|
|
174
174
|
};
|
|
175
|
-
export const createPlugin = (dispatch,
|
|
175
|
+
export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
176
176
|
return new SafePlugin({
|
|
177
177
|
state: createPluginState(dispatch, state => ({
|
|
178
178
|
decorationSet: DecorationSet.empty,
|
|
@@ -241,7 +241,7 @@ export const createPlugin = (dispatch, getEditorFeatureFlags, editorAnalyticsAPI
|
|
|
241
241
|
},
|
|
242
242
|
view: editorView => {
|
|
243
243
|
return {
|
|
244
|
-
destroy: destroyFn(editorView, editorAnalyticsAPI
|
|
244
|
+
destroy: destroyFn(editorView, editorAnalyticsAPI)
|
|
245
245
|
};
|
|
246
246
|
},
|
|
247
247
|
props: {
|
|
@@ -18,7 +18,7 @@ const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
|
|
|
18
18
|
},
|
|
19
19
|
eventType: EVENT_TYPE.TRACK
|
|
20
20
|
})(editorAnalyticsAPI)(createTable());
|
|
21
|
-
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI,
|
|
21
|
+
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false) {
|
|
22
22
|
const list = {};
|
|
23
23
|
bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
|
|
24
24
|
bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
|
|
@@ -29,8 +29,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEdi
|
|
|
29
29
|
// Add row/column shortcuts
|
|
30
30
|
bindKeymapWithCommand(addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
31
31
|
bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
32
|
-
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(
|
|
33
|
-
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(
|
|
32
|
+
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled), list);
|
|
33
|
+
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled), list);
|
|
34
34
|
if (dragAndDropEnabled) {
|
|
35
35
|
// Move row/column shortcuts
|
|
36
36
|
/**
|
|
@@ -50,14 +50,11 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEdi
|
|
|
50
50
|
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
|
|
51
51
|
}
|
|
52
52
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
53
|
-
const {
|
|
54
|
-
tablePreserveWidth = false
|
|
55
|
-
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
56
53
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
|
|
57
54
|
bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
|
|
58
55
|
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
|
|
59
|
-
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth,
|
|
60
|
-
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth,
|
|
56
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, INPUT_METHOD.SHORTCUT), list);
|
|
57
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, INPUT_METHOD.SHORTCUT), list);
|
|
61
58
|
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing(), list);
|
|
62
59
|
}
|
|
63
60
|
return keymap(list);
|
|
@@ -22,7 +22,7 @@ import { isHeaderRowRequired } from '../utils/paste';
|
|
|
22
22
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
23
23
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
24
24
|
import { pluginKey } from './plugin-key';
|
|
25
|
-
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
|
|
25
|
+
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled) => {
|
|
26
26
|
var _window;
|
|
27
27
|
const state = createPluginState(dispatch, {
|
|
28
28
|
pluginConfig,
|
|
@@ -36,6 +36,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
36
36
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
37
37
|
isHeaderColumnEnabled: false,
|
|
38
38
|
isDragAndDropEnabled: dragAndDropEnabled,
|
|
39
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
39
40
|
...defaultHoveredCell,
|
|
40
41
|
...defaultTableSelection,
|
|
41
42
|
getIntl
|
|
@@ -82,12 +83,9 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
82
83
|
}
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
|
-
const {
|
|
86
|
-
tablePreserveWidth = false
|
|
87
|
-
} = getEditorFeatureFlags();
|
|
88
86
|
if (tr) {
|
|
89
87
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
90
|
-
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined,
|
|
88
|
+
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, isTableScalingEnabled);
|
|
91
89
|
return fixTables(updatedTr) || updatedTr;
|
|
92
90
|
}
|
|
93
91
|
if (transactions.find(tr => tr.docChanged)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { pluginKey } from './plugin-key';
|
|
3
3
|
import { createPluginState } from './plugin-state';
|
|
4
|
-
export const createPlugin = (dispatch,
|
|
4
|
+
export const createPlugin = (dispatch, initialState = () => []) => {
|
|
5
5
|
return new SafePlugin({
|
|
6
6
|
state: createPluginState(dispatch, initialState),
|
|
7
7
|
key: pluginKey
|
|
@@ -22,8 +22,8 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
22
22
|
const editorDisabled = !view.editable;
|
|
23
23
|
const domAtPos = view.domAtPos.bind(view);
|
|
24
24
|
const {
|
|
25
|
-
|
|
26
|
-
} =
|
|
25
|
+
isTableScalingEnabled = false
|
|
26
|
+
} = getTablePluginState(state);
|
|
27
27
|
if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
@@ -71,7 +71,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
71
71
|
tableRef: dom,
|
|
72
72
|
start,
|
|
73
73
|
domAtPos,
|
|
74
|
-
|
|
74
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
75
75
|
});
|
|
76
76
|
if (evenColumns({
|
|
77
77
|
resizeState,
|
|
@@ -153,7 +153,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
153
153
|
const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
154
154
|
// only selected (or selected - 1) columns should be distributed
|
|
155
155
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
156
|
-
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined,
|
|
156
|
+
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled);
|
|
157
157
|
const resizedDelta = clientX - startX;
|
|
158
158
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
159
159
|
if (colIndex === map.width - 1) {
|
|
@@ -222,7 +222,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
222
222
|
const table = $cell.node(-1);
|
|
223
223
|
const map = TableMap.get(table);
|
|
224
224
|
const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
225
|
-
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, undefined,
|
|
225
|
+
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, isTableScalingEnabled);
|
|
226
226
|
updateControls()(state);
|
|
227
227
|
}
|
|
228
228
|
window.addEventListener('mouseup', finish);
|
|
@@ -75,12 +75,12 @@ export const generateColgroup = (table, tableRef) => {
|
|
|
75
75
|
}
|
|
76
76
|
return cols;
|
|
77
77
|
};
|
|
78
|
-
export const insertColgroupFromNode = (tableRef, table,
|
|
78
|
+
export const insertColgroupFromNode = (tableRef, table, isTableScalingEnabled = false, shouldRemove = true) => {
|
|
79
79
|
let colgroup = tableRef.querySelector('colgroup');
|
|
80
80
|
if (colgroup && shouldRemove) {
|
|
81
81
|
tableRef.removeChild(colgroup);
|
|
82
82
|
}
|
|
83
|
-
colgroup = renderColgroupFromNode(table,
|
|
83
|
+
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef : undefined);
|
|
84
84
|
if (shouldRemove) {
|
|
85
85
|
tableRef.insertBefore(colgroup, tableRef.firstChild);
|
|
86
86
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const COLUMN_MIN_WIDTH = 48;
|
|
2
2
|
export const TABLE_DEFAULT_WIDTH = 760;
|
|
3
3
|
export const TABLE_MAX_WIDTH = 1800;
|
|
4
|
-
export const MAX_SCALING_PERCENT = 0.3;
|
|
4
|
+
export const MAX_SCALING_PERCENT = 0.3;
|
|
5
|
+
// Used to calculate the width of a table using the Editor width
|
|
6
|
+
export const TABLE_EDITOR_MARGIN = 76;
|
|
@@ -3,7 +3,7 @@ export { contentWidth } from './content-width';
|
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding } from './column-state';
|
|
4
4
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
5
5
|
export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bulkColumnsResize, areColumnsEven, adjustColumnsWidths } from './resize-state';
|
|
6
|
-
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth,
|
|
6
|
+
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth, getTableContainerElementWidth } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
9
|
export { resizeColumn } from './resize-column';
|
|
@@ -85,8 +85,8 @@ export const getTableElementWidth = table => {
|
|
|
85
85
|
// TODO: is there a scenario where ADF columns are SMALLER than container width?
|
|
86
86
|
return calcTableColumnWidths(table).reduce((sum, width) => sum + width, 0);
|
|
87
87
|
}
|
|
88
|
-
return
|
|
88
|
+
return getTableContainerElementWidth(table);
|
|
89
89
|
};
|
|
90
|
-
export const
|
|
90
|
+
export const getTableContainerElementWidth = table => {
|
|
91
91
|
return getTableContainerWidth(table);
|
|
92
92
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Resize a given column by an amount from the current state
|
|
2
|
+
|
|
2
3
|
import { growColumn, shrinkColumn } from './resize-logic';
|
|
3
4
|
import { updateColgroup } from './resize-state';
|
|
4
|
-
export const resizeColumn = (resizeState, colIndex, amount, tableRef, selectedColumns,
|
|
5
|
+
export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false) => {
|
|
5
6
|
const newState = amount > 0 ? growColumn(resizeState, colIndex, amount, selectedColumns) : amount < 0 ? shrinkColumn(resizeState, colIndex, amount, selectedColumns) : resizeState;
|
|
6
|
-
updateColgroup(newState, tableRef,
|
|
7
|
+
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
7
8
|
return newState;
|
|
8
9
|
};
|
|
@@ -5,8 +5,8 @@ import { getSelectedTableInfo } from '../../../utils';
|
|
|
5
5
|
import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
6
6
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
7
7
|
import { syncStickyRowToTable } from './dom';
|
|
8
|
-
import { getTableMaxWidth } from './misc';
|
|
9
|
-
import { MAX_SCALING_PERCENT, TABLE_DEFAULT_WIDTH } from './index';
|
|
8
|
+
import { getTableContainerElementWidth, getTableMaxWidth } from './misc';
|
|
9
|
+
import { COLUMN_MIN_WIDTH, MAX_SCALING_PERCENT, TABLE_DEFAULT_WIDTH } from './index';
|
|
10
10
|
export const getResizeState = ({
|
|
11
11
|
minWidth,
|
|
12
12
|
maxSize,
|
|
@@ -14,7 +14,7 @@ export const getResizeState = ({
|
|
|
14
14
|
tableRef,
|
|
15
15
|
start,
|
|
16
16
|
domAtPos,
|
|
17
|
-
|
|
17
|
+
isTableScalingEnabled = false
|
|
18
18
|
}) => {
|
|
19
19
|
// If the table has been resized, we can use the column widths from the table node
|
|
20
20
|
if (hasTableBeenResized(table)) {
|
|
@@ -34,19 +34,19 @@ export const getResizeState = ({
|
|
|
34
34
|
overflow
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
const shouldReinsertColgroup = !
|
|
37
|
+
const shouldReinsertColgroup = !isTableScalingEnabled;
|
|
38
38
|
|
|
39
39
|
// Getting the resize state from DOM
|
|
40
|
-
const colgroupChildren = insertColgroupFromNode(tableRef, table,
|
|
40
|
+
const colgroupChildren = insertColgroupFromNode(tableRef, table, isTableScalingEnabled, shouldReinsertColgroup // don't reinsert colgroup when preserving table width - this causes widths to jump
|
|
41
41
|
);
|
|
42
42
|
const cols = Array.from(colgroupChildren).map((_, index) => {
|
|
43
43
|
// If the table hasn't been resized and we have a table width attribute, we can use it
|
|
44
44
|
// to calculate the widths of the columns
|
|
45
|
-
if (
|
|
45
|
+
if (isTableScalingEnabled && table.attrs.width) {
|
|
46
46
|
return {
|
|
47
47
|
index,
|
|
48
48
|
width: table.attrs.width / colgroupChildren.length,
|
|
49
|
-
minWidth:
|
|
49
|
+
minWidth: COLUMN_MIN_WIDTH
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
const cellsRefs = getCellsRefsInColumn(index, table, start, domAtPos);
|
|
@@ -65,13 +65,12 @@ export const getResizeState = ({
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// updates Colgroup DOM node with new widths
|
|
68
|
-
export const updateColgroup = (state, tableRef,
|
|
68
|
+
export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled) => {
|
|
69
69
|
const cols = tableRef.querySelectorAll('col');
|
|
70
70
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
71
71
|
const columnsCount = cols.length;
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
const tableWidth = parseInt(((_tableRef$dataset = tableRef.dataset) === null || _tableRef$dataset === void 0 ? void 0 : _tableRef$dataset.tableWidth) || ''); // TODO - get this value from the table node, not the dom
|
|
72
|
+
if (isTableScalingEnabled && tableNode) {
|
|
73
|
+
const tableWidth = getTableContainerElementWidth(tableNode);
|
|
75
74
|
if (tableWidth) {
|
|
76
75
|
var _tableRef$parentEleme;
|
|
77
76
|
let renderWidth = ((_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || TABLE_DEFAULT_WIDTH;
|
|
@@ -275,7 +274,7 @@ export const normaliseTableLayout = input => {
|
|
|
275
274
|
return 'default';
|
|
276
275
|
}
|
|
277
276
|
};
|
|
278
|
-
export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getEditorContainerWidth,
|
|
277
|
+
export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getEditorContainerWidth, isTableScalingEnabled = false) => {
|
|
279
278
|
// Fail early so that we don't do complex calculations for no reason
|
|
280
279
|
const numColumnsSelected = rect.right - rect.left;
|
|
281
280
|
if (numColumnsSelected <= 1) {
|
|
@@ -314,7 +313,7 @@ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getE
|
|
|
314
313
|
tableRef,
|
|
315
314
|
start: table.start,
|
|
316
315
|
domAtPos,
|
|
317
|
-
|
|
316
|
+
isTableScalingEnabled
|
|
318
317
|
});
|
|
319
318
|
const newResizeState = evenSelectedColumnsWidths(resizeState, rect);
|
|
320
319
|
const widthsBefore = resizeState.widths;
|
|
@@ -10,7 +10,7 @@ import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
|
10
10
|
import { syncStickyRowToTable } from './dom';
|
|
11
11
|
// Base function to trigger the actual scale on a table node.
|
|
12
12
|
// Will only resize/scale if a table has been previously resized.
|
|
13
|
-
export const scale = (tableRef, options, domAtPos,
|
|
13
|
+
export const scale = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
|
|
14
14
|
/**
|
|
15
15
|
* isBreakoutEnabled === true -> default center aligned
|
|
16
16
|
* isBreakoutEnabled === false -> full width mode
|
|
@@ -58,11 +58,11 @@ export const scale = (tableRef, options, domAtPos, tablePreserveWidth = false) =
|
|
|
58
58
|
tableRef,
|
|
59
59
|
start,
|
|
60
60
|
domAtPos,
|
|
61
|
-
|
|
61
|
+
isTableScalingEnabled
|
|
62
62
|
});
|
|
63
63
|
return scaleTableTo(resizeState, newWidth);
|
|
64
64
|
};
|
|
65
|
-
export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos,
|
|
65
|
+
export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, isTableScalingEnabled = false) => {
|
|
66
66
|
const resizeState = getResizeState({
|
|
67
67
|
minWidth: tableCellMinWidth,
|
|
68
68
|
maxSize: parentWidth,
|
|
@@ -70,7 +70,7 @@ export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, t
|
|
|
70
70
|
tableRef,
|
|
71
71
|
start,
|
|
72
72
|
domAtPos,
|
|
73
|
-
|
|
73
|
+
isTableScalingEnabled
|
|
74
74
|
});
|
|
75
75
|
if (table.attrs.isNumberColumnEnabled) {
|
|
76
76
|
parentWidth -= akEditorTableNumberColumnWidth;
|
|
@@ -105,7 +105,7 @@ export function scaleTableTo(state, maxSize) {
|
|
|
105
105
|
}
|
|
106
106
|
return adjustColumnsWidths(newState, maxSize);
|
|
107
107
|
}
|
|
108
|
-
export const previewScaleTable = (tableRef, options, domAtPos,
|
|
108
|
+
export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
|
|
109
109
|
const {
|
|
110
110
|
node,
|
|
111
111
|
start,
|
|
@@ -121,19 +121,19 @@ export const previewScaleTable = (tableRef, options, domAtPos, tablePreserveWidt
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
|
|
124
|
-
// If we are scaling the table down with
|
|
125
|
-
if (!hasTableBeenResized(node) && !
|
|
124
|
+
// If we are scaling the table down with isTableScalingEnabled, the colgroup widths may be scaled to a value that is not 48px.
|
|
125
|
+
if (!hasTableBeenResized(node) && !isTableScalingEnabled) {
|
|
126
126
|
syncStickyRowToTable(tableRef);
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos,
|
|
129
|
+
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabled) : scale(tableRef, options, domAtPos, isTableScalingEnabled);
|
|
130
130
|
if (resizeState) {
|
|
131
|
-
updateColgroup(resizeState, tableRef,
|
|
131
|
+
updateColgroup(resizeState, tableRef, node, isTableScalingEnabled);
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
136
|
-
export const scaleTable = (tableRef, options, domAtPos,
|
|
136
|
+
export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false) => tr => {
|
|
137
137
|
if (!tableRef) {
|
|
138
138
|
return tr;
|
|
139
139
|
}
|
|
@@ -147,7 +147,7 @@ export const scaleTable = (tableRef, options, domAtPos, tablePreserveWidth = fal
|
|
|
147
147
|
if (hasTableBeenResized(node) === false) {
|
|
148
148
|
// If its not a re-sized table, we still want to re-create cols
|
|
149
149
|
// To force reflow of columns upon delete.
|
|
150
|
-
if (!
|
|
150
|
+
if (!isTableScalingEnabled) {
|
|
151
151
|
insertColgroupFromNode(tableRef, node);
|
|
152
152
|
}
|
|
153
153
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -155,9 +155,9 @@ export const scaleTable = (tableRef, options, domAtPos, tablePreserveWidth = fal
|
|
|
155
155
|
}
|
|
156
156
|
let resizeState;
|
|
157
157
|
if (parentWidth) {
|
|
158
|
-
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos,
|
|
158
|
+
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabled);
|
|
159
159
|
} else {
|
|
160
|
-
resizeState = scale(tableRef, options, domAtPos,
|
|
160
|
+
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabled);
|
|
161
161
|
}
|
|
162
162
|
if (resizeState) {
|
|
163
163
|
tr = updateColumnWidths(resizeState, node, start)(tr);
|