etherpad-lite/src/static/js/pluginfw/client_plugins.js

27 lines
799 B
JavaScript
Raw Normal View History

2020-12-16 06:10:41 +03:30
'use strict';
2020-11-23 13:24:19 -05:00
const pluginUtils = require('./shared');
const defs = require('./plugin_defs');
exports.baseURL = '';
2020-12-16 06:10:41 +03:30
exports.update = (cb) => {
// It appears that this response (see #620) may interrupt the current thread
// of execution on Firefox. This schedules the response in the run-loop,
// which appears to fix the issue.
2020-12-16 06:10:41 +03:30
const callback = () => setTimeout(cb, 0);
2021-02-15 08:52:38 +01:00
jQuery.getJSON(
`${exports.baseURL}pluginfw/plugin-definitions.json?v=${clientVars.randomVersionString}`
).done((data) => {
defs.plugins = data.plugins;
defs.parts = data.parts;
2020-11-23 13:24:19 -05:00
defs.hooks = pluginUtils.extractHooks(defs.parts, 'client_hooks');
defs.loaded = true;
callback();
2020-12-16 06:10:41 +03:30
}).fail((err) => {
2020-11-23 13:24:19 -05:00
console.error(`Failed to load plugin-definitions: ${err}`);
2020-06-07 12:01:14 +01:00
callback();
});
};