Skip to content

feat: add multi-line highlights and comments support#16

Open
mattfinlayson wants to merge 1 commit into
jancbeck:masterfrom
mattfinlayson:001-multiline-highlights-comments
Open

feat: add multi-line highlights and comments support#16
mattfinlayson wants to merge 1 commit into
jancbeck:masterfrom
mattfinlayson:001-multiline-highlights-comments

Conversation

@mattfinlayson

Copy link
Copy Markdown

Summary

Extend the annotation plugin to support highlighting text that spans multiple lines and attaching comments to those highlights.

Previously, the plugin only supported single-line ==highlights==. This PR adds multi-line %%highlight-start:ID%% / %%highlight-end:ID%% markers that work across paragraphs.

Changes

Multi-line Highlighting

  • Auto-detection: createHighlightCommand now detects whether the selection spans multiple lines. Single-line uses ==text==, multi-line uses %%highlight-start:ID%%..%%highlight-end:ID%%
  • Live preview rendering: Extended findHighlightsAndComments in extension.tsx to detect and render both marker formats
  • Reading mode rendering: Updated postprocessor.tsx to parse multi-line highlights alongside single-line ones
  • Styles: Added .multiline CSS class for block-level highlight display

Comments

  • Comments on multi-line highlights use inline <!--comment--> after the end marker (consistent with existing single-line pattern)
  • Existing CommentPopover UI works for both highlight types without changes

Editing & Management

  • "Delete annotation at cursor" command: Removes markers and inline comments for both single-line and multi-line highlights
  • "Clear all annotations" command: Strips all ==, %%, and <!----> markers from the document
  • Comment editing via popover works for multi-line highlights via handleCommentUpdate

Version

  • Bumped to 1.1.0

Test Plan

  1. Open a note with multiple paragraphs
  2. Select text across paragraph breaks → trigger "Highlight selection" → verify %%highlight-start:ID%% markers appear
  3. Click the highlight in live preview → add a comment → verify <!--comment--> appears after end marker
  4. Place cursor inside a highlight → "Delete annotation at cursor" → verify markers and comment are removed
  5. "Clear all annotations" → verify all highlights and comments are stripped
  6. Single-line ==highlights== still work as before

Extend the annotation plugin to support highlighting text that spans
multiple lines using %%highlight-start:ID%% / %%highlight-end:ID%% markers.

- Auto-detect single-line vs multi-line selection: single-line uses
  existing ==text== syntax, multi-line uses new %% marker syntax
- Comments on multi-line highlights stored as inline <!--comment-->
  after the end marker, consistent with single-line highlight pattern
- Add 'Delete annotation at cursor' command for both single and
  multi-line highlights
- Add 'Clear all annotations' command to strip all markers and
  comments from the document
- Update reading mode post-processor to render multi-line highlights
- Add .multiline CSS class for block-level highlight styling
- Bump version to 1.1.0
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.

1 participant