diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js b/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js index dfaa55e76..9cedb068f 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js @@ -463,32 +463,34 @@ RED.typeSearch = (function() { let index = 0; - // const suggestionItem = { - // suggestionPlaceholder: true, - // label: 'loading suggestions...', - // separator: true, - // i: index++ - // } - // searchResults.editableList('addItem', suggestionItem); - // setTimeout(function() { - // searchResults.editableList('removeItem', suggestionItem); - - // const suggestedItem = { - // suggestion: true, - // label: 'Change/Debug Combo', - // separator: true, - // i: suggestionItem.i, - // nodes: [ - // { id: 'suggestion-1', type: 'change', x: 0, y: 0, wires:[['suggestion-2']] }, - // { id: 'suggestion-2', type: 'function', outputs: 3, x: 200, y: 0, wires:[['suggestion-3'],['suggestion-4'],['suggestion-6']] }, - // { id: 'suggestion-3', _g: 'suggestion-group-1', type: 'debug', x: 375, y: -40 }, - // { id: 'suggestion-4', _g: 'suggestion-group-1', type: 'debug', x: 375, y: 0 }, - // { id: 'suggestion-5', _g: 'suggestion-group-1', type: 'debug', x: 410, y: 40 }, - // { id: 'suggestion-6', type: 'junction', wires: [['suggestion-5']], x:325, y:40 } - // ] - // } - // searchResults.editableList('addItem', suggestedItem); - // }, 1000) + if (!opts.context?.virtualLink) { + // Check for suggestion plugins + const suggestionPlugins = RED.plugins.getPluginsByType('node-red-flow-suggestion-source'); + if (suggestionPlugins.length > 0) { + const suggestionItem = { + suggestionPlaceholder: true, + label: 'loading suggestions...', // TODO: NLS + separator: true, + i: index++ + } + searchResults.editableList('addItem', suggestionItem); + suggestionPlugins[0].getSuggestions(opts.context).then(function (suggestedFlows) { + searchResults.editableList('removeItem', suggestionItem); + if (!Array.isArray(suggestedFlows)) { + suggestedFlows = [suggestedFlows]; + } + suggestedFlows.forEach(function(suggestion, index) { + const suggestedItem = { + suggestion: true, + separator: index === suggestedFlows.length - 1, + i: suggestionItem.i, + ...suggestion + } + searchResults.editableList('addItem', suggestedItem); + }) + }) + } + } for(i=0;i