mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add RED.plugins module to editor
This commit is contained in:
parent
a006b52052
commit
7531314e3f
@ -142,6 +142,7 @@ module.exports = function(grunt) {
|
||||
"packages/node_modules/@node-red/editor-client/src/js/text/bidi.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/text/format.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/ui/state.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/plugins.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/nodes.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/font-awesome.js",
|
||||
"packages/node_modules/@node-red/editor-client/src/js/history.js",
|
||||
|
29
packages/node_modules/@node-red/editor-client/src/js/plugins.js
vendored
Normal file
29
packages/node_modules/@node-red/editor-client/src/js/plugins.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
RED.plugins = (function() {
|
||||
var plugins = {};
|
||||
var pluginsByType = {};
|
||||
|
||||
function registerPlugin(id,definition) {
|
||||
plugins[id] = definition;
|
||||
if (definition.type) {
|
||||
pluginsByType[definition.type] = pluginsByType[definition.type] || [];
|
||||
pluginsByType[definition.type].push(definition);
|
||||
}
|
||||
if (definition.onadd && typeof definition.onadd === 'function') {
|
||||
definition.onadd();
|
||||
}
|
||||
RED.events.emit("registry:plugin-added",id);
|
||||
}
|
||||
|
||||
function getPlugin(id) {
|
||||
return plugins[id]
|
||||
}
|
||||
|
||||
function getPluginsByType(type) {
|
||||
return pluginsByType[type] || [];
|
||||
}
|
||||
return {
|
||||
registerPlugin: registerPlugin,
|
||||
getPlugin: getPlugin,
|
||||
getPluginsByType: getPluginsByType
|
||||
}
|
||||
})();
|
@ -1,5 +1,9 @@
|
||||
<script type="text/javascript">
|
||||
console.log("Loaded test-plugin/test-editor-plugin")
|
||||
// RED.plugins.registerPlugin("")
|
||||
//
|
||||
RED.plugins.registerPlugin("my-test-editor-only-plugin", {
|
||||
type: "bar",
|
||||
onadd: function() {
|
||||
console.log("my-test-editor-only-plugin.onadd called")
|
||||
}
|
||||
})
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user