Skip to content

fix(editor): partially disable at mention in code block#8564

Open
chloelee767 wants to merge 6 commits intoTriliumNext:mainfrom
chloelee767:fix/at-symbol-in-code-block
Open

fix(editor): partially disable at mention in code block#8564
chloelee767 wants to merge 6 commits intoTriliumNext:mainfrom
chloelee767:fix/at-symbol-in-code-block

Conversation

@chloelee767
Copy link
Contributor

Hello, this is a PR to disable the at-symbol to insert note links and slash commands inside code blocks, by disabling the mention plugin in code blocks. Note that this fix only affects code blocks, not inline code. Ideally I would like to disable the plugin for inline code too, but I haven't figured how to do that.

Known issues:

There still seems to be some kind of race condition that causes the at-symbol or slash commands to trigger inside the code block sometimes, when moving quickly from a text region to a code block using the mouse or arrow keys – see the video below.

Screen.Recording.2026-01-31.at.11.53.21.PM.mov

Scenarios tested:

  • at mention and slash commands still work in regular text
  • at mention and slash commands are no longer triggered in code blocks
  • ~ and # inside the note attributes popup section still works (since my understanding is they are also implemented using the mention plugin)

I frankly don't know much about ckeditor, so I'm too not sure if this approach is a good idea or have any unintended side effects (I also notice there's already an upstream issue ckeditor/ckeditor5#19146 , so I'm not sure if the preference is to wait for the issue to be fixed upstream instead), but I personally haven't noticed any issues in the couple of weeks I've been test driving this.

Partially solves #8322

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 31, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chloelee767, 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 addresses an undesirable behavior in CKEditor 5 where the mention plugin, used for note links and slash commands, would incorrectly activate within code blocks. By introducing a dedicated plugin, DisableMentionInCodeBlock, the change ensures that the mention functionality is selectively disabled only within code block regions, thereby improving the editing experience and preventing unintended autocomplete popups. The solution maintains full mention functionality in regular text areas and includes new tests to validate its effectiveness.

Highlights

  • Disable Mentions in Code Blocks: Implemented a new CKEditor 5 plugin, DisableMentionInCodeBlock, to prevent the mention feature (at-symbols and slash commands) from triggering inside code blocks.
  • Schema Configuration: Configured the CKEditor 5 schema to disallow the 'mention' attribute within codeBlock $text contexts, ensuring mentions only work in regular text.
  • New Testing Framework: Introduced Vitest for testing, adding new test files and a configuration to verify the correct behavior of the new plugin.
  • Dependency and Script Updates: Updated package.json with new development dependencies and test scripts to support the Vitest testing framework.

🧠 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.

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.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

Thank you for this contribution. This PR introduces a clever solution to disable mentions within code blocks by creating a custom CKEditor plugin that modifies the schema. The approach is sound and the inclusion of unit tests with the new Vitest setup is excellent, ensuring the change is robust.

I've found one critical issue in package.json with a duplicate dependency that needs to be addressed. Otherwise, the changes look great. Well done!

@chloelee767 chloelee767 changed the title fix: partially disable at mention in code block fix(editor): partially disable at mention in code block Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflicts size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants