mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Avoid dispatching unnecessary transaction for review panel tooltip (#22524)
* Avoid dispatching unneeded review panel effects * Remove event listeners GitOrigin-RevId: 17fec45f660fdd7934aa6ef3202159377902f6a5
This commit is contained in:
@@ -41,31 +41,7 @@ export const reviewTooltip = (): Extension => {
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
reviewTooltipTheme,
|
||||
reviewTooltipStateField,
|
||||
EditorView.updateListener.of(update => {
|
||||
if (update.selectionSet && !update.state.selection.main.empty) {
|
||||
update.view.dispatch({
|
||||
effects: textSelectedEffect.of(null),
|
||||
})
|
||||
} else if (
|
||||
!update.startState.selection.main.empty &&
|
||||
update.state.selection.main.empty
|
||||
) {
|
||||
update.view.dispatch({
|
||||
effects: removeReviewPanelTooltipEffect.of(null),
|
||||
})
|
||||
}
|
||||
}),
|
||||
EditorView.domEventHandlers({
|
||||
mousedown(event, view) {
|
||||
view.dispatch({
|
||||
effects: removeReviewPanelTooltipEffect.of(null),
|
||||
})
|
||||
},
|
||||
}),
|
||||
]
|
||||
return [reviewTooltipTheme, reviewTooltipStateField]
|
||||
}
|
||||
|
||||
export const reviewTooltipStateField = StateField.define<{
|
||||
@@ -82,10 +58,6 @@ export const reviewTooltipStateField = StateField.define<{
|
||||
addCommentRanges = addCommentRanges.map(tr.changes)
|
||||
|
||||
for (const effect of tr.effects) {
|
||||
if (effect.is(removeReviewPanelTooltipEffect)) {
|
||||
return { tooltip: null, addCommentRanges }
|
||||
}
|
||||
|
||||
if (effect.is(removeNewCommentRangeEffect)) {
|
||||
const rangeToRemove = effect.value
|
||||
addCommentRanges = addCommentRanges.update({
|
||||
@@ -102,14 +74,10 @@ export const reviewTooltipStateField = StateField.define<{
|
||||
add: [rangeToAdd],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (effect.is(textSelectedEffect)) {
|
||||
tooltip = buildTooltip(tr.state)
|
||||
}
|
||||
|
||||
if (tooltip && tr.state.selection.main.empty) {
|
||||
tooltip = null
|
||||
}
|
||||
if (tr.selection) {
|
||||
tooltip = buildTooltip(tr.state)
|
||||
}
|
||||
|
||||
return { tooltip, addCommentRanges }
|
||||
|
||||
Reference in New Issue
Block a user