EditorPropsinterface
import { EditorProps } from '@mortar-kit/admin'
interface EditorPropsProperties
bricks: readonly AnyBrick[]The bricks this site defines.
collection: AnyCollectionThe collection the document belongs to.
doc: DocThe document to edit. Edits are kept in the editor; a new
docvalue replaces them.isNew?: booleanA new document that was never saved: it starts unsaved, and the first save creates it (the editor then treats it as saved).
previewUrl: stringURL of the app route that renders
<PreviewPage>from@mortar-kit/admin/preview.refresh?: numberBump it after saved content changes elsewhere, so bricks in the preview load again. Saves here do it already.
onChange?: (doc: Doc) => voidCalled with a plain copy of the document after every change.
onSave?: (doc: Doc) => Promise<void | SaveResult>Saves the document; without it there is no Save button. Resolve with a
SaveResult(e.g. fromContent.save) to report validation problems, or reject if saving failed. The editor validates before calling it too.onRemove?: () => voidDeletes the document; without it there is no Delete button. The editor doesn't ask first: the handler does.
onDirtyChange?: (dirty: boolean) => voidCalled with whether there are unsaved changes, initially and whenever that changes (only with
onSave), and with false if the save controls go away while dirty (the editor unmounts oronSaveis removed). Use it to guard in-app navigation, e.g. with the router'suseBeforeLeave; closing the tab is already guarded.onFollowLink?: (url: URL) => voidCalled when a same-origin link is ⌘/Ctrl-clicked in the preview (a plain click selects the brick instead). Default: opens it in a new tab.
<Admin>opens the document it points to (seeAdminProps.resolveLink).