# "new Transform" with leaf text node

**URL:** <https://discuss.prosemirror.net/t/new-transform-with-leaf-text-node/8488>\
**Category:** Uncategorized\
**Created:** [July 18, 2025, 11:21am UTC](https://discuss.prosemirror.net/t/new-transform-with-leaf-text-node/8488 "2025-07-18T11:21:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ViktorVaczi](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/viktorvaczi/32/1919_2.png) [@ViktorVaczi](https://discuss.prosemirror.net/u/ViktorVaczi)\
**Post date:** [July 18, 2025, 11:21am UTC](https://discuss.prosemirror.net/t/new-transform-with-leaf-text-node/8488/1 "2025-07-18T11:21:07Z")

</div>

Background: I’m working on improving / fixing bugs in [prosemirror-suggest-changes](https://github.com/handlewithcarecollective/prosemirror-suggest-changes?tab=readme-ov-file).

This is the `Slice` we’re working with:

```json
{
  "content": [
    {
      "type": "text",
      "marks": [
        {
          "type": "em"
        },
        {
          "type": "strong"
        },
        {
          "type": "insertion",
          "attrs": {
            "id": "1"
          }
        }
      ],
      "text": "test paragraph"
    }
  ]
}

```

The code then loops through all the nodes in a slice and creates a `new Transfrom` for each children ( only 1 children in our example ):

```js
  const tr = new Transform(node);

```

Then on that `Transform` it calls:

```auto
tr.removeMark(0, node.nodeSize, markTypeToApply);
// or
tr.removeNodeMark(0, markTypeToApply);

```

Both of these calls fail. The first one at `nodesBetween` because it doesn’t have any children ( okay ). The second one is because `doc.nodeAt(0)` doesn’t return a Node.

In the docs:

```auto
new Transform(doc: Node)
Create a transform that starts with the given document.

```

What we’re giving to the `Transform` is not a document, so I understand why this would not work.

My question is: how to do this correctly, what direction I should try?

---

<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:** [July 18, 2025, 11:34am UTC](https://discuss.prosemirror.net/t/new-transform-with-leaf-text-node/8488/2 "2025-07-18T11:34:20Z")

</div>

You can create a transform with a non-document node, but addressing will work the same as with a document—position 0 refers to the start of the content of the top node, not to the top node itself. So if you’re trying to remove marks from that outer node, this will not work. But doing that is much easier if you just create a copy of the node without the mark, anyway.
