@atlaskit/editor-plugin-block-menu 5.1.6 → 5.1.8

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 (41) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/flattenListStep.js +9 -32
  3. package/dist/cjs/editor-commands/transform-node-utils/transform.js +5 -4
  4. package/dist/cjs/editor-commands/transform-node-utils/unwrapListStep.js +16 -1
  5. package/dist/cjs/editor-commands/transform-node-utils/utils.js +30 -1
  6. package/dist/cjs/editor-commands/transform-node-utils/wrapMixedContentStep.js +141 -0
  7. package/dist/cjs/editor-commands/transformNode.js +6 -6
  8. package/dist/cjs/ui/block-menu-components.js +29 -24
  9. package/dist/cjs/ui/suggested-items-renderer.js +62 -0
  10. package/dist/cjs/ui/utils/suggested-items-rank.js +66 -0
  11. package/dist/es2019/editor-commands/transform-node-utils/flattenListStep.js +9 -32
  12. package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -4
  13. package/dist/es2019/editor-commands/transform-node-utils/unwrapListStep.js +16 -1
  14. package/dist/es2019/editor-commands/transform-node-utils/utils.js +29 -1
  15. package/dist/es2019/editor-commands/transform-node-utils/wrapMixedContentStep.js +135 -0
  16. package/dist/es2019/editor-commands/transformNode.js +2 -2
  17. package/dist/es2019/ui/block-menu-components.js +12 -9
  18. package/dist/es2019/ui/suggested-items-renderer.js +48 -0
  19. package/dist/es2019/ui/utils/suggested-items-rank.js +130 -0
  20. package/dist/esm/editor-commands/transform-node-utils/flattenListStep.js +9 -32
  21. package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -4
  22. package/dist/esm/editor-commands/transform-node-utils/unwrapListStep.js +16 -1
  23. package/dist/esm/editor-commands/transform-node-utils/utils.js +30 -1
  24. package/dist/esm/editor-commands/transform-node-utils/wrapMixedContentStep.js +135 -0
  25. package/dist/esm/editor-commands/transformNode.js +4 -4
  26. package/dist/esm/ui/block-menu-components.js +30 -25
  27. package/dist/esm/ui/suggested-items-renderer.js +54 -0
  28. package/dist/esm/ui/utils/suggested-items-rank.js +60 -0
  29. package/dist/types/editor-commands/transform-node-utils/flattenListStep.d.ts +0 -18
  30. package/dist/types/editor-commands/transform-node-utils/unwrapListStep.d.ts +16 -1
  31. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +12 -0
  32. package/dist/types/editor-commands/transform-node-utils/wrapMixedContentStep.d.ts +20 -0
  33. package/dist/types/ui/suggested-items-renderer.d.ts +8 -0
  34. package/dist/types/ui/utils/suggested-items-rank.d.ts +45 -0
  35. package/dist/types-ts4.5/editor-commands/transform-node-utils/flattenListStep.d.ts +0 -18
  36. package/dist/types-ts4.5/editor-commands/transform-node-utils/unwrapListStep.d.ts +16 -1
  37. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +12 -0
  38. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapMixedContentStep.d.ts +20 -0
  39. package/dist/types-ts4.5/ui/suggested-items-renderer.d.ts +8 -0
  40. package/dist/types-ts4.5/ui/utils/suggested-items-rank.d.ts +45 -0
  41. package/package.json +4 -4
@@ -1,5 +1,17 @@
1
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
3
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
3
4
  import type { NodeTypeName } from './types';
4
5
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
5
6
  export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
7
+ /**
8
+ * Use common expandToBlockRange function, but account for edge cases with lists.
9
+ *
10
+ * @param selection
11
+ * @param schema
12
+ * @returns
13
+ */
14
+ export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
15
+ $from: import("prosemirror-model").ResolvedPos;
16
+ $to: import("prosemirror-model").ResolvedPos;
17
+ };
@@ -0,0 +1,20 @@
1
+ import type { TransformStep } from './types';
2
+ /**
3
+ * A wrap step that handles mixed content according to the Compatibility Matrix:
4
+ * - Wraps consecutive compatible nodes into the target container
5
+ * - Same-type containers break out as separate containers (preserved as-is)
6
+ * - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
7
+ * - Container structures that can't be nested in target break out (not flattened)
8
+ * - Text/list nodes that can't be wrapped are flattened and merged into the container
9
+ * - Atomic nodes (tables, media, macros) break out
10
+ *
11
+ * What can be wrapped depends on the target container's schema:
12
+ * - expand → panel: tables break out, nestedExpands convert to expands and break out
13
+ * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
14
+ * - expand → expand: tables/media stay inside (expands can contain them)
15
+ *
16
+ * Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
17
+ * Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
18
+ * Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
19
+ */
20
+ export declare const wrapMixedContentStep: TransformStep;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
+ type SuggestedItemsRendererProps = {
5
+ api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
6
+ };
7
+ export declare const SuggestedItemsRenderer: React.NamedExoticComponent<SuggestedItemsRendererProps>;
8
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Suggested transformations mapping for each block type.
3
+ * Based on the Block Menu Compatibility Matrix:
4
+ * https://hello.atlassian.net/wiki/spaces/egcuc/pages/5868774224/Block+Menu+Compatibility+Matrix#Suggested-for-each-block-type
5
+ *
6
+ * This mapping defines which transform items should appear in the TRANSFORM_SUGGESTED_MENU_SECTION
7
+ * for each block type, ranked by priority (lower rank = higher priority).
8
+ *
9
+ * Structure:
10
+ * {
11
+ * [sourceNodeType]: {
12
+ * [targetMenuItemKey]: rank
13
+ * }
14
+ * }
15
+ */
16
+ export declare const BLOCK_MENU_NODE_TYPES: {
17
+ readonly PARAGRAPH: "paragraph";
18
+ readonly EXPAND: "expand";
19
+ readonly BLOCKQUOTE: "blockquote";
20
+ readonly LAYOUT_SECTION: "layoutSection";
21
+ readonly PANEL: "panel";
22
+ readonly CODE_BLOCK: "codeBlock";
23
+ readonly DECISION: "decisionList";
24
+ readonly BULLET_LIST: "bulletList";
25
+ readonly ORDERED_LIST: "orderedList";
26
+ readonly HEADING: "heading";
27
+ readonly TASK_LIST: "taskList";
28
+ readonly MEDIA_SINGLE: "mediaSingle";
29
+ readonly EXTENSION: "extension";
30
+ readonly BODIED_EXTENSION: "bodiedExtension";
31
+ readonly BLOCK_CARD: "blockCard";
32
+ readonly EMBED_CARD: "embedCard";
33
+ readonly TABLE: "table";
34
+ };
35
+ export type BlockMenuNodeType = (typeof BLOCK_MENU_NODE_TYPES)[keyof typeof BLOCK_MENU_NODE_TYPES];
36
+ export type SuggestedItemsRankMap = {
37
+ [nodeType: string]: {
38
+ [menuItemKey: string]: number;
39
+ };
40
+ };
41
+ export declare const TRANSFORM_SUGGESTED_ITEMS_RANK: SuggestedItemsRankMap;
42
+ export declare const getSuggestedItemsForNodeType: (nodeType: string) => {
43
+ [menuItemKey: string]: number;
44
+ } | undefined;
45
+ export declare const getSortedSuggestedItems: (nodeType: string) => string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.1.6",
3
+ "version": "5.1.8",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/css": "^0.17.0",
32
32
  "@atlaskit/dropdown-menu": "^16.3.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
- "@atlaskit/editor-plugin-block-controls": "^7.12.0",
34
+ "@atlaskit/editor-plugin-block-controls": "^7.13.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
@@ -44,12 +44,12 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^16.4.0",
47
- "@atlaskit/tmp-editor-statsig": "^14.7.0",
47
+ "@atlaskit/tmp-editor-statsig": "^14.8.0",
48
48
  "@atlaskit/tokens": "^8.4.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^110.38.0",
52
+ "@atlaskit/editor-common": "^110.40.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },