Improve selection detection for "Add comment" tooltip (#21731)

GitOrigin-RevId: cd13cacea0d6e45015997f3a831d0f127ddf8cd8
This commit is contained in:
Domagoj Kriskovic 2024-11-11 17:24:20 +01:00 committed by Copybot
parent 805c4f8321
commit edb4e3d537

View file

@ -43,24 +43,21 @@ export const reviewTooltip = (): Extension => {
return [
reviewTooltipTheme,
reviewTooltipStateField,
EditorView.domEventHandlers({
mouseup(event, view) {
if (!view.state.selection.main.empty) {
view.dispatch({
effects: textSelectedEffect.of(view),
EditorView.updateListener.of(update => {
if (update.selectionSet && !update.state.selection.main.empty) {
update.view.dispatch({
effects: textSelectedEffect.of(update.view),
})
}
},
keyup(event, view) {
if (
(event.shiftKey || event.key === 'Meta') &&
!view.state.selection.main.empty
} else if (
!update.startState.selection.main.empty &&
update.state.selection.main.empty
) {
view.dispatch({
effects: textSelectedEffect.of(view),
update.view.dispatch({
effects: removeReviewPanelTooltipEffect.of(null),
})
}
},
}),
EditorView.domEventHandlers({
mousedown(event, view) {
view.dispatch({
effects: removeReviewPanelTooltipEffect.of(null),