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))) + } + } } // Загрузка контента при смене файла