From 966733d2e1778ccb9c62c55251d3d77923139b2c Mon Sep 17 00:00:00 2001 From: bordun Date: Tue, 28 Jan 2020 16:32:47 +0100 Subject: [PATCH] text: optimize value update when there's no icon to draw --- CHANGELOG.md | 1 + src/client/app/widgets/plots/text.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b23cb65..6b50cd26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - widgets: - **new** `menu` widget, circular alternative to the dropdown & switch widgets - file: allow selecting folders + - text: optimize value update when there's no icon to draw - editor: - convert invalid quote characters automatically to avoid errors diff --git a/src/client/app/widgets/plots/text.js b/src/client/app/widgets/plots/text.js index 391292f5..533b737f 100644 --- a/src/client/app/widgets/plots/text.js +++ b/src/client/app/widgets/plots/text.js @@ -57,7 +57,13 @@ module.exports = class Text extends Widget { setValue(v, options={}) { this.value = v==null ? this.defaultValue : v - this.widget.innerHTML = iconify(String(this.value).replace(//g, '>').replace(/\n/g,'
')) + + var s = String(this.value) + if (s.indexOf('^') > -1) { + this.widget.innerHTML = iconify(s.replace(//g, '>').replace(/\n/g,'
')) + } else { + this.widget.textContent = s.replace(/\n/g,'\r\n') + } if (options.sync) this.changed(options)