Skip to content

Commit

Permalink
Add addClosing option
Browse files Browse the repository at this point in the history
  • Loading branch information
bytesnz authored and antonmedv committed Aug 7, 2020
1 parent b410124 commit 0155b20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Third argument to `CodeJar` is options:
- `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`
- `addClosing: boolean` automatically adds closing brackets, quotes. Default `true`


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

type HistoryRecord = {
Expand All @@ -22,6 +23,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
tab: "\t",
indentOn: /{$/,
spellcheck: false,
addClosing: true
...opt
}
let listeners: [string, any][] = []
Expand Down Expand Up @@ -74,7 +76,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
prev = toString()
handleNewLine(event)
handleTabCharacters(event)
handleSelfClosingCharacters(event)
if (options.addClosing) handleSelfClosingCharacters(event)
handleUndoRedo(event)
if (shouldRecord(event) && !recording) {
recordHistory()
Expand Down

0 comments on commit 0155b20

Please sign in to comment.