@atlaskit/editor-common 134.1.0 → 134.1.2
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 +19 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/registered-menu/reconcileRegisteredMenuSelection.js +27 -0
- package/dist/cjs/registered-menu/useRegisteredMenu.js +31 -8
- package/dist/cjs/registered-menu/useRegisteredMenuSelection.js +20 -7
- package/dist/cjs/table/SortingIcon.js +2 -8
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/registered-menu/reconcileRegisteredMenuSelection.js +22 -0
- package/dist/es2019/registered-menu/useRegisteredMenu.js +20 -8
- package/dist/es2019/registered-menu/useRegisteredMenuSelection.js +21 -6
- package/dist/es2019/table/SortingIcon.js +4 -7
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/registered-menu/reconcileRegisteredMenuSelection.js +21 -0
- package/dist/esm/registered-menu/useRegisteredMenu.js +31 -8
- package/dist/esm/registered-menu/useRegisteredMenuSelection.js +21 -8
- package/dist/esm/table/SortingIcon.js +2 -8
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/registered-menu/reconcileRegisteredMenuSelection.d.ts +7 -0
- package/dist/types/registered-menu/useRegisteredMenuSelection.d.ts +3 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 134.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9e0f075939161`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9e0f075939161) -
|
|
8
|
+
Deduplicate registered Quick Insert items across recommended, search, and browse views, while
|
|
9
|
+
preserving selection identity and registration context when `platform_editor_slash_command` is
|
|
10
|
+
enabled.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 134.1.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`ada3de6988596`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ada3de6988596) -
|
|
18
|
+
Clean up the shipped `confluence_live_doc_table_sort_bugfix` experiment: the renderer table sort
|
|
19
|
+
button now always sits above header content so its whole body is clickable in live docs.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 134.1.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -27,7 +27,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
27
27
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
28
28
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
29
29
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
30
|
-
var packageVersion = "134.
|
|
30
|
+
var packageVersion = "134.1.1";
|
|
31
31
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
32
32
|
// Remove URL as it has UGC
|
|
33
33
|
// Ignored via go/ees007
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reconcileRegisteredMenuSelection = void 0;
|
|
7
|
+
/** Keeps selection attached to the same registration when live menu updates reorder rows. */
|
|
8
|
+
var reconcileRegisteredMenuSelection = exports.reconcileRegisteredMenuSelection = function reconcileRegisteredMenuSelection(_ref) {
|
|
9
|
+
var nextIdentities = _ref.nextIdentities,
|
|
10
|
+
previousIdentities = _ref.previousIdentities,
|
|
11
|
+
previousIndex = _ref.previousIndex,
|
|
12
|
+
reset = _ref.reset;
|
|
13
|
+
if (nextIdentities.length === 0) {
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
if (reset) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
var previousIdentity = previousIdentities[previousIndex];
|
|
20
|
+
if (previousIdentity !== undefined) {
|
|
21
|
+
var nextIndex = nextIdentities.indexOf(previousIdentity);
|
|
22
|
+
if (nextIndex >= 0) {
|
|
23
|
+
return nextIndex;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Math.min(Math.max(previousIndex, 0), nextIdentities.length - 1);
|
|
27
|
+
};
|
|
@@ -6,10 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useRegisteredMenu = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
11
|
-
var _getRegisteredMenuRows = require("./getRegisteredMenuRows");
|
|
12
12
|
var _useRegisteredMenuSelection = require("./useRegisteredMenuSelection");
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
var getSelectableItemIdentity = function getSelectableItemIdentity(item, scope) {
|
|
15
|
+
return JSON.stringify([scope.type, scope.type === 'section' ? scope.sectionKey : undefined, (0, _surfaceRenderer.getComponentIdentity)(item)]);
|
|
16
|
+
};
|
|
13
17
|
/**
|
|
14
18
|
* Connects menu rows to keyboard selection and tracks which item is active through
|
|
15
19
|
* keyboard, pointer and focus events. Selection controls navigation; activation lets
|
|
@@ -20,18 +24,37 @@ var useRegisteredMenu = exports.useRegisteredMenu = function useRegisteredMenu(_
|
|
|
20
24
|
var model = _ref.model,
|
|
21
25
|
resetKey = _ref.resetKey;
|
|
22
26
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
23
|
-
var rows =
|
|
27
|
+
var rows = [];
|
|
24
28
|
var selectableItems = [];
|
|
25
29
|
var selectableItemIdentities = [];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
var appendItem = function appendItem(item, scope) {
|
|
31
|
+
rows.push(item);
|
|
32
|
+
selectableItems.push(item);
|
|
33
|
+
// A shared item key in another section is a different selection target.
|
|
34
|
+
selectableItemIdentities.push(getSelectableItemIdentity(item, scope));
|
|
35
|
+
};
|
|
36
|
+
model.sections.forEach(function (_ref2) {
|
|
37
|
+
var _ref3 = (0, _toArray2.default)(_ref2),
|
|
38
|
+
section = _ref3[0],
|
|
39
|
+
items = _arrayLikeToArray(_ref3).slice(1);
|
|
40
|
+
rows.push(section);
|
|
41
|
+
items.forEach(function (item) {
|
|
42
|
+
return appendItem(item, {
|
|
43
|
+
sectionKey: (0, _surfaceRenderer.getComponentIdentity)(section),
|
|
44
|
+
type: 'section'
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
model.fallbackItems.forEach(function (item) {
|
|
49
|
+
return appendItem(item, {
|
|
50
|
+
type: 'fallback'
|
|
51
|
+
});
|
|
31
52
|
});
|
|
32
53
|
// The footer participates in navigation but is rendered outside the scrolling rows.
|
|
33
54
|
if (model.footer) {
|
|
34
|
-
selectableItemIdentities.push((
|
|
55
|
+
selectableItemIdentities.push(getSelectableItemIdentity(model.footer, {
|
|
56
|
+
type: 'footer'
|
|
57
|
+
}));
|
|
35
58
|
}
|
|
36
59
|
return {
|
|
37
60
|
rows: rows,
|
|
@@ -7,9 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useRegisteredMenuSelection = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
+
var _reconcileRegisteredMenuSelection = require("./reconcileRegisteredMenuSelection");
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* Keeps selection on the same item as items reorder. If that item disappears,
|
|
13
|
+
* keeps the previous index within the remaining items. A changed reset key
|
|
14
|
+
* selects the first item instead.
|
|
13
15
|
*/
|
|
14
16
|
var useRegisteredMenuSelection = exports.useRegisteredMenuSelection = function useRegisteredMenuSelection(_ref) {
|
|
15
17
|
var identities = _ref.identities,
|
|
@@ -21,17 +23,28 @@ var useRegisteredMenuSelection = exports.useRegisteredMenuSelection = function u
|
|
|
21
23
|
selectedIndex = _useState2[0],
|
|
22
24
|
setSelectedIndex = _useState2[1];
|
|
23
25
|
var selectedIndexRef = (0, _react.useRef)(selectedIndex);
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
var previousRef = (0, _react.useRef)({
|
|
27
|
+
identities: identities,
|
|
28
|
+
resetKey: resetKey
|
|
29
|
+
});
|
|
27
30
|
var itemCount = identities.length;
|
|
28
31
|
var select = (0, _react.useCallback)(function (index) {
|
|
29
32
|
selectedIndexRef.current = index;
|
|
30
33
|
setSelectedIndex(index);
|
|
31
34
|
}, []);
|
|
32
35
|
(0, _react.useLayoutEffect)(function () {
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
var previous = previousRef.current;
|
|
37
|
+
previousRef.current = {
|
|
38
|
+
identities: identities,
|
|
39
|
+
resetKey: resetKey
|
|
40
|
+
};
|
|
41
|
+
select((0, _reconcileRegisteredMenuSelection.reconcileRegisteredMenuSelection)({
|
|
42
|
+
nextIdentities: identities,
|
|
43
|
+
previousIdentities: previous.identities,
|
|
44
|
+
previousIndex: selectedIndexRef.current,
|
|
45
|
+
reset: previous.resetKey !== resetKey
|
|
46
|
+
}));
|
|
47
|
+
}, [identities, resetKey, select]);
|
|
35
48
|
var selectNext = (0, _react.useCallback)(function () {
|
|
36
49
|
var currentIndex = selectedIndexRef.current;
|
|
37
50
|
var nextIndex = itemCount === 0 ? -1 : currentIndex < 0 ? 0 : (currentIndex + 1) % itemCount;
|
|
@@ -30,13 +30,7 @@ var _templateObject, _templateObject2;
|
|
|
30
30
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
31
31
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
32
32
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
33
|
-
var buttonStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\tposition: absolute;\n\tdisplay: flex;\n\theight: 28px;\n\twidth: 28px;\n\tmargin: ", ";\n\tright: 0;\n\ttop: 0;\n\tborder: ", " solid ", ";\n\tborder-radius: ", ";\n\tbackground-color: ", ";\n\tjustify-content: center;\n\talign-items: center;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: ", ";\n\t}\n\n\t&:active {\n\t\tbackground-color: ", ";\n\t}\n\n\t&.", "__not-allowed {\n\t\tcursor: not-allowed;\n\t}\n"])), "var(--ds-space-075, 6px)", "var(--ds-border-width-selected, 2px)", "var(--ds-border, #0B120E24)", "var(--ds-radius-small, 4px)", "var(--ds-surface-overlay, #FFFFFF)", "var(--ds-surface-overlay-hovered, #F0F1F2)", "var(--ds-surface-overlay-pressed, #DDDEE1)", _consts.SORTABLE_COLUMN_ICON_CLASSNAME);
|
|
34
|
-
|
|
35
|
-
// Keep the sort button above header content nodes that the editor's native-anchor DnD
|
|
36
|
-
// styles give a z-index in live docs, which otherwise cover the button's clickable body.
|
|
37
|
-
var sortButtonElevatedStyles = (0, _react.css)({
|
|
38
|
-
zIndex: 1
|
|
39
|
-
});
|
|
33
|
+
var buttonStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\tposition: absolute;\n\tdisplay: flex;\n\theight: 28px;\n\twidth: 28px;\n\tmargin: ", ";\n\tright: 0;\n\ttop: 0;\n\tborder: ", " solid ", ";\n\tborder-radius: ", ";\n\tbackground-color: ", ";\n\tjustify-content: center;\n\talign-items: center;\n\tcursor: pointer;\n\t/* Stay above header content nodes that the editor's native-anchor DnD styles give a\n\t z-index in live docs, which otherwise cover the button's clickable body. */\n\tz-index: 1;\n\n\t&:hover {\n\t\tbackground-color: ", ";\n\t}\n\n\t&:active {\n\t\tbackground-color: ", ";\n\t}\n\n\t&.", "__not-allowed {\n\t\tcursor: not-allowed;\n\t}\n"])), "var(--ds-space-075, 6px)", "var(--ds-border-width-selected, 2px)", "var(--ds-border, #0B120E24)", "var(--ds-radius-small, 4px)", "var(--ds-surface-overlay, #FFFFFF)", "var(--ds-surface-overlay-hovered, #F0F1F2)", "var(--ds-surface-overlay-pressed, #DDDEE1)", _consts.SORTABLE_COLUMN_ICON_CLASSNAME);
|
|
40
34
|
|
|
41
35
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
42
36
|
var iconWrapperStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n\twidth: 8px;\n\theight: 12px;\n\ttransition: transform 0.3s cubic-bezier(0.15, 1, 0.3, 1);\n\ttransform-origin: 50% 50%;\n\tdisplay: flex;\n\tjustify-content: center;\n\n\t&.", " {\n\t\ttransform: rotate(-180deg);\n\t}\n\n\t&.", "-inactive {\n\t\topacity: 0.7;\n\t}\n"])), _StatusClassNames.StatusClassNames.DESC, _consts.SORTABLE_COLUMN_ICON_CLASSNAME);
|
|
@@ -142,7 +136,7 @@ var SortingIcon = function SortingIcon(_ref) {
|
|
|
142
136
|
position: "top",
|
|
143
137
|
hasNewContentOnTriggerClick: true
|
|
144
138
|
}, (0, _react.jsx)("div", {
|
|
145
|
-
css:
|
|
139
|
+
css: buttonStyles
|
|
146
140
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
147
141
|
,
|
|
148
142
|
className: buttonClassName,
|
|
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
23
23
|
* @jsx jsx
|
|
24
24
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
25
|
var packageName = "@atlaskit/editor-common";
|
|
26
|
-
var packageVersion = "134.
|
|
26
|
+
var packageVersion = "134.1.1";
|
|
27
27
|
var halfFocusRing = 1;
|
|
28
28
|
var dropOffset = '0, 8';
|
|
29
29
|
// Ignored via go/ees005
|
|
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
13
13
|
const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
14
14
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
15
15
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
16
|
-
const packageVersion = "134.
|
|
16
|
+
const packageVersion = "134.1.1";
|
|
17
17
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
18
18
|
// Remove URL as it has UGC
|
|
19
19
|
// Ignored via go/ees007
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Keeps selection attached to the same registration when live menu updates reorder rows. */
|
|
2
|
+
export const reconcileRegisteredMenuSelection = ({
|
|
3
|
+
nextIdentities,
|
|
4
|
+
previousIdentities,
|
|
5
|
+
previousIndex,
|
|
6
|
+
reset
|
|
7
|
+
}) => {
|
|
8
|
+
if (nextIdentities.length === 0) {
|
|
9
|
+
return -1;
|
|
10
|
+
}
|
|
11
|
+
if (reset) {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
const previousIdentity = previousIdentities[previousIndex];
|
|
15
|
+
if (previousIdentity !== undefined) {
|
|
16
|
+
const nextIndex = nextIdentities.indexOf(previousIdentity);
|
|
17
|
+
if (nextIndex >= 0) {
|
|
18
|
+
return nextIndex;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return Math.min(Math.max(previousIndex, 0), nextIdentities.length - 1);
|
|
22
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { getComponentIdentity } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
3
|
-
import { getRegisteredMenuRows } from './getRegisteredMenuRows';
|
|
4
3
|
import { useRegisteredMenuSelection } from './useRegisteredMenuSelection';
|
|
4
|
+
const getSelectableItemIdentity = (item, scope) => JSON.stringify([scope.type, scope.type === 'section' ? scope.sectionKey : undefined, getComponentIdentity(item)]);
|
|
5
5
|
/**
|
|
6
6
|
* Connects menu rows to keyboard selection and tracks which item is active through
|
|
7
7
|
* keyboard, pointer and focus events. Selection controls navigation; activation lets
|
|
@@ -17,18 +17,30 @@ export const useRegisteredMenu = ({
|
|
|
17
17
|
selectableItems,
|
|
18
18
|
selectableItemIdentities
|
|
19
19
|
} = useMemo(() => {
|
|
20
|
-
const rows =
|
|
20
|
+
const rows = [];
|
|
21
21
|
const selectableItems = [];
|
|
22
22
|
const selectableItemIdentities = [];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const appendItem = (item, scope) => {
|
|
24
|
+
rows.push(item);
|
|
25
|
+
selectableItems.push(item);
|
|
26
|
+
// A shared item key in another section is a different selection target.
|
|
27
|
+
selectableItemIdentities.push(getSelectableItemIdentity(item, scope));
|
|
28
|
+
};
|
|
29
|
+
model.sections.forEach(([section, ...items]) => {
|
|
30
|
+
rows.push(section);
|
|
31
|
+
items.forEach(item => appendItem(item, {
|
|
32
|
+
sectionKey: getComponentIdentity(section),
|
|
33
|
+
type: 'section'
|
|
34
|
+
}));
|
|
28
35
|
});
|
|
36
|
+
model.fallbackItems.forEach(item => appendItem(item, {
|
|
37
|
+
type: 'fallback'
|
|
38
|
+
}));
|
|
29
39
|
// The footer participates in navigation but is rendered outside the scrolling rows.
|
|
30
40
|
if (model.footer) {
|
|
31
|
-
selectableItemIdentities.push(
|
|
41
|
+
selectableItemIdentities.push(getSelectableItemIdentity(model.footer, {
|
|
42
|
+
type: 'footer'
|
|
43
|
+
}));
|
|
32
44
|
}
|
|
33
45
|
return {
|
|
34
46
|
rows,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { useCallback, useLayoutEffect,
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { reconcileRegisteredMenuSelection } from './reconcileRegisteredMenuSelection';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Keeps selection on the same item as items reorder. If that item disappears,
|
|
5
|
+
* keeps the previous index within the remaining items. A changed reset key
|
|
6
|
+
* selects the first item instead.
|
|
5
7
|
*/
|
|
6
8
|
export const useRegisteredMenuSelection = ({
|
|
7
9
|
identities,
|
|
@@ -9,15 +11,28 @@ export const useRegisteredMenuSelection = ({
|
|
|
9
11
|
}) => {
|
|
10
12
|
const [selectedIndex, setSelectedIndex] = useState(() => identities.length > 0 ? 0 : -1);
|
|
11
13
|
const selectedIndexRef = useRef(selectedIndex);
|
|
12
|
-
const
|
|
14
|
+
const previousRef = useRef({
|
|
15
|
+
identities,
|
|
16
|
+
resetKey
|
|
17
|
+
});
|
|
13
18
|
const itemCount = identities.length;
|
|
14
19
|
const select = useCallback(index => {
|
|
15
20
|
selectedIndexRef.current = index;
|
|
16
21
|
setSelectedIndex(index);
|
|
17
22
|
}, []);
|
|
18
23
|
useLayoutEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
const previous = previousRef.current;
|
|
25
|
+
previousRef.current = {
|
|
26
|
+
identities,
|
|
27
|
+
resetKey
|
|
28
|
+
};
|
|
29
|
+
select(reconcileRegisteredMenuSelection({
|
|
30
|
+
nextIdentities: identities,
|
|
31
|
+
previousIdentities: previous.identities,
|
|
32
|
+
previousIndex: selectedIndexRef.current,
|
|
33
|
+
reset: previous.resetKey !== resetKey
|
|
34
|
+
}));
|
|
35
|
+
}, [identities, resetKey, select]);
|
|
21
36
|
const selectNext = useCallback(() => {
|
|
22
37
|
const currentIndex = selectedIndexRef.current;
|
|
23
38
|
const nextIndex = itemCount === 0 ? -1 : currentIndex < 0 ? 0 : (currentIndex + 1) % itemCount;
|
|
@@ -31,6 +31,9 @@ const buttonStyles = css`
|
|
|
31
31
|
justify-content: center;
|
|
32
32
|
align-items: center;
|
|
33
33
|
cursor: pointer;
|
|
34
|
+
/* Stay above header content nodes that the editor's native-anchor DnD styles give a
|
|
35
|
+
z-index in live docs, which otherwise cover the button's clickable body. */
|
|
36
|
+
z-index: 1;
|
|
34
37
|
|
|
35
38
|
&:hover {
|
|
36
39
|
background-color: ${"var(--ds-surface-overlay-hovered, #F0F1F2)"};
|
|
@@ -45,12 +48,6 @@ const buttonStyles = css`
|
|
|
45
48
|
}
|
|
46
49
|
`;
|
|
47
50
|
|
|
48
|
-
// Keep the sort button above header content nodes that the editor's native-anchor DnD
|
|
49
|
-
// styles give a z-index in live docs, which otherwise cover the button's clickable body.
|
|
50
|
-
const sortButtonElevatedStyles = css({
|
|
51
|
-
zIndex: 1
|
|
52
|
-
});
|
|
53
|
-
|
|
54
51
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
55
52
|
const iconWrapperStyles = css`
|
|
56
53
|
width: 8px;
|
|
@@ -175,7 +172,7 @@ const SortingIcon = ({
|
|
|
175
172
|
position: "top",
|
|
176
173
|
hasNewContentOnTriggerClick: true
|
|
177
174
|
}, jsx("div", {
|
|
178
|
-
css:
|
|
175
|
+
css: buttonStyles
|
|
179
176
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
180
177
|
,
|
|
181
178
|
className: buttonClassName,
|
|
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import Layer from '../Layer';
|
|
15
15
|
const packageName = "@atlaskit/editor-common";
|
|
16
|
-
const packageVersion = "134.
|
|
16
|
+
const packageVersion = "134.1.1";
|
|
17
17
|
const halfFocusRing = 1;
|
|
18
18
|
const dropOffset = '0, 8';
|
|
19
19
|
// Ignored via go/ees005
|
|
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
19
19
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
20
20
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
21
21
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
22
|
-
var packageVersion = "134.
|
|
22
|
+
var packageVersion = "134.1.1";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// Ignored via go/ees007
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Keeps selection attached to the same registration when live menu updates reorder rows. */
|
|
2
|
+
export var reconcileRegisteredMenuSelection = function reconcileRegisteredMenuSelection(_ref) {
|
|
3
|
+
var nextIdentities = _ref.nextIdentities,
|
|
4
|
+
previousIdentities = _ref.previousIdentities,
|
|
5
|
+
previousIndex = _ref.previousIndex,
|
|
6
|
+
reset = _ref.reset;
|
|
7
|
+
if (nextIdentities.length === 0) {
|
|
8
|
+
return -1;
|
|
9
|
+
}
|
|
10
|
+
if (reset) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
var previousIdentity = previousIdentities[previousIndex];
|
|
14
|
+
if (previousIdentity !== undefined) {
|
|
15
|
+
var nextIndex = nextIdentities.indexOf(previousIdentity);
|
|
16
|
+
if (nextIndex >= 0) {
|
|
17
|
+
return nextIndex;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return Math.min(Math.max(previousIndex, 0), nextIdentities.length - 1);
|
|
21
|
+
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _toArray from "@babel/runtime/helpers/toArray";
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2
4
|
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
|
3
5
|
import { getComponentIdentity } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
4
|
-
import { getRegisteredMenuRows } from './getRegisteredMenuRows';
|
|
5
6
|
import { useRegisteredMenuSelection } from './useRegisteredMenuSelection';
|
|
7
|
+
var getSelectableItemIdentity = function getSelectableItemIdentity(item, scope) {
|
|
8
|
+
return JSON.stringify([scope.type, scope.type === 'section' ? scope.sectionKey : undefined, getComponentIdentity(item)]);
|
|
9
|
+
};
|
|
6
10
|
/**
|
|
7
11
|
* Connects menu rows to keyboard selection and tracks which item is active through
|
|
8
12
|
* keyboard, pointer and focus events. Selection controls navigation; activation lets
|
|
@@ -13,18 +17,37 @@ export var useRegisteredMenu = function useRegisteredMenu(_ref) {
|
|
|
13
17
|
var model = _ref.model,
|
|
14
18
|
resetKey = _ref.resetKey;
|
|
15
19
|
var _useMemo = useMemo(function () {
|
|
16
|
-
var rows =
|
|
20
|
+
var rows = [];
|
|
17
21
|
var selectableItems = [];
|
|
18
22
|
var selectableItemIdentities = [];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
var appendItem = function appendItem(item, scope) {
|
|
24
|
+
rows.push(item);
|
|
25
|
+
selectableItems.push(item);
|
|
26
|
+
// A shared item key in another section is a different selection target.
|
|
27
|
+
selectableItemIdentities.push(getSelectableItemIdentity(item, scope));
|
|
28
|
+
};
|
|
29
|
+
model.sections.forEach(function (_ref2) {
|
|
30
|
+
var _ref3 = _toArray(_ref2),
|
|
31
|
+
section = _ref3[0],
|
|
32
|
+
items = _arrayLikeToArray(_ref3).slice(1);
|
|
33
|
+
rows.push(section);
|
|
34
|
+
items.forEach(function (item) {
|
|
35
|
+
return appendItem(item, {
|
|
36
|
+
sectionKey: getComponentIdentity(section),
|
|
37
|
+
type: 'section'
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
model.fallbackItems.forEach(function (item) {
|
|
42
|
+
return appendItem(item, {
|
|
43
|
+
type: 'fallback'
|
|
44
|
+
});
|
|
24
45
|
});
|
|
25
46
|
// The footer participates in navigation but is rendered outside the scrolling rows.
|
|
26
47
|
if (model.footer) {
|
|
27
|
-
selectableItemIdentities.push(
|
|
48
|
+
selectableItemIdentities.push(getSelectableItemIdentity(model.footer, {
|
|
49
|
+
type: 'footer'
|
|
50
|
+
}));
|
|
28
51
|
}
|
|
29
52
|
return {
|
|
30
53
|
rows: rows,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import { useCallback, useLayoutEffect,
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import { reconcileRegisteredMenuSelection } from './reconcileRegisteredMenuSelection';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Keeps selection on the same item as items reorder. If that item disappears,
|
|
6
|
+
* keeps the previous index within the remaining items. A changed reset key
|
|
7
|
+
* selects the first item instead.
|
|
6
8
|
*/
|
|
7
9
|
export var useRegisteredMenuSelection = function useRegisteredMenuSelection(_ref) {
|
|
8
10
|
var identities = _ref.identities,
|
|
@@ -14,17 +16,28 @@ export var useRegisteredMenuSelection = function useRegisteredMenuSelection(_ref
|
|
|
14
16
|
selectedIndex = _useState2[0],
|
|
15
17
|
setSelectedIndex = _useState2[1];
|
|
16
18
|
var selectedIndexRef = useRef(selectedIndex);
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
var previousRef = useRef({
|
|
20
|
+
identities: identities,
|
|
21
|
+
resetKey: resetKey
|
|
22
|
+
});
|
|
20
23
|
var itemCount = identities.length;
|
|
21
24
|
var select = useCallback(function (index) {
|
|
22
25
|
selectedIndexRef.current = index;
|
|
23
26
|
setSelectedIndex(index);
|
|
24
27
|
}, []);
|
|
25
28
|
useLayoutEffect(function () {
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
var previous = previousRef.current;
|
|
30
|
+
previousRef.current = {
|
|
31
|
+
identities: identities,
|
|
32
|
+
resetKey: resetKey
|
|
33
|
+
};
|
|
34
|
+
select(reconcileRegisteredMenuSelection({
|
|
35
|
+
nextIdentities: identities,
|
|
36
|
+
previousIdentities: previous.identities,
|
|
37
|
+
previousIndex: selectedIndexRef.current,
|
|
38
|
+
reset: previous.resetKey !== resetKey
|
|
39
|
+
}));
|
|
40
|
+
}, [identities, resetKey, select]);
|
|
28
41
|
var selectNext = useCallback(function () {
|
|
29
42
|
var currentIndex = selectedIndexRef.current;
|
|
30
43
|
var nextIndex = itemCount === 0 ? -1 : currentIndex < 0 ? 0 : (currentIndex + 1) % itemCount;
|
|
@@ -19,13 +19,7 @@ import { sortingIconMessages } from './sortingIconMessages';
|
|
|
19
19
|
import { StatusClassNames } from './StatusClassNames';
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
22
|
-
var buttonStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tposition: absolute;\n\tdisplay: flex;\n\theight: 28px;\n\twidth: 28px;\n\tmargin: ", ";\n\tright: 0;\n\ttop: 0;\n\tborder: ", " solid ", ";\n\tborder-radius: ", ";\n\tbackground-color: ", ";\n\tjustify-content: center;\n\talign-items: center;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: ", ";\n\t}\n\n\t&:active {\n\t\tbackground-color: ", ";\n\t}\n\n\t&.", "__not-allowed {\n\t\tcursor: not-allowed;\n\t}\n"])), "var(--ds-space-075, 6px)", "var(--ds-border-width-selected, 2px)", "var(--ds-border, #0B120E24)", "var(--ds-radius-small, 4px)", "var(--ds-surface-overlay, #FFFFFF)", "var(--ds-surface-overlay-hovered, #F0F1F2)", "var(--ds-surface-overlay-pressed, #DDDEE1)", SORTABLE_COLUMN_ICON_CLASSNAME);
|
|
23
|
-
|
|
24
|
-
// Keep the sort button above header content nodes that the editor's native-anchor DnD
|
|
25
|
-
// styles give a z-index in live docs, which otherwise cover the button's clickable body.
|
|
26
|
-
var sortButtonElevatedStyles = css({
|
|
27
|
-
zIndex: 1
|
|
28
|
-
});
|
|
22
|
+
var buttonStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tposition: absolute;\n\tdisplay: flex;\n\theight: 28px;\n\twidth: 28px;\n\tmargin: ", ";\n\tright: 0;\n\ttop: 0;\n\tborder: ", " solid ", ";\n\tborder-radius: ", ";\n\tbackground-color: ", ";\n\tjustify-content: center;\n\talign-items: center;\n\tcursor: pointer;\n\t/* Stay above header content nodes that the editor's native-anchor DnD styles give a\n\t z-index in live docs, which otherwise cover the button's clickable body. */\n\tz-index: 1;\n\n\t&:hover {\n\t\tbackground-color: ", ";\n\t}\n\n\t&:active {\n\t\tbackground-color: ", ";\n\t}\n\n\t&.", "__not-allowed {\n\t\tcursor: not-allowed;\n\t}\n"])), "var(--ds-space-075, 6px)", "var(--ds-border-width-selected, 2px)", "var(--ds-border, #0B120E24)", "var(--ds-radius-small, 4px)", "var(--ds-surface-overlay, #FFFFFF)", "var(--ds-surface-overlay-hovered, #F0F1F2)", "var(--ds-surface-overlay-pressed, #DDDEE1)", SORTABLE_COLUMN_ICON_CLASSNAME);
|
|
29
23
|
|
|
30
24
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
31
25
|
var iconWrapperStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n\twidth: 8px;\n\theight: 12px;\n\ttransition: transform 0.3s cubic-bezier(0.15, 1, 0.3, 1);\n\ttransform-origin: 50% 50%;\n\tdisplay: flex;\n\tjustify-content: center;\n\n\t&.", " {\n\t\ttransform: rotate(-180deg);\n\t}\n\n\t&.", "-inactive {\n\t\topacity: 0.7;\n\t}\n"])), StatusClassNames.DESC, SORTABLE_COLUMN_ICON_CLASSNAME);
|
|
@@ -131,7 +125,7 @@ var SortingIcon = function SortingIcon(_ref) {
|
|
|
131
125
|
position: "top",
|
|
132
126
|
hasNewContentOnTriggerClick: true
|
|
133
127
|
}, jsx("div", {
|
|
134
|
-
css:
|
|
128
|
+
css: buttonStyles
|
|
135
129
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
136
130
|
,
|
|
137
131
|
className: buttonClassName,
|
|
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
20
20
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
21
21
|
import Layer from '../Layer';
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "134.
|
|
23
|
+
var packageVersion = "134.1.1";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
// Ignored via go/ees005
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Keeps selection attached to the same registration when live menu updates reorder rows. */
|
|
2
|
+
export declare const reconcileRegisteredMenuSelection: ({ nextIdentities, previousIdentities, previousIndex, reset, }: {
|
|
3
|
+
nextIdentities: readonly string[];
|
|
4
|
+
previousIdentities: readonly string[];
|
|
5
|
+
previousIndex: number;
|
|
6
|
+
reset: boolean;
|
|
7
|
+
}) => number;
|
|
@@ -9,8 +9,9 @@ type RegisteredMenuSelectionState = {
|
|
|
9
9
|
selectPrevious: () => number;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Keeps selection on the same item as items reorder. If that item disappears,
|
|
13
|
+
* keeps the previous index within the remaining items. A changed reset key
|
|
14
|
+
* selects the first item instead.
|
|
14
15
|
*/
|
|
15
16
|
export declare const useRegisteredMenuSelection: ({ identities, resetKey, }: Options) => RegisteredMenuSelectionState;
|
|
16
17
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "134.1.
|
|
3
|
+
"version": "134.1.2",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@atlaskit/platform-feature-flags-react": "^1.2.0",
|
|
75
75
|
"@atlaskit/popper": "^9.4.0",
|
|
76
76
|
"@atlaskit/primitives": "^22.6.0",
|
|
77
|
-
"@atlaskit/profilecard": "^27.
|
|
77
|
+
"@atlaskit/profilecard": "^27.4.0",
|
|
78
78
|
"@atlaskit/prosemirror-history": "^1.3.0",
|
|
79
79
|
"@atlaskit/react-compiler-gating": "^0.2.0",
|
|
80
80
|
"@atlaskit/react-ufo": "^8.3.0",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"@atlaskit/spinner": "^20.4.0",
|
|
85
85
|
"@atlaskit/task-decision": "^21.13.0",
|
|
86
86
|
"@atlaskit/teams-app-config": "^3.1.0",
|
|
87
|
-
"@atlaskit/textfield": "^10.
|
|
88
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
87
|
+
"@atlaskit/textfield": "^10.3.0",
|
|
88
|
+
"@atlaskit/tmp-editor-statsig": "^248.0.0",
|
|
89
89
|
"@atlaskit/tokens": "^20.8.0",
|
|
90
90
|
"@atlaskit/tooltip": "^24.4.0",
|
|
91
91
|
"@atlaskit/width-detector": "^7.2.0",
|