@difizen/libro-code-editor 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/code-editor-info-manager.d.ts +7 -0
- package/es/code-editor-info-manager.d.ts.map +1 -0
- package/es/code-editor-info-manager.js +32 -0
- package/es/code-editor-manager.d.ts +67 -0
- package/es/code-editor-manager.d.ts.map +1 -0
- package/es/code-editor-manager.js +130 -0
- package/es/{model.d.ts → code-editor-model.d.ts} +2 -2
- package/es/code-editor-model.d.ts.map +1 -0
- package/es/{model.js → code-editor-model.js} +1 -3
- package/es/{code-editor.d.ts → code-editor-protocol.d.ts} +70 -145
- package/es/code-editor-protocol.d.ts.map +1 -0
- package/es/{code-editor.js → code-editor-protocol.js} +17 -15
- package/es/code-editor-settings.d.ts +34 -0
- package/es/code-editor-settings.d.ts.map +1 -0
- package/es/code-editor-settings.js +225 -0
- package/es/code-editor-view.d.ts +26 -14
- package/es/code-editor-view.d.ts.map +1 -1
- package/es/code-editor-view.js +108 -72
- package/es/index.d.ts +5 -3
- package/es/index.d.ts.map +1 -1
- package/es/index.js +6 -4
- package/es/mimetype.d.ts.map +1 -1
- package/es/mimetype.js +3 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +5 -2
- package/package.json +4 -5
- package/src/code-editor-info-manager.ts +25 -0
- package/src/code-editor-manager.ts +86 -0
- package/src/{model.ts → code-editor-model.ts} +4 -4
- package/src/{code-editor.ts → code-editor-protocol.ts} +136 -189
- package/src/code-editor-settings.ts +214 -0
- package/src/code-editor-view.tsx +93 -49
- package/src/index.spec.ts +1 -3
- package/src/index.ts +5 -3
- package/src/mimetype.ts +3 -0
- package/src/module.ts +13 -2
- package/es/code-editor.d.ts.map +0 -1
- package/es/completer/completer-protocol.d.ts +0 -210
- package/es/completer/completer-protocol.d.ts.map +0 -1
- package/es/completer/completer-protocol.js +0 -34
- package/es/model.d.ts.map +0 -1
- package/src/completer/completer-protocol.ts +0 -259
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A zero-based position in the editor.
|
|
2
|
+
* A one-based position in the editor.
|
|
7
3
|
*/
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -55,10 +51,6 @@ export var defaultSelectionStyle = {
|
|
|
55
51
|
* A widget that provides a code editor.
|
|
56
52
|
*/
|
|
57
53
|
|
|
58
|
-
/**
|
|
59
|
-
* A factory used to create a code editor.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
54
|
/**
|
|
63
55
|
* The configuration options for an editor.
|
|
64
56
|
*/
|
|
@@ -67,16 +59,21 @@ export var defaultSelectionStyle = {
|
|
|
67
59
|
* The default configuration options for an editor.
|
|
68
60
|
*/
|
|
69
61
|
export var defaultConfig = {
|
|
62
|
+
theme: {
|
|
63
|
+
light: 'light',
|
|
64
|
+
dark: 'dark',
|
|
65
|
+
hc: 'hc-mana'
|
|
66
|
+
},
|
|
70
67
|
// Order matters as gutters will be sorted by the configuration order
|
|
71
68
|
autoClosingBrackets: true,
|
|
72
69
|
cursorBlinkRate: 530,
|
|
73
70
|
fontFamily: null,
|
|
74
|
-
fontSize:
|
|
71
|
+
fontSize: 13,
|
|
75
72
|
handlePaste: true,
|
|
76
73
|
insertSpaces: true,
|
|
77
74
|
lineHeight: null,
|
|
78
75
|
lineNumbers: true,
|
|
79
|
-
lineWrap: '
|
|
76
|
+
lineWrap: 'off',
|
|
80
77
|
matchBrackets: true,
|
|
81
78
|
readOnly: false,
|
|
82
79
|
editable: true,
|
|
@@ -84,16 +81,21 @@ export var defaultConfig = {
|
|
|
84
81
|
rulers: [],
|
|
85
82
|
showTrailingSpace: false,
|
|
86
83
|
wordWrapColumn: 80,
|
|
87
|
-
codeFolding:
|
|
84
|
+
codeFolding: true,
|
|
88
85
|
foldGutter: true,
|
|
89
86
|
styleActiveLine: false,
|
|
90
|
-
highlightActiveLineGutter: false
|
|
87
|
+
highlightActiveLineGutter: false,
|
|
88
|
+
lspEnabled: true,
|
|
89
|
+
paddingTop: 12,
|
|
90
|
+
paddingBottom: 18,
|
|
91
|
+
scrollBarHeight: 0,
|
|
92
|
+
placeholder: ''
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
/**
|
|
94
|
-
*
|
|
96
|
+
* The options used to initialize an editor.
|
|
95
97
|
*/
|
|
96
98
|
|
|
97
99
|
/**
|
|
98
|
-
*
|
|
100
|
+
* Base search match interface
|
|
99
101
|
*/
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ApplicationContribution, DisposableCollection, Emitter, ConfigurationContribution, ConfigurationService } from '@difizen/mana-app';
|
|
2
|
+
import type { Disposable, ConfigurationNode } from '@difizen/mana-app';
|
|
3
|
+
import type { IEditorConfig } from './code-editor-protocol.js';
|
|
4
|
+
declare global {
|
|
5
|
+
interface ObjectConstructor {
|
|
6
|
+
typedKeys<T>(obj: T): (keyof T)[];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const CodeEditorSetting: {
|
|
10
|
+
[key in keyof IEditorConfig]?: ConfigurationNode<any>;
|
|
11
|
+
};
|
|
12
|
+
export declare class CodeEditorSettings implements ConfigurationContribution, ApplicationContribution, Disposable {
|
|
13
|
+
protected readonly configurationService: ConfigurationService;
|
|
14
|
+
protected codeEditorSettingsChangeEmitter: Emitter<{
|
|
15
|
+
key: keyof IEditorConfig;
|
|
16
|
+
value: any;
|
|
17
|
+
}>;
|
|
18
|
+
onCodeEditorSettingsChange: import("@difizen/mana-app").Event<{
|
|
19
|
+
key: keyof IEditorConfig;
|
|
20
|
+
value: any;
|
|
21
|
+
}>;
|
|
22
|
+
protected toDispose: DisposableCollection;
|
|
23
|
+
protected useSettings: Partial<IEditorConfig> | undefined;
|
|
24
|
+
constructor(configurationService: ConfigurationService);
|
|
25
|
+
registerConfigurations(): (ConfigurationNode<number> | ConfigurationNode<boolean> | ConfigurationNode<"wordWrapColumn" | "off" | "on" | "bounded">)[];
|
|
26
|
+
onStart(): Promise<void>;
|
|
27
|
+
getUserEditorSettings(): Partial<IEditorConfig> | undefined;
|
|
28
|
+
protected fetchUserEditorSettings(): Promise<Partial<IEditorConfig>>;
|
|
29
|
+
protected handleEditorSettingsChange(): void;
|
|
30
|
+
protected isDisposed: boolean;
|
|
31
|
+
get disposed(): boolean;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=code-editor-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor-settings.d.ts","sourceRoot":"","sources":["../src/code-editor-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EACvB,oBAAoB,EACpB,OAAO,EACP,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,iBAAiB;QACzB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;KACnC;CACF;AAmGD,eAAO,MAAM,iBAAiB,EAAE;KAC7B,GAAG,IAAI,MAAM,aAAa,CAAC,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC;CAStD,CAAC;AAEF,qBACa,kBACX,YAAW,yBAAyB,EAAE,uBAAuB,EAAE,UAAU;IAEzE,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAE9D,SAAS,CAAC,+BAA+B;aAClC,MAAM,aAAa;eACjB,GAAG;OACP;IAEL,0BAA0B;aAJnB,MAAM,aAAa;eACjB,GAAG;OAG4D;IAExE,SAAS,CAAC,SAAS,uBAA8B;IAEjD,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC;gBAIxD,oBAAoB,EAAE,oBAAoB;IAI5C,sBAAsB;IAYhB,OAAO;IAIb,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS;cAI3C,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAQ1E,SAAS,CAAC,0BAA0B;IAiBpC,SAAS,CAAC,UAAU,UAAS;IAC7B,IAAI,QAAQ,YAEX;IACD,OAAO;CAOR"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _defaultConfig$fontSi, _defaultConfig$lineHe, _defaultConfig$tabSiz, _dec, _class;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
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); }
|
|
11
|
+
import { inject, singleton, ApplicationContribution, DisposableCollection, Emitter, ConfigurationContribution, ConfigurationService } from '@difizen/mana-app';
|
|
12
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
13
|
+
import { defaultConfig } from "./code-editor-protocol.js";
|
|
14
|
+
Object.typedKeys = Object.keys;
|
|
15
|
+
var LibroUserSettingStorage = {
|
|
16
|
+
id: '__libro.user.storage__',
|
|
17
|
+
priority: 100
|
|
18
|
+
};
|
|
19
|
+
var FontSize = {
|
|
20
|
+
id: 'libro.user.codeeditor.fontsize',
|
|
21
|
+
description: l10n.t('代码编辑区域字体大小'),
|
|
22
|
+
title: l10n.t('代码字号'),
|
|
23
|
+
type: 'inputnumber',
|
|
24
|
+
defaultValue: (_defaultConfig$fontSi = defaultConfig.fontSize) !== null && _defaultConfig$fontSi !== void 0 ? _defaultConfig$fontSi : 13,
|
|
25
|
+
schema: {
|
|
26
|
+
type: 'number'
|
|
27
|
+
},
|
|
28
|
+
storage: LibroUserSettingStorage
|
|
29
|
+
};
|
|
30
|
+
var LineHeight = {
|
|
31
|
+
id: 'libro.user.codeeditor.lineheight',
|
|
32
|
+
description: l10n.t('代码编辑区域字体行高'),
|
|
33
|
+
title: l10n.t('代码行高'),
|
|
34
|
+
type: 'inputnumber',
|
|
35
|
+
defaultValue: (_defaultConfig$lineHe = defaultConfig.lineHeight) !== null && _defaultConfig$lineHe !== void 0 ? _defaultConfig$lineHe : 20,
|
|
36
|
+
schema: {
|
|
37
|
+
type: 'number'
|
|
38
|
+
},
|
|
39
|
+
storage: LibroUserSettingStorage
|
|
40
|
+
};
|
|
41
|
+
var TabSize = {
|
|
42
|
+
id: 'libro.user.codeeditor.tabsize',
|
|
43
|
+
description: l10n.t('tab转换为几个空格大小'),
|
|
44
|
+
title: l10n.t('tab大小'),
|
|
45
|
+
type: 'inputnumber',
|
|
46
|
+
defaultValue: (_defaultConfig$tabSiz = defaultConfig.tabSize) !== null && _defaultConfig$tabSiz !== void 0 ? _defaultConfig$tabSiz : 4,
|
|
47
|
+
schema: {
|
|
48
|
+
type: 'number'
|
|
49
|
+
},
|
|
50
|
+
storage: LibroUserSettingStorage
|
|
51
|
+
};
|
|
52
|
+
var InsertSpaces = {
|
|
53
|
+
id: 'libro.user.codeeditor.insertspaces',
|
|
54
|
+
description: l10n.t('输入tab是否转换为空格'),
|
|
55
|
+
title: l10n.t('tab转空格'),
|
|
56
|
+
type: 'checkbox',
|
|
57
|
+
defaultValue: defaultConfig.insertSpaces,
|
|
58
|
+
schema: {
|
|
59
|
+
type: 'boolean'
|
|
60
|
+
},
|
|
61
|
+
storage: LibroUserSettingStorage
|
|
62
|
+
};
|
|
63
|
+
var LineWarp = {
|
|
64
|
+
id: 'libro.user.codeeditor.linewarp',
|
|
65
|
+
description: l10n.t("\u81EA\u52A8\u6362\u884C\u7B56\u7565:\n - \"off\", lines will never wrap.\n - \"on\", lines will wrap at the viewport border.\n - \"wordWrapColumn\", lines will wrap at 'wordWrapColumn'.\n - \"bounded\", lines will wrap at minimum between viewport width and wordWrapColumn."),
|
|
66
|
+
title: l10n.t('自动换行'),
|
|
67
|
+
type: 'select',
|
|
68
|
+
defaultValue: defaultConfig.lineWrap,
|
|
69
|
+
schema: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
enum: ['off', 'on', 'wordWrapColumn', 'bounded']
|
|
72
|
+
},
|
|
73
|
+
storage: LibroUserSettingStorage
|
|
74
|
+
};
|
|
75
|
+
var WordWrapColumn = {
|
|
76
|
+
id: 'libro.user.codeeditor.wordWrapColumn',
|
|
77
|
+
description: l10n.t('开启自动换行后,自动换行的列数'),
|
|
78
|
+
title: l10n.t('自动换行列数'),
|
|
79
|
+
type: 'inputnumber',
|
|
80
|
+
defaultValue: defaultConfig.wordWrapColumn,
|
|
81
|
+
schema: {
|
|
82
|
+
type: 'number'
|
|
83
|
+
},
|
|
84
|
+
storage: LibroUserSettingStorage
|
|
85
|
+
};
|
|
86
|
+
var LSPEnabled = {
|
|
87
|
+
id: 'libro.user.codeeditor.lspenabled',
|
|
88
|
+
description: l10n.t('开启语言服务后,编辑器能提供更多辅助编码能力,包括:自动提示、代码诊断、hover提示、格式化、代码跳转、重命名等等(需要使用带有lsp服务的容器, 详情请咨询 @沧浪)'),
|
|
89
|
+
title: l10n.t('开启语言服务'),
|
|
90
|
+
type: 'checkbox',
|
|
91
|
+
defaultValue: defaultConfig.lspEnabled,
|
|
92
|
+
schema: {
|
|
93
|
+
type: 'boolean'
|
|
94
|
+
},
|
|
95
|
+
storage: LibroUserSettingStorage
|
|
96
|
+
};
|
|
97
|
+
export var CodeEditorSetting = {
|
|
98
|
+
fontSize: FontSize,
|
|
99
|
+
tabSize: TabSize,
|
|
100
|
+
insertSpaces: InsertSpaces,
|
|
101
|
+
lineHeight: LineHeight,
|
|
102
|
+
lineWrap: LineWarp,
|
|
103
|
+
wordWrapColumn: WordWrapColumn,
|
|
104
|
+
lspEnabled: LSPEnabled
|
|
105
|
+
};
|
|
106
|
+
export var CodeEditorSettings = (_dec = singleton({
|
|
107
|
+
contrib: [ConfigurationContribution, ApplicationContribution]
|
|
108
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
109
|
+
function CodeEditorSettings(configurationService) {
|
|
110
|
+
_classCallCheck(this, CodeEditorSettings);
|
|
111
|
+
this.codeEditorSettingsChangeEmitter = new Emitter();
|
|
112
|
+
this.onCodeEditorSettingsChange = this.codeEditorSettingsChangeEmitter.event;
|
|
113
|
+
this.toDispose = new DisposableCollection();
|
|
114
|
+
this.isDisposed = false;
|
|
115
|
+
this.configurationService = configurationService;
|
|
116
|
+
}
|
|
117
|
+
CodeEditorSettings = inject(ConfigurationService)(CodeEditorSettings, undefined, 0) || CodeEditorSettings;
|
|
118
|
+
_createClass(CodeEditorSettings, [{
|
|
119
|
+
key: "registerConfigurations",
|
|
120
|
+
value: function registerConfigurations() {
|
|
121
|
+
return [FontSize, TabSize, InsertSpaces, LineHeight, LineWarp, WordWrapColumn, LSPEnabled];
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "onStart",
|
|
125
|
+
value: function () {
|
|
126
|
+
var _onStart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
127
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
128
|
+
while (1) switch (_context.prev = _context.next) {
|
|
129
|
+
case 0:
|
|
130
|
+
_context.next = 2;
|
|
131
|
+
return this.fetchUserEditorSettings();
|
|
132
|
+
case 2:
|
|
133
|
+
this.useSettings = _context.sent;
|
|
134
|
+
this.handleEditorSettingsChange();
|
|
135
|
+
case 4:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee, this);
|
|
140
|
+
}));
|
|
141
|
+
function onStart() {
|
|
142
|
+
return _onStart.apply(this, arguments);
|
|
143
|
+
}
|
|
144
|
+
return onStart;
|
|
145
|
+
}()
|
|
146
|
+
}, {
|
|
147
|
+
key: "getUserEditorSettings",
|
|
148
|
+
value: function getUserEditorSettings() {
|
|
149
|
+
return this.useSettings;
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "fetchUserEditorSettings",
|
|
153
|
+
value: function () {
|
|
154
|
+
var _fetchUserEditorSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
155
|
+
var _this = this;
|
|
156
|
+
var result;
|
|
157
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
158
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
159
|
+
case 0:
|
|
160
|
+
result = {};
|
|
161
|
+
Object.typedKeys(CodeEditorSetting).forEach( /*#__PURE__*/function () {
|
|
162
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key) {
|
|
163
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
164
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
165
|
+
case 0:
|
|
166
|
+
_context2.next = 2;
|
|
167
|
+
return _this.configurationService.get(CodeEditorSetting[key]);
|
|
168
|
+
case 2:
|
|
169
|
+
result[key] = _context2.sent;
|
|
170
|
+
case 3:
|
|
171
|
+
case "end":
|
|
172
|
+
return _context2.stop();
|
|
173
|
+
}
|
|
174
|
+
}, _callee2);
|
|
175
|
+
}));
|
|
176
|
+
return function (_x) {
|
|
177
|
+
return _ref.apply(this, arguments);
|
|
178
|
+
};
|
|
179
|
+
}());
|
|
180
|
+
return _context3.abrupt("return", result);
|
|
181
|
+
case 3:
|
|
182
|
+
case "end":
|
|
183
|
+
return _context3.stop();
|
|
184
|
+
}
|
|
185
|
+
}, _callee3);
|
|
186
|
+
}));
|
|
187
|
+
function fetchUserEditorSettings() {
|
|
188
|
+
return _fetchUserEditorSettings.apply(this, arguments);
|
|
189
|
+
}
|
|
190
|
+
return fetchUserEditorSettings;
|
|
191
|
+
}()
|
|
192
|
+
}, {
|
|
193
|
+
key: "handleEditorSettingsChange",
|
|
194
|
+
value: function handleEditorSettingsChange() {
|
|
195
|
+
var _this2 = this;
|
|
196
|
+
this.toDispose.push(this.configurationService.onConfigurationValueChange(function (e) {
|
|
197
|
+
// const ids = Object.values(CodeEditorSetting).map(item => item.id);
|
|
198
|
+
var match = Object.entries(CodeEditorSetting).find(function (item) {
|
|
199
|
+
return item[1].id === e.key;
|
|
200
|
+
});
|
|
201
|
+
if (match) {
|
|
202
|
+
_this2.codeEditorSettingsChangeEmitter.fire({
|
|
203
|
+
key: match[0],
|
|
204
|
+
value: e.value
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "disposed",
|
|
211
|
+
get: function get() {
|
|
212
|
+
return this.isDisposed;
|
|
213
|
+
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "dispose",
|
|
216
|
+
value: function dispose() {
|
|
217
|
+
if (this.disposed) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.toDispose.dispose();
|
|
221
|
+
this.isDisposed = true;
|
|
222
|
+
}
|
|
223
|
+
}]);
|
|
224
|
+
return CodeEditorSettings;
|
|
225
|
+
}()) || _class);
|
package/es/code-editor-view.d.ts
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
-
import { BaseView } from '@difizen/mana-app';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
2
|
+
import { Deferred, Emitter, BaseView, ThemeService } from '@difizen/mana-app';
|
|
3
|
+
import { CodeEditorInfoManager } from './code-editor-info-manager.js';
|
|
4
|
+
import type { CodeEditorFactory } from './code-editor-manager.js';
|
|
5
|
+
import type { IModel } from './code-editor-model.js';
|
|
6
|
+
import type { CompletionProvider, IEditorConfig, IEditorSelectionStyle, TooltipProvider } from './code-editor-protocol.js';
|
|
7
|
+
import type { IEditor } from './code-editor-protocol.js';
|
|
8
|
+
import { CodeEditorSettings } from './code-editor-settings.js';
|
|
7
9
|
export declare const CodeEditorRender: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>>;
|
|
8
10
|
/**
|
|
9
11
|
* A widget which hosts a code editor.
|
|
10
12
|
*/
|
|
11
13
|
export declare class CodeEditorView extends BaseView {
|
|
14
|
+
protected readonly themeService: ThemeService;
|
|
15
|
+
protected readonly codeEditorSettings: CodeEditorSettings;
|
|
16
|
+
codeEditorInfoManager: CodeEditorInfoManager;
|
|
12
17
|
view: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>>;
|
|
13
18
|
protected classlist: string[];
|
|
14
19
|
protected options: CodeEditorViewOptions;
|
|
15
20
|
protected modalChangeEmitter: Emitter<any>;
|
|
21
|
+
protected editorHostRef: any;
|
|
16
22
|
get onModalChange(): import("@difizen/mana-app").Event<any>;
|
|
17
23
|
/**
|
|
18
24
|
* Get the editor wrapped by the widget.
|
|
19
25
|
*/
|
|
20
|
-
editor: IEditor
|
|
26
|
+
editor: IEditor;
|
|
21
27
|
protected editorReadyDeferred: Deferred<void>;
|
|
22
28
|
get editorReady(): Promise<void>;
|
|
23
29
|
/**
|
|
24
30
|
* Construct a new code editor widget.
|
|
25
31
|
*/
|
|
26
|
-
constructor(options: CodeEditorViewOptions);
|
|
27
|
-
onViewMount(): void
|
|
28
|
-
|
|
32
|
+
constructor(options: CodeEditorViewOptions, codeEditorInfoManager: CodeEditorInfoManager);
|
|
33
|
+
onViewMount(): Promise<void>;
|
|
34
|
+
removeChildNodes: (parent: any) => void;
|
|
35
|
+
onViewUnmount: () => void;
|
|
36
|
+
onViewResize(): void;
|
|
29
37
|
/**
|
|
30
38
|
* Get the model used by the widget.
|
|
31
39
|
*/
|
|
32
|
-
get model(): IModel
|
|
40
|
+
get model(): IModel;
|
|
33
41
|
/**
|
|
34
42
|
* Dispose of the resources held by the widget.
|
|
35
43
|
*/
|
|
@@ -68,7 +76,7 @@ export declare class CodeEditorView extends BaseView {
|
|
|
68
76
|
/**
|
|
69
77
|
* The options used to initialize a code editor widget.
|
|
70
78
|
*/
|
|
71
|
-
export interface CodeEditorViewOptions {
|
|
79
|
+
export interface CodeEditorViewOptions<Config extends IEditorConfig = IEditorConfig> {
|
|
72
80
|
/**
|
|
73
81
|
* A code editor factory.
|
|
74
82
|
*
|
|
@@ -76,7 +84,11 @@ export interface CodeEditorViewOptions {
|
|
|
76
84
|
* The widget needs a factory and a model instead of a `CodeEditor.IEditor`
|
|
77
85
|
* object because it needs to provide its own node as the host.
|
|
78
86
|
*/
|
|
79
|
-
factory
|
|
87
|
+
factory?: CodeEditorFactory;
|
|
88
|
+
/**
|
|
89
|
+
* where to mount the editor
|
|
90
|
+
*/
|
|
91
|
+
editorHostId?: string;
|
|
80
92
|
/**
|
|
81
93
|
* The model used to initialize the code editor.
|
|
82
94
|
*/
|
|
@@ -88,14 +100,14 @@ export interface CodeEditorViewOptions {
|
|
|
88
100
|
/**
|
|
89
101
|
* The configuration options for the editor.
|
|
90
102
|
*/
|
|
91
|
-
config?: Partial<
|
|
103
|
+
config?: Partial<Config>;
|
|
92
104
|
/**
|
|
93
105
|
* The default selection style for the editor.
|
|
94
106
|
*/
|
|
95
107
|
selectionStyle?: IEditorSelectionStyle;
|
|
96
108
|
tooltipProvider?: TooltipProvider;
|
|
97
109
|
completionProvider?: CompletionProvider;
|
|
98
|
-
lspProvider?: LSPProvider;
|
|
99
110
|
autoFocus?: boolean;
|
|
111
|
+
[key: string]: any;
|
|
100
112
|
}
|
|
101
113
|
//# sourceMappingURL=code-editor-view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor-view.d.ts","sourceRoot":"","sources":["../src/code-editor-view.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"code-editor-view.d.ts","sourceRoot":"","sources":["../src/code-editor-view.tsx"],"names":[],"mappings":";AAIA,OAAO,EAGL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,kBAAkB,EAElB,aAAa,EACb,qBAAqB,EACrB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,gBAAgB,+HAI5B,CAAC;AAuBF;;GAEG;AACH,qBAEa,cAAe,SAAQ,QAAQ;IACpB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAEtF,qBAAqB,EAAE,qBAAqB,CAAC;IAEpC,IAAI,gIAAoB;IAEjC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAEnC,SAAS,CAAC,OAAO,EAAE,qBAAqB,CAAC;IAEzC,SAAS,CAAC,kBAAkB,eAAiB;IAE7C,SAAS,CAAC,aAAa,EAAE,GAAG,CAAC;IAE7B,IAAI,aAAa,2CAEhB;IAED;;OAEG;IAEH,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,mBAAmB,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAwB;IACrE,IAAI,WAAW,kBAEd;IACD;;OAEG;gBAEmB,OAAO,EAAE,qBAAqB,EACnB,qBAAqB,EAAE,qBAAqB;IAO9D,WAAW;IA4C1B,gBAAgB,WAAY,GAAG,UAI7B;IAEO,aAAa,aAepB;IAEO,YAAY;IAIrB;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACM,OAAO,IAAI,IAAI;IAQxB,SAAS,CAAC,YAAY,QAAO,IAAI,CAE/B;IAEF;;OAEG;IACH,SAAS,CAAC,QAAQ,IAAI,IAAI;IAM1B,QAAQ,CAAC,SAAS,EAAE,MAAM;IAI1B,WAAW,CAAC,SAAS,EAAE,MAAM;IAO7B;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAqBtC;;OAEG;IACH,SAAS,CAAC,aAAa,UAAW,SAAS,KAAG,IAAI,CAWhD;IAEF;;OAEG;IACH,SAAS,CAAC,aAAa,UAAW,SAAS,KAAG,IAAI,CAWhD;IAEF;;OAEG;IACH,SAAS,CAAC,YAAY,UAAW,SAAS,KAAG,IAAI,CAa/C;IAEF;;OAEG;IACH,SAAS,CAAC,QAAQ,UAAW,SAAS,KAAG,IAAI,CA+B3C;CACH;AAED;;GAEG;AACH;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa;IACjF;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAE5B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAEvC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|