Skip to content

Commit

Permalink
remove new keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed May 19, 2020
1 parent df33039 commit 7111766
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Create element and init:
```html
<div class="editor"></div>
<script>
let jar = new CodeJar(document.querySelector('.editor'), Prism.highlightElement)
let jar = CodeJar(document.querySelector('.editor'), Prism.highlightElement)
</script>
```

Expand All @@ -47,7 +47,7 @@ const highlight = (editor: HTMLElement) => {
editor.innerHTML = code
}

let jar = new CodeJar(editor, highlight)
let jar = CodeJar(editor, highlight)
```

Third argument to `CodeJar` is options:
Expand All @@ -57,7 +57,7 @@ let options = {
tab: ' '.repeat(4), // default is \t
}

let jar = new CodeJar(editor, highlight, options)
let jar = CodeJar(editor, highlight, options)
```

Some styles may be applied to our editor to make it better looking:
Expand Down
2 changes: 2 additions & 0 deletions codejar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Position = {
dir?: "->" | "<-"
}

export type CodeJar = ReturnType<typeof CodeJar>

export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void, opt: Partial<Options> = {}) {
const options = {
tab: "\t",
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
hljs.highlightBlock(editor)
}

const jar = new CodeJar(editor, highlight)
const jar = CodeJar(editor, highlight)

jar.updateCode(localStorage.getItem('code'))
jar.onUpdate(code => {
Expand Down

0 comments on commit 7111766

Please sign in to comment.