Skip to content

Commit

Permalink
fix(LinkBubble): Allow to close link bubble with Escape
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Jan 26, 2024
1 parent dde2f18 commit 025a719
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/extensions/LinkBubblePluginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class LinkBubblePluginView {
this.hide()
}

keydownHandler = (event) => {
if (event.key === 'Escape') {
event.preventDefault()
this.hide()
}
}

createTooltip() {
const { element: editorElement } = this.editor.options
const editorIsAttached = !!editorElement.parentElement
Expand Down Expand Up @@ -192,9 +199,11 @@ class LinkBubblePluginView {

show() {
this.tippy?.show()
this.view.dom.addEventListener('keydown', this.keydownHandler)
}

hide() {
this.view.dom.removeEventListener('keydown', this.keydownHandler)
this.tippy?.hide()
}

Expand Down

0 comments on commit 025a719

Please sign in to comment.