mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
pad.html: for each client plugin, add a class to #editorcontainerbox
This commit implements the following behaviour: 1. adds a function clientPluginNames() to hooks.js (mimicking what is done in static.js), which returns an array containing the list of currently installed client side plugins. The array is eventually empty. 2. calls that function in pad.html at rendering time (thus server-side) to populate a class attribute. Example results: - with no client-side plugins installed: <div id="editorcontainerbox" class=""> - with some client-side plugins installed: <div id="editorcontainerbox" class="ep_author_neat ep_adminpads"> Looking at the existing code (src/node/hooks/express/static.js#L39-L57), a client-side plugin is defined as a plugin that implements at least a client side hook. NOTE: there is currently no support for notifying plugin removal/installation to the connected clients: for now, in order to get an updated class list, the clients will have to refresh the page. Fixes #3488
This commit is contained in:
parent
2a5e87cc7d
commit
23eab79946
3 changed files with 43 additions and 1 deletions
|
@ -125,3 +125,29 @@ exports.callAllStr = function(hook_name, args, sep, pre, post) {
|
|||
}
|
||||
return newCallhooks.join(sep || "");
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an array containing the names of the installed client-side plugins
|
||||
*
|
||||
* If no client-side plugins are installed, returns an empty array.
|
||||
* Duplicate names are always discarded.
|
||||
*
|
||||
* A client-side plugin is a plugin that implements at least one client_hook
|
||||
*
|
||||
* EXAMPLE:
|
||||
* No plugins: []
|
||||
* Some plugins: [ 'ep_adminpads', 'ep_add_buttons', 'ep_activepads' ]
|
||||
*/
|
||||
exports.clientPluginNames = function() {
|
||||
if (!(exports.plugins)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var client_plugin_names = [...new Set(
|
||||
exports.plugins.parts
|
||||
.filter(part => part.hasOwnProperty('client_hooks'))
|
||||
.map(part => part['plugin'])
|
||||
)];
|
||||
|
||||
return client_plugin_names;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue