@atlaskit/editor-plugin-block-menu 0.0.2 → 0.0.3

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-passionfruit/tsconfig.json +51 -0
  4. package/dist/cjs/blockMenuPlugin.js +12 -0
  5. package/dist/cjs/editor-actions/index.js +65 -0
  6. package/dist/cjs/ui/block-menu-components.js +131 -0
  7. package/dist/cjs/ui/block-menu-renderer.js +54 -0
  8. package/dist/cjs/ui/block-menu.js +26 -65
  9. package/dist/cjs/ui/consts.js +7 -0
  10. package/dist/es2019/blockMenuPlugin.js +37 -23
  11. package/dist/es2019/editor-actions/index.js +57 -0
  12. package/dist/es2019/ui/block-menu-components.js +127 -0
  13. package/dist/es2019/ui/block-menu-renderer.js +35 -0
  14. package/dist/es2019/ui/block-menu.js +21 -63
  15. package/dist/es2019/ui/consts.js +1 -0
  16. package/dist/esm/blockMenuPlugin.js +12 -0
  17. package/dist/esm/editor-actions/index.js +58 -0
  18. package/dist/esm/ui/block-menu-components.js +124 -0
  19. package/dist/esm/ui/block-menu-renderer.js +45 -0
  20. package/dist/esm/ui/block-menu.js +26 -64
  21. package/dist/esm/ui/consts.js +1 -0
  22. package/dist/types/blockMenuPluginType.d.ts +41 -0
  23. package/dist/types/editor-actions/index.d.ts +52 -0
  24. package/dist/types/index.d.ts +1 -1
  25. package/dist/types/ui/block-menu-components.d.ts +2 -0
  26. package/dist/types/ui/block-menu-renderer.d.ts +18 -0
  27. package/dist/types/ui/consts.d.ts +1 -0
  28. package/dist/types-ts4.5/blockMenuPluginType.d.ts +41 -0
  29. package/dist/types-ts4.5/editor-actions/index.d.ts +52 -0
  30. package/dist/types-ts4.5/index.d.ts +1 -1
  31. package/dist/types-ts4.5/ui/block-menu-components.d.ts +2 -0
  32. package/dist/types-ts4.5/ui/block-menu-renderer.d.ts +18 -0
  33. package/dist/types-ts4.5/ui/consts.d.ts +1 -0
  34. package/package.json +2 -1
@@ -3,4 +3,45 @@ import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls
3
3
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
4
4
  export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
5
5
  dependencies: [OptionalPlugin<BlockControlsPlugin>, OptionalPlugin<UserIntentPlugin>];
6
+ actions: {
7
+ registerBlockMenuComponents: (blockMenuComponents: Array<RegisterBlockMenuComponent>) => void;
8
+ getBlockMenuComponents: () => Array<RegisterBlockMenuComponent>;
9
+ };
6
10
  }>;
11
+ type WithRank<T> = T & {
12
+ rank: number;
13
+ };
14
+ export type Parent<T> = WithRank<T>;
15
+ type ComponentType = BlockMenuSection | BlockMenuItem | BlockMenuNested;
16
+ export type ComponentTypes = Array<ComponentType>;
17
+ type BlockMenuItem = {
18
+ key: string;
19
+ type: 'block-menu-item';
20
+ };
21
+ type BlockMenuSection = {
22
+ key: string;
23
+ type: 'block-menu-section';
24
+ };
25
+ type BlockMenuNested = {
26
+ key: string;
27
+ type: 'block-menu-nested';
28
+ };
29
+ export type BlockMenuNestedComponent = () => React.ReactNode;
30
+ export type BlockMenuSectionComponent = (props: {
31
+ children: React.ReactNode;
32
+ }) => React.ReactNode;
33
+ export type BlockMenuItemComponent = () => React.ReactNode;
34
+ export type RegisterBlockMenuNested = BlockMenuNested & {
35
+ parent: Parent<BlockMenuSection>;
36
+ component?: BlockMenuNestedComponent;
37
+ };
38
+ export type RegisterBlockMenuSection = BlockMenuSection & {
39
+ rank: number;
40
+ component?: BlockMenuSectionComponent;
41
+ };
42
+ export type RegisterBlockMenuItem = BlockMenuItem & {
43
+ parent: Parent<BlockMenuSection>;
44
+ component?: BlockMenuItemComponent;
45
+ };
46
+ export type RegisterBlockMenuComponent = RegisterBlockMenuNested | RegisterBlockMenuSection | RegisterBlockMenuItem;
47
+ export {};
@@ -0,0 +1,52 @@
1
+ import type { RegisterBlockMenuComponent } from '../blockMenuPluginType';
2
+ /**
3
+ * Create a simple registry for block menu components.
4
+ *
5
+ * @returns A registry object with a `register` method and a `components` array.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const registry = createBlockMenuRegistry();
10
+ * registry.register(
11
+ * [{
12
+ * type: 'block-menu-section' as const,
13
+ * key: 'block-menu-section-format',
14
+ * rank: 100,
15
+ * component: ({ children }: { children: React.ReactNode }) => {
16
+ * return <ToolbarDropdownItemSection>{children}</ToolbarDropdownItemSection>;
17
+ * },
18
+ * },
19
+ * {
20
+ * type: 'block-menu-nested' as const,
21
+ * key: 'nested-menu',
22
+ * parent: {
23
+ * type: 'block-menu-section' as const,
24
+ * key: 'block-menu-section-format',
25
+ * rank: 100,
26
+ * },
27
+ * component: () => {
28
+ * return (
29
+ * <ToolbarNestedDropdownMenu>{...}</ToolbarNestedDropdownMenu>
30
+ * );
31
+ * },
32
+ * },
33
+ * {
34
+ * type: 'block-menu-item' as const,
35
+ * key: 'block-menu-item-create-jira',
36
+ * parent: {
37
+ * type: 'block-menu-section' as const,
38
+ * key: 'block-menu-section-format',
39
+ * rank: 200,
40
+ * },
41
+ * component: () => {
42
+ * return <ToolbarDropdownItem elemBefore={<JiraIcon label="" />}>Create Jira work item</ToolbarDropdownItem>;
43
+ * },
44
+ * },
45
+ * ]);
46
+ * ```
47
+ *
48
+ */
49
+ export declare const createBlockMenuRegistry: () => {
50
+ register: (blockMenuComponents: RegisterBlockMenuComponent[]) => void;
51
+ components: RegisterBlockMenuComponent[];
52
+ };
@@ -1,2 +1,2 @@
1
1
  export { blockMenuPlugin } from './blockMenuPlugin';
2
- export type { BlockMenuPlugin } from './blockMenuPluginType';
2
+ export type { BlockMenuPlugin, RegisterBlockMenuComponent, Parent } from './blockMenuPluginType';
@@ -0,0 +1,2 @@
1
+ import { type RegisterBlockMenuComponent } from '../blockMenuPluginType';
2
+ export declare const getBlockMenuComponents: () => RegisterBlockMenuComponent[];
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent, BlockMenuNestedComponent, BlockMenuSectionComponent, BlockMenuItemComponent } from '../blockMenuPluginType';
3
+ type BlockMenuProps = {
4
+ /**
5
+ * Every registered block menu component
6
+ */
7
+ components: RegisterBlockMenuComponent[];
8
+ /**
9
+ * Fallback components used in rendering
10
+ */
11
+ fallbacks: {
12
+ nestedMenu: BlockMenuNestedComponent;
13
+ section: BlockMenuSectionComponent;
14
+ item: BlockMenuItemComponent;
15
+ };
16
+ };
17
+ export declare const BlockMenuRenderer: ({ components, fallbacks }: BlockMenuProps) => React.JSX.Element;
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare const BLOCK_MENU_LABEL = "Editor Block Menu";
@@ -6,4 +6,45 @@ export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
6
6
  OptionalPlugin<BlockControlsPlugin>,
7
7
  OptionalPlugin<UserIntentPlugin>
8
8
  ];
9
+ actions: {
10
+ registerBlockMenuComponents: (blockMenuComponents: Array<RegisterBlockMenuComponent>) => void;
11
+ getBlockMenuComponents: () => Array<RegisterBlockMenuComponent>;
12
+ };
9
13
  }>;
14
+ type WithRank<T> = T & {
15
+ rank: number;
16
+ };
17
+ export type Parent<T> = WithRank<T>;
18
+ type ComponentType = BlockMenuSection | BlockMenuItem | BlockMenuNested;
19
+ export type ComponentTypes = Array<ComponentType>;
20
+ type BlockMenuItem = {
21
+ key: string;
22
+ type: 'block-menu-item';
23
+ };
24
+ type BlockMenuSection = {
25
+ key: string;
26
+ type: 'block-menu-section';
27
+ };
28
+ type BlockMenuNested = {
29
+ key: string;
30
+ type: 'block-menu-nested';
31
+ };
32
+ export type BlockMenuNestedComponent = () => React.ReactNode;
33
+ export type BlockMenuSectionComponent = (props: {
34
+ children: React.ReactNode;
35
+ }) => React.ReactNode;
36
+ export type BlockMenuItemComponent = () => React.ReactNode;
37
+ export type RegisterBlockMenuNested = BlockMenuNested & {
38
+ parent: Parent<BlockMenuSection>;
39
+ component?: BlockMenuNestedComponent;
40
+ };
41
+ export type RegisterBlockMenuSection = BlockMenuSection & {
42
+ rank: number;
43
+ component?: BlockMenuSectionComponent;
44
+ };
45
+ export type RegisterBlockMenuItem = BlockMenuItem & {
46
+ parent: Parent<BlockMenuSection>;
47
+ component?: BlockMenuItemComponent;
48
+ };
49
+ export type RegisterBlockMenuComponent = RegisterBlockMenuNested | RegisterBlockMenuSection | RegisterBlockMenuItem;
50
+ export {};
@@ -0,0 +1,52 @@
1
+ import type { RegisterBlockMenuComponent } from '../blockMenuPluginType';
2
+ /**
3
+ * Create a simple registry for block menu components.
4
+ *
5
+ * @returns A registry object with a `register` method and a `components` array.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const registry = createBlockMenuRegistry();
10
+ * registry.register(
11
+ * [{
12
+ * type: 'block-menu-section' as const,
13
+ * key: 'block-menu-section-format',
14
+ * rank: 100,
15
+ * component: ({ children }: { children: React.ReactNode }) => {
16
+ * return <ToolbarDropdownItemSection>{children}</ToolbarDropdownItemSection>;
17
+ * },
18
+ * },
19
+ * {
20
+ * type: 'block-menu-nested' as const,
21
+ * key: 'nested-menu',
22
+ * parent: {
23
+ * type: 'block-menu-section' as const,
24
+ * key: 'block-menu-section-format',
25
+ * rank: 100,
26
+ * },
27
+ * component: () => {
28
+ * return (
29
+ * <ToolbarNestedDropdownMenu>{...}</ToolbarNestedDropdownMenu>
30
+ * );
31
+ * },
32
+ * },
33
+ * {
34
+ * type: 'block-menu-item' as const,
35
+ * key: 'block-menu-item-create-jira',
36
+ * parent: {
37
+ * type: 'block-menu-section' as const,
38
+ * key: 'block-menu-section-format',
39
+ * rank: 200,
40
+ * },
41
+ * component: () => {
42
+ * return <ToolbarDropdownItem elemBefore={<JiraIcon label="" />}>Create Jira work item</ToolbarDropdownItem>;
43
+ * },
44
+ * },
45
+ * ]);
46
+ * ```
47
+ *
48
+ */
49
+ export declare const createBlockMenuRegistry: () => {
50
+ register: (blockMenuComponents: RegisterBlockMenuComponent[]) => void;
51
+ components: RegisterBlockMenuComponent[];
52
+ };
@@ -1,2 +1,2 @@
1
1
  export { blockMenuPlugin } from './blockMenuPlugin';
2
- export type { BlockMenuPlugin } from './blockMenuPluginType';
2
+ export type { BlockMenuPlugin, RegisterBlockMenuComponent, Parent } from './blockMenuPluginType';
@@ -0,0 +1,2 @@
1
+ import { type RegisterBlockMenuComponent } from '../blockMenuPluginType';
2
+ export declare const getBlockMenuComponents: () => RegisterBlockMenuComponent[];
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent, BlockMenuNestedComponent, BlockMenuSectionComponent, BlockMenuItemComponent } from '../blockMenuPluginType';
3
+ type BlockMenuProps = {
4
+ /**
5
+ * Every registered block menu component
6
+ */
7
+ components: RegisterBlockMenuComponent[];
8
+ /**
9
+ * Fallback components used in rendering
10
+ */
11
+ fallbacks: {
12
+ nestedMenu: BlockMenuNestedComponent;
13
+ section: BlockMenuSectionComponent;
14
+ item: BlockMenuItemComponent;
15
+ };
16
+ };
17
+ export declare const BlockMenuRenderer: ({ components, fallbacks }: BlockMenuProps) => React.JSX.Element;
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare const BLOCK_MENU_LABEL = "Editor Block Menu";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,6 +37,7 @@
37
37
  "@atlaskit/editor-plugin-user-intent": "^1.1.0",
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
39
  "@atlaskit/editor-shared-styles": "^3.6.0",
40
+ "@atlaskit/editor-toolbar": "^0.2.0",
40
41
  "@atlaskit/icon": "^27.11.0",
41
42
  "@atlaskit/icon-lab": "^5.4.0",
42
43
  "@atlaskit/primitives": "^14.11.0",