editable.js icon indicating copy to clipboard operation
editable.js copied to clipboard

Remove zero width space when getting text range for comment highlights

Open ajwild opened this issue 10 months ago • 0 comments

Relations:

  • Issue: Fixes https://github.com/livingdocsIO/livingdocs-bugs/issues/5048
  • Related PRs:
    • https://github.com/livingdocsIO/livingdocs-editor/pull/9743
    • https://github.com/livingdocsIO/livingdocs-framework/pull/1262

Motivation

When creating comments in Livingdocs it uses the selected text to create a highlight. If the text selection contains a zero width non-breaking space, which is removed when the component is blurred, then the highlight never computes the correct start and end offset for the range because the text string no longer matches.

Changelog

  • 🍬 Validate (optional) text when highlighting range
  • 🐞 Do not let highlight exceed text range
  • 🐞 Remove zero width space to make selection more accurate, because it will be removed on component blur via extractContent

ajwild avatar Apr 03 '25 20:04 ajwild