← @mortar-kit/admin

EditorStoreinterface

import { EditorStore } from '@mortar-kit/admin'

interface EditorStore

The editor's state and the only ways to change it.

Properties

readonly state: EditorState
select: (target: Target | null) => void
setSlug: (slug: string) => void

Sets the document's slug (checked when saving).

addEntry: (brickName: string, index?: number) => string | undefined

Adds an entry of the named brick with its default data at index (default: the end) and selects it. Returns the new id, or undefined if no brick has that name or the collection has no body.

removeEntry: (id: string) => void

Removes an entry. If it was selected, a neighbour (or the fields) is selected.

moveEntry: (id: string, toIndex: number) => void

Moves an entry to toIndex. Indexes past either end are ignored.

duplicateEntry: (id: string) => string | undefined

Inserts a copy of an entry (new id, cloned data) after it and selects it. Returns the new id.

setValue: (target: Target, path: Path, value: unknown) => void

Sets the value at path in an entry's data or the document's fields.

insertItem: (target: Target, path: Path, index: number, value: unknown) => void

Inserts value into the list at path.

removeItem: (target: Target, path: Path, index: number) => void

Removes item index from the list at path.

moveItem: (target: Target, path: Path, from: number, to: number) => void

Moves an item of the list at path from one index to another.