diff --git a/.changeset/codemirror-v6-migration.md b/.changeset/codemirror-v6-migration.md new file mode 100644 index 00000000..675fc11d --- /dev/null +++ b/.changeset/codemirror-v6-migration.md @@ -0,0 +1,23 @@ +--- +"@matdata/yasqe": major +"@matdata/yasr": major +"@matdata/yasgui": major +--- + +Migrate the editor stack from CodeMirror 5 to CodeMirror 6. + +**@matdata/yasqe** + +- The query editor now runs on CodeMirror 6 (`@codemirror/state`, `@codemirror/view`, `@codemirror/language`, `@codemirror/autocomplete`, `@codemirror/search`, `@codemirror/commands`). +- `Yasqe` no longer extends the CodeMirror class. It wraps an `EditorView` and exposes a CodeMirror 5–compatible facade (`getValue`, `setValue`, `getCursor`, `setCursor`, `getTokenAt`, `getDoc`, `markText`, `on('change' | 'cursorActivity' | ...)`, `addKeyMap`, ...). Code relying on CodeMirror 5 internals (`yasqe.display`, `CodeMirror.defineMode`, addons, `codemirror/theme/*.css`) must be updated. +- The underlying `EditorView` is available for advanced integrations that want to use CodeMirror 6 extensions directly. +- Syntax highlighting, error/warning gutter markers, PREFIX/brace folding, autocompletion popups (`.CodeMirror-hints`), formatting, comment toggling and all keyboard shortcuts keep their previous behaviour. Token CSS classes keep the CodeMirror 5 names (`cm-keyword`, `cm-variable-3`, ...), and the editor root still carries the `CodeMirror cm-s-` classes so existing theme stylesheets continue to apply. + +**@matdata/yasr** + +- The Response plugin renders raw responses with a read-only CodeMirror 6 view (`@codemirror/lang-json`, `@codemirror/lang-xml`, legacy Turtle mode) instead of CodeMirror 5. + +**@matdata/yasgui** + +- Adapted to the new editor API (Ctrl/Cmd-click IRI navigation, theme handling). +- The editor theme picker now offers the bundled `default` and `github-dark` themes; the CodeMirror 5 theme catalogue (`material-palenight`, `dracula`, ...) is no longer shipped. Custom themes can be added by styling the `cm-s-` class. diff --git a/docs/developer-guide.md b/docs/developer-guide.md index eca3bce0..0f0c868c 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -244,7 +244,7 @@ YASGUI is built as a monorepo with four main packages, each serving a specific p #### @matdata/yasqe (SPARQL Query Editor) -**Purpose**: Rich SPARQL query editor built on CodeMirror. +**Purpose**: Rich SPARQL query editor built on CodeMirror 6. **Key Features:** - SPARQL syntax highlighting @@ -257,12 +257,29 @@ YASGUI is built as a monorepo with four main packages, each serving a specific p - Keyboard shortcuts **Core Components:** -- CodeMirror editor with SPARQL mode -- SPARQL tokenizer/grammar -- Autocomplete system (extensible) +- CodeMirror 6 `EditorView` wrapped by a CodeMirror 5-compatible facade (`packages/yasqe/src/editor/`) +- SPARQL tokenizer/grammar exposed as a `StreamLanguage` (`packages/yasqe/grammar/tokenizer.ts`) +- Autocomplete system (extensible, bridged to `@codemirror/autocomplete`) - HTTP request handler - Prefix utilities +**Editor architecture (CodeMirror 6):** + +`Yasqe` no longer extends the CodeMirror class. It owns a CodeMirror 6 `EditorView` and exposes the familiar +CodeMirror 5-style API (`getValue`, `setValue`, `getCursor`, `setCursor`, `getTokenAt`, `getDoc`, `markText`, +`on('change'|'cursorActivity'|...)`, `addKeyMap`, etc.) through the `EditorFacade`/`DocFacade` classes. The +`editor/` folder contains the CM6 building blocks: + +- `facade.ts` / `doc.ts` – CM5-compatible editor and document API on top of `EditorView`/`EditorState` +- `language.ts` / `tokenizerRunner.ts` – `StreamLanguage` for the SPARQL grammar emitting `cm-