@difizen/libro-jupyter 0.0.2-alpha.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/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/components/index.less +1 -0
- 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 +21 -0
- package/es/file/file-command.d.ts.map +1 -0
- package/es/file/file-command.js +469 -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 +12 -0
- package/es/file/file-create-modal.d.ts.map +1 -0
- package/es/file/file-create-modal.js +223 -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 +9 -0
- package/es/file/file-createdir-modal.d.ts.map +1 -0
- package/es/file/file-createdir-modal.js +168 -0
- package/es/file/file-icon.d.ts +11 -0
- package/es/file/file-icon.d.ts.map +1 -0
- package/es/file/file-icon.js +475 -0
- package/es/file/file-name-alias.js +1 -1
- package/es/file/file-protocol.d.ts +6 -0
- package/es/file/file-protocol.d.ts.map +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 +10 -0
- package/es/file/file-rename-modal.d.ts.map +1 -0
- package/es/file/file-rename-modal.js +150 -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/index.d.ts +3 -0
- package/es/file/index.d.ts.map +1 -1
- package/es/file/index.js +4 -1
- package/es/file/index.less +98 -0
- package/es/file/module.d.ts.map +1 -1
- package/es/file/module.js +5 -1
- package/es/file/navigatable-view.d.ts +9 -3
- package/es/file/navigatable-view.d.ts.map +1 -1
- package/es/file/navigatable-view.js +46 -13
- package/es/file/open-handler-contribution.js +4 -4
- package/es/file/utils.d.ts +2 -0
- package/es/file/utils.d.ts.map +1 -0
- 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/components/index.less +1 -0
- package/src/file/file-command.tsx +325 -0
- package/src/file/file-create-modal-contribution.ts +10 -0
- package/src/file/file-create-modal.tsx +176 -0
- package/src/file/file-createdir-modal-contribution.ts +10 -0
- package/src/file/file-createdir-modal.tsx +108 -0
- package/src/file/file-icon.tsx +502 -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 +103 -0
- package/src/file/file-service.ts +69 -33
- package/src/file/file-view/index.tsx +4 -1
- package/src/file/index.less +98 -0
- package/src/file/index.ts +3 -0
- package/src/file/module.ts +8 -0
- package/src/file/navigatable-view.tsx +39 -3
- 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
|
@@ -0,0 +1,223 @@
|
|
|
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 { Col, Form, message, Row, Input, Modal } from 'antd';
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import "./index.less";
|
|
15
|
+
import { FileView, JSONIcon, JupyterFileService, MoreIcon, NotebookIcon, PythonIcon } from "./index.js";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
|
|
19
|
+
var visible = _ref.visible,
|
|
20
|
+
close = _ref.close,
|
|
21
|
+
data = _ref.data;
|
|
22
|
+
var fileService = useInject(JupyterFileService);
|
|
23
|
+
var viewManager = useInject(ViewManager);
|
|
24
|
+
var _useState = useState(data.fileType),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
fileType = _useState2[0],
|
|
27
|
+
setFileType = _useState2[1];
|
|
28
|
+
var _useState3 = useState(),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
fileView = _useState4[0],
|
|
31
|
+
setFileView = _useState4[1];
|
|
32
|
+
var inputRef = useRef(null);
|
|
33
|
+
var _Form$useForm = Form.useForm(),
|
|
34
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
35
|
+
form = _Form$useForm2[0];
|
|
36
|
+
var onFinish = /*#__PURE__*/function () {
|
|
37
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
|
|
38
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context.next = 2;
|
|
42
|
+
return form.validateFields();
|
|
43
|
+
case 2:
|
|
44
|
+
close();
|
|
45
|
+
_context.prev = 3;
|
|
46
|
+
_context.next = 6;
|
|
47
|
+
return fileService.newFile(values.fileName + fileType || '', new URI(data.path));
|
|
48
|
+
case 6:
|
|
49
|
+
if (fileView) {
|
|
50
|
+
fileView.model.refresh();
|
|
51
|
+
}
|
|
52
|
+
_context.next = 12;
|
|
53
|
+
break;
|
|
54
|
+
case 9:
|
|
55
|
+
_context.prev = 9;
|
|
56
|
+
_context.t0 = _context["catch"](3);
|
|
57
|
+
message.error('新建文件失败');
|
|
58
|
+
case 12:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context.stop();
|
|
61
|
+
}
|
|
62
|
+
}, _callee, null, [[3, 9]]);
|
|
63
|
+
}));
|
|
64
|
+
return function onFinish(_x) {
|
|
65
|
+
return _ref2.apply(this, arguments);
|
|
66
|
+
};
|
|
67
|
+
}();
|
|
68
|
+
var validateFileName = /*#__PURE__*/function () {
|
|
69
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(rule, value, callback) {
|
|
70
|
+
var targetURI, fileRes;
|
|
71
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
if (!(!value || !value.length)) {
|
|
75
|
+
_context2.next = 4;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
throw new Error('请输入文件名');
|
|
79
|
+
case 4:
|
|
80
|
+
targetURI = new URI(data.path + value + (fileType || ''));
|
|
81
|
+
_context2.next = 7;
|
|
82
|
+
return fileService.resolve(targetURI);
|
|
83
|
+
case 7:
|
|
84
|
+
fileRes = _context2.sent;
|
|
85
|
+
if (!fileRes.isFile) {
|
|
86
|
+
_context2.next = 10;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
throw new Error('文件名称已存在,请重新输入');
|
|
90
|
+
case 10:
|
|
91
|
+
case "end":
|
|
92
|
+
return _context2.stop();
|
|
93
|
+
}
|
|
94
|
+
}, _callee2);
|
|
95
|
+
}));
|
|
96
|
+
return function validateFileName(_x2, _x3, _x4) {
|
|
97
|
+
return _ref3.apply(this, arguments);
|
|
98
|
+
};
|
|
99
|
+
}();
|
|
100
|
+
useEffect(function () {
|
|
101
|
+
var _inputRef$current;
|
|
102
|
+
viewManager.getOrCreateView(FileView).then(function (view) {
|
|
103
|
+
setFileView(view);
|
|
104
|
+
return;
|
|
105
|
+
}).catch(function () {
|
|
106
|
+
//
|
|
107
|
+
});
|
|
108
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
109
|
+
});
|
|
110
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
111
|
+
title: "\u65B0\u5EFA\u6587\u4EF6",
|
|
112
|
+
open: visible,
|
|
113
|
+
onCancel: close,
|
|
114
|
+
width: 788,
|
|
115
|
+
cancelText: "\u53D6\u6D88",
|
|
116
|
+
okText: "\u786E\u5B9A",
|
|
117
|
+
onOk: function onOk() {
|
|
118
|
+
form.submit();
|
|
119
|
+
},
|
|
120
|
+
keyboard: true,
|
|
121
|
+
wrapClassName: "libro-create-file-modal",
|
|
122
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
123
|
+
className: "libro-create-file-path-container",
|
|
124
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
125
|
+
className: "libro-create-file-des",
|
|
126
|
+
children: "\u521B\u5EFA\u4F4D\u7F6E\uFF1A"
|
|
127
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
128
|
+
className: "libro-create-file-path",
|
|
129
|
+
children: data.path
|
|
130
|
+
})]
|
|
131
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
132
|
+
className: "libro-create-file-des",
|
|
133
|
+
children: "\u6587\u4EF6\u7C7B\u578B\uFF1A"
|
|
134
|
+
}), /*#__PURE__*/_jsxs(Row, {
|
|
135
|
+
children: [/*#__PURE__*/_jsx(Col, {
|
|
136
|
+
className: "gutter-row",
|
|
137
|
+
style: {
|
|
138
|
+
paddingLeft: 'unset',
|
|
139
|
+
paddingRight: '16px'
|
|
140
|
+
},
|
|
141
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
142
|
+
className: "libro-create-file-type ".concat(fileType === '.ipynb' ? 'active' : ''),
|
|
143
|
+
onClick: function onClick() {
|
|
144
|
+
setFileType('.ipynb');
|
|
145
|
+
},
|
|
146
|
+
children: [/*#__PURE__*/_jsx(NotebookIcon, {}), /*#__PURE__*/_jsx("span", {
|
|
147
|
+
className: "libro-create-file-type-text",
|
|
148
|
+
children: "Notebook"
|
|
149
|
+
})]
|
|
150
|
+
})
|
|
151
|
+
}), /*#__PURE__*/_jsx(Col, {
|
|
152
|
+
className: "gutter-row",
|
|
153
|
+
style: {
|
|
154
|
+
paddingLeft: 'unset',
|
|
155
|
+
paddingRight: '16px'
|
|
156
|
+
},
|
|
157
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
158
|
+
className: "libro-create-file-type ".concat(fileType === '.py' ? 'active' : ''),
|
|
159
|
+
onClick: function onClick() {
|
|
160
|
+
setFileType('.py');
|
|
161
|
+
},
|
|
162
|
+
children: [/*#__PURE__*/_jsx(PythonIcon, {}), /*#__PURE__*/_jsx("span", {
|
|
163
|
+
className: "libro-create-file-type-text",
|
|
164
|
+
children: "Python"
|
|
165
|
+
})]
|
|
166
|
+
})
|
|
167
|
+
}), /*#__PURE__*/_jsx(Col, {
|
|
168
|
+
className: "gutter-row",
|
|
169
|
+
style: {
|
|
170
|
+
paddingLeft: 'unset',
|
|
171
|
+
paddingRight: '16px'
|
|
172
|
+
},
|
|
173
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
174
|
+
className: "libro-create-file-type ".concat(fileType === '.json' ? 'active' : ''),
|
|
175
|
+
onClick: function onClick() {
|
|
176
|
+
setFileType('.json');
|
|
177
|
+
},
|
|
178
|
+
children: [/*#__PURE__*/_jsx(JSONIcon, {}), /*#__PURE__*/_jsx("span", {
|
|
179
|
+
className: "libro-create-file-type-text",
|
|
180
|
+
children: "JSON"
|
|
181
|
+
})]
|
|
182
|
+
})
|
|
183
|
+
}), /*#__PURE__*/_jsx(Col, {
|
|
184
|
+
className: "gutter-row",
|
|
185
|
+
style: {
|
|
186
|
+
paddingLeft: 'unset',
|
|
187
|
+
paddingRight: '16px'
|
|
188
|
+
},
|
|
189
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
190
|
+
className: "libro-create-file-type ".concat(fileType === undefined ? 'active' : ''),
|
|
191
|
+
onClick: function onClick() {
|
|
192
|
+
setFileType(undefined);
|
|
193
|
+
},
|
|
194
|
+
children: [/*#__PURE__*/_jsx(MoreIcon, {}), /*#__PURE__*/_jsx("span", {
|
|
195
|
+
className: "libro-create-file-type-text",
|
|
196
|
+
children: "\u5176\u4ED6"
|
|
197
|
+
})]
|
|
198
|
+
})
|
|
199
|
+
})]
|
|
200
|
+
}), /*#__PURE__*/_jsx(Form, {
|
|
201
|
+
layout: "vertical",
|
|
202
|
+
autoComplete: "off",
|
|
203
|
+
form: form,
|
|
204
|
+
onFinish: onFinish,
|
|
205
|
+
className: "libro-create-file-form",
|
|
206
|
+
children: /*#__PURE__*/_jsx(Form.Item, {
|
|
207
|
+
name: "fileName",
|
|
208
|
+
label: "\u6587\u4EF6\u540D\u79F0",
|
|
209
|
+
rules: [{
|
|
210
|
+
required: true,
|
|
211
|
+
validator: validateFileName
|
|
212
|
+
}],
|
|
213
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
214
|
+
addonAfter: fileType || ''
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})]
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
export var FileCreateModal = {
|
|
221
|
+
id: 'file.create.modal',
|
|
222
|
+
component: FileCreateModalComponent
|
|
223
|
+
};
|
|
@@ -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").FileDirCreateModalItemType>;
|
|
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"}
|
|
@@ -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 { FileDirCreateModal } from "./file-createdir-modal.js";
|
|
10
|
+
export var FileCreateDirModalContribution = (_dec = singleton({
|
|
11
|
+
contrib: ModalContribution
|
|
12
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
13
|
+
function FileCreateDirModalContribution() {
|
|
14
|
+
_classCallCheck(this, FileCreateDirModalContribution);
|
|
15
|
+
}
|
|
16
|
+
_createClass(FileCreateDirModalContribution, [{
|
|
17
|
+
key: "registerModal",
|
|
18
|
+
value: function registerModal() {
|
|
19
|
+
return FileDirCreateModal;
|
|
20
|
+
}
|
|
21
|
+
}]);
|
|
22
|
+
return FileCreateDirModalContribution;
|
|
23
|
+
}()) || _class);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface FileDirCreateModalItemType {
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const FileCreateDirModalComponent: React.FC<ModalItemProps<FileDirCreateModalItemType>>;
|
|
8
|
+
export declare const FileDirCreateModal: ModalItem<FileDirCreateModalItemType>;
|
|
9
|
+
//# sourceMappingURL=file-createdir-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-createdir-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-createdir-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAUnE,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAChD,cAAc,CAAC,0BAA0B,CAAC,CAqF3C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAAS,CAAC,0BAA0B,CAGpE,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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 } from '@difizen/mana-app';
|
|
12
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
13
|
+
import { useInject } from '@difizen/mana-app';
|
|
14
|
+
import { Form, message, Input, Modal } from 'antd';
|
|
15
|
+
import { useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { JupyterFileService } from "./file-service.js";
|
|
17
|
+
import { FileView } from "./file-view/index.js";
|
|
18
|
+
import "./index.less";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
export var FileCreateDirModalComponent = function FileCreateDirModalComponent(_ref) {
|
|
22
|
+
var visible = _ref.visible,
|
|
23
|
+
close = _ref.close,
|
|
24
|
+
data = _ref.data;
|
|
25
|
+
var fileService = useInject(JupyterFileService);
|
|
26
|
+
var viewManager = useInject(ViewManager);
|
|
27
|
+
var inputRef = useRef(null);
|
|
28
|
+
var _useState = useState(),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
fileView = _useState2[0],
|
|
31
|
+
setFileView = _useState2[1];
|
|
32
|
+
var _Form$useForm = Form.useForm(),
|
|
33
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
34
|
+
form = _Form$useForm2[0];
|
|
35
|
+
var onFinish = /*#__PURE__*/function () {
|
|
36
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
|
|
37
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
38
|
+
while (1) switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
_context.next = 2;
|
|
41
|
+
return form.validateFields();
|
|
42
|
+
case 2:
|
|
43
|
+
close();
|
|
44
|
+
_context.prev = 3;
|
|
45
|
+
_context.next = 6;
|
|
46
|
+
return fileService.newFileDir(values.dirName, new URI(data.path));
|
|
47
|
+
case 6:
|
|
48
|
+
if (fileView) {
|
|
49
|
+
fileView.model.refresh();
|
|
50
|
+
}
|
|
51
|
+
_context.next = 12;
|
|
52
|
+
break;
|
|
53
|
+
case 9:
|
|
54
|
+
_context.prev = 9;
|
|
55
|
+
_context.t0 = _context["catch"](3);
|
|
56
|
+
message.error('新建文件夹失败');
|
|
57
|
+
case 12:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee, null, [[3, 9]]);
|
|
62
|
+
}));
|
|
63
|
+
return function onFinish(_x) {
|
|
64
|
+
return _ref2.apply(this, arguments);
|
|
65
|
+
};
|
|
66
|
+
}();
|
|
67
|
+
var validateDirName = /*#__PURE__*/function () {
|
|
68
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(rule, value, callback) {
|
|
69
|
+
var targetURI, fileRes;
|
|
70
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
71
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(!value || !value.length)) {
|
|
74
|
+
_context2.next = 4;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
throw new Error('请输入文件夹名');
|
|
78
|
+
case 4:
|
|
79
|
+
targetURI = new URI(data.path + value);
|
|
80
|
+
_context2.next = 7;
|
|
81
|
+
return fileService.resolve(targetURI);
|
|
82
|
+
case 7:
|
|
83
|
+
fileRes = _context2.sent;
|
|
84
|
+
if (!fileRes.isDirectory) {
|
|
85
|
+
_context2.next = 10;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
throw new Error('文件夹名称已存在,请重新输入');
|
|
89
|
+
case 10:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context2.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee2);
|
|
94
|
+
}));
|
|
95
|
+
return function validateDirName(_x2, _x3, _x4) {
|
|
96
|
+
return _ref3.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}();
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
var _inputRef$current;
|
|
101
|
+
viewManager.getOrCreateView(FileView).then(function (view) {
|
|
102
|
+
setFileView(view);
|
|
103
|
+
return;
|
|
104
|
+
}).catch(function () {
|
|
105
|
+
//
|
|
106
|
+
});
|
|
107
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
108
|
+
});
|
|
109
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
110
|
+
title: "\u65B0\u5EFA\u6587\u4EF6\u5939",
|
|
111
|
+
open: visible,
|
|
112
|
+
onCancel: close,
|
|
113
|
+
cancelText: "\u53D6\u6D88",
|
|
114
|
+
okText: "\u786E\u5B9A",
|
|
115
|
+
onOk: function onOk() {
|
|
116
|
+
form.submit();
|
|
117
|
+
},
|
|
118
|
+
keyboard: true,
|
|
119
|
+
wrapClassName: "libro-create-dir-modal",
|
|
120
|
+
width: 524,
|
|
121
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
122
|
+
className: "libro-create-file-des",
|
|
123
|
+
children: "\u521B\u5EFA\u4F4D\u7F6E\uFF1A"
|
|
124
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
125
|
+
className: "libro-create-file-path",
|
|
126
|
+
children: data.path
|
|
127
|
+
}), /*#__PURE__*/_jsx(Form, {
|
|
128
|
+
layout: "vertical",
|
|
129
|
+
autoComplete: "off",
|
|
130
|
+
form: form,
|
|
131
|
+
onFinish: onFinish,
|
|
132
|
+
className: "libro-create-dir-file-form",
|
|
133
|
+
children: /*#__PURE__*/_jsx(Form.Item, {
|
|
134
|
+
name: "dirName",
|
|
135
|
+
label: "\u6587\u4EF6\u5939\u540D\u79F0",
|
|
136
|
+
rules: [{
|
|
137
|
+
required: true,
|
|
138
|
+
validator: validateDirName
|
|
139
|
+
}],
|
|
140
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
141
|
+
ref: inputRef,
|
|
142
|
+
onKeyDown: /*#__PURE__*/function () {
|
|
143
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e) {
|
|
144
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
145
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
146
|
+
case 0:
|
|
147
|
+
if (e.keyCode === 13) {
|
|
148
|
+
form.submit();
|
|
149
|
+
}
|
|
150
|
+
case 1:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context3.stop();
|
|
153
|
+
}
|
|
154
|
+
}, _callee3);
|
|
155
|
+
}));
|
|
156
|
+
return function (_x5) {
|
|
157
|
+
return _ref4.apply(this, arguments);
|
|
158
|
+
};
|
|
159
|
+
}()
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
})]
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
export var FileDirCreateModal = {
|
|
166
|
+
id: 'file.createdir.modal',
|
|
167
|
+
component: FileCreateDirModalComponent
|
|
168
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
width?: string;
|
|
4
|
+
height?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function NotebookIcon(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function SQLIcon(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function JSONIcon(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function PythonIcon(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function MoreIcon(prop: IProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=file-icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-icon.d.ts","sourceRoot":"","sources":["../../src/file/file-icon.tsx"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,2CA6BzC;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,2CA6BpC;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,2CA8DrC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,2CA8CvC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,2CAiUpC"}
|