@atlaskit/editor-plugin-toolbar 3.2.1 → 3.3.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +23 -3
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-dev-agents/tsconfig.json +3 -0
  4. package/afm-jira/tsconfig.json +3 -0
  5. package/afm-passionfruit/tsconfig.json +3 -0
  6. package/afm-post-office/tsconfig.json +3 -0
  7. package/afm-rovo-extension/tsconfig.json +3 -0
  8. package/afm-townsquare/tsconfig.json +3 -0
  9. package/dist/cjs/pm-plugins/experiences/ContextualToolbarOpenExperience.js +73 -0
  10. package/dist/cjs/toolbarPlugin.js +17 -1
  11. package/dist/cjs/ui/SelectionToolbar/index.js +66 -93
  12. package/dist/cjs/ui/SelectionToolbar/keyboard-config.js +70 -0
  13. package/dist/cjs/ui/SelectionToolbar/utils.js +42 -0
  14. package/dist/es2019/pm-plugins/experiences/ContextualToolbarOpenExperience.js +61 -0
  15. package/dist/es2019/toolbarPlugin.js +16 -3
  16. package/dist/es2019/ui/SelectionToolbar/index.js +63 -91
  17. package/dist/es2019/ui/SelectionToolbar/keyboard-config.js +64 -0
  18. package/dist/es2019/ui/SelectionToolbar/utils.js +36 -0
  19. package/dist/esm/pm-plugins/experiences/ContextualToolbarOpenExperience.js +66 -0
  20. package/dist/esm/toolbarPlugin.js +19 -3
  21. package/dist/esm/ui/SelectionToolbar/index.js +64 -91
  22. package/dist/esm/ui/SelectionToolbar/keyboard-config.js +64 -0
  23. package/dist/esm/ui/SelectionToolbar/utils.js +36 -0
  24. package/dist/types/pm-plugins/experiences/ContextualToolbarOpenExperience.d.ts +5 -0
  25. package/dist/types/ui/SelectionToolbar/index.d.ts +2 -1
  26. package/dist/types/ui/SelectionToolbar/keyboard-config.d.ts +6 -0
  27. package/dist/types/ui/SelectionToolbar/utils.d.ts +3 -0
  28. package/dist/types-ts4.5/pm-plugins/experiences/ContextualToolbarOpenExperience.d.ts +5 -0
  29. package/dist/types-ts4.5/ui/SelectionToolbar/index.d.ts +2 -1
  30. package/dist/types-ts4.5/ui/SelectionToolbar/keyboard-config.d.ts +6 -0
  31. package/dist/types-ts4.5/ui/SelectionToolbar/utils.d.ts +3 -0
  32. package/package.json +13 -4
@@ -0,0 +1,64 @@
1
+ import { getDocument } from '@atlaskit/browser-apis';
2
+ import { fullPageMessages } from '@atlaskit/editor-common/messages';
3
+ import { logException } from '@atlaskit/editor-common/monitoring';
4
+ import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
5
+ import { getFocusableElements, isShortcutToFocusToolbar } from '../utils/toolbar';
6
+ export var getKeyboardNavigationConfig = function getKeyboardNavigationConfig(editorView, intl, api) {
7
+ if (!(editorView.dom instanceof HTMLElement)) {
8
+ return;
9
+ }
10
+ var toolbarSelector = "[data-testid='editor-floating-toolbar']";
11
+ return {
12
+ childComponentSelector: toolbarSelector,
13
+ dom: editorView.dom,
14
+ isShortcutToFocusToolbar: isShortcutToFocusToolbar,
15
+ handleFocus: function handleFocus(event) {
16
+ try {
17
+ var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
18
+ var toolbar = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
19
+ if (!(toolbar instanceof HTMLElement)) {
20
+ return;
21
+ }
22
+ var filteredFocusableElements = getFocusableElements(toolbar);
23
+ (_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 || _filteredFocusableEle.focus();
24
+
25
+ // the button element removes the focus ring so this class adds it back
26
+ if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
27
+ filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
28
+ }
29
+ (_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 || _filteredFocusableEle3.scrollIntoView({
30
+ behavior: 'smooth',
31
+ block: 'center',
32
+ inline: 'nearest'
33
+ });
34
+ event.preventDefault();
35
+ event.stopPropagation();
36
+ } catch (error) {
37
+ if (error instanceof Error) {
38
+ logException(error, {
39
+ location: 'editor-plugin-toolbar/selectionToolbar'
40
+ });
41
+ }
42
+ }
43
+ },
44
+ handleEscape: function handleEscape(event) {
45
+ try {
46
+ var isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
47
+ if (isDropdownOpen) {
48
+ return;
49
+ }
50
+ api === null || api === void 0 || api.core.actions.focus();
51
+ event.preventDefault();
52
+ event.stopPropagation();
53
+ } catch (error) {
54
+ if (error instanceof Error) {
55
+ logException(error, {
56
+ location: 'editor-plugin-toolbar/selectionToolbar'
57
+ });
58
+ }
59
+ }
60
+ },
61
+ ariaControls: EDIT_AREA_ID,
62
+ ariaLabel: intl.formatMessage(fullPageMessages.toolbarLabel)
63
+ };
64
+ };
@@ -0,0 +1,36 @@
1
+ import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { logException } from '@atlaskit/editor-common/monitoring';
3
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
+ export var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
5
+ try {
6
+ var domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
7
+ if (domRef instanceof HTMLElement) {
8
+ return domRef;
9
+ }
10
+ throw new Error('Invalid DOM reference');
11
+ } catch (error) {
12
+ if (dispatchAnalyticsEvent) {
13
+ var payload = {
14
+ action: ACTION.ERRORED,
15
+ actionSubject: ACTION_SUBJECT.CONTENT_COMPONENT,
16
+ eventType: EVENT_TYPE.OPERATIONAL,
17
+ attributes: {
18
+ component: CONTENT_COMPONENT.SELECTION_TOOLBAR,
19
+ selection: view.state.selection.toJSON(),
20
+ position: view.state.selection.from,
21
+ docSize: view.state.doc.nodeSize,
22
+ error: error instanceof Error ? error.toString() : String(error),
23
+ // @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
24
+ // This error was introduced after upgrading to TypeScript 5
25
+ errorStack: error instanceof Error ? error.stack : undefined
26
+ }
27
+ };
28
+ dispatchAnalyticsEvent(payload);
29
+ }
30
+ if (error instanceof Error) {
31
+ logException(error, {
32
+ location: 'editor-plugin-toolbar/selectionToolbar'
33
+ });
34
+ }
35
+ }
36
+ };
@@ -0,0 +1,5 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ declare const _default: () => SafePlugin<{
3
+ shouldShowContextualToolbar: boolean;
4
+ }>;
5
+ export default _default;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ToolbarPlugin } from '../../toolbarPluginType';
5
5
  type SelectionToolbarProps = {
6
6
  api?: ExtractInjectionAPI<ToolbarPlugin>;
@@ -9,4 +9,5 @@ type SelectionToolbarProps = {
9
9
  mountPoint: HTMLElement | undefined;
10
10
  };
11
11
  export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
12
+ export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
12
13
  export {};
@@ -0,0 +1,6 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { type ToolbarKeyboardNavigationProviderConfig } from '@atlaskit/editor-toolbar';
5
+ import type { ToolbarPlugin } from '../../toolbarPluginType';
6
+ export declare const getKeyboardNavigationConfig: (editorView: EditorView, intl: IntlShape, api?: ExtractInjectionAPI<ToolbarPlugin>) => ToolbarKeyboardNavigationProviderConfig | undefined;
@@ -0,0 +1,3 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ export declare const getDomRefFromSelection: (view: EditorView, dispatchAnalyticsEvent?: DispatchAnalyticsEvent) => HTMLElement | undefined;
@@ -0,0 +1,5 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ declare const _default: () => SafePlugin<{
3
+ shouldShowContextualToolbar: boolean;
4
+ }>;
5
+ export default _default;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ToolbarPlugin } from '../../toolbarPluginType';
5
5
  type SelectionToolbarProps = {
6
6
  api?: ExtractInjectionAPI<ToolbarPlugin>;
@@ -9,4 +9,5 @@ type SelectionToolbarProps = {
9
9
  mountPoint: HTMLElement | undefined;
10
10
  };
11
11
  export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
12
+ export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
12
13
  export {};
@@ -0,0 +1,6 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { type ToolbarKeyboardNavigationProviderConfig } from '@atlaskit/editor-toolbar';
5
+ import type { ToolbarPlugin } from '../../toolbarPluginType';
6
+ export declare const getKeyboardNavigationConfig: (editorView: EditorView, intl: IntlShape, api?: ExtractInjectionAPI<ToolbarPlugin>) => ToolbarKeyboardNavigationProviderConfig | undefined;
@@ -0,0 +1,3 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ export declare const getDomRefFromSelection: (view: EditorView, dispatchAnalyticsEvent?: DispatchAnalyticsEvent) => HTMLElement | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-toolbar",
3
- "version": "3.2.1",
3
+ "version": "3.3.1",
4
4
  "description": "Toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/browser-apis": "^0.0.1",
32
- "@atlaskit/editor-plugin-analytics": "^6.1.0",
32
+ "@atlaskit/editor-plugin-analytics": "^6.2.0",
33
33
  "@atlaskit/editor-plugin-connectivity": "^6.0.0",
34
34
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
35
35
  "@atlaskit/editor-plugin-selection": "^6.1.0",
@@ -38,16 +38,25 @@
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
39
  "@atlaskit/editor-toolbar": "^0.15.0",
40
40
  "@atlaskit/editor-toolbar-model": "^0.2.0",
41
+ "@atlaskit/platform-feature-flags": "^1.1.0",
41
42
  "@atlaskit/platform-feature-flags-react": "^0.3.0",
42
- "@atlaskit/tmp-editor-statsig": "^13.10.0",
43
+ "@atlaskit/tmp-editor-statsig": "^13.16.0",
43
44
  "@babel/runtime": "^7.0.0",
44
45
  "bind-event-listener": "^3.0.0",
45
46
  "react-intl-next": "npm:react-intl@^5.18.1"
46
47
  },
47
48
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^110.10.0",
49
+ "@atlaskit/editor-common": "^110.15.0",
49
50
  "react": "^18.2.0"
50
51
  },
52
+ "platform-feature-flags": {
53
+ "platform_editor_toolbar_aifc_patch_7": {
54
+ "type": "boolean"
55
+ },
56
+ "platform_editor_toolbar_aifc_user_intent_fix": {
57
+ "type": "boolean"
58
+ }
59
+ },
51
60
  "techstack": {
52
61
  "@atlassian/frontend": {
53
62
  "code-structure": [