2024-11-10 14:04:46 +00:00
import Logger from '@joplin/utils/Logger' ;
2025-06-06 02:00:47 -07:00
import { PluginStates } from '../reducer' ;
import getActivePluginEditorViews from './getActivePluginEditorViews' ;
2024-11-10 14:04:46 +00:00
const logger = Logger . create ( 'getActivePluginEditorView' ) ;
2025-06-06 02:00:47 -07:00
export default ( plugins : PluginStates , windowId : string ) = > {
const allActiveViews = getActivePluginEditorViews ( plugins , windowId ) ;
2024-11-10 14:04:46 +00:00
2025-06-06 02:00:47 -07:00
if ( allActiveViews . length === 0 ) {
return { editorPlugin : null , editorView : null } ;
2024-11-10 14:04:46 +00:00
}
2025-06-06 02:00:47 -07:00
const result = allActiveViews [ 0 ] ;
if ( allActiveViews . length > 1 ) {
const ignoredPluginIds = allActiveViews . slice ( 1 ) . map ( ( { editorPlugin } ) = > editorPlugin . id ) ;
logger . warn ( ` More than one editor plugin are active for this note. Active plugin: ${ result . editorPlugin . id } . Ignored plugins: ${ ignoredPluginIds . join ( ',' ) } ` ) ;
}
return allActiveViews [ 0 ] ;
2024-11-10 14:04:46 +00:00
} ;