Explorar el Código

Allow enabling EditContext in CodeMirror (#29114)

GitOrigin-RevId: 15d70fd2d5da68d43f441bb0c65ff0cd2d785306
Alf Eaton hace 11 meses
padre
commit
1d3d81e67d

+ 0 - 1
services/web/cypress/support/component.ts

@@ -4,7 +4,6 @@ import localesPromise from '@/i18n'
 import './shared/commands'
 import './shared/exceptions'
 import './ct/commands'
-import './ct/codemirror'
 import '../../test/frontend/helpers/bootstrap'
 
 beforeEach(function () {

+ 0 - 4
services/web/cypress/support/ct/codemirror.ts

@@ -1,4 +0,0 @@
-import { EditorView } from '@codemirror/view'
-
-// @ts-ignore (disable EditContext-based editing until stable)
-EditorView.EDIT_CONTEXT = false

+ 6 - 2
services/web/frontend/js/features/source-editor/components/codemirror-editor.tsx

@@ -19,6 +19,7 @@ import {
 import MathPreviewTooltip from './math-preview-tooltip'
 import { useToolbarMenuBarEditorCommands } from '@/features/ide-redesign/hooks/use-toolbar-menu-editor-commands'
 import { useProjectContext } from '@/shared/context/project-context'
+import { useFeatureFlag } from '@/shared/context/split-test-context'
 
 // TODO: remove this when definitely no longer used
 export * from './codemirror-context'
@@ -34,12 +35,15 @@ function CodeMirrorEditor() {
   })
 
   const isMounted = useIsMounted()
+  const editContextEnabled = useFeatureFlag('edit-context')
 
   // create the view using the initial state and intercept transactions
   const viewRef = useRef<EditorView | null>(null)
   if (viewRef.current === null) {
-    // @ts-ignore (disable EditContext-based editing until stable)
-    EditorView.EDIT_CONTEXT = false
+    if (!editContextEnabled) {
+      // @ts-expect-error (disable EditContext-based editing until stable)
+      EditorView.EDIT_CONTEXT = false
+    }
 
     const view = new EditorView({
       state,