refactor(editor): move history from doc to store (#12131)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Undo/redo history management is now centralized in the workspace, providing more consistent and robust undo/redo behavior. - History update events are emitted at the workspace level, enabling better tracking of changes. - **Bug Fixes** - Improved reliability of undo/redo actions by shifting history management from documents to the workspace. - **Documentation** - Updated and clarified documentation for history-related APIs, including improved examples and clearer descriptions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -112,7 +112,7 @@ export const database: InitFn = (collection: Workspace, id: string) => {
|
||||
store.addBlock('affine:paragraph', {}, noteId);
|
||||
datasource.viewManager.viewAdd(viewPresets.kanbanViewMeta.type);
|
||||
|
||||
doc.resetHistory();
|
||||
store.resetHistory();
|
||||
};
|
||||
// Add database block inside note block
|
||||
addDatabase('Database 1', false);
|
||||
|
||||
@@ -47,7 +47,7 @@ export const embed: InitFn = (collection: Workspace, id: string) => {
|
||||
store.addBlock('affine:paragraph', {}, noteId);
|
||||
});
|
||||
|
||||
doc.resetHistory();
|
||||
store.resetHistory();
|
||||
};
|
||||
|
||||
embed.id = 'embed';
|
||||
|
||||
@@ -21,7 +21,7 @@ export const empty: InitFn = (collection: Workspace, id: string) => {
|
||||
store.addBlock('affine:paragraph', {}, noteId);
|
||||
});
|
||||
|
||||
doc.resetHistory();
|
||||
store.resetHistory();
|
||||
};
|
||||
|
||||
empty.id = 'empty';
|
||||
|
||||
@@ -95,6 +95,5 @@ export async function initStarterDocCollection(collection: TestWorkspace) {
|
||||
if (!doc?.loaded) {
|
||||
doc?.load();
|
||||
}
|
||||
doc?.resetHistory();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user