1
0
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:
Hiroyasu Nishiyama 2021-01-28 05:32:15 +09:00 committed by GitHub
parent bebebaa3dd
commit 34ef055d7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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) {

View File

@ -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];