Skip to content

Implement SPI to support search highlight#89

Merged
cyanzhong merged 1 commit intomainfrom
develop
Apr 3, 2026
Merged

Implement SPI to support search highlight#89
cyanzhong merged 1 commit intomainfrom
develop

Conversation

@cyanzhong
Copy link
Copy Markdown
Contributor

Closes #87. When review, focus on logic correctness only, majority of the code is AI-generated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements a preview-side Search SPI so the editor can drive search highlighting and match navigation inside the rendered Markdown preview (closes #87).

Changes:

  • Add src/search.ts implementing mark/unmark, match indexing, and preview-side counter info.
  • Expose the Search SPI on window.__markeditPreviewSPI__ for CoreEditor to call.
  • Add unit tests for the preview search behavior using happy-dom, and add mark.js as a dependency.

Reviewed changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/search.ts New search/highlighting engine for the preview using mark.js, plus counter/index helpers.
main.ts Exposes performSearch, setSearchMatchIndex, clearSearch, searchCounterInfo over a global SPI.
types/global.d.ts Types the global SPI on window for TS consumers.
types/markjs.d.ts Adds minimal mark.js type declarations.
tests/search.test.ts Adds tests covering preview-mode counter behavior, search, index wrapping, and clearing.
package.json Adds runtime dependency mark.js and dev dependency happy-dom for tests.
tsconfig.json Suppresses TS deprecation warnings via ignoreDeprecations.
yarn.lock Lockfile updates for newly added dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cyanzhong cyanzhong merged commit 1c8b76d into main Apr 3, 2026
1 check passed
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.

[Feature Request] Allow Preview to show what's searched

2 participants