Add option to insert content to a new node during creation
What does this change?
Provides a new optional argument to RepeaterFieldView.addChildAfter() and RepeaterFieldView.addChildAtEnd().
The old behaviour is kept; that is, if you call field.view.addChildAfter(index) a blank field will still be inserted. However, you can now call field.view.addChildAfter(index, { nodeContent: someNode }) and have that field inserted with the given node.
As a convenience, you can also call field.addChildAfter(index, {textContent: someTextString}) and have a node automatically created for you.
How to test
How can we measure success?
Have we considered potential risks?
Images
Accessibility
This would be a great improvement. Spoken AOB, but to summarise, for a public API the surface area here allows a few footguns:
- no guarantee the node accepts text
- no guarantee the node is valid in the repeater context
- users have to construct the node, meaning users must understand ProseMirror APIs when previously they've been working with data, something this library tries to avoid
Ideally you'd pass the data (typesafely!), and the repeater would handle the translation from data to node.