fix(editor+outline): 2个问题修复——1.tiptap error: resetEditor清空currentPath后TiptapEditor提前return不渲染EditorContent, 但useEffect仍调editor.commands.setContent触发view.dom访问崩溃; 修复: currentPath为null时跳过setContent并注销useEditorShared引用; 2a.大纲不随文档切换更新: collect effect仅依赖editor, setContent用emitUpdate:false不触发update事件; 修复: 加currentPath依赖+rAF延迟收集; 2b.大纲点击跳转位置不准: scrollIntoView的block:start受父容器影响; 修复: 手动计算scrollTop=elRect.top-containerRect.top+scrollEl.scrollTop, scrollTo精确到容器最上方

This commit is contained in:
hunter-dev
2026-08-26 21:35:11 +08:00
parent b01bdd380a
commit 0c605cb8b6
3 changed files with 47 additions and 14 deletions
+16
View File
@@ -339,3 +339,19 @@ test('TabBar: 关闭全部标签后编辑器应显示空状态', async () => {
await expect(a.page.getByText('从左侧选择一篇笔记')).toBeVisible({ timeout: 5000 });
await a.app.close();
});
test('OutlinePanel: 切换文档后大纲自动更新', async () => {
const a = await launch(nodePath.join(os.tmpdir(), 'hn-outline-' + Date.now()));
await setupVault(a, [
{ name: 'DocA', body: '# Title A\n## Sub A' },
{ name: 'DocB', body: '# Title B\n## Sub B\n### Deep B' },
]);
await a.page.getByTestId('filetree').getByText('DocA', { exact: true }).click();
await a.page.waitForTimeout(500);
await expect(a.page.locator('.outline-item', { hasText: 'Title A' })).toBeVisible({ timeout: 5000 });
await expect(a.page.locator('.outline-item', { hasText: 'Sub A' })).toBeVisible({ timeout: 5000 });
await a.page.getByTestId('filetree').getByText('DocB', { exact: true }).click();
await a.page.waitForTimeout(800);
await expect(a.page.locator('.outline-item', { hasText: 'Title B' })).toBeVisible({ timeout: 5000 });
await expect(a.page.locator('.outline-item', { hasText: 'Deep B' })).toBeVisible({ timeout: 5000 });
await a.app.close();
});