Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/document-viewer-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed

- We updated library dependencies version of document viewer.

## [1.2.2] - 2026-07-17

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions packages/pluggableWidgets/document-viewer-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"@mendix/widget-plugin-component-kit": "workspace:*",
"@mendix/widget-plugin-platform": "workspace:*",
"classnames": "^2.5.1",
"docx-preview": "^0.3.6",
"pdfjs-dist": "4.8.69",
"react-pdf": "^9.2.1",
"docx-preview": "^0.4.0",
"pdfjs-dist": "^6.1.200",
"react-pdf": "^10.4.1",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options, parseAsync, renderDocument, WordDocument } from "docx-preview";
import { Options, renderAsync } from "docx-preview";
import { useCallback, useEffect, useRef } from "react";
import { BaseControlViewer } from "./BaseViewer";
import { DocRendererElement, DocumentRendererProps, DocumentStatus } from "./documentRenderer";
Expand All @@ -17,27 +17,11 @@
const loadContent = useCallback(
async (arrayBuffer: any) => {
try {
parseAsync(arrayBuffer, DOC_CONFIG)
.then((wordDocument: WordDocument) => {
if (localRef.current) {
// create new dummy stylecontainer to be ignored
const styleContainer = document.createElement("div");
renderDocument(wordDocument, localRef.current, styleContainer, DOC_CONFIG).catch(
(_error: any) => {
setDocumentStatus({
status: DocumentStatus.error,
message: "Failed to load DOCX document"
});
}
);
}
})
.catch((_error: any) => {
setDocumentStatus({
status: DocumentStatus.error,
message: "Failed to load DOCX document"
});
});
if (localRef.current) {
// Keep generated styles out of the document head.
const styleContainer = document.createElement("div");
await renderAsync(arrayBuffer, localRef.current, styleContainer, DOC_CONFIG);
}
} catch (_error: any) {
setDocumentStatus({
status: DocumentStatus.error,
Expand All @@ -56,13 +40,21 @@
.then(res => res.arrayBuffer())
.then(response => {
loadContent(response);
})
.catch((_error: any) => {
if (!signal.aborted) {
setDocumentStatus({
status: DocumentStatus.error,
message: "Failed to load DOCX document"
});
}
});
}

return () => {
controller.abort();
};
}, [file, file.status, file.value?.uri, loadContent]);

Check warning on line 57 in packages/pluggableWidgets/document-viewer-web/src/components/DocxViewer.tsx

View workflow job for this annotation

GitHub Actions / Run code quality check

React Hook useEffect has a missing dependency: 'setDocumentStatus'. Either include it or remove the dependency array

return (
<BaseControlViewer {...props} file={file}>
Expand Down
Loading
Loading