s-m-r-t
Open the s-m-r-t source on GitHub Switch to dark color scheme
← All UI components

Content · Components

ContentBodyEditor

No summary has been written for ContentBodyEditor. Everything below is generated from the declaration shipped in 0.57.40 and describes the real contract.

Public export

typescript
import { ContentBodyEditor } from '@happyvertical/smrt-content/svelte';
Import path
@happyvertical/smrt-content/svelte
Props
19
Props described
19 of 19
Bindable state
0
Callback events
7
Verified release
0.57.40

Props

NameTypeRequiredDescription
valuestringYesThe body content string being edited, in HTML or the configured format.
formatContentBodyFormat | nullNoFormat of the body content: HTML, Markdown, or auto-detected.
showFormatPickerbooleanNoShow the "Save as" HTML/Markdown picker in the toolbar. Off by default: the storage format is a technical choice most editors should not face, so hosts opt in for technical users. The body keeps its `format` either way.
placeholderstringNoPlaceholder text shown when the editor is empty.
idstringNoDOM id of the editable surface (default `content-body-input`).
namestringNoField name; also the control id agents address (default `body`).
labelstringNoAccessible and agent-facing label (default "Story").
selectedImageIndexnumberNoIndex of the currently selected image in the body, or -1 for none.
onChange(change: ContentBodyEditorChange) => voidNoFired when the body content or embedded images change.
onOpenImageChooser() => voidNoFired when the user clicks to open the image chooser.
onSelectImage(index: number) => voidNoFired when the user selects an image within the body.
onUseImageAsThumbnail(assetId: string) => voidNoFired when the user sets an image as the content thumbnail.
mainImageAssetIdstring | nullNoAsset id of the current main picture (thumbnail). The selected image's "Use as main picture" button shows as pressed when it is this one.
onResolveImage(selected: ImageLike | File | string) => Promise<unknown> | unknownNoResolves an image file, asset, or ID to a persisted image URL or object.
imagePanelSnippetNoThe image panel (chooser/editor) the toolbar's image button opens. When provided it renders between the toolbar and the writing surface, sliding open above the text, and the image button reports `aria-expanded` / `aria-controls`. Without it the button only fires `onOpenImageChooser`.
imagePanelOpenbooleanNoWhether the image panel is open (controlled by the parent).
imagePanelLabelstringNoAccessible name of the image panel region (default "Pictures").
onCloseImagePanel() => voidNoFired when the panel asks to close (Escape inside it).
onRequestImageChange(request: ContentBodyImageChangeRequest) => voidNoThe person wants a picture changed. With it, a selected or hovered picture shows a "Change this picture" button, the picture toolbar gets one too, and pressing and holding a picture (about half a second, without moving; moving is still a drag) asks with `listen: true`. Without it none of these show.

Bindable state

This component has no bindable public state.

Callback events

  • onChange(change: ContentBodyEditorChange) => void
  • onOpenImageChooser() => void
  • onSelectImage(index: number) => void
  • onUseImageAsThumbnail(assetId: string) => void
  • onResolveImage(selected: ImageLike | File | string) => Promise<unknown> | unknown
  • onCloseImagePanel() => void
  • onRequestImageChange(request: ContentBodyImageChangeRequest) => void

Examples and explanation