@twip/web 0.0.0-canary-d060d80 → 0.0.0-canary-8a13ac8
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/dist/commands.d.ts +24 -28
- package/dist/commands.js +1 -1
- package/dist/editor.d.ts +3 -2
- package/dist/editor.js +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/services/elements.d.ts +32 -3
- package/dist/services/elements.js +4 -0
- package/dist/state.d.ts +5 -0
- package/dist/transport/protocol.d.ts +1 -0
- package/dist/transport/protocol.js +1 -0
- package/dist/twip_wasm.wasm +0 -0
- package/package.json +1 -1
package/dist/commands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RichText } from './review.js';
|
|
2
|
-
import type { ControlKind, ControlOptions, DataBinding, ReferenceRule } from './services/elements.js';
|
|
2
|
+
import type { ControlKind, ControlOptions, DataBinding, PlaceholderImage, ReferenceRule } from './services/elements.js';
|
|
3
3
|
import type { TabAlignment, TabLeader, TabSelector } from './services/ruler.js';
|
|
4
4
|
import type { ViewOptions } from './services/view.js';
|
|
5
5
|
import type { AutoCorrectChange, HighlightColor, HorizontalPosition, LineSpacing, MarkupView, ObjectWrap, RowHeight, TablePosition, TableWidth, UnderlineStyle, VerticalPosition, WrapSide } from './state.js';
|
|
@@ -9,26 +9,6 @@ export interface FieldTargets {
|
|
|
9
9
|
/** The fields; default: the selection's. */
|
|
10
10
|
ids?: ElementId[];
|
|
11
11
|
}
|
|
12
|
-
/** How a picture placeholder looks before it is filled. */
|
|
13
|
-
export interface PlaceholderLook {
|
|
14
|
-
/** Which placeholders: one, those with a tag or a key prefix, or the default for the rest. */
|
|
15
|
-
match: {
|
|
16
|
-
id: ElementId;
|
|
17
|
-
} | {
|
|
18
|
-
tag: string;
|
|
19
|
-
} | {
|
|
20
|
-
prefix: string;
|
|
21
|
-
} | 'default';
|
|
22
|
-
/** A fill, label and icon, or an image. */
|
|
23
|
-
look: {
|
|
24
|
-
fill?: Color;
|
|
25
|
-
label?: string;
|
|
26
|
-
iconSvg?: string;
|
|
27
|
-
} | {
|
|
28
|
-
image: Uint8Array;
|
|
29
|
-
mime: string;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
12
|
/**
|
|
33
13
|
* Every edit, one method per command. Each resolves after its change commits, with `getState()` already at that
|
|
34
14
|
* revision, and rejects with `EditorError`. Commands act on the selection at the time they run. Each is one undo
|
|
@@ -501,11 +481,15 @@ export interface Commands {
|
|
|
501
481
|
}): Promise<void>;
|
|
502
482
|
/** Back to the template from a sub-template, at the template's selection from before. View. */
|
|
503
483
|
closeSubTemplate(): Promise<void>;
|
|
504
|
-
/**
|
|
484
|
+
/**
|
|
485
|
+
* A new sub-template, empty, with a DOCX's body, or a copy of the sub-template `copyOf` in the same category
|
|
486
|
+
* (`category`: default the first rule's).
|
|
487
|
+
*/
|
|
505
488
|
createSubTemplate(options: {
|
|
506
489
|
name: string;
|
|
507
490
|
category?: string;
|
|
508
491
|
from?: Uint8Array;
|
|
492
|
+
copyOf?: string;
|
|
509
493
|
}): Promise<void>;
|
|
510
494
|
/** Renames a sub-template, and with `updateReferences` every reference to it. */
|
|
511
495
|
renameSubTemplate(options: {
|
|
@@ -519,6 +503,13 @@ export interface Commands {
|
|
|
519
503
|
name: string;
|
|
520
504
|
category?: string;
|
|
521
505
|
}): Promise<void>;
|
|
506
|
+
/**
|
|
507
|
+
* The template's body becomes the DOCX `from`'s body, on its last section's page; its sub-templates, custom XML
|
|
508
|
+
* data parts, settings, styles, headers and footers stay. Closes a sub-template being edited first.
|
|
509
|
+
*/
|
|
510
|
+
replaceBody(options: {
|
|
511
|
+
from: Uint8Array;
|
|
512
|
+
}): Promise<void>;
|
|
522
513
|
/** Inserts a content control, optionally around the selection. */
|
|
523
514
|
insertControl(options: {
|
|
524
515
|
kind: ControlKind;
|
|
@@ -528,11 +519,20 @@ export interface Commands {
|
|
|
528
519
|
placeholder?: string;
|
|
529
520
|
binding?: DataBinding;
|
|
530
521
|
options?: ControlOptions;
|
|
522
|
+
/**
|
|
523
|
+
* A picture control's placeholder picture (PNG, JPEG, GIF, BMP or SVG): what the editor, the saved DOCX and a
|
|
524
|
+
* PDF show until it is filled. An SVG is drawn with the picture's box as its viewport, so one with percentage
|
|
525
|
+
* geometry and no `viewBox` adapts to every size. Default: the engine's.
|
|
526
|
+
*/
|
|
527
|
+
placeholderImage?: PlaceholderImage;
|
|
531
528
|
wrapSelection?: boolean;
|
|
532
529
|
}): Promise<{
|
|
533
530
|
id: ElementId;
|
|
534
531
|
}>;
|
|
535
|
-
/**
|
|
532
|
+
/**
|
|
533
|
+
* Changes a content control; a `null` binding removes it. `placeholderImage` replaces a picture control's
|
|
534
|
+
* placeholder picture while it shows it (else it rejects with `unavailable`).
|
|
535
|
+
*/
|
|
536
536
|
setControl(options: {
|
|
537
537
|
id: ElementId;
|
|
538
538
|
tag?: string;
|
|
@@ -541,6 +541,7 @@ export interface Commands {
|
|
|
541
541
|
placeholder?: string;
|
|
542
542
|
binding?: DataBinding | null;
|
|
543
543
|
options?: ControlOptions;
|
|
544
|
+
placeholderImage?: PlaceholderImage;
|
|
544
545
|
}): Promise<void>;
|
|
545
546
|
/** Removes a content control, optionally keeping its content. */
|
|
546
547
|
removeControl(options: {
|
|
@@ -587,11 +588,6 @@ export interface Commands {
|
|
|
587
588
|
}[];
|
|
588
589
|
clear?: boolean;
|
|
589
590
|
}): Promise<void>;
|
|
590
|
-
/** Sets how picture placeholders look. View. */
|
|
591
|
-
setPlaceholderLooks(options: {
|
|
592
|
-
looks: PlaceholderLook[];
|
|
593
|
-
merge?: boolean;
|
|
594
|
-
}): Promise<void>;
|
|
595
591
|
/** Fills the selected placeholder, or every unfilled one with `key`: each becomes a plain picture, its content control removed. */
|
|
596
592
|
fillPlaceholder(options: {
|
|
597
593
|
key?: string;
|
package/dist/commands.js
CHANGED
|
@@ -151,6 +151,7 @@ const encodings = {
|
|
|
151
151
|
createSubTemplate: 'spread',
|
|
152
152
|
renameSubTemplate: 'spread',
|
|
153
153
|
removeSubTemplate: 'spread',
|
|
154
|
+
replaceBody: 'spread',
|
|
154
155
|
insertControl: 'spread',
|
|
155
156
|
setControl: 'spread',
|
|
156
157
|
removeControl: 'spread',
|
|
@@ -160,7 +161,6 @@ const encodings = {
|
|
|
160
161
|
removeElement: 'value',
|
|
161
162
|
replaceInElements: 'spread',
|
|
162
163
|
markElements: 'spread',
|
|
163
|
-
setPlaceholderLooks: 'spread',
|
|
164
164
|
fillPlaceholder: 'spread',
|
|
165
165
|
writeDataPart: 'spread',
|
|
166
166
|
removeDataPart: 'spread',
|
package/dist/editor.d.ts
CHANGED
|
@@ -192,8 +192,9 @@ export declare class HeadlessEditor {
|
|
|
192
192
|
/** Replaces the document with a blank one. */
|
|
193
193
|
newDocument(): Promise<void>;
|
|
194
194
|
/**
|
|
195
|
-
* Exports the document as DOCX or PDF, with the revision it captures
|
|
196
|
-
* an
|
|
195
|
+
* Exports the document as DOCX or PDF, with the revision it captures: the whole document, template and every
|
|
196
|
+
* sub-template, whether or not a sub-template is being edited. A PDF can take an open password and keywords; an
|
|
197
|
+
* empty password rejects with `invalid-argument`.
|
|
197
198
|
*/
|
|
198
199
|
export(options: ExportOptions): Promise<ExportResult>;
|
|
199
200
|
/** Runs several commands atomically: one transaction and one undo step, or nothing when one fails. */
|
package/dist/editor.js
CHANGED
|
@@ -329,8 +329,9 @@ export class HeadlessEditor {
|
|
|
329
329
|
return sessionOf(this).call(Method.NewDocument);
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
|
-
* Exports the document as DOCX or PDF, with the revision it captures
|
|
333
|
-
* an
|
|
332
|
+
* Exports the document as DOCX or PDF, with the revision it captures: the whole document, template and every
|
|
333
|
+
* sub-template, whether or not a sub-template is being edited. A PDF can take an open password and keywords; an
|
|
334
|
+
* empty password rejects with `invalid-argument`.
|
|
334
335
|
*/
|
|
335
336
|
export(options) {
|
|
336
337
|
const s = sessionOf(this);
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { Editor, HeadlessEditor } from './editor.js';
|
|
8
8
|
export { configure } from './transport/module.js';
|
|
9
9
|
export type { ExportOptions, ExportResult, MountOptions, PdfOptions, SessionOptions } from './editor.js';
|
|
10
|
-
export type { CommandEntry, CommandId, CommandInfo, Commands, FieldTargets, NoArgumentCommandId, Op, OpArgs,
|
|
10
|
+
export type { CommandEntry, CommandId, CommandInfo, Commands, FieldTargets, NoArgumentCommandId, Op, OpArgs, } from './commands.js';
|
|
11
11
|
export type { AutoCorrectChange, AutoCorrectEntry, AutoCorrectOptions, CharacterFormatting, CommandState, CommandValues, EditingTarget, EditorState, ElementContext, HighlightColor, HorizontalPosition, HorizontalReference, LineSpacing, MarkupView, Mixed, ObjectHorizontalAlignment, ObjectPlacement, ObjectSelection, ObjectVerticalAlignment, ObjectWrap, PageFormatting, ParagraphFormatting, ReviewState, RowHeight, SelectionSummary, TablePosition, TableSelection, TableStyleOptions, TableWidth, TextDistance, Tri, UnderlineStyle, VerticalPosition, VerticalReference, ViewState, WrapSide, } from './state.js';
|
|
12
12
|
export type { HostCommand, Tooltip, TransactionRecord, TwipEvents } from './events.js';
|
|
13
13
|
export { EditorError } from './errors.js';
|
|
@@ -19,7 +19,7 @@ export type { ContextMenu, ContextMenuEvent, MenuAction, MenuItem, MenuTarget, M
|
|
|
19
19
|
export type { AccessibilityDialogSession, DialogKind, DialogSession, DialogSessionOf, DialogValues, Dialogs, FieldInfo, } from './services/dialogs.js';
|
|
20
20
|
export type { Find, FindMatch, FindQuery, FindResult } from './services/find.js';
|
|
21
21
|
export type { Dictionary, Spelling } from './services/spelling.js';
|
|
22
|
-
export type { Block, ControlKind, ControlOptions, DataBinding, DataParts, ElementDetail, ElementInfo, Elements, MountedElements, PlaceholderInfo, ReferenceResolution, ReferenceRule, SubTemplateInfo, SubTemplateReference, SubTemplates, } from './services/elements.js';
|
|
22
|
+
export type { Block, ControlKind, ControlOptions, PlaceholderImage, DataBinding, DataParts, ElementDetail, ElementInfo, Elements, MountedElements, PlaceholderInfo, ReferenceResolution, ReferenceRule, SubTemplateInfo, SubTemplateReference, SubTemplates, } from './services/elements.js';
|
|
23
23
|
export type { Accessibility, AccessibleId, AccessibleNode, AnnouncementKind, CellPlace, ListPosition, Shortcuts } from './services/accessibility.js';
|
|
24
24
|
export type { Heading, Navigation, StyleInfo, Styles } from './services/navigation.js';
|
|
25
25
|
export type { Ruler, RulerModel, RulerModelSource, RulerUnit, RulerView, TabAlignment, TabLeader, TabSelector, } from './services/ruler.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Op } from '../commands.js';
|
|
2
2
|
import type { Session } from '../editor.js';
|
|
3
3
|
import type { SelectionSummary } from '../state.js';
|
|
4
|
-
import type { ClientPoint, ElementId } from '../types.js';
|
|
4
|
+
import type { ClientPoint, ElementId, Points } from '../types.js';
|
|
5
5
|
/** A content control's kind. */
|
|
6
6
|
export type ControlKind = 'richText' | 'plainText' | 'picture' | 'checkbox' | 'date' | 'dropDown' | 'comboBox' | 'group' | 'repeatingSection';
|
|
7
7
|
/** The merge designer's elements: fields and content controls. Changing them is done with the commands. */
|
|
@@ -76,6 +76,11 @@ export interface ElementInfo {
|
|
|
76
76
|
locked: boolean;
|
|
77
77
|
/** A sub-template reference field's sub-template. */
|
|
78
78
|
reference?: SubTemplateReference;
|
|
79
|
+
/** A picture control's picture size (inline or floating). */
|
|
80
|
+
size?: {
|
|
81
|
+
width: Points;
|
|
82
|
+
height: Points;
|
|
83
|
+
};
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
86
|
* One sub-template reference rule (`setSubTemplateRules`): a field of type `fieldType` names, in argument `argument`,
|
|
@@ -126,7 +131,17 @@ export interface DataBinding {
|
|
|
126
131
|
/** The XPath's namespace prefixes. */
|
|
127
132
|
prefixMappings?: string;
|
|
128
133
|
}
|
|
129
|
-
/** A
|
|
134
|
+
/** A picture control's placeholder picture: PNG, JPEG, GIF, BMP or SVG (`image/svg+xml`). */
|
|
135
|
+
export interface PlaceholderImage {
|
|
136
|
+
/** The picture's bytes. */
|
|
137
|
+
data: Uint8Array;
|
|
138
|
+
/** Its MIME type; the data must be one. */
|
|
139
|
+
mime: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A content control's options, by kind: checkbox, date, list, plain text, or picture. A picture's size (1…1584 pt) is
|
|
143
|
+
* its placeholder's, and the picture's once filled (fitted to it); `setControl` keeps a side not given.
|
|
144
|
+
*/
|
|
130
145
|
export type ControlOptions = {
|
|
131
146
|
checked?: boolean;
|
|
132
147
|
} | {
|
|
@@ -139,6 +154,9 @@ export type ControlOptions = {
|
|
|
139
154
|
}[];
|
|
140
155
|
} | {
|
|
141
156
|
multiline?: boolean;
|
|
157
|
+
} | {
|
|
158
|
+
width?: Points;
|
|
159
|
+
height?: Points;
|
|
142
160
|
};
|
|
143
161
|
/** A block of the document structure. */
|
|
144
162
|
export type Block = {
|
|
@@ -197,11 +215,22 @@ export interface SubTemplates {
|
|
|
197
215
|
edit(name: string, category?: string): Promise<void>;
|
|
198
216
|
/** Back to the template, at its selection from before. */
|
|
199
217
|
close(): Promise<void>;
|
|
200
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* A new sub-template: empty, with the body of the DOCX `from`, or a copy of the sub-template `copyOf` in the same
|
|
220
|
+
* category (its formatting, fields, controls, pictures and references). One undo step.
|
|
221
|
+
*/
|
|
201
222
|
create(name: string, options?: {
|
|
202
223
|
category?: string;
|
|
203
224
|
from?: Uint8Array;
|
|
225
|
+
copyOf?: string;
|
|
204
226
|
}): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* A standalone DOCX of a sub-template's body, with the document's styles, numbering, theme and fonts and without
|
|
229
|
+
* its headers, footers or other sub-templates; `create(name, { from })` reads it back unchanged.
|
|
230
|
+
*/
|
|
231
|
+
export(name: string, options?: {
|
|
232
|
+
category?: string;
|
|
233
|
+
}): Promise<Uint8Array>;
|
|
205
234
|
/** Renames a sub-template; `updateReferences` renames every reference to it too. One undo step. */
|
|
206
235
|
rename(name: string, to: string, options?: {
|
|
207
236
|
category?: string;
|
|
@@ -18,6 +18,10 @@ export function createSubTemplates(s) {
|
|
|
18
18
|
remove: async (name, options) => {
|
|
19
19
|
await s.run({ type: 'removeSubTemplate', name, ...options });
|
|
20
20
|
},
|
|
21
|
+
export: async (name, options) => {
|
|
22
|
+
const docx = await s.call(Method.SubTemplateExport, { name, ...options });
|
|
23
|
+
return Uint8Array.from(atob(docx), (c) => c.charCodeAt(0));
|
|
24
|
+
},
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
/** The elements over a session. */
|
package/dist/state.d.ts
CHANGED
|
@@ -426,6 +426,11 @@ export interface ElementContext {
|
|
|
426
426
|
tag?: string;
|
|
427
427
|
/** A control's title. */
|
|
428
428
|
title?: string;
|
|
429
|
+
/** A picture control's picture size (inline or floating). */
|
|
430
|
+
size?: {
|
|
431
|
+
width: Points;
|
|
432
|
+
height: Points;
|
|
433
|
+
};
|
|
429
434
|
}
|
|
430
435
|
/** The selection's character formatting. */
|
|
431
436
|
export interface CharacterFormatting {
|
|
@@ -91,6 +91,7 @@ export declare const Method: {
|
|
|
91
91
|
readonly AccessibleGo: 78;
|
|
92
92
|
readonly HostCaretWindowSelect: 79;
|
|
93
93
|
readonly AnnouncementsSet: 80;
|
|
94
|
+
readonly SubTemplateExport: 81;
|
|
94
95
|
};
|
|
95
96
|
/** A structured call number. */
|
|
96
97
|
export type Method = (typeof Method)[keyof typeof Method];
|
package/dist/twip_wasm.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twip/web",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-8a13ac8",
|
|
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",
|