mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-08 12:45:55 +08:00
fix(editor): support relative image reference path when importing zip with images (#12264)
Closes: [BS-3385](https://linear.app/affine-design/issue/BS-3385/markdown类型的导入,支持media文件和md文件不在同目录的情况) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added utility functions to resolve and normalize image file paths in markdown and HTML imports. - Introduced middleware to provide full file path context during file import and transformation. - Added new types for improved asset and file management in zip imports. - **Refactor** - Centralized and simplified image processing logic across HTML, Markdown, and Notion HTML adapters for improved maintainability. - Enhanced type safety and clarity in file and asset handling during zip imports. - **Tests** - Added comprehensive tests for image file path resolution utility. - **Documentation** - Improved inline code comments explaining file path resolution logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import type { TransformerMiddleware } from '@blocksuite/store';
|
||||
|
||||
export const FULL_FILE_PATH_KEY = 'fullFilePath';
|
||||
|
||||
/**
|
||||
* Middleware to set the full file path of the imported file
|
||||
* @param filePath - The full file path of the imported file
|
||||
* @returns A TransformerMiddleware that sets the full file path of the imported file
|
||||
*/
|
||||
export const filePathMiddleware = (filePath: string): TransformerMiddleware => {
|
||||
return ({ adapterConfigs }) => {
|
||||
adapterConfigs.set(FULL_FILE_PATH_KEY, filePath);
|
||||
};
|
||||
};
|
||||
@@ -2,6 +2,7 @@ export * from './code';
|
||||
export * from './copy';
|
||||
export * from './doc-link';
|
||||
export * from './file-name';
|
||||
export * from './file-path';
|
||||
export * from './paste';
|
||||
export * from './proxy';
|
||||
export * from './replace-id';
|
||||
|
||||
Reference in New Issue
Block a user