From b3fa778d8867c32083add5ef5218f9bfaf0c7591 Mon Sep 17 00:00:00 2001 From: grendervill Date: Tue, 1 Sep 2026 21:24:37 +0300 Subject: [PATCH] =?UTF-8?q?MarkdownView:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=B4=D0=B5=D0=BB=D0=B5=D0=B3=D0=B0?= =?UTF-8?q?=D1=82=20=D0=B8=20=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D0=BD=D0=B3=20?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Repeater delegate: убраны required property, заменены на property string blockType: model.type || "" и т.д. для html/code блоков (иначе QML Cannot create delegate когда у html нет codeId) - parseBlocks тест в mdparser_test.cpp: проверка 3 блоков (html/code/html) и highlighted - Убран console.log из MarkdownView::update --- qml/panels/MarkdownView.qml | 31 ++++++++++++++----------------- tests/mdparser_test.cpp | 10 ++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/qml/panels/MarkdownView.qml b/qml/panels/MarkdownView.qml index 632e0a0..d0e8e41 100644 --- a/qml/panels/MarkdownView.qml +++ b/qml/panels/MarkdownView.qml @@ -17,7 +17,6 @@ Item { // Триггерим пересборку блоков blocksModel.clear() const blocks = mdParser.parseBlocks(markdown, vaultRoot, fileDir) - // console.log("MarkdownView update", markdown.length, blocks.length) for (let i = 0; i < blocks.length; i++) { blocksModel.append(blocks[i]) } @@ -35,30 +34,28 @@ Item { Column { id: column - width: parent.width - spacing: 8 anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.margins: 12 + spacing: 8 Repeater { model: blocksModel delegate: Item { - required property int index - required property string type - required property string html - required property string code - required property string language - required property string codeId - required property string highlighted width: parent.width height: childrenRect.height + property string blockType: model.type || "" + property string blockHtml: model.html || "" + property string blockCode: model.code || "" + property string blockLang: model.language || "text" + property string blockCodeId: model.codeId || "" + property string blockHighlighted: model.highlighted || "" // HTML block Text { - visible: type === "html" && html + visible: blockType === "html" && blockHtml width: parent.width - text: html || "" + text: blockHtml textFormat: Text.RichText wrapMode: Text.Wrap color: Theme.text @@ -68,12 +65,12 @@ Item { } // Code block - separate component CodeBlock { - visible: type === "code" + visible: blockType === "code" width: parent.width - code: code || "" - language: language || "text" - codeId: codeId || "" - highlightedText: highlighted || "" + code: blockCode + language: blockLang + codeId: blockCodeId + highlightedText: blockHighlighted onCopyRequested: (id) => { const txt = mdParser.getCodeBlock(id) if (txt.length > 0) { diff --git a/tests/mdparser_test.cpp b/tests/mdparser_test.cpp index 7473613..5db76c3 100644 --- a/tests/mdparser_test.cpp +++ b/tests/mdparser_test.cpp @@ -105,6 +105,16 @@ int main(int argc, char *argv[]) if (!probe(im, "