feat(ui/scripts/Utils/utils): encodeTextToQmlRichFormat supports tab/spaces correctly

This commit is contained in:
Ronan Abhamon 2017-03-10 10:14:07 +01:00
parent 1a32b3972e
commit 14aa6a9cf1
2 changed files with 3 additions and 5 deletions

View file

@ -59,7 +59,7 @@ Item {
// See http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop
// and http://doc.qt.io/qt-5/richtext-html-subset.html
textFormat: Text.RichText // To supports links and imgs.
wrapMode: TextEdit.Wrap
wrapMode: TextEdit.WordWrap
onCursorRectangleChanged: Logic.ensureVisible(cursorRectangle)
onLinkActivated: Qt.openUrlExternally(link)

View file

@ -50,9 +50,7 @@ function encodeTextToQmlRichFormat (text, options) {
var formattedText = execAll(UriTools.URI_REGEX, text, function (str, valid) {
if (!valid) {
return unscapeHtml(str).replace(/\r\n|\n/g, '<br/>')
.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp; ')
.replace(/ /g, '&nbsp; ')
return unscapeHtml(str)
}
var uri = startsWith(str, 'www.') ? 'http://' + str : str
@ -76,7 +74,7 @@ function encodeTextToQmlRichFormat (text, options) {
images = '<div>' + images + '</div>'
}
return images.concat('<p>' + formattedText + '</p>')
return images.concat('<p style="white-space:pre-wrap;">' + formattedText + '</p>')
}
function extractFirstUri (str) {