@mocanvas/editor · class

UserPreferencesManager

declare class UserPreferencesManager

Reads preferences with the editor's defaults applied, and writes them back through whoever owns them.

Every getter resolves in the same order: the value the CurrentUser carries, then the editor-level fallback passed to the constructor (for colorScheme only), then USER_PREFERENCES_DEFAULTS. The controlled user therefore always wins over an editor option — which is the point of controlling it.

The getters read a signal, so calling them inside a computed or react subscribes to preference changes.


Methods · 21

constructor(user: CurrentUser,
getAnimationSpeed(): number

How fast the editor animates; 0 means "do not animate".

A user who has expressed no preference inherits the operating system's, the same way colorScheme: "system" does. Reduced motion is an accessibility setting people set once, for every application, and an editor that ignored it until it was told a second time would be reading the setting and then disregarding it.

getAreKeyboardShortcutsEnabled(): boolean
getColor(): string
getColorScheme(): ColorScheme

The scheme actually in force: the user's, else the editor's, else "system".

getEdgeScrollSpeed(): number
getId(): UserId
getIsDarkMode(): boolean

getColorScheme with "system" resolved against the OS setting.

getIsDynamicResizeMode(): boolean

Alias of getIsDynamicSizeMode. The preference is spelled "dynamic resize mode" at some call sites and "dynamic size mode" at others; both names read the one setting.

getIsDynamicSizeMode(): boolean
getIsEnhancedA11yMode(): boolean
getIsPasteAtCursorMode(): boolean
getIsSnapMode(): boolean
getIsWrapMode(): boolean
getLocale(): string
getName(): string
getUserPreferences(): UserPreferencesState

The raw preferences object, exactly as its owner holds it.

setColor(color: string): void
setName(name: string): void
setUserPreferences(next: UserPreferencesState): void

Replace the whole object.

updateUserPreferences(patch: Partial<UserPreferencesState>): void

Merge patch into the current preferences and hand the result to the owner.


Properties · 1

colorScheme?: ColorScheme | null)

The editor-level fallback, used only when the user has no colorScheme of their own.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.