Rich text / foldkit-richtext-dom

The editor's Messages

foldkit-richtext-dom/editor holds the vocabulary an editor's update handles. Message's cases (each built as Message.Typed({ text }) and so on, not exported one by one):

Typed, Backspace, DeletedForward, Entered, ToggledMark, AppliedMark, ClearedMark,
RetypedBlock, WrappedBlock, ConvertedBlock, LiftedBlock, MovedBlock, InsertedBlock,
DeletedBlock, ChangedProps, InsertedRow, InsertedColumn, DeletedRow, DeletedColumn, Indented,
Outdented, ActivatedAdornment, Selected, Pasted, Undone, Redone, Patched

The adapter reports what the browser did as commands, a caret, and history chords, and toMessage turns each into a Message. It refuses what the vocabulary cannot carry rather than dropping a detail: an insertion carrying marks, or a mark value with props, comes back undefined. The rest are the application's to send, because no browser event means them:

  • RetypedBlock, WrappedBlock ({ containers }), ConvertedBlock ({ to }), and LiftedBlock for the core's block commands;
  • MovedBlock ({ node, to }, to a RichText.Beside), which a block handle sends and which needs no selection;
  • InsertedBlock ({ block, to? }) and DeletedBlock ({ node }) for InsertBlock and DeleteBlock: an insert menu's image or table, a handle's Duplicate and Delete;
  • ChangedProps ({ node, props }) for SetProps. The adapter sends it too, for a click on a block's adornment that toggles a prop (a task's checkbox, from ElementRendering.adornments);
  • InsertedRow and InsertedColumn ({ where }), DeletedRow and DeletedColumn for the table commands, which act on the caret's cell: what a table toolbar sends;
  • Indented and Outdented for Indent and Outdent. The adapter sends them for Tab and Shift+Tab, but only where RichText.takesTab says Tab means something (code, a table cell, under the placement's vocabulary); anywhere else Tab is left to move focus;
  • ReplacedText ({ query, replacement, caseSensitive?, at? }) for Replace: one match, or every match, as one undo step, which a find bar sends;
  • InsertedFootnote ({ text? }) and RenamedFootnote ({ from, to }) for InsertFootnote and RenameFootnote, which need FootnoteRef in the placement's vocabulary;
  • ActivatedAdornment ({ node, action }): an adornment with an action was clicked, a code block's Copy, say. It is no edit, and the editor changes nothing; the application acts on it;
  • AppliedMark ({ mark }, a name or a { name, props } value) and ClearedMark ({ mark }) for SetMark and ClearMark: what a link editor sends, which at a caret changes or removes the whole link the caret is in.

Patched is the patch Command's own completion, because a Foldkit Command must return a Message.