diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-30 10:42:00 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-30 10:42:00 +0200 |
commit | 845e2e99fd869be1d8d12f69590131bdfb988768 (patch) | |
tree | cfbfa26eceba384d4bf838a5cef2181793e1ef9e | |
parent | c56b187779b53429e868c94e55149c14676a31cb (diff) | |
download | kube-845e2e99fd869be1d8d12f69590131bdfb988768.tar.gz kube-845e2e99fd869be1d8d12f69590131bdfb988768.zip |
Preserve newlines when converting plain to html
-rw-r--r-- | framework/qml/TextEditor.qml | 2 | ||||
-rw-r--r-- | framework/qml/tests/tst_texteditor.qml | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml index ec5993b7..e5cc665c 100644 --- a/framework/qml/TextEditor.qml +++ b/framework/qml/TextEditor.qml | |||
@@ -39,7 +39,7 @@ FocusScope { | |||
39 | 39 | ||
40 | onHtmlEnabledChanged: { | 40 | onHtmlEnabledChanged: { |
41 | if (htmlEnabled) { | 41 | if (htmlEnabled) { |
42 | var t = document.plainText | 42 | var t = document.htmlText |
43 | edit.textFormat = Qt.RichText | 43 | edit.textFormat = Qt.RichText |
44 | edit.text = t | 44 | edit.text = t |
45 | } else { | 45 | } else { |
diff --git a/framework/qml/tests/tst_texteditor.qml b/framework/qml/tests/tst_texteditor.qml index e6773aaa..e4813a0d 100644 --- a/framework/qml/tests/tst_texteditor.qml +++ b/framework/qml/tests/tst_texteditor.qml | |||
@@ -30,7 +30,7 @@ TestCase { | |||
30 | 30 | ||
31 | Kube.TextEditor { | 31 | Kube.TextEditor { |
32 | id: editor | 32 | id: editor |
33 | initialText: "Foobar" | 33 | initialText: "Foobar\nBarBar" |
34 | htmlEnabled: false | 34 | htmlEnabled: false |
35 | } | 35 | } |
36 | 36 | ||
@@ -41,7 +41,9 @@ TestCase { | |||
41 | function test_2htmlConversion() { | 41 | function test_2htmlConversion() { |
42 | editor.htmlEnabled = true | 42 | editor.htmlEnabled = true |
43 | verify(editor.text.indexOf("<html>") !== -1) | 43 | verify(editor.text.indexOf("<html>") !== -1) |
44 | verify(editor.text.indexOf(editor.initialText) !== -1) | 44 | //It's converted into two paragraphs, so we can't check as a single string |
45 | verify(editor.text.indexOf("Foobar") !== -1) | ||
46 | verify(editor.text.indexOf("BarBar") !== -1) | ||
45 | editor.htmlEnabled = false | 47 | editor.htmlEnabled = false |
46 | compare(editor.text, editor.initialText) | 48 | compare(editor.text, editor.initialText) |
47 | } | 49 | } |