mirror of
https://github.com/zadam/trilium.git
synced 2026-02-28 01:23:37 +01:00
disable @ to insert links in code blocks
This commit is contained in:
parent
e070fc2f52
commit
c9ea0f9f7f
@ -31,6 +31,7 @@ import CodeBlockLanguageDropdown from "./plugins/code_block_language_dropdown.js
|
|||||||
import MoveBlockUpDownPlugin from "./plugins/move_block_updown.js";
|
import MoveBlockUpDownPlugin from "./plugins/move_block_updown.js";
|
||||||
import ScrollOnUndoRedoPlugin from "./plugins/scroll_on_undo_redo.js"
|
import ScrollOnUndoRedoPlugin from "./plugins/scroll_on_undo_redo.js"
|
||||||
import InlineCodeNoSpellcheck from "./plugins/inline_code_no_spellcheck.js";
|
import InlineCodeNoSpellcheck from "./plugins/inline_code_no_spellcheck.js";
|
||||||
|
import DisableMentionInCodeBlock from "./plugins/disable_mention_in_codeblock.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugins that are specific to Trilium and not part of the CKEditor 5 core, included in both text editors but not in the attribute editor.
|
* Plugins that are specific to Trilium and not part of the CKEditor 5 core, included in both text editors but not in the attribute editor.
|
||||||
@ -53,6 +54,7 @@ const TRILIUM_PLUGINS: typeof Plugin[] = [
|
|||||||
MoveBlockUpDownPlugin,
|
MoveBlockUpDownPlugin,
|
||||||
ScrollOnUndoRedoPlugin,
|
ScrollOnUndoRedoPlugin,
|
||||||
InlineCodeNoSpellcheck,
|
InlineCodeNoSpellcheck,
|
||||||
|
DisableMentionInCodeBlock,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
import { Plugin } from "ckeditor5";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the mention feature (triggered by `@`) inside code blocks.
|
||||||
|
* This prevents the autocomplete popup from appearing when typing `@` 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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user