2 import QtQuick.Controls.Suru 2.2
3 import Lomiri.Components 1.3
4 import
Dekko.Markdown 1.0
8 property int frameSpacing: 0
9 property bool plainTextOnly:
false
10 property alias headerHeight: col.height
11 property alias options: mdDoc.options
12 property alias text: te.text
13 property alias textDocument: te.textDocument
15 property alias header: h.data
16 property alias toolbar: t.data
25 contentHeight: col.height + te.paintedHeight + editor.frameSpacing + units.gu(1)
26 boundsBehavior: Flickable.StopAtBounds
38 height: childrenRect.height
43 height: childrenRect.height
49 visible: te.text && !editor.plainTextOnly
58 height: l.height + units.gu(1)
64 rightMargin: units.gu(3)
65 verticalCenter: parent.verticalCenter
68 color: LomiriColors.blue
70 onClicked: showPreview()
81 leftMargin: editor.frameSpacing
82 topMargin: text && !editor.plainTextOnly ? 0 : editor.frameSpacing
83 rightMargin: editor.frameSpacing
85 height: Math.max(editor.height - col.height, contentHeight)
86 wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
87 mouseSelectionMode: TextEdit.SelectWords
88 persistentSelection:
true
90 selectionColor: Qt.rgba(LomiriColors.blue.r, LomiriColors.blue.g, LomiriColors.blue.b, 0.2)
91 selectedTextColor: Suru.foregroundColor
92 color: Suru.foregroundColor
93 Keys.forwardTo: editor.plainTextOnly ? [inputOverlay] : [mdDoc, inputOverlay]
94 Mouse.forwardTo: [inputOverlay]
106 property:
"textDocument"
107 value: te.textDocument
108 when: !editor.plainTextOnly
114 fontSize: FontUtils.sizeToPixels(
"medium")
115 enableLargeHeadingSizes:
true
116 autoMatchEnabled:
true
117 cycleBulletMarker:
true
120 textColor: Suru.secondaryForegroundColor
121 backgroundColor: Suru.backgroundColor
122 linkColor: LomiriColors.blue
123 markupColor: Suru.neutralColor
126 cursorPosition: te.cursorPosition
127 onCursorPositionChanged: {
128 if (te.cursorPosition !== cursorPosition) {
129 te.cursorPosition = cursorPosition
132 hasSelection: te.selectedText
133 selectionStart: te.selectionStart
134 selectionEnd: te.selectionEnd
136 Component.onCompleted: cursorPosition = 0