# DOM-like editing - anything out there already?

**URL:** <https://discuss.prosemirror.net/t/dom-like-editing-anything-out-there-already/4111>\
**Category:** Uncategorized\
**Created:** [October 13, 2021, 8:51am UTC](https://discuss.prosemirror.net/t/dom-like-editing-anything-out-there-already/4111 "2021-10-13T08:51:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tslocke](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/tslocke/32/2218_2.png) [@tslocke](https://discuss.prosemirror.net/u/tslocke)\
**Post date:** [October 13, 2021, 8:51am UTC](https://discuss.prosemirror.net/t/dom-like-editing-anything-out-there-already/4111/1 "2021-10-13T08:51:09Z")

</div>

My ProseMirror project is (among other things) a kind of hybrid general text editor (i.e. normal ProseMirror) and a block based outliner.

To facilitate this I’m writing a layer of DOM-like editing operations on top of the existing Transform API, so I can do things like remove a node, insert a child node at a given index, append a child node, and so on. A ResolvedPos pointing to the start of a node works well as a “node” instance. For example, here’s `remove`:

```
function remove(tr: Transaction, $n: ResolvedPos) {
  if ($n.nodeAfter) {
    tr.deleteRange($n.pos, $n.pos + $n.nodeAfter.nodeSize)
  }
}

```

My questions:

Does this make sense as a way to get block based editing? It seems a bit clunky that I’m having to implement in terms of integer positions, which ProseMirror (I think?) will translate back into the dom-like edit that I wanted in the first place. I’m pretty sure there’s good reason it has to work this way, but thought I’d double check.

It seems like this must be a common use-case. Is there anything out there already along these lines?

Thanks!

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 13, 2021, 9:06am UTC](https://discuss.prosemirror.net/t/dom-like-editing-anything-out-there-already/4111/2 "2021-10-13T09:06:05Z")

</div>

Yes, this looks like the right way to do something like that.
