88import { Balloon , Breadcrumb , Button , Card , Checkbox , DatePicker , Dialog , Dropdown , Form , Icon , Input , Loading , Message , Overlay , Pagination , Radio , Search , Select , SplitButton , Step , Switch , Tab , Table , Tree , TreeSelect , Upload , Divider } from '@alifd/next' ;
99import { ContextMenu } from '../components/context-menu' ;
1010import { editorSymbol } from '../symbols' ;
11+ import { ReactElement } from 'react' ;
1112
1213export class CommonUI implements IPublicApiCommonUI {
1314 [ editorSymbol ] : IEditor ;
@@ -40,8 +41,27 @@ export class CommonUI implements IPublicApiCommonUI {
4041 Upload = Upload ;
4142 Divider = Divider ;
4243
44+ ContextMenu : ( ( props : {
45+ menus : IPublicTypeContextMenuAction [ ] ;
46+ children : React . ReactElement [ ] | React . ReactElement ;
47+ } ) => ReactElement ) & {
48+ create ( menus : IPublicTypeContextMenuAction [ ] , event : MouseEvent | React . MouseEvent ) : void ;
49+ } ;
50+
4351 constructor ( editor : IEditor ) {
4452 this [ editorSymbol ] = editor ;
53+
54+ const innerContextMenu = ( props : any ) => {
55+ const pluginContext : IPublicModelPluginContext = editor . get ( 'pluginContext' ) as IPublicModelPluginContext ;
56+ return < ContextMenu { ...props } pluginContext = { pluginContext } /> ;
57+ } ;
58+
59+ innerContextMenu . create = ( menus : IPublicTypeContextMenuAction [ ] , event : MouseEvent ) => {
60+ const pluginContext : IPublicModelPluginContext = editor . get ( 'pluginContext' ) as IPublicModelPluginContext ;
61+ return ContextMenu . create ( pluginContext , menus , event ) ;
62+ } ;
63+
64+ this . ContextMenu = innerContextMenu ;
4565 }
4666
4767 get Tip ( ) {
@@ -55,19 +75,4 @@ export class CommonUI implements IPublicApiCommonUI {
5575 get Title ( ) {
5676 return InnerTitle ;
5777 }
58-
59- get ContextMenu ( ) {
60- const editor = this [ editorSymbol ] ;
61- const innerContextMenu = ( props : any ) => {
62- const pluginContext : IPublicModelPluginContext = editor . get ( 'pluginContext' ) as IPublicModelPluginContext ;
63- return < ContextMenu { ...props } pluginContext = { pluginContext } /> ;
64- } ;
65-
66- innerContextMenu . create = ( menus : IPublicTypeContextMenuAction [ ] , event : MouseEvent ) => {
67- const pluginContext : IPublicModelPluginContext = editor . get ( 'pluginContext' ) as IPublicModelPluginContext ;
68- return ContextMenu . create ( pluginContext , menus , event ) ;
69- } ;
70-
71- return innerContextMenu ;
72- }
7378}
0 commit comments