|
@@ -1,4 +1,4 @@
|
|
|
-import { EditorSelection } from '@codemirror/state'
|
|
|
|
|
|
|
+import { EditorSelection, StateEffect } from '@codemirror/state'
|
|
|
import { EditorView, WidgetType } from '@codemirror/view'
|
|
import { EditorView, WidgetType } from '@codemirror/view'
|
|
|
import { SyntaxNode } from '@lezer/common'
|
|
import { SyntaxNode } from '@lezer/common'
|
|
|
|
|
|
|
@@ -15,6 +15,8 @@ export type Preamble = {
|
|
|
}[]
|
|
}[]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export const collapsePreambleEffect = StateEffect.define<boolean>()
|
|
|
|
|
+
|
|
|
export class PreambleWidget extends WidgetType {
|
|
export class PreambleWidget extends WidgetType {
|
|
|
constructor(public expanded: boolean) {
|
|
constructor(public expanded: boolean) {
|
|
|
super()
|
|
super()
|
|
@@ -60,7 +62,9 @@ export class PreambleWidget extends WidgetType {
|
|
|
}
|
|
}
|
|
|
event.preventDefault()
|
|
event.preventDefault()
|
|
|
if (this.expanded) {
|
|
if (this.expanded) {
|
|
|
- view.dom.dispatchEvent(new Event('editor:collapse-preamble'))
|
|
|
|
|
|
|
+ view.dispatch({
|
|
|
|
|
+ effects: collapsePreambleEffect.of(true),
|
|
|
|
|
+ })
|
|
|
} else {
|
|
} else {
|
|
|
view.dispatch({
|
|
view.dispatch({
|
|
|
selection: EditorSelection.cursor(0),
|
|
selection: EditorSelection.cursor(0),
|