You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
All: Use Lerna to manage monorepo
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
import { PluginStates } from '../reducer';
|
||||
import { ExtraRendererRule } from '@joplinapp/renderer/MdToHtml';
|
||||
import { ContentScriptType } from '../api/types';
|
||||
|
||||
export default function contentScriptsToRendererRules(plugins:PluginStates):ExtraRendererRule[] {
|
||||
const output:ExtraRendererRule[] = [];
|
||||
|
||||
for (const pluginId in plugins) {
|
||||
const plugin = plugins[pluginId];
|
||||
const contentScripts = plugin.contentScripts[ContentScriptType.MarkdownItPlugin];
|
||||
if (!contentScripts) continue;
|
||||
|
||||
for (const contentScript of contentScripts) {
|
||||
const module = require(contentScript.path);
|
||||
if (!module.default || typeof module.default !== 'function') throw new Error(`Content script must export a function under the "default" key: Plugin: ${pluginId}: Script: ${contentScript.id}`);
|
||||
|
||||
const loadedModule = module.default({});
|
||||
if (!loadedModule.plugin) throw new Error(`Content script must export a "plugin" key: Plugin: ${pluginId}: Script: ${contentScript.id}`);
|
||||
|
||||
output.push({
|
||||
id: contentScript.id,
|
||||
module: loadedModule,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
Reference in New Issue
Block a user