Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Mar 28, 2024
1 parent 9119987 commit deee346
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import ReactDOM from 'react-dom/client'

import { ActionBarWidget } from './action-bar-widget'

let delayTimer: number

function ActionBarWidgetExtension(): Extension {
return StateField.define<Tooltip | null>({
create() {
return null
},
update(value, transaction) {
if (transaction.newSelection.main.empty) {
clearTimeout(delayTimer)
return null
}
if (transaction.selection) {
Expand All @@ -22,6 +25,8 @@ function ActionBarWidgetExtension(): Extension {
// return tooltip?.pos !== value?.pos ? tooltip : value
return tooltip
}

clearTimeout(delayTimer)
return null
}
return value
Expand All @@ -30,8 +35,6 @@ function ActionBarWidgetExtension(): Extension {
})
}

let delayTimer: number

function createActionBarWidget(state: EditorState): Tooltip {
const { selection } = state
const lineFrom = state.doc.lineAt(selection.main.from)
Expand Down

0 comments on commit deee346

Please sign in to comment.