You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/modules/index.md
+53-2Lines changed: 53 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ const config {
18
18
}
19
19
```
20
20
21
+
22
+
21
23
# Search
22
24
23
25
SuperDoc 0.11 adds a new .docx search feature.
@@ -63,6 +65,8 @@ You can customize the color of the highlights from these styles:
63
65
.ProseMirror-active-search-match
64
66
```
65
67
68
+
69
+
66
70
# Comments
67
71
68
72
The comments module can be added by adding the comments config to the modules.
@@ -171,6 +175,8 @@ const config = {
171
175
### Default toolbar buttons
172
176
See all buttons in defaultItems.js
173
177
178
+
179
+
174
180
# Fields
175
181
176
182
SuperDoc by default has the **fields** extension enabled. You can learn more about the [**Field Annotation** node here](https://github.com/Harbour-Enterprises/SuperDoc/blob/main/packages/super-editor/src/extensions/field-annotation/field-annotation.js)
@@ -221,9 +227,54 @@ Example:
221
227
## Fields docx export
222
228
SuperDoc supports full export and re-import of fields. By default, SuperDoc will not re-import document fields and will convert them to mustache style templates only.
223
229
224
-
To enable fields import simply add:
230
+
To enable fields import simply add the below to your config when instantiating `new SuperDoc`
225
231
```
226
232
annotations: true
227
233
```
228
234
229
-
To your SuperDoc config when instantiating with `new SuperDoc`
235
+
236
+
237
+
238
+
# Annotate
239
+
240
+
SuperDoc's editor instance (`superdoc.activeEditor`) exposes the `annotate()` function, allowing you to insert values into the Field nodes, either for preview or final document export.
241
+
242
+
### Usage
243
+
244
+
```ts
245
+
typeFieldValue= {
246
+
input_id:string// The ID of the input field being annotated
247
+
input_value:string// The value to insert into that field
248
+
}
249
+
250
+
editor.annotate(
251
+
fieldValues: FieldValue[], // Array of field annotations to insert or update
252
+
hiddenFieldIds?:string[], // Optional array of field IDs to hide from the annotated view
253
+
): void
254
+
```
255
+
256
+
## Example use
257
+
```
258
+
editor.annotate(
259
+
[
260
+
{
261
+
input_id: "name-123",
262
+
input_value: "Alice Smith"
263
+
},
264
+
{
265
+
input_id: "image-field-456",
266
+
input_value: "http://some-image-url.jpg" // Images should be Object URLs (URL.createObjectURL) or base64
267
+
}
268
+
],
269
+
["obsolete-field-id"]
270
+
)
271
+
```
272
+
273
+
## Exporting after annotate()
274
+
If using annotate() to do field value replacement, and then exporting the `.docx` document via `superdoc.export()` the `.docx` file will be exported with the fields still in the document (rather than replacing the fields with their expected values, ie: for final document export).
275
+
276
+
You can pass in the `isFinalDoc` flag to export() in order to actually replace fields with their values, creating a seamless final document that contains no field objects.
0 commit comments