@twip/web 0.0.0-canary-7dfb59b → 0.0.0-canary-1644e0a

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
@@ -32,6 +32,19 @@ await editor.destroy();
32
32
 
33
33
  In Node, workers and tests, `HeadlessEditor.create()` gives the same API with no DOM.
34
34
 
35
+ ## Your own field types
36
+
37
+ A field whose type isn't one of Word's reads as a bookmark reference, and with no result it shows "Error! Bookmark
38
+ not defined.", as in Word. Declare the types your application fills itself after each `open`:
39
+
40
+ ```ts
41
+ await editor.commands.setApplicationFieldTypes({ types: ['CUSTOMVALUE', 'CUSTOMTEXT'] });
42
+ ```
43
+
44
+ Their fields then keep their results, show nothing when empty (their `setFieldLabels` label, else «first argument»,
45
+ in design mode) and are listed by `fieldsUpdateRequested` on `updateFields`, for `setFieldResults` to fill. Types
46
+ compare without case; each call replaces the list, and `[]` clears it. Setting it doesn't mark the document modified.
47
+
35
48
  ## Serving the engine's files yourself
36
49
 
37
50
  The engine runs from files in the package's `dist/`: `worker.js`, `twip-wasm.js`, `twip_wasm.wasm`, and the
@@ -508,6 +508,15 @@ export interface Commands {
508
508
  setSubTemplateRules(options: {
509
509
  rules: ReferenceRule[];
510
510
  }): Promise<void>;
511
+ /**
512
+ * The application's own field types (a code's first word, compared without case), replacing those set before:
513
+ * their fields keep their results, show their labels in design mode ({@link Commands.setFieldLabels}, else
514
+ * «first argument»), are listed by `fieldsUpdateRequested` and are never read as bookmark references
515
+ * ("Error! Bookmark not defined."). `[]` clears them. Set it after each `open`, as the rules. View.
516
+ */
517
+ setApplicationFieldTypes(options: {
518
+ types: string[];
519
+ }): Promise<void>;
511
520
  /** Shows references' sub-template bodies in their place, or their fields (default: every reference). View. */
512
521
  setSubTemplateView(options: {
513
522
  ids?: ElementId[];
package/dist/commands.js CHANGED
@@ -146,6 +146,7 @@ const encodings = {
146
146
  setFieldTypes: 'spread',
147
147
  setUnmappedFields: 'spread',
148
148
  setSubTemplateRules: 'spread',
149
+ setApplicationFieldTypes: 'spread',
149
150
  setSubTemplateView: 'spread',
150
151
  editSubTemplate: 'spread',
151
152
  closeSubTemplate: 'none',
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twip/web",
3
- "version": "0.0.0-canary-7dfb59b",
3
+ "version": "0.0.0-canary-1644e0a",
4
4
  "description": "The Twip DOCX editor for the browser and Node: a managed, framework-independent editor over the WebAssembly engine.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",