// CodeMirror 6 bundle for PromptChain // Exports: core CM6 + custom prompt language, theme, linter, keybindings, wildcard system // -- Core CM6 -- import { EditorView, keymap, Decoration, ViewPlugin, WidgetType } from "@codemirror/view"; import { EditorState, StateField, StateEffect, Compartment } from "@codemirror/state"; import { history, historyKeymap, defaultKeymap } from "@codemirror/commands"; import { bracketMatching } from "@codemirror/language"; import { StreamLanguage, syntaxHighlighting, HighlightStyle } from "@codemirror/language"; import { linter, diagnosticCount, forceLinting } from "@codemirror/lint"; import { autocompletion, startCompletion, acceptCompletion, completionStatus, pickedCompletion } from "@codemirror/autocomplete"; import { tooltips } from "@codemirror/view"; import { tags } from "@lezer/highlight"; // -- Prompt Language (StreamLanguage) -- const promptLanguage = StreamLanguage.define({ startState() { return { inBlockComment: false, inNegativeRegion: false, inScriptBlock: false }; }, copyState(state) { return { inBlockComment: state.inBlockComment, inNegativeRegion: state.inNegativeRegion, inScriptBlock: state.inScriptBlock, }; }, token(stream, state) { // script blocks if (state.inScriptBlock && stream.match(/<\/SCRIPT>/i)) { state.inScriptBlock = false; return "moduleKeyword"; } if (state.inScriptBlock) { if (stream.match(/\{PROMPT\}/i)) return "operator"; stream.next(); return "typeName"; } if (stream.match(/