From b81d175145c38101c682d085b09f6cb54e7da04c Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 18 Nov 2020 11:31:19 +0100 Subject: [PATCH] :bug: Fix bug with multi line texts on Edit Image Node --- packages/nodes-base/nodes/EditImage.node.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/nodes-base/nodes/EditImage.node.ts b/packages/nodes-base/nodes/EditImage.node.ts index fba65d1144..16c718e274 100644 --- a/packages/nodes-base/nodes/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage.node.ts @@ -721,16 +721,19 @@ export class EditImage implements INodeType { // Split the text in multiple lines const lines: string[] = []; let currentLine = ''; - (text as string).split(' ').forEach((textPart: string) => { - if (currentLine.length + textPart.length + 1 > lineLength) { - lines.push(currentLine.trim()); - currentLine = `${textPart} `; - return; - } - currentLine += `${textPart} `; + (text as string).split('\n').forEach((textLine: string) => { + textLine.split(' ').forEach((textPart: string) => { + if ((currentLine.length + textPart.length + 1) > lineLength) { + lines.push(currentLine.trim()); + currentLine = `${textPart} `; + return; + } + currentLine += `${textPart} `; + }); + + lines.push(currentLine.trim()); + currentLine = ''; }); - // Add the last line - lines.push(currentLine.trim()); // Combine the lines to a single string const renderText = lines.join('\n');