@difizen/libro-jupyter 0.1.28 → 0.1.29

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.
@@ -1 +1 @@
1
- {"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,cAAc,CAAC;AAWtB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CA0J5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
1
+ {"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMnE,OAAO,cAAc,CAAC;AAWtB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAkK5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
@@ -8,6 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
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
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
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { CommandRegistry } from '@difizen/mana-app';
11
12
  import { URI, useInject, ViewManager } from '@difizen/mana-app';
12
13
  import { Col, Form, message, Row, Input, Modal } from 'antd';
13
14
  import { useEffect, useRef, useState } from 'react';
@@ -20,6 +21,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
20
21
  close = _ref.close,
21
22
  data = _ref.data;
22
23
  var fileService = useInject(JupyterFileService);
24
+ var commands = useInject(CommandRegistry);
23
25
  var viewManager = useInject(ViewManager);
24
26
  var _useState = useState(data === null || data === void 0 ? void 0 : data.fileType),
25
27
  _useState2 = _slicedToArray(_useState, 2),
@@ -35,6 +37,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
35
37
  form = _Form$useForm2[0];
36
38
  var onFinish = /*#__PURE__*/function () {
37
39
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
40
+ var stat;
38
41
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
42
  while (1) switch (_context.prev = _context.next) {
40
43
  case 0:
@@ -46,20 +49,28 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
46
49
  _context.next = 6;
47
50
  return fileService.newFile(values.fileName + (fileType || ''), new URI(data === null || data === void 0 ? void 0 : data.path));
48
51
  case 6:
52
+ stat = _context.sent;
49
53
  if (fileView) {
50
54
  fileView.model.refresh();
51
55
  }
52
- _context.next = 12;
56
+ if (stat.isFile) {
57
+ commands.executeCommand('fileTree.command.openfile', {
58
+ fileStat: stat,
59
+ uri: stat.resource
60
+ });
61
+ }
62
+ // message.success('新建文件成功');
63
+ _context.next = 14;
53
64
  break;
54
- case 9:
55
- _context.prev = 9;
65
+ case 11:
66
+ _context.prev = 11;
56
67
  _context.t0 = _context["catch"](3);
57
68
  message.error('新建文件失败');
58
- case 12:
69
+ case 14:
59
70
  case "end":
60
71
  return _context.stop();
61
72
  }
62
- }, _callee, null, [[3, 9]]);
73
+ }, _callee, null, [[3, 11]]);
63
74
  }));
64
75
  return function onFinish(_x) {
65
76
  return _ref2.apply(this, arguments);
@@ -390,7 +390,7 @@ export var JupyterFileService = (_dec = singleton({
390
390
  _context10.next = 13;
391
391
  return this.rename(new URI(res.path.toString()), fileName);
392
392
  case 13:
393
- return _context10.abrupt("return", this.resolve(target));
393
+ return _context10.abrupt("return", this.resolve(targetFileUri));
394
394
  case 14:
395
395
  case "end":
396
396
  return _context10.stop();
@@ -7,4 +7,5 @@ export * from './file-protocol.js';
7
7
  export * from './file-icon.js';
8
8
  export * from './file-create-modal.js';
9
9
  export * from './file-createdir-modal.js';
10
+ export * from './file-command.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC"}
package/es/file/index.js CHANGED
@@ -6,4 +6,5 @@ export * from "./file-service.js";
6
6
  export * from "./file-protocol.js";
7
7
  export * from "./file-icon.js";
8
8
  export * from "./file-create-modal.js";
9
- export * from "./file-createdir-modal.js";
9
+ export * from "./file-createdir-modal.js";
10
+ export * from "./file-command.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro"
@@ -31,22 +31,22 @@
31
31
  "src"
32
32
  ],
33
33
  "dependencies": {
34
- "@difizen/libro-cofine-editor": "^0.1.28",
35
- "@difizen/libro-code-editor": "^0.1.28",
36
- "@difizen/libro-code-cell": "^0.1.28",
37
- "@difizen/libro-codemirror": "^0.1.28",
38
- "@difizen/libro-rendermime": "^0.1.28",
39
- "@difizen/libro-common": "^0.1.28",
40
- "@difizen/libro-core": "^0.1.28",
41
- "@difizen/libro-kernel": "^0.1.28",
42
- "@difizen/libro-l10n": "^0.1.28",
43
- "@difizen/libro-output": "^0.1.28",
44
- "@difizen/libro-search": "^0.1.28",
45
- "@difizen/libro-search-code-cell": "^0.1.28",
46
- "@difizen/libro-lsp": "^0.1.28",
47
- "@difizen/libro-markdown-cell": "^0.1.28",
48
- "@difizen/libro-raw-cell": "^0.1.28",
49
- "@difizen/libro-language-client": "^0.1.28",
34
+ "@difizen/libro-cofine-editor": "^0.1.29",
35
+ "@difizen/libro-code-editor": "^0.1.29",
36
+ "@difizen/libro-code-cell": "^0.1.29",
37
+ "@difizen/libro-codemirror": "^0.1.29",
38
+ "@difizen/libro-rendermime": "^0.1.29",
39
+ "@difizen/libro-common": "^0.1.29",
40
+ "@difizen/libro-core": "^0.1.29",
41
+ "@difizen/libro-kernel": "^0.1.29",
42
+ "@difizen/libro-l10n": "^0.1.29",
43
+ "@difizen/libro-output": "^0.1.29",
44
+ "@difizen/libro-search": "^0.1.29",
45
+ "@difizen/libro-search-code-cell": "^0.1.29",
46
+ "@difizen/libro-lsp": "^0.1.29",
47
+ "@difizen/libro-markdown-cell": "^0.1.29",
48
+ "@difizen/libro-raw-cell": "^0.1.29",
49
+ "@difizen/libro-language-client": "^0.1.29",
50
50
  "@difizen/mana-app": "latest",
51
51
  "@difizen/mana-l10n": "latest",
52
52
  "@ant-design/colors": "^7.0.0",
@@ -1,4 +1,5 @@
1
1
  import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
2
+ import { CommandRegistry } from '@difizen/mana-app';
2
3
  import { URI, useInject, ViewManager } from '@difizen/mana-app';
3
4
  import { Col, Form, message, Row, Input, Modal } from 'antd';
4
5
  import type { InputRef } from 'antd';
@@ -27,6 +28,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
27
28
  data,
28
29
  }: ModalItemProps<ModalItemType>) => {
29
30
  const fileService = useInject(JupyterFileService);
31
+ const commands = useInject(CommandRegistry);
30
32
  const viewManager = useInject(ViewManager);
31
33
  const [fileType, setFileType] = useState<FileType>(data?.fileType);
32
34
  const [fileView, setFileView] = useState<FileView>();
@@ -37,13 +39,20 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
37
39
  await form.validateFields();
38
40
  close();
39
41
  try {
40
- await fileService.newFile(
42
+ const stat = await fileService.newFile(
41
43
  values.fileName + (fileType || ''),
42
44
  new URI(data?.path),
43
45
  );
44
46
  if (fileView) {
45
47
  fileView.model.refresh();
46
48
  }
49
+ if (stat.isFile) {
50
+ commands.executeCommand('fileTree.command.openfile', {
51
+ fileStat: stat,
52
+ uri: stat.resource,
53
+ });
54
+ }
55
+ // message.success('新建文件成功');
47
56
  } catch {
48
57
  message.error('新建文件失败');
49
58
  }
@@ -205,7 +205,7 @@ export class JupyterFileService extends FileService {
205
205
  ext,
206
206
  });
207
207
  await this.rename(new URI(res.path.toString()), fileName);
208
- return this.resolve(target);
208
+ return this.resolve(targetFileUri);
209
209
  }
210
210
 
211
211
  async newFileDir(dirName: string, target: URI): Promise<FileStatWithMetadata> {
package/src/file/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from './file-protocol.js';
7
7
  export * from './file-icon.js';
8
8
  export * from './file-create-modal.js';
9
9
  export * from './file-createdir-modal.js';
10
+ export * from './file-command.js';