question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProseMirror/CodeMirror offsets

See original GitHub issue

How does the offset on a match relate to its position in a document?

Is it possible to get the character index of the match within an entire document?

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
spencermountaincommented, Nov 13, 2020

beautiful. Yeah, you can use nlp.tokenize() to fast-parse and cache the unchanged sentences. That’s what I would do. cheers

1reaction
douglancecommented, Nov 13, 2020

@spencermountain Thanks for pinging me to circle back here! 😄

I was able to use doc.match() to find parts of speech and decorate them with ProseMirror by getting offsets from the .json() call. It was actually pretty smooth sailing once I figured out how the offsets and positions were calculated.

I’m still working through how to optimize my system because I want it to run on each keystroke and for the moment it’s not scaling well on larger text samples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embedded code editor - ProseMirror
When adding steps to a transaction for content changes, the offset is adjusted for the changes in length caused by the change, so...
Read more >
CRDTs & Positions in CodeMirror 6
Your blog post describes perfectly the advantages of using a CRDT for position mapping. As I described in the ProseMirror forum, the current ......
Read more >
ProseMirror Plugin for CodeBlock Decorations · GitHub
Global set of CodeMirror languages to dynamically import. */. const codeMirrorImports = new Set(); ... Calculate token offsets and apply decorations.
Read more >
How to use the codemirror.Pass function in codemirror - Snyk
To help you get started, we've selected a few codemirror examples, based on popular ways it is used in public projects. ; ProseMirror...
Read more >
Comparison with Other Rich Text Editors - Quill.js
ProseMirror is relatively new but has already captured signficant attention, being built by the same author of CodeMirror.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found