Skip to content

Conversation

@sotayamashita
Copy link
Owner

@sotayamashita sotayamashita commented Sep 2, 2025

Before merging

Wait two weeks for comments from the original PR creator, just in case

Summary

This PR adopts the upstream "ColorShift" feature from the original Highlightr-Plugin repository.

What's Changed

✨ New Feature: ColorShift Highlighter Style

Adds a new "ColorShift" highlighting option that changes the text color instead of the background. This provides an alternative highlighting style that some users may find more subtle or readable.

📝 Changes Included

  • CSS: Added ColorShift styles and reset text color for other highlighter styles
  • Core Logic: Modified inline mode to set color property and toggle highlightr-colorshift class on document body
  • Settings: Added "ColorShift" to available highlighter styles in settings
  • UI: Display "ColorShift" badge in settings documentation
  • Assets: Added screenshot demonstrating the ColorShift feature

🔧 Additional Updates

  • Updated @rollup/plugin-node-resolve to ^15 to satisfy Rollup plugin version constraints

Testing

  • ✅ Built successfully with npm run build
  • ✅ ColorShift option appears in settings
  • ✅ ColorShift style applies correctly in both preview and live preview modes
  • ✅ No regressions in existing highlighter styles (Lowlight, Floating, Rounded, Realistic)

Credits

Full credit goes to @Jayydoodle for the original implementation. This fork preserves the original authorship and includes proper attribution.

Summary by CodeRabbit

  • New Features

    • Added a new “ColorShift” highlight style, with UI toggle applied on load and during style updates.
    • Updated settings preview to include a “ColorShift” badge.
  • Style

    • Inline highlights now set both text color and background color when not using CSS classes.
    • Prevented inherited text color from affecting highlights by unsetting color on multiple styles.
    • Tweaked “Floating” gradient stops for earlier transitions.
    • Introduced “ColorShift” visuals: bold text with unset background for marked content.

Jayydoodle and others added 2 commits September 2, 2025 22:58
'ColorShift' is a neew option which just changes the overall text color

(cherry picked from commit d4f2cad)
Updated dev dependency to satisfy Rollup plugin version constraints
required by @rollup/plugin-commonjs@^28
@coderabbitai
Copy link

coderabbitai bot commented Sep 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new "colorshift" highlighter style across plugin, settings, and styles. Updates mark element generation to set both color and background when not using CSS classes. Toggles a body class for colorshift during onload and in updateStyle. Extends settings options and demos. Adjusts CSS for color inheritance and gradients.

Changes

Cohort / File(s) Summary
Plugin behavior
src/plugin/main.ts
Generates mark tags with both color and background styles when not using css-classes; introduces and enforces body class highlightr-colorshift when highlighterStyle === "colorshift" during onload and in updateStyle.
Settings data
src/settings/settingsData.ts
Adds "colorshift" to HIGHLIGHTER_STYLES.
Settings UI demo
src/settings/settingsTab.ts
Adds a “ColorShift” demo badge (inline styled span) to the style previews in the settings tab; no logic changes.
Styles
styles.css
Unsets text color on multiple highlight variants to avoid inheritance; tweaks floating gradient stops (28%→14%); adds .highlightr-colorshift rules (unset background, bold text).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant P as Plugin
  participant S as Settings
  participant D as DOM/CSS

  U->>P: Load plugin
  P->>S: Read highlighterStyle
  alt highlighterStyle == "colorshift"
    P->>D: Add body class .highlightr-colorshift
  else
    P->>D: Ensure .highlightr-colorshift not present
  end

  U->>P: Change highlighter style (settings)
  P->>S: Persist new style
  P->>D: updateStyle()
  alt style == "colorshift"
    P->>D: Add .highlightr-colorshift
  else
    P->>D: Remove .highlightr-colorshift
  end

  note over P,D: Rendering highlights
  P->>D: Insert <mark>...</mark>\n- If not css-classes: set style color + background\n- Else rely on CSS rules
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A whisker-twitch, a palette swift,
I hop through code to colorshift—
Marks now glow, both shade and light,
CSS or inline, they’re just right.
With gradients trimmed and boldness rife,
I highlight words, and spring to life! 🐇✨

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/colorshift-upstream-pr84

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6249cf and faf14ea.

📒 Files selected for processing (1)
  • styles.css (5 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
styles.css (1)

46-50: Sync demo with CSS: Floating gradient now stops at 14%.
Update the inline demo in src/settings/settingsTab.ts to 14% to match this change.

src/settings/settingsTab.ts (4)

11-15: Follow base-url import guideline.
Use base-url import instead of relative path.

-import {
-  HIGHLIGHTER_METHODS,
-  HIGHLIGHTER_STYLES,
-  CONTEXT_MENU_PALETTE,
-} from "./settingsData";
+import {
+  HIGHLIGHTER_METHODS,
+  HIGHLIGHTER_STYLES,
+  CONTEXT_MENU_PALETTE,
+} from "src/settings/settingsData";

70-75: Fix user-facing typo (“overriden” → “overridden”).

-`Depending on your design aesthetic, you may want to customize the style of your highlights. Choose from an assortment of different highlighter styles by using the dropdown. Depending on your theme, this plugin's CSS may be overriden.`
+`Depending on your design aesthetic, you may want to customize the style of your highlights. Choose from an assortment of different highlighter styles by using the dropdown. Depending on your theme, this plugin's CSS may be overridden.`

93-98: Sync Floating demo with CSS (28% → 14%).

-      <span style="background:#93C0FFCC;--floating-background: var(--background-primary);border-radius: 0;padding-bottom: 5px;background-image: linear-gradient(360deg,rgba(255, 255, 255, 0) 28%,var(--floating-background) 28%) !important;">Floating</span> 
+      <span style="background:#93C0FFCC;--floating-background: var(--background-primary);border-radius: 0;padding-bottom: 5px;background-image: linear-gradient(360deg,rgba(255, 255, 255, 0) 14%,var(--floating-background) 14%) !important;">Floating</span> 

229-252: Avoid ‘any’: type the click event.
Use MouseEvent to satisfy “prefer explicit types”.

-          .onClick(async (buttonEl: any) => {
+          .onClick(async (evt: MouseEvent) => {
             let color = colorInput.inputEl.value.replace(" ", "-");
             let value = valueInput.inputEl.value;
 
             if (color && value) {
               if (!this.plugin.settings.highlighterOrder.includes(color)) {
                 this.plugin.settings.highlighterOrder.push(color);
                 this.plugin.settings.highlighters[color] = value;
                 setTimeout(() => {
                   dispatchEvent(new Event("Highlightr-NewCommand"));
                 }, 100);
                 await this.plugin.saveSettings();
                 this.display();
               } else {
-                buttonEl.stopImmediatePropagation();
+                evt.stopImmediatePropagation();
                 new Notice("This color already exists");
               }
             }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c2f2a34 and e6249cf.

⛔ Files ignored due to path filters (2)
  • assets/colorshift-update.png is excluded by !**/*.png
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/plugin/main.ts (2 hunks)
  • src/settings/settingsData.ts (1 hunks)
  • src/settings/settingsTab.ts (1 hunks)
  • styles.css (5 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
{manifest.json,package.json}

📄 CodeRabbit inference engine (AGENTS.md)

When bumping versions, keep manifest.json and package.json versions in sync

Files:

  • package.json
src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.ts: Prefer explicit types over using any
Code formatting: 2-space indentation, use semicolons, use double quotes, avoid trailing commas
Use base-url imports from src/... instead of relative paths

Files:

  • src/settings/settingsTab.ts
  • src/settings/settingsData.ts
  • src/plugin/main.ts
src/{ui,settings,utils,icons}/**

📄 CodeRabbit inference engine (AGENTS.md)

Place UI, settings, helper utilities, and icons in their respective directories: src/ui/, src/settings/, src/utils/, src/icons/

Files:

  • src/settings/settingsTab.ts
  • src/settings/settingsData.ts
{main.js,styles.css}

📄 CodeRabbit inference engine (AGENTS.md)

Build outputs must be main.js and styles.css at the repository root

Files:

  • styles.css
src/plugin/main.ts

📄 CodeRabbit inference engine (AGENTS.md)

Entry point is src/plugin/main.ts and should contain plugin startup/wiring

Files:

  • src/plugin/main.ts
🔇 Additional comments (5)
styles.css (3)

13-13: LGTM: prevent unintended text color overrides.
Using color: unset !important on lowlight marks restores theme/inherited color.


81-81: LGTM: rounded text color inheritance.
Matches intent to avoid forcing foreground color.


110-111: LGTM: realistic text color inheritance.
Consistent with other styles.

src/settings/settingsData.ts (1)

7-8: LGTM: added “colorshift” style key.
Data-only change; no API impact.

src/plugin/main.ts (1)

200-203: LGTM: colorshift body class toggle.
Ensures runtime switch via updateStyle; pair with per-color text rules for “css-classes” method (see styles/createStyles note).

Please verify colorshift behavior in both methods:

  • inline-styles + colorshift: text colored, background removed.
  • css-classes + colorshift: text colored via class; background removed.

@sotayamashita sotayamashita merged commit b06ccb4 into main Sep 14, 2025
1 check was pending
@sotayamashita sotayamashita deleted the feature/colorshift-upstream-pr84 branch September 14, 2025 14:26
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.

3 participants