@atlaskit/editor-plugin-block-menu 0.0.12 → 0.0.14
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.
- package/CHANGELOG.md +15 -0
- package/afm-cc/tsconfig.json +4 -1
- package/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/blockMenuPlugin.js +6 -0
- package/dist/cjs/editor-commands/formatNode.js +23 -0
- package/dist/cjs/editor-commands/transforms/block-transforms.js +37 -0
- package/dist/cjs/editor-commands/transforms/container-transforms.js +59 -0
- package/dist/cjs/editor-commands/transforms/list-transforms.js +53 -0
- package/dist/cjs/editor-commands/transforms/transformNodeToTargetType.js +50 -0
- package/dist/cjs/editor-commands/transforms/types.js +5 -0
- package/dist/cjs/editor-commands/transforms/utils.js +109 -0
- package/dist/cjs/ui/block-menu-components.js +55 -42
- package/dist/cjs/ui/block-menu-renderer.js +48 -11
- package/dist/es2019/blockMenuPlugin.js +6 -0
- package/dist/es2019/editor-commands/formatNode.js +20 -0
- package/dist/es2019/editor-commands/transforms/block-transforms.js +38 -0
- package/dist/es2019/editor-commands/transforms/container-transforms.js +55 -0
- package/dist/es2019/editor-commands/transforms/list-transforms.js +49 -0
- package/dist/es2019/editor-commands/transforms/transformNodeToTargetType.js +48 -0
- package/dist/es2019/editor-commands/transforms/types.js +1 -0
- package/dist/es2019/editor-commands/transforms/utils.js +103 -0
- package/dist/es2019/ui/block-menu-components.js +45 -32
- package/dist/es2019/ui/block-menu-renderer.js +46 -11
- package/dist/esm/blockMenuPlugin.js +6 -0
- package/dist/esm/editor-commands/formatNode.js +17 -0
- package/dist/esm/editor-commands/transforms/block-transforms.js +32 -0
- package/dist/esm/editor-commands/transforms/container-transforms.js +54 -0
- package/dist/esm/editor-commands/transforms/list-transforms.js +48 -0
- package/dist/esm/editor-commands/transforms/transformNodeToTargetType.js +44 -0
- package/dist/esm/editor-commands/transforms/types.js +1 -0
- package/dist/esm/editor-commands/transforms/utils.js +103 -0
- package/dist/esm/ui/block-menu-components.js +56 -43
- package/dist/esm/ui/block-menu-renderer.js +48 -11
- package/dist/types/blockMenuPluginType.d.ts +27 -3
- package/dist/types/editor-commands/formatNode.d.ts +9 -0
- package/dist/types/editor-commands/transforms/block-transforms.d.ts +5 -0
- package/dist/types/editor-commands/transforms/container-transforms.d.ts +17 -0
- package/dist/types/editor-commands/transforms/list-transforms.d.ts +17 -0
- package/dist/types/editor-commands/transforms/transformNodeToTargetType.d.ts +4 -0
- package/dist/types/editor-commands/transforms/types.d.ts +11 -0
- package/dist/types/editor-commands/transforms/utils.d.ts +12 -0
- package/dist/types-ts4.5/blockMenuPluginType.d.ts +27 -3
- package/dist/types-ts4.5/editor-commands/formatNode.d.ts +9 -0
- package/dist/types-ts4.5/editor-commands/transforms/block-transforms.d.ts +5 -0
- package/dist/types-ts4.5/editor-commands/transforms/container-transforms.d.ts +17 -0
- package/dist/types-ts4.5/editor-commands/transforms/list-transforms.d.ts +17 -0
- package/dist/types-ts4.5/editor-commands/transforms/transformNodeToTargetType.d.ts +4 -0
- package/dist/types-ts4.5/editor-commands/transforms/types.d.ts +11 -0
- package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +12 -0
- package/package.json +13 -10
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin, EditorCommand } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
|
|
3
3
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
4
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
5
5
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
6
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
+
import type { FormatNodeTargetType } from './editor-commands/transforms/types';
|
|
6
8
|
export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
|
|
7
9
|
actions: {
|
|
8
10
|
getBlockMenuComponents: () => Array<RegisterBlockMenuComponent>;
|
|
9
11
|
registerBlockMenuComponents: (blockMenuComponents: Array<RegisterBlockMenuComponent>) => void;
|
|
10
12
|
};
|
|
13
|
+
commands: {
|
|
14
|
+
formatNode: (currentNode: PMNode, targetType: FormatNodeTargetType) => EditorCommand;
|
|
15
|
+
};
|
|
11
16
|
dependencies: [
|
|
12
17
|
OptionalPlugin<BlockControlsPlugin>,
|
|
13
18
|
OptionalPlugin<UserIntentPlugin>,
|
|
@@ -33,6 +38,19 @@ type WithRank<T> = T & {
|
|
|
33
38
|
export type Parent<T> = WithRank<T>;
|
|
34
39
|
type ComponentType = BlockMenuSection | BlockMenuItem | BlockMenuNested;
|
|
35
40
|
export type ComponentTypes = Array<ComponentType>;
|
|
41
|
+
/**
|
|
42
|
+
* The relationship between BlockMenuItem, BlockMenuSection, BlockMenuNested
|
|
43
|
+
* BlockMenuSection can have BlockMenuItem or BlockMenuNested as children
|
|
44
|
+
* BlockMenuNested can have BlockMenuSection as children,
|
|
45
|
+
* BlockMenuNested, with BlockMenuSection and BlockMenuItem, is a nested menu
|
|
46
|
+
* _______________________________________
|
|
47
|
+
* | Block menu (no typing)
|
|
48
|
+
* | |BlockMenuSection
|
|
49
|
+
* | | |BlockMenuItem
|
|
50
|
+
* | | |BlockMenuNested
|
|
51
|
+
* | | | |BlockMenuSection
|
|
52
|
+
* | | | | |BlockMenuItem
|
|
53
|
+
*/
|
|
36
54
|
type BlockMenuItem = {
|
|
37
55
|
key: string;
|
|
38
56
|
type: 'block-menu-item';
|
|
@@ -45,10 +63,15 @@ type BlockMenuNested = {
|
|
|
45
63
|
key: string;
|
|
46
64
|
type: 'block-menu-nested';
|
|
47
65
|
};
|
|
48
|
-
export type BlockMenuNestedComponent = (
|
|
66
|
+
export type BlockMenuNestedComponent = (props?: {
|
|
67
|
+
children: React.ReactNode;
|
|
68
|
+
}) => React.ReactNode;
|
|
49
69
|
export type BlockMenuSectionComponent = (props: {
|
|
50
70
|
children: React.ReactNode;
|
|
51
71
|
}) => React.ReactNode;
|
|
72
|
+
export type BlockMenuNestedSectionComponent = (props: {
|
|
73
|
+
children: React.ReactNode;
|
|
74
|
+
}) => React.ReactNode;
|
|
52
75
|
export type BlockMenuItemComponent = () => React.ReactNode;
|
|
53
76
|
export type RegisterBlockMenuNested = BlockMenuNested & {
|
|
54
77
|
component?: BlockMenuNestedComponent;
|
|
@@ -56,7 +79,8 @@ export type RegisterBlockMenuNested = BlockMenuNested & {
|
|
|
56
79
|
};
|
|
57
80
|
export type RegisterBlockMenuSection = BlockMenuSection & {
|
|
58
81
|
component?: BlockMenuSectionComponent;
|
|
59
|
-
|
|
82
|
+
parent?: Parent<BlockMenuNested>;
|
|
83
|
+
rank?: number;
|
|
60
84
|
};
|
|
61
85
|
export type RegisterBlockMenuItem = BlockMenuItem & {
|
|
62
86
|
component?: BlockMenuItemComponent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { FormatNodeTargetType } from './transforms/types';
|
|
4
|
+
/**
|
|
5
|
+
* Formats the current node or selection to the specified target type
|
|
6
|
+
* @param currentNode - The current node
|
|
7
|
+
* @param targetType - The target node type to convert to
|
|
8
|
+
*/
|
|
9
|
+
export declare const formatNode: (currentNode: PMNode, targetType: FormatNodeTargetType) => EditorCommand;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TransformFunction } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Transform selection to container type
|
|
4
|
+
*/
|
|
5
|
+
export declare const transformToContainer: () => null;
|
|
6
|
+
/**
|
|
7
|
+
* Transform container nodes (panel, expand, blockquote)
|
|
8
|
+
*/
|
|
9
|
+
export declare const transformContainerNode: TransformFunction;
|
|
10
|
+
/**
|
|
11
|
+
* Unwrap container node and convert content to block type
|
|
12
|
+
*/
|
|
13
|
+
export declare const unwrapAndConvertToBlockType: () => null;
|
|
14
|
+
/**
|
|
15
|
+
* Unwrap container node and convert content to list
|
|
16
|
+
*/
|
|
17
|
+
export declare const unwrapAndConvertToList: () => null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TransformFunction } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Transform selection to list type
|
|
4
|
+
*/
|
|
5
|
+
export declare const transformToList: () => null;
|
|
6
|
+
/**
|
|
7
|
+
* Transform list nodes
|
|
8
|
+
*/
|
|
9
|
+
export declare const transformListNode: TransformFunction;
|
|
10
|
+
/**
|
|
11
|
+
* Lift list content and convert to block type
|
|
12
|
+
*/
|
|
13
|
+
export declare const liftListToBlockType: () => null;
|
|
14
|
+
/**
|
|
15
|
+
* Transform between different list types
|
|
16
|
+
*/
|
|
17
|
+
export declare const transformBetweenListTypes: () => null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { FormatNodeTargetType } from './types';
|
|
4
|
+
export declare function transformNodeToTargetType(tr: Transaction, sourceNode: PMNode, sourcePos: number | null, targetType: FormatNodeTargetType): Transaction | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Node as PMNode, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'panel' | 'codeblock' | 'bulletList' | 'orderedList' | 'taskList';
|
|
4
|
+
export interface TransformContext {
|
|
5
|
+
tr: Transaction;
|
|
6
|
+
sourceNode: PMNode;
|
|
7
|
+
sourcePos: number | null;
|
|
8
|
+
targetNodeType: NodeType;
|
|
9
|
+
targetAttrs?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export type TransformFunction = (context: TransformContext) => Transaction | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Node as PMNode, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { FormatNodeTargetType } from './types';
|
|
3
|
+
export declare const getTargetNodeInfo: (targetType: FormatNodeTargetType, nodes: Record<string, NodeType>) => {
|
|
4
|
+
nodeType: NodeType;
|
|
5
|
+
attrs?: Record<string, unknown>;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare const isBlockNode: (node: PMNode) => boolean;
|
|
8
|
+
export declare const isListNode: (node: PMNode) => boolean;
|
|
9
|
+
export declare const isContainerNode: (node: PMNode) => boolean;
|
|
10
|
+
export declare const isBlockNodeType: (nodeType: NodeType) => boolean;
|
|
11
|
+
export declare const isListNodeType: (nodeType: NodeType) => boolean;
|
|
12
|
+
export declare const isContainerNodeType: (nodeType: NodeType) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
|
-
"af:exports": {
|
|
31
|
-
".": "./src/index.ts"
|
|
32
|
-
},
|
|
33
30
|
"dependencies": {
|
|
34
31
|
"@atlaskit/css": "^0.12.0",
|
|
35
32
|
"@atlaskit/dropdown-menu": "^16.3.0",
|
|
@@ -40,15 +37,16 @@
|
|
|
40
37
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
38
|
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
42
39
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
43
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
44
|
-
"@atlaskit/icon": "^28.
|
|
45
|
-
"@atlaskit/icon-lab": "^5.
|
|
46
|
-
"@atlaskit/
|
|
47
|
-
"@atlaskit/
|
|
40
|
+
"@atlaskit/editor-toolbar": "^0.4.0",
|
|
41
|
+
"@atlaskit/icon": "^28.1.0",
|
|
42
|
+
"@atlaskit/icon-lab": "^5.7.0",
|
|
43
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
|
+
"@atlaskit/primitives": "^14.12.0",
|
|
45
|
+
"@atlaskit/tokens": "^6.1.0",
|
|
48
46
|
"@babel/runtime": "^7.0.0"
|
|
49
47
|
},
|
|
50
48
|
"peerDependencies": {
|
|
51
|
-
"@atlaskit/editor-common": "^107.
|
|
49
|
+
"@atlaskit/editor-common": "^107.32.0",
|
|
52
50
|
"react": "^18.2.0",
|
|
53
51
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
54
52
|
},
|
|
@@ -87,5 +85,10 @@
|
|
|
87
85
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
88
86
|
]
|
|
89
87
|
}
|
|
88
|
+
},
|
|
89
|
+
"platform-feature-flags": {
|
|
90
|
+
"platform_editor_block_menu_format": {
|
|
91
|
+
"type": "boolean"
|
|
92
|
+
}
|
|
90
93
|
}
|
|
91
94
|
}
|