chrome-devtools-frontend 1.0.945579 → 1.0.946920
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/config/gni/all_devtools_files.gni +0 -7
- package/config/gni/devtools_grd_files.gni +3 -39
- package/front_end/core/host/InspectorFrontendHostAPI.ts +0 -1
- package/front_end/core/host/UserMetrics.ts +0 -22
- package/front_end/core/i18n/locales/en-US.json +33 -27
- package/front_end/core/i18n/locales/en-XL.json +33 -27
- package/front_end/core/root/Runtime.ts +0 -1
- package/front_end/core/sdk/CSSProperty.ts +16 -9
- package/front_end/core/sdk/sdk-meta.ts +20 -8
- package/front_end/devtools_compatibility.js +1 -8
- package/front_end/entrypoints/devtools_app/devtools_app.js +3 -0
- package/front_end/entrypoints/devtools_app/devtools_app.json +1 -2
- package/front_end/entrypoints/formatter_worker/CSSFormatter.ts +1 -3
- package/front_end/entrypoints/formatter_worker/FormatterActions.ts +0 -2
- package/front_end/entrypoints/formatter_worker/FormatterWorker.ts +0 -120
- package/front_end/entrypoints/formatter_worker/formatter_worker-entrypoint.ts +1 -11
- package/front_end/entrypoints/formatter_worker/formatter_worker.ts +5 -0
- package/front_end/entrypoints/js_app/js_app.js +3 -0
- package/front_end/entrypoints/js_app/js_app.json +1 -2
- package/front_end/entrypoints/main/MainImpl.ts +0 -6
- package/front_end/entrypoints/ndb_app/ndb_app.js +3 -0
- package/front_end/entrypoints/ndb_app/ndb_app.json +1 -2
- package/front_end/entrypoints/{node_main → node_app}/NodeConnectionsPanel.ts +1 -1
- package/front_end/entrypoints/{node_main → node_app}/NodeMain.ts +2 -4
- package/front_end/entrypoints/{node_main → node_app}/nodeConnectionsPanel.css +0 -0
- package/front_end/entrypoints/node_app/node_app.ts +81 -0
- package/front_end/entrypoints/shell/shell.js +18 -1
- package/front_end/entrypoints/worker_app/worker_app.js +3 -0
- package/front_end/entrypoints/worker_app/worker_app.json +1 -2
- package/front_end/legacy_test_runner/sources_test_runner/sources_test_runner.js +0 -1
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +1 -1
- package/front_end/models/bindings/ResourceMapping.ts +1 -1
- package/front_end/models/formatter/FormatterWorkerPool.ts +0 -18
- package/front_end/models/text_utils/CodeMirrorUtils.ts +6 -51
- package/front_end/models/text_utils/TextUtils.ts +1 -2
- package/front_end/models/text_utils/text_utils-legacy.ts +0 -5
- package/front_end/panels/animation/AnimationTimeline.ts +1 -1
- package/front_end/panels/application/ApplicationPanelSidebar.ts +2 -4
- package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +0 -11
- package/front_end/panels/elements/StylesSidebarPane.ts +0 -1
- package/front_end/panels/elements/elementsTreeOutline.css +0 -13
- package/front_end/panels/emulation/DeviceModeToolbar.ts +0 -16
- package/front_end/panels/network/NetworkConfigView.ts +10 -0
- package/front_end/panels/network/NetworkItemView.ts +10 -1
- package/front_end/panels/network/networkConfigView.css +5 -0
- package/front_end/panels/profiler/heapProfiler.css +2 -5
- package/front_end/panels/profiler/profilesPanel.css +1 -1
- package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +6 -4
- package/front_end/panels/settings/emulation/components/userAgentClientHintsForm.css +0 -12
- package/front_end/panels/sources/DebuggerPlugin.ts +7 -3
- package/front_end/panels/sources/sourcesView.css +0 -130
- package/front_end/panels/timeline/TimelineTreeView.ts +1 -0
- package/front_end/panels/webauthn/WebauthnPane.ts +31 -32
- package/front_end/third_party/codemirror/codemirror-tsconfig.json +1 -25
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +1486 -1423
- package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +9 -9
- package/front_end/ui/components/buttons/Button.ts +17 -0
- package/front_end/ui/components/buttons/button.css +31 -0
- package/front_end/ui/components/data_grid/DataGrid.ts +9 -0
- package/front_end/ui/components/docs/button/basic.ts +42 -0
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +0 -8
- package/front_end/ui/components/text_editor/TextEditor.ts +5 -2
- package/front_end/ui/components/text_editor/config.ts +3 -3
- package/front_end/ui/components/text_editor/javascript.ts +28 -10
- package/front_end/ui/components/text_editor/theme.ts +1 -0
- package/front_end/ui/legacy/InspectorView.ts +10 -0
- package/front_end/ui/legacy/ListWidget.ts +2 -2
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +2 -3
- package/front_end/ui/legacy/components/object_ui/objectPropertiesSection.css +0 -1
- package/front_end/ui/legacy/components/object_ui/object_ui-legacy.ts +0 -8
- package/front_end/ui/legacy/components/object_ui/object_ui.ts +0 -4
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +3 -0
- package/front_end/ui/legacy/inspectorSyntaxHighlight.css +0 -211
- package/front_end/ui/legacy/legacy-legacy.ts +0 -6
- package/front_end/ui/legacy/legacy.ts +0 -2
- package/front_end/ui/legacy/tabbedPane.css +1 -1
- package/package.json +1 -1
- package/scripts/check_gn.js +1 -1
- package/scripts/eslint_rules/lib/l10n_filename_matches.js +17 -4
- package/scripts/eslint_rules/tests/l10n_filename_matches_test.js +21 -0
- package/scripts/hosted_mode/server.js +17 -2
- package/front_end/entrypoints/node_app/node_app-meta.ts +0 -43
- package/front_end/entrypoints/node_app/node_app.js +0 -13
- package/front_end/entrypoints/node_app/node_app.json +0 -4
- package/front_end/entrypoints/node_main/node_main-meta.ts +0 -48
- package/front_end/entrypoints/node_main/node_main.ts +0 -11
- package/front_end/entrypoints/shell/shell-meta-files.ts +0 -22
- package/front_end/entrypoints/shell/shell.json +0 -5
- package/front_end/ui/legacy/TextEditor.ts +0 -82
- package/front_end/ui/legacy/components/object_ui/JavaScriptAutocomplete.ts +0 -836
- package/front_end/ui/legacy/components/text_editor/CodeMirrorTextEditor.ts +0 -1676
- package/front_end/ui/legacy/components/text_editor/TextEditorAutocompleteController.ts +0 -586
- package/front_end/ui/legacy/components/text_editor/autocompleteTooltip.css +0 -20
- package/front_end/ui/legacy/components/text_editor/cm_modes.ts +0 -23
- package/front_end/ui/legacy/components/text_editor/cmdevtools.css +0 -995
- package/front_end/ui/legacy/components/text_editor/module.json +0 -7
- package/front_end/ui/legacy/components/text_editor/text_editor-legacy.ts +0 -33
- package/front_end/ui/legacy/components/text_editor/text_editor.ts +0 -13
|
@@ -169,6 +169,7 @@ interface SyntaxNode {
|
|
|
169
169
|
prevSibling: SyntaxNode | null;
|
|
170
170
|
cursor: TreeCursor;
|
|
171
171
|
resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
|
172
|
+
resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
|
172
173
|
enterUnfinishedNodesBefore(pos: number): SyntaxNode;
|
|
173
174
|
tree: Tree | null;
|
|
174
175
|
toTree(): Tree;
|
|
@@ -1583,1932 +1584,1988 @@ declare type StateCommand = (target: {
|
|
|
1583
1584
|
}) => boolean;
|
|
1584
1585
|
|
|
1585
1586
|
/**
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
managed as a [Lezer](https://lezer.codemirror.net) tree. You'll
|
|
1589
|
-
want to subclass this class for custom parsers, or use the
|
|
1590
|
-
[`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage) or
|
|
1591
|
-
[`StreamLanguage`](https://codemirror.net/6/docs/ref/#stream-parser.StreamLanguage) abstractions for
|
|
1592
|
-
[Lezer](https://lezer.codemirror.net/) or stream parsers.
|
|
1587
|
+
Each range is associated with a value, which must inherit from
|
|
1588
|
+
this class.
|
|
1593
1589
|
*/
|
|
1594
|
-
declare class
|
|
1595
|
-
/**
|
|
1596
|
-
The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) data
|
|
1597
|
-
facet used for this language.
|
|
1598
|
-
*/
|
|
1599
|
-
readonly data: Facet<{
|
|
1600
|
-
[name: string]: any;
|
|
1601
|
-
}>;
|
|
1590
|
+
declare abstract class RangeValue {
|
|
1602
1591
|
/**
|
|
1603
|
-
|
|
1592
|
+
Compare this value with another value. The default
|
|
1593
|
+
implementation compares by identity.
|
|
1604
1594
|
*/
|
|
1605
|
-
|
|
1595
|
+
eq(other: RangeValue): boolean;
|
|
1606
1596
|
/**
|
|
1607
|
-
The
|
|
1597
|
+
The bias value at the start of the range. Determines how the
|
|
1598
|
+
range is positioned relative to other ranges starting at this
|
|
1599
|
+
position. Defaults to 0.
|
|
1608
1600
|
*/
|
|
1609
|
-
|
|
1601
|
+
startSide: number;
|
|
1610
1602
|
/**
|
|
1611
|
-
The
|
|
1612
|
-
parser](https://lezer.codemirror.net/docs/ref#common.Parser).
|
|
1603
|
+
The bias value at the end of the range. Defaults to 0.
|
|
1613
1604
|
*/
|
|
1614
|
-
|
|
1605
|
+
endSide: number;
|
|
1615
1606
|
/**
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
the first argument.
|
|
1607
|
+
The mode with which the location of the range should be mapped
|
|
1608
|
+
when its `from` and `to` are the same, to decide whether a
|
|
1609
|
+
change deletes the range. Defaults to `MapMode.TrackDel`.
|
|
1620
1610
|
*/
|
|
1621
|
-
|
|
1611
|
+
mapMode: MapMode;
|
|
1622
1612
|
/**
|
|
1623
|
-
|
|
1624
|
-
|
|
1613
|
+
Whether this value marks a point range, which is treated as
|
|
1614
|
+
atomic and shadows the ranges contained in it.
|
|
1625
1615
|
*/
|
|
1626
|
-
|
|
1627
|
-
[name: string]: any;
|
|
1628
|
-
}>, parser: Parser,
|
|
1616
|
+
point: boolean;
|
|
1629
1617
|
/**
|
|
1630
|
-
|
|
1618
|
+
Create a [range](https://codemirror.net/6/docs/ref/#rangeset.Range) with this value.
|
|
1631
1619
|
*/
|
|
1632
|
-
|
|
1620
|
+
range(from: number, to?: number): Range<this>;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
A range associates a value with a range of positions.
|
|
1624
|
+
*/
|
|
1625
|
+
declare class Range<T extends RangeValue> {
|
|
1633
1626
|
/**
|
|
1634
|
-
|
|
1627
|
+
The range's start position.
|
|
1635
1628
|
*/
|
|
1636
|
-
|
|
1629
|
+
readonly from: number;
|
|
1637
1630
|
/**
|
|
1638
|
-
|
|
1639
|
-
The returned regions will _include_ any nested languages rooted
|
|
1640
|
-
in this language, when those exist.
|
|
1631
|
+
Its end position.
|
|
1641
1632
|
*/
|
|
1642
|
-
|
|
1643
|
-
from: number;
|
|
1644
|
-
to: number;
|
|
1645
|
-
}[];
|
|
1633
|
+
readonly to: number;
|
|
1646
1634
|
/**
|
|
1647
|
-
|
|
1648
|
-
default implementation returns true.
|
|
1635
|
+
The value associated with this range.
|
|
1649
1636
|
*/
|
|
1650
|
-
|
|
1637
|
+
readonly value: T;
|
|
1651
1638
|
}
|
|
1652
1639
|
/**
|
|
1653
|
-
|
|
1654
|
-
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
|
1655
|
-
parsers.
|
|
1640
|
+
Collection of methods used when comparing range sets.
|
|
1656
1641
|
*/
|
|
1657
|
-
|
|
1658
|
-
readonly parser: LRParser;
|
|
1659
|
-
private constructor();
|
|
1642
|
+
interface RangeComparator<T extends RangeValue> {
|
|
1660
1643
|
/**
|
|
1661
|
-
|
|
1644
|
+
Notifies the comparator that the given range has the given set
|
|
1645
|
+
of values associated with it.
|
|
1662
1646
|
*/
|
|
1663
|
-
|
|
1664
|
-
/**
|
|
1665
|
-
The parser to use. Should already have added editor-relevant
|
|
1666
|
-
node props (and optionally things like dialect and top rule)
|
|
1667
|
-
configured.
|
|
1668
|
-
*/
|
|
1669
|
-
parser: LRParser;
|
|
1670
|
-
/**
|
|
1671
|
-
[Language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)
|
|
1672
|
-
to register for this language.
|
|
1673
|
-
*/
|
|
1674
|
-
languageData?: {
|
|
1675
|
-
[name: string]: any;
|
|
1676
|
-
};
|
|
1677
|
-
}): LRLanguage;
|
|
1647
|
+
compareRange(from: number, to: number, activeA: T[], activeB: T[]): void;
|
|
1678
1648
|
/**
|
|
1679
|
-
|
|
1680
|
-
version of its parser.
|
|
1649
|
+
Notification for a point range.
|
|
1681
1650
|
*/
|
|
1682
|
-
|
|
1683
|
-
get allowsNesting(): boolean;
|
|
1651
|
+
comparePoint(from: number, to: number, byA: T | null, byB: T | null): void;
|
|
1684
1652
|
}
|
|
1685
1653
|
/**
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
or
|
|
1689
|
-
*/
|
|
1690
|
-
declare function syntaxTree(state: EditorState): Tree;
|
|
1691
|
-
/**
|
|
1692
|
-
Try to get a parse tree that spans at least up to `upto`. The
|
|
1693
|
-
method will do at most `timeout` milliseconds of work to parse
|
|
1694
|
-
up to that point if the tree isn't already available.
|
|
1654
|
+
Methods used when iterating over the spans created by a set of
|
|
1655
|
+
ranges. The entire iterated range will be covered with either
|
|
1656
|
+
`span` or `point` calls.
|
|
1695
1657
|
*/
|
|
1696
|
-
|
|
1658
|
+
interface SpanIterator<T extends RangeValue> {
|
|
1659
|
+
/**
|
|
1660
|
+
Called for any ranges not covered by point decorations. `active`
|
|
1661
|
+
holds the values that the range is marked with (and may be
|
|
1662
|
+
empty). `openStart` indicates how many of those ranges are open
|
|
1663
|
+
(continued) at the start of the span.
|
|
1664
|
+
*/
|
|
1665
|
+
span(from: number, to: number, active: readonly T[], openStart: number): void;
|
|
1666
|
+
/**
|
|
1667
|
+
Called when going over a point decoration. The active range
|
|
1668
|
+
decorations that cover the point and have a higher precedence
|
|
1669
|
+
are provided in `active`. The open count in `openStart` counts
|
|
1670
|
+
the number of those ranges that started before the point and. If
|
|
1671
|
+
the point started before the iterated range, `openStart` will be
|
|
1672
|
+
`active.length + 1` to signal this.
|
|
1673
|
+
*/
|
|
1674
|
+
point(from: number, to: number, value: T, active: readonly T[], openStart: number): void;
|
|
1675
|
+
}
|
|
1697
1676
|
/**
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
the main way for client code to use the package.
|
|
1677
|
+
A range cursor is an object that moves to the next range every
|
|
1678
|
+
time you call `next` on it. Note that, unlike ES6 iterators, these
|
|
1679
|
+
start out pointing at the first element, so you should call `next`
|
|
1680
|
+
only after reading the first range (if any).
|
|
1703
1681
|
*/
|
|
1704
|
-
|
|
1682
|
+
interface RangeCursor<T> {
|
|
1705
1683
|
/**
|
|
1706
|
-
|
|
1684
|
+
Move the iterator forward.
|
|
1707
1685
|
*/
|
|
1708
|
-
|
|
1686
|
+
next: () => void;
|
|
1709
1687
|
/**
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
to include the supporting extensions for its inner languages
|
|
1713
|
-
in its own set of support extensions.
|
|
1688
|
+
The next range's value. Holds `null` when the cursor has reached
|
|
1689
|
+
its end.
|
|
1714
1690
|
*/
|
|
1715
|
-
|
|
1691
|
+
value: T | null;
|
|
1716
1692
|
/**
|
|
1717
|
-
|
|
1718
|
-
extensions. (Allowing the object to be used as an extension
|
|
1719
|
-
value itself.)
|
|
1693
|
+
The next range's start position.
|
|
1720
1694
|
*/
|
|
1721
|
-
|
|
1695
|
+
from: number;
|
|
1722
1696
|
/**
|
|
1723
|
-
|
|
1697
|
+
The next end position.
|
|
1724
1698
|
*/
|
|
1725
|
-
|
|
1699
|
+
to: number;
|
|
1700
|
+
}
|
|
1701
|
+
declare type RangeSetUpdate<T extends RangeValue> = {
|
|
1726
1702
|
/**
|
|
1727
|
-
|
|
1703
|
+
An array of ranges to add. If given, this should be sorted by
|
|
1704
|
+
`from` position and `startSide` unless
|
|
1705
|
+
[`sort`](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.update^updateSpec.sort) is given as
|
|
1706
|
+
`true`.
|
|
1728
1707
|
*/
|
|
1729
|
-
|
|
1708
|
+
add?: readonly Range<T>[];
|
|
1730
1709
|
/**
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
to include the supporting extensions for its inner languages
|
|
1734
|
-
in its own set of support extensions.
|
|
1710
|
+
Indicates whether the library should sort the ranges in `add`.
|
|
1711
|
+
Defaults to `false`.
|
|
1735
1712
|
*/
|
|
1736
|
-
|
|
1737
|
-
}
|
|
1738
|
-
/**
|
|
1739
|
-
Language descriptions are used to store metadata about languages
|
|
1740
|
-
and to dynamically load them. Their main role is finding the
|
|
1741
|
-
appropriate language for a filename or dynamically loading nested
|
|
1742
|
-
parsers.
|
|
1743
|
-
*/
|
|
1744
|
-
declare class LanguageDescription {
|
|
1713
|
+
sort?: boolean;
|
|
1745
1714
|
/**
|
|
1746
|
-
|
|
1715
|
+
Filter the ranges already in the set. Only those for which this
|
|
1716
|
+
function returns `true` are kept.
|
|
1747
1717
|
*/
|
|
1748
|
-
|
|
1718
|
+
filter?: (from: number, to: number, value: T) => boolean;
|
|
1749
1719
|
/**
|
|
1750
|
-
|
|
1720
|
+
Can be used to limit the range on which the filter is
|
|
1721
|
+
applied. Filtering only a small range, as opposed to the entire
|
|
1722
|
+
set, can make updates cheaper.
|
|
1751
1723
|
*/
|
|
1752
|
-
|
|
1724
|
+
filterFrom?: number;
|
|
1753
1725
|
/**
|
|
1754
|
-
|
|
1726
|
+
The end position to apply the filter to.
|
|
1755
1727
|
*/
|
|
1756
|
-
|
|
1728
|
+
filterTo?: number;
|
|
1729
|
+
};
|
|
1730
|
+
/**
|
|
1731
|
+
A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#rangeset.Range) in a
|
|
1732
|
+
way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.map) and
|
|
1733
|
+
[update](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.update). This is an immutable data
|
|
1734
|
+
structure.
|
|
1735
|
+
*/
|
|
1736
|
+
declare class RangeSet<T extends RangeValue> {
|
|
1757
1737
|
/**
|
|
1758
|
-
|
|
1759
|
-
language.
|
|
1738
|
+
The number of ranges in the set.
|
|
1760
1739
|
*/
|
|
1761
|
-
|
|
1762
|
-
private loadFunc;
|
|
1740
|
+
get size(): number;
|
|
1763
1741
|
/**
|
|
1764
|
-
|
|
1742
|
+
Update the range set, optionally adding new ranges or filtering
|
|
1743
|
+
out existing ones.
|
|
1744
|
+
|
|
1745
|
+
(The extra type parameter is just there as a kludge to work
|
|
1746
|
+
around TypeScript variance issues that prevented `RangeSet<X>`
|
|
1747
|
+
from being a subtype of `RangeSet<Y>` when `X` is a subtype of
|
|
1748
|
+
`Y`.)
|
|
1765
1749
|
*/
|
|
1766
|
-
|
|
1767
|
-
private loading;
|
|
1768
|
-
private constructor();
|
|
1750
|
+
update<U extends T>(updateSpec: RangeSetUpdate<U>): RangeSet<T>;
|
|
1769
1751
|
/**
|
|
1770
|
-
|
|
1771
|
-
resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
|
|
1772
|
-
object when the language successfully loads.
|
|
1752
|
+
Map this range set through a set of changes, return the new set.
|
|
1773
1753
|
*/
|
|
1774
|
-
|
|
1754
|
+
map(changes: ChangeDesc): RangeSet<T>;
|
|
1775
1755
|
/**
|
|
1776
|
-
|
|
1756
|
+
Iterate over the ranges that touch the region `from` to `to`,
|
|
1757
|
+
calling `f` for each. There is no guarantee that the ranges will
|
|
1758
|
+
be reported in any specific order. When the callback returns
|
|
1759
|
+
`false`, iteration stops.
|
|
1777
1760
|
*/
|
|
1778
|
-
|
|
1779
|
-
/**
|
|
1780
|
-
The language's name.
|
|
1781
|
-
*/
|
|
1782
|
-
name: string;
|
|
1783
|
-
/**
|
|
1784
|
-
An optional array of alternative names.
|
|
1785
|
-
*/
|
|
1786
|
-
alias?: readonly string[];
|
|
1787
|
-
/**
|
|
1788
|
-
An optional array of extensions associated with this language.
|
|
1789
|
-
*/
|
|
1790
|
-
extensions?: readonly string[];
|
|
1791
|
-
/**
|
|
1792
|
-
An optional filename pattern associated with this language.
|
|
1793
|
-
*/
|
|
1794
|
-
filename?: RegExp;
|
|
1795
|
-
/**
|
|
1796
|
-
A function that will asynchronously load the language.
|
|
1797
|
-
*/
|
|
1798
|
-
load: () => Promise<LanguageSupport>;
|
|
1799
|
-
}): LanguageDescription;
|
|
1761
|
+
between(from: number, to: number, f: (from: number, to: number, value: T) => void | false): void;
|
|
1800
1762
|
/**
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
[`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
|
|
1804
|
-
and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
|
|
1805
|
-
and return the first language that matches.
|
|
1763
|
+
Iterate over the ranges in this set, in order, including all
|
|
1764
|
+
ranges that end at or after `from`.
|
|
1806
1765
|
*/
|
|
1807
|
-
|
|
1766
|
+
iter(from?: number): RangeCursor<T>;
|
|
1808
1767
|
/**
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
matchs is found, this'll also search for a language whose name
|
|
1812
|
-
or alias occurs in the string (for names shorter than three
|
|
1813
|
-
characters, only when surrounded by non-word characters).
|
|
1768
|
+
Iterate over the ranges in a collection of sets, in order,
|
|
1769
|
+
starting from `from`.
|
|
1814
1770
|
*/
|
|
1815
|
-
static
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
Facet for overriding the unit by which indentation happens.
|
|
1819
|
-
Should be a string consisting either entirely of spaces or
|
|
1820
|
-
entirely of tabs. When not set, this defaults to 2 spaces.
|
|
1821
|
-
*/
|
|
1822
|
-
declare const indentUnit: Facet<string, string>;
|
|
1823
|
-
/**
|
|
1824
|
-
Indentation contexts are used when calling [indentation
|
|
1825
|
-
services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
|
|
1826
|
-
useful in indentation logic, and can selectively override the
|
|
1827
|
-
indentation reported for some lines.
|
|
1828
|
-
*/
|
|
1829
|
-
declare class IndentContext {
|
|
1771
|
+
static iter<T extends RangeValue>(sets: readonly RangeSet<T>[], from?: number): RangeCursor<T>;
|
|
1830
1772
|
/**
|
|
1831
|
-
|
|
1773
|
+
Iterate over two groups of sets, calling methods on `comparator`
|
|
1774
|
+
to notify it of possible differences.
|
|
1832
1775
|
*/
|
|
1833
|
-
readonly
|
|
1776
|
+
static compare<T extends RangeValue>(oldSets: readonly RangeSet<T>[], newSets: readonly RangeSet<T>[],
|
|
1834
1777
|
/**
|
|
1835
|
-
|
|
1778
|
+
This indicates how the underlying data changed between these
|
|
1779
|
+
ranges, and is needed to synchronize the iteration. `from` and
|
|
1780
|
+
`to` are coordinates in the _new_ space, after these changes.
|
|
1836
1781
|
*/
|
|
1837
|
-
|
|
1782
|
+
textDiff: ChangeDesc, comparator: RangeComparator<T>,
|
|
1838
1783
|
/**
|
|
1839
|
-
|
|
1784
|
+
Can be used to ignore all non-point ranges, and points below
|
|
1785
|
+
the given size. When -1, all ranges are compared.
|
|
1840
1786
|
*/
|
|
1841
|
-
|
|
1787
|
+
minPointSize?: number): void;
|
|
1842
1788
|
/**
|
|
1843
|
-
|
|
1789
|
+
Compare the contents of two groups of range sets, returning true
|
|
1790
|
+
if they are equivalent in the given range.
|
|
1844
1791
|
*/
|
|
1845
|
-
|
|
1792
|
+
static eq<T extends RangeValue>(oldSets: readonly RangeSet<T>[], newSets: readonly RangeSet<T>[], from?: number, to?: number): boolean;
|
|
1846
1793
|
/**
|
|
1847
|
-
|
|
1794
|
+
Iterate over a group of range sets at the same time, notifying
|
|
1795
|
+
the iterator about the ranges covering every given piece of
|
|
1796
|
+
content. Returns the open count (see
|
|
1797
|
+
[`SpanIterator.span`](https://codemirror.net/6/docs/ref/#rangeset.SpanIterator.span)) at the end
|
|
1798
|
+
of the iteration.
|
|
1848
1799
|
*/
|
|
1849
|
-
|
|
1850
|
-
/**
|
|
1851
|
-
Override line indentations provided to the indentation
|
|
1852
|
-
helper function, which is useful when implementing region
|
|
1853
|
-
indentation, where indentation for later lines needs to refer
|
|
1854
|
-
to previous lines, which may have been reindented compared to
|
|
1855
|
-
the original start state. If given, this function should
|
|
1856
|
-
return -1 for lines (given by start position) that didn't
|
|
1857
|
-
change, and an updated indentation otherwise.
|
|
1858
|
-
*/
|
|
1859
|
-
overrideIndentation?: (pos: number) => number;
|
|
1860
|
-
/**
|
|
1861
|
-
Make it look, to the indent logic, like a line break was
|
|
1862
|
-
added at the given position (which is mostly just useful for
|
|
1863
|
-
implementing something like
|
|
1864
|
-
[`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)).
|
|
1865
|
-
*/
|
|
1866
|
-
simulateBreak?: number;
|
|
1867
|
-
/**
|
|
1868
|
-
When `simulateBreak` is given, this can be used to make the
|
|
1869
|
-
simulate break behave like a double line break.
|
|
1870
|
-
*/
|
|
1871
|
-
simulateDoubleBreak?: boolean;
|
|
1872
|
-
});
|
|
1800
|
+
static spans<T extends RangeValue>(sets: readonly RangeSet<T>[], from: number, to: number, iterator: SpanIterator<T>,
|
|
1873
1801
|
/**
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
|
|
1877
|
-
into account. If there is such a break at `pos`, the `bias`
|
|
1878
|
-
argument determines whether the part of the line line before or
|
|
1879
|
-
after the break is used.
|
|
1802
|
+
When given and greater than -1, only points of at least this
|
|
1803
|
+
size are taken into account.
|
|
1880
1804
|
*/
|
|
1881
|
-
|
|
1882
|
-
text: string;
|
|
1883
|
-
from: number;
|
|
1884
|
-
};
|
|
1805
|
+
minPointSize?: number): number;
|
|
1885
1806
|
/**
|
|
1886
|
-
|
|
1887
|
-
|
|
1807
|
+
Create a range set for the given range or array of ranges. By
|
|
1808
|
+
default, this expects the ranges to be _sorted_ (by start
|
|
1809
|
+
position and, if two start at the same position,
|
|
1810
|
+
`value.startSide`). You can pass `true` as second argument to
|
|
1811
|
+
cause the method to sort them.
|
|
1888
1812
|
*/
|
|
1889
|
-
|
|
1813
|
+
static of<T extends RangeValue>(ranges: readonly Range<T>[] | Range<T>, sort?: boolean): RangeSet<T>;
|
|
1890
1814
|
/**
|
|
1891
|
-
|
|
1815
|
+
The empty set of ranges.
|
|
1892
1816
|
*/
|
|
1893
|
-
|
|
1817
|
+
static empty: RangeSet<any>;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
A range set builder is a data structure that helps build up a
|
|
1821
|
+
[range set](https://codemirror.net/6/docs/ref/#rangeset.RangeSet) directly, without first allocating
|
|
1822
|
+
an array of [`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range) objects.
|
|
1823
|
+
*/
|
|
1824
|
+
declare class RangeSetBuilder<T extends RangeValue> {
|
|
1825
|
+
private chunks;
|
|
1826
|
+
private chunkPos;
|
|
1827
|
+
private chunkStart;
|
|
1828
|
+
private last;
|
|
1829
|
+
private lastFrom;
|
|
1830
|
+
private lastTo;
|
|
1831
|
+
private from;
|
|
1832
|
+
private to;
|
|
1833
|
+
private value;
|
|
1834
|
+
private maxPoint;
|
|
1835
|
+
private setMaxPoint;
|
|
1836
|
+
private nextLayer;
|
|
1837
|
+
private finishChunk;
|
|
1894
1838
|
/**
|
|
1895
|
-
|
|
1896
|
-
position in the given string.
|
|
1839
|
+
Create an empty builder.
|
|
1897
1840
|
*/
|
|
1898
|
-
|
|
1841
|
+
constructor();
|
|
1899
1842
|
/**
|
|
1900
|
-
|
|
1843
|
+
Add a range. Ranges should be added in sorted (by `from` and
|
|
1844
|
+
`value.startSide`) order.
|
|
1901
1845
|
*/
|
|
1902
|
-
|
|
1846
|
+
add(from: number, to: number, value: T): void;
|
|
1903
1847
|
/**
|
|
1904
|
-
Returns the
|
|
1905
|
-
|
|
1906
|
-
for this context, if any.
|
|
1848
|
+
Finish the range set. Returns the new set. The builder can't be
|
|
1849
|
+
used anymore after this has been called.
|
|
1907
1850
|
*/
|
|
1908
|
-
|
|
1851
|
+
finish(): RangeSet<T>;
|
|
1909
1852
|
}
|
|
1910
|
-
/**
|
|
1911
|
-
Enables reindentation on input. When a language defines an
|
|
1912
|
-
`indentOnInput` field in its [language
|
|
1913
|
-
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
|
|
1914
|
-
expression, the line at the cursor will be reindented whenever new
|
|
1915
|
-
text is typed and the input from the start of the line up to the
|
|
1916
|
-
cursor matches that regexp.
|
|
1917
1853
|
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1854
|
+
declare class StyleModule {
|
|
1855
|
+
constructor(spec: {[selector: string]: StyleSpec}, options?: {
|
|
1856
|
+
finish?(sel: string): string
|
|
1857
|
+
})
|
|
1858
|
+
getRules(): string
|
|
1859
|
+
static mount(root: Document | ShadowRoot | DocumentOrShadowRoot, module: StyleModule | ReadonlyArray<StyleModule>): void
|
|
1860
|
+
static newName(): string
|
|
1861
|
+
}
|
|
1924
1862
|
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
declare
|
|
1863
|
+
type StyleSpec = {
|
|
1864
|
+
[propOrSelector: string]: string | number | StyleSpec | null
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
declare type Attrs = {
|
|
1868
|
+
[name: string]: string;
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
interface MarkDecorationSpec {
|
|
1930
1872
|
/**
|
|
1931
|
-
|
|
1932
|
-
|
|
1873
|
+
Whether the mark covers its start and end position or not. This
|
|
1874
|
+
influences whether content inserted at those positions becomes
|
|
1875
|
+
part of the mark. Defaults to false.
|
|
1933
1876
|
*/
|
|
1934
|
-
|
|
1877
|
+
inclusive?: boolean;
|
|
1935
1878
|
/**
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
position. Defaults to 0.
|
|
1879
|
+
Specify whether the start position of the marked range should be
|
|
1880
|
+
inclusive. Overrides `inclusive`, when both are present.
|
|
1939
1881
|
*/
|
|
1940
|
-
|
|
1882
|
+
inclusiveStart?: boolean;
|
|
1941
1883
|
/**
|
|
1942
|
-
|
|
1884
|
+
Whether the end should be inclusive.
|
|
1943
1885
|
*/
|
|
1944
|
-
|
|
1886
|
+
inclusiveEnd?: boolean;
|
|
1945
1887
|
/**
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
change deletes the range. Defaults to `MapMode.TrackDel`.
|
|
1888
|
+
Add attributes to the DOM elements that hold the text in the
|
|
1889
|
+
marked range.
|
|
1949
1890
|
*/
|
|
1950
|
-
|
|
1891
|
+
attributes?: {
|
|
1892
|
+
[key: string]: string;
|
|
1893
|
+
};
|
|
1951
1894
|
/**
|
|
1952
|
-
|
|
1953
|
-
atomic and shadows the ranges contained in it.
|
|
1895
|
+
Shorthand for `{attributes: {class: value}}`.
|
|
1954
1896
|
*/
|
|
1955
|
-
|
|
1897
|
+
class?: string;
|
|
1956
1898
|
/**
|
|
1957
|
-
|
|
1899
|
+
Add a wrapping element around the text in the marked range. Note
|
|
1900
|
+
that there will not be a single element covering the entire
|
|
1901
|
+
range—content is split on mark starts and ends, and each piece
|
|
1902
|
+
gets its own element.
|
|
1958
1903
|
*/
|
|
1959
|
-
|
|
1960
|
-
}
|
|
1961
|
-
/**
|
|
1962
|
-
A range associates a value with a range of positions.
|
|
1963
|
-
*/
|
|
1964
|
-
declare class Range<T extends RangeValue> {
|
|
1904
|
+
tagName?: string;
|
|
1965
1905
|
/**
|
|
1966
|
-
|
|
1906
|
+
Decoration specs allow extra properties, which can be retrieved
|
|
1907
|
+
through the decoration's [`spec`](https://codemirror.net/6/docs/ref/#view.Decoration.spec)
|
|
1908
|
+
property.
|
|
1967
1909
|
*/
|
|
1968
|
-
|
|
1910
|
+
[other: string]: any;
|
|
1911
|
+
}
|
|
1912
|
+
interface WidgetDecorationSpec {
|
|
1969
1913
|
/**
|
|
1970
|
-
|
|
1914
|
+
The type of widget to draw here.
|
|
1971
1915
|
*/
|
|
1972
|
-
|
|
1916
|
+
widget: WidgetType;
|
|
1973
1917
|
/**
|
|
1974
|
-
|
|
1918
|
+
Which side of the given position the widget is on. When this is
|
|
1919
|
+
positive, the widget will be drawn after the cursor if the
|
|
1920
|
+
cursor is on the same position. Otherwise, it'll be drawn before
|
|
1921
|
+
it. When multiple widgets sit at the same position, their `side`
|
|
1922
|
+
values will determine their ordering—those with a lower value
|
|
1923
|
+
come first. Defaults to 0.
|
|
1975
1924
|
*/
|
|
1976
|
-
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
Collection of methods used when comparing range sets.
|
|
1980
|
-
*/
|
|
1981
|
-
interface RangeComparator<T extends RangeValue> {
|
|
1925
|
+
side?: number;
|
|
1982
1926
|
/**
|
|
1983
|
-
|
|
1984
|
-
|
|
1927
|
+
Determines whether this is a block widgets, which will be drawn
|
|
1928
|
+
between lines, or an inline widget (the default) which is drawn
|
|
1929
|
+
between the surrounding text.
|
|
1930
|
+
|
|
1931
|
+
Note that block-level decorations should not have vertical
|
|
1932
|
+
margins, and if you dynamically change their height, you should
|
|
1933
|
+
make sure to call
|
|
1934
|
+
[`requestMeasure`](https://codemirror.net/6/docs/ref/#view.EditorView.requestMeasure), so that the
|
|
1935
|
+
editor can update its information about its vertical layout.
|
|
1985
1936
|
*/
|
|
1986
|
-
|
|
1937
|
+
block?: boolean;
|
|
1987
1938
|
/**
|
|
1988
|
-
|
|
1939
|
+
Other properties are allowed.
|
|
1989
1940
|
*/
|
|
1990
|
-
|
|
1941
|
+
[other: string]: any;
|
|
1991
1942
|
}
|
|
1992
|
-
|
|
1993
|
-
Methods used when iterating over the spans created by a set of
|
|
1994
|
-
ranges. The entire iterated range will be covered with either
|
|
1995
|
-
`span` or `point` calls.
|
|
1996
|
-
*/
|
|
1997
|
-
interface SpanIterator<T extends RangeValue> {
|
|
1943
|
+
interface ReplaceDecorationSpec {
|
|
1998
1944
|
/**
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
empty). `openStart` indicates how many of those ranges are open
|
|
2002
|
-
(continued) at the start of the span.
|
|
1945
|
+
An optional widget to drawn in the place of the replaced
|
|
1946
|
+
content.
|
|
2003
1947
|
*/
|
|
2004
|
-
|
|
1948
|
+
widget?: WidgetType;
|
|
2005
1949
|
/**
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
the point started before the iterated range, `openStart` will be
|
|
2011
|
-
`active.length + 1` to signal this.
|
|
1950
|
+
Whether this range covers the positions on its sides. This
|
|
1951
|
+
influences whether new content becomes part of the range and
|
|
1952
|
+
whether the cursor can be drawn on its sides. Defaults to false
|
|
1953
|
+
for inline replacements, and true for block replacements.
|
|
2012
1954
|
*/
|
|
2013
|
-
|
|
2014
|
-
}
|
|
2015
|
-
/**
|
|
2016
|
-
A range cursor is an object that moves to the next range every
|
|
2017
|
-
time you call `next` on it. Note that, unlike ES6 iterators, these
|
|
2018
|
-
start out pointing at the first element, so you should call `next`
|
|
2019
|
-
only after reading the first range (if any).
|
|
2020
|
-
*/
|
|
2021
|
-
interface RangeCursor<T> {
|
|
1955
|
+
inclusive?: boolean;
|
|
2022
1956
|
/**
|
|
2023
|
-
|
|
1957
|
+
Set inclusivity at the start.
|
|
2024
1958
|
*/
|
|
2025
|
-
|
|
1959
|
+
inclusiveStart?: boolean;
|
|
2026
1960
|
/**
|
|
2027
|
-
|
|
2028
|
-
its end.
|
|
1961
|
+
Set inclusivity at the end.
|
|
2029
1962
|
*/
|
|
2030
|
-
|
|
1963
|
+
inclusiveEnd?: boolean;
|
|
2031
1964
|
/**
|
|
2032
|
-
|
|
1965
|
+
Whether this is a block-level decoration. Defaults to false.
|
|
2033
1966
|
*/
|
|
2034
|
-
|
|
1967
|
+
block?: boolean;
|
|
2035
1968
|
/**
|
|
2036
|
-
|
|
1969
|
+
Other properties are allowed.
|
|
2037
1970
|
*/
|
|
2038
|
-
|
|
1971
|
+
[other: string]: any;
|
|
2039
1972
|
}
|
|
2040
|
-
|
|
1973
|
+
interface LineDecorationSpec {
|
|
2041
1974
|
/**
|
|
2042
|
-
|
|
2043
|
-
`from` position and `startSide` unless
|
|
2044
|
-
[`sort`](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.update^updateSpec.sort) is given as
|
|
2045
|
-
`true`.
|
|
1975
|
+
DOM attributes to add to the element wrapping the line.
|
|
2046
1976
|
*/
|
|
2047
|
-
|
|
1977
|
+
attributes?: {
|
|
1978
|
+
[key: string]: string;
|
|
1979
|
+
};
|
|
2048
1980
|
/**
|
|
2049
|
-
|
|
2050
|
-
Defaults to `false`.
|
|
1981
|
+
Shorthand for `{attributes: {class: value}}`.
|
|
2051
1982
|
*/
|
|
2052
|
-
|
|
1983
|
+
class?: string;
|
|
2053
1984
|
/**
|
|
2054
|
-
|
|
2055
|
-
function returns `true` are kept.
|
|
1985
|
+
Other properties are allowed.
|
|
2056
1986
|
*/
|
|
2057
|
-
|
|
1987
|
+
[other: string]: any;
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
Widgets added to the content are described by subclasses of this
|
|
1991
|
+
class. Using a description object like that makes it possible to
|
|
1992
|
+
delay creating of the DOM structure for a widget until it is
|
|
1993
|
+
needed, and to avoid redrawing widgets even when the decorations
|
|
1994
|
+
that define them are recreated.
|
|
1995
|
+
*/
|
|
1996
|
+
declare abstract class WidgetType {
|
|
2058
1997
|
/**
|
|
2059
|
-
|
|
2060
|
-
applied. Filtering only a small range, as opposed to the entire
|
|
2061
|
-
set, can make updates cheaper.
|
|
1998
|
+
Build the DOM structure for this widget instance.
|
|
2062
1999
|
*/
|
|
2063
|
-
|
|
2000
|
+
abstract toDOM(view: EditorView): HTMLElement;
|
|
2064
2001
|
/**
|
|
2065
|
-
|
|
2002
|
+
Compare this instance to another instance of the same type.
|
|
2003
|
+
(TypeScript can't express this, but only instances of the same
|
|
2004
|
+
specific class will be passed to this method.) This is used to
|
|
2005
|
+
avoid redrawing widgets when they are replaced by a new
|
|
2006
|
+
decoration of the same type. The default implementation just
|
|
2007
|
+
returns `false`, which will cause new instances of the widget to
|
|
2008
|
+
always be redrawn.
|
|
2066
2009
|
*/
|
|
2067
|
-
|
|
2068
|
-
};
|
|
2069
|
-
/**
|
|
2070
|
-
A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#rangeset.Range) in a
|
|
2071
|
-
way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.map) and
|
|
2072
|
-
[update](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.update). This is an immutable data
|
|
2073
|
-
structure.
|
|
2074
|
-
*/
|
|
2075
|
-
declare class RangeSet<T extends RangeValue> {
|
|
2010
|
+
eq(_widget: WidgetType): boolean;
|
|
2076
2011
|
/**
|
|
2077
|
-
|
|
2012
|
+
Update a DOM element created by a widget of the same type (but
|
|
2013
|
+
different, non-`eq` content) to reflect this widget. May return
|
|
2014
|
+
true to indicate that it could update, false to indicate it
|
|
2015
|
+
couldn't (in which case the widget will be redrawn). The default
|
|
2016
|
+
implementation just returns false.
|
|
2078
2017
|
*/
|
|
2079
|
-
|
|
2018
|
+
updateDOM(_dom: HTMLElement): boolean;
|
|
2080
2019
|
/**
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
around TypeScript variance issues that prevented `RangeSet<X>`
|
|
2086
|
-
from being a subtype of `RangeSet<Y>` when `X` is a subtype of
|
|
2087
|
-
`Y`.)
|
|
2020
|
+
The estimated height this widget will have, to be used when
|
|
2021
|
+
estimating the height of content that hasn't been drawn. May
|
|
2022
|
+
return -1 to indicate you don't know. The default implementation
|
|
2023
|
+
returns -1.
|
|
2088
2024
|
*/
|
|
2089
|
-
|
|
2025
|
+
get estimatedHeight(): number;
|
|
2090
2026
|
/**
|
|
2091
|
-
|
|
2027
|
+
Can be used to configure which kinds of events inside the widget
|
|
2028
|
+
should be ignored by the editor. The default is to ignore all
|
|
2029
|
+
events.
|
|
2092
2030
|
*/
|
|
2093
|
-
|
|
2031
|
+
ignoreEvent(_event: Event): boolean;
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
A decoration set represents a collection of decorated ranges,
|
|
2035
|
+
organized for efficient access and mapping. See
|
|
2036
|
+
[`RangeSet`](https://codemirror.net/6/docs/ref/#rangeset.RangeSet) for its methods.
|
|
2037
|
+
*/
|
|
2038
|
+
declare type DecorationSet = RangeSet<Decoration>;
|
|
2039
|
+
/**
|
|
2040
|
+
The different types of blocks that can occur in an editor view.
|
|
2041
|
+
*/
|
|
2042
|
+
declare enum BlockType {
|
|
2094
2043
|
/**
|
|
2095
|
-
|
|
2096
|
-
calling `f` for each. There is no guarantee that the ranges will
|
|
2097
|
-
be reported in any specific order. When the callback returns
|
|
2098
|
-
`false`, iteration stops.
|
|
2044
|
+
A line of text.
|
|
2099
2045
|
*/
|
|
2100
|
-
|
|
2046
|
+
Text = 0,
|
|
2101
2047
|
/**
|
|
2102
|
-
|
|
2103
|
-
ranges that end at or after `from`.
|
|
2048
|
+
A block widget associated with the position after it.
|
|
2104
2049
|
*/
|
|
2105
|
-
|
|
2050
|
+
WidgetBefore = 1,
|
|
2106
2051
|
/**
|
|
2107
|
-
|
|
2108
|
-
starting from `from`.
|
|
2052
|
+
A block widget associated with the position before it.
|
|
2109
2053
|
*/
|
|
2110
|
-
|
|
2054
|
+
WidgetAfter = 2,
|
|
2111
2055
|
/**
|
|
2112
|
-
|
|
2113
|
-
to notify it of possible differences.
|
|
2056
|
+
A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
|
|
2114
2057
|
*/
|
|
2115
|
-
|
|
2058
|
+
WidgetRange = 3
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
A decoration provides information on how to draw or style a piece
|
|
2062
|
+
of content. You'll usually use it wrapped in a
|
|
2063
|
+
[`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range), which adds a start and end position.
|
|
2064
|
+
*/
|
|
2065
|
+
declare abstract class Decoration extends RangeValue {
|
|
2116
2066
|
/**
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2067
|
+
The config object used to create this decoration. You can
|
|
2068
|
+
include additional properties in there to store metadata about
|
|
2069
|
+
your decoration.
|
|
2120
2070
|
*/
|
|
2121
|
-
|
|
2071
|
+
readonly spec: any;
|
|
2072
|
+
abstract eq(other: Decoration): boolean;
|
|
2122
2073
|
/**
|
|
2123
|
-
|
|
2124
|
-
|
|
2074
|
+
Create a mark decoration, which influences the styling of the
|
|
2075
|
+
content in its range. Nested mark decorations will cause nested
|
|
2076
|
+
DOM elements to be created. Nesting order is determined by
|
|
2077
|
+
precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations) or
|
|
2078
|
+
(below the facet-provided decorations) [view
|
|
2079
|
+
plugin](https://codemirror.net/6/docs/ref/#view.PluginSpec.decorations). Such elements are split
|
|
2080
|
+
on line boundaries and on the boundaries of higher-precedence
|
|
2081
|
+
decorations.
|
|
2125
2082
|
*/
|
|
2126
|
-
|
|
2083
|
+
static mark(spec: MarkDecorationSpec): Decoration;
|
|
2127
2084
|
/**
|
|
2128
|
-
|
|
2129
|
-
|
|
2085
|
+
Create a widget decoration, which adds an element at the given
|
|
2086
|
+
position.
|
|
2130
2087
|
*/
|
|
2131
|
-
static
|
|
2088
|
+
static widget(spec: WidgetDecorationSpec): Decoration;
|
|
2132
2089
|
/**
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
content. Returns the open count (see
|
|
2136
|
-
[`SpanIterator.span`](https://codemirror.net/6/docs/ref/#rangeset.SpanIterator.span)) at the end
|
|
2137
|
-
of the iteration.
|
|
2090
|
+
Create a replace decoration which replaces the given range with
|
|
2091
|
+
a widget, or simply hides it.
|
|
2138
2092
|
*/
|
|
2139
|
-
static
|
|
2093
|
+
static replace(spec: ReplaceDecorationSpec): Decoration;
|
|
2140
2094
|
/**
|
|
2141
|
-
|
|
2142
|
-
|
|
2095
|
+
Create a line decoration, which can add DOM attributes to the
|
|
2096
|
+
line starting at the given position.
|
|
2143
2097
|
*/
|
|
2144
|
-
|
|
2098
|
+
static line(spec: LineDecorationSpec): Decoration;
|
|
2145
2099
|
/**
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
`value.startSide`). You can pass `true` as second argument to
|
|
2150
|
-
cause the method to sort them.
|
|
2100
|
+
Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
|
|
2101
|
+
decorated range or ranges. If the ranges aren't already sorted,
|
|
2102
|
+
pass `true` for `sort` to make the library sort them for you.
|
|
2151
2103
|
*/
|
|
2152
|
-
static of<
|
|
2104
|
+
static set(of: Range<Decoration> | readonly Range<Decoration>[], sort?: boolean): DecorationSet;
|
|
2153
2105
|
/**
|
|
2154
|
-
The empty set of
|
|
2106
|
+
The empty set of decorations.
|
|
2155
2107
|
*/
|
|
2156
|
-
static
|
|
2108
|
+
static none: DecorationSet;
|
|
2157
2109
|
}
|
|
2110
|
+
|
|
2158
2111
|
/**
|
|
2159
|
-
|
|
2160
|
-
[range set](https://codemirror.net/6/docs/ref/#rangeset.RangeSet) directly, without first allocating
|
|
2161
|
-
an array of [`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range) objects.
|
|
2112
|
+
Basic rectangle type.
|
|
2162
2113
|
*/
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2114
|
+
interface Rect {
|
|
2115
|
+
readonly left: number;
|
|
2116
|
+
readonly right: number;
|
|
2117
|
+
readonly top: number;
|
|
2118
|
+
readonly bottom: number;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
Command functions are used in key bindings and other types of user
|
|
2123
|
+
actions. Given an editor view, they check whether their effect can
|
|
2124
|
+
apply to the editor, and if it can, perform it as a side effect
|
|
2125
|
+
(which usually means [dispatching](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) a
|
|
2126
|
+
transaction) and return `true`.
|
|
2127
|
+
*/
|
|
2128
|
+
declare type Command = (target: EditorView) => boolean;
|
|
2129
|
+
/**
|
|
2130
|
+
This is the interface plugin objects conform to.
|
|
2131
|
+
*/
|
|
2132
|
+
interface PluginValue {
|
|
2181
2133
|
/**
|
|
2182
|
-
|
|
2183
|
-
|
|
2134
|
+
Notifies the plugin of an update that happened in the view. This
|
|
2135
|
+
is called _before_ the view updates its own DOM. It is
|
|
2136
|
+
responsible for updating the plugin's internal state (including
|
|
2137
|
+
any state that may be read by plugin fields) and _writing_ to
|
|
2138
|
+
the DOM for the changes in the update. To avoid unnecessary
|
|
2139
|
+
layout recomputations, it should _not_ read the DOM layout—use
|
|
2140
|
+
[`requestMeasure`](https://codemirror.net/6/docs/ref/#view.EditorView.requestMeasure) to schedule
|
|
2141
|
+
your code in a DOM reading phase if you need to.
|
|
2184
2142
|
*/
|
|
2185
|
-
|
|
2143
|
+
update?(_update: ViewUpdate): void;
|
|
2186
2144
|
/**
|
|
2187
|
-
|
|
2188
|
-
|
|
2145
|
+
Called when the plugin is no longer going to be used. Should
|
|
2146
|
+
revert any changes the plugin made to the DOM.
|
|
2189
2147
|
*/
|
|
2190
|
-
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
declare class StyleModule {
|
|
2194
|
-
constructor(spec: {[selector: string]: StyleSpec}, options?: {
|
|
2195
|
-
finish?(sel: string): string
|
|
2196
|
-
})
|
|
2197
|
-
getRules(): string
|
|
2198
|
-
static mount(root: Document | ShadowRoot | DocumentOrShadowRoot, module: StyleModule | ReadonlyArray<StyleModule>): void
|
|
2199
|
-
static newName(): string
|
|
2148
|
+
destroy?(): void;
|
|
2200
2149
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2150
|
+
declare const isFieldProvider: unique symbol;
|
|
2151
|
+
/**
|
|
2152
|
+
Used to [declare](https://codemirror.net/6/docs/ref/#view.PluginSpec.provide) which
|
|
2153
|
+
[fields](https://codemirror.net/6/docs/ref/#view.PluginValue) a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin)
|
|
2154
|
+
provides.
|
|
2155
|
+
*/
|
|
2156
|
+
declare class PluginFieldProvider<V> {
|
|
2157
|
+
private [isFieldProvider];
|
|
2204
2158
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2159
|
+
/**
|
|
2160
|
+
Plugin fields are a mechanism for allowing plugins to provide
|
|
2161
|
+
values that can be retrieved through the
|
|
2162
|
+
[`pluginField`](https://codemirror.net/6/docs/ref/#view.EditorView.pluginField) view method.
|
|
2163
|
+
*/
|
|
2164
|
+
declare class PluginField<T> {
|
|
2211
2165
|
/**
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2166
|
+
Create a [provider](https://codemirror.net/6/docs/ref/#view.PluginFieldProvider) for this field,
|
|
2167
|
+
to use with a plugin's [provide](https://codemirror.net/6/docs/ref/#view.PluginSpec.provide)
|
|
2168
|
+
option.
|
|
2215
2169
|
*/
|
|
2216
|
-
|
|
2170
|
+
from<V extends PluginValue>(get: (value: V) => T): PluginFieldProvider<V>;
|
|
2217
2171
|
/**
|
|
2218
|
-
|
|
2219
|
-
inclusive. Overrides `inclusive`, when both are present.
|
|
2172
|
+
Define a new plugin field.
|
|
2220
2173
|
*/
|
|
2221
|
-
|
|
2174
|
+
static define<T>(): PluginField<T>;
|
|
2222
2175
|
/**
|
|
2223
|
-
|
|
2176
|
+
This field can be used by plugins to provide
|
|
2177
|
+
[decorations](https://codemirror.net/6/docs/ref/#view.Decoration).
|
|
2178
|
+
|
|
2179
|
+
**Note**: For reasons of data flow (plugins are only updated
|
|
2180
|
+
after the viewport is computed), decorations produced by plugins
|
|
2181
|
+
are _not_ taken into account when predicting the vertical layout
|
|
2182
|
+
structure of the editor. Thus, things like large widgets or big
|
|
2183
|
+
replacements (i.e. code folding) should be provided through the
|
|
2184
|
+
state-level [`decorations` facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations),
|
|
2185
|
+
not this plugin field. Specifically, replacing decorations that
|
|
2186
|
+
cross line boundaries will break if provided through a plugin.
|
|
2224
2187
|
*/
|
|
2225
|
-
|
|
2188
|
+
static decorations: PluginField<DecorationSet>;
|
|
2226
2189
|
/**
|
|
2227
|
-
|
|
2228
|
-
|
|
2190
|
+
Used to provide ranges that should be treated as atoms as far as
|
|
2191
|
+
cursor motion is concerned. This causes methods like
|
|
2192
|
+
[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
|
|
2193
|
+
[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
|
|
2194
|
+
commands built on top of them) to skip across such regions when
|
|
2195
|
+
a selection endpoint would enter them. This does _not_ prevent
|
|
2196
|
+
direct programmatic [selection
|
|
2197
|
+
updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
|
|
2198
|
+
regions.
|
|
2229
2199
|
*/
|
|
2230
|
-
|
|
2231
|
-
[key: string]: string;
|
|
2232
|
-
};
|
|
2200
|
+
static atomicRanges: PluginField<RangeSet<any>>;
|
|
2233
2201
|
/**
|
|
2234
|
-
|
|
2202
|
+
Plugins can provide additional scroll margins (space around the
|
|
2203
|
+
sides of the scrolling element that should be considered
|
|
2204
|
+
invisible) through this field. This can be useful when the
|
|
2205
|
+
plugin introduces elements that cover part of that element (for
|
|
2206
|
+
example a horizontally fixed gutter).
|
|
2235
2207
|
*/
|
|
2236
|
-
|
|
2208
|
+
static scrollMargins: PluginField<Partial<Rect> | null>;
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
Provides additional information when defining a [view
|
|
2212
|
+
plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin).
|
|
2213
|
+
*/
|
|
2214
|
+
interface PluginSpec<V extends PluginValue> {
|
|
2237
2215
|
/**
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2216
|
+
Register the given [event
|
|
2217
|
+
handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers) for the plugin.
|
|
2218
|
+
When called, these will have their `this` bound to the plugin
|
|
2219
|
+
value.
|
|
2242
2220
|
*/
|
|
2243
|
-
|
|
2221
|
+
eventHandlers?: DOMEventHandlers<V>;
|
|
2244
2222
|
/**
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2223
|
+
Allow the plugin to provide decorations. When given, this should
|
|
2224
|
+
a function that take the plugin value and return a [decoration
|
|
2225
|
+
set](https://codemirror.net/6/docs/ref/#view.DecorationSet). See also the caveat about
|
|
2226
|
+
[layout-changing decorations](https://codemirror.net/6/docs/ref/#view.PluginField^decorations)
|
|
2227
|
+
from plugins.
|
|
2248
2228
|
*/
|
|
2249
|
-
|
|
2250
|
-
}
|
|
2251
|
-
interface WidgetDecorationSpec {
|
|
2229
|
+
decorations?: (value: V) => DecorationSet;
|
|
2252
2230
|
/**
|
|
2253
|
-
|
|
2231
|
+
Specify that the plugin provides [plugin
|
|
2232
|
+
field](https://codemirror.net/6/docs/ref/#view.PluginField) values. Use a field's
|
|
2233
|
+
[`from`](https://codemirror.net/6/docs/ref/#view.PluginField.from) method to create these
|
|
2234
|
+
providers.
|
|
2254
2235
|
*/
|
|
2255
|
-
|
|
2236
|
+
provide?: PluginFieldProvider<V> | readonly PluginFieldProvider<V>[];
|
|
2237
|
+
}
|
|
2238
|
+
/**
|
|
2239
|
+
View plugins associate stateful values with a view. They can
|
|
2240
|
+
influence the way the content is drawn, and are notified of things
|
|
2241
|
+
that happen in the view.
|
|
2242
|
+
*/
|
|
2243
|
+
declare class ViewPlugin<V extends PluginValue> {
|
|
2256
2244
|
/**
|
|
2257
|
-
|
|
2258
|
-
positive, the widget will be drawn after the cursor if the
|
|
2259
|
-
cursor is on the same position. Otherwise, it'll be drawn before
|
|
2260
|
-
it. When multiple widgets sit at the same position, their `side`
|
|
2261
|
-
values will determine their ordering—those with a lower value
|
|
2262
|
-
come first. Defaults to 0.
|
|
2245
|
+
Instances of this class act as extensions.
|
|
2263
2246
|
*/
|
|
2264
|
-
|
|
2247
|
+
extension: Extension;
|
|
2248
|
+
private constructor();
|
|
2265
2249
|
/**
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
between the surrounding text.
|
|
2269
|
-
|
|
2270
|
-
Note that block-level decorations should not have vertical
|
|
2271
|
-
margins, and if you dynamically change their height, you should
|
|
2272
|
-
make sure to call
|
|
2273
|
-
[`requestMeasure`](https://codemirror.net/6/docs/ref/#view.EditorView.requestMeasure), so that the
|
|
2274
|
-
editor can update its information about its vertical layout.
|
|
2250
|
+
Define a plugin from a constructor function that creates the
|
|
2251
|
+
plugin's value, given an editor view.
|
|
2275
2252
|
*/
|
|
2276
|
-
|
|
2253
|
+
static define<V extends PluginValue>(create: (view: EditorView) => V, spec?: PluginSpec<V>): ViewPlugin<V>;
|
|
2277
2254
|
/**
|
|
2278
|
-
|
|
2255
|
+
Create a plugin for a class whose constructor takes a single
|
|
2256
|
+
editor view as argument.
|
|
2279
2257
|
*/
|
|
2280
|
-
|
|
2258
|
+
static fromClass<V extends PluginValue>(cls: {
|
|
2259
|
+
new (view: EditorView): V;
|
|
2260
|
+
}, spec?: PluginSpec<V>): ViewPlugin<V>;
|
|
2281
2261
|
}
|
|
2282
|
-
interface
|
|
2262
|
+
interface MeasureRequest<T> {
|
|
2283
2263
|
/**
|
|
2284
|
-
|
|
2285
|
-
|
|
2264
|
+
Called in a DOM read phase to gather information that requires
|
|
2265
|
+
DOM layout. Should _not_ mutate the document.
|
|
2286
2266
|
*/
|
|
2287
|
-
|
|
2267
|
+
read(view: EditorView): T;
|
|
2288
2268
|
/**
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
whether the cursor can be drawn on its sides. Defaults to false
|
|
2292
|
-
for inline replacements, and true for block replacements.
|
|
2269
|
+
Called in a DOM write phase to update the document. Should _not_
|
|
2270
|
+
do anything that triggers DOM layout.
|
|
2293
2271
|
*/
|
|
2294
|
-
|
|
2272
|
+
write?(measure: T, view: EditorView): void;
|
|
2295
2273
|
/**
|
|
2296
|
-
|
|
2274
|
+
When multiple requests with the same key are scheduled, only the
|
|
2275
|
+
last one will actually be ran.
|
|
2297
2276
|
*/
|
|
2298
|
-
|
|
2277
|
+
key?: any;
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
2281
|
+
class, which describe what happened, whenever the view is updated.
|
|
2282
|
+
*/
|
|
2283
|
+
declare class ViewUpdate {
|
|
2299
2284
|
/**
|
|
2300
|
-
|
|
2285
|
+
The editor view that the update is associated with.
|
|
2301
2286
|
*/
|
|
2302
|
-
|
|
2287
|
+
readonly view: EditorView;
|
|
2303
2288
|
/**
|
|
2304
|
-
|
|
2289
|
+
The new editor state.
|
|
2305
2290
|
*/
|
|
2306
|
-
|
|
2291
|
+
readonly state: EditorState;
|
|
2307
2292
|
/**
|
|
2308
|
-
|
|
2293
|
+
The transactions involved in the update. May be empty.
|
|
2309
2294
|
*/
|
|
2310
|
-
|
|
2311
|
-
}
|
|
2312
|
-
interface LineDecorationSpec {
|
|
2295
|
+
readonly transactions: readonly Transaction[];
|
|
2313
2296
|
/**
|
|
2314
|
-
|
|
2297
|
+
The changes made to the document by this update.
|
|
2315
2298
|
*/
|
|
2316
|
-
|
|
2317
|
-
[key: string]: string;
|
|
2318
|
-
};
|
|
2299
|
+
readonly changes: ChangeSet;
|
|
2319
2300
|
/**
|
|
2320
|
-
|
|
2301
|
+
The previous editor state.
|
|
2321
2302
|
*/
|
|
2322
|
-
|
|
2303
|
+
readonly startState: EditorState;
|
|
2323
2304
|
/**
|
|
2324
|
-
|
|
2305
|
+
Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
|
|
2306
|
+
[visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
|
|
2307
|
+
update.
|
|
2325
2308
|
*/
|
|
2326
|
-
|
|
2327
|
-
}
|
|
2328
|
-
/**
|
|
2329
|
-
Widgets added to the content are described by subclasses of this
|
|
2330
|
-
class. Using a description object like that makes it possible to
|
|
2331
|
-
delay creating of the DOM structure for a widget until it is
|
|
2332
|
-
needed, and to avoid redrawing widgets even when the decorations
|
|
2333
|
-
that define them are recreated.
|
|
2334
|
-
*/
|
|
2335
|
-
declare abstract class WidgetType {
|
|
2309
|
+
get viewportChanged(): boolean;
|
|
2336
2310
|
/**
|
|
2337
|
-
|
|
2311
|
+
Indicates whether the line height in the editor changed in this update.
|
|
2338
2312
|
*/
|
|
2339
|
-
|
|
2313
|
+
get heightChanged(): boolean;
|
|
2340
2314
|
/**
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
specific class will be passed to this method.) This is used to
|
|
2344
|
-
avoid redrawing widgets when they are replaced by a new
|
|
2345
|
-
decoration of the same type. The default implementation just
|
|
2346
|
-
returns `false`, which will cause new instances of the widget to
|
|
2347
|
-
always be redrawn.
|
|
2315
|
+
Returns true when the document changed or the size of the editor
|
|
2316
|
+
or the lines or characters within it has changed.
|
|
2348
2317
|
*/
|
|
2349
|
-
|
|
2318
|
+
get geometryChanged(): boolean;
|
|
2350
2319
|
/**
|
|
2351
|
-
|
|
2352
|
-
different, non-`eq` content) to reflect this widget. May return
|
|
2353
|
-
true to indicate that it could update, false to indicate it
|
|
2354
|
-
couldn't (in which case the widget will be redrawn). The default
|
|
2355
|
-
implementation just returns false.
|
|
2320
|
+
True when this update indicates a focus change.
|
|
2356
2321
|
*/
|
|
2357
|
-
|
|
2322
|
+
get focusChanged(): boolean;
|
|
2358
2323
|
/**
|
|
2359
|
-
|
|
2360
|
-
estimating the height of content that hasn't been drawn. May
|
|
2361
|
-
return -1 to indicate you don't know. The default implementation
|
|
2362
|
-
returns -1.
|
|
2324
|
+
Whether the document changed in this update.
|
|
2363
2325
|
*/
|
|
2364
|
-
get
|
|
2326
|
+
get docChanged(): boolean;
|
|
2365
2327
|
/**
|
|
2366
|
-
|
|
2367
|
-
should be ignored by the editor. The default is to ignore all
|
|
2368
|
-
events.
|
|
2328
|
+
Whether the selection was explicitly set in this update.
|
|
2369
2329
|
*/
|
|
2370
|
-
|
|
2330
|
+
get selectionSet(): boolean;
|
|
2371
2331
|
}
|
|
2332
|
+
|
|
2372
2333
|
/**
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
*/
|
|
2377
|
-
declare type DecorationSet = RangeSet<Decoration>;
|
|
2378
|
-
/**
|
|
2379
|
-
The different types of blocks that can occur in an editor view.
|
|
2334
|
+
Interface that objects registered with
|
|
2335
|
+
[`EditorView.mouseSelectionStyle`](https://codemirror.net/6/docs/ref/#view.EditorView^mouseSelectionStyle)
|
|
2336
|
+
must conform to.
|
|
2380
2337
|
*/
|
|
2381
|
-
|
|
2338
|
+
interface MouseSelectionStyle {
|
|
2382
2339
|
/**
|
|
2383
|
-
|
|
2340
|
+
Return a new selection for the mouse gesture that starts with
|
|
2341
|
+
the event that was originally given to the constructor, and ends
|
|
2342
|
+
with the event passed here. In case of a plain click, those may
|
|
2343
|
+
both be the `mousedown` event, in case of a drag gesture, the
|
|
2344
|
+
latest `mousemove` event will be passed.
|
|
2345
|
+
|
|
2346
|
+
When `extend` is true, that means the new selection should, if
|
|
2347
|
+
possible, extend the start selection. If `multiple` is true, the
|
|
2348
|
+
new selection should be added to the original selection.
|
|
2384
2349
|
*/
|
|
2385
|
-
|
|
2350
|
+
get: (curEvent: MouseEvent, extend: boolean, multiple: boolean) => EditorSelection;
|
|
2386
2351
|
/**
|
|
2387
|
-
|
|
2352
|
+
Called when the view is updated while the gesture is in
|
|
2353
|
+
progress. When the document changes, it may be necessary to map
|
|
2354
|
+
some data (like the original selection or start position)
|
|
2355
|
+
through the changes.
|
|
2356
|
+
|
|
2357
|
+
This may return `true` to indicate that the `get` method should
|
|
2358
|
+
get queried again after the update, because something in the
|
|
2359
|
+
update could change its result. Be wary of infinite loops when
|
|
2360
|
+
using this (where `get` returns a new selection, which will
|
|
2361
|
+
trigger `update`, which schedules another `get` in response).
|
|
2388
2362
|
*/
|
|
2389
|
-
|
|
2363
|
+
update: (update: ViewUpdate) => boolean | void;
|
|
2364
|
+
}
|
|
2365
|
+
declare type MakeSelectionStyle = (view: EditorView, event: MouseEvent) => MouseSelectionStyle | null;
|
|
2366
|
+
|
|
2367
|
+
/**
|
|
2368
|
+
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
2369
|
+
*/
|
|
2370
|
+
declare enum Direction {
|
|
2390
2371
|
/**
|
|
2391
|
-
|
|
2372
|
+
Left-to-right.
|
|
2392
2373
|
*/
|
|
2393
|
-
|
|
2374
|
+
LTR = 0,
|
|
2394
2375
|
/**
|
|
2395
|
-
|
|
2376
|
+
Right-to-left.
|
|
2396
2377
|
*/
|
|
2397
|
-
|
|
2378
|
+
RTL = 1
|
|
2398
2379
|
}
|
|
2399
2380
|
/**
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
[`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range), which adds a start and end position.
|
|
2381
|
+
Represents a contiguous range of text that has a single direction
|
|
2382
|
+
(as in left-to-right or right-to-left).
|
|
2403
2383
|
*/
|
|
2404
|
-
declare
|
|
2384
|
+
declare class BidiSpan {
|
|
2405
2385
|
/**
|
|
2406
|
-
The
|
|
2407
|
-
include additional properties in there to store metadata about
|
|
2408
|
-
your decoration.
|
|
2386
|
+
The start of the span (relative to the start of the line).
|
|
2409
2387
|
*/
|
|
2410
|
-
readonly
|
|
2411
|
-
abstract eq(other: Decoration): boolean;
|
|
2388
|
+
readonly from: number;
|
|
2412
2389
|
/**
|
|
2413
|
-
|
|
2414
|
-
content in its range. Nested mark decorations will cause nested
|
|
2415
|
-
DOM elements to be created. Nesting order is determined by
|
|
2416
|
-
precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations) or
|
|
2417
|
-
(below the facet-provided decorations) [view
|
|
2418
|
-
plugin](https://codemirror.net/6/docs/ref/#view.PluginSpec.decorations). Such elements are split
|
|
2419
|
-
on line boundaries and on the boundaries of higher-precedence
|
|
2420
|
-
decorations.
|
|
2390
|
+
The end of the span.
|
|
2421
2391
|
*/
|
|
2422
|
-
|
|
2392
|
+
readonly to: number;
|
|
2423
2393
|
/**
|
|
2424
|
-
|
|
2425
|
-
|
|
2394
|
+
The ["bidi
|
|
2395
|
+
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
2396
|
+
of the span (in this context, 0 means
|
|
2397
|
+
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
2398
|
+
number inside right-to-left text).
|
|
2426
2399
|
*/
|
|
2427
|
-
|
|
2400
|
+
readonly level: number;
|
|
2428
2401
|
/**
|
|
2429
|
-
|
|
2430
|
-
a widget, or simply hides it.
|
|
2402
|
+
The direction of this span.
|
|
2431
2403
|
*/
|
|
2432
|
-
|
|
2404
|
+
get dir(): Direction;
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
/**
|
|
2408
|
+
Record used to represent information about a block-level element
|
|
2409
|
+
in the editor view.
|
|
2410
|
+
*/
|
|
2411
|
+
declare class BlockInfo {
|
|
2433
2412
|
/**
|
|
2434
|
-
|
|
2435
|
-
line starting at the given position.
|
|
2413
|
+
The start of the element in the document.
|
|
2436
2414
|
*/
|
|
2437
|
-
|
|
2415
|
+
readonly from: number;
|
|
2438
2416
|
/**
|
|
2439
|
-
|
|
2440
|
-
decorated range or ranges. If the ranges aren't already sorted,
|
|
2441
|
-
pass `true` for `sort` to make the library sort them for you.
|
|
2417
|
+
The length of the element.
|
|
2442
2418
|
*/
|
|
2443
|
-
|
|
2419
|
+
readonly length: number;
|
|
2444
2420
|
/**
|
|
2445
|
-
The
|
|
2421
|
+
The top position of the element (relative to the top of the
|
|
2422
|
+
document).
|
|
2446
2423
|
*/
|
|
2447
|
-
static none: DecorationSet;
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
|
-
/**
|
|
2451
|
-
Basic rectangle type.
|
|
2452
|
-
*/
|
|
2453
|
-
interface Rect {
|
|
2454
|
-
readonly left: number;
|
|
2455
|
-
readonly right: number;
|
|
2456
2424
|
readonly top: number;
|
|
2457
|
-
readonly bottom: number;
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
/**
|
|
2461
|
-
Command functions are used in key bindings and other types of user
|
|
2462
|
-
actions. Given an editor view, they check whether their effect can
|
|
2463
|
-
apply to the editor, and if it can, perform it as a side effect
|
|
2464
|
-
(which usually means [dispatching](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) a
|
|
2465
|
-
transaction) and return `true`.
|
|
2466
|
-
*/
|
|
2467
|
-
declare type Command = (target: EditorView) => boolean;
|
|
2468
|
-
/**
|
|
2469
|
-
This is the interface plugin objects conform to.
|
|
2470
|
-
*/
|
|
2471
|
-
interface PluginValue {
|
|
2472
2425
|
/**
|
|
2473
|
-
|
|
2474
|
-
is called _before_ the view updates its own DOM. It is
|
|
2475
|
-
responsible for updating the plugin's internal state (including
|
|
2476
|
-
any state that may be read by plugin fields) and _writing_ to
|
|
2477
|
-
the DOM for the changes in the update. To avoid unnecessary
|
|
2478
|
-
layout recomputations, it should _not_ read the DOM layout—use
|
|
2479
|
-
[`requestMeasure`](https://codemirror.net/6/docs/ref/#view.EditorView.requestMeasure) to schedule
|
|
2480
|
-
your code in a DOM reading phase if you need to.
|
|
2426
|
+
Its height.
|
|
2481
2427
|
*/
|
|
2482
|
-
|
|
2428
|
+
readonly height: number;
|
|
2483
2429
|
/**
|
|
2484
|
-
|
|
2485
|
-
|
|
2430
|
+
The type of element this is. When querying lines, this may be
|
|
2431
|
+
an array of all the blocks that make up the line.
|
|
2486
2432
|
*/
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
*/
|
|
2495
|
-
|
|
2496
|
-
private [isFieldProvider];
|
|
2433
|
+
readonly type: BlockType | readonly BlockInfo[];
|
|
2434
|
+
/**
|
|
2435
|
+
The end of the element as a document position.
|
|
2436
|
+
*/
|
|
2437
|
+
get to(): number;
|
|
2438
|
+
/**
|
|
2439
|
+
The bottom position of the element.
|
|
2440
|
+
*/
|
|
2441
|
+
get bottom(): number;
|
|
2497
2442
|
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
values that can be retrieved through the
|
|
2501
|
-
[`pluginField`](https://codemirror.net/6/docs/ref/#view.EditorView.pluginField) view method.
|
|
2502
|
-
*/
|
|
2503
|
-
declare class PluginField<T> {
|
|
2443
|
+
|
|
2444
|
+
interface EditorConfig {
|
|
2504
2445
|
/**
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
option.
|
|
2446
|
+
The view's initial state. Defaults to an extension-less state
|
|
2447
|
+
with an empty document.
|
|
2508
2448
|
*/
|
|
2509
|
-
|
|
2449
|
+
state?: EditorState;
|
|
2510
2450
|
/**
|
|
2511
|
-
|
|
2451
|
+
If the view is going to be mounted in a shadow root or document
|
|
2452
|
+
other than the one held by the global variable `document` (the
|
|
2453
|
+
default), you should pass it here. If you provide `parent`, but
|
|
2454
|
+
not this option, the editor will automatically look up a root
|
|
2455
|
+
from the parent.
|
|
2512
2456
|
*/
|
|
2513
|
-
|
|
2457
|
+
root?: Document | ShadowRoot;
|
|
2514
2458
|
/**
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
are _not_ taken into account when predicting the vertical layout
|
|
2521
|
-
structure of the editor. Thus, things like large widgets or big
|
|
2522
|
-
replacements (i.e. code folding) should be provided through the
|
|
2523
|
-
state-level [`decorations` facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations),
|
|
2524
|
-
not this plugin field. Specifically, replacing decorations that
|
|
2525
|
-
cross line boundaries will break if provided through a plugin.
|
|
2526
|
-
*/
|
|
2527
|
-
static decorations: PluginField<DecorationSet>;
|
|
2528
|
-
/**
|
|
2529
|
-
Used to provide ranges that should be treated as atoms as far as
|
|
2530
|
-
cursor motion is concerned. This causes methods like
|
|
2531
|
-
[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
|
|
2532
|
-
[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
|
|
2533
|
-
commands built on top of them) to skip across such regions when
|
|
2534
|
-
a selection endpoint would enter them. This does _not_ prevent
|
|
2535
|
-
direct programmatic [selection
|
|
2536
|
-
updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
|
|
2537
|
-
regions.
|
|
2459
|
+
Override the transaction [dispatch
|
|
2460
|
+
function](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) for this editor view, which
|
|
2461
|
+
is the way updates get routed to the view. Your implementation,
|
|
2462
|
+
if provided, should probably call the view's [`update`
|
|
2463
|
+
method](https://codemirror.net/6/docs/ref/#view.EditorView.update).
|
|
2538
2464
|
*/
|
|
2539
|
-
|
|
2465
|
+
dispatch?: (tr: Transaction) => void;
|
|
2540
2466
|
/**
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
plugin introduces elements that cover part of that element (for
|
|
2545
|
-
example a horizontally fixed gutter).
|
|
2467
|
+
When given, the editor is immediately appended to the given
|
|
2468
|
+
element on creation. (Otherwise, you'll have to place the view's
|
|
2469
|
+
[`dom`](https://codemirror.net/6/docs/ref/#view.EditorView.dom) element in the document yourself.)
|
|
2546
2470
|
*/
|
|
2547
|
-
|
|
2471
|
+
parent?: Element | DocumentFragment;
|
|
2548
2472
|
}
|
|
2549
2473
|
/**
|
|
2550
|
-
|
|
2551
|
-
|
|
2474
|
+
An editor view represents the editor's user interface. It holds
|
|
2475
|
+
the editable DOM surface, and possibly other elements such as the
|
|
2476
|
+
line number gutter. It handles events and dispatches state
|
|
2477
|
+
transactions for editing actions.
|
|
2552
2478
|
*/
|
|
2553
|
-
|
|
2479
|
+
declare class EditorView {
|
|
2554
2480
|
/**
|
|
2555
|
-
|
|
2556
|
-
handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers) for the plugin.
|
|
2557
|
-
When called, these will have their `this` bound to the plugin
|
|
2558
|
-
value.
|
|
2481
|
+
The current editor state.
|
|
2559
2482
|
*/
|
|
2560
|
-
|
|
2483
|
+
get state(): EditorState;
|
|
2561
2484
|
/**
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2485
|
+
To be able to display large documents without consuming too much
|
|
2486
|
+
memory or overloading the browser, CodeMirror only draws the
|
|
2487
|
+
code that is visible (plus a margin around it) to the DOM. This
|
|
2488
|
+
property tells you the extent of the current drawn viewport, in
|
|
2489
|
+
document positions.
|
|
2567
2490
|
*/
|
|
2568
|
-
|
|
2491
|
+
get viewport(): {
|
|
2492
|
+
from: number;
|
|
2493
|
+
to: number;
|
|
2494
|
+
};
|
|
2569
2495
|
/**
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2496
|
+
When there are, for example, large collapsed ranges in the
|
|
2497
|
+
viewport, its size can be a lot bigger than the actual visible
|
|
2498
|
+
content. Thus, if you are doing something like styling the
|
|
2499
|
+
content in the viewport, it is preferable to only do so for
|
|
2500
|
+
these ranges, which are the subset of the viewport that is
|
|
2501
|
+
actually drawn.
|
|
2574
2502
|
*/
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
influence the way the content is drawn, and are notified of things
|
|
2580
|
-
that happen in the view.
|
|
2581
|
-
*/
|
|
2582
|
-
declare class ViewPlugin<V extends PluginValue> {
|
|
2503
|
+
get visibleRanges(): readonly {
|
|
2504
|
+
from: number;
|
|
2505
|
+
to: number;
|
|
2506
|
+
}[];
|
|
2583
2507
|
/**
|
|
2584
|
-
|
|
2508
|
+
Returns false when the editor is entirely scrolled out of view
|
|
2509
|
+
or otherwise hidden.
|
|
2585
2510
|
*/
|
|
2586
|
-
|
|
2587
|
-
private constructor();
|
|
2511
|
+
get inView(): boolean;
|
|
2588
2512
|
/**
|
|
2589
|
-
|
|
2590
|
-
|
|
2513
|
+
Indicates whether the user is currently composing text via
|
|
2514
|
+
[IME](https://en.wikipedia.org/wiki/Input_method).
|
|
2591
2515
|
*/
|
|
2592
|
-
|
|
2516
|
+
get composing(): boolean;
|
|
2517
|
+
private _dispatch;
|
|
2593
2518
|
/**
|
|
2594
|
-
|
|
2595
|
-
editor view as argument.
|
|
2519
|
+
The document or shadow root that the view lives in.
|
|
2596
2520
|
*/
|
|
2597
|
-
|
|
2598
|
-
new (view: EditorView): V;
|
|
2599
|
-
}, spec?: PluginSpec<V>): ViewPlugin<V>;
|
|
2600
|
-
}
|
|
2601
|
-
interface MeasureRequest<T> {
|
|
2521
|
+
readonly root: DocumentOrShadowRoot;
|
|
2602
2522
|
/**
|
|
2603
|
-
|
|
2604
|
-
DOM layout. Should _not_ mutate the document.
|
|
2523
|
+
The DOM element that wraps the entire editor view.
|
|
2605
2524
|
*/
|
|
2606
|
-
|
|
2525
|
+
readonly dom: HTMLElement;
|
|
2607
2526
|
/**
|
|
2608
|
-
|
|
2609
|
-
|
|
2527
|
+
The DOM element that can be styled to scroll. (Note that it may
|
|
2528
|
+
not have been, so you can't assume this is scrollable.)
|
|
2610
2529
|
*/
|
|
2611
|
-
|
|
2530
|
+
readonly scrollDOM: HTMLElement;
|
|
2612
2531
|
/**
|
|
2613
|
-
|
|
2614
|
-
|
|
2532
|
+
The editable DOM element holding the editor content. You should
|
|
2533
|
+
not, usually, interact with this content directly though the
|
|
2534
|
+
DOM, since the editor will immediately undo most of the changes
|
|
2535
|
+
you make. Instead, [dispatch](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch)
|
|
2536
|
+
[transactions](https://codemirror.net/6/docs/ref/#state.Transaction) to modify content, and
|
|
2537
|
+
[decorations](https://codemirror.net/6/docs/ref/#view.Decoration) to style it.
|
|
2615
2538
|
*/
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2539
|
+
readonly contentDOM: HTMLElement;
|
|
2540
|
+
private announceDOM;
|
|
2541
|
+
private plugins;
|
|
2542
|
+
private editorAttrs;
|
|
2543
|
+
private contentAttrs;
|
|
2544
|
+
private styleModules;
|
|
2545
|
+
private bidiCache;
|
|
2546
|
+
private destroyed;
|
|
2623
2547
|
/**
|
|
2624
|
-
|
|
2548
|
+
Construct a new view. You'll usually want to put `view.dom` into
|
|
2549
|
+
your document after creating a view, so that the user can see
|
|
2550
|
+
it.
|
|
2625
2551
|
*/
|
|
2626
|
-
|
|
2552
|
+
constructor(
|
|
2627
2553
|
/**
|
|
2628
|
-
|
|
2554
|
+
Initialization options.
|
|
2629
2555
|
*/
|
|
2630
|
-
|
|
2556
|
+
config?: EditorConfig);
|
|
2631
2557
|
/**
|
|
2632
|
-
|
|
2558
|
+
All regular editor state updates should go through this. It
|
|
2559
|
+
takes a transaction or transaction spec and updates the view to
|
|
2560
|
+
show the new state produced by that transaction. Its
|
|
2561
|
+
implementation can be overridden with an
|
|
2562
|
+
[option](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.dispatch). This
|
|
2563
|
+
function is bound to the view instance, so it does not have to
|
|
2564
|
+
be called as a method.
|
|
2633
2565
|
*/
|
|
2634
|
-
|
|
2566
|
+
dispatch(tr: Transaction): void;
|
|
2567
|
+
dispatch(...specs: TransactionSpec[]): void;
|
|
2635
2568
|
/**
|
|
2636
|
-
|
|
2569
|
+
Update the view for the given array of transactions. This will
|
|
2570
|
+
update the visible document and selection to match the state
|
|
2571
|
+
produced by the transactions, and notify view plugins of the
|
|
2572
|
+
change. You should usually call
|
|
2573
|
+
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
|
|
2574
|
+
as a primitive.
|
|
2637
2575
|
*/
|
|
2638
|
-
readonly
|
|
2576
|
+
update(transactions: readonly Transaction[]): void;
|
|
2639
2577
|
/**
|
|
2640
|
-
|
|
2578
|
+
Reset the view to the given state. (This will cause the entire
|
|
2579
|
+
document to be redrawn and all view plugins to be reinitialized,
|
|
2580
|
+
so you should probably only use it when the new state isn't
|
|
2581
|
+
derived from the old state. Otherwise, use
|
|
2582
|
+
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
2641
2583
|
*/
|
|
2642
|
-
|
|
2584
|
+
setState(newState: EditorState): void;
|
|
2585
|
+
private updatePlugins;
|
|
2643
2586
|
/**
|
|
2644
|
-
|
|
2645
|
-
[visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
|
|
2646
|
-
update.
|
|
2587
|
+
Get the CSS classes for the currently active editor themes.
|
|
2647
2588
|
*/
|
|
2648
|
-
get
|
|
2589
|
+
get themeClasses(): string;
|
|
2590
|
+
private updateAttrs;
|
|
2591
|
+
private showAnnouncements;
|
|
2592
|
+
private mountStyles;
|
|
2593
|
+
private readMeasured;
|
|
2649
2594
|
/**
|
|
2650
|
-
|
|
2595
|
+
Schedule a layout measurement, optionally providing callbacks to
|
|
2596
|
+
do custom DOM measuring followed by a DOM write phase. Using
|
|
2597
|
+
this is preferable reading DOM layout directly from, for
|
|
2598
|
+
example, an event handler, because it'll make sure measuring and
|
|
2599
|
+
drawing done by other components is synchronized, avoiding
|
|
2600
|
+
unnecessary DOM layout computations.
|
|
2651
2601
|
*/
|
|
2652
|
-
|
|
2602
|
+
requestMeasure<T>(request?: MeasureRequest<T>): void;
|
|
2653
2603
|
/**
|
|
2654
|
-
|
|
2655
|
-
|
|
2604
|
+
Collect all values provided by the active plugins for a given
|
|
2605
|
+
field.
|
|
2656
2606
|
*/
|
|
2657
|
-
|
|
2607
|
+
pluginField<T>(field: PluginField<T>): readonly T[];
|
|
2658
2608
|
/**
|
|
2659
|
-
|
|
2609
|
+
Get the value of a specific plugin, if present. Note that
|
|
2610
|
+
plugins that crash can be dropped from a view, so even when you
|
|
2611
|
+
know you registered a given plugin, it is recommended to check
|
|
2612
|
+
the return value of this method.
|
|
2660
2613
|
*/
|
|
2661
|
-
|
|
2614
|
+
plugin<T>(plugin: ViewPlugin<T>): T | null;
|
|
2662
2615
|
/**
|
|
2663
|
-
|
|
2616
|
+
The top position of the document, in screen coordinates. This
|
|
2617
|
+
may be negative when the editor is scrolled down. Points
|
|
2618
|
+
directly to the top of the first line, not above the padding.
|
|
2664
2619
|
*/
|
|
2665
|
-
get
|
|
2620
|
+
get documentTop(): number;
|
|
2666
2621
|
/**
|
|
2667
|
-
|
|
2622
|
+
Reports the padding above and below the document.
|
|
2668
2623
|
*/
|
|
2669
|
-
get
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
Interface that objects registered with
|
|
2674
|
-
[`EditorView.mouseSelectionStyle`](https://codemirror.net/6/docs/ref/#view.EditorView^mouseSelectionStyle)
|
|
2675
|
-
must conform to.
|
|
2676
|
-
*/
|
|
2677
|
-
interface MouseSelectionStyle {
|
|
2624
|
+
get documentPadding(): {
|
|
2625
|
+
top: number;
|
|
2626
|
+
bottom: number;
|
|
2627
|
+
};
|
|
2678
2628
|
/**
|
|
2679
|
-
|
|
2680
|
-
the event that was originally given to the constructor, and ends
|
|
2681
|
-
with the event passed here. In case of a plain click, those may
|
|
2682
|
-
both be the `mousedown` event, in case of a drag gesture, the
|
|
2683
|
-
latest `mousemove` event will be passed.
|
|
2629
|
+
Find the line or block widget at the given vertical position.
|
|
2684
2630
|
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2631
|
+
By default, this position is interpreted as a screen position,
|
|
2632
|
+
meaning `docTop` is set to the DOM top position of the editor
|
|
2633
|
+
content (forcing a layout). You can pass a different `docTop`
|
|
2634
|
+
value—for example 0 to interpret `height` as a document-relative
|
|
2635
|
+
position, or a precomputed document top
|
|
2636
|
+
(`view.contentDOM.getBoundingClientRect().top`) to limit layout
|
|
2637
|
+
queries.
|
|
2638
|
+
|
|
2639
|
+
*Deprecated: use `blockAtHeight` instead.*
|
|
2688
2640
|
*/
|
|
2689
|
-
|
|
2641
|
+
blockAtHeight(height: number, docTop?: number): BlockInfo;
|
|
2690
2642
|
/**
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
through the changes.
|
|
2695
|
-
|
|
2696
|
-
This may return `true` to indicate that the `get` method should
|
|
2697
|
-
get queried again after the update, because something in the
|
|
2698
|
-
update could change its result. Be wary of infinite loops when
|
|
2699
|
-
using this (where `get` returns a new selection, which will
|
|
2700
|
-
trigger `update`, which schedules another `get` in response).
|
|
2643
|
+
Find the text line or block widget at the given vertical
|
|
2644
|
+
position (which is interpreted as relative to the [top of the
|
|
2645
|
+
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
|
|
2701
2646
|
*/
|
|
2702
|
-
|
|
2703
|
-
}
|
|
2704
|
-
declare type MakeSelectionStyle = (view: EditorView, event: MouseEvent) => MouseSelectionStyle | null;
|
|
2705
|
-
|
|
2706
|
-
/**
|
|
2707
|
-
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
2708
|
-
*/
|
|
2709
|
-
declare enum Direction {
|
|
2647
|
+
elementAtHeight(height: number): BlockInfo;
|
|
2710
2648
|
/**
|
|
2711
|
-
|
|
2649
|
+
Find information for the visual line (see
|
|
2650
|
+
[`visualLineAt`](https://codemirror.net/6/docs/ref/#view.EditorView.visualLineAt)) at the given
|
|
2651
|
+
vertical position. The resulting block info might hold another
|
|
2652
|
+
array of block info structs in its `type` field if this line
|
|
2653
|
+
consists of more than one block.
|
|
2654
|
+
|
|
2655
|
+
Defaults to treating `height` as a screen position. See
|
|
2656
|
+
[`blockAtHeight`](https://codemirror.net/6/docs/ref/#view.EditorView.blockAtHeight) for the
|
|
2657
|
+
interpretation of the `docTop` parameter.
|
|
2658
|
+
|
|
2659
|
+
*Deprecated: use `lineBlockAtHeight` instead.*
|
|
2712
2660
|
*/
|
|
2713
|
-
|
|
2661
|
+
visualLineAtHeight(height: number, docTop?: number): BlockInfo;
|
|
2714
2662
|
/**
|
|
2715
|
-
|
|
2663
|
+
Find the line block (see
|
|
2664
|
+
[`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
|
|
2665
|
+
height.
|
|
2716
2666
|
*/
|
|
2717
|
-
|
|
2718
|
-
}
|
|
2719
|
-
/**
|
|
2720
|
-
Represents a contiguous range of text that has a single direction
|
|
2721
|
-
(as in left-to-right or right-to-left).
|
|
2722
|
-
*/
|
|
2723
|
-
declare class BidiSpan {
|
|
2667
|
+
lineBlockAtHeight(height: number): BlockInfo;
|
|
2724
2668
|
/**
|
|
2725
|
-
|
|
2669
|
+
Iterate over the height information of the visual lines in the
|
|
2670
|
+
viewport. The heights of lines are reported relative to the
|
|
2671
|
+
given document top, which defaults to the screen position of the
|
|
2672
|
+
document (forcing a layout).
|
|
2673
|
+
|
|
2674
|
+
*Deprecated: use `viewportLineBlocks` instead.*
|
|
2726
2675
|
*/
|
|
2727
|
-
|
|
2676
|
+
viewportLines(f: (line: BlockInfo) => void, docTop?: number): void;
|
|
2728
2677
|
/**
|
|
2729
|
-
|
|
2678
|
+
Get the extent and vertical position of all [line
|
|
2679
|
+
blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
|
|
2680
|
+
are relative to the [top of the
|
|
2681
|
+
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
|
|
2730
2682
|
*/
|
|
2731
|
-
|
|
2683
|
+
get viewportLineBlocks(): BlockInfo[];
|
|
2732
2684
|
/**
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
of the
|
|
2736
|
-
|
|
2737
|
-
|
|
2685
|
+
Find the extent and height of the visual line (a range delimited
|
|
2686
|
+
on both sides by either non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range)
|
|
2687
|
+
line breaks, or the start/end of the document) at the given position.
|
|
2688
|
+
|
|
2689
|
+
Vertical positions are computed relative to the `docTop`
|
|
2690
|
+
argument, which defaults to 0 for this method. You can pass
|
|
2691
|
+
`view.contentDOM.getBoundingClientRect().top` here to get screen
|
|
2692
|
+
coordinates.
|
|
2693
|
+
|
|
2694
|
+
*Deprecated: use `lineBlockAt` instead.*
|
|
2738
2695
|
*/
|
|
2739
|
-
|
|
2696
|
+
visualLineAt(pos: number, docTop?: number): BlockInfo;
|
|
2740
2697
|
/**
|
|
2741
|
-
|
|
2698
|
+
Find the line block around the given document position. A line
|
|
2699
|
+
block is a range delimited on both sides by either a
|
|
2700
|
+
non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range) line breaks, or the
|
|
2701
|
+
start/end of the document. It will usually just hold a line of
|
|
2702
|
+
text, but may be broken into multiple textblocks by block
|
|
2703
|
+
widgets.
|
|
2742
2704
|
*/
|
|
2743
|
-
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
|
-
/**
|
|
2747
|
-
Record used to represent information about a block-level element
|
|
2748
|
-
in the editor view.
|
|
2749
|
-
*/
|
|
2750
|
-
declare class BlockInfo {
|
|
2705
|
+
lineBlockAt(pos: number): BlockInfo;
|
|
2751
2706
|
/**
|
|
2752
|
-
The
|
|
2707
|
+
The editor's total content height.
|
|
2753
2708
|
*/
|
|
2754
|
-
|
|
2709
|
+
get contentHeight(): number;
|
|
2755
2710
|
/**
|
|
2756
|
-
|
|
2711
|
+
Move a cursor position by [grapheme
|
|
2712
|
+
cluster](https://codemirror.net/6/docs/ref/#text.findClusterBreak). `forward` determines whether
|
|
2713
|
+
the motion is away from the line start, or towards it. Motion in
|
|
2714
|
+
bidirectional text is in visual order, in the editor's [text
|
|
2715
|
+
direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). When the start
|
|
2716
|
+
position was the last one on the line, the returned position
|
|
2717
|
+
will be across the line break. If there is no further line, the
|
|
2718
|
+
original position is returned.
|
|
2719
|
+
|
|
2720
|
+
By default, this method moves over a single cluster. The
|
|
2721
|
+
optional `by` argument can be used to move across more. It will
|
|
2722
|
+
be called with the first cluster as argument, and should return
|
|
2723
|
+
a predicate that determines, for each subsequent cluster,
|
|
2724
|
+
whether it should also be moved over.
|
|
2757
2725
|
*/
|
|
2758
|
-
|
|
2726
|
+
moveByChar(start: SelectionRange, forward: boolean, by?: (initial: string) => (next: string) => boolean): SelectionRange;
|
|
2759
2727
|
/**
|
|
2760
|
-
|
|
2728
|
+
Move a cursor position across the next group of either
|
|
2729
|
+
[letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
|
|
2730
|
+
non-whitespace characters.
|
|
2761
2731
|
*/
|
|
2762
|
-
|
|
2732
|
+
moveByGroup(start: SelectionRange, forward: boolean): SelectionRange;
|
|
2763
2733
|
/**
|
|
2764
|
-
|
|
2734
|
+
Move to the next line boundary in the given direction. If
|
|
2735
|
+
`includeWrap` is true, line wrapping is on, and there is a
|
|
2736
|
+
further wrap point on the current line, the wrap point will be
|
|
2737
|
+
returned. Otherwise this function will return the start or end
|
|
2738
|
+
of the line.
|
|
2765
2739
|
*/
|
|
2766
|
-
|
|
2740
|
+
moveToLineBoundary(start: SelectionRange, forward: boolean, includeWrap?: boolean): SelectionRange;
|
|
2767
2741
|
/**
|
|
2768
|
-
|
|
2769
|
-
|
|
2742
|
+
Move a cursor position vertically. When `distance` isn't given,
|
|
2743
|
+
it defaults to moving to the next line (including wrapped
|
|
2744
|
+
lines). Otherwise, `distance` should provide a positive distance
|
|
2745
|
+
in pixels.
|
|
2746
|
+
|
|
2747
|
+
When `start` has a
|
|
2748
|
+
[`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
|
|
2749
|
+
motion will use that as a target horizontal position. Otherwise,
|
|
2750
|
+
the cursor's own horizontal position is used. The returned
|
|
2751
|
+
cursor will have its goal column set to whichever column was
|
|
2752
|
+
used.
|
|
2770
2753
|
*/
|
|
2771
|
-
|
|
2754
|
+
moveVertically(start: SelectionRange, forward: boolean, distance?: number): SelectionRange;
|
|
2755
|
+
scrollPosIntoView(pos: number): void;
|
|
2772
2756
|
/**
|
|
2773
|
-
|
|
2757
|
+
Find the DOM parent node and offset (child offset if `node` is
|
|
2758
|
+
an element, character offset when it is a text node) at the
|
|
2759
|
+
given document position.
|
|
2774
2760
|
*/
|
|
2775
|
-
|
|
2761
|
+
domAtPos(pos: number): {
|
|
2762
|
+
node: Node;
|
|
2763
|
+
offset: number;
|
|
2764
|
+
};
|
|
2776
2765
|
/**
|
|
2777
|
-
|
|
2766
|
+
Find the document position at the given DOM node. Can be useful
|
|
2767
|
+
for associating positions with DOM events. Will raise an error
|
|
2768
|
+
when `node` isn't part of the editor content.
|
|
2778
2769
|
*/
|
|
2779
|
-
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2782
|
-
interface EditorConfig {
|
|
2770
|
+
posAtDOM(node: Node, offset?: number): number;
|
|
2783
2771
|
/**
|
|
2784
|
-
|
|
2785
|
-
|
|
2772
|
+
Get the document position at the given screen coordinates.
|
|
2773
|
+
Returns null if no valid position could be found.
|
|
2786
2774
|
*/
|
|
2787
|
-
|
|
2775
|
+
posAtCoords(coords: {
|
|
2776
|
+
x: number;
|
|
2777
|
+
y: number;
|
|
2778
|
+
}, precise: false): number;
|
|
2779
|
+
posAtCoords(coords: {
|
|
2780
|
+
x: number;
|
|
2781
|
+
y: number;
|
|
2782
|
+
}): number | null;
|
|
2788
2783
|
/**
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2784
|
+
Get the screen coordinates at the given document position.
|
|
2785
|
+
`side` determines whether the coordinates are based on the
|
|
2786
|
+
element before (-1) or after (1) the position (if no element is
|
|
2787
|
+
available on the given side, the method will transparently use
|
|
2788
|
+
another strategy to get reasonable coordinates).
|
|
2794
2789
|
*/
|
|
2795
|
-
|
|
2790
|
+
coordsAtPos(pos: number, side?: -1 | 1): Rect | null;
|
|
2796
2791
|
/**
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
if provided, should probably call the view's [`update`
|
|
2801
|
-
method](https://codemirror.net/6/docs/ref/#view.EditorView.update).
|
|
2792
|
+
The default width of a character in the editor. May not
|
|
2793
|
+
accurately reflect the width of all characters (given variable
|
|
2794
|
+
width fonts or styling of invididual ranges).
|
|
2802
2795
|
*/
|
|
2803
|
-
|
|
2796
|
+
get defaultCharacterWidth(): number;
|
|
2804
2797
|
/**
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
[`dom`](https://codemirror.net/6/docs/ref/#view.EditorView.dom) element in the document yourself.)
|
|
2798
|
+
The default height of a line in the editor. May not be accurate
|
|
2799
|
+
for all lines.
|
|
2808
2800
|
*/
|
|
2809
|
-
|
|
2810
|
-
}
|
|
2811
|
-
/**
|
|
2812
|
-
An editor view represents the editor's user interface. It holds
|
|
2813
|
-
the editable DOM surface, and possibly other elements such as the
|
|
2814
|
-
line number gutter. It handles events and dispatches state
|
|
2815
|
-
transactions for editing actions.
|
|
2816
|
-
*/
|
|
2817
|
-
declare class EditorView {
|
|
2801
|
+
get defaultLineHeight(): number;
|
|
2818
2802
|
/**
|
|
2819
|
-
The
|
|
2803
|
+
The text direction
|
|
2804
|
+
([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
|
|
2805
|
+
CSS property) of the editor.
|
|
2820
2806
|
*/
|
|
2821
|
-
get
|
|
2807
|
+
get textDirection(): Direction;
|
|
2822
2808
|
/**
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
property
|
|
2827
|
-
document positions.
|
|
2809
|
+
Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
|
|
2810
|
+
(as determined by the
|
|
2811
|
+
[`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
|
|
2812
|
+
CSS property of its content element).
|
|
2828
2813
|
*/
|
|
2829
|
-
get
|
|
2830
|
-
from: number;
|
|
2831
|
-
to: number;
|
|
2832
|
-
};
|
|
2814
|
+
get lineWrapping(): boolean;
|
|
2833
2815
|
/**
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2816
|
+
Returns the bidirectional text structure of the given line
|
|
2817
|
+
(which should be in the current document) as an array of span
|
|
2818
|
+
objects. The order of these spans matches the [text
|
|
2819
|
+
direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
|
|
2820
|
+
left-to-right, the leftmost spans come first, otherwise the
|
|
2821
|
+
rightmost spans come first.
|
|
2840
2822
|
*/
|
|
2841
|
-
|
|
2842
|
-
from: number;
|
|
2843
|
-
to: number;
|
|
2844
|
-
}[];
|
|
2823
|
+
bidiSpans(line: Line$1): readonly BidiSpan[];
|
|
2845
2824
|
/**
|
|
2846
|
-
|
|
2847
|
-
or otherwise hidden.
|
|
2825
|
+
Check whether the editor has focus.
|
|
2848
2826
|
*/
|
|
2849
|
-
get
|
|
2827
|
+
get hasFocus(): boolean;
|
|
2850
2828
|
/**
|
|
2851
|
-
|
|
2852
|
-
[IME](https://en.wikipedia.org/wiki/Input_method).
|
|
2829
|
+
Put focus on the editor.
|
|
2853
2830
|
*/
|
|
2854
|
-
|
|
2855
|
-
private _dispatch;
|
|
2831
|
+
focus(): void;
|
|
2856
2832
|
/**
|
|
2857
|
-
|
|
2833
|
+
Clean up this editor view, removing its element from the
|
|
2834
|
+
document, unregistering event handlers, and notifying
|
|
2835
|
+
plugins. The view instance can no longer be used after
|
|
2836
|
+
calling this.
|
|
2858
2837
|
*/
|
|
2859
|
-
|
|
2838
|
+
destroy(): void;
|
|
2860
2839
|
/**
|
|
2861
|
-
|
|
2840
|
+
Effect that can be [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a
|
|
2841
|
+
transaction to make it scroll the given range into view.
|
|
2862
2842
|
*/
|
|
2863
|
-
|
|
2843
|
+
static scrollTo: StateEffectType<SelectionRange>;
|
|
2864
2844
|
/**
|
|
2865
|
-
|
|
2866
|
-
|
|
2845
|
+
Effect that makes the editor scroll the given range to the
|
|
2846
|
+
center of the visible view.
|
|
2867
2847
|
*/
|
|
2868
|
-
|
|
2848
|
+
static centerOn: StateEffectType<SelectionRange>;
|
|
2869
2849
|
/**
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
[decorations](https://codemirror.net/6/docs/ref/#view.Decoration) to style it.
|
|
2850
|
+
Facet to add a [style
|
|
2851
|
+
module](https://github.com/marijnh/style-mod#documentation) to
|
|
2852
|
+
an editor view. The view will ensure that the module is
|
|
2853
|
+
mounted in its [document
|
|
2854
|
+
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
2876
2855
|
*/
|
|
2877
|
-
|
|
2878
|
-
private announceDOM;
|
|
2879
|
-
private plugins;
|
|
2880
|
-
private editorAttrs;
|
|
2881
|
-
private contentAttrs;
|
|
2882
|
-
private styleModules;
|
|
2883
|
-
private bidiCache;
|
|
2884
|
-
private destroyed;
|
|
2856
|
+
static styleModule: Facet<StyleModule, readonly StyleModule[]>;
|
|
2885
2857
|
/**
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2858
|
+
Facet that can be used to add DOM event handlers. The value
|
|
2859
|
+
should be an object mapping event names to handler functions. The
|
|
2860
|
+
first such function to return true will be assumed to have handled
|
|
2861
|
+
that event, and no other handlers or built-in behavior will be
|
|
2862
|
+
activated for it.
|
|
2863
|
+
These are registered on the [content
|
|
2864
|
+
element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except for `scroll`
|
|
2865
|
+
handlers, which will be called any time the editor's [scroll
|
|
2866
|
+
element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of its parent nodes
|
|
2867
|
+
is scrolled.
|
|
2889
2868
|
*/
|
|
2890
|
-
|
|
2869
|
+
static domEventHandlers(handlers: DOMEventHandlers<any>): Extension;
|
|
2891
2870
|
/**
|
|
2892
|
-
|
|
2871
|
+
An input handler can override the way changes to the editable
|
|
2872
|
+
DOM content are handled. Handlers are passed the document
|
|
2873
|
+
positions between which the change was found, and the new
|
|
2874
|
+
content. When one returns true, no further input handlers are
|
|
2875
|
+
called and the default behavior is prevented.
|
|
2893
2876
|
*/
|
|
2894
|
-
|
|
2877
|
+
static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string) => boolean, readonly ((view: EditorView, from: number, to: number, text: string) => boolean)[]>;
|
|
2895
2878
|
/**
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
[
|
|
2901
|
-
function is bound to the view instance, so it does not have to
|
|
2902
|
-
be called as a method.
|
|
2879
|
+
Allows you to provide a function that should be called when the
|
|
2880
|
+
library catches an exception from an extension (mostly from view
|
|
2881
|
+
plugins, but may be used by other extensions to route exceptions
|
|
2882
|
+
from user-code-provided callbacks). This is mostly useful for
|
|
2883
|
+
debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
|
|
2903
2884
|
*/
|
|
2904
|
-
|
|
2905
|
-
dispatch(...specs: TransactionSpec[]): void;
|
|
2885
|
+
static exceptionSink: Facet<(exception: any) => void, readonly ((exception: any) => void)[]>;
|
|
2906
2886
|
/**
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
produced by the transactions, and notify view plugins of the
|
|
2910
|
-
change. You should usually call
|
|
2911
|
-
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
|
|
2912
|
-
as a primitive.
|
|
2887
|
+
A facet that can be used to register a function to be called
|
|
2888
|
+
every time the view updates.
|
|
2913
2889
|
*/
|
|
2914
|
-
update
|
|
2890
|
+
static updateListener: Facet<(update: ViewUpdate) => void, readonly ((update: ViewUpdate) => void)[]>;
|
|
2915
2891
|
/**
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2892
|
+
Facet that controls whether the editor content DOM is editable.
|
|
2893
|
+
When its highest-precedence value is `false`, the element will
|
|
2894
|
+
not longer have its `contenteditable` attribute set. (Note that
|
|
2895
|
+
this doesn't affect API calls that change the editor content,
|
|
2896
|
+
even when those are bound to keys or buttons. See the
|
|
2897
|
+
[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
|
|
2921
2898
|
*/
|
|
2922
|
-
|
|
2923
|
-
private updatePlugins;
|
|
2899
|
+
static editable: Facet<boolean, boolean>;
|
|
2924
2900
|
/**
|
|
2925
|
-
|
|
2901
|
+
Allows you to influence the way mouse selection happens. The
|
|
2902
|
+
functions in this facet will be called for a `mousedown` event
|
|
2903
|
+
on the editor, and can return an object that overrides the way a
|
|
2904
|
+
selection is computed from that mouse click or drag.
|
|
2926
2905
|
*/
|
|
2927
|
-
|
|
2928
|
-
private updateAttrs;
|
|
2929
|
-
private showAnnouncements;
|
|
2930
|
-
private mountStyles;
|
|
2931
|
-
private readMeasured;
|
|
2906
|
+
static mouseSelectionStyle: Facet<MakeSelectionStyle, readonly MakeSelectionStyle[]>;
|
|
2932
2907
|
/**
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
drawing done by other components is synchronized, avoiding
|
|
2938
|
-
unnecessary DOM layout computations.
|
|
2908
|
+
Facet used to configure whether a given selection drag event
|
|
2909
|
+
should move or copy the selection. The given predicate will be
|
|
2910
|
+
called with the `mousedown` event, and can return `true` when
|
|
2911
|
+
the drag should move the content.
|
|
2939
2912
|
*/
|
|
2940
|
-
|
|
2913
|
+
static dragMovesSelection: Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
|
|
2941
2914
|
/**
|
|
2942
|
-
|
|
2943
|
-
|
|
2915
|
+
Facet used to configure whether a given selecting click adds
|
|
2916
|
+
a new range to the existing selection or replaces it entirely.
|
|
2944
2917
|
*/
|
|
2945
|
-
|
|
2918
|
+
static clickAddsSelectionRange: Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
|
|
2946
2919
|
/**
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2920
|
+
A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
|
|
2921
|
+
are shown in the view. See also [view
|
|
2922
|
+
plugins](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), which have a separate
|
|
2923
|
+
mechanism for providing decorations.
|
|
2951
2924
|
*/
|
|
2952
|
-
|
|
2925
|
+
static decorations: Facet<DecorationSet, readonly DecorationSet[]>;
|
|
2953
2926
|
/**
|
|
2954
|
-
|
|
2927
|
+
Create a theme extension. The first argument can be a
|
|
2928
|
+
[`style-mod`](https://github.com/marijnh/style-mod#documentation)
|
|
2929
|
+
style spec providing the styles for the theme. These will be
|
|
2930
|
+
prefixed with a generated class for the style.
|
|
2955
2931
|
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
queries.
|
|
2963
|
-
*/
|
|
2964
|
-
blockAtHeight(height: number, docTop?: number): BlockInfo;
|
|
2965
|
-
/**
|
|
2966
|
-
Find information for the visual line (see
|
|
2967
|
-
[`visualLineAt`](https://codemirror.net/6/docs/ref/#view.EditorView.visualLineAt)) at the given
|
|
2968
|
-
vertical position. The resulting block info might hold another
|
|
2969
|
-
array of block info structs in its `type` field if this line
|
|
2970
|
-
consists of more than one block.
|
|
2932
|
+
Because the selectors will be prefixed with a scope class, rule
|
|
2933
|
+
that directly match the editor's [wrapper
|
|
2934
|
+
element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
|
|
2935
|
+
added—need to be explicitly differentiated by adding an `&` to
|
|
2936
|
+
the selector for that element—for example
|
|
2937
|
+
`&.cm-focused`.
|
|
2971
2938
|
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
visualLineAtHeight(height: number, docTop?: number): BlockInfo;
|
|
2977
|
-
/**
|
|
2978
|
-
Iterate over the height information of the visual lines in the
|
|
2979
|
-
viewport. The heights of lines are reported relative to the
|
|
2980
|
-
given document top, which defaults to the screen position of the
|
|
2981
|
-
document (forcing a layout).
|
|
2939
|
+
When `dark` is set to true, the theme will be marked as dark,
|
|
2940
|
+
which will cause the `&dark` rules from [base
|
|
2941
|
+
themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
|
|
2942
|
+
`&light` when a light theme is active).
|
|
2982
2943
|
*/
|
|
2983
|
-
|
|
2944
|
+
static theme(spec: {
|
|
2945
|
+
[selector: string]: StyleSpec;
|
|
2946
|
+
}, options?: {
|
|
2947
|
+
dark?: boolean;
|
|
2948
|
+
}): Extension;
|
|
2984
2949
|
/**
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
argument, which defaults to 0 for this method. You can pass
|
|
2991
|
-
`view.contentDOM.getBoundingClientRect().top` here to get screen
|
|
2992
|
-
coordinates.
|
|
2950
|
+
Create an extension that adds styles to the base theme. Like
|
|
2951
|
+
with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
|
|
2952
|
+
place of the editor wrapper element when directly targeting
|
|
2953
|
+
that. You can also use `&dark` or `&light` instead to only
|
|
2954
|
+
target editors with a dark or light theme.
|
|
2993
2955
|
*/
|
|
2994
|
-
|
|
2956
|
+
static baseTheme(spec: {
|
|
2957
|
+
[selector: string]: StyleSpec;
|
|
2958
|
+
}): Extension;
|
|
2995
2959
|
/**
|
|
2996
|
-
|
|
2960
|
+
Facet that provides additional DOM attributes for the editor's
|
|
2961
|
+
editable DOM element.
|
|
2997
2962
|
*/
|
|
2998
|
-
|
|
2963
|
+
static contentAttributes: Facet<Attrs, Attrs>;
|
|
2999
2964
|
/**
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
the motion is away from the line start, or towards it. Motion in
|
|
3003
|
-
bidirectional text is in visual order, in the editor's [text
|
|
3004
|
-
direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). When the start
|
|
3005
|
-
position was the last one on the line, the returned position
|
|
3006
|
-
will be across the line break. If there is no further line, the
|
|
3007
|
-
original position is returned.
|
|
3008
|
-
|
|
3009
|
-
By default, this method moves over a single cluster. The
|
|
3010
|
-
optional `by` argument can be used to move across more. It will
|
|
3011
|
-
be called with the first cluster as argument, and should return
|
|
3012
|
-
a predicate that determines, for each subsequent cluster,
|
|
3013
|
-
whether it should also be moved over.
|
|
2965
|
+
Facet that provides DOM attributes for the editor's outer
|
|
2966
|
+
element.
|
|
3014
2967
|
*/
|
|
3015
|
-
|
|
2968
|
+
static editorAttributes: Facet<Attrs, Attrs>;
|
|
3016
2969
|
/**
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
non-whitespace characters.
|
|
2970
|
+
An extension that enables line wrapping in the editor (by
|
|
2971
|
+
setting CSS `white-space` to `pre-wrap` in the content).
|
|
3020
2972
|
*/
|
|
3021
|
-
|
|
2973
|
+
static lineWrapping: Extension;
|
|
3022
2974
|
/**
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
2975
|
+
State effect used to include screen reader announcements in a
|
|
2976
|
+
transaction. These will be added to the DOM in a visually hidden
|
|
2977
|
+
element with `aria-live="polite"` set, and should be used to
|
|
2978
|
+
describe effects that are visually obvious but may not be
|
|
2979
|
+
noticed by screen reader users (such as moving to the next
|
|
2980
|
+
search match).
|
|
3028
2981
|
*/
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
2982
|
+
static announce: StateEffectType<string>;
|
|
2983
|
+
}
|
|
2984
|
+
/**
|
|
2985
|
+
Helper type that maps event names to event object types, or the
|
|
2986
|
+
`any` type for unknown events.
|
|
2987
|
+
*/
|
|
2988
|
+
interface DOMEventMap extends HTMLElementEventMap {
|
|
2989
|
+
[other: string]: any;
|
|
2990
|
+
}
|
|
2991
|
+
/**
|
|
2992
|
+
Event handlers are specified with objects like this. For event
|
|
2993
|
+
types known by TypeScript, this will infer the event argument type
|
|
2994
|
+
to hold the appropriate event object type. For unknown events, it
|
|
2995
|
+
is inferred to `any`, and should be explicitly set if you want type
|
|
2996
|
+
checking.
|
|
2997
|
+
*/
|
|
2998
|
+
declare type DOMEventHandlers<This> = {
|
|
2999
|
+
[event in keyof DOMEventMap]?: (this: This, event: DOMEventMap[event], view: EditorView) => boolean | void;
|
|
3000
|
+
};
|
|
3035
3001
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3002
|
+
/**
|
|
3003
|
+
Key bindings associate key names with
|
|
3004
|
+
[command](https://codemirror.net/6/docs/ref/#view.Command)-style functions.
|
|
3005
|
+
|
|
3006
|
+
Key names may be strings like `"Shift-Ctrl-Enter"`—a key identifier
|
|
3007
|
+
prefixed with zero or more modifiers. Key identifiers are based on
|
|
3008
|
+
the strings that can appear in
|
|
3009
|
+
[`KeyEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
|
|
3010
|
+
Use lowercase letters to refer to letter keys (or uppercase letters
|
|
3011
|
+
if you want shift to be held). You may use `"Space"` as an alias
|
|
3012
|
+
for the `" "` name.
|
|
3013
|
+
|
|
3014
|
+
Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
|
|
3015
|
+
`a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
|
|
3016
|
+
`Meta-`) are recognized.
|
|
3017
|
+
|
|
3018
|
+
When a key binding contains multiple key names separated by
|
|
3019
|
+
spaces, it represents a multi-stroke binding, which will fire when
|
|
3020
|
+
the user presses the given keys after each other order.
|
|
3021
|
+
|
|
3022
|
+
You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
|
|
3023
|
+
other platforms. So `Mod-b` is `Ctrl-b` on Linux but `Cmd-b` on
|
|
3024
|
+
macOS.
|
|
3025
|
+
*/
|
|
3026
|
+
interface KeyBinding {
|
|
3060
3027
|
/**
|
|
3061
|
-
|
|
3062
|
-
|
|
3028
|
+
The key name to use for this binding. If the platform-specific
|
|
3029
|
+
property (`mac`, `win`, or `linux`) for the current platform is
|
|
3030
|
+
used as well in the binding, that one takes precedence. If `key`
|
|
3031
|
+
isn't defined and the platform-specific binding isn't either,
|
|
3032
|
+
a binding is ignored.
|
|
3063
3033
|
*/
|
|
3064
|
-
|
|
3065
|
-
x: number;
|
|
3066
|
-
y: number;
|
|
3067
|
-
}, precise: false): number;
|
|
3068
|
-
posAtCoords(coords: {
|
|
3069
|
-
x: number;
|
|
3070
|
-
y: number;
|
|
3071
|
-
}): number | null;
|
|
3034
|
+
key?: string;
|
|
3072
3035
|
/**
|
|
3073
|
-
|
|
3074
|
-
`side` determines whether the coordinates are based on the
|
|
3075
|
-
element before (-1) or after (1) the position (if no element is
|
|
3076
|
-
available on the given side, the method will transparently use
|
|
3077
|
-
another strategy to get reasonable coordinates).
|
|
3036
|
+
Key to use specifically on macOS.
|
|
3078
3037
|
*/
|
|
3079
|
-
|
|
3038
|
+
mac?: string;
|
|
3080
3039
|
/**
|
|
3081
|
-
|
|
3082
|
-
accurately reflect the width of all characters (given variable
|
|
3083
|
-
width fonts or styling of invididual ranges).
|
|
3040
|
+
Key to use specifically on Windows.
|
|
3084
3041
|
*/
|
|
3085
|
-
|
|
3042
|
+
win?: string;
|
|
3086
3043
|
/**
|
|
3087
|
-
|
|
3088
|
-
for all lines.
|
|
3044
|
+
Key to use specifically on Linux.
|
|
3089
3045
|
*/
|
|
3090
|
-
|
|
3046
|
+
linux?: string;
|
|
3091
3047
|
/**
|
|
3092
|
-
The
|
|
3093
|
-
|
|
3094
|
-
|
|
3048
|
+
The command to execute when this binding is triggered. When the
|
|
3049
|
+
command function returns `false`, further bindings will be tried
|
|
3050
|
+
for the key.
|
|
3095
3051
|
*/
|
|
3096
|
-
|
|
3052
|
+
run: Command;
|
|
3097
3053
|
/**
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
CSS property of its content element).
|
|
3054
|
+
When given, this defines a second binding, using the (possibly
|
|
3055
|
+
platform-specific) key name prefixed with `Shift-` to activate
|
|
3056
|
+
this command.
|
|
3102
3057
|
*/
|
|
3103
|
-
|
|
3058
|
+
shift?: Command;
|
|
3104
3059
|
/**
|
|
3105
|
-
|
|
3106
|
-
(
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3060
|
+
By default, key bindings apply when focus is on the editor
|
|
3061
|
+
content (the `"editor"` scope). Some extensions, mostly those
|
|
3062
|
+
that define their own panels, might want to allow you to
|
|
3063
|
+
register bindings local to that panel. Such bindings should use
|
|
3064
|
+
a custom scope name. You may also set multiple scope names,
|
|
3065
|
+
separated by spaces.
|
|
3111
3066
|
*/
|
|
3112
|
-
|
|
3067
|
+
scope?: string;
|
|
3113
3068
|
/**
|
|
3114
|
-
|
|
3069
|
+
When set to true (the default is false), this will always
|
|
3070
|
+
prevent the further handling for the bound key, even if the
|
|
3071
|
+
command(s) return false. This can be useful for cases where the
|
|
3072
|
+
native behavior of the key is annoying or irrelevant but the
|
|
3073
|
+
command doesn't always apply (such as, Mod-u for undo selection,
|
|
3074
|
+
which would cause the browser to view source instead when no
|
|
3075
|
+
selection can be undone).
|
|
3115
3076
|
*/
|
|
3116
|
-
|
|
3077
|
+
preventDefault?: boolean;
|
|
3078
|
+
}
|
|
3079
|
+
/**
|
|
3080
|
+
Facet used for registering keymaps.
|
|
3081
|
+
|
|
3082
|
+
You can add multiple keymaps to an editor. Their priorities
|
|
3083
|
+
determine their precedence (the ones specified early or with high
|
|
3084
|
+
priority get checked first). When a handler has returned `true`
|
|
3085
|
+
for a given key, no further handlers are called.
|
|
3086
|
+
*/
|
|
3087
|
+
declare const keymap: Facet<readonly KeyBinding[], readonly (readonly KeyBinding[])[]>;
|
|
3088
|
+
|
|
3089
|
+
declare type SelectionConfig = {
|
|
3117
3090
|
/**
|
|
3118
|
-
|
|
3091
|
+
The length of a full cursor blink cycle, in milliseconds.
|
|
3092
|
+
Defaults to 1200. Can be set to 0 to disable blinking.
|
|
3119
3093
|
*/
|
|
3120
|
-
|
|
3094
|
+
cursorBlinkRate?: number;
|
|
3121
3095
|
/**
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
plugins. The view instance can no longer be used after
|
|
3125
|
-
calling this.
|
|
3096
|
+
Whether to show a cursor for non-empty ranges. Defaults to
|
|
3097
|
+
true.
|
|
3126
3098
|
*/
|
|
3127
|
-
|
|
3099
|
+
drawRangeCursor?: boolean;
|
|
3100
|
+
};
|
|
3101
|
+
/**
|
|
3102
|
+
Returns an extension that hides the browser's native selection and
|
|
3103
|
+
cursor, replacing the selection with a background behind the text
|
|
3104
|
+
(with the `cm-selectionBackground` class), and the
|
|
3105
|
+
cursors with elements overlaid over the code (using
|
|
3106
|
+
`cm-cursor-primary` and `cm-cursor-secondary`).
|
|
3107
|
+
|
|
3108
|
+
This allows the editor to display secondary selection ranges, and
|
|
3109
|
+
tends to produce a type of selection more in line with that users
|
|
3110
|
+
expect in a text editor (the native selection styling will often
|
|
3111
|
+
leave gaps between lines and won't fill the horizontal space after
|
|
3112
|
+
a line when the selection continues past it).
|
|
3113
|
+
|
|
3114
|
+
It does have a performance cost, in that it requires an extra DOM
|
|
3115
|
+
layout cycle for many updates (the selection is drawn based on DOM
|
|
3116
|
+
layout information that's only available after laying out the
|
|
3117
|
+
content).
|
|
3118
|
+
*/
|
|
3119
|
+
declare function drawSelection(config?: SelectionConfig): Extension;
|
|
3120
|
+
|
|
3121
|
+
interface SpecialCharConfig {
|
|
3128
3122
|
/**
|
|
3129
|
-
|
|
3130
|
-
|
|
3123
|
+
An optional function that renders the placeholder elements.
|
|
3124
|
+
|
|
3125
|
+
The `description` argument will be text that clarifies what the
|
|
3126
|
+
character is, which should be provided to screen readers (for
|
|
3127
|
+
example with the
|
|
3128
|
+
[`aria-label`](https://www.w3.org/TR/wai-aria/#aria-label)
|
|
3129
|
+
attribute) and optionally shown to the user in other ways (such
|
|
3130
|
+
as the
|
|
3131
|
+
[`title`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title)
|
|
3132
|
+
attribute).
|
|
3133
|
+
|
|
3134
|
+
The given placeholder string is a suggestion for how to display
|
|
3135
|
+
the character visually.
|
|
3131
3136
|
*/
|
|
3132
|
-
|
|
3137
|
+
render?: ((code: number, description: string | null, placeholder: string) => HTMLElement) | null;
|
|
3133
3138
|
/**
|
|
3134
|
-
|
|
3135
|
-
|
|
3139
|
+
Regular expression that matches the special characters to
|
|
3140
|
+
highlight. Must have its 'g'/global flag set.
|
|
3136
3141
|
*/
|
|
3137
|
-
|
|
3142
|
+
specialChars?: RegExp;
|
|
3138
3143
|
/**
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
an editor view. The view will ensure that the module is
|
|
3142
|
-
mounted in its [document
|
|
3143
|
-
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
3144
|
+
Regular expression that can be used to add characters to the
|
|
3145
|
+
default set of characters to highlight.
|
|
3144
3146
|
*/
|
|
3145
|
-
|
|
3147
|
+
addSpecialChars?: RegExp | null;
|
|
3148
|
+
}
|
|
3149
|
+
/**
|
|
3150
|
+
Returns an extension that installs highlighting of special
|
|
3151
|
+
characters.
|
|
3152
|
+
*/
|
|
3153
|
+
declare function highlightSpecialChars(
|
|
3154
|
+
/**
|
|
3155
|
+
Configuration options.
|
|
3156
|
+
*/
|
|
3157
|
+
config?: SpecialCharConfig): Extension;
|
|
3158
|
+
|
|
3159
|
+
/**
|
|
3160
|
+
Returns a plugin that makes sure the content has a bottom margin
|
|
3161
|
+
equivalent to the height of the editor, minus one line height, so
|
|
3162
|
+
that every line in the document can be scrolled to the top of the
|
|
3163
|
+
editor.
|
|
3164
|
+
|
|
3165
|
+
This is only meaningful when the editor is scrollable, and should
|
|
3166
|
+
not be enabled in editors that take the size of their content.
|
|
3167
|
+
*/
|
|
3168
|
+
declare function scrollPastEnd(): Extension;
|
|
3169
|
+
|
|
3170
|
+
/**
|
|
3171
|
+
Extension that enables a placeholder—a piece of example content
|
|
3172
|
+
to show when the editor is empty.
|
|
3173
|
+
*/
|
|
3174
|
+
declare function placeholder(content: string | HTMLElement): Extension;
|
|
3175
|
+
|
|
3176
|
+
/**
|
|
3177
|
+
Helper class used to make it easier to maintain decorations on
|
|
3178
|
+
visible code that matches a given regular expression. To be used
|
|
3179
|
+
in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
|
|
3180
|
+
represent a matching configuration.
|
|
3181
|
+
*/
|
|
3182
|
+
declare class MatchDecorator {
|
|
3183
|
+
private regexp;
|
|
3184
|
+
private getDeco;
|
|
3185
|
+
private boundary;
|
|
3146
3186
|
/**
|
|
3147
|
-
|
|
3148
|
-
should be an object mapping event names to handler functions. The
|
|
3149
|
-
first such function to return true will be assumed to have handled
|
|
3150
|
-
that event, and no other handlers or built-in behavior will be
|
|
3151
|
-
activated for it.
|
|
3152
|
-
These are registered on the [content
|
|
3153
|
-
element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except for `scroll`
|
|
3154
|
-
handlers, which will be called any time the editor's [scroll
|
|
3155
|
-
element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of its parent nodes
|
|
3156
|
-
is scrolled.
|
|
3187
|
+
Create a decorator.
|
|
3157
3188
|
*/
|
|
3158
|
-
|
|
3189
|
+
constructor(config: {
|
|
3190
|
+
/**
|
|
3191
|
+
The regular expression to match against the content. Will only
|
|
3192
|
+
be matched inside lines (not across them). Should have its 'g'
|
|
3193
|
+
flag set.
|
|
3194
|
+
*/
|
|
3195
|
+
regexp: RegExp;
|
|
3196
|
+
/**
|
|
3197
|
+
The decoration to apply to matches, either directly or as a
|
|
3198
|
+
function of the match.
|
|
3199
|
+
*/
|
|
3200
|
+
decoration: Decoration | ((match: RegExpExecArray, view: EditorView, pos: number) => Decoration);
|
|
3201
|
+
/**
|
|
3202
|
+
By default, changed lines are re-matched entirely. You can
|
|
3203
|
+
provide a boundary expression, which should match single
|
|
3204
|
+
character strings that can never occur in `regexp`, to reduce
|
|
3205
|
+
the amount of re-matching.
|
|
3206
|
+
*/
|
|
3207
|
+
boundary?: RegExp;
|
|
3208
|
+
});
|
|
3159
3209
|
/**
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
content. When one returns true, no further input handlers are
|
|
3164
|
-
called and the default behavior is prevented.
|
|
3210
|
+
Compute the full set of decorations for matches in the given
|
|
3211
|
+
view's viewport. You'll want to call this when initializing your
|
|
3212
|
+
plugin.
|
|
3165
3213
|
*/
|
|
3166
|
-
|
|
3214
|
+
createDeco(view: EditorView): RangeSet<Decoration>;
|
|
3167
3215
|
/**
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
from user-code-provided callbacks). This is mostly useful for
|
|
3172
|
-
debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
|
|
3216
|
+
Update a set of decorations for a view update. `deco` _must_ be
|
|
3217
|
+
the set of decorations produced by _this_ `MatchDecorator` for
|
|
3218
|
+
the view state before the update.
|
|
3173
3219
|
*/
|
|
3174
|
-
|
|
3220
|
+
updateDeco(update: ViewUpdate, deco: DecorationSet): DecorationSet;
|
|
3221
|
+
private updateRange;
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
/**
|
|
3225
|
+
A language object manages parsing and per-language
|
|
3226
|
+
[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
|
|
3227
|
+
managed as a [Lezer](https://lezer.codemirror.net) tree. You'll
|
|
3228
|
+
want to subclass this class for custom parsers, or use the
|
|
3229
|
+
[`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage) or
|
|
3230
|
+
[`StreamLanguage`](https://codemirror.net/6/docs/ref/#stream-parser.StreamLanguage) abstractions for
|
|
3231
|
+
[Lezer](https://lezer.codemirror.net/) or stream parsers.
|
|
3232
|
+
*/
|
|
3233
|
+
declare class Language {
|
|
3175
3234
|
/**
|
|
3176
|
-
|
|
3177
|
-
|
|
3235
|
+
The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) data
|
|
3236
|
+
facet used for this language.
|
|
3178
3237
|
*/
|
|
3179
|
-
|
|
3238
|
+
readonly data: Facet<{
|
|
3239
|
+
[name: string]: any;
|
|
3240
|
+
}>;
|
|
3180
3241
|
/**
|
|
3181
|
-
|
|
3182
|
-
When its highest-precedence value is `false`, the element will
|
|
3183
|
-
not longer have its `contenteditable` attribute set. (Note that
|
|
3184
|
-
this doesn't affect API calls that change the editor content,
|
|
3185
|
-
even when those are bound to keys or buttons. See the
|
|
3186
|
-
[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
|
|
3242
|
+
The node type of the top node of trees produced by this parser.
|
|
3187
3243
|
*/
|
|
3188
|
-
|
|
3244
|
+
readonly topNode: NodeType;
|
|
3189
3245
|
/**
|
|
3190
|
-
|
|
3191
|
-
functions in this facet will be called for a `mousedown` event
|
|
3192
|
-
on the editor, and can return an object that overrides the way a
|
|
3193
|
-
selection is computed from that mouse click or drag.
|
|
3246
|
+
The extension value to install this provider.
|
|
3194
3247
|
*/
|
|
3195
|
-
|
|
3248
|
+
readonly extension: Extension;
|
|
3196
3249
|
/**
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
called with the `mousedown` event, and can return `true` when
|
|
3200
|
-
the drag should move the content.
|
|
3250
|
+
The parser object. Can be useful when using this as a [nested
|
|
3251
|
+
parser](https://lezer.codemirror.net/docs/ref#common.Parser).
|
|
3201
3252
|
*/
|
|
3202
|
-
|
|
3253
|
+
parser: Parser;
|
|
3203
3254
|
/**
|
|
3204
|
-
|
|
3205
|
-
|
|
3255
|
+
Construct a language object. You usually don't need to invoke
|
|
3256
|
+
this directly. But when you do, make sure you use
|
|
3257
|
+
[`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet) to create
|
|
3258
|
+
the first argument.
|
|
3206
3259
|
*/
|
|
3207
|
-
|
|
3260
|
+
constructor(
|
|
3208
3261
|
/**
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
plugins](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), which have a separate
|
|
3212
|
-
mechanism for providing decorations.
|
|
3262
|
+
The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) data
|
|
3263
|
+
facet used for this language.
|
|
3213
3264
|
*/
|
|
3214
|
-
|
|
3265
|
+
data: Facet<{
|
|
3266
|
+
[name: string]: any;
|
|
3267
|
+
}>, parser: Parser,
|
|
3215
3268
|
/**
|
|
3216
|
-
|
|
3217
|
-
[`style-mod`](https://github.com/marijnh/style-mod#documentation)
|
|
3218
|
-
style spec providing the styles for the theme. These will be
|
|
3219
|
-
prefixed with a generated class for the style.
|
|
3220
|
-
|
|
3221
|
-
Because the selectors will be prefixed with a scope class, rule
|
|
3222
|
-
that directly match the editor's [wrapper
|
|
3223
|
-
element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
|
|
3224
|
-
added—need to be explicitly differentiated by adding an `&` to
|
|
3225
|
-
the selector for that element—for example
|
|
3226
|
-
`&.cm-focused`.
|
|
3227
|
-
|
|
3228
|
-
When `dark` is set to true, the theme will be marked as dark,
|
|
3229
|
-
which will cause the `&dark` rules from [base
|
|
3230
|
-
themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
|
|
3231
|
-
`&light` when a light theme is active).
|
|
3269
|
+
The node type of the top node of trees produced by this parser.
|
|
3232
3270
|
*/
|
|
3233
|
-
|
|
3234
|
-
[selector: string]: StyleSpec;
|
|
3235
|
-
}, options?: {
|
|
3236
|
-
dark?: boolean;
|
|
3237
|
-
}): Extension;
|
|
3271
|
+
topNode: NodeType, extraExtensions?: Extension[]);
|
|
3238
3272
|
/**
|
|
3239
|
-
|
|
3240
|
-
with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
|
|
3241
|
-
place of the editor wrapper element when directly targeting
|
|
3242
|
-
that. You can also use `&dark` or `&light` instead to only
|
|
3243
|
-
target editors with a dark or light theme.
|
|
3273
|
+
Query whether this language is active at the given position.
|
|
3244
3274
|
*/
|
|
3245
|
-
|
|
3246
|
-
[selector: string]: StyleSpec;
|
|
3247
|
-
}): Extension;
|
|
3275
|
+
isActiveAt(state: EditorState, pos: number, side?: -1 | 0 | 1): boolean;
|
|
3248
3276
|
/**
|
|
3249
|
-
|
|
3250
|
-
|
|
3277
|
+
Find the document regions that were parsed using this language.
|
|
3278
|
+
The returned regions will _include_ any nested languages rooted
|
|
3279
|
+
in this language, when those exist.
|
|
3251
3280
|
*/
|
|
3252
|
-
|
|
3281
|
+
findRegions(state: EditorState): {
|
|
3282
|
+
from: number;
|
|
3283
|
+
to: number;
|
|
3284
|
+
}[];
|
|
3253
3285
|
/**
|
|
3254
|
-
|
|
3255
|
-
|
|
3286
|
+
Indicates whether this language allows nested languages. The
|
|
3287
|
+
default implementation returns true.
|
|
3256
3288
|
*/
|
|
3257
|
-
|
|
3289
|
+
get allowsNesting(): boolean;
|
|
3290
|
+
}
|
|
3291
|
+
/**
|
|
3292
|
+
A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
|
|
3293
|
+
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
|
3294
|
+
parsers.
|
|
3295
|
+
*/
|
|
3296
|
+
declare class LRLanguage extends Language {
|
|
3297
|
+
readonly parser: LRParser;
|
|
3298
|
+
private constructor();
|
|
3258
3299
|
/**
|
|
3259
|
-
|
|
3260
|
-
setting CSS `white-space` to `pre-wrap` in the content).
|
|
3300
|
+
Define a language from a parser.
|
|
3261
3301
|
*/
|
|
3262
|
-
static
|
|
3302
|
+
static define(spec: {
|
|
3303
|
+
/**
|
|
3304
|
+
The parser to use. Should already have added editor-relevant
|
|
3305
|
+
node props (and optionally things like dialect and top rule)
|
|
3306
|
+
configured.
|
|
3307
|
+
*/
|
|
3308
|
+
parser: LRParser;
|
|
3309
|
+
/**
|
|
3310
|
+
[Language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)
|
|
3311
|
+
to register for this language.
|
|
3312
|
+
*/
|
|
3313
|
+
languageData?: {
|
|
3314
|
+
[name: string]: any;
|
|
3315
|
+
};
|
|
3316
|
+
}): LRLanguage;
|
|
3263
3317
|
/**
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
element with `aria-live="polite"` set, and should be used to
|
|
3267
|
-
describe effects that are visually obvious but may not be
|
|
3268
|
-
noticed by screen reader users (such as moving to the next
|
|
3269
|
-
search match).
|
|
3318
|
+
Create a new instance of this language with a reconfigured
|
|
3319
|
+
version of its parser.
|
|
3270
3320
|
*/
|
|
3271
|
-
|
|
3321
|
+
configure(options: ParserConfig): LRLanguage;
|
|
3322
|
+
get allowsNesting(): boolean;
|
|
3272
3323
|
}
|
|
3273
3324
|
/**
|
|
3274
|
-
|
|
3275
|
-
|
|
3325
|
+
Get the syntax tree for a state, which is the current (possibly
|
|
3326
|
+
incomplete) parse tree of active [language](https://codemirror.net/6/docs/ref/#language.Language),
|
|
3327
|
+
or the empty tree if there is no language available.
|
|
3276
3328
|
*/
|
|
3277
|
-
|
|
3278
|
-
[other: string]: any;
|
|
3279
|
-
}
|
|
3329
|
+
declare function syntaxTree(state: EditorState): Tree;
|
|
3280
3330
|
/**
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
to
|
|
3284
|
-
is inferred to `any`, and should be explicitly set if you want type
|
|
3285
|
-
checking.
|
|
3331
|
+
Try to get a parse tree that spans at least up to `upto`. The
|
|
3332
|
+
method will do at most `timeout` milliseconds of work to parse
|
|
3333
|
+
up to that point if the tree isn't already available.
|
|
3286
3334
|
*/
|
|
3287
|
-
declare
|
|
3288
|
-
[event in keyof DOMEventMap]?: (this: This, event: DOMEventMap[event], view: EditorView) => boolean | void;
|
|
3289
|
-
};
|
|
3290
|
-
|
|
3335
|
+
declare function ensureSyntaxTree(state: EditorState, upto: number, timeout?: number): Tree | null;
|
|
3291
3336
|
/**
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
the strings that can appear in
|
|
3298
|
-
[`KeyEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
|
|
3299
|
-
Use lowercase letters to refer to letter keys (or uppercase letters
|
|
3300
|
-
if you want shift to be held). You may use `"Space"` as an alias
|
|
3301
|
-
for the `" "` name.
|
|
3302
|
-
|
|
3303
|
-
Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
|
|
3304
|
-
`a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
|
|
3305
|
-
`Meta-`) are recognized.
|
|
3306
|
-
|
|
3307
|
-
When a key binding contains multiple key names separated by
|
|
3308
|
-
spaces, it represents a multi-stroke binding, which will fire when
|
|
3309
|
-
the user presses the given keys after each other order.
|
|
3310
|
-
|
|
3311
|
-
You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
|
|
3312
|
-
other platforms. So `Mod-b` is `Ctrl-b` on Linux but `Cmd-b` on
|
|
3313
|
-
macOS.
|
|
3337
|
+
This class bundles a [language object](https://codemirror.net/6/docs/ref/#language.Language) with an
|
|
3338
|
+
optional set of supporting extensions. Language packages are
|
|
3339
|
+
encouraged to export a function that optionally takes a
|
|
3340
|
+
configuration object and returns a `LanguageSupport` instance, as
|
|
3341
|
+
the main way for client code to use the package.
|
|
3314
3342
|
*/
|
|
3315
|
-
|
|
3343
|
+
declare class LanguageSupport {
|
|
3316
3344
|
/**
|
|
3317
|
-
The
|
|
3318
|
-
property (`mac`, `win`, or `linux`) for the current platform is
|
|
3319
|
-
used as well in the binding, that one takes precedence. If `key`
|
|
3320
|
-
isn't defined and the platform-specific binding isn't either,
|
|
3321
|
-
a binding is ignored.
|
|
3345
|
+
The language object.
|
|
3322
3346
|
*/
|
|
3323
|
-
|
|
3347
|
+
readonly language: Language;
|
|
3324
3348
|
/**
|
|
3325
|
-
|
|
3349
|
+
An optional set of supporting extensions. When nesting a
|
|
3350
|
+
language in another language, the outer language is encouraged
|
|
3351
|
+
to include the supporting extensions for its inner languages
|
|
3352
|
+
in its own set of support extensions.
|
|
3326
3353
|
*/
|
|
3327
|
-
|
|
3354
|
+
readonly support: Extension;
|
|
3328
3355
|
/**
|
|
3329
|
-
|
|
3356
|
+
An extension including both the language and its support
|
|
3357
|
+
extensions. (Allowing the object to be used as an extension
|
|
3358
|
+
value itself.)
|
|
3330
3359
|
*/
|
|
3331
|
-
|
|
3360
|
+
extension: Extension;
|
|
3332
3361
|
/**
|
|
3333
|
-
|
|
3362
|
+
Create a support object.
|
|
3334
3363
|
*/
|
|
3335
|
-
|
|
3364
|
+
constructor(
|
|
3336
3365
|
/**
|
|
3337
|
-
The
|
|
3338
|
-
command function returns `false`, further bindings will be tried
|
|
3339
|
-
for the key.
|
|
3366
|
+
The language object.
|
|
3340
3367
|
*/
|
|
3341
|
-
|
|
3368
|
+
language: Language,
|
|
3342
3369
|
/**
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3370
|
+
An optional set of supporting extensions. When nesting a
|
|
3371
|
+
language in another language, the outer language is encouraged
|
|
3372
|
+
to include the supporting extensions for its inner languages
|
|
3373
|
+
in its own set of support extensions.
|
|
3346
3374
|
*/
|
|
3347
|
-
|
|
3375
|
+
support?: Extension);
|
|
3376
|
+
}
|
|
3377
|
+
/**
|
|
3378
|
+
Language descriptions are used to store metadata about languages
|
|
3379
|
+
and to dynamically load them. Their main role is finding the
|
|
3380
|
+
appropriate language for a filename or dynamically loading nested
|
|
3381
|
+
parsers.
|
|
3382
|
+
*/
|
|
3383
|
+
declare class LanguageDescription {
|
|
3348
3384
|
/**
|
|
3349
|
-
|
|
3350
|
-
content (the `"editor"` scope). Some extensions, mostly those
|
|
3351
|
-
that define their own panels, might want to allow you to
|
|
3352
|
-
register bindings local to that panel. Such bindings should use
|
|
3353
|
-
a custom scope name. You may also set multiple scope names,
|
|
3354
|
-
separated by spaces.
|
|
3385
|
+
The name of this language.
|
|
3355
3386
|
*/
|
|
3356
|
-
|
|
3387
|
+
readonly name: string;
|
|
3357
3388
|
/**
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3389
|
+
Alternative names for the mode (lowercased, includes `this.name`).
|
|
3390
|
+
*/
|
|
3391
|
+
readonly alias: readonly string[];
|
|
3392
|
+
/**
|
|
3393
|
+
File extensions associated with this language.
|
|
3394
|
+
*/
|
|
3395
|
+
readonly extensions: readonly string[];
|
|
3396
|
+
/**
|
|
3397
|
+
Optional filename pattern that should be associated with this
|
|
3398
|
+
language.
|
|
3365
3399
|
*/
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
/**
|
|
3369
|
-
Facet used for registering keymaps.
|
|
3370
|
-
|
|
3371
|
-
You can add multiple keymaps to an editor. Their priorities
|
|
3372
|
-
determine their precedence (the ones specified early or with high
|
|
3373
|
-
priority get checked first). When a handler has returned `true`
|
|
3374
|
-
for a given key, no further handlers are called.
|
|
3375
|
-
*/
|
|
3376
|
-
declare const keymap: Facet<readonly KeyBinding[], readonly (readonly KeyBinding[])[]>;
|
|
3377
|
-
|
|
3378
|
-
declare type SelectionConfig = {
|
|
3400
|
+
readonly filename: RegExp | undefined;
|
|
3401
|
+
private loadFunc;
|
|
3379
3402
|
/**
|
|
3380
|
-
|
|
3381
|
-
Defaults to 1200. Can be set to 0 to disable blinking.
|
|
3403
|
+
If the language has been loaded, this will hold its value.
|
|
3382
3404
|
*/
|
|
3383
|
-
|
|
3405
|
+
support: LanguageSupport | undefined;
|
|
3406
|
+
private loading;
|
|
3407
|
+
private constructor();
|
|
3384
3408
|
/**
|
|
3385
|
-
|
|
3386
|
-
|
|
3409
|
+
Start loading the the language. Will return a promise that
|
|
3410
|
+
resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
|
|
3411
|
+
object when the language successfully loads.
|
|
3387
3412
|
*/
|
|
3388
|
-
|
|
3389
|
-
};
|
|
3390
|
-
/**
|
|
3391
|
-
Returns an extension that hides the browser's native selection and
|
|
3392
|
-
cursor, replacing the selection with a background behind the text
|
|
3393
|
-
(with the `cm-selectionBackground` class), and the
|
|
3394
|
-
cursors with elements overlaid over the code (using
|
|
3395
|
-
`cm-cursor-primary` and `cm-cursor-secondary`).
|
|
3396
|
-
|
|
3397
|
-
This allows the editor to display secondary selection ranges, and
|
|
3398
|
-
tends to produce a type of selection more in line with that users
|
|
3399
|
-
expect in a text editor (the native selection styling will often
|
|
3400
|
-
leave gaps between lines and won't fill the horizontal space after
|
|
3401
|
-
a line when the selection continues past it).
|
|
3402
|
-
|
|
3403
|
-
It does have a performance cost, in that it requires an extra DOM
|
|
3404
|
-
layout cycle for many updates (the selection is drawn based on DOM
|
|
3405
|
-
layout information that's only available after laying out the
|
|
3406
|
-
content).
|
|
3407
|
-
*/
|
|
3408
|
-
declare function drawSelection(config?: SelectionConfig): Extension;
|
|
3409
|
-
|
|
3410
|
-
interface SpecialCharConfig {
|
|
3413
|
+
load(): Promise<LanguageSupport>;
|
|
3411
3414
|
/**
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
The `description` argument will be text that clarifies what the
|
|
3415
|
-
character is, which should be provided to screen readers (for
|
|
3416
|
-
example with the
|
|
3417
|
-
[`aria-label`](https://www.w3.org/TR/wai-aria/#aria-label)
|
|
3418
|
-
attribute) and optionally shown to the user in other ways (such
|
|
3419
|
-
as the
|
|
3420
|
-
[`title`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title)
|
|
3421
|
-
attribute).
|
|
3422
|
-
|
|
3423
|
-
The given placeholder string is a suggestion for how to display
|
|
3424
|
-
the character visually.
|
|
3415
|
+
Create a language description.
|
|
3425
3416
|
*/
|
|
3426
|
-
|
|
3417
|
+
static of(spec: {
|
|
3418
|
+
/**
|
|
3419
|
+
The language's name.
|
|
3420
|
+
*/
|
|
3421
|
+
name: string;
|
|
3422
|
+
/**
|
|
3423
|
+
An optional array of alternative names.
|
|
3424
|
+
*/
|
|
3425
|
+
alias?: readonly string[];
|
|
3426
|
+
/**
|
|
3427
|
+
An optional array of filename extensions associated with this
|
|
3428
|
+
language.
|
|
3429
|
+
*/
|
|
3430
|
+
extensions?: readonly string[];
|
|
3431
|
+
/**
|
|
3432
|
+
An optional filename pattern associated with this language.
|
|
3433
|
+
*/
|
|
3434
|
+
filename?: RegExp;
|
|
3435
|
+
/**
|
|
3436
|
+
A function that will asynchronously load the language.
|
|
3437
|
+
*/
|
|
3438
|
+
load?: () => Promise<LanguageSupport>;
|
|
3439
|
+
/**
|
|
3440
|
+
Alternatively to `load`, you can provide an already loaded
|
|
3441
|
+
support object. Either this or `load` should be provided.
|
|
3442
|
+
*/
|
|
3443
|
+
support?: LanguageSupport;
|
|
3444
|
+
}): LanguageDescription;
|
|
3427
3445
|
/**
|
|
3428
|
-
|
|
3429
|
-
|
|
3446
|
+
Look for a language in the given array of descriptions that
|
|
3447
|
+
matches the filename. Will first match
|
|
3448
|
+
[`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
|
|
3449
|
+
and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
|
|
3450
|
+
and return the first language that matches.
|
|
3430
3451
|
*/
|
|
3431
|
-
|
|
3452
|
+
static matchFilename(descs: readonly LanguageDescription[], filename: string): LanguageDescription | null;
|
|
3432
3453
|
/**
|
|
3433
|
-
|
|
3434
|
-
|
|
3454
|
+
Look for a language whose name or alias matches the the given
|
|
3455
|
+
name (case-insensitively). If `fuzzy` is true, and no direct
|
|
3456
|
+
matchs is found, this'll also search for a language whose name
|
|
3457
|
+
or alias occurs in the string (for names shorter than three
|
|
3458
|
+
characters, only when surrounded by non-word characters).
|
|
3435
3459
|
*/
|
|
3436
|
-
|
|
3460
|
+
static matchLanguageName(descs: readonly LanguageDescription[], name: string, fuzzy?: boolean): LanguageDescription | null;
|
|
3437
3461
|
}
|
|
3438
3462
|
/**
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
declare function highlightSpecialChars(
|
|
3443
|
-
/**
|
|
3444
|
-
Configuration options.
|
|
3445
|
-
*/
|
|
3446
|
-
config?: SpecialCharConfig): Extension;
|
|
3447
|
-
|
|
3448
|
-
/**
|
|
3449
|
-
Returns a plugin that makes sure the content has a bottom margin
|
|
3450
|
-
equivalent to the height of the editor, minus one line height, so
|
|
3451
|
-
that every line in the document can be scrolled to the top of the
|
|
3452
|
-
editor.
|
|
3453
|
-
|
|
3454
|
-
This is only meaningful when the editor is scrollable, and should
|
|
3455
|
-
not be enabled in editors that take the size of their content.
|
|
3456
|
-
*/
|
|
3457
|
-
declare function scrollPastEnd(): Extension;
|
|
3458
|
-
|
|
3459
|
-
/**
|
|
3460
|
-
Extension that enables a placeholder—a piece of example content
|
|
3461
|
-
to show when the editor is empty.
|
|
3463
|
+
Facet for overriding the unit by which indentation happens.
|
|
3464
|
+
Should be a string consisting either entirely of spaces or
|
|
3465
|
+
entirely of tabs. When not set, this defaults to 2 spaces.
|
|
3462
3466
|
*/
|
|
3463
|
-
declare
|
|
3464
|
-
|
|
3467
|
+
declare const indentUnit: Facet<string, string>;
|
|
3465
3468
|
/**
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
in
|
|
3469
|
-
|
|
3469
|
+
Indentation contexts are used when calling [indentation
|
|
3470
|
+
services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
|
|
3471
|
+
useful in indentation logic, and can selectively override the
|
|
3472
|
+
indentation reported for some lines.
|
|
3470
3473
|
*/
|
|
3471
|
-
declare class
|
|
3472
|
-
private regexp;
|
|
3473
|
-
private getDeco;
|
|
3474
|
-
private boundary;
|
|
3474
|
+
declare class IndentContext {
|
|
3475
3475
|
/**
|
|
3476
|
-
|
|
3476
|
+
The editor state.
|
|
3477
3477
|
*/
|
|
3478
|
-
|
|
3478
|
+
readonly state: EditorState;
|
|
3479
|
+
/**
|
|
3480
|
+
The indent unit (number of columns per indentation level).
|
|
3481
|
+
*/
|
|
3482
|
+
unit: number;
|
|
3483
|
+
/**
|
|
3484
|
+
Create an indent context.
|
|
3485
|
+
*/
|
|
3486
|
+
constructor(
|
|
3487
|
+
/**
|
|
3488
|
+
The editor state.
|
|
3489
|
+
*/
|
|
3490
|
+
state: EditorState,
|
|
3491
|
+
/**
|
|
3492
|
+
@internal
|
|
3493
|
+
*/
|
|
3494
|
+
options?: {
|
|
3479
3495
|
/**
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3496
|
+
Override line indentations provided to the indentation
|
|
3497
|
+
helper function, which is useful when implementing region
|
|
3498
|
+
indentation, where indentation for later lines needs to refer
|
|
3499
|
+
to previous lines, which may have been reindented compared to
|
|
3500
|
+
the original start state. If given, this function should
|
|
3501
|
+
return -1 for lines (given by start position) that didn't
|
|
3502
|
+
change, and an updated indentation otherwise.
|
|
3483
3503
|
*/
|
|
3484
|
-
|
|
3504
|
+
overrideIndentation?: (pos: number) => number;
|
|
3485
3505
|
/**
|
|
3486
|
-
|
|
3487
|
-
|
|
3506
|
+
Make it look, to the indent logic, like a line break was
|
|
3507
|
+
added at the given position (which is mostly just useful for
|
|
3508
|
+
implementing something like
|
|
3509
|
+
[`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)).
|
|
3488
3510
|
*/
|
|
3489
|
-
|
|
3511
|
+
simulateBreak?: number;
|
|
3490
3512
|
/**
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
character strings that can never occur in `regexp`, to reduce
|
|
3494
|
-
the amount of re-matching.
|
|
3513
|
+
When `simulateBreak` is given, this can be used to make the
|
|
3514
|
+
simulate break behave like a double line break.
|
|
3495
3515
|
*/
|
|
3496
|
-
|
|
3516
|
+
simulateDoubleBreak?: boolean;
|
|
3497
3517
|
});
|
|
3498
3518
|
/**
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3519
|
+
Get a description of the line at the given position, taking
|
|
3520
|
+
[simulated line
|
|
3521
|
+
breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
|
|
3522
|
+
into account. If there is such a break at `pos`, the `bias`
|
|
3523
|
+
argument determines whether the part of the line line before or
|
|
3524
|
+
after the break is used.
|
|
3502
3525
|
*/
|
|
3503
|
-
|
|
3526
|
+
lineAt(pos: number, bias?: -1 | 1): {
|
|
3527
|
+
text: string;
|
|
3528
|
+
from: number;
|
|
3529
|
+
};
|
|
3504
3530
|
/**
|
|
3505
|
-
|
|
3506
|
-
the
|
|
3507
|
-
the view state before the update.
|
|
3531
|
+
Get the text directly after `pos`, either the entire line
|
|
3532
|
+
or the next 100 characters, whichever is shorter.
|
|
3508
3533
|
*/
|
|
3509
|
-
|
|
3510
|
-
|
|
3534
|
+
textAfterPos(pos: number, bias?: -1 | 1): string;
|
|
3535
|
+
/**
|
|
3536
|
+
Find the column for the given position.
|
|
3537
|
+
*/
|
|
3538
|
+
column(pos: number, bias?: -1 | 1): number;
|
|
3539
|
+
/**
|
|
3540
|
+
Find the column position (taking tabs into account) of the given
|
|
3541
|
+
position in the given string.
|
|
3542
|
+
*/
|
|
3543
|
+
countColumn(line: string, pos?: number): number;
|
|
3544
|
+
/**
|
|
3545
|
+
Find the indentation column of the line at the given point.
|
|
3546
|
+
*/
|
|
3547
|
+
lineIndent(pos: number, bias?: -1 | 1): number;
|
|
3548
|
+
/**
|
|
3549
|
+
Returns the [simulated line
|
|
3550
|
+
break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
|
|
3551
|
+
for this context, if any.
|
|
3552
|
+
*/
|
|
3553
|
+
get simulatedBreak(): number | null;
|
|
3511
3554
|
}
|
|
3555
|
+
/**
|
|
3556
|
+
Enables reindentation on input. When a language defines an
|
|
3557
|
+
`indentOnInput` field in its [language
|
|
3558
|
+
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
|
|
3559
|
+
expression, the line at the cursor will be reindented whenever new
|
|
3560
|
+
text is typed and the input from the start of the line up to the
|
|
3561
|
+
cursor matches that regexp.
|
|
3562
|
+
|
|
3563
|
+
To avoid unneccesary reindents, it is recommended to start the
|
|
3564
|
+
regexp with `^` (usually followed by `\s*`), and end it with `$`.
|
|
3565
|
+
For example, `/^\s*\}$/` will reindent when a closing brace is
|
|
3566
|
+
added at the start of a line.
|
|
3567
|
+
*/
|
|
3568
|
+
declare function indentOnInput(): Extension;
|
|
3512
3569
|
|
|
3513
3570
|
interface CompletionConfig {
|
|
3514
3571
|
/**
|
|
@@ -4604,6 +4661,12 @@ interface GutterConfig {
|
|
|
4604
4661
|
*/
|
|
4605
4662
|
lineMarker?: (view: EditorView, line: BlockInfo, otherMarkers: readonly GutterMarker[]) => GutterMarker | null;
|
|
4606
4663
|
/**
|
|
4664
|
+
If line markers depend on additional state, and should be
|
|
4665
|
+
updated when that changes, pass a predicate here that checks
|
|
4666
|
+
whether a given view update might change the line markers.
|
|
4667
|
+
*/
|
|
4668
|
+
lineMarkerChange?: null | ((update: ViewUpdate) => boolean);
|
|
4669
|
+
/**
|
|
4607
4670
|
Add a hidden spacer element that gives the gutter its base
|
|
4608
4671
|
width.
|
|
4609
4672
|
*/
|