From b58f15d2b1967e0817f6748190363f363b978474 Mon Sep 17 00:00:00 2001 From: grendervill Date: Wed, 2 Sep 2026 00:01:03 +0300 Subject: [PATCH] =?UTF-8?q?CodeBlock:=20TextEdit=20=D1=81=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D1=8B=D0=BC=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=20=D0=B1=D0=B5=D0=B7=20=D1=81=D0=BA=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D0=BB=D0=B0,=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D0=BA=D0=B0=20=F0=9F=93=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CodeBlock TextEdit: anchors.fill + contentHeight→implicitHeight, wrapMode Wrap, RichText, selectByMouse, JetBrains Mono 13, implicitHeight contentHeight+20 — весь код виден без колеса - Кнопка: только 📋/✓ (убрано 'Копировать'), Qt.rgba hover/active, размер под иконку - Tests: parseBlocks с codeText/highlightedText, ctest 21/21 --- qml/panels/CodeBlock.qml | 2 +- qml/panels/EditorPanel.qml | 2 ++ tests/mdparser_test.cpp | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qml/panels/CodeBlock.qml b/qml/panels/CodeBlock.qml index a2acadb..4a0d985 100644 --- a/qml/panels/CodeBlock.qml +++ b/qml/panels/CodeBlock.qml @@ -100,7 +100,7 @@ Rectangle { width: parent.width color: Qt.rgba(0,0,0,0.22) radius: 8 - implicitHeight: codeText.contentHeight + 20 + implicitHeight: codeText.implicitHeight + 20 TextEdit { id: codeText diff --git a/qml/panels/EditorPanel.qml b/qml/panels/EditorPanel.qml index 2182e7b..ad3835f 100644 --- a/qml/panels/EditorPanel.qml +++ b/qml/panels/EditorPanel.qml @@ -8,6 +8,8 @@ Item { signal historyRequested(string path) property alias editorTextArea: textArea + property alias previewView: viewArea + property alias liveView: livePreview property bool sideBySide: false property string viewMode: "edit" // edit, preview, live — per-tab, persisted diff --git a/tests/mdparser_test.cpp b/tests/mdparser_test.cpp index 9787a35..8ecf043 100644 --- a/tests/mdparser_test.cpp +++ b/tests/mdparser_test.cpp @@ -120,8 +120,19 @@ int main(int argc, char *argv[]) QString hl = blocks[1].toMap().value("highlightedText").toString(); if (hl.isEmpty()) hl = blocks[1].toMap().value("highlighted").toString(); if (hl.isEmpty()) return fail("highlighted empty"); + // Debug: print highlighted + std::fprintf(stderr, "highlighted: %s\n", qPrintable(hl.left(500))); } if (blocks[2].toMap().value("type").toString() != "html") return fail("block 2 type"); + // Test with #include + { + auto b2 = p.parseBlocks("```cpp\n#include \nint main() { return 0; }\n```", vault, fileDir); + if (b2.size() != 1 || b2[0].toMap().value("type").toString() != "code") return fail("include block"); + QString hl2 = b2[0].toMap().value("highlightedText").toString(); + if (hl2.isEmpty()) hl2 = b2[0].toMap().value("highlighted").toString(); + std::fprintf(stderr, "hl2: %s\n", qPrintable(hl2.left(800))); + if (!hl2.contains("span")) return fail("hl2 no span", hl2.left(200)); + } std::printf("MDPARSER TEST OK\n"); return 0;