Insert node child to existing node

Hi, I am writing here because I already check everything and I cannot find a solution.

I would like to insert a child node to an already existing node.

For example:

I have:

<div class="section"></section>

and I would like to add dynamically a child element without using the createAndFIll():

<div class="section"><div class="section-element">Content</div></section>

Thanks in advance.

You can’t. Node objects are immutable, which means they are never changed. However, you can create a new node with different content.

If you’re editing an actual document in the editor, rather than building up a new one, you should look into the methods on Transform (of which Transaction is a subclass), which abstract all this away, allowing you to insert a node at a given position (which will still end up creating a new document).