@difizen/libro-app 0.2.45

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.
@@ -0,0 +1,99 @@
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, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3;
3
+ 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 }); }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ 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); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
13
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
+ 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; } }
15
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
+ 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; }
17
+ 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.'); }
18
+ import { ViewRender, ViewManager } from '@difizen/mana-app';
19
+ import { BaseView, inject, LabelProvider, prop, transient, URI as VScodeURI, URIIconReference, useInject, view, ViewInstance, ViewOption, Deferred, URI, CommandRegistry } from '@difizen/mana-app';
20
+ import { forwardRef } from 'react';
21
+ import "./index.less";
22
+ import { LibroAppView } from "./app-view.js";
23
+ import { AppViewerFactory } from "./protocol.js";
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ export var AppViewerComponent = /*#__PURE__*/forwardRef(function LibroEditorComponent() {
26
+ var instance = useInject(ViewInstance);
27
+ return /*#__PURE__*/_jsx("div", {
28
+ className: "libro-app-viewer-container",
29
+ children: instance.appView && /*#__PURE__*/_jsx(ViewRender, {
30
+ view: instance.appView
31
+ })
32
+ });
33
+ });
34
+ export var LibroAppViewer = (_dec = transient(), _dec2 = view(AppViewerFactory), _dec3 = inject(CommandRegistry), _dec4 = prop(), _dec5 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
35
+ _inherits(LibroAppViewer, _BaseView);
36
+ var _super = _createSuper(LibroAppViewer);
37
+ function LibroAppViewer(options, labelProvider, viewManager) {
38
+ var _this;
39
+ _classCallCheck(this, LibroAppViewer);
40
+ _this = _super.call(this);
41
+ _initializerDefineProperty(_this, "commandRegistry", _descriptor, _assertThisInitialized(_this));
42
+ _this.view = AppViewerComponent;
43
+ _initializerDefineProperty(_this, "appView", _descriptor2, _assertThisInitialized(_this));
44
+ _initializerDefineProperty(_this, "filePath", _descriptor3, _assertThisInitialized(_this));
45
+ _this.defer = new Deferred();
46
+ _this.filePath = options.path;
47
+ _this.title.caption = options.path;
48
+ var uri = new URI(options.path);
49
+ viewManager.getOrCreateView(LibroAppView, options).then(function (appView) {
50
+ _this.appView = appView;
51
+ return;
52
+ }).catch(function () {
53
+ //
54
+ });
55
+ var uriRef = URIIconReference.create('file', new VScodeURI(options.path));
56
+ var iconClass = labelProvider.getIcon(uriRef);
57
+ _this.title.icon = /*#__PURE__*/_jsx("div", {
58
+ className: iconClass
59
+ });
60
+ _this.title.label = uri.displayName;
61
+ return _this;
62
+ }
63
+ LibroAppViewer = inject(ViewManager)(LibroAppViewer, undefined, 2) || LibroAppViewer;
64
+ LibroAppViewer = inject(LabelProvider)(LibroAppViewer, undefined, 1) || LibroAppViewer;
65
+ LibroAppViewer = inject(ViewOption)(LibroAppViewer, undefined, 0) || LibroAppViewer;
66
+ _createClass(LibroAppViewer, [{
67
+ key: "ready",
68
+ get: function get() {
69
+ return this.defer.promise;
70
+ }
71
+ }, {
72
+ key: "getResourceUri",
73
+ value: function getResourceUri() {
74
+ return new URI(this.filePath);
75
+ }
76
+ }, {
77
+ key: "createMoveToUri",
78
+ value: function createMoveToUri(resourceUri) {
79
+ this.filePath = resourceUri.path.toString();
80
+ return resourceUri;
81
+ }
82
+ }]);
83
+ return LibroAppViewer;
84
+ }(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "commandRegistry", [_dec3], {
85
+ configurable: true,
86
+ enumerable: true,
87
+ writable: true,
88
+ initializer: null
89
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "appView", [_dec4], {
90
+ configurable: true,
91
+ enumerable: true,
92
+ writable: true,
93
+ initializer: null
94
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filePath", [_dec5], {
95
+ configurable: true,
96
+ enumerable: true,
97
+ writable: true,
98
+ initializer: null
99
+ })), _class2)) || _class) || _class);
package/es/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './module.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/es/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./module.js";
package/es/index.less ADDED
@@ -0,0 +1,147 @@
1
+ .libro-app-container {
2
+ background: var(--mana-libro-background);
3
+ height: 100%;
4
+
5
+ .libro-cell-collapsed-expander {
6
+ padding-left: 0;
7
+ }
8
+
9
+ .libro-app-container-header {
10
+ padding: 12px 24px;
11
+ border-bottom: 1px solid var(--mana-libro-code-border-color);
12
+ }
13
+
14
+ .libro-app-cell-container {
15
+ position: relative;
16
+ }
17
+
18
+ .libro-app-container-content {
19
+ height: calc(100% - 56px);
20
+
21
+ .libro-view-top {
22
+ display: none;
23
+ }
24
+ }
25
+
26
+ .libro-app-cell-list {
27
+ padding: 0 48px 12px;
28
+ height: 100%;
29
+ overflow-y: auto;
30
+ }
31
+
32
+ .libro-markdown-collapser {
33
+ position: absolute;
34
+ top: 4px;
35
+ left: -24px;
36
+ z-index: 90;
37
+ min-width: 24px;
38
+ white-space: pre-wrap;
39
+ text-align: center;
40
+ cursor: pointer;
41
+ }
42
+
43
+ .libro-markdown-warpper-container {
44
+ .libro-markdown-preview {
45
+ min-height: 50px;
46
+ padding: 0 4px;
47
+ overflow: hidden;
48
+
49
+ img {
50
+ max-width: 100%;
51
+ max-height: 100%;
52
+ }
53
+
54
+ a {
55
+ text-decoration: none;
56
+ }
57
+
58
+ a:hover {
59
+ text-decoration: underline;
60
+ }
61
+
62
+ a:focus,
63
+ input:focus,
64
+ select:focus,
65
+ textarea:focus {
66
+ outline: 1px solid -webkit-focus-ring-color;
67
+ outline-offset: -1px;
68
+ }
69
+
70
+ hr {
71
+ height: 2px;
72
+ border: 0;
73
+ border-bottom: 2px solid;
74
+ }
75
+
76
+ div {
77
+ width: 100%;
78
+ min-height: 20px;
79
+ }
80
+
81
+ /* Adjust margin of first item in markdown cell */
82
+ *:first-child {
83
+ margin-top: 0;
84
+ }
85
+
86
+ /* h1 tags don't need top margin */
87
+ h1:first-child {
88
+ margin-top: 0;
89
+ }
90
+
91
+ /* Removes bottom margin when only one item exists in markdown cell */
92
+ #preview > *:only-child,
93
+ #preview > *:last-child {
94
+ margin-bottom: 0;
95
+ padding-bottom: 0;
96
+ }
97
+
98
+ table {
99
+ border-collapse: collapse;
100
+ border-spacing: 0;
101
+ }
102
+
103
+ table th,
104
+ table td {
105
+ border: 1px solid;
106
+ }
107
+
108
+ table > thead > tr > th {
109
+ text-align: left;
110
+ border-bottom: 1px solid;
111
+ }
112
+
113
+ table > thead > tr > th,
114
+ table > thead > tr > td,
115
+ table > tbody > tr > th,
116
+ table > tbody > tr > td {
117
+ padding: 5px 10px;
118
+ }
119
+
120
+ table > tbody > tr + tr > td {
121
+ border-top: 1px solid;
122
+ }
123
+
124
+ blockquote {
125
+ margin: 0 7px 0 5px;
126
+ padding: 0 16px 0 10px;
127
+ border-left-width: 5px;
128
+ border-left-style: solid;
129
+ }
130
+
131
+ code {
132
+ font-size: 1em;
133
+ }
134
+
135
+ pre code {
136
+ color: var(--mana-libro-text-default-color);
137
+ font-family: 12px;
138
+ line-height: 1.357em;
139
+ white-space: pre-wrap;
140
+ }
141
+ }
142
+ }
143
+ }
144
+
145
+ .libro-app-viewer-container {
146
+ height: 100%;
147
+ }
package/es/module.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ export declare const LibroAppModule: ManaModule;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C,eAAO,MAAM,cAAc,YAK1B,CAAC"}
package/es/module.js ADDED
@@ -0,0 +1,6 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ import { AppFileCommandContribution } from "./app-file-command-contribution.js";
3
+ import { LibroAppOpenHandler } from "./app-open-handler.js";
4
+ import { LibroAppView } from "./app-view.js";
5
+ import { LibroAppViewer } from "./app-viewer.js";
6
+ export var LibroAppModule = ManaModule.create().register(AppFileCommandContribution, LibroAppOpenHandler, LibroAppViewer, LibroAppView);
@@ -0,0 +1,2 @@
1
+ export declare const AppViewerFactory = "libro-app-viewer";
2
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC"}
package/es/protocol.js ADDED
@@ -0,0 +1 @@
1
+ export var AppViewerFactory = 'libro-app-viewer';
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@difizen/libro-app",
3
+ "version": "0.2.45",
4
+ "description": "",
5
+ "keywords": [
6
+ "libro",
7
+ "app"
8
+ ],
9
+ "repository": "git@github.com:difizen/libro.git",
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "typings": "./es/index.d.ts",
15
+ "default": "./es/index.js"
16
+ },
17
+ "./mock": {
18
+ "typings": "./es/mock/index.d.ts",
19
+ "default": "./es/mock/index.js"
20
+ },
21
+ "./es/mock": {
22
+ "typings": "./es/mock/index.d.ts",
23
+ "default": "./es/mock/index.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "main": "es/index.js",
28
+ "module": "es/index.js",
29
+ "typings": "es/index.d.ts",
30
+ "files": [
31
+ "es",
32
+ "src"
33
+ ],
34
+ "dependencies": {
35
+ "@difizen/libro-jupyter": "^0.2.45",
36
+ "@ant-design/icons": "^5.4.0",
37
+ "@difizen/mana-app": "latest",
38
+ "@difizen/mana-l10n": "latest"
39
+ },
40
+ "peerDependencies": {
41
+ "antd": "^5.8.6",
42
+ "react": ">=16"
43
+ },
44
+ "devDependencies": {
45
+ "@types/react": "^18.2.25",
46
+ "@types/uuid": "^9.0.2"
47
+ },
48
+ "scripts": {
49
+ "setup": "father build",
50
+ "build": "father build",
51
+ "test": ": Note: lint task is delegated to test:* scripts",
52
+ "test:vitest": "vitest run",
53
+ "test:jest": "jest",
54
+ "coverage": ": Note: lint task is delegated to coverage:* scripts",
55
+ "coverage:vitest": "vitest run --coverage",
56
+ "coverage:jest": "jest --coverage",
57
+ "lint": ": Note: lint task is delegated to lint:* scripts",
58
+ "lint:eslint": "eslint src",
59
+ "typecheck:tsc": "tsc --noEmit"
60
+ }
61
+ }
@@ -0,0 +1,75 @@
1
+ import { FileTreeContextMenuGroups, JupyterFileService } from '@difizen/libro-jupyter';
2
+ import type { CommandRegistry, MenuRegistry, ViewManager } from '@difizen/mana-app';
3
+ import {
4
+ ConfigurationService,
5
+ CommandContribution,
6
+ FileStatNode,
7
+ inject,
8
+ MenuContribution,
9
+ ModalService,
10
+ OpenerService,
11
+ singleton,
12
+ } from '@difizen/mana-app';
13
+ import { l10n } from '@difizen/mana-l10n';
14
+ import { message } from 'antd';
15
+
16
+ export const AppFileCommands = {
17
+ OPEN_FILE_BY_LIBRO_APP: {
18
+ id: 'fileTree.command.openfilebyapp',
19
+ label: '以报告的形式打开',
20
+ },
21
+ };
22
+
23
+ @singleton({
24
+ contrib: [CommandContribution, MenuContribution],
25
+ })
26
+ export class AppFileCommandContribution
27
+ implements CommandContribution, MenuContribution
28
+ {
29
+ protected viewManager: ViewManager;
30
+ @inject(JupyterFileService) fileService: JupyterFileService;
31
+ @inject(ModalService) modalService: ModalService;
32
+ @inject(OpenerService) protected openService: OpenerService;
33
+ @inject(ConfigurationService) configurationService: ConfigurationService;
34
+
35
+ registerMenus(menu: MenuRegistry) {
36
+ menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
37
+ id: AppFileCommands.OPEN_FILE_BY_LIBRO_APP.id,
38
+ command: AppFileCommands.OPEN_FILE_BY_LIBRO_APP.id,
39
+ label: () => <div>{l10n.t(AppFileCommands.OPEN_FILE_BY_LIBRO_APP.label)}</div>,
40
+ order: 'e',
41
+ });
42
+ }
43
+ registerCommands(command: CommandRegistry): void {
44
+ command.registerCommand(AppFileCommands.OPEN_FILE_BY_LIBRO_APP, {
45
+ execute: (node) => {
46
+ try {
47
+ if (node.fileStat.isFile) {
48
+ this.openService
49
+ .getOpener(node.uri, {
50
+ isApp: true,
51
+ })
52
+ .then((opener) => {
53
+ if (opener) {
54
+ opener.open(node.uri, {
55
+ viewOptions: {
56
+ name: node.fileStat.name,
57
+ },
58
+ });
59
+ }
60
+ return;
61
+ })
62
+ .catch(() => {
63
+ throw Error();
64
+ });
65
+ }
66
+ } catch {
67
+ message.error(l10n.t('文件打开失败'));
68
+ }
69
+ },
70
+ isVisible: (node) => {
71
+ return FileStatNode.is(node) && node.fileStat.isFile;
72
+ },
73
+ });
74
+ }
75
+ }
@@ -0,0 +1,46 @@
1
+ import { LibroJupyterConfiguration } from '@difizen/libro-jupyter';
2
+ import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
3
+ import { ConfigurationService, inject } from '@difizen/mana-app';
4
+ import {
5
+ NavigatableViewOpenHandler,
6
+ OpenHandler,
7
+ singleton,
8
+ Priority,
9
+ } from '@difizen/mana-app';
10
+
11
+ import type { LibroAppViewer } from './app-viewer.js';
12
+ import { AppViewerFactory } from './protocol.js';
13
+
14
+ interface AppOpenHandlerOptions extends ViewOpenHandlerOptions {
15
+ isApp?: boolean;
16
+ }
17
+ @singleton({ contrib: OpenHandler })
18
+ export class LibroAppOpenHandler extends NavigatableViewOpenHandler<LibroAppViewer> {
19
+ @inject(ConfigurationService) protected configurationService: ConfigurationService;
20
+
21
+ id = AppViewerFactory;
22
+
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ canHandle(uri: URI, _options?: AppOpenHandlerOptions) {
25
+ if (uri.scheme === 'file' && uri.path.ext === '.ipynb' && _options?.isApp) {
26
+ return Priority.PRIOR + 2;
27
+ }
28
+ return Priority.IDLE;
29
+ }
30
+
31
+ override async open(uri: URI, options: AppOpenHandlerOptions = {}) {
32
+ const { viewOptions, ...extra } = options;
33
+ const slot = await this.configurationService.get(
34
+ LibroJupyterConfiguration['OpenSlot'],
35
+ );
36
+ return super.open(uri, {
37
+ slot,
38
+ viewOptions: {
39
+ path: uri.path.toString(),
40
+ ...viewOptions,
41
+ },
42
+ reveal: true,
43
+ ...extra,
44
+ });
45
+ }
46
+ }
@@ -0,0 +1,142 @@
1
+ import type { LibroView } from '@difizen/libro-jupyter';
2
+ import {
3
+ ExecutableCellView,
4
+ LibroService,
5
+ CellCollapsible,
6
+ ArrowDown,
7
+ ArrowRight,
8
+ PlusOutlined,
9
+ } from '@difizen/libro-jupyter';
10
+ import {
11
+ BaseView,
12
+ inject,
13
+ prop,
14
+ transient,
15
+ useInject,
16
+ view,
17
+ ViewInstance,
18
+ ViewOption,
19
+ ViewRender,
20
+ } from '@difizen/mana-app';
21
+ import { l10n } from '@difizen/mana-l10n';
22
+ import type { RadioChangeEvent } from 'antd';
23
+ import { Radio, Button } from 'antd';
24
+ import type { ReactElement } from 'react';
25
+ import { forwardRef } from 'react';
26
+ import './index.less';
27
+
28
+ export const AppViewComponent = forwardRef(function LibroAppComponent() {
29
+ const instance = useInject<LibroAppView>(ViewInstance);
30
+
31
+ if (!instance.libroView || !instance.libroView.view) {
32
+ return null;
33
+ }
34
+
35
+ const handleSizeChange = (e: RadioChangeEvent) => {
36
+ instance.mode = e.target.value;
37
+ };
38
+ let children: ReactElement | null = null;
39
+ if (instance.mode === 'notebook') {
40
+ children = instance.libroView ? (
41
+ <ViewRender view={instance.libroView}></ViewRender>
42
+ ) : null;
43
+ } else {
44
+ children = (
45
+ <div className="libro-app-cell-list">
46
+ {instance.libroView?.model.cells.map((cell) => {
47
+ if (cell.collapsedHidden) {
48
+ return null;
49
+ }
50
+ if (ExecutableCellView.is(cell)) {
51
+ return <ViewRender view={cell.outputArea} key={cell.id}></ViewRender>;
52
+ } else {
53
+ const isCollapsible = CellCollapsible.is(cell);
54
+ return (
55
+ <>
56
+ {instance.libroView?.collapserVisible && isCollapsible && (
57
+ <div className="libro-app-cell-container">
58
+ <div
59
+ className="libro-markdown-collapser"
60
+ onClick={() => {
61
+ instance.libroView?.collapseCell(cell, !cell.headingCollapsed);
62
+ }}
63
+ >
64
+ {cell.headingCollapsed ? <ArrowRight /> : <ArrowDown />}
65
+ </div>
66
+ <ViewRender view={cell}></ViewRender>
67
+ {isCollapsible &&
68
+ cell.headingCollapsed &&
69
+ cell.collapsibleChildNumber > 0 && (
70
+ <div className="libro-cell-collapsed-expander">
71
+ <Button
72
+ className="libro-cell-expand-button"
73
+ onClick={() =>
74
+ instance.libroView?.collapseCell(cell, false)
75
+ }
76
+ icon={<PlusOutlined className="" />}
77
+ type="default"
78
+ >
79
+ {cell.collapsibleChildNumber} cell hidden
80
+ </Button>
81
+ </div>
82
+ )}
83
+ </div>
84
+ )}
85
+ </>
86
+ );
87
+ }
88
+ })}
89
+ </div>
90
+ );
91
+ }
92
+ return (
93
+ <div className="libro-app-container">
94
+ <div className="libro-app-container-header">
95
+ <Radio.Group value={instance.mode} onChange={handleSizeChange}>
96
+ <Radio.Button value="app">{l10n.t('报告预览')}</Radio.Button>
97
+ <Radio.Button value="notebook">notebook</Radio.Button>
98
+ </Radio.Group>
99
+ </div>
100
+ <div className="libro-app-container-content">{children}</div>
101
+ </div>
102
+ );
103
+ });
104
+
105
+ @transient()
106
+ @view('libro-app')
107
+ export class LibroAppView extends BaseView {
108
+ @inject(LibroService) protected libroService: LibroService;
109
+ override view = AppViewComponent;
110
+
111
+ @prop() libroView?: LibroView;
112
+ path: string;
113
+
114
+ @prop()
115
+ mode = 'app';
116
+
117
+ constructor(@inject(ViewOption) options: { path: string }) {
118
+ super();
119
+ this.path = options.path;
120
+ }
121
+
122
+ override onViewMount(): void {
123
+ this.getOrCreateLibroView();
124
+ }
125
+
126
+ protected async getOrCreateLibroView() {
127
+ const libroView = await this.libroService.getOrCreateView({
128
+ id: this.path,
129
+ resource: this.path,
130
+ });
131
+ if (!libroView) {
132
+ return;
133
+ }
134
+ libroView.model.cellsEditable = false;
135
+ libroView.model.runnable = false;
136
+ libroView.model.inputEditable = false;
137
+ libroView.model.outputEditable = false;
138
+ libroView.model.savable = false;
139
+ this.libroView = libroView;
140
+ await this.libroView.initialized;
141
+ }
142
+ }