@difizen/libro-codemirror 0.1.0 → 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/closebrackets.d.ts +12 -0
- package/es/auto-complete/closebrackets.d.ts.map +1 -0
- package/es/auto-complete/completion.d.ts +57 -0
- package/es/auto-complete/completion.d.ts.map +1 -0
- package/es/auto-complete/config.d.ts +22 -0
- package/es/auto-complete/config.d.ts.map +1 -0
- package/es/auto-complete/filter.d.ts +13 -0
- package/es/auto-complete/filter.d.ts.map +1 -0
- 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 +14 -0
- package/es/auto-complete/snippet.d.ts.map +1 -0
- package/es/auto-complete/snippet.js +2 -2
- package/es/auto-complete/state.d.ts +63 -0
- package/es/auto-complete/state.d.ts.map +1 -0
- package/es/auto-complete/state.js +5 -16
- package/es/auto-complete/theme.d.ts +6 -0
- package/es/auto-complete/theme.d.ts.map +1 -0
- package/es/auto-complete/tooltip.d.ts +5 -0
- package/es/auto-complete/tooltip.d.ts.map +1 -0
- package/es/auto-complete/view.d.ts +43 -0
- package/es/auto-complete/view.d.ts.map +1 -0
- package/es/auto-complete/view.js +2 -13
- package/es/auto-complete/word.d.ts +3 -0
- package/es/auto-complete/word.d.ts.map +1 -0
- 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/hyperlink.d.ts +15 -0
- package/es/hyperlink.d.ts.map +1 -0
- package/es/indentation-markers/config.d.ts +17 -0
- package/es/indentation-markers/config.d.ts.map +1 -0
- package/es/indentation-markers/index.d.ts +3 -0
- package/es/indentation-markers/index.d.ts.map +1 -0
- package/es/indentation-markers/map.d.ts +77 -0
- package/es/indentation-markers/map.d.ts.map +1 -0
- package/es/indentation-markers/utils.d.ts +27 -0
- package/es/indentation-markers/utils.d.ts.map +1 -0
- 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 +3 -0
- package/es/libro-icon.d.ts.map +1 -0
- 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/monitor.d.ts +32 -0
- package/es/monitor.d.ts.map +1 -0
- package/es/python-lang.d.ts +3 -0
- package/es/python-lang.d.ts.map +1 -0
- package/es/theme.d.ts +35 -0
- package/es/theme.d.ts.map +1 -0
- package/es/theme.js +4 -5
- package/es/tooltip.d.ts +1 -1
- 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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorState, Transaction, Extension, StateCommand } from '@codemirror/state';
|
|
2
|
+
import type { KeyBinding } from '@codemirror/view';
|
|
3
|
+
export interface CloseBracketConfig {
|
|
4
|
+
brackets?: string[];
|
|
5
|
+
before?: string;
|
|
6
|
+
stringPrefixes?: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function closeBrackets(): Extension;
|
|
9
|
+
export declare const deleteBracketPair: StateCommand;
|
|
10
|
+
export declare const closeBracketsKeymap: readonly KeyBinding[];
|
|
11
|
+
export declare function insertBracket(state: EditorState, bracket: string): Transaction | null;
|
|
12
|
+
//# sourceMappingURL=closebrackets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closebrackets.d.ts","sourceRoot":"","sources":["../../src/auto-complete/closebrackets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAa3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMnD,MAAM,WAAW,kBAAkB;IAIjC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAIpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAyDD,wBAAgB,aAAa,IAAI,SAAS,CAEzC;AA0CD,eAAO,MAAM,iBAAiB,EAAE,YAiC/B,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,SAAS,UAAU,EAEpD,CAAC;AAWF,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAerF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { EditorState, TransactionSpec } from '@codemirror/state';
|
|
2
|
+
import type { EditorView } from '@codemirror/view';
|
|
3
|
+
import type { ActiveResult } from './state.js';
|
|
4
|
+
export interface Completion {
|
|
5
|
+
label: string;
|
|
6
|
+
detail?: string;
|
|
7
|
+
info?: string | ((completion: Completion) => Node | null | Promise<Node | null>);
|
|
8
|
+
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void);
|
|
9
|
+
type?: string;
|
|
10
|
+
boost?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class CompletionContext {
|
|
13
|
+
readonly state: EditorState;
|
|
14
|
+
readonly pos: number;
|
|
15
|
+
readonly explicit: boolean;
|
|
16
|
+
abortListeners: (() => void)[] | null;
|
|
17
|
+
constructor(state: EditorState, pos: number, explicit: boolean);
|
|
18
|
+
tokenBefore(types: readonly string[]): {
|
|
19
|
+
from: number;
|
|
20
|
+
to: number;
|
|
21
|
+
text: string;
|
|
22
|
+
type: import("@lezer/common").NodeType;
|
|
23
|
+
} | null;
|
|
24
|
+
matchBefore(expr: RegExp): {
|
|
25
|
+
from: number;
|
|
26
|
+
to: number;
|
|
27
|
+
text: string;
|
|
28
|
+
} | null;
|
|
29
|
+
get aborted(): boolean;
|
|
30
|
+
addEventListener(type: 'abort', listener: () => void): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource;
|
|
33
|
+
export declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
|
34
|
+
export declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
|
35
|
+
export type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise<CompletionResult | null>;
|
|
36
|
+
export interface CompletionResult {
|
|
37
|
+
from: number;
|
|
38
|
+
to?: number;
|
|
39
|
+
options: readonly Completion[];
|
|
40
|
+
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean);
|
|
41
|
+
filter?: boolean;
|
|
42
|
+
getMatch?: (completion: Completion) => readonly number[];
|
|
43
|
+
update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null;
|
|
44
|
+
}
|
|
45
|
+
export declare class Option {
|
|
46
|
+
readonly completion: Completion;
|
|
47
|
+
readonly source: ActiveResult;
|
|
48
|
+
readonly match: readonly number[];
|
|
49
|
+
constructor(completion: Completion, source: ActiveResult, match: readonly number[]);
|
|
50
|
+
}
|
|
51
|
+
export declare function cur(state: EditorState): number;
|
|
52
|
+
export declare function ensureAnchor(expr: RegExp, start: boolean): RegExp;
|
|
53
|
+
export declare const pickedCompletion: import("@codemirror/state").AnnotationType<Completion>;
|
|
54
|
+
export declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec;
|
|
55
|
+
export declare function applyCompletion(view: EditorView, option: Option): void;
|
|
56
|
+
export declare function asSource(source: CompletionSource | readonly (string | Completion)[]): CompletionSource;
|
|
57
|
+
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -0,0 +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,E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AAM,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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EditorState } from '@codemirror/state';
|
|
2
|
+
import { Facet } from '@codemirror/state';
|
|
3
|
+
import type { Completion, CompletionSource } from './completion.js';
|
|
4
|
+
export interface CompletionConfig {
|
|
5
|
+
activateOnTyping?: boolean;
|
|
6
|
+
selectOnOpen?: boolean;
|
|
7
|
+
override?: readonly CompletionSource[] | null;
|
|
8
|
+
closeOnBlur?: boolean;
|
|
9
|
+
maxRenderedOptions?: number;
|
|
10
|
+
defaultKeymap?: boolean;
|
|
11
|
+
aboveCursor?: boolean;
|
|
12
|
+
optionClass?: (completion: Completion) => string;
|
|
13
|
+
icons?: boolean;
|
|
14
|
+
addToOptions?: {
|
|
15
|
+
render: (completion: Completion, state: EditorState) => Node | null;
|
|
16
|
+
position: number;
|
|
17
|
+
}[];
|
|
18
|
+
compareCompletions?: (a: Completion, b: Completion) => number;
|
|
19
|
+
interactionDelay?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const completionConfig: Facet<CompletionConfig, Required<CompletionConfig>>;
|
|
22
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/auto-complete/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAiB,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAG/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAO3B,YAAY,CAAC,EAAE,OAAO,CAAC;IAMvB,QAAQ,CAAC,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IAG9C,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAM5B,aAAa,CAAC,EAAE,OAAO,CAAC;IAIxB,WAAW,CAAC,EAAE,OAAO,CAAC;IAGtB,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,MAAM,CAAC;IAIjD,KAAK,CAAC,EAAE,OAAO,CAAC;IAQhB,YAAY,CAAC,EAAE;QACb,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;QACpE,QAAQ,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;IAIJ,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC;IAK9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,qDA8B3B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class FuzzyMatcher {
|
|
2
|
+
readonly pattern: string;
|
|
3
|
+
chars: number[];
|
|
4
|
+
folded: number[];
|
|
5
|
+
astral: boolean;
|
|
6
|
+
any: number[];
|
|
7
|
+
precise: number[];
|
|
8
|
+
byWord: number[];
|
|
9
|
+
constructor(pattern: string);
|
|
10
|
+
match(word: string): number[] | null;
|
|
11
|
+
result(score: number, positions: number[], word: string): number[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/auto-complete/filter.ts"],"names":[],"mappings":"AAsBA,qBAAa,YAAY;IAWX,QAAQ,CAAC,OAAO,EAAE,MAAM;IAVpC,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,MAAM,EAAE,MAAM,EAAE,CAAM;IACtB,MAAM,EAAE,OAAO,CAAC;IAIhB,GAAG,EAAE,MAAM,EAAE,CAAM;IACnB,OAAO,EAAE,MAAM,EAAE,CAAM;IACvB,MAAM,EAAE,MAAM,EAAE,CAAM;gBAED,OAAO,EAAE,MAAM;IAoBpC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAkJpC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM;CAcxD"}
|
|
@@ -76,13 +76,7 @@ export var FuzzyMatcher = /*#__PURE__*/function () {
|
|
|
76
76
|
// at the start
|
|
77
77
|
if (chars.length === 1) {
|
|
78
78
|
var first = codePointAt(word, 0);
|
|
79
|
-
|
|
80
|
-
return [0, 0, codePointSize(first)];
|
|
81
|
-
}
|
|
82
|
-
if (first === folded[0]) {
|
|
83
|
-
return [Penalty.CaseFold, 0, codePointSize(first)];
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
79
|
+
return first === chars[0] ? [0, 0, codePointSize(first)] : first === folded[0] ? [Penalty.CaseFold, 0, codePointSize(first)] : null;
|
|
86
80
|
}
|
|
87
81
|
var direct = word.indexOf(this.pattern);
|
|
88
82
|
if (direct === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auto-complete/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auto-complete/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAWpD,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AAGnC,wBAAgB,cAAc,CAAC,MAAM,GAAE,gBAAqB,GAAG,SAAS,CAQvE;AAWD,eAAO,MAAM,gBAAgB,EAAE,SAAS,UAAU,EAQjD,CAAC;AAYF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,CAOhF;AAMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,UAAU,EAAE,CAa5E;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAGxE;AAID,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAGzE;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAEzE"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
|
+
|
|
1
3
|
import { Prec } from '@codemirror/state';
|
|
2
4
|
import { keymap } from '@codemirror/view';
|
|
3
5
|
import { indentOrCompletion, indentOrTooltip } from "../indent.js";
|
|
@@ -59,17 +61,11 @@ var completionKeymapExt = Prec.highest(keymap.computeN([completionConfig], funct
|
|
|
59
61
|
/// returns `null`.
|
|
60
62
|
export function completionStatus(state) {
|
|
61
63
|
var cState = state.field(completionState, false);
|
|
62
|
-
|
|
64
|
+
return cState && cState.active.some(function (a) {
|
|
63
65
|
return a.state === State.Pending;
|
|
64
|
-
})) {
|
|
65
|
-
return 'pending';
|
|
66
|
-
}
|
|
67
|
-
if (cState && cState.active.some(function (a) {
|
|
66
|
+
}) ? 'pending' : cState && cState.active.some(function (a) {
|
|
68
67
|
return a.state !== State.Inactive;
|
|
69
|
-
})
|
|
70
|
-
return 'active';
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
68
|
+
}) ? 'active' : null;
|
|
73
69
|
}
|
|
74
70
|
var completionArrayCache = new WeakMap();
|
|
75
71
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorState, Transaction, StateCommand } from '@codemirror/state';
|
|
2
|
+
import { Facet } from '@codemirror/state';
|
|
3
|
+
import type { KeyBinding } from '@codemirror/view';
|
|
4
|
+
import type { Completion } from './completion.js';
|
|
5
|
+
export declare function snippet(template: string): (editor: {
|
|
6
|
+
state: EditorState;
|
|
7
|
+
dispatch: (tr: Transaction) => void;
|
|
8
|
+
}, _completion: Completion, from: number, to: number) => void;
|
|
9
|
+
export declare const clearSnippet: StateCommand;
|
|
10
|
+
export declare const nextSnippetField: StateCommand;
|
|
11
|
+
export declare const prevSnippetField: StateCommand;
|
|
12
|
+
export declare const snippetKeymap: Facet<readonly KeyBinding[], readonly KeyBinding[]>;
|
|
13
|
+
export declare function snippetCompletion(template: string, completion: Completion): Completion;
|
|
14
|
+
//# sourceMappingURL=snippet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../../src/auto-complete/snippet.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,WAAW,EACX,WAAW,EAEX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAML,KAAK,EAEN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmPlD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM;WAGnB,WAAW;mBAAiB,WAAW,KAAK,IAAI;gBACpD,UAAU,QACjB,MAAM,MACR,MAAM,UA0Bb;AAqBD,eAAO,MAAM,YAAY,EAAE,YAO1B,CAAC;AAGF,eAAO,MAAM,gBAAgB,cAAe,CAAC;AAG7C,eAAO,MAAM,gBAAgB,cAAgB,CAAC;AAY9C,eAAO,MAAM,aAAa,qDAMzB,CAAC;AASF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,UAAU,GACrB,UAAU,CAEZ"}
|
|
@@ -20,6 +20,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
20
20
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
21
21
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
22
22
|
/* eslint-disable prefer-const */
|
|
23
|
+
|
|
23
24
|
import { indentUnit } from '@codemirror/language';
|
|
24
25
|
import { StateField, StateEffect, EditorSelection, Text, Prec, Facet, MapMode } from '@codemirror/state';
|
|
25
26
|
import { Decoration, WidgetType, EditorView, keymap } from '@codemirror/view';
|
|
@@ -108,8 +109,7 @@ var Snippet = /*#__PURE__*/function () {
|
|
|
108
109
|
name = m[2] || m[3] || '',
|
|
109
110
|
found = -1;
|
|
110
111
|
for (var i = 0; i < fields.length; i++) {
|
|
111
|
-
|
|
112
|
-
if (seq !== null ? fields[i].seq === seq : sameName) {
|
|
112
|
+
if (seq !== null ? fields[i].seq === seq : name ? fields[i].name === name : false) {
|
|
113
113
|
found = i;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Transaction, EditorState, ChangeDesc } from '@codemirror/state';
|
|
2
|
+
import { StateField } from '@codemirror/state';
|
|
3
|
+
import type { Tooltip } from '@codemirror/view';
|
|
4
|
+
import type { CompletionSource, CompletionResult } from './completion.js';
|
|
5
|
+
import { Option } from './completion.js';
|
|
6
|
+
import type { CompletionConfig } from './config.js';
|
|
7
|
+
declare class CompletionDialog {
|
|
8
|
+
readonly options: readonly Option[];
|
|
9
|
+
readonly attrs: Record<string, string>;
|
|
10
|
+
readonly tooltip: Tooltip;
|
|
11
|
+
readonly timestamp: number;
|
|
12
|
+
readonly selected: number;
|
|
13
|
+
constructor(options: readonly Option[], attrs: Record<string, string>, tooltip: Tooltip, timestamp: number, selected: number);
|
|
14
|
+
setSelected(selected: number, id: string): CompletionDialog;
|
|
15
|
+
static build(active: readonly ActiveSource[], state: EditorState, id: string, prev: CompletionDialog | null, conf: Required<CompletionConfig>): CompletionDialog | null;
|
|
16
|
+
map(changes: ChangeDesc): CompletionDialog;
|
|
17
|
+
}
|
|
18
|
+
export declare class CompletionState {
|
|
19
|
+
readonly active: readonly ActiveSource[];
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly open: CompletionDialog | null;
|
|
22
|
+
constructor(active: readonly ActiveSource[], id: string, open: CompletionDialog | null);
|
|
23
|
+
static start(): CompletionState;
|
|
24
|
+
update(tr: Transaction): CompletionState;
|
|
25
|
+
get tooltip(): Tooltip | null;
|
|
26
|
+
get attrs(): Record<string, string> | {
|
|
27
|
+
'aria-autocomplete': string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare const enum State {
|
|
31
|
+
Inactive = 0,
|
|
32
|
+
Pending = 1,
|
|
33
|
+
Result = 2
|
|
34
|
+
}
|
|
35
|
+
export declare function getUserEvent(tr: Transaction): 'input' | 'delete' | null;
|
|
36
|
+
export declare class ActiveSource {
|
|
37
|
+
readonly source: CompletionSource;
|
|
38
|
+
readonly state: State;
|
|
39
|
+
readonly explicitPos: number;
|
|
40
|
+
constructor(source: CompletionSource, state: State, explicitPos?: number);
|
|
41
|
+
hasResult(): this is ActiveResult;
|
|
42
|
+
update(tr: Transaction, conf: Required<CompletionConfig>): ActiveSource;
|
|
43
|
+
handleUserEvent(tr: Transaction, type: 'input' | 'delete', conf: Required<CompletionConfig>): ActiveSource;
|
|
44
|
+
handleChange(tr: Transaction): ActiveSource;
|
|
45
|
+
map(changes: ChangeDesc): ActiveSource;
|
|
46
|
+
}
|
|
47
|
+
export declare class ActiveResult extends ActiveSource {
|
|
48
|
+
readonly result: CompletionResult;
|
|
49
|
+
readonly from: number;
|
|
50
|
+
readonly to: number;
|
|
51
|
+
constructor(source: CompletionSource, explicitPos: number, result: CompletionResult, from: number, to: number);
|
|
52
|
+
hasResult(): this is ActiveResult;
|
|
53
|
+
handleUserEvent(tr: Transaction, type: 'input' | 'delete', conf: Required<CompletionConfig>): ActiveSource;
|
|
54
|
+
handleChange(tr: Transaction): ActiveSource;
|
|
55
|
+
map(mapping: ChangeDesc): ActiveResult;
|
|
56
|
+
}
|
|
57
|
+
export declare const startCompletionEffect: import("@codemirror/state").StateEffectType<boolean>;
|
|
58
|
+
export declare const closeCompletionEffect: import("@codemirror/state").StateEffectType<null>;
|
|
59
|
+
export declare const setActiveEffect: import("@codemirror/state").StateEffectType<readonly ActiveSource[]>;
|
|
60
|
+
export declare const setSelectedEffect: import("@codemirror/state").StateEffectType<number>;
|
|
61
|
+
export declare const completionState: StateField<CompletionState>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/auto-complete/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAe,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AACtF,OAA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AG,YAAY;IAM3C,GAAG,CAAC,OAAO,EAAE,UAAU;CAWjC;AAoBD,eAAO,MAAM,qBAAqB,sDAAgC,CAAC;AACnE,eAAO,MAAM,qBAAqB,mDAA6B,CAAC;AAChE,eAAO,MAAM,eAAe,sEAI1B,CAAC;AACH,eAAO,MAAM,iBAAiB,qDAA+B,CAAC;AAE9D,eAAO,MAAM,eAAe,6BAa1B,CAAC"}
|
|
@@ -78,7 +78,7 @@ function sortOptions(active, state) {
|
|
|
78
78
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
79
79
|
var _option = _step5.value;
|
|
80
80
|
if (_match = matcher.match(_option.label)) {
|
|
81
|
-
if (_option.boost
|
|
81
|
+
if (_option.boost) {
|
|
82
82
|
_match[0] += _option.boost;
|
|
83
83
|
}
|
|
84
84
|
options.push(new Option(_option, a, _match));
|
|
@@ -107,7 +107,7 @@ function sortOptions(active, state) {
|
|
|
107
107
|
try {
|
|
108
108
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
109
109
|
var opt = _step2.value;
|
|
110
|
-
if (!prev || prev.label !== opt.completion.label || prev.detail !== opt.completion.detail || prev.type
|
|
110
|
+
if (!prev || prev.label !== opt.completion.label || prev.detail !== opt.completion.detail || prev.type && opt.completion.type && prev.type !== opt.completion.type || prev.apply !== opt.completion.apply) {
|
|
111
111
|
result.push(opt);
|
|
112
112
|
} else if (score(opt.completion) > score(prev)) {
|
|
113
113
|
result[result.length - 1] = opt;
|
|
@@ -197,14 +197,9 @@ export var CompletionState = /*#__PURE__*/function () {
|
|
|
197
197
|
})) {
|
|
198
198
|
active = this.active;
|
|
199
199
|
}
|
|
200
|
-
var open
|
|
201
|
-
if (tr.selection || active.some(function (a) {
|
|
200
|
+
var open = tr.selection || active.some(function (a) {
|
|
202
201
|
return a.hasResult() && tr.changes.touchesRange(a.from, a.to);
|
|
203
|
-
}) || !sameResults(active, this.active))
|
|
204
|
-
open = CompletionDialog.build(active, state, this.id, this.open, conf);
|
|
205
|
-
} else {
|
|
206
|
-
open = this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
|
|
207
|
-
}
|
|
202
|
+
}) || !sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf) : this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
|
|
208
203
|
if (!open && active.every(function (a) {
|
|
209
204
|
return a.state !== State.Pending;
|
|
210
205
|
}) && active.some(function (a) {
|
|
@@ -291,13 +286,7 @@ export var State = /*#__PURE__*/function (State) {
|
|
|
291
286
|
return State;
|
|
292
287
|
}({});
|
|
293
288
|
export function getUserEvent(tr) {
|
|
294
|
-
|
|
295
|
-
return 'input';
|
|
296
|
-
}
|
|
297
|
-
if (tr.isUserEvent('delete.backward')) {
|
|
298
|
-
return 'delete';
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
289
|
+
return tr.isUserEvent('input.type') ? 'input' : tr.isUserEvent('delete.backward') ? 'delete' : null;
|
|
301
290
|
}
|
|
302
291
|
export var ActiveSource = /*#__PURE__*/function () {
|
|
303
292
|
function ActiveSource(source, state) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/auto-complete/theme.ts"],"names":[],"mappings":"AAEA,0BAAkB,IAAI;IACpB,MAAM,KAAK;IACX,KAAK,MAAM;CACZ;AAED,eAAO,MAAM,SAAS,uCAsHpB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StateField } from '@codemirror/state';
|
|
2
|
+
import type { EditorView, TooltipView } from '@codemirror/view';
|
|
3
|
+
import type { CompletionState } from './state.js';
|
|
4
|
+
export declare function completionTooltip(stateField: StateField<CompletionState>): (view: EditorView) => TooltipView;
|
|
5
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/auto-complete/tooltip.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAc,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAO5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyWlD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC,UACzD,UAAU,KAAG,WAAW,CACvC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
5
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
6
|
+
import type { Transaction } from '@codemirror/state';
|
|
7
|
+
import type { EditorView, Command, ViewUpdate } from '@codemirror/view';
|
|
8
|
+
import { ViewPlugin } from '@codemirror/view';
|
|
9
|
+
import type { CompletionResult } from './completion.js';
|
|
10
|
+
import { CompletionContext } from './completion.js';
|
|
11
|
+
import { ActiveSource } from './state.js';
|
|
12
|
+
export declare function moveCompletionSelection(forward: boolean, by?: 'option' | 'page'): Command;
|
|
13
|
+
export declare const acceptCompletion: Command;
|
|
14
|
+
export declare const startCompletion: Command;
|
|
15
|
+
export declare const closeCompletion: Command;
|
|
16
|
+
declare class RunningQuery {
|
|
17
|
+
readonly active: ActiveSource;
|
|
18
|
+
readonly context: CompletionContext;
|
|
19
|
+
time: number;
|
|
20
|
+
updates: Transaction[];
|
|
21
|
+
done: undefined | CompletionResult | null;
|
|
22
|
+
constructor(active: ActiveSource, context: CompletionContext);
|
|
23
|
+
}
|
|
24
|
+
declare const enum CompositionState {
|
|
25
|
+
None = 0,
|
|
26
|
+
Started = 1,
|
|
27
|
+
Changed = 2,
|
|
28
|
+
ChangedAndMoved = 3
|
|
29
|
+
}
|
|
30
|
+
export declare const completionPlugin: ViewPlugin<{
|
|
31
|
+
debounceUpdate: NodeJS.Timeout | -1;
|
|
32
|
+
running: RunningQuery[];
|
|
33
|
+
debounceAccept: NodeJS.Timeout | -1;
|
|
34
|
+
composing: CompositionState;
|
|
35
|
+
readonly view: EditorView;
|
|
36
|
+
update(update: ViewUpdate): void;
|
|
37
|
+
startUpdate(): void;
|
|
38
|
+
startQuery(active: ActiveSource): void;
|
|
39
|
+
scheduleAccept(): void;
|
|
40
|
+
accept(): void;
|
|
41
|
+
}>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +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,iBAAiB,EAAmB,MAAM,iBAAiB,CAAC;AAE1E,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,iBAAiB;IARrC,IAAI,SAAc;IAClB,OAAO,EAAE,WAAW,EAAE,CAAM;IAG5B,IAAI,EAAE,SAAS,GAAG,gBAAgB,GAAG,IAAI,CAAa;gBAG3C,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,iBAAiB;CAEtC;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;;;EA2HlC,CAAC"}
|
package/es/auto-complete/view.js
CHANGED
|
@@ -31,16 +31,7 @@ export function moveCompletionSelection(forward) {
|
|
|
31
31
|
step = Math.max(2, Math.floor(tooltip.dom.offsetHeight / tooltip.dom.querySelector('li').offsetHeight) - 1);
|
|
32
32
|
}
|
|
33
33
|
var length = cState.open.options.length;
|
|
34
|
-
var selected;
|
|
35
|
-
if (cState.open.selected > -1) {
|
|
36
|
-
selected = cState.open.selected + step * (forward ? 1 : -1);
|
|
37
|
-
} else {
|
|
38
|
-
if (forward) {
|
|
39
|
-
selected = 0;
|
|
40
|
-
} else {
|
|
41
|
-
selected = length - 1;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
34
|
+
var selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1;
|
|
44
35
|
if (selected < 0) {
|
|
45
36
|
selected = by === 'page' ? 0 : length - 1;
|
|
46
37
|
} else if (selected >= length) {
|
|
@@ -245,9 +236,7 @@ export var completionPlugin = ViewPlugin.fromClass( /*#__PURE__*/function () {
|
|
|
245
236
|
});
|
|
246
237
|
logException(_this3.view.state, err);
|
|
247
238
|
return undefined;
|
|
248
|
-
}).catch(
|
|
249
|
-
//
|
|
250
|
-
});
|
|
239
|
+
}).catch(console.error);
|
|
251
240
|
}
|
|
252
241
|
}, {
|
|
253
242
|
key: "scheduleAccept",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word.d.ts","sourceRoot":"","sources":["../../src/auto-complete/word.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA+FpE,eAAO,MAAM,eAAe,EAAE,gBAkB7B,CAAC"}
|
package/es/completion.js
CHANGED
|
@@ -22,7 +22,7 @@ export var kernelCompletions = function kernelCompletions(provider) {
|
|
|
22
22
|
_context.next = 7;
|
|
23
23
|
return Promise.any([provider({
|
|
24
24
|
cursorPosition: context.pos
|
|
25
|
-
}), new Promise(function (
|
|
25
|
+
}), new Promise(function (resolve, reject) {
|
|
26
26
|
setTimeout(function () {
|
|
27
27
|
reject("request time out in ".concat(timeout, "ms"));
|
|
28
28
|
}, timeout);
|
package/es/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Extension } from '@codemirror/state';
|
|
2
|
+
import { Compartment, StateEffect } from '@codemirror/state';
|
|
2
3
|
import type { KeyBinding } from '@codemirror/view';
|
|
3
4
|
import { EditorView } from '@codemirror/view';
|
|
4
5
|
import type { IEditorConfig } from '@difizen/libro-code-editor';
|
|
@@ -15,11 +16,6 @@ export interface CodeMirrorConfig extends IEditorConfig {
|
|
|
15
16
|
* content mimetype
|
|
16
17
|
*/
|
|
17
18
|
mimetype?: string;
|
|
18
|
-
/**
|
|
19
|
-
* The theme to style the editor with. see editortheme.ts for an example
|
|
20
|
-
* of how to design a theme for CodeMirror 6.
|
|
21
|
-
*/
|
|
22
|
-
theme?: string;
|
|
23
19
|
/**
|
|
24
20
|
* Whether to use the context-sensitive indentation that the mode provides
|
|
25
21
|
* (or just indent the same as the line before).
|
|
@@ -149,6 +145,14 @@ export interface CodeMirrorConfig extends IEditorConfig {
|
|
|
149
145
|
lspLint?: boolean;
|
|
150
146
|
placeholder?: HTMLElement | string;
|
|
151
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Builds an extension in a compartment that can
|
|
150
|
+
* be reconfigured.
|
|
151
|
+
*/
|
|
152
|
+
interface IConfigurableBuilder {
|
|
153
|
+
of: <T>(value: T) => Extension;
|
|
154
|
+
reconfigure: <T>(value: T) => StateEffect<unknown>;
|
|
155
|
+
}
|
|
152
156
|
/**
|
|
153
157
|
* Editor configuration: provides APIs to get and reconfigure CodeMirror 6
|
|
154
158
|
* extensions from option names. Also allows to register new themes and
|
|
@@ -175,10 +179,11 @@ export declare class EditorConfiguration {
|
|
|
175
179
|
* based on the provided configuration.
|
|
176
180
|
*/
|
|
177
181
|
getInitialExtensions(config: CodeMirrorConfig): Extension[];
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
protected updateThemeOverload(config: Partial<CodeMirrorConfig> | Record<string, any>): Extension;
|
|
183
|
+
protected get(key: string): IConfigurableBuilder | undefined;
|
|
184
|
+
protected _configurableBuilderMap: Map<string, IConfigurableBuilder>;
|
|
185
|
+
protected _themeOverloaderSpec: Record<string, Record<string, string>>;
|
|
186
|
+
protected _themeOverloader: Compartment;
|
|
183
187
|
}
|
|
188
|
+
export {};
|
|
184
189
|
//# sourceMappingURL=config.d.ts.map
|
package/es/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAIL,UAAU,EAQX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aA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AAI;IAiBhF;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI;IAMvD;;;OAGG;IACH,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EAAE;IA0D3D,SAAS,CAAC,mBAAmB,CAC3B,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACtD,SAAS;IA0CZ,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAI5D,SAAS,CAAC,uBAAuB,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACrE,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvE,SAAS,CAAC,gBAAgB,EAAE,WAAW,CAAC;CACzC"}
|
package/es/config.js
CHANGED
|
@@ -25,18 +25,21 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
25
25
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
26
26
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
27
27
|
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); }
|
|
28
|
-
import { defaultKeymap,
|
|
28
|
+
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
|
|
29
29
|
import { pythonLanguage } from '@codemirror/lang-python';
|
|
30
30
|
import { bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, indentUnit, syntaxHighlighting } from '@codemirror/language';
|
|
31
31
|
import { lintKeymap } from '@codemirror/lint';
|
|
32
32
|
import { highlightSelectionMatches } from '@codemirror/search';
|
|
33
33
|
import { Compartment, EditorState, StateEffect } from '@codemirror/state';
|
|
34
|
-
import { crosshairCursor,
|
|
35
|
-
import { closeBrackets, closeBracketsKeymap,
|
|
34
|
+
import { crosshairCursor, drawSelection, dropCursor, EditorView, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers, placeholder, rectangularSelection } from '@codemirror/view';
|
|
35
|
+
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "./auto-complete/index.js";
|
|
36
36
|
import { kernelCompletions } from "./completion.js";
|
|
37
37
|
import { hyperLink } from "./hyperlink.js";
|
|
38
38
|
import { indentationMarkers } from "./indentation-markers/index.js";
|
|
39
39
|
import { FoldIcon, UnFoldIcon } from "./libro-icon.js";
|
|
40
|
+
import { lspPythonCompletion } from "./lsp/completion.js";
|
|
41
|
+
import { formatKeymap } from "./lsp/format.js";
|
|
42
|
+
import { lspLint, lspTooltip } from "./lsp/index.js";
|
|
40
43
|
import { ensure } from "./mode.js";
|
|
41
44
|
import { getTheme, defaultTheme } from "./theme.js";
|
|
42
45
|
import { tabTooltip, tooltipKeymap } from "./tooltip.js";
|
|
@@ -304,8 +307,14 @@ export var EditorConfiguration = /*#__PURE__*/function () {
|
|
|
304
307
|
}))], ['syntaxHighlighting', createConditionalBuilder(syntaxHighlighting(defaultHighlightStyle, {
|
|
305
308
|
fallback: true
|
|
306
309
|
}))], ['jupyterKernelCompletion', createConditionalBuilder(pythonLanguage.data.of({
|
|
307
|
-
autocomplete: kernelCompletions(options
|
|
308
|
-
}))], ['jupyterKernelTooltip', createConditionalBuilder(tabTooltip(options
|
|
310
|
+
autocomplete: kernelCompletions(options.completionProvider)
|
|
311
|
+
}))], ['jupyterKernelTooltip', createConditionalBuilder(tabTooltip(options.tooltipProvider))], ['indentationMarkers', createConditionalBuilder(indentationMarkers())], ['hyperLink', createConditionalBuilder(hyperLink)], ['placeholder', createPlaceHolderBuilder()], ['lspTooltip', createConditionalBuilder(lspTooltip({
|
|
312
|
+
lspProvider: options.lspProvider
|
|
313
|
+
}))], ['lspLint', createConditionalBuilder(lspLint({
|
|
314
|
+
lspProvider: options.lspProvider
|
|
315
|
+
}))], ['lspCompletion', createConditionalBuilder(lspPythonCompletion({
|
|
316
|
+
lspProvider: options.lspProvider
|
|
317
|
+
}))]]);
|
|
309
318
|
this._themeOverloaderSpec = {
|
|
310
319
|
'&': {},
|
|
311
320
|
'.cm-line': {}
|
|
@@ -406,7 +415,7 @@ export var EditorConfiguration = /*#__PURE__*/function () {
|
|
|
406
415
|
extensions.push(defaultTheme());
|
|
407
416
|
}
|
|
408
417
|
var builder = this.get('keymap');
|
|
409
|
-
var initialKeymap = [].concat(_toConsumableArray(libroDefaultKeymap), _toConsumableArray(closeBracketsKeymap), _toConsumableArray(historyKeymap), _toConsumableArray(foldKeymap), _toConsumableArray(completionKeymap), _toConsumableArray(lintKeymap), _toConsumableArray(tooltipKeymap));
|
|
418
|
+
var initialKeymap = [].concat(_toConsumableArray(libroDefaultKeymap), _toConsumableArray(closeBracketsKeymap), _toConsumableArray(historyKeymap), _toConsumableArray(foldKeymap), _toConsumableArray(completionKeymap), _toConsumableArray(lintKeymap), _toConsumableArray(tooltipKeymap), _toConsumableArray(formatKeymap));
|
|
410
419
|
var keymapExt = builder.of(config.extraKeys ? [initialKeymap].concat(_toConsumableArray(config.extraKeys)) : _toConsumableArray(initialKeymap));
|
|
411
420
|
var indentBuilder = this.get('indentUnit');
|
|
412
421
|
var insertExt = indentBuilder.of(config.insertSpaces ? ' '.repeat(config.tabSize) : '\t');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CodeEditorFactory } from '@difizen/libro-code-editor';
|
|
2
|
+
import { CodeEditorContribution } from '@difizen/libro-code-editor';
|
|
3
|
+
export declare class CodeMirrorEditorContribution implements CodeEditorContribution {
|
|
4
|
+
canHandle(mime: string): number;
|
|
5
|
+
factory: CodeEditorFactory;
|
|
6
|
+
defaultConfig: Required<import("./config.js").CodeMirrorConfig>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=editor-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-contribution.d.ts","sourceRoot":"","sources":["../src/editor-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAMpE,qBACa,4BAA6B,YAAW,sBAAsB;IAEzE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI/B,OAAO,EAAE,iBAAiB,CAA2B;IACrD,aAAa,mDAA2B;CACzC"}
|