Skip to content

Conversation

nperez0111
Copy link
Contributor

@nperez0111 nperez0111 commented Apr 15, 2025

This completely overhauls selection restoration to be based on Prosemirror Bookmarks which are used to store & restore selections independent of the current document.
This is useful for y-prosemirror, since it means that we do not have to implement each selection type, yet all of them will work.

These also fallback to a TextSelection.between if a bookmark, if invalid or unimplemented, which is a good default.

Resolves:

Comment on lines +250 to +254
export const relativePositionStore = (pmbinding, pos) => {
const relPos = absolutePositionToRelativePosition(pos, pmbinding.type, pmbinding.mapping)

return (binding = pmbinding) => {
return relativePositionToAbsolutePosition(binding.doc, binding.type, relPos, binding.mapping)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't necessarily have to be exported, I thought it was just a useful abstraction to have. Happy to inline it if we don't want it

@tommoor
Copy link
Contributor

tommoor commented Jul 10, 2025

This would be great – nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants