@difizen/libro-lab 0.1.11 → 0.1.12

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,6 +1,9 @@
1
- import type { View } from '@difizen/mana-app';
1
+ import { JupyterFileService } from '@difizen/libro-jupyter';
2
+ import type { CardTabOption, View } from '@difizen/mana-app';
3
+ import { ViewManager } from '@difizen/mana-app';
2
4
  import { CardTabView } from '@difizen/mana-app';
3
5
  export declare class SaveableTabView extends CardTabView {
6
+ constructor(option: CardTabOption, manager: ViewManager, fileService: JupyterFileService);
4
7
  protected renderTab(item: View): import("react/jsx-runtime").JSX.Element;
5
8
  protected renderTail(item: View): import("react/jsx-runtime").JSX.Element;
6
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"saveable-tab-view.d.ts","sourceRoot":"","sources":["../../src/layout/saveable-tab-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,WAAW,EAMZ,MAAM,mBAAmB,CAAC;AAK3B,qBAEa,eAAgB,SAAQ,WAAW;cAC3B,SAAS,CAAC,IAAI,EAAE,IAAI;IAuBvC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI;CAyBhC"}
1
+ {"version":3,"file":"saveable-tab-view.d.ts","sourceRoot":"","sources":["../../src/layout/saveable-tab-view.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EACL,WAAW,EAMZ,MAAM,mBAAmB,CAAC;AAK3B,qBAEa,eAAgB,SAAQ,WAAW;gBAExB,MAAM,EAAE,aAAa,EACpB,OAAO,EAAE,WAAW,EACb,WAAW,EAAE,kBAAkB;cAc1C,SAAS,CAAC,IAAI,EAAE,IAAI;IAuBvC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI;CAyBhC"}
@@ -13,6 +13,10 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
13
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
14
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
15
  import { CloseOutlined } from '@ant-design/icons';
16
+ import { JupyterFileService } from '@difizen/libro-jupyter';
17
+ import { ViewManager, ViewOption } from '@difizen/mana-app';
18
+ import { NavigatableView } from '@difizen/mana-app';
19
+ import { inject } from '@difizen/mana-app';
16
20
  import { CardTabView, MenuRender, transient, view, ViewContext, Saveable } from '@difizen/mana-app';
17
21
  import { Dropdown } from '@difizen/mana-react';
18
22
  import { Badge } from 'antd';
@@ -22,10 +26,25 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
22
26
  export var SaveableTabView = (_dec = transient(), _dec2 = view('libro-lab-saveable-tab'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_CardTabView) {
23
27
  _inherits(SaveableTabView, _CardTabView);
24
28
  var _super = _createSuper(SaveableTabView);
25
- function SaveableTabView() {
29
+ function SaveableTabView(option, manager, fileService) {
30
+ var _this;
26
31
  _classCallCheck(this, SaveableTabView);
27
- return _super.apply(this, arguments);
32
+ _this = _super.call(this, option, manager);
33
+ fileService.onFileRemove(function (e) {
34
+ var toDisposeView = _this.children.find(function (item) {
35
+ var _item$getResourceUri;
36
+ if (NavigatableView.is(item) && ((_item$getResourceUri = item.getResourceUri()) === null || _item$getResourceUri === void 0 ? void 0 : _item$getResourceUri.path.toString()) === e) {
37
+ return true;
38
+ }
39
+ return undefined;
40
+ });
41
+ toDisposeView === null || toDisposeView === void 0 || toDisposeView.dispose();
42
+ });
43
+ return _this;
28
44
  }
45
+ SaveableTabView = inject(JupyterFileService)(SaveableTabView, undefined, 2) || SaveableTabView;
46
+ SaveableTabView = inject(ViewManager)(SaveableTabView, undefined, 1) || SaveableTabView;
47
+ SaveableTabView = inject(ViewOption)(SaveableTabView, undefined, 0) || SaveableTabView;
29
48
  _createClass(SaveableTabView, [{
30
49
  key: "renderTab",
31
50
  value: function renderTab(item) {
@@ -51,7 +70,7 @@ export var SaveableTabView = (_dec = transient(), _dec2 = view('libro-lab-saveab
51
70
  }, {
52
71
  key: "renderTail",
53
72
  value: function renderTail(item) {
54
- var _this = this;
73
+ var _this2 = this;
55
74
  var isDirty = Saveable.is(item) && Saveable.isDirty(item);
56
75
  return /*#__PURE__*/_jsx("div", {
57
76
  className: "libro-lab-editor-tab-tail",
@@ -63,9 +82,9 @@ export var SaveableTabView = (_dec = transient(), _dec2 = view('libro-lab-saveab
63
82
  }) : item.title.closable && /*#__PURE__*/_jsx(CloseOutlined, {
64
83
  onClick: function onClick(e) {
65
84
  e.stopPropagation();
66
- _this.close(item);
67
- if (_this.children.length > 0) {
68
- _this.active = _this.children[_this.children.length - 1];
85
+ _this2.close(item);
86
+ if (_this2.children.length > 0) {
87
+ _this2.active = _this2.children[_this2.children.length - 1];
69
88
  }
70
89
  },
71
90
  className: "mana-tab-close"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-lab",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -34,13 +34,13 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "^5.1.0",
37
- "@difizen/libro-core": "^0.1.11",
38
- "@difizen/libro-jupyter": "^0.1.11",
39
- "@difizen/libro-kernel": "^0.1.11",
40
- "@difizen/libro-prompt-cell": "^0.1.11",
41
- "@difizen/libro-terminal": "^0.1.11",
42
- "@difizen/libro-toc": "^0.1.11",
43
- "@difizen/libro-cofine-editor-core": "^0.1.11",
37
+ "@difizen/libro-core": "^0.1.12",
38
+ "@difizen/libro-jupyter": "^0.1.12",
39
+ "@difizen/libro-kernel": "^0.1.12",
40
+ "@difizen/libro-prompt-cell": "^0.1.12",
41
+ "@difizen/libro-terminal": "^0.1.12",
42
+ "@difizen/libro-toc": "^0.1.12",
43
+ "@difizen/libro-cofine-editor-core": "^0.1.12",
44
44
  "@difizen/mana-app": "latest",
45
45
  "@difizen/mana-react": "latest",
46
46
  "classnames": "^2.3.2",
@@ -1,5 +1,9 @@
1
1
  import { CloseOutlined } from '@ant-design/icons';
2
- import type { View } from '@difizen/mana-app';
2
+ import { JupyterFileService } from '@difizen/libro-jupyter';
3
+ import type { CardTabOption, View } from '@difizen/mana-app';
4
+ import { ViewManager, ViewOption } from '@difizen/mana-app';
5
+ import { NavigatableView } from '@difizen/mana-app';
6
+ import { inject } from '@difizen/mana-app';
3
7
  import {
4
8
  CardTabView,
5
9
  MenuRender,
@@ -15,6 +19,23 @@ import classnames from 'classnames';
15
19
  @transient()
16
20
  @view('libro-lab-saveable-tab')
17
21
  export class SaveableTabView extends CardTabView {
22
+ constructor(
23
+ @inject(ViewOption) option: CardTabOption,
24
+ @inject(ViewManager) manager: ViewManager,
25
+ @inject(JupyterFileService) fileService: JupyterFileService,
26
+ ) {
27
+ super(option, manager);
28
+ fileService.onFileRemove((e) => {
29
+ const toDisposeView = this.children.find((item) => {
30
+ if (NavigatableView.is(item) && item.getResourceUri()?.path.toString() === e) {
31
+ return true;
32
+ }
33
+ return undefined;
34
+ });
35
+ toDisposeView?.dispose();
36
+ });
37
+ }
38
+
18
39
  protected override renderTab(item: View) {
19
40
  return (
20
41
  <ViewContext view={item}>