Disable spell-check on code-snippets (#7929)

This commit is contained in:
Elian Doran 2025-12-04 07:47:02 +00:00 committed by GitHub
commit 7cc20600e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import CodeBlockToolbar from "./plugins/code_block_toolbar.js";
import CodeBlockLanguageDropdown from "./plugins/code_block_language_dropdown.js";
import MoveBlockUpDownPlugin from "./plugins/move_block_updown.js";
import ScrollOnUndoRedoPlugin from "./plugins/scroll_on_undo_redo.js"
import InlineCodeNoSpellcheck from "./plugins/inline_code_no_spellcheck.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.
@ -49,7 +50,8 @@ const TRILIUM_PLUGINS: typeof Plugin[] = [
CodeBlockLanguageDropdown,
CodeBlockToolbar,
MoveBlockUpDownPlugin,
ScrollOnUndoRedoPlugin
ScrollOnUndoRedoPlugin,
InlineCodeNoSpellcheck,
];
/**

View File

@ -0,0 +1,18 @@
import { Plugin } from "ckeditor5";
export default class InlineCodeNoSpellcheck extends Plugin {
init() {
this.editor.conversion.for('downcast').attributeToElement({
model: 'code',
view: (modelAttributeValue, conversionApi) => {
const { writer } = conversionApi;
return writer.createAttributeElement('code', {
spellcheck: 'false'
});
},
converterPriority: 'high'
});
}
}