@difizen/libro-lab 0.1.4 → 0.1.6
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/editor-viewer/code-editor-open-handler.d.ts +12 -0
- package/es/editor-viewer/code-editor-open-handler.d.ts.map +1 -0
- package/es/editor-viewer/code-editor-open-handler.js +101 -0
- package/es/editor-viewer/code-editor-viewer.d.ts +38 -0
- package/es/editor-viewer/code-editor-viewer.d.ts.map +1 -0
- package/es/editor-viewer/code-editor-viewer.js +235 -0
- package/es/editor-viewer/index.d.ts +3 -0
- package/es/editor-viewer/index.d.ts.map +1 -0
- package/es/editor-viewer/index.js +2 -0
- package/es/editor-viewer/index.less +3 -0
- package/es/editor-viewer/module.d.ts +3 -0
- package/es/editor-viewer/module.d.ts.map +1 -0
- package/es/editor-viewer/module.js +4 -0
- package/es/editor-viewer/protocol.d.ts +7 -0
- package/es/editor-viewer/protocol.d.ts.map +1 -0
- package/es/editor-viewer/protocol.js +1 -0
- package/es/image-viewer/index.d.ts +3 -0
- package/es/image-viewer/index.d.ts.map +1 -0
- package/es/image-viewer/index.js +2 -0
- package/es/image-viewer/index.less +3 -0
- package/es/image-viewer/module.d.ts +3 -0
- package/es/image-viewer/module.d.ts.map +1 -0
- package/es/image-viewer/module.js +4 -0
- package/es/image-viewer/open-handler.d.ts +11 -0
- package/es/image-viewer/open-handler.d.ts.map +1 -0
- package/es/image-viewer/open-handler.js +106 -0
- package/es/image-viewer/protocol.d.ts +10 -0
- package/es/image-viewer/protocol.d.ts.map +1 -0
- package/es/image-viewer/protocol.js +27 -0
- package/es/image-viewer/viewer.d.ts +29 -0
- package/es/image-viewer/viewer.d.ts.map +1 -0
- package/es/image-viewer/viewer.js +185 -0
- package/es/index.d.ts +11 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +12 -1
- package/es/layout/brand/{index.d.ts → brand.d.ts} +1 -1
- package/es/layout/brand/{index.d.ts.map → brand.d.ts.map} +1 -1
- package/es/layout/index.d.ts +8 -0
- package/es/layout/index.d.ts.map +1 -1
- package/es/layout/index.js +9 -1
- package/es/layout/layout.d.ts +1 -1
- package/es/layout/layout.d.ts.map +1 -1
- package/es/layout/layout.js +2 -2
- package/es/layout/module.js +1 -1
- package/es/menu/index.d.ts +5 -0
- package/es/menu/index.d.ts.map +1 -0
- package/es/menu/index.js +4 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +3 -1
- package/es/toc/index.d.ts +3 -0
- package/es/toc/index.d.ts.map +1 -0
- package/es/toc/index.js +2 -0
- package/es/welcome/index.d.ts +2 -12
- package/es/welcome/index.d.ts.map +1 -1
- package/es/welcome/index.js +2 -70
- package/es/welcome/welcome-view.d.ts +13 -0
- package/es/welcome/welcome-view.d.ts.map +1 -0
- package/es/welcome/welcome-view.js +70 -0
- package/package.json +13 -9
- package/src/editor-viewer/code-editor-open-handler.ts +42 -0
- package/src/editor-viewer/code-editor-viewer.tsx +183 -0
- package/src/editor-viewer/index.less +3 -0
- package/src/editor-viewer/index.ts +2 -0
- package/src/editor-viewer/module.ts +8 -0
- package/src/editor-viewer/protocol.ts +7 -0
- package/src/image-viewer/index.less +3 -0
- package/src/image-viewer/index.ts +2 -0
- package/src/image-viewer/module.ts +9 -0
- package/src/image-viewer/open-handler.ts +47 -0
- package/src/image-viewer/protocol.ts +43 -0
- package/src/image-viewer/viewer.tsx +131 -0
- package/src/index.ts +11 -0
- package/src/layout/index.tsx +8 -0
- package/src/layout/layout.tsx +3 -3
- package/src/layout/module.ts +1 -1
- package/src/menu/index.ts +4 -0
- package/src/module.tsx +4 -0
- package/src/toc/index.ts +2 -0
- package/src/welcome/index.ts +2 -0
- /package/es/layout/brand/{index.js → brand.js} +0 -0
- /package/src/layout/brand/{index.tsx → brand.tsx} +0 -0
- /package/src/welcome/{index.tsx → welcome-view.tsx} +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ContentsManager } from '@difizen/libro-kernel';
|
|
2
|
+
import type { NavigatableView } from '@difizen/mana-app';
|
|
3
|
+
import { DisposableCollection } from '@difizen/mana-app';
|
|
4
|
+
import {
|
|
5
|
+
BaseView,
|
|
6
|
+
inject,
|
|
7
|
+
LabelProvider,
|
|
8
|
+
prop,
|
|
9
|
+
transient,
|
|
10
|
+
URI as VScodeURI,
|
|
11
|
+
URIIconReference,
|
|
12
|
+
useInject,
|
|
13
|
+
view,
|
|
14
|
+
ViewInstance,
|
|
15
|
+
ViewOption,
|
|
16
|
+
Deferred,
|
|
17
|
+
URI,
|
|
18
|
+
CommandRegistry,
|
|
19
|
+
} from '@difizen/mana-app';
|
|
20
|
+
import { Spin } from 'antd';
|
|
21
|
+
import { createRef, forwardRef, useEffect, useRef } from 'react';
|
|
22
|
+
import Viewer from 'viewerjs';
|
|
23
|
+
import './index.less';
|
|
24
|
+
import 'viewerjs/dist/viewer.css';
|
|
25
|
+
|
|
26
|
+
export function ImageViewer() {
|
|
27
|
+
const instance = useInject<NavigatableImageViewerView>(ViewInstance);
|
|
28
|
+
const ref = useRef<HTMLImageElement>(null);
|
|
29
|
+
const content = instance.content;
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (ref && ref.current) {
|
|
32
|
+
new Viewer(ref.current, {
|
|
33
|
+
toolbar: {
|
|
34
|
+
prev: 0,
|
|
35
|
+
next: 0,
|
|
36
|
+
zoomIn: 4,
|
|
37
|
+
zoomOut: 4,
|
|
38
|
+
oneToOne: 4,
|
|
39
|
+
reset: 4,
|
|
40
|
+
play: {
|
|
41
|
+
show: 4,
|
|
42
|
+
size: 'large',
|
|
43
|
+
},
|
|
44
|
+
rotateLeft: 4,
|
|
45
|
+
rotateRight: 4,
|
|
46
|
+
flipHorizontal: 4,
|
|
47
|
+
flipVertical: 4,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, [content, ref]);
|
|
52
|
+
if (!content) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return <img ref={ref} src={`data:image/png;base64,${content}`} />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const NavigatableImageViewerComponent = forwardRef<HTMLDivElement>(
|
|
59
|
+
function LibroEditorComponent(props, ref) {
|
|
60
|
+
const instance = useInject<NavigatableImageViewerView>(ViewInstance);
|
|
61
|
+
const content = instance.content;
|
|
62
|
+
return (
|
|
63
|
+
<Spin spinning={!content}>
|
|
64
|
+
<div className="libro-lab-image-viewer" ref={ref}>
|
|
65
|
+
{content && <ImageViewer />}
|
|
66
|
+
</div>
|
|
67
|
+
</Spin>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export const NavigatableImageViewerViewFactoryId =
|
|
73
|
+
'navigatable-image-viewer-view-factory';
|
|
74
|
+
@transient()
|
|
75
|
+
@view(NavigatableImageViewerViewFactoryId)
|
|
76
|
+
export class NavigatableImageViewerView extends BaseView implements NavigatableView {
|
|
77
|
+
@inject(CommandRegistry) commandRegistry: CommandRegistry;
|
|
78
|
+
@inject(ContentsManager) contentsManager: ContentsManager;
|
|
79
|
+
|
|
80
|
+
protected readonly toDisposeOnAutoSave = new DisposableCollection();
|
|
81
|
+
|
|
82
|
+
override view = NavigatableImageViewerComponent;
|
|
83
|
+
|
|
84
|
+
codeRef = createRef<HTMLDivElement>();
|
|
85
|
+
|
|
86
|
+
@prop() filePath?: string;
|
|
87
|
+
@prop() content?: string;
|
|
88
|
+
|
|
89
|
+
protected defer = new Deferred<void>();
|
|
90
|
+
|
|
91
|
+
get ready() {
|
|
92
|
+
return this.defer.promise;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
constructor(
|
|
96
|
+
@inject(ViewOption) options: { path: string },
|
|
97
|
+
@inject(LabelProvider) labelProvider: LabelProvider,
|
|
98
|
+
) {
|
|
99
|
+
super();
|
|
100
|
+
this.filePath = options.path;
|
|
101
|
+
this.title.caption = options.path;
|
|
102
|
+
const uri = new URI(options.path);
|
|
103
|
+
const uriRef = URIIconReference.create('file', new VScodeURI(options.path));
|
|
104
|
+
const iconClass = labelProvider.getIcon(uriRef);
|
|
105
|
+
this.title.icon = <div className={iconClass} />;
|
|
106
|
+
this.title.label = uri.displayName;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getFileContent = async () => {
|
|
110
|
+
if (this.filePath) {
|
|
111
|
+
const content = await this.contentsManager.get(this.filePath, {
|
|
112
|
+
content: true,
|
|
113
|
+
format: 'base64',
|
|
114
|
+
});
|
|
115
|
+
this.content = content.content;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
override async onViewMount(): Promise<void> {
|
|
120
|
+
this.getFileContent();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
getResourceUri(): URI | undefined {
|
|
124
|
+
return new URI(this.filePath);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
createMoveToUri(resourceUri: URI): URI | undefined {
|
|
128
|
+
this.filePath = resourceUri.path.toString();
|
|
129
|
+
return resourceUri;
|
|
130
|
+
}
|
|
131
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
1
|
export * from './module.js';
|
|
2
|
+
export * from './lab-app.js';
|
|
3
|
+
export * from './github-link/index.js';
|
|
4
|
+
export * from './config/index.js';
|
|
5
|
+
export * from './layout/index.js';
|
|
6
|
+
export * from './menu/index.js';
|
|
7
|
+
export * from './toc/index.js';
|
|
8
|
+
export * from './welcome/index.js';
|
|
9
|
+
export * from './kernel-manager/index.js';
|
|
10
|
+
export * from './common/index.js';
|
|
11
|
+
export * from './image-viewer/index.js';
|
|
12
|
+
export * from './editor-viewer/index.js';
|
package/src/layout/index.tsx
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export * from './protocol.js';
|
|
2
2
|
export * from './module.js';
|
|
3
3
|
export * from './layout.js';
|
|
4
|
+
export * from './layout-service.js';
|
|
5
|
+
export * from './saveable-tab-view.js';
|
|
4
6
|
export * from './footer/footer-view.js';
|
|
7
|
+
export * from './footer/status-footer-view.js';
|
|
8
|
+
export * from './footer/current-file-footer-view.js';
|
|
9
|
+
export * from './brand/brand.js';
|
|
10
|
+
export * from './main.js';
|
|
11
|
+
export * from './container.js';
|
|
12
|
+
export * from './content-bottom-tab-view.js';
|
package/src/layout/layout.tsx
CHANGED
|
@@ -11,8 +11,8 @@ import type { VisibilityMap } from './layout-service.js';
|
|
|
11
11
|
import { LayoutService } from './layout-service.js';
|
|
12
12
|
import { LibroLabLayoutSlots } from './protocol.js';
|
|
13
13
|
|
|
14
|
-
export const
|
|
15
|
-
function
|
|
14
|
+
export const LibroLabLayoutComponent = forwardRef(
|
|
15
|
+
function LibroLabLayoutComponent() {
|
|
16
16
|
const layoutService = useInject(LayoutService);
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -46,7 +46,7 @@ export const LibroLabLayoutContainerComponent = forwardRef(
|
|
|
46
46
|
@singleton()
|
|
47
47
|
@view('libro-lab-layout')
|
|
48
48
|
export class LibroLabLayoutView extends BaseView {
|
|
49
|
-
override view =
|
|
49
|
+
override view = LibroLabLayoutComponent;
|
|
50
50
|
|
|
51
51
|
@inject(LayoutService) layoutService: LayoutService;
|
|
52
52
|
|
package/src/layout/module.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
ManaModule,
|
|
7
7
|
} from '@difizen/mana-app';
|
|
8
8
|
|
|
9
|
-
import { BrandView } from './brand/
|
|
9
|
+
import { BrandView } from './brand/brand.js';
|
|
10
10
|
import { LibroLabLayoutContainerView } from './container.js';
|
|
11
11
|
import { ContentBottomTabView } from './content-bottom-tab-view.js';
|
|
12
12
|
import { LibroLabCurrentFileFooterView } from './footer/current-file-footer-view.js';
|
package/src/module.tsx
CHANGED
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
} from '@difizen/mana-app';
|
|
12
12
|
|
|
13
13
|
import { LabConfigAppContribution } from './config/config-contribution.js';
|
|
14
|
+
import { CodeEditorViewerModule } from './editor-viewer/index.js';
|
|
14
15
|
import { GithubLinkView } from './github-link/index.js';
|
|
16
|
+
import { ImageViewerModule } from './image-viewer/index.js';
|
|
15
17
|
import { KernelManagerView } from './kernel-manager/index.js';
|
|
16
18
|
import { LibroLabApp } from './lab-app.js';
|
|
17
19
|
import { ContentBottomTabView } from './layout/content-bottom-tab-view.js';
|
|
@@ -98,4 +100,6 @@ export const LibroLabModule = ManaModule.create()
|
|
|
98
100
|
LibroLabTocModule,
|
|
99
101
|
LibroPromptCellModule,
|
|
100
102
|
TerminalModule,
|
|
103
|
+
ImageViewerModule,
|
|
104
|
+
CodeEditorViewerModule,
|
|
101
105
|
);
|
package/src/toc/index.ts
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|