# When the mouse is released, I want to know how to obtain the node where the selection is currently located?

**URL:** <https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838>\
**Category:** Uncategorized\
**Created:** [June 16, 2021, 11:15pm UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838 "2021-06-16T23:15:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 16, 2021, 11:15pm UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/1 "2021-06-16T23:15:47Z")

</div>

![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/b/b7fe213b3ae73af036160499934fd08d712a6dcb.png)

I mean, I only selected a small part of the text, but I want to get the full range of the mark

---

<div class="post-metadata">

**Author:** ![jessejorgenson](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/jessejorgenson/32/958_2.png) [@jessejorgenson](https://discuss.prosemirror.net/u/jessejorgenson)\
**Post date:** [June 17, 2021, 12:38am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/2 "2021-06-17T00:38:41Z")

</div>

Are you asking where to find the selection or the mouse position?

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 17, 2021, 12:52am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/3 "2021-06-17T00:52:18Z")

</div>

no，like this:

 ![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/6/6771448a9f853e6235a1c037db7e868c392426e5.png)

When I click on a small part of the annotated text, then I want to delete the comment.

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 17, 2021, 12:58am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/4 "2021-06-17T00:58:51Z")

</div>

![nka0r-0bctk](https://discuss.prosemirror.net/uploads/secondsite/original/2X/b/bfb750fff05a055223a83f6ac60c9b9b2d62bb65.gif)

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 17, 2021, 1:01am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/5 "2021-06-17T01:01:51Z")

</div>

```javascript
handleDOMEvents: {

    mouseup: (view, event) => {

        let {state} = view;
        let {tr} = state;

        let {selection} = state;

        if(event.target.tagName == 'SPAN' && Object.values(event.target.classList).includes('comment')){

            let resolve = tr.doc.resolve( selection.from );

          //. I want to get the position of this mark

            console.log('resolve', resolve);

            let cid = event.target.getAttribute('cid');
            options.event.show_comment_dialog({cid, selection});

            let new_selection = TextSelection.create(view.state.doc, 0, 0);
			tr.setSelection(new_selection);
			view.dispatch(tr);

        }else{
            return;
        }

    },

},

```

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 17, 2021, 1:05am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/6 "2021-06-17T01:05:43Z")

</div>

help me @marijn

---

<div class="post-metadata">

**Author:** ![philippkuehn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/philippkuehn/32/1820_2.png) [@philippkuehn](https://discuss.prosemirror.net/u/philippkuehn)\
**Post date:** [June 17, 2021, 7:19am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/7 "2021-06-17T07:19:54Z")

</div>

As I can see, you are using tiptap here. There is a [extendMarkRange](https://www.tiptap.dev/api/commands/extend-mark-range) command for exactly doing this. The [getMarkRange](https://github.com/ueberdosis/tiptap/blob/f130f004fb29ea75361871c8c80e950431d290fb/packages/core/src/helpers/getMarkRange.ts#L23) helper method is doing most of its logic.

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 17, 2021, 10:11am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/8 "2021-06-17T10:11:17Z")

</div>

Thank you. I don’t use tiptap, I’m really studying him at the moment, but this code is very valuable.

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [June 17, 2021, 10:55am UTC](https://discuss.prosemirror.net/t/when-the-mouse-is-released-i-want-to-know-how-to-obtain-the-node-where-the-selection-is-currently-located/3838/9 "2021-06-17T10:55:49Z")

</div>

Thank you. Because of your help, the problem has been solved. Thank you
