@difizen/libro-jupyter 0.1.16 → 0.1.17
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/config/config-contribution.d.ts.map +1 -1
- package/es/config/config-contribution.js +1 -1
- package/es/config/config.d.ts +4 -0
- package/es/config/config.d.ts.map +1 -1
- package/es/config/config.js +25 -3
- package/es/file/file-command.d.ts +9 -1
- package/es/file/file-command.d.ts.map +1 -1
- package/es/file/file-command.js +68 -14
- package/package.json +16 -16
- package/src/config/config-contribution.ts +6 -1
- package/src/config/config.ts +26 -2
- package/src/file/file-command.tsx +66 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-contribution.d.ts","sourceRoot":"","sources":["../../src/config/config-contribution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,qBACa,+BAAgC,YAAW,yBAAyB;IAC/E,sBAAsB;
|
|
1
|
+
{"version":3,"file":"config-contribution.d.ts","sourceRoot":"","sources":["../../src/config/config-contribution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,qBACa,+BAAgC,YAAW,yBAAyB;IAC/E,sBAAsB;CAQvB;AACD,qBACa,qBAAsB,YAAW,uBAAuB;IACrC,oBAAoB,EAAE,oBAAoB,CAAC;IACzE,WAAW;CAIZ"}
|
|
@@ -22,7 +22,7 @@ export var LibroJupyterSettingContribution = (_dec = singleton({
|
|
|
22
22
|
_createClass(LibroJupyterSettingContribution, [{
|
|
23
23
|
key: "registerConfigurations",
|
|
24
24
|
value: function registerConfigurations() {
|
|
25
|
-
return [LibroJupyterConfiguration.AutoSave, LibroJupyterConfiguration.OpenSlot];
|
|
25
|
+
return [LibroJupyterConfiguration.AutoSave, LibroJupyterConfiguration.OpenSlot, LibroJupyterConfiguration.AllowDownload, LibroJupyterConfiguration.AllowUpload];
|
|
26
26
|
}
|
|
27
27
|
}]);
|
|
28
28
|
return LibroJupyterSettingContribution;
|
package/es/config/config.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ConfigurationNode } from '@difizen/mana-app';
|
|
2
2
|
export declare const LibroConfigAutoSave: ConfigurationNode<boolean>;
|
|
3
3
|
export declare const LibroConfigOpenSlot: ConfigurationNode<string>;
|
|
4
|
+
export declare const LibroConfigAllowDownload: ConfigurationNode<boolean>;
|
|
5
|
+
export declare const LibroConfigAllowUpload: ConfigurationNode<boolean>;
|
|
4
6
|
export declare const LibroJupyterConfiguration: {
|
|
5
7
|
AutoSave: ConfigurationNode<boolean>;
|
|
6
8
|
OpenSlot: ConfigurationNode<string>;
|
|
9
|
+
AllowUpload: ConfigurationNode<boolean>;
|
|
10
|
+
AllowDownload: ConfigurationNode<boolean>;
|
|
7
11
|
};
|
|
8
12
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,OAAO,CAS1D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,MAAM,CASzD,CAAC;AAEF,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,OAAO,CAS1D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,MAAM,CASzD,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,OAAO,CAS/D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,OAAO,CAS7D,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;CAKrC,CAAC"}
|
package/es/config/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import { l10n } from '@difizen/mana-l10n';
|
|
|
2
2
|
export var LibroConfigAutoSave = {
|
|
3
3
|
id: 'libro.autosave',
|
|
4
4
|
description: l10n.t('是否自动保存修改'),
|
|
5
|
-
title: '
|
|
5
|
+
title: '自动保存',
|
|
6
6
|
type: 'checkbox',
|
|
7
7
|
defaultValue: false,
|
|
8
8
|
schema: {
|
|
@@ -13,13 +13,35 @@ export var LibroConfigOpenSlot = {
|
|
|
13
13
|
id: 'libro.jupyter.open.slot',
|
|
14
14
|
description: '文件默认打开位置',
|
|
15
15
|
title: '文件默认打开位置',
|
|
16
|
-
type: '
|
|
16
|
+
type: 'input',
|
|
17
17
|
defaultValue: 'main',
|
|
18
18
|
schema: {
|
|
19
19
|
type: 'string'
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
export var LibroConfigAllowDownload = {
|
|
23
|
+
id: 'libro.jupyter.allow.download',
|
|
24
|
+
description: '是否允许下载',
|
|
25
|
+
title: '允许下载',
|
|
26
|
+
type: 'checkbox',
|
|
27
|
+
defaultValue: true,
|
|
28
|
+
schema: {
|
|
29
|
+
type: 'boolean'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export var LibroConfigAllowUpload = {
|
|
33
|
+
id: 'libro.jupyter.allow.upload',
|
|
34
|
+
description: '是否允许上传',
|
|
35
|
+
title: '允许上传',
|
|
36
|
+
type: 'checkbox',
|
|
37
|
+
defaultValue: true,
|
|
38
|
+
schema: {
|
|
39
|
+
type: 'boolean'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
22
42
|
export var LibroJupyterConfiguration = {
|
|
23
43
|
AutoSave: LibroConfigAutoSave,
|
|
24
|
-
OpenSlot: LibroConfigOpenSlot
|
|
44
|
+
OpenSlot: LibroConfigOpenSlot,
|
|
45
|
+
AllowUpload: LibroConfigAllowUpload,
|
|
46
|
+
AllowDownload: LibroConfigAllowDownload
|
|
25
47
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ContentsManager } from '@difizen/libro-kernel';
|
|
1
2
|
import type { CommandRegistry, MenuPath, MenuRegistry, ToolbarRegistry } from '@difizen/mana-app';
|
|
2
|
-
import { ViewManager } from '@difizen/mana-app';
|
|
3
|
+
import { ViewManager, ConfigurationService } from '@difizen/mana-app';
|
|
3
4
|
import { CommandContribution, FileStatNode, MenuContribution, ModalService, OpenerService, ToolbarContribution } from '@difizen/mana-app';
|
|
4
5
|
import { JupyterFileService } from './file-service.js';
|
|
5
6
|
import { FileView } from './file-view/index.js';
|
|
@@ -49,13 +50,20 @@ export declare const FileCommands: {
|
|
|
49
50
|
id: string;
|
|
50
51
|
label: string;
|
|
51
52
|
};
|
|
53
|
+
DOWNLOAD: {
|
|
54
|
+
id: string;
|
|
55
|
+
label: string;
|
|
56
|
+
};
|
|
52
57
|
};
|
|
53
58
|
export declare const FileTreeContextMenuPath: MenuPath;
|
|
59
|
+
export declare const FileTreeContextMenuGroups: Record<string, MenuPath>;
|
|
54
60
|
export declare class FileCommandContribution implements CommandContribution, MenuContribution, ToolbarContribution {
|
|
55
61
|
protected viewManager: ViewManager;
|
|
56
62
|
fileService: JupyterFileService;
|
|
57
63
|
modalService: ModalService;
|
|
58
64
|
protected openService: OpenerService;
|
|
65
|
+
configurationService: ConfigurationService;
|
|
66
|
+
contentsManager: ContentsManager;
|
|
59
67
|
fileView: FileView;
|
|
60
68
|
lastAction: 'COPY' | 'CUT';
|
|
61
69
|
lastActionNode: FileStatNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-command.d.ts","sourceRoot":"","sources":["../../src/file/file-command.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-command.d.ts","sourceRoot":"","sources":["../../src/file/file-command.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,mBAAmB,EACnB,YAAY,EAEZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EAEb,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDxB,CAAC;AACF,eAAO,MAAM,uBAAuB,EAAE,QAAqC,CAAC;AAC5E,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAK9D,CAAC;AAEF,qBAGa,uBACX,YAAW,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB;IAErE,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACP,WAAW,EAAE,kBAAkB,CAAC;IACtC,YAAY,EAAE,YAAY,CAAC;IAC1B,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC;IAC9B,oBAAoB,EAAE,oBAAoB,CAAC;IAChD,eAAe,EAAE,eAAe,CAAC;IAE1D,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,cAAc,EAAE,YAAY,CAAC;gBAEI,WAAW,EAAE,WAAW;IAazD,aAAa,CAAC,IAAI,EAAE,YAAY;IA8DhC,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAmMhD,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;CAQ7D"}
|
package/es/file/file-command.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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 _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
|
|
3
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
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
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); }); }; }
|
|
@@ -16,9 +16,11 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
|
|
|
16
16
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
17
17
|
import pathUtil from 'path';
|
|
18
18
|
import { ReloadOutlined } from '@ant-design/icons';
|
|
19
|
-
import {
|
|
19
|
+
import { ContentsManager } from '@difizen/libro-kernel';
|
|
20
|
+
import { ViewManager, ConfigurationService } from '@difizen/mana-app';
|
|
20
21
|
import { CommandContribution, FileStatNode, inject, MenuContribution, ModalService, OpenerService, singleton, ToolbarContribution, URI } from '@difizen/mana-app';
|
|
21
22
|
import { message, Modal } from 'antd';
|
|
23
|
+
import { LibroConfigAllowDownload } from "../config/index.js";
|
|
22
24
|
import { FileCreateModal } from "./file-create-modal.js";
|
|
23
25
|
import { FileDirCreateModal } from "./file-createdir-modal.js";
|
|
24
26
|
import { FileRenameModal } from "./file-rename-modal.js";
|
|
@@ -71,12 +73,22 @@ export var FileCommands = {
|
|
|
71
73
|
REMOVE: {
|
|
72
74
|
id: 'fileTree.command.remove',
|
|
73
75
|
label: '删除'
|
|
76
|
+
},
|
|
77
|
+
DOWNLOAD: {
|
|
78
|
+
id: 'fileTree.command.download',
|
|
79
|
+
label: '下载'
|
|
74
80
|
}
|
|
75
81
|
};
|
|
76
82
|
export var FileTreeContextMenuPath = ['file-tree-context-menu'];
|
|
83
|
+
export var FileTreeContextMenuGroups = {
|
|
84
|
+
new: [].concat(FileTreeContextMenuPath, ['a_new']),
|
|
85
|
+
operator: [].concat(FileTreeContextMenuPath, ['b_operator']),
|
|
86
|
+
change: [].concat(FileTreeContextMenuPath, ['c_change']),
|
|
87
|
+
extra: [].concat(FileTreeContextMenuPath, ['d_extra'])
|
|
88
|
+
};
|
|
77
89
|
export var FileCommandContribution = (_dec = singleton({
|
|
78
90
|
contrib: [CommandContribution, MenuContribution, ToolbarContribution]
|
|
79
|
-
}), _dec2 = inject(JupyterFileService), _dec3 = inject(ModalService), _dec4 = inject(OpenerService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
91
|
+
}), _dec2 = inject(JupyterFileService), _dec3 = inject(ModalService), _dec4 = inject(OpenerService), _dec5 = inject(ConfigurationService), _dec6 = inject(ContentsManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
80
92
|
function FileCommandContribution(viewManager) {
|
|
81
93
|
var _this = this;
|
|
82
94
|
_classCallCheck(this, FileCommandContribution);
|
|
@@ -84,6 +96,8 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
84
96
|
_initializerDefineProperty(this, "fileService", _descriptor, this);
|
|
85
97
|
_initializerDefineProperty(this, "modalService", _descriptor2, this);
|
|
86
98
|
_initializerDefineProperty(this, "openService", _descriptor3, this);
|
|
99
|
+
_initializerDefineProperty(this, "configurationService", _descriptor4, this);
|
|
100
|
+
_initializerDefineProperty(this, "contentsManager", _descriptor5, this);
|
|
87
101
|
this.fileView = void 0;
|
|
88
102
|
this.lastAction = void 0;
|
|
89
103
|
this.lastActionNode = void 0;
|
|
@@ -99,55 +113,64 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
99
113
|
_createClass(FileCommandContribution, [{
|
|
100
114
|
key: "registerMenus",
|
|
101
115
|
value: function registerMenus(menu) {
|
|
102
|
-
menu.
|
|
116
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['new']);
|
|
117
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['operator']);
|
|
118
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['change']);
|
|
119
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['extra']);
|
|
120
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
103
121
|
id: FileCommands.CREATE_FILE.id,
|
|
104
122
|
command: FileCommands.CREATE_FILE.id,
|
|
105
123
|
order: 'a'
|
|
106
124
|
});
|
|
107
|
-
menu.registerMenuAction(
|
|
125
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
108
126
|
id: FileCommands.CREATE_DIR.id,
|
|
109
127
|
command: FileCommands.CREATE_DIR.id,
|
|
110
128
|
order: 'a'
|
|
111
129
|
});
|
|
112
|
-
menu.registerMenuAction(
|
|
130
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
113
131
|
id: FileCommands.OPEN_FILE.id,
|
|
114
132
|
command: FileCommands.OPEN_FILE.id,
|
|
115
133
|
order: 'a'
|
|
116
134
|
});
|
|
117
|
-
menu.registerMenuAction(
|
|
135
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['operator'], {
|
|
118
136
|
id: FileCommands.COPY.id,
|
|
119
137
|
command: FileCommands.COPY.id,
|
|
120
138
|
order: 'b'
|
|
121
139
|
});
|
|
122
|
-
menu.registerMenuAction(
|
|
140
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['operator'], {
|
|
123
141
|
id: FileCommands.PASTE.id,
|
|
124
142
|
command: FileCommands.PASTE.id,
|
|
125
143
|
order: 'c'
|
|
126
144
|
});
|
|
127
|
-
menu.registerMenuAction(
|
|
145
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['operator'], {
|
|
128
146
|
id: FileCommands.CUT.id,
|
|
129
147
|
command: FileCommands.CUT.id,
|
|
130
148
|
order: 'd'
|
|
131
149
|
});
|
|
132
|
-
menu.registerMenuAction(
|
|
150
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['change'], _objectSpread({
|
|
133
151
|
command: FileCommands.REMOVE.id,
|
|
134
152
|
order: 'd'
|
|
135
153
|
}, FileCommands.REMOVE));
|
|
136
|
-
menu.registerMenuAction(
|
|
154
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['change'], {
|
|
137
155
|
id: FileCommands.RENAME.id,
|
|
138
156
|
command: FileCommands.RENAME.id,
|
|
139
157
|
order: 'e'
|
|
140
158
|
});
|
|
141
|
-
menu.registerMenuAction(
|
|
159
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
142
160
|
id: FileCommands.COPY_PATH.id,
|
|
143
161
|
command: FileCommands.COPY_PATH.id,
|
|
144
|
-
order: '
|
|
162
|
+
order: 'f'
|
|
145
163
|
});
|
|
146
|
-
menu.registerMenuAction(
|
|
164
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
147
165
|
id: FileCommands.COPY_RELATIVE_PATH.id,
|
|
148
166
|
command: FileCommands.COPY_RELATIVE_PATH.id,
|
|
149
167
|
order: 'g'
|
|
150
168
|
});
|
|
169
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
170
|
+
id: FileCommands.DOWNLOAD.id,
|
|
171
|
+
command: FileCommands.DOWNLOAD.id,
|
|
172
|
+
order: 'h'
|
|
173
|
+
});
|
|
151
174
|
}
|
|
152
175
|
}, {
|
|
153
176
|
key: "registerCommands",
|
|
@@ -450,6 +473,27 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
450
473
|
return view instanceof FileView;
|
|
451
474
|
}
|
|
452
475
|
});
|
|
476
|
+
command.registerCommand(FileCommands.DOWNLOAD, {
|
|
477
|
+
execute: function execute(data) {
|
|
478
|
+
if (!FileStatNode.is(data)) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
var path = data.uri.path.toString();
|
|
482
|
+
_this2.contentsManager.getDownloadUrl(path).then(function (url) {
|
|
483
|
+
var element = document.createElement('a');
|
|
484
|
+
element.href = url;
|
|
485
|
+
element.download = '';
|
|
486
|
+
element.target = '_blank';
|
|
487
|
+
document.body.appendChild(element);
|
|
488
|
+
element.click();
|
|
489
|
+
document.body.removeChild(element);
|
|
490
|
+
return;
|
|
491
|
+
}).catch(console.error);
|
|
492
|
+
},
|
|
493
|
+
isVisible: function isVisible(data) {
|
|
494
|
+
return !!_this2.configurationService.get(LibroConfigAllowDownload) && FileStatNode.is(data);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
453
497
|
}
|
|
454
498
|
}, {
|
|
455
499
|
key: "registerToolbarItems",
|
|
@@ -478,4 +522,14 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
478
522
|
enumerable: true,
|
|
479
523
|
writable: true,
|
|
480
524
|
initializer: null
|
|
525
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec5], {
|
|
526
|
+
configurable: true,
|
|
527
|
+
enumerable: true,
|
|
528
|
+
writable: true,
|
|
529
|
+
initializer: null
|
|
530
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "contentsManager", [_dec6], {
|
|
531
|
+
configurable: true,
|
|
532
|
+
enumerable: true,
|
|
533
|
+
writable: true,
|
|
534
|
+
initializer: null
|
|
481
535
|
})), _class2)) || _class);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-jupyter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro"
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@difizen/libro-cofine-editor": "^0.1.
|
|
35
|
-
"@difizen/libro-code-editor": "^0.1.
|
|
36
|
-
"@difizen/libro-code-cell": "^0.1.
|
|
37
|
-
"@difizen/libro-codemirror": "^0.1.
|
|
38
|
-
"@difizen/libro-rendermime": "^0.1.
|
|
39
|
-
"@difizen/libro-common": "^0.1.
|
|
40
|
-
"@difizen/libro-core": "^0.1.
|
|
41
|
-
"@difizen/libro-kernel": "^0.1.
|
|
42
|
-
"@difizen/libro-l10n": "^0.1.
|
|
43
|
-
"@difizen/libro-output": "^0.1.
|
|
44
|
-
"@difizen/libro-search": "^0.1.
|
|
45
|
-
"@difizen/libro-search-code-cell": "^0.1.
|
|
46
|
-
"@difizen/libro-lsp": "^0.1.
|
|
47
|
-
"@difizen/libro-markdown-cell": "^0.1.
|
|
48
|
-
"@difizen/libro-raw-cell": "^0.1.
|
|
34
|
+
"@difizen/libro-cofine-editor": "^0.1.17",
|
|
35
|
+
"@difizen/libro-code-editor": "^0.1.17",
|
|
36
|
+
"@difizen/libro-code-cell": "^0.1.17",
|
|
37
|
+
"@difizen/libro-codemirror": "^0.1.17",
|
|
38
|
+
"@difizen/libro-rendermime": "^0.1.17",
|
|
39
|
+
"@difizen/libro-common": "^0.1.17",
|
|
40
|
+
"@difizen/libro-core": "^0.1.17",
|
|
41
|
+
"@difizen/libro-kernel": "^0.1.17",
|
|
42
|
+
"@difizen/libro-l10n": "^0.1.17",
|
|
43
|
+
"@difizen/libro-output": "^0.1.17",
|
|
44
|
+
"@difizen/libro-search": "^0.1.17",
|
|
45
|
+
"@difizen/libro-search-code-cell": "^0.1.17",
|
|
46
|
+
"@difizen/libro-lsp": "^0.1.17",
|
|
47
|
+
"@difizen/libro-markdown-cell": "^0.1.17",
|
|
48
|
+
"@difizen/libro-raw-cell": "^0.1.17",
|
|
49
49
|
"@difizen/mana-app": "latest",
|
|
50
50
|
"@difizen/mana-l10n": "latest",
|
|
51
51
|
"@ant-design/colors": "^7.0.0",
|
|
@@ -8,7 +8,12 @@ import { LibroJupyterConfiguration } from './config.js';
|
|
|
8
8
|
@singleton({ contrib: ConfigurationContribution })
|
|
9
9
|
export class LibroJupyterSettingContribution implements ConfigurationContribution {
|
|
10
10
|
registerConfigurations() {
|
|
11
|
-
return [
|
|
11
|
+
return [
|
|
12
|
+
LibroJupyterConfiguration.AutoSave,
|
|
13
|
+
LibroJupyterConfiguration.OpenSlot,
|
|
14
|
+
LibroJupyterConfiguration.AllowDownload,
|
|
15
|
+
LibroJupyterConfiguration.AllowUpload,
|
|
16
|
+
];
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
@singleton({ contrib: ApplicationContribution })
|
package/src/config/config.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { l10n } from '@difizen/mana-l10n';
|
|
|
4
4
|
export const LibroConfigAutoSave: ConfigurationNode<boolean> = {
|
|
5
5
|
id: 'libro.autosave',
|
|
6
6
|
description: l10n.t('是否自动保存修改'),
|
|
7
|
-
title: '
|
|
7
|
+
title: '自动保存',
|
|
8
8
|
type: 'checkbox',
|
|
9
9
|
defaultValue: false,
|
|
10
10
|
schema: {
|
|
@@ -16,14 +16,38 @@ export const LibroConfigOpenSlot: ConfigurationNode<string> = {
|
|
|
16
16
|
id: 'libro.jupyter.open.slot',
|
|
17
17
|
description: '文件默认打开位置',
|
|
18
18
|
title: '文件默认打开位置',
|
|
19
|
-
type: '
|
|
19
|
+
type: 'input',
|
|
20
20
|
defaultValue: 'main',
|
|
21
21
|
schema: {
|
|
22
22
|
type: 'string',
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
export const LibroConfigAllowDownload: ConfigurationNode<boolean> = {
|
|
27
|
+
id: 'libro.jupyter.allow.download',
|
|
28
|
+
description: '是否允许下载',
|
|
29
|
+
title: '允许下载',
|
|
30
|
+
type: 'checkbox',
|
|
31
|
+
defaultValue: true,
|
|
32
|
+
schema: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const LibroConfigAllowUpload: ConfigurationNode<boolean> = {
|
|
38
|
+
id: 'libro.jupyter.allow.upload',
|
|
39
|
+
description: '是否允许上传',
|
|
40
|
+
title: '允许上传',
|
|
41
|
+
type: 'checkbox',
|
|
42
|
+
defaultValue: true,
|
|
43
|
+
schema: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
26
48
|
export const LibroJupyterConfiguration = {
|
|
27
49
|
AutoSave: LibroConfigAutoSave,
|
|
28
50
|
OpenSlot: LibroConfigOpenSlot,
|
|
51
|
+
AllowUpload: LibroConfigAllowUpload,
|
|
52
|
+
AllowDownload: LibroConfigAllowDownload,
|
|
29
53
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import pathUtil from 'path';
|
|
2
2
|
|
|
3
3
|
import { ReloadOutlined } from '@ant-design/icons';
|
|
4
|
+
import { ContentsManager } from '@difizen/libro-kernel';
|
|
4
5
|
import type {
|
|
5
6
|
CommandRegistry,
|
|
6
7
|
MenuPath,
|
|
7
8
|
MenuRegistry,
|
|
8
9
|
ToolbarRegistry,
|
|
9
10
|
} from '@difizen/mana-app';
|
|
10
|
-
import { ViewManager } from '@difizen/mana-app';
|
|
11
|
+
import { ViewManager, ConfigurationService } from '@difizen/mana-app';
|
|
11
12
|
import {
|
|
12
13
|
CommandContribution,
|
|
13
14
|
FileStatNode,
|
|
@@ -21,6 +22,8 @@ import {
|
|
|
21
22
|
} from '@difizen/mana-app';
|
|
22
23
|
import { message, Modal } from 'antd';
|
|
23
24
|
|
|
25
|
+
import { LibroConfigAllowDownload } from '../config/index.js';
|
|
26
|
+
|
|
24
27
|
import { FileCreateModal } from './file-create-modal.js';
|
|
25
28
|
import { FileDirCreateModal } from './file-createdir-modal.js';
|
|
26
29
|
import { FileRenameModal } from './file-rename-modal.js';
|
|
@@ -74,8 +77,18 @@ export const FileCommands = {
|
|
|
74
77
|
id: 'fileTree.command.remove',
|
|
75
78
|
label: '删除',
|
|
76
79
|
},
|
|
80
|
+
DOWNLOAD: {
|
|
81
|
+
id: 'fileTree.command.download',
|
|
82
|
+
label: '下载',
|
|
83
|
+
},
|
|
77
84
|
};
|
|
78
85
|
export const FileTreeContextMenuPath: MenuPath = ['file-tree-context-menu'];
|
|
86
|
+
export const FileTreeContextMenuGroups: Record<string, MenuPath> = {
|
|
87
|
+
new: [...FileTreeContextMenuPath, 'a_new'],
|
|
88
|
+
operator: [...FileTreeContextMenuPath, 'b_operator'],
|
|
89
|
+
change: [...FileTreeContextMenuPath, 'c_change'],
|
|
90
|
+
extra: [...FileTreeContextMenuPath, 'd_extra'],
|
|
91
|
+
};
|
|
79
92
|
|
|
80
93
|
@singleton({
|
|
81
94
|
contrib: [CommandContribution, MenuContribution, ToolbarContribution],
|
|
@@ -87,6 +100,9 @@ export class FileCommandContribution
|
|
|
87
100
|
@inject(JupyterFileService) fileService: JupyterFileService;
|
|
88
101
|
@inject(ModalService) modalService: ModalService;
|
|
89
102
|
@inject(OpenerService) protected openService: OpenerService;
|
|
103
|
+
@inject(ConfigurationService) configurationService: ConfigurationService;
|
|
104
|
+
@inject(ContentsManager) contentsManager: ContentsManager;
|
|
105
|
+
|
|
90
106
|
fileView: FileView;
|
|
91
107
|
lastAction: 'COPY' | 'CUT';
|
|
92
108
|
lastActionNode: FileStatNode;
|
|
@@ -105,56 +121,66 @@ export class FileCommandContribution
|
|
|
105
121
|
}
|
|
106
122
|
|
|
107
123
|
registerMenus(menu: MenuRegistry) {
|
|
108
|
-
menu.
|
|
124
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['new']);
|
|
125
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['operator']);
|
|
126
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['change']);
|
|
127
|
+
menu.registerGroupMenu(FileTreeContextMenuGroups['extra']);
|
|
128
|
+
|
|
129
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
109
130
|
id: FileCommands.CREATE_FILE.id,
|
|
110
131
|
command: FileCommands.CREATE_FILE.id,
|
|
111
132
|
order: 'a',
|
|
112
133
|
});
|
|
113
|
-
menu.registerMenuAction(
|
|
134
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
114
135
|
id: FileCommands.CREATE_DIR.id,
|
|
115
136
|
command: FileCommands.CREATE_DIR.id,
|
|
116
137
|
order: 'a',
|
|
117
138
|
});
|
|
118
|
-
menu.registerMenuAction(
|
|
139
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
119
140
|
id: FileCommands.OPEN_FILE.id,
|
|
120
141
|
command: FileCommands.OPEN_FILE.id,
|
|
121
142
|
order: 'a',
|
|
122
143
|
});
|
|
123
|
-
menu.registerMenuAction(
|
|
144
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['operator'], {
|
|
124
145
|
id: FileCommands.COPY.id,
|
|
125
146
|
command: FileCommands.COPY.id,
|
|
126
147
|
order: 'b',
|
|
127
148
|
});
|
|
128
|
-
menu.registerMenuAction(
|
|
149
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['operator'], {
|
|
129
150
|
id: FileCommands.PASTE.id,
|
|
130
151
|
command: FileCommands.PASTE.id,
|
|
131
152
|
order: 'c',
|
|
132
153
|
});
|
|
133
|
-
menu.registerMenuAction(
|
|
154
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['operator'], {
|
|
134
155
|
id: FileCommands.CUT.id,
|
|
135
156
|
command: FileCommands.CUT.id,
|
|
136
157
|
order: 'd',
|
|
137
158
|
});
|
|
138
|
-
menu.registerMenuAction(
|
|
159
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['change'], {
|
|
139
160
|
command: FileCommands.REMOVE.id,
|
|
140
161
|
order: 'd',
|
|
141
162
|
...FileCommands.REMOVE,
|
|
142
163
|
});
|
|
143
|
-
menu.registerMenuAction(
|
|
164
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['change'], {
|
|
144
165
|
id: FileCommands.RENAME.id,
|
|
145
166
|
command: FileCommands.RENAME.id,
|
|
146
167
|
order: 'e',
|
|
147
168
|
});
|
|
148
|
-
menu.registerMenuAction(
|
|
169
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
149
170
|
id: FileCommands.COPY_PATH.id,
|
|
150
171
|
command: FileCommands.COPY_PATH.id,
|
|
151
|
-
order: '
|
|
172
|
+
order: 'f',
|
|
152
173
|
});
|
|
153
|
-
menu.registerMenuAction(
|
|
174
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
154
175
|
id: FileCommands.COPY_RELATIVE_PATH.id,
|
|
155
176
|
command: FileCommands.COPY_RELATIVE_PATH.id,
|
|
156
177
|
order: 'g',
|
|
157
178
|
});
|
|
179
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
180
|
+
id: FileCommands.DOWNLOAD.id,
|
|
181
|
+
command: FileCommands.DOWNLOAD.id,
|
|
182
|
+
order: 'h',
|
|
183
|
+
});
|
|
158
184
|
}
|
|
159
185
|
registerCommands(command: CommandRegistry): void {
|
|
160
186
|
command.registerCommand(FileCommands.OPEN_FILE, {
|
|
@@ -321,6 +347,34 @@ export class FileCommandContribution
|
|
|
321
347
|
return view instanceof FileView;
|
|
322
348
|
},
|
|
323
349
|
});
|
|
350
|
+
|
|
351
|
+
command.registerCommand(FileCommands.DOWNLOAD, {
|
|
352
|
+
execute: (data) => {
|
|
353
|
+
if (!FileStatNode.is(data)) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const path = data.uri.path.toString();
|
|
357
|
+
this.contentsManager
|
|
358
|
+
.getDownloadUrl(path)
|
|
359
|
+
.then((url) => {
|
|
360
|
+
const element = document.createElement('a');
|
|
361
|
+
element.href = url;
|
|
362
|
+
element.download = '';
|
|
363
|
+
element.target = '_blank';
|
|
364
|
+
document.body.appendChild(element);
|
|
365
|
+
element.click();
|
|
366
|
+
document.body.removeChild(element);
|
|
367
|
+
return;
|
|
368
|
+
})
|
|
369
|
+
.catch(console.error);
|
|
370
|
+
},
|
|
371
|
+
isVisible: (data) => {
|
|
372
|
+
return (
|
|
373
|
+
!!this.configurationService.get(LibroConfigAllowDownload) &&
|
|
374
|
+
FileStatNode.is(data)
|
|
375
|
+
);
|
|
376
|
+
},
|
|
377
|
+
});
|
|
324
378
|
}
|
|
325
379
|
|
|
326
380
|
registerToolbarItems(toolbarRegistry: ToolbarRegistry): void {
|