1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-06 23:56:13 +02:00

Plugins: Add support for editor plugins (#11296)

This commit is contained in:
Laurent Cozic
2024-11-10 14:04:46 +00:00
committed by GitHub
parent 49e86d116f
commit f091c32992
29 changed files with 630 additions and 38 deletions

View File

@ -0,0 +1,28 @@
import Logger from '@joplin/utils/Logger';
import { PluginState, PluginStates, PluginViewState } from '../reducer';
import { ContainerType } from '../WebviewController';
const logger = Logger.create('getActivePluginEditorView');
interface Output {
editorPlugin: PluginState;
editorView: PluginViewState;
}
export default (plugins: PluginStates) => {
let output: Output = { editorPlugin: null, editorView: null };
for (const [, pluginState] of Object.entries(plugins)) {
for (const [, view] of Object.entries(pluginState.views)) {
if (view.type === 'webview' && view.containerType === ContainerType.Editor && view.opened) {
if (output.editorPlugin) {
logger.warn(`More than one editor plugin are active for this note. Active plugin: ${output.editorPlugin.id}. Ignored plugin: ${pluginState.id}`);
} else {
output = { editorPlugin: pluginState, editorView: view };
}
}
}
}
return output;
};