@atlaskit/editor-plugin-table 2.10.8 → 2.11.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 +11 -0
- package/dist/cjs/plugins/table/commands/misc.js +58 -5
- package/dist/cjs/plugins/table/event-handlers.js +3 -6
- package/dist/cjs/plugins/table/index.js +3 -2
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +13 -19
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +18 -5
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +6 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +7 -3
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
- package/dist/cjs/plugins/table/reducer.js +26 -2
- package/dist/cjs/plugins/table/types.js +1 -0
- package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +44 -0
- package/dist/cjs/plugins/table/ui/messages.js +5 -0
- package/dist/cjs/plugins/table/utils/decoration.js +17 -4
- package/dist/es2019/plugins/table/commands/misc.js +49 -5
- package/dist/es2019/plugins/table/event-handlers.js +3 -6
- package/dist/es2019/plugins/table/index.js +3 -2
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +14 -17
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +12 -2
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/index.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -3
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
- package/dist/es2019/plugins/table/reducer.js +29 -2
- package/dist/es2019/plugins/table/types.js +1 -0
- package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +35 -0
- package/dist/es2019/plugins/table/ui/messages.js +5 -0
- package/dist/es2019/plugins/table/utils/decoration.js +16 -5
- package/dist/esm/plugins/table/commands/misc.js +56 -5
- package/dist/esm/plugins/table/event-handlers.js +3 -6
- package/dist/esm/plugins/table/index.js +3 -2
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +13 -19
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +15 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/index.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/main.js +8 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
- package/dist/esm/plugins/table/reducer.js +26 -2
- package/dist/esm/plugins/table/types.js +1 -0
- package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +35 -0
- package/dist/esm/plugins/table/ui/messages.js +5 -0
- package/dist/esm/plugins/table/utils/decoration.js +17 -4
- package/dist/types/plugins/table/commands/misc.d.ts +8 -6
- package/dist/types/plugins/table/event-handlers.d.ts +3 -3
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/index.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types/plugins/table/reducer.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +18 -0
- package/dist/types/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
- package/dist/types/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +8 -6
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/reducer.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -1
- package/package.json +2 -2
- package/src/__tests__/unit/event-handlers.ts +1 -1
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +17 -8
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
- package/src/plugins/table/commands/misc.ts +84 -7
- package/src/plugins/table/event-handlers.ts +11 -16
- package/src/plugins/table/index.tsx +2 -0
- package/src/plugins/table/nodeviews/TableResizer.tsx +12 -20
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +34 -7
- package/src/plugins/table/pm-plugins/decorations/utils/index.ts +4 -1
- package/src/plugins/table/pm-plugins/main.ts +7 -1
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin.ts +3 -5
- package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +5 -3
- package/src/plugins/table/reducer.ts +51 -3
- package/src/plugins/table/types.ts +19 -0
- package/src/plugins/table/ui/ColumnResizeWidget/index.tsx +53 -0
- package/src/plugins/table/ui/messages.ts +5 -0
- package/src/plugins/table/utils/decoration.ts +27 -5
|
@@ -87,7 +87,8 @@ const tablesPlugin = ({
|
|
|
87
87
|
dispatchAnalyticsEvent,
|
|
88
88
|
dispatch,
|
|
89
89
|
portalProviderAPI,
|
|
90
|
-
eventDispatcher
|
|
90
|
+
eventDispatcher,
|
|
91
|
+
getIntl
|
|
91
92
|
}) => {
|
|
92
93
|
const {
|
|
93
94
|
fullWidthEnabled,
|
|
@@ -97,7 +98,7 @@ const tablesPlugin = ({
|
|
|
97
98
|
tableOptions,
|
|
98
99
|
getEditorFeatureFlags
|
|
99
100
|
} = options || {};
|
|
100
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
101
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
101
102
|
}
|
|
102
103
|
}, {
|
|
103
104
|
name: 'tablePMColResizing',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import rafSchd from 'raf-schd';
|
|
3
|
+
import { defineMessages, useIntl } from 'react-intl-next';
|
|
3
4
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
4
5
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
5
|
-
import { resizerHandleShadowClassName } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
8
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
@@ -11,6 +11,13 @@ import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '
|
|
|
11
11
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
12
12
|
import { defaultGuidelines } from '../utils/guidelines';
|
|
13
13
|
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
14
|
+
const messages = defineMessages({
|
|
15
|
+
resizeTable: {
|
|
16
|
+
id: 'fabric.editor.tables.resizeTable',
|
|
17
|
+
defaultMessage: 'Resize table',
|
|
18
|
+
description: 'Tooltip displayed on custom table width resize hande'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
14
21
|
const handles = {
|
|
15
22
|
right: true
|
|
16
23
|
};
|
|
@@ -73,6 +80,9 @@ export const TableResizer = ({
|
|
|
73
80
|
var _findTable, _editorView$state;
|
|
74
81
|
const currentGap = useRef(0);
|
|
75
82
|
const [snappingEnabled, setSnappingEnabled] = useState(false);
|
|
83
|
+
const {
|
|
84
|
+
formatMessage
|
|
85
|
+
} = useIntl();
|
|
76
86
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
77
87
|
const handleHeightSize = getResizerHandleHeight(tableRef);
|
|
78
88
|
const {
|
|
@@ -177,20 +187,6 @@ export const TableResizer = ({
|
|
|
177
187
|
scheduleResize.cancel();
|
|
178
188
|
return newWidth;
|
|
179
189
|
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
180
|
-
const handleComponent = useMemo(() => ({
|
|
181
|
-
left: /*#__PURE__*/React.createElement("div", {
|
|
182
|
-
className: resizerHandleShadowClassName,
|
|
183
|
-
style: {
|
|
184
|
-
height: 'calc(100% - 24px)'
|
|
185
|
-
}
|
|
186
|
-
}),
|
|
187
|
-
right: /*#__PURE__*/React.createElement("div", {
|
|
188
|
-
className: resizerHandleShadowClassName,
|
|
189
|
-
style: {
|
|
190
|
-
height: 'calc(100% - 24px)'
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
}), []);
|
|
194
190
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
195
191
|
enable: handles,
|
|
196
192
|
width: width,
|
|
@@ -208,7 +204,8 @@ export const TableResizer = ({
|
|
|
208
204
|
handlePositioning: "adjacent",
|
|
209
205
|
innerPadding: tableHandlePosition,
|
|
210
206
|
isHandleVisible: ((_findTable = findTable((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos(),
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
appearance: isInDanger ? 'danger' : undefined,
|
|
208
|
+
handleHighlight: "shadow",
|
|
209
|
+
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
213
210
|
}, children);
|
|
214
211
|
};
|
|
@@ -5,18 +5,28 @@ const emptyDecorations = [[], []];
|
|
|
5
5
|
const updateColumnResizeHandle = columnResizesDecorations => ({
|
|
6
6
|
decorationSet,
|
|
7
7
|
tr
|
|
8
|
-
}) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.
|
|
8
|
+
}) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET);
|
|
9
9
|
const updateLastCellElement = lastCellElementsDecorations => ({
|
|
10
10
|
decorationSet,
|
|
11
11
|
tr
|
|
12
12
|
}) => updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
|
|
13
|
-
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex) => ({
|
|
13
|
+
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex, includeTooltip, getIntl) => ({
|
|
14
14
|
tr,
|
|
15
15
|
decorationSet
|
|
16
16
|
}) => {
|
|
17
17
|
const [columnResizesDecorations, lastCellElementsDecorations] = columnEndIndex < 0 ? emptyDecorations : createResizeHandleDecoration(tr, rowEndIndex, {
|
|
18
18
|
right: columnEndIndex
|
|
19
|
+
}, includeTooltip, getIntl);
|
|
20
|
+
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
21
|
+
decorationSet,
|
|
22
|
+
tr
|
|
19
23
|
});
|
|
24
|
+
};
|
|
25
|
+
export const clearColumnResizingDecorations = () => ({
|
|
26
|
+
tr,
|
|
27
|
+
decorationSet
|
|
28
|
+
}) => {
|
|
29
|
+
const [columnResizesDecorations, lastCellElementsDecorations] = emptyDecorations;
|
|
20
30
|
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
21
31
|
decorationSet,
|
|
22
32
|
tr
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration } from './column-controls';
|
|
2
|
-
export { buildColumnResizingDecorations } from './column-resizing';
|
|
2
|
+
export { buildColumnResizingDecorations, clearColumnResizingDecorations } from './column-resizing';
|
|
3
3
|
export { composeDecorations } from './compose-decorations';
|
|
@@ -7,7 +7,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
|
|
|
7
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
10
|
-
import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
10
|
+
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
11
11
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
12
12
|
import { createTableView } from '../nodeviews/table';
|
|
13
13
|
import TableCellNodeView from '../nodeviews/tableCell';
|
|
@@ -23,7 +23,7 @@ let isBreakoutEnabled;
|
|
|
23
23
|
let isFullWidthModeEnabled;
|
|
24
24
|
let wasFullWidthModeEnabled;
|
|
25
25
|
let isTableResizingEnabled;
|
|
26
|
-
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
|
|
26
|
+
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
|
|
27
27
|
var _window;
|
|
28
28
|
isBreakoutEnabled = breakoutEnabled;
|
|
29
29
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
@@ -36,7 +36,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
36
36
|
isFullWidthModeEnabled,
|
|
37
37
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
38
38
|
isHeaderColumnEnabled: false,
|
|
39
|
-
...defaultTableSelection
|
|
39
|
+
...defaultTableSelection,
|
|
40
|
+
getIntl
|
|
40
41
|
});
|
|
41
42
|
let elementContentRects = {};
|
|
42
43
|
const observer = (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(entries => {
|
|
@@ -136,6 +137,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
136
137
|
addBoldInEmptyHeaderCells(tableCellHeader)(state, dispatch);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
140
|
+
} else if (pluginState.isResizeHandleWidgetAdded) {
|
|
141
|
+
removeResizeHandleDecorations()(state, dispatch);
|
|
139
142
|
}
|
|
140
143
|
},
|
|
141
144
|
destroy: () => {
|
|
@@ -5,6 +5,7 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
8
9
|
import { updateColumnWidths } from '../../transforms';
|
|
9
10
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
10
11
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
@@ -60,6 +61,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
60
61
|
startX: event.clientX,
|
|
61
62
|
startWidth: width
|
|
62
63
|
})(state, dispatch);
|
|
64
|
+
|
|
65
|
+
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
66
|
+
// unnecessary tooltips being displayed during drag.
|
|
67
|
+
updateResizeHandleDecorations(undefined, undefined, false)(state, dispatch);
|
|
63
68
|
function finish(event) {
|
|
64
69
|
window.removeEventListener('mouseup', finish);
|
|
65
70
|
window.removeEventListener('mousemove', move);
|
|
@@ -7,6 +7,7 @@ import { getLayoutSize } from '../utils/misc';
|
|
|
7
7
|
import { reduceSpace } from '../utils/resize-logic';
|
|
8
8
|
import { adjustColumnsWidths, getResizeState, getTotalWidth, updateColgroup } from '../utils/resize-state';
|
|
9
9
|
import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
10
|
+
import { syncStickyRowToTable } from './dom';
|
|
10
11
|
// Base function to trigger the actual scale on a table node.
|
|
11
12
|
// Will only resize/scale if a table has been previously resized.
|
|
12
13
|
export const scale = (tableRef, options, domAtPos) => {
|
|
@@ -117,6 +118,7 @@ export const previewScaleTable = (tableRef, options, domAtPos) => {
|
|
|
117
118
|
tableRef.style.width = `${width}px`;
|
|
118
119
|
}
|
|
119
120
|
if (!hasTableBeenResized(node)) {
|
|
121
|
+
syncStickyRowToTable(tableRef);
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
124
|
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
|
|
@@ -76,12 +76,39 @@ export default ((pluginState, action) => {
|
|
|
76
76
|
resizeHandleRowIndex: undefined
|
|
77
77
|
};
|
|
78
78
|
case 'ADD_RESIZE_HANDLE_DECORATIONS':
|
|
79
|
-
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex) {
|
|
79
|
+
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
|
|
80
80
|
return pluginState;
|
|
81
81
|
}
|
|
82
82
|
return {
|
|
83
83
|
...pluginState,
|
|
84
|
-
...action.data
|
|
84
|
+
...action.data,
|
|
85
|
+
isResizeHandleWidgetAdded: true
|
|
86
|
+
};
|
|
87
|
+
case 'UPDATE_RESIZE_HANDLE_DECORATIONS':
|
|
88
|
+
const {
|
|
89
|
+
resizeHandleColumnIndex,
|
|
90
|
+
resizeHandleRowIndex,
|
|
91
|
+
resizeHandleIncludeTooltip
|
|
92
|
+
} = action.data;
|
|
93
|
+
if ((resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex || !Number.isFinite(resizeHandleColumnIndex)) && (resizeHandleRowIndex === pluginState.resizeHandleRowIndex || !Number.isFinite(resizeHandleRowIndex)) && (resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip || resizeHandleIncludeTooltip === undefined)) {
|
|
94
|
+
return pluginState;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
...pluginState,
|
|
98
|
+
resizeHandleColumnIndex: resizeHandleColumnIndex !== null && resizeHandleColumnIndex !== void 0 ? resizeHandleColumnIndex : pluginState.resizeHandleColumnIndex,
|
|
99
|
+
resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
|
|
100
|
+
resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
|
|
101
|
+
};
|
|
102
|
+
case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
|
|
103
|
+
if (!pluginState.isResizeHandleWidgetAdded) {
|
|
104
|
+
return pluginState;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
...pluginState,
|
|
108
|
+
...action.data,
|
|
109
|
+
resizeHandleColumnIndex: undefined,
|
|
110
|
+
resizeHandleRowIndex: undefined,
|
|
111
|
+
isResizeHandleWidgetAdded: false
|
|
85
112
|
};
|
|
86
113
|
case 'SET_TABLE_REF':
|
|
87
114
|
case 'HOVER_ROWS':
|
|
@@ -36,6 +36,7 @@ export let TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
|
36
36
|
TableDecorations["COLUMN_CONTROLS_DECORATIONS"] = "COLUMN_CONTROLS_DECORATIONS";
|
|
37
37
|
TableDecorations["COLUMN_SELECTED"] = "COLUMN_SELECTED";
|
|
38
38
|
TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
|
|
39
|
+
TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
|
|
39
40
|
TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
|
|
40
41
|
TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
|
|
41
42
|
return TableDecorations;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { useIntl } from 'react-intl-next';
|
|
6
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
7
|
+
import { TableCssClassName } from '../../types';
|
|
8
|
+
import messages from '../messages';
|
|
9
|
+
export const ColumnResizeWidget = ({
|
|
10
|
+
startIndex,
|
|
11
|
+
endIndex,
|
|
12
|
+
includeTooltip
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
formatMessage
|
|
16
|
+
} = useIntl();
|
|
17
|
+
if (!includeTooltip) {
|
|
18
|
+
return jsx("div", {
|
|
19
|
+
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
20
|
+
"data-start-index": startIndex,
|
|
21
|
+
"data-end-index": endIndex
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return jsx(Tooltip, {
|
|
25
|
+
content: formatMessage(messages.adjustColumns),
|
|
26
|
+
hideTooltipOnClick: true,
|
|
27
|
+
hideTooltipOnMouseDown: true,
|
|
28
|
+
position: "mouse",
|
|
29
|
+
mousePosition: "auto-start"
|
|
30
|
+
}, tooltipProps => jsx("div", _extends({
|
|
31
|
+
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
32
|
+
"data-start-index": startIndex,
|
|
33
|
+
"data-end-index": endIndex
|
|
34
|
+
}, tooltipProps)));
|
|
35
|
+
};
|
|
@@ -54,5 +54,10 @@ export default defineMessages({
|
|
|
54
54
|
id: 'fabric.editor.extension.sourceNoTitledName',
|
|
55
55
|
defaultMessage: 'this element',
|
|
56
56
|
description: 'The current element without preset name been selected'
|
|
57
|
+
},
|
|
58
|
+
adjustColumns: {
|
|
59
|
+
id: 'fabric.editor.tables.adjustColumn',
|
|
60
|
+
defaultMessage: 'Adjust column',
|
|
61
|
+
description: 'Tooltip displayed on table column resize handle'
|
|
57
62
|
}
|
|
58
63
|
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { RawIntlProvider } from 'react-intl-next';
|
|
1
4
|
import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
2
5
|
|
|
3
6
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
@@ -6,6 +9,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
9
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
10
|
import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
11
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
12
|
+
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
9
13
|
const filterDecorationByKey = (key, decorationSet) => decorationSet.find(undefined, undefined, spec => spec.key.indexOf(key) > -1);
|
|
10
14
|
export const findColumnControlSelectedDecoration = decorationSet => filterDecorationByKey(TableDecorations.COLUMN_SELECTED, decorationSet);
|
|
11
15
|
export const findControlsHoverDecoration = decorationSet => filterDecorationByKey(TableDecorations.ALL_CONTROLS_HOVER, decorationSet);
|
|
@@ -235,7 +239,7 @@ const makeArray = n => Array.from(Array(n).keys());
|
|
|
235
239
|
* we will add a new class on the last item for each cell,
|
|
236
240
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
237
241
|
*/
|
|
238
|
-
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget) => {
|
|
242
|
+
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget, includeTooltip = false, getIntl) => {
|
|
239
243
|
const emptyResult = [[], []];
|
|
240
244
|
const table = findTable(tr.selection);
|
|
241
245
|
if (!table || !table.node) {
|
|
@@ -249,12 +253,19 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
|
|
|
249
253
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
250
254
|
return Decoration.widget(position, () => {
|
|
251
255
|
const element = document.createElement('div');
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
257
|
+
value: getIntl()
|
|
258
|
+
}, /*#__PURE__*/createElement(ColumnResizeWidget, {
|
|
259
|
+
startIndex: cellColumnPositioning.left,
|
|
260
|
+
endIndex: cellColumnPositioning.right,
|
|
261
|
+
includeTooltip
|
|
262
|
+
})), element);
|
|
255
263
|
return element;
|
|
256
264
|
}, {
|
|
257
|
-
key: `${TableDecorations.
|
|
265
|
+
key: `${TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET}_${rowIndex}_${columnIndex}_${includeTooltip ? 'with' : 'no'}-tooltip`,
|
|
266
|
+
destroy: node => {
|
|
267
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
268
|
+
}
|
|
258
269
|
});
|
|
259
270
|
};
|
|
260
271
|
const createLastCellElementDecoration = (cellColumnPositioning, cellPos, cellNode) => {
|
|
@@ -9,7 +9,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
9
9
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
10
|
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumn as selectColumnTransform, selectionCell, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
12
|
-
import { buildColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
12
|
+
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
13
13
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
14
14
|
import { fixAutoSizedTable } from '../transforms';
|
|
15
15
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
@@ -335,23 +335,74 @@ export var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton()
|
|
|
335
335
|
return tr.setMeta('addToHistory', false);
|
|
336
336
|
});
|
|
337
337
|
};
|
|
338
|
-
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex) {
|
|
338
|
+
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
339
339
|
return createCommand(function (state) {
|
|
340
340
|
var tableNode = findTable(state.selection);
|
|
341
341
|
var _getPluginState = getPluginState(state),
|
|
342
|
-
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing
|
|
342
|
+
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
|
|
343
|
+
getIntl = _getPluginState.getIntl;
|
|
343
344
|
if (!tableNode || !allowColumnResizing) {
|
|
344
345
|
return false;
|
|
345
346
|
}
|
|
346
347
|
return {
|
|
347
348
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
348
349
|
data: {
|
|
349
|
-
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex)({
|
|
350
|
+
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex, includeTooltip, getIntl)({
|
|
350
351
|
tr: state.tr,
|
|
351
352
|
decorationSet: getDecorations(state)
|
|
352
353
|
}),
|
|
353
354
|
resizeHandleRowIndex: rowIndex,
|
|
354
|
-
resizeHandleColumnIndex: columnIndex
|
|
355
|
+
resizeHandleColumnIndex: columnIndex,
|
|
356
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}, function (tr) {
|
|
360
|
+
return tr.setMeta('addToHistory', false);
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
export var updateResizeHandleDecorations = function updateResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
364
|
+
return createCommand(function (state) {
|
|
365
|
+
var tableNode = findTable(state.selection);
|
|
366
|
+
var _getPluginState2 = getPluginState(state),
|
|
367
|
+
resizeHandleRowIndex = _getPluginState2.resizeHandleRowIndex,
|
|
368
|
+
resizeHandleColumnIndex = _getPluginState2.resizeHandleColumnIndex,
|
|
369
|
+
resizeHandleIncludeTooltip = _getPluginState2.resizeHandleIncludeTooltip,
|
|
370
|
+
allowColumnResizing = _getPluginState2.pluginConfig.allowColumnResizing,
|
|
371
|
+
getIntl = _getPluginState2.getIntl;
|
|
372
|
+
if (!tableNode || !allowColumnResizing) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
var resolvedRowIndex = rowIndex !== null && rowIndex !== void 0 ? rowIndex : resizeHandleRowIndex;
|
|
376
|
+
var resolvedColumnIndex = columnIndex !== null && columnIndex !== void 0 ? columnIndex : resizeHandleColumnIndex;
|
|
377
|
+
var resolvedIncludeTooltip = includeTooltip !== null && includeTooltip !== void 0 ? includeTooltip : resizeHandleIncludeTooltip;
|
|
378
|
+
if (resolvedRowIndex === undefined || resolvedColumnIndex === undefined || resolvedIncludeTooltip === undefined) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
type: 'UPDATE_RESIZE_HANDLE_DECORATIONS',
|
|
383
|
+
data: {
|
|
384
|
+
decorationSet: buildColumnResizingDecorations(resolvedRowIndex, resolvedColumnIndex, resolvedIncludeTooltip, getIntl)({
|
|
385
|
+
tr: state.tr,
|
|
386
|
+
decorationSet: getDecorations(state)
|
|
387
|
+
}),
|
|
388
|
+
resizeHandleRowIndex: rowIndex,
|
|
389
|
+
resizeHandleColumnIndex: columnIndex,
|
|
390
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}, function (tr) {
|
|
394
|
+
return tr.setMeta('addToHistory', false);
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
export var removeResizeHandleDecorations = function removeResizeHandleDecorations() {
|
|
398
|
+
return createCommand(function (state) {
|
|
399
|
+
return {
|
|
400
|
+
type: 'REMOVE_RESIZE_HANDLE_DECORATIONS',
|
|
401
|
+
data: {
|
|
402
|
+
decorationSet: clearColumnResizingDecorations()({
|
|
403
|
+
tr: state.tr,
|
|
404
|
+
decorationSet: getDecorations(state)
|
|
405
|
+
})
|
|
355
406
|
}
|
|
356
407
|
};
|
|
357
408
|
}, function (tr) {
|
|
@@ -225,7 +225,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
225
225
|
target: element,
|
|
226
226
|
columnEndIndexTarget: columnEndIndexTarget
|
|
227
227
|
})) {
|
|
228
|
-
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
|
|
228
|
+
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true)(_state4, _dispatch5);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
}
|
|
@@ -303,11 +303,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
303
303
|
};
|
|
304
304
|
export var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
|
|
305
305
|
return function (view, mouseEvent) {
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
var isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
|
|
309
|
-
var hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
310
|
-
if (!hasTableNode || isDragging) {
|
|
306
|
+
var _getPluginState7, _getResizePluginState;
|
|
307
|
+
if (!((_getPluginState7 = getPluginState(view.state)) !== null && _getPluginState7 !== void 0 && _getPluginState7.tableNode) || !!((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging)) {
|
|
311
308
|
return false;
|
|
312
309
|
}
|
|
313
310
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
@@ -90,7 +90,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
90
90
|
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
91
91
|
dispatch = _ref2.dispatch,
|
|
92
92
|
portalProviderAPI = _ref2.portalProviderAPI,
|
|
93
|
-
eventDispatcher = _ref2.eventDispatcher
|
|
93
|
+
eventDispatcher = _ref2.eventDispatcher,
|
|
94
|
+
getIntl = _ref2.getIntl;
|
|
94
95
|
var _ref3 = options || {},
|
|
95
96
|
fullWidthEnabled = _ref3.fullWidthEnabled,
|
|
96
97
|
wasFullWidthEnabled = _ref3.wasFullWidthEnabled,
|
|
@@ -98,7 +99,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
98
99
|
breakoutEnabled = _ref3.breakoutEnabled,
|
|
99
100
|
tableOptions = _ref3.tableOptions,
|
|
100
101
|
getEditorFeatureFlags = _ref3.getEditorFeatureFlags;
|
|
101
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
102
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
102
103
|
}
|
|
103
104
|
}, {
|
|
104
105
|
name: 'tablePMColResizing',
|
|
@@ -4,9 +4,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import rafSchd from 'raf-schd';
|
|
7
|
+
import { defineMessages, useIntl } from 'react-intl-next';
|
|
7
8
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
8
9
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
9
|
-
import { resizerHandleShadowClassName } from '@atlaskit/editor-common/styles';
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
12
12
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
@@ -15,6 +15,13 @@ import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '
|
|
|
15
15
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
16
16
|
import { defaultGuidelines } from '../utils/guidelines';
|
|
17
17
|
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
18
|
+
var messages = defineMessages({
|
|
19
|
+
resizeTable: {
|
|
20
|
+
id: 'fabric.editor.tables.resizeTable',
|
|
21
|
+
defaultMessage: 'Resize table',
|
|
22
|
+
description: 'Tooltip displayed on custom table width resize hande'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
18
25
|
var handles = {
|
|
19
26
|
right: true
|
|
20
27
|
};
|
|
@@ -79,6 +86,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
79
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
80
87
|
snappingEnabled = _useState2[0],
|
|
81
88
|
setSnappingEnabled = _useState2[1];
|
|
89
|
+
var _useIntl = useIntl(),
|
|
90
|
+
formatMessage = _useIntl.formatMessage;
|
|
82
91
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
83
92
|
var handleHeightSize = getResizerHandleHeight(tableRef);
|
|
84
93
|
var _getPluginState = getPluginState(editorView.state),
|
|
@@ -177,22 +186,6 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
177
186
|
scheduleResize.cancel();
|
|
178
187
|
return newWidth;
|
|
179
188
|
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
180
|
-
var handleComponent = useMemo(function () {
|
|
181
|
-
return {
|
|
182
|
-
left: /*#__PURE__*/React.createElement("div", {
|
|
183
|
-
className: resizerHandleShadowClassName,
|
|
184
|
-
style: {
|
|
185
|
-
height: 'calc(100% - 24px)'
|
|
186
|
-
}
|
|
187
|
-
}),
|
|
188
|
-
right: /*#__PURE__*/React.createElement("div", {
|
|
189
|
-
className: resizerHandleShadowClassName,
|
|
190
|
-
style: {
|
|
191
|
-
height: 'calc(100% - 24px)'
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
};
|
|
195
|
-
}, []);
|
|
196
189
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
197
190
|
enable: handles,
|
|
198
191
|
width: width,
|
|
@@ -210,7 +203,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
210
203
|
handlePositioning: "adjacent",
|
|
211
204
|
innerPadding: tableHandlePosition,
|
|
212
205
|
isHandleVisible: ((_findTable = findTable((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos(),
|
|
213
|
-
|
|
214
|
-
|
|
206
|
+
appearance: isInDanger ? 'danger' : undefined,
|
|
207
|
+
handleHighlight: "shadow",
|
|
208
|
+
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
215
209
|
}, children);
|
|
216
210
|
};
|
|
@@ -7,7 +7,7 @@ var updateColumnResizeHandle = function updateColumnResizeHandle(columnResizesDe
|
|
|
7
7
|
return function (_ref) {
|
|
8
8
|
var decorationSet = _ref.decorationSet,
|
|
9
9
|
tr = _ref.tr;
|
|
10
|
-
return updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.
|
|
10
|
+
return updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET);
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
var updateLastCellElement = function updateLastCellElement(lastCellElementsDecorations) {
|
|
@@ -17,13 +17,13 @@ var updateLastCellElement = function updateLastCellElement(lastCellElementsDecor
|
|
|
17
17
|
return updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex) {
|
|
20
|
+
export var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex, includeTooltip, getIntl) {
|
|
21
21
|
return function (_ref3) {
|
|
22
22
|
var tr = _ref3.tr,
|
|
23
23
|
decorationSet = _ref3.decorationSet;
|
|
24
24
|
var _ref4 = columnEndIndex < 0 ? emptyDecorations : createResizeHandleDecoration(tr, rowEndIndex, {
|
|
25
25
|
right: columnEndIndex
|
|
26
|
-
}),
|
|
26
|
+
}, includeTooltip, getIntl),
|
|
27
27
|
_ref5 = _slicedToArray(_ref4, 2),
|
|
28
28
|
columnResizesDecorations = _ref5[0],
|
|
29
29
|
lastCellElementsDecorations = _ref5[1];
|
|
@@ -32,4 +32,16 @@ export var buildColumnResizingDecorations = function buildColumnResizingDecorati
|
|
|
32
32
|
tr: tr
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
+
};
|
|
36
|
+
export var clearColumnResizingDecorations = function clearColumnResizingDecorations() {
|
|
37
|
+
return function (_ref6) {
|
|
38
|
+
var tr = _ref6.tr,
|
|
39
|
+
decorationSet = _ref6.decorationSet;
|
|
40
|
+
var columnResizesDecorations = emptyDecorations[0],
|
|
41
|
+
lastCellElementsDecorations = emptyDecorations[1];
|
|
42
|
+
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
43
|
+
decorationSet: decorationSet,
|
|
44
|
+
tr: tr
|
|
45
|
+
});
|
|
46
|
+
};
|
|
35
47
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration } from './column-controls';
|
|
2
|
-
export { buildColumnResizingDecorations } from './column-resizing';
|
|
2
|
+
export { buildColumnResizingDecorations, clearColumnResizingDecorations } from './column-resizing';
|
|
3
3
|
export { composeDecorations } from './compose-decorations';
|
|
@@ -10,7 +10,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
|
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
13
|
-
import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
13
|
+
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
14
14
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
15
15
|
import { createTableView } from '../nodeviews/table';
|
|
16
16
|
import TableCellNodeView from '../nodeviews/tableCell';
|
|
@@ -26,20 +26,22 @@ var isBreakoutEnabled;
|
|
|
26
26
|
var isFullWidthModeEnabled;
|
|
27
27
|
var wasFullWidthModeEnabled;
|
|
28
28
|
var isTableResizingEnabled;
|
|
29
|
-
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
29
|
+
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
30
30
|
var _window;
|
|
31
31
|
isBreakoutEnabled = breakoutEnabled;
|
|
32
32
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
33
33
|
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
34
34
|
isTableResizingEnabled = tableResizingEnabled;
|
|
35
|
-
var state = createPluginState(dispatch, _objectSpread({
|
|
35
|
+
var state = createPluginState(dispatch, _objectSpread(_objectSpread({
|
|
36
36
|
pluginConfig: pluginConfig,
|
|
37
37
|
insertColumnButtonIndex: undefined,
|
|
38
38
|
insertRowButtonIndex: undefined,
|
|
39
39
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
40
40
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
41
41
|
isHeaderColumnEnabled: false
|
|
42
|
-
}, defaultTableSelection)
|
|
42
|
+
}, defaultTableSelection), {}, {
|
|
43
|
+
getIntl: getIntl
|
|
44
|
+
}));
|
|
43
45
|
var elementContentRects = {};
|
|
44
46
|
var observer = (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(function (entries) {
|
|
45
47
|
entries.forEach(function (entry) {
|
|
@@ -143,6 +145,8 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
143
145
|
addBoldInEmptyHeaderCells(tableCellHeader)(state, dispatch);
|
|
144
146
|
}
|
|
145
147
|
}
|
|
148
|
+
} else if (pluginState.isResizeHandleWidgetAdded) {
|
|
149
|
+
removeResizeHandleDecorations()(state, dispatch);
|
|
146
150
|
}
|
|
147
151
|
},
|
|
148
152
|
destroy: function destroy() {
|