summaryrefslogtreecommitdiffstats
path: root/framework/qml/TextEditor.qml
diff options
context:
space:
mode:
Diffstat (limited to 'framework/qml/TextEditor.qml')
-rw-r--r--framework/qml/TextEditor.qml17
1 files changed, 4 insertions, 13 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml
index 7b1c5dee..45bf2ecd 100644
--- a/framework/qml/TextEditor.qml
+++ b/framework/qml/TextEditor.qml
@@ -34,21 +34,11 @@ FocusScope {
34 34
35 property string initialText 35 property string initialText
36 onInitialTextChanged: { 36 onInitialTextChanged: {
37 htmlEnabled = document.isHtml(initialText)
38 edit.text = initialText 37 edit.text = initialText
39 } 38 }
40 39
41 onHtmlEnabledChanged: { 40 function clearFormatting() {
42 if (htmlEnabled) { 41 document.resetFormat()
43 var t = document.htmlText
44 edit.textFormat = Qt.RichText
45 edit.text = t
46 } else {
47 var t = document.plainText
48 document.resetFormat()
49 edit.textFormat = Qt.PlainText
50 edit.text = t
51 }
52 } 42 }
53 43
54 Kube.TextDocumentHandler { 44 Kube.TextDocumentHandler {
@@ -57,6 +47,7 @@ FocusScope {
57 selectionStart: edit.selectionStart 47 selectionStart: edit.selectionStart
58 selectionEnd: edit.selectionEnd 48 selectionEnd: edit.selectionEnd
59 onTextChanged: { 49 onTextChanged: {
50 root.htmlEnabled = containsFormatting();
60 root.htmlEnabled ? root.text = htmlText : root.text = plainText 51 root.htmlEnabled ? root.text = htmlText : root.text = plainText
61 } 52 }
62 cursorPosition: edit.cursorPosition 53 cursorPosition: edit.cursorPosition
@@ -105,7 +96,7 @@ FocusScope {
105 focus: true 96 focus: true
106 selectByMouse: true 97 selectByMouse: true
107 wrapMode: TextEdit.Wrap 98 wrapMode: TextEdit.Wrap
108 textFormat: Qt.PlainText 99 textFormat: Qt.RichText
109 onCursorRectangleChanged: flickableItem.ensureVisible(cursorRectangle) 100 onCursorRectangleChanged: flickableItem.ensureVisible(cursorRectangle)
110 101
111 color: Kube.Colors.textColor 102 color: Kube.Colors.textColor