Skip to content

Commit

Permalink
fix toString bug
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Apr 8, 2020
1 parent a8171d7 commit ff5ca0f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions codejar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
return [text.substring(i, j) || "", i, j]
}

function toString() {
return editor.textContent || ""
}

return {
updateOptions(options: Partial<Options>) {
options = {...options, ...options}
Expand All @@ -412,12 +416,10 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
editor.textContent = code
highlight(editor)
},
onUpdate(callback: (code: string) => void) {
callback = callback
},
toString() {
return editor.textContent || ""
onUpdate(cb: (code: string) => void) {
callback = cb
},
toString,
destroy() {
for (let [type, fn] of listeners) {
editor.removeEventListener(type, fn)
Expand Down

0 comments on commit ff5ca0f

Please sign in to comment.