diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index c1c9316d8..9bba632f9 100644 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -684,7 +684,7 @@ "title": "Remove nodes" }, "removePlugin": { - "body": "

Removed plugin __module__. Please reload the editor to clear left-overs.

" + "body": "

Removed plugin __module__. Please reload the editor to continue.

" }, "update": { "body": "

Updating '__module__'

Updating the node will require a restart of Node-RED to complete the update. This must be done manually.

", diff --git a/packages/node_modules/@node-red/editor-client/locales/fr/editor.json b/packages/node_modules/@node-red/editor-client/locales/fr/editor.json index a205002d9..8ad966f4d 100644 --- a/packages/node_modules/@node-red/editor-client/locales/fr/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/fr/editor.json @@ -682,7 +682,7 @@ "title": "Supprimer les noeuds" }, "removePlugin": { - "body": "

Suppression du plugin '__module__'. Veuillez recharger l'éditeur afin d'appliquer les changements.

" + "body": "

Suppression du plugin '__module__'. Veuillez recharger l'éditeur pour continuer.

" }, "update": { "body": "

Mise à jour de '__module__'

La mise à jour du noeud nécessitera un redémarrage de Node-RED pour terminer la mise à jour. Cela doit être fait manuellement.

", diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js index 1a34d1927..915945495 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js @@ -1624,23 +1624,40 @@ RED.palette.editor = (function() { refreshUpdateStatus(); } + const pluginList = []; + Object.entries(entry.pluginSet).forEach(([key, set]) => { + if (set.plugins && set.plugins.length) { + // Adds ID of plugins that exist in the runtime and possibly in the editor + pluginList.push(...set.plugins.map((plugin) => plugin.id)); + } else { + // Adds plugin ID that only exist in the editor + pluginList.push(key); + } + }); + // We assume that a plugin that implements onremove // cleans the editor accordingly of its left-overs. let found_onremove = true; - - let keys = Object.keys(entry.pluginSet); - keys.forEach((key) => { - let set = entry.pluginSet[key]; - for (let i=0; i { + const plugin = RED.plugins.getPlugin(id); + if (plugin) { + if (typeof plugin.onremove === 'function') { + try { + plugin.onremove(); + } catch (error) { + console.warn(`Error while calling 'onremove' for plugin '${id}': `, error); } + } else if (typeof plugin.onadd === 'function') { + // We assume that the plugin adds something to the editor but is not able to remove it + // Notify the user to refresh the editor to remove that plugin + found_onremove = false; + } else { + // If there's no 'onadd', there shouldn't be any left-overs } + } else { + // Either the plugin exists only in the runtime or it is a known limitation + // of purely editor plugins which must have their ID identical to that + // defined in the package.json } });