Просмотр исходного кода

Avoid selecting word when opening spell check context menu (#23756)

GitOrigin-RevId: 0276979d18583f5813476b2ac01a8eb33b352fcb
Alf Eaton 1 год назад
Родитель
Сommit
e151be6b89

+ 2 - 9
services/web/frontend/js/features/source-editor/extensions/spelling/context-menu.tsx

@@ -1,9 +1,4 @@
-import {
-  StateField,
-  StateEffect,
-  EditorSelection,
-  Prec,
-} from '@codemirror/state'
+import { StateField, StateEffect, Prec } from '@codemirror/state'
 import { EditorView, showTooltip, Tooltip, keymap } from '@codemirror/view'
 import { Word, Mark, getMarkAtPosition } from './spellchecker'
 import { debugConsole } from '@/utils/debugging'
@@ -57,7 +52,7 @@ const handleContextMenuEvent = (event: MouseEvent, view: EditorView) => {
     return
   }
 
-  const { from, to, value } = targetMark
+  const { value } = targetMark
 
   const targetWord = value.spec.word
   if (!targetWord) {
@@ -72,7 +67,6 @@ const handleContextMenuEvent = (event: MouseEvent, view: EditorView) => {
   openingUntil = Date.now() + 100
 
   view.dispatch({
-    selection: EditorSelection.range(from, to),
     effects: showSpellingMenu.of({
       mark: targetMark,
       word: targetWord,
@@ -88,7 +82,6 @@ const handleShortcutEvent = (view: EditorView) => {
   }
 
   view.dispatch({
-    selection: EditorSelection.range(targetMark.from, targetMark.to),
     effects: showSpellingMenu.of({
       mark: targetMark,
       word: targetMark.value.spec.word,