cozy-viewer 30.0.54 → 31.0.0
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/CHANGELOG.md +19 -0
- package/dist/ViewersByFile/TextViewer.js +2 -3
- package/dist/stylesheet.css +1 -0
- package/jest.config.js +2 -1
- package/package.json +8 -8
- package/src/Readme.md +23 -26
- package/src/ViewersByFile/TextViewer.jsx +3 -4
- package/src/ViewersByFile/styles.styl +1 -0
- package/test/__mocks__/react-pdf.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [31.0.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@30.0.55...cozy-viewer@31.0.0) (2026-10-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **cozy-viewer:** Keep the text viewer scrollbar clickable ([d1a743e](https://github.com/cozy/cozy-libs/commit/d1a743e8428d5f7c15391037d135750ddfd5559c))
|
|
11
|
+
- **cozy-viewer:** Upgrade react-markdown to 6.0.3 ([13cb65f](https://github.com/cozy/cozy-libs/commit/13cb65f912a8fdea6be4a7c1e1fc05bfb066935e))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **cozy-viewer:** Upgrade react-pdf to 9.2.1 ([844097e](https://github.com/cozy/cozy-libs/commit/844097ed521349bc1c574da522beca047a7ada43))
|
|
16
|
+
|
|
17
|
+
### BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
- **cozy-viewer:** react-pdf 9 requires React >= 16.14.0 and no longer ships the webpack entries that configured the pdf.js worker. Remove any `react-pdf$` alias and set `pdfjs.GlobalWorkerOptions.workerSrc` in your app, see the cozy-viewer Readme.
|
|
20
|
+
|
|
21
|
+
## [30.0.55](https://github.com/cozy/cozy-libs/compare/cozy-viewer@30.0.54...cozy-viewer@30.0.55) (2026-10-05)
|
|
22
|
+
|
|
23
|
+
**Note:** Version bump only for package cozy-viewer
|
|
24
|
+
|
|
6
25
|
## [30.0.54](https://github.com/cozy/cozy-libs/compare/cozy-viewer@30.0.53...cozy-viewer@30.0.54) (2026-10-04)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package cozy-viewer
|
|
@@ -71,9 +71,8 @@ var styles = {
|
|
|
71
71
|
var MarkdownRenderer = function MarkdownRenderer(_ref) {
|
|
72
72
|
var text = _ref.text;
|
|
73
73
|
return /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
|
|
74
|
-
className: (0, _classnames.default)(styles['viewer-textviewer-content'], 'u-p-1')
|
|
75
|
-
|
|
76
|
-
});
|
|
74
|
+
className: (0, _classnames.default)(styles['viewer-textviewer-content'], 'u-p-1')
|
|
75
|
+
}, text);
|
|
77
76
|
};
|
|
78
77
|
|
|
79
78
|
var PlainTextRenderer = function PlainTextRenderer(_ref2) {
|
package/dist/stylesheet.css
CHANGED
package/jest.config.js
CHANGED
|
@@ -9,7 +9,8 @@ module.exports = {
|
|
|
9
9
|
moduleNameMapper: {
|
|
10
10
|
'\\.(png|gif|jpe?g|svg)$': '<rootDir>/test/__mocks__/fileMock.js',
|
|
11
11
|
'\\.styl$': 'identity-obj-proxy',
|
|
12
|
-
|
|
12
|
+
// react-pdf needs react/jsx-runtime, missing from the monorepo's React 16.12
|
|
13
|
+
'^react-pdf$': '<rootDir>/test/__mocks__/react-pdf.js',
|
|
13
14
|
'^cozy-client/src/(.*)$': '<rootDir>/node_modules/cozy-client/dist/$1',
|
|
14
15
|
'^cozy-client$': '<rootDir>/node_modules/cozy-client/dist/index',
|
|
15
16
|
'^cozy-client/dist/(.*)$': '<rootDir>/node_modules/cozy-client/dist/$1',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "Cozy-Viewer provides a component to show files in a viewer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"cozy-device-helper": "2.0.0",
|
|
35
35
|
"cozy-intent": "^2.31.1",
|
|
36
36
|
"cozy-logger": "^1.18.1",
|
|
37
|
-
"cozy-sharing": "^38.1.
|
|
37
|
+
"cozy-sharing": "^38.1.10",
|
|
38
38
|
"cozy-ui": "^138.1.0",
|
|
39
|
-
"cozy-ui-plus": "^13.0.
|
|
39
|
+
"cozy-ui-plus": "^13.0.14",
|
|
40
40
|
"identity-obj-proxy": "3.0.0",
|
|
41
41
|
"jest": "30.3.0",
|
|
42
42
|
"jest-canvas-mock": "2.3.1",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"classnames": "^2.5.1",
|
|
54
54
|
"hammerjs": "^2.0.8",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
|
-
"react-markdown": "^
|
|
57
|
-
"react-pdf": "^
|
|
56
|
+
"react-markdown": "^6.0.3",
|
|
57
|
+
"react-pdf": "^9.2.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@linagora/twake-icons": ">=2.6.6",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"cozy-sharing": ">=30.0.0",
|
|
67
67
|
"cozy-ui": ">=138.1.0",
|
|
68
68
|
"cozy-ui-plus": ">=6.0.0",
|
|
69
|
-
"react": ">=16.
|
|
70
|
-
"react-dom": ">=16.
|
|
69
|
+
"react": ">=16.14.0",
|
|
70
|
+
"react-dom": ">=16.14.0",
|
|
71
71
|
"react-router-dom": ">=6.14.2",
|
|
72
72
|
"twake-i18n": ">=0.3.0"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "4f5afde6a7bb139332739a93efc455ea9e088b81"
|
|
75
75
|
}
|
package/src/Readme.md
CHANGED
|
@@ -297,42 +297,39 @@ const onFileChange = (file, nextIndex) => setState({ currentIndex: nextIndex, cu
|
|
|
297
297
|
|
|
298
298
|
### Using a worker for pdfjs
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
```diff
|
|
303
|
-
+ resolve: {
|
|
304
|
-
+ alias: {
|
|
305
|
-
+ 'react-pdf$' : 'react-pdf/dist/esm/entry.webpack'
|
|
306
|
-
+ }
|
|
307
|
-
+ }
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
With this alias, a specific JS file for the worker will be created in the build directory. By design, this directory is only accessible (ie. served by the stack) if you are logged in. If you need the viewer on a public page, you must tell webpack to create the worker in a public folder, that will be served by the stack even if the user is not logged in.
|
|
311
|
-
|
|
312
|
-
One way to do this is to explicitly load the web worker in your application like this:
|
|
300
|
+
The PDF viewer relies on [react-pdf](https://github.com/wojtekmaj/react-pdf), which needs the pdf.js worker to be configured by your application, once, before a PDF is shown:
|
|
313
301
|
|
|
314
302
|
```js static
|
|
315
|
-
import
|
|
316
|
-
import { pdfjs } from 'react-pdf';
|
|
303
|
+
import { pdfjs } from 'react-pdf'
|
|
317
304
|
|
|
318
|
-
pdfjs.GlobalWorkerOptions.
|
|
305
|
+
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
|
306
|
+
'pdfjs-dist/legacy/build/pdf.worker.min.mjs',
|
|
307
|
+
import.meta.url
|
|
308
|
+
).toString()
|
|
319
309
|
```
|
|
320
310
|
|
|
321
|
-
|
|
311
|
+
With Webpack 5 or Rspack, also add this configuration:
|
|
322
312
|
|
|
323
313
|
```js static
|
|
324
|
-
{
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
314
|
+
resolve: {
|
|
315
|
+
alias: {
|
|
316
|
+
'react-pdf$': 'react-pdf/dist/esm/index.js',
|
|
317
|
+
'pdfjs-dist$': 'pdfjs-dist/legacy/build/pdf.mjs'
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
module: {
|
|
321
|
+
rules: [
|
|
322
|
+
{ test: /react-pdf[\\/]dist[\\/]esm[\\/]index\.js$/, sideEffects: true }
|
|
323
|
+
]
|
|
333
324
|
}
|
|
334
325
|
```
|
|
335
326
|
|
|
327
|
+
- react-pdf resets `workerSrc` to `'pdf.worker.mjs'` when it loads. cozy-viewer requires its CommonJS build while your app imports the ESM one: the `react-pdf$` alias keeps a single build, so it cannot load again after your setup.
|
|
328
|
+
- react-pdf declares no side effects, so the bundler may skip its index when you import `pdfjs` and run it later. The `sideEffects` rule runs it first.
|
|
329
|
+
- The `legacy` build of pdf.js supports browsers without `Promise.withResolvers` (iOS and Safari before 17.4), in the main thread and in the worker.
|
|
330
|
+
|
|
331
|
+
The worker is emitted as an asset. If the viewer is used on a public page, make sure it is written to a folder served by the stack without authentication (for example with `output.assetModuleFilename: 'static/resource/[hash][ext][query]'`).
|
|
332
|
+
|
|
336
333
|
### Only works with React
|
|
337
334
|
|
|
338
335
|
The `Viewer` can be used only in a `React` Application. You can't use it with `Preact`.
|
|
@@ -13,10 +13,9 @@ import { isFileEncrypted } from '../helpers'
|
|
|
13
13
|
import withFileUrl from '../hoc/withFileUrl'
|
|
14
14
|
|
|
15
15
|
const MarkdownRenderer = ({ text }) => (
|
|
16
|
-
<ReactMarkdown
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/>
|
|
16
|
+
<ReactMarkdown className={cx(styles['viewer-textviewer-content'], 'u-p-1')}>
|
|
17
|
+
{text}
|
|
18
|
+
</ReactMarkdown>
|
|
20
19
|
)
|
|
21
20
|
|
|
22
21
|
const PlainTextRenderer = ({ text }) => (
|