text: add soft mode for the wrap property

This commit is contained in:
bordun 2021-05-08 12:35:27 +02:00
parent 827ea47b6f
commit 6a2b69bad7
3 changed files with 7 additions and 3 deletions

View file

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

View file

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

View file

@ -85,6 +85,9 @@
white-space: pre-wrap;
word-break: break-all;
}
&.wrap-soft {
word-break: normal
}
&.vertical {
transform: rotate(180deg);
text-overflow: ellipsis;