@codemirror/view 0.20.7 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +12 -6
- package/dist/index.d.ts +17 -10
- package/dist/index.js +12 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 6.0.0 (2022-06-08)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
The new static `EditorView.findFromDOM` method can be used to retrieve an editor instance from its DOM structure.
|
|
6
|
+
|
|
7
|
+
Instead of passing a constructed state to the `EditorView` constructor, it is now also possible to inline the configuration options to the state in the view config object.
|
|
8
|
+
|
|
1
9
|
## 0.20.7 (2022-05-30)
|
|
2
10
|
|
|
3
11
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -5959,11 +5959,7 @@ class EditorView {
|
|
|
5959
5959
|
option, or put `view.dom` into your document after creating a
|
|
5960
5960
|
view, so that the user can see the editor.
|
|
5961
5961
|
*/
|
|
5962
|
-
constructor(
|
|
5963
|
-
/**
|
|
5964
|
-
Initialization options.
|
|
5965
|
-
*/
|
|
5966
|
-
config = {}) {
|
|
5962
|
+
constructor(config = {}) {
|
|
5967
5963
|
this.plugins = [];
|
|
5968
5964
|
this.pluginMap = new Map;
|
|
5969
5965
|
this.editorAttrs = {};
|
|
@@ -5996,7 +5992,7 @@ class EditorView {
|
|
|
5996
5992
|
this._dispatch = config.dispatch || ((tr) => this.update([tr]));
|
|
5997
5993
|
this.dispatch = this.dispatch.bind(this);
|
|
5998
5994
|
this.root = (config.root || getRoot(config.parent) || document);
|
|
5999
|
-
this.viewState = new ViewState(config.state || state.EditorState.create());
|
|
5995
|
+
this.viewState = new ViewState(config.state || state.EditorState.create(config));
|
|
6000
5996
|
this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
|
|
6001
5997
|
for (let plugin of this.plugins)
|
|
6002
5998
|
plugin.update(this);
|
|
@@ -6671,6 +6667,16 @@ class EditorView {
|
|
|
6671
6667
|
static baseTheme(spec) {
|
|
6672
6668
|
return state.Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
|
|
6673
6669
|
}
|
|
6670
|
+
/**
|
|
6671
|
+
Retrieve an editor view instance from the view's DOM
|
|
6672
|
+
representation.
|
|
6673
|
+
*/
|
|
6674
|
+
static findFromDOM(dom) {
|
|
6675
|
+
var _a;
|
|
6676
|
+
let content = dom.querySelector(".cm-content");
|
|
6677
|
+
let cView = content && ContentView.get(content) || ContentView.get(dom);
|
|
6678
|
+
return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
|
|
6679
|
+
}
|
|
6674
6680
|
}
|
|
6675
6681
|
/**
|
|
6676
6682
|
Facet to add a [style
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _codemirror_state from '@codemirror/state';
|
|
2
|
-
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
2
|
+
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, EditorStateConfig, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
3
3
|
import { StyleModule, StyleSpec } from 'style-mod';
|
|
4
4
|
|
|
5
5
|
declare type Attrs = {
|
|
@@ -559,10 +559,16 @@ declare class BidiSpan {
|
|
|
559
559
|
get dir(): Direction;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
|
|
562
|
+
/**
|
|
563
|
+
The type of object given to the [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView)
|
|
564
|
+
constructor.
|
|
565
|
+
*/
|
|
566
|
+
interface EditorViewConfig extends EditorStateConfig {
|
|
563
567
|
/**
|
|
564
|
-
The view's initial state.
|
|
565
|
-
|
|
568
|
+
The view's initial state. If not given, a new state is created
|
|
569
|
+
by passing this configuration object to
|
|
570
|
+
[`EditorState.create`](https://codemirror.net/6/docs/ref/#state.EditorState^create), using its
|
|
571
|
+
`doc`, `selection`, and `extensions` field (if provided).
|
|
566
572
|
*/
|
|
567
573
|
state?: EditorState;
|
|
568
574
|
/**
|
|
@@ -676,11 +682,7 @@ declare class EditorView {
|
|
|
676
682
|
option, or put `view.dom` into your document after creating a
|
|
677
683
|
view, so that the user can see the editor.
|
|
678
684
|
*/
|
|
679
|
-
constructor(
|
|
680
|
-
/**
|
|
681
|
-
Initialization options.
|
|
682
|
-
*/
|
|
683
|
-
config?: EditorConfig);
|
|
685
|
+
constructor(config?: EditorViewConfig);
|
|
684
686
|
/**
|
|
685
687
|
All regular editor state updates should go through this. It
|
|
686
688
|
takes a transaction or transaction spec and updates the view to
|
|
@@ -1131,6 +1133,11 @@ declare class EditorView {
|
|
|
1131
1133
|
search match).
|
|
1132
1134
|
*/
|
|
1133
1135
|
static announce: _codemirror_state.StateEffectType<string>;
|
|
1136
|
+
/**
|
|
1137
|
+
Retrieve an editor view instance from the view's DOM
|
|
1138
|
+
representation.
|
|
1139
|
+
*/
|
|
1140
|
+
static findFromDOM(dom: HTMLElement): EditorView | null;
|
|
1134
1141
|
}
|
|
1135
1142
|
/**
|
|
1136
1143
|
Helper type that maps event names to event object types, or the
|
|
@@ -1783,4 +1790,4 @@ line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
|
|
|
1783
1790
|
*/
|
|
1784
1791
|
declare function highlightActiveLineGutter(): Extension;
|
|
1785
1792
|
|
|
1786
|
-
export { BidiSpan, BlockInfo, BlockType, Command, DOMEventHandlers, DOMEventMap, Decoration, DecorationSet, Direction, EditorView, GutterMarker, KeyBinding, MatchDecorator, MouseSelectionStyle, Panel, PanelConstructor, PluginSpec, PluginValue, Rect, Tooltip, TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
|
1793
|
+
export { BidiSpan, BlockInfo, BlockType, Command, DOMEventHandlers, DOMEventMap, Decoration, DecorationSet, Direction, EditorView, EditorViewConfig, GutterMarker, KeyBinding, MatchDecorator, MouseSelectionStyle, Panel, PanelConstructor, PluginSpec, PluginValue, Rect, Tooltip, TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
package/dist/index.js
CHANGED
|
@@ -5952,11 +5952,7 @@ class EditorView {
|
|
|
5952
5952
|
option, or put `view.dom` into your document after creating a
|
|
5953
5953
|
view, so that the user can see the editor.
|
|
5954
5954
|
*/
|
|
5955
|
-
constructor(
|
|
5956
|
-
/**
|
|
5957
|
-
Initialization options.
|
|
5958
|
-
*/
|
|
5959
|
-
config = {}) {
|
|
5955
|
+
constructor(config = {}) {
|
|
5960
5956
|
this.plugins = [];
|
|
5961
5957
|
this.pluginMap = new Map;
|
|
5962
5958
|
this.editorAttrs = {};
|
|
@@ -5989,7 +5985,7 @@ class EditorView {
|
|
|
5989
5985
|
this._dispatch = config.dispatch || ((tr) => this.update([tr]));
|
|
5990
5986
|
this.dispatch = this.dispatch.bind(this);
|
|
5991
5987
|
this.root = (config.root || getRoot(config.parent) || document);
|
|
5992
|
-
this.viewState = new ViewState(config.state || EditorState.create());
|
|
5988
|
+
this.viewState = new ViewState(config.state || EditorState.create(config));
|
|
5993
5989
|
this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
|
|
5994
5990
|
for (let plugin of this.plugins)
|
|
5995
5991
|
plugin.update(this);
|
|
@@ -6664,6 +6660,16 @@ class EditorView {
|
|
|
6664
6660
|
static baseTheme(spec) {
|
|
6665
6661
|
return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
|
|
6666
6662
|
}
|
|
6663
|
+
/**
|
|
6664
|
+
Retrieve an editor view instance from the view's DOM
|
|
6665
|
+
representation.
|
|
6666
|
+
*/
|
|
6667
|
+
static findFromDOM(dom) {
|
|
6668
|
+
var _a;
|
|
6669
|
+
let content = dom.querySelector(".cm-content");
|
|
6670
|
+
let cView = content && ContentView.get(content) || ContentView.get(dom);
|
|
6671
|
+
return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
|
|
6672
|
+
}
|
|
6667
6673
|
}
|
|
6668
6674
|
/**
|
|
6669
6675
|
Facet to add a [style
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "DOM view component for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@codemirror/state": "^0.
|
|
29
|
+
"@codemirror/state": "^6.0.0",
|
|
30
30
|
"style-mod": "^4.0.0",
|
|
31
31
|
"w3c-keyname": "^2.2.4"
|
|
32
32
|
},
|