mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
fix line break of group label
This commit is contained in:
parent
fbd911ed27
commit
243915516e
@ -4156,7 +4156,7 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
|
|||||||
"stroke": d.stroke||"none",
|
"stroke": d.stroke||"none",
|
||||||
})
|
})
|
||||||
g.on("mousedown",groupMouseDown).on("mouseup",groupMouseUp)
|
g.on("mousedown",groupMouseDown).on("mouseup",groupMouseUp)
|
||||||
g.append('svg:text').attr("class","red-ui-flow-group-label").text(d.name);
|
g.append('svg:text').attr("class","red-ui-flow-group-label");
|
||||||
d.dirty = true;
|
d.dirty = true;
|
||||||
});
|
});
|
||||||
if (addedGroups) {
|
if (addedGroups) {
|
||||||
@ -4207,12 +4207,20 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
|
|||||||
if (!d.minWidth) {
|
if (!d.minWidth) {
|
||||||
if (d.style.label && d.name) {
|
if (d.style.label && d.name) {
|
||||||
d.minWidth = calculateTextWidth(d.name||"","red-ui-flow-group-label",8);
|
d.minWidth = calculateTextWidth(d.name||"","red-ui-flow-group-label",8);
|
||||||
|
d.labels = separateTextByLineBreak;
|
||||||
} else {
|
} else {
|
||||||
d.minWidth = 40;
|
d.minWidth = 40;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.w = Math.max(d.minWidth,d.w);
|
d.w = Math.max(d.minWidth,d.w);
|
||||||
|
if (d.style.label && d.labels) {
|
||||||
|
var h = (d.labels.length -1) *15;
|
||||||
|
var labelPos = d.style["label-position"] || "nw";
|
||||||
|
d.h += h;
|
||||||
|
if (labelPos[0] === "n") {
|
||||||
|
d.y -= h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g.attr("transform","translate("+d.x+","+d.y+")")
|
g.attr("transform","translate("+d.x+","+d.y+")")
|
||||||
g.selectAll(".red-ui-flow-group-outline")
|
g.selectAll(".red-ui-flow-group-outline")
|
||||||
@ -4263,7 +4271,7 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
|
|||||||
if (labelPos[0] === 'n') {
|
if (labelPos[0] === 'n') {
|
||||||
labelY = 0+15; // Allow for font-height
|
labelY = 0+15; // Allow for font-height
|
||||||
} else {
|
} else {
|
||||||
labelY = d.h - 5;
|
labelY = d.h - 5 -(d.labels.length -1) *15;
|
||||||
}
|
}
|
||||||
if (labelPos[1] === 'w') {
|
if (labelPos[1] === 'w') {
|
||||||
labelX = 5;
|
labelX = 5;
|
||||||
@ -4275,10 +4283,20 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
|
|||||||
labelX = d.w/2;
|
labelX = d.w/2;
|
||||||
labelAnchor = "middle"
|
labelAnchor = "middle"
|
||||||
}
|
}
|
||||||
label.text(d.name)
|
label
|
||||||
.style("fill", d.style.hasOwnProperty('color')?d.style.color:"#999")
|
.style("fill", d.style.hasOwnProperty('color')?d.style.color:"#999")
|
||||||
.attr("transform","translate("+labelX+","+labelY+")")
|
.attr("transform","translate("+labelX+","+labelY+")")
|
||||||
.attr("text-anchor",labelAnchor);
|
.attr("text-anchor",labelAnchor);
|
||||||
|
var ypos = 0;
|
||||||
|
g.selectAll(".red-ui-flow-group-label-text").remove();
|
||||||
|
d.labels.forEach(function (name) {
|
||||||
|
label.append("tspan")
|
||||||
|
.classed("red-ui-flow-group-label-text", true)
|
||||||
|
.text(name)
|
||||||
|
.attr("x", 0)
|
||||||
|
.attr("y", ypos);
|
||||||
|
ypos += 15;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete dirtyGroups[d.id];
|
delete dirtyGroups[d.id];
|
||||||
|
Loading…
Reference in New Issue
Block a user