How to find node by position (not selection) in update handler

I added plugin to process update (view, prevState) . I need to define which node owns the particular view.state.doc.textContent position. Just for the case - it is not selected position. Thank you in advance for your help!

I tried this, but return undefined:

findParentNodeClosestToPos(resolved, (node) => {
                          
                          return true
                        }))

Have you tried view.state.doc.nodeAt(pos) or view.state.doc.resolve(pos).parent?

What do you mean by this? doc.textcontent does not return the position. Can you add some more details, in particular what you are trying to achieve.

Good question! I need to iterate through all text nodes and specific regex their to replace the corresponding match with special custom node (which I created). I guess searching in textContent is really mistake.

I guess it will not work, because I cannot find the correct position.

I need to iterate through all text nodes and specific regex their to replace the corresponding match with special custom node

I believe you will have to do a two-step parse here:

  1. find the absolute position of the node whose textContent you want to parse
  2. run the regex on the textContent, and find the matching start and end positions of the regex relative to the parent node
  3. add that relative offset to the absolute position of the parent node

An open-source example that I can think does that is prosemirror-suggestions