mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
Added support for plugins
This commit is contained in:
parent
b7e0e6b216
commit
85dc9c088f
3 changed files with 6 additions and 5 deletions
|
@ -9,7 +9,7 @@ const disabledHookReasons = {
|
|||
},
|
||||
};
|
||||
|
||||
const loadFn = (path, hookName) => {
|
||||
const loadFn = (path, hookName, modules) => {
|
||||
let functionName;
|
||||
const parts = path.split(':');
|
||||
|
||||
|
@ -24,7 +24,7 @@ const loadFn = (path, hookName) => {
|
|||
functionName = parts[1];
|
||||
}
|
||||
|
||||
let fn = require(path);
|
||||
let fn = modules ? modules.get(path) : require(/* webpackIgnore: true */ path);
|
||||
functionName = functionName ? functionName : hookName;
|
||||
|
||||
for (const name of functionName.split('.')) {
|
||||
|
@ -33,7 +33,7 @@ const loadFn = (path, hookName) => {
|
|||
return fn;
|
||||
};
|
||||
|
||||
const extractHooks = (parts, hookSetName, normalizer) => {
|
||||
const extractHooks = (parts, hookSetName, normalizer, modules) => {
|
||||
const hooks = {};
|
||||
for (const part of parts) {
|
||||
for (const [hookName, regHookFnName] of Object.entries(part[hookSetName] || {})) {
|
||||
|
@ -53,7 +53,7 @@ const extractHooks = (parts, hookSetName, normalizer) => {
|
|||
}
|
||||
let hookFn;
|
||||
try {
|
||||
hookFn = loadFn(hookFnName, hookName);
|
||||
hookFn = loadFn(hookFnName, hookName, modules);
|
||||
if (!hookFn) throw new Error('Not a function');
|
||||
} catch (err) {
|
||||
console.error(`Failed to load hook function "${hookFnName}" for plugin "${part.plugin}" ` +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue