@atlaskit/editor-plugin-table 2.13.3 → 2.14.1
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 +16 -0
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +52 -9
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +17 -3
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +2 -12
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +54 -13
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +17 -3
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +2 -13
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +52 -9
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +17 -3
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +2 -12
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +5 -1
- package/dist/types/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +4 -5
- package/dist/types/plugins/table/ui/FloatingContextualMenu/index.d.ts +4 -4
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +4 -5
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/index.d.ts +4 -4
- package/package.json +7 -4
- package/src/__tests__/unit/ui/ContextualMenu.tsx +0 -2
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +0 -1
- package/src/plugins/table/nodeviews/TableContainer.tsx +73 -13
- package/src/plugins/table/nodeviews/TableResizer.tsx +30 -2
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +5 -22
- package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b6525ba4703`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b6525ba4703) - [ux] Reimplement inline height for table when resizing
|
|
8
|
+
|
|
9
|
+
## 2.14.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`6ccd72d2fe0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6ccd72d2fe0) - ED-18264: Clean up useSomewhatSemanticTextColorNames - default behaviour will be same as when FF was on.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`69857bbbff0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/69857bbbff0) - [ED-20004] Capture errors in getPos due to prosemirror-view bump
|
|
18
|
+
|
|
3
19
|
## 2.13.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -6,16 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.TableContainer = exports.ResizableTableContainer = exports.InnerContainer = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
12
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
12
13
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
15
17
|
var _types = require("../types");
|
|
16
18
|
var _TableResizer = require("./TableResizer");
|
|
17
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
23
|
var getMarginLeft = function getMarginLeft(lineLength, tableWidth) {
|
|
20
24
|
var marginLeft;
|
|
21
25
|
if (tableWidth !== 'inherit' && lineLength) {
|
|
@@ -55,6 +59,38 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
55
59
|
var containerRef = (0, _react.useRef)(null);
|
|
56
60
|
var marginLeftRef = (0, _react.useRef)(0);
|
|
57
61
|
var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
|
|
62
|
+
var updateContainerHeight = (0, _react.useCallback)(function (height) {
|
|
63
|
+
var _containerRef$current;
|
|
64
|
+
// current StickyHeader State is not stable to be fetch.
|
|
65
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
66
|
+
// consistently fetch and refactor below
|
|
67
|
+
var stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
68
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
69
|
+
var _containerRef$current2;
|
|
70
|
+
// when starting to drag, we need to keep the original space,
|
|
71
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
72
|
+
// 1px is border width but collapse make it 0.5.
|
|
73
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
74
|
+
// collapsed border
|
|
75
|
+
(_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto');
|
|
76
|
+
} else {
|
|
77
|
+
var _containerRef$current3, _containerRef$current4;
|
|
78
|
+
var stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
79
|
+
(_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto');
|
|
80
|
+
}
|
|
81
|
+
}, []);
|
|
82
|
+
var resizeObserverRef = (0, _react.useRef)(new ResizeObserver(function (entries) {
|
|
83
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
84
|
+
}));
|
|
85
|
+
var onResizeStart = (0, _react.useCallback)(function () {
|
|
86
|
+
if (tableRef) {
|
|
87
|
+
resizeObserverRef.current.observe(tableRef);
|
|
88
|
+
}
|
|
89
|
+
}, [tableRef]);
|
|
90
|
+
var onResizeStop = (0, _react.useCallback)(function () {
|
|
91
|
+
updateContainerHeight('auto');
|
|
92
|
+
resizeObserverRef.current.disconnect();
|
|
93
|
+
}, [updateContainerHeight]);
|
|
58
94
|
var updateWidth = (0, _react.useCallback)(function (width) {
|
|
59
95
|
if (!containerRef.current) {
|
|
60
96
|
return;
|
|
@@ -98,14 +134,7 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
98
134
|
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
99
135
|
}
|
|
100
136
|
var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
|
|
101
|
-
|
|
102
|
-
style: {
|
|
103
|
-
marginLeft: marginLeftRef.current,
|
|
104
|
-
width: tableWidthRef.current
|
|
105
|
-
},
|
|
106
|
-
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
107
|
-
ref: containerRef
|
|
108
|
-
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, {
|
|
137
|
+
var tableResizerProps = {
|
|
109
138
|
width: width,
|
|
110
139
|
maxWidth: maxResizerWidth,
|
|
111
140
|
containerWidth: containerWidth,
|
|
@@ -117,7 +146,21 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
117
146
|
displayGuideline: displayGuideline,
|
|
118
147
|
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
119
148
|
displayGapCursor: displayGapCursor
|
|
120
|
-
}
|
|
149
|
+
};
|
|
150
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement')) {
|
|
151
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
152
|
+
onResizeStart: onResizeStart,
|
|
153
|
+
onResizeStop: onResizeStop
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
157
|
+
style: {
|
|
158
|
+
marginLeft: marginLeftRef.current,
|
|
159
|
+
width: tableWidthRef.current
|
|
160
|
+
},
|
|
161
|
+
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
162
|
+
ref: containerRef
|
|
163
|
+
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, tableResizerProps, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
121
164
|
className: className,
|
|
122
165
|
node: node
|
|
123
166
|
}, children)));
|
|
@@ -14,6 +14,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
14
14
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
15
15
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
16
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
18
19
|
var _utils2 = require("../pm-plugins/table-resizing/utils");
|
|
19
20
|
var _tableWidth = require("../pm-plugins/table-width");
|
|
@@ -85,6 +86,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
85
86
|
maxWidth = _ref.maxWidth,
|
|
86
87
|
containerWidth = _ref.containerWidth,
|
|
87
88
|
updateWidth = _ref.updateWidth,
|
|
89
|
+
onResizeStop = _ref.onResizeStop,
|
|
90
|
+
onResizeStart = _ref.onResizeStart,
|
|
88
91
|
editorView = _ref.editorView,
|
|
89
92
|
getPos = _ref.getPos,
|
|
90
93
|
node = _ref.node,
|
|
@@ -145,11 +148,19 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
145
148
|
dispatch(tr);
|
|
146
149
|
var visibleGuidelines = getVisibleGuidelines(_guidelines.defaultGuidelines, containerWidth);
|
|
147
150
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
148
|
-
|
|
151
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
152
|
+
onResizeStart();
|
|
153
|
+
}
|
|
154
|
+
}, [displayGapCursor, displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
149
155
|
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
150
156
|
countFrames();
|
|
151
157
|
var newWidth = originalState.width + delta.width;
|
|
152
|
-
var pos
|
|
158
|
+
var pos;
|
|
159
|
+
try {
|
|
160
|
+
pos = getPos();
|
|
161
|
+
} catch (e) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
153
164
|
if (typeof pos !== 'number') {
|
|
154
165
|
return;
|
|
155
166
|
}
|
|
@@ -212,8 +223,11 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
212
223
|
displayGuideline([]);
|
|
213
224
|
updateWidth(newWidth);
|
|
214
225
|
scheduleResize.cancel();
|
|
226
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement') && onResizeStop) {
|
|
227
|
+
onResizeStop();
|
|
228
|
+
}
|
|
215
229
|
return newWidth;
|
|
216
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
230
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
217
231
|
var isTableSelected = ((_findTable = (0, _utils.findTable)((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos();
|
|
218
232
|
return /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
|
|
219
233
|
enable: handles,
|
|
@@ -115,12 +115,9 @@ var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
115
115
|
isOpen = _this$props.isOpen,
|
|
116
116
|
selectionRect = _this$props.selectionRect,
|
|
117
117
|
formatMessage = _this$props.intl.formatMessage,
|
|
118
|
-
editorView = _this$props.editorView
|
|
119
|
-
getEditorFeatureFlags = _this$props.getEditorFeatureFlags;
|
|
118
|
+
editorView = _this$props.editorView;
|
|
120
119
|
var items = [];
|
|
121
120
|
var isSubmenuOpen = _this.state.isSubmenuOpen;
|
|
122
|
-
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
123
|
-
useSomewhatSemanticTextColorNames = _getEditorFeatureFlag.useSomewhatSemanticTextColorNames;
|
|
124
121
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
125
122
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
126
123
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
@@ -149,14 +146,7 @@ var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
149
146
|
paletteOptions: {
|
|
150
147
|
palette: _uiColor.cellBackgroundColorPalette,
|
|
151
148
|
paletteColorTooltipMessages: _uiColor.backgroundPaletteTooltipMessages,
|
|
152
|
-
hexToPaletteColor: _editorPalette.hexToEditorBackgroundPaletteColor
|
|
153
|
-
// We did not want to create new FF or update
|
|
154
|
-
// useSomewhatSemanticTextColorNames name
|
|
155
|
-
// because it is temporary and require extra work.
|
|
156
|
-
// So even though it says text color names,
|
|
157
|
-
// we are going to use for all color pickers
|
|
158
|
-
// such as text, background and table charts.
|
|
159
|
-
showSomewhatSemanticTooltips: useSomewhatSemanticTextColorNames
|
|
149
|
+
hexToPaletteColor: _editorPalette.hexToEditorBackgroundPaletteColor
|
|
160
150
|
}
|
|
161
151
|
})))
|
|
162
152
|
});
|
|
@@ -24,8 +24,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
24
24
|
isOpen = _ref.isOpen,
|
|
25
25
|
pluginConfig = _ref.pluginConfig,
|
|
26
26
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
27
|
-
getEditorContainerWidth = _ref.getEditorContainerWidth
|
|
28
|
-
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
27
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth;
|
|
29
28
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
30
29
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
31
30
|
targetCellPosition = _getPluginState.targetCellPosition;
|
|
@@ -72,8 +71,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
72
71
|
selectionRect: selectionRect,
|
|
73
72
|
boundariesElement: boundariesElement,
|
|
74
73
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
75
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
76
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
74
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
77
75
|
})));
|
|
78
76
|
};
|
|
79
77
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -3,6 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
4
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
7
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
8
9
|
import { TableResizer } from './TableResizer';
|
|
@@ -46,6 +47,38 @@ export const ResizableTableContainer = ({
|
|
|
46
47
|
const containerRef = useRef(null);
|
|
47
48
|
const marginLeftRef = useRef(0);
|
|
48
49
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
50
|
+
const updateContainerHeight = useCallback(height => {
|
|
51
|
+
var _containerRef$current;
|
|
52
|
+
// current StickyHeader State is not stable to be fetch.
|
|
53
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
54
|
+
// consistently fetch and refactor below
|
|
55
|
+
const stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
56
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
57
|
+
var _containerRef$current2;
|
|
58
|
+
// when starting to drag, we need to keep the original space,
|
|
59
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
60
|
+
// 1px is border width but collapse make it 0.5.
|
|
61
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
62
|
+
// collapsed border
|
|
63
|
+
(_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? `${height + 40.5}px` : 'auto');
|
|
64
|
+
} else {
|
|
65
|
+
var _containerRef$current3, _containerRef$current4;
|
|
66
|
+
const stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
67
|
+
(_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto');
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
const resizeObserverRef = useRef(new ResizeObserver(entries => {
|
|
71
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
72
|
+
}));
|
|
73
|
+
const onResizeStart = useCallback(() => {
|
|
74
|
+
if (tableRef) {
|
|
75
|
+
resizeObserverRef.current.observe(tableRef);
|
|
76
|
+
}
|
|
77
|
+
}, [tableRef]);
|
|
78
|
+
const onResizeStop = useCallback(() => {
|
|
79
|
+
updateContainerHeight('auto');
|
|
80
|
+
resizeObserverRef.current.disconnect();
|
|
81
|
+
}, [updateContainerHeight]);
|
|
49
82
|
const updateWidth = useCallback(width => {
|
|
50
83
|
if (!containerRef.current) {
|
|
51
84
|
return;
|
|
@@ -89,6 +122,26 @@ export const ResizableTableContainer = ({
|
|
|
89
122
|
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
90
123
|
}
|
|
91
124
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
125
|
+
let tableResizerProps = {
|
|
126
|
+
width,
|
|
127
|
+
maxWidth: maxResizerWidth,
|
|
128
|
+
containerWidth,
|
|
129
|
+
updateWidth,
|
|
130
|
+
editorView,
|
|
131
|
+
getPos,
|
|
132
|
+
node,
|
|
133
|
+
tableRef,
|
|
134
|
+
displayGuideline,
|
|
135
|
+
attachAnalyticsEvent,
|
|
136
|
+
displayGapCursor
|
|
137
|
+
};
|
|
138
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
139
|
+
tableResizerProps = {
|
|
140
|
+
...tableResizerProps,
|
|
141
|
+
onResizeStart: onResizeStart,
|
|
142
|
+
onResizeStop: onResizeStop
|
|
143
|
+
};
|
|
144
|
+
}
|
|
92
145
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
146
|
style: {
|
|
94
147
|
marginLeft: marginLeftRef.current,
|
|
@@ -96,19 +149,7 @@ export const ResizableTableContainer = ({
|
|
|
96
149
|
},
|
|
97
150
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
98
151
|
ref: containerRef
|
|
99
|
-
}, /*#__PURE__*/React.createElement(TableResizer, {
|
|
100
|
-
width: width,
|
|
101
|
-
maxWidth: maxResizerWidth,
|
|
102
|
-
containerWidth: containerWidth,
|
|
103
|
-
updateWidth: updateWidth,
|
|
104
|
-
editorView: editorView,
|
|
105
|
-
getPos: getPos,
|
|
106
|
-
node: node,
|
|
107
|
-
tableRef: tableRef,
|
|
108
|
-
displayGuideline: displayGuideline,
|
|
109
|
-
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
110
|
-
displayGapCursor: displayGapCursor
|
|
111
|
-
}, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
152
|
+
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
112
153
|
className: className,
|
|
113
154
|
node: node
|
|
114
155
|
}, children)));
|
|
@@ -4,6 +4,7 @@ import { defineMessages, useIntl } from 'react-intl-next';
|
|
|
4
4
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
5
5
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
6
6
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
9
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
9
10
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -70,6 +71,8 @@ export const TableResizer = ({
|
|
|
70
71
|
maxWidth,
|
|
71
72
|
containerWidth,
|
|
72
73
|
updateWidth,
|
|
74
|
+
onResizeStop,
|
|
75
|
+
onResizeStart,
|
|
73
76
|
editorView,
|
|
74
77
|
getPos,
|
|
75
78
|
node,
|
|
@@ -135,11 +138,19 @@ export const TableResizer = ({
|
|
|
135
138
|
dispatch(tr);
|
|
136
139
|
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
137
140
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
138
|
-
|
|
141
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
142
|
+
onResizeStart();
|
|
143
|
+
}
|
|
144
|
+
}, [displayGapCursor, displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
139
145
|
const handleResize = useCallback((originalState, delta) => {
|
|
140
146
|
countFrames();
|
|
141
147
|
const newWidth = originalState.width + delta.width;
|
|
142
|
-
|
|
148
|
+
let pos;
|
|
149
|
+
try {
|
|
150
|
+
pos = getPos();
|
|
151
|
+
} catch (e) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
143
154
|
if (typeof pos !== 'number') {
|
|
144
155
|
return;
|
|
145
156
|
}
|
|
@@ -203,8 +214,11 @@ export const TableResizer = ({
|
|
|
203
214
|
displayGuideline([]);
|
|
204
215
|
updateWidth(newWidth);
|
|
205
216
|
scheduleResize.cancel();
|
|
217
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStop) {
|
|
218
|
+
onResizeStop();
|
|
219
|
+
}
|
|
206
220
|
return newWidth;
|
|
207
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
221
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
208
222
|
const isTableSelected = ((_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();
|
|
209
223
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
210
224
|
enable: handles,
|
|
@@ -95,16 +95,12 @@ export class ContextualMenu extends Component {
|
|
|
95
95
|
intl: {
|
|
96
96
|
formatMessage
|
|
97
97
|
},
|
|
98
|
-
editorView
|
|
99
|
-
getEditorFeatureFlags
|
|
98
|
+
editorView
|
|
100
99
|
} = this.props;
|
|
101
100
|
const items = [];
|
|
102
101
|
const {
|
|
103
102
|
isSubmenuOpen
|
|
104
103
|
} = this.state;
|
|
105
|
-
const {
|
|
106
|
-
useSomewhatSemanticTextColorNames
|
|
107
|
-
} = getEditorFeatureFlags();
|
|
108
104
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
109
105
|
const {
|
|
110
106
|
targetCellPosition,
|
|
@@ -136,14 +132,7 @@ export class ContextualMenu extends Component {
|
|
|
136
132
|
paletteOptions: {
|
|
137
133
|
palette: cellBackgroundColorPalette,
|
|
138
134
|
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
139
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
140
|
-
// We did not want to create new FF or update
|
|
141
|
-
// useSomewhatSemanticTextColorNames name
|
|
142
|
-
// because it is temporary and require extra work.
|
|
143
|
-
// So even though it says text color names,
|
|
144
|
-
// we are going to use for all color pickers
|
|
145
|
-
// such as text, background and table charts.
|
|
146
|
-
showSomewhatSemanticTooltips: useSomewhatSemanticTextColorNames
|
|
135
|
+
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
147
136
|
}
|
|
148
137
|
})))
|
|
149
138
|
});
|
|
@@ -16,8 +16,7 @@ const FloatingContextualMenu = ({
|
|
|
16
16
|
isOpen,
|
|
17
17
|
pluginConfig,
|
|
18
18
|
editorAnalyticsAPI,
|
|
19
|
-
getEditorContainerWidth
|
|
20
|
-
getEditorFeatureFlags
|
|
19
|
+
getEditorContainerWidth
|
|
21
20
|
}) => {
|
|
22
21
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
23
22
|
const {
|
|
@@ -68,8 +67,7 @@ const FloatingContextualMenu = ({
|
|
|
68
67
|
selectionRect: selectionRect,
|
|
69
68
|
boundariesElement: boundariesElement,
|
|
70
69
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
71
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
72
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
70
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
73
71
|
})));
|
|
74
72
|
};
|
|
75
73
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1
4
|
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
2
5
|
import classNames from 'classnames';
|
|
3
6
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
7
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
5
8
|
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
10
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
7
11
|
import { TableCssClassName as ClassName } from '../types';
|
|
8
12
|
import { TableResizer } from './TableResizer';
|
|
@@ -44,6 +48,38 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
44
48
|
var containerRef = useRef(null);
|
|
45
49
|
var marginLeftRef = useRef(0);
|
|
46
50
|
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
51
|
+
var updateContainerHeight = useCallback(function (height) {
|
|
52
|
+
var _containerRef$current;
|
|
53
|
+
// current StickyHeader State is not stable to be fetch.
|
|
54
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
55
|
+
// consistently fetch and refactor below
|
|
56
|
+
var stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
57
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
58
|
+
var _containerRef$current2;
|
|
59
|
+
// when starting to drag, we need to keep the original space,
|
|
60
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
61
|
+
// 1px is border width but collapse make it 0.5.
|
|
62
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
63
|
+
// collapsed border
|
|
64
|
+
(_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto');
|
|
65
|
+
} else {
|
|
66
|
+
var _containerRef$current3, _containerRef$current4;
|
|
67
|
+
var stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
68
|
+
(_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto');
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
var resizeObserverRef = useRef(new ResizeObserver(function (entries) {
|
|
72
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
73
|
+
}));
|
|
74
|
+
var onResizeStart = useCallback(function () {
|
|
75
|
+
if (tableRef) {
|
|
76
|
+
resizeObserverRef.current.observe(tableRef);
|
|
77
|
+
}
|
|
78
|
+
}, [tableRef]);
|
|
79
|
+
var onResizeStop = useCallback(function () {
|
|
80
|
+
updateContainerHeight('auto');
|
|
81
|
+
resizeObserverRef.current.disconnect();
|
|
82
|
+
}, [updateContainerHeight]);
|
|
47
83
|
var updateWidth = useCallback(function (width) {
|
|
48
84
|
if (!containerRef.current) {
|
|
49
85
|
return;
|
|
@@ -87,14 +123,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
87
123
|
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
88
124
|
}
|
|
89
125
|
var maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
90
|
-
|
|
91
|
-
style: {
|
|
92
|
-
marginLeft: marginLeftRef.current,
|
|
93
|
-
width: tableWidthRef.current
|
|
94
|
-
},
|
|
95
|
-
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
96
|
-
ref: containerRef
|
|
97
|
-
}, /*#__PURE__*/React.createElement(TableResizer, {
|
|
126
|
+
var tableResizerProps = {
|
|
98
127
|
width: width,
|
|
99
128
|
maxWidth: maxResizerWidth,
|
|
100
129
|
containerWidth: containerWidth,
|
|
@@ -106,7 +135,21 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
106
135
|
displayGuideline: displayGuideline,
|
|
107
136
|
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
108
137
|
displayGapCursor: displayGapCursor
|
|
109
|
-
}
|
|
138
|
+
};
|
|
139
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
140
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
141
|
+
onResizeStart: onResizeStart,
|
|
142
|
+
onResizeStop: onResizeStop
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
style: {
|
|
147
|
+
marginLeft: marginLeftRef.current,
|
|
148
|
+
width: tableWidthRef.current
|
|
149
|
+
},
|
|
150
|
+
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
151
|
+
ref: containerRef
|
|
152
|
+
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
110
153
|
className: className,
|
|
111
154
|
node: node
|
|
112
155
|
}, children)));
|
|
@@ -8,6 +8,7 @@ import { defineMessages, useIntl } from 'react-intl-next';
|
|
|
8
8
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
9
9
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
12
13
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
13
14
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -75,6 +76,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
75
76
|
maxWidth = _ref.maxWidth,
|
|
76
77
|
containerWidth = _ref.containerWidth,
|
|
77
78
|
updateWidth = _ref.updateWidth,
|
|
79
|
+
onResizeStop = _ref.onResizeStop,
|
|
80
|
+
onResizeStart = _ref.onResizeStart,
|
|
78
81
|
editorView = _ref.editorView,
|
|
79
82
|
getPos = _ref.getPos,
|
|
80
83
|
node = _ref.node,
|
|
@@ -135,11 +138,19 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
135
138
|
dispatch(tr);
|
|
136
139
|
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
137
140
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
138
|
-
|
|
141
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
142
|
+
onResizeStart();
|
|
143
|
+
}
|
|
144
|
+
}, [displayGapCursor, displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
139
145
|
var handleResize = useCallback(function (originalState, delta) {
|
|
140
146
|
countFrames();
|
|
141
147
|
var newWidth = originalState.width + delta.width;
|
|
142
|
-
var pos
|
|
148
|
+
var pos;
|
|
149
|
+
try {
|
|
150
|
+
pos = getPos();
|
|
151
|
+
} catch (e) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
143
154
|
if (typeof pos !== 'number') {
|
|
144
155
|
return;
|
|
145
156
|
}
|
|
@@ -202,8 +213,11 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
202
213
|
displayGuideline([]);
|
|
203
214
|
updateWidth(newWidth);
|
|
204
215
|
scheduleResize.cancel();
|
|
216
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStop) {
|
|
217
|
+
onResizeStop();
|
|
218
|
+
}
|
|
205
219
|
return newWidth;
|
|
206
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
220
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
207
221
|
var isTableSelected = ((_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();
|
|
208
222
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
209
223
|
enable: handles,
|
|
@@ -108,12 +108,9 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
108
108
|
isOpen = _this$props.isOpen,
|
|
109
109
|
selectionRect = _this$props.selectionRect,
|
|
110
110
|
formatMessage = _this$props.intl.formatMessage,
|
|
111
|
-
editorView = _this$props.editorView
|
|
112
|
-
getEditorFeatureFlags = _this$props.getEditorFeatureFlags;
|
|
111
|
+
editorView = _this$props.editorView;
|
|
113
112
|
var items = [];
|
|
114
113
|
var isSubmenuOpen = _this.state.isSubmenuOpen;
|
|
115
|
-
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
116
|
-
useSomewhatSemanticTextColorNames = _getEditorFeatureFlag.useSomewhatSemanticTextColorNames;
|
|
117
114
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
118
115
|
var _getPluginState = getPluginState(editorView.state),
|
|
119
116
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
@@ -142,14 +139,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
142
139
|
paletteOptions: {
|
|
143
140
|
palette: cellBackgroundColorPalette,
|
|
144
141
|
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
145
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
146
|
-
// We did not want to create new FF or update
|
|
147
|
-
// useSomewhatSemanticTextColorNames name
|
|
148
|
-
// because it is temporary and require extra work.
|
|
149
|
-
// So even though it says text color names,
|
|
150
|
-
// we are going to use for all color pickers
|
|
151
|
-
// such as text, background and table charts.
|
|
152
|
-
showSomewhatSemanticTooltips: useSomewhatSemanticTextColorNames
|
|
142
|
+
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
153
143
|
}
|
|
154
144
|
})))
|
|
155
145
|
});
|
|
@@ -16,8 +16,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
16
16
|
isOpen = _ref.isOpen,
|
|
17
17
|
pluginConfig = _ref.pluginConfig,
|
|
18
18
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
19
|
-
getEditorContainerWidth = _ref.getEditorContainerWidth
|
|
20
|
-
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
19
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth;
|
|
21
20
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
22
21
|
var _getPluginState = getPluginState(editorView.state),
|
|
23
22
|
targetCellPosition = _getPluginState.targetCellPosition;
|
|
@@ -64,8 +63,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
64
63
|
selectionRect: selectionRect,
|
|
65
64
|
boundariesElement: boundariesElement,
|
|
66
65
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
67
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
68
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
66
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
69
67
|
})));
|
|
70
68
|
};
|
|
71
69
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -17,5 +17,9 @@ interface TableResizerProps {
|
|
|
17
17
|
attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
|
|
18
18
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
21
|
+
onResizeStop?: () => void;
|
|
22
|
+
onResizeStart?: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
|
|
21
25
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
5
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import type { GetEditorContainerWidth
|
|
7
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
6
|
+
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
export declare const messages: {
|
|
10
10
|
cellBackground: {
|
|
11
11
|
id: string;
|
|
@@ -61,7 +61,6 @@ export interface Props {
|
|
|
61
61
|
offset?: Array<number>;
|
|
62
62
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
63
63
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
64
|
-
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
65
64
|
}
|
|
66
65
|
export interface State {
|
|
67
66
|
isSubmenuOpen: boolean;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { PluginConfig } from '../../types';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import type { PluginConfig } from '../../types';
|
|
7
7
|
export interface Props {
|
|
8
8
|
editorView: EditorView;
|
|
9
9
|
isOpen: boolean;
|
|
10
10
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
11
|
-
getEditorFeatureFlags
|
|
11
|
+
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
12
12
|
targetCellPosition?: number;
|
|
13
13
|
mountPoint?: HTMLElement;
|
|
14
14
|
boundariesElement?: HTMLElement;
|
|
@@ -17,7 +17,7 @@ export interface Props {
|
|
|
17
17
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
18
18
|
}
|
|
19
19
|
declare const FloatingContextualMenu: {
|
|
20
|
-
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, pluginConfig, editorAnalyticsAPI, getEditorContainerWidth,
|
|
20
|
+
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, pluginConfig, editorAnalyticsAPI, getEditorContainerWidth, }: Props): jsx.JSX.Element | null;
|
|
21
21
|
displayName: string;
|
|
22
22
|
};
|
|
23
23
|
export default FloatingContextualMenu;
|
|
@@ -17,5 +17,9 @@ interface TableResizerProps {
|
|
|
17
17
|
attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
|
|
18
18
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
21
|
+
onResizeStop?: () => void;
|
|
22
|
+
onResizeStart?: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
|
|
21
25
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
5
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import type { GetEditorContainerWidth
|
|
7
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
6
|
+
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
export declare const messages: {
|
|
10
10
|
cellBackground: {
|
|
11
11
|
id: string;
|
|
@@ -61,7 +61,6 @@ export interface Props {
|
|
|
61
61
|
offset?: Array<number>;
|
|
62
62
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
63
63
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
64
|
-
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
65
64
|
}
|
|
66
65
|
export interface State {
|
|
67
66
|
isSubmenuOpen: boolean;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { PluginConfig } from '../../types';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import type { PluginConfig } from '../../types';
|
|
7
7
|
export interface Props {
|
|
8
8
|
editorView: EditorView;
|
|
9
9
|
isOpen: boolean;
|
|
10
10
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
11
|
-
getEditorFeatureFlags
|
|
11
|
+
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
12
12
|
targetCellPosition?: number;
|
|
13
13
|
mountPoint?: HTMLElement;
|
|
14
14
|
boundariesElement?: HTMLElement;
|
|
@@ -17,7 +17,7 @@ export interface Props {
|
|
|
17
17
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
18
18
|
}
|
|
19
19
|
declare const FloatingContextualMenu: {
|
|
20
|
-
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, pluginConfig, editorAnalyticsAPI, getEditorContainerWidth,
|
|
20
|
+
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, pluginConfig, editorAnalyticsAPI, getEditorContainerWidth, }: Props): jsx.JSX.Element | null;
|
|
21
21
|
displayName: string;
|
|
22
22
|
};
|
|
23
23
|
export default FloatingContextualMenu;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^29.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
31
|
+
"@atlaskit/editor-common": "^74.59.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/icon": "^21.12.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
40
40
|
"@atlaskit/theme": "^12.6.0",
|
|
41
|
-
"@atlaskit/tokens": "^1.
|
|
41
|
+
"@atlaskit/tokens": "^1.22.0",
|
|
42
42
|
"@atlaskit/tooltip": "^17.8.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@emotion/react": "^11.7.1",
|
|
@@ -105,8 +105,11 @@
|
|
|
105
105
|
"platform.editor.update-table-cell-width-via-step": {
|
|
106
106
|
"type": "boolean"
|
|
107
107
|
},
|
|
108
|
+
"platform.editor.resizing-table-height-improvement": {
|
|
109
|
+
"type": "boolean"
|
|
110
|
+
},
|
|
108
111
|
"platform.editor.table-remove-update-resize-handles_djvab": {
|
|
109
112
|
"type": "boolean"
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
}
|
|
115
|
+
}
|
|
@@ -30,7 +30,6 @@ import { ContextualMenu } from '../../../plugins/table/ui/FloatingContextualMenu
|
|
|
30
30
|
|
|
31
31
|
describe('ContextualMenu', () => {
|
|
32
32
|
const getEditorContainerWidth = () => ({ width: 500 });
|
|
33
|
-
const getEditorFeatureFlags = () => ({});
|
|
34
33
|
const createEditor = createProsemirrorEditorFactory();
|
|
35
34
|
describe('with right table cell position in plugin state', () => {
|
|
36
35
|
let editorView: EditorView;
|
|
@@ -57,7 +56,6 @@ describe('ContextualMenu', () => {
|
|
|
57
56
|
isOpen
|
|
58
57
|
selectionRect={{ bottom: 0, left: 0, right: 0, top: 0 }}
|
|
59
58
|
getEditorContainerWidth={getEditorContainerWidth}
|
|
60
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
61
59
|
/>,
|
|
62
60
|
);
|
|
63
61
|
|
|
@@ -14,12 +14,14 @@ import {
|
|
|
14
14
|
akEditorDefaultLayoutWidth,
|
|
15
15
|
akEditorMobileBreakoutPoint,
|
|
16
16
|
} from '@atlaskit/editor-shared-styles';
|
|
17
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
|
|
18
19
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
19
20
|
import type { PluginInjectionAPI } from '../types';
|
|
20
21
|
import { TableCssClassName as ClassName } from '../types';
|
|
21
22
|
|
|
22
23
|
import { TableResizer } from './TableResizer';
|
|
24
|
+
import type { TableResizerImprovementProps } from './TableResizer';
|
|
23
25
|
|
|
24
26
|
const getMarginLeft = (lineLength: number, tableWidth: number | 'inherit') => {
|
|
25
27
|
let marginLeft;
|
|
@@ -89,6 +91,54 @@ export const ResizableTableContainer = ({
|
|
|
89
91
|
const marginLeftRef = useRef<number | undefined>(0);
|
|
90
92
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
91
93
|
|
|
94
|
+
const updateContainerHeight = useCallback((height: number | 'auto') => {
|
|
95
|
+
// current StickyHeader State is not stable to be fetch.
|
|
96
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
97
|
+
// consistently fetch and refactor below
|
|
98
|
+
const stickyHeaders =
|
|
99
|
+
containerRef.current?.getElementsByClassName('pm-table-sticky');
|
|
100
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
101
|
+
// when starting to drag, we need to keep the original space,
|
|
102
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
103
|
+
// 1px is border width but collapse make it 0.5.
|
|
104
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
105
|
+
// collapsed border
|
|
106
|
+
containerRef.current?.style.setProperty(
|
|
107
|
+
'height',
|
|
108
|
+
typeof height === 'number' ? `${height + 40.5}px` : 'auto',
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
const stickyHeaderHeight =
|
|
112
|
+
containerRef.current
|
|
113
|
+
?.getElementsByTagName('th')[0]
|
|
114
|
+
.getBoundingClientRect().height || 0;
|
|
115
|
+
containerRef.current?.style.setProperty(
|
|
116
|
+
'height',
|
|
117
|
+
typeof height === 'number'
|
|
118
|
+
? `${height + stickyHeaderHeight + 39.5}px`
|
|
119
|
+
: 'auto',
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
const resizeObserverRef = useRef(
|
|
125
|
+
new ResizeObserver((entries) => {
|
|
126
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const onResizeStart = useCallback(() => {
|
|
131
|
+
if (tableRef) {
|
|
132
|
+
resizeObserverRef.current.observe(tableRef);
|
|
133
|
+
}
|
|
134
|
+
}, [tableRef]);
|
|
135
|
+
|
|
136
|
+
const onResizeStop = useCallback(() => {
|
|
137
|
+
updateContainerHeight('auto');
|
|
138
|
+
|
|
139
|
+
resizeObserverRef.current.disconnect();
|
|
140
|
+
}, [updateContainerHeight]);
|
|
141
|
+
|
|
92
142
|
const updateWidth = useCallback(
|
|
93
143
|
(width: number) => {
|
|
94
144
|
if (!containerRef.current) {
|
|
@@ -158,6 +208,28 @@ export const ResizableTableContainer = ({
|
|
|
158
208
|
}
|
|
159
209
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
160
210
|
|
|
211
|
+
let tableResizerProps: TableResizerImprovementProps = {
|
|
212
|
+
width,
|
|
213
|
+
maxWidth: maxResizerWidth,
|
|
214
|
+
containerWidth,
|
|
215
|
+
updateWidth,
|
|
216
|
+
editorView,
|
|
217
|
+
getPos,
|
|
218
|
+
node,
|
|
219
|
+
tableRef,
|
|
220
|
+
displayGuideline,
|
|
221
|
+
attachAnalyticsEvent,
|
|
222
|
+
displayGapCursor,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
226
|
+
tableResizerProps = {
|
|
227
|
+
...tableResizerProps,
|
|
228
|
+
onResizeStart: onResizeStart,
|
|
229
|
+
onResizeStop: onResizeStop,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
161
233
|
return (
|
|
162
234
|
<div
|
|
163
235
|
style={{
|
|
@@ -167,19 +239,7 @@ export const ResizableTableContainer = ({
|
|
|
167
239
|
className={ClassName.TABLE_RESIZER_CONTAINER}
|
|
168
240
|
ref={containerRef}
|
|
169
241
|
>
|
|
170
|
-
<TableResizer
|
|
171
|
-
width={width}
|
|
172
|
-
maxWidth={maxResizerWidth}
|
|
173
|
-
containerWidth={containerWidth}
|
|
174
|
-
updateWidth={updateWidth}
|
|
175
|
-
editorView={editorView}
|
|
176
|
-
getPos={getPos}
|
|
177
|
-
node={node}
|
|
178
|
-
tableRef={tableRef}
|
|
179
|
-
displayGuideline={displayGuideline}
|
|
180
|
-
attachAnalyticsEvent={attachAnalyticsEvent}
|
|
181
|
-
displayGapCursor={displayGapCursor}
|
|
182
|
-
>
|
|
242
|
+
<TableResizer {...tableResizerProps}>
|
|
183
243
|
<InnerContainer className={className} node={node}>
|
|
184
244
|
{children}
|
|
185
245
|
</InnerContainer>
|
|
@@ -22,6 +22,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
22
22
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
23
23
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
24
24
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
25
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
|
|
26
27
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
27
28
|
import {
|
|
@@ -60,6 +61,11 @@ interface TableResizerProps {
|
|
|
60
61
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
65
|
+
onResizeStop?: () => void;
|
|
66
|
+
onResizeStart?: () => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
const messages = defineMessages({
|
|
64
70
|
resizeTable: {
|
|
65
71
|
id: 'fabric.editor.tables.resizeTable',
|
|
@@ -135,6 +141,8 @@ export const TableResizer = ({
|
|
|
135
141
|
maxWidth,
|
|
136
142
|
containerWidth,
|
|
137
143
|
updateWidth,
|
|
144
|
+
onResizeStop,
|
|
145
|
+
onResizeStart,
|
|
138
146
|
editorView,
|
|
139
147
|
getPos,
|
|
140
148
|
node,
|
|
@@ -142,7 +150,7 @@ export const TableResizer = ({
|
|
|
142
150
|
displayGuideline,
|
|
143
151
|
attachAnalyticsEvent,
|
|
144
152
|
displayGapCursor,
|
|
145
|
-
}: PropsWithChildren<
|
|
153
|
+
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
146
154
|
const currentGap = useRef(0);
|
|
147
155
|
// track resizing state - use ref over state to avoid re-render
|
|
148
156
|
const isResizing = useRef(false);
|
|
@@ -214,11 +222,18 @@ export const TableResizer = ({
|
|
|
214
222
|
containerWidth,
|
|
215
223
|
);
|
|
216
224
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
225
|
+
if (
|
|
226
|
+
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
227
|
+
onResizeStart
|
|
228
|
+
) {
|
|
229
|
+
onResizeStart();
|
|
230
|
+
}
|
|
217
231
|
}, [
|
|
218
232
|
displayGapCursor,
|
|
219
233
|
displayGuideline,
|
|
220
234
|
editorView,
|
|
221
235
|
startMeasure,
|
|
236
|
+
onResizeStart,
|
|
222
237
|
containerWidth,
|
|
223
238
|
]);
|
|
224
239
|
|
|
@@ -226,7 +241,12 @@ export const TableResizer = ({
|
|
|
226
241
|
(originalState, delta) => {
|
|
227
242
|
countFrames();
|
|
228
243
|
const newWidth = originalState.width + delta.width;
|
|
229
|
-
|
|
244
|
+
let pos: number | undefined;
|
|
245
|
+
try {
|
|
246
|
+
pos = getPos();
|
|
247
|
+
} catch (e) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
230
250
|
if (typeof pos !== 'number') {
|
|
231
251
|
return;
|
|
232
252
|
}
|
|
@@ -325,6 +345,13 @@ export const TableResizer = ({
|
|
|
325
345
|
updateWidth(newWidth);
|
|
326
346
|
scheduleResize.cancel();
|
|
327
347
|
|
|
348
|
+
if (
|
|
349
|
+
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
350
|
+
onResizeStop
|
|
351
|
+
) {
|
|
352
|
+
onResizeStop();
|
|
353
|
+
}
|
|
354
|
+
|
|
328
355
|
return newWidth;
|
|
329
356
|
},
|
|
330
357
|
[
|
|
@@ -338,6 +365,7 @@ export const TableResizer = ({
|
|
|
338
365
|
displayGuideline,
|
|
339
366
|
attachAnalyticsEvent,
|
|
340
367
|
endMeasure,
|
|
368
|
+
onResizeStop,
|
|
341
369
|
],
|
|
342
370
|
);
|
|
343
371
|
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
injectIntl,
|
|
8
|
-
WrappedComponentProps,
|
|
9
|
-
} from 'react-intl-next';
|
|
5
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
6
|
+
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
10
7
|
|
|
11
8
|
type DropdownItem = MenuItem & {
|
|
12
9
|
value: {
|
|
@@ -24,10 +21,7 @@ import {
|
|
|
24
21
|
tooltip,
|
|
25
22
|
} from '@atlaskit/editor-common/keymaps';
|
|
26
23
|
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
27
|
-
import type {
|
|
28
|
-
GetEditorContainerWidth,
|
|
29
|
-
GetEditorFeatureFlags,
|
|
30
|
-
} from '@atlaskit/editor-common/types';
|
|
24
|
+
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
31
25
|
import {
|
|
32
26
|
backgroundPaletteTooltipMessages,
|
|
33
27
|
cellBackgroundColorPalette,
|
|
@@ -40,9 +34,9 @@ import {
|
|
|
40
34
|
} from '@atlaskit/editor-common/ui-menu';
|
|
41
35
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
42
36
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
43
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
37
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
44
38
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
45
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
39
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
46
40
|
import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
47
41
|
|
|
48
42
|
import {
|
|
@@ -135,7 +129,6 @@ export interface Props {
|
|
|
135
129
|
offset?: Array<number>;
|
|
136
130
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
137
131
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
138
|
-
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
139
132
|
}
|
|
140
133
|
|
|
141
134
|
export interface State {
|
|
@@ -215,11 +208,9 @@ export class ContextualMenu extends Component<
|
|
|
215
208
|
selectionRect,
|
|
216
209
|
intl: { formatMessage },
|
|
217
210
|
editorView,
|
|
218
|
-
getEditorFeatureFlags,
|
|
219
211
|
} = this.props;
|
|
220
212
|
const items: any[] = [];
|
|
221
213
|
const { isSubmenuOpen } = this.state;
|
|
222
|
-
const { useSomewhatSemanticTextColorNames } = getEditorFeatureFlags();
|
|
223
214
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
224
215
|
const {
|
|
225
216
|
targetCellPosition,
|
|
@@ -256,14 +247,6 @@ export class ContextualMenu extends Component<
|
|
|
256
247
|
paletteColorTooltipMessages:
|
|
257
248
|
backgroundPaletteTooltipMessages,
|
|
258
249
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor,
|
|
259
|
-
// We did not want to create new FF or update
|
|
260
|
-
// useSomewhatSemanticTextColorNames name
|
|
261
|
-
// because it is temporary and require extra work.
|
|
262
|
-
// So even though it says text color names,
|
|
263
|
-
// we are going to use for all color pickers
|
|
264
|
-
// such as text, background and table charts.
|
|
265
|
-
showSomewhatSemanticTooltips:
|
|
266
|
-
useSomewhatSemanticTextColorNames,
|
|
267
250
|
}}
|
|
268
251
|
/>
|
|
269
252
|
</div>
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
} from '@atlaskit/editor-common/types';
|
|
9
9
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
10
10
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
12
12
|
import {
|
|
13
13
|
akEditorFloatingDialogZIndex,
|
|
14
14
|
akEditorFloatingOverlapPanelZIndex,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from '@atlaskit/editor-tables/utils';
|
|
21
21
|
|
|
22
22
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
23
|
-
import { PluginConfig } from '../../types';
|
|
23
|
+
import type { PluginConfig } from '../../types';
|
|
24
24
|
import {
|
|
25
25
|
contextualMenuDropdownWidth,
|
|
26
26
|
contextualMenuTriggerSize,
|
|
@@ -33,7 +33,7 @@ export interface Props {
|
|
|
33
33
|
editorView: EditorView;
|
|
34
34
|
isOpen: boolean;
|
|
35
35
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
36
|
-
getEditorFeatureFlags
|
|
36
|
+
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
37
37
|
targetCellPosition?: number;
|
|
38
38
|
mountPoint?: HTMLElement;
|
|
39
39
|
boundariesElement?: HTMLElement;
|
|
@@ -51,7 +51,6 @@ const FloatingContextualMenu = ({
|
|
|
51
51
|
pluginConfig,
|
|
52
52
|
editorAnalyticsAPI,
|
|
53
53
|
getEditorContainerWidth,
|
|
54
|
-
getEditorFeatureFlags,
|
|
55
54
|
}: Props) => {
|
|
56
55
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
57
56
|
const { targetCellPosition } = getPluginState(editorView.state);
|
|
@@ -115,7 +114,6 @@ const FloatingContextualMenu = ({
|
|
|
115
114
|
boundariesElement={boundariesElement}
|
|
116
115
|
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
117
116
|
getEditorContainerWidth={getEditorContainerWidth}
|
|
118
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
119
117
|
/>
|
|
120
118
|
</div>
|
|
121
119
|
</Popup>
|