Repository navigation
fix(notes): 修复打开 Markdown 文件时相对路径图片无法渲染 - #448
Merged
Merged
Conversation
NotesView 打开外部 Markdown 文件时,编辑器经 from_markdown_embedded_with_host 创建,file_path 恒为 None,image_base_dir 回退到进程 CWD,导致相对路径图片 解析失败。现在: - Editor 新增公开的 file_path()/set_file_path(),设置后重建图片运行时并通知 - open_markdown_document 创建编辑器后立即绑定 descriptor.absolute_path - 笔记本内重命名文档时(remap_markdown_sessions)同步更新编辑器 file_path 回归测试:standalone_markdown_binds_editor_to_the_opened_file
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
打开本地 Markdown 文件时,正文里相对路径的图片(如
)无法渲染。根因
NotesView打开外部 Markdown 文件时,编辑器经MarkdownEditor::from_markdown_embedded_with_host创建,其file_path恒为None:Editor::image_base_dir()(crates/markdown-editor/src/editor/runtime_context.rs:88)在file_path为None时回退到进程 CWD(GUI 应用通常是/)<stem>.assets退化为untitle.assets修复
crates/markdown-editor/src/editor/host.rsEditor新增公开file_path()/set_file_path();设置新路径后重建图片运行时(rebuild_image_runtimes)并通知crates/notes/src/markdown_view.rsopen_markdown_document创建编辑器后立即绑定descriptor.absolute_path;remap_markdown_sessions(笔记本内重命名)同步更新编辑器file_pathcrates/notes/src/notes_actions.rsapply_rename传入cx验证
standalone_markdown_binds_editor_to_the_opened_file:打开含相对路径图片的 md 文件,断言editor.file_path()为文件绝对路径(dev 基线隔离 worktree 中 1 passed)cargo check -p markdown-editor0 error