Skip to content

Commit

Permalink
Fix pos restore for cut event
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Jul 26, 2023
1 parent 49745eb commit f730c38
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions codejar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,13 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P
const pos = save()
const selection = getSelection()
const originalEvent = (event as any).originalEvent ?? event
originalEvent.clipboardData.setData("text/plain", selection.toString())
originalEvent.clipboardData.setData('text/plain', selection.toString())
document.execCommand('delete')
highlight(editor)
restore({
start: pos.start,
end: pos.start,
dir: '->',
start: Math.min(pos.start, pos.end),
end: Math.min(pos.start, pos.end),
dir: '<-',
})
preventDefault(event)
}
Expand Down

0 comments on commit f730c38

Please sign in to comment.