Fix: TextArea заменён на TextEdit+Flickable (базовый QML без Controls styling, гарантированный рендеринг); anchors.top/bottom/left/right для позиционирования
This commit is contained in:
+34
-41
@@ -14,7 +14,7 @@ Item {
|
||||
signal closePane()
|
||||
|
||||
function insertText(t) {
|
||||
editor.insert(editor.cursorPosition, t)
|
||||
textDisplay.insert(textDisplay.cursorPosition, t)
|
||||
}
|
||||
|
||||
// Шапка файла — плавающий оверлей
|
||||
@@ -60,43 +60,38 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
// TextArea — заполняет ВСЁ пространство
|
||||
TextArea {
|
||||
id: editor
|
||||
anchors.fill: parent
|
||||
visible: pane.editMode
|
||||
color: "black"
|
||||
font.family: "monospace"
|
||||
font.pixelSize: 14
|
||||
padding: 10
|
||||
onTextEdited: documentManager.updateContent(pane.docIndex, text)
|
||||
}
|
||||
// Текст файла — Text вместо TextArea (гарантированный рендеринг)
|
||||
Flickable {
|
||||
id: flickable
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
contentWidth: textDisplay.paintedWidth
|
||||
contentHeight: textDisplay.paintedHeight
|
||||
clip: true
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
// Просмотр
|
||||
TextArea {
|
||||
id: viewer
|
||||
anchors.fill: parent
|
||||
visible: !pane.editMode
|
||||
readOnly: true
|
||||
color: "black"
|
||||
font.family: "monospace"
|
||||
font.pixelSize: 14
|
||||
padding: 10
|
||||
onLinkActivated: (href) => {
|
||||
if (href.startsWith("flora://task/")) {
|
||||
const line = Number(href.substring(14))
|
||||
if (line > 0) {
|
||||
const lines = editor.text.split("\n")
|
||||
const ln = lines[line - 1]
|
||||
if (ln !== undefined) {
|
||||
if (/\[ \]/.test(ln)) lines[line - 1] = ln.replace("[ ]", "[x]")
|
||||
else if (/\[x\]/.test(ln)) lines[line - 1] = ln.replace("[x]", "[ ]")
|
||||
editor.text = lines.join("\n")
|
||||
documentManager.updateContent(pane.docIndex, editor.text)
|
||||
}
|
||||
TextEdit {
|
||||
id: textDisplay
|
||||
width: flickable.width
|
||||
text: documentManager.activeIndex >= 0
|
||||
? documentManager.contentAt(documentManager.activeIndex)
|
||||
: ""
|
||||
color: "black"
|
||||
font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace"
|
||||
font.pixelSize: 14
|
||||
wrapMode: TextEdit.NoWrap
|
||||
readOnly: true
|
||||
selectByMouse: true
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onWheel: (w) => {
|
||||
if (w.angleDelta.y > 0)
|
||||
flickable.contentY = Math.max(0, flickable.contentY - 30)
|
||||
else
|
||||
flickable.contentY = Math.min(flickable.contentHeight - flickable.height, flickable.contentY + 30)
|
||||
}
|
||||
} else if (href.startsWith("flora://open/")) {
|
||||
documentManager.openDocument(decodeURIComponent(href.substring(13)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,11 +101,9 @@ Item {
|
||||
const idx = pane.docIndex
|
||||
if (idx >= 0) {
|
||||
const c = documentManager.contentAt(idx)
|
||||
editor.text = c
|
||||
viewer.text = mdParser.render(c, fileStore.vault, filePathDir(documentManager.pathAt(idx)))
|
||||
textDisplay.text = c
|
||||
} else {
|
||||
editor.text = ""
|
||||
viewer.text = ""
|
||||
textDisplay.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +113,7 @@ Item {
|
||||
}
|
||||
|
||||
onDocIndexChanged: refresh()
|
||||
onEditModeChanged: { if (!editMode) refresh() }
|
||||
onEditModeChanged: { refresh() }
|
||||
|
||||
Connections {
|
||||
target: documentManager
|
||||
|
||||
Reference in New Issue
Block a user