Primitives / Interaction
Editing in place
EditableText is text typed into a marked descendant of a container while
it is contenteditable, as one Mount on the container. The view decides which
field is editable; the Mount focuses it as it becomes so (made editable, or
drawn editable), with the caret at its end, and at no other time: a field
editable all along, or another going away, moves no focus. It reads what is
typed:
- Text, never markup. It reads
innerText. A field is one line unless it carriesaria-multiline="true", and in one line a line break becomes a space. Where the browser lackscontenteditable="plaintext-only", a paste is inserted as its text. TextEdited { field, text }on each change,fieldbeing the marking attribute's value. Nothing is reported while an input method composes; the composed text arrives once.TextCommitted { field, text }on Enter (Shift+Enter breaks a line in a multiline field) or on leaving the field;TextCancelled { field, initial }on Escape, which also puts the text the field had when the edit began (on focus, or on the first keystroke after an edit ended) back in the DOM, the caret at its end. A view that stopped redrawing the field while it was edited would not. An edit ends once: the blur after Enter commits nothing more.- Focus comes back to the container when Enter or Escape ended an edit and
the view then removes the field or makes it no longer editable, which leaves
focus on nothing; give the container a
tabindex, and the next key (an undo) reaches it. A field left by the author keeps no such claim. EditAsked { field }on a double-click over a marked field that is not editable yet: the view's cue to make it so.
The Mount is EditableText({ attribute }) in foldkit-primitives/dom;
EditableText.behavior(Slots)<Input, Message>({ container, attribute, toMessage })
attaches it. What a change means (a prop set, an undo group) is the parent's
update.