@@ -2720,10 +2720,16 @@ export namespace CRMNodes {
27202720 return new Promise < void > ( ( resolve ) => {
27212721 modules . crmValues . nodeTabStatuses = new window . Map ( ) ;
27222722 browserAPI . contextMenus . removeAll ( ) . then ( async ( ) => {
2723+ const contexts : CRM . ContentTypes [ ] = [ ] ;
2724+ modules . Util . crmForEach ( modules . crm . crmTree , ( node ) => {
2725+ contexts . push ( node . onContentTypes || [ false , false , false , false , false , false ] ) ;
2726+ } ) ;
2727+
2728+ console . log ( contexts , CRMNodes . getJoinedContexts ( contexts ) ) ;
27232729 const done = await modules . Util . lock ( modules . Util . LOCK . ROOT_CONTEXTMENU_NODE ) ;
27242730 modules . crmValues . rootId = await browserAPI . contextMenus . create ( {
27252731 title : modules . storages . settingsStorage . rootName || 'Custom Menu' ,
2726- contexts : [ 'all' ]
2732+ contexts : CRMNodes . getJoinedContexts ( contexts )
27272733 } ) ;
27282734 done ( ) ;
27292735 modules . toExecuteNodes = {
@@ -2805,6 +2811,24 @@ export namespace CRMNodes {
28052811 }
28062812 return newContexts ;
28072813 }
2814+ export function getJoinedContexts ( contexts : CRM . ContentTypes [ ] ) : _browser . contextMenus . ContextType [ ] {
2815+ const newContexts : {
2816+ [ key : string ] : boolean ;
2817+ } = { } ;
2818+ newContexts [ 'browser_action' ] = true ;
2819+ const textContexts = modules . constants . contexts ;
2820+ for ( const context of contexts ) {
2821+ for ( let i = 0 ; i < 6 ; i ++ ) {
2822+ if ( context [ i ] ) {
2823+ newContexts [ textContexts [ i ] ] = true ;
2824+ }
2825+ }
2826+ if ( context [ 0 ] ) {
2827+ newContexts [ 'editable' ] = true ;
2828+ }
2829+ }
2830+ return Object . getOwnPropertyNames ( newContexts ) as _browser . contextMenus . ContextType [ ] ;
2831+ }
28082832 export async function converToLegacy ( ) : Promise < {
28092833 [ key : number ] : string ;
28102834 [ key : string ] : string ;
0 commit comments