diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 4a114560b..7608ff1e4 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -277,7 +277,7 @@ RED.nodes = (function() { nodeDefinitions[nt] = def; if (def.defaults) { - for (var d in def.defaults) { + for (let d in def.defaults) { if (def.defaults.hasOwnProperty(d)) { if (def.defaults[d].type) { try { @@ -286,16 +286,20 @@ RED.nodes = (function() { console.warn(err); } } - if (internalProperties.includes(d)) { console.warn(`registerType: ${nt}: the property "${d}" is internal and cannot be used.`); delete def.defaults[d]; } + const settingOverride = RED.settings?.nodeDefaults?.[def.type]?.[d] + if (settingOverride !== undefined) { + console.log(`Applying node default override for ${def.type}.${d}:`, settingOverride); + def.defaults[d]._override = true; + def.defaults[d]._originalValue = def.defaults[d].value; + def.defaults[d].value = settingOverride; + } } } } - - RED.events.emit("registry:node-type-added",nt); }, removeNodeType: function(nt) { @@ -406,9 +410,9 @@ RED.nodes = (function() { }, /** * Add an object to our dirty/clean tracking state - * @param {String} z - * @param {String} id - * @param {Boolean} isDirty + * @param {String} z + * @param {String} id + * @param {Boolean} isDirty */ addObjectToWorkspace: function (z, id, isDirty) { if (isDirty) { @@ -421,8 +425,8 @@ RED.nodes = (function() { }, /** * Remove an object from our dirty/clean tracking state - * @param {String} z - * @param {String} id + * @param {String} z + * @param {String} id */ removeObjectFromWorkspace: function (z, id) { if (!addedDirtyObjects.has(id)) { @@ -444,7 +448,7 @@ RED.nodes = (function() { api.addNode(n) }, /** - * @param {array} nodes + * @param {array} nodes * @param {boolean} direction true:forwards false:back * @param {boolean} singleStep true:single-step false:all-the-way */ @@ -2117,7 +2121,7 @@ RED.nodes = (function() { $("
  • ").text(t).appendTo(typeList); }) typeList = typeList[0].outerHTML; - + unknownNotification = RED.notify( "

    "+RED._("clipboard.importUnrecognised",{count:unknownTypes.length})+"

    "+typeList, notificationOptions @@ -2358,7 +2362,7 @@ RED.nodes = (function() { // We need to sort new_nodes (which only contains config nodes at this point) // to ensure they get added in the right order. If NodeA depends on NodeB, then // NodeB must be added first. - + // Limit us to 5 full iterations of the list - this should be more than // enough to process the list as config->config node relationships are // not very common diff --git a/packages/node_modules/@node-red/runtime/lib/api/settings.js b/packages/node_modules/@node-red/runtime/lib/api/settings.js index 634f5dbf3..e30c0a6a7 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/settings.js +++ b/packages/node_modules/@node-red/runtime/lib/api/settings.js @@ -172,6 +172,10 @@ var api = module.exports = { safeSettings.runtimeState.ui = false; // cannot have UI without endpoint } + if (runtime.settings.nodeDefaults) { + safeSettings.nodeDefaults = runtime.settings.nodeDefaults; + } + runtime.settings.exportNodeSettings(safeSettings); runtime.plugins.exportPluginSettings(safeSettings); } diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index 269cac160..2faecc47b 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -313,10 +313,10 @@ module.exports = { ui: false, }, telemetry: { - /** + /** * By default, telemetry is disabled until the user provides consent the first * time they open the editor. - * + * * The following property can be uncommented and set to true/false to enable/disable * telemetry without seeking further consent in the editor. * The user can override this setting via the user settings dialog within the editor @@ -620,4 +620,23 @@ module.exports = { // * - reason: if result is false, the HTTP reason string to return // */ //}, + +/******************************************************************************* + * Node Default Overrides + * + * This allows the user to override default values of a node. These are the values + * that are applied when a node is added to the workspace. They do not affect + * nodes that have already been deployed. + * + * The available properties of a node type can be found in the Information sidebar when + * selecting a node of that type. + * + * + *******************************************************************************/ + + // nodeDefaults: { + // "debug": { + // "complete": true // set the debug node to show complete msg by default + // } + // } }