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.

Properties ​

getVersion ​

ts
readonly getVersion: () => number;

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

Return the current version counter, which increments by 1 (with 32-bit wrap-around) on every transaction. Safe to call detached, like subscribe.

Returns ​

number


subscribe ​

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

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

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

Declared as a function-typed property rather than a method: the implementation does not use this, so callers may pass it detached (for example, to React's useSyncExternalStore).

Parameters ​

ParameterType
onChange() => void

Returns ​

() => void

Released under the MIT License.