@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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/es/app-file-command-contribution.d.ts +19 -0
- package/es/app-file-command-contribution.d.ts.map +1 -0
- package/es/app-file-command-contribution.js +100 -0
- package/es/app-open-handler.d.ts +15 -0
- package/es/app-open-handler.d.ts.map +1 -0
- package/es/app-open-handler.js +102 -0
- package/es/app-view.d.ts +19 -0
- package/es/app-view.d.ts.map +1 -0
- package/es/app-view.js +191 -0
- package/es/app-viewer.d.ts +21 -0
- package/es/app-viewer.d.ts.map +1 -0
- package/es/app-viewer.js +99 -0
- package/es/index.d.ts +2 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +1 -0
- package/es/index.less +147 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +6 -0
- package/es/protocol.d.ts +2 -0
- package/es/protocol.d.ts.map +1 -0
- package/es/protocol.js +1 -0
- package/package.json +61 -0
- package/src/app-file-command-contribution.tsx +75 -0
- package/src/app-open-handler.ts +46 -0
- package/src/app-view.tsx +142 -0
- package/src/app-viewer.tsx +85 -0
- package/src/index.less +147 -0
- package/src/index.spec.ts +8 -0
- package/src/index.ts +1 -0
- package/src/module.ts +13 -0
- package/src/protocol.ts +1 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { NavigatableView } from '@difizen/mana-app';
|
|
2
|
+
import { ViewRender, ViewManager } from '@difizen/mana-app';
|
|
3
|
+
import {
|
|
4
|
+
BaseView,
|
|
5
|
+
inject,
|
|
6
|
+
LabelProvider,
|
|
7
|
+
prop,
|
|
8
|
+
transient,
|
|
9
|
+
URI as VScodeURI,
|
|
10
|
+
URIIconReference,
|
|
11
|
+
useInject,
|
|
12
|
+
view,
|
|
13
|
+
ViewInstance,
|
|
14
|
+
ViewOption,
|
|
15
|
+
Deferred,
|
|
16
|
+
URI,
|
|
17
|
+
CommandRegistry,
|
|
18
|
+
} from '@difizen/mana-app';
|
|
19
|
+
import { forwardRef } from 'react';
|
|
20
|
+
|
|
21
|
+
import './index.less';
|
|
22
|
+
import { LibroAppView } from './app-view.js';
|
|
23
|
+
import { AppViewerFactory } from './protocol.js';
|
|
24
|
+
|
|
25
|
+
export const AppViewerComponent = forwardRef(function LibroEditorComponent() {
|
|
26
|
+
const instance = useInject<LibroAppViewer>(ViewInstance);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="libro-app-viewer-container">
|
|
30
|
+
{instance.appView && <ViewRender view={instance.appView}></ViewRender>}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
@transient()
|
|
36
|
+
@view(AppViewerFactory)
|
|
37
|
+
export class LibroAppViewer extends BaseView implements NavigatableView {
|
|
38
|
+
@inject(CommandRegistry) commandRegistry: CommandRegistry;
|
|
39
|
+
|
|
40
|
+
override view = AppViewerComponent;
|
|
41
|
+
|
|
42
|
+
@prop()
|
|
43
|
+
appView?: LibroAppView;
|
|
44
|
+
|
|
45
|
+
@prop() filePath?: string;
|
|
46
|
+
|
|
47
|
+
protected defer = new Deferred<void>();
|
|
48
|
+
|
|
49
|
+
get ready() {
|
|
50
|
+
return this.defer.promise;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor(
|
|
54
|
+
@inject(ViewOption) options: { path: string },
|
|
55
|
+
@inject(LabelProvider) labelProvider: LabelProvider,
|
|
56
|
+
@inject(ViewManager) viewManager: ViewManager,
|
|
57
|
+
) {
|
|
58
|
+
super();
|
|
59
|
+
this.filePath = options.path;
|
|
60
|
+
this.title.caption = options.path;
|
|
61
|
+
const uri = new URI(options.path);
|
|
62
|
+
viewManager
|
|
63
|
+
.getOrCreateView(LibroAppView, options)
|
|
64
|
+
.then((appView) => {
|
|
65
|
+
this.appView = appView;
|
|
66
|
+
return;
|
|
67
|
+
})
|
|
68
|
+
.catch(() => {
|
|
69
|
+
//
|
|
70
|
+
});
|
|
71
|
+
const uriRef = URIIconReference.create('file', new VScodeURI(options.path));
|
|
72
|
+
const iconClass = labelProvider.getIcon(uriRef);
|
|
73
|
+
this.title.icon = <div className={iconClass} />;
|
|
74
|
+
this.title.label = uri.displayName;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getResourceUri(): URI | undefined {
|
|
78
|
+
return new URI(this.filePath);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
createMoveToUri(resourceUri: URI): URI | undefined {
|
|
82
|
+
this.filePath = resourceUri.path.toString();
|
|
83
|
+
return resourceUri;
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/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/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './module.js';
|
package/src/module.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { AppFileCommandContribution } from './app-file-command-contribution.js';
|
|
4
|
+
import { LibroAppOpenHandler } from './app-open-handler.js';
|
|
5
|
+
import { LibroAppView } from './app-view.js';
|
|
6
|
+
import { LibroAppViewer } from './app-viewer.js';
|
|
7
|
+
|
|
8
|
+
export const LibroAppModule = ManaModule.create().register(
|
|
9
|
+
AppFileCommandContribution,
|
|
10
|
+
LibroAppOpenHandler,
|
|
11
|
+
LibroAppViewer,
|
|
12
|
+
LibroAppView,
|
|
13
|
+
);
|
package/src/protocol.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AppViewerFactory = 'libro-app-viewer';
|