@bpmn-io/form-js-viewer 1.20.0 → 1.21.1

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/README.md CHANGED
@@ -48,6 +48,37 @@ form.on('changed', 500, (event) => {
48
48
  });
49
49
  ```
50
50
 
51
+ ### Customize document preview requests
52
+
53
+ If you use the `documentPreview` field and need custom authentication for file downloads/previews,
54
+ you can provide a `documentEndpointBuilder` service via dependency injection.
55
+
56
+ ```javascript
57
+ import { Form } from '@bpmn-io/form-js-viewer';
58
+
59
+ const DocumentPreviewRequestModule = {
60
+ documentEndpointBuilder: [
61
+ 'value',
62
+ {
63
+ buildUrl: (document) => document.endpoint,
64
+ buildRequestInit: (document) => ({
65
+ headers: {
66
+ 'x-document-id': document.documentId,
67
+ },
68
+ credentials: 'include',
69
+ }),
70
+ },
71
+ ],
72
+ };
73
+
74
+ const form = new Form({
75
+ container: document.querySelector('#form'),
76
+ additionalModules: [DocumentPreviewRequestModule],
77
+ });
78
+ ```
79
+
80
+ `buildRequestInit` is optional, used to [configure the fetch request](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit). If omitted, document requests use the default `fetch(url)` behavior.
81
+
51
82
  Check out [a full example](https://github.com/bpmn-io/form-js-examples).
52
83
 
53
84
  ## Styling