From e6cdbf9a5de8a4b60d696be7463e4eb18aa4143e Mon Sep 17 00:00:00 2001 From: Monica Kozbial Date: Mon, 16 Nov 2020 17:19:42 -0800 Subject: [PATCH] Add fix for display text on multiline text block (#4454) --- core/field_multilineinput.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/field_multilineinput.js b/core/field_multilineinput.js index 2205cb03f..dfb8d68c4 100644 --- a/core/field_multilineinput.js +++ b/core/field_multilineinput.js @@ -116,13 +116,13 @@ Blockly.FieldMultilineInput.prototype.initView = function() { * @private */ Blockly.FieldMultilineInput.prototype.getDisplayText_ = function() { - var value = this.value_; - if (!value) { + var textLines = this.getText(); + if (!textLines) { // Prevent the field from disappearing if empty. return Blockly.Field.NBSP; } - var lines = value.split('\n'); - value = ''; + var lines = textLines.split('\n'); + textLines = ''; for (var i = 0; i < lines.length; i++) { var text = lines[i]; if (text.length > this.maxDisplayLength) { @@ -132,16 +132,16 @@ Blockly.FieldMultilineInput.prototype.getDisplayText_ = function() { // Replace whitespace with non-breaking spaces so the text doesn't collapse. text = text.replace(/\s/g, Blockly.Field.NBSP); - value += text; + textLines += text; if (i !== lines.length - 1) { - value += '\n'; + textLines += '\n'; } } if (this.sourceBlock_.RTL) { // The SVG is LTR, force value to be RTL. - value += '\u200F'; + textLines += '\u200F'; } - return value; + return textLines; }; /**