Skip to content

Vizel API / core/src / VizelEditorTransactionStore

Interface: VizelEditorTransactionStore

Defined in: packages/core/src/controllers/transactionStore.ts:18

Framework-agnostic store that exposes editor transaction notifications.

The store does not hold the transaction itself — Tiptap's state.tr is a getter that returns a fresh Transaction on every read, which breaks referential-equality based change detection (notably React's useSyncExternalStore). Instead it tracks a monotonically increasing version counter and lets framework adapters wire the change signal into their reactivity primitive (useState, ref, $state, etc.).

Subscribers are notified on every transaction event from the supplied editor. Swapping the editor (via getEditor returning a different value across subscribe calls) is supported transparently: each subscribe binds against the editor that's current when it is called.

Methods

getVersion()

ts
getVersion(): number;

Defined in: packages/core/src/controllers/transactionStore.ts:28

Return the current version counter, which increments by 1 (with 32-bit wrap-around) on every transaction.

Returns

number


subscribe()

ts
subscribe(onChange): () => void;

Defined in: packages/core/src/controllers/transactionStore.ts:23

Register a callback fired on every editor transaction. Returns an unsubscribe function that detaches the listener.

Parameters

ParameterType
onChange() => void

Returns

() => void

Released under the MIT License.