1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: Rich text editor: Disable spellcheck in inline code blocks (#8532)

This commit is contained in:
Henry Heino
2023-07-23 07:59:51 -07:00
committed by GitHub
parent e47985c101
commit 93c5f6c9d3

View File

@ -599,6 +599,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
joplinInsert: { inline: 'ins', remove: 'all' },
joplinSub: { inline: 'sub', remove: 'all' },
joplinSup: { inline: 'sup', remove: 'all' },
code: { inline: 'code', remove: 'all', attributes: { spellcheck: false } },
},
setup: (editor: Editor) => {
editor.addCommand('joplinAttach', () => {
@ -697,7 +698,17 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
setEditorReady(true);
});
const preprocessContent = () => {
// Disable spellcheck for all inline code blocks.
const codeElements = editor.dom.doc.querySelectorAll('code.inline-code');
for (const code of codeElements) {
code.setAttribute('spellcheck', 'false');
}
};
editor.on('SetContent', () => {
preprocessContent();
props_onMessage.current({ channel: 'noteRenderComplete' });
});
},