@atlaskit/editor-plugin-insert-block 8.4.4 → 8.5.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 (47) hide show
  1. package/CHANGELOG.md +19 -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/ElementBrowser/InsertMenu.js +18 -5
  6. package/dist/cjs/ui/toolbar-components/EmojiButton.js +3 -1
  7. package/dist/cjs/ui/toolbar-components/ImageButton.js +2 -1
  8. package/dist/cjs/ui/toolbar-components/InsertButton.js +2 -1
  9. package/dist/cjs/ui/toolbar-components/LayoutButton.js +2 -1
  10. package/dist/cjs/ui/toolbar-components/MediaButton.js +3 -1
  11. package/dist/cjs/ui/toolbar-components/MentionButton.js +3 -1
  12. package/dist/cjs/ui/toolbar-components/TableButton.js +1 -1
  13. package/dist/cjs/ui/toolbar-components/TableSizePicker.js +3 -1
  14. package/dist/cjs/ui/toolbar-components/TaskListButton.js +2 -1
  15. package/dist/es2019/insertBlockPlugin.js +15 -0
  16. package/dist/es2019/pm-plugins/experiences/toolbar-action-experiences.js +173 -0
  17. package/dist/es2019/pm-plugins/experiences/toolbar-experience-utils.js +279 -0
  18. package/dist/es2019/ui/ElementBrowser/InsertMenu.js +15 -4
  19. package/dist/es2019/ui/toolbar-components/EmojiButton.js +3 -1
  20. package/dist/es2019/ui/toolbar-components/ImageButton.js +3 -2
  21. package/dist/es2019/ui/toolbar-components/InsertButton.js +3 -2
  22. package/dist/es2019/ui/toolbar-components/LayoutButton.js +3 -2
  23. package/dist/es2019/ui/toolbar-components/MediaButton.js +3 -1
  24. package/dist/es2019/ui/toolbar-components/MentionButton.js +3 -1
  25. package/dist/es2019/ui/toolbar-components/TableButton.js +2 -2
  26. package/dist/es2019/ui/toolbar-components/TableSizePicker.js +3 -1
  27. package/dist/es2019/ui/toolbar-components/TaskListButton.js +3 -2
  28. package/dist/esm/insertBlockPlugin.js +17 -0
  29. package/dist/esm/pm-plugins/experiences/toolbar-action-experiences.js +177 -0
  30. package/dist/esm/pm-plugins/experiences/toolbar-experience-utils.js +403 -0
  31. package/dist/esm/ui/ElementBrowser/InsertMenu.js +17 -4
  32. package/dist/esm/ui/toolbar-components/EmojiButton.js +3 -1
  33. package/dist/esm/ui/toolbar-components/ImageButton.js +3 -2
  34. package/dist/esm/ui/toolbar-components/InsertButton.js +3 -2
  35. package/dist/esm/ui/toolbar-components/LayoutButton.js +3 -2
  36. package/dist/esm/ui/toolbar-components/MediaButton.js +3 -1
  37. package/dist/esm/ui/toolbar-components/MentionButton.js +3 -1
  38. package/dist/esm/ui/toolbar-components/TableButton.js +2 -2
  39. package/dist/esm/ui/toolbar-components/TableSizePicker.js +3 -1
  40. package/dist/esm/ui/toolbar-components/TaskListButton.js +3 -2
  41. package/dist/types/pm-plugins/experiences/toolbar-action-experiences.d.ts +10 -0
  42. package/dist/types/pm-plugins/experiences/toolbar-experience-utils.d.ts +57 -0
  43. package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +5 -2
  44. package/dist/types-ts4.5/pm-plugins/experiences/toolbar-action-experiences.d.ts +10 -0
  45. package/dist/types-ts4.5/pm-plugins/experiences/toolbar-experience-utils.d.ts +57 -0
  46. package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +5 -2
  47. package/package.json +6 -2
@@ -4,11 +4,14 @@ import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
4
4
  import type { InsertMenuProps } from './types';
5
5
  export declare const DEFAULT_HEIGHT = 560;
6
6
  /**
7
- * Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
7
+ * Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
8
8
  *not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
9
9
  method that can be used to get suggestions -> once all experiments are cleaned up,
10
10
  they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
11
+
12
+ `cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
13
+ this newer implementation matches how the "quick insert menu" sorts elements
11
14
  */
12
- export declare const filterForPinWhiteboards: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
15
+ export declare const sortPrioritizedElements: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
13
16
  declare const InsertMenu: ({ editorView, dropdownItems, showElementBrowserLink, onInsert, toggleVisiblity, pluginInjectionApi, }: InsertMenuProps) => jsx.JSX.Element;
14
17
  export default InsertMenu;
@@ -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;
@@ -4,11 +4,14 @@ import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
4
4
  import type { InsertMenuProps } from './types';
5
5
  export declare const DEFAULT_HEIGHT = 560;
6
6
  /**
7
- * Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
7
+ * Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
8
8
  *not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
9
9
  method that can be used to get suggestions -> once all experiments are cleaned up,
10
10
  they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
11
+
12
+ `cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
13
+ this newer implementation matches how the "quick insert menu" sorts elements
11
14
  */
12
- export declare const filterForPinWhiteboards: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
15
+ export declare const sortPrioritizedElements: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
13
16
  declare const InsertMenu: ({ editorView, dropdownItems, showElementBrowserLink, onInsert, toggleVisiblity, pluginInjectionApi, }: InsertMenuProps) => jsx.JSX.Element;
14
17
  export default InsertMenu;
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.5.0",
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",
@@ -64,7 +65,7 @@
64
65
  "@atlaskit/icon-lab": "^5.15.0",
65
66
  "@atlaskit/platform-feature-flags": "^1.1.0",
66
67
  "@atlaskit/theme": "^21.0.0",
67
- "@atlaskit/tmp-editor-statsig": "^23.0.0",
68
+ "@atlaskit/tmp-editor-statsig": "^23.1.0",
68
69
  "@atlaskit/tokens": "^11.0.0",
69
70
  "@babel/runtime": "^7.0.0",
70
71
  "@emotion/react": "^11.7.1",
@@ -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
  }