@atlaskit/editor-plugin-insert-block 8.4.4 → 8.4.5

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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/insertBlockPlugin.js +17 -0
  3. package/dist/cjs/pm-plugins/experiences/toolbar-action-experiences.js +183 -0
  4. package/dist/cjs/pm-plugins/experiences/toolbar-experience-utils.js +409 -0
  5. package/dist/cjs/ui/toolbar-components/EmojiButton.js +3 -1
  6. package/dist/cjs/ui/toolbar-components/ImageButton.js +2 -1
  7. package/dist/cjs/ui/toolbar-components/InsertButton.js +2 -1
  8. package/dist/cjs/ui/toolbar-components/LayoutButton.js +2 -1
  9. package/dist/cjs/ui/toolbar-components/MediaButton.js +3 -1
  10. package/dist/cjs/ui/toolbar-components/MentionButton.js +3 -1
  11. package/dist/cjs/ui/toolbar-components/TableButton.js +1 -1
  12. package/dist/cjs/ui/toolbar-components/TableSizePicker.js +3 -1
  13. package/dist/cjs/ui/toolbar-components/TaskListButton.js +2 -1
  14. package/dist/es2019/insertBlockPlugin.js +15 -0
  15. package/dist/es2019/pm-plugins/experiences/toolbar-action-experiences.js +173 -0
  16. package/dist/es2019/pm-plugins/experiences/toolbar-experience-utils.js +279 -0
  17. package/dist/es2019/ui/toolbar-components/EmojiButton.js +3 -1
  18. package/dist/es2019/ui/toolbar-components/ImageButton.js +3 -2
  19. package/dist/es2019/ui/toolbar-components/InsertButton.js +3 -2
  20. package/dist/es2019/ui/toolbar-components/LayoutButton.js +3 -2
  21. package/dist/es2019/ui/toolbar-components/MediaButton.js +3 -1
  22. package/dist/es2019/ui/toolbar-components/MentionButton.js +3 -1
  23. package/dist/es2019/ui/toolbar-components/TableButton.js +2 -2
  24. package/dist/es2019/ui/toolbar-components/TableSizePicker.js +3 -1
  25. package/dist/es2019/ui/toolbar-components/TaskListButton.js +3 -2
  26. package/dist/esm/insertBlockPlugin.js +17 -0
  27. package/dist/esm/pm-plugins/experiences/toolbar-action-experiences.js +177 -0
  28. package/dist/esm/pm-plugins/experiences/toolbar-experience-utils.js +403 -0
  29. package/dist/esm/ui/toolbar-components/EmojiButton.js +3 -1
  30. package/dist/esm/ui/toolbar-components/ImageButton.js +3 -2
  31. package/dist/esm/ui/toolbar-components/InsertButton.js +3 -2
  32. package/dist/esm/ui/toolbar-components/LayoutButton.js +3 -2
  33. package/dist/esm/ui/toolbar-components/MediaButton.js +3 -1
  34. package/dist/esm/ui/toolbar-components/MentionButton.js +3 -1
  35. package/dist/esm/ui/toolbar-components/TableButton.js +2 -2
  36. package/dist/esm/ui/toolbar-components/TableSizePicker.js +3 -1
  37. package/dist/esm/ui/toolbar-components/TaskListButton.js +3 -2
  38. package/dist/types/pm-plugins/experiences/toolbar-action-experiences.d.ts +10 -0
  39. package/dist/types/pm-plugins/experiences/toolbar-experience-utils.d.ts +57 -0
  40. package/dist/types-ts4.5/pm-plugins/experiences/toolbar-action-experiences.d.ts +10 -0
  41. package/dist/types-ts4.5/pm-plugins/experiences/toolbar-experience-utils.d.ts +57 -0
  42. package/package.json +5 -1
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
5
+ import { useEditorToolbar, TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
6
6
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
7
  import { ToolbarButton, ToolbarTooltip, ImageIcon } from '@atlaskit/editor-toolbar';
8
8
  export var ImageButton = function ImageButton(_ref) {
@@ -37,6 +37,7 @@ export var ImageButton = function ImageButton(_ref) {
37
37
  size: "small"
38
38
  }),
39
39
  onClick: onClick,
40
- isDisabled: !imageUploadEnabled || isOffline
40
+ isDisabled: !imageUploadEnabled || isOffline,
41
+ testId: TOOLBAR_BUTTON_TEST_ID.IMAGE
41
42
  }));
42
43
  };
@@ -4,7 +4,7 @@ import { useIntl } from 'react-intl-next';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { getAriaKeyshortcuts, insertElements, ToolTipContent } from '@atlaskit/editor-common/keymaps';
6
6
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
7
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
7
+ import { TOOLBAR_BUTTON_TEST_ID, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
8
8
  import { Popup } from '@atlaskit/editor-common/ui';
9
9
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
10
10
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
@@ -241,6 +241,7 @@ export var InsertButton = function InsertButton(_ref) {
241
241
  ref: insertButtonRef,
242
242
  onClick: onClick,
243
243
  isSelected: insertMenuOpen,
244
- isDisabled: !isTypeAheadAllowed || isDisabled
244
+ isDisabled: !isTypeAheadAllowed || isDisabled,
245
+ testId: TOOLBAR_BUTTON_TEST_ID.INSERT
245
246
  })));
246
247
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
5
+ import { useEditorToolbar, TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
6
6
  import { ToolbarButton, ToolbarTooltip, LayoutIcon } from '@atlaskit/editor-toolbar';
7
7
  export var LayoutButton = function LayoutButton(_ref) {
8
8
  var api = _ref.api;
@@ -28,6 +28,7 @@ export var LayoutButton = function LayoutButton(_ref) {
28
28
  label: formatMessage(messages.columns),
29
29
  size: "small"
30
30
  }),
31
- onClick: onClick
31
+ onClick: onClick,
32
+ testId: TOOLBAR_BUTTON_TEST_ID.LAYOUT
32
33
  }));
33
34
  };
@@ -3,6 +3,7 @@ import { useIntl } from 'react-intl-next';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
6
7
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
8
  import { ToolbarButton, ToolbarTooltip, ImageIcon } from '@atlaskit/editor-toolbar';
8
9
  export var MediaButton = function MediaButton(_ref) {
@@ -59,6 +60,7 @@ export var MediaButton = function MediaButton(_ref) {
59
60
  }),
60
61
  onClick: onClick,
61
62
  ref: mediaButtonRef,
62
- isDisabled: isOffline || !allowsUploads
63
+ isDisabled: isOffline || !allowsUploads,
64
+ testId: TOOLBAR_BUTTON_TEST_ID.MEDIA
63
65
  }));
64
66
  };
@@ -4,6 +4,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { ToolTipContent, insertMention } from '@atlaskit/editor-common/keymaps';
6
6
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
7
8
  import { ToolbarButton, ToolbarTooltip, MentionIcon } from '@atlaskit/editor-toolbar';
8
9
  export var MentionButton = function MentionButton(_ref) {
9
10
  var api = _ref.api;
@@ -39,6 +40,7 @@ export var MentionButton = function MentionButton(_ref) {
39
40
  }),
40
41
  onClick: onClick,
41
42
  ariaKeyshortcuts: "Shift+2 Space",
42
- isDisabled: !canInsertMention || !mentionProvider || !isTypeAheadAllowed
43
+ isDisabled: !canInsertMention || !mentionProvider || !isTypeAheadAllowed,
44
+ testId: TOOLBAR_BUTTON_TEST_ID.MENTION
43
45
  }));
44
46
  };
@@ -3,7 +3,7 @@ import { useIntl } from 'react-intl-next';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { ToolTipContent, getAriaKeyshortcuts, toggleTable } from '@atlaskit/editor-common/keymaps';
5
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
6
+ import { useEditorToolbar, TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
7
7
  import { ToolbarButton, ToolbarTooltip, TableIcon } from '@atlaskit/editor-toolbar';
8
8
  export var TableButton = function TableButton(_ref) {
9
9
  var api = _ref.api;
@@ -45,6 +45,6 @@ export var TableButton = function TableButton(_ref) {
45
45
  }),
46
46
  onClick: onClick,
47
47
  ariaKeyshortcuts: getAriaKeyshortcuts(toggleTable),
48
- testId: "Table"
48
+ testId: TOOLBAR_BUTTON_TEST_ID.TABLE
49
49
  }));
50
50
  };
@@ -1,6 +1,7 @@
1
1
  import React, { useRef } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
4
+ import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
4
5
  import { MoreItemsIcon, ToolbarButton, ToolbarTooltip, useToolbarUI } from '@atlaskit/editor-toolbar';
5
6
  import { useTableSelectorPopup } from './hooks/useTableSelectorPopup';
6
7
  import { TableSelectorPopupWrapper } from './popups/TableSelectorPopupWrapper';
@@ -46,6 +47,7 @@ export var TableSizePicker = function TableSizePicker(_ref) {
46
47
  }),
47
48
  onClick: onClick,
48
49
  isSelected: tableSelectorPopup.isOpen,
49
- ref: tableSizePickerRef
50
+ ref: tableSizePickerRef,
51
+ testId: TOOLBAR_BUTTON_TEST_ID.TABLE_SELECTOR
50
52
  })));
51
53
  };
@@ -3,7 +3,7 @@ import { useIntl } from 'react-intl-next';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { ToolTipContent, insertTaskList } from '@atlaskit/editor-common/keymaps';
5
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
6
+ import { TOOLBAR_BUTTON_TEST_ID, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
7
7
  import { ToolbarButton, ToolbarTooltip, TaskIcon } from '@atlaskit/editor-toolbar';
8
8
  export var TaskListButton = function TaskListButton(_ref) {
9
9
  var api = _ref.api;
@@ -33,6 +33,7 @@ export var TaskListButton = function TaskListButton(_ref) {
33
33
  size: "small"
34
34
  }),
35
35
  onClick: onClick,
36
- ariaKeyshortcuts: "[ ] Space"
36
+ ariaKeyshortcuts: "[ ] Space",
37
+ testId: TOOLBAR_BUTTON_TEST_ID.TASK_LIST
37
38
  }));
38
39
  };
@@ -0,0 +1,10 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ type ToolbarActionExperienceOptions = {
4
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
5
+ refs: {
6
+ popupsMountPoint?: HTMLElement;
7
+ };
8
+ };
9
+ export declare const getToolbarActionExperiencesPlugin: ({ refs, dispatchAnalyticsEvent, }: ToolbarActionExperienceOptions) => SafePlugin<any>;
10
+ export {};
@@ -0,0 +1,57 @@
1
+ import type { ExperienceCheck, ExperienceCheckCallback, ExperienceCheckResult } from '@atlaskit/editor-common/experiences';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ /**
4
+ * DOM marker selectors for node types inserted via toolbar actions.
5
+ * Matches outermost wrapper elements set synchronously by ReactNodeView
6
+ * (`{nodeTypeName}View-content-wrap`) or schema `toDOM` attributes.
7
+ */
8
+ export declare const NODE_INSERT_MARKERS: {
9
+ readonly TABLE: ".tableView-content-wrap";
10
+ readonly LAYOUT: ".layoutSectionView-content-wrap";
11
+ readonly LAYOUT_COLUMN: ".layoutColumnView-content-wrap";
12
+ readonly TASK_LIST: "[data-node-type=\"actionList\"]";
13
+ readonly TASK_ITEM: ".taskItemView-content-wrap";
14
+ };
15
+ export declare const isToolbarButtonClick: (target: HTMLElement, testId: string) => boolean;
16
+ /**
17
+ * ExperienceCheck that observes popup mount point and all its
18
+ * `[data-editor-popup]` children with `{ childList: true }` (no subtree).
19
+ *
20
+ * Detects when a popup containing the given nested element is added to the
21
+ * DOM — either as a new `[data-editor-popup]` direct child, or as content
22
+ * rendered inside an existing `[data-editor-popup]` wrapper.
23
+ */
24
+ export declare const TYPEAHEAD_DECORATION_SELECTOR = "[data-type-ahead=\"typeaheadDecoration\"]";
25
+ export declare const handleTypeAheadOpenDomMutation: ({ mutations, }: {
26
+ mutations: MutationRecord[];
27
+ }) => ExperienceCheckResult | undefined;
28
+ export declare class ExperienceCheckPopupMutation implements ExperienceCheck {
29
+ private nestedElementQuery;
30
+ private getTarget;
31
+ private getEditorDom;
32
+ private observers;
33
+ constructor(nestedElementQuery: string, getTarget: () => HTMLElement | undefined | null, getEditorDom: () => HTMLElement | undefined | null);
34
+ start(callback: ExperienceCheckCallback): void;
35
+ stop(): void;
36
+ }
37
+ /**
38
+ * Returns the narrow parent DOM element at the current selection, suitable
39
+ * for observing with `{ childList: true }` (no subtree).
40
+ *
41
+ * Uses the resolved position's depth to find the block node at the cursor
42
+ * via `nodeDOM`, then returns its `parentElement` — the container whose
43
+ * direct children change when content is inserted at this position.
44
+ *
45
+ * Falls back to `domAtPos` if `nodeDOM` is unavailable.
46
+ */
47
+ export declare const getParentDOMAtSelection: (editorView?: EditorView) => HTMLElement | null;
48
+ /**
49
+ * Evaluates DOM mutations to detect a node insert action.
50
+ *
51
+ * Uses two strategies:
52
+ * 1. Marker-based: checks `addedNodes` against known node insert selectors.
53
+ * 2. Structure-based: detects element add+remove (block-level replacement).
54
+ */
55
+ export declare const handleEditorNodeInsertDomMutation: ({ mutations, }: {
56
+ mutations: MutationRecord[];
57
+ }) => ExperienceCheckResult | undefined;
@@ -0,0 +1,10 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ type ToolbarActionExperienceOptions = {
4
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
5
+ refs: {
6
+ popupsMountPoint?: HTMLElement;
7
+ };
8
+ };
9
+ export declare const getToolbarActionExperiencesPlugin: ({ refs, dispatchAnalyticsEvent, }: ToolbarActionExperienceOptions) => SafePlugin<any>;
10
+ export {};
@@ -0,0 +1,57 @@
1
+ import type { ExperienceCheck, ExperienceCheckCallback, ExperienceCheckResult } from '@atlaskit/editor-common/experiences';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ /**
4
+ * DOM marker selectors for node types inserted via toolbar actions.
5
+ * Matches outermost wrapper elements set synchronously by ReactNodeView
6
+ * (`{nodeTypeName}View-content-wrap`) or schema `toDOM` attributes.
7
+ */
8
+ export declare const NODE_INSERT_MARKERS: {
9
+ readonly TABLE: ".tableView-content-wrap";
10
+ readonly LAYOUT: ".layoutSectionView-content-wrap";
11
+ readonly LAYOUT_COLUMN: ".layoutColumnView-content-wrap";
12
+ readonly TASK_LIST: "[data-node-type=\"actionList\"]";
13
+ readonly TASK_ITEM: ".taskItemView-content-wrap";
14
+ };
15
+ export declare const isToolbarButtonClick: (target: HTMLElement, testId: string) => boolean;
16
+ /**
17
+ * ExperienceCheck that observes popup mount point and all its
18
+ * `[data-editor-popup]` children with `{ childList: true }` (no subtree).
19
+ *
20
+ * Detects when a popup containing the given nested element is added to the
21
+ * DOM — either as a new `[data-editor-popup]` direct child, or as content
22
+ * rendered inside an existing `[data-editor-popup]` wrapper.
23
+ */
24
+ export declare const TYPEAHEAD_DECORATION_SELECTOR = "[data-type-ahead=\"typeaheadDecoration\"]";
25
+ export declare const handleTypeAheadOpenDomMutation: ({ mutations, }: {
26
+ mutations: MutationRecord[];
27
+ }) => ExperienceCheckResult | undefined;
28
+ export declare class ExperienceCheckPopupMutation implements ExperienceCheck {
29
+ private nestedElementQuery;
30
+ private getTarget;
31
+ private getEditorDom;
32
+ private observers;
33
+ constructor(nestedElementQuery: string, getTarget: () => HTMLElement | undefined | null, getEditorDom: () => HTMLElement | undefined | null);
34
+ start(callback: ExperienceCheckCallback): void;
35
+ stop(): void;
36
+ }
37
+ /**
38
+ * Returns the narrow parent DOM element at the current selection, suitable
39
+ * for observing with `{ childList: true }` (no subtree).
40
+ *
41
+ * Uses the resolved position's depth to find the block node at the cursor
42
+ * via `nodeDOM`, then returns its `parentElement` — the container whose
43
+ * direct children change when content is inserted at this position.
44
+ *
45
+ * Falls back to `domAtPos` if `nodeDOM` is unavailable.
46
+ */
47
+ export declare const getParentDOMAtSelection: (editorView?: EditorView) => HTMLElement | null;
48
+ /**
49
+ * Evaluates DOM mutations to detect a node insert action.
50
+ *
51
+ * Uses two strategies:
52
+ * 1. Marker-based: checks `addedNodes` against known node insert selectors.
53
+ * 2. Structure-based: detects element add+remove (block-level replacement).
54
+ */
55
+ export declare const handleEditorNodeInsertDomMutation: ({ mutations, }: {
56
+ mutations: MutationRecord[];
57
+ }) => ExperienceCheckResult | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "8.4.4",
3
+ "version": "8.4.5",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,6 +29,7 @@
29
29
  ],
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
+ "@atlaskit/browser-apis": "^0.0.1",
32
33
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
33
34
  "@atlaskit/editor-plugin-block-type": "^11.2.0",
34
35
  "@atlaskit/editor-plugin-code-block": "^9.0.0",
@@ -131,6 +132,9 @@
131
132
  },
132
133
  "platform_editor_media_insert_check": {
133
134
  "type": "boolean"
135
+ },
136
+ "platform_editor_experience_tracking_toolbar_button": {
137
+ "type": "boolean"
134
138
  }
135
139
  }
136
140
  }