Fix: textDisplay — editMode=readWrite (редактирование), viewDisplay=readOnly+RichText+wrap (просмотр); прокрутка встроена в TextEdit; переключение по ✎👁

This commit is contained in:
Flora (opencode)
2026-08-17 19:45:24 +03:00
parent d709724fed
commit 15813d358e
+41 -2
View File
@@ -60,13 +60,14 @@ Item {
} }
} }
// Текст файла — TextEdit напрямую (без Flickable) // Текст файла — TextEdit напрямую
TextEdit { TextEdit {
id: textDisplay id: textDisplay
anchors.top: headerBar.bottom anchors.top: headerBar.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: pane.editMode
text: documentManager.activeIndex >= 0 text: documentManager.activeIndex >= 0
? documentManager.contentAt(documentManager.activeIndex) ? documentManager.contentAt(documentManager.activeIndex)
: "" : ""
@@ -74,8 +75,46 @@ Item {
font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace" font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace"
font.pixelSize: 14 font.pixelSize: 14
wrapMode: TextEdit.NoWrap wrapMode: TextEdit.NoWrap
readOnly: true
selectByMouse: true selectByMouse: true
onTextEdited: documentManager.updateContent(pane.docIndex, text)
}
// Режим просмотра (read-only)
TextEdit {
id: viewDisplay
anchors.top: headerBar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: !pane.editMode
readOnly: true
text: pane.editMode ? "" : mdParser.render(
documentManager.contentAt(pane.docIndex),
fileStore.vault,
filePathDir(documentManager.pathAt(pane.docIndex))
)
textFormat: TextEdit.RichText
color: "black"
font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace"
font.pixelSize: 14
wrapMode: TextEdit.Wrap
onLinkActivated: (href) => {
if (href.startsWith("flora://task/")) {
const line = Number(href.substring(14))
if (line > 0) {
const lines = textDisplay.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]", "[ ]")
textDisplay.text = lines.join("\n")
documentManager.updateContent(pane.docIndex, textDisplay.text)
}
}
} else if (href.startsWith("flora://open/")) {
documentManager.openDocument(decodeURIComponent(href.substring(13)))
}
}
} }
// Загрузка контента при смене файла // Загрузка контента при смене файла