leafwiki
leafwiki copied to clipboard
Enable the browser's native spellcheck in the editor
From discussion #1726: the Markdown editor shows no spellcheck in any browser (Firefox, Chrome, with and without spellcheck extensions).
Cause
The editor is CodeMirror 6 (MarkdownCodeEditor.tsx). CodeMirror sets spellcheck="false" on its content element by default, so the browser's built-in spellcheck never runs.
Proposal
As a first step, turn the browser's native spellcheck on via EditorView.contentAttributes.of({ spellcheck: 'true', autocorrect: 'on', autocapitalize: 'on' }). No custom dictionary or spellcheck engine.
Things to check:
- The spellcheck language follows the page's
langattribute / browser settings; check that it matches the UI locale or the user's browser language sensibly. - Code blocks, inline code, URLs and frontmatter will get flagged. Decide whether that's acceptable for a first version or whether those ranges should get
spellcheck="false"via a decoration. - Possibly a user setting to turn it off.
- Behaviour on mobile (autocorrect/autocapitalize can be annoying while typing Markdown syntax).