@brftech/filex-core 0.1.56
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 +108 -0
- package/dist/ArchiveViewer-CJdaw5x3.js +99 -0
- package/dist/ArchiveViewer-CJdaw5x3.js.map +1 -0
- package/dist/CsvViewer-QYx_tePQ.js +132 -0
- package/dist/CsvViewer-QYx_tePQ.js.map +1 -0
- package/dist/DrawioViewer-GWt0TyB7.js +141 -0
- package/dist/DrawioViewer-GWt0TyB7.js.map +1 -0
- package/dist/EpubViewer-Je0ywklQ.js +146 -0
- package/dist/EpubViewer-Je0ywklQ.js.map +1 -0
- package/dist/IpynbViewer-TsB4gqP-.js +175 -0
- package/dist/IpynbViewer-TsB4gqP-.js.map +1 -0
- package/dist/MermaidViewer-CXfeDS-7.js +128 -0
- package/dist/MermaidViewer-CXfeDS-7.js.map +1 -0
- package/dist/PsdViewer-VtPpxKVe.js +113 -0
- package/dist/PsdViewer-VtPpxKVe.js.map +1 -0
- package/dist/TiffViewer-OINn9bbb.js +133 -0
- package/dist/TiffViewer-OINn9bbb.js.map +1 -0
- package/dist/UTIF-Cjsrlm0l.js +3104 -0
- package/dist/UTIF-Cjsrlm0l.js.map +1 -0
- package/dist/Viewer3D-xvvyiWHd.js +61 -0
- package/dist/Viewer3D-xvvyiWHd.js.map +1 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +9 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js.map +1 -0
- package/dist/filex-core.js +26 -0
- package/dist/filex-core.js.map +1 -0
- package/dist/filex-core.umd.cjs +285 -0
- package/dist/filex-core.umd.cjs.map +1 -0
- package/dist/index-CmSYzt6L.js +5404 -0
- package/dist/index-CmSYzt6L.js.map +1 -0
- package/dist/index-UFULWo35.js +10736 -0
- package/dist/index-UFULWo35.js.map +1 -0
- package/dist/index.d.ts +1089 -0
- package/dist/katex-yuB6V-q6.js +11616 -0
- package/dist/katex-yuB6V-q6.js.map +1 -0
- package/dist/papaparse.min-VB1HBwYX.js +441 -0
- package/dist/papaparse.min-VB1HBwYX.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/useViewerFetch-czqbd2Lj.js +25 -0
- package/dist/useViewerFetch-czqbd2Lj.js.map +1 -0
- package/package.json +113 -0
- package/src/FileExplorer.vue +1872 -0
- package/src/components/Breadcrumb.vue +282 -0
- package/src/components/ContextMenu.vue +152 -0
- package/src/components/GridView.vue +166 -0
- package/src/components/ListView.vue +212 -0
- package/src/components/PendingOpsTray.vue +91 -0
- package/src/components/RecentlyOpened.vue +155 -0
- package/src/components/StarButton.vue +101 -0
- package/src/components/TagPicker.vue +184 -0
- package/src/components/Toolbar.vue +220 -0
- package/src/components/UploadProgress.vue +78 -0
- package/src/composables/useFileApi.ts +692 -0
- package/src/composables/useKeyboardShortcuts.ts +144 -0
- package/src/composables/useLocale.ts +60 -0
- package/src/composables/useMonacoLoader.ts +98 -0
- package/src/composables/usePendingOps.ts +200 -0
- package/src/composables/useSelection.ts +81 -0
- package/src/composables/useUploadChunked.ts +250 -0
- package/src/composables/useViewerFetch.ts +58 -0
- package/src/index.ts +80 -0
- package/src/locales/en.ts +122 -0
- package/src/locales/index.ts +12 -0
- package/src/locales/tr.ts +122 -0
- package/src/modals/ConvertModal.vue +254 -0
- package/src/modals/DeleteConfirmModal.vue +32 -0
- package/src/modals/Modal.vue +104 -0
- package/src/modals/NewFolderModal.vue +64 -0
- package/src/modals/PermissionsModal.vue +815 -0
- package/src/modals/PreviewModal.vue +1070 -0
- package/src/modals/RenameModal.vue +58 -0
- package/src/modals/ShareModal.vue +135 -0
- package/src/styles/base.css +1224 -0
- package/src/styles/variables.css +90 -0
- package/src/types/ExplorerConfig.ts +282 -0
- package/src/types/FileNode.ts +136 -0
- package/src/types/index.ts +27 -0
- package/src/types/peers.d.ts +45 -0
- package/src/viewers/ArchiveViewer.vue +186 -0
- package/src/viewers/CsvViewer.vue +319 -0
- package/src/viewers/DrawioViewer.vue +243 -0
- package/src/viewers/EpubViewer.vue +307 -0
- package/src/viewers/IpynbViewer.vue +365 -0
- package/src/viewers/MermaidViewer.vue +259 -0
- package/src/viewers/PdfViewer.vue +562 -0
- package/src/viewers/PsdViewer.vue +264 -0
- package/src/viewers/TiffViewer.vue +273 -0
- package/src/viewers/Viewer3D.vue +120 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* DrawioViewer — embed diagrams.net via iframe + postMessage handshake.
|
|
4
|
+
*
|
|
5
|
+
* The diagrams.net embed mode (`?embed=1&proto=json`) handshakes via
|
|
6
|
+
* window.postMessage:
|
|
7
|
+
*
|
|
8
|
+
* 1. iframe sends {event:'init'} ← bootstrap
|
|
9
|
+
* 2. parent sends {action:'load', xml} ← our payload
|
|
10
|
+
* 3. iframe sends {event:'save', xml} on save ← we POST back
|
|
11
|
+
*
|
|
12
|
+
* No external library required — diagrams.net hosts the entire editor
|
|
13
|
+
* inside the iframe. We just fetch the source XML on mount and route
|
|
14
|
+
* `save` events back to the configured `pdfSaveUrl`-style endpoint
|
|
15
|
+
* (drawio uses the same shape: POST `{path, content}` body).
|
|
16
|
+
*/
|
|
17
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
18
|
+
import { fetchViewerText } from '../composables/useViewerFetch';
|
|
19
|
+
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
url: string;
|
|
22
|
+
filePath: string;
|
|
23
|
+
ext: string;
|
|
24
|
+
drawioUrl?: string;
|
|
25
|
+
/** Optional save endpoint. When unset the iframe stays read-only. */
|
|
26
|
+
saveUrl?: string;
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
t?: (key: string) => string;
|
|
29
|
+
authHeaders?: () => Record<string, string>;
|
|
30
|
+
authCredentials?: RequestCredentials;
|
|
31
|
+
}>();
|
|
32
|
+
|
|
33
|
+
const iframeRef = ref<HTMLIFrameElement | null>(null);
|
|
34
|
+
const error = ref<string | null>(null);
|
|
35
|
+
const status = ref<'loading' | 'ready' | 'saving' | 'saved' | 'error'>('loading');
|
|
36
|
+
const readOnly = ref(!!props.readOnly || !props.saveUrl);
|
|
37
|
+
|
|
38
|
+
// drawioUrl=null is the operator's "off" signal — FileExplorer wipes it
|
|
39
|
+
// when the capabilities probe reports drawio offline. Don't silently fall
|
|
40
|
+
// back to the public embed.diagrams.net iframe, that defeats the point of
|
|
41
|
+
// gating: render a "not configured" pane instead so the user understands
|
|
42
|
+
// why the editor isn't loading.
|
|
43
|
+
//
|
|
44
|
+
// `drawioBase` MUST be a computed (not a const), otherwise a stale null
|
|
45
|
+
// at mount time (capabilities probe still inflight) gets cached for the
|
|
46
|
+
// component's lifetime — leading to the spurious
|
|
47
|
+
// "viewer.drawio.disabled" fallback after the capability flips to "ok".
|
|
48
|
+
const drawioBase = computed<string | null>(() =>
|
|
49
|
+
props.drawioUrl ? props.drawioUrl.replace(/\/$/, '') : null,
|
|
50
|
+
);
|
|
51
|
+
const iframeSrc = computed<string>(() => {
|
|
52
|
+
if (!drawioBase.value) return '';
|
|
53
|
+
const params = new URLSearchParams({
|
|
54
|
+
embed: '1',
|
|
55
|
+
proto: 'json',
|
|
56
|
+
spin: '1',
|
|
57
|
+
saveAndExit: '0',
|
|
58
|
+
noSaveBtn: readOnly.value ? '1' : '0',
|
|
59
|
+
noExitBtn: '1',
|
|
60
|
+
ui: 'kennedy',
|
|
61
|
+
modified: 'unsavedChanges',
|
|
62
|
+
});
|
|
63
|
+
return `${drawioBase.value}/?${params.toString()}`;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
let pendingXml: string = '';
|
|
67
|
+
|
|
68
|
+
async function loadXml(): Promise<void> {
|
|
69
|
+
status.value = 'loading';
|
|
70
|
+
error.value = null;
|
|
71
|
+
try {
|
|
72
|
+
pendingXml = await fetchViewerText({
|
|
73
|
+
url: props.url,
|
|
74
|
+
headers: props.authHeaders?.() ?? {},
|
|
75
|
+
credentials: props.authCredentials,
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
error.value = err instanceof Error ? err.message : 'fetch failed';
|
|
79
|
+
status.value = 'error';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function send(msg: unknown): void {
|
|
84
|
+
iframeRef.value?.contentWindow?.postMessage(JSON.stringify(msg), '*');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function persist(xml: string): Promise<void> {
|
|
88
|
+
if (!props.saveUrl) return;
|
|
89
|
+
status.value = 'saving';
|
|
90
|
+
try {
|
|
91
|
+
const headers: Record<string, string> = {
|
|
92
|
+
'Content-Type': 'application/json',
|
|
93
|
+
...(props.authHeaders?.() ?? {}),
|
|
94
|
+
};
|
|
95
|
+
const res = await fetch(props.saveUrl, {
|
|
96
|
+
method: 'POST',
|
|
97
|
+
headers,
|
|
98
|
+
credentials: props.authCredentials || 'same-origin',
|
|
99
|
+
body: JSON.stringify({ path: props.filePath, content: xml }),
|
|
100
|
+
});
|
|
101
|
+
if (!res.ok) {
|
|
102
|
+
throw new Error(`${res.status} ${res.statusText}`);
|
|
103
|
+
}
|
|
104
|
+
status.value = 'saved';
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
if (status.value === 'saved') status.value = 'ready';
|
|
107
|
+
}, 2500);
|
|
108
|
+
} catch (err) {
|
|
109
|
+
error.value = err instanceof Error ? err.message : 'save failed';
|
|
110
|
+
status.value = 'error';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function onMessage(ev: MessageEvent): void {
|
|
115
|
+
if (typeof ev.data !== 'string' || ev.data.length === 0) return;
|
|
116
|
+
// Drawio messages always start with '{' or '<'. Ignore anything else
|
|
117
|
+
// (devtools / unrelated postMessage senders inside the same window).
|
|
118
|
+
const first = ev.data[0];
|
|
119
|
+
if (first !== '{' && first !== '<') return;
|
|
120
|
+
let payload: any;
|
|
121
|
+
try {
|
|
122
|
+
payload = JSON.parse(ev.data);
|
|
123
|
+
} catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!payload || typeof payload !== 'object') return;
|
|
127
|
+
switch (payload.event) {
|
|
128
|
+
case 'init':
|
|
129
|
+
send({
|
|
130
|
+
action: 'load',
|
|
131
|
+
xml: pendingXml,
|
|
132
|
+
autosave: 0,
|
|
133
|
+
});
|
|
134
|
+
status.value = 'ready';
|
|
135
|
+
break;
|
|
136
|
+
case 'save':
|
|
137
|
+
if (typeof payload.xml === 'string') {
|
|
138
|
+
persist(payload.xml);
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
case 'export':
|
|
142
|
+
// Could persist a PNG/SVG render; out of V1 scope.
|
|
143
|
+
break;
|
|
144
|
+
case 'autosave':
|
|
145
|
+
if (typeof payload.xml === 'string' && !readOnly.value) {
|
|
146
|
+
persist(payload.xml);
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function bootIfReady(): void {
|
|
155
|
+
if (!drawioBase.value) {
|
|
156
|
+
error.value = tt('viewer.drawio.disabled', 'Drawio (diagrams.net) yapılandırılmamış.');
|
|
157
|
+
status.value = 'error';
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
// Clear a previous "disabled" error in case the prop just became
|
|
161
|
+
// available (capability probe finished after mount).
|
|
162
|
+
if (error.value === tt('viewer.drawio.disabled', 'Drawio (diagrams.net) yapılandırılmamış.')) {
|
|
163
|
+
error.value = null;
|
|
164
|
+
status.value = 'loading';
|
|
165
|
+
}
|
|
166
|
+
loadXml();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
onMounted(() => {
|
|
170
|
+
window.addEventListener('message', onMessage);
|
|
171
|
+
bootIfReady();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
watch(() => props.drawioUrl, bootIfReady);
|
|
175
|
+
|
|
176
|
+
onBeforeUnmount(() => {
|
|
177
|
+
window.removeEventListener('message', onMessage);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
function tt(key: string, fallback: string): string {
|
|
181
|
+
return props.t ? props.t(key) : fallback;
|
|
182
|
+
}
|
|
183
|
+
</script>
|
|
184
|
+
|
|
185
|
+
<template>
|
|
186
|
+
<div class="filex-viewer-drawio">
|
|
187
|
+
<div v-if="error" class="filex-viewer-fallback">
|
|
188
|
+
<span class="filex-viewer-fallback__icon">📐</span>
|
|
189
|
+
<p>{{ error }}</p>
|
|
190
|
+
</div>
|
|
191
|
+
<iframe
|
|
192
|
+
v-else
|
|
193
|
+
ref="iframeRef"
|
|
194
|
+
:src="iframeSrc"
|
|
195
|
+
class="filex-viewer-drawio__frame"
|
|
196
|
+
title="diagrams.net editor"
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
</template>
|
|
200
|
+
|
|
201
|
+
<style scoped>
|
|
202
|
+
.filex-viewer-drawio {
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
width: 100%;
|
|
206
|
+
height: 100%;
|
|
207
|
+
min-height: 70vh;
|
|
208
|
+
background: var(--fe-bg, #fff);
|
|
209
|
+
}
|
|
210
|
+
.filex-viewer-drawio__bar {
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
gap: 12px;
|
|
214
|
+
padding: 6px 12px;
|
|
215
|
+
background: var(--fe-bg-elev, #f7f8fa);
|
|
216
|
+
border-bottom: 1px solid var(--fe-border, #e2e6ed);
|
|
217
|
+
font-size: 12px;
|
|
218
|
+
color: var(--fe-text-muted, #5a6475);
|
|
219
|
+
}
|
|
220
|
+
.filex-viewer-drawio__status[data-state="error"] { color: var(--fe-danger, #dc2626); }
|
|
221
|
+
.filex-viewer-drawio__status[data-state="saved"] { color: #059669; }
|
|
222
|
+
.filex-viewer-drawio__readonly {
|
|
223
|
+
font-style: italic;
|
|
224
|
+
margin-left: auto;
|
|
225
|
+
}
|
|
226
|
+
.filex-viewer-drawio__frame {
|
|
227
|
+
flex: 1;
|
|
228
|
+
width: 100%;
|
|
229
|
+
border: 0;
|
|
230
|
+
background: #fafafa;
|
|
231
|
+
min-height: 0;
|
|
232
|
+
}
|
|
233
|
+
.filex-viewer-fallback {
|
|
234
|
+
text-align: center;
|
|
235
|
+
padding: 32px;
|
|
236
|
+
color: var(--fe-text-muted, #5a6475);
|
|
237
|
+
}
|
|
238
|
+
.filex-viewer-fallback__icon {
|
|
239
|
+
font-size: 48px;
|
|
240
|
+
display: block;
|
|
241
|
+
margin-bottom: 12px;
|
|
242
|
+
}
|
|
243
|
+
</style>
|
|
@@ -0,0 +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>
|