Allow enabling EditContext in CodeMirror (#29114)

GitOrigin-RevId: 15d70fd2d5da68d43f441bb0c65ff0cd2d785306
This commit is contained in:
Alf Eaton
2025-11-03 10:51:44 +00:00
committed by Copybot
parent ad3d68ece0
commit 1d3d81e67d
3 changed files with 6 additions and 7 deletions

View File

@@ -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 () {

View File

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

View File

@@ -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,