mirror of
https://github.com/zadam/trilium.git
synced 2026-02-07 22:34:24 +01:00
24 lines
720 B
TypeScript
24 lines
720 B
TypeScript
import { Plugin } from "ckeditor5";
|
|
|
|
/**
|
|
* Disables the mention feature inside code blocks.
|
|
* This prevents the autocomplete popup from appearing when typing `@` or `/` within code blocks.
|
|
*/
|
|
export default class DisableMentionInCodeBlock extends Plugin {
|
|
public static get pluginName() {
|
|
return "DisableMentionInCodeBlock" as const;
|
|
}
|
|
|
|
init() {
|
|
const editor = this.editor;
|
|
const schema = editor.model.schema;
|
|
|
|
// Disallow mention attribute inside code blocks
|
|
schema.addAttributeCheck((context, attributeName) => {
|
|
if (attributeName === 'mention' && context.endsWith('codeBlock $text')) {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
}
|