refactor(editor): replace-id middlware (#12250)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Refactor**
  - Improved the internal structure and clarity of ID handling during import processes, leading to more maintainable and modular code. No changes to user-facing functionality.
- **Chores**
  - Enhanced type definitions for import events to improve code readability and maintainability. No impact on end-user experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fundon
2025-05-13 12:27:52 +00:00
parent 08d6c5a97c
commit e4f32cd61e
2 changed files with 79 additions and 53 deletions

View File

@@ -11,13 +11,15 @@ import type {
SliceSnapshot,
} from './type.js';
export type BeforeImportBlockPayload = {
snapshot: BlockSnapshot;
type: 'block';
parent?: string;
index?: number;
};
export type BeforeImportPayload =
| {
snapshot: BlockSnapshot;
type: 'block';
parent?: string;
index?: number;
}
| BeforeImportBlockPayload
| {
snapshot: SliceSnapshot;
type: 'slice';
@@ -71,14 +73,16 @@ export type AfterExportPayload =
type: 'info';
};
export type AfterImportBlockPayload = {
snapshot: BlockSnapshot;
type: 'block';
model: BlockModel;
parent?: string;
index?: number;
};
export type AfterImportPayload =
| {
snapshot: BlockSnapshot;
type: 'block';
model: BlockModel;
parent?: string;
index?: number;
}
| AfterImportBlockPayload
| {
snapshot: DocSnapshot;
type: 'page';