mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Use subflow.info for help text and meta.type for node type
This commit is contained in:
@@ -342,6 +342,7 @@
|
||||
"module": "Module",
|
||||
"license": "License",
|
||||
"licenseOther": "Other",
|
||||
"type": "Node Type",
|
||||
"version": "Version",
|
||||
"versionPlaceholder": "x.y.z",
|
||||
"keys": "Keywords",
|
||||
|
@@ -1921,6 +1921,18 @@ RED.nodes = (function() {
|
||||
RED.events.emit("groups:remove",group);
|
||||
}
|
||||
|
||||
function getNodeHelp(type) {
|
||||
var helpContent = "";
|
||||
var helpElement = $("script[data-help-name='"+type+"']");
|
||||
if (helpElement) {
|
||||
helpContent = helpElement.html();
|
||||
var helpType = helpElement.attr("type");
|
||||
if (helpType === "text/markdown") {
|
||||
helpContent = RED.utils.renderMarkdown(helpContent);
|
||||
}
|
||||
}
|
||||
return helpContent;
|
||||
}
|
||||
|
||||
return {
|
||||
init: function() {
|
||||
@@ -2000,6 +2012,7 @@ RED.nodes = (function() {
|
||||
|
||||
registerType: registry.registerNodeType,
|
||||
getType: registry.getNodeType,
|
||||
getNodeHelp: getNodeHelp,
|
||||
convertNode: convertNode,
|
||||
|
||||
add: addNode,
|
||||
|
@@ -147,7 +147,7 @@ RED.palette = (function() {
|
||||
var popOverContent;
|
||||
try {
|
||||
var l = "<p><b>"+RED.text.bidi.enforceTextDirectionWithUCC(label)+"</b></p>";
|
||||
popOverContent = $('<div></div>').append($(l+(info?info:$("script[data-help-name='"+type+"']").html()||"<p>"+RED._("palette.noInfo")+"</p>").trim())
|
||||
popOverContent = $('<div></div>').append($(l+(info?info:RED.nodes.getNodeHelp(type)||"<p>"+RED._("palette.noInfo")+"</p>").trim())
|
||||
.filter(function(n) {
|
||||
return (this.nodeType == 1 && this.nodeName == "P") || (this.nodeType == 3 && this.textContent.trim().length > 0)
|
||||
}).slice(0,2));
|
||||
@@ -264,27 +264,6 @@ RED.palette = (function() {
|
||||
|
||||
d.data('popover',popover);
|
||||
|
||||
// $(d).popover({
|
||||
// title:d.type,
|
||||
// placement:"right",
|
||||
// trigger: "hover",
|
||||
// delay: { show: 750, hide: 50 },
|
||||
// html: true,
|
||||
// container:'body'
|
||||
// });
|
||||
// d.on("click", function() {
|
||||
// RED.view.focus();
|
||||
// var helpText;
|
||||
// if (nt.indexOf("subflow:") === 0) {
|
||||
// helpText = RED.utils.renderMarkdown(RED.nodes.subflow(nt.substring(8)).info||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
// } else {
|
||||
// helpText = $("script[data-help-name='"+d.attr("data-palette-type")+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
// }
|
||||
// // Don't look too closely. RED.sidebar.info.set will set the 'Description'
|
||||
// // section of the sidebar. Pass in the title of the Help section so it looks
|
||||
// // right.
|
||||
// RED.sidebar.type.show(helpText,RED._("sidebar.info.nodeHelp"));
|
||||
// });
|
||||
var chart = $("#red-ui-workspace-chart");
|
||||
var chartSVG = $("#red-ui-workspace-chart>svg").get(0);
|
||||
var activeSpliceLink;
|
||||
|
@@ -52,6 +52,10 @@ RED.subflow = (function() {
|
||||
'<label for="subflow-input-module-module" data-i18n="[append]editor:subflow.module"><i class="fa fa-cube"></i> </label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-module" data-i18n="[placeholder]common.label.name">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
'<label for="subflow-input-module-type" data-i18n="[append]editor:subflow.type"> </label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-type">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
'<label for="subflow-input-module-version" data-i18n="[append]editor:subflow.version"></label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-version" data-i18n="[placeholder]editor:subflow.versionPlaceholder">'+
|
||||
@@ -61,7 +65,7 @@ RED.subflow = (function() {
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-desc">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
'<label for="subflow-input-module-version" data-i18n="[append]editor:subflow.license"></label>'+
|
||||
'<label for="subflow-input-module-license" data-i18n="[append]editor:subflow.license"></label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-license">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
@@ -1767,7 +1771,7 @@ RED.subflow = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (/^sf-/.test(node.type)) {
|
||||
} else if (node._def.subflowModule) {
|
||||
var keys = Object.keys(node._def.defaults);
|
||||
keys.forEach(function(name) {
|
||||
if (name !== 'name') {
|
||||
@@ -1954,6 +1958,7 @@ RED.subflow = (function() {
|
||||
var moduleProps = node.meta || {};
|
||||
[
|
||||
'module',
|
||||
'type',
|
||||
'version',
|
||||
'author',
|
||||
'desc',
|
||||
@@ -1962,6 +1967,8 @@ RED.subflow = (function() {
|
||||
].forEach(function(property) {
|
||||
$("#subflow-input-module-"+property).val(moduleProps[property]||"")
|
||||
})
|
||||
$("#subflow-input-module-type").attr("placeholder",node.id);
|
||||
|
||||
setupInputValidation($("#subflow-input-module-module"), function(newValue) {
|
||||
newValue = newValue.trim();
|
||||
var isValid = newValue.length < 215;
|
||||
@@ -2008,6 +2015,7 @@ RED.subflow = (function() {
|
||||
var moduleProps = {};
|
||||
[
|
||||
'module',
|
||||
'type',
|
||||
'version',
|
||||
'author',
|
||||
'desc',
|
||||
|
@@ -247,7 +247,7 @@ RED.sidebar.help = (function() {
|
||||
helpText = (RED.utils.renderMarkdown(subflowNode.info||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>'));
|
||||
title = subflowNode.name || nodeType;
|
||||
} else {
|
||||
helpText = $("script[data-help-name='"+nodeType+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
helpText = RED.nodes.getNodeHelp(nodeType)||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
title = nodeType;
|
||||
}
|
||||
setInfoText(title, helpText, helpSection);
|
||||
|
@@ -390,19 +390,6 @@ RED.sidebar.info = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
// var helpText = "";
|
||||
// if (node.type === "tab" || node.type === "subflow") {
|
||||
// } else {
|
||||
// if (subflowNode && node.type !== "subflow") {
|
||||
// // Selected a subflow instance node.
|
||||
// // - The subflow template info goes into help
|
||||
// helpText = (RED.utils.renderMarkdown(subflowNode.info||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>'));
|
||||
// } else {
|
||||
// helpText = $("script[data-help-name='"+node.type+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
// }
|
||||
// setInfoText(helpText, helpSection.content);
|
||||
// }
|
||||
|
||||
var infoText = "";
|
||||
|
||||
if (node._def && node._def.info) {
|
||||
@@ -415,23 +402,6 @@ RED.sidebar.info = (function() {
|
||||
}
|
||||
var infoSectionContainer = $("<div>").css("padding","0 6px 6px").appendTo(propertiesPanelContent)
|
||||
|
||||
// var editInfo = $('<button class="red-ui-button red-ui-button-small" style="float: right"><i class="fa fa-file-text-o"></button>').appendTo(infoSectionContainer).on("click", function(evt) {
|
||||
// //.text(RED._("sidebar.info.editDescription"))
|
||||
// evt.preventDefault();
|
||||
// evt.stopPropagation();
|
||||
// if (node.type === 'tab') {
|
||||
//
|
||||
// } else if (node.type === 'subflow') {
|
||||
//
|
||||
// } else if (node.type === 'group') {
|
||||
//
|
||||
// } else if (node._def.category !== 'config') {
|
||||
// RED.editor.edit(node,"editor-tab-description");
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
// })
|
||||
|
||||
setInfoText(infoText, infoSectionContainer);
|
||||
|
||||
$(".red-ui-sidebar-info-stack").scrollTop(0);
|
||||
|
Reference in New Issue
Block a user