@atlaskit/editor-core 187.8.3 → 187.8.7
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 +8 -0
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +4 -5
- package/dist/cjs/plugins/annotation/commands/transform.js +2 -2
- package/dist/cjs/plugins/block-type/commands/block-type.js +2 -2
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +2 -2
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +2 -2
- package/dist/cjs/plugins/text-color/commands/toggle-color.js +2 -2
- package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +9 -9
- package/dist/cjs/plugins/text-formatting/commands/transform-to-code.js +2 -2
- package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting.js +2 -5
- package/dist/cjs/plugins/text-formatting/pm-plugins/input-rule.js +2 -2
- package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +2 -1
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +2 -2
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +2 -3
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +2 -2
- package/dist/cjs/ui/Appearance/Comment/Comment.js +5 -6
- package/dist/cjs/ui/Appearance/Comment/Toolbar.js +2 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +2 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +5 -5
- package/dist/cjs/ui/Dropdown/index.js +1 -2
- package/dist/cjs/ui/styles.js +3 -5
- package/dist/cjs/utils/commands.js +8 -121
- package/dist/cjs/utils/index.js +0 -13
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +3 -6
- package/dist/es2019/plugins/annotation/commands/transform.js +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +1 -1
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -5
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -1
- package/dist/es2019/plugins/text-color/commands/toggle-color.js +1 -1
- package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +1 -1
- package/dist/es2019/plugins/text-formatting/commands/transform-to-code.js +1 -1
- package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting.js +2 -2
- package/dist/es2019/plugins/text-formatting/pm-plugins/input-rule.js +1 -1
- package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +2 -1
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +1 -1
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +1 -2
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
- package/dist/es2019/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/es2019/ui/Appearance/Comment/Toolbar.js +3 -2
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +2 -3
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +2 -2
- package/dist/es2019/ui/Dropdown/index.js +1 -2
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/es2019/ui/styles.js +0 -5
- package/dist/es2019/utils/commands.js +1 -113
- package/dist/es2019/utils/index.js +0 -12
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ReactEditorViewInternal.js +3 -6
- package/dist/esm/plugins/annotation/commands/transform.js +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +1 -1
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -5
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -1
- package/dist/esm/plugins/text-color/commands/toggle-color.js +1 -1
- package/dist/esm/plugins/text-formatting/commands/text-formatting.js +1 -1
- package/dist/esm/plugins/text-formatting/commands/transform-to-code.js +1 -1
- package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting.js +2 -2
- package/dist/esm/plugins/text-formatting/pm-plugins/input-rule.js +1 -1
- package/dist/esm/plugins/text-formatting/pm-plugins/main.js +2 -1
- package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +1 -1
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +1 -2
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
- package/dist/esm/ui/Appearance/Comment/Comment.js +4 -5
- package/dist/esm/ui/Appearance/Comment/Toolbar.js +3 -2
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +2 -3
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +2 -2
- package/dist/esm/ui/Dropdown/index.js +1 -2
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/esm/ui/styles.js +2 -3
- package/dist/esm/utils/commands.js +7 -118
- package/dist/esm/utils/index.js +0 -12
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -1
- package/dist/types/plugins/block-type/commands/block-type.d.ts +1 -2
- package/dist/types/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
- package/dist/types/plugins/text-color/commands/toggle-color.d.ts +1 -1
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +2 -2
- package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +1 -1
- package/dist/types/types/editor-appearance-component.d.ts +4 -4
- package/dist/types/types/editor-instance.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +5 -8
- package/dist/types/ui/Appearance/Comment/Comment.d.ts +2 -2
- package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +1 -2
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/types.d.ts +1 -1
- package/dist/types/ui/styles.d.ts +0 -1
- package/dist/types/utils/commands.d.ts +2 -12
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -1
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +1 -2
- package/dist/types-ts4.5/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +1 -1
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +2 -2
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-appearance-component.d.ts +4 -4
- package/dist/types-ts4.5/types/editor-instance.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +5 -8
- package/dist/types-ts4.5/ui/Appearance/Comment/Comment.d.ts +2 -2
- package/dist/types-ts4.5/ui/Appearance/Comment/Toolbar.d.ts +1 -2
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types-ts4.5/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +1 -1
- package/dist/types-ts4.5/ui/ElementBrowser/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/styles.d.ts +0 -1
- package/dist/types-ts4.5/utils/commands.d.ts +2 -12
- package/dist/types-ts4.5/utils/index.d.ts +0 -4
- package/package.json +3 -3
- package/report.api.md +2 -10
- package/tmp/api-report-tmp.d.ts +2 -7
- package/dist/cjs/ui/Appearance/FullPage/messages.js +0 -25
- package/dist/cjs/ui/DropdownMenu/index.js +0 -31
- package/dist/cjs/ui/DropdownMenu/types.js +0 -5
- package/dist/cjs/ui/ToolbarArrowKeyNavigationProvider/index.js +0 -218
- package/dist/es2019/ui/Appearance/FullPage/messages.js +0 -18
- package/dist/es2019/ui/DropdownMenu/index.js +0 -18
- package/dist/es2019/ui/DropdownMenu/types.js +0 -1
- package/dist/es2019/ui/ToolbarArrowKeyNavigationProvider/index.js +0 -205
- package/dist/esm/ui/Appearance/FullPage/messages.js +0 -18
- package/dist/esm/ui/DropdownMenu/index.js +0 -20
- package/dist/esm/ui/DropdownMenu/types.js +0 -1
- package/dist/esm/ui/ToolbarArrowKeyNavigationProvider/index.js +0 -205
- package/dist/types/ui/Appearance/FullPage/messages.d.ts +0 -18
- package/dist/types/ui/DropdownMenu/index.d.ts +0 -3
- package/dist/types/ui/DropdownMenu/types.d.ts +0 -1
- package/dist/types/ui/ToolbarArrowKeyNavigationProvider/index.d.ts +0 -31
- package/dist/types-ts4.5/ui/Appearance/FullPage/messages.d.ts +0 -18
- package/dist/types-ts4.5/ui/DropdownMenu/index.d.ts +0 -3
- package/dist/types-ts4.5/ui/DropdownMenu/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/ToolbarArrowKeyNavigationProvider/index.d.ts +0 -31
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ import type { MentionDescription } from '@atlaskit/mention';
|
|
|
99
99
|
import { MentionProvider } from '@atlaskit/mention/resource';
|
|
100
100
|
import type { MentionProvider as MentionProvider_2 } from '@atlaskit/mention';
|
|
101
101
|
import { MentionResource } from '@atlaskit/mention/resource';
|
|
102
|
-
import { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
102
|
+
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
103
103
|
import { default as messages } from '@atlaskit/editor-common/messages';
|
|
104
104
|
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
105
105
|
import { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -129,7 +129,6 @@ import { QuickInsertProvider } from '@atlaskit/editor-common/provider-factory';
|
|
|
129
129
|
import { default as React_2 } from 'react';
|
|
130
130
|
import { ReactElement } from 'react';
|
|
131
131
|
import type { ReactHookFactory } from '@atlaskit/editor-common/types';
|
|
132
|
-
import type { RefObject } from 'react';
|
|
133
132
|
import type { ReplaceRawValue } from '@atlaskit/editor-common/types';
|
|
134
133
|
import type { ResolvedEditorState } from '@atlaskit/collab-provider';
|
|
135
134
|
import type { RichMediaLayout } from '@atlaskit/adf-schema';
|
|
@@ -154,6 +153,7 @@ import { UploadEndEventPayload } from '@atlaskit/media-picker/types';
|
|
|
154
153
|
import { UploadErrorEventPayload } from '@atlaskit/media-picker/types';
|
|
155
154
|
import { UploadParams } from '@atlaskit/media-picker/types';
|
|
156
155
|
import { UploadPreviewUpdateEventPayload } from '@atlaskit/media-picker/types';
|
|
156
|
+
import type { UseStickyToolbarType } from '@atlaskit/editor-common/ui';
|
|
157
157
|
import type { WeekDay } from '@atlaskit/calendar/types';
|
|
158
158
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
159
159
|
import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
|
|
@@ -2164,11 +2164,6 @@ export const updateStatus: (status?: StatusType) => Command;
|
|
|
2164
2164
|
// @public (undocumented)
|
|
2165
2165
|
export const updateStatusWithAnalytics: (inputMethod: InsertBlockInputMethodToolbar, status?: StatusType) => Command;
|
|
2166
2166
|
|
|
2167
|
-
// @public (undocumented)
|
|
2168
|
-
type UseStickyToolbarType = RefObject<HTMLElement> | boolean | {
|
|
2169
|
-
offsetTop: number;
|
|
2170
|
-
};
|
|
2171
|
-
|
|
2172
2167
|
// @public (undocumented)
|
|
2173
2168
|
export const version: string;
|
|
2174
2169
|
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactIntlNext = require("react-intl-next");
|
|
8
|
-
var _default = (0, _reactIntlNext.defineMessages)({
|
|
9
|
-
toolbarLabel: {
|
|
10
|
-
id: 'fabric.editor.toolbarLabel',
|
|
11
|
-
defaultMessage: 'Editor toolbar',
|
|
12
|
-
description: 'Label for the ARIA region landmark'
|
|
13
|
-
},
|
|
14
|
-
pageActionsLabel: {
|
|
15
|
-
id: 'fabric.editor.pageActionsLabel',
|
|
16
|
-
defaultMessage: 'Page actions',
|
|
17
|
-
description: 'Label for the ARIA region landmark'
|
|
18
|
-
},
|
|
19
|
-
editableContentLabel: {
|
|
20
|
-
id: 'fabric.editor.editableContentLabel',
|
|
21
|
-
defaultMessage: 'Editable content',
|
|
22
|
-
description: 'Label for the ARIA region landmark'
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
exports.default = _default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
|
|
11
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
13
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _ToolbarArrowKeyNavigationProvider = require("../ToolbarArrowKeyNavigationProvider");
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
var DropdownMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
20
|
-
var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref), _ref));
|
|
21
|
-
var keyDownHandlerContext = (0, _react.useContext)(_ToolbarArrowKeyNavigationProvider.KeyDownHandlerContext);
|
|
22
|
-
//This context is to handle the tab, Arrow Right/Left key events for dropdown.
|
|
23
|
-
//Default context has the void callbacks for above key events
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenu, (0, _extends2.default)({
|
|
25
|
-
arrowKeyNavigationProviderOptions: _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
|
|
26
|
-
keyDownHandlerContext: keyDownHandlerContext
|
|
27
|
-
})
|
|
28
|
-
}, props));
|
|
29
|
-
});
|
|
30
|
-
var _default = DropdownMenu;
|
|
31
|
-
exports.default = _default;
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.ToolbarArrowKeyNavigationProvider = exports.KeyDownHandlerContext = void 0;
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _styles = require("../styles");
|
|
11
|
-
var _react2 = _interopRequireWildcard(require("react"));
|
|
12
|
-
var _ReactEditorViewInternal = require("../../create-editor/ReactEditorViewInternal");
|
|
13
|
-
var _messages = _interopRequireDefault(require("../Appearance/FullPage/messages"));
|
|
14
|
-
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); }
|
|
15
|
-
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; }
|
|
16
|
-
/** @jsx jsx */
|
|
17
|
-
/* eslint-disable no-console */
|
|
18
|
-
|
|
19
|
-
/*
|
|
20
|
-
** The context is used to handle the keydown events of submenus.
|
|
21
|
-
** Because the keyboard navigation is explicitly managed for main toolbar items
|
|
22
|
-
** Few key presses such as Tab,Arrow Right/Left need ot be handled here via context
|
|
23
|
-
*/
|
|
24
|
-
var KeyDownHandlerContext = /*#__PURE__*/_react2.default.createContext({
|
|
25
|
-
handleArrowLeft: function handleArrowLeft() {},
|
|
26
|
-
handleArrowRight: function handleArrowRight() {},
|
|
27
|
-
handleTab: function handleTab() {}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* This component is a wrapper of main toolbar which listens to keydown events of children
|
|
32
|
-
* and handles left/right arrow key navigation for all focusable elements
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
exports.KeyDownHandlerContext = KeyDownHandlerContext;
|
|
37
|
-
var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigationProvider(_ref) {
|
|
38
|
-
var children = _ref.children,
|
|
39
|
-
editorView = _ref.editorView,
|
|
40
|
-
childComponentSelector = _ref.childComponentSelector,
|
|
41
|
-
handleEscape = _ref.handleEscape,
|
|
42
|
-
disableArrowKeyNavigation = _ref.disableArrowKeyNavigation,
|
|
43
|
-
isShortcutToFocusToolbar = _ref.isShortcutToFocusToolbar,
|
|
44
|
-
editorAppearance = _ref.editorAppearance,
|
|
45
|
-
useStickyToolbar = _ref.useStickyToolbar,
|
|
46
|
-
intl = _ref.intl;
|
|
47
|
-
var wrapperRef = (0, _react2.useRef)(null);
|
|
48
|
-
var selectedItemIndex = (0, _react2.useRef)(0);
|
|
49
|
-
var incrementIndex = (0, _react2.useCallback)(function (list) {
|
|
50
|
-
var index = 0;
|
|
51
|
-
if (document.activeElement) {
|
|
52
|
-
index = list.indexOf(document.activeElement);
|
|
53
|
-
index = (index + 1) % list.length;
|
|
54
|
-
}
|
|
55
|
-
selectedItemIndex.current = index;
|
|
56
|
-
}, []);
|
|
57
|
-
var decrementIndex = (0, _react2.useCallback)(function (list) {
|
|
58
|
-
var index = 0;
|
|
59
|
-
if (document.activeElement) {
|
|
60
|
-
index = list.indexOf(document.activeElement);
|
|
61
|
-
index = (list.length + index - 1) % list.length;
|
|
62
|
-
}
|
|
63
|
-
selectedItemIndex.current = index;
|
|
64
|
-
}, []);
|
|
65
|
-
var handleArrowRight = function handleArrowRight() {
|
|
66
|
-
var _filteredFocusableEle;
|
|
67
|
-
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
68
|
-
incrementIndex(filteredFocusableElements);
|
|
69
|
-
(_filteredFocusableEle = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
|
|
70
|
-
};
|
|
71
|
-
var handleArrowLeft = function handleArrowLeft() {
|
|
72
|
-
var _filteredFocusableEle2;
|
|
73
|
-
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
74
|
-
decrementIndex(filteredFocusableElements);
|
|
75
|
-
(_filteredFocusableEle2 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.focus();
|
|
76
|
-
};
|
|
77
|
-
var handleTab = function handleTab() {
|
|
78
|
-
var _filteredFocusableEle3;
|
|
79
|
-
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
80
|
-
(_filteredFocusableEle3 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.focus();
|
|
81
|
-
};
|
|
82
|
-
var handleTabLocal = function handleTabLocal() {
|
|
83
|
-
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
84
|
-
filteredFocusableElements.forEach(function (element) {
|
|
85
|
-
element.setAttribute('tabindex', '-1');
|
|
86
|
-
});
|
|
87
|
-
filteredFocusableElements[selectedItemIndex.current].setAttribute('tabindex', '0');
|
|
88
|
-
};
|
|
89
|
-
var focusAndScrollToElement = function focusAndScrollToElement(element) {
|
|
90
|
-
var scrollToElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
91
|
-
if (scrollToElement) {
|
|
92
|
-
element === null || element === void 0 ? void 0 : element.scrollIntoView({
|
|
93
|
-
behavior: 'smooth',
|
|
94
|
-
block: 'center',
|
|
95
|
-
inline: 'nearest'
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
element.focus();
|
|
99
|
-
};
|
|
100
|
-
var submenuKeydownHandleContext = {
|
|
101
|
-
handleArrowLeft: handleArrowLeft,
|
|
102
|
-
handleArrowRight: handleArrowRight,
|
|
103
|
-
handleTab: handleTab
|
|
104
|
-
};
|
|
105
|
-
(0, _react2.useLayoutEffect)(function () {
|
|
106
|
-
if (!wrapperRef.current || disableArrowKeyNavigation) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
var element = wrapperRef.current;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* To handle the key events on the list
|
|
113
|
-
* @param event
|
|
114
|
-
*/
|
|
115
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
116
|
-
var _document$querySelect, _document$querySelect2, _wrapperRef$current;
|
|
117
|
-
//To trap the focus inside the horizontal toolbar for left and right arrow keys
|
|
118
|
-
var targetElement = event.target;
|
|
119
|
-
|
|
120
|
-
//To filter out the events outside the child component
|
|
121
|
-
if (!targetElement.closest("".concat(childComponentSelector))) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
//The key events are from child components such as dropdown menus / popups are ignored
|
|
126
|
-
if ((_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
var menuWrapper = document.querySelector('.menu-key-handler-wrapper');
|
|
130
|
-
if (menuWrapper) {
|
|
131
|
-
// if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
135
|
-
if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//This is kind of hack to reset the current focused toolbar item
|
|
140
|
-
//to handle some use cases such as Tab in/out of main toolbar
|
|
141
|
-
if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
|
|
142
|
-
selectedItemIndex.current = -1;
|
|
143
|
-
} else {
|
|
144
|
-
selectedItemIndex.current = filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//do not scroll to focused element for sticky toolbar when navigating with arrows to avoid unnesessary scroll jump
|
|
148
|
-
var allowScrollToElement = !(editorAppearance === 'comment' && !!useStickyToolbar);
|
|
149
|
-
switch (event.key) {
|
|
150
|
-
case 'ArrowRight':
|
|
151
|
-
incrementIndex(filteredFocusableElements);
|
|
152
|
-
focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
|
|
153
|
-
event.preventDefault();
|
|
154
|
-
break;
|
|
155
|
-
case 'ArrowLeft':
|
|
156
|
-
decrementIndex(filteredFocusableElements);
|
|
157
|
-
focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
break;
|
|
160
|
-
case 'Tab':
|
|
161
|
-
handleTabLocal();
|
|
162
|
-
break;
|
|
163
|
-
case 'Escape':
|
|
164
|
-
handleEscape(event);
|
|
165
|
-
break;
|
|
166
|
-
default:
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
var globalKeyDownHandler = function globalKeyDownHandler(event) {
|
|
170
|
-
//To focus the first element in the toolbar
|
|
171
|
-
if (isShortcutToFocusToolbar(event)) {
|
|
172
|
-
var _filteredFocusableEle4, _filteredFocusableEle5;
|
|
173
|
-
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
174
|
-
(_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
|
|
175
|
-
(_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
|
|
176
|
-
behavior: 'smooth',
|
|
177
|
-
block: 'center',
|
|
178
|
-
inline: 'nearest'
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
|
|
183
|
-
var editorViewDom = editorView === null || editorView === void 0 ? void 0 : editorView.dom;
|
|
184
|
-
if (isShortcutToFocusToolbar) {
|
|
185
|
-
editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.addEventListener('keydown', globalKeyDownHandler);
|
|
186
|
-
}
|
|
187
|
-
return function () {
|
|
188
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
|
|
189
|
-
if (isShortcutToFocusToolbar) {
|
|
190
|
-
editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.removeEventListener('keydown', globalKeyDownHandler);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar, editorAppearance, useStickyToolbar]);
|
|
194
|
-
return (0, _react.jsx)("div", {
|
|
195
|
-
css: editorAppearance === 'comment' && _styles.centeredToolbarContainer,
|
|
196
|
-
className: "custom-key-handler-wrapper",
|
|
197
|
-
ref: wrapperRef,
|
|
198
|
-
role: "toolbar",
|
|
199
|
-
"aria-label": intl.formatMessage(_messages.default.toolbarLabel),
|
|
200
|
-
"aria-controls": _ReactEditorViewInternal.EDIT_AREA_ID
|
|
201
|
-
}, (0, _react.jsx)(KeyDownHandlerContext.Provider, {
|
|
202
|
-
value: submenuKeydownHandleContext
|
|
203
|
-
}, children));
|
|
204
|
-
};
|
|
205
|
-
exports.ToolbarArrowKeyNavigationProvider = ToolbarArrowKeyNavigationProvider;
|
|
206
|
-
function getFocusableElements(rootNode) {
|
|
207
|
-
if (!rootNode) {
|
|
208
|
-
return [];
|
|
209
|
-
}
|
|
210
|
-
var focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || [];
|
|
211
|
-
return Array.from(focusableModalElements);
|
|
212
|
-
}
|
|
213
|
-
function getFilteredFocusableElements(rootNode) {
|
|
214
|
-
//The focusable elements from child components such as dropdown menus / popups are ignored
|
|
215
|
-
return getFocusableElements(rootNode).filter(function (elm) {
|
|
216
|
-
return !elm.closest('[data-role="droplistContent"]') && !elm.closest('[data-emoji-picker-container="true"]') && !elm.closest('[data-test-id="color-picker-menu"]') && !elm.closest('.scroll-buttons');
|
|
217
|
-
});
|
|
218
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from 'react-intl-next';
|
|
2
|
-
export default defineMessages({
|
|
3
|
-
toolbarLabel: {
|
|
4
|
-
id: 'fabric.editor.toolbarLabel',
|
|
5
|
-
defaultMessage: 'Editor toolbar',
|
|
6
|
-
description: 'Label for the ARIA region landmark'
|
|
7
|
-
},
|
|
8
|
-
pageActionsLabel: {
|
|
9
|
-
id: 'fabric.editor.pageActionsLabel',
|
|
10
|
-
defaultMessage: 'Page actions',
|
|
11
|
-
description: 'Label for the ARIA region landmark'
|
|
12
|
-
},
|
|
13
|
-
editableContentLabel: {
|
|
14
|
-
id: 'fabric.editor.editableContentLabel',
|
|
15
|
-
defaultMessage: 'Editable content',
|
|
16
|
-
description: 'Label for the ARIA region landmark'
|
|
17
|
-
}
|
|
18
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { DropdownMenu as DropdownComponent } from '@atlaskit/editor-common/ui-menu';
|
|
3
|
-
import React, { useContext } from 'react';
|
|
4
|
-
import { KeyDownHandlerContext } from '../ToolbarArrowKeyNavigationProvider';
|
|
5
|
-
const DropdownMenu = /*#__PURE__*/React.memo(({
|
|
6
|
-
...props
|
|
7
|
-
}) => {
|
|
8
|
-
const keyDownHandlerContext = useContext(KeyDownHandlerContext);
|
|
9
|
-
//This context is to handle the tab, Arrow Right/Left key events for dropdown.
|
|
10
|
-
//Default context has the void callbacks for above key events
|
|
11
|
-
return /*#__PURE__*/React.createElement(DropdownComponent, _extends({
|
|
12
|
-
arrowKeyNavigationProviderOptions: {
|
|
13
|
-
...props.arrowKeyNavigationProviderOptions,
|
|
14
|
-
keyDownHandlerContext
|
|
15
|
-
}
|
|
16
|
-
}, props));
|
|
17
|
-
});
|
|
18
|
-
export default DropdownMenu;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import { centeredToolbarContainer } from '../styles';
|
|
5
|
-
import React, { useCallback, useLayoutEffect, useRef } from 'react';
|
|
6
|
-
import { EDIT_AREA_ID } from '../../create-editor/ReactEditorViewInternal';
|
|
7
|
-
import messages from '../Appearance/FullPage/messages';
|
|
8
|
-
/*
|
|
9
|
-
** The context is used to handle the keydown events of submenus.
|
|
10
|
-
** Because the keyboard navigation is explicitly managed for main toolbar items
|
|
11
|
-
** Few key presses such as Tab,Arrow Right/Left need ot be handled here via context
|
|
12
|
-
*/
|
|
13
|
-
export const KeyDownHandlerContext = /*#__PURE__*/React.createContext({
|
|
14
|
-
handleArrowLeft: () => {},
|
|
15
|
-
handleArrowRight: () => {},
|
|
16
|
-
handleTab: () => {}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* This component is a wrapper of main toolbar which listens to keydown events of children
|
|
21
|
-
* and handles left/right arrow key navigation for all focusable elements
|
|
22
|
-
* @param
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export const ToolbarArrowKeyNavigationProvider = ({
|
|
26
|
-
children,
|
|
27
|
-
editorView,
|
|
28
|
-
childComponentSelector,
|
|
29
|
-
handleEscape,
|
|
30
|
-
disableArrowKeyNavigation,
|
|
31
|
-
isShortcutToFocusToolbar,
|
|
32
|
-
editorAppearance,
|
|
33
|
-
useStickyToolbar,
|
|
34
|
-
intl
|
|
35
|
-
}) => {
|
|
36
|
-
const wrapperRef = useRef(null);
|
|
37
|
-
const selectedItemIndex = useRef(0);
|
|
38
|
-
const incrementIndex = useCallback(list => {
|
|
39
|
-
let index = 0;
|
|
40
|
-
if (document.activeElement) {
|
|
41
|
-
index = list.indexOf(document.activeElement);
|
|
42
|
-
index = (index + 1) % list.length;
|
|
43
|
-
}
|
|
44
|
-
selectedItemIndex.current = index;
|
|
45
|
-
}, []);
|
|
46
|
-
const decrementIndex = useCallback(list => {
|
|
47
|
-
let index = 0;
|
|
48
|
-
if (document.activeElement) {
|
|
49
|
-
index = list.indexOf(document.activeElement);
|
|
50
|
-
index = (list.length + index - 1) % list.length;
|
|
51
|
-
}
|
|
52
|
-
selectedItemIndex.current = index;
|
|
53
|
-
}, []);
|
|
54
|
-
const handleArrowRight = () => {
|
|
55
|
-
var _filteredFocusableEle;
|
|
56
|
-
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
57
|
-
incrementIndex(filteredFocusableElements);
|
|
58
|
-
(_filteredFocusableEle = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
|
|
59
|
-
};
|
|
60
|
-
const handleArrowLeft = () => {
|
|
61
|
-
var _filteredFocusableEle2;
|
|
62
|
-
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
63
|
-
decrementIndex(filteredFocusableElements);
|
|
64
|
-
(_filteredFocusableEle2 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.focus();
|
|
65
|
-
};
|
|
66
|
-
const handleTab = () => {
|
|
67
|
-
var _filteredFocusableEle3;
|
|
68
|
-
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
69
|
-
(_filteredFocusableEle3 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.focus();
|
|
70
|
-
};
|
|
71
|
-
const handleTabLocal = () => {
|
|
72
|
-
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
73
|
-
filteredFocusableElements.forEach(element => {
|
|
74
|
-
element.setAttribute('tabindex', '-1');
|
|
75
|
-
});
|
|
76
|
-
filteredFocusableElements[selectedItemIndex.current].setAttribute('tabindex', '0');
|
|
77
|
-
};
|
|
78
|
-
const focusAndScrollToElement = (element, scrollToElement = true) => {
|
|
79
|
-
if (scrollToElement) {
|
|
80
|
-
element === null || element === void 0 ? void 0 : element.scrollIntoView({
|
|
81
|
-
behavior: 'smooth',
|
|
82
|
-
block: 'center',
|
|
83
|
-
inline: 'nearest'
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
element.focus();
|
|
87
|
-
};
|
|
88
|
-
const submenuKeydownHandleContext = {
|
|
89
|
-
handleArrowLeft,
|
|
90
|
-
handleArrowRight,
|
|
91
|
-
handleTab
|
|
92
|
-
};
|
|
93
|
-
useLayoutEffect(() => {
|
|
94
|
-
if (!wrapperRef.current || disableArrowKeyNavigation) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const {
|
|
98
|
-
current: element
|
|
99
|
-
} = wrapperRef;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* To handle the key events on the list
|
|
103
|
-
* @param event
|
|
104
|
-
*/
|
|
105
|
-
const handleKeyDown = event => {
|
|
106
|
-
var _document$querySelect, _document$querySelect2, _wrapperRef$current;
|
|
107
|
-
//To trap the focus inside the horizontal toolbar for left and right arrow keys
|
|
108
|
-
const targetElement = event.target;
|
|
109
|
-
|
|
110
|
-
//To filter out the events outside the child component
|
|
111
|
-
if (!targetElement.closest(`${childComponentSelector}`)) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//The key events are from child components such as dropdown menus / popups are ignored
|
|
116
|
-
if ((_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const menuWrapper = document.querySelector('.menu-key-handler-wrapper');
|
|
120
|
-
if (menuWrapper) {
|
|
121
|
-
// if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
125
|
-
if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
//This is kind of hack to reset the current focused toolbar item
|
|
130
|
-
//to handle some use cases such as Tab in/out of main toolbar
|
|
131
|
-
if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
|
|
132
|
-
selectedItemIndex.current = -1;
|
|
133
|
-
} else {
|
|
134
|
-
selectedItemIndex.current = filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
//do not scroll to focused element for sticky toolbar when navigating with arrows to avoid unnesessary scroll jump
|
|
138
|
-
const allowScrollToElement = !(editorAppearance === 'comment' && !!useStickyToolbar);
|
|
139
|
-
switch (event.key) {
|
|
140
|
-
case 'ArrowRight':
|
|
141
|
-
incrementIndex(filteredFocusableElements);
|
|
142
|
-
focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
|
|
143
|
-
event.preventDefault();
|
|
144
|
-
break;
|
|
145
|
-
case 'ArrowLeft':
|
|
146
|
-
decrementIndex(filteredFocusableElements);
|
|
147
|
-
focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
|
|
148
|
-
event.preventDefault();
|
|
149
|
-
break;
|
|
150
|
-
case 'Tab':
|
|
151
|
-
handleTabLocal();
|
|
152
|
-
break;
|
|
153
|
-
case 'Escape':
|
|
154
|
-
handleEscape(event);
|
|
155
|
-
break;
|
|
156
|
-
default:
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const globalKeyDownHandler = event => {
|
|
160
|
-
//To focus the first element in the toolbar
|
|
161
|
-
if (isShortcutToFocusToolbar(event)) {
|
|
162
|
-
var _filteredFocusableEle4, _filteredFocusableEle5;
|
|
163
|
-
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
164
|
-
(_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
|
|
165
|
-
(_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
|
|
166
|
-
behavior: 'smooth',
|
|
167
|
-
block: 'center',
|
|
168
|
-
inline: 'nearest'
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
|
|
173
|
-
const editorViewDom = editorView === null || editorView === void 0 ? void 0 : editorView.dom;
|
|
174
|
-
if (isShortcutToFocusToolbar) {
|
|
175
|
-
editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.addEventListener('keydown', globalKeyDownHandler);
|
|
176
|
-
}
|
|
177
|
-
return () => {
|
|
178
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
|
|
179
|
-
if (isShortcutToFocusToolbar) {
|
|
180
|
-
editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.removeEventListener('keydown', globalKeyDownHandler);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar, editorAppearance, useStickyToolbar]);
|
|
184
|
-
return jsx("div", {
|
|
185
|
-
css: editorAppearance === 'comment' && centeredToolbarContainer,
|
|
186
|
-
className: "custom-key-handler-wrapper",
|
|
187
|
-
ref: wrapperRef,
|
|
188
|
-
role: "toolbar",
|
|
189
|
-
"aria-label": intl.formatMessage(messages.toolbarLabel),
|
|
190
|
-
"aria-controls": EDIT_AREA_ID
|
|
191
|
-
}, jsx(KeyDownHandlerContext.Provider, {
|
|
192
|
-
value: submenuKeydownHandleContext
|
|
193
|
-
}, children));
|
|
194
|
-
};
|
|
195
|
-
function getFocusableElements(rootNode) {
|
|
196
|
-
if (!rootNode) {
|
|
197
|
-
return [];
|
|
198
|
-
}
|
|
199
|
-
const focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || [];
|
|
200
|
-
return Array.from(focusableModalElements);
|
|
201
|
-
}
|
|
202
|
-
function getFilteredFocusableElements(rootNode) {
|
|
203
|
-
//The focusable elements from child components such as dropdown menus / popups are ignored
|
|
204
|
-
return getFocusableElements(rootNode).filter(elm => !elm.closest('[data-role="droplistContent"]') && !elm.closest('[data-emoji-picker-container="true"]') && !elm.closest('[data-test-id="color-picker-menu"]') && !elm.closest('.scroll-buttons'));
|
|
205
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from 'react-intl-next';
|
|
2
|
-
export default defineMessages({
|
|
3
|
-
toolbarLabel: {
|
|
4
|
-
id: 'fabric.editor.toolbarLabel',
|
|
5
|
-
defaultMessage: 'Editor toolbar',
|
|
6
|
-
description: 'Label for the ARIA region landmark'
|
|
7
|
-
},
|
|
8
|
-
pageActionsLabel: {
|
|
9
|
-
id: 'fabric.editor.pageActionsLabel',
|
|
10
|
-
defaultMessage: 'Page actions',
|
|
11
|
-
description: 'Label for the ARIA region landmark'
|
|
12
|
-
},
|
|
13
|
-
editableContentLabel: {
|
|
14
|
-
id: 'fabric.editor.editableContentLabel',
|
|
15
|
-
defaultMessage: 'Editable content',
|
|
16
|
-
description: 'Label for the ARIA region landmark'
|
|
17
|
-
}
|
|
18
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
3
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
import { DropdownMenu as DropdownComponent } from '@atlaskit/editor-common/ui-menu';
|
|
7
|
-
import React, { useContext } from 'react';
|
|
8
|
-
import { KeyDownHandlerContext } from '../ToolbarArrowKeyNavigationProvider';
|
|
9
|
-
var DropdownMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
10
|
-
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
11
|
-
var keyDownHandlerContext = useContext(KeyDownHandlerContext);
|
|
12
|
-
//This context is to handle the tab, Arrow Right/Left key events for dropdown.
|
|
13
|
-
//Default context has the void callbacks for above key events
|
|
14
|
-
return /*#__PURE__*/React.createElement(DropdownComponent, _extends({
|
|
15
|
-
arrowKeyNavigationProviderOptions: _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
|
|
16
|
-
keyDownHandlerContext: keyDownHandlerContext
|
|
17
|
-
})
|
|
18
|
-
}, props));
|
|
19
|
-
});
|
|
20
|
-
export default DropdownMenu;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|