@codemirror/view 6.11.3 → 6.12.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 +10 -0
- package/dist/index.cjs +66 -66
- package/dist/index.d.ts +12 -12
- package/dist/index.js +66 -66
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -822,6 +822,9 @@ function textCoords(text, pos, side) {
|
|
|
822
822
|
}
|
|
823
823
|
// Also used for collapsed ranges that don't have a placeholder widget!
|
|
824
824
|
class WidgetView extends ContentView {
|
|
825
|
+
static create(widget, length, side) {
|
|
826
|
+
return new (widget.customView || WidgetView)(widget, length, side);
|
|
827
|
+
}
|
|
825
828
|
constructor(widget, length, side) {
|
|
826
829
|
super();
|
|
827
830
|
this.widget = widget;
|
|
@@ -829,9 +832,6 @@ class WidgetView extends ContentView {
|
|
|
829
832
|
this.side = side;
|
|
830
833
|
this.prevWidget = null;
|
|
831
834
|
}
|
|
832
|
-
static create(widget, length, side) {
|
|
833
|
-
return new (widget.customView || WidgetView)(widget, length, side);
|
|
834
|
-
}
|
|
835
835
|
split(from) {
|
|
836
836
|
let result = WidgetView.create(this.widget, this.length - from, this.side);
|
|
837
837
|
this.length -= from;
|
|
@@ -2216,6 +2216,10 @@ Represents a contiguous range of text that has a single direction
|
|
|
2216
2216
|
(as in left-to-right or right-to-left).
|
|
2217
2217
|
*/
|
|
2218
2218
|
class BidiSpan {
|
|
2219
|
+
/**
|
|
2220
|
+
The direction of this span.
|
|
2221
|
+
*/
|
|
2222
|
+
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2219
2223
|
/**
|
|
2220
2224
|
@internal
|
|
2221
2225
|
*/
|
|
@@ -2241,10 +2245,6 @@ class BidiSpan {
|
|
|
2241
2245
|
this.level = level;
|
|
2242
2246
|
}
|
|
2243
2247
|
/**
|
|
2244
|
-
The direction of this span.
|
|
2245
|
-
*/
|
|
2246
|
-
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2247
|
-
/**
|
|
2248
2248
|
@internal
|
|
2249
2249
|
*/
|
|
2250
2250
|
side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
|
|
@@ -2482,7 +2482,6 @@ class DOMReader {
|
|
|
2482
2482
|
constructor(points, state$1) {
|
|
2483
2483
|
this.points = points;
|
|
2484
2484
|
this.text = "";
|
|
2485
|
-
console.log("make reader");
|
|
2486
2485
|
this.lineSeparator = state$1.facet(state.EditorState.lineSeparator);
|
|
2487
2486
|
}
|
|
2488
2487
|
append(text) {
|
|
@@ -2586,6 +2585,7 @@ class DOMPoint {
|
|
|
2586
2585
|
}
|
|
2587
2586
|
|
|
2588
2587
|
class DocView extends ContentView {
|
|
2588
|
+
get length() { return this.view.state.doc.length; }
|
|
2589
2589
|
constructor(view) {
|
|
2590
2590
|
super();
|
|
2591
2591
|
this.view = view;
|
|
@@ -2616,7 +2616,6 @@ class DocView extends ContentView {
|
|
|
2616
2616
|
this.updateDeco();
|
|
2617
2617
|
this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
|
|
2618
2618
|
}
|
|
2619
|
-
get length() { return this.view.state.doc.length; }
|
|
2620
2619
|
// Update the document view to a given state. scrollIntoView can be
|
|
2621
2620
|
// used as a hint to compute a new viewport that includes that
|
|
2622
2621
|
// position, if we know the editor is going to scroll that position
|
|
@@ -3477,6 +3476,10 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3477
3476
|
|
|
3478
3477
|
// This will also be where dragging info and such goes
|
|
3479
3478
|
class InputState {
|
|
3479
|
+
setSelectionOrigin(origin) {
|
|
3480
|
+
this.lastSelectionOrigin = origin;
|
|
3481
|
+
this.lastSelectionTime = Date.now();
|
|
3482
|
+
}
|
|
3480
3483
|
constructor(view) {
|
|
3481
3484
|
this.lastKeyCode = 0;
|
|
3482
3485
|
this.lastKeyTime = 0;
|
|
@@ -3573,10 +3576,6 @@ class InputState {
|
|
|
3573
3576
|
if (browser.safari)
|
|
3574
3577
|
view.contentDOM.addEventListener("input", () => null);
|
|
3575
3578
|
}
|
|
3576
|
-
setSelectionOrigin(origin) {
|
|
3577
|
-
this.lastSelectionOrigin = origin;
|
|
3578
|
-
this.lastSelectionTime = Date.now();
|
|
3579
|
-
}
|
|
3580
3579
|
ensureHandlers(view, plugins) {
|
|
3581
3580
|
var _a;
|
|
3582
3581
|
let handlers;
|
|
@@ -6500,6 +6499,53 @@ line number gutter. It handles events and dispatches state
|
|
|
6500
6499
|
transactions for editing actions.
|
|
6501
6500
|
*/
|
|
6502
6501
|
class EditorView {
|
|
6502
|
+
/**
|
|
6503
|
+
The current editor state.
|
|
6504
|
+
*/
|
|
6505
|
+
get state() { return this.viewState.state; }
|
|
6506
|
+
/**
|
|
6507
|
+
To be able to display large documents without consuming too much
|
|
6508
|
+
memory or overloading the browser, CodeMirror only draws the
|
|
6509
|
+
code that is visible (plus a margin around it) to the DOM. This
|
|
6510
|
+
property tells you the extent of the current drawn viewport, in
|
|
6511
|
+
document positions.
|
|
6512
|
+
*/
|
|
6513
|
+
get viewport() { return this.viewState.viewport; }
|
|
6514
|
+
/**
|
|
6515
|
+
When there are, for example, large collapsed ranges in the
|
|
6516
|
+
viewport, its size can be a lot bigger than the actual visible
|
|
6517
|
+
content. Thus, if you are doing something like styling the
|
|
6518
|
+
content in the viewport, it is preferable to only do so for
|
|
6519
|
+
these ranges, which are the subset of the viewport that is
|
|
6520
|
+
actually drawn.
|
|
6521
|
+
*/
|
|
6522
|
+
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6523
|
+
/**
|
|
6524
|
+
Returns false when the editor is entirely scrolled out of view
|
|
6525
|
+
or otherwise hidden.
|
|
6526
|
+
*/
|
|
6527
|
+
get inView() { return this.viewState.inView; }
|
|
6528
|
+
/**
|
|
6529
|
+
Indicates whether the user is currently composing text via
|
|
6530
|
+
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6531
|
+
one change has been made in the current composition.
|
|
6532
|
+
*/
|
|
6533
|
+
get composing() { return this.inputState.composing > 0; }
|
|
6534
|
+
/**
|
|
6535
|
+
Indicates whether the user is currently in composing state. Note
|
|
6536
|
+
that on some platforms, like Android, this will be the case a
|
|
6537
|
+
lot, since just putting the cursor on a word starts a
|
|
6538
|
+
composition there.
|
|
6539
|
+
*/
|
|
6540
|
+
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6541
|
+
/**
|
|
6542
|
+
The document or shadow root that the view lives in.
|
|
6543
|
+
*/
|
|
6544
|
+
get root() { return this._root; }
|
|
6545
|
+
/**
|
|
6546
|
+
@internal
|
|
6547
|
+
*/
|
|
6548
|
+
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6503
6549
|
/**
|
|
6504
6550
|
Construct a new view. You'll want to either provide a `parent`
|
|
6505
6551
|
option, or put `view.dom` into your document after creating a
|
|
@@ -6553,56 +6599,10 @@ class EditorView {
|
|
|
6553
6599
|
if (config.parent)
|
|
6554
6600
|
config.parent.appendChild(this.dom);
|
|
6555
6601
|
}
|
|
6556
|
-
/**
|
|
6557
|
-
The current editor state.
|
|
6558
|
-
*/
|
|
6559
|
-
get state() { return this.viewState.state; }
|
|
6560
|
-
/**
|
|
6561
|
-
To be able to display large documents without consuming too much
|
|
6562
|
-
memory or overloading the browser, CodeMirror only draws the
|
|
6563
|
-
code that is visible (plus a margin around it) to the DOM. This
|
|
6564
|
-
property tells you the extent of the current drawn viewport, in
|
|
6565
|
-
document positions.
|
|
6566
|
-
*/
|
|
6567
|
-
get viewport() { return this.viewState.viewport; }
|
|
6568
|
-
/**
|
|
6569
|
-
When there are, for example, large collapsed ranges in the
|
|
6570
|
-
viewport, its size can be a lot bigger than the actual visible
|
|
6571
|
-
content. Thus, if you are doing something like styling the
|
|
6572
|
-
content in the viewport, it is preferable to only do so for
|
|
6573
|
-
these ranges, which are the subset of the viewport that is
|
|
6574
|
-
actually drawn.
|
|
6575
|
-
*/
|
|
6576
|
-
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6577
|
-
/**
|
|
6578
|
-
Returns false when the editor is entirely scrolled out of view
|
|
6579
|
-
or otherwise hidden.
|
|
6580
|
-
*/
|
|
6581
|
-
get inView() { return this.viewState.inView; }
|
|
6582
|
-
/**
|
|
6583
|
-
Indicates whether the user is currently composing text via
|
|
6584
|
-
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6585
|
-
one change has been made in the current composition.
|
|
6586
|
-
*/
|
|
6587
|
-
get composing() { return this.inputState.composing > 0; }
|
|
6588
|
-
/**
|
|
6589
|
-
Indicates whether the user is currently in composing state. Note
|
|
6590
|
-
that on some platforms, like Android, this will be the case a
|
|
6591
|
-
lot, since just putting the cursor on a word starts a
|
|
6592
|
-
composition there.
|
|
6593
|
-
*/
|
|
6594
|
-
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6595
|
-
/**
|
|
6596
|
-
The document or shadow root that the view lives in.
|
|
6597
|
-
*/
|
|
6598
|
-
get root() { return this._root; }
|
|
6599
|
-
/**
|
|
6600
|
-
@internal
|
|
6601
|
-
*/
|
|
6602
|
-
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6603
6602
|
dispatch(...input) {
|
|
6604
|
-
|
|
6605
|
-
: this.state.update(...input)
|
|
6603
|
+
let tr = input.length == 1 && input[0] instanceof state.Transaction ? input[0]
|
|
6604
|
+
: this.state.update(...input);
|
|
6605
|
+
this._dispatch(tr, this);
|
|
6606
6606
|
}
|
|
6607
6607
|
/**
|
|
6608
6608
|
Update the view for the given array of transactions. This will
|
|
@@ -8907,6 +8907,10 @@ const showTooltip = state.Facet.define({
|
|
|
8907
8907
|
});
|
|
8908
8908
|
const showHoverTooltip = state.Facet.define();
|
|
8909
8909
|
class HoverTooltipHost {
|
|
8910
|
+
// Needs to be static so that host tooltip instances always match
|
|
8911
|
+
static create(view) {
|
|
8912
|
+
return new HoverTooltipHost(view);
|
|
8913
|
+
}
|
|
8910
8914
|
constructor(view) {
|
|
8911
8915
|
this.view = view;
|
|
8912
8916
|
this.mounted = false;
|
|
@@ -8914,10 +8918,6 @@ class HoverTooltipHost {
|
|
|
8914
8918
|
this.dom.classList.add("cm-tooltip-hover");
|
|
8915
8919
|
this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
|
|
8916
8920
|
}
|
|
8917
|
-
// Needs to be static so that host tooltip instances always match
|
|
8918
|
-
static create(view) {
|
|
8919
|
-
return new HoverTooltipHost(view);
|
|
8920
|
-
}
|
|
8921
8921
|
createHostedView(tooltip) {
|
|
8922
8922
|
let hostedView = tooltip.create(this.view);
|
|
8923
8923
|
hostedView.dom.classList.add("cm-tooltip-section");
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _codemirror_state from '@codemirror/state';
|
|
|
2
2
|
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, EditorStateConfig, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
3
3
|
import { StyleModule, StyleSpec } from 'style-mod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Attrs = {
|
|
6
6
|
[name: string]: string;
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ interface Rect {
|
|
|
15
15
|
readonly top: number;
|
|
16
16
|
readonly bottom: number;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
type ScrollStrategy = "nearest" | "start" | "end" | "center";
|
|
19
19
|
|
|
20
20
|
interface MarkDecorationSpec {
|
|
21
21
|
/**
|
|
@@ -198,7 +198,7 @@ A decoration set represents a collection of decorated ranges,
|
|
|
198
198
|
organized for efficient access and mapping. See
|
|
199
199
|
[`RangeSet`](https://codemirror.net/6/docs/ref/#state.RangeSet) for its methods.
|
|
200
200
|
*/
|
|
201
|
-
|
|
201
|
+
type DecorationSet = RangeSet<Decoration>;
|
|
202
202
|
/**
|
|
203
203
|
The different types of blocks that can occur in an editor view.
|
|
204
204
|
*/
|
|
@@ -297,7 +297,7 @@ apply to the editor, and if it can, perform it as a side effect
|
|
|
297
297
|
(which usually means [dispatching](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) a
|
|
298
298
|
transaction) and return `true`.
|
|
299
299
|
*/
|
|
300
|
-
|
|
300
|
+
type Command = (target: EditorView) => boolean;
|
|
301
301
|
/**
|
|
302
302
|
Log or report an unhandled exception in client code. Should
|
|
303
303
|
probably only be used by extension code that allows client code to
|
|
@@ -399,7 +399,7 @@ interface MeasureRequest<T> {
|
|
|
399
399
|
*/
|
|
400
400
|
key?: any;
|
|
401
401
|
}
|
|
402
|
-
|
|
402
|
+
type AttrSource = Attrs | ((view: EditorView) => Attrs | null);
|
|
403
403
|
/**
|
|
404
404
|
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
405
405
|
class, which describe what happened, whenever the view is updated.
|
|
@@ -488,7 +488,7 @@ interface MouseSelectionStyle {
|
|
|
488
488
|
*/
|
|
489
489
|
update: (update: ViewUpdate) => boolean | void;
|
|
490
490
|
}
|
|
491
|
-
|
|
491
|
+
type MakeSelectionStyle = (view: EditorView, event: MouseEvent) => MouseSelectionStyle | null;
|
|
492
492
|
|
|
493
493
|
/**
|
|
494
494
|
Record used to represent information about a block-level element
|
|
@@ -605,7 +605,7 @@ interface EditorViewConfig extends EditorStateConfig {
|
|
|
605
605
|
if provided, should probably call the view's [`update`
|
|
606
606
|
method](https://codemirror.net/6/docs/ref/#view.EditorView.update).
|
|
607
607
|
*/
|
|
608
|
-
dispatch?: (tr: Transaction) => void;
|
|
608
|
+
dispatch?: (tr: Transaction, view: EditorView) => void;
|
|
609
609
|
}
|
|
610
610
|
/**
|
|
611
611
|
An editor view represents the editor's user interface. It holds
|
|
@@ -1183,7 +1183,7 @@ to hold the appropriate event object type. For unknown events, it
|
|
|
1183
1183
|
is inferred to `any`, and should be explicitly set if you want type
|
|
1184
1184
|
checking.
|
|
1185
1185
|
*/
|
|
1186
|
-
|
|
1186
|
+
type DOMEventHandlers<This> = {
|
|
1187
1187
|
[event in keyof DOMEventMap]?: (this: This, event: DOMEventMap[event], view: EditorView) => boolean | void;
|
|
1188
1188
|
};
|
|
1189
1189
|
|
|
@@ -1285,7 +1285,7 @@ handlers handled it.
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
declare function runScopeHandlers(view: EditorView, event: KeyboardEvent, scope: string): boolean;
|
|
1287
1287
|
|
|
1288
|
-
|
|
1288
|
+
type SelectionConfig = {
|
|
1289
1289
|
/**
|
|
1290
1290
|
The length of a full cursor blink cycle, in milliseconds.
|
|
1291
1291
|
Defaults to 1200. Can be set to 0 to disable blinking.
|
|
@@ -1751,7 +1751,7 @@ invalidate the existing tooltip positions.
|
|
|
1751
1751
|
*/
|
|
1752
1752
|
declare function repositionTooltips(view: EditorView): void;
|
|
1753
1753
|
|
|
1754
|
-
|
|
1754
|
+
type PanelConfig = {
|
|
1755
1755
|
/**
|
|
1756
1756
|
By default, panels will be placed inside the editor's DOM
|
|
1757
1757
|
structure. You can use this option to override where panels with
|
|
@@ -1805,7 +1805,7 @@ declare function getPanel(view: EditorView, panel: PanelConstructor): Panel | nu
|
|
|
1805
1805
|
A function that initializes a panel. Used in
|
|
1806
1806
|
[`showPanel`](https://codemirror.net/6/docs/ref/#view.showPanel).
|
|
1807
1807
|
*/
|
|
1808
|
-
|
|
1808
|
+
type PanelConstructor = (view: EditorView) => Panel;
|
|
1809
1809
|
/**
|
|
1810
1810
|
Opening a panel is done by providing a constructor function for
|
|
1811
1811
|
the panel through this facet. (The panel is closed again when its
|
|
@@ -1846,7 +1846,7 @@ Markers given to this facet should _only_ define an
|
|
|
1846
1846
|
in all gutters for the line).
|
|
1847
1847
|
*/
|
|
1848
1848
|
declare const gutterLineClass: Facet<RangeSet<GutterMarker>, readonly RangeSet<GutterMarker>[]>;
|
|
1849
|
-
|
|
1849
|
+
type Handlers = {
|
|
1850
1850
|
[event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
|
|
1851
1851
|
};
|
|
1852
1852
|
interface GutterConfig {
|
package/dist/index.js
CHANGED
|
@@ -818,6 +818,9 @@ function textCoords(text, pos, side) {
|
|
|
818
818
|
}
|
|
819
819
|
// Also used for collapsed ranges that don't have a placeholder widget!
|
|
820
820
|
class WidgetView extends ContentView {
|
|
821
|
+
static create(widget, length, side) {
|
|
822
|
+
return new (widget.customView || WidgetView)(widget, length, side);
|
|
823
|
+
}
|
|
821
824
|
constructor(widget, length, side) {
|
|
822
825
|
super();
|
|
823
826
|
this.widget = widget;
|
|
@@ -825,9 +828,6 @@ class WidgetView extends ContentView {
|
|
|
825
828
|
this.side = side;
|
|
826
829
|
this.prevWidget = null;
|
|
827
830
|
}
|
|
828
|
-
static create(widget, length, side) {
|
|
829
|
-
return new (widget.customView || WidgetView)(widget, length, side);
|
|
830
|
-
}
|
|
831
831
|
split(from) {
|
|
832
832
|
let result = WidgetView.create(this.widget, this.length - from, this.side);
|
|
833
833
|
this.length -= from;
|
|
@@ -2210,6 +2210,10 @@ Represents a contiguous range of text that has a single direction
|
|
|
2210
2210
|
(as in left-to-right or right-to-left).
|
|
2211
2211
|
*/
|
|
2212
2212
|
class BidiSpan {
|
|
2213
|
+
/**
|
|
2214
|
+
The direction of this span.
|
|
2215
|
+
*/
|
|
2216
|
+
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2213
2217
|
/**
|
|
2214
2218
|
@internal
|
|
2215
2219
|
*/
|
|
@@ -2235,10 +2239,6 @@ class BidiSpan {
|
|
|
2235
2239
|
this.level = level;
|
|
2236
2240
|
}
|
|
2237
2241
|
/**
|
|
2238
|
-
The direction of this span.
|
|
2239
|
-
*/
|
|
2240
|
-
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2241
|
-
/**
|
|
2242
2242
|
@internal
|
|
2243
2243
|
*/
|
|
2244
2244
|
side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
|
|
@@ -2476,7 +2476,6 @@ class DOMReader {
|
|
|
2476
2476
|
constructor(points, state) {
|
|
2477
2477
|
this.points = points;
|
|
2478
2478
|
this.text = "";
|
|
2479
|
-
console.log("make reader");
|
|
2480
2479
|
this.lineSeparator = state.facet(EditorState.lineSeparator);
|
|
2481
2480
|
}
|
|
2482
2481
|
append(text) {
|
|
@@ -2580,6 +2579,7 @@ class DOMPoint {
|
|
|
2580
2579
|
}
|
|
2581
2580
|
|
|
2582
2581
|
class DocView extends ContentView {
|
|
2582
|
+
get length() { return this.view.state.doc.length; }
|
|
2583
2583
|
constructor(view) {
|
|
2584
2584
|
super();
|
|
2585
2585
|
this.view = view;
|
|
@@ -2610,7 +2610,6 @@ class DocView extends ContentView {
|
|
|
2610
2610
|
this.updateDeco();
|
|
2611
2611
|
this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
|
|
2612
2612
|
}
|
|
2613
|
-
get length() { return this.view.state.doc.length; }
|
|
2614
2613
|
// Update the document view to a given state. scrollIntoView can be
|
|
2615
2614
|
// used as a hint to compute a new viewport that includes that
|
|
2616
2615
|
// position, if we know the editor is going to scroll that position
|
|
@@ -3471,6 +3470,10 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3471
3470
|
|
|
3472
3471
|
// This will also be where dragging info and such goes
|
|
3473
3472
|
class InputState {
|
|
3473
|
+
setSelectionOrigin(origin) {
|
|
3474
|
+
this.lastSelectionOrigin = origin;
|
|
3475
|
+
this.lastSelectionTime = Date.now();
|
|
3476
|
+
}
|
|
3474
3477
|
constructor(view) {
|
|
3475
3478
|
this.lastKeyCode = 0;
|
|
3476
3479
|
this.lastKeyTime = 0;
|
|
@@ -3567,10 +3570,6 @@ class InputState {
|
|
|
3567
3570
|
if (browser.safari)
|
|
3568
3571
|
view.contentDOM.addEventListener("input", () => null);
|
|
3569
3572
|
}
|
|
3570
|
-
setSelectionOrigin(origin) {
|
|
3571
|
-
this.lastSelectionOrigin = origin;
|
|
3572
|
-
this.lastSelectionTime = Date.now();
|
|
3573
|
-
}
|
|
3574
3573
|
ensureHandlers(view, plugins) {
|
|
3575
3574
|
var _a;
|
|
3576
3575
|
let handlers;
|
|
@@ -6493,6 +6492,53 @@ line number gutter. It handles events and dispatches state
|
|
|
6493
6492
|
transactions for editing actions.
|
|
6494
6493
|
*/
|
|
6495
6494
|
class EditorView {
|
|
6495
|
+
/**
|
|
6496
|
+
The current editor state.
|
|
6497
|
+
*/
|
|
6498
|
+
get state() { return this.viewState.state; }
|
|
6499
|
+
/**
|
|
6500
|
+
To be able to display large documents without consuming too much
|
|
6501
|
+
memory or overloading the browser, CodeMirror only draws the
|
|
6502
|
+
code that is visible (plus a margin around it) to the DOM. This
|
|
6503
|
+
property tells you the extent of the current drawn viewport, in
|
|
6504
|
+
document positions.
|
|
6505
|
+
*/
|
|
6506
|
+
get viewport() { return this.viewState.viewport; }
|
|
6507
|
+
/**
|
|
6508
|
+
When there are, for example, large collapsed ranges in the
|
|
6509
|
+
viewport, its size can be a lot bigger than the actual visible
|
|
6510
|
+
content. Thus, if you are doing something like styling the
|
|
6511
|
+
content in the viewport, it is preferable to only do so for
|
|
6512
|
+
these ranges, which are the subset of the viewport that is
|
|
6513
|
+
actually drawn.
|
|
6514
|
+
*/
|
|
6515
|
+
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6516
|
+
/**
|
|
6517
|
+
Returns false when the editor is entirely scrolled out of view
|
|
6518
|
+
or otherwise hidden.
|
|
6519
|
+
*/
|
|
6520
|
+
get inView() { return this.viewState.inView; }
|
|
6521
|
+
/**
|
|
6522
|
+
Indicates whether the user is currently composing text via
|
|
6523
|
+
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6524
|
+
one change has been made in the current composition.
|
|
6525
|
+
*/
|
|
6526
|
+
get composing() { return this.inputState.composing > 0; }
|
|
6527
|
+
/**
|
|
6528
|
+
Indicates whether the user is currently in composing state. Note
|
|
6529
|
+
that on some platforms, like Android, this will be the case a
|
|
6530
|
+
lot, since just putting the cursor on a word starts a
|
|
6531
|
+
composition there.
|
|
6532
|
+
*/
|
|
6533
|
+
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6534
|
+
/**
|
|
6535
|
+
The document or shadow root that the view lives in.
|
|
6536
|
+
*/
|
|
6537
|
+
get root() { return this._root; }
|
|
6538
|
+
/**
|
|
6539
|
+
@internal
|
|
6540
|
+
*/
|
|
6541
|
+
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6496
6542
|
/**
|
|
6497
6543
|
Construct a new view. You'll want to either provide a `parent`
|
|
6498
6544
|
option, or put `view.dom` into your document after creating a
|
|
@@ -6546,56 +6592,10 @@ class EditorView {
|
|
|
6546
6592
|
if (config.parent)
|
|
6547
6593
|
config.parent.appendChild(this.dom);
|
|
6548
6594
|
}
|
|
6549
|
-
/**
|
|
6550
|
-
The current editor state.
|
|
6551
|
-
*/
|
|
6552
|
-
get state() { return this.viewState.state; }
|
|
6553
|
-
/**
|
|
6554
|
-
To be able to display large documents without consuming too much
|
|
6555
|
-
memory or overloading the browser, CodeMirror only draws the
|
|
6556
|
-
code that is visible (plus a margin around it) to the DOM. This
|
|
6557
|
-
property tells you the extent of the current drawn viewport, in
|
|
6558
|
-
document positions.
|
|
6559
|
-
*/
|
|
6560
|
-
get viewport() { return this.viewState.viewport; }
|
|
6561
|
-
/**
|
|
6562
|
-
When there are, for example, large collapsed ranges in the
|
|
6563
|
-
viewport, its size can be a lot bigger than the actual visible
|
|
6564
|
-
content. Thus, if you are doing something like styling the
|
|
6565
|
-
content in the viewport, it is preferable to only do so for
|
|
6566
|
-
these ranges, which are the subset of the viewport that is
|
|
6567
|
-
actually drawn.
|
|
6568
|
-
*/
|
|
6569
|
-
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6570
|
-
/**
|
|
6571
|
-
Returns false when the editor is entirely scrolled out of view
|
|
6572
|
-
or otherwise hidden.
|
|
6573
|
-
*/
|
|
6574
|
-
get inView() { return this.viewState.inView; }
|
|
6575
|
-
/**
|
|
6576
|
-
Indicates whether the user is currently composing text via
|
|
6577
|
-
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6578
|
-
one change has been made in the current composition.
|
|
6579
|
-
*/
|
|
6580
|
-
get composing() { return this.inputState.composing > 0; }
|
|
6581
|
-
/**
|
|
6582
|
-
Indicates whether the user is currently in composing state. Note
|
|
6583
|
-
that on some platforms, like Android, this will be the case a
|
|
6584
|
-
lot, since just putting the cursor on a word starts a
|
|
6585
|
-
composition there.
|
|
6586
|
-
*/
|
|
6587
|
-
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6588
|
-
/**
|
|
6589
|
-
The document or shadow root that the view lives in.
|
|
6590
|
-
*/
|
|
6591
|
-
get root() { return this._root; }
|
|
6592
|
-
/**
|
|
6593
|
-
@internal
|
|
6594
|
-
*/
|
|
6595
|
-
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6596
6595
|
dispatch(...input) {
|
|
6597
|
-
|
|
6598
|
-
: this.state.update(...input)
|
|
6596
|
+
let tr = input.length == 1 && input[0] instanceof Transaction ? input[0]
|
|
6597
|
+
: this.state.update(...input);
|
|
6598
|
+
this._dispatch(tr, this);
|
|
6599
6599
|
}
|
|
6600
6600
|
/**
|
|
6601
6601
|
Update the view for the given array of transactions. This will
|
|
@@ -8900,6 +8900,10 @@ const showTooltip = /*@__PURE__*/Facet.define({
|
|
|
8900
8900
|
});
|
|
8901
8901
|
const showHoverTooltip = /*@__PURE__*/Facet.define();
|
|
8902
8902
|
class HoverTooltipHost {
|
|
8903
|
+
// Needs to be static so that host tooltip instances always match
|
|
8904
|
+
static create(view) {
|
|
8905
|
+
return new HoverTooltipHost(view);
|
|
8906
|
+
}
|
|
8903
8907
|
constructor(view) {
|
|
8904
8908
|
this.view = view;
|
|
8905
8909
|
this.mounted = false;
|
|
@@ -8907,10 +8911,6 @@ class HoverTooltipHost {
|
|
|
8907
8911
|
this.dom.classList.add("cm-tooltip-hover");
|
|
8908
8912
|
this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
|
|
8909
8913
|
}
|
|
8910
|
-
// Needs to be static so that host tooltip instances always match
|
|
8911
|
-
static create(view) {
|
|
8912
|
-
return new HoverTooltipHost(view);
|
|
8913
|
-
}
|
|
8914
8914
|
createHostedView(tooltip) {
|
|
8915
8915
|
let hostedView = tooltip.create(this.view);
|
|
8916
8916
|
hostedView.dom.classList.add("cm-tooltip-section");
|