@twip/web 0.0.0 → 0.1.0-alpha.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.
Files changed (106) hide show
  1. package/LICENSE +202 -0
  2. package/dist/AccessibleNode.d.ts +51 -0
  3. package/dist/AccessibleNode.mjs +177 -0
  4. package/dist/Alignment.d.ts +38 -0
  5. package/dist/Alignment.mjs +90 -0
  6. package/dist/BorderEdges.d.ts +50 -0
  7. package/dist/BorderEdges.mjs +114 -0
  8. package/dist/BorderStyle.d.ts +27 -0
  9. package/dist/BorderStyle.mjs +81 -0
  10. package/dist/Bytes.d.ts +19 -0
  11. package/dist/Bytes.mjs +76 -0
  12. package/dist/CaretPosition.d.ts +34 -0
  13. package/dist/CaretPosition.mjs +148 -0
  14. package/dist/CellAlignment.d.ts +25 -0
  15. package/dist/CellAlignment.mjs +75 -0
  16. package/dist/CellShift.d.ts +30 -0
  17. package/dist/CellShift.mjs +78 -0
  18. package/dist/Clipboard.d.ts +22 -0
  19. package/dist/Clipboard.mjs +90 -0
  20. package/dist/ColumnSide.d.ts +24 -0
  21. package/dist/ColumnSide.mjs +72 -0
  22. package/dist/ControlKind.d.ts +28 -0
  23. package/dist/ControlKind.mjs +84 -0
  24. package/dist/ControlLock.d.ts +42 -0
  25. package/dist/ControlLock.mjs +96 -0
  26. package/dist/DocumentStatus.d.ts +34 -0
  27. package/dist/DocumentStatus.mjs +148 -0
  28. package/dist/Editor.d.ts +773 -0
  29. package/dist/Editor.mjs +2269 -0
  30. package/dist/EditorMode.d.ts +34 -0
  31. package/dist/EditorMode.mjs +84 -0
  32. package/dist/Element.d.ts +57 -0
  33. package/dist/Element.mjs +201 -0
  34. package/dist/ElementKind.d.ts +28 -0
  35. package/dist/ElementKind.mjs +78 -0
  36. package/dist/ElementList.d.ts +20 -0
  37. package/dist/ElementList.mjs +71 -0
  38. package/dist/ElementText.d.ts +34 -0
  39. package/dist/ElementText.mjs +84 -0
  40. package/dist/Event.d.ts +45 -0
  41. package/dist/Event.mjs +159 -0
  42. package/dist/EventKind.d.ts +39 -0
  43. package/dist/EventKind.mjs +93 -0
  44. package/dist/EventList.d.ts +20 -0
  45. package/dist/EventList.mjs +71 -0
  46. package/dist/Fonts.d.ts +29 -0
  47. package/dist/Fonts.mjs +107 -0
  48. package/dist/Highlight.d.ts +41 -0
  49. package/dist/Highlight.mjs +117 -0
  50. package/dist/MarginPreset.d.ts +38 -0
  51. package/dist/MarginPreset.mjs +90 -0
  52. package/dist/MarkSeverity.d.ts +25 -0
  53. package/dist/MarkSeverity.mjs +75 -0
  54. package/dist/Modifiers.d.ts +34 -0
  55. package/dist/Modifiers.mjs +148 -0
  56. package/dist/OpenError.d.ts +30 -0
  57. package/dist/OpenError.mjs +78 -0
  58. package/dist/Orientation.d.ts +30 -0
  59. package/dist/Orientation.mjs +78 -0
  60. package/dist/PageNumber.d.ts +34 -0
  61. package/dist/PageNumber.mjs +84 -0
  62. package/dist/PaperSize.d.ts +50 -0
  63. package/dist/PaperSize.mjs +108 -0
  64. package/dist/ParagraphBorders.d.ts +34 -0
  65. package/dist/ParagraphBorders.mjs +84 -0
  66. package/dist/PictureWrap.d.ts +34 -0
  67. package/dist/PictureWrap.mjs +90 -0
  68. package/dist/PointerKind.d.ts +23 -0
  69. package/dist/PointerKind.mjs +75 -0
  70. package/dist/Rect.d.ts +34 -0
  71. package/dist/Rect.mjs +148 -0
  72. package/dist/Request.d.ts +55 -0
  73. package/dist/Request.mjs +207 -0
  74. package/dist/RequestKind.d.ts +45 -0
  75. package/dist/RequestKind.mjs +105 -0
  76. package/dist/RequestList.d.ts +20 -0
  77. package/dist/RequestList.mjs +71 -0
  78. package/dist/RowHeightRule.d.ts +34 -0
  79. package/dist/RowHeightRule.mjs +84 -0
  80. package/dist/RowSide.d.ts +24 -0
  81. package/dist/RowSide.mjs +72 -0
  82. package/dist/SaveError.d.ts +24 -0
  83. package/dist/SaveError.mjs +72 -0
  84. package/dist/SelectionInfo.d.ts +39 -0
  85. package/dist/SelectionInfo.mjs +166 -0
  86. package/dist/SelectionKind.d.ts +37 -0
  87. package/dist/SelectionKind.mjs +93 -0
  88. package/dist/THIRD-PARTY-NOTICES.md +4475 -0
  89. package/dist/TableAlignment.d.ts +25 -0
  90. package/dist/TableAlignment.mjs +75 -0
  91. package/dist/TableSelection.d.ts +38 -0
  92. package/dist/TableSelection.mjs +90 -0
  93. package/dist/TableWidthUnit.d.ts +31 -0
  94. package/dist/TableWidthUnit.mjs +81 -0
  95. package/dist/TextUnit.d.ts +25 -0
  96. package/dist/TextUnit.mjs +75 -0
  97. package/dist/diplomat-runtime.d.ts +15 -0
  98. package/dist/diplomat-runtime.mjs +786 -0
  99. package/dist/diplomat-wasm.mjs +18 -0
  100. package/dist/gpu.d.ts +15 -0
  101. package/dist/gpu.mjs +42 -0
  102. package/dist/index.d.ts +98 -0
  103. package/dist/index.mjs +101 -0
  104. package/dist/twip-wasm.js +2 -0
  105. package/dist/twip_wasm.wasm +0 -0
  106. package/package.json +18 -4
@@ -0,0 +1,2269 @@
1
+ // generated by diplomat-tool
2
+ import { AccessibleNode } from "./AccessibleNode.mjs"
3
+ import { Alignment } from "./Alignment.mjs"
4
+ import { BorderEdges } from "./BorderEdges.mjs"
5
+ import { BorderStyle } from "./BorderStyle.mjs"
6
+ import { Bytes } from "./Bytes.mjs"
7
+ import { CaretPosition } from "./CaretPosition.mjs"
8
+ import { CellAlignment } from "./CellAlignment.mjs"
9
+ import { CellShift } from "./CellShift.mjs"
10
+ import { Clipboard } from "./Clipboard.mjs"
11
+ import { ColumnSide } from "./ColumnSide.mjs"
12
+ import { ControlKind } from "./ControlKind.mjs"
13
+ import { ControlLock } from "./ControlLock.mjs"
14
+ import { DocumentStatus } from "./DocumentStatus.mjs"
15
+ import { EditorMode } from "./EditorMode.mjs"
16
+ import { ElementKind } from "./ElementKind.mjs"
17
+ import { ElementList } from "./ElementList.mjs"
18
+ import { ElementText } from "./ElementText.mjs"
19
+ import { EventList } from "./EventList.mjs"
20
+ import { Fonts } from "./Fonts.mjs"
21
+ import { Highlight } from "./Highlight.mjs"
22
+ import { MarginPreset } from "./MarginPreset.mjs"
23
+ import { MarkSeverity } from "./MarkSeverity.mjs"
24
+ import { Modifiers } from "./Modifiers.mjs"
25
+ import { OpenError } from "./OpenError.mjs"
26
+ import { Orientation } from "./Orientation.mjs"
27
+ import { PageNumber } from "./PageNumber.mjs"
28
+ import { PaperSize } from "./PaperSize.mjs"
29
+ import { ParagraphBorders } from "./ParagraphBorders.mjs"
30
+ import { PictureWrap } from "./PictureWrap.mjs"
31
+ import { PointerKind } from "./PointerKind.mjs"
32
+ import { Rect } from "./Rect.mjs"
33
+ import { RequestList } from "./RequestList.mjs"
34
+ import { RowHeightRule } from "./RowHeightRule.mjs"
35
+ import { RowSide } from "./RowSide.mjs"
36
+ import { SaveError } from "./SaveError.mjs"
37
+ import { SelectionInfo } from "./SelectionInfo.mjs"
38
+ import { TableAlignment } from "./TableAlignment.mjs"
39
+ import { TableSelection } from "./TableSelection.mjs"
40
+ import { TableWidthUnit } from "./TableWidthUnit.mjs"
41
+ import { TextUnit } from "./TextUnit.mjs"
42
+ import wasm from "./diplomat-wasm.mjs";
43
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
44
+
45
+ const Editor_box_destroy_registry = new FinalizationRegistry((ptr) => {
46
+ wasm.Editor_destroy(ptr);
47
+ });
48
+
49
+ /**
50
+ * An editor for one document: input, commands, saving and drawing.
51
+ */
52
+ export class Editor {
53
+ // Internal ptr reference:
54
+ #ptr = null;
55
+
56
+ // Lifetimes are only to keep dependencies alive.
57
+ // Since JS won't garbage collect until there are no incoming edges.
58
+ #selfEdge = [];
59
+
60
+ #internalConstructor(symbol, ptr, selfEdge) {
61
+ if (symbol !== diplomatRuntime.internalConstructor) {
62
+ console.error("Editor is an Opaque type. You cannot call its constructor.");
63
+ return;
64
+ }
65
+ this.#ptr = ptr;
66
+ this.#selfEdge = selfEdge;
67
+
68
+ // Are we being borrowed? If not, we can register.
69
+ if (this.#selfEdge.length === 0) {
70
+ Editor_box_destroy_registry.register(this, this.#ptr);
71
+ }
72
+
73
+ return this;
74
+ }
75
+ /** @internal */
76
+ get ffiValue() {
77
+ return this.#ptr;
78
+ }
79
+
80
+
81
+ /**
82
+ * An editor holding a new, empty US Letter document.
83
+ */
84
+ #defaultConstructor(fonts) {
85
+
86
+ const result = wasm.Editor_create(fonts instanceof Fonts ? fonts.ffiValue : typeError('fonts', 'Fonts'));
87
+
88
+ try {
89
+ return new Editor(diplomatRuntime.internalConstructor, result, []);
90
+ }
91
+
92
+ finally {
93
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Opens .docx bytes in place of the current document; on an error the current one stays.
99
+ */
100
+ open(bytes) {
101
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
102
+
103
+ const bytesSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, bytes, "u8")));
104
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
105
+
106
+
107
+ const result = wasm.Editor_open(diplomatReceive.buffer, this.ffiValue, bytesSlice.ptr);
108
+
109
+ try {
110
+ if (!diplomatReceive.resultFlag) {
111
+ const cause = new OpenError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
112
+ throw new globalThis.Error('OpenError.' + cause.value, { cause });
113
+ }
114
+ }
115
+
116
+ finally {
117
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
118
+ functionCleanupArena.free();
119
+
120
+ diplomatReceive.free();
121
+ }
122
+ }
123
+
124
+ /**
125
+ * The document as .docx bytes.
126
+ */
127
+ save() {
128
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
129
+
130
+
131
+ const result = wasm.Editor_save(diplomatReceive.buffer, this.ffiValue);
132
+
133
+ try {
134
+ if (!diplomatReceive.resultFlag) {
135
+ const cause = new SaveError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
136
+ throw new globalThis.Error('SaveError.' + cause.value, { cause });
137
+ }
138
+ return new Bytes(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
139
+ }
140
+
141
+ finally {
142
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
143
+ diplomatReceive.free();
144
+ }
145
+ }
146
+
147
+ /**
148
+ * The document as PDF, laid out completely first.
149
+ */
150
+ exportPdf(title) {
151
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
152
+
153
+ const titleSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, title)));
154
+
155
+ const result = wasm.Editor_export_pdf(this.ffiValue, titleSlice.ptr);
156
+
157
+ try {
158
+ return new Bytes(diplomatRuntime.internalConstructor, result, []);
159
+ }
160
+
161
+ finally {
162
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
163
+ functionCleanupArena.free();
164
+
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Pages laid out so far (layout continues in the background: see `idle`).
170
+ */
171
+ get pageCount() {
172
+
173
+ const result = wasm.Editor_page_count(this.ffiValue);
174
+
175
+ try {
176
+ return result;
177
+ }
178
+
179
+ finally {
180
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
181
+ }
182
+ }
183
+
184
+ /**
185
+ * A summary for logs: pages and whether there are unsaved changes.
186
+ */
187
+ describe() {
188
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
189
+
190
+ wasm.Editor_describe(this.ffiValue, write.buffer);
191
+
192
+ try {
193
+ return write.readString8();
194
+ }
195
+
196
+ finally {
197
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
198
+ write.free();
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Runs background layout for a while; true while there is more to do.
204
+ */
205
+ idle() {
206
+
207
+ const result = wasm.Editor_idle(this.ffiValue);
208
+
209
+ try {
210
+ return result === 1;
211
+ }
212
+
213
+ finally {
214
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
215
+ }
216
+ }
217
+
218
+ /**
219
+ * A key press (DOM `KeyboardEvent.code` names, e.g. `KeyB`, `ArrowLeft`); true if the editor handled it.
220
+ */
221
+ key(code, mods) {
222
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
223
+
224
+ const codeSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, code)));
225
+
226
+ const result = wasm.Editor_key(this.ffiValue, codeSlice.ptr, Modifiers._fromSuppliedValue(diplomatRuntime.internalConstructor, mods)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(Modifiers._sizeBytes), functionCleanupArena, {}, false));
227
+
228
+ try {
229
+ return result === 1;
230
+ }
231
+
232
+ finally {
233
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
234
+ functionCleanupArena.free();
235
+
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Text typed or composed (an IME's committed text).
241
+ */
242
+ text(text) {
243
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
244
+
245
+ const textSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, text)));
246
+ wasm.Editor_text(this.ffiValue, textSlice.ptr);
247
+
248
+ try {}
249
+
250
+ finally {
251
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
252
+ functionCleanupArena.free();
253
+
254
+ }
255
+ }
256
+
257
+ /**
258
+ * A pointer event at (`x`, `y`) content pixels; true if the editor wants the pointer captured.
259
+ */
260
+ pointer(kind, x, y, clicks, mods) {
261
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
262
+
263
+
264
+ const result = wasm.Editor_pointer(this.ffiValue, new PointerKind(kind).ffiValue, x, y, clicks, Modifiers._fromSuppliedValue(diplomatRuntime.internalConstructor, mods)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(Modifiers._sizeBytes), functionCleanupArena, {}, false));
265
+
266
+ try {
267
+ return result === 1;
268
+ }
269
+
270
+ finally {
271
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
272
+ functionCleanupArena.free();
273
+
274
+ }
275
+ }
276
+
277
+ /**
278
+ * The visible part of the content, in content pixels, and the device pixel ratio.
279
+ */
280
+ setViewport(left, top, width, height, dpr) {
281
+ wasm.Editor_set_viewport(this.ffiValue, left, top, width, height, dpr);
282
+
283
+ try {}
284
+
285
+ finally {
286
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Zoom: 1.0 = 100% (a point is 96/72 pixels).
292
+ */
293
+ setZoom(zoom) {
294
+ wasm.Editor_set_zoom(this.ffiValue, zoom);
295
+
296
+ try {}
297
+
298
+ finally {
299
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
300
+ }
301
+ }
302
+
303
+ undo() {
304
+ wasm.Editor_undo(this.ffiValue);
305
+
306
+ try {}
307
+
308
+ finally {
309
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
310
+ }
311
+ }
312
+
313
+ redo() {
314
+ wasm.Editor_redo(this.ffiValue);
315
+
316
+ try {}
317
+
318
+ finally {
319
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
320
+ }
321
+ }
322
+
323
+ selectAll() {
324
+ wasm.Editor_select_all(this.ffiValue);
325
+
326
+ try {}
327
+
328
+ finally {
329
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Copies the selection; `cut` deletes it too. `None` when nothing is selected.
335
+ */
336
+ copy(cut) {
337
+
338
+ const result = wasm.Editor_copy(this.ffiValue, cut);
339
+
340
+ try {
341
+ return result === 0 ? null : new Clipboard(diplomatRuntime.internalConstructor, result, []);
342
+ }
343
+
344
+ finally {
345
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Pastes: the content `token` names when it came from a Twip editor (`Clipboard.token`), else `text` as
351
+ * plain text.
352
+ */
353
+ paste(text, token) {
354
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
355
+
356
+ const textSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, text)));
357
+ const tokenSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, token)));
358
+ wasm.Editor_paste(this.ffiValue, textSlice.ptr, tokenSlice.ptr);
359
+
360
+ try {}
361
+
362
+ finally {
363
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
364
+ functionCleanupArena.free();
365
+
366
+ }
367
+ }
368
+
369
+ /**
370
+ * Inserts a row above or below the selected rows.
371
+ */
372
+ insertRow(side) {
373
+ wasm.Editor_insert_row(this.ffiValue, new RowSide(side).ffiValue);
374
+
375
+ try {}
376
+
377
+ finally {
378
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
379
+ }
380
+ }
381
+
382
+ /**
383
+ * Inserts a column left or right of the selected columns.
384
+ */
385
+ insertColumn(side) {
386
+ wasm.Editor_insert_column(this.ffiValue, new ColumnSide(side).ffiValue);
387
+
388
+ try {}
389
+
390
+ finally {
391
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
392
+ }
393
+ }
394
+
395
+ /**
396
+ * Deletes the selected rows.
397
+ */
398
+ deleteRows() {
399
+ wasm.Editor_delete_rows(this.ffiValue);
400
+
401
+ try {}
402
+
403
+ finally {
404
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Deletes the selected columns.
410
+ */
411
+ deleteColumns() {
412
+ wasm.Editor_delete_columns(this.ffiValue);
413
+
414
+ try {}
415
+
416
+ finally {
417
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
418
+ }
419
+ }
420
+
421
+ /**
422
+ * Deletes the table around the selection.
423
+ */
424
+ deleteTable() {
425
+ wasm.Editor_delete_table(this.ffiValue);
426
+
427
+ try {}
428
+
429
+ finally {
430
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
431
+ }
432
+ }
433
+
434
+ /**
435
+ * Deletes the selected cells, moving the remaining cells left or up.
436
+ */
437
+ deleteCells(shift) {
438
+ wasm.Editor_delete_cells(this.ffiValue, new CellShift(shift).ffiValue);
439
+
440
+ try {}
441
+
442
+ finally {
443
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Merges the selected cells into one.
449
+ */
450
+ mergeCells() {
451
+ wasm.Editor_merge_cells(this.ffiValue);
452
+
453
+ try {}
454
+
455
+ finally {
456
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
457
+ }
458
+ }
459
+
460
+ /**
461
+ * Splits the cell into `columns` cells side by side.
462
+ */
463
+ splitCell(columns) {
464
+ wasm.Editor_split_cell(this.ffiValue, columns);
465
+
466
+ try {}
467
+
468
+ finally {
469
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Splits the cell into `rows` cells stacked vertically.
475
+ */
476
+ splitCellIntoRows(rows) {
477
+ wasm.Editor_split_cell_into_rows(this.ffiValue, rows);
478
+
479
+ try {}
480
+
481
+ finally {
482
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
483
+ }
484
+ }
485
+
486
+ /**
487
+ * Selects the current cells, rows, columns or the whole table.
488
+ */
489
+ selectInTable(part) {
490
+ wasm.Editor_select_in_table(this.ffiValue, new TableSelection(part).ffiValue);
491
+
492
+ try {}
493
+
494
+ finally {
495
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
496
+ }
497
+ }
498
+
499
+ /**
500
+ * Gives the selected columns equal widths.
501
+ */
502
+ distributeColumns() {
503
+ wasm.Editor_distribute_columns(this.ffiValue);
504
+
505
+ try {}
506
+
507
+ finally {
508
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
509
+ }
510
+ }
511
+
512
+ /**
513
+ * Gives the selected rows equal heights.
514
+ */
515
+ distributeRows() {
516
+ wasm.Editor_distribute_rows(this.ffiValue);
517
+
518
+ try {}
519
+
520
+ finally {
521
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
522
+ }
523
+ }
524
+
525
+ /**
526
+ * Sets the vertical alignment of text in the selected cells.
527
+ */
528
+ setCellAlignment(alignment) {
529
+ wasm.Editor_set_cell_alignment(this.ffiValue, new CellAlignment(alignment).ffiValue);
530
+
531
+ try {}
532
+
533
+ finally {
534
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
535
+ }
536
+ }
537
+
538
+ /**
539
+ * Turns repeating the header rows at the top of each page on or off for the selected rows.
540
+ */
541
+ toggleHeaderRow() {
542
+ wasm.Editor_toggle_header_row(this.ffiValue);
543
+
544
+ try {}
545
+
546
+ finally {
547
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
548
+ }
549
+ }
550
+
551
+ /**
552
+ * Sets the borders on the given edges of the selected cells, with `width` in points and `color` as 0xRRGGBB (above 0xFFFFFF for automatic).
553
+ */
554
+ setCellBorders(edges, style, width, color) {
555
+ wasm.Editor_set_cell_borders(this.ffiValue, new BorderEdges(edges).ffiValue, new BorderStyle(style).ffiValue, width, color);
556
+
557
+ try {}
558
+
559
+ finally {
560
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
561
+ }
562
+ }
563
+
564
+ /**
565
+ * Sets the inner margins of the selected cells, in points.
566
+ */
567
+ setCellMargins(top, left, bottom, right) {
568
+ wasm.Editor_set_cell_margins(this.ffiValue, top, left, bottom, right);
569
+
570
+ try {}
571
+
572
+ finally {
573
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
574
+ }
575
+ }
576
+
577
+ /**
578
+ * Sets the height of the selected rows, in points (ignored for `Auto`).
579
+ */
580
+ setRowHeight(height, rule) {
581
+ wasm.Editor_set_row_height(this.ffiValue, height, new RowHeightRule(rule).ffiValue);
582
+
583
+ try {}
584
+
585
+ finally {
586
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
587
+ }
588
+ }
589
+
590
+ /**
591
+ * Turns allowing the selected rows to break across pages on or off.
592
+ */
593
+ toggleRowBreakAcrossPages() {
594
+ wasm.Editor_toggle_row_break_across_pages(this.ffiValue);
595
+
596
+ try {}
597
+
598
+ finally {
599
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
600
+ }
601
+ }
602
+
603
+ /**
604
+ * Sets the width of the selected columns, in points.
605
+ */
606
+ setColumnWidth(width) {
607
+ wasm.Editor_set_column_width(this.ffiValue, width);
608
+
609
+ try {}
610
+
611
+ finally {
612
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
613
+ }
614
+ }
615
+
616
+ /**
617
+ * Sets the table's preferred width, in points or as a percentage (ignored for `Auto`).
618
+ */
619
+ setTableWidth(width, unit) {
620
+ wasm.Editor_set_table_width(this.ffiValue, width, new TableWidthUnit(unit).ffiValue);
621
+
622
+ try {}
623
+
624
+ finally {
625
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
626
+ }
627
+ }
628
+
629
+ /**
630
+ * Aligns the table horizontally on the page.
631
+ */
632
+ setTableAlignment(alignment) {
633
+ wasm.Editor_set_table_alignment(this.ffiValue, new TableAlignment(alignment).ffiValue);
634
+
635
+ try {}
636
+
637
+ finally {
638
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
639
+ }
640
+ }
641
+
642
+ /**
643
+ * Sets the table's indent from the margin, in points.
644
+ */
645
+ setTableIndent(indent) {
646
+ wasm.Editor_set_table_indent(this.ffiValue, indent);
647
+
648
+ try {}
649
+
650
+ finally {
651
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
652
+ }
653
+ }
654
+
655
+ /**
656
+ * Applies the table style with this style id to the table.
657
+ */
658
+ setTableStyle(styleId) {
659
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
660
+
661
+ const styleIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, styleId)));
662
+ wasm.Editor_set_table_style(this.ffiValue, styleIdSlice.ptr);
663
+
664
+ try {}
665
+
666
+ finally {
667
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
668
+ functionCleanupArena.free();
669
+
670
+ }
671
+ }
672
+
673
+ /**
674
+ * Sets which parts of the table get the table style's special formatting.
675
+ */
676
+ setTableStyleOptions(headerRow, totalRow, firstColumn, lastColumn, bandedRows, bandedColumns) {
677
+ wasm.Editor_set_table_style_options(this.ffiValue, headerRow, totalRow, firstColumn, lastColumn, bandedRows, bandedColumns);
678
+
679
+ try {}
680
+
681
+ finally {
682
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
683
+ }
684
+ }
685
+
686
+ /**
687
+ * Sets the fill colour of the selected cells as 0xRRGGBB, or removes it for a value above 0xFFFFFF.
688
+ */
689
+ setCellShading(color) {
690
+ wasm.Editor_set_cell_shading(this.ffiValue, color);
691
+
692
+ try {}
693
+
694
+ finally {
695
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
696
+ }
697
+ }
698
+
699
+ /**
700
+ * Shows or hides gridlines on table cells that have no borders.
701
+ */
702
+ setTableGridlines(show) {
703
+ wasm.Editor_set_table_gridlines(this.ffiValue, show);
704
+
705
+ try {}
706
+
707
+ finally {
708
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
709
+ }
710
+ }
711
+
712
+ /**
713
+ * Deletes the selected picture.
714
+ */
715
+ deletePicture() {
716
+ wasm.Editor_delete_picture(this.ffiValue);
717
+
718
+ try {}
719
+
720
+ finally {
721
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
722
+ }
723
+ }
724
+
725
+ /**
726
+ * Sets how text wraps around the selected floating picture.
727
+ */
728
+ setPictureWrap(wrap) {
729
+ wasm.Editor_set_picture_wrap(this.ffiValue, new PictureWrap(wrap).ffiValue);
730
+
731
+ try {}
732
+
733
+ finally {
734
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
735
+ }
736
+ }
737
+
738
+ /**
739
+ * Locks or unlocks the selected floating picture's anchor.
740
+ */
741
+ togglePictureAnchorLock() {
742
+ wasm.Editor_toggle_picture_anchor_lock(this.ffiValue);
743
+
744
+ try {}
745
+
746
+ finally {
747
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
748
+ }
749
+ }
750
+
751
+ /**
752
+ * Returns the selected picture to its original size.
753
+ */
754
+ resetPictureSize() {
755
+ wasm.Editor_reset_picture_size(this.ffiValue);
756
+
757
+ try {}
758
+
759
+ finally {
760
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
761
+ }
762
+ }
763
+
764
+ /**
765
+ * Sets the alternative text of the selected picture.
766
+ */
767
+ setPictureAltText(text) {
768
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
769
+
770
+ const textSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, text)));
771
+ wasm.Editor_set_picture_alt_text(this.ffiValue, textSlice.ptr);
772
+
773
+ try {}
774
+
775
+ finally {
776
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
777
+ functionCleanupArena.free();
778
+
779
+ }
780
+ }
781
+
782
+ /**
783
+ * Sets the size of the selected picture, in points (both must be positive).
784
+ */
785
+ setPictureSize(width, height) {
786
+ wasm.Editor_set_picture_size(this.ffiValue, width, height);
787
+
788
+ try {}
789
+
790
+ finally {
791
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
792
+ }
793
+ }
794
+
795
+ /**
796
+ * Inserts a field with this code and result text at the caret, or right after element `after` (empty for the caret).
797
+ */
798
+ insertField(code, display, showCode, after) {
799
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
800
+
801
+ const codeSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, code)));
802
+ const displaySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, display)));
803
+ const afterSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, after)));
804
+ wasm.Editor_insert_field(this.ffiValue, codeSlice.ptr, displaySlice.ptr, showCode, afterSlice.ptr);
805
+
806
+ try {}
807
+
808
+ finally {
809
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
810
+ functionCleanupArena.free();
811
+
812
+ }
813
+ }
814
+
815
+ /**
816
+ * Changes a field's code and result text; an empty string keeps that part as it is.
817
+ */
818
+ setField(id, code, display) {
819
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
820
+
821
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
822
+ const codeSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, code)));
823
+ const displaySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, display)));
824
+ wasm.Editor_set_field(this.ffiValue, idSlice.ptr, codeSlice.ptr, displaySlice.ptr);
825
+
826
+ try {}
827
+
828
+ finally {
829
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
830
+ functionCleanupArena.free();
831
+
832
+ }
833
+ }
834
+
835
+ /**
836
+ * Inserts an empty field showing its code with the caret inside it, or turns the selected text into a field code.
837
+ */
838
+ insertEmptyField() {
839
+ wasm.Editor_insert_empty_field(this.ffiValue);
840
+
841
+ try {}
842
+
843
+ finally {
844
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
845
+ }
846
+ }
847
+
848
+ /**
849
+ * Asks the host to update field `id` and the fields inside it, or the fields at the selection when `id` is empty.
850
+ */
851
+ updateFields(id) {
852
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
853
+
854
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
855
+ wasm.Editor_update_fields(this.ffiValue, idSlice.ptr);
856
+
857
+ try {}
858
+
859
+ finally {
860
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
861
+ functionCleanupArena.free();
862
+
863
+ }
864
+ }
865
+
866
+ /**
867
+ * Sets the result text of field `id` after the host computed it.
868
+ */
869
+ setFieldResult(id, display) {
870
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
871
+
872
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
873
+ const displaySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, display)));
874
+ wasm.Editor_set_field_result(this.ffiValue, idSlice.ptr, displaySlice.ptr);
875
+
876
+ try {}
877
+
878
+ finally {
879
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
880
+ functionCleanupArena.free();
881
+
882
+ }
883
+ }
884
+
885
+ /**
886
+ * Locks or unlocks field `id` and the fields inside it, or the fields at the selection when `id` is empty.
887
+ */
888
+ setFieldsLocked(id, locked) {
889
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
890
+
891
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
892
+ wasm.Editor_set_fields_locked(this.ffiValue, idSlice.ptr, locked);
893
+
894
+ try {}
895
+
896
+ finally {
897
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
898
+ functionCleanupArena.free();
899
+
900
+ }
901
+ }
902
+
903
+ /**
904
+ * Replaces field `id`, or the fields at the selection when `id` is empty, with its result text.
905
+ */
906
+ unlinkFields(id) {
907
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
908
+
909
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
910
+ wasm.Editor_unlink_fields(this.ffiValue, idSlice.ptr);
911
+
912
+ try {}
913
+
914
+ finally {
915
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
916
+ functionCleanupArena.free();
917
+
918
+ }
919
+ }
920
+
921
+ /**
922
+ * Sets the label shown in design mode for empty fields with this code; `replace_all` drops the other labels first, and an empty `code` with `replace_all` clears them all.
923
+ */
924
+ setFieldLabel(code, label, replaceAll) {
925
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
926
+
927
+ const codeSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, code)));
928
+ const labelSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, label)));
929
+ wasm.Editor_set_field_label(this.ffiValue, codeSlice.ptr, labelSlice.ptr, replaceAll);
930
+
931
+ try {}
932
+
933
+ finally {
934
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
935
+ functionCleanupArena.free();
936
+
937
+ }
938
+ }
939
+
940
+ /**
941
+ * Removes a field or content control together with its content.
942
+ */
943
+ removeElement(id) {
944
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
945
+
946
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
947
+ wasm.Editor_remove_element(this.ffiValue, idSlice.ptr);
948
+
949
+ try {}
950
+
951
+ finally {
952
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
953
+ functionCleanupArena.free();
954
+
955
+ }
956
+ }
957
+
958
+ /**
959
+ * Selects a field or content control, scrolling it into view when `reveal` is true.
960
+ */
961
+ selectElement(id, reveal) {
962
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
963
+
964
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
965
+ wasm.Editor_select_element(this.ffiValue, idSlice.ptr, reveal);
966
+
967
+ try {}
968
+
969
+ finally {
970
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
971
+ functionCleanupArena.free();
972
+
973
+ }
974
+ }
975
+
976
+ /**
977
+ * Marks an element with a severity and a tooltip message; `clear_others` removes the other marks first, and an empty `id` with it clears all marks.
978
+ */
979
+ markElement(id, severity, message, clearOthers) {
980
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
981
+
982
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
983
+ const messageSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, message)));
984
+ wasm.Editor_mark_element(this.ffiValue, idSlice.ptr, new MarkSeverity(severity).ffiValue, messageSlice.ptr, clearOthers);
985
+
986
+ try {}
987
+
988
+ finally {
989
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
990
+ functionCleanupArena.free();
991
+
992
+ }
993
+ }
994
+
995
+ /**
996
+ * Replaces text in field codes or control tags or titles, in element `id` only or in all of them when `id` is empty.
997
+ */
998
+ replaceInElements(find, replace, within, kind, id) {
999
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1000
+
1001
+ const findSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, find)));
1002
+ const replaceSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, replace)));
1003
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
1004
+ wasm.Editor_replace_in_elements(this.ffiValue, findSlice.ptr, replaceSlice.ptr, new ElementText(within).ffiValue, new ElementKind(kind).ffiValue, idSlice.ptr);
1005
+
1006
+ try {}
1007
+
1008
+ finally {
1009
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1010
+ functionCleanupArena.free();
1011
+
1012
+ }
1013
+ }
1014
+
1015
+ /**
1016
+ * Inserts a content control at the caret or after element `after`, or around the selection with `wrap_selection` (rich text and group only); empty strings use the defaults.
1017
+ */
1018
+ insertControl(kind, tag, alias, placeholder, lock, binding, wrapSelection, multiLine, checked, dateFormat, after) {
1019
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1020
+
1021
+ const tagSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, tag)));
1022
+ const aliasSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, alias)));
1023
+ const placeholderSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, placeholder)));
1024
+ const bindingSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, binding)));
1025
+ const dateFormatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, dateFormat)));
1026
+ const afterSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, after)));
1027
+ wasm.Editor_insert_control(this.ffiValue, new ControlKind(kind).ffiValue, tagSlice.ptr, aliasSlice.ptr, placeholderSlice.ptr, new ControlLock(lock).ffiValue, bindingSlice.ptr, wrapSelection, multiLine, checked, dateFormatSlice.ptr, afterSlice.ptr);
1028
+
1029
+ try {}
1030
+
1031
+ finally {
1032
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1033
+ functionCleanupArena.free();
1034
+
1035
+ }
1036
+ }
1037
+
1038
+ /**
1039
+ * Changes a content control's tag, title, data binding, placeholder text and lock; empty strings and `Unchanged` keep what it has.
1040
+ */
1041
+ setControl(id, tag, alias, binding, placeholder, lock) {
1042
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1043
+
1044
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
1045
+ const tagSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, tag)));
1046
+ const aliasSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, alias)));
1047
+ const bindingSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, binding)));
1048
+ const placeholderSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, placeholder)));
1049
+ wasm.Editor_set_control(this.ffiValue, idSlice.ptr, tagSlice.ptr, aliasSlice.ptr, bindingSlice.ptr, placeholderSlice.ptr, new ControlLock(lock).ffiValue);
1050
+
1051
+ try {}
1052
+
1053
+ finally {
1054
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1055
+ functionCleanupArena.free();
1056
+
1057
+ }
1058
+ }
1059
+
1060
+ /**
1061
+ * Removes a content control, keeping its content in the document when `keep_content` is true.
1062
+ */
1063
+ removeControl(id, keepContent) {
1064
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1065
+
1066
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
1067
+ wasm.Editor_remove_control(this.ffiValue, idSlice.ptr, keepContent);
1068
+
1069
+ try {}
1070
+
1071
+ finally {
1072
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1073
+ functionCleanupArena.free();
1074
+
1075
+ }
1076
+ }
1077
+
1078
+ /**
1079
+ * Replaces the content of a plain-text, date or rich-text control with this text.
1080
+ */
1081
+ fillControl(id, text) {
1082
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1083
+
1084
+ const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
1085
+ const textSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, text)));
1086
+ wasm.Editor_fill_control(this.ffiValue, idSlice.ptr, textSlice.ptr);
1087
+
1088
+ try {}
1089
+
1090
+ finally {
1091
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1092
+ functionCleanupArena.free();
1093
+
1094
+ }
1095
+ }
1096
+
1097
+ /**
1098
+ * Wraps the selected table rows or paragraphs in a new repeating section, with an optional tag and title (empty for none).
1099
+ */
1100
+ wrapInRepeatingSection(tag, alias) {
1101
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1102
+
1103
+ const tagSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, tag)));
1104
+ const aliasSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, alias)));
1105
+ wasm.Editor_wrap_in_repeating_section(this.ffiValue, tagSlice.ptr, aliasSlice.ptr);
1106
+
1107
+ try {}
1108
+
1109
+ finally {
1110
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1111
+ functionCleanupArena.free();
1112
+
1113
+ }
1114
+ }
1115
+
1116
+ /**
1117
+ * Writes an XML data part whose root is in `namespace`, replacing the part with that namespace (and `item_id` when not empty) or adding a new one.
1118
+ */
1119
+ writeDataPart(namespace, itemId, xml) {
1120
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1121
+
1122
+ const namespaceSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, namespace)));
1123
+ const itemIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, itemId)));
1124
+ const xmlSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, xml)));
1125
+ wasm.Editor_write_data_part(this.ffiValue, namespaceSlice.ptr, itemIdSlice.ptr, xmlSlice.ptr);
1126
+
1127
+ try {}
1128
+
1129
+ finally {
1130
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1131
+ functionCleanupArena.free();
1132
+
1133
+ }
1134
+ }
1135
+
1136
+ /**
1137
+ * Removes the XML data part with this namespace (and `item_id` when not empty).
1138
+ */
1139
+ removeDataPart(namespace, itemId) {
1140
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1141
+
1142
+ const namespaceSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, namespace)));
1143
+ const itemIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, itemId)));
1144
+ wasm.Editor_remove_data_part(this.ffiValue, namespaceSlice.ptr, itemIdSlice.ptr);
1145
+
1146
+ try {}
1147
+
1148
+ finally {
1149
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1150
+ functionCleanupArena.free();
1151
+
1152
+ }
1153
+ }
1154
+
1155
+ /**
1156
+ * Toggles bold on the selection (or the next typed text).
1157
+ */
1158
+ bold() {
1159
+ wasm.Editor_bold(this.ffiValue);
1160
+
1161
+ try {}
1162
+
1163
+ finally {
1164
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1165
+ }
1166
+ }
1167
+
1168
+ /**
1169
+ * Toggles italic on the selection (or the next typed text).
1170
+ */
1171
+ italic() {
1172
+ wasm.Editor_italic(this.ffiValue);
1173
+
1174
+ try {}
1175
+
1176
+ finally {
1177
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1178
+ }
1179
+ }
1180
+
1181
+ /**
1182
+ * Toggles a single underline on the selection (or the next typed text).
1183
+ */
1184
+ underline() {
1185
+ wasm.Editor_underline(this.ffiValue);
1186
+
1187
+ try {}
1188
+
1189
+ finally {
1190
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1191
+ }
1192
+ }
1193
+
1194
+ /**
1195
+ * Toggles strikethrough on the selection (or the next typed text).
1196
+ */
1197
+ strikethrough() {
1198
+ wasm.Editor_strikethrough(this.ffiValue);
1199
+
1200
+ try {}
1201
+
1202
+ finally {
1203
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1204
+ }
1205
+ }
1206
+
1207
+ /**
1208
+ * Toggles subscript on the selection (or the next typed text).
1209
+ */
1210
+ subscript() {
1211
+ wasm.Editor_subscript(this.ffiValue);
1212
+
1213
+ try {}
1214
+
1215
+ finally {
1216
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1217
+ }
1218
+ }
1219
+
1220
+ /**
1221
+ * Toggles superscript on the selection (or the next typed text).
1222
+ */
1223
+ superscript() {
1224
+ wasm.Editor_superscript(this.ffiValue);
1225
+
1226
+ try {}
1227
+
1228
+ finally {
1229
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1230
+ }
1231
+ }
1232
+
1233
+ /**
1234
+ * Sets the font family of the selection (or the next typed text).
1235
+ */
1236
+ setFont(family) {
1237
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1238
+
1239
+ const familySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, family)));
1240
+ wasm.Editor_set_font(this.ffiValue, familySlice.ptr);
1241
+
1242
+ try {}
1243
+
1244
+ finally {
1245
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1246
+ functionCleanupArena.free();
1247
+
1248
+ }
1249
+ }
1250
+
1251
+ /**
1252
+ * Sets the font size of the selection (or the next typed text), rounded to the nearest half point.
1253
+ */
1254
+ setFontSize(points) {
1255
+ wasm.Editor_set_font_size(this.ffiValue, points);
1256
+
1257
+ try {}
1258
+
1259
+ finally {
1260
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1261
+ }
1262
+ }
1263
+
1264
+ /**
1265
+ * Makes the selected text one step larger in the standard font size list.
1266
+ */
1267
+ growFont() {
1268
+ wasm.Editor_grow_font(this.ffiValue);
1269
+
1270
+ try {}
1271
+
1272
+ finally {
1273
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1274
+ }
1275
+ }
1276
+
1277
+ /**
1278
+ * Makes the selected text one step smaller in the standard font size list.
1279
+ */
1280
+ shrinkFont() {
1281
+ wasm.Editor_shrink_font(this.ffiValue);
1282
+
1283
+ try {}
1284
+
1285
+ finally {
1286
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1287
+ }
1288
+ }
1289
+
1290
+ /**
1291
+ * Sets the text colour of the selection (or the next typed text).
1292
+ */
1293
+ setFontColor(color) {
1294
+ wasm.Editor_set_font_color(this.ffiValue, color);
1295
+
1296
+ try {}
1297
+
1298
+ finally {
1299
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1300
+ }
1301
+ }
1302
+
1303
+ /**
1304
+ * Gives the selection (or the next typed text) the automatic text colour.
1305
+ */
1306
+ setFontColorAutomatic() {
1307
+ wasm.Editor_set_font_color_automatic(this.ffiValue);
1308
+
1309
+ try {}
1310
+
1311
+ finally {
1312
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1313
+ }
1314
+ }
1315
+
1316
+ /**
1317
+ * Highlights the selection (or the next typed text) in a colour, or removes the highlight.
1318
+ */
1319
+ setHighlight(color) {
1320
+ wasm.Editor_set_highlight(this.ffiValue, new Highlight(color).ffiValue);
1321
+
1322
+ try {}
1323
+
1324
+ finally {
1325
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1326
+ }
1327
+ }
1328
+
1329
+ /**
1330
+ * Removes the direct character formatting from the selection.
1331
+ */
1332
+ clearFormatting() {
1333
+ wasm.Editor_clear_formatting(this.ffiValue);
1334
+
1335
+ try {}
1336
+
1337
+ finally {
1338
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1339
+ }
1340
+ }
1341
+
1342
+ /**
1343
+ * Applies a paragraph style to the selected paragraphs; nothing happens if the document has no such style.
1344
+ */
1345
+ setStyle(styleId) {
1346
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1347
+
1348
+ const styleIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, styleId)));
1349
+ wasm.Editor_set_style(this.ffiValue, styleIdSlice.ptr);
1350
+
1351
+ try {}
1352
+
1353
+ finally {
1354
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1355
+ functionCleanupArena.free();
1356
+
1357
+ }
1358
+ }
1359
+
1360
+ /**
1361
+ * Toggles a bulleted list on the selected paragraphs.
1362
+ */
1363
+ bullets() {
1364
+ wasm.Editor_bullets(this.ffiValue);
1365
+
1366
+ try {}
1367
+
1368
+ finally {
1369
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1370
+ }
1371
+ }
1372
+
1373
+ /**
1374
+ * Toggles a numbered list on the selected paragraphs.
1375
+ */
1376
+ numbering() {
1377
+ wasm.Editor_numbering(this.ffiValue);
1378
+
1379
+ try {}
1380
+
1381
+ finally {
1382
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1383
+ }
1384
+ }
1385
+
1386
+ /**
1387
+ * Moves the selected paragraphs' left indent in by half an inch.
1388
+ */
1389
+ increaseIndent() {
1390
+ wasm.Editor_increase_indent(this.ffiValue);
1391
+
1392
+ try {}
1393
+
1394
+ finally {
1395
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1396
+ }
1397
+ }
1398
+
1399
+ /**
1400
+ * Moves the selected paragraphs' left indent out by half an inch, not below zero.
1401
+ */
1402
+ decreaseIndent() {
1403
+ wasm.Editor_decrease_indent(this.ffiValue);
1404
+
1405
+ try {}
1406
+
1407
+ finally {
1408
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1409
+ }
1410
+ }
1411
+
1412
+ /**
1413
+ * Aligns the selected paragraphs.
1414
+ */
1415
+ setAlignment(alignment) {
1416
+ wasm.Editor_set_alignment(this.ffiValue, new Alignment(alignment).ffiValue);
1417
+
1418
+ try {}
1419
+
1420
+ finally {
1421
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1422
+ }
1423
+ }
1424
+
1425
+ /**
1426
+ * Sets the selected paragraphs' line spacing as a multiple of single spacing.
1427
+ */
1428
+ setLineSpacing(multiple) {
1429
+ wasm.Editor_set_line_spacing(this.ffiValue, multiple);
1430
+
1431
+ try {}
1432
+
1433
+ finally {
1434
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1435
+ }
1436
+ }
1437
+
1438
+ /**
1439
+ * Adds 12 points of space before the selected paragraphs, or removes it when the first one already has some.
1440
+ */
1441
+ toggleSpaceBefore() {
1442
+ wasm.Editor_toggle_space_before(this.ffiValue);
1443
+
1444
+ try {}
1445
+
1446
+ finally {
1447
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1448
+ }
1449
+ }
1450
+
1451
+ /**
1452
+ * Removes the space after the selected paragraphs.
1453
+ */
1454
+ removeSpaceAfter() {
1455
+ wasm.Editor_remove_space_after(this.ffiValue);
1456
+
1457
+ try {}
1458
+
1459
+ finally {
1460
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1461
+ }
1462
+ }
1463
+
1464
+ /**
1465
+ * Toggles keeping the selected paragraphs on the same page as the next one.
1466
+ */
1467
+ keepWithNext() {
1468
+ wasm.Editor_keep_with_next(this.ffiValue);
1469
+
1470
+ try {}
1471
+
1472
+ finally {
1473
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1474
+ }
1475
+ }
1476
+
1477
+ /**
1478
+ * Sets the borders of the selected paragraphs.
1479
+ */
1480
+ setParagraphBorders(borders) {
1481
+ wasm.Editor_set_paragraph_borders(this.ffiValue, new ParagraphBorders(borders).ffiValue);
1482
+
1483
+ try {}
1484
+
1485
+ finally {
1486
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1487
+ }
1488
+ }
1489
+
1490
+ /**
1491
+ * Fills the background of the selected paragraphs with a colour.
1492
+ */
1493
+ setParagraphShading(color) {
1494
+ wasm.Editor_set_paragraph_shading(this.ffiValue, color);
1495
+
1496
+ try {}
1497
+
1498
+ finally {
1499
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1500
+ }
1501
+ }
1502
+
1503
+ /**
1504
+ * Removes the background colour of the selected paragraphs.
1505
+ */
1506
+ clearParagraphShading() {
1507
+ wasm.Editor_clear_paragraph_shading(this.ffiValue);
1508
+
1509
+ try {}
1510
+
1511
+ finally {
1512
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1513
+ }
1514
+ }
1515
+
1516
+ /**
1517
+ * Ends the paragraph at the caret and starts a new one, as pressing Enter does.
1518
+ */
1519
+ insertParagraph() {
1520
+ wasm.Editor_insert_paragraph(this.ffiValue);
1521
+
1522
+ try {}
1523
+
1524
+ finally {
1525
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1526
+ }
1527
+ }
1528
+
1529
+ /**
1530
+ * Inserts a tab character at the caret.
1531
+ */
1532
+ insertTab() {
1533
+ wasm.Editor_insert_tab(this.ffiValue);
1534
+
1535
+ try {}
1536
+
1537
+ finally {
1538
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1539
+ }
1540
+ }
1541
+
1542
+ /**
1543
+ * Redoes the last undone change, or else repeats the last edit at the selection.
1544
+ */
1545
+ repeat() {
1546
+ wasm.Editor_repeat(this.ffiValue);
1547
+
1548
+ try {}
1549
+
1550
+ finally {
1551
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1552
+ }
1553
+ }
1554
+
1555
+ /**
1556
+ * Selects the word, sentence or paragraph at the caret.
1557
+ */
1558
+ select(unit) {
1559
+ wasm.Editor_select(this.ffiValue, new TextUnit(unit).ffiValue);
1560
+
1561
+ try {}
1562
+
1563
+ finally {
1564
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1565
+ }
1566
+ }
1567
+
1568
+ /**
1569
+ * Selects text within one paragraph and scrolls it into view.
1570
+ */
1571
+ selectRange(paragraph, start, end) {
1572
+ wasm.Editor_select_range(this.ffiValue, paragraph, start, end);
1573
+
1574
+ try {}
1575
+
1576
+ finally {
1577
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1578
+ }
1579
+ }
1580
+
1581
+ /**
1582
+ * Replaces every occurrence of a text in the document body, as one undo step.
1583
+ */
1584
+ replaceAll(find, replacement, matchCase) {
1585
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1586
+
1587
+ const findSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, find)));
1588
+ const replacementSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, replacement)));
1589
+ wasm.Editor_replace_all(this.ffiValue, findSlice.ptr, replacementSlice.ptr, matchCase);
1590
+
1591
+ try {}
1592
+
1593
+ finally {
1594
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1595
+ functionCleanupArena.free();
1596
+
1597
+ }
1598
+ }
1599
+
1600
+ /**
1601
+ * Inserts an empty table at the caret.
1602
+ */
1603
+ insertTable(rows, cols) {
1604
+ wasm.Editor_insert_table(this.ffiValue, rows, cols);
1605
+
1606
+ try {}
1607
+
1608
+ finally {
1609
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1610
+ }
1611
+ }
1612
+
1613
+ /**
1614
+ * Inserts a picture at the caret at its own size, scaled down to the text width if wider, and selects it.
1615
+ */
1616
+ insertPicture(image) {
1617
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1618
+
1619
+ const imageSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, image, "u8")));
1620
+ wasm.Editor_insert_picture(this.ffiValue, imageSlice.ptr);
1621
+
1622
+ try {}
1623
+
1624
+ finally {
1625
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1626
+ functionCleanupArena.free();
1627
+
1628
+ }
1629
+ }
1630
+
1631
+ /**
1632
+ * Inserts a 2 x 1 inch text box in front of the text at the caret and puts the caret in it.
1633
+ */
1634
+ insertTextBox() {
1635
+ wasm.Editor_insert_text_box(this.ffiValue);
1636
+
1637
+ try {}
1638
+
1639
+ finally {
1640
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1641
+ }
1642
+ }
1643
+
1644
+ /**
1645
+ * Inserts an unchecked checkbox content control at the caret.
1646
+ */
1647
+ insertCheckbox() {
1648
+ wasm.Editor_insert_checkbox(this.ffiValue);
1649
+
1650
+ try {}
1651
+
1652
+ finally {
1653
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1654
+ }
1655
+ }
1656
+
1657
+ /**
1658
+ * Inserts a symbol character at the caret, optionally in a given font.
1659
+ */
1660
+ insertSymbol(symbol, font) {
1661
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1662
+
1663
+ const symbolSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, symbol)));
1664
+ const fontSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, font)));
1665
+ wasm.Editor_insert_symbol(this.ffiValue, symbolSlice.ptr, fontSlice.ptr);
1666
+
1667
+ try {}
1668
+
1669
+ finally {
1670
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1671
+ functionCleanupArena.free();
1672
+
1673
+ }
1674
+ }
1675
+
1676
+ /**
1677
+ * Inserts a footnote reference at the caret and moves the caret to the new note's text.
1678
+ */
1679
+ insertFootnote() {
1680
+ wasm.Editor_insert_footnote(this.ffiValue);
1681
+
1682
+ try {}
1683
+
1684
+ finally {
1685
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1686
+ }
1687
+ }
1688
+
1689
+ /**
1690
+ * Inserts an endnote reference at the caret and moves the caret to the new note's text.
1691
+ */
1692
+ insertEndnote() {
1693
+ wasm.Editor_insert_endnote(this.ffiValue);
1694
+
1695
+ try {}
1696
+
1697
+ finally {
1698
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1699
+ }
1700
+ }
1701
+
1702
+ /**
1703
+ * Inserts a page number field at the caret (in a header, footer or the body).
1704
+ */
1705
+ insertPageNumber(kind) {
1706
+ wasm.Editor_insert_page_number(this.ffiValue, new PageNumber(kind).ffiValue);
1707
+
1708
+ try {}
1709
+
1710
+ finally {
1711
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1712
+ }
1713
+ }
1714
+
1715
+ /**
1716
+ * Inserts a page break at the caret.
1717
+ */
1718
+ insertPageBreak() {
1719
+ wasm.Editor_insert_page_break(this.ffiValue);
1720
+
1721
+ try {}
1722
+
1723
+ finally {
1724
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1725
+ }
1726
+ }
1727
+
1728
+ /**
1729
+ * Inserts a column break at the caret.
1730
+ */
1731
+ insertColumnBreak() {
1732
+ wasm.Editor_insert_column_break(this.ffiValue);
1733
+
1734
+ try {}
1735
+
1736
+ finally {
1737
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1738
+ }
1739
+ }
1740
+
1741
+ /**
1742
+ * Inserts a line break at the caret, starting a new line in the same paragraph.
1743
+ */
1744
+ insertLineBreak() {
1745
+ wasm.Editor_insert_line_break(this.ffiValue);
1746
+
1747
+ try {}
1748
+
1749
+ finally {
1750
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1751
+ }
1752
+ }
1753
+
1754
+ /**
1755
+ * Sets the page margins of the current section to a preset.
1756
+ */
1757
+ setMargins(preset) {
1758
+ wasm.Editor_set_margins(this.ffiValue, new MarginPreset(preset).ffiValue);
1759
+
1760
+ try {}
1761
+
1762
+ finally {
1763
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1764
+ }
1765
+ }
1766
+
1767
+ /**
1768
+ * Turns the current section's pages to portrait or landscape, turning the margins with them.
1769
+ */
1770
+ setOrientation(orientation) {
1771
+ wasm.Editor_set_orientation(this.ffiValue, new Orientation(orientation).ffiValue);
1772
+
1773
+ try {}
1774
+
1775
+ finally {
1776
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1777
+ }
1778
+ }
1779
+
1780
+ /**
1781
+ * Sets the paper size of the current section, keeping its orientation.
1782
+ */
1783
+ setPaperSize(size) {
1784
+ wasm.Editor_set_paper_size(this.ffiValue, new PaperSize(size).ffiValue);
1785
+
1786
+ try {}
1787
+
1788
+ finally {
1789
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1790
+ }
1791
+ }
1792
+
1793
+ /**
1794
+ * Lays out the current section in equal-width text columns.
1795
+ */
1796
+ setColumns(count) {
1797
+ wasm.Editor_set_columns(this.ffiValue, count);
1798
+
1799
+ try {}
1800
+
1801
+ finally {
1802
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1803
+ }
1804
+ }
1805
+
1806
+ /**
1807
+ * Moves the caret into the current page's header, creating an empty one if there is none.
1808
+ */
1809
+ editHeader() {
1810
+ wasm.Editor_edit_header(this.ffiValue);
1811
+
1812
+ try {}
1813
+
1814
+ finally {
1815
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1816
+ }
1817
+ }
1818
+
1819
+ /**
1820
+ * Moves the caret into the current page's footer, creating an empty one if there is none.
1821
+ */
1822
+ editFooter() {
1823
+ wasm.Editor_edit_footer(this.ffiValue);
1824
+
1825
+ try {}
1826
+
1827
+ finally {
1828
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1829
+ }
1830
+ }
1831
+
1832
+ /**
1833
+ * Leaves the header or footer and returns the caret to the body.
1834
+ */
1835
+ closeHeaderFooter() {
1836
+ wasm.Editor_close_header_footer(this.ffiValue);
1837
+
1838
+ try {}
1839
+
1840
+ finally {
1841
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1842
+ }
1843
+ }
1844
+
1845
+ /**
1846
+ * Toggles a different header and footer on the first page of the current section.
1847
+ */
1848
+ differentFirstPage() {
1849
+ wasm.Editor_different_first_page(this.ffiValue);
1850
+
1851
+ try {}
1852
+
1853
+ finally {
1854
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1855
+ }
1856
+ }
1857
+
1858
+ /**
1859
+ * Switches between editing, template design and read-only viewing.
1860
+ */
1861
+ setMode(mode) {
1862
+ wasm.Editor_set_mode(this.ffiValue, new EditorMode(mode).ffiValue);
1863
+
1864
+ try {}
1865
+
1866
+ finally {
1867
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1868
+ }
1869
+ }
1870
+
1871
+ /**
1872
+ * Zooms in by 10%, up to 400%.
1873
+ */
1874
+ zoomIn() {
1875
+ wasm.Editor_zoom_in(this.ffiValue);
1876
+
1877
+ try {}
1878
+
1879
+ finally {
1880
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1881
+ }
1882
+ }
1883
+
1884
+ /**
1885
+ * Zooms out by 10%, down to 25%.
1886
+ */
1887
+ zoomOut() {
1888
+ wasm.Editor_zoom_out(this.ffiValue);
1889
+
1890
+ try {}
1891
+
1892
+ finally {
1893
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1894
+ }
1895
+ }
1896
+
1897
+ /**
1898
+ * Sets how placeholders with a given key are drawn: a fill colour, a label and an icon.
1899
+ */
1900
+ setPlaceholderLook(key, color, label, iconSvg) {
1901
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1902
+
1903
+ const keySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, key)));
1904
+ const labelSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, label)));
1905
+ const iconSvgSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, iconSvg)));
1906
+ wasm.Editor_set_placeholder_look(this.ffiValue, keySlice.ptr, color, labelSlice.ptr, iconSvgSlice.ptr);
1907
+
1908
+ try {}
1909
+
1910
+ finally {
1911
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1912
+ functionCleanupArena.free();
1913
+
1914
+ }
1915
+ }
1916
+
1917
+ /**
1918
+ * Restores the default look of placeholders with a given key.
1919
+ */
1920
+ clearPlaceholderLook(key) {
1921
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1922
+
1923
+ const keySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, key)));
1924
+ wasm.Editor_clear_placeholder_look(this.ffiValue, keySlice.ptr);
1925
+
1926
+ try {}
1927
+
1928
+ finally {
1929
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1930
+ functionCleanupArena.free();
1931
+
1932
+ }
1933
+ }
1934
+
1935
+ /**
1936
+ * Toggles code view for every field (`all`) or for the fields at the caret.
1937
+ */
1938
+ toggleFieldCodes(all) {
1939
+ wasm.Editor_toggle_field_codes(this.ffiValue, all);
1940
+
1941
+ try {}
1942
+
1943
+ finally {
1944
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1945
+ }
1946
+ }
1947
+
1948
+ /**
1949
+ * Shows every field's code (`true`) or its result (`false`).
1950
+ */
1951
+ showFieldCodes(show) {
1952
+ wasm.Editor_show_field_codes(this.ffiValue, show);
1953
+
1954
+ try {}
1955
+
1956
+ finally {
1957
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1958
+ }
1959
+ }
1960
+
1961
+ /**
1962
+ * Shows the drop caret where a dragged item would land, at (`x`, `y`) content pixels.
1963
+ */
1964
+ setDropCaret(x, y) {
1965
+ wasm.Editor_set_drop_caret(this.ffiValue, x, y);
1966
+
1967
+ try {}
1968
+
1969
+ finally {
1970
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1971
+ }
1972
+ }
1973
+
1974
+ /**
1975
+ * Hides the drop caret.
1976
+ */
1977
+ clearDropCaret() {
1978
+ wasm.Editor_clear_drop_caret(this.ffiValue);
1979
+
1980
+ try {}
1981
+
1982
+ finally {
1983
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1984
+ }
1985
+ }
1986
+
1987
+ /**
1988
+ * The status bar's numbers.
1989
+ */
1990
+ status() {
1991
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 24, 8, false);
1992
+
1993
+
1994
+ const result = wasm.Editor_status(diplomatReceive.buffer, this.ffiValue);
1995
+
1996
+ try {
1997
+ return DocumentStatus._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
1998
+ }
1999
+
2000
+ finally {
2001
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2002
+ diplomatReceive.free();
2003
+ }
2004
+ }
2005
+
2006
+ /**
2007
+ * The selection.
2008
+ */
2009
+ selection() {
2010
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 40, 8, false);
2011
+
2012
+
2013
+ const result = wasm.Editor_selection(diplomatReceive.buffer, this.ffiValue);
2014
+
2015
+ try {
2016
+ return SelectionInfo._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
2017
+ }
2018
+
2019
+ finally {
2020
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2021
+ diplomatReceive.free();
2022
+ }
2023
+ }
2024
+
2025
+ /**
2026
+ * The document's reading structure, for assistive technology.
2027
+ */
2028
+ accessibleTree() {
2029
+
2030
+ const result = wasm.Editor_accessible_tree(this.ffiValue);
2031
+
2032
+ try {
2033
+ return new AccessibleNode(diplomatRuntime.internalConstructor, result, []);
2034
+ }
2035
+
2036
+ finally {
2037
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2038
+ }
2039
+ }
2040
+
2041
+ /**
2042
+ * The fields and content controls in document order; `kind` filters (`field`, `plain_text`, ...; empty for
2043
+ * all).
2044
+ */
2045
+ elements(kind) {
2046
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2047
+
2048
+ const kindSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, kind)));
2049
+
2050
+ const result = wasm.Editor_elements(this.ffiValue, kindSlice.ptr);
2051
+
2052
+ try {
2053
+ return new ElementList(diplomatRuntime.internalConstructor, result, []);
2054
+ }
2055
+
2056
+ finally {
2057
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2058
+ functionCleanupArena.free();
2059
+
2060
+ }
2061
+ }
2062
+
2063
+ /**
2064
+ * What the editor asked of the host since the last call (scroll, cursor, clipboard, ...). Call after inputs.
2065
+ */
2066
+ takeRequests() {
2067
+
2068
+ const result = wasm.Editor_take_requests(this.ffiValue);
2069
+
2070
+ try {
2071
+ return new RequestList(diplomatRuntime.internalConstructor, result, []);
2072
+ }
2073
+
2074
+ finally {
2075
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2076
+ }
2077
+ }
2078
+
2079
+ /**
2080
+ * What happened that the application may act on since the last call.
2081
+ */
2082
+ takeEvents() {
2083
+
2084
+ const result = wasm.Editor_take_events(this.ffiValue);
2085
+
2086
+ try {
2087
+ return new EventList(diplomatRuntime.internalConstructor, result, []);
2088
+ }
2089
+
2090
+ finally {
2091
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2092
+ }
2093
+ }
2094
+
2095
+ /**
2096
+ * As `paint`, into a new buffer (JavaScript can't lend one). `None` for an empty size.
2097
+ */
2098
+ paint(width, height, originX, originY, dpr) {
2099
+
2100
+ const result = wasm.Editor_paint_to_bytes(this.ffiValue, width, height, originX, originY, dpr);
2101
+
2102
+ try {
2103
+ return result === 0 ? null : new Bytes(diplomatRuntime.internalConstructor, result, []);
2104
+ }
2105
+
2106
+ finally {
2107
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2108
+ }
2109
+ }
2110
+
2111
+ /**
2112
+ * Browser: a WebGPU instance handle for `Module.WebGPU.importJsDevice` / `importJsQueue` (see the web
2113
+ * package's `attachWebGpu` helper).
2114
+ */
2115
+ static webgpuInstance() {
2116
+
2117
+ const result = wasm.Editor_webgpu_instance();
2118
+
2119
+ try {
2120
+ return result;
2121
+ }
2122
+
2123
+ finally {
2124
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2125
+ }
2126
+ }
2127
+
2128
+ /**
2129
+ * Browser: adopts the page's WebGPU device for every editor (imported device and queue handles, and the
2130
+ * instance from `webgpu_instance`). False when it can't be used: paint with WebGL instead.
2131
+ */
2132
+ static attachWebgpu(instance, device, queue) {
2133
+
2134
+ const result = wasm.Editor_attach_webgpu(instance, device, queue);
2135
+
2136
+ try {
2137
+ return result === 1;
2138
+ }
2139
+
2140
+ finally {
2141
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2142
+ }
2143
+ }
2144
+
2145
+ /**
2146
+ * Browser: paints the pages under the viewport into a WebGPU canvas texture (a handle from
2147
+ * `importJsTexture`, released here); `height` is the texture's height in pixels. False if nothing was drawn.
2148
+ */
2149
+ paintWebgpu(texture, bgra, originX, originY, height, dpr) {
2150
+
2151
+ const result = wasm.Editor_paint_webgpu(this.ffiValue, texture, bgra, originX, originY, height, dpr);
2152
+
2153
+ try {
2154
+ return result === 1;
2155
+ }
2156
+
2157
+ finally {
2158
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2159
+ }
2160
+ }
2161
+
2162
+ /**
2163
+ * Browser: adopts the current WebGL 2 context (made current with `Module.GL.makeContextCurrent`) for this
2164
+ * editor's canvas.
2165
+ */
2166
+ attachWebgl() {
2167
+
2168
+ const result = wasm.Editor_attach_webgl(this.ffiValue);
2169
+
2170
+ try {
2171
+ return result === 1;
2172
+ }
2173
+
2174
+ finally {
2175
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2176
+ }
2177
+ }
2178
+
2179
+ /**
2180
+ * Browser: paints the pages under the viewport into this editor's WebGL canvas (`width` x `height` device
2181
+ * pixels, its context current).
2182
+ */
2183
+ paintWebgl(originX, originY, width, height, dpr) {
2184
+
2185
+ const result = wasm.Editor_paint_webgl(this.ffiValue, originX, originY, width, height, dpr);
2186
+
2187
+ try {
2188
+ return result === 1;
2189
+ }
2190
+
2191
+ finally {
2192
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2193
+ }
2194
+ }
2195
+
2196
+ /**
2197
+ * The caret, content pixels.
2198
+ */
2199
+ caret() {
2200
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 32, 8, false);
2201
+
2202
+
2203
+ const result = wasm.Editor_caret(diplomatReceive.buffer, this.ffiValue);
2204
+
2205
+ try {
2206
+ return CaretPosition._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
2207
+ }
2208
+
2209
+ finally {
2210
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2211
+ diplomatReceive.free();
2212
+ }
2213
+ }
2214
+
2215
+ /**
2216
+ * The size of all pages stacked with their gaps, content pixels (what the host scrolls).
2217
+ */
2218
+ contentSize() {
2219
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 32, 8, false);
2220
+
2221
+
2222
+ const result = wasm.Editor_content_size(diplomatReceive.buffer, this.ffiValue);
2223
+
2224
+ try {
2225
+ return Rect._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
2226
+ }
2227
+
2228
+ finally {
2229
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2230
+ diplomatReceive.free();
2231
+ }
2232
+ }
2233
+
2234
+ /**
2235
+ * Fills the selected placeholder (`key` empty) or every unfilled one with `key`, with an image file's bytes;
2236
+ * how many were filled.
2237
+ */
2238
+ fillPlaceholder(key, image) {
2239
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2240
+
2241
+ const keySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, key)));
2242
+ const imageSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, image, "u8")));
2243
+
2244
+ const result = wasm.Editor_fill_placeholder(this.ffiValue, keySlice.ptr, imageSlice.ptr);
2245
+
2246
+ try {
2247
+ return result;
2248
+ }
2249
+
2250
+ finally {
2251
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2252
+ functionCleanupArena.free();
2253
+
2254
+ }
2255
+ }
2256
+
2257
+ /**
2258
+ * An editor holding a new, empty US Letter document.
2259
+ */
2260
+ constructor(fonts) {
2261
+ if (arguments[0] === diplomatRuntime.exposeConstructor) {
2262
+ return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1));
2263
+ } else if (arguments[0] === diplomatRuntime.internalConstructor) {
2264
+ return this.#internalConstructor(...arguments);
2265
+ } else {
2266
+ return this.#defaultConstructor(...arguments);
2267
+ }
2268
+ }
2269
+ }