UNPKG

@codemirror/view

Version:

DOM view component for the CodeMirror code editor

1,452 lines (727 loc) 78.6 kB
## 6.41.0 (2026-04-01) ### Bug fixes Fix an issue where `EditorView.posAtCoords` could incorrectly return a position near a higher element on the line, in mixed-font-size lines. Expand the workaround for the Webkit bug that causes nonexistent selections to stay visible to be active on non-Safari Webkit browsers. ### New features The new `EditorView.cursorScrollMargin` facet can now be used to configure the extra space used when scrolling the cursor into view. ## 6.40.0 (2026-03-12) ### Bug fixes Fix a bug that caused Shift-Enter/Backspace/Delete on iOS to lose the shift modifier when delivered to key event handlers. Fix an issue where `EditorView.moveVertically` could move to the wrong place in wrapped lines with a large line height. Make sure the selection head associativity is properly set for mouse selections made with shift held down. ### New features `WidgetType.updateDOM` is now called with the previous widget value as third argument. ## 6.39.17 (2026-03-10) ### Bug fixes Improve touch tap-selection on line wrapping boundaries. Make `drawSelection` draw our own selection handles on iOS. Fix an issue where `posAtCoords`, when querying line wrapping points, got confused by extra empty client rectangles produced by Safari. ## 6.39.16 (2026-03-02) ### Bug fixes Perform scroll stabilization on the document or wrapping scrollable elements, when the user scrolls the editor. Fix an issue where changing decorations right before a composition could end up corrupting the visible DOM. Fix an issue where some types of text input over a selection would be read as happening in wrong position. ## 6.39.15 (2026-02-20) ### Bug fixes Fix a regression where the editor would forget previously measured line heights without good reason. Fix an issue where scrolling the cursor into view sometimes wouldn't work on Chrome Android. Fix a bug that broke composition inside of block wrappers. ## 6.39.14 (2026-02-12) ### Bug fixes Improve performance of `posAtCoords` on long lines. Fix a regression where copy and cut in a shadow DOM on Safari would fall back to the native behavior, often copying the wrong text. ## 6.39.13 (2026-02-08) ### Bug fixes Fix an issue where a widget at start or end of line, when wrapped to cover that whole line, could block vertical cursor motion. Fix an issue `EditorView.moveVertically` that would sometimes cause selection-extending vertical motion to get stuck on line wrapping points. ## 6.39.12 (2026-01-30) ### Bug fixes Fix a bug where the visual selection drawn by `drawSelection` could fail to update properly in some circumstances. Fix a bug where PageUp/PageDown near the edge of the viewport might completely skip to the start/end of the document. Fix a regression that caused mark decorations to be split on text node chunk boundaries again. ## 6.39.11 (2026-01-14) ### Bug fixes Avoid handling copy events for parent editors. ## 6.39.10 (2026-01-13) ### Bug fixes Fix a regression in the way widget are reused when content next to them changes. Make sure font metrics get recomputed on `fonts.ready` even if the line height doesn't change. Fix an issue where compositions next to a widget that create a new text node could get needlessly interrupted during an editor update. ## 6.39.9 (2026-01-06) ### Bug fixes Fix a bug where `EditorSelection.cursor()` with a non-zero `assoc` value would not be visually respected at soft-wrap boundaries on initial view creation. Fix error caused by hover tooltips running a scheduled timeout after their editor has been destroyed. Fix a bug that caused `EditorView.outerDecorations` to not affect the content height map. Fix an issue where composition near a widget could get unnecessarily interrupted. ## 6.39.8 (2025-12-30) ### Bug fixes Fix a bug that cause `coordsAtPos` to use the dimensions of widget buffers when there were more meaningful elements to use nearby. Fix a data structure corruption that could cause crashes during viewport changes. ## 6.39.7 (2025-12-24) ### Bug fixes Fix a bug that could sometimes cause the document to become mangled during composition. ## 6.39.6 (2025-12-23) ### Bug fixes Fix an issue when composing on the boundary of a decoration, where the text after the composition would get garbled. ## 6.39.5 (2025-12-22) ### Bug fixes Fix an issue where replaced widgets alone on a line weren't reused and didn't get their `updateDOM` method called. Fix a bug where, when selecting full lines at the end of the document and inserting a character on Chrome, an inappropriate extra newline was inserted. ## 6.39.4 (2025-12-12) ### Bug fixes Fix a bug where paste events handlers on Chrome could fail to run when pasting on a blank line. Fix a regression causing the native cursor to get stuck before block widgets with side>0. Fix a crash in content DOM building after a block widget. Fix a bug in `posAtCoords` that would in some circumstances make it return positions on the wrong side of a block widget. ## 6.39.3 (2025-12-11) ### Bug fixes Fix a bug that could corrupt the rendered document in some situations involving adjacent mark decorations of the same type. ## 6.39.2 (2025-12-09) ### Bug fixes Fix an issue where `moveVertially` was sometimes unable to escape lines with thick borders or padding. ## 6.39.1 (2025-12-09) ### Bug fixes Restore a workaround for a Chrome selection bug that had regressed in the previous release. ## 6.39.0 (2025-12-08) ### Bug fixes Properly handle bidirectional text in `posAtCoords`. Avoid computing a zero character width (leading to divisions by zero) when the editor is hidden and the browser doesn't have a layout for it. ### New features The `posAndSideAtCoords` method is an extended version of `posAtCoords` that also tells you which side of the position the coordinates are associated with. Add support for block wrappers, decoration-like things that allow extension code to create DOM nodes around groups of lines. ## 6.38.8 (2025-11-17) ### Bug fixes Improve handling of composition with multiple cursors on MacOS. Fix an issue where computing a document position from screen coordinates would sometimes go wrong in right-to-left text. ## 6.38.7 (2025-11-14) ### Bug fixes Make detection of transformed tooltip parent elements (forcing absolute positioning) more robust on current browsers. Avoid an issue where on Chrome and Safari, typing over a cross-line selection can replace widgets on the line after the selection with their plain text content. Fix a bug that broke insertion of composed input at multiple cursors when the IME keeps the selection at the start of the composed text. ## 6.38.6 (2025-10-13) ### Bug fixes Work around a regression in Safari 26 that causes fragments of old selections to remain visible. ## 6.38.5 (2025-10-07) ### Bug fixes Avoid firing text changes that cover unchanged text on Android. Fix an issue where the editor could, in some circumstances, insert a stray newline when typing over a document that ended in a block widget. Work around an issue in Safari 26 that causes inappropriate scrolling on focus in some circumstances. ## 6.38.4 (2025-09-28) ### Bug fixes Work around a Chrome Android issue where the browser doesn't properly fire composition end events, leaving CodeMirror to believe the user was still composing. ## 6.38.3 (2025-09-22) ### Bug fixes Work around a rendering bug in Mobile Safari by completely hiding empty layers. Fix vertical cursor motion in Chrome around decorations with bottom borders or margins. Fix an issue that caused mark decorations longer than 512 characters to needlessly be split. Move the cursor out of atomic ranges when text input happens. ## 6.38.2 (2025-09-01) ### Bug fixes Re-enable falling dispatching keys by key code for Cmd-Alt- combinations on macOS. Make sure all pointer selections skip atomic ranges. ## 6.38.1 (2025-07-15) ### Bug fixes Make the keymap not dispatch Alt key combos on macOS by key code, because those are generally used to type special characters. Fix a layout bug that could occur with very narrow editors. ## 6.38.0 (2025-06-27) ### New features Gutters can now specify that they should be displayed after the content (which would be to the right in a left-to-right layout). ## 6.37.2 (2025-06-12) ### Bug fixes Fix an issue where moving the cursor vertically from the one-but-last character on a line would sometimes move incorrectly on Safari. Fix an issue causing coordinates between lines of text to sometimes be inappropriately placed at the end of the line by `posAtCoords`. ## 6.37.1 (2025-05-30) ### Bug fixes Properly add `crelt` as a dependency. ## 6.37.0 (2025-05-29) ### New features View plugins can now take an argument, in which case they must be instantiated with their `of` method in order to be added to a configuration. The new `showDialog` function makes it easy to show a notification or prompt using a CodeMirror panel. ## 6.36.8 (2025-05-12) ### Bug fixes Make `logException` log errors to the console when `onerror` returns a falsy value. Fix an issue in `MatchDecorator` causing `updateDeco` to sometimes not do the right thing for deletions. ## 6.36.7 (2025-05-02) ### Bug fixes Use the `aria-placeholder` attribute to communicate the placeholder text to screen readers. Fix a crash when `EditorView.composing` or `.compositionStarted` are accessed during view initialization. ## 6.36.6 (2025-04-24) ### Bug fixes Fix an issue where `drawSelection` would draw selections starting at a block widget not at a line break in an odd way. Fix an issue where the editor would inappropriately scroll when editing near the bottom of the document with line wrapping enabled, in some cases. Fix an issue that caused unnecessary transactions on focus change. ## 6.36.5 (2025-03-29) ### Bug fixes Fix an issue where some browsers wouldn't enable context menu paste when clicking on placeholder text. Fix an issue where cursor height would unnecessarily be based on a placeholder node's dimensions, and thus be off from the text height. ## 6.36.4 (2025-03-03) ### Bug fixes Fix an issue where scrolling down to a range higher than the viewport could in some situations fail to scroll to the proper position. ## 6.36.3 (2025-02-18) ### Bug fixes Make sure event handlers registered with `domEventHandlers` are not called during view updates, to avoid triggering nested update errors. Don't include the window scrollbars in the space available for displaying tooltips. Work around an issue with Chrome's `EditContext` that shows up when using autocompletion while composing with Samsung's virtual Android keyboard. ## 6.36.2 (2025-01-09) ### Bug fixes Fix an issue where some kinds of relayouts could put the editor in a state where it believed it wasn't in window, preventing relayout, though it in fact was. Make sure macOS double-space-to-period conversions are properly suppressed. Fix an issue where native selection changes, such as mobile spacebar-drag, weren't being picked up in edit context mode. ## 6.36.1 (2024-12-19) ### Bug fixes Fix a crash in MatchDecorator when updating matches at the end of the document. ## 6.36.0 (2024-12-17) ### Bug fixes Make selection rectangles verticaly align precisely, rather than introducing a slight overlap. Fix an issue in `MatchDecorator` that caused it to fully rebuild its decorations on normal edits. ### New features View updates now have a `viewportMoved` flag that is only true when a viewport change originated from something other than mapping the viewport over a document change. ## 6.35.3 (2024-12-09) ### Bug fixes Fix an issue where mark decorations that got merged or split weren't properly redrawn. Avoid spurious focus events by not updating the DOM selection when the editor is unfocused but focusable. Disable `writingsuggestions` for the editable element, to opt out of Safari's new intelligence completions (which mess up in the editor). ## 6.35.2 (2024-12-07) ### Bug fixes Fix an issue on Chrome where typing at the end of the document would insert a character after the cursor. ## 6.35.1 (2024-12-06) ### Bug fixes Work around another crash caused by incorrect composition positions reported by `EditContext`. Stop disabling custom cursors on Safari version 11.4 and up, which support `caret-color`. Fix an issue where a tooltip with wrapped content could, in some circumstances, fail to find a stable position due to a cyclic dependency between its width and its position. ## 6.35.0 (2024-11-21) ### New features Tooltips can now use the `clip` option to control whether they are hidden when outside the visible editor content. ## 6.34.3 (2024-11-15) ### Bug fixes Make sure positions covered by a gutter or a panel aren't treated as visible for the purpose of displaying tooltips. Properly include the tooltip arrow height when checking whether a tooltip fits in its preferred above/below position. Fix an issue with compositions on Chrome inserting their content in the wrong position when another document change came in during composition. ## 6.34.2 (2024-11-05) ### Bug fixes Fix the default cursor color for dark themes, which was way too dark. ## 6.34.1 (2024-09-27) ### Bug fixes Avoid a stack overflow that could happen when updating a line with a lot of text tokens. Improve the way enormously long (non-wrapped) lines are displayed by making sure they stay shorter than the maximal pixel size the browser's CSS engine can handle. ## 6.34.0 (2024-09-25) ### Bug fixes Fix an issue where the dots past the wrapping point were displayed incorrectly when using `highlightWhitespace` with a wrapped sequence of spaces. Improve performance of documents displaying lots of highlighted spaces by using a CSS background instead of pseudo-element. ### New features `placeholder` now allows a function that constructs the placedholder DOM to be passed in, and uses `cloneNode` when a raw element is passed in, to prevent adding the same element to multiple editors. ## 6.33.1 (2024-08-30) ### Bug fixes Work around odd behavior in Chrome's newly supported `caretPositionFromPoint` method, which could cause CodeMirror to crash with a null dereference. ## 6.33.0 (2024-08-24) ### Bug fixes Make it easier to move the pointer over a hover tooltip with an arrow by not closing the tooltip when the pointer is moving over the gap for the arrow. ### New features The new `EditorView.clipboardInputFilter` and `clipboardOutputFilter` facets allow you to register filter functions that change text taken from or sent to the clipboard. ## 6.32.0 (2024-08-12) ### Bug fixes Fix a bug where the editor could draw way too big a viewport when not managing its own scrollbar. ### New features The new `gutterWidgetClass` facet makes it possible to add a class to gutter elements next to widgets. ## 6.31.0 (2024-08-11) ### Bug fixes Avoid the editor's geometry measurements becoming incorrect when fonts finish loading by scheduling a measure on `document.fonts.ready`. Avoid an issue where Chrome would incorrectly scroll the window when deleting lines in the editor. Fix an issue where in some layouts editor content would be drawn on top of panel elements. Fix an issue where `coordsAtPos` would return null when querying a position in a block widget. ### New features The new `lineNumberWidgetMarker` facet makes it possible to insert markers into the line number gutter for widgets. ## 6.30.0 (2024-08-05) ### Bug fixes Make spell check corrections work again on `EditContext`-enabled Chrome versions. ### New features The value returned by `hoverTooltip` now has an `active` property providing the state field used to store the open tooltips. ## 6.29.1 (2024-07-29) ### Bug fixes Fix a crash on old Safari browsers that don't support `MediaQueryList.addEventListener`. Fix an issue where `EditorView.viewportLineBlocks` (and thus other things like the gutter) might be out of date after some kinds of decoration changes. ## 6.29.0 (2024-07-25) ### Bug fixes Fix an issue that caused typing into an editor marked read-only to cause document changes when using `EditContext`. Associate a cursor created by clicking above the end of the text on a wrap point with the line before it. ### New features The package now exports the type of hover tooltip sources as `HoverTooltipSource`. ## 6.28.6 (2024-07-19) ### Bug fixes Fix an issue where the editor got confused about the position of inserted text when using Chrome's `EditContext` and canceling transactions for typed text. ## 6.28.5 (2024-07-17) ### Bug fixes Fix a bug that broke drag scrolling along one axis when the innermost scrollable element around the editor was only scrollable along the other axis. Work around a memory leak in Chrome's EditContext implementation. ## 6.28.4 (2024-07-03) ### Bug fixes Fix a bug where EditContext-based editing could corrupt the document in some situations. ## 6.28.3 (2024-07-01) ### Bug fixes Fix an issue causing the IME interface to appear in the wrong spot on Chrome Windows. ## 6.28.2 (2024-06-21) ### Bug fixes Only use `EditContext` on Chrome versions that support passing it an inverted selection range. Fix an issue that prevented non-inclusive block widgets from having their `updateDOM` method called when changed. Re-enable `EditContext` use on Chrome 126 and up. ## 6.28.1 (2024-06-12) ### Bug fixes Disable `EditContext` by default again, to work around a regression where Chrome's implementation doesn't support inverted selections. Make sure `EditorView.editable` is respected when `EditContext` is used. ## 6.28.0 (2024-06-10) ### Bug fixes Fix an issue where long lines broken up by block widgets were sometimes only partially rendered. ### New features The editor will now, when available (which is only on Chrome for the foreseeable future) use the [`EditContext`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext) API to capture text input. ## 6.27.0 (2024-06-04) ### New features The new `setTabFocusMode` method can be used to control whether the editor disables key bindings for Tab and Shift-Tab. ## 6.26.4 (2024-06-04) ### Bug fixes Fix an issue where commands with an optional second argument would get the keyboard event in that argument when called from a keymap. Fix an issue that could cause the cursor to be rendered on the wrong side of a zero-length block widget. Fix an issue where `drawSelection` got confused by block widgets in line-wrapped editors in some situations. Don't hide the native selection in widgets that have focus. Make sure that clicking an unfocusable editor still remove focus from any other focused elements. Fix a crash when loading the package in a non-browser environment. Stop mouse selection when the user types. ## 6.26.3 (2024-04-12) ### Bug fixes Fix an issue where dispatching an update to an editor before it measured itself for the first time could cause the scroll position to incorrectly move. Fix a crash when multiple tooltips with arrows are shown. ## 6.26.2 (2024-04-09) ### Bug fixes Improve behavior of `scrollPastEnd` in a scaled editor. When available, use `Selection.getComposedRanges` on Safari to find the selection inside a shadow DOM. Remove the workaround that avoided inappropriate styling on composed text after a decoration again, since it breaks the stock Android virtual keyboard. ## 6.26.1 (2024-03-28) ### Bug fixes Fix the editor getting stuck in composition when Safari fails to fire a compositionend event for a dead key composition. Fix an issue where, with IME systems that kept the cursor at the start of the composed text, the editor misidentified the target node and disrupted composition. Fix a bug where in a line-wrapped editor, with some content, the initial scroll position would be off from the top of the document. ## 6.26.0 (2024-03-14) ### Bug fixes Avoid the editor getting confused when iOS autocorrects on pressing Enter and does the correction and the break insertion in two different events. Fix the pasting of copied URIs in iOS. Fix a bug where a scaled editor could keep performing unnecessary updates due to tiny differences in geometry values returned by the browser. Fix a bug where, on iOS with a physical keyboard, the modifiers for some keys weren't being passed to the keymaps. Work around the fact that Mobile Safari makes DOM changes before firing a key event when typing ctrl-d on an external keyboard. Fix an issue where some commands didn't properly scroll the cursor into view on Mobile Safari. Re-measure the document when print settings are changed on Chrome. ### New features The `EditorView.scrollHandler` facet can be used to override or extend the behavior of the editor when things are scrolled into view. ## 6.25.1 (2024-03-06) ### Bug fixes Fix accidental non-optional field in layer config objects. ## 6.25.0 (2024-03-04) ### Bug fixes Properly recognize Android GBoard enter presses that strip a space at the end of the line as enter. Fix a bug that caused the gutter to have the wrong height when the editor was scaled after construction. When starting a composition after a non-inclusive mark decoration, temporarily insert a widget that prevents the composed text from inheriting that mark's styles. Make sure the selection is repositioned when a transaction changes decorations without changing the document. ### New features View plugins can now provide a `docViewUpdate` method that is called whenever the document view is updated. Layers now take a `updateOnDocUpdate` option that controls whether they are automatically updated when the document view changes. ## 6.24.1 (2024-02-19) ### Bug fixes Fix a crash that happens when hover tooltips are active during changes, introduced in 6.24.0. ## 6.24.0 (2024-02-09) ### Bug fixes Fix an issue that broke context-menu select-all on Chrome when the viewport didn't cover the whole document. Make sure tooltips are ordered by extension precedence in the DOM. ### New features Hover tooltip sources may now return multiple tooltips. ## 6.23.1 (2024-01-24) ### Bug fixes Fix a bug that caused `Tooltip.above` to not take effect for tooltips that were already present when the tooltip plugin is initialized. Automatically reposition tooltips when their size changes. ## 6.23.0 (2023-12-28) ### Bug fixes Work around odd iOS Safari behavior when doing select all. Fix a composition interruption when an widget is inserted next to the cursor. Fix a crash in bidirectional cursor motion. Simplify visual motion through bidirectional text, fix several corner cases where it would work badly. Fix a bug that broke some bidi isolates not on the first line of the document. ### New features `EditorView.bidiIsolatedRanges` now supports automatically determining the direction of the range if not provided by the decoration. `EditorView.visualLineSide` can be used to find the visual end or start of a line with bidirectional text. The new `EditorView.outerDecorations` facet can be used to provide decorations that should always be at the bottom of the precedence stack. ## 6.22.3 (2023-12-13) ### Bug fixes Fix a bug that could cause tooltips to be unnecessarily be positioned absolutely. Make sure that, when an editor creates tooltips immediately on initialization, the editor is attached to the document when their `mount` callback is called. ## 6.22.2 (2023-12-08) ### Bug fixes Fix an issue in the bidirectional motion that could cause the cursor to get stuck in a loop when a zero-width non-joiner char was placed on a direction boundary. Fix a bug that corrupts the editor's internal view tree data structure on some types of edits, putting the editor in a broken state. ## 6.22.1 (2023-11-27) ### Bug fixes Call widget `destroy` methods when the entire editor is destroyed or reset. Work around an issue on Safari on macOS Sonoma that made the native cursor visible even when `drawSelection` is enabled. Fix an issue where, on some browsers, the screenreader announced text ended up in the printed document. Fix a bug where a hover tooltip could stick around even though the pointer was no longer on the editor when it was moved out over the tooltip. Fix an issue where hover tooltips could close when moving the mouse onto them due to mouse position rounding issues. ## 6.22.0 (2023-11-03) ### Bug fixes Exceptions raised by update listeners are now routed to the configured exception sink, if any. Fix an issue where passing large scroll margins to `scrollIntoView` would cause the measure loop to fail to terminate. Widgets that are draggable (and allow drag events through in their `ignoreEvent` implementation) can now use the editor's built-in drag/drop behavior. ### New features The new `scrollTo` option to `EditorView` allows an initial scroll position to be provided. The new `EditorView.scrollSnapshot` method returns an effect that can be used to reset to a previous scroll position. ## 6.21.4 (2023-10-24) ### Bug fixes Support the `offset`, `getCoords`, `overlap`, and `resize` properties on hover tooltips, as long as they aren't given conflicting values when there are multiple active hover tooltips. Fix a bug that caused tooltips in the default configuration to be positioned incorrectly on Chrome when the editor was transformed. ## 6.21.3 (2023-10-06) ### Bug fixes Fix an issue that caused `coordsForChar` to return the wrong rectangle for characters after a line wrap in Safari. Make the context menu work when clicking below the content in a fixed-height editor. Tooltips that have been put below/above their target position because there is no room on their default side now stay there on further updates. ## 6.21.2 (2023-10-02) ### Bug fixes Fix a regression that broke dragging text from inside the editor. ## 6.21.1 (2023-10-02) ### Bug fixes Fix a bug that could corrupt the DOM view for specific changes involving newlines and mark decorations. ## 6.21.0 (2023-09-29) ### Bug fixes Fix a bug that could cause zero-length widgets at the start of a line to be left in the view even after they were removed. ### New features `RectangleMarker`'s dimension properties are now public. ## 6.20.2 (2023-09-25) ### Bug fixes Fix an issue in the way the DOM selection is being read that could break backspacing of widgets on Android. Fix a bug where the editor could incorrectly computate its transform scale when it was small. ## 6.20.1 (2023-09-22) ### Bug fixes Fix a crash in plugin event handlers after dynamic reconfiguration. Fix an issue where, on Chrome, tooltips would no longer use fixed positioning. ## 6.20.0 (2023-09-20) ### Bug fixes Fix an issue that caused `repositionTooltips` to crash when it was called on an editor without tooltips. Fix an issue that caused the tooltip system to leave empty nodes in the DOM when an editor using the `parent` option to `tooltips` is destroyed. Fix a bug that regression mouse interaction with the area of a fixed-size editor that isn't covered by the content. Fix some issues with the way `moveVertically` behaved for positions on line wrap points. Fix a bug that could cause the document DOM to be incorrectly updated on some types of viewport changes. ### New features The new `getDrawSelectionConfig` function returns the `drawSelection` configuration for a given state. ## 6.19.0 (2023-09-14) ### Bug fixes Make sure the drop cursor is properly cleaned up even when another extension handles the drop event. Fix a crash related to non-inclusive replacing block decorations. ### New features The new `EditorView.domEventObservers` (and the corresponding option to view plugins) allows you to register functions that are always called for an event, regardless of whether other handlers handled it. ## 6.18.1 (2023-09-11) ### Bug fixes Fix an issue where the editor duplicated text when the browser moved content into the focused text node on composition. Make sure `widgetMarker` is called for gutters on lines covered by a block replace decoration. Fix an issue where the cursor could be shown in a position that doesn't allow a cursor when the selection is in a block widget. ## 6.18.0 (2023-09-05) ### New features The new `EditorView.scaleX` and `scaleY` properties return the CSS-transformed scale of the editor (or 1 when not scaled). The editor now supports being scaled with CSS. ## 6.17.1 (2023-08-31) ### Bug fixes Don't close the hover tooltip when the pointer moves over empty space caused by line breaks within the hovered range. Fix a bug where on Chrome Android, if a virtual keyboard was slow to apply a change, the editor could end up dropping it. Work around an issue where line-wise copy/cut didn't work in Firefox because the browser wasn't firing those events when nothing was selected. Fix a crash triggered by the way some Android IME systems update the DOM. Fix a bug that caused replacing a word by an emoji on Chrome Android to be treated as a backspace press. ## 6.17.0 (2023-08-28) ### Bug fixes Fix a bug that broke hover tooltips when hovering over a widget. ### New features The new `EditorView.cspNonce` facet can be used to provide a Content Security Policy nonce for the library's generated CSS. The new `EditorView.bidiIsolatedRanges` can be used to inform the editor about ranges styled as Unicode bidirection isolates, so that it can compute the character order correctly. `EditorView.dispatch` now also accepts an array of transactions to be applied together in a single view update. The new `dispatchTransactions` option to `new EditorView` now replaces the old (deprecated but still supported) `dispatch` option in a way that allows multiple transactions to be applied in one update. Input handlers are now passed an additional argument that they can use to retrieve the default transaction that would be applied for the insertion. ## 6.16.0 (2023-07-31) ### Bug fixes Fix an issue that made the gutter not stick in place when the editor was in a right-to-left context. ### New features The new `EditorView.coordsForChar` method returns the client rectangle for a given character in the editor. ## 6.15.3 (2023-07-18) ### Bug fixes Fix another crash regression for compositions before line breaks. ## 6.15.2 (2023-07-18) ### Bug fixes Fix the check that made sure compositions are dropped when the selection is moved. ## 6.15.1 (2023-07-18) ### Bug fixes Fix a regression that could cause the composition content to be drawn incorrectly. ## 6.15.0 (2023-07-17) ### Bug fixes Fix dragging a selection from inside the current selection on macOS. Fix an issue that could cause the scroll position to jump wildly Don't try to scroll fixed-positioned elements into view by scrolling their parent elements. Fix a bug that caused the cursor to be hidden when showing a placeholder that consisted of the empty string. Resolve some issues where composition could incorrectly affect nearby replaced content. ### New features Key bindings can now set a `stopPropagation` field to cause the view to stop the key event propagation when it considers the event handled. ## 6.14.1 (2023-07-06) ### Bug fixes Fix an issue where scrolling up through line-wrapped text would sometimes cause the scroll position to pop down. Fix an issue where clicking wouldn't focus the editor on Firefox when it was in an iframe and already the active element of the frame. Fix a bug that could cause compositions to be disrupted because their surrounding DOM was repurposed for some other piece of content. Fix a bug where adding content to the editor could inappropriately move the scroll position. Extend detection of Enter presses on Android to `beforeInput` events with an `"insertLineBreak"` type. ## 6.14.0 (2023-06-23) ### Bug fixes When dragging text inside the editor, look at the state of Ctrl (or Alt on macOS) at the time of the drop, not the start of drag, to determine whether to move or copy the text. Fix an issue where having a bunch of padding on lines could cause vertical cursor motion and `posAtCoords` to jump over lines. ### New features Block widget decorations can now be given an `inlineOrder` option to make them appear in the same ordering as surrounding inline widgets. ## 6.13.2 (2023-06-13) ### Bug fixes Fix an issue in scroll position stabilization for changes above the visible, where Chrome already does this natively and we ended up compensating twice. ## 6.13.1 (2023-06-12) ### Bug fixes Fix a bug where the cursor would in some circumstances be drawn on the wrong side of an inline widget. Fix an issue where `scrollPastEnd` could cause the scroll position of editors that weren't in view to be changed unnecessarily. ## 6.13.0 (2023-06-05) ### Bug fixes Forbid widget decoration side values bigger than 10000, to prevent them from breaking range ordering invariants. Fix a bug where differences between widgets' estimated and actual heights could cause the editor to inappropriately move the scroll position. Avoid another situation in which composition that inserts line breaks could corrupt the editor DOM. ### New features Inline widgets may now introduce line breaks, if they report this through the `WidgetType.lineBreaks` property. ## 6.12.0 (2023-05-18) ### Bug fixes Remove an accidentally included `console.log`. ### New features `EditorViewConfig.dispatch` is now passed the view object as a second argument. ## 6.11.3 (2023-05-17) ### Bug fixes Make sure pointer selection respects `EditorView.atomicRanges`. Preserve DOM widgets when their decoration type changes but they otherwise stay in the same place. Fix a bug in `drawSelection` that could lead to invisible or incorrect selections for a blank line below a block widget. ## 6.11.2 (2023-05-13) ### Bug fixes Fix a bug where the `crosshairCursor` extension could, when non-native key events were fired, trigger disruptive and needless view updates. Fix an Android issue where backspacing at the front of a line with widget decorations could replace those decorations with their text content. Respect scroll margins when scrolling the target of drag-selection into view. Validate selection offsets reported by the browser, to work around Safari giving us invalid values in some cases. ## 6.11.1 (2023-05-09) ### Bug fixes Don't preserve the DOM around a composition that spans multiple lines. ## 6.11.0 (2023-05-03) ### New features Gutters now support a `widgetMarker` option that can be used to add markers next to block widgets. ## 6.10.1 (2023-05-01) ### Bug fixes Limit cursor height in front of custom placeholder DOM elements. ## 6.10.0 (2023-04-25) ### Bug fixes Fix a crash in `drawSelection` when a measured position falls on a position that doesn't have corresponding screen coordinates. Work around unhelpful interaction observer behavior that could cause the editor to not notice it was visible. Give the cursor next to a line-wrapped placeholder a single-line height. Make sure drop events below the editable element in a fixed-height editor get handled properly. ### New features Widget decorations can now define custom `coordsAtPos` methods to control the way the editor computes screen positions at or in the widget. ## 6.9.6 (2023-04-21) ### Bug fixes Fix an issue where, when escape was pressed followed by a key that the editor handled, followed by tab, the tab would still move focus. Fix an issue where, in some circumstances, the editor would ignore text changes at the end of a composition. Allow inline widgets to be updated to a different length via `updateDOM`. ## 6.9.5 (2023-04-17) ### Bug fixes Avoid disrupting the composition in specific cases where Safari invasively changes the DOM structure in the middle of a composition. Fix a bug that prevented `destroy` being called on hover tooltips. Fix a bug where the editor could take focus when content changes required it to restore the DOM selection. Fix height layout corruption caused by a division by zero. Make sure styles targeting the editor's focus status are specific enough to not cause them to apply to editors nested inside another focused editor. This will require themes to adjust their selection background styles to match the new specificity. ## 6.9.4 (2023-04-11) ### Bug fixes Make the editor scroll while dragging a selection near its sides, even if the cursor isn't outside the scrollable element. Fix a bug that interrupted composition after widgets in some circumstances on Firefox. Make sure the last change in a composition has its user event set to `input.type.compose`, even if the `compositionend` event fires before the changes are applied. Make it possible to remove additional selection ranges by clicking on them with ctrl/cmd held, even if they aren't cursors. Keep widget buffers between widgets and compositions, since removing them confuses IME on macOS Firefox. Fix a bug where, for DOM changes that put the selection in the middle of the changed range, the editor incorrectly set its selection state. Fix a bug where `coordsAtPos` could return a coordinates before the line break when querying a line-wrapped position with a positive `side`. ## 6.9.3 (2023-03-21) ### Bug fixes Work around a Firefox issue that caused `coordsAtPos` to return rectangles with the full line height on empty lines. Opening a context menu by clicking below the content element but inside the editor now properly shows the browser's menu for editable elements. Fix an issue that broke composition (especially of Chinese IME) after widget decorations. Fix an issue that would cause the cursor to jump around during compositions inside nested mark decorations. ## 6.9.2 (2023-03-08) ### Bug fixes Work around a Firefox CSS bug that caused cursors to stop blinking in a scrolled editor. Fix an issue in `drawSelection` where the selection extended into the editor's padding. Fix pasting of links copied from iOS share sheet. ## 6.9.1 (2023-02-17) ### Bug fixes Improve the way `posAtCoords` picks the side of a widget to return by comparing the coordinates the center of the widget. Fix an issue where transactions created for the `focusChangeEffect` facet were sometimes not dispatched. ## 6.9.0 (2023-02-15) ### Bug fixes Fix an issue where inaccurate estimated vertical positions could cause the viewport to not converge in line-wrapped editors. Don't suppress double-space to period conversion when autocorrect is enabled. Make sure the measuring code notices when the scaling of the editor is changed, and does a full measure in that case. ### New features The new `EditorView.focusChangeEffect` facet can be used to dispatch a state effect when the editor is focused or blurred. ## 6.8.1 (2023-02-08) ### Bug fixes Fix an issue where tooltips that have their height reduced have their height flicker when scrolling or otherwise interacting with the editor. ## 6.8.0 (2023-02-07) ### Bug fixes Fix a regression that caused clicking on the scrollbar to move the selection. Fix an issue where focus or blur event handlers that dispatched editor transactions could corrupt the mouse selection state. Fix a CSS regression that prevented the drop cursor from being positioned properly. ### New features `WidgetType.updateDOM` is now passed the editor view object. ## 6.7.3 (2023-01-12) ### Bug fixes Fix a bug in `posAtCoords` that could cause incorrect results for positions to the left of a wrapped line. ## 6.7.2 (2023-01-04) ### Bug fixes Fix a regression where the cursor didn't restart its blink cycle when moving it with the pointer. Even without a `key` property, measure request objects that are already scheduled will not be scheduled again by `requestMeasure`. Fix an issue where keymaps incorrectly interpreted key events that used Ctrl+Alt modifiers to simulate AltGr on Windows. Fix a bug where line decorations with a different `class` property would be treated as equal. Fix a bug that caused `drawSelection` to not notice when it was reconfigured. Fix a crash in the gutter extension caused by sharing of mutable arrays. Fix a regression that caused touch selection on mobile platforms to not work in an uneditable editor. Fix a bug where DOM events on the boundary between lines could get assigned to the wrong line. ## 6.7.1 (2022-12-12) ### Bug fixes Make the editor properly scroll when moving the pointer out of it during drag selection. Fix a regression where clicking below the content element in an editor with its own height didn't focus the editor. ## 6.7.0 (2022-12-07) ### Bug fixes Make the editor notice widget height changes to automatically adjust its height information. Fix an issue where widget buffers could be incorrectly omitted after empty lines. Fix an issue in content redrawing that could cause `coordsAtPos` to return incorrect results. ### New features The static `RectangleMarker.forRange` method exposes the logic used by the editor to draw rectangles covering a selection range. Layers can now provide a `destroy` function to be called when the layer is removed. The new `highlightWhitespace` extension makes spaces and tabs in the editor visible. The `highlightTrailingWhitespace` extension can be used to make trailing whitespace stand out. ## 6.6.0 (2022-11-24) ### New features The `layer` function can now be used to define extensions that draw DOM elements over or below the document text. Tooltips that are bigger than the available vertical space for them will now have their height set so that they don't stick out of the window. The new `resize` property on `TooltipView` can be used to opt out of this behavior. ## 6.5.1 (2022-11-15) ### Bug fixes Fix a bug that caused marked unnecessary splitting of mark decoration DOM elements in some cases. ## 6.5.0 (2022-11-14) ### Bug fixes Fix an issue where key bindings were activated for the wrong key in some situations with non-US keyboards. ### New features A tooltip's `positioned` callback is now passed the available space for tooltips. ## 6.4.2 (2022-11-10) ### Bug fixes Typing into a read-only editor no longer moves the cursor. Fix an issue where hover tooltips were closed when the mouse was moved over them if they had a custom parent element. Fix an issue where the editor could end up displaying incorrect height measurements (typically after initializing). ## 6.4.1 (2022-11-07) ### Bug fixes Fix an issue where coordinates next to replaced widgets were returned incorrectly, causing the cursor to be drawn in the wrong place. Update the `crosshairCursor` state on every mousemove event. Avoid an issue in the way that the editor enforces cursor associativity that could cause the cursor to get stuck on single-character wrapped lines. ## 6.4.0 (2022-10-18) ### Bug fixes Avoid an issue where `scrollPastEnd` makes a single-line editor have a vertical scrollbar. Work around a Chrome bug where it inserts a newline when you press space at the start of a wrapped line. Align `rectangularSelection`'s behavior with other popular editors by making it create cursors at the end of lines that are too short to touch the rectangle. Fix an issue where coordinates on mark decoration boundaries were sometimes taken from the wrong side of the position. Prevent scrolling artifacts caused by attempts to scroll stuff into view when the editor isn't being displayed. ### New features `TooltipView` objects can now provide a `destroy` method to be called when the tooltip is removed. ## 6.3.1 (2022-10-10) ### Bug fixes Fix a crash when trying to scroll something into view in an editor that wasn't in the visible DOM. Fix an issue where `coordsAtPos` returned the coordinates on the wrong side of a widget decoration wrapped in a mark decoration. Fix an issue where content on long wrapped lines could fail to properly scroll into view. Fix an issue where DOM change reading on Chrome Android could get confused when a transaction came in right after a beforeinput event for backspace, enter, or delete. ## 6.3.0 (2022-09-28) ### Bug fixes Reduce the amount of wrap-point jittering when scrolling through a very long wrapped line. Fix an issue where scrolling to content that wasn't currently drawn due to being on a very long line would often fail to scroll to the right position. Suppress double-space-adds-period behavior on Chrome Mac when it behaves weirdly next to widget. ### New features Key binding objects with an `any` property will now add handlers that are called for any key, within the ordering of the keybindings. ## 6.2.5 (2022-09-24) ### Bug fixes Don't override double/triple tap behavior on touch screen devices, so that the mobile selection menu pops up properly. Fix an issue where updating the selection could crash on Safari when the editor was hidden. ## 6.2.4 (2022-09-16) ### Bug fixes Highlight the active line even when there is a selection. Prevent the active line background from obscuring the selection backdrop. Fix an issue where elements with negative margins would confuse the editor's scrolling-into-view logic. Fix scrolling to a specific position in an editor that has not been in view yet. ## 6.2.3 (2022-09-08) ### Bug fixes Fix a bug where cursor motion, when starting from a non-empty selection range, could get stuck on atomic ranges in some circumstances. Avoid triggering Chrome Android's text-duplication issue when a period is typed in the middle of a word. ## 6.2.2 (2022-08-31) ### Bug fixes Don't reset the selection for selection change events that were suppressed by a node view. ## 6.2.1 (2022-08-25) ### Bug fixes Don't use the global `document` variable to track focus, since that doesn't work in another window/frame. Fix an issue where key handlers that didn't return true were sometimes called twice for the same keypress. Avoid editing glitches when using deletion keys like ctrl-d on iOS. Properly treat characters from the 'Arabic Presentation Forms-A' Unicode block as right-to-left. Work around a Firefox bug that inserts text at the wrong point for specific cross-line selections. ## 6.2.0 (2022-08-05) ### Bug fixes Fix a bug where `posAtCoords` would return the wrong results for positions to the right of wrapped lines. ### New features The new `EditorView.setRoot` method can be used when an editor view is moved to a new document or shadow root. ## 6.1.4 (2022-08-04) ### Bug fixes Make selection-restoration on focus more reliable. ## 6.1.3 (2022-08-03) ### Bug fixes Fix a bug where a document that contains only non-printing characters would lead to bogus text measurements (and, from those, to crashing). Make sure differences between estimated and actual block heights don't cause visible scroll glitches. ## 6.1.2 (2022-07-27) ### Bug fixes Fix an issue where double tapping enter to confirm IME input and insert a newline on iOS would sometimes insert two newlines. Fix an issue on iOS where a composition could get aborted if the editor scrolled on backspace. ## 6.1.1 (2022-07-25) ### Bug fixes Make `highlightSpecialChars` replace directional isolate characters by default. The editor will now try to suppress browsers' native behavior of resetting the selection in the editable content when the editable element is focused (programmatically, with tab, etc). Fix a CSS issue that made it possible, when the gutters were wide enough, for them to overlap with the content. ## 6.1.0 (2022-07-19) ### New features `MatchDecorator` now supports a `decorate` option that can be used to customize the way decorations are added for each match. ## 6.0.3 (2022-07-08) ### Bug fixes Fix a problem where `posAtCoords` could incorrectly return the start of the next line when querying positions between lines. Fix an issue where registering a high-precedence keymap made keymap handling take precedence over other keydown event handlers. Ctrl/Cmd-clicking can now remove ranges from a multi-range selection. ## 6.0.2 (2022-06-23) ### Bug fixes Fix a CSS issue that broke horizontal scroll width stabilization. Fix a bug where `defaultLineHeight` could get an incorrect value in very narrow editors. ## 6.0.1 (2022-06-17) ### Bug fixes Avoid DOM selection corruption when the editor doesn't have focus but has selection and updates its content. Fall back to dispatching by key code when a key event produces a non-ASCII character (so that Cyrillic and Arabic keyboards can still use bindings specified with Latin characters). ## 6.0.0 (2022-06-08) ### New features The new static `EditorView.findFromDOM` method can be used to retrieve an editor instance from its DOM structure. Instead of passing a constructed state to the `EditorView` constructor, it is now also possible to inline the configuration options to the state in the view config object. ## 0.20.7 (2022-05-30) ### Bug fixes Fix an issue on Chrome Android where the DOM could fail to display the actual document after backspace. Avoid an issue on Chrome Android where DOM changes were sometimes inappropriately replace by a backspace key effect due to spurious beforeinput events. Fix a problem where the content element's width didn't cover the width of the actual content. Work around a bug in Chrome 102 which caused wheel scrolling of the editor to be interrupted every few lines. ## 0.20.6 (2022-05-20) ### Bug fixes Make sure the editor re-measures itself when its attributes are updated. ## 0.20.5 (2022-05-18) ### Bug fixes Fix an issue where gutter elements without any markers in them would not get the `cm-gutterElement` class assigned. Fix an issue where DOM event handlers registered by plugins were retained indefinitely, even after the editor was reconfigured. ## 0.20.4 (2022-05-03) ### Bug fixes Prevent Mac-style behavior of inserting a period when the user inserts two spaces. Fix an issue where the editor would sometimes not restore the DOM selection when refocused