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 [ return [
reviewTooltipTheme, reviewTooltipTheme,
reviewTooltipStateField, reviewTooltipStateField,
EditorView.domEventHandlers({ EditorView.updateListener.of(update => {
mouseup(event, view) { if (update.selectionSet && !update.state.selection.main.empty) {
if (!view.state.selection.main.empty) { update.view.dispatch({
view.dispatch({ effects: textSelectedEffect.of(update.view),
effects: textSelectedEffect.of(view),
}) })
} } else if (
}, !update.startState.selection.main.empty &&
keyup(event, view) { update.state.selection.main.empty
if (
(event.shiftKey || event.key === 'Meta') &&
!view.state.selection.main.empty
) { ) {
view.dispatch({ update.view.dispatch({
effects: textSelectedEffect.of(view), effects: removeReviewPanelTooltipEffect.of(null),
}) })
} }
}, }),
EditorView.domEventHandlers({
mousedown(event, view) { mousedown(event, view) {
view.dispatch({ view.dispatch({
effects: removeReviewPanelTooltipEffect.of(null), effects: removeReviewPanelTooltipEffect.of(null),