-
Notifications
You must be signed in to change notification settings - Fork 366
Open
Description
Hi, apologies if this is a basic question. I've been banging my head against the wall on this and feel like I must be missing something straightforward.
I'm attempting to use Rangy and the Highlighter + TextRange modules in a React project that lets users serialize highlights and then later de-serialize them. It's the de-serialization part that is causing trouble.
Approaches for deserialization:
- Manipulate DOM directly: This is an anti-pattern in React, and I eventually came across some issues where React's virtualDOM and the browser's actual DOM got out of sync, leading to some React-specific bugs.
- Manipulate DOM object and pass as prop: The alternative is to have Rangy add the
Highlightsto a DOM object that's held as state and then pass it as an HTML string and via something likedangerouslySetInnerHTML. However, while this works with many of Rangy's functions, theTextRangelibrary seems to require working with a DOM that's actually rendered in the window. - Don't use
TextRange: I considered usingtextContentinstead, but one feature I want is the ability to start serialization within a specified node. This is a parameter offered in many ofTextRange's functions, but not available inHighlighter.serialize().
What am I missing? Is my understanding of the library incorrect? Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels