mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix line break of subflow label on palette (#2828)
* fix line break of subflow label on palette * handle line break on palette
This commit is contained in:
parent
bebebaa3dd
commit
34ef055d7b
@ -97,13 +97,18 @@ RED.palette = (function() {
|
||||
label = RED.utils.sanitize(label);
|
||||
|
||||
|
||||
var words = label.split(/[ -]/);
|
||||
var words = label.split(/([ -]|\\n )/);
|
||||
|
||||
var displayLines = [];
|
||||
|
||||
var currentLine = "";
|
||||
for (var i=0;i<words.length;i++) {
|
||||
var word = words[i];
|
||||
if (word === "\\n ") {
|
||||
displayLines.push(currentLine);
|
||||
currentLine = "";
|
||||
continue;
|
||||
}
|
||||
var sep = (i == 0) ? "" : " ";
|
||||
var newWidth = RED.view.calculateTextWidth(currentLine+sep+word, "red-ui-palette-label");
|
||||
if (newWidth < nodeWidth) {
|
||||
|
@ -2276,7 +2276,7 @@ RED.view = (function() {
|
||||
}
|
||||
|
||||
function calculateTextWidth(str, className) {
|
||||
var result=convertLineBreakCharacter(str);
|
||||
var result = convertLineBreakCharacter(str);
|
||||
var width = 0;
|
||||
for (var i=0;i<result.length;i++) {
|
||||
var calculateTextW=calculateTextDimensions(result[i],className)[0];
|
||||
|
Loading…
Reference in New Issue
Block a user