From 52bb83e878bf267822a886a2b846029b3271a81a Mon Sep 17 00:00:00 2001 From: lzinga Date: Wed, 3 Dec 2025 10:02:35 -0800 Subject: [PATCH] feat(plugins): add InlineCodeNoSpellcheck plugin to disable spellcheck for inline code --- packages/ckeditor5/src/plugins.ts | 4 +++- .../src/plugins/inline_code_no_spellcheck.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 packages/ckeditor5/src/plugins/inline_code_no_spellcheck.ts diff --git a/packages/ckeditor5/src/plugins.ts b/packages/ckeditor5/src/plugins.ts index 81a8a7fe1..8f4e723f8 100644 --- a/packages/ckeditor5/src/plugins.ts +++ b/packages/ckeditor5/src/plugins.ts @@ -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, ]; /** diff --git a/packages/ckeditor5/src/plugins/inline_code_no_spellcheck.ts b/packages/ckeditor5/src/plugins/inline_code_no_spellcheck.ts new file mode 100644 index 000000000..2411691e4 --- /dev/null +++ b/packages/ckeditor5/src/plugins/inline_code_no_spellcheck.ts @@ -0,0 +1,19 @@ +import { Plugin } from "ckeditor5"; + +export default class InlineCodeNoSpellcheck extends Plugin { + + init() { + const editor = this.editor; + editor.conversion.for('downcast').attributeToElement({ + model: 'code', + view: (modelAttributeValue, conversionApi) => { + const { writer } = conversionApi; + return writer.createAttributeElement('code', { + spellcheck: 'false' + }, { priority: 5 }); + }, + converterPriority: 'high' + }); + } + +}