From 6a2b69bad7242e70c2d475777e9d9c95165802e7 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 8 May 2021 12:35:27 +0200 Subject: [PATCH] text: add `soft` mode for the `wrap` property --- CHANGELOG.md | 1 + src/client/widgets/indicators/text.js | 6 +++--- src/scss/widgets/indicators.scss | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84256b7b..3df669fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - widgets - script: bypass keyboard shortcuts already used by the editor if it is enabled - matrix: removed ambiguous `start` property + - text: add `soft` mode for the `wrap` property ## 1.9.6 diff --git a/src/client/widgets/indicators/text.js b/src/client/widgets/indicators/text.js index e10ad6da..f2f7e8cd 100644 --- a/src/client/widgets/indicators/text.js +++ b/src/client/widgets/indicators/text.js @@ -20,8 +20,8 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true, inte style: { _separator_text_style: 'Text style', vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, - wrap: {type: 'boolean', value: false, help: [ - 'Set to `true` to wrap long lines automatically.', + wrap: {type: 'boolean|string', value: false, choices: [false, true, 'soft'], help: [ + 'Set to `true` to wrap long lines automatically. Set to `soft` to avoid breaking words.', ]}, align: {type: 'string', value: 'center', choices: ['center', 'left', 'right', 'top', 'bottom', 'left top', 'left bottom', 'right top', 'right bottom'], help: 'Text alignment.'}, }, @@ -46,7 +46,7 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true, inte if (this.getProp('align').includes('top')) this.text.classList.add('top') if (this.getProp('align').includes('bottom')) this.text.classList.add('bottom') if (this.getProp('wrap')) this.text.classList.add('wrap') - + if (this.getProp('wrap') === 'soft') this.text.classList.add('wrap-soft') this.setValue(this.getProp('default')) diff --git a/src/scss/widgets/indicators.scss b/src/scss/widgets/indicators.scss index f88613ef..f6b8a3c2 100644 --- a/src/scss/widgets/indicators.scss +++ b/src/scss/widgets/indicators.scss @@ -85,6 +85,9 @@ white-space: pre-wrap; word-break: break-all; } + &.wrap-soft { + word-break: normal + } &.vertical { transform: rotate(180deg); text-overflow: ellipsis;