# Cannot lift a paragraph/inline content if depth \<= 2

**URL:** <https://discuss.prosemirror.net/t/cannot-lift-a-paragraph-inline-content-if-depth-2/2359>\
**Category:** Uncategorized\
**Created:** [November 20, 2019, 7:11am UTC](https://discuss.prosemirror.net/t/cannot-lift-a-paragraph-inline-content-if-depth-2/2359 "2019-11-20T07:11:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javarome](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/javarome/32/1212_2.png) [@Javarome](https://discuss.prosemirror.net/u/Javarome)\
**Post date:** [November 20, 2019, 7:11am UTC](https://discuss.prosemirror.net/t/cannot-lift-a-paragraph-inline-content-if-depth-2/2359/1 "2019-11-20T07:11:38Z")

</div>

(this is a follow up of [Split at paragraph boundaries leaves empty paragraphs before/after](https://discuss.prosemirror.net/t/split-at-paragraph-boundaries-leaves-empty-paragraphs-before-after/2358/4) after I realized that `split` could not help for my purpose described below)

I’m trying to lift the selection as a higher node. That is, changing:

- simpleAnswer
  - paragraph
    - textStart(selection)textEnd

to:

- simpleAnswer
  - paragraph
    - textStart

- simpleAnswer
  - paragraph
    - (selection)

- simpleAnswer
  - paragraph \*textEnd

Using:

```
const fromPos = tr.doc.resolve(tr.mapping.map(selection.from));
const toPos = tr.doc.resolve(tr.mapping.map(selection.to));
const range = fromPos.blockRange(toPos);
if (range) {
  const depth = liftTarget(range);
  if (depth || depth === 0) {
    tr.lift(range, depth);
  } 
}

```

However `targetLiftDepth` is always `undefined`, I guess because, while the selection has a depth of 2, the range has a depth of 1 (apparently a decrement rule when the selection node has inline content). As a result I guess the lift is considered invalid as it would go below depth 1 (i.e. doc depth 0).

So i cannot devise the proper transform API to use to achieve my goal. I also tried to `wrap` the selection into a `simpleAnswer`, but this is interpreted as having a `simpleAnswer` inside the current one, which is not allowed by my schema.

---

<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:** [November 20, 2019, 7:35am UTC](https://discuss.prosemirror.net/t/cannot-lift-a-paragraph-inline-content-if-depth-2/2359/2 "2019-11-20T07:35:16Z")

</div>

That looks more like a split (with `depth = 2`) than a lift—lift moves content to a shallower parent node. This leaves it exactly as deep, if I understand your example correctly.

---

<div class="post-metadata">

**Author:** ![Javarome](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/javarome/32/1212_2.png) [@Javarome](https://discuss.prosemirror.net/u/Javarome)\
**Post date:** [November 20, 2019, 10:06am UTC](https://discuss.prosemirror.net/t/cannot-lift-a-paragraph-inline-content-if-depth-2/2359/3 "2019-11-20T10:06:50Z")

</div>

Yes I wan’t to keep it as deep. I just assumed (wrongly apparently) that lifting a paragraph selection would automatically put it in its own `simpleAnswer` (according to my schema).

Ok so this leads me back to my original issue on lifting, because lifting with depth 2\* does insulate the selection in a paragraph in its own `simpleAnswer` but I cannot avoid splitting before/after the selection when the selection it at paragraph start/end because otherwise it would keep the text before/after in the same `simpleAnswer`. So _the empty paragraph issue raises again_ (i.e. if I split from paragraph start the previous `simpleAnswer` will have an empty paragraph at its end, and conversely, see [Split at paragraph boundaries leaves empty paragraphs before/after](https://discuss.prosemirror.net/t/split-at-paragraph-boundaries-leaves-empty-paragraphs-before-after/2358/4) where you gave me the solution for split at depth 1).

\*_Sounds obvious when you know it, but there might be some misunderstanding when reading the docs about absolute depth (in document) dans relative depth (as parameters for perform some transformations). Both goes 0 to n, but not in the same direction, and this can be confusing for beginners. Maybe different terms should be employed to clarify things, such as “absolute depth” and “relative depth”. Just to let you know._

---

<div class="post-metadata">

**Author:** ![Pier](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/pier/32/616_2.png) [@Pier](https://discuss.prosemirror.net/u/Pier)\
**Post date:** [December 7, 2020, 9:31pm UTC](https://discuss.prosemirror.net/t/cannot-lift-a-paragraph-inline-content-if-depth-2/2359/4 "2020-12-07T21:31:27Z")

</div>

> [@Javarome](#):
>
> Sounds obvious when you know it, but there might be some misunderstanding when reading the docs about absolute depth (in document) dans relative depth (as parameters for perform some transformations). Both goes 0 to n, but not in the same direction, and this can be confusing for beginners. Maybe different terms should be employed to clarify things, such as “absolute depth” and “relative depth”. Just to let you know.

Thanks for this comment @Javarome . I was pulling my hair out trying to use `split()` thinking depth was an absolute number.
