@codemirror/view 6.28.6 → 6.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +9 -8
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +9 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.29.0 (2024-07-25)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue that caused typing into an editor marked read-only to cause document changes when using `EditContext`.
|
|
6
|
+
|
|
7
|
+
Associate a cursor created by clicking above the end of the text on a wrap point with the line before it.
|
|
8
|
+
|
|
9
|
+
### New features
|
|
10
|
+
|
|
11
|
+
The package now exports the type of hover tooltip sources as `HoverTooltipSource`.
|
|
12
|
+
|
|
1
13
|
## 6.28.6 (2024-07-19)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -4252,8 +4252,7 @@ function rangeForClick(view, pos, bias, type) {
|
|
|
4252
4252
|
return state.EditorSelection.range(from, to);
|
|
4253
4253
|
}
|
|
4254
4254
|
}
|
|
4255
|
-
let
|
|
4256
|
-
let inside = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;
|
|
4255
|
+
let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
|
|
4257
4256
|
// Try to determine, for the given coordinates, associated with the
|
|
4258
4257
|
// given position, whether they are related to the element before or
|
|
4259
4258
|
// the element after the position.
|
|
@@ -4275,8 +4274,8 @@ function findPositionSide(view, pos, x, y) {
|
|
|
4275
4274
|
if (after && inside(x, y, after))
|
|
4276
4275
|
return 1;
|
|
4277
4276
|
// This is probably a line wrap point. Pick before if the point is
|
|
4278
|
-
//
|
|
4279
|
-
return before &&
|
|
4277
|
+
// above its bottom.
|
|
4278
|
+
return before && before.bottom >= y ? -1 : 1;
|
|
4280
4279
|
}
|
|
4281
4280
|
function queryPos(view, event) {
|
|
4282
4281
|
let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
|
|
@@ -7123,7 +7122,8 @@ class EditContextManager {
|
|
|
7123
7122
|
if (change.from == change.to && !change.insert.length)
|
|
7124
7123
|
return;
|
|
7125
7124
|
this.pendingContextChange = change;
|
|
7126
|
-
|
|
7125
|
+
if (!view.state.readOnly)
|
|
7126
|
+
applyDOMChangeInner(view, change, state.EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd)));
|
|
7127
7127
|
// If the transaction didn't flush our change, revert it so
|
|
7128
7128
|
// that the context is in sync with the editor state again.
|
|
7129
7129
|
if (this.pendingContextChange) {
|
|
@@ -9866,9 +9866,10 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
9866
9866
|
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
9867
9867
|
let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
|
|
9868
9868
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == exports.Direction.LTR;
|
|
9869
|
-
let left = size.width > space.right - space.left
|
|
9870
|
-
|
|
9871
|
-
|
|
9869
|
+
let left = size.width > space.right - space.left
|
|
9870
|
+
? (ltr ? space.left : space.right - size.width)
|
|
9871
|
+
: ltr ? Math.max(space.left, Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width))
|
|
9872
|
+
: Math.min(Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x), space.right - width);
|
|
9872
9873
|
let above = this.above[i];
|
|
9873
9874
|
if (!tooltip.strictSide && (above
|
|
9874
9875
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
package/dist/index.d.cts
CHANGED
|
@@ -1931,7 +1931,11 @@ interface TooltipView {
|
|
|
1931
1931
|
Facet to which an extension can add a value to show a tooltip.
|
|
1932
1932
|
*/
|
|
1933
1933
|
declare const showTooltip: Facet<Tooltip | null, readonly (Tooltip | null)[]>;
|
|
1934
|
-
|
|
1934
|
+
/**
|
|
1935
|
+
The type of function that can be used as a [hover tooltip
|
|
1936
|
+
source](https://codemirror.net/6/docs/ref/#view.hoverTooltip^source).
|
|
1937
|
+
*/
|
|
1938
|
+
type HoverTooltipSource = (view: EditorView, pos: number, side: -1 | 1) => Tooltip | readonly Tooltip[] | null | Promise<Tooltip | readonly Tooltip[] | null>;
|
|
1935
1939
|
/**
|
|
1936
1940
|
Set up a hover tooltip, which shows up when the pointer hovers
|
|
1937
1941
|
over ranges of text. The callback is called when the mouse hovers
|
|
@@ -1945,7 +1949,7 @@ Note that all hover tooltips are hosted within a single tooltip
|
|
|
1945
1949
|
container element. This allows multiple tooltips over the same
|
|
1946
1950
|
range to be "merged" together without overlapping.
|
|
1947
1951
|
*/
|
|
1948
|
-
declare function hoverTooltip(source:
|
|
1952
|
+
declare function hoverTooltip(source: HoverTooltipSource, options?: {
|
|
1949
1953
|
/**
|
|
1950
1954
|
Controls whether a transaction hides the tooltip. The default
|
|
1951
1955
|
is to not hide.
|
|
@@ -2180,4 +2184,4 @@ trailing whitespace.
|
|
|
2180
2184
|
*/
|
|
2181
2185
|
declare function highlightTrailingWhitespace(): Extension;
|
|
2182
2186
|
|
|
2183
|
-
export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
|
2187
|
+
export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type HoverTooltipSource, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
package/dist/index.d.ts
CHANGED
|
@@ -1931,7 +1931,11 @@ interface TooltipView {
|
|
|
1931
1931
|
Facet to which an extension can add a value to show a tooltip.
|
|
1932
1932
|
*/
|
|
1933
1933
|
declare const showTooltip: Facet<Tooltip | null, readonly (Tooltip | null)[]>;
|
|
1934
|
-
|
|
1934
|
+
/**
|
|
1935
|
+
The type of function that can be used as a [hover tooltip
|
|
1936
|
+
source](https://codemirror.net/6/docs/ref/#view.hoverTooltip^source).
|
|
1937
|
+
*/
|
|
1938
|
+
type HoverTooltipSource = (view: EditorView, pos: number, side: -1 | 1) => Tooltip | readonly Tooltip[] | null | Promise<Tooltip | readonly Tooltip[] | null>;
|
|
1935
1939
|
/**
|
|
1936
1940
|
Set up a hover tooltip, which shows up when the pointer hovers
|
|
1937
1941
|
over ranges of text. The callback is called when the mouse hovers
|
|
@@ -1945,7 +1949,7 @@ Note that all hover tooltips are hosted within a single tooltip
|
|
|
1945
1949
|
container element. This allows multiple tooltips over the same
|
|
1946
1950
|
range to be "merged" together without overlapping.
|
|
1947
1951
|
*/
|
|
1948
|
-
declare function hoverTooltip(source:
|
|
1952
|
+
declare function hoverTooltip(source: HoverTooltipSource, options?: {
|
|
1949
1953
|
/**
|
|
1950
1954
|
Controls whether a transaction hides the tooltip. The default
|
|
1951
1955
|
is to not hide.
|
|
@@ -2180,4 +2184,4 @@ trailing whitespace.
|
|
|
2180
2184
|
*/
|
|
2181
2185
|
declare function highlightTrailingWhitespace(): Extension;
|
|
2182
2186
|
|
|
2183
|
-
export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
|
2187
|
+
export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type HoverTooltipSource, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
package/dist/index.js
CHANGED
|
@@ -4248,8 +4248,7 @@ function rangeForClick(view, pos, bias, type) {
|
|
|
4248
4248
|
return EditorSelection.range(from, to);
|
|
4249
4249
|
}
|
|
4250
4250
|
}
|
|
4251
|
-
let
|
|
4252
|
-
let inside = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;
|
|
4251
|
+
let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
|
|
4253
4252
|
// Try to determine, for the given coordinates, associated with the
|
|
4254
4253
|
// given position, whether they are related to the element before or
|
|
4255
4254
|
// the element after the position.
|
|
@@ -4271,8 +4270,8 @@ function findPositionSide(view, pos, x, y) {
|
|
|
4271
4270
|
if (after && inside(x, y, after))
|
|
4272
4271
|
return 1;
|
|
4273
4272
|
// This is probably a line wrap point. Pick before if the point is
|
|
4274
|
-
//
|
|
4275
|
-
return before &&
|
|
4273
|
+
// above its bottom.
|
|
4274
|
+
return before && before.bottom >= y ? -1 : 1;
|
|
4276
4275
|
}
|
|
4277
4276
|
function queryPos(view, event) {
|
|
4278
4277
|
let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
|
|
@@ -7118,7 +7117,8 @@ class EditContextManager {
|
|
|
7118
7117
|
if (change.from == change.to && !change.insert.length)
|
|
7119
7118
|
return;
|
|
7120
7119
|
this.pendingContextChange = change;
|
|
7121
|
-
|
|
7120
|
+
if (!view.state.readOnly)
|
|
7121
|
+
applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd)));
|
|
7122
7122
|
// If the transaction didn't flush our change, revert it so
|
|
7123
7123
|
// that the context is in sync with the editor state again.
|
|
7124
7124
|
if (this.pendingContextChange) {
|
|
@@ -9861,9 +9861,10 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9861
9861
|
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
9862
9862
|
let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
|
|
9863
9863
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
|
|
9864
|
-
let left = size.width > space.right - space.left
|
|
9865
|
-
|
|
9866
|
-
|
|
9864
|
+
let left = size.width > space.right - space.left
|
|
9865
|
+
? (ltr ? space.left : space.right - size.width)
|
|
9866
|
+
: ltr ? Math.max(space.left, Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width))
|
|
9867
|
+
: Math.min(Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x), space.right - width);
|
|
9867
9868
|
let above = this.above[i];
|
|
9868
9869
|
if (!tooltip.strictSide && (above
|
|
9869
9870
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|