@difizen/libro-jupyter 0.0.2-alpha.0 → 0.1.0
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/add-between-cell/add-between-cell-command-contribution.js +2 -2
- package/es/add-between-cell/add-between-cell.js +5 -5
- package/es/cell/jupyter-code-cell-model.js +1 -1
- package/es/cell/jupyter-code-cell-view.js +6 -6
- package/es/command/command-contribution.js +2 -2
- package/es/command/keybinding-contribution.js +1 -1
- package/es/config/config-contribution.js +1 -1
- package/es/configuration/libro-configuration-contribution.js +1 -1
- package/es/contents/content-contribution.js +2 -2
- package/es/file/file-command.d.ts +20 -0
- package/es/file/file-command.d.ts.map +1 -0
- package/es/file/file-command.js +461 -0
- package/es/file/file-create-modal-contribution.d.ts +5 -0
- package/es/file/file-create-modal-contribution.d.ts.map +1 -0
- package/es/file/file-create-modal-contribution.js +23 -0
- package/es/file/file-create-modal.d.ts +8 -0
- package/es/file/file-create-modal.d.ts.map +1 -0
- package/es/file/file-create-modal.js +101 -0
- package/es/file/file-createdir-modal-contribution.d.ts +5 -0
- package/es/file/file-createdir-modal-contribution.d.ts.map +1 -0
- package/es/file/file-createdir-modal-contribution.js +23 -0
- package/es/file/file-createdir-modal.d.ts +8 -0
- package/es/file/file-createdir-modal.d.ts.map +1 -0
- package/es/file/file-createdir-modal.js +105 -0
- package/es/file/file-name-alias.js +1 -1
- package/es/file/file-protocol.js +7 -1
- package/es/file/file-rename-modal-contribution.d.ts +5 -0
- package/es/file/file-rename-modal-contribution.d.ts.map +1 -0
- package/es/file/file-rename-modal-contribution.js +23 -0
- package/es/file/file-rename-modal.d.ts +9 -0
- package/es/file/file-rename-modal.d.ts.map +1 -0
- package/es/file/file-rename-modal.js +75 -0
- package/es/file/file-service.d.ts +7 -3
- package/es/file/file-service.d.ts.map +1 -1
- package/es/file/file-service.js +155 -40
- package/es/file/file-tree-label-provider.js +1 -1
- package/es/file/file-view/index.d.ts +1 -1
- package/es/file/file-view/index.d.ts.map +1 -1
- package/es/file/file-view/index.js +7 -2
- package/es/file/module.d.ts.map +1 -1
- package/es/file/module.js +5 -1
- package/es/file/navigatable-view.d.ts +5 -1
- package/es/file/navigatable-view.d.ts.map +1 -1
- package/es/file/navigatable-view.js +33 -11
- package/es/file/open-handler-contribution.js +4 -4
- package/es/file/utils.js +43 -0
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +1 -0
- package/es/keybind-instructions/keybind-instructions-contribution.js +2 -2
- package/es/keybind-instructions/keybind-instructions-items.js +1 -1
- package/es/keybind-instructions/keybind-instructions-view.js +2 -2
- package/es/libro-jupyter-file-service.js +3 -3
- package/es/libro-jupyter-model.js +2 -2
- package/es/libro-jupyter-protocol.d.ts +0 -4
- package/es/libro-jupyter-protocol.d.ts.map +1 -1
- package/es/libro-jupyter-protocol.js +1 -2
- package/es/libro-jupyter-server-launch-manager.d.ts +1 -3
- package/es/libro-jupyter-server-launch-manager.d.ts.map +1 -1
- package/es/libro-jupyter-server-launch-manager.js +4 -11
- package/es/libro-jupyter-view.js +1 -1
- package/es/output/libro-jupyter-outputarea.js +3 -3
- package/es/rendermime/index.less +1 -10
- package/es/rendermime/plotly-renderers.js +4 -4
- package/es/rendermime/plotly-rendermime-contribution.js +1 -1
- package/es/theme/color-registry.js +1 -1
- package/es/toolbar/kernel-selector-dropdown.js +3 -3
- package/es/toolbar/save-file-error-contribution.js +1 -1
- package/es/toolbar/toolbar-contribution.js +1 -1
- package/package.json +16 -16
- package/src/file/file-command.tsx +320 -0
- package/src/file/file-create-modal-contribution.ts +10 -0
- package/src/file/file-create-modal.tsx +73 -0
- package/src/file/file-createdir-modal-contribution.ts +10 -0
- package/src/file/file-createdir-modal.tsx +76 -0
- package/src/file/file-protocol.ts +17 -0
- package/src/file/file-rename-modal-contribution.ts +10 -0
- package/src/file/file-rename-modal.tsx +64 -0
- package/src/file/file-service.ts +69 -33
- package/src/file/file-view/index.tsx +4 -1
- package/src/file/module.ts +8 -0
- package/src/file/navigatable-view.tsx +20 -1
- package/src/file/utils.ts +51 -0
- package/src/index.spec.ts +11 -0
- package/src/index.ts +1 -0
- package/src/libro-jupyter-protocol.ts +0 -5
- package/src/libro-jupyter-server-launch-manager.ts +2 -11
- package/es/components/icons.d.ts +0 -5
- package/es/components/icons.d.ts.map +0 -1
- package/es/config/config.d.ts +0 -3
- package/es/config/config.d.ts.map +0 -1
- package/es/configuration/index.d.ts +0 -3
- package/es/configuration/index.d.ts.map +0 -1
- package/es/configuration/libro-configuration-contribution.d.ts +0 -5
- package/es/configuration/libro-configuration-contribution.d.ts.map +0 -1
- package/es/configuration/libro-configuration.d.ts +0 -3
- package/es/configuration/libro-configuration.d.ts.map +0 -1
- package/es/file/file-name-alias.d.ts +0 -7
- package/es/file/file-name-alias.d.ts.map +0 -1
- package/es/file/file-protocol.d.ts +0 -8
- package/es/file/file-protocol.d.ts.map +0 -1
- package/es/file/file-tree-label-provider.d.ts +0 -13
- package/es/file/file-tree-label-provider.d.ts.map +0 -1
- package/es/keybind-instructions/keybind-instructions-items.d.ts +0 -14
- package/es/keybind-instructions/keybind-instructions-items.d.ts.map +0 -1
- package/es/theme/color-registry.d.ts +0 -6
- package/es/theme/color-registry.d.ts.map +0 -1
- package/es/theme/index.d.ts +0 -2
- package/es/theme/index.d.ts.map +0 -1
|
@@ -0,0 +1,461 @@
|
|
|
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;
|
|
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 _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
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); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); }
|
|
12
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
|
+
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.'); }
|
|
14
|
+
import pathUtil from 'path';
|
|
15
|
+
import { ReloadOutlined } from '@ant-design/icons';
|
|
16
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
17
|
+
import { CommandContribution, FileStatNode, FileTreeCommand, inject, MenuContribution, ModalService, OpenerService, singleton, ToolbarContribution, URI } from '@difizen/mana-app';
|
|
18
|
+
import { message, Modal } from 'antd';
|
|
19
|
+
import { FileCreateModal } from "./file-create-modal.js";
|
|
20
|
+
import { FileDirCreateModal } from "./file-createdir-modal.js";
|
|
21
|
+
import { FileRenameModal } from "./file-rename-modal.js";
|
|
22
|
+
import { JupyterFileService } from "./file-service.js";
|
|
23
|
+
import { FileView } from "./file-view/index.js";
|
|
24
|
+
import { copy2clipboard } from "./utils.js";
|
|
25
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
+
var FileCommands = {
|
|
27
|
+
OPEN_FILE: {
|
|
28
|
+
id: 'fileTree.command.openfile',
|
|
29
|
+
label: '打开'
|
|
30
|
+
},
|
|
31
|
+
COPY: {
|
|
32
|
+
id: 'fileTree.command.copy',
|
|
33
|
+
label: '复制'
|
|
34
|
+
},
|
|
35
|
+
PASTE: {
|
|
36
|
+
id: 'fileTree.command.paste',
|
|
37
|
+
label: '粘贴'
|
|
38
|
+
},
|
|
39
|
+
CUT: {
|
|
40
|
+
id: 'fileTree.command.cut',
|
|
41
|
+
label: '剪切'
|
|
42
|
+
},
|
|
43
|
+
RENAME: {
|
|
44
|
+
id: 'fileTree.command.rename',
|
|
45
|
+
label: '重命名'
|
|
46
|
+
},
|
|
47
|
+
COPY_PATH: {
|
|
48
|
+
id: 'fileTree.command.copyPath',
|
|
49
|
+
label: '复制路径'
|
|
50
|
+
},
|
|
51
|
+
COPY_RELATIVE_PATH: {
|
|
52
|
+
id: 'fileTree.command.copyRelativePath',
|
|
53
|
+
label: '复制相对路径'
|
|
54
|
+
},
|
|
55
|
+
CREATE_FILE: {
|
|
56
|
+
id: 'fileTree.command.createfile',
|
|
57
|
+
label: '新建文件'
|
|
58
|
+
},
|
|
59
|
+
CREATE_DIR: {
|
|
60
|
+
id: 'fileTree.command.createdir',
|
|
61
|
+
label: '新建文件夹'
|
|
62
|
+
},
|
|
63
|
+
REFRESH: {
|
|
64
|
+
id: 'fileTree.command.refresh',
|
|
65
|
+
label: '刷新'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export var FileTreeContextMenuPath = ['file-tree-context-menu'];
|
|
69
|
+
export var FileCommandContribution = (_dec = singleton({
|
|
70
|
+
contrib: [CommandContribution, MenuContribution, ToolbarContribution]
|
|
71
|
+
}), _dec2 = inject(JupyterFileService), _dec3 = inject(ModalService), _dec4 = inject(OpenerService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
72
|
+
function FileCommandContribution(viewManager) {
|
|
73
|
+
var _this = this;
|
|
74
|
+
_classCallCheck(this, FileCommandContribution);
|
|
75
|
+
this.viewManager = void 0;
|
|
76
|
+
_initializerDefineProperty(this, "fileService", _descriptor, this);
|
|
77
|
+
_initializerDefineProperty(this, "modalService", _descriptor2, this);
|
|
78
|
+
_initializerDefineProperty(this, "openService", _descriptor3, this);
|
|
79
|
+
this.fileView = void 0;
|
|
80
|
+
this.lastAction = void 0;
|
|
81
|
+
this.lastActionNode = void 0;
|
|
82
|
+
this.viewManager = viewManager;
|
|
83
|
+
this.viewManager.getOrCreateView(FileView).then(function (view) {
|
|
84
|
+
_this.fileView = view;
|
|
85
|
+
return;
|
|
86
|
+
}).catch(function () {
|
|
87
|
+
//
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
FileCommandContribution = inject(ViewManager)(FileCommandContribution, undefined, 0) || FileCommandContribution;
|
|
91
|
+
_createClass(FileCommandContribution, [{
|
|
92
|
+
key: "registerMenus",
|
|
93
|
+
value: function registerMenus(menu) {
|
|
94
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
95
|
+
id: FileCommands.CREATE_FILE.id,
|
|
96
|
+
command: FileCommands.CREATE_FILE.id,
|
|
97
|
+
order: 'a'
|
|
98
|
+
});
|
|
99
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
100
|
+
id: FileCommands.CREATE_DIR.id,
|
|
101
|
+
command: FileCommands.CREATE_DIR.id,
|
|
102
|
+
order: 'a'
|
|
103
|
+
});
|
|
104
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
105
|
+
id: FileCommands.OPEN_FILE.id,
|
|
106
|
+
command: FileCommands.OPEN_FILE.id,
|
|
107
|
+
order: 'a'
|
|
108
|
+
});
|
|
109
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
110
|
+
id: FileCommands.COPY.id,
|
|
111
|
+
command: FileCommands.COPY.id,
|
|
112
|
+
order: 'b'
|
|
113
|
+
});
|
|
114
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
115
|
+
id: FileCommands.PASTE.id,
|
|
116
|
+
command: FileCommands.PASTE.id,
|
|
117
|
+
order: 'c'
|
|
118
|
+
});
|
|
119
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
120
|
+
id: FileCommands.CUT.id,
|
|
121
|
+
command: FileCommands.CUT.id,
|
|
122
|
+
order: 'd'
|
|
123
|
+
});
|
|
124
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
125
|
+
id: FileCommands.RENAME.id,
|
|
126
|
+
command: FileCommands.RENAME.id,
|
|
127
|
+
order: 'e'
|
|
128
|
+
});
|
|
129
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
130
|
+
id: FileCommands.COPY_PATH.id,
|
|
131
|
+
command: FileCommands.COPY_PATH.id,
|
|
132
|
+
order: 'g'
|
|
133
|
+
});
|
|
134
|
+
menu.registerMenuAction(FileTreeContextMenuPath, {
|
|
135
|
+
id: FileCommands.COPY_RELATIVE_PATH.id,
|
|
136
|
+
command: FileCommands.COPY_RELATIVE_PATH.id,
|
|
137
|
+
order: 'g'
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "registerCommands",
|
|
142
|
+
value: function registerCommands(command) {
|
|
143
|
+
var _this2 = this;
|
|
144
|
+
command.registerCommand(FileCommands.OPEN_FILE, {
|
|
145
|
+
execute: function execute(node) {
|
|
146
|
+
try {
|
|
147
|
+
if (node.fileStat.isFile) {
|
|
148
|
+
_this2.openService.getOpener(node.uri).then(function (opener) {
|
|
149
|
+
if (opener) {
|
|
150
|
+
opener.open(node.uri, {
|
|
151
|
+
viewOptions: {
|
|
152
|
+
name: node.fileStat.name
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}).catch(function () {
|
|
158
|
+
throw Error();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} catch (_unused) {
|
|
162
|
+
message.error('文件打开失败');
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
isVisible: function isVisible(node) {
|
|
166
|
+
return FileStatNode.is(node) && node.fileStat.isFile;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
command.registerHandler(FileTreeCommand.REMOVE.id, {
|
|
170
|
+
execute: function execute(node) {
|
|
171
|
+
if (FileStatNode.is(node)) {
|
|
172
|
+
var filePath = node.uri.path.toString();
|
|
173
|
+
Modal.confirm({
|
|
174
|
+
title: '确认删除一下文件或文件夹?',
|
|
175
|
+
content: filePath,
|
|
176
|
+
onOk: function () {
|
|
177
|
+
var _onOk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
178
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
179
|
+
while (1) switch (_context.prev = _context.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
_context.prev = 0;
|
|
182
|
+
_context.next = 3;
|
|
183
|
+
return _this2.fileService.delete(node.uri);
|
|
184
|
+
case 3:
|
|
185
|
+
_context.next = 8;
|
|
186
|
+
break;
|
|
187
|
+
case 5:
|
|
188
|
+
_context.prev = 5;
|
|
189
|
+
_context.t0 = _context["catch"](0);
|
|
190
|
+
message.error('删除文件失败!');
|
|
191
|
+
case 8:
|
|
192
|
+
_this2.fileView.model.refresh();
|
|
193
|
+
case 9:
|
|
194
|
+
case "end":
|
|
195
|
+
return _context.stop();
|
|
196
|
+
}
|
|
197
|
+
}, _callee, null, [[0, 5]]);
|
|
198
|
+
}));
|
|
199
|
+
function onOk() {
|
|
200
|
+
return _onOk.apply(this, arguments);
|
|
201
|
+
}
|
|
202
|
+
return onOk;
|
|
203
|
+
}()
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
isVisible: function isVisible(node) {
|
|
208
|
+
return FileStatNode.is(node);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
command.registerCommand(FileCommands.COPY, {
|
|
212
|
+
execute: function execute(node) {
|
|
213
|
+
_this2.lastAction = 'COPY';
|
|
214
|
+
_this2.lastActionNode = node;
|
|
215
|
+
},
|
|
216
|
+
isVisible: function isVisible(node) {
|
|
217
|
+
return FileStatNode.is(node) && node.fileStat.isFile;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
command.registerCommand(FileCommands.CUT, {
|
|
221
|
+
execute: function execute(node) {
|
|
222
|
+
_this2.lastAction = 'CUT';
|
|
223
|
+
_this2.lastActionNode = node;
|
|
224
|
+
},
|
|
225
|
+
isVisible: function isVisible(node) {
|
|
226
|
+
return FileStatNode.is(node) && node.fileStat.isFile;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
command.registerCommand(FileCommands.PASTE, {
|
|
230
|
+
execute: function () {
|
|
231
|
+
var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
|
|
232
|
+
var targetUri, targetPath;
|
|
233
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
234
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
_context2.prev = 0;
|
|
237
|
+
if (!FileStatNode.is(data)) {
|
|
238
|
+
_context2.next = 7;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
targetUri = data.fileStat.isDirectory ? data.uri : data.uri.parent;
|
|
242
|
+
_context2.next = 5;
|
|
243
|
+
return _this2.fileService.copy(_this2.lastActionNode.uri, targetUri);
|
|
244
|
+
case 5:
|
|
245
|
+
_context2.next = 11;
|
|
246
|
+
break;
|
|
247
|
+
case 7:
|
|
248
|
+
if (!(data instanceof FileView)) {
|
|
249
|
+
_context2.next = 11;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
targetPath = '/';
|
|
253
|
+
_context2.next = 11;
|
|
254
|
+
return _this2.fileService.copy(_this2.lastActionNode.uri, new URI(targetPath));
|
|
255
|
+
case 11:
|
|
256
|
+
if (!(_this2.lastAction === 'CUT')) {
|
|
257
|
+
_context2.next = 14;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
_context2.next = 14;
|
|
261
|
+
return _this2.fileService.delete(_this2.lastActionNode.uri);
|
|
262
|
+
case 14:
|
|
263
|
+
_this2.fileView.model.refresh();
|
|
264
|
+
return _context2.abrupt("return");
|
|
265
|
+
case 18:
|
|
266
|
+
_context2.prev = 18;
|
|
267
|
+
_context2.t0 = _context2["catch"](0);
|
|
268
|
+
message.error('粘贴失败!');
|
|
269
|
+
case 21:
|
|
270
|
+
case "end":
|
|
271
|
+
return _context2.stop();
|
|
272
|
+
}
|
|
273
|
+
}, _callee2, null, [[0, 18]]);
|
|
274
|
+
}));
|
|
275
|
+
function execute(_x) {
|
|
276
|
+
return _execute.apply(this, arguments);
|
|
277
|
+
}
|
|
278
|
+
return execute;
|
|
279
|
+
}(),
|
|
280
|
+
isVisible: function isVisible() {
|
|
281
|
+
return _this2.lastAction === 'CUT' || _this2.lastAction === 'COPY';
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
command.registerCommand(FileCommands.RENAME, {
|
|
285
|
+
execute: function () {
|
|
286
|
+
var _execute2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(node) {
|
|
287
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
288
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
289
|
+
case 0:
|
|
290
|
+
_this2.modalService.openModal(FileRenameModal, {
|
|
291
|
+
resource: node.uri,
|
|
292
|
+
fileName: node.uri.path.base
|
|
293
|
+
});
|
|
294
|
+
case 1:
|
|
295
|
+
case "end":
|
|
296
|
+
return _context3.stop();
|
|
297
|
+
}
|
|
298
|
+
}, _callee3);
|
|
299
|
+
}));
|
|
300
|
+
function execute(_x2) {
|
|
301
|
+
return _execute2.apply(this, arguments);
|
|
302
|
+
}
|
|
303
|
+
return execute;
|
|
304
|
+
}(),
|
|
305
|
+
isVisible: function isVisible(node) {
|
|
306
|
+
return FileStatNode.is(node);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
command.registerCommand(FileCommands.CREATE_FILE, {
|
|
310
|
+
execute: function () {
|
|
311
|
+
var _execute3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
|
|
312
|
+
var path;
|
|
313
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
314
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
315
|
+
case 0:
|
|
316
|
+
path = '/workspace';
|
|
317
|
+
if (FileStatNode.is(data)) {
|
|
318
|
+
path = data.fileStat.isDirectory ? data.uri.path.toString() : data.uri.path.dir.toString();
|
|
319
|
+
}
|
|
320
|
+
_this2.modalService.openModal(FileCreateModal, {
|
|
321
|
+
path: path
|
|
322
|
+
});
|
|
323
|
+
case 3:
|
|
324
|
+
case "end":
|
|
325
|
+
return _context4.stop();
|
|
326
|
+
}
|
|
327
|
+
}, _callee4);
|
|
328
|
+
}));
|
|
329
|
+
function execute(_x3) {
|
|
330
|
+
return _execute3.apply(this, arguments);
|
|
331
|
+
}
|
|
332
|
+
return execute;
|
|
333
|
+
}()
|
|
334
|
+
});
|
|
335
|
+
command.registerCommand(FileCommands.CREATE_DIR, {
|
|
336
|
+
execute: function () {
|
|
337
|
+
var _execute4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(data) {
|
|
338
|
+
var path;
|
|
339
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
340
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
341
|
+
case 0:
|
|
342
|
+
path = '/workspace';
|
|
343
|
+
if (FileStatNode.is(data)) {
|
|
344
|
+
path = data.fileStat.isDirectory ? data.uri.path.toString() : data.uri.path.dir.toString();
|
|
345
|
+
}
|
|
346
|
+
_this2.modalService.openModal(FileDirCreateModal, {
|
|
347
|
+
path: path
|
|
348
|
+
});
|
|
349
|
+
case 3:
|
|
350
|
+
case "end":
|
|
351
|
+
return _context5.stop();
|
|
352
|
+
}
|
|
353
|
+
}, _callee5);
|
|
354
|
+
}));
|
|
355
|
+
function execute(_x4) {
|
|
356
|
+
return _execute4.apply(this, arguments);
|
|
357
|
+
}
|
|
358
|
+
return execute;
|
|
359
|
+
}()
|
|
360
|
+
});
|
|
361
|
+
command.registerCommand(FileCommands.COPY_PATH, {
|
|
362
|
+
execute: function () {
|
|
363
|
+
var _execute5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) {
|
|
364
|
+
var path;
|
|
365
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
366
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
367
|
+
case 0:
|
|
368
|
+
path = '/workspace';
|
|
369
|
+
if (FileStatNode.is(data)) {
|
|
370
|
+
path = data.uri.path.toString();
|
|
371
|
+
}
|
|
372
|
+
copy2clipboard(path);
|
|
373
|
+
case 3:
|
|
374
|
+
case "end":
|
|
375
|
+
return _context6.stop();
|
|
376
|
+
}
|
|
377
|
+
}, _callee6);
|
|
378
|
+
}));
|
|
379
|
+
function execute(_x5) {
|
|
380
|
+
return _execute5.apply(this, arguments);
|
|
381
|
+
}
|
|
382
|
+
return execute;
|
|
383
|
+
}()
|
|
384
|
+
});
|
|
385
|
+
command.registerCommand(FileCommands.COPY_RELATIVE_PATH, {
|
|
386
|
+
execute: function () {
|
|
387
|
+
var _execute6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(data) {
|
|
388
|
+
var relative;
|
|
389
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
390
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
391
|
+
case 0:
|
|
392
|
+
relative = '';
|
|
393
|
+
if (FileStatNode.is(data)) {
|
|
394
|
+
relative = pathUtil.relative('/workspace', data.uri.path.toString());
|
|
395
|
+
}
|
|
396
|
+
copy2clipboard(relative);
|
|
397
|
+
case 3:
|
|
398
|
+
case "end":
|
|
399
|
+
return _context7.stop();
|
|
400
|
+
}
|
|
401
|
+
}, _callee7);
|
|
402
|
+
}));
|
|
403
|
+
function execute(_x6) {
|
|
404
|
+
return _execute6.apply(this, arguments);
|
|
405
|
+
}
|
|
406
|
+
return execute;
|
|
407
|
+
}()
|
|
408
|
+
});
|
|
409
|
+
command.registerCommand(FileCommands.REFRESH, {
|
|
410
|
+
execute: function () {
|
|
411
|
+
var _execute7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(view) {
|
|
412
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
413
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
414
|
+
case 0:
|
|
415
|
+
if (view instanceof FileView) {
|
|
416
|
+
view.model.refresh();
|
|
417
|
+
}
|
|
418
|
+
case 1:
|
|
419
|
+
case "end":
|
|
420
|
+
return _context8.stop();
|
|
421
|
+
}
|
|
422
|
+
}, _callee8);
|
|
423
|
+
}));
|
|
424
|
+
function execute(_x7) {
|
|
425
|
+
return _execute7.apply(this, arguments);
|
|
426
|
+
}
|
|
427
|
+
return execute;
|
|
428
|
+
}(),
|
|
429
|
+
isVisible: function isVisible(view) {
|
|
430
|
+
return view instanceof FileView;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}, {
|
|
435
|
+
key: "registerToolbarItems",
|
|
436
|
+
value: function registerToolbarItems(toolbarRegistry) {
|
|
437
|
+
toolbarRegistry.registerItem({
|
|
438
|
+
id: FileCommands.REFRESH.id,
|
|
439
|
+
command: FileCommands.REFRESH.id,
|
|
440
|
+
icon: /*#__PURE__*/_jsx(ReloadOutlined, {}),
|
|
441
|
+
tooltip: '刷新'
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}]);
|
|
445
|
+
return FileCommandContribution;
|
|
446
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "fileService", [_dec2], {
|
|
447
|
+
configurable: true,
|
|
448
|
+
enumerable: true,
|
|
449
|
+
writable: true,
|
|
450
|
+
initializer: null
|
|
451
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "modalService", [_dec3], {
|
|
452
|
+
configurable: true,
|
|
453
|
+
enumerable: true,
|
|
454
|
+
writable: true,
|
|
455
|
+
initializer: null
|
|
456
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "openService", [_dec4], {
|
|
457
|
+
configurable: true,
|
|
458
|
+
enumerable: true,
|
|
459
|
+
writable: true,
|
|
460
|
+
initializer: null
|
|
461
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ModalContribution } from '@difizen/mana-app';
|
|
2
|
+
export declare class FileCreateModalContribution implements ModalContribution {
|
|
3
|
+
registerModal(): import("@difizen/mana-app").ModalItem<import("./file-create-modal.js").ModalItemType>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=file-create-modal-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-create-modal-contribution.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAC;AAIjE,qBACa,2BAA4B,YAAW,iBAAiB;IACnE,aAAa;CAGd"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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, _class;
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
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); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
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); }
|
|
8
|
+
import { ModalContribution, singleton } from '@difizen/mana-app';
|
|
9
|
+
import { FileCreateModal } from "./file-create-modal.js";
|
|
10
|
+
export var FileCreateModalContribution = (_dec = singleton({
|
|
11
|
+
contrib: ModalContribution
|
|
12
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
13
|
+
function FileCreateModalContribution() {
|
|
14
|
+
_classCallCheck(this, FileCreateModalContribution);
|
|
15
|
+
}
|
|
16
|
+
_createClass(FileCreateModalContribution, [{
|
|
17
|
+
key: "registerModal",
|
|
18
|
+
value: function registerModal() {
|
|
19
|
+
return FileCreateModal;
|
|
20
|
+
}
|
|
21
|
+
}]);
|
|
22
|
+
return FileCreateModalContribution;
|
|
23
|
+
}()) || _class);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
|
|
3
|
+
export interface ModalItemType {
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>>;
|
|
7
|
+
export declare const FileCreateModal: ModalItem<ModalItemType>;
|
|
8
|
+
//# sourceMappingURL=file-create-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAuD5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { URI, useInject, ViewManager } from '@difizen/mana-app';
|
|
12
|
+
import { Input, Modal } from 'antd';
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import { FileView, JupyterFileService } from "./index.js";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
|
|
17
|
+
var visible = _ref.visible,
|
|
18
|
+
close = _ref.close,
|
|
19
|
+
data = _ref.data;
|
|
20
|
+
var fileService = useInject(JupyterFileService);
|
|
21
|
+
var viewManager = useInject(ViewManager);
|
|
22
|
+
var _useState = useState(''),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
newFileName = _useState2[0],
|
|
25
|
+
setNewFileName = _useState2[1];
|
|
26
|
+
var _useState3 = useState(),
|
|
27
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
28
|
+
fileView = _useState4[0],
|
|
29
|
+
setFileView = _useState4[1];
|
|
30
|
+
var inputRef = useRef(null);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var _inputRef$current;
|
|
33
|
+
viewManager.getOrCreateView(FileView).then(function (view) {
|
|
34
|
+
setFileView(view);
|
|
35
|
+
return;
|
|
36
|
+
}).catch(function () {
|
|
37
|
+
//
|
|
38
|
+
});
|
|
39
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
40
|
+
});
|
|
41
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
42
|
+
title: "\u65B0\u5EFA\u6587\u4EF6",
|
|
43
|
+
open: visible,
|
|
44
|
+
onCancel: close,
|
|
45
|
+
onOk: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
46
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
_context.next = 2;
|
|
50
|
+
return fileService.newFile(newFileName, new URI(data.path));
|
|
51
|
+
case 2:
|
|
52
|
+
if (fileView) {
|
|
53
|
+
fileView.model.refresh();
|
|
54
|
+
}
|
|
55
|
+
close();
|
|
56
|
+
case 4:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
})),
|
|
62
|
+
keyboard: true,
|
|
63
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
64
|
+
value: newFileName,
|
|
65
|
+
onChange: function onChange(e) {
|
|
66
|
+
setNewFileName(e.target.value);
|
|
67
|
+
},
|
|
68
|
+
ref: inputRef,
|
|
69
|
+
onKeyDown: /*#__PURE__*/function () {
|
|
70
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
|
|
71
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
if (!(e.keyCode === 13)) {
|
|
75
|
+
_context2.next = 5;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
_context2.next = 3;
|
|
79
|
+
return fileService.newFile(newFileName, new URI(data.path));
|
|
80
|
+
case 3:
|
|
81
|
+
if (fileView) {
|
|
82
|
+
fileView.model.refresh();
|
|
83
|
+
}
|
|
84
|
+
close();
|
|
85
|
+
case 5:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context2.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee2);
|
|
90
|
+
}));
|
|
91
|
+
return function (_x) {
|
|
92
|
+
return _ref3.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}()
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export var FileCreateModal = {
|
|
99
|
+
id: 'file.create.modal',
|
|
100
|
+
component: FileCreateModalComponent
|
|
101
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ModalContribution } from '@difizen/mana-app';
|
|
2
|
+
export declare class FileCreateDirModalContribution implements ModalContribution {
|
|
3
|
+
registerModal(): import("@difizen/mana-app").ModalItem<import("./file-createdir-modal.js").ModalItemType>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=file-createdir-modal-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-createdir-modal-contribution.d.ts","sourceRoot":"","sources":["../../src/file/file-createdir-modal-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAC;AAIjE,qBACa,8BAA+B,YAAW,iBAAiB;IACtE,aAAa;CAGd"}
|