Files
AFFiNE/blocksuite/docs/api/@blocksuite/store/interfaces/StoreSlots.md
Saul-Mirone d859c4252b 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 -->
2025-05-05 09:24:09 +00:00

1.5 KiB

BlockSuite API Documentation


BlockSuite API Documentation / @blocksuite/store / StoreSlots

Interface: StoreSlots

Slots for receiving events from the store. All events are rxjs Subjects, you can subscribe to them like this:

store.slots.ready.subscribe(() => {
  console.log('store is ready');
});

You can also use rxjs operators to handle the events.

Properties

blockUpdated

blockUpdated: Subject<StoreBlockUpdatedPayloads>

This fires when a block is updated via API call or has just been updated from existing ydoc.

The payload can have three types:

  • add: When a new block is added
  • delete: When a block is removed
  • update: When a block's properties are modified

historyUpdated

historyUpdated: Subject<void>

This fires when the history is updated.


ready

ready: Subject<void>

This fires after doc.load is called. The Y.Doc is fully loaded and ready to use.


rootAdded

rootAdded: Subject<string>

This fires when the root block is added via API call or has just been initialized from existing ydoc. useful for internal block UI components to start subscribing following up events. Note that at this moment, the whole block tree may not be fully initialized yet.


rootDeleted

rootDeleted: Subject<string>

This fires when the root block is deleted via API call or has just been removed from existing ydoc. In most cases, you don't need to subscribe to this event.