@difizen/libro-codemirror 0.3.16 → 1.0.1
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/completion.d.ts +3 -3
- package/es/auto-complete/completion.d.ts.map +1 -1
- package/es/auto-complete/completion.js +6 -6
- package/es/auto-complete/state.js +2 -2
- package/es/auto-complete/theme.js +1 -1
- package/es/auto-complete/view.d.ts +3 -3
- package/es/auto-complete/view.d.ts.map +1 -1
- package/es/auto-complete/view.js +2 -2
- package/es/config.js +2 -2
- package/es/editor-contribution.js +1 -1
- package/es/editor.d.ts +3 -3
- package/es/editor.d.ts.map +1 -1
- package/es/editor.js +4 -4
- package/es/lsp/completion.d.ts.map +1 -1
- package/es/lsp/completion.js +4 -3
- package/es/lsp/lint.d.ts.map +1 -1
- package/es/lsp/lint.js +3 -3
- package/es/mode.d.ts +2 -2
- package/es/mode.d.ts.map +1 -1
- package/es/mode.js +6 -6
- package/es/module.d.ts +1 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +1 -1
- package/es/monitor.d.ts +3 -3
- package/es/monitor.d.ts.map +1 -1
- package/es/monitor.js +1 -1
- package/es/style/variables.css +24 -15
- package/package.json +5 -7
- package/src/auto-complete/README.md +1 -1
- package/src/auto-complete/completion.ts +7 -7
- package/src/auto-complete/state.ts +2 -2
- package/src/auto-complete/theme.ts +1 -1
- package/src/auto-complete/view.ts +7 -3
- package/src/config.ts +2 -2
- package/src/editor-contribution.ts +1 -1
- package/src/editor.ts +4 -4
- package/src/lsp/completion.ts +5 -4
- package/src/lsp/lint.ts +51 -49
- package/src/mode.ts +2 -2
- package/src/module.ts +1 -1
- package/src/monitor.ts +1 -1
- package/src/style/variables.css +24 -15
|
@@ -9,7 +9,7 @@ export interface Completion {
|
|
|
9
9
|
type?: string;
|
|
10
10
|
boost?: number;
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
12
|
+
export declare class CodemirrorCompletionContext {
|
|
13
13
|
readonly state: EditorState;
|
|
14
14
|
readonly pos: number;
|
|
15
15
|
readonly explicit: boolean;
|
|
@@ -32,7 +32,7 @@ export declare class CompletionContext {
|
|
|
32
32
|
export declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource;
|
|
33
33
|
export declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
|
34
34
|
export declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
|
35
|
-
export type CompletionSource = (context:
|
|
35
|
+
export type CompletionSource = (context: CodemirrorCompletionContext) => CompletionResult | null | Promise<CompletionResult | null>;
|
|
36
36
|
export interface CompletionResult {
|
|
37
37
|
from: number;
|
|
38
38
|
to?: number;
|
|
@@ -40,7 +40,7 @@ export interface CompletionResult {
|
|
|
40
40
|
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean);
|
|
41
41
|
filter?: boolean;
|
|
42
42
|
getMatch?: (completion: Completion) => readonly number[];
|
|
43
|
-
update?: (current: CompletionResult, from: number, to: number, context:
|
|
43
|
+
update?: (current: CompletionResult, from: number, to: number, context: CodemirrorCompletionContext) => CompletionResult | null;
|
|
44
44
|
}
|
|
45
45
|
export declare class Option {
|
|
46
46
|
readonly completion: Completion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/auto-complete/completion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,WAAW,UAAU;IAIzB,KAAK,EAAE,MAAM,CAAC;IAGd,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,GA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I,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,2BAA2B,KACjC,gBAAgB,GAAG,IAAI,CAAC;CAC9B;AAED,qBAAa,MAAM;IAEf,QAAQ,CAAC,UAAU,EAAE,UAAU;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE;gBAFxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,SAAS,MAAM,EAAE;CAEpC;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,WAAW,UAErC;AAID,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,UAWxD;AAID,eAAO,MAAM,gBAAgB,wDAAkC,CAAC;AAKhE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,eAAe,CAwBjB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,QAQ/D;AAID,wBAAgB,QAAQ,CACtB,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,GAC1D,gBAAgB,CASlB"}
|
|
@@ -22,11 +22,11 @@ import { Annotation, EditorSelection } from '@codemirror/state';
|
|
|
22
22
|
/// Objects type used to represent individual completions.
|
|
23
23
|
|
|
24
24
|
/// An instance of this is passed to completion source functions.
|
|
25
|
-
export var
|
|
25
|
+
export var CodemirrorCompletionContext = /*#__PURE__*/function () {
|
|
26
26
|
/// Create a new completion context. (Mostly useful for testing
|
|
27
27
|
/// completion sources—in the editor, the extension will create
|
|
28
28
|
/// these for you.)
|
|
29
|
-
function
|
|
29
|
+
function CodemirrorCompletionContext(
|
|
30
30
|
/// The editor state that the completion happens in.
|
|
31
31
|
state,
|
|
32
32
|
/// The position at which the completion is happening.
|
|
@@ -36,7 +36,7 @@ export var CompletionContext = /*#__PURE__*/function () {
|
|
|
36
36
|
/// only return completions when either there is part of a
|
|
37
37
|
/// completable entity before the cursor, or `explicit` is true.
|
|
38
38
|
explicit) {
|
|
39
|
-
_classCallCheck(this,
|
|
39
|
+
_classCallCheck(this, CodemirrorCompletionContext);
|
|
40
40
|
this.state = state;
|
|
41
41
|
this.pos = pos;
|
|
42
42
|
this.explicit = explicit;
|
|
@@ -46,7 +46,7 @@ export var CompletionContext = /*#__PURE__*/function () {
|
|
|
46
46
|
|
|
47
47
|
/// Get the extent, content, and (if there is a token) type of the
|
|
48
48
|
/// token before `this.pos`.
|
|
49
|
-
_createClass(
|
|
49
|
+
_createClass(CodemirrorCompletionContext, [{
|
|
50
50
|
key: "tokenBefore",
|
|
51
51
|
value: function tokenBefore(types) {
|
|
52
52
|
var token = syntaxTree(this.state).resolveInner(this.pos, -1);
|
|
@@ -87,7 +87,7 @@ export var CompletionContext = /*#__PURE__*/function () {
|
|
|
87
87
|
|
|
88
88
|
/// Allows you to register abort handlers, which will be called when
|
|
89
89
|
/// the query is
|
|
90
|
-
/// [aborted](#autocomplete.
|
|
90
|
+
/// [aborted](#autocomplete.CodemirrorCompletionContext.aborted).
|
|
91
91
|
}, {
|
|
92
92
|
key: "addEventListener",
|
|
93
93
|
value: function addEventListener(type, listener) {
|
|
@@ -96,7 +96,7 @@ export var CompletionContext = /*#__PURE__*/function () {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}]);
|
|
99
|
-
return
|
|
99
|
+
return CodemirrorCompletionContext;
|
|
100
100
|
}();
|
|
101
101
|
function toSet(chars) {
|
|
102
102
|
var flat = Object.keys(chars).join('');
|
|
@@ -21,7 +21,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
21
21
|
|
|
22
22
|
import { StateField, StateEffect } from '@codemirror/state';
|
|
23
23
|
import { EditorView, showTooltip } from '@codemirror/view';
|
|
24
|
-
import { Option, cur, asSource, ensureAnchor,
|
|
24
|
+
import { Option, cur, asSource, ensureAnchor, CodemirrorCompletionContext } from "./completion.js";
|
|
25
25
|
import { completionConfig } from "./config.js";
|
|
26
26
|
import { FuzzyMatcher } from "./filter.js";
|
|
27
27
|
import { completionTooltip } from "./tooltip.js";
|
|
@@ -395,7 +395,7 @@ export var ActiveResult = /*#__PURE__*/function (_ActiveSource) {
|
|
|
395
395
|
if (checkValid(this.result.validFor, tr.state, from, to)) {
|
|
396
396
|
return new ActiveResult(this.source, explicitPos, this.result, from, to);
|
|
397
397
|
}
|
|
398
|
-
if (this.result.update && (updated = this.result.update(this.result, from, to, new
|
|
398
|
+
if (this.result.update && (updated = this.result.update(this.result, from, to, new CodemirrorCompletionContext(tr.state, pos, explicitPos >= 0)))) {
|
|
399
399
|
var _updated$to;
|
|
400
400
|
return new ActiveResult(this.source, explicitPos, updated, updated.from, (_updated$to = updated.to) !== null && _updated$to !== void 0 ? _updated$to : cur(tr.state));
|
|
401
401
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorView } from '@codemirror/view';
|
|
2
|
-
import { l10n } from '@difizen/
|
|
2
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
3
3
|
export var Info = /*#__PURE__*/function (Info) {
|
|
4
4
|
Info[Info["Margin"] = 30] = "Margin";
|
|
5
5
|
Info[Info["Width"] = 400] = "Width";
|
|
@@ -10,7 +10,7 @@ import type { Transaction } from '@codemirror/state';
|
|
|
10
10
|
import type { EditorView, Command, ViewUpdate } from '@codemirror/view';
|
|
11
11
|
import { ViewPlugin } from '@codemirror/view';
|
|
12
12
|
import type { CompletionResult } from './completion.js';
|
|
13
|
-
import {
|
|
13
|
+
import { CodemirrorCompletionContext } from './completion.js';
|
|
14
14
|
import { ActiveSource } from './state.js';
|
|
15
15
|
export declare function moveCompletionSelection(forward: boolean, by?: 'option' | 'page'): Command;
|
|
16
16
|
export declare const acceptCompletion: Command;
|
|
@@ -18,11 +18,11 @@ export declare const startCompletion: Command;
|
|
|
18
18
|
export declare const closeCompletion: Command;
|
|
19
19
|
declare class RunningQuery {
|
|
20
20
|
readonly active: ActiveSource;
|
|
21
|
-
readonly context:
|
|
21
|
+
readonly context: CodemirrorCompletionContext;
|
|
22
22
|
time: number;
|
|
23
23
|
updates: Transaction[];
|
|
24
24
|
done: undefined | CompletionResult | null;
|
|
25
|
-
constructor(active: ActiveSource, context:
|
|
25
|
+
constructor(active: ActiveSource, context: CodemirrorCompletionContext);
|
|
26
26
|
}
|
|
27
27
|
declare const enum CompositionState {
|
|
28
28
|
None = 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/auto-complete/view.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EAEP,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAO,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/auto-complete/view.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EAEP,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAO,2BAA2B,EAAmB,MAAM,iBAAiB,CAAC;AAEpF,OAAO,EAOL,YAAY,EAGb,MAAM,YAAY,CAAC;AAIpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,EAAE,GAAE,QAAQ,GAAG,MAAiB,GAC/B,OAAO,CAqCT;AAGD,eAAO,MAAM,gBAAgB,EAAE,OAc9B,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,OAO7B,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,OAO7B,CAAC;AAEF,cAAM,YAAY;IAQd,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,OAAO,EAAE,2BAA2B;IAR/C,IAAI,SAAc;IAClB,OAAO,EAAE,WAAW,EAAE,CAAM;IAG5B,IAAI,EAAE,SAAS,GAAG,gBAAgB,GAAG,IAAI,CAAa;gBAG3C,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,2BAA2B;CAEhD;AAMD,mBAAW,gBAAgB;IACzB,IAAI,IAAA;IACJ,OAAO,IAAA;IACP,OAAO,IAAA;IACP,eAAe,IAAA;CAChB;AAED,eAAO,MAAM,gBAAgB;oBAET,OAAO,OAAO,GAAG,CAAC,CAAC;aAC1B,YAAY,EAAE;oBACP,OAAO,OAAO,GAAG,CAAC,CAAC;;mBAGR,UAAU;mBAQtB,UAAU;;uBAsEN,YAAY;;;EA+HlC,CAAC"}
|
package/es/auto-complete/view.js
CHANGED
|
@@ -12,7 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
14
|
import { ViewPlugin, logException, getTooltip } from '@codemirror/view';
|
|
15
|
-
import { cur,
|
|
15
|
+
import { cur, CodemirrorCompletionContext, applyCompletion } from "./completion.js";
|
|
16
16
|
import { completionConfig } from "./config.js";
|
|
17
17
|
import { completionState, setSelectedEffect, startCompletionEffect, closeCompletionEffect, setActiveEffect, State, ActiveSource, ActiveResult, getUserEvent } from "./state.js";
|
|
18
18
|
|
|
@@ -221,7 +221,7 @@ export var completionPlugin = ViewPlugin.fromClass( /*#__PURE__*/function () {
|
|
|
221
221
|
var _this3 = this;
|
|
222
222
|
var state = this.view.state,
|
|
223
223
|
pos = cur(state);
|
|
224
|
-
var context = new
|
|
224
|
+
var context = new CodemirrorCompletionContext(state, pos, active.explicitPos === pos);
|
|
225
225
|
var pending = new RunningQuery(active, context);
|
|
226
226
|
this.running.push(pending);
|
|
227
227
|
Promise.resolve(active.source(context)).then(function (result) {
|
package/es/config.js
CHANGED
|
@@ -40,7 +40,7 @@ import { FoldIcon, UnFoldIcon } from "./libro-icon.js";
|
|
|
40
40
|
import { lspPythonCompletion } from "./lsp/completion.js";
|
|
41
41
|
import { formatKeymap } from "./lsp/format.js";
|
|
42
42
|
import { lspLint, lspTooltip } from "./lsp/index.js";
|
|
43
|
-
import {
|
|
43
|
+
import { codemirrorEnsure } from "./mode.js";
|
|
44
44
|
import { getTheme, defaultTheme } from "./theme.js";
|
|
45
45
|
import { tabTooltip, tooltipKeymap } from "./tooltip.js";
|
|
46
46
|
|
|
@@ -421,7 +421,7 @@ export var EditorConfiguration = /*#__PURE__*/function () {
|
|
|
421
421
|
var insertExt = indentBuilder.of(config.insertSpaces ? ' '.repeat(config.tabSize) : '\t');
|
|
422
422
|
var themeOverload = this.updateThemeOverload(config);
|
|
423
423
|
extensions.push(this._themeOverloader.of(themeOverload), insertExt, keymapExt);
|
|
424
|
-
|
|
424
|
+
codemirrorEnsure((_config$mimetype = config === null || config === void 0 ? void 0 : config.mimetype) !== null && _config$mimetype !== void 0 ? _config$mimetype : 'text/x-python').then(function (spec) {
|
|
425
425
|
if (spec) {
|
|
426
426
|
var _this4$get;
|
|
427
427
|
extensions.push((_this4$get = _this4.get('language')) === null || _this4$get === void 0 ? void 0 : _this4$get.of(spec.support));
|
|
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
import { CodeEditorContribution } from '@difizen/libro-code-editor';
|
|
9
9
|
import { MIME } from '@difizen/libro-common';
|
|
10
|
-
import { singleton } from '@difizen/
|
|
10
|
+
import { singleton } from '@difizen/libro-common/app';
|
|
11
11
|
import { codeMirrorDefaultConfig } from "./editor.js";
|
|
12
12
|
import { codeMirrorEditorFactory, stateFactory } from "./factory.js";
|
|
13
13
|
export var CodeMirrorEditorContribution = (_dec = singleton({
|
package/es/editor.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Command, DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
|
4
4
|
import { Decoration, EditorView } from '@codemirror/view';
|
|
5
5
|
import type { EditorState as LibroEditorState, ICoordinate, IEditor, IEditorConfig, IEditorOptions, IEditorSelectionStyle, IModel, IPosition, IRange, ITextSelection, IToken, KeydownHandler, SearchMatch } from '@difizen/libro-code-editor';
|
|
6
6
|
import type { LSPProvider } from '@difizen/libro-lsp';
|
|
7
|
-
import { Deferred, Disposable, Emitter } from '@difizen/
|
|
7
|
+
import { Deferred, Disposable, Emitter } from '@difizen/libro-common/app';
|
|
8
8
|
import type { CodeMirrorConfig } from './config.js';
|
|
9
9
|
import { EditorConfiguration } from './config.js';
|
|
10
10
|
/**
|
|
@@ -38,7 +38,7 @@ export declare class CodeMirrorEditor implements IEditor {
|
|
|
38
38
|
* A signal emitted when either the top or bottom edge is requested.
|
|
39
39
|
*/
|
|
40
40
|
readonly edgeRequestedEmitter: Emitter<any>;
|
|
41
|
-
readonly edgeRequested: import("@difizen/
|
|
41
|
+
readonly edgeRequested: import("@difizen/libro-common/app").Event<any>;
|
|
42
42
|
/**
|
|
43
43
|
* The DOM node that hosts the editor.
|
|
44
44
|
*/
|
|
@@ -49,7 +49,7 @@ export declare class CodeMirrorEditor implements IEditor {
|
|
|
49
49
|
get uuid(): string;
|
|
50
50
|
set uuid(value: string);
|
|
51
51
|
protected modalChangeEmitter: Emitter<boolean>;
|
|
52
|
-
get onModalChange(): import("@difizen/
|
|
52
|
+
get onModalChange(): import("@difizen/libro-common/app").Event<boolean>;
|
|
53
53
|
/**
|
|
54
54
|
* The selection style of this editor.
|
|
55
55
|
*/
|
package/es/editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,YAAY,EACZ,eAAe,EACf,IAAI,EACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,WAAW,EAGX,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EACV,WAAW,IAAI,gBAAgB,EAC/B,WAAW,EACX,OAAO,EACP,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,MAAM,EACN,SAAS,EACT,MAAM,EACN,cAAc,EACd,MAAM,EACN,cAAc,EACd,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAMpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mapp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,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AACD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;CAClC"}
|
package/es/editor.js
CHANGED
|
@@ -20,12 +20,12 @@ import { EditorSelection, EditorState, Prec, StateEffect, StateField } from '@co
|
|
|
20
20
|
import { Decoration, EditorView } from '@codemirror/view';
|
|
21
21
|
import { defaultConfig, defaultSelectionStyle } from '@difizen/libro-code-editor';
|
|
22
22
|
import { findFirstArrayIndex, MIME, removeAllWhereFromArray } from '@difizen/libro-common';
|
|
23
|
-
import { Deferred, Disposable, Emitter } from '@difizen/
|
|
24
|
-
import { getOrigin, watch } from '@difizen/
|
|
23
|
+
import { Deferred, Disposable, Emitter } from '@difizen/libro-common/app';
|
|
24
|
+
import { getOrigin, watch } from '@difizen/libro-common/app';
|
|
25
25
|
import { v4 } from 'uuid';
|
|
26
26
|
import { EditorConfiguration } from "./config.js";
|
|
27
27
|
import { stateFactory } from "./factory.js";
|
|
28
|
-
import {
|
|
28
|
+
import { codemirrorEnsure } from "./mode.js";
|
|
29
29
|
import { monitorPlugin } from "./monitor.js";
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -1003,7 +1003,7 @@ export var CodeMirrorEditor = /*#__PURE__*/function () {
|
|
|
1003
1003
|
var _this7 = this;
|
|
1004
1004
|
var mime = this._model.mimeType;
|
|
1005
1005
|
// TODO: should we provide a hook for when the mode is done being set?
|
|
1006
|
-
void
|
|
1006
|
+
void codemirrorEnsure(mime).then(function (spec) {
|
|
1007
1007
|
if (spec) {
|
|
1008
1008
|
_this7._editorConfig.reconfigureExtension(_this7._editor, 'language', spec.support);
|
|
1009
1009
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lsp/completion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lsp/completion.ts"],"names":[],"mappings":"AAIA,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"}
|
package/es/lsp/completion.js
CHANGED
|
@@ -12,9 +12,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
12
12
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
import { pythonLanguage } from '@codemirror/lang-python';
|
|
15
|
-
import {
|
|
15
|
+
import { LspCompletionTriggerKind } from '@difizen/libro-lsp';
|
|
16
|
+
import { LspCompletionItemKind } from '@difizen/libro-lsp';
|
|
16
17
|
import { offsetToPos, renderMarkupContent } from "./util.js";
|
|
17
|
-
var CompletionItemKindMap = Object.fromEntries(Object.entries(
|
|
18
|
+
var CompletionItemKindMap = Object.fromEntries(Object.entries(LspCompletionItemKind).map(function (_ref) {
|
|
18
19
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
19
20
|
key = _ref2[0],
|
|
20
21
|
value = _ref2[1];
|
|
@@ -116,7 +117,7 @@ export var lspPythonCompletion = function lspPythonCompletion(_ref5) {
|
|
|
116
117
|
uri: doc.documentInfo.uri
|
|
117
118
|
},
|
|
118
119
|
context: {
|
|
119
|
-
triggerKind:
|
|
120
|
+
triggerKind: LspCompletionTriggerKind.Invoked
|
|
120
121
|
}
|
|
121
122
|
});
|
|
122
123
|
case 19:
|
package/es/lsp/lint.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/lsp/lint.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/lsp/lint.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC;AA2GzE,eAAO,MAAM,OAAO,EAAE,cAErB,CAAC"}
|
package/es/lsp/lint.js
CHANGED
|
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
import { setDiagnostics } from '@codemirror/lint';
|
|
9
9
|
import { ViewPlugin } from '@codemirror/view';
|
|
10
|
-
import {
|
|
10
|
+
import { LspDiagnosticSeverity } from '@difizen/libro-lsp';
|
|
11
11
|
import { posToOffset } from "./util.js";
|
|
12
12
|
var LintPlugin = /*#__PURE__*/function () {
|
|
13
13
|
function LintPlugin(view, options) {
|
|
@@ -35,7 +35,7 @@ var LintPlugin = /*#__PURE__*/function () {
|
|
|
35
35
|
var range = _ref2.range,
|
|
36
36
|
message = _ref2.message,
|
|
37
37
|
_ref2$severity = _ref2.severity,
|
|
38
|
-
severity = _ref2$severity === void 0 ?
|
|
38
|
+
severity = _ref2$severity === void 0 ? LspDiagnosticSeverity.Information : _ref2$severity;
|
|
39
39
|
var currentEditor = virtualDocument.getEditorAtVirtualLine({
|
|
40
40
|
line: range.start.line,
|
|
41
41
|
ch: range.start.character,
|
|
@@ -73,7 +73,7 @@ var LintPlugin = /*#__PURE__*/function () {
|
|
|
73
73
|
return {
|
|
74
74
|
from: offset,
|
|
75
75
|
to: end,
|
|
76
|
-
severity: _defineProperty(_defineProperty(_defineProperty(_defineProperty({},
|
|
76
|
+
severity: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, LspDiagnosticSeverity.Error, 'error'), LspDiagnosticSeverity.Warning, 'warning'), LspDiagnosticSeverity.Information, 'info'), LspDiagnosticSeverity.Hint, 'info')[severity],
|
|
77
77
|
message: message
|
|
78
78
|
};
|
|
79
79
|
}).filter(isDiagnostic).sort(function (a, b) {
|
package/es/mode.d.ts
CHANGED
|
@@ -61,12 +61,12 @@ export declare function findBest(mode: string | ISpec, fallback?: boolean): ISpe
|
|
|
61
61
|
/**
|
|
62
62
|
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
63
63
|
*
|
|
64
|
-
* @param mode - The mode to
|
|
64
|
+
* @param mode - The mode to codemirrorEnsure. If it is a string, uses [findBest]
|
|
65
65
|
* to get the appropriate spec.
|
|
66
66
|
*
|
|
67
67
|
* @returns A promise that resolves when the mode is available.
|
|
68
68
|
*/
|
|
69
|
-
export declare function
|
|
69
|
+
export declare function codemirrorEnsure(mode: string | ISpec): Promise<ISpec | null>;
|
|
70
70
|
/**
|
|
71
71
|
* Register a new mode for CodeMirror
|
|
72
72
|
*
|
package/es/mode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mode.d.ts","sourceRoot":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K,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAyBpE"}
|
package/es/mode.js
CHANGED
|
@@ -195,13 +195,13 @@ export function findBest(mode) {
|
|
|
195
195
|
/**
|
|
196
196
|
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
197
197
|
*
|
|
198
|
-
* @param mode - The mode to
|
|
198
|
+
* @param mode - The mode to codemirrorEnsure. If it is a string, uses [findBest]
|
|
199
199
|
* to get the appropriate spec.
|
|
200
200
|
*
|
|
201
201
|
* @returns A promise that resolves when the mode is available.
|
|
202
202
|
*/
|
|
203
|
-
export function
|
|
204
|
-
return
|
|
203
|
+
export function codemirrorEnsure(_x) {
|
|
204
|
+
return _codemirrorEnsure.apply(this, arguments);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
@@ -210,8 +210,8 @@ export function ensure(_x) {
|
|
|
210
210
|
* @alpha
|
|
211
211
|
* @param mode Mode to register
|
|
212
212
|
*/
|
|
213
|
-
function
|
|
214
|
-
|
|
213
|
+
function _codemirrorEnsure() {
|
|
214
|
+
_codemirrorEnsure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(mode) {
|
|
215
215
|
var spec;
|
|
216
216
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
217
217
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -234,7 +234,7 @@ function _ensure() {
|
|
|
234
234
|
}
|
|
235
235
|
}, _callee2);
|
|
236
236
|
}));
|
|
237
|
-
return
|
|
237
|
+
return _codemirrorEnsure.apply(this, arguments);
|
|
238
238
|
}
|
|
239
239
|
export function registerModeInfo(mode) {
|
|
240
240
|
var info = findBest(mode, false);
|
package/es/module.d.ts
CHANGED
package/es/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,eAAO,MAAM,sBAAsB,YAEN,CAAC"}
|
package/es/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CodeEditorModule } from '@difizen/libro-code-editor';
|
|
2
|
-
import { ManaModule } from '@difizen/
|
|
2
|
+
import { ManaModule } from '@difizen/libro-common/app';
|
|
3
3
|
import { CodeMirrorEditorContribution } from "./editor-contribution.js";
|
|
4
4
|
export var CodeMirrorEditorModule = ManaModule.create().register(CodeMirrorEditorContribution).dependOn(CodeEditorModule);
|
package/es/monitor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Emitter } from '@difizen/
|
|
1
|
+
import { Emitter } from '@difizen/libro-common/app';
|
|
2
2
|
interface DocStatus {
|
|
3
3
|
source: string[];
|
|
4
4
|
cursor: number;
|
|
@@ -14,9 +14,9 @@ export declare class CompletionMonitor {
|
|
|
14
14
|
protected static instance: CompletionMonitor;
|
|
15
15
|
static getInstance(): CompletionMonitor;
|
|
16
16
|
protected completionChangeEmitter: Emitter<CompletionChange>;
|
|
17
|
-
get compeltionChange(): import("@difizen/
|
|
17
|
+
get compeltionChange(): import("@difizen/libro-common/app").Event<CompletionChange>;
|
|
18
18
|
protected tooltipChangeEmitter: Emitter<boolean>;
|
|
19
|
-
get onTooltipChange(): import("@difizen/
|
|
19
|
+
get onTooltipChange(): import("@difizen/libro-common/app").Event<boolean>;
|
|
20
20
|
protected currentChange: CompletionChange | undefined;
|
|
21
21
|
start(doc: DocStatus): void;
|
|
22
22
|
accept(doc: DocStatus): void;
|
package/es/monitor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAQpD,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,iBAAiB;IAC5B,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAE7C,MAAM,CAAC,WAAW;IAOlB,SAAS,CAAC,uBAAuB,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAiB;IAE7E,IAAI,gBAAgB,gEAEnB;IAED,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAiB;IAEjE,IAAI,eAAe,uDAElB;IAED,SAAS,CAAC,aAAa,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAEtD,KAAK,CAAC,GAAG,EAAE,SAAS;IAIpB,MAAM,CAAC,GAAG,EAAE,SAAS;IAKrB,KAAK,CAAC,GAAG,EAAE,SAAS;IAKpB,WAAW,CAAC,KAAK,EAAE,MAAM;IAIzB,UAAU,CAAC,MAAM,EAAE,gBAAgB;CAGpC;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,aAAa,YAAa,oBAAoB,0CA+BvD,CAAC"}
|
package/es/monitor.js
CHANGED
|
@@ -11,7 +11,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
11
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
import { EditorView, hasHoverTooltips } from '@codemirror/view';
|
|
14
|
-
import { Emitter } from '@difizen/
|
|
14
|
+
import { Emitter } from '@difizen/libro-common/app';
|
|
15
15
|
import { closeCompletionEffect, setSelectedEffect, startCompletionEffect } from "./auto-complete/state.js";
|
|
16
16
|
export var CompletionMonitor = /*#__PURE__*/function () {
|
|
17
17
|
function CompletionMonitor() {
|
package/es/style/variables.css
CHANGED
|
@@ -50,31 +50,40 @@ all of MD as it is not optimized for dense, information rich UIs.
|
|
|
50
50
|
12%
|
|
51
51
|
);
|
|
52
52
|
--jp-elevation-z0: none;
|
|
53
|
-
--jp-elevation-z1:
|
|
53
|
+
--jp-elevation-z1:
|
|
54
|
+
0 2px 1px -1px var(--jp-shadow-umbra-color),
|
|
54
55
|
0 1px 1px 0 var(--jp-shadow-penumbra-color),
|
|
55
56
|
0 1px 3px 0 var(--jp-shadow-ambient-color);
|
|
56
|
-
--jp-elevation-z2:
|
|
57
|
+
--jp-elevation-z2:
|
|
58
|
+
0 3px 1px -2px var(--jp-shadow-umbra-color),
|
|
57
59
|
0 2px 2px 0 var(--jp-shadow-penumbra-color),
|
|
58
60
|
0 1px 5px 0 var(--jp-shadow-ambient-color);
|
|
59
|
-
--jp-elevation-z4:
|
|
61
|
+
--jp-elevation-z4:
|
|
62
|
+
0 2px 4px -1px var(--jp-shadow-umbra-color),
|
|
60
63
|
0 4px 5px 0 var(--jp-shadow-penumbra-color),
|
|
61
64
|
0 1px 10px 0 var(--jp-shadow-ambient-color);
|
|
62
|
-
--jp-elevation-z6:
|
|
65
|
+
--jp-elevation-z6:
|
|
66
|
+
0 3px 5px -1px var(--jp-shadow-umbra-color),
|
|
63
67
|
0 6px 10px 0 var(--jp-shadow-penumbra-color),
|
|
64
68
|
0 1px 18px 0 var(--jp-shadow-ambient-color);
|
|
65
|
-
--jp-elevation-z8:
|
|
69
|
+
--jp-elevation-z8:
|
|
70
|
+
0 5px 5px -3px var(--jp-shadow-umbra-color),
|
|
66
71
|
0 8px 10px 1px var(--jp-shadow-penumbra-color),
|
|
67
72
|
0 3px 14px 2px var(--jp-shadow-ambient-color);
|
|
68
|
-
--jp-elevation-z12:
|
|
73
|
+
--jp-elevation-z12:
|
|
74
|
+
0 7px 8px -4px var(--jp-shadow-umbra-color),
|
|
69
75
|
0 12px 17px 2px var(--jp-shadow-penumbra-color),
|
|
70
76
|
0 5px 22px 4px var(--jp-shadow-ambient-color);
|
|
71
|
-
--jp-elevation-z16:
|
|
77
|
+
--jp-elevation-z16:
|
|
78
|
+
0 8px 10px -5px var(--jp-shadow-umbra-color),
|
|
72
79
|
0 16px 24px 2px var(--jp-shadow-penumbra-color),
|
|
73
80
|
0 6px 30px 5px var(--jp-shadow-ambient-color);
|
|
74
|
-
--jp-elevation-z20:
|
|
81
|
+
--jp-elevation-z20:
|
|
82
|
+
0 10px 13px -6px var(--jp-shadow-umbra-color),
|
|
75
83
|
0 20px 31px 3px var(--jp-shadow-penumbra-color),
|
|
76
84
|
0 8px 38px 7px var(--jp-shadow-ambient-color);
|
|
77
|
-
--jp-elevation-z24:
|
|
85
|
+
--jp-elevation-z24:
|
|
86
|
+
0 11px 15px -7px var(--jp-shadow-umbra-color),
|
|
78
87
|
0 24px 38px 3px var(--jp-shadow-penumbra-color),
|
|
79
88
|
0 9px 46px 8px var(--jp-shadow-ambient-color);
|
|
80
89
|
|
|
@@ -106,9 +115,9 @@ all of MD as it is not optimized for dense, information rich UIs.
|
|
|
106
115
|
--jp-ui-font-size1: 13px; /* Base font size */
|
|
107
116
|
--jp-ui-font-size2: 1.2em;
|
|
108
117
|
--jp-ui-font-size3: 1.44em;
|
|
109
|
-
--jp-ui-font-family:
|
|
110
|
-
|
|
111
|
-
'Segoe UI Symbol';
|
|
118
|
+
--jp-ui-font-family:
|
|
119
|
+
system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', helvetica, arial,
|
|
120
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
112
121
|
|
|
113
122
|
/*
|
|
114
123
|
* Use these font colors against the corresponding main layout colors.
|
|
@@ -162,9 +171,9 @@ all of MD as it is not optimized for dense, information rich UIs.
|
|
|
162
171
|
--jp-content-font-color2: rgba(0, 0, 0, 54%);
|
|
163
172
|
--jp-content-font-color3: rgba(0, 0, 0, 38%);
|
|
164
173
|
--jp-content-link-color: var(--md-blue-700);
|
|
165
|
-
--jp-content-font-family:
|
|
166
|
-
|
|
167
|
-
'Segoe UI Symbol';
|
|
174
|
+
--jp-content-font-family:
|
|
175
|
+
system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', helvetica, arial,
|
|
176
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
168
177
|
|
|
169
178
|
/*
|
|
170
179
|
* Code Fonts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-codemirror",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -41,12 +41,10 @@
|
|
|
41
41
|
"@codemirror/search": "^6.0.0",
|
|
42
42
|
"@codemirror/state": "^6.4.0",
|
|
43
43
|
"@codemirror/view": "^6.23.0",
|
|
44
|
-
"@difizen/libro-code-editor": "^0.
|
|
45
|
-
"@difizen/libro-common": "^0.
|
|
46
|
-
"@difizen/libro-lsp": "^0.
|
|
47
|
-
"@difizen/libro-rendermime": "^0.
|
|
48
|
-
"@difizen/mana-l10n": "latest",
|
|
49
|
-
"@difizen/mana-app": "latest",
|
|
44
|
+
"@difizen/libro-code-editor": "^1.0.1",
|
|
45
|
+
"@difizen/libro-common": "^1.0.1",
|
|
46
|
+
"@difizen/libro-lsp": "^1.0.1",
|
|
47
|
+
"@difizen/libro-rendermime": "^1.0.1",
|
|
50
48
|
"@lezer/common": "^1.2.1",
|
|
51
49
|
"@lezer/highlight": "^1.1.4",
|
|
52
50
|
"highlight.js": "^11.9.0",
|
|
@@ -49,7 +49,7 @@ export interface Completion {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/// An instance of this is passed to completion source functions.
|
|
52
|
-
export class
|
|
52
|
+
export class CodemirrorCompletionContext {
|
|
53
53
|
/// @internal
|
|
54
54
|
abortListeners: (() => void)[] | null = [];
|
|
55
55
|
|
|
@@ -105,7 +105,7 @@ export class CompletionContext {
|
|
|
105
105
|
|
|
106
106
|
/// Allows you to register abort handlers, which will be called when
|
|
107
107
|
/// the query is
|
|
108
|
-
/// [aborted](#autocomplete.
|
|
108
|
+
/// [aborted](#autocomplete.CodemirrorCompletionContext.aborted).
|
|
109
109
|
addEventListener(type: 'abort', listener: () => void) {
|
|
110
110
|
if (type === 'abort' && this.abortListeners) {
|
|
111
111
|
this.abortListeners.push(listener);
|
|
@@ -144,7 +144,7 @@ export function completeFromList(
|
|
|
144
144
|
const [validFor, match] = options.every((o) => /^\w+$/.test(o.label))
|
|
145
145
|
? [/\w*$/, /\w+$/]
|
|
146
146
|
: prefixMatch(options);
|
|
147
|
-
return (context:
|
|
147
|
+
return (context: CodemirrorCompletionContext) => {
|
|
148
148
|
const token = context.matchBefore(match);
|
|
149
149
|
return token || context.explicit
|
|
150
150
|
? { from: token ? token.from : context.pos, options, validFor }
|
|
@@ -158,7 +158,7 @@ export function ifIn(
|
|
|
158
158
|
nodes: readonly string[],
|
|
159
159
|
source: CompletionSource,
|
|
160
160
|
): CompletionSource {
|
|
161
|
-
return (context:
|
|
161
|
+
return (context: CodemirrorCompletionContext) => {
|
|
162
162
|
for (
|
|
163
163
|
let pos: SyntaxNode | null = syntaxTree(context.state).resolveInner(
|
|
164
164
|
context.pos,
|
|
@@ -181,7 +181,7 @@ export function ifNotIn(
|
|
|
181
181
|
nodes: readonly string[],
|
|
182
182
|
source: CompletionSource,
|
|
183
183
|
): CompletionSource {
|
|
184
|
-
return (context:
|
|
184
|
+
return (context: CodemirrorCompletionContext) => {
|
|
185
185
|
for (
|
|
186
186
|
let pos: SyntaxNode | null = syntaxTree(context.state).resolveInner(
|
|
187
187
|
context.pos,
|
|
@@ -203,7 +203,7 @@ export function ifNotIn(
|
|
|
203
203
|
/// synchronously or as a promise. Returning null indicates no
|
|
204
204
|
/// completions are available.
|
|
205
205
|
export type CompletionSource = (
|
|
206
|
-
context:
|
|
206
|
+
context: CodemirrorCompletionContext,
|
|
207
207
|
) => CompletionResult | null | Promise<CompletionResult | null>;
|
|
208
208
|
|
|
209
209
|
/// Interface for objects returned by completion sources.
|
|
@@ -250,7 +250,7 @@ export interface CompletionResult {
|
|
|
250
250
|
current: CompletionResult,
|
|
251
251
|
from: number,
|
|
252
252
|
to: number,
|
|
253
|
-
context:
|
|
253
|
+
context: CodemirrorCompletionContext,
|
|
254
254
|
) => CompletionResult | null;
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
cur,
|
|
11
11
|
asSource,
|
|
12
12
|
ensureAnchor,
|
|
13
|
-
|
|
13
|
+
CodemirrorCompletionContext,
|
|
14
14
|
} from './completion.js';
|
|
15
15
|
import type { CompletionConfig } from './config.js';
|
|
16
16
|
import { completionConfig } from './config.js';
|
|
@@ -389,7 +389,7 @@ export class ActiveResult extends ActiveSource {
|
|
|
389
389
|
this.result,
|
|
390
390
|
from,
|
|
391
391
|
to,
|
|
392
|
-
new
|
|
392
|
+
new CodemirrorCompletionContext(tr.state, pos, explicitPos >= 0),
|
|
393
393
|
))
|
|
394
394
|
) {
|
|
395
395
|
return new ActiveResult(
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
import { ViewPlugin, logException, getTooltip } from '@codemirror/view';
|
|
10
10
|
|
|
11
11
|
import type { CompletionResult } from './completion.js';
|
|
12
|
-
import { cur,
|
|
12
|
+
import { cur, CodemirrorCompletionContext, applyCompletion } from './completion.js';
|
|
13
13
|
import { completionConfig } from './config.js';
|
|
14
14
|
import {
|
|
15
15
|
completionState,
|
|
@@ -113,7 +113,7 @@ class RunningQuery {
|
|
|
113
113
|
|
|
114
114
|
constructor(
|
|
115
115
|
readonly active: ActiveSource,
|
|
116
|
-
readonly context:
|
|
116
|
+
readonly context: CodemirrorCompletionContext,
|
|
117
117
|
) {}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -216,7 +216,11 @@ export const completionPlugin = ViewPlugin.fromClass(
|
|
|
216
216
|
startQuery(active: ActiveSource) {
|
|
217
217
|
const { state } = this.view,
|
|
218
218
|
pos = cur(state);
|
|
219
|
-
const context = new
|
|
219
|
+
const context = new CodemirrorCompletionContext(
|
|
220
|
+
state,
|
|
221
|
+
pos,
|
|
222
|
+
active.explicitPos === pos,
|
|
223
|
+
);
|
|
220
224
|
const pending = new RunningQuery(active, context);
|
|
221
225
|
this.running.push(pending);
|
|
222
226
|
Promise.resolve(active.source(context))
|
package/src/config.ts
CHANGED
|
@@ -44,7 +44,7 @@ import { FoldIcon, UnFoldIcon } from './libro-icon.js';
|
|
|
44
44
|
import { lspPythonCompletion } from './lsp/completion.js';
|
|
45
45
|
import { formatKeymap } from './lsp/format.js';
|
|
46
46
|
import { lspLint, lspTooltip } from './lsp/index.js';
|
|
47
|
-
import {
|
|
47
|
+
import { codemirrorEnsure } from './mode.js';
|
|
48
48
|
import { getTheme, defaultTheme } from './theme.js';
|
|
49
49
|
import { tabTooltip, tooltipKeymap } from './tooltip.js';
|
|
50
50
|
|
|
@@ -632,7 +632,7 @@ export class EditorConfiguration {
|
|
|
632
632
|
const themeOverload = this.updateThemeOverload(config);
|
|
633
633
|
extensions.push(this._themeOverloader.of(themeOverload), insertExt, keymapExt);
|
|
634
634
|
|
|
635
|
-
|
|
635
|
+
codemirrorEnsure(config?.mimetype ?? 'text/x-python')
|
|
636
636
|
.then((spec) => {
|
|
637
637
|
if (spec) {
|
|
638
638
|
extensions.push(this.get('language')?.of(spec.support!));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CodeEditorFactory } from '@difizen/libro-code-editor';
|
|
2
2
|
import { CodeEditorContribution } from '@difizen/libro-code-editor';
|
|
3
3
|
import { MIME } from '@difizen/libro-common';
|
|
4
|
-
import { singleton } from '@difizen/
|
|
4
|
+
import { singleton } from '@difizen/libro-common/app';
|
|
5
5
|
|
|
6
6
|
import { codeMirrorDefaultConfig } from './editor.js';
|
|
7
7
|
import { codeMirrorEditorFactory, stateFactory } from './factory.js';
|
package/src/editor.ts
CHANGED
|
@@ -39,15 +39,15 @@ import {
|
|
|
39
39
|
removeAllWhereFromArray,
|
|
40
40
|
} from '@difizen/libro-common';
|
|
41
41
|
import type { LSPProvider } from '@difizen/libro-lsp';
|
|
42
|
-
import { Deferred, Disposable, Emitter } from '@difizen/
|
|
43
|
-
import { getOrigin, watch } from '@difizen/
|
|
42
|
+
import { Deferred, Disposable, Emitter } from '@difizen/libro-common/app';
|
|
43
|
+
import { getOrigin, watch } from '@difizen/libro-common/app';
|
|
44
44
|
import type { SyntaxNodeRef } from '@lezer/common';
|
|
45
45
|
import { v4 } from 'uuid';
|
|
46
46
|
|
|
47
47
|
import type { CodeMirrorConfig } from './config.js';
|
|
48
48
|
import { EditorConfiguration } from './config.js';
|
|
49
49
|
import { stateFactory } from './factory.js';
|
|
50
|
-
import {
|
|
50
|
+
import { codemirrorEnsure } from './mode.js';
|
|
51
51
|
import { monitorPlugin } from './monitor.js';
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -922,7 +922,7 @@ export class CodeMirrorEditor implements IEditor {
|
|
|
922
922
|
protected _onMimeTypeChanged(): void {
|
|
923
923
|
const mime = this._model.mimeType;
|
|
924
924
|
// TODO: should we provide a hook for when the mode is done being set?
|
|
925
|
-
void
|
|
925
|
+
void codemirrorEnsure(mime).then((spec) => {
|
|
926
926
|
if (spec) {
|
|
927
927
|
this._editorConfig.reconfigureExtension(
|
|
928
928
|
this._editor,
|
package/src/lsp/completion.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pythonLanguage } from '@codemirror/lang-python';
|
|
2
|
-
import {
|
|
2
|
+
import { LspCompletionTriggerKind } from '@difizen/libro-lsp';
|
|
3
|
+
import { LspCompletionItemKind } from '@difizen/libro-lsp';
|
|
3
4
|
|
|
4
5
|
import type { Completion, CompletionSource } from '../auto-complete/index.js';
|
|
5
6
|
|
|
@@ -11,8 +12,8 @@ export type CompletionItemDetailReolve = (
|
|
|
11
12
|
) => Node | null | Promise<Node | null>;
|
|
12
13
|
|
|
13
14
|
const CompletionItemKindMap = Object.fromEntries(
|
|
14
|
-
Object.entries(
|
|
15
|
-
) as Record<
|
|
15
|
+
Object.entries(LspCompletionItemKind).map(([key, value]) => [value, key]),
|
|
16
|
+
) as Record<LspCompletionTriggerKind, string>;
|
|
16
17
|
|
|
17
18
|
function toSet(chars: Set<string>) {
|
|
18
19
|
let preamble = '';
|
|
@@ -86,7 +87,7 @@ export const lspPythonCompletion: CMLSPExtension = ({ lspProvider }) => {
|
|
|
86
87
|
uri: doc.documentInfo.uri,
|
|
87
88
|
},
|
|
88
89
|
context: {
|
|
89
|
-
triggerKind:
|
|
90
|
+
triggerKind: LspCompletionTriggerKind.Invoked,
|
|
90
91
|
},
|
|
91
92
|
});
|
|
92
93
|
|
package/src/lsp/lint.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Diagnostic } from '@codemirror/lint';
|
|
|
2
2
|
import { setDiagnostics } from '@codemirror/lint';
|
|
3
3
|
import type { PluginValue, EditorView } from '@codemirror/view';
|
|
4
4
|
import { ViewPlugin } from '@codemirror/view';
|
|
5
|
-
import {
|
|
5
|
+
import { LspDiagnosticSeverity } from '@difizen/libro-lsp';
|
|
6
6
|
|
|
7
7
|
import type { CMLSPExtension, LSPExtensionOptions } from './protocol.js';
|
|
8
8
|
import { posToOffset } from './util.js';
|
|
@@ -28,59 +28,61 @@ class LintPlugin implements PluginValue {
|
|
|
28
28
|
lspConnection.serverNotifications['textDocument/publishDiagnostics'].event(
|
|
29
29
|
(e) => {
|
|
30
30
|
const diagnostics = e.diagnostics
|
|
31
|
-
.map(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// the diagnostic range must be in current editor
|
|
39
|
-
if (editor !== currentEditor) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
31
|
+
.map(
|
|
32
|
+
({ range, message, severity = LspDiagnosticSeverity.Information }) => {
|
|
33
|
+
const currentEditor = virtualDocument.getEditorAtVirtualLine({
|
|
34
|
+
line: range.start.line,
|
|
35
|
+
ch: range.start.character,
|
|
36
|
+
isVirtual: true,
|
|
37
|
+
});
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
39
|
+
// the diagnostic range must be in current editor
|
|
40
|
+
if (editor !== currentEditor) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})!;
|
|
55
|
-
}
|
|
44
|
+
const editorStart = virtualDocument.transformVirtualToEditor({
|
|
45
|
+
line: range.start.line,
|
|
46
|
+
ch: range.start.character,
|
|
47
|
+
isVirtual: true,
|
|
48
|
+
});
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
let offset: number | undefined;
|
|
51
|
+
if (editorStart) {
|
|
52
|
+
offset = posToOffset(this.view.state.doc, {
|
|
53
|
+
line: editorStart.line,
|
|
54
|
+
character: editorStart.ch,
|
|
55
|
+
})!;
|
|
56
|
+
}
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
character: editorEnd.ch,
|
|
58
|
+
const editorEnd = virtualDocument.transformVirtualToEditor({
|
|
59
|
+
line: range.end.line,
|
|
60
|
+
ch: range.end.character,
|
|
61
|
+
isVirtual: true,
|
|
68
62
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
|
|
64
|
+
let end: number | undefined;
|
|
65
|
+
if (editorEnd) {
|
|
66
|
+
end = posToOffset(this.view.state.doc, {
|
|
67
|
+
line: editorEnd.line,
|
|
68
|
+
character: editorEnd.ch,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
from: offset,
|
|
73
|
+
to: end,
|
|
74
|
+
severity: (
|
|
75
|
+
{
|
|
76
|
+
[LspDiagnosticSeverity.Error]: 'error',
|
|
77
|
+
[LspDiagnosticSeverity.Warning]: 'warning',
|
|
78
|
+
[LspDiagnosticSeverity.Information]: 'info',
|
|
79
|
+
[LspDiagnosticSeverity.Hint]: 'info',
|
|
80
|
+
} as const
|
|
81
|
+
)[severity],
|
|
82
|
+
message,
|
|
83
|
+
} as Diagnostic;
|
|
84
|
+
},
|
|
85
|
+
)
|
|
84
86
|
.filter<Diagnostic>(isDiagnostic)
|
|
85
87
|
.sort((a, b) => {
|
|
86
88
|
switch (true) {
|
package/src/mode.ts
CHANGED
|
@@ -200,12 +200,12 @@ export function findBest(mode: string | ISpec, fallback = true): ISpec | null {
|
|
|
200
200
|
/**
|
|
201
201
|
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
202
202
|
*
|
|
203
|
-
* @param mode - The mode to
|
|
203
|
+
* @param mode - The mode to codemirrorEnsure. If it is a string, uses [findBest]
|
|
204
204
|
* to get the appropriate spec.
|
|
205
205
|
*
|
|
206
206
|
* @returns A promise that resolves when the mode is available.
|
|
207
207
|
*/
|
|
208
|
-
export async function
|
|
208
|
+
export async function codemirrorEnsure(mode: string | ISpec): Promise<ISpec | null> {
|
|
209
209
|
const spec = findBest(mode);
|
|
210
210
|
if (spec) {
|
|
211
211
|
spec.support = await spec.load!();
|
package/src/module.ts
CHANGED
package/src/monitor.ts
CHANGED
package/src/style/variables.css
CHANGED
|
@@ -50,31 +50,40 @@ all of MD as it is not optimized for dense, information rich UIs.
|
|
|
50
50
|
12%
|
|
51
51
|
);
|
|
52
52
|
--jp-elevation-z0: none;
|
|
53
|
-
--jp-elevation-z1:
|
|
53
|
+
--jp-elevation-z1:
|
|
54
|
+
0 2px 1px -1px var(--jp-shadow-umbra-color),
|
|
54
55
|
0 1px 1px 0 var(--jp-shadow-penumbra-color),
|
|
55
56
|
0 1px 3px 0 var(--jp-shadow-ambient-color);
|
|
56
|
-
--jp-elevation-z2:
|
|
57
|
+
--jp-elevation-z2:
|
|
58
|
+
0 3px 1px -2px var(--jp-shadow-umbra-color),
|
|
57
59
|
0 2px 2px 0 var(--jp-shadow-penumbra-color),
|
|
58
60
|
0 1px 5px 0 var(--jp-shadow-ambient-color);
|
|
59
|
-
--jp-elevation-z4:
|
|
61
|
+
--jp-elevation-z4:
|
|
62
|
+
0 2px 4px -1px var(--jp-shadow-umbra-color),
|
|
60
63
|
0 4px 5px 0 var(--jp-shadow-penumbra-color),
|
|
61
64
|
0 1px 10px 0 var(--jp-shadow-ambient-color);
|
|
62
|
-
--jp-elevation-z6:
|
|
65
|
+
--jp-elevation-z6:
|
|
66
|
+
0 3px 5px -1px var(--jp-shadow-umbra-color),
|
|
63
67
|
0 6px 10px 0 var(--jp-shadow-penumbra-color),
|
|
64
68
|
0 1px 18px 0 var(--jp-shadow-ambient-color);
|
|
65
|
-
--jp-elevation-z8:
|
|
69
|
+
--jp-elevation-z8:
|
|
70
|
+
0 5px 5px -3px var(--jp-shadow-umbra-color),
|
|
66
71
|
0 8px 10px 1px var(--jp-shadow-penumbra-color),
|
|
67
72
|
0 3px 14px 2px var(--jp-shadow-ambient-color);
|
|
68
|
-
--jp-elevation-z12:
|
|
73
|
+
--jp-elevation-z12:
|
|
74
|
+
0 7px 8px -4px var(--jp-shadow-umbra-color),
|
|
69
75
|
0 12px 17px 2px var(--jp-shadow-penumbra-color),
|
|
70
76
|
0 5px 22px 4px var(--jp-shadow-ambient-color);
|
|
71
|
-
--jp-elevation-z16:
|
|
77
|
+
--jp-elevation-z16:
|
|
78
|
+
0 8px 10px -5px var(--jp-shadow-umbra-color),
|
|
72
79
|
0 16px 24px 2px var(--jp-shadow-penumbra-color),
|
|
73
80
|
0 6px 30px 5px var(--jp-shadow-ambient-color);
|
|
74
|
-
--jp-elevation-z20:
|
|
81
|
+
--jp-elevation-z20:
|
|
82
|
+
0 10px 13px -6px var(--jp-shadow-umbra-color),
|
|
75
83
|
0 20px 31px 3px var(--jp-shadow-penumbra-color),
|
|
76
84
|
0 8px 38px 7px var(--jp-shadow-ambient-color);
|
|
77
|
-
--jp-elevation-z24:
|
|
85
|
+
--jp-elevation-z24:
|
|
86
|
+
0 11px 15px -7px var(--jp-shadow-umbra-color),
|
|
78
87
|
0 24px 38px 3px var(--jp-shadow-penumbra-color),
|
|
79
88
|
0 9px 46px 8px var(--jp-shadow-ambient-color);
|
|
80
89
|
|
|
@@ -106,9 +115,9 @@ all of MD as it is not optimized for dense, information rich UIs.
|
|
|
106
115
|
--jp-ui-font-size1: 13px; /* Base font size */
|
|
107
116
|
--jp-ui-font-size2: 1.2em;
|
|
108
117
|
--jp-ui-font-size3: 1.44em;
|
|
109
|
-
--jp-ui-font-family:
|
|
110
|
-
|
|
111
|
-
'Segoe UI Symbol';
|
|
118
|
+
--jp-ui-font-family:
|
|
119
|
+
system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', helvetica, arial,
|
|
120
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
112
121
|
|
|
113
122
|
/*
|
|
114
123
|
* Use these font colors against the corresponding main layout colors.
|
|
@@ -162,9 +171,9 @@ all of MD as it is not optimized for dense, information rich UIs.
|
|
|
162
171
|
--jp-content-font-color2: rgba(0, 0, 0, 54%);
|
|
163
172
|
--jp-content-font-color3: rgba(0, 0, 0, 38%);
|
|
164
173
|
--jp-content-link-color: var(--md-blue-700);
|
|
165
|
-
--jp-content-font-family:
|
|
166
|
-
|
|
167
|
-
'Segoe UI Symbol';
|
|
174
|
+
--jp-content-font-family:
|
|
175
|
+
system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', helvetica, arial,
|
|
176
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
168
177
|
|
|
169
178
|
/*
|
|
170
179
|
* Code Fonts
|