Skip to content

Build your personal knowledge base with Trilium Notes

fix(ckeditor5): internal link enabled in code block (closes #1712)

Elian Doran1becc1835435
diff --git a/packages/ckeditor5/src/plugins/internallink.ts b/packages/ckeditor5/src/plugins/internallink.ts
index f6045dbc9f..b80591fe56 100644
--- a/packages/ckeditor5/src/plugins/internallink.ts
+++ b/packages/ckeditor5/src/plugins/internallink.ts
@@ -39,7 +39,11 @@ export default class InternalLinkPlugin extends Plugin {
class InsertInternalLinkCommand extends Command {
refresh() {
- this.isEnabled = !this.editor.isReadOnly;
+ const selection = this.editor.model.document.selection;
+ const position = selection.getFirstPosition();
+ const isInCodeBlock = position?.findAncestor("codeBlock");
+
+ this.isEnabled = !this.editor.isReadOnly && !isInCodeBlock;
}
execute() {