Skip to content

Fix highlighting issues in core, react and angular packages - #27

Merged
saurabhiam merged 6 commits into
mainfrom
fix/content-highlight-fix
Mar 10, 2026
Merged

Fix highlighting issues in core, react and angular packages#27
saurabhiam merged 6 commits into
mainfrom
fix/content-highlight-fix

Conversation

@saurabhiam

Copy link
Copy Markdown
Owner
  • @markitjs/core: Fix highlight-api overriding in case of multiple instance causing highlights to render only in last instance.
  • @markitjs/react: Fix garbled value in case of renderer: dom.
    • Added lifecycle optimisations.
    • Added optimisation for dynamic content with contentKey which are passed like deps in useEffect.
  • @markitjs/angular: Fix garbled value in case of renderer: dom.
    • Added lifecycle optimisations.
    • Added optimisation for dynamic content with markitContentKey
  • @markitjs/doc: Updated docs, added search, added mermaid chart support.
  • Bug fixes and Optimisations

…ates

- Added support for `markitContentKey` input, allowing the directive to unmark and re-apply highlights when the content key changes.
- Implemented logic in `ngOnChanges` and `ngAfterViewChecked` to handle updates efficiently, preventing garbled text during content changes.
- Introduced a utility function to compare previous and current content key values, supporting both single values and arrays.
- Updated tests to cover new functionality, ensuring correct behavior when content keys change.
- Added functionality to share highlights across multiple instances using the CSS Highlight API, preventing overwrites.
- Updated `HighlightApiRenderer` to manage highlights by name, allowing both default and custom highlight names.
- Enhanced tests to verify correct behavior when multiple instances are created with the same highlight name.
- Introduced `contentKey` prop in React components to handle dynamic content updates without garbled text.
- Updated `useHighlight` hook to reapply highlights when `contentKey` changes, ensuring accurate rendering.
…ntent handling

- Introduced a new script to report bundle sizes for core, React, and Angular packages, aiding in performance monitoring.
- Updated documentation across various guides to clarify the use of `contentKey` for dynamic content in both React and Angular, ensuring highlights re-apply correctly.
- Added a new section on framework lifecycles to explain how highlights are managed over time in React and Angular.
- Enhanced README.md and other documentation files to improve clarity and usability for developers.
…pt configuration

- Added `mermaid` and `vitepress-plugin-mermaid` as dev dependencies to enable diagram rendering in documentation.
- Updated VitePress configuration to utilize the `withMermaid` function for enhanced diagram support.
- Created a new TypeScript configuration file for the documentation to streamline type checking.
- Refactored lifecycle diagrams in the documentation to use sequence diagrams for improved clarity.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Package Raw Gzipped Limit
@markitjs/core 27.52 KB 6.69 KB 15 KB
@markitjs/react 2.42 KB 850 B 3 KB
@markitjs/angular 9.26 KB 2.71 KB 5 KB

✅ All packages within size limits

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the MarkIt highlighting library by resolving critical highlighting issues across its core, React, and Angular packages. The primary focus is on improving how the library handles dynamic content and multiple instances, preventing garbled text and ensuring consistent highlight rendering. Additionally, the documentation has been substantially updated to reflect these changes and provide better guidance to users, including new search capabilities and support for Mermaid diagrams.

Highlights

  • @markitjs/core: Fixed highlight-api overriding in cases of multiple instances, ensuring highlights render correctly across all instances.
  • @markitjs/react: Addressed garbled values when using renderer: dom and introduced lifecycle optimizations, including an optimization for dynamic content using contentKey.
  • @markitjs/angular: Resolved garbled values when using renderer: dom and implemented lifecycle optimizations, including an optimization for dynamic content using markitContentKey.
  • @markitjs/doc: Updated documentation, integrated search functionality, and added support for Mermaid charts.
  • General: Included various bug fixes and performance optimizations across the project.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • @markitjs/angular
    • Fixed garbled value in case of renderer: dom.
    • Added lifecycle optimisations.
    • Added optimisation for dynamic content with markitContentKey.
  • @markitjs/core
    • Fixed highlight-api overriding in case of multiple instance causing highlights to render only in last instance.
  • @markitjs/doc
    • Updated docs, added search, added mermaid chart support.
  • @markitjs/react
    • Fixed garbled value in case of renderer: dom.
    • Added lifecycle optimisations.
    • Added optimisation for dynamic content with contentKey which are passed like deps in useEffect.
  • General
    • Bug fixes and Optimisations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces significant improvements and bug fixes across the core, React, and Angular packages. The fix for multiple highlight-api instances overriding each other is a crucial correction. The introduction of contentKey in React and markitContentKey in Angular provides a robust solution for handling dynamic content, which is a common use case in modern frameworks. The accompanying documentation updates, including the new 'Framework Lifecycles' page with Mermaid diagrams, are excellent and greatly improve clarity for developers. I've found one potential issue in the Angular directive's lifecycle logic, which I've detailed in a specific comment.

Comment thread packages/angular/src/lib/highlight.directive.ts
@saurabhiam
saurabhiam merged commit 7dcd94b into main Mar 10, 2026
11 checks passed
@saurabhiam
saurabhiam deleted the fix/content-highlight-fix branch March 10, 2026 20:53
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