Исправлен белый экран в предпросмотре: отдельный компонент CodeBlock
- CodeBlock.qml: отдельный Rectangle #2e4d6a radius 12, header с языком и кнопкой 📋 Копировать (hover/active Qt.rgba, Timer 1.5с), код в rgba(0,0,0,0.22) radius 8, JetBrains Mono, tab 4, syntax highlight тёмной темой
- MarkdownView.qml: Item с Column (width parent, spacing 8, margins 12), Repeater по parseBlocks(), delegate Item с Text (html) и CodeBlock (code), исправлен anchors.fill → width/anchors.top для корректного implicitHeight, убраны дубли visible
- MdParser: parseBlocks() сохраняет codeBlocks/counter перед render(htmlPart) чтобы не терять codeId, QRegularExpression для ```lang, highlightedCode() с forceDark
- EditorPanel: viewArea/livePreview теперь MarkdownView (markdown property), liveDebounce/markdown, убран лишний \}
- qmllint чист, ctest 21/21, offscreen/cocoa RUNNING OK
This commit is contained in:
@@ -762,7 +762,12 @@ QVariantList MdParser::parseBlocks(const QString &markdown, const QString &vault
|
||||
if (start > lastPos) {
|
||||
QString htmlPart = markdown.mid(lastPos, start - lastPos);
|
||||
if (!htmlPart.trimmed().isEmpty()) {
|
||||
// Сохраняем codeBlocks, т.к. render() их очищает
|
||||
QHash<QString, QString> savedBlocks;
|
||||
int savedCounter = 0;
|
||||
if (m) { savedBlocks = m->codeBlocks; savedCounter = m->codeCounter; }
|
||||
QString html = render(htmlPart, vaultRoot, fileDir);
|
||||
if (m) { m->codeBlocks = savedBlocks; m->codeCounter = savedCounter; }
|
||||
if (!html.trimmed().isEmpty())
|
||||
blocks.append(QVariantMap{{"type", "html"}, {"html", html}});
|
||||
}
|
||||
@@ -795,14 +800,22 @@ QVariantList MdParser::parseBlocks(const QString &markdown, const QString &vault
|
||||
if (lastPos < markdown.length()) {
|
||||
QString htmlPart = markdown.mid(lastPos);
|
||||
if (!htmlPart.trimmed().isEmpty()) {
|
||||
QHash<QString, QString> savedBlocks;
|
||||
int savedCounter = 0;
|
||||
if (m) { savedBlocks = m->codeBlocks; savedCounter = m->codeCounter; }
|
||||
QString html = render(htmlPart, vaultRoot, fileDir);
|
||||
if (m) { m->codeBlocks = savedBlocks; m->codeCounter = savedCounter; }
|
||||
if (!html.trimmed().isEmpty())
|
||||
blocks.append(QVariantMap{{"type", "html"}, {"html", html}});
|
||||
}
|
||||
}
|
||||
// Если вообще не нашли блоки, но markdown не пустой — вернём как html
|
||||
if (blocks.isEmpty() && !markdown.trimmed().isEmpty()) {
|
||||
QHash<QString, QString> savedBlocks;
|
||||
int savedCounter = 0;
|
||||
if (m) { savedBlocks = m->codeBlocks; savedCounter = m->codeCounter; }
|
||||
QString html = render(markdown, vaultRoot, fileDir);
|
||||
if (m) { m->codeBlocks = savedBlocks; m->codeCounter = savedCounter; }
|
||||
blocks.append(QVariantMap{{"type", "html"}, {"html", html}});
|
||||
}
|
||||
return blocks;
|
||||
|
||||
Reference in New Issue
Block a user