|
|
@@ -12,7 +12,6 @@ import { markDecorations } from './mark-decorations'
|
|
|
import { EditorView, ViewPlugin } from '@codemirror/view'
|
|
|
import { visualKeymap } from './visual-keymap'
|
|
|
import { mousedown, mouseDownEffect } from './selection'
|
|
|
-import { findEffect } from '../../utils/effects'
|
|
|
import { forceParsing, syntaxTree } from '@codemirror/language'
|
|
|
import { hasLanguageLoadedEffect } from '../language'
|
|
|
import { restoreScrollPosition } from '../scroll-position'
|
|
|
@@ -34,14 +33,18 @@ type Options = {
|
|
|
const visualConf = new Compartment()
|
|
|
|
|
|
export const toggleVisualEffect = StateEffect.define<boolean>()
|
|
|
-export const findToggleVisualEffect = findEffect(toggleVisualEffect)
|
|
|
|
|
|
const visualState = StateField.define<boolean>({
|
|
|
create() {
|
|
|
return false
|
|
|
},
|
|
|
update(value, tr) {
|
|
|
- return findToggleVisualEffect(tr)?.value ?? value
|
|
|
+ for (const effect of tr.effects) {
|
|
|
+ if (effect.is(toggleVisualEffect)) {
|
|
|
+ return effect.value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return value
|
|
|
},
|
|
|
})
|
|
|
|
|
|
@@ -80,10 +83,11 @@ export const sourceOnly = (visual: boolean, extension: Extension) => {
|
|
|
|
|
|
// Respond to switching editor modes
|
|
|
EditorState.transactionExtender.of(tr => {
|
|
|
- const effect = findToggleVisualEffect(tr)
|
|
|
- if (effect) {
|
|
|
- return {
|
|
|
- effects: conf.reconfigure(configure(effect.value)),
|
|
|
+ for (const effect of tr.effects) {
|
|
|
+ if (effect.is(toggleVisualEffect)) {
|
|
|
+ return {
|
|
|
+ effects: conf.reconfigure(configure(effect.value)),
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return null
|