1
0
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:
Laurent Cozic
2020-11-05 16:58:23 +00:00
parent 122f20905c
commit cc07016b07
2839 changed files with 54217 additions and 16111 deletions

View File

@ -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;
}