@file-viewer/renderer-ofd 2.1.25 → 2.1.27
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/dist/ofd.js +22 -1
- package/package.json +2 -2
- package/vendor/dltech/ofd/ofd.js +2 -2
- package/vendor/dltech/ofd/ofd_render.js +4 -5
package/dist/ofd.js
CHANGED
|
@@ -85,6 +85,7 @@ const appendPages = (documentRef, target, pages) => {
|
|
|
85
85
|
target.appendChild(fragment);
|
|
86
86
|
};
|
|
87
87
|
export default async function renderOfd(buffer, target, context) {
|
|
88
|
+
var _a;
|
|
88
89
|
const t = createFileViewerTranslator(context === null || context === void 0 ? void 0 : context.options);
|
|
89
90
|
const documentRef = target.ownerDocument || document;
|
|
90
91
|
const targetWindow = documentRef.defaultView || (typeof window !== 'undefined' ? window : null);
|
|
@@ -242,10 +243,29 @@ export default async function renderOfd(buffer, target, context) {
|
|
|
242
243
|
startResizeObserver();
|
|
243
244
|
}
|
|
244
245
|
});
|
|
246
|
+
(_a = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _a === void 0 ? void 0 : _a.call(context, {
|
|
247
|
+
beforeCapture: async ({ signal }) => {
|
|
248
|
+
while (state === 'loading' && !disposed) {
|
|
249
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
250
|
+
throw signal.reason;
|
|
251
|
+
}
|
|
252
|
+
await new Promise(resolve => {
|
|
253
|
+
if (targetWindow)
|
|
254
|
+
targetWindow.setTimeout(resolve, 16);
|
|
255
|
+
else
|
|
256
|
+
setTimeout(resolve, 16);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (state === 'error') {
|
|
260
|
+
throw new Error(errorMessage || t('ofd.error.parseFailed'));
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
getTarget: () => stage.querySelector('.ofd-page-frame, .ofd-page') || stage,
|
|
264
|
+
});
|
|
245
265
|
return {
|
|
246
266
|
$el: viewer,
|
|
247
267
|
unmount() {
|
|
248
|
-
var _a;
|
|
268
|
+
var _a, _b;
|
|
249
269
|
disposed = true;
|
|
250
270
|
renderVersion += 1;
|
|
251
271
|
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.clearTimeout(resizeTimer);
|
|
@@ -254,6 +274,7 @@ export default async function renderOfd(buffer, target, context) {
|
|
|
254
274
|
unregisterFileViewerZoomProvider(viewer);
|
|
255
275
|
clearStage();
|
|
256
276
|
(_a = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
|
|
277
|
+
(_b = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _b === void 0 ? void 0 : _b.call(context, null);
|
|
257
278
|
},
|
|
258
279
|
};
|
|
259
280
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-ofd",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.27",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone OFD renderer plugin for Flyfish File Viewer powered by DLTech21/ofd.js.",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"LICENSE"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@file-viewer/core": "2.1.
|
|
56
|
+
"@file-viewer/core": "2.1.27",
|
|
57
57
|
"jszip": "^3.10.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
package/vendor/dltech/ofd/ofd.js
CHANGED
|
@@ -60,7 +60,7 @@ export const renderOfd = function (screenWidth, ofd) {
|
|
|
60
60
|
const pageId = Object.keys(page)[0];
|
|
61
61
|
let pageDiv = document.createElement('div');
|
|
62
62
|
pageDiv.id = pageId;
|
|
63
|
-
pageDiv.setAttribute('style', `margin-bottom: 20px;position: relative;width:${box.w}px;height:${box.h}px;background: white;`)
|
|
63
|
+
pageDiv.setAttribute('style', `margin-bottom: 20px;position: relative;width:${box.w}px;height:${box.h}px;background: white;overflow:hidden;`)
|
|
64
64
|
renderPage(pageDiv, page, ofd.tpls, ofd.fontResObj, ofd.drawParamResObj, ofd.multiMediaResObj);
|
|
65
65
|
divArray.push(pageDiv);
|
|
66
66
|
}
|
|
@@ -77,7 +77,7 @@ export const renderOfdByScale = function (ofd) {
|
|
|
77
77
|
const pageId = Object.keys(page)[0];
|
|
78
78
|
let pageDiv = document.createElement('div');
|
|
79
79
|
pageDiv.id = pageId;
|
|
80
|
-
pageDiv.setAttribute('style', `margin-bottom: 20px;position: relative;width:${box.w}px;height:${box.h}px;background: white;`)
|
|
80
|
+
pageDiv.setAttribute('style', `margin-bottom: 20px;position: relative;width:${box.w}px;height:${box.h}px;background: white;overflow:hidden;`)
|
|
81
81
|
renderPage(pageDiv, page, ofd.tpls, ofd.fontResObj, ofd.drawParamResObj, ofd.multiMediaResObj);
|
|
82
82
|
divArray.push(pageDiv);
|
|
83
83
|
}
|
|
@@ -418,16 +418,15 @@ export const renderImageOnDiv = function (pageWidth, pageHeight, imgSrc, boundar
|
|
|
418
418
|
img.setAttribute('width', '100%');
|
|
419
419
|
img.setAttribute('height', '100%');
|
|
420
420
|
div.appendChild(img);
|
|
421
|
-
const pw = parseFloat(pageWidth.replace('px', ''));
|
|
422
|
-
const ph = parseFloat(pageHeight.replace('px', ''));
|
|
423
|
-
const w = boundary.w > pw ? pw : boundary.w;
|
|
424
|
-
const h = boundary.h > ph ? ph : boundary.h;
|
|
425
421
|
let c = '';
|
|
426
422
|
if (clip) {
|
|
427
423
|
clip = converterBox(clip);
|
|
428
424
|
c = `clip: rect(${clip.y}px, ${clip.w + clip.x}px, ${clip.h + clip.y}px, ${clip.x}px)`
|
|
429
425
|
}
|
|
430
|
-
|
|
426
|
+
// Preserve the stamp geometry declared by OFD. Oversized or partially
|
|
427
|
+
// off-page seals are clipped by the page container, matching OFD readers;
|
|
428
|
+
// shrinking or moving the seal here changes both its position and scale.
|
|
429
|
+
div.setAttribute('style', `cursor: pointer; overflow: hidden; position: absolute; left: ${boundary.x}px; top: ${boundary.y}px; width: ${boundary.w}px; height: ${boundary.h}px; ${c};z-index: ${oid}`)
|
|
431
430
|
return div;
|
|
432
431
|
}
|
|
433
432
|
|