Rich text / foldkit-richtext-dom/input

RichTextCodec

interface · packages/richtext-dom/src/input.ts:76

interface RichTextCodec<A> {
  readonly value: (document: RichText.Document) => A
  readonly blank?: A | undefined
  readonly fill: (value: A) => RichText.Document
}

How a key holds a type other than a RichText.Document while the editor still holds one: a stored Markdown text, say. value runs on every read of the key and fill on a given value, so both stay a plain function of their argument. fill is called with stored data and may throw, which fails the form's fill as any control that cannot show a value does.

Members

RichTextCodec.value

property · packages/richtext-dom/src/input.ts:78

readonly value: (document: RichText.Document) => A

The key's value for a document the editor holds. It is never called with a blank one.

RichTextCodec.blank

property · packages/richtext-dom/src/input.ts:83

readonly blank?: A | undefined

The key's value for a blank document, where nothing entered is a value of its own (an empty text, not "required"). Absent, a blank document is no value and a required key refuses it.

RichTextCodec.fill

property · packages/richtext-dom/src/input.ts:85

readonly fill: (value: A) => RichText.Document

The document the editor shows for a value the form was given.