@atlaskit/editor-common 70.3.0 → 71.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/dist/cjs/analytics/types/enums.js +1 -0
- package/dist/cjs/keymaps/index.js +5 -8
- package/dist/cjs/messages/insert-block.js +12 -7
- package/dist/cjs/panel.js +6 -0
- package/dist/cjs/styles/shared/code-block.js +5 -5
- package/dist/cjs/styles/shared/panel.js +54 -17
- package/dist/cjs/styles/shared/table.js +12 -7
- package/dist/cjs/styles/shared/text-color.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui-color/ColorPalette/Color/index.js +6 -2
- package/dist/cjs/ui-color/ColorPalette/index.js +21 -11
- package/dist/cjs/ui-menu/Dropdown/index.js +16 -2
- package/dist/cjs/ui-menu/DropdownMenu/index.js +27 -8
- package/dist/cjs/ui-menu/MenuArrowKeyNavigationProvider/index.js +162 -0
- package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +22 -13
- package/dist/cjs/utils/index.js +6 -0
- package/dist/cjs/utils/performance/measure-render.js +44 -23
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/types/enums.js +1 -0
- package/dist/es2019/keymaps/index.js +4 -6
- package/dist/es2019/messages/insert-block.js +12 -7
- package/dist/es2019/panel.js +1 -1
- package/dist/es2019/styles/shared/code-block.js +39 -25
- package/dist/es2019/styles/shared/panel.js +48 -18
- package/dist/es2019/styles/shared/table.js +24 -13
- package/dist/es2019/styles/shared/text-color.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui-color/ColorPalette/Color/index.js +6 -3
- package/dist/es2019/ui-color/ColorPalette/index.js +19 -11
- package/dist/es2019/ui-menu/Dropdown/index.js +13 -2
- package/dist/es2019/ui-menu/DropdownMenu/index.js +41 -6
- package/dist/es2019/ui-menu/MenuArrowKeyNavigationProvider/index.js +146 -0
- package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +20 -13
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/performance/measure-render.js +43 -23
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/types/enums.js +1 -0
- package/dist/esm/keymaps/index.js +3 -6
- package/dist/esm/messages/insert-block.js +12 -7
- package/dist/esm/panel.js +1 -1
- package/dist/esm/styles/shared/code-block.js +5 -5
- package/dist/esm/styles/shared/panel.js +49 -18
- package/dist/esm/styles/shared/table.js +12 -9
- package/dist/esm/styles/shared/text-color.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui-color/ColorPalette/Color/index.js +5 -2
- package/dist/esm/ui-color/ColorPalette/index.js +20 -11
- package/dist/esm/ui-menu/Dropdown/index.js +15 -2
- package/dist/esm/ui-menu/DropdownMenu/index.js +28 -9
- package/dist/esm/ui-menu/MenuArrowKeyNavigationProvider/index.js +147 -0
- package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +22 -13
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/performance/measure-render.js +42 -23
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/types/enums.d.ts +1 -0
- package/dist/types/analytics/types/general-events.d.ts +2 -1
- package/dist/types/keymaps/index.d.ts +0 -1
- package/dist/types/messages/insert-block.d.ts +7 -2
- package/dist/types/panel.d.ts +1 -1
- package/dist/types/styles/shared/code-block.d.ts +1 -0
- package/dist/types/styles/shared/panel.d.ts +1 -0
- package/dist/types/types/feature-flags.d.ts +27 -6
- package/dist/types/types/floating-toolbar.d.ts +4 -0
- package/dist/types/ui-color/ColorPalette/Color/index.d.ts +5 -0
- package/dist/types/ui-color/ColorPalette/index.d.ts +8 -0
- package/dist/types/ui-menu/Dropdown/index.d.ts +3 -0
- package/dist/types/ui-menu/DropdownMenu/index.d.ts +1 -0
- package/dist/types/ui-menu/DropdownMenu/types.d.ts +7 -0
- package/dist/types/ui-menu/MenuArrowKeyNavigationProvider/index.d.ts +15 -0
- package/dist/types/ui-react/with-react-editor-view-outer-listeners.d.ts +2 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/performance/measure-render.d.ts +12 -0
- package/package.json +8 -7
- package/report.api.md +12 -5
|
@@ -14,6 +14,7 @@ import React, { PureComponent } from 'react';
|
|
|
14
14
|
import { withReactEditorViewOuterListeners } from '../../ui-react';
|
|
15
15
|
import DropdownList from '../../ui/DropList';
|
|
16
16
|
import Popup from '../../ui/Popup';
|
|
17
|
+
import { MenuArrowKeyNavigationProvider } from '../MenuArrowKeyNavigationProvider';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Wrapper around @atlaskit/droplist which uses Popup and Portal to render
|
|
@@ -65,7 +66,9 @@ export var Dropdown = /*#__PURE__*/function (_PureComponent) {
|
|
|
65
66
|
onOpenChange = _this$props.onOpenChange,
|
|
66
67
|
fitHeight = _this$props.fitHeight,
|
|
67
68
|
fitWidth = _this$props.fitWidth,
|
|
68
|
-
zIndex = _this$props.zIndex
|
|
69
|
+
zIndex = _this$props.zIndex,
|
|
70
|
+
disableArrowKeyNavigation = _this$props.disableArrowKeyNavigation,
|
|
71
|
+
keyDownHandlerContext = _this$props.keyDownHandlerContext;
|
|
69
72
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
70
73
|
target: target,
|
|
71
74
|
mountTo: mountTo,
|
|
@@ -75,6 +78,16 @@ export var Dropdown = /*#__PURE__*/function (_PureComponent) {
|
|
|
75
78
|
fitHeight: fitHeight,
|
|
76
79
|
fitWidth: fitWidth,
|
|
77
80
|
zIndex: zIndex
|
|
81
|
+
}, /*#__PURE__*/React.createElement(MenuArrowKeyNavigationProvider, {
|
|
82
|
+
disableArrowKeyNavigation: disableArrowKeyNavigation,
|
|
83
|
+
keyDownHandlerContext: keyDownHandlerContext,
|
|
84
|
+
closeonTab: true,
|
|
85
|
+
handleClose: function handleClose(event) {
|
|
86
|
+
return onOpenChange && onOpenChange({
|
|
87
|
+
isOpen: false,
|
|
88
|
+
event: event
|
|
89
|
+
});
|
|
90
|
+
}
|
|
78
91
|
}, /*#__PURE__*/React.createElement("div", {
|
|
79
92
|
style: {
|
|
80
93
|
height: 0,
|
|
@@ -85,7 +98,7 @@ export var Dropdown = /*#__PURE__*/function (_PureComponent) {
|
|
|
85
98
|
onOpenChange: onOpenChange,
|
|
86
99
|
position: popupPlacement.join(' '),
|
|
87
100
|
shouldFitContainer: true
|
|
88
|
-
}, children)));
|
|
101
|
+
}, children))));
|
|
89
102
|
}
|
|
90
103
|
}, {
|
|
91
104
|
key: "render",
|
|
@@ -10,7 +10,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
10
10
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
11
11
|
var _excluded = ["children"];
|
|
12
12
|
|
|
13
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
13
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
14
14
|
|
|
15
15
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
16
|
|
|
@@ -21,14 +21,16 @@ import React, { PureComponent } from 'react';
|
|
|
21
21
|
import { css, jsx } from '@emotion/react';
|
|
22
22
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
23
23
|
import { CustomItem, MenuGroup } from '@atlaskit/menu';
|
|
24
|
-
import { DN600, DN80, N70, N900 } from '@atlaskit/theme/colors';
|
|
24
|
+
import { B100, DN600, DN80, N70, N900 } from '@atlaskit/theme/colors';
|
|
25
25
|
import { themed } from '@atlaskit/theme/components';
|
|
26
26
|
import { token } from '@atlaskit/tokens';
|
|
27
27
|
import Tooltip from '@atlaskit/tooltip';
|
|
28
28
|
import { withReactEditorViewOuterListeners } from '../../ui-react';
|
|
29
29
|
import DropList from '../../ui/DropList';
|
|
30
30
|
import Popup from '../../ui/Popup';
|
|
31
|
+
import { MenuArrowKeyNavigationProvider } from '../MenuArrowKeyNavigationProvider';
|
|
31
32
|
var wrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* tooltip in ToolbarButton is display:block */\n & > div > div {\n display: flex;\n }\n"])));
|
|
33
|
+
var focusedMenuItemStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n box-shadow: inset 0px 0px 0px 2px ", ";\n outline: none;\n"])), token('color.border.focused', B100));
|
|
32
34
|
|
|
33
35
|
var buttonStyles = function buttonStyles(isActive) {
|
|
34
36
|
return function (theme) {
|
|
@@ -36,9 +38,9 @@ var buttonStyles = function buttonStyles(isActive) {
|
|
|
36
38
|
/**
|
|
37
39
|
* Hack for item to imitate old dropdown-menu selected styles
|
|
38
40
|
*/
|
|
39
|
-
return css(
|
|
41
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n > span,\n > span:hover,\n > span:active {\n background: ", ";\n color: ", ";\n }\n :focus > span[aria-disabled='false'] {\n ", ";\n }\n :focus-visible,\n :focus-visible > span[aria-disabled='false'] {\n outline: none;\n }\n "])), token('color.background.selected', '#6c798f'), token('color.text', '#fff'), focusedMenuItemStyle);
|
|
40
42
|
} else {
|
|
41
|
-
return css(
|
|
43
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n > span:hover[aria-disabled='false'] {\n color: ", ";\n background-color: ", ";\n }\n > span:active[aria-disabled='false'] {\n background-color: ", ";\n }\n > span[aria-disabled='true'] {\n color: ", ";\n }\n :focus > span[aria-disabled='false'] {\n ", ";\n }\n :focus-visible,\n :focus-visible > span[aria-disabled='false'] {\n outline: none;\n }\n "])), themed({
|
|
42
44
|
light: token('color.text', N900),
|
|
43
45
|
dark: token('color.text', DN600)
|
|
44
46
|
})(theme), themed({
|
|
@@ -50,7 +52,7 @@ var buttonStyles = function buttonStyles(isActive) {
|
|
|
50
52
|
})(theme), themed({
|
|
51
53
|
light: token('color.text.disabled', N70),
|
|
52
54
|
dark: token('color.text.disabled', DN80)
|
|
53
|
-
})(theme));
|
|
55
|
+
})(theme), focusedMenuItemStyle); // The deafut focus-visible style is removed to ensure consistency across browsers
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
};
|
|
@@ -99,6 +101,14 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
|
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
|
|
104
|
+
_defineProperty(_assertThisInitialized(_this), "handleCloseandFocus", function () {
|
|
105
|
+
var _this$state$target, _this$state$target$qu;
|
|
106
|
+
|
|
107
|
+
_this.handleClose();
|
|
108
|
+
|
|
109
|
+
(_this$state$target = _this.state.target) === null || _this$state$target === void 0 ? void 0 : (_this$state$target$qu = _this$state$target.querySelector('button')) === null || _this$state$target$qu === void 0 ? void 0 : _this$state$target$qu.focus();
|
|
110
|
+
});
|
|
111
|
+
|
|
102
112
|
_defineProperty(_assertThisInitialized(_this), "handleClose", function () {
|
|
103
113
|
if (_this.props.onOpenChange) {
|
|
104
114
|
_this.props.onOpenChange({
|
|
@@ -128,7 +138,9 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
|
|
|
128
138
|
fitWidth = _this$props.fitWidth,
|
|
129
139
|
isOpen = _this$props.isOpen,
|
|
130
140
|
zIndex = _this$props.zIndex,
|
|
131
|
-
shouldUseDefaultRole = _this$props.shouldUseDefaultRole
|
|
141
|
+
shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
|
|
142
|
+
disableArrowKeyNavigation = _this$props.disableArrowKeyNavigation,
|
|
143
|
+
keyDownHandlerContext = _this$props.keyDownHandlerContext;
|
|
132
144
|
return jsx(Popup, {
|
|
133
145
|
target: isOpen ? target : undefined,
|
|
134
146
|
mountTo: mountTo,
|
|
@@ -139,6 +151,11 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
|
|
|
139
151
|
fitWidth: fitWidth,
|
|
140
152
|
zIndex: zIndex || akEditorFloatingPanelZIndex,
|
|
141
153
|
offset: offset
|
|
154
|
+
}, jsx(MenuArrowKeyNavigationProvider, {
|
|
155
|
+
disableArrowKeyNavigation: disableArrowKeyNavigation,
|
|
156
|
+
handleClose: this.handleCloseandFocus,
|
|
157
|
+
keyDownHandlerContext: keyDownHandlerContext,
|
|
158
|
+
closeonTab: true
|
|
142
159
|
}, jsx(DropListWithOutsideListeners, {
|
|
143
160
|
isOpen: true,
|
|
144
161
|
appearance: "tall",
|
|
@@ -147,7 +164,8 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
|
|
|
147
164
|
shouldFitContainer: true,
|
|
148
165
|
isTriggerNotTabbable: true,
|
|
149
166
|
handleClickOutside: this.handleClose,
|
|
150
|
-
handleEscapeKeydown: this.
|
|
167
|
+
handleEscapeKeydown: this.handleCloseandFocus,
|
|
168
|
+
targetRef: this.state.target
|
|
151
169
|
}, jsx("div", {
|
|
152
170
|
style: {
|
|
153
171
|
height: 0,
|
|
@@ -169,7 +187,7 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
|
|
|
169
187
|
onMouseLeave: _this2.props.onMouseLeave
|
|
170
188
|
});
|
|
171
189
|
}));
|
|
172
|
-
})));
|
|
190
|
+
}))));
|
|
173
191
|
}
|
|
174
192
|
}, {
|
|
175
193
|
key: "render",
|
|
@@ -220,7 +238,8 @@ function DropdownMenuItem(_ref) {
|
|
|
220
238
|
return buttonStyles(item.isActive)({
|
|
221
239
|
theme: theme
|
|
222
240
|
});
|
|
223
|
-
}
|
|
241
|
+
},
|
|
242
|
+
tabIndex: -1
|
|
224
243
|
}, jsx(CustomItem, {
|
|
225
244
|
item: item,
|
|
226
245
|
key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React, { useLayoutEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This component is a wrapper of vertical menus which listens to keydown events of children
|
|
5
|
+
* and handles up/down arrow key navigation
|
|
6
|
+
*/
|
|
7
|
+
export var MenuArrowKeyNavigationProvider = function MenuArrowKeyNavigationProvider(_ref) {
|
|
8
|
+
var children = _ref.children,
|
|
9
|
+
handleClose = _ref.handleClose,
|
|
10
|
+
disableArrowKeyNavigation = _ref.disableArrowKeyNavigation,
|
|
11
|
+
keyDownHandlerContext = _ref.keyDownHandlerContext,
|
|
12
|
+
closeonTab = _ref.closeonTab;
|
|
13
|
+
var wrapperRef = useRef(null);
|
|
14
|
+
var currentSelectedItemIndex = useRef(-1);
|
|
15
|
+
|
|
16
|
+
var incrementIndex = function incrementIndex(list) {
|
|
17
|
+
if (currentSelectedItemIndex.current === list.length - 1 || currentSelectedItemIndex.current === -1) {
|
|
18
|
+
currentSelectedItemIndex.current = 0;
|
|
19
|
+
} else {
|
|
20
|
+
currentSelectedItemIndex.current = currentSelectedItemIndex.current + 1;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var decrementIndex = function decrementIndex(list) {
|
|
25
|
+
if (currentSelectedItemIndex.current === 0 || currentSelectedItemIndex.current === -1) {
|
|
26
|
+
currentSelectedItemIndex.current = list.length - 1;
|
|
27
|
+
} else {
|
|
28
|
+
currentSelectedItemIndex.current = currentSelectedItemIndex.current - 1;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
useLayoutEffect(function () {
|
|
33
|
+
if (disableArrowKeyNavigation) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* To handle the key events on the list
|
|
38
|
+
* @param event
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
43
|
+
var _wrapperRef$current, _focusableElements$cu, _focusableElements$cu2;
|
|
44
|
+
|
|
45
|
+
var targetElement = event.target; //Tab key on menu items can be handled in the parent components of dropdown menus with KeydownHandlerContext
|
|
46
|
+
|
|
47
|
+
if (event.key === 'Tab' && closeonTab) {
|
|
48
|
+
handleClose(event);
|
|
49
|
+
keyDownHandlerContext === null || keyDownHandlerContext === void 0 ? void 0 : keyDownHandlerContext.handleTab();
|
|
50
|
+
return;
|
|
51
|
+
} //To trap the focus inside the toolbar using left and right arrow keys
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
var focusableElements = getEnabledElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
55
|
+
|
|
56
|
+
if (!focusableElements || (focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) === 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
|
|
61
|
+
currentSelectedItemIndex.current = -1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
switch (event.key) {
|
|
65
|
+
case 'ArrowDown':
|
|
66
|
+
//If ArrowDown pressed
|
|
67
|
+
//If on last item
|
|
68
|
+
// Focus last item
|
|
69
|
+
//Else
|
|
70
|
+
// Focus next item
|
|
71
|
+
incrementIndex(focusableElements);
|
|
72
|
+
(_focusableElements$cu = focusableElements[currentSelectedItemIndex.current]) === null || _focusableElements$cu === void 0 ? void 0 : _focusableElements$cu.focus();
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 'ArrowUp':
|
|
77
|
+
//ArrowUP pressed
|
|
78
|
+
//If on First item
|
|
79
|
+
// Focus last item
|
|
80
|
+
//Else
|
|
81
|
+
// Focus previous item
|
|
82
|
+
decrementIndex(focusableElements);
|
|
83
|
+
(_focusableElements$cu2 = focusableElements[currentSelectedItemIndex.current]) === null || _focusableElements$cu2 === void 0 ? void 0 : _focusableElements$cu2.focus();
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
break;
|
|
86
|
+
//ArrowLeft/Right on the menu should close the menus
|
|
87
|
+
//then logic to retain the focus can be handled in the parent components with KeydownHandlerContext
|
|
88
|
+
|
|
89
|
+
case 'ArrowLeft':
|
|
90
|
+
//Filter out the events from outside the menu
|
|
91
|
+
if (!targetElement.closest('.custom-key-handler-wrapper')) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
handleClose(event);
|
|
96
|
+
keyDownHandlerContext === null || keyDownHandlerContext === void 0 ? void 0 : keyDownHandlerContext.handleArrowLeft();
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case 'ArrowRight':
|
|
100
|
+
//Filter out the events from outside the menu
|
|
101
|
+
if (!targetElement.closest('.custom-key-handler-wrapper')) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
handleClose(event);
|
|
106
|
+
keyDownHandlerContext === null || keyDownHandlerContext === void 0 ? void 0 : keyDownHandlerContext.handleArrowRight();
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
case 'Escape':
|
|
110
|
+
handleClose(event);
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
default:
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
119
|
+
return function () {
|
|
120
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
121
|
+
};
|
|
122
|
+
}, [currentSelectedItemIndex, wrapperRef, handleClose, disableArrowKeyNavigation, keyDownHandlerContext, closeonTab]);
|
|
123
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: "custom-key-handler-wrapper",
|
|
125
|
+
ref: wrapperRef
|
|
126
|
+
}, children);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
function getFocusableElements(rootNode) {
|
|
130
|
+
if (!rootNode) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"]') || [];
|
|
135
|
+
return Array.from(focusableModalElements);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* This method filters out all the disabled menu items
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
function getEnabledElements(rootNode) {
|
|
143
|
+
var focusableElements = getFocusableElements(rootNode);
|
|
144
|
+
return focusableElements.filter(function (element) {
|
|
145
|
+
return !element.querySelector('[role="button"][aria-disabled="true"]') && !element.querySelector('[role="menuitem"][aria-disabled="true"]');
|
|
146
|
+
});
|
|
147
|
+
}
|
|
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown"];
|
|
9
|
+
var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown", "closeonTab"];
|
|
10
10
|
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
12
|
|
|
@@ -41,7 +41,16 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
|
|
|
41
41
|
|
|
42
42
|
if (!domNode || evt.target instanceof Node && !domNode.contains(evt.target)) {
|
|
43
43
|
if (_this.props.handleClickOutside) {
|
|
44
|
-
_this
|
|
44
|
+
var _this$props$editorVie;
|
|
45
|
+
|
|
46
|
+
_this.props.handleClickOutside(evt); //When the menus are closed by clicking outside the focus is set on editor.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if (!((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
|
|
50
|
+
var _this$props$editorVie2;
|
|
51
|
+
|
|
52
|
+
(_this$props$editorVie2 = _this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
});
|
|
@@ -52,22 +61,18 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
|
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
if (evt.code === 'Escape' && _this.props.handleEscapeKeydown) {
|
|
55
|
-
var _this$props$editorVie;
|
|
56
|
-
|
|
57
64
|
evt.preventDefault();
|
|
58
65
|
evt.stopPropagation();
|
|
59
66
|
|
|
60
|
-
_this.props.handleEscapeKeydown(evt);
|
|
61
|
-
|
|
62
|
-
if (!((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
|
|
63
|
-
var _this$props$editorVie2;
|
|
67
|
+
_this.props.handleEscapeKeydown(evt); //on 'Esc', Focus is handled in 'handleEscapeKeydown'.
|
|
64
68
|
|
|
65
|
-
(_this$props$editorVie2 = _this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
|
|
66
|
-
}
|
|
67
69
|
|
|
68
70
|
return false;
|
|
69
71
|
} else if (evt.code === 'Enter' && _this.props.handleEnterKeydown) {
|
|
70
72
|
_this.props.handleEnterKeydown(evt);
|
|
73
|
+
} else if (evt.code === 'Tab' && _this.props.handleEscapeKeydown && _this.props.closeonTab) {
|
|
74
|
+
//The menus should be closed when the tab is pressed as it takes the focus out of the menu
|
|
75
|
+
_this.props.handleEscapeKeydown(evt);
|
|
71
76
|
}
|
|
72
77
|
});
|
|
73
78
|
|
|
@@ -84,7 +89,8 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
|
|
|
84
89
|
if (this.props.handleEscapeKeydown) {
|
|
85
90
|
var _this$props$editorRef;
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
//Attached event to the menu so that 'ESC' events from the opened menu also will be handled.
|
|
93
|
+
(((_this$props$editorRef = this.props.editorRef) === null || _this$props$editorRef === void 0 ? void 0 : _this$props$editorRef.current) || this.props.targetRef || document).addEventListener('keydown', this.handleKeydown, false);
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
}, {
|
|
@@ -97,7 +103,7 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
|
|
|
97
103
|
if (this.props.handleEscapeKeydown) {
|
|
98
104
|
var _this$props$editorRef2;
|
|
99
105
|
|
|
100
|
-
(((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || document).removeEventListener('keydown', this.handleKeydown, false);
|
|
106
|
+
(((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || this.props.targetRef || document).removeEventListener('keydown', this.handleKeydown, false);
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
}, {
|
|
@@ -119,6 +125,7 @@ export default function withReactEditorViewOuterListeners(Component) {
|
|
|
119
125
|
var handleClickOutside = _ref.handleClickOutside,
|
|
120
126
|
handleEnterKeydown = _ref.handleEnterKeydown,
|
|
121
127
|
handleEscapeKeydown = _ref.handleEscapeKeydown,
|
|
128
|
+
closeonTab = _ref.closeonTab,
|
|
122
129
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
123
130
|
|
|
124
131
|
var isActiveComponent = hasIsOpen(props) ? props.isOpen : true;
|
|
@@ -128,10 +135,12 @@ export default function withReactEditorViewOuterListeners(Component) {
|
|
|
128
135
|
return /*#__PURE__*/React.createElement(WithOutsideClick, {
|
|
129
136
|
editorView: editorView,
|
|
130
137
|
editorRef: editorRef,
|
|
138
|
+
targetRef: props.targetRef,
|
|
131
139
|
isActiveComponent: isActiveComponent,
|
|
132
140
|
handleClickOutside: handleClickOutside,
|
|
133
141
|
handleEnterKeydown: handleEnterKeydown,
|
|
134
|
-
handleEscapeKeydown: handleEscapeKeydown
|
|
142
|
+
handleEscapeKeydown: handleEscapeKeydown,
|
|
143
|
+
closeonTab: closeonTab
|
|
135
144
|
}, /*#__PURE__*/React.createElement(Component, props));
|
|
136
145
|
});
|
|
137
146
|
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, close
|
|
|
13
13
|
export { default as ADFTraversor } from './traversor';
|
|
14
14
|
export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEventSeverity, SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './analytics';
|
|
15
15
|
export { findAndTrackUnsupportedContentNodes } from './track-unsupported-content';
|
|
16
|
-
export { measureRender } from './performance/measure-render';
|
|
16
|
+
export { getDistortedDurationMonitor, measureRender } from './performance/measure-render';
|
|
17
17
|
export { startMeasure, stopMeasure, clearMeasure } from './performance/measure';
|
|
18
18
|
export { measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS } from './performance/measure-tti';
|
|
19
19
|
export { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from './performance/is-performance-api-available';
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
import { isPerformanceAPIAvailable } from './is-performance-api-available';
|
|
2
|
+
/**
|
|
3
|
+
* Monitors if a pages enters a visibility state which will lead to
|
|
4
|
+
* distorted duration measurements (where the measurement uses the
|
|
5
|
+
* requestAnimationFrame api).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function getDistortedDurationMonitor() {
|
|
9
|
+
// If an editor is rendered when the document is not visible -- the callback passed to
|
|
10
|
+
// requestAnimationFrame will not fire until the document becomes visible again.
|
|
11
|
+
//
|
|
12
|
+
// For the purposes of using performance measurement -- this behaviour means the events
|
|
13
|
+
// which have been fired in the background are not useful -- and lead to other events
|
|
14
|
+
// being hard to draw conclusions from.
|
|
15
|
+
//
|
|
16
|
+
// To mitigate this -- we detect this state -- and fire a seperate callback when the
|
|
17
|
+
// measurement has occured when the render was in the backgroun
|
|
18
|
+
var distortedDuration = document.visibilityState !== 'visible';
|
|
19
|
+
|
|
20
|
+
function handleVisibilityChange() {
|
|
21
|
+
if (document.visibilityState !== 'visible') {
|
|
22
|
+
distortedDuration = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
27
|
+
return {
|
|
28
|
+
distortedDuration: distortedDuration,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Cleans up the document visibility event listener
|
|
32
|
+
*/
|
|
33
|
+
cleanup: function cleanup() {
|
|
34
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
2
38
|
/**
|
|
3
39
|
* Measures time it takes to render a frame including -> style, paint, layout and composition.
|
|
4
40
|
*
|
|
@@ -37,29 +73,12 @@ onMeasureComplete) {
|
|
|
37
73
|
var startMark = "[START]: ".concat(measureName);
|
|
38
74
|
var endMark = "[END]: ".concat(measureName);
|
|
39
75
|
var startTime = performance.now();
|
|
40
|
-
performance.mark(startMark);
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
// For the purposes of using performance measurement -- this behaviour means the events
|
|
44
|
-
// which have been fired in the background are not useful -- and lead to other events
|
|
45
|
-
// being hard to draw conclusions from.
|
|
46
|
-
//
|
|
47
|
-
// To mitigate this -- we detect this state -- and fire a seperate callback when the
|
|
48
|
-
// measurement has occured when the render was in the backgroun
|
|
49
|
-
|
|
50
|
-
var distortedDuration = document.visibilityState !== 'visible';
|
|
51
|
-
|
|
52
|
-
function handleVisibilityChange() {
|
|
53
|
-
if (document.visibilityState !== 'visible') {
|
|
54
|
-
distortedDuration = true;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
76
|
+
performance.mark(startMark);
|
|
77
|
+
var distortedDurationMonitor = getDistortedDurationMonitor();
|
|
59
78
|
requestAnimationFrame(function () {
|
|
60
79
|
requestAnimationFrame(function () {
|
|
61
80
|
performance.mark(endMark);
|
|
62
|
-
|
|
81
|
+
distortedDurationMonitor.cleanup();
|
|
63
82
|
var duration = performance.now() - startTime;
|
|
64
83
|
|
|
65
84
|
try {
|
|
@@ -70,20 +89,20 @@ onMeasureComplete) {
|
|
|
70
89
|
onMeasureComplete({
|
|
71
90
|
duration: duration,
|
|
72
91
|
startTime: startTime,
|
|
73
|
-
distortedDuration: distortedDuration
|
|
92
|
+
distortedDuration: distortedDurationMonitor.distortedDuration
|
|
74
93
|
});
|
|
75
94
|
} else {
|
|
76
95
|
onMeasureComplete({
|
|
77
96
|
duration: entry.duration,
|
|
78
97
|
startTime: entry.startTime,
|
|
79
|
-
distortedDuration: distortedDuration
|
|
98
|
+
distortedDuration: distortedDurationMonitor.distortedDuration
|
|
80
99
|
});
|
|
81
100
|
}
|
|
82
101
|
} catch (e) {
|
|
83
102
|
onMeasureComplete({
|
|
84
103
|
duration: duration,
|
|
85
104
|
startTime: startTime,
|
|
86
|
-
distortedDuration: distortedDuration
|
|
105
|
+
distortedDuration: distortedDurationMonitor.distortedDuration
|
|
87
106
|
});
|
|
88
107
|
}
|
|
89
108
|
|
package/dist/esm/version.json
CHANGED
|
@@ -92,6 +92,7 @@ export declare enum ACTION {
|
|
|
92
92
|
DEDUPE_MARKS_TRANSFORMED = "dedupeMarksTransformed",
|
|
93
93
|
NODES_MISSING_CONTENT_TRANSFORMED = "nodesMissingContentTransformed",
|
|
94
94
|
INDENTATION_MARKS_TRANSFORMED = "indentationMarksTransformed",
|
|
95
|
+
INVALID_MEDIA_CONTENT_TRANSFORMED = "invalidMediaContentTransformed",
|
|
95
96
|
TOGGLE_EXPAND = "toggleExpand",
|
|
96
97
|
TRANSACTION_DISPATCHED = "transactionDispatched",
|
|
97
98
|
TRANSACTION_MUTATED_AFTER_DISPATCH = "transactionMutatedAfterDispatched",
|
|
@@ -175,5 +175,6 @@ declare type DedupeMarksTransformedAEP = OperationalAEP<ACTION.DEDUPE_MARKS_TRAN
|
|
|
175
175
|
}, undefined>;
|
|
176
176
|
declare type IndentationMarksTransformedAEP = OperationalAEP<ACTION.INDENTATION_MARKS_TRANSFORMED, ACTION_SUBJECT.EDITOR, undefined, undefined, undefined>;
|
|
177
177
|
declare type NodesMissingContentTransformedAEP = OperationalAEP<ACTION.NODES_MISSING_CONTENT_TRANSFORMED, ACTION_SUBJECT.EDITOR, undefined, undefined, undefined>;
|
|
178
|
-
|
|
178
|
+
declare type InvalidMediaContentTransformedAEP = OperationalAEP<ACTION.INVALID_MEDIA_CONTENT_TRANSFORMED, ACTION_SUBJECT.EDITOR, undefined, undefined, undefined>;
|
|
179
|
+
export declare type GeneralEventPayload<T = void> = AnnotateButtonAEP | AnnotationAEP | BrowserFreezePayload | ButtonFeedbackAEP | ButtonHelpAEP | ColorPickerAEP | DispatchedTransactionAEP | EditorPerfAEP | EditorRenderedAEP<T> | EditorStartAEP | EditorStopAEP | EditorTTIAEP | ExpandToggleAEP | FeedbackAEP | FullWidthModeAEP | HelpQuickInsertAEP | InputPerfSamlingAEP | InputPerfSamplingAvgAEP | PickerEmojiAEP | PickerImageAEP | ReactNodeViewRenderedAEP | RichMediaLayoutAEP | SelectionAEP | SlowInputAEP | TransactionMutatedAEP | UploadExternalFailedAEP | WithPluginStateCalledAEP | CodeBlockLanguageSelectedAEP | EditorContentRetrievalPerformedAEP | UfoSessionCompletePayloadAEP | MediaLinkTransformedAEP | TextLinkCodeMarkTransformedAEP | DedupeMarksTransformedAEP | IndentationMarksTransformedAEP | NodesMissingContentTransformedAEP | InvalidProsemirrorDocumentErrorAEP | DocumentProcessingErrorAEP | InvalidMediaContentTransformedAEP;
|
|
179
180
|
export {};
|
|
@@ -64,7 +64,6 @@ export declare const paste: Keymap;
|
|
|
64
64
|
export declare const altPaste: Keymap;
|
|
65
65
|
export declare const find: Keymap;
|
|
66
66
|
export declare const alignLeft: Keymap;
|
|
67
|
-
export declare const alignRight: Keymap;
|
|
68
67
|
export declare function tooltip(keymap?: Keymap, description?: string): string | undefined;
|
|
69
68
|
export declare const ToolTipContent: React.MemoExoticComponent<({ description, shortcutOverride, keymap, }: {
|
|
70
69
|
description?: string | React.ReactNode;
|
|
@@ -19,12 +19,17 @@ export declare const toolbarInsertBlockMessages: {
|
|
|
19
19
|
defaultMessage: string;
|
|
20
20
|
description: string;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
mediaFiles: {
|
|
23
23
|
id: string;
|
|
24
24
|
defaultMessage: string;
|
|
25
25
|
description: string;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
addMediaFiles: {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
mediaFilesDescription: {
|
|
28
33
|
id: string;
|
|
29
34
|
defaultMessage: string;
|
|
30
35
|
description: string;
|
package/dist/types/panel.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getPanelTypeBackground, darkPanelColors, getPanelDarkColor, panelSharedStyles, panelSharedStylesWithoutPrefix, PanelSharedCssClassName, PanelSharedSelectors, getPanelBackgroundDarkModeColors, } from './styles/shared/panel';
|
|
1
|
+
export { getPanelTypeBackground, getPanelTypeBackgroundNoTokens, darkPanelColors, getPanelDarkColor, panelSharedStyles, panelSharedStylesWithoutPrefix, PanelSharedCssClassName, PanelSharedSelectors, getPanelBackgroundDarkModeColors, } from './styles/shared/panel';
|
|
@@ -79,6 +79,7 @@ export declare const PanelSharedSelectors: {
|
|
|
79
79
|
yellowWarningIcon: string;
|
|
80
80
|
copyButton: string;
|
|
81
81
|
};
|
|
82
|
+
export declare const getPanelTypeBackgroundNoTokens: (panelType: Exclude<PanelType, PanelType.CUSTOM>, props?: ThemeProps) => string;
|
|
82
83
|
export declare const getPanelTypeBackground: (panelType: Exclude<PanelType, PanelType.CUSTOM>, props?: ThemeProps) => string;
|
|
83
84
|
export declare const panelSharedStylesWithoutPrefix: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
84
85
|
export declare const panelSharedStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
@@ -244,12 +244,6 @@ export declare type FeatureFlags = {
|
|
|
244
244
|
* @default false
|
|
245
245
|
*/
|
|
246
246
|
saferDispatchedTransactions?: boolean;
|
|
247
|
-
/**
|
|
248
|
-
* Create non-smart hyperlinks on plain text paste (Cmd/Ctrl+Shift+v)
|
|
249
|
-
* @see https://product-fabric.atlassian.net/browse/EDM-2492
|
|
250
|
-
* @default false
|
|
251
|
-
*/
|
|
252
|
-
plainTextPasteLinkification?: boolean;
|
|
253
247
|
/**
|
|
254
248
|
* @description
|
|
255
249
|
* Enable new collab service
|
|
@@ -339,6 +333,33 @@ export declare type FeatureFlags = {
|
|
|
339
333
|
* @default null
|
|
340
334
|
*/
|
|
341
335
|
floatingToolbarLinkSettingsButton?: string;
|
|
336
|
+
/**
|
|
337
|
+
* @description
|
|
338
|
+
* Allow numbered lists to start from any number greater than 0, not just 1
|
|
339
|
+
*
|
|
340
|
+
* @see https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3257270398/MAKE+PP+Restart+Numbered+Lists
|
|
341
|
+
* @see https://product-fabric.atlassian.net/browse/ED-15210
|
|
342
|
+
* @default false
|
|
343
|
+
*/
|
|
344
|
+
restartNumberedLists?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* @description
|
|
347
|
+
* Allow lists to continue their numbering when split by other nodes
|
|
348
|
+
*
|
|
349
|
+
* @see https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3257270398/MAKE+PP+Restart+Numbered+Lists
|
|
350
|
+
* @see https://product-fabric.atlassian.net/browse/ED-15210
|
|
351
|
+
* @default false
|
|
352
|
+
*/
|
|
353
|
+
listNumberContinuity?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* @description
|
|
356
|
+
* Show a toolbar for users to restart the numbering of a list
|
|
357
|
+
*
|
|
358
|
+
* @see https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3257270398/MAKE+PP+Restart+Numbered+Lists
|
|
359
|
+
* @see https://product-fabric.atlassian.net/browse/ED-15210
|
|
360
|
+
* @default false
|
|
361
|
+
*/
|
|
362
|
+
restartNumberedListsToolbar?: boolean;
|
|
342
363
|
};
|
|
343
364
|
export declare type FeatureFlagKey = keyof FeatureFlags;
|
|
344
365
|
export declare type GetEditorFeatureFlags = () => FeatureFlags;
|
|
@@ -17,6 +17,9 @@ export interface DropdownOptionT<T> {
|
|
|
17
17
|
id?: string;
|
|
18
18
|
title: string;
|
|
19
19
|
onClick: T;
|
|
20
|
+
onMouseOver?: T;
|
|
21
|
+
onMouseEnter?: T;
|
|
22
|
+
onMouseLeave?: T;
|
|
20
23
|
selected?: boolean;
|
|
21
24
|
disabled?: boolean;
|
|
22
25
|
hidden?: boolean;
|
|
@@ -198,6 +201,7 @@ export interface FloatingToolbarConfig {
|
|
|
198
201
|
className?: string;
|
|
199
202
|
height?: number;
|
|
200
203
|
width?: number;
|
|
204
|
+
zIndex?: number;
|
|
201
205
|
offset?: [number, number];
|
|
202
206
|
forcePlacement?: boolean;
|
|
203
207
|
onPositionCalculated?: (editorView: EditorView, nextPos: Position) => Position;
|