@brftech/filex-core 0.1.56 → 0.1.60
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,273 +1,273 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* TiffViewer — multi-page TIFF preview via `utif`.
|
|
4
|
-
*
|
|
5
|
-
* Lazy-imports `utif` (~50 KB). Decodes IFDs once, paints the active
|
|
6
|
-
* page to a `<canvas>` via `UTIF.toRGBA8`. Page navigation (1/N) +
|
|
7
|
-
* zoom in/out controls. Browser <img> can't render TIFF natively, so
|
|
8
|
-
* the canvas pipeline is the only option short of server-side
|
|
9
|
-
* conversion.
|
|
10
|
-
*/
|
|
11
|
-
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
12
|
-
import { fetchViewerArrayBuffer } from '../composables/useViewerFetch';
|
|
13
|
-
|
|
14
|
-
const props = defineProps<{
|
|
15
|
-
url: string;
|
|
16
|
-
mime?: string;
|
|
17
|
-
ext: string;
|
|
18
|
-
t?: (key: string) => string;
|
|
19
|
-
authHeaders?: () => Record<string, string>;
|
|
20
|
-
authCredentials?: RequestCredentials;
|
|
21
|
-
}>();
|
|
22
|
-
|
|
23
|
-
const canvasEl = ref<HTMLCanvasElement | null>(null);
|
|
24
|
-
const error = ref<string | null>(null);
|
|
25
|
-
const loading = ref(true);
|
|
26
|
-
const scale = ref(1);
|
|
27
|
-
const pageIndex = ref(0);
|
|
28
|
-
const pageCount = ref(0);
|
|
29
|
-
const pageDims = ref<{ width: number; height: number }>({ width: 0, height: 0 });
|
|
30
|
-
|
|
31
|
-
let UTIF: any = null;
|
|
32
|
-
let ifds: any[] | null = null;
|
|
33
|
-
let renderToken = 0;
|
|
34
|
-
|
|
35
|
-
async function ensureUtif(): Promise<any | null> {
|
|
36
|
-
if (UTIF) return UTIF;
|
|
37
|
-
try {
|
|
38
|
-
const mod = await import(/* @vite-ignore */ 'utif');
|
|
39
|
-
UTIF = mod.default ?? mod;
|
|
40
|
-
return UTIF;
|
|
41
|
-
} catch {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function load(): Promise<void> {
|
|
47
|
-
loading.value = true;
|
|
48
|
-
error.value = null;
|
|
49
|
-
ifds = null;
|
|
50
|
-
pageIndex.value = 0;
|
|
51
|
-
pageCount.value = 0;
|
|
52
|
-
const myToken = ++renderToken;
|
|
53
|
-
|
|
54
|
-
const lib = await ensureUtif();
|
|
55
|
-
if (myToken !== renderToken) return;
|
|
56
|
-
if (!lib) {
|
|
57
|
-
error.value = props.t
|
|
58
|
-
? props.t('viewer.peer_not_installed')
|
|
59
|
-
: 'TIFF viewer requires `utif` — install or use download.';
|
|
60
|
-
loading.value = false;
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const buf = await fetchViewerArrayBuffer({
|
|
66
|
-
url: props.url,
|
|
67
|
-
headers: props.authHeaders?.() ?? {},
|
|
68
|
-
credentials: props.authCredentials,
|
|
69
|
-
});
|
|
70
|
-
if (myToken !== renderToken) return;
|
|
71
|
-
ifds = lib.decode(buf);
|
|
72
|
-
pageCount.value = ifds?.length ?? 0;
|
|
73
|
-
if (pageCount.value === 0) {
|
|
74
|
-
throw new Error('No pages decoded');
|
|
75
|
-
}
|
|
76
|
-
paint();
|
|
77
|
-
} catch (err) {
|
|
78
|
-
error.value = err instanceof Error ? err.message : 'TIFF decode failed';
|
|
79
|
-
} finally {
|
|
80
|
-
loading.value = false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function paint(): void {
|
|
85
|
-
if (!UTIF || !ifds || !canvasEl.value) return;
|
|
86
|
-
const idx = Math.max(0, Math.min(pageIndex.value, ifds.length - 1));
|
|
87
|
-
const ifd = ifds[idx];
|
|
88
|
-
try {
|
|
89
|
-
UTIF.decodeImage(undefined, ifd);
|
|
90
|
-
} catch {
|
|
91
|
-
// some images already decoded — UTIF.decodeImage is idempotent on
|
|
92
|
-
// older versions.
|
|
93
|
-
}
|
|
94
|
-
const rgba = UTIF.toRGBA8(ifd);
|
|
95
|
-
const w = ifd.width;
|
|
96
|
-
const h = ifd.height;
|
|
97
|
-
pageDims.value = { width: w, height: h };
|
|
98
|
-
const canvas = canvasEl.value;
|
|
99
|
-
canvas.width = w;
|
|
100
|
-
canvas.height = h;
|
|
101
|
-
const ctx = canvas.getContext('2d');
|
|
102
|
-
if (!ctx) return;
|
|
103
|
-
const imageData = ctx.createImageData(w, h);
|
|
104
|
-
imageData.data.set(rgba);
|
|
105
|
-
ctx.putImageData(imageData, 0, 0);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function next(): void {
|
|
109
|
-
if (pageIndex.value < pageCount.value - 1) {
|
|
110
|
-
pageIndex.value++;
|
|
111
|
-
paint();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function prev(): void {
|
|
115
|
-
if (pageIndex.value > 0) {
|
|
116
|
-
pageIndex.value--;
|
|
117
|
-
paint();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function zoomIn(): void {
|
|
121
|
-
scale.value = Math.min(8, scale.value * 1.25);
|
|
122
|
-
}
|
|
123
|
-
function zoomOut(): void {
|
|
124
|
-
scale.value = Math.max(0.1, scale.value / 1.25);
|
|
125
|
-
}
|
|
126
|
-
function reset(): void {
|
|
127
|
-
scale.value = 1;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
onMounted(load);
|
|
131
|
-
onBeforeUnmount(() => {
|
|
132
|
-
renderToken++;
|
|
133
|
-
ifds = null;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
watch(() => props.url, load);
|
|
137
|
-
|
|
138
|
-
const pageLabel = computed(() => {
|
|
139
|
-
const m = (props.t && props.t('viewer.page_n_of_m')) || 'Page {n} of {m}';
|
|
140
|
-
return m.replace('{n}', String(pageIndex.value + 1)).replace('{m}', String(pageCount.value));
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
function tt(key: string, fallback: string): string {
|
|
144
|
-
return props.t ? props.t(key) : fallback;
|
|
145
|
-
}
|
|
146
|
-
</script>
|
|
147
|
-
|
|
148
|
-
<template>
|
|
149
|
-
<div class="filex-viewer-tiff">
|
|
150
|
-
<div class="filex-viewer-tiff__pane">
|
|
151
|
-
<div v-if="error" class="filex-viewer-fallback">
|
|
152
|
-
<span class="filex-viewer-fallback__icon">🖼️</span>
|
|
153
|
-
<p>{{ error }}</p>
|
|
154
|
-
</div>
|
|
155
|
-
<div v-else-if="loading" class="filex-viewer-fallback">
|
|
156
|
-
<span class="filex-viewer-fallback__icon">⏳</span>
|
|
157
|
-
<p>{{ tt('viewer.loading', 'Loading…') }}</p>
|
|
158
|
-
</div>
|
|
159
|
-
<canvas
|
|
160
|
-
v-show="!loading && !error"
|
|
161
|
-
ref="canvasEl"
|
|
162
|
-
:style="{ imageRendering: 'pixelated' }"
|
|
163
|
-
/>
|
|
164
|
-
<div v-if="!loading && !error && pageCount > 1" class="filex-viewer-tiff__pager">
|
|
165
|
-
<button
|
|
166
|
-
type="button"
|
|
167
|
-
class="filex-viewer-btn"
|
|
168
|
-
:disabled="pageIndex === 0"
|
|
169
|
-
@click="prev"
|
|
170
|
-
>‹</button>
|
|
171
|
-
<span class="filex-viewer-tiff__pages">{{ pageLabel }}</span>
|
|
172
|
-
<button
|
|
173
|
-
type="button"
|
|
174
|
-
class="filex-viewer-btn"
|
|
175
|
-
:disabled="pageIndex >= pageCount - 1"
|
|
176
|
-
@click="next"
|
|
177
|
-
>›</button>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
</template>
|
|
182
|
-
|
|
183
|
-
<style scoped>
|
|
184
|
-
.filex-viewer-tiff__pager {
|
|
185
|
-
position: absolute;
|
|
186
|
-
bottom: 12px;
|
|
187
|
-
left: 50%;
|
|
188
|
-
transform: translateX(-50%);
|
|
189
|
-
display: flex;
|
|
190
|
-
align-items: center;
|
|
191
|
-
gap: 8px;
|
|
192
|
-
padding: 4px 8px;
|
|
193
|
-
background: var(--fe-bg-elev, rgba(255, 255, 255, 0.9));
|
|
194
|
-
border: 1px solid var(--fe-border, #e2e6ed);
|
|
195
|
-
border-radius: 6px;
|
|
196
|
-
backdrop-filter: blur(4px);
|
|
197
|
-
}
|
|
198
|
-
.filex-viewer-tiff__pages {
|
|
199
|
-
font-size: 12px;
|
|
200
|
-
font-variant-numeric: tabular-nums;
|
|
201
|
-
}
|
|
202
|
-
.filex-viewer-tiff {
|
|
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-tiff__bar {
|
|
211
|
-
display: flex;
|
|
212
|
-
align-items: center;
|
|
213
|
-
gap: 6px;
|
|
214
|
-
padding: 8px 12px;
|
|
215
|
-
background: var(--fe-bg-elev, #f7f8fa);
|
|
216
|
-
border-bottom: 1px solid var(--fe-border, #e2e6ed);
|
|
217
|
-
font-size: 13px;
|
|
218
|
-
}
|
|
219
|
-
.filex-viewer-tiff__pages {
|
|
220
|
-
min-width: 110px;
|
|
221
|
-
text-align: center;
|
|
222
|
-
font-variant-numeric: tabular-nums;
|
|
223
|
-
font-size: 12px;
|
|
224
|
-
}
|
|
225
|
-
.filex-viewer-tiff__zoom {
|
|
226
|
-
min-width: 50px;
|
|
227
|
-
text-align: center;
|
|
228
|
-
font-variant-numeric: tabular-nums;
|
|
229
|
-
font-size: 12px;
|
|
230
|
-
}
|
|
231
|
-
.filex-viewer-spacer { flex: 1; }
|
|
232
|
-
.filex-viewer-tiff__pane {
|
|
233
|
-
flex: 1;
|
|
234
|
-
overflow: auto;
|
|
235
|
-
padding: 16px;
|
|
236
|
-
background: #2a2d33;
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: flex-start;
|
|
239
|
-
justify-content: flex-start;
|
|
240
|
-
}
|
|
241
|
-
.filex-viewer-tiff__pane canvas {
|
|
242
|
-
background: #fff;
|
|
243
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
|
244
|
-
}
|
|
245
|
-
.filex-viewer-fallback {
|
|
246
|
-
text-align: center;
|
|
247
|
-
padding: 32px;
|
|
248
|
-
color: #c8cdd6;
|
|
249
|
-
margin: auto;
|
|
250
|
-
}
|
|
251
|
-
.filex-viewer-fallback__icon {
|
|
252
|
-
font-size: 48px;
|
|
253
|
-
display: block;
|
|
254
|
-
margin-bottom: 12px;
|
|
255
|
-
}
|
|
256
|
-
.filex-viewer-btn {
|
|
257
|
-
border: 1px solid var(--fe-border, #e2e6ed);
|
|
258
|
-
background: var(--fe-bg, #fff);
|
|
259
|
-
color: var(--fe-text, #1a1e27);
|
|
260
|
-
padding: 4px 10px;
|
|
261
|
-
border-radius: 4px;
|
|
262
|
-
cursor: pointer;
|
|
263
|
-
font: inherit;
|
|
264
|
-
font-size: 12px;
|
|
265
|
-
}
|
|
266
|
-
.filex-viewer-btn:hover:not(:disabled) {
|
|
267
|
-
background: var(--fe-bg-hover, #edf0f5);
|
|
268
|
-
}
|
|
269
|
-
.filex-viewer-btn:disabled {
|
|
270
|
-
opacity: 0.4;
|
|
271
|
-
cursor: not-allowed;
|
|
272
|
-
}
|
|
273
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* TiffViewer — multi-page TIFF preview via `utif`.
|
|
4
|
+
*
|
|
5
|
+
* Lazy-imports `utif` (~50 KB). Decodes IFDs once, paints the active
|
|
6
|
+
* page to a `<canvas>` via `UTIF.toRGBA8`. Page navigation (1/N) +
|
|
7
|
+
* zoom in/out controls. Browser <img> can't render TIFF natively, so
|
|
8
|
+
* the canvas pipeline is the only option short of server-side
|
|
9
|
+
* conversion.
|
|
10
|
+
*/
|
|
11
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
12
|
+
import { fetchViewerArrayBuffer } from '../composables/useViewerFetch';
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
url: string;
|
|
16
|
+
mime?: string;
|
|
17
|
+
ext: string;
|
|
18
|
+
t?: (key: string) => string;
|
|
19
|
+
authHeaders?: () => Record<string, string>;
|
|
20
|
+
authCredentials?: RequestCredentials;
|
|
21
|
+
}>();
|
|
22
|
+
|
|
23
|
+
const canvasEl = ref<HTMLCanvasElement | null>(null);
|
|
24
|
+
const error = ref<string | null>(null);
|
|
25
|
+
const loading = ref(true);
|
|
26
|
+
const scale = ref(1);
|
|
27
|
+
const pageIndex = ref(0);
|
|
28
|
+
const pageCount = ref(0);
|
|
29
|
+
const pageDims = ref<{ width: number; height: number }>({ width: 0, height: 0 });
|
|
30
|
+
|
|
31
|
+
let UTIF: any = null;
|
|
32
|
+
let ifds: any[] | null = null;
|
|
33
|
+
let renderToken = 0;
|
|
34
|
+
|
|
35
|
+
async function ensureUtif(): Promise<any | null> {
|
|
36
|
+
if (UTIF) return UTIF;
|
|
37
|
+
try {
|
|
38
|
+
const mod = await import(/* @vite-ignore */ 'utif');
|
|
39
|
+
UTIF = mod.default ?? mod;
|
|
40
|
+
return UTIF;
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function load(): Promise<void> {
|
|
47
|
+
loading.value = true;
|
|
48
|
+
error.value = null;
|
|
49
|
+
ifds = null;
|
|
50
|
+
pageIndex.value = 0;
|
|
51
|
+
pageCount.value = 0;
|
|
52
|
+
const myToken = ++renderToken;
|
|
53
|
+
|
|
54
|
+
const lib = await ensureUtif();
|
|
55
|
+
if (myToken !== renderToken) return;
|
|
56
|
+
if (!lib) {
|
|
57
|
+
error.value = props.t
|
|
58
|
+
? props.t('viewer.peer_not_installed')
|
|
59
|
+
: 'TIFF viewer requires `utif` — install or use download.';
|
|
60
|
+
loading.value = false;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const buf = await fetchViewerArrayBuffer({
|
|
66
|
+
url: props.url,
|
|
67
|
+
headers: props.authHeaders?.() ?? {},
|
|
68
|
+
credentials: props.authCredentials,
|
|
69
|
+
});
|
|
70
|
+
if (myToken !== renderToken) return;
|
|
71
|
+
ifds = lib.decode(buf);
|
|
72
|
+
pageCount.value = ifds?.length ?? 0;
|
|
73
|
+
if (pageCount.value === 0) {
|
|
74
|
+
throw new Error('No pages decoded');
|
|
75
|
+
}
|
|
76
|
+
paint();
|
|
77
|
+
} catch (err) {
|
|
78
|
+
error.value = err instanceof Error ? err.message : 'TIFF decode failed';
|
|
79
|
+
} finally {
|
|
80
|
+
loading.value = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function paint(): void {
|
|
85
|
+
if (!UTIF || !ifds || !canvasEl.value) return;
|
|
86
|
+
const idx = Math.max(0, Math.min(pageIndex.value, ifds.length - 1));
|
|
87
|
+
const ifd = ifds[idx];
|
|
88
|
+
try {
|
|
89
|
+
UTIF.decodeImage(undefined, ifd);
|
|
90
|
+
} catch {
|
|
91
|
+
// some images already decoded — UTIF.decodeImage is idempotent on
|
|
92
|
+
// older versions.
|
|
93
|
+
}
|
|
94
|
+
const rgba = UTIF.toRGBA8(ifd);
|
|
95
|
+
const w = ifd.width;
|
|
96
|
+
const h = ifd.height;
|
|
97
|
+
pageDims.value = { width: w, height: h };
|
|
98
|
+
const canvas = canvasEl.value;
|
|
99
|
+
canvas.width = w;
|
|
100
|
+
canvas.height = h;
|
|
101
|
+
const ctx = canvas.getContext('2d');
|
|
102
|
+
if (!ctx) return;
|
|
103
|
+
const imageData = ctx.createImageData(w, h);
|
|
104
|
+
imageData.data.set(rgba);
|
|
105
|
+
ctx.putImageData(imageData, 0, 0);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function next(): void {
|
|
109
|
+
if (pageIndex.value < pageCount.value - 1) {
|
|
110
|
+
pageIndex.value++;
|
|
111
|
+
paint();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function prev(): void {
|
|
115
|
+
if (pageIndex.value > 0) {
|
|
116
|
+
pageIndex.value--;
|
|
117
|
+
paint();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function zoomIn(): void {
|
|
121
|
+
scale.value = Math.min(8, scale.value * 1.25);
|
|
122
|
+
}
|
|
123
|
+
function zoomOut(): void {
|
|
124
|
+
scale.value = Math.max(0.1, scale.value / 1.25);
|
|
125
|
+
}
|
|
126
|
+
function reset(): void {
|
|
127
|
+
scale.value = 1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
onMounted(load);
|
|
131
|
+
onBeforeUnmount(() => {
|
|
132
|
+
renderToken++;
|
|
133
|
+
ifds = null;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
watch(() => props.url, load);
|
|
137
|
+
|
|
138
|
+
const pageLabel = computed(() => {
|
|
139
|
+
const m = (props.t && props.t('viewer.page_n_of_m')) || 'Page {n} of {m}';
|
|
140
|
+
return m.replace('{n}', String(pageIndex.value + 1)).replace('{m}', String(pageCount.value));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
function tt(key: string, fallback: string): string {
|
|
144
|
+
return props.t ? props.t(key) : fallback;
|
|
145
|
+
}
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<template>
|
|
149
|
+
<div class="filex-viewer-tiff">
|
|
150
|
+
<div class="filex-viewer-tiff__pane">
|
|
151
|
+
<div v-if="error" class="filex-viewer-fallback">
|
|
152
|
+
<span class="filex-viewer-fallback__icon">🖼️</span>
|
|
153
|
+
<p>{{ error }}</p>
|
|
154
|
+
</div>
|
|
155
|
+
<div v-else-if="loading" class="filex-viewer-fallback">
|
|
156
|
+
<span class="filex-viewer-fallback__icon">⏳</span>
|
|
157
|
+
<p>{{ tt('viewer.loading', 'Loading…') }}</p>
|
|
158
|
+
</div>
|
|
159
|
+
<canvas
|
|
160
|
+
v-show="!loading && !error"
|
|
161
|
+
ref="canvasEl"
|
|
162
|
+
:style="{ imageRendering: 'pixelated' }"
|
|
163
|
+
/>
|
|
164
|
+
<div v-if="!loading && !error && pageCount > 1" class="filex-viewer-tiff__pager">
|
|
165
|
+
<button
|
|
166
|
+
type="button"
|
|
167
|
+
class="filex-viewer-btn"
|
|
168
|
+
:disabled="pageIndex === 0"
|
|
169
|
+
@click="prev"
|
|
170
|
+
>‹</button>
|
|
171
|
+
<span class="filex-viewer-tiff__pages">{{ pageLabel }}</span>
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
class="filex-viewer-btn"
|
|
175
|
+
:disabled="pageIndex >= pageCount - 1"
|
|
176
|
+
@click="next"
|
|
177
|
+
>›</button>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</template>
|
|
182
|
+
|
|
183
|
+
<style scoped>
|
|
184
|
+
.filex-viewer-tiff__pager {
|
|
185
|
+
position: absolute;
|
|
186
|
+
bottom: 12px;
|
|
187
|
+
left: 50%;
|
|
188
|
+
transform: translateX(-50%);
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
gap: 8px;
|
|
192
|
+
padding: 4px 8px;
|
|
193
|
+
background: var(--fe-bg-elev, rgba(255, 255, 255, 0.9));
|
|
194
|
+
border: 1px solid var(--fe-border, #e2e6ed);
|
|
195
|
+
border-radius: 6px;
|
|
196
|
+
backdrop-filter: blur(4px);
|
|
197
|
+
}
|
|
198
|
+
.filex-viewer-tiff__pages {
|
|
199
|
+
font-size: 12px;
|
|
200
|
+
font-variant-numeric: tabular-nums;
|
|
201
|
+
}
|
|
202
|
+
.filex-viewer-tiff {
|
|
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-tiff__bar {
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
gap: 6px;
|
|
214
|
+
padding: 8px 12px;
|
|
215
|
+
background: var(--fe-bg-elev, #f7f8fa);
|
|
216
|
+
border-bottom: 1px solid var(--fe-border, #e2e6ed);
|
|
217
|
+
font-size: 13px;
|
|
218
|
+
}
|
|
219
|
+
.filex-viewer-tiff__pages {
|
|
220
|
+
min-width: 110px;
|
|
221
|
+
text-align: center;
|
|
222
|
+
font-variant-numeric: tabular-nums;
|
|
223
|
+
font-size: 12px;
|
|
224
|
+
}
|
|
225
|
+
.filex-viewer-tiff__zoom {
|
|
226
|
+
min-width: 50px;
|
|
227
|
+
text-align: center;
|
|
228
|
+
font-variant-numeric: tabular-nums;
|
|
229
|
+
font-size: 12px;
|
|
230
|
+
}
|
|
231
|
+
.filex-viewer-spacer { flex: 1; }
|
|
232
|
+
.filex-viewer-tiff__pane {
|
|
233
|
+
flex: 1;
|
|
234
|
+
overflow: auto;
|
|
235
|
+
padding: 16px;
|
|
236
|
+
background: #2a2d33;
|
|
237
|
+
display: flex;
|
|
238
|
+
align-items: flex-start;
|
|
239
|
+
justify-content: flex-start;
|
|
240
|
+
}
|
|
241
|
+
.filex-viewer-tiff__pane canvas {
|
|
242
|
+
background: #fff;
|
|
243
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
|
244
|
+
}
|
|
245
|
+
.filex-viewer-fallback {
|
|
246
|
+
text-align: center;
|
|
247
|
+
padding: 32px;
|
|
248
|
+
color: #c8cdd6;
|
|
249
|
+
margin: auto;
|
|
250
|
+
}
|
|
251
|
+
.filex-viewer-fallback__icon {
|
|
252
|
+
font-size: 48px;
|
|
253
|
+
display: block;
|
|
254
|
+
margin-bottom: 12px;
|
|
255
|
+
}
|
|
256
|
+
.filex-viewer-btn {
|
|
257
|
+
border: 1px solid var(--fe-border, #e2e6ed);
|
|
258
|
+
background: var(--fe-bg, #fff);
|
|
259
|
+
color: var(--fe-text, #1a1e27);
|
|
260
|
+
padding: 4px 10px;
|
|
261
|
+
border-radius: 4px;
|
|
262
|
+
cursor: pointer;
|
|
263
|
+
font: inherit;
|
|
264
|
+
font-size: 12px;
|
|
265
|
+
}
|
|
266
|
+
.filex-viewer-btn:hover:not(:disabled) {
|
|
267
|
+
background: var(--fe-bg-hover, #edf0f5);
|
|
268
|
+
}
|
|
269
|
+
.filex-viewer-btn:disabled {
|
|
270
|
+
opacity: 0.4;
|
|
271
|
+
cursor: not-allowed;
|
|
272
|
+
}
|
|
273
|
+
</style>
|