Feature: Support for replace with multiple nodes
There currently is a way to replace a LexicalNode with another node. It would be great to extend this functionality to be able to replace with a list of nodes.
Would ElementNode.splice meet this use case?
@acywatson Hmmm, thanks! It does look like I would be able to achieve that using ElementNode.splice with the help of LexicalNode.getParent() and LexicalNode.getIndexWithinParent().
I think that makes this less of an issue, however it would still be easier/nice to have to do the replace at the child LexicalNode level like LexicalNode.replace does, perhaps by changing that to replace<N extends LexicalNode>(replaceWith: Array<N>): Array<N>
Yea, I think that does make sense. I momentarily forgot that replace is a method on LexicalNode. I think it makes sense to have an interface that supports replacing a single node with multiple.
Maybe even
replace<N extends LexicalNode>(replaceWith: Array<N> | N): Array<N>
for backwards compat.
I don't think we need to expand core functionality on this given you can achieve this easily in user-land today.