11import fsOperation from "fileSystem" ;
22import sidebarApps from "sidebarApps" ;
3- import { HighlightStyle , syntaxHighlighting } from "@codemirror/language" ;
4- import { Compartment , EditorState , Prec , StateEffect } from "@codemirror/state" ;
5- import { EditorView } from "@codemirror/view" ;
3+ import * as cmAutocomplete from "@codemirror/autocomplete" ;
4+ import * as cmCommands from "@codemirror/commands" ;
5+ import * as cmLanguage from "@codemirror/language" ;
6+ import * as cmLint from "@codemirror/lint" ;
7+ import * as cmSearch from "@codemirror/search" ;
8+ import * as cmState from "@codemirror/state" ;
9+ import * as cmView from "@codemirror/view" ;
610import ajax from "@deadlyjack/ajax" ;
7- import { tags } from "@lezer/highlight" ;
11+ import * as lezerHighlight from "@lezer/highlight" ;
812import {
913 getRegisteredCommands as listRegisteredCommands ,
1014 refreshCommandKeymap ,
@@ -150,7 +154,7 @@ export default class Acode {
150154
151155 const createHighlightStyle = ( spec ) => {
152156 if ( ! spec ) return null ;
153- if ( Array . isArray ( spec ) ) return HighlightStyle . define ( spec ) ;
157+ if ( Array . isArray ( spec ) ) return cmLanguage . HighlightStyle . define ( spec ) ;
154158 return spec ;
155159 } ;
156160
@@ -163,12 +167,12 @@ export default class Acode {
163167 const ext = [ ] ;
164168
165169 if ( styles && typeof styles === "object" ) {
166- ext . push ( EditorView . theme ( styles , { dark : ! ! dark } ) ) ;
170+ ext . push ( cmView . EditorView . theme ( styles , { dark : ! ! dark } ) ) ;
167171 }
168172
169173 const resolvedHighlight = createHighlightStyle ( highlightStyle ) ;
170174 if ( resolvedHighlight ) {
171- ext . push ( syntaxHighlighting ( resolvedHighlight ) ) ;
175+ ext . push ( cmLanguage . syntaxHighlighting ( resolvedHighlight ) ) ;
172176 }
173177
174178 if ( Array . isArray ( extensions ) ) {
@@ -213,10 +217,10 @@ export default class Acode {
213217 createTheme,
214218 createHighlightStyle,
215219 cm : {
216- EditorView,
217- HighlightStyle,
218- syntaxHighlighting,
219- tags,
220+ EditorView : cmView . EditorView ,
221+ HighlightStyle : cmLanguage . HighlightStyle ,
222+ syntaxHighlighting : cmLanguage . syntaxHighlighting ,
223+ tags : lezerHighlight . tags ,
220224 } ,
221225 } ;
222226
@@ -314,6 +318,17 @@ export default class Acode {
314318 } ,
315319 } ;
316320
321+ const codemirrorModule = Object . freeze ( {
322+ autocomplete : cmAutocomplete ,
323+ commands : cmCommands ,
324+ language : cmLanguage ,
325+ lezer : lezerHighlight ,
326+ lint : cmLint ,
327+ search : cmSearch ,
328+ state : cmState ,
329+ view : cmView ,
330+ } ) ;
331+
317332 this . define ( "Url" , Url ) ;
318333 this . define ( "page" , Page ) ;
319334 this . define ( "Color" , Color ) ;
@@ -356,6 +371,15 @@ export default class Acode {
356371 this . define ( "selectionMenu" , selectionMenu ) ;
357372 this . define ( "sidebarApps" , sidebarAppsModule ) ;
358373 this . define ( "terminal" , terminalModule ) ;
374+ this . define ( "codemirror" , codemirrorModule ) ;
375+ this . define ( "@codemirror/autocomplete" , cmAutocomplete ) ;
376+ this . define ( "@codemirror/commands" , cmCommands ) ;
377+ this . define ( "@codemirror/language" , cmLanguage ) ;
378+ this . define ( "@codemirror/lint" , cmLint ) ;
379+ this . define ( "@codemirror/search" , cmSearch ) ;
380+ this . define ( "@codemirror/state" , cmState ) ;
381+ this . define ( "@codemirror/view" , cmView ) ;
382+ this . define ( "@lezer/highlight" , lezerHighlight ) ;
359383 this . define ( "createKeyboardEvent" , KeyboardEvent ) ;
360384 this . define ( "toInternalUrl" , helpers . toInternalUri ) ;
361385 this . define ( "commands" , this . #createCommandApi( ) ) ;
0 commit comments