@atlaskit/editor-plugin-table 2.1.7 → 2.2.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 +10 -0
- package/dist/cjs/plugins/table/handlers.js +1 -0
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +50 -47
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +64 -28
- package/dist/cjs/plugins/table/nodeviews/table.js +5 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +6 -2
- package/dist/cjs/plugins/table/utils/collapse.js +2 -0
- package/dist/cjs/plugins/table/utils/decoration.js +2 -0
- package/dist/cjs/plugins/table/utils/guidelines.js +12 -0
- package/dist/cjs/plugins/table/utils/snapping.js +37 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/handlers.js +1 -0
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +25 -23
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +59 -29
- package/dist/es2019/plugins/table/nodeviews/table.js +5 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +4 -1
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
- package/dist/es2019/plugins/table/ui/consts.js +3 -1
- package/dist/es2019/plugins/table/utils/collapse.js +2 -0
- package/dist/es2019/plugins/table/utils/decoration.js +2 -0
- package/dist/es2019/plugins/table/utils/guidelines.js +4 -0
- package/dist/es2019/plugins/table/utils/snapping.js +27 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/handlers.js +1 -0
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +50 -47
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +61 -28
- package/dist/esm/plugins/table/nodeviews/table.js +5 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +4 -1
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
- package/dist/esm/plugins/table/ui/consts.js +3 -1
- package/dist/esm/plugins/table/utils/collapse.js +2 -0
- package/dist/esm/plugins/table/utils/decoration.js +2 -0
- package/dist/esm/plugins/table/utils/guidelines.js +4 -0
- package/dist/esm/plugins/table/utils/snapping.js +30 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +3 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -2
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/table/types.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types/plugins/table/utils/guidelines.d.ts +3 -0
- package/dist/types/plugins/table/utils/snapping.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +8 -0
- package/package.json +3 -2
- package/report.api.md +2 -0
- package/src/__tests__/unit/analytics.ts +2 -0
- package/src/__tests__/unit/collab.ts +2 -0
- package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
- package/src/__tests__/unit/commands/insert.ts +2 -0
- package/src/__tests__/unit/commands/misc.ts +2 -0
- package/src/__tests__/unit/commands/sort.ts +4 -0
- package/src/__tests__/unit/commands.ts +2 -0
- package/src/__tests__/unit/copy-paste.ts +2 -0
- package/src/__tests__/unit/event-handlers/index.ts +3 -0
- package/src/__tests__/unit/event-handlers.ts +3 -0
- package/src/__tests__/unit/fix-tables.ts +2 -0
- package/src/__tests__/unit/get-toolbar-config.ts +2 -0
- package/src/__tests__/unit/handlers.ts +2 -0
- package/src/__tests__/unit/hover-selection.ts +2 -0
- package/src/__tests__/unit/index.ts +2 -0
- package/src/__tests__/unit/layout.ts +2 -0
- package/src/__tests__/unit/nodeviews/cell.ts +2 -0
- package/src/__tests__/unit/nodeviews/table.ts +2 -0
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +2 -0
- package/src/__tests__/unit/pm-plugins/main.ts +2 -0
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
- package/src/__tests__/unit/sort-column.ts +2 -0
- package/src/__tests__/unit/toolbar.ts +2 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
- package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
- package/src/__tests__/unit/transforms/merging.ts +2 -0
- package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/RowControls.tsx +2 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
- package/src/__tests__/unit/undo-redo.ts +2 -0
- package/src/__tests__/unit/utils/collapse.ts +2 -0
- package/src/__tests__/unit/utils/nodes.ts +2 -0
- package/src/__tests__/unit/utils/row-controls.ts +2 -0
- package/src/__tests__/unit/utils.ts +2 -0
- package/src/plugins/table/handlers.ts +1 -0
- package/src/plugins/table/index.tsx +3 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +4 -0
- package/src/plugins/table/nodeviews/TableContainer.tsx +31 -22
- package/src/plugins/table/nodeviews/TableResizer.tsx +100 -34
- package/src/plugins/table/nodeviews/table.tsx +4 -0
- package/src/plugins/table/nodeviews/types.ts +2 -0
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +1 -0
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -0
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +1 -0
- package/src/plugins/table/pm-plugins/main.ts +3 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin-factory.ts +1 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +1 -0
- package/src/plugins/table/types.ts +4 -0
- package/src/plugins/table/ui/consts.ts +3 -0
- package/src/plugins/table/utils/collapse.ts +1 -0
- package/src/plugins/table/utils/decoration.ts +1 -0
- package/src/plugins/table/utils/guidelines.ts +17 -0
- package/src/plugins/table/utils/snapping.ts +38 -0
- package/tmp/api-report-tmp.d.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`464745a92e6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/464745a92e6) - [ux] Updated the Editor Table plugin to use the new guidelines plugin when custom-table-widths FF is enabled
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 2.1.7
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -16,6 +16,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
|
|
|
16
16
|
var _nodes = require("./utils/nodes");
|
|
17
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
18
|
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) { (0, _defineProperty2.default)(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; } // #region Imports
|
|
19
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
19
20
|
// #endregion
|
|
20
21
|
var nextTableSorting = function nextTableSorting(tr, table) {
|
|
21
22
|
var tableSortStep = tr.steps.find(function (step) {
|
|
@@ -103,7 +103,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
103
103
|
breakoutEnabled = _ref2.breakoutEnabled,
|
|
104
104
|
tableOptions = _ref2.tableOptions,
|
|
105
105
|
getEditorFeatureFlags = _ref2.getEditorFeatureFlags;
|
|
106
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
106
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
107
107
|
}
|
|
108
108
|
}, {
|
|
109
109
|
name: 'tablePMColResizing',
|
|
@@ -393,7 +393,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
393
393
|
tableActive = _this$props8.tableActive,
|
|
394
394
|
containerWidth = _this$props8.containerWidth,
|
|
395
395
|
options = _this$props8.options,
|
|
396
|
-
getPos = _this$props8.getPos
|
|
396
|
+
getPos = _this$props8.getPos,
|
|
397
|
+
pluginInjectionApi = _this$props8.pluginInjectionApi;
|
|
397
398
|
var _this$state = this.state,
|
|
398
399
|
isLoading = _this$state.isLoading,
|
|
399
400
|
showBeforeShadow = _this$state.showBeforeShadow,
|
|
@@ -453,7 +454,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
453
454
|
containerWidth: containerWidth,
|
|
454
455
|
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.isFullWidthModeEnabled,
|
|
455
456
|
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
456
|
-
isNested: isNested
|
|
457
|
+
isNested: isNested,
|
|
458
|
+
pluginInjectionApi: pluginInjectionApi
|
|
457
459
|
}, stickyHeadersOptimization && /*#__PURE__*/_react.default.createElement("div", {
|
|
458
460
|
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
459
461
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -14,9 +14,7 @@ var _TableResizer = require("./TableResizer");
|
|
|
14
14
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
15
15
|
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); }
|
|
16
16
|
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; }
|
|
17
|
-
var getMarginLeft = function getMarginLeft(
|
|
18
|
-
var lineLength = _ref.lineLength,
|
|
19
|
-
tableWidth = _ref.tableWidth;
|
|
17
|
+
var getMarginLeft = function getMarginLeft(lineLength, tableWidth) {
|
|
20
18
|
var marginLeft;
|
|
21
19
|
if (tableWidth !== 'inherit' && lineLength) {
|
|
22
20
|
var containerWidth = tableWidth;
|
|
@@ -26,11 +24,11 @@ var getMarginLeft = function getMarginLeft(_ref) {
|
|
|
26
24
|
}
|
|
27
25
|
return marginLeft;
|
|
28
26
|
};
|
|
29
|
-
var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
30
|
-
var className =
|
|
31
|
-
style =
|
|
32
|
-
node =
|
|
33
|
-
children =
|
|
27
|
+
var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
28
|
+
var className = _ref.className,
|
|
29
|
+
style = _ref.style,
|
|
30
|
+
node = _ref.node,
|
|
31
|
+
children = _ref.children;
|
|
34
32
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
35
33
|
ref: ref,
|
|
36
34
|
style: style,
|
|
@@ -41,42 +39,47 @@ var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
41
39
|
}, children);
|
|
42
40
|
});
|
|
43
41
|
exports.InnerContainer = InnerContainer;
|
|
44
|
-
var ResizableTableContainer = function ResizableTableContainer(
|
|
45
|
-
var children =
|
|
46
|
-
className =
|
|
47
|
-
node =
|
|
48
|
-
lineLength =
|
|
49
|
-
containerWidth =
|
|
50
|
-
editorView =
|
|
51
|
-
getPos =
|
|
52
|
-
tableRef =
|
|
42
|
+
var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
43
|
+
var children = _ref2.children,
|
|
44
|
+
className = _ref2.className,
|
|
45
|
+
node = _ref2.node,
|
|
46
|
+
lineLength = _ref2.lineLength,
|
|
47
|
+
containerWidth = _ref2.containerWidth,
|
|
48
|
+
editorView = _ref2.editorView,
|
|
49
|
+
getPos = _ref2.getPos,
|
|
50
|
+
tableRef = _ref2.tableRef,
|
|
51
|
+
pluginInjectionApi = _ref2.pluginInjectionApi;
|
|
53
52
|
var containerRef = (0, _react.useRef)(null);
|
|
54
53
|
var innerContainerRef = (0, _react.useRef)(null);
|
|
54
|
+
var marginLeftRef = (0, _react.useRef)(0);
|
|
55
55
|
var updateWidth = (0, _react.useCallback)(function (width) {
|
|
56
56
|
if (!containerRef.current || !innerContainerRef.current) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
var marginLeft = getMarginLeft(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
var marginLeft = getMarginLeft(lineLength, width);
|
|
60
|
+
if (marginLeftRef.current !== marginLeft) {
|
|
61
|
+
marginLeftRef.current = marginLeft;
|
|
62
|
+
if (Number.isFinite(marginLeft)) {
|
|
63
|
+
containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
}, [lineLength]);
|
|
67
|
+
var displayGuideline = (0, _react.useCallback)(function (guidelines) {
|
|
68
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
69
|
+
return (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.guideline) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.actions) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.displayGuideline(editorView)({
|
|
70
|
+
guidelines: guidelines
|
|
71
|
+
})) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : false;
|
|
72
|
+
}, [pluginInjectionApi, editorView]);
|
|
67
73
|
var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
68
74
|
|
|
69
75
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
70
76
|
var responsiveContainerWidth = containerWidth - 76;
|
|
71
77
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
72
|
-
|
|
73
|
-
lineLength: lineLength,
|
|
74
|
-
tableWidth: width
|
|
75
|
-
});
|
|
78
|
+
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
76
79
|
var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
|
|
77
80
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
78
81
|
style: {
|
|
79
|
-
marginLeft:
|
|
82
|
+
marginLeft: marginLeftRef.current,
|
|
80
83
|
width: width
|
|
81
84
|
},
|
|
82
85
|
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
@@ -88,7 +91,8 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
|
|
|
88
91
|
editorView: editorView,
|
|
89
92
|
getPos: getPos,
|
|
90
93
|
node: node,
|
|
91
|
-
tableRef: tableRef
|
|
94
|
+
tableRef: tableRef,
|
|
95
|
+
displayGuideline: displayGuideline
|
|
92
96
|
}, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
93
97
|
ref: innerContainerRef,
|
|
94
98
|
className: className,
|
|
@@ -96,19 +100,20 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
|
|
|
96
100
|
}, children)));
|
|
97
101
|
};
|
|
98
102
|
exports.ResizableTableContainer = ResizableTableContainer;
|
|
99
|
-
var TableContainer = function TableContainer(
|
|
100
|
-
var children =
|
|
101
|
-
node =
|
|
102
|
-
className =
|
|
103
|
-
|
|
104
|
-
lineLength =
|
|
105
|
-
editorWidth =
|
|
106
|
-
isFullWidthModeEnabled =
|
|
107
|
-
isBreakoutEnabled =
|
|
108
|
-
editorView =
|
|
109
|
-
getPos =
|
|
110
|
-
tableRef =
|
|
111
|
-
isNested =
|
|
103
|
+
var TableContainer = function TableContainer(_ref3) {
|
|
104
|
+
var children = _ref3.children,
|
|
105
|
+
node = _ref3.node,
|
|
106
|
+
className = _ref3.className,
|
|
107
|
+
_ref3$containerWidth = _ref3.containerWidth,
|
|
108
|
+
lineLength = _ref3$containerWidth.lineLength,
|
|
109
|
+
editorWidth = _ref3$containerWidth.width,
|
|
110
|
+
isFullWidthModeEnabled = _ref3.isFullWidthModeEnabled,
|
|
111
|
+
isBreakoutEnabled = _ref3.isBreakoutEnabled,
|
|
112
|
+
editorView = _ref3.editorView,
|
|
113
|
+
getPos = _ref3.getPos,
|
|
114
|
+
tableRef = _ref3.tableRef,
|
|
115
|
+
isNested = _ref3.isNested,
|
|
116
|
+
pluginInjectionApi = _ref3.pluginInjectionApi;
|
|
112
117
|
if ((isFullWidthModeEnabled || isBreakoutEnabled) && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && !isNested) {
|
|
113
118
|
return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
|
|
114
119
|
className: className,
|
|
@@ -117,7 +122,8 @@ var TableContainer = function TableContainer(_ref4) {
|
|
|
117
122
|
containerWidth: editorWidth,
|
|
118
123
|
editorView: editorView,
|
|
119
124
|
getPos: getPos,
|
|
120
|
-
tableRef: tableRef
|
|
125
|
+
tableRef: tableRef,
|
|
126
|
+
pluginInjectionApi: pluginInjectionApi
|
|
121
127
|
}, children);
|
|
122
128
|
}
|
|
123
129
|
var tableWidth = isBreakoutEnabled ? (0, _styles.calcTableWidth)(node.attrs.layout, editorWidth) : 'inherit';
|
|
@@ -126,10 +132,7 @@ var TableContainer = function TableContainer(_ref4) {
|
|
|
126
132
|
className: className,
|
|
127
133
|
style: {
|
|
128
134
|
width: tableWidth,
|
|
129
|
-
marginLeft: getMarginLeft(
|
|
130
|
-
lineLength: lineLength,
|
|
131
|
-
tableWidth: tableWidth
|
|
132
|
-
})
|
|
135
|
+
marginLeft: getMarginLeft(lineLength, tableWidth)
|
|
133
136
|
}
|
|
134
137
|
}, children);
|
|
135
138
|
};
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.TableResizer = void 0;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
12
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
11
13
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
14
|
+
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
12
15
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
16
|
+
var _guidelines = require("../utils/guidelines");
|
|
17
|
+
var _snapping = require("../utils/snapping");
|
|
18
|
+
var _consts = require("../ui/consts");
|
|
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); }
|
|
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; }
|
|
13
21
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
22
|
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) { (0, _defineProperty2.default)(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; }
|
|
15
23
|
var handles = {
|
|
@@ -24,7 +32,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
24
32
|
editorView = _ref.editorView,
|
|
25
33
|
getPos = _ref.getPos,
|
|
26
34
|
node = _ref.node,
|
|
27
|
-
tableRef = _ref.tableRef
|
|
35
|
+
tableRef = _ref.tableRef,
|
|
36
|
+
displayGuideline = _ref.displayGuideline;
|
|
28
37
|
var currentColumnCount = (0, _utils.getColgroupChildrenLength)(node);
|
|
29
38
|
var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * _utils.COLUMN_MIN_WIDTH : 3 * _utils.COLUMN_MIN_WIDTH;
|
|
30
39
|
var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
|
|
@@ -42,15 +51,60 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
42
51
|
} else if (tableHeight && tableHeight >= 96) {
|
|
43
52
|
handleHeightSize = 'large';
|
|
44
53
|
}
|
|
54
|
+
var currentGap = (0, _react.useRef)(0);
|
|
55
|
+
var _useState = (0, _react.useState)(false),
|
|
56
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
57
|
+
snappingEnabled = _useState2[0],
|
|
58
|
+
setSnappingEnabled = _useState2[1];
|
|
59
|
+
var updateActiveGuidelines = (0, _react.useCallback)(function (_ref2) {
|
|
60
|
+
var gap = _ref2.gap,
|
|
61
|
+
keys = _ref2.keys;
|
|
62
|
+
if (gap !== currentGap.current) {
|
|
63
|
+
currentGap.current = gap;
|
|
64
|
+
displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _consts.TABLE_SNAP_GAP, keys, _guidelines.defaultGuidelines));
|
|
65
|
+
}
|
|
66
|
+
}, [displayGuideline]);
|
|
67
|
+
var guidelineSnaps = (0, _react.useMemo)(function () {
|
|
68
|
+
return snappingEnabled ? {
|
|
69
|
+
x: _guidelines.defaultGuidelineWidths
|
|
70
|
+
} : undefined;
|
|
71
|
+
}, [snappingEnabled]);
|
|
72
|
+
var handleResizeStart = (0, _react.useCallback)(function () {
|
|
73
|
+
setSnappingEnabled(displayGuideline(_guidelines.defaultGuidelines));
|
|
74
|
+
return width;
|
|
75
|
+
}, [width, displayGuideline]);
|
|
76
|
+
var handleResizeStop = (0, _react.useCallback)(function (originalState, delta) {
|
|
77
|
+
var newWidth = originalState.width + delta.width;
|
|
78
|
+
var state = editorView.state,
|
|
79
|
+
dispatch = editorView.dispatch;
|
|
80
|
+
var pos = getPos();
|
|
81
|
+
if (typeof pos !== 'number') {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
85
|
+
width: newWidth
|
|
86
|
+
}));
|
|
87
|
+
var newNode = tr.doc.nodeAt(pos);
|
|
88
|
+
tr = (0, _utils.scaleTable)(tableRef, {
|
|
89
|
+
node: newNode,
|
|
90
|
+
prevNode: node,
|
|
91
|
+
start: pos + 1,
|
|
92
|
+
parentWidth: newWidth
|
|
93
|
+
}, editorView.domAtPos.bind(editorView))(tr);
|
|
94
|
+
dispatch(tr);
|
|
95
|
+
|
|
96
|
+
// Hide guidelines when resizing stops
|
|
97
|
+
displayGuideline([]);
|
|
98
|
+
updateWidth(newWidth);
|
|
99
|
+
return newWidth;
|
|
100
|
+
}, [updateWidth, editorView, getPos, node, tableRef, displayGuideline]);
|
|
45
101
|
return /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
|
|
46
102
|
enable: handles,
|
|
47
103
|
width: width,
|
|
48
104
|
handleAlignmentMethod: "sticky",
|
|
49
105
|
handleHeightSize: handleHeightSize,
|
|
50
106
|
handleMarginTop: tableHandleMarginTop,
|
|
51
|
-
handleResizeStart:
|
|
52
|
-
return width;
|
|
53
|
-
},
|
|
107
|
+
handleResizeStart: handleResizeStart,
|
|
54
108
|
handleResize: (0, _rafSchd.default)(function (originalState, delta) {
|
|
55
109
|
var newWidth = originalState.width + delta.width;
|
|
56
110
|
var pos = getPos();
|
|
@@ -63,34 +117,16 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
63
117
|
start: pos + 1,
|
|
64
118
|
parentWidth: newWidth
|
|
65
119
|
}, editorView.domAtPos.bind(editorView));
|
|
120
|
+
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, _guidelines.defaultGuidelineWidths, _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP));
|
|
66
121
|
updateWidth(newWidth);
|
|
67
122
|
return newWidth;
|
|
68
123
|
}),
|
|
69
|
-
handleResizeStop:
|
|
70
|
-
var newWidth = originalState.width + delta.width;
|
|
71
|
-
var state = editorView.state,
|
|
72
|
-
dispatch = editorView.dispatch;
|
|
73
|
-
var pos = getPos();
|
|
74
|
-
if (typeof pos !== 'number') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
78
|
-
width: newWidth
|
|
79
|
-
}));
|
|
80
|
-
var newNode = tr.doc.nodeAt(pos);
|
|
81
|
-
tr = (0, _utils.scaleTable)(tableRef, {
|
|
82
|
-
node: newNode,
|
|
83
|
-
prevNode: node,
|
|
84
|
-
start: pos + 1,
|
|
85
|
-
parentWidth: newWidth
|
|
86
|
-
}, editorView.domAtPos.bind(editorView))(tr);
|
|
87
|
-
dispatch(tr);
|
|
88
|
-
updateWidth(newWidth);
|
|
89
|
-
return newWidth;
|
|
90
|
-
},
|
|
124
|
+
handleResizeStop: handleResizeStop,
|
|
91
125
|
resizeRatio: 2,
|
|
92
126
|
minWidth: minColumnWidth,
|
|
93
|
-
maxWidth: maxWidth
|
|
127
|
+
maxWidth: maxWidth,
|
|
128
|
+
snapGap: _consts.TABLE_SNAP_GAP,
|
|
129
|
+
snap: guidelineSnaps
|
|
94
130
|
}, children);
|
|
95
131
|
};
|
|
96
132
|
exports.TableResizer = TableResizer;
|
|
@@ -140,7 +140,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
140
140
|
getNode: _this3.getNode,
|
|
141
141
|
containerWidth: containerWidth,
|
|
142
142
|
contentDOM: forwardRef,
|
|
143
|
-
getEditorFeatureFlags: props.getEditorFeatureFlags
|
|
143
|
+
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
144
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
144
145
|
});
|
|
145
146
|
}
|
|
146
147
|
});
|
|
@@ -209,7 +210,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
209
210
|
return TableView;
|
|
210
211
|
}(_reactNodeView.default);
|
|
211
212
|
exports.default = TableView;
|
|
212
|
-
var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags) {
|
|
213
|
+
var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
|
|
213
214
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
214
215
|
pluginConfig = _getPluginState2.pluginConfig;
|
|
215
216
|
var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
|
|
@@ -228,7 +229,8 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
|
|
|
228
229
|
tableRenderOptimization: tableRenderOptimization,
|
|
229
230
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
230
231
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
231
|
-
hasIntlContext: hasIntlContext
|
|
232
|
+
hasIntlContext: hasIntlContext,
|
|
233
|
+
pluginInjectionApi: pluginInjectionApi
|
|
232
234
|
}).init();
|
|
233
235
|
};
|
|
234
236
|
exports.createTableView = createTableView;
|
|
@@ -9,6 +9,8 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
9
9
|
var _types = require("../../../types");
|
|
10
10
|
var _decoration = require("../../../utils/decoration");
|
|
11
11
|
var _composeDecorations = require("./compose-decorations");
|
|
12
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
13
|
+
|
|
12
14
|
var isColumnSelected = function isColumnSelected(tr) {
|
|
13
15
|
return tr.selection instanceof _cellSelection.CellSelection && tr.selection.isColSelection();
|
|
14
16
|
};
|
|
@@ -31,7 +31,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
31
31
|
var isBreakoutEnabled;
|
|
32
32
|
var isFullWidthModeEnabled;
|
|
33
33
|
var wasFullWidthModeEnabled;
|
|
34
|
-
var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
34
|
+
var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
35
35
|
var _window;
|
|
36
36
|
isBreakoutEnabled = breakoutEnabled;
|
|
37
37
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
@@ -236,7 +236,7 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
|
|
|
236
236
|
isBreakoutEnabled: isBreakoutEnabled,
|
|
237
237
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
238
238
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled
|
|
239
|
-
}, getEditorContainerWidth, getEditorFeatureFlags);
|
|
239
|
+
}, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
240
240
|
}
|
|
241
241
|
}),
|
|
242
242
|
handleDOMEvents: {
|
|
@@ -10,7 +10,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
10
10
|
var _pluginKey = require("./plugin-key");
|
|
11
11
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
12
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
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) { (0, _defineProperty2.default)(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; }
|
|
13
|
+
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) { (0, _defineProperty2.default)(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; } // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
14
14
|
function mapping(tr, pluginState) {
|
|
15
15
|
if (pluginState && pluginState.resizeHandlePos !== null) {
|
|
16
16
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePadding = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedColor = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = void 0;
|
|
6
|
+
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePadding = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedColor = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.TABLE_SNAP_GAP = exports.TABLE_HIGHLIGHT_GAP = void 0;
|
|
7
7
|
var _colors = require("@atlaskit/theme/colors");
|
|
8
8
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
9
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -104,4 +104,8 @@ exports.stickyRowZIndex = stickyRowZIndex;
|
|
|
104
104
|
var stickyRowOffsetTop = 8;
|
|
105
105
|
exports.stickyRowOffsetTop = stickyRowOffsetTop;
|
|
106
106
|
var stickyHeaderBorderBottomWidth = 1;
|
|
107
|
-
exports.stickyHeaderBorderBottomWidth = stickyHeaderBorderBottomWidth;
|
|
107
|
+
exports.stickyHeaderBorderBottomWidth = stickyHeaderBorderBottomWidth;
|
|
108
|
+
var TABLE_SNAP_GAP = 5;
|
|
109
|
+
exports.TABLE_SNAP_GAP = TABLE_SNAP_GAP;
|
|
110
|
+
var TABLE_HIGHLIGHT_GAP = 10;
|
|
111
|
+
exports.TABLE_HIGHLIGHT_GAP = TABLE_HIGHLIGHT_GAP;
|
|
@@ -7,6 +7,8 @@ exports.isTableCollapsible = exports.collapseSelectedTable = void 0;
|
|
|
7
7
|
var _prosemirrorModel = require("prosemirror-model");
|
|
8
8
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
9
9
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
10
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
11
|
+
|
|
10
12
|
var bail = function bail() {
|
|
11
13
|
return {
|
|
12
14
|
tableIsCollapsible: false
|
|
@@ -11,6 +11,8 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
11
11
|
var _prosemirrorView = require("prosemirror-view");
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _types = require("../types");
|
|
14
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
15
|
+
|
|
14
16
|
var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
|
|
15
17
|
return decorationSet.find(undefined, undefined, function (spec) {
|
|
16
18
|
return spec.key.indexOf(key) > -1;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultGuidelines = exports.defaultGuidelineWidths = void 0;
|
|
7
|
+
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
8
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
|
+
var defaultGuidelineWidths = [_editorSharedStyles.akEditorDefaultLayoutWidth, _editorSharedStyles.akEditorWideLayoutWidth, _editorSharedStyles.akEditorFullWidthLayoutWidth];
|
|
10
|
+
exports.defaultGuidelineWidths = defaultGuidelineWidths;
|
|
11
|
+
var defaultGuidelines = (0, _guideline.createFixedGuidelinesFromLengths)(defaultGuidelineWidths);
|
|
12
|
+
exports.defaultGuidelines = defaultGuidelines;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findClosestSnap = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
9
|
+
*/
|
|
10
|
+
var findClosestSnap = function findClosestSnap(currentWidth, snapWidths, guidelines) {
|
|
11
|
+
var snapGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
12
|
+
var closestGapIndex = snapWidths.reduce(function (prev, curr, index) {
|
|
13
|
+
return Math.abs(curr - currentWidth) < Math.abs(snapWidths[prev] - currentWidth) ? index : prev;
|
|
14
|
+
}, 0);
|
|
15
|
+
var gap = Math.abs(snapWidths[closestGapIndex] - currentWidth);
|
|
16
|
+
if (gap < snapGap) {
|
|
17
|
+
var snappingWidth = Math.round(snapWidths[closestGapIndex]);
|
|
18
|
+
var guidelineKeys = guidelines.reduce(function (acc, guideline) {
|
|
19
|
+
// NOTE: The snap points are based on the guidelines, however their formatted as a length value whereas the guidelines
|
|
20
|
+
// are point based. The point base x coords are calculated by halving the lengths. This means we can convert the
|
|
21
|
+
// point base position to length by simply multiplying by 2.
|
|
22
|
+
if (Math.round(Math.abs(guideline.position.x) * 2) === snappingWidth) {
|
|
23
|
+
acc.push(guideline.key);
|
|
24
|
+
}
|
|
25
|
+
return acc;
|
|
26
|
+
}, []);
|
|
27
|
+
return {
|
|
28
|
+
gap: gap,
|
|
29
|
+
keys: guidelineKeys
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
gap: gap,
|
|
34
|
+
keys: []
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.findClosestSnap = findClosestSnap;
|
package/dist/cjs/version.json
CHANGED
|
@@ -94,7 +94,7 @@ const tablesPlugin = (options, api) => {
|
|
|
94
94
|
tableOptions,
|
|
95
95
|
getEditorFeatureFlags
|
|
96
96
|
} = options || {};
|
|
97
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
97
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
98
98
|
}
|
|
99
99
|
}, {
|
|
100
100
|
name: 'tablePMColResizing',
|
|
@@ -384,7 +384,8 @@ class TableComponent extends React.Component {
|
|
|
384
384
|
tableActive,
|
|
385
385
|
containerWidth,
|
|
386
386
|
options,
|
|
387
|
-
getPos
|
|
387
|
+
getPos,
|
|
388
|
+
pluginInjectionApi
|
|
388
389
|
} = this.props;
|
|
389
390
|
const {
|
|
390
391
|
isLoading,
|
|
@@ -452,7 +453,8 @@ class TableComponent extends React.Component {
|
|
|
452
453
|
containerWidth: containerWidth,
|
|
453
454
|
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.isFullWidthModeEnabled,
|
|
454
455
|
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
455
|
-
isNested: isNested
|
|
456
|
+
isNested: isNested,
|
|
457
|
+
pluginInjectionApi: pluginInjectionApi
|
|
456
458
|
}, stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
|
|
457
459
|
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
458
460
|
"data-testid": "sticky-sentinel-top"
|