Fix: TextArea заменён на TextEdit+Flickable (базовый QML без Controls styling, гарантированный рендеринг); anchors.top/bottom/left/right для позиционирования

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