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

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

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

no,like this:

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

nka0r-0bctk

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;
        }

    },

},

help me @marijn

As I can see, you are using tiptap here. There is a extendMarkRange command for exactly doing this. The getMarkRange helper method is doing most of its logic.

1 Like

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

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