@difizen/libro-codemirror 0.1.1 → 0.1.2
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/es/auto-complete/filter.d.ts.map +1 -1
- package/es/auto-complete/filter.js +1 -7
- package/es/auto-complete/index.d.ts.map +1 -1
- package/es/auto-complete/index.js +5 -9
- package/es/auto-complete/snippet.d.ts.map +1 -1
- package/es/auto-complete/snippet.js +2 -2
- package/es/auto-complete/state.d.ts.map +1 -1
- package/es/auto-complete/state.js +5 -16
- package/es/auto-complete/view.d.ts +5 -0
- package/es/auto-complete/view.d.ts.map +1 -1
- package/es/auto-complete/view.js +2 -13
- package/es/completion.js +1 -1
- package/es/config.d.ts +15 -10
- package/es/config.d.ts.map +1 -1
- package/es/config.js +15 -6
- package/es/editor-contribution.d.ts +8 -0
- package/es/editor-contribution.d.ts.map +1 -0
- package/es/editor-contribution.js +30 -0
- package/es/editor.d.ts +40 -10
- package/es/editor.d.ts.map +1 -1
- package/es/editor.js +241 -45
- package/es/indentation-markers/map.d.ts +9 -9
- package/es/indentation-markers/map.d.ts.map +1 -1
- package/es/index.d.ts +3 -1
- package/es/index.d.ts.map +1 -1
- package/es/index.js +3 -1
- package/es/libro-icon.d.ts +2 -2
- package/es/libro-icon.d.ts.map +1 -1
- package/es/libro-icon.js +2 -2
- package/es/lsp/completion.d.ts +5 -0
- package/es/lsp/completion.d.ts.map +1 -0
- package/es/lsp/completion.js +245 -0
- package/es/lsp/format.d.ts +7 -0
- package/es/lsp/format.d.ts.map +1 -0
- package/es/lsp/format.js +193 -0
- package/es/lsp/index.d.ts +7 -0
- package/es/lsp/index.d.ts.map +1 -0
- package/es/lsp/index.js +6 -0
- package/es/lsp/lint.d.ts +3 -0
- package/es/lsp/lint.d.ts.map +1 -0
- package/es/lsp/lint.js +114 -0
- package/es/lsp/protocol.d.ts +7 -0
- package/es/lsp/protocol.d.ts.map +1 -0
- package/es/lsp/protocol.js +1 -0
- package/es/lsp/tooltip.d.ts +3 -0
- package/es/lsp/tooltip.d.ts.map +1 -0
- package/es/lsp/tooltip.js +113 -0
- package/es/lsp/util.d.ts +15 -0
- package/es/lsp/util.d.ts.map +1 -0
- package/es/lsp/util.js +58 -0
- package/es/mode.d.ts.map +1 -1
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +4 -0
- package/es/theme.js +4 -5
- package/es/tooltip.d.ts.map +1 -1
- package/es/tooltip.js +2 -4
- package/package.json +7 -5
- package/src/auto-complete/filter.ts +5 -7
- package/src/auto-complete/index.ts +6 -7
- package/src/auto-complete/snippet.ts +8 -2
- package/src/auto-complete/state.ts +13 -18
- package/src/auto-complete/view.ts +7 -13
- package/src/completion.ts +2 -2
- package/src/config.ts +40 -28
- package/src/editor-contribution.ts +17 -0
- package/src/editor.ts +226 -50
- package/src/hyperlink.ts +1 -1
- package/src/indentation-markers/index.ts +3 -3
- package/src/indentation-markers/map.ts +9 -9
- package/src/index.ts +4 -1
- package/src/libro-icon.tsx +4 -0
- package/src/lsp/completion.ts +175 -0
- package/src/lsp/format.ts +144 -0
- package/src/lsp/index.ts +6 -0
- package/src/lsp/lint.ts +125 -0
- package/src/lsp/protocol.ts +8 -0
- package/src/lsp/tooltip.ts +76 -0
- package/src/lsp/util.ts +69 -0
- package/src/mode.ts +1 -1
- package/src/module.ts +8 -0
- package/src/theme.ts +4 -4
- package/src/tooltip.ts +2 -4
- package/src/libro-icon.ts +0 -4
package/es/editor.js
CHANGED
|
@@ -16,9 +16,9 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
16
16
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
17
|
import { insertNewlineAndIndent, redo as _redo, undo as _undo } from '@codemirror/commands';
|
|
18
18
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
19
|
-
import {
|
|
19
|
+
import { EditorSelection, EditorState, Prec, StateEffect, StateField } from '@codemirror/state';
|
|
20
20
|
import { Decoration, EditorView } from '@codemirror/view';
|
|
21
|
-
import {
|
|
21
|
+
import { defaultConfig, defaultSelectionStyle } from '@difizen/libro-code-editor';
|
|
22
22
|
import { findFirstArrayIndex, removeAllWhereFromArray } from '@difizen/libro-common';
|
|
23
23
|
import { Disposable, Emitter } from '@difizen/mana-app';
|
|
24
24
|
import { getOrigin, watch } from '@difizen/mana-app';
|
|
@@ -74,7 +74,11 @@ var DOWN_ARROW = 40;
|
|
|
74
74
|
export var codeMirrorDefaultConfig = _objectSpread(_objectSpread({}, defaultConfig), {}, {
|
|
75
75
|
mode: 'null',
|
|
76
76
|
mimetype: 'text/x-python',
|
|
77
|
-
theme:
|
|
77
|
+
theme: {
|
|
78
|
+
light: 'jupyter',
|
|
79
|
+
dark: 'jupyter',
|
|
80
|
+
hc: 'jupyter'
|
|
81
|
+
},
|
|
78
82
|
smartIndent: true,
|
|
79
83
|
electricChars: true,
|
|
80
84
|
keyMap: 'default',
|
|
@@ -92,7 +96,7 @@ export var codeMirrorDefaultConfig = _objectSpread(_objectSpread({}, defaultConf
|
|
|
92
96
|
styleSelectedText: true,
|
|
93
97
|
selectionPointer: false,
|
|
94
98
|
handlePaste: true,
|
|
95
|
-
|
|
99
|
+
scrollBarHeight: 8,
|
|
96
100
|
//
|
|
97
101
|
highlightActiveLineGutter: false,
|
|
98
102
|
highlightSpecialChars: true,
|
|
@@ -117,51 +121,36 @@ export var codeMirrorDefaultConfig = _objectSpread(_objectSpread({}, defaultConf
|
|
|
117
121
|
placeholder: ''
|
|
118
122
|
});
|
|
119
123
|
export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
124
|
+
// highlight
|
|
125
|
+
|
|
120
126
|
/**
|
|
121
127
|
* Construct a CodeMirror editor.
|
|
122
128
|
*/
|
|
123
129
|
function CodeMirrorEditor(options) {
|
|
124
130
|
var _this = this;
|
|
125
131
|
_classCallCheck(this, CodeMirrorEditor);
|
|
126
|
-
this.handleTooltipChange = function (val) {
|
|
127
|
-
_this.modalChangeEmitter.fire(val);
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Initialize the editor binding.
|
|
131
|
-
*/
|
|
132
|
-
// protected _initializeEditorBinding(): void {
|
|
133
|
-
// const sharedModel = this.model.sharedModel as models.IYText;
|
|
134
|
-
// this._yeditorBinding = {
|
|
135
|
-
// text: sharedModel.ysource,
|
|
136
|
-
// awareness: sharedModel.awareness,
|
|
137
|
-
// undoManager: sharedModel.undoManager,
|
|
138
|
-
// };
|
|
139
|
-
// }
|
|
140
|
-
this.save = function () {
|
|
141
|
-
//
|
|
142
|
-
};
|
|
143
132
|
/**
|
|
144
133
|
* A signal emitted when either the top or bottom edge is requested.
|
|
145
134
|
*/
|
|
146
135
|
this.edgeRequestedEmitter = new Emitter();
|
|
147
136
|
this.edgeRequested = this.edgeRequestedEmitter.event;
|
|
148
137
|
this.modalChangeEmitter = new Emitter();
|
|
138
|
+
this.handleTooltipChange = function (val) {
|
|
139
|
+
_this.modalChangeEmitter.fire(val);
|
|
140
|
+
};
|
|
149
141
|
this._selectionMarkers = {};
|
|
150
|
-
this._caretHover = null;
|
|
151
|
-
this._hoverTimeout = undefined;
|
|
152
|
-
this._hoverId = undefined;
|
|
153
142
|
this._keydownHandlers = new Array();
|
|
154
143
|
this._uuid = '';
|
|
155
144
|
this._isDisposed = false;
|
|
156
145
|
this._lastChange = null;
|
|
157
146
|
this._editorConfig = new EditorConfiguration(options);
|
|
158
|
-
var host = this.host = options
|
|
147
|
+
var host = this.host = options.host;
|
|
159
148
|
host.classList.add(EDITOR_CLASS);
|
|
160
149
|
host.classList.add('jp-Editor');
|
|
161
150
|
host.addEventListener('focus', this, true);
|
|
162
151
|
host.addEventListener('blur', this, true);
|
|
163
152
|
host.addEventListener('scroll', this, true);
|
|
164
|
-
this._uuid = options
|
|
153
|
+
this._uuid = options.uuid || v4();
|
|
165
154
|
|
|
166
155
|
// State and effects for handling the selection marks
|
|
167
156
|
this._addMark = StateEffect.define();
|
|
@@ -220,13 +209,83 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
220
209
|
}
|
|
221
210
|
});
|
|
222
211
|
|
|
212
|
+
// handle highlight
|
|
213
|
+
this.highlightEffect = StateEffect.define({
|
|
214
|
+
map: function map(value, mapping) {
|
|
215
|
+
return {
|
|
216
|
+
matches: value.matches.map(function (v) {
|
|
217
|
+
return {
|
|
218
|
+
text: v.text,
|
|
219
|
+
position: mapping.mapPos(v.position)
|
|
220
|
+
};
|
|
221
|
+
}),
|
|
222
|
+
currentIndex: value.currentIndex
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
this.highlightMark = Decoration.mark({
|
|
227
|
+
class: 'cm-searchMatch'
|
|
228
|
+
});
|
|
229
|
+
this.selectedMatchMark = Decoration.mark({
|
|
230
|
+
class: 'cm-searchMatch cm-searchMatch-selected libro-selectedtext'
|
|
231
|
+
});
|
|
232
|
+
this.highlightField = StateField.define({
|
|
233
|
+
create: function create() {
|
|
234
|
+
return Decoration.none;
|
|
235
|
+
},
|
|
236
|
+
update: function update(highlights, transaction) {
|
|
237
|
+
// eslint-disable-next-line no-param-reassign
|
|
238
|
+
highlights = highlights.map(transaction.changes);
|
|
239
|
+
var _iterator3 = _createForOfIteratorHelper(transaction.effects),
|
|
240
|
+
_step3;
|
|
241
|
+
try {
|
|
242
|
+
var _loop2 = function _loop2() {
|
|
243
|
+
var ef = _step3.value;
|
|
244
|
+
if (ef.is(_this.highlightEffect)) {
|
|
245
|
+
var e = ef;
|
|
246
|
+
if (e.value.matches.length) {
|
|
247
|
+
// eslint-disable-next-line no-param-reassign
|
|
248
|
+
highlights = highlights.update({
|
|
249
|
+
add: e.value.matches.map(function (m, index) {
|
|
250
|
+
if (index === e.value.currentIndex) {
|
|
251
|
+
return _this.selectedMatchMark.range(m.position, m.position + m.text.length);
|
|
252
|
+
}
|
|
253
|
+
return _this.highlightMark.range(m.position, m.position + m.text.length);
|
|
254
|
+
}),
|
|
255
|
+
filter: function filter(from, to) {
|
|
256
|
+
return !e.value.matches.some(function (m) {
|
|
257
|
+
return m.position >= from && m.position + m.text.length <= to;
|
|
258
|
+
}) || from === to;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
} else {
|
|
262
|
+
// eslint-disable-next-line no-param-reassign
|
|
263
|
+
highlights = Decoration.none;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
268
|
+
_loop2();
|
|
269
|
+
}
|
|
270
|
+
} catch (err) {
|
|
271
|
+
_iterator3.e(err);
|
|
272
|
+
} finally {
|
|
273
|
+
_iterator3.f();
|
|
274
|
+
}
|
|
275
|
+
return highlights;
|
|
276
|
+
},
|
|
277
|
+
provide: function provide(f) {
|
|
278
|
+
return EditorView.decorations.from(f);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
223
282
|
// Handle selection style.
|
|
224
|
-
var style = options
|
|
283
|
+
var style = options.selectionStyle || {};
|
|
225
284
|
this._selectionStyle = _objectSpread(_objectSpread({}, defaultSelectionStyle), style);
|
|
226
|
-
var model = this._model = options
|
|
285
|
+
var model = this._model = options.model;
|
|
227
286
|
var config = options.config || {};
|
|
228
287
|
var fullConfig = this._config = _objectSpread(_objectSpread(_objectSpread({}, codeMirrorDefaultConfig), config), {}, {
|
|
229
|
-
mimetype: options
|
|
288
|
+
mimetype: options.model.mimeType
|
|
230
289
|
});
|
|
231
290
|
|
|
232
291
|
// this._initializeEditorBinding();
|
|
@@ -272,6 +331,18 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
272
331
|
|
|
273
332
|
watch(model, 'mimeType', this._onMimeTypeChanged);
|
|
274
333
|
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Initialize the editor binding.
|
|
337
|
+
*/
|
|
338
|
+
// protected _initializeEditorBinding(): void {
|
|
339
|
+
// const sharedModel = this.model.sharedModel as models.IYText;
|
|
340
|
+
// this._yeditorBinding = {
|
|
341
|
+
// text: sharedModel.ysource,
|
|
342
|
+
// awareness: sharedModel.awareness,
|
|
343
|
+
// undoManager: sharedModel.undoManager,
|
|
344
|
+
// };
|
|
345
|
+
// }
|
|
275
346
|
_createClass(CodeMirrorEditor, [{
|
|
276
347
|
key: "uuid",
|
|
277
348
|
get:
|
|
@@ -364,7 +435,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
364
435
|
* Tests whether the editor is disposed.
|
|
365
436
|
*/
|
|
366
437
|
}, {
|
|
367
|
-
key: "
|
|
438
|
+
key: "disposed",
|
|
368
439
|
get: function get() {
|
|
369
440
|
return this._isDisposed;
|
|
370
441
|
}
|
|
@@ -375,7 +446,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
375
446
|
}, {
|
|
376
447
|
key: "dispose",
|
|
377
448
|
value: function dispose() {
|
|
378
|
-
if (this.
|
|
449
|
+
if (this.disposed) {
|
|
379
450
|
return;
|
|
380
451
|
}
|
|
381
452
|
this._isDisposed = true;
|
|
@@ -442,8 +513,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
442
513
|
key: "getLine",
|
|
443
514
|
value: function getLine(line) {
|
|
444
515
|
// TODO: CM6 remove +1 when CM6 first line number has propagated
|
|
445
|
-
|
|
446
|
-
return _line <= this.doc.lines ? this.doc.line(_line).text : undefined;
|
|
516
|
+
return line <= this.doc.lines ? this.doc.line(line).text : undefined;
|
|
447
517
|
}
|
|
448
518
|
|
|
449
519
|
/**
|
|
@@ -453,7 +523,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
453
523
|
key: "getOffsetAt",
|
|
454
524
|
value: function getOffsetAt(position) {
|
|
455
525
|
// TODO: CM6 remove +1 when CM6 first line number has propagated
|
|
456
|
-
return this.doc.line(position.line
|
|
526
|
+
return this.doc.line(position.line).from + position.column - 1;
|
|
457
527
|
}
|
|
458
528
|
|
|
459
529
|
/**
|
|
@@ -574,6 +644,13 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
574
644
|
var toOffset = this.getOffsetAt(this._toPosition(to));
|
|
575
645
|
return this.state.sliceDoc(fromOffset, toOffset);
|
|
576
646
|
}
|
|
647
|
+
}, {
|
|
648
|
+
key: "getSelectionValue",
|
|
649
|
+
value: function getSelectionValue(range) {
|
|
650
|
+
var fromOffset = range ? this.getOffsetAt(range.start) : this.editor.state.selection.main.from;
|
|
651
|
+
var toOffset = range ? this.getOffsetAt(range.end) : this.editor.state.selection.main.to;
|
|
652
|
+
return this.state.sliceDoc(fromOffset, toOffset);
|
|
653
|
+
}
|
|
577
654
|
|
|
578
655
|
/**
|
|
579
656
|
* Add a keydown handler to the editor.
|
|
@@ -752,24 +829,59 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
752
829
|
*/
|
|
753
830
|
}, {
|
|
754
831
|
key: "replaceSelection",
|
|
755
|
-
value: function replaceSelection(text) {
|
|
756
|
-
this.editor.dispatch(
|
|
832
|
+
value: function replaceSelection(text, range) {
|
|
833
|
+
this.editor.dispatch({
|
|
834
|
+
changes: {
|
|
835
|
+
from: this.getOffsetAt(range.start),
|
|
836
|
+
to: this.getOffsetAt(range.end),
|
|
837
|
+
insert: text
|
|
838
|
+
}
|
|
839
|
+
});
|
|
757
840
|
}
|
|
758
|
-
|
|
841
|
+
}, {
|
|
842
|
+
key: "replaceSelections",
|
|
843
|
+
value: function replaceSelections(edits) {
|
|
844
|
+
var _this5 = this;
|
|
845
|
+
// const trans = this.state.replaceSelection(text);
|
|
846
|
+
this.editor.dispatch({
|
|
847
|
+
changes: edits.map(function (item) {
|
|
848
|
+
return {
|
|
849
|
+
from: _this5.getOffsetAt(item.range.start),
|
|
850
|
+
to: _this5.getOffsetAt(item.range.end),
|
|
851
|
+
insert: item.text
|
|
852
|
+
};
|
|
853
|
+
})
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}, {
|
|
857
|
+
key: "highlightMatches",
|
|
858
|
+
value: function highlightMatches(matches, currentIndex) {
|
|
859
|
+
var effects = [this.highlightEffect.of({
|
|
860
|
+
matches: matches,
|
|
861
|
+
currentIndex: currentIndex
|
|
862
|
+
})];
|
|
863
|
+
if (!this.state.field(this.highlightField, false)) {
|
|
864
|
+
effects.push(StateEffect.appendConfig.of([this.highlightField]));
|
|
865
|
+
}
|
|
866
|
+
this.editor.dispatch({
|
|
867
|
+
effects: effects
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
}, {
|
|
871
|
+
key: "getTokens",
|
|
872
|
+
value:
|
|
759
873
|
/**
|
|
760
874
|
* Get a list of tokens for the current editor text content.
|
|
761
875
|
*/
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
value: function getTokens() {
|
|
765
|
-
var _this5 = this;
|
|
876
|
+
function getTokens() {
|
|
877
|
+
var _this6 = this;
|
|
766
878
|
var tokens = [];
|
|
767
879
|
var tree = ensureSyntaxTree(this.state, this.doc.length);
|
|
768
880
|
if (tree) {
|
|
769
881
|
tree.iterate({
|
|
770
882
|
enter: function enter(node) {
|
|
771
883
|
tokens.push({
|
|
772
|
-
value:
|
|
884
|
+
value: _this6.state.sliceDoc(node.from, node.to),
|
|
773
885
|
offset: node.from,
|
|
774
886
|
type: node.name
|
|
775
887
|
});
|
|
@@ -873,21 +985,51 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
873
985
|
}, {
|
|
874
986
|
key: "_onMimeTypeChanged",
|
|
875
987
|
value: function _onMimeTypeChanged() {
|
|
876
|
-
var
|
|
988
|
+
var _this7 = this;
|
|
877
989
|
var mime = this._model.mimeType;
|
|
878
990
|
// TODO: should we provide a hook for when the mode is done being set?
|
|
879
991
|
void ensure(mime).then(function (spec) {
|
|
880
992
|
if (spec) {
|
|
881
|
-
|
|
993
|
+
_this7._editorConfig.reconfigureExtension(_this7._editor, 'language', spec.support);
|
|
882
994
|
}
|
|
883
995
|
return;
|
|
884
996
|
});
|
|
885
997
|
}
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Handles a selections change.
|
|
1001
|
+
*/
|
|
1002
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1003
|
+
}, {
|
|
1004
|
+
key: "_onSelectionsChanged",
|
|
1005
|
+
value: function _onSelectionsChanged(args) {
|
|
1006
|
+
// const uuid = args.key;
|
|
1007
|
+
// if (uuid !== this.uuid) {
|
|
1008
|
+
// this._cleanSelections(uuid);
|
|
1009
|
+
// if (args.type !== 'remove' && args.newValue) {
|
|
1010
|
+
// this._markSelections(uuid, args.newValue);
|
|
1011
|
+
// }
|
|
1012
|
+
// }
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Clean selections for the given uuid.
|
|
1017
|
+
*/
|
|
1018
|
+
}, {
|
|
1019
|
+
key: "_cleanSelections",
|
|
1020
|
+
value: function _cleanSelections(uuid) {
|
|
1021
|
+
this.editor.dispatch({
|
|
1022
|
+
effects: this._removeMark.of({
|
|
1023
|
+
uuid: uuid,
|
|
1024
|
+
decorations: this._selectionMarkers[uuid]
|
|
1025
|
+
})
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
886
1028
|
}, {
|
|
887
1029
|
key: "_buildMarkDecoration",
|
|
888
1030
|
value: function _buildMarkDecoration(uuid,
|
|
889
1031
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
890
|
-
|
|
1032
|
+
selections) {
|
|
891
1033
|
var decorations = [];
|
|
892
1034
|
|
|
893
1035
|
// If we are marking selections corresponding to an active hover,
|
|
@@ -963,6 +1105,28 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
963
1105
|
// });
|
|
964
1106
|
// }
|
|
965
1107
|
|
|
1108
|
+
/**
|
|
1109
|
+
* Marks selections.
|
|
1110
|
+
*/
|
|
1111
|
+
}, {
|
|
1112
|
+
key: "_markSelections",
|
|
1113
|
+
value: function _markSelections(uuid, selections) {
|
|
1114
|
+
var _this8 = this;
|
|
1115
|
+
var sel = selections.map(function (selection) {
|
|
1116
|
+
return {
|
|
1117
|
+
from: _this8.getOffsetAt(selection.start),
|
|
1118
|
+
to: _this8.getOffsetAt(selection.end),
|
|
1119
|
+
style: selection.style
|
|
1120
|
+
};
|
|
1121
|
+
});
|
|
1122
|
+
this.editor.dispatch({
|
|
1123
|
+
effects: this._addMark.of({
|
|
1124
|
+
uuid: uuid,
|
|
1125
|
+
selections: sel
|
|
1126
|
+
})
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
|
|
966
1130
|
/**
|
|
967
1131
|
* Handles a cursor activity event.
|
|
968
1132
|
*/
|
|
@@ -1103,6 +1267,38 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
1103
1267
|
this._caretHover = null;
|
|
1104
1268
|
}
|
|
1105
1269
|
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Check for an out of sync editor.
|
|
1272
|
+
*/
|
|
1273
|
+
}, {
|
|
1274
|
+
key: "_checkSync",
|
|
1275
|
+
value: function _checkSync() {
|
|
1276
|
+
var change = this._lastChange;
|
|
1277
|
+
if (!change) {
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
this._lastChange = null;
|
|
1281
|
+
var doc = this.doc;
|
|
1282
|
+
if (doc.toString() === this._model.value) {
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// void showDialog({
|
|
1287
|
+
// title: this._trans.__('Code Editor out of Sync'),
|
|
1288
|
+
// body: this._trans.__(
|
|
1289
|
+
// 'Please open your browser JavaScript console for bug report instructions',
|
|
1290
|
+
// ),
|
|
1291
|
+
// });
|
|
1292
|
+
console.warn('If you are able and willing to publicly share the text or code in your editor, you can help us debug the "Code Editor out of Sync" message by pasting the following to the public issue at https://github.com/jupyterlab/jupyterlab/issues/2951. Please note that the data below includes the text/code in your editor.');
|
|
1293
|
+
console.warn(JSON.stringify({
|
|
1294
|
+
model: this._model.value,
|
|
1295
|
+
view: doc.toString(),
|
|
1296
|
+
selections: this.getSelections(),
|
|
1297
|
+
cursor: this.getCursorPosition(),
|
|
1298
|
+
lineSep: this.state.facet(EditorState.lineSeparator),
|
|
1299
|
+
change: change
|
|
1300
|
+
}));
|
|
1301
|
+
}
|
|
1106
1302
|
|
|
1107
1303
|
// protected _poll: Poll;
|
|
1108
1304
|
// protected _yeditorBinding: IYCodeMirrorBinding | null;
|
|
@@ -17,15 +17,15 @@ export interface IndentEntry {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare class IndentationMap {
|
|
19
19
|
/** The {@link EditorState} indentation is derived from. */
|
|
20
|
-
|
|
20
|
+
protected state: EditorState;
|
|
21
21
|
/** The set of lines that are used as an entrypoint. */
|
|
22
|
-
|
|
22
|
+
protected lines: Set<Line>;
|
|
23
23
|
/** The internal mapping of line numbers to {@link IndentEntry} objects. */
|
|
24
|
-
|
|
24
|
+
protected map: Map<number, IndentEntry>;
|
|
25
25
|
/** The width of the editor's indent unit. */
|
|
26
|
-
|
|
26
|
+
protected unitWidth: number;
|
|
27
27
|
/** The type of indentation to use (terminate at end of scope vs last non-empty line in scope) */
|
|
28
|
-
|
|
28
|
+
protected markerType: 'fullScope' | 'codeOnly';
|
|
29
29
|
/**
|
|
30
30
|
* @param lines - The set of lines to get the indentation map for.
|
|
31
31
|
* @param state - The {@link EditorState} to derive the indentation map from.
|
|
@@ -54,24 +54,24 @@ export declare class IndentationMap {
|
|
|
54
54
|
* @param col - The visual beginning whitespace width of the line.
|
|
55
55
|
* @param level - The indentation level of the line.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
protected set(line: Line, col: number, level: number): IndentEntry;
|
|
58
58
|
/**
|
|
59
59
|
* Adds a line to the indentation map.
|
|
60
60
|
*
|
|
61
61
|
* @param line - The {@link Line} to add to the map.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
protected add(line: Line): IndentEntry;
|
|
64
64
|
/**
|
|
65
65
|
* Finds the closest non-empty line, starting from the given line.
|
|
66
66
|
*
|
|
67
67
|
* @param from - The {@link Line} to start from.
|
|
68
68
|
* @param dir - The direction to search in. Either `1` or `-1`.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
protected closestNonEmpty(from: Line, dir: -1 | 1): IndentEntry;
|
|
71
71
|
/**
|
|
72
72
|
* Finds the state's active block (via the current selection) and sets all
|
|
73
73
|
* the active indent level for the lines in the block.
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
protected findAndSetActiveLines(): void;
|
|
76
76
|
}
|
|
77
77
|
//# sourceMappingURL=map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAK3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACzB,2DAA2D;IAC3D,
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAK3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACzB,2DAA2D;IAC3D,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC;IAE7B,uDAAuD;IACvD,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAE3B,2EAA2E;IAC3E,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAExC,6CAA6C;IAC7C,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAE5B,iGAAiG;IACjG,SAAS,CAAC,UAAU,EAAE,WAAW,GAAG,UAAU,CAAC;IAE/C;;;;;OAKG;gBAED,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,EAChB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,WAAW,GAAG,UAAU;IAiBtC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAIvB;;;;;;OAMG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAUvB;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQpD;;;;OAIG;IACH,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI;IAkDxB;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC;IAoCjD;;;OAGG;IACH,SAAS,CAAC,qBAAqB;CAiEhC"}
|
package/es/index.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import './style/theme.css';
|
|
|
3
3
|
import './style/variables.css';
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './editor.js';
|
|
6
|
+
export * from './lsp/index.js';
|
|
6
7
|
export * from './mode.js';
|
|
7
|
-
export * from './
|
|
8
|
+
export * from './module.js';
|
|
8
9
|
export * from './factory.js';
|
|
9
10
|
export * from './monitor.js';
|
|
11
|
+
export * from './theme.js';
|
|
10
12
|
export * from './auto-complete/index.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
package/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAE3B,cAAc,0BAA0B,CAAC"}
|
package/es/index.js
CHANGED
|
@@ -3,8 +3,10 @@ import "./style/theme.css";
|
|
|
3
3
|
import "./style/variables.css";
|
|
4
4
|
export * from "./config.js";
|
|
5
5
|
export * from "./editor.js";
|
|
6
|
+
export * from "./lsp/index.js";
|
|
6
7
|
export * from "./mode.js";
|
|
7
|
-
export * from "./
|
|
8
|
+
export * from "./module.js";
|
|
8
9
|
export * from "./factory.js";
|
|
9
10
|
export * from "./monitor.js";
|
|
11
|
+
export * from "./theme.js";
|
|
10
12
|
export * from "./auto-complete/index.js";
|
package/es/libro-icon.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const FoldIcon = "<svg width=\"8px\" height=\"6px\" viewBox=\"0 0 8 6\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\"
|
|
2
|
-
export declare const UnFoldIcon = "<svg width=\"6px\" height=\"8px\" viewBox=\"0 0 6 8\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\u6536\u8D77</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\"
|
|
1
|
+
export declare const FoldIcon = "<svg width=\"8px\" height=\"6px\" viewBox=\"0 0 8 6\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2015.000000, -434.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\" transform=\"translate(2004.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(11.250000, 27.500000)\"><path d=\"M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z\" id=\"Down\"></path></g></g></g></g></svg>";
|
|
2
|
+
export declare const UnFoldIcon = "<svg width=\"6px\" height=\"8px\" viewBox=\"0 0 6 8\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\u6536\u8D77</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2094.000000, -433.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\u5907\u4EFD\" transform=\"translate(2082.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)\"><path d=\"M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z\" id=\"Down\"></path></g></g></g></g></svg>";
|
|
3
3
|
//# sourceMappingURL=libro-icon.d.ts.map
|
package/es/libro-icon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-icon.d.ts","sourceRoot":"","sources":["../src/libro-icon.
|
|
1
|
+
{"version":3,"file":"libro-icon.d.ts","sourceRoot":"","sources":["../src/libro-icon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,+iCACq7B,CAAC;AAC38B,eAAO,MAAM,UAAU,ixCACioC,CAAC"}
|
package/es/libro-icon.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var FoldIcon = '<svg width="8px" height="6px" viewBox="0 0 8 6" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down</title><g id="0424" stroke="none" stroke-width="1" fill="none"
|
|
2
|
-
export var UnFoldIcon = '<svg width="6px" height="8px" viewBox="0 0 6 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down收起</title><g id="0424" stroke="none" stroke-width="1" fill="none"
|
|
1
|
+
export var FoldIcon = '<svg width="8px" height="6px" viewBox="0 0 8 6" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down</title><g id="0424" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2015.000000, -434.000000)" fill="#A4AECB"><g id="编组-15" transform="translate(2004.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(11.250000, 27.500000)"><path d="M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z" id="Down"></path></g></g></g></g></svg>';
|
|
2
|
+
export var UnFoldIcon = '<svg width="6px" height="8px" viewBox="0 0 6 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down收起</title><g id="0424" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2094.000000, -433.000000)" fill="#A4AECB"><g id="编组-15备份" transform="translate(2082.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)"><path d="M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z" id="Down"></path></g></g></g></g></svg>';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Completion } from '../auto-complete/index.js';
|
|
2
|
+
import type { CMLSPExtension } from './protocol.js';
|
|
3
|
+
export type CompletionItemDetailReolve = (completion: Completion) => Node | null | Promise<Node | null>;
|
|
4
|
+
export declare const lspPythonCompletion: CMLSPExtension;
|
|
5
|
+
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lsp/completion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,MAAM,0BAA0B,GAAG,CACvC,UAAU,EAAE,UAAU,KACnB,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAiCxC,eAAO,MAAM,mBAAmB,EAAE,cAmIjC,CAAC"}
|