@brftech/filex-core 0.1.56 → 0.1.61
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 -21
- package/README.md +108 -108
- package/dist/{ArchiveViewer-CJdaw5x3.js → ArchiveViewer-CbUUEREI.js} +20 -20
- package/dist/ArchiveViewer-CbUUEREI.js.map +1 -0
- package/dist/{CsvViewer-QYx_tePQ.js → CsvViewer-72rDsQJX.js} +3 -3
- package/dist/CsvViewer-72rDsQJX.js.map +1 -0
- package/dist/{DrawioViewer-GWt0TyB7.js → DrawioViewer-DSyMwGvg.js} +7 -7
- package/dist/DrawioViewer-DSyMwGvg.js.map +1 -0
- package/dist/{EpubViewer-Je0ywklQ.js → EpubViewer-DvDa17d7.js} +3 -3
- package/dist/EpubViewer-DvDa17d7.js.map +1 -0
- package/dist/{IpynbViewer-TsB4gqP-.js → IpynbViewer-DibIkdsz.js} +3 -3
- package/dist/IpynbViewer-DibIkdsz.js.map +1 -0
- package/dist/{MermaidViewer-CXfeDS-7.js → MermaidViewer-BoFLtGvl.js} +3 -3
- package/dist/MermaidViewer-BoFLtGvl.js.map +1 -0
- package/dist/{PsdViewer-VtPpxKVe.js → PsdViewer-K2iZkwax.js} +3 -3
- package/dist/PsdViewer-K2iZkwax.js.map +1 -0
- package/dist/{TiffViewer-OINn9bbb.js → TiffViewer-JzDzbqpO.js} +3 -3
- package/dist/TiffViewer-JzDzbqpO.js.map +1 -0
- package/dist/{Viewer3D-xvvyiWHd.js → Viewer3D-WEMYCP8l.js} +7 -7
- package/dist/Viewer3D-WEMYCP8l.js.map +1 -0
- package/dist/filex-core.js +1 -1
- package/dist/filex-core.umd.cjs +4 -4
- package/dist/filex-core.umd.cjs.map +1 -1
- package/dist/{index-CmSYzt6L.js → index-B5YT-m5Q.js} +209 -209
- package/dist/index-B5YT-m5Q.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/useViewerFetch-czqbd2Lj.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Breadcrumb.vue +282 -282
- package/src/components/ContextMenu.vue +152 -152
- package/src/components/GridView.vue +166 -166
- package/src/components/ListView.vue +212 -212
- package/src/components/PendingOpsTray.vue +91 -91
- package/src/components/RecentlyOpened.vue +155 -155
- package/src/components/StarButton.vue +101 -101
- package/src/components/TagPicker.vue +184 -184
- package/src/components/Toolbar.vue +220 -220
- package/src/components/UploadProgress.vue +78 -78
- package/src/composables/useFileApi.ts +692 -692
- package/src/composables/useKeyboardShortcuts.ts +144 -144
- package/src/composables/useLocale.ts +60 -60
- package/src/composables/useMonacoLoader.ts +98 -98
- package/src/composables/usePendingOps.ts +200 -200
- package/src/composables/useSelection.ts +81 -81
- package/src/composables/useUploadChunked.ts +250 -250
- package/src/composables/useViewerFetch.ts +58 -58
- package/src/index.ts +80 -80
- package/src/locales/en.ts +122 -122
- package/src/locales/index.ts +12 -12
- package/src/locales/tr.ts +122 -122
- package/src/modals/DeleteConfirmModal.vue +32 -32
- package/src/modals/Modal.vue +104 -104
- package/src/modals/NewFolderModal.vue +64 -64
- package/src/modals/PermissionsModal.vue +815 -815
- package/src/modals/PreviewModal.vue +1070 -1070
- package/src/modals/RenameModal.vue +58 -58
- package/src/modals/ShareModal.vue +135 -135
- package/src/styles/base.css +1224 -1224
- package/src/styles/variables.css +90 -90
- package/src/types/FileNode.ts +136 -136
- package/src/types/index.ts +27 -27
- package/src/types/peers.d.ts +45 -45
- package/src/viewers/ArchiveViewer.vue +186 -186
- package/src/viewers/CsvViewer.vue +319 -319
- package/src/viewers/DrawioViewer.vue +243 -243
- package/src/viewers/EpubViewer.vue +307 -307
- package/src/viewers/IpynbViewer.vue +365 -365
- package/src/viewers/MermaidViewer.vue +259 -259
- package/src/viewers/PdfViewer.vue +562 -562
- package/src/viewers/PsdViewer.vue +264 -264
- package/src/viewers/TiffViewer.vue +273 -273
- package/src/viewers/Viewer3D.vue +120 -120
- package/dist/ArchiveViewer-CJdaw5x3.js.map +0 -1
- package/dist/CsvViewer-QYx_tePQ.js.map +0 -1
- package/dist/DrawioViewer-GWt0TyB7.js.map +0 -1
- package/dist/EpubViewer-Je0ywklQ.js.map +0 -1
- package/dist/IpynbViewer-TsB4gqP-.js.map +0 -1
- package/dist/MermaidViewer-CXfeDS-7.js.map +0 -1
- package/dist/PsdViewer-VtPpxKVe.js.map +0 -1
- package/dist/TiffViewer-OINn9bbb.js.map +0 -1
- package/dist/Viewer3D-xvvyiWHd.js.map +0 -1
- package/dist/index-CmSYzt6L.js.map +0 -1
|
@@ -1,307 +1,307 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* EpubViewer — flowable EPUB reader via `epubjs`.
|
|
4
|
-
*
|
|
5
|
-
* Lazy-imports `epubjs` (~80 KB gzipped). epub.js renders the publication
|
|
6
|
-
* inside an iframe (default `flow: 'paginated'`), but we use it in
|
|
7
|
-
* scrolled-doc mode only when the user toggles the "fit-width" flag — by
|
|
8
|
-
* default we keep paginated since that matches reader-app expectations.
|
|
9
|
-
*
|
|
10
|
-
* UX:
|
|
11
|
-
* - prev/next page buttons (also keyboard arrow keys via composable)
|
|
12
|
-
* - collapsible TOC sidebar (built from `book.loaded.navigation`)
|
|
13
|
-
* - font size +/- (Themes API)
|
|
14
|
-
* - graceful fallback if peer not installed
|
|
15
|
-
*/
|
|
16
|
-
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
17
|
-
|
|
18
|
-
const props = defineProps<{
|
|
19
|
-
url: string;
|
|
20
|
-
mime?: string;
|
|
21
|
-
ext: string;
|
|
22
|
-
t?: (key: string) => string;
|
|
23
|
-
authHeaders?: () => Record<string, string>;
|
|
24
|
-
authCredentials?: RequestCredentials;
|
|
25
|
-
}>();
|
|
26
|
-
|
|
27
|
-
interface TocNode {
|
|
28
|
-
href: string;
|
|
29
|
-
label: string;
|
|
30
|
-
subitems?: TocNode[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const root = ref<HTMLDivElement | null>(null);
|
|
34
|
-
const containerRef = ref<HTMLDivElement | null>(null);
|
|
35
|
-
const error = ref<string | null>(null);
|
|
36
|
-
const toc = ref<TocNode[]>([]);
|
|
37
|
-
const tocOpen = ref(false);
|
|
38
|
-
const fontSize = ref(100);
|
|
39
|
-
const ready = ref(false);
|
|
40
|
-
const loading = ref(true);
|
|
41
|
-
|
|
42
|
-
let book: any = null;
|
|
43
|
-
let rendition: any = null;
|
|
44
|
-
|
|
45
|
-
async function load(): Promise<void> {
|
|
46
|
-
loading.value = true;
|
|
47
|
-
ready.value = false;
|
|
48
|
-
error.value = null;
|
|
49
|
-
let mod: any = null;
|
|
50
|
-
try {
|
|
51
|
-
mod = await import(/* @vite-ignore */ 'epubjs');
|
|
52
|
-
} catch {
|
|
53
|
-
error.value = props.t
|
|
54
|
-
? props.t('viewer.peer_not_installed')
|
|
55
|
-
: 'EPUB viewer requires `epubjs` — install or use download.';
|
|
56
|
-
loading.value = false;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
const Epub = mod.default ?? mod;
|
|
61
|
-
// epub.js wants a URL (it then fetches with XHR). When the host
|
|
62
|
-
// site requires auth headers we have to load the file ourselves
|
|
63
|
-
// and pass an ArrayBuffer instead.
|
|
64
|
-
let source: string | ArrayBuffer = props.url;
|
|
65
|
-
if (props.authHeaders) {
|
|
66
|
-
const headers = props.authHeaders();
|
|
67
|
-
const res = await fetch(props.url, {
|
|
68
|
-
headers,
|
|
69
|
-
credentials: props.authCredentials || 'same-origin',
|
|
70
|
-
});
|
|
71
|
-
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
|
|
72
|
-
source = await res.arrayBuffer();
|
|
73
|
-
}
|
|
74
|
-
book = Epub(source);
|
|
75
|
-
if (!containerRef.value) {
|
|
76
|
-
throw new Error('EPUB mount target missing');
|
|
77
|
-
}
|
|
78
|
-
rendition = book.renderTo(containerRef.value, {
|
|
79
|
-
width: '100%',
|
|
80
|
-
height: '100%',
|
|
81
|
-
flow: 'paginated',
|
|
82
|
-
manager: 'default',
|
|
83
|
-
});
|
|
84
|
-
await rendition.display();
|
|
85
|
-
rendition.themes.fontSize(fontSize.value + '%');
|
|
86
|
-
const nav = await book.loaded.navigation;
|
|
87
|
-
toc.value = (nav?.toc ?? []) as TocNode[];
|
|
88
|
-
ready.value = true;
|
|
89
|
-
} catch (err) {
|
|
90
|
-
error.value =
|
|
91
|
-
err instanceof Error ? err.message : 'EPUB load failed';
|
|
92
|
-
} finally {
|
|
93
|
-
loading.value = false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function next(): void {
|
|
98
|
-
rendition?.next?.();
|
|
99
|
-
}
|
|
100
|
-
function prev(): void {
|
|
101
|
-
rendition?.prev?.();
|
|
102
|
-
}
|
|
103
|
-
function gotoHref(href: string): void {
|
|
104
|
-
rendition?.display?.(href);
|
|
105
|
-
tocOpen.value = false;
|
|
106
|
-
}
|
|
107
|
-
function bigger(): void {
|
|
108
|
-
fontSize.value = Math.min(200, fontSize.value + 10);
|
|
109
|
-
rendition?.themes?.fontSize(fontSize.value + '%');
|
|
110
|
-
}
|
|
111
|
-
function smaller(): void {
|
|
112
|
-
fontSize.value = Math.max(60, fontSize.value - 10);
|
|
113
|
-
rendition?.themes?.fontSize(fontSize.value + '%');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function onKey(ev: KeyboardEvent): void {
|
|
117
|
-
if (ev.key === 'ArrowRight' || ev.key === 'PageDown') next();
|
|
118
|
-
else if (ev.key === 'ArrowLeft' || ev.key === 'PageUp') prev();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
onMounted(() => {
|
|
122
|
-
load();
|
|
123
|
-
window.addEventListener('keydown', onKey);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
onBeforeUnmount(() => {
|
|
127
|
-
window.removeEventListener('keydown', onKey);
|
|
128
|
-
try {
|
|
129
|
-
rendition?.destroy?.();
|
|
130
|
-
} catch {
|
|
131
|
-
/* ignore */
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
book?.destroy?.();
|
|
135
|
-
} catch {
|
|
136
|
-
/* ignore */
|
|
137
|
-
}
|
|
138
|
-
rendition = null;
|
|
139
|
-
book = null;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
watch(
|
|
143
|
-
() => props.url,
|
|
144
|
-
() => {
|
|
145
|
-
if (rendition) {
|
|
146
|
-
try {
|
|
147
|
-
rendition.destroy();
|
|
148
|
-
} catch {
|
|
149
|
-
/* ignore */
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (book) {
|
|
153
|
-
try {
|
|
154
|
-
book.destroy();
|
|
155
|
-
} catch {
|
|
156
|
-
/* ignore */
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
book = null;
|
|
160
|
-
rendition = null;
|
|
161
|
-
load();
|
|
162
|
-
},
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
function tt(key: string, fallback: string): string {
|
|
166
|
-
return props.t ? props.t(key) : fallback;
|
|
167
|
-
}
|
|
168
|
-
</script>
|
|
169
|
-
|
|
170
|
-
<template>
|
|
171
|
-
<div ref="root" class="filex-viewer-epub">
|
|
172
|
-
<div v-if="error" class="filex-viewer-fallback">
|
|
173
|
-
<span class="filex-viewer-fallback__icon">📖</span>
|
|
174
|
-
<p>{{ error }}</p>
|
|
175
|
-
</div>
|
|
176
|
-
<template v-else>
|
|
177
|
-
<div ref="containerRef" class="filex-viewer-epub__rendition" />
|
|
178
|
-
<div v-if="ready" class="filex-viewer-epub__nav">
|
|
179
|
-
<button type="button" class="filex-viewer-btn" @click="prev" :disabled="!ready">‹</button>
|
|
180
|
-
<button type="button" class="filex-viewer-btn" @click="next" :disabled="!ready">›</button>
|
|
181
|
-
</div>
|
|
182
|
-
<div v-if="loading" class="filex-viewer-epub__loading">
|
|
183
|
-
{{ tt('viewer.loading', 'Loading…') }}
|
|
184
|
-
</div>
|
|
185
|
-
</template>
|
|
186
|
-
</div>
|
|
187
|
-
</template>
|
|
188
|
-
|
|
189
|
-
<style scoped>
|
|
190
|
-
.filex-viewer-epub__nav {
|
|
191
|
-
position: absolute;
|
|
192
|
-
bottom: 12px;
|
|
193
|
-
left: 50%;
|
|
194
|
-
transform: translateX(-50%);
|
|
195
|
-
display: flex;
|
|
196
|
-
gap: 8px;
|
|
197
|
-
padding: 4px 8px;
|
|
198
|
-
background: var(--fe-bg-elev, rgba(255, 255, 255, 0.9));
|
|
199
|
-
border: 1px solid var(--fe-border, #e2e6ed);
|
|
200
|
-
border-radius: 6px;
|
|
201
|
-
backdrop-filter: blur(4px);
|
|
202
|
-
}
|
|
203
|
-
.filex-viewer-epub {
|
|
204
|
-
display: flex;
|
|
205
|
-
flex-direction: column;
|
|
206
|
-
width: 100%;
|
|
207
|
-
height: 100%;
|
|
208
|
-
min-height: 70vh;
|
|
209
|
-
background: var(--fe-bg, #fff);
|
|
210
|
-
color: var(--fe-text, #1a1e27);
|
|
211
|
-
position: relative;
|
|
212
|
-
}
|
|
213
|
-
.filex-viewer-epub__bar {
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
gap: 6px;
|
|
217
|
-
padding: 8px 12px;
|
|
218
|
-
background: var(--fe-bg-elev, #f7f8fa);
|
|
219
|
-
border-bottom: 1px solid var(--fe-border, #e2e6ed);
|
|
220
|
-
font-size: 13px;
|
|
221
|
-
}
|
|
222
|
-
.filex-viewer-spacer { flex: 1; }
|
|
223
|
-
.filex-viewer-epub__fs {
|
|
224
|
-
display: inline-block;
|
|
225
|
-
min-width: 40px;
|
|
226
|
-
text-align: center;
|
|
227
|
-
font-variant-numeric: tabular-nums;
|
|
228
|
-
font-size: 12px;
|
|
229
|
-
color: var(--fe-text-muted, #5a6475);
|
|
230
|
-
}
|
|
231
|
-
.filex-viewer-epub__main {
|
|
232
|
-
flex: 1;
|
|
233
|
-
min-height: 0;
|
|
234
|
-
display: flex;
|
|
235
|
-
}
|
|
236
|
-
.filex-viewer-epub__rendition {
|
|
237
|
-
flex: 1;
|
|
238
|
-
min-height: 0;
|
|
239
|
-
}
|
|
240
|
-
.filex-viewer-epub__toc {
|
|
241
|
-
width: 260px;
|
|
242
|
-
border-right: 1px solid var(--fe-border, #e2e6ed);
|
|
243
|
-
overflow-y: auto;
|
|
244
|
-
padding: 12px 0;
|
|
245
|
-
background: var(--fe-bg-elev, #f7f8fa);
|
|
246
|
-
}
|
|
247
|
-
.filex-viewer-epub__toc ul {
|
|
248
|
-
list-style: none;
|
|
249
|
-
margin: 0;
|
|
250
|
-
padding: 0;
|
|
251
|
-
}
|
|
252
|
-
.filex-viewer-epub__toc-link {
|
|
253
|
-
display: block;
|
|
254
|
-
width: 100%;
|
|
255
|
-
text-align: left;
|
|
256
|
-
background: transparent;
|
|
257
|
-
border: 0;
|
|
258
|
-
padding: 6px 14px;
|
|
259
|
-
font: inherit;
|
|
260
|
-
color: inherit;
|
|
261
|
-
cursor: pointer;
|
|
262
|
-
}
|
|
263
|
-
.filex-viewer-epub__toc-link:hover {
|
|
264
|
-
background: var(--fe-bg-hover, #edf0f5);
|
|
265
|
-
}
|
|
266
|
-
.filex-viewer-epub__toc-link.is-child {
|
|
267
|
-
padding-left: 28px;
|
|
268
|
-
color: var(--fe-text-muted, #5a6475);
|
|
269
|
-
font-size: 12px;
|
|
270
|
-
}
|
|
271
|
-
.filex-viewer-epub__loading {
|
|
272
|
-
position: absolute;
|
|
273
|
-
inset: auto 0 0 0;
|
|
274
|
-
text-align: center;
|
|
275
|
-
padding: 6px;
|
|
276
|
-
background: rgba(0, 0, 0, 0.05);
|
|
277
|
-
font-size: 12px;
|
|
278
|
-
color: var(--fe-text-muted, #5a6475);
|
|
279
|
-
}
|
|
280
|
-
.filex-viewer-fallback {
|
|
281
|
-
text-align: center;
|
|
282
|
-
padding: 32px;
|
|
283
|
-
color: var(--fe-text-muted, #5a6475);
|
|
284
|
-
}
|
|
285
|
-
.filex-viewer-fallback__icon {
|
|
286
|
-
font-size: 48px;
|
|
287
|
-
display: block;
|
|
288
|
-
margin-bottom: 12px;
|
|
289
|
-
}
|
|
290
|
-
.filex-viewer-btn {
|
|
291
|
-
border: 1px solid var(--fe-border, #e2e6ed);
|
|
292
|
-
background: var(--fe-bg, #fff);
|
|
293
|
-
color: var(--fe-text, #1a1e27);
|
|
294
|
-
padding: 4px 10px;
|
|
295
|
-
border-radius: 4px;
|
|
296
|
-
cursor: pointer;
|
|
297
|
-
font: inherit;
|
|
298
|
-
font-size: 12px;
|
|
299
|
-
}
|
|
300
|
-
.filex-viewer-btn:hover:not(:disabled) {
|
|
301
|
-
background: var(--fe-bg-hover, #edf0f5);
|
|
302
|
-
}
|
|
303
|
-
.filex-viewer-btn:disabled {
|
|
304
|
-
opacity: 0.5;
|
|
305
|
-
cursor: not-allowed;
|
|
306
|
-
}
|
|
307
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* EpubViewer — flowable EPUB reader via `epubjs`.
|
|
4
|
+
*
|
|
5
|
+
* Lazy-imports `epubjs` (~80 KB gzipped). epub.js renders the publication
|
|
6
|
+
* inside an iframe (default `flow: 'paginated'`), but we use it in
|
|
7
|
+
* scrolled-doc mode only when the user toggles the "fit-width" flag — by
|
|
8
|
+
* default we keep paginated since that matches reader-app expectations.
|
|
9
|
+
*
|
|
10
|
+
* UX:
|
|
11
|
+
* - prev/next page buttons (also keyboard arrow keys via composable)
|
|
12
|
+
* - collapsible TOC sidebar (built from `book.loaded.navigation`)
|
|
13
|
+
* - font size +/- (Themes API)
|
|
14
|
+
* - graceful fallback if peer not installed
|
|
15
|
+
*/
|
|
16
|
+
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
17
|
+
|
|
18
|
+
const props = defineProps<{
|
|
19
|
+
url: string;
|
|
20
|
+
mime?: string;
|
|
21
|
+
ext: string;
|
|
22
|
+
t?: (key: string) => string;
|
|
23
|
+
authHeaders?: () => Record<string, string>;
|
|
24
|
+
authCredentials?: RequestCredentials;
|
|
25
|
+
}>();
|
|
26
|
+
|
|
27
|
+
interface TocNode {
|
|
28
|
+
href: string;
|
|
29
|
+
label: string;
|
|
30
|
+
subitems?: TocNode[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const root = ref<HTMLDivElement | null>(null);
|
|
34
|
+
const containerRef = ref<HTMLDivElement | null>(null);
|
|
35
|
+
const error = ref<string | null>(null);
|
|
36
|
+
const toc = ref<TocNode[]>([]);
|
|
37
|
+
const tocOpen = ref(false);
|
|
38
|
+
const fontSize = ref(100);
|
|
39
|
+
const ready = ref(false);
|
|
40
|
+
const loading = ref(true);
|
|
41
|
+
|
|
42
|
+
let book: any = null;
|
|
43
|
+
let rendition: any = null;
|
|
44
|
+
|
|
45
|
+
async function load(): Promise<void> {
|
|
46
|
+
loading.value = true;
|
|
47
|
+
ready.value = false;
|
|
48
|
+
error.value = null;
|
|
49
|
+
let mod: any = null;
|
|
50
|
+
try {
|
|
51
|
+
mod = await import(/* @vite-ignore */ 'epubjs');
|
|
52
|
+
} catch {
|
|
53
|
+
error.value = props.t
|
|
54
|
+
? props.t('viewer.peer_not_installed')
|
|
55
|
+
: 'EPUB viewer requires `epubjs` — install or use download.';
|
|
56
|
+
loading.value = false;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const Epub = mod.default ?? mod;
|
|
61
|
+
// epub.js wants a URL (it then fetches with XHR). When the host
|
|
62
|
+
// site requires auth headers we have to load the file ourselves
|
|
63
|
+
// and pass an ArrayBuffer instead.
|
|
64
|
+
let source: string | ArrayBuffer = props.url;
|
|
65
|
+
if (props.authHeaders) {
|
|
66
|
+
const headers = props.authHeaders();
|
|
67
|
+
const res = await fetch(props.url, {
|
|
68
|
+
headers,
|
|
69
|
+
credentials: props.authCredentials || 'same-origin',
|
|
70
|
+
});
|
|
71
|
+
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
|
|
72
|
+
source = await res.arrayBuffer();
|
|
73
|
+
}
|
|
74
|
+
book = Epub(source);
|
|
75
|
+
if (!containerRef.value) {
|
|
76
|
+
throw new Error('EPUB mount target missing');
|
|
77
|
+
}
|
|
78
|
+
rendition = book.renderTo(containerRef.value, {
|
|
79
|
+
width: '100%',
|
|
80
|
+
height: '100%',
|
|
81
|
+
flow: 'paginated',
|
|
82
|
+
manager: 'default',
|
|
83
|
+
});
|
|
84
|
+
await rendition.display();
|
|
85
|
+
rendition.themes.fontSize(fontSize.value + '%');
|
|
86
|
+
const nav = await book.loaded.navigation;
|
|
87
|
+
toc.value = (nav?.toc ?? []) as TocNode[];
|
|
88
|
+
ready.value = true;
|
|
89
|
+
} catch (err) {
|
|
90
|
+
error.value =
|
|
91
|
+
err instanceof Error ? err.message : 'EPUB load failed';
|
|
92
|
+
} finally {
|
|
93
|
+
loading.value = false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function next(): void {
|
|
98
|
+
rendition?.next?.();
|
|
99
|
+
}
|
|
100
|
+
function prev(): void {
|
|
101
|
+
rendition?.prev?.();
|
|
102
|
+
}
|
|
103
|
+
function gotoHref(href: string): void {
|
|
104
|
+
rendition?.display?.(href);
|
|
105
|
+
tocOpen.value = false;
|
|
106
|
+
}
|
|
107
|
+
function bigger(): void {
|
|
108
|
+
fontSize.value = Math.min(200, fontSize.value + 10);
|
|
109
|
+
rendition?.themes?.fontSize(fontSize.value + '%');
|
|
110
|
+
}
|
|
111
|
+
function smaller(): void {
|
|
112
|
+
fontSize.value = Math.max(60, fontSize.value - 10);
|
|
113
|
+
rendition?.themes?.fontSize(fontSize.value + '%');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function onKey(ev: KeyboardEvent): void {
|
|
117
|
+
if (ev.key === 'ArrowRight' || ev.key === 'PageDown') next();
|
|
118
|
+
else if (ev.key === 'ArrowLeft' || ev.key === 'PageUp') prev();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
onMounted(() => {
|
|
122
|
+
load();
|
|
123
|
+
window.addEventListener('keydown', onKey);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
onBeforeUnmount(() => {
|
|
127
|
+
window.removeEventListener('keydown', onKey);
|
|
128
|
+
try {
|
|
129
|
+
rendition?.destroy?.();
|
|
130
|
+
} catch {
|
|
131
|
+
/* ignore */
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
book?.destroy?.();
|
|
135
|
+
} catch {
|
|
136
|
+
/* ignore */
|
|
137
|
+
}
|
|
138
|
+
rendition = null;
|
|
139
|
+
book = null;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
watch(
|
|
143
|
+
() => props.url,
|
|
144
|
+
() => {
|
|
145
|
+
if (rendition) {
|
|
146
|
+
try {
|
|
147
|
+
rendition.destroy();
|
|
148
|
+
} catch {
|
|
149
|
+
/* ignore */
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (book) {
|
|
153
|
+
try {
|
|
154
|
+
book.destroy();
|
|
155
|
+
} catch {
|
|
156
|
+
/* ignore */
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
book = null;
|
|
160
|
+
rendition = null;
|
|
161
|
+
load();
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
function tt(key: string, fallback: string): string {
|
|
166
|
+
return props.t ? props.t(key) : fallback;
|
|
167
|
+
}
|
|
168
|
+
</script>
|
|
169
|
+
|
|
170
|
+
<template>
|
|
171
|
+
<div ref="root" class="filex-viewer-epub">
|
|
172
|
+
<div v-if="error" class="filex-viewer-fallback">
|
|
173
|
+
<span class="filex-viewer-fallback__icon">📖</span>
|
|
174
|
+
<p>{{ error }}</p>
|
|
175
|
+
</div>
|
|
176
|
+
<template v-else>
|
|
177
|
+
<div ref="containerRef" class="filex-viewer-epub__rendition" />
|
|
178
|
+
<div v-if="ready" class="filex-viewer-epub__nav">
|
|
179
|
+
<button type="button" class="filex-viewer-btn" @click="prev" :disabled="!ready">‹</button>
|
|
180
|
+
<button type="button" class="filex-viewer-btn" @click="next" :disabled="!ready">›</button>
|
|
181
|
+
</div>
|
|
182
|
+
<div v-if="loading" class="filex-viewer-epub__loading">
|
|
183
|
+
{{ tt('viewer.loading', 'Loading…') }}
|
|
184
|
+
</div>
|
|
185
|
+
</template>
|
|
186
|
+
</div>
|
|
187
|
+
</template>
|
|
188
|
+
|
|
189
|
+
<style scoped>
|
|
190
|
+
.filex-viewer-epub__nav {
|
|
191
|
+
position: absolute;
|
|
192
|
+
bottom: 12px;
|
|
193
|
+
left: 50%;
|
|
194
|
+
transform: translateX(-50%);
|
|
195
|
+
display: flex;
|
|
196
|
+
gap: 8px;
|
|
197
|
+
padding: 4px 8px;
|
|
198
|
+
background: var(--fe-bg-elev, rgba(255, 255, 255, 0.9));
|
|
199
|
+
border: 1px solid var(--fe-border, #e2e6ed);
|
|
200
|
+
border-radius: 6px;
|
|
201
|
+
backdrop-filter: blur(4px);
|
|
202
|
+
}
|
|
203
|
+
.filex-viewer-epub {
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-direction: column;
|
|
206
|
+
width: 100%;
|
|
207
|
+
height: 100%;
|
|
208
|
+
min-height: 70vh;
|
|
209
|
+
background: var(--fe-bg, #fff);
|
|
210
|
+
color: var(--fe-text, #1a1e27);
|
|
211
|
+
position: relative;
|
|
212
|
+
}
|
|
213
|
+
.filex-viewer-epub__bar {
|
|
214
|
+
display: flex;
|
|
215
|
+
align-items: center;
|
|
216
|
+
gap: 6px;
|
|
217
|
+
padding: 8px 12px;
|
|
218
|
+
background: var(--fe-bg-elev, #f7f8fa);
|
|
219
|
+
border-bottom: 1px solid var(--fe-border, #e2e6ed);
|
|
220
|
+
font-size: 13px;
|
|
221
|
+
}
|
|
222
|
+
.filex-viewer-spacer { flex: 1; }
|
|
223
|
+
.filex-viewer-epub__fs {
|
|
224
|
+
display: inline-block;
|
|
225
|
+
min-width: 40px;
|
|
226
|
+
text-align: center;
|
|
227
|
+
font-variant-numeric: tabular-nums;
|
|
228
|
+
font-size: 12px;
|
|
229
|
+
color: var(--fe-text-muted, #5a6475);
|
|
230
|
+
}
|
|
231
|
+
.filex-viewer-epub__main {
|
|
232
|
+
flex: 1;
|
|
233
|
+
min-height: 0;
|
|
234
|
+
display: flex;
|
|
235
|
+
}
|
|
236
|
+
.filex-viewer-epub__rendition {
|
|
237
|
+
flex: 1;
|
|
238
|
+
min-height: 0;
|
|
239
|
+
}
|
|
240
|
+
.filex-viewer-epub__toc {
|
|
241
|
+
width: 260px;
|
|
242
|
+
border-right: 1px solid var(--fe-border, #e2e6ed);
|
|
243
|
+
overflow-y: auto;
|
|
244
|
+
padding: 12px 0;
|
|
245
|
+
background: var(--fe-bg-elev, #f7f8fa);
|
|
246
|
+
}
|
|
247
|
+
.filex-viewer-epub__toc ul {
|
|
248
|
+
list-style: none;
|
|
249
|
+
margin: 0;
|
|
250
|
+
padding: 0;
|
|
251
|
+
}
|
|
252
|
+
.filex-viewer-epub__toc-link {
|
|
253
|
+
display: block;
|
|
254
|
+
width: 100%;
|
|
255
|
+
text-align: left;
|
|
256
|
+
background: transparent;
|
|
257
|
+
border: 0;
|
|
258
|
+
padding: 6px 14px;
|
|
259
|
+
font: inherit;
|
|
260
|
+
color: inherit;
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
}
|
|
263
|
+
.filex-viewer-epub__toc-link:hover {
|
|
264
|
+
background: var(--fe-bg-hover, #edf0f5);
|
|
265
|
+
}
|
|
266
|
+
.filex-viewer-epub__toc-link.is-child {
|
|
267
|
+
padding-left: 28px;
|
|
268
|
+
color: var(--fe-text-muted, #5a6475);
|
|
269
|
+
font-size: 12px;
|
|
270
|
+
}
|
|
271
|
+
.filex-viewer-epub__loading {
|
|
272
|
+
position: absolute;
|
|
273
|
+
inset: auto 0 0 0;
|
|
274
|
+
text-align: center;
|
|
275
|
+
padding: 6px;
|
|
276
|
+
background: rgba(0, 0, 0, 0.05);
|
|
277
|
+
font-size: 12px;
|
|
278
|
+
color: var(--fe-text-muted, #5a6475);
|
|
279
|
+
}
|
|
280
|
+
.filex-viewer-fallback {
|
|
281
|
+
text-align: center;
|
|
282
|
+
padding: 32px;
|
|
283
|
+
color: var(--fe-text-muted, #5a6475);
|
|
284
|
+
}
|
|
285
|
+
.filex-viewer-fallback__icon {
|
|
286
|
+
font-size: 48px;
|
|
287
|
+
display: block;
|
|
288
|
+
margin-bottom: 12px;
|
|
289
|
+
}
|
|
290
|
+
.filex-viewer-btn {
|
|
291
|
+
border: 1px solid var(--fe-border, #e2e6ed);
|
|
292
|
+
background: var(--fe-bg, #fff);
|
|
293
|
+
color: var(--fe-text, #1a1e27);
|
|
294
|
+
padding: 4px 10px;
|
|
295
|
+
border-radius: 4px;
|
|
296
|
+
cursor: pointer;
|
|
297
|
+
font: inherit;
|
|
298
|
+
font-size: 12px;
|
|
299
|
+
}
|
|
300
|
+
.filex-viewer-btn:hover:not(:disabled) {
|
|
301
|
+
background: var(--fe-bg-hover, #edf0f5);
|
|
302
|
+
}
|
|
303
|
+
.filex-viewer-btn:disabled {
|
|
304
|
+
opacity: 0.5;
|
|
305
|
+
cursor: not-allowed;
|
|
306
|
+
}
|
|
307
|
+
</style>
|