From 15813d358e7326497a4982a70c94021a8125a933 Mon Sep 17 00:00:00 2001 From: "Flora (opencode)" Date: Mon, 17 Aug 2026 19:45:24 +0300 Subject: [PATCH] =?UTF-8?q?Fix:=20textDisplay=20=E2=80=94=20editMode=3Drea?= =?UTF-8?q?dWrite=20(=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5),=20viewDisplay=3DreadOnly?= =?UTF-8?q?+RichText+wrap=20(=D0=BF=D1=80=D0=BE=D1=81=D0=BC=D0=BE=D1=82?= =?UTF-8?q?=D1=80);=20=D0=BF=D1=80=D0=BE=D0=BA=D1=80=D1=83=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=20TextEdit;=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=20=E2=9C=8E?= =?UTF-8?q?=F0=9F=91=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/panels/EditorPane.qml | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/qml/panels/EditorPane.qml b/qml/panels/EditorPane.qml index 02b28de..f68849d 100644 --- a/qml/panels/EditorPane.qml +++ b/qml/panels/EditorPane.qml @@ -60,13 +60,14 @@ Item { } } - // Текст файла — TextEdit напрямую (без Flickable) + // Текст файла — TextEdit напрямую TextEdit { id: textDisplay anchors.top: headerBar.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom + visible: pane.editMode text: documentManager.activeIndex >= 0 ? documentManager.contentAt(documentManager.activeIndex) : "" @@ -74,8 +75,46 @@ Item { font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace" font.pixelSize: 14 wrapMode: TextEdit.NoWrap - readOnly: 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))) + } + } } // Загрузка контента при смене файла