@atlaskit/editor-common 70.3.0 → 71.0.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/analytics/types/enums.js +1 -0
  3. package/dist/cjs/keymaps/index.js +5 -8
  4. package/dist/cjs/messages/insert-block.js +12 -7
  5. package/dist/cjs/panel.js +6 -0
  6. package/dist/cjs/styles/shared/code-block.js +5 -5
  7. package/dist/cjs/styles/shared/panel.js +54 -17
  8. package/dist/cjs/styles/shared/table.js +12 -7
  9. package/dist/cjs/styles/shared/text-color.js +1 -1
  10. package/dist/cjs/ui/DropList/index.js +1 -1
  11. package/dist/cjs/ui-color/ColorPalette/Color/index.js +6 -2
  12. package/dist/cjs/ui-color/ColorPalette/index.js +21 -11
  13. package/dist/cjs/ui-menu/Dropdown/index.js +16 -2
  14. package/dist/cjs/ui-menu/DropdownMenu/index.js +27 -8
  15. package/dist/cjs/ui-menu/MenuArrowKeyNavigationProvider/index.js +162 -0
  16. package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +22 -13
  17. package/dist/cjs/utils/index.js +6 -0
  18. package/dist/cjs/utils/performance/measure-render.js +44 -23
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/analytics/types/enums.js +1 -0
  21. package/dist/es2019/keymaps/index.js +4 -6
  22. package/dist/es2019/messages/insert-block.js +12 -7
  23. package/dist/es2019/panel.js +1 -1
  24. package/dist/es2019/styles/shared/code-block.js +39 -25
  25. package/dist/es2019/styles/shared/panel.js +48 -18
  26. package/dist/es2019/styles/shared/table.js +24 -13
  27. package/dist/es2019/styles/shared/text-color.js +1 -1
  28. package/dist/es2019/ui/DropList/index.js +1 -1
  29. package/dist/es2019/ui-color/ColorPalette/Color/index.js +6 -3
  30. package/dist/es2019/ui-color/ColorPalette/index.js +19 -11
  31. package/dist/es2019/ui-menu/Dropdown/index.js +13 -2
  32. package/dist/es2019/ui-menu/DropdownMenu/index.js +41 -6
  33. package/dist/es2019/ui-menu/MenuArrowKeyNavigationProvider/index.js +146 -0
  34. package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +20 -13
  35. package/dist/es2019/utils/index.js +1 -1
  36. package/dist/es2019/utils/performance/measure-render.js +43 -23
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/analytics/types/enums.js +1 -0
  39. package/dist/esm/keymaps/index.js +3 -6
  40. package/dist/esm/messages/insert-block.js +12 -7
  41. package/dist/esm/panel.js +1 -1
  42. package/dist/esm/styles/shared/code-block.js +5 -5
  43. package/dist/esm/styles/shared/panel.js +49 -18
  44. package/dist/esm/styles/shared/table.js +12 -9
  45. package/dist/esm/styles/shared/text-color.js +1 -1
  46. package/dist/esm/ui/DropList/index.js +1 -1
  47. package/dist/esm/ui-color/ColorPalette/Color/index.js +5 -2
  48. package/dist/esm/ui-color/ColorPalette/index.js +20 -11
  49. package/dist/esm/ui-menu/Dropdown/index.js +15 -2
  50. package/dist/esm/ui-menu/DropdownMenu/index.js +28 -9
  51. package/dist/esm/ui-menu/MenuArrowKeyNavigationProvider/index.js +147 -0
  52. package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +22 -13
  53. package/dist/esm/utils/index.js +1 -1
  54. package/dist/esm/utils/performance/measure-render.js +42 -23
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/analytics/types/enums.d.ts +1 -0
  57. package/dist/types/analytics/types/general-events.d.ts +2 -1
  58. package/dist/types/keymaps/index.d.ts +0 -1
  59. package/dist/types/messages/insert-block.d.ts +7 -2
  60. package/dist/types/panel.d.ts +1 -1
  61. package/dist/types/styles/shared/code-block.d.ts +1 -0
  62. package/dist/types/styles/shared/panel.d.ts +1 -0
  63. package/dist/types/types/feature-flags.d.ts +27 -6
  64. package/dist/types/types/floating-toolbar.d.ts +4 -0
  65. package/dist/types/ui-color/ColorPalette/Color/index.d.ts +5 -0
  66. package/dist/types/ui-color/ColorPalette/index.d.ts +8 -0
  67. package/dist/types/ui-menu/Dropdown/index.d.ts +3 -0
  68. package/dist/types/ui-menu/DropdownMenu/index.d.ts +1 -0
  69. package/dist/types/ui-menu/DropdownMenu/types.d.ts +7 -0
  70. package/dist/types/ui-menu/MenuArrowKeyNavigationProvider/index.d.ts +15 -0
  71. package/dist/types/ui-react/with-react-editor-view-outer-listeners.d.ts +2 -0
  72. package/dist/types/utils/index.d.ts +1 -1
  73. package/dist/types/utils/performance/measure-render.d.ts +12 -0
  74. package/package.json +8 -7
  75. package/report.api.md +12 -5
@@ -51,9 +51,11 @@ var _DropList = _interopRequireDefault(require("../../ui/DropList"));
51
51
 
52
52
  var _Popup = _interopRequireDefault(require("../../ui/Popup"));
53
53
 
54
+ var _MenuArrowKeyNavigationProvider = require("../MenuArrowKeyNavigationProvider");
55
+
54
56
  var _excluded = ["children"];
55
57
 
56
- var _templateObject, _templateObject2, _templateObject3;
58
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
57
59
 
58
60
  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); }
59
61
 
@@ -64,6 +66,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
64
66
  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; } }
65
67
 
66
68
  var wrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n /* tooltip in ToolbarButton is display:block */\n & > div > div {\n display: flex;\n }\n"])));
69
+ var focusedMenuItemStyle = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n box-shadow: inset 0px 0px 0px 2px ", ";\n outline: none;\n"])), (0, _tokens.token)('color.border.focused', _colors.B100));
67
70
 
68
71
  var buttonStyles = function buttonStyles(isActive) {
69
72
  return function (theme) {
@@ -71,9 +74,9 @@ var buttonStyles = function buttonStyles(isActive) {
71
74
  /**
72
75
  * Hack for item to imitate old dropdown-menu selected styles
73
76
  */
74
- return (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n > span,\n > span:hover,\n > span:active {\n background: ", ";\n color: ", ";\n }\n "])), (0, _tokens.token)('color.background.selected', '#6c798f'), (0, _tokens.token)('color.text', '#fff'));
77
+ return (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\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 "])), (0, _tokens.token)('color.background.selected', '#6c798f'), (0, _tokens.token)('color.text', '#fff'), focusedMenuItemStyle);
75
78
  } else {
76
- return (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\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 "])), (0, _components.themed)({
79
+ return (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\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 "])), (0, _components.themed)({
77
80
  light: (0, _tokens.token)('color.text', _colors.N900),
78
81
  dark: (0, _tokens.token)('color.text', _colors.DN600)
79
82
  })(theme), (0, _components.themed)({
@@ -85,7 +88,7 @@ var buttonStyles = function buttonStyles(isActive) {
85
88
  })(theme), (0, _components.themed)({
86
89
  light: (0, _tokens.token)('color.text.disabled', _colors.N70),
87
90
  dark: (0, _tokens.token)('color.text.disabled', _colors.DN80)
88
- })(theme));
91
+ })(theme), focusedMenuItemStyle); // The deafut focus-visible style is removed to ensure consistency across browsers
89
92
  }
90
93
  };
91
94
  };
@@ -130,6 +133,13 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
130
133
  });
131
134
  }
132
135
  });
136
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleCloseandFocus", function () {
137
+ var _this$state$target, _this$state$target$qu;
138
+
139
+ _this.handleClose();
140
+
141
+ (_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();
142
+ });
133
143
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClose", function () {
134
144
  if (_this.props.onOpenChange) {
135
145
  _this.props.onOpenChange({
@@ -158,7 +168,9 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
158
168
  fitWidth = _this$props.fitWidth,
159
169
  isOpen = _this$props.isOpen,
160
170
  zIndex = _this$props.zIndex,
161
- shouldUseDefaultRole = _this$props.shouldUseDefaultRole;
171
+ shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
172
+ disableArrowKeyNavigation = _this$props.disableArrowKeyNavigation,
173
+ keyDownHandlerContext = _this$props.keyDownHandlerContext;
162
174
  return (0, _react2.jsx)(_Popup.default, {
163
175
  target: isOpen ? target : undefined,
164
176
  mountTo: mountTo,
@@ -169,6 +181,11 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
169
181
  fitWidth: fitWidth,
170
182
  zIndex: zIndex || _editorSharedStyles.akEditorFloatingPanelZIndex,
171
183
  offset: offset
184
+ }, (0, _react2.jsx)(_MenuArrowKeyNavigationProvider.MenuArrowKeyNavigationProvider, {
185
+ disableArrowKeyNavigation: disableArrowKeyNavigation,
186
+ handleClose: this.handleCloseandFocus,
187
+ keyDownHandlerContext: keyDownHandlerContext,
188
+ closeonTab: true
172
189
  }, (0, _react2.jsx)(DropListWithOutsideListeners, {
173
190
  isOpen: true,
174
191
  appearance: "tall",
@@ -177,7 +194,8 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
177
194
  shouldFitContainer: true,
178
195
  isTriggerNotTabbable: true,
179
196
  handleClickOutside: this.handleClose,
180
- handleEscapeKeydown: this.handleClose
197
+ handleEscapeKeydown: this.handleCloseandFocus,
198
+ targetRef: this.state.target
181
199
  }, (0, _react2.jsx)("div", {
182
200
  style: {
183
201
  height: 0,
@@ -199,7 +217,7 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
199
217
  onMouseLeave: _this2.props.onMouseLeave
200
218
  });
201
219
  }));
202
- })));
220
+ }))));
203
221
  }
204
222
  }, {
205
223
  key: "render",
@@ -249,7 +267,8 @@ function DropdownMenuItem(_ref) {
249
267
  return buttonStyles(item.isActive)({
250
268
  theme: theme
251
269
  });
252
- }
270
+ },
271
+ tabIndex: -1
253
272
  }, (0, _react2.jsx)(_menu.CustomItem, {
254
273
  item: item,
255
274
  key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.MenuArrowKeyNavigationProvider = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ 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); }
13
+
14
+ 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; }
15
+
16
+ /**
17
+ * This component is a wrapper of vertical menus which listens to keydown events of children
18
+ * and handles up/down arrow key navigation
19
+ */
20
+ var MenuArrowKeyNavigationProvider = function MenuArrowKeyNavigationProvider(_ref) {
21
+ var children = _ref.children,
22
+ handleClose = _ref.handleClose,
23
+ disableArrowKeyNavigation = _ref.disableArrowKeyNavigation,
24
+ keyDownHandlerContext = _ref.keyDownHandlerContext,
25
+ closeonTab = _ref.closeonTab;
26
+ var wrapperRef = (0, _react.useRef)(null);
27
+ var currentSelectedItemIndex = (0, _react.useRef)(-1);
28
+
29
+ var incrementIndex = function incrementIndex(list) {
30
+ if (currentSelectedItemIndex.current === list.length - 1 || currentSelectedItemIndex.current === -1) {
31
+ currentSelectedItemIndex.current = 0;
32
+ } else {
33
+ currentSelectedItemIndex.current = currentSelectedItemIndex.current + 1;
34
+ }
35
+ };
36
+
37
+ var decrementIndex = function decrementIndex(list) {
38
+ if (currentSelectedItemIndex.current === 0 || currentSelectedItemIndex.current === -1) {
39
+ currentSelectedItemIndex.current = list.length - 1;
40
+ } else {
41
+ currentSelectedItemIndex.current = currentSelectedItemIndex.current - 1;
42
+ }
43
+ };
44
+
45
+ (0, _react.useLayoutEffect)(function () {
46
+ if (disableArrowKeyNavigation) {
47
+ return;
48
+ }
49
+ /**
50
+ * To handle the key events on the list
51
+ * @param event
52
+ */
53
+
54
+
55
+ var handleKeyDown = function handleKeyDown(event) {
56
+ var _wrapperRef$current, _focusableElements$cu, _focusableElements$cu2;
57
+
58
+ var targetElement = event.target; //Tab key on menu items can be handled in the parent components of dropdown menus with KeydownHandlerContext
59
+
60
+ if (event.key === 'Tab' && closeonTab) {
61
+ handleClose(event);
62
+ keyDownHandlerContext === null || keyDownHandlerContext === void 0 ? void 0 : keyDownHandlerContext.handleTab();
63
+ return;
64
+ } //To trap the focus inside the toolbar using left and right arrow keys
65
+
66
+
67
+ var focusableElements = getEnabledElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
68
+
69
+ if (!focusableElements || (focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) === 0) {
70
+ return;
71
+ }
72
+
73
+ if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
74
+ currentSelectedItemIndex.current = -1;
75
+ }
76
+
77
+ switch (event.key) {
78
+ case 'ArrowDown':
79
+ //If ArrowDown pressed
80
+ //If on last item
81
+ // Focus last item
82
+ //Else
83
+ // Focus next item
84
+ incrementIndex(focusableElements);
85
+ (_focusableElements$cu = focusableElements[currentSelectedItemIndex.current]) === null || _focusableElements$cu === void 0 ? void 0 : _focusableElements$cu.focus();
86
+ event.preventDefault();
87
+ break;
88
+
89
+ case 'ArrowUp':
90
+ //ArrowUP pressed
91
+ //If on First item
92
+ // Focus last item
93
+ //Else
94
+ // Focus previous item
95
+ decrementIndex(focusableElements);
96
+ (_focusableElements$cu2 = focusableElements[currentSelectedItemIndex.current]) === null || _focusableElements$cu2 === void 0 ? void 0 : _focusableElements$cu2.focus();
97
+ event.preventDefault();
98
+ break;
99
+ //ArrowLeft/Right on the menu should close the menus
100
+ //then logic to retain the focus can be handled in the parent components with KeydownHandlerContext
101
+
102
+ case 'ArrowLeft':
103
+ //Filter out the events from outside the menu
104
+ if (!targetElement.closest('.custom-key-handler-wrapper')) {
105
+ return;
106
+ }
107
+
108
+ handleClose(event);
109
+ keyDownHandlerContext === null || keyDownHandlerContext === void 0 ? void 0 : keyDownHandlerContext.handleArrowLeft();
110
+ break;
111
+
112
+ case 'ArrowRight':
113
+ //Filter out the events from outside the menu
114
+ if (!targetElement.closest('.custom-key-handler-wrapper')) {
115
+ return;
116
+ }
117
+
118
+ handleClose(event);
119
+ keyDownHandlerContext === null || keyDownHandlerContext === void 0 ? void 0 : keyDownHandlerContext.handleArrowRight();
120
+ break;
121
+
122
+ case 'Escape':
123
+ handleClose(event);
124
+ break;
125
+
126
+ default:
127
+ return;
128
+ }
129
+ };
130
+
131
+ document.addEventListener('keydown', handleKeyDown);
132
+ return function () {
133
+ document.removeEventListener('keydown', handleKeyDown);
134
+ };
135
+ }, [currentSelectedItemIndex, wrapperRef, handleClose, disableArrowKeyNavigation, keyDownHandlerContext, closeonTab]);
136
+ return /*#__PURE__*/_react.default.createElement("div", {
137
+ className: "custom-key-handler-wrapper",
138
+ ref: wrapperRef
139
+ }, children);
140
+ };
141
+
142
+ exports.MenuArrowKeyNavigationProvider = MenuArrowKeyNavigationProvider;
143
+
144
+ function getFocusableElements(rootNode) {
145
+ if (!rootNode) {
146
+ return [];
147
+ }
148
+
149
+ var focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"]') || [];
150
+ return Array.from(focusableModalElements);
151
+ }
152
+ /**
153
+ * This method filters out all the disabled menu items
154
+ */
155
+
156
+
157
+ function getEnabledElements(rootNode) {
158
+ var focusableElements = getFocusableElements(rootNode);
159
+ return focusableElements.filter(function (element) {
160
+ return !element.querySelector('[role="button"][aria-disabled="true"]') && !element.querySelector('[role="menuitem"][aria-disabled="true"]');
161
+ });
162
+ }
@@ -31,7 +31,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
31
31
 
32
32
  var _ReactEditorViewContext = _interopRequireDefault(require("./ReactEditorViewContext"));
33
33
 
34
- var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown"];
34
+ var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown", "closeonTab"];
35
35
 
36
36
  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); }
37
37
 
@@ -66,7 +66,16 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
66
66
 
67
67
  if (!domNode || evt.target instanceof Node && !domNode.contains(evt.target)) {
68
68
  if (_this.props.handleClickOutside) {
69
- _this.props.handleClickOutside(evt);
69
+ var _this$props$editorVie;
70
+
71
+ _this.props.handleClickOutside(evt); //When the menus are closed by clicking outside the focus is set on editor.
72
+
73
+
74
+ if (!((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
75
+ var _this$props$editorVie2;
76
+
77
+ (_this$props$editorVie2 = _this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
78
+ }
70
79
  }
71
80
  }
72
81
  });
@@ -76,22 +85,18 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
76
85
  }
77
86
 
78
87
  if (evt.code === 'Escape' && _this.props.handleEscapeKeydown) {
79
- var _this$props$editorVie;
80
-
81
88
  evt.preventDefault();
82
89
  evt.stopPropagation();
83
90
 
84
- _this.props.handleEscapeKeydown(evt);
85
-
86
- if (!((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
87
- var _this$props$editorVie2;
91
+ _this.props.handleEscapeKeydown(evt); //on 'Esc', Focus is handled in 'handleEscapeKeydown'.
88
92
 
89
- (_this$props$editorVie2 = _this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
90
- }
91
93
 
92
94
  return false;
93
95
  } else if (evt.code === 'Enter' && _this.props.handleEnterKeydown) {
94
96
  _this.props.handleEnterKeydown(evt);
97
+ } else if (evt.code === 'Tab' && _this.props.handleEscapeKeydown && _this.props.closeonTab) {
98
+ //The menus should be closed when the tab is pressed as it takes the focus out of the menu
99
+ _this.props.handleEscapeKeydown(evt);
95
100
  }
96
101
  });
97
102
  return _this;
@@ -107,7 +112,8 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
107
112
  if (this.props.handleEscapeKeydown) {
108
113
  var _this$props$editorRef;
109
114
 
110
- (((_this$props$editorRef = this.props.editorRef) === null || _this$props$editorRef === void 0 ? void 0 : _this$props$editorRef.current) || document).addEventListener('keydown', this.handleKeydown, false);
115
+ //Attached event to the menu so that 'ESC' events from the opened menu also will be handled.
116
+ (((_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);
111
117
  }
112
118
  }
113
119
  }, {
@@ -120,7 +126,7 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
120
126
  if (this.props.handleEscapeKeydown) {
121
127
  var _this$props$editorRef2;
122
128
 
123
- (((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || document).removeEventListener('keydown', this.handleKeydown, false);
129
+ (((_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);
124
130
  }
125
131
  }
126
132
  }, {
@@ -141,6 +147,7 @@ function withReactEditorViewOuterListeners(Component) {
141
147
  var handleClickOutside = _ref.handleClickOutside,
142
148
  handleEnterKeydown = _ref.handleEnterKeydown,
143
149
  handleEscapeKeydown = _ref.handleEscapeKeydown,
150
+ closeonTab = _ref.closeonTab,
144
151
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
145
152
  var isActiveComponent = hasIsOpen(props) ? props.isOpen : true;
146
153
  return /*#__PURE__*/_react.default.createElement(_ReactEditorViewContext.default.Consumer, null, function (_ref2) {
@@ -149,10 +156,12 @@ function withReactEditorViewOuterListeners(Component) {
149
156
  return /*#__PURE__*/_react.default.createElement(WithOutsideClick, {
150
157
  editorView: editorView,
151
158
  editorRef: editorRef,
159
+ targetRef: props.targetRef,
152
160
  isActiveComponent: isActiveComponent,
153
161
  handleClickOutside: handleClickOutside,
154
162
  handleEnterKeydown: handleEnterKeydown,
155
- handleEscapeKeydown: handleEscapeKeydown
163
+ handleEscapeKeydown: handleEscapeKeydown,
164
+ closeonTab: closeonTab
156
165
  }, /*#__PURE__*/_react.default.createElement(Component, props));
157
166
  });
158
167
  };
@@ -215,6 +215,12 @@ Object.defineProperty(exports, "getAnnotationIdsFromRange", {
215
215
  return _annotation.getAnnotationIdsFromRange;
216
216
  }
217
217
  });
218
+ Object.defineProperty(exports, "getDistortedDurationMonitor", {
219
+ enumerable: true,
220
+ get: function get() {
221
+ return _measureRender.getDistortedDurationMonitor;
222
+ }
223
+ });
218
224
  Object.defineProperty(exports, "getExtensionLozengeData", {
219
225
  enumerable: true,
220
226
  get: function get() {
@@ -3,10 +3,46 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getDistortedDurationMonitor = getDistortedDurationMonitor;
6
7
  exports.measureRender = measureRender;
7
8
 
8
9
  var _isPerformanceApiAvailable = require("./is-performance-api-available");
9
10
 
11
+ /**
12
+ * Monitors if a pages enters a visibility state which will lead to
13
+ * distorted duration measurements (where the measurement uses the
14
+ * requestAnimationFrame api).
15
+ */
16
+ function getDistortedDurationMonitor() {
17
+ // If an editor is rendered when the document is not visible -- the callback passed to
18
+ // requestAnimationFrame will not fire until the document becomes visible again.
19
+ //
20
+ // For the purposes of using performance measurement -- this behaviour means the events
21
+ // which have been fired in the background are not useful -- and lead to other events
22
+ // being hard to draw conclusions from.
23
+ //
24
+ // To mitigate this -- we detect this state -- and fire a seperate callback when the
25
+ // measurement has occured when the render was in the backgroun
26
+ var distortedDuration = document.visibilityState !== 'visible';
27
+
28
+ function handleVisibilityChange() {
29
+ if (document.visibilityState !== 'visible') {
30
+ distortedDuration = true;
31
+ }
32
+ }
33
+
34
+ document.addEventListener('visibilitychange', handleVisibilityChange);
35
+ return {
36
+ distortedDuration: distortedDuration,
37
+
38
+ /**
39
+ * Cleans up the document visibility event listener
40
+ */
41
+ cleanup: function cleanup() {
42
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
43
+ }
44
+ };
45
+ }
10
46
  /**
11
47
  * Measures time it takes to render a frame including -> style, paint, layout and composition.
12
48
  *
@@ -20,6 +56,8 @@ var _isPerformanceApiAvailable = require("./is-performance-api-available");
20
56
  * | javascript (framework) | style | layout | paint | composite | javascript | ...
21
57
  * | startMark + scheduling rAF | | rAF callback, endMark
22
58
  */
59
+
60
+
23
61
  function measureRender(
24
62
  /**
25
63
  * Unique name for the measurement
@@ -44,29 +82,12 @@ onMeasureComplete) {
44
82
  var startMark = "[START]: ".concat(measureName);
45
83
  var endMark = "[END]: ".concat(measureName);
46
84
  var startTime = performance.now();
47
- performance.mark(startMark); // If an editor is rendered when the document is not visible -- the callback passed to
48
- // requestAnimationFrame will not fire until the document becomes visible again.
49
- //
50
- // For the purposes of using performance measurement -- this behaviour means the events
51
- // which have been fired in the background are not useful -- and lead to other events
52
- // being hard to draw conclusions from.
53
- //
54
- // To mitigate this -- we detect this state -- and fire a seperate callback when the
55
- // measurement has occured when the render was in the backgroun
56
-
57
- var distortedDuration = document.visibilityState !== 'visible';
58
-
59
- function handleVisibilityChange() {
60
- if (document.visibilityState !== 'visible') {
61
- distortedDuration = true;
62
- }
63
- }
64
-
65
- document.addEventListener('visibilitychange', handleVisibilityChange);
85
+ performance.mark(startMark);
86
+ var distortedDurationMonitor = getDistortedDurationMonitor();
66
87
  requestAnimationFrame(function () {
67
88
  requestAnimationFrame(function () {
68
89
  performance.mark(endMark);
69
- document.removeEventListener('visibilitychange', handleVisibilityChange);
90
+ distortedDurationMonitor.cleanup();
70
91
  var duration = performance.now() - startTime;
71
92
 
72
93
  try {
@@ -77,20 +98,20 @@ onMeasureComplete) {
77
98
  onMeasureComplete({
78
99
  duration: duration,
79
100
  startTime: startTime,
80
- distortedDuration: distortedDuration
101
+ distortedDuration: distortedDurationMonitor.distortedDuration
81
102
  });
82
103
  } else {
83
104
  onMeasureComplete({
84
105
  duration: entry.duration,
85
106
  startTime: entry.startTime,
86
- distortedDuration: distortedDuration
107
+ distortedDuration: distortedDurationMonitor.distortedDuration
87
108
  });
88
109
  }
89
110
  } catch (e) {
90
111
  onMeasureComplete({
91
112
  duration: duration,
92
113
  startTime: startTime,
93
- distortedDuration: distortedDuration
114
+ distortedDuration: distortedDurationMonitor.distortedDuration
94
115
  });
95
116
  }
96
117
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "70.3.0",
3
+ "version": "71.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -92,6 +92,7 @@ export let ACTION;
92
92
  ACTION["DEDUPE_MARKS_TRANSFORMED"] = "dedupeMarksTransformed";
93
93
  ACTION["NODES_MISSING_CONTENT_TRANSFORMED"] = "nodesMissingContentTransformed";
94
94
  ACTION["INDENTATION_MARKS_TRANSFORMED"] = "indentationMarksTransformed";
95
+ ACTION["INVALID_MEDIA_CONTENT_TRANSFORMED"] = "invalidMediaContentTransformed";
95
96
  ACTION["TOGGLE_EXPAND"] = "toggleExpand";
96
97
  ACTION["TRANSACTION_DISPATCHED"] = "transactionDispatched";
97
98
  ACTION["TRANSACTION_MUTATED_AFTER_DISPATCH"] = "transactionMutatedAfterDispatched";
@@ -2,6 +2,7 @@
2
2
  import React, { Fragment } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { N400 } from '@atlaskit/theme/colors';
5
+ import { token } from '@atlaskit/tokens';
5
6
  import { browser } from '../utils';
6
7
  export const addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
7
8
  export const toggleBold = makeKeyMapWithCommon('Bold', 'Mod-b');
@@ -65,21 +66,18 @@ export const paste = makeKeyMapWithCommon('Paste', 'Mod-v');
65
66
  export const altPaste = makeKeyMapWithCommon('Paste', 'Mod-Shift-v');
66
67
  export const find = makeKeyMapWithCommon('Find', 'Mod-f');
67
68
  export const alignLeft = makeKeyMapWithCommon('Align Left', 'Mod-Shift-l');
68
- export const alignRight = makeKeyMapWithCommon('Align Right', 'Mod-Shift-r');
69
69
  const arrowKeysMap = {
70
70
  // for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
71
71
  ARROWLEFT: '\u2190',
72
72
  ARROWRIGHT: '\u2192',
73
73
  ARROWUP: '\u2191',
74
74
  ARROWDOWN: '\u2193'
75
- }; // TOOD: https://product-fabric.atlassian.net/browse/DSP-4460
76
-
77
- /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
78
-
75
+ };
79
76
  const tooltipShortcutStyle = css`
80
77
  border-radius: 2px;
81
- background-color: ${N400};
78
+ background-color: ${token('color.background.inverse.subtle', N400)};
82
79
  padding: 0 2px;
80
+
83
81
  /* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */
84
82
  /* stylelint-disable-next-line */
85
83
  label: tooltip-shortcut;
@@ -20,13 +20,18 @@ export const toolbarInsertBlockMessages = defineMessages({
20
20
  defaultMessage: 'Insert a link',
21
21
  description: 'Insert a hyperlink'
22
22
  },
23
- filesAndImages: {
24
- id: 'fabric.editor.filesAndImages',
25
- defaultMessage: 'Files & images',
26
- description: 'Insert one or more files or images'
27
- },
28
- filesAndImagesDescription: {
29
- id: 'fabric.editor.filesAndImages.description',
23
+ mediaFiles: {
24
+ id: 'fabric.editor.mediaFiles',
25
+ defaultMessage: 'Image, video, or file',
26
+ description: 'Insert one or more files, videos or images'
27
+ },
28
+ addMediaFiles: {
29
+ id: 'fabric.editor.addMediaFiles',
30
+ defaultMessage: 'Add image, video, or file',
31
+ description: 'Insert one or more files, videos or images'
32
+ },
33
+ mediaFilesDescription: {
34
+ id: 'fabric.editor.mediaFiles.description',
30
35
  defaultMessage: 'Add images and other files to your page',
31
36
  description: 'Insert one or more files or images'
32
37
  },
@@ -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';
@@ -8,6 +8,7 @@ export const CodeBlockSharedCssClassName = {
8
8
  CODEBLOCK_CONTAINER: 'code-block',
9
9
  CODEBLOCK_START: 'code-block--start',
10
10
  CODEBLOCK_END: 'code-block--end',
11
+ CODEBLOCK_CONTENT_WRAPPER: 'code-block-content-wrapper',
11
12
  CODEBLOCK_LINE_NUMBER_GUTTER: 'line-number-gutter',
12
13
  CODEBLOCK_CONTENT: 'code-content',
13
14
  DS_CODEBLOCK: '[data-ds--code--code-block]'
@@ -15,36 +16,18 @@ export const CodeBlockSharedCssClassName = {
15
16
  export const codeBlockSharedStyles = props => css`
16
17
  .${CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER} {
17
18
  position: relative;
18
- background-color: ${themed({
19
- light: token('color.background.neutral', N20),
20
- dark: token('color.background.neutral', DN50)
21
- })(props)};
19
+ background-color: ${token('elevation.surface.raised', 'transparent')};
22
20
  border-radius: ${borderRadius()}px;
23
- counter-reset: line;
24
- display: flex;
25
- overflow-x: auto;
26
-
27
- background-image: ${overflowShadow({
28
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
29
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
30
- background: themed({
31
- light: N20,
32
- dark: DN50
33
- })(props),
34
- width: '8px'
35
- })};
36
-
37
- --ds--code--bg-color: transparent;
38
-
39
- background-repeat: no-repeat;
40
- background-attachment: local, scroll, scroll;
41
- background-size: 8px 100%, 8px 100%, 8px 100%;
42
- background-position: 100% 0, 100% 0, 0 0;
43
- font-family: ${akEditorCodeFontFamily};
44
21
  margin: ${blockNodesVerticalMargin} 0 0 0;
22
+ font-family: ${akEditorCodeFontFamily};
45
23
  min-width: ${akEditorTableCellMinWidth}px;
46
24
  cursor: pointer;
47
25
 
26
+ --ds--code--bg-color: transparent;
27
+
28
+ /* This is necessary to allow for arrow key navigation in/out of code blocks in Firefox. */
29
+ white-space: normal;
30
+
48
31
  .${CodeBlockSharedCssClassName.CODEBLOCK_START} {
49
32
  position: absolute;
50
33
  visibility: hidden;
@@ -61,6 +44,36 @@ export const codeBlockSharedStyles = props => css`
61
44
  right: 0px;
62
45
  }
63
46
 
47
+ .${CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER} {
48
+ background-color: ${themed({
49
+ light: token('color.background.neutral', N20),
50
+ dark: token('color.background.neutral', DN50)
51
+ })(props)};
52
+ display: flex;
53
+ border-radius: ${borderRadius()}px;
54
+ width: 100%;
55
+ counter-reset: line;
56
+ overflow-x: auto;
57
+
58
+ background-image: ${overflowShadow({
59
+ // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
60
+ background: themed({
61
+ light: token('color.background.neutral', N20),
62
+ dark: token('color.background.neutral', DN50)
63
+ })(props),
64
+ width: '8px'
65
+ })};
66
+
67
+ background-repeat: no-repeat;
68
+ background-attachment: local, local, local, local, scroll, scroll;
69
+ background-size: 8px 100%, 8px 100%, 8px 100%, 8px 100%, 8px 100%,
70
+ 8px 100%;
71
+ background-position: 0 0, 0 0, 100% 0, 100% 0, 100% 0, 0 0;
72
+
73
+ /* Be careful if refactoring this; it is needed to keep arrow key navigation in Firefox consistent with other browsers. */
74
+ overflow-y: hidden;
75
+ }
76
+
64
77
  .${CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER} {
65
78
  flex-shrink: 0;
66
79
  text-align: right;
@@ -69,6 +82,7 @@ export const codeBlockSharedStyles = props => css`
69
82
  dark: token('color.background.neutral', DN20)
70
83
  })(props)};
71
84
  padding: ${gridSize()}px;
85
+ position: relative;
72
86
 
73
87
  span {
74
88
  display: block;