I have just tagged a 0.20.0 release for all the @codemirror packages (and 0.16.0 for the @lezer packages). These introduce some package restructuring and a few minor breaking changes (listed below). I will tag 6.0 with this interface in a few weeks, if no significant issues are encountered.
To update your codebase, these are the things you’ll want to look at:
-
If you were still using
Prec.fallback
/Prec.override
/Prec.extend
, you must move to the new names. -
The old height querying system on the view (
blockAtHeight
,visualLineAtHeight
,viewportLines
,visualLineAt
) has been replaced with a simpler system where all y offsets are relative to the document top (see here). -
The scroll control effects and method (
scrollPosIntoView
,scrollTo
, andcenterOn
) are now replaced by the more generalscrollIntoView
effect. -
Plugin fields no longer exist, and providing decorations from a view plugin now happens by providing a function to the
EditorView.decorations
facet. Same for atomic ranges and scroll margins — you must use a facet for them now. -
The exports from the @codemirror/text and @codemirror/rangeset packages have been moved into @codemirror/state, and the old packages are no longer available.
-
The exports from the @codemirror/tooltip, gutter, panel, and rectangular-selection packages have been moved into @codemirror/view.
-
The exports from @codemirror/matchbrackets, @codemirror/stream-parser, and @codemirror/fold have been moved into @codemirror/language.
-
The exports from @codemirror/comment and @codemirror/history have been moved into @codemirror/commands.
commentKeymap
has been merged intodefaultKeymap
. -
The @codemirror/closebrackets package has been merged into @codemirror/autocomplete.
-
The @codemirror/highlight package has been split between @codemirror/language (the editor-specific parts) and @lezer/highlight (a new package containing the generic syntax-highlighting functionality). Lezer parser packages are now expected to provide highlighting information.
-
HighlightStyles
objects no longer directly act as editor extensions, but have to be wrapped with thesyntaxHighlighting
function first. -
Language
objects no longer export atopNode
property, and if you want to use per-language highlighting you should pass the entireLanguage
object to thescope
option instead. -
In completion results, the rather confusing
span
property has been renamed tovalidFor
(and may be a function, not just a regexp). -
If you’re using
iterate
on syntax trees, the signature of theenter
/leave
functions was simplified in a breaking way.
The less granular module structure should make setting up your editor a bit more straightforward, and the changes to the highlighting logic make it a lot easier to do syntax highlighting based on Lezer parsers without pulling in a bunch of irrelevant editor code.