2025-06-06 02:00:47 -07:00
|
|
|
import { useContext, useMemo } from 'react';
|
2024-11-10 14:04:46 +00:00
|
|
|
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
2025-02-17 13:47:56 +00:00
|
|
|
import getShownPluginEditorView from '@joplin/lib/services/plugins/utils/getShownPluginEditorView';
|
2025-06-06 02:00:47 -07:00
|
|
|
import { WindowIdContext } from '../../NewWindowOrIFrame';
|
2024-11-10 14:04:46 +00:00
|
|
|
|
|
|
|
// If a plugin editor should be shown for the current note, this function will return the plugin and
|
|
|
|
// associated view.
|
2025-06-06 02:00:47 -07:00
|
|
|
export default (plugins: PluginStates) => {
|
|
|
|
const windowId = useContext(WindowIdContext);
|
2024-11-10 14:04:46 +00:00
|
|
|
return useMemo(() => {
|
2025-06-06 02:00:47 -07:00
|
|
|
return getShownPluginEditorView(plugins, windowId);
|
|
|
|
}, [plugins, windowId]);
|
2024-11-10 14:04:46 +00:00
|
|
|
};
|