MarkdownView: исправлен делегат и парсинг блоков
- 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
This commit is contained in:
+14
-17
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user