@atlaskit/editor-common 75.8.4 → 76.1.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 +20 -0
- package/dist/cjs/element-browser/constants.js +1 -1
- package/dist/cjs/floating-toolbar/index.js +111 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/resizer/Resizer.js +37 -71
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/element-browser/constants.js +1 -1
- package/dist/es2019/floating-toolbar/index.js +86 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/resizer/Resizer.js +49 -73
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/element-browser/constants.js +1 -1
- package/dist/esm/floating-toolbar/index.js +101 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/resizer/Resizer.js +38 -72
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/floating-toolbar/index.d.ts +6 -0
- package/dist/types/provider-factory/types.d.ts +13 -13
- package/dist/types/resizer/Resizer.d.ts +38 -18
- package/dist/types/resizer/index.d.ts +1 -1
- package/dist/types/resizer/types.d.ts +1 -1
- package/dist/types-ts4.5/floating-toolbar/index.d.ts +6 -0
- package/dist/types-ts4.5/provider-factory/types.d.ts +13 -13
- package/dist/types-ts4.5/resizer/Resizer.d.ts +38 -18
- package/dist/types-ts4.5/resizer/index.d.ts +1 -1
- package/dist/types-ts4.5/resizer/types.d.ts +1 -1
- package/floating-toolbar/package.json +15 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 76.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#40698](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40698) [`37b11d838e4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/37b11d838e4) - ED-20017 Decouple floating toolbar from editor-core
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#40700](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40700) [`07c8d720947`](https://bitbucket.org/atlassian/atlassian-frontend/commits/07c8d720947) - [ED-17196] Refactored editor internal abstraction
|
|
12
|
+
|
|
13
|
+
## 76.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- [`151b0d45db4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/151b0d45db4) - Changed Resizer API. Removed handleComponent, innerPadding & handleMarginTop. Also renamed HandleHeightSizeType to HandleSize. The resizer should be opionated and control the handle component itself. innerPadding & handleMarginTop can also be controlled via the handleStyles override property.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`6c7eda4573e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c7eda4573e) - ADFEXP-526: create a patch changeset for editor-common to try make Confluence Pipeline green
|
|
22
|
+
|
|
3
23
|
## 75.8.4
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -7,7 +7,7 @@ exports.SIDEBAR_WIDTH = exports.SIDEBAR_HEADING_WRAPPER_HEIGHT = exports.SIDEBAR
|
|
|
7
7
|
var _constants = require("@atlaskit/theme/constants");
|
|
8
8
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
9
9
|
|
|
10
|
-
// TODO: Migrate away from gridSize
|
|
10
|
+
// TODO: Migrate away from deprecated gridSize
|
|
11
11
|
// Recommendation: Replace gridSize with 8
|
|
12
12
|
var GRID_SIZE = (0, _constants.gridSize)();
|
|
13
13
|
exports.GRID_SIZE = GRID_SIZE;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shallowEqual = exports.isSameItem = exports.compareArrays = exports.areSameItems = void 0;
|
|
7
|
+
function makeSameType(_a, _b) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
var shallowEqual = function shallowEqual(objA, objB) {
|
|
11
|
+
if (objA === objB) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (objA == null || objB == null) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
var keysA = Object.keys(objA);
|
|
18
|
+
var keysB = Object.keys(objB);
|
|
19
|
+
if (keysA.length !== keysB.length) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
23
|
+
for (var idx = 0; idx < keysA.length; idx++) {
|
|
24
|
+
var key = keysA[idx];
|
|
25
|
+
if (!bHasOwnProperty(key)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (objA[key] !== objB[key]) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
exports.shallowEqual = shallowEqual;
|
|
35
|
+
var compareArrays = function compareArrays(left, right) {
|
|
36
|
+
var compareFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : shallowEqual;
|
|
37
|
+
if (left.length !== right.length) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
for (var idx = 0; idx < left.length; idx++) {
|
|
41
|
+
if (!compareFn(left[idx], right[idx])) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
exports.compareArrays = compareArrays;
|
|
48
|
+
var compareItemWithKeys = function compareItemWithKeys(leftItem, rightItem) {
|
|
49
|
+
var excludedKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
50
|
+
return Object.keys(leftItem).filter(function (key) {
|
|
51
|
+
return excludedKeys.indexOf(key) === -1;
|
|
52
|
+
}).every(function (key) {
|
|
53
|
+
return leftItem[key] instanceof Object ? shallowEqual(leftItem[key], rightItem[key]) : leftItem[key] === rightItem[key];
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var isSameItem = function isSameItem(leftItem, rightItem) {
|
|
57
|
+
if (leftItem.type !== rightItem.type) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
switch (leftItem.type) {
|
|
61
|
+
case 'button':
|
|
62
|
+
// Need to typecast `rightItem as typeof leftItem` otherwise we will
|
|
63
|
+
// have to put the `type !==` inside each case.
|
|
64
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'onClick', 'onMouseEnter', 'onMouseLeave']);
|
|
65
|
+
case 'copy-button':
|
|
66
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'items']);
|
|
67
|
+
case 'input':
|
|
68
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'onSubmit', 'onBlur']);
|
|
69
|
+
case 'select':
|
|
70
|
+
if (makeSameType(leftItem, rightItem) && Array.isArray(leftItem.options) && Array.isArray(rightItem.options) && !compareArrays(leftItem.options, rightItem.options, function (left, right) {
|
|
71
|
+
return compareItemWithKeys(left, right);
|
|
72
|
+
})) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'onChange', 'options']);
|
|
76
|
+
case 'dropdown':
|
|
77
|
+
if (makeSameType(leftItem, rightItem) && Array.isArray(leftItem.options) && Array.isArray(rightItem.options) &&
|
|
78
|
+
// @ts-expect-error TS2345: Argument of type 'DropdownOptionT<Function>[]' is not assignable to parameter of type 'any[][]'
|
|
79
|
+
!compareArrays(leftItem.options, rightItem.options, function (left, right) {
|
|
80
|
+
return (
|
|
81
|
+
// @ts-expect-error TS2322: Type '"onClick"' is not assignable to type 'keyof any[]'
|
|
82
|
+
compareItemWithKeys(left, right, ['onClick'])
|
|
83
|
+
);
|
|
84
|
+
})) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'options']);
|
|
88
|
+
case 'custom':
|
|
89
|
+
return false;
|
|
90
|
+
case 'separator':
|
|
91
|
+
return compareItemWithKeys(leftItem, rightItem);
|
|
92
|
+
case 'extensions-placeholder':
|
|
93
|
+
return compareItemWithKeys(leftItem, rightItem);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
exports.isSameItem = isSameItem;
|
|
97
|
+
var areSameItems = function areSameItems(leftArr, rightArr) {
|
|
98
|
+
if (leftArr === undefined && rightArr === undefined) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (leftArr === undefined || rightArr === undefined) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (leftArr.length !== rightArr.length) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return leftArr.every(function (item, index) {
|
|
108
|
+
return isSameItem(rightArr[index], item);
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
exports.areSameItems = areSameItems;
|
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
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
17
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
18
18
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
19
|
-
var packageVersion = "
|
|
19
|
+
var packageVersion = "76.1.0";
|
|
20
20
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
21
21
|
// Remove URL as it has UGC
|
|
22
22
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -15,11 +15,12 @@ var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
|
15
15
|
var _reResizable = require("re-resizable");
|
|
16
16
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
17
17
|
var _resizer = require("../styles/shared/resizer");
|
|
18
|
-
var _excluded = ["width", "children", "handleClassName", "className", "handleResize", "handleResizeStart", "handleResizeStop", "
|
|
18
|
+
var _excluded = ["width", "children", "handleClassName", "className", "handleResize", "handleResizeStart", "handleResizeStop", "handleSize", "handleAlignmentMethod", "handlePositioning", "appearance", "handleStyles", "resizeRatio", "snap", "snapGap", "isHandleVisible", "handleHighlight", "handleTooltipContent"];
|
|
19
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
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
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
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; }
|
|
23
|
+
var SUPPORTED_HANDLES = ['left', 'right'];
|
|
23
24
|
function ResizerNext(props) {
|
|
24
25
|
var _useState = (0, _react.useState)(false),
|
|
25
26
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -33,8 +34,8 @@ function ResizerNext(props) {
|
|
|
33
34
|
handleResize = props.handleResize,
|
|
34
35
|
handleResizeStart = props.handleResizeStart,
|
|
35
36
|
handleResizeStop = props.handleResizeStop,
|
|
36
|
-
_props$
|
|
37
|
-
|
|
37
|
+
_props$handleSize = props.handleSize,
|
|
38
|
+
handleSize = _props$handleSize === void 0 ? 'medium' : _props$handleSize,
|
|
38
39
|
_props$handleAlignmen = props.handleAlignmentMethod,
|
|
39
40
|
handleAlignmentMethod = _props$handleAlignmen === void 0 ? 'center' : _props$handleAlignmen,
|
|
40
41
|
_props$handlePosition = props.handlePositioning,
|
|
@@ -43,24 +44,21 @@ function ResizerNext(props) {
|
|
|
43
44
|
handleStyles = props.handleStyles,
|
|
44
45
|
_props$resizeRatio = props.resizeRatio,
|
|
45
46
|
resizeRatio = _props$resizeRatio === void 0 ? 1 : _props$resizeRatio,
|
|
46
|
-
innerPadding = props.innerPadding,
|
|
47
47
|
snap = props.snap,
|
|
48
48
|
snapGap = props.snapGap,
|
|
49
|
-
handleMarginTop = props.handleMarginTop,
|
|
50
49
|
_props$isHandleVisibl = props.isHandleVisible,
|
|
51
50
|
isHandleVisible = _props$isHandleVisibl === void 0 ? false : _props$isHandleVisibl,
|
|
52
|
-
handleComponent = props.handleComponent,
|
|
53
51
|
_props$handleHighligh = props.handleHighlight,
|
|
54
52
|
handleHighlight = _props$handleHighligh === void 0 ? 'none' : _props$handleHighligh,
|
|
55
53
|
handleTooltipContent = props.handleTooltipContent,
|
|
56
54
|
otherProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
57
|
-
var onResizeStart = _react.
|
|
55
|
+
var onResizeStart = (0, _react.useCallback)(function (event) {
|
|
58
56
|
// prevent creating a drag event on Firefox
|
|
59
57
|
event.preventDefault();
|
|
60
58
|
setIsResizing(true);
|
|
61
59
|
handleResizeStart();
|
|
62
60
|
}, [handleResizeStart]);
|
|
63
|
-
var onResize = _react.
|
|
61
|
+
var onResize = (0, _react.useCallback)(function (_event, _direction, _elementRef, delta) {
|
|
64
62
|
var resizableCurrent = resizable.current;
|
|
65
63
|
if (!resizableCurrent || !resizableCurrent.state.original) {
|
|
66
64
|
return;
|
|
@@ -73,7 +71,7 @@ function ResizerNext(props) {
|
|
|
73
71
|
};
|
|
74
72
|
handleResize(originalState, delta);
|
|
75
73
|
}, [handleResize]);
|
|
76
|
-
var onResizeStop = _react.
|
|
74
|
+
var onResizeStop = (0, _react.useCallback)(function (_event, _direction, _elementRef, delta) {
|
|
77
75
|
var resizableCurrent = resizable.current;
|
|
78
76
|
if (!resizableCurrent || !resizableCurrent.state.original) {
|
|
79
77
|
return;
|
|
@@ -88,81 +86,49 @@ function ResizerNext(props) {
|
|
|
88
86
|
handleResizeStop(originalState, delta);
|
|
89
87
|
}, [handleResizeStop]);
|
|
90
88
|
var handles = {
|
|
91
|
-
left: (0, _classnames2.default)(handleClassName !== null && handleClassName !== void 0 ? handleClassName : _resizer.resizerHandleClassName, 'left',
|
|
92
|
-
right: (0, _classnames2.default)(handleClassName !== null && handleClassName !== void 0 ? handleClassName : _resizer.resizerHandleClassName, 'right',
|
|
89
|
+
left: (0, _classnames2.default)(handleClassName !== null && handleClassName !== void 0 ? handleClassName : _resizer.resizerHandleClassName, 'left', handleSize, handleAlignmentMethod),
|
|
90
|
+
right: (0, _classnames2.default)(handleClassName !== null && handleClassName !== void 0 ? handleClassName : _resizer.resizerHandleClassName, 'right', handleSize, handleAlignmentMethod)
|
|
93
91
|
};
|
|
94
92
|
var baseHandleStyles = {
|
|
95
93
|
width: handlePositioning === 'adjacent' ? "var(--ds-space-100, 8px)" : "var(--ds-space-300, 24px)",
|
|
96
|
-
// eslint-disable-next-line
|
|
97
|
-
marginTop: Number.isFinite(handleMarginTop) ? "".concat(handleMarginTop, "px") : undefined,
|
|
98
94
|
zIndex: _resizer.resizerHandleZIndex,
|
|
99
95
|
pointerEvents: 'auto',
|
|
100
96
|
alignItems: handlePositioning === 'adjacent' ? 'center' : undefined
|
|
101
97
|
};
|
|
102
|
-
var offset =
|
|
103
|
-
var nextHandleStyles = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
left: offset
|
|
107
|
-
}, handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles.left),
|
|
108
|
-
right: _objectSpread(_objectSpread({}, baseHandleStyles), {}, {
|
|
109
|
-
// eslint-disable-next-line
|
|
110
|
-
right: offset
|
|
111
|
-
}, handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles.right)
|
|
112
|
-
};
|
|
98
|
+
var offset = handlePositioning === 'adjacent' ? "calc(".concat(baseHandleStyles.width, " * -1)") : "calc(".concat(baseHandleStyles.width, " * -0.5)");
|
|
99
|
+
var nextHandleStyles = SUPPORTED_HANDLES.reduce(function (result, position) {
|
|
100
|
+
return _objectSpread(_objectSpread({}, result), {}, (0, _defineProperty2.default)({}, position, _objectSpread(_objectSpread({}, baseHandleStyles), {}, (0, _defineProperty2.default)({}, position, offset), handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles[position])));
|
|
101
|
+
}, {});
|
|
113
102
|
var resizerClassName = (0, _classnames2.default)(className, _resizer.resizerItemClassName, (0, _defineProperty2.default)({
|
|
114
103
|
'is-resizing': isResizing,
|
|
115
104
|
'display-handle': isHandleVisible
|
|
116
105
|
}, _resizer.resizerDangerClassName, appearance === 'danger'));
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
className: _resizer.resizerHandleThumbClassName
|
|
134
|
-
}),
|
|
135
|
-
right: handleComponent.right && /*#__PURE__*/_react.default.cloneElement(handleComponent.right, {
|
|
136
|
-
className: _resizer.resizerHandleThumbClassName
|
|
137
|
-
})
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
var children = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
-
className: (0, _classnames2.default)(_resizer.resizerHandleTrackClassName, handleHighlight)
|
|
142
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
143
|
-
className: _resizer.resizerHandleThumbClassName
|
|
144
|
-
}));
|
|
145
|
-
if (!!handleTooltipContent) {
|
|
146
|
-
return {
|
|
147
|
-
left: /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
106
|
+
var handleComponent = (0, _react.useMemo)(function () {
|
|
107
|
+
return SUPPORTED_HANDLES.reduce(function (result, position) {
|
|
108
|
+
var thumb = /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
className: _resizer.resizerHandleThumbClassName,
|
|
110
|
+
"data-testid": "resizer-handle-".concat(position, "-thumb"),
|
|
111
|
+
contentEditable: false
|
|
112
|
+
});
|
|
113
|
+
if ((!handleHighlight || handleHighlight === 'none') && !handleTooltipContent) {
|
|
114
|
+
return _objectSpread(_objectSpread({}, result), {}, (0, _defineProperty2.default)({}, position, thumb));
|
|
115
|
+
}
|
|
116
|
+
var thumbWithTrack = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
117
|
+
className: (0, _classnames2.default)(_resizer.resizerHandleTrackClassName, handleHighlight),
|
|
118
|
+
"data-testid": "resizer-handle-".concat(position, "-track")
|
|
119
|
+
}), thumb);
|
|
120
|
+
if (!!handleTooltipContent) {
|
|
121
|
+
return _objectSpread(_objectSpread({}, result), {}, (0, _defineProperty2.default)({}, position, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
148
122
|
content: handleTooltipContent,
|
|
149
123
|
hideTooltipOnClick: true,
|
|
150
124
|
position: "mouse",
|
|
151
|
-
mousePosition: "auto-start"
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}, children)
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
left: children,
|
|
163
|
-
right: children
|
|
164
|
-
};
|
|
165
|
-
}, [handleHighlight, handleTooltipContent, handleComponent]);
|
|
125
|
+
mousePosition: "auto-start",
|
|
126
|
+
testId: "resizer-handle-".concat(position, "-tooltip")
|
|
127
|
+
}, thumbWithTrack)));
|
|
128
|
+
}
|
|
129
|
+
return _objectSpread(_objectSpread({}, result), {}, (0, _defineProperty2.default)({}, position, thumbWithTrack));
|
|
130
|
+
}, {});
|
|
131
|
+
}, [handleHighlight, handleTooltipContent]);
|
|
166
132
|
|
|
167
133
|
// snapGap is usually a constant, if snap.x?.length is 0 and snapGap has a value resizer cannot be resized
|
|
168
134
|
var snapGapActual = (0, _react.useMemo)(function () {
|
|
@@ -189,7 +155,7 @@ function ResizerNext(props) {
|
|
|
189
155
|
resizeRatio: resizeRatio,
|
|
190
156
|
snapGap: snapGapActual,
|
|
191
157
|
snap: snap,
|
|
192
|
-
handleComponent:
|
|
158
|
+
handleComponent: handleComponent
|
|
193
159
|
}, otherProps), /*#__PURE__*/_react.default.createElement("span", {
|
|
194
160
|
className: _resizer.resizerHoverZoneClassName
|
|
195
161
|
}, children));
|
|
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
24
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
25
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "
|
|
27
|
+
var packageVersion = "76.1.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
2
2
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
-
// TODO: Migrate away from gridSize
|
|
3
|
+
// TODO: Migrate away from deprecated gridSize
|
|
4
4
|
// Recommendation: Replace gridSize with 8
|
|
5
5
|
export const GRID_SIZE = gridSize();
|
|
6
6
|
export const DEVICE_BREAKPOINT_NUMBERS = {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function makeSameType(_a, _b) {
|
|
2
|
+
return true;
|
|
3
|
+
}
|
|
4
|
+
export const shallowEqual = (objA, objB) => {
|
|
5
|
+
if (objA === objB) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (objA == null || objB == null) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const keysA = Object.keys(objA);
|
|
12
|
+
const keysB = Object.keys(objB);
|
|
13
|
+
if (keysA.length !== keysB.length) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
17
|
+
for (let idx = 0; idx < keysA.length; idx++) {
|
|
18
|
+
const key = keysA[idx];
|
|
19
|
+
if (!bHasOwnProperty(key)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (objA[key] !== objB[key]) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
export const compareArrays = (left, right, compareFn = shallowEqual) => {
|
|
29
|
+
if (left.length !== right.length) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
for (let idx = 0; idx < left.length; idx++) {
|
|
33
|
+
if (!compareFn(left[idx], right[idx])) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
const compareItemWithKeys = (leftItem, rightItem, excludedKeys = []) => Object.keys(leftItem).filter(key => excludedKeys.indexOf(key) === -1).every(key => leftItem[key] instanceof Object ? shallowEqual(leftItem[key], rightItem[key]) : leftItem[key] === rightItem[key]);
|
|
40
|
+
export const isSameItem = (leftItem, rightItem) => {
|
|
41
|
+
if (leftItem.type !== rightItem.type) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
switch (leftItem.type) {
|
|
45
|
+
case 'button':
|
|
46
|
+
// Need to typecast `rightItem as typeof leftItem` otherwise we will
|
|
47
|
+
// have to put the `type !==` inside each case.
|
|
48
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'onClick', 'onMouseEnter', 'onMouseLeave']);
|
|
49
|
+
case 'copy-button':
|
|
50
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'items']);
|
|
51
|
+
case 'input':
|
|
52
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'onSubmit', 'onBlur']);
|
|
53
|
+
case 'select':
|
|
54
|
+
if (makeSameType(leftItem, rightItem) && Array.isArray(leftItem.options) && Array.isArray(rightItem.options) && !compareArrays(leftItem.options, rightItem.options, (left, right) => compareItemWithKeys(left, right))) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'onChange', 'options']);
|
|
58
|
+
case 'dropdown':
|
|
59
|
+
if (makeSameType(leftItem, rightItem) && Array.isArray(leftItem.options) && Array.isArray(rightItem.options) &&
|
|
60
|
+
// @ts-expect-error TS2345: Argument of type 'DropdownOptionT<Function>[]' is not assignable to parameter of type 'any[][]'
|
|
61
|
+
!compareArrays(leftItem.options, rightItem.options, (left, right) =>
|
|
62
|
+
// @ts-expect-error TS2322: Type '"onClick"' is not assignable to type 'keyof any[]'
|
|
63
|
+
compareItemWithKeys(left, right, ['onClick']))) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return compareItemWithKeys(leftItem, rightItem, ['type', 'options']);
|
|
67
|
+
case 'custom':
|
|
68
|
+
return false;
|
|
69
|
+
case 'separator':
|
|
70
|
+
return compareItemWithKeys(leftItem, rightItem);
|
|
71
|
+
case 'extensions-placeholder':
|
|
72
|
+
return compareItemWithKeys(leftItem, rightItem);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export const areSameItems = (leftArr, rightArr) => {
|
|
76
|
+
if (leftArr === undefined && rightArr === undefined) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (leftArr === undefined || rightArr === undefined) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (leftArr.length !== rightArr.length) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return leftArr.every((item, index) => isSameItem(rightArr[index], item));
|
|
86
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "
|
|
3
|
+
const packageVersion = "76.1.0";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { Resizable } from 're-resizable';
|
|
5
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
6
6
|
import { handleWrapperClass, resizerDangerClassName, resizerHandleClassName, resizerHandleThumbClassName, resizerHandleTrackClassName, resizerHandleZIndex, resizerHoverZoneClassName, resizerItemClassName } from '../styles/shared/resizer';
|
|
7
|
+
const SUPPORTED_HANDLES = ['left', 'right'];
|
|
7
8
|
export default function ResizerNext(props) {
|
|
8
9
|
const [isResizing, setIsResizing] = useState(false);
|
|
9
10
|
const resizable = useRef(null);
|
|
@@ -15,29 +16,26 @@ export default function ResizerNext(props) {
|
|
|
15
16
|
handleResize,
|
|
16
17
|
handleResizeStart,
|
|
17
18
|
handleResizeStop,
|
|
18
|
-
|
|
19
|
+
handleSize = 'medium',
|
|
19
20
|
handleAlignmentMethod = 'center',
|
|
20
21
|
handlePositioning = 'overlap',
|
|
21
22
|
appearance,
|
|
22
23
|
handleStyles,
|
|
23
24
|
resizeRatio = 1,
|
|
24
|
-
innerPadding,
|
|
25
25
|
snap,
|
|
26
26
|
snapGap,
|
|
27
|
-
handleMarginTop,
|
|
28
27
|
isHandleVisible = false,
|
|
29
|
-
handleComponent,
|
|
30
28
|
handleHighlight = 'none',
|
|
31
29
|
handleTooltipContent,
|
|
32
30
|
...otherProps
|
|
33
31
|
} = props;
|
|
34
|
-
const onResizeStart =
|
|
32
|
+
const onResizeStart = useCallback(event => {
|
|
35
33
|
// prevent creating a drag event on Firefox
|
|
36
34
|
event.preventDefault();
|
|
37
35
|
setIsResizing(true);
|
|
38
36
|
handleResizeStart();
|
|
39
37
|
}, [handleResizeStart]);
|
|
40
|
-
const onResize =
|
|
38
|
+
const onResize = useCallback((_event, _direction, _elementRef, delta) => {
|
|
41
39
|
const resizableCurrent = resizable.current;
|
|
42
40
|
if (!resizableCurrent || !resizableCurrent.state.original) {
|
|
43
41
|
return;
|
|
@@ -50,7 +48,7 @@ export default function ResizerNext(props) {
|
|
|
50
48
|
};
|
|
51
49
|
handleResize(originalState, delta);
|
|
52
50
|
}, [handleResize]);
|
|
53
|
-
const onResizeStop =
|
|
51
|
+
const onResizeStop = useCallback((_event, _direction, _elementRef, delta) => {
|
|
54
52
|
const resizableCurrent = resizable.current;
|
|
55
53
|
if (!resizableCurrent || !resizableCurrent.state.original) {
|
|
56
54
|
return;
|
|
@@ -65,86 +63,64 @@ export default function ResizerNext(props) {
|
|
|
65
63
|
handleResizeStop(originalState, delta);
|
|
66
64
|
}, [handleResizeStop]);
|
|
67
65
|
const handles = {
|
|
68
|
-
left: classnames(handleClassName !== null && handleClassName !== void 0 ? handleClassName : resizerHandleClassName, 'left',
|
|
69
|
-
right: classnames(handleClassName !== null && handleClassName !== void 0 ? handleClassName : resizerHandleClassName, 'right',
|
|
66
|
+
left: classnames(handleClassName !== null && handleClassName !== void 0 ? handleClassName : resizerHandleClassName, 'left', handleSize, handleAlignmentMethod),
|
|
67
|
+
right: classnames(handleClassName !== null && handleClassName !== void 0 ? handleClassName : resizerHandleClassName, 'right', handleSize, handleAlignmentMethod)
|
|
70
68
|
};
|
|
71
69
|
const baseHandleStyles = {
|
|
72
70
|
width: handlePositioning === 'adjacent' ? "var(--ds-space-100, 8px)" : "var(--ds-space-300, 24px)",
|
|
73
|
-
// eslint-disable-next-line
|
|
74
|
-
marginTop: Number.isFinite(handleMarginTop) ? `${handleMarginTop}px` : undefined,
|
|
75
71
|
zIndex: resizerHandleZIndex,
|
|
76
72
|
pointerEvents: 'auto',
|
|
77
73
|
alignItems: handlePositioning === 'adjacent' ? 'center' : undefined
|
|
78
74
|
};
|
|
79
|
-
const offset =
|
|
80
|
-
const nextHandleStyles = {
|
|
81
|
-
|
|
75
|
+
const offset = handlePositioning === 'adjacent' ? `calc(${baseHandleStyles.width} * -1)` : `calc(${baseHandleStyles.width} * -0.5)`;
|
|
76
|
+
const nextHandleStyles = SUPPORTED_HANDLES.reduce((result, position) => ({
|
|
77
|
+
...result,
|
|
78
|
+
[position]: {
|
|
82
79
|
...baseHandleStyles,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...(handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles.left)
|
|
86
|
-
},
|
|
87
|
-
right: {
|
|
88
|
-
...baseHandleStyles,
|
|
89
|
-
// eslint-disable-next-line
|
|
90
|
-
right: offset,
|
|
91
|
-
...(handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles.right)
|
|
80
|
+
[position]: offset,
|
|
81
|
+
...(handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles[position])
|
|
92
82
|
}
|
|
93
|
-
};
|
|
83
|
+
}), {});
|
|
94
84
|
const resizerClassName = classnames(className, resizerItemClassName, {
|
|
95
85
|
'is-resizing': isResizing,
|
|
96
86
|
'display-handle': isHandleVisible,
|
|
97
87
|
[resizerDangerClassName]: appearance === 'danger'
|
|
98
88
|
});
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
89
|
+
const handleComponent = useMemo(() => {
|
|
90
|
+
return SUPPORTED_HANDLES.reduce((result, position) => {
|
|
91
|
+
const thumb = /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: resizerHandleThumbClassName,
|
|
93
|
+
"data-testid": `resizer-handle-${position}-thumb`,
|
|
94
|
+
contentEditable: false
|
|
95
|
+
});
|
|
96
|
+
if ((!handleHighlight || handleHighlight === 'none') && !handleTooltipContent) {
|
|
97
|
+
return {
|
|
98
|
+
...result,
|
|
99
|
+
[position]: thumb
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const thumbWithTrack = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
className: classnames(resizerHandleTrackClassName, handleHighlight),
|
|
104
|
+
"data-testid": `resizer-handle-${position}-track`
|
|
105
|
+
}), thumb);
|
|
106
|
+
if (!!handleTooltipContent) {
|
|
107
|
+
return {
|
|
108
|
+
...result,
|
|
109
|
+
[position]: /*#__PURE__*/React.createElement(Tooltip, {
|
|
110
|
+
content: handleTooltipContent,
|
|
111
|
+
hideTooltipOnClick: true,
|
|
112
|
+
position: "mouse",
|
|
113
|
+
mousePosition: "auto-start",
|
|
114
|
+
testId: `resizer-handle-${position}-tooltip`
|
|
115
|
+
}, thumbWithTrack)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
128
118
|
return {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
hideTooltipOnClick: true,
|
|
132
|
-
position: "mouse",
|
|
133
|
-
mousePosition: "auto-start"
|
|
134
|
-
}, children),
|
|
135
|
-
right: /*#__PURE__*/React.createElement(Tooltip, {
|
|
136
|
-
content: handleTooltipContent,
|
|
137
|
-
hideTooltipOnClick: true,
|
|
138
|
-
position: "mouse",
|
|
139
|
-
mousePosition: "auto-start"
|
|
140
|
-
}, children)
|
|
119
|
+
...result,
|
|
120
|
+
[position]: thumbWithTrack
|
|
141
121
|
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
left: children,
|
|
145
|
-
right: children
|
|
146
|
-
};
|
|
147
|
-
}, [handleHighlight, handleTooltipContent, handleComponent]);
|
|
122
|
+
}, {});
|
|
123
|
+
}, [handleHighlight, handleTooltipContent]);
|
|
148
124
|
|
|
149
125
|
// snapGap is usually a constant, if snap.x?.length is 0 and snapGap has a value resizer cannot be resized
|
|
150
126
|
const snapGapActual = useMemo(() => {
|
|
@@ -171,7 +147,7 @@ export default function ResizerNext(props) {
|
|
|
171
147
|
resizeRatio: resizeRatio,
|
|
172
148
|
snapGap: snapGapActual,
|
|
173
149
|
snap: snap,
|
|
174
|
-
handleComponent:
|
|
150
|
+
handleComponent: handleComponent
|
|
175
151
|
}, otherProps), /*#__PURE__*/React.createElement("span", {
|
|
176
152
|
className: resizerHoverZoneClassName
|
|
177
153
|
}, children));
|