Skip to content

Commit

Permalink
Add spellcheck option to dis/enable spellchecking
Browse files Browse the repository at this point in the history
  • Loading branch information
bytesnz authored and antonmedv committed Aug 7, 2020
1 parent 321725c commit b410124
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ Third argument to `CodeJar` is options:
- Note: use css rule `tab-size` to customize size.
- `identOn: RegExp` allows auto indent rule to be customized. Default `{$`
- Auto-tab if the text before cursor match the given regex while pressing Enter.

- `spellcheck: boolean` enables spellchecking on the editor. Default `false`


```js
let options = {
Expand Down
4 changes: 3 additions & 1 deletion codejar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type Options = {
tab: string
indentOn: RegExp
spellcheck: boolean
}

type HistoryRecord = {
Expand All @@ -20,6 +21,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
const options: Options = {
tab: "\t",
indentOn: /{$/,
spellcheck: false,
...opt
}
let listeners: [string, any][] = []
Expand All @@ -31,7 +33,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
let isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1

editor.setAttribute("contentEditable", isFirefox ? "true" : "plaintext-only")
editor.setAttribute("spellcheck", "false")
editor.setAttribute("spellcheck", options.spellcheck ? "true" : "false")
editor.style.outline = "none"
editor.style.overflowWrap = "break-word"
editor.style.overflowY = "auto"
Expand Down

0 comments on commit b410124

Please sign in to comment.