mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
fix(task-view): resolve text display sync issues in markdown rendering
- Use requestAnimationFrame for proper DOM cleanup timing - Fix text discrepancies when switching between edit and view modes - Ensure markdown renderer properly updates on metadata changes
This commit is contained in:
parent
393fb48c01
commit
99861bdb9a
1 changed files with 20 additions and 17 deletions
|
|
@ -741,24 +741,27 @@ export class TaskListItemComponent extends Component {
|
|||
// Clear the content element
|
||||
this.contentEl.empty();
|
||||
|
||||
// Create new renderer
|
||||
this.markdownRenderer = new MarkdownRendererComponent(
|
||||
this.app,
|
||||
this.contentEl,
|
||||
this.task.filePath
|
||||
);
|
||||
this.addChild(this.markdownRenderer);
|
||||
|
||||
// Render the markdown content
|
||||
this.markdownRenderer.render(this.task.originalMarkdown || "\u200b");
|
||||
|
||||
// Re-register the click event for editing after rendering
|
||||
this.registerContentClickHandler();
|
||||
|
||||
// Update layout mode after content is rendered
|
||||
// Use requestAnimationFrame to ensure the content is fully rendered
|
||||
// 使用 requestAnimationFrame 确保 DOM 完全清理后再渲染新内容
|
||||
requestAnimationFrame(() => {
|
||||
this.updateLayoutMode();
|
||||
// Create new renderer
|
||||
this.markdownRenderer = new MarkdownRendererComponent(
|
||||
this.app,
|
||||
this.contentEl,
|
||||
this.task.filePath
|
||||
);
|
||||
this.addChild(this.markdownRenderer);
|
||||
|
||||
// Render the markdown content - 使用最新的 originalMarkdown
|
||||
this.markdownRenderer.render(this.task.originalMarkdown || "\u200b");
|
||||
|
||||
// Re-register the click event for editing after rendering
|
||||
this.registerContentClickHandler();
|
||||
|
||||
// Update layout mode after content is rendered
|
||||
// Use another requestAnimationFrame to ensure the content is fully rendered
|
||||
requestAnimationFrame(() => {
|
||||
this.updateLayoutMode();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue