|
@@ -512,16 +512,20 @@ const tocItems = computed(() => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 检查是否是标题块
|
|
|
|
|
- else if (block.type === 'heading' || (block.style && block.style.headingLevel)) {
|
|
|
|
|
- const level = block.style?.headingLevel || 1
|
|
|
|
|
|
|
+ // 检查是否是标题块 (type: heading1, heading2, heading3...)
|
|
|
|
|
+ else if (block.type && block.type.startsWith('heading')) {
|
|
|
|
|
+ const levelMatch = block.type.match(/heading(\d+)/)
|
|
|
|
|
+ const level = levelMatch ? parseInt(levelMatch[1]) : 1
|
|
|
// 只提取1-3级标题
|
|
// 只提取1-3级标题
|
|
|
if (level <= 3) {
|
|
if (level <= 3) {
|
|
|
- items.push({
|
|
|
|
|
- level: level,
|
|
|
|
|
- text: getBlockPlainText(block),
|
|
|
|
|
- blockId: block.id
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const text = block.plainText || getBlockPlainText(block)
|
|
|
|
|
+ if (text && text.trim()) {
|
|
|
|
|
+ items.push({
|
|
|
|
|
+ level: level,
|
|
|
|
|
+ text: text.trim(),
|
|
|
|
|
+ blockId: block.id
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|