@twip/web 0.0.0-canary-84c6597 → 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.
@@ -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
@@ -539,11 +519,20 @@ export interface Commands {
539
519
  placeholder?: string;
540
520
  binding?: DataBinding;
541
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;
542
528
  wrapSelection?: boolean;
543
529
  }): Promise<{
544
530
  id: ElementId;
545
531
  }>;
546
- /** Changes a content control; a `null` binding removes it. */
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
+ */
547
536
  setControl(options: {
548
537
  id: ElementId;
549
538
  tag?: string;
@@ -552,6 +541,7 @@ export interface Commands {
552
541
  placeholder?: string;
553
542
  binding?: DataBinding | null;
554
543
  options?: ControlOptions;
544
+ placeholderImage?: PlaceholderImage;
555
545
  }): Promise<void>;
556
546
  /** Removes a content control, optionally keeping its content. */
557
547
  removeControl(options: {
@@ -598,11 +588,6 @@ export interface Commands {
598
588
  }[];
599
589
  clear?: boolean;
600
590
  }): Promise<void>;
601
- /** Sets how picture placeholders look. View. */
602
- setPlaceholderLooks(options: {
603
- looks: PlaceholderLook[];
604
- merge?: boolean;
605
- }): Promise<void>;
606
591
  /** Fills the selected placeholder, or every unfilled one with `key`: each becomes a plain picture, its content control removed. */
607
592
  fillPlaceholder(options: {
608
593
  key?: string;
package/dist/commands.js CHANGED
@@ -161,7 +161,6 @@ const encodings = {
161
161
  removeElement: 'value',
162
162
  replaceInElements: 'spread',
163
163
  markElements: 'spread',
164
- setPlaceholderLooks: 'spread',
165
164
  fillPlaceholder: 'spread',
166
165
  writeDataPart: 'spread',
167
166
  removeDataPart: 'spread',
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, PlaceholderLook, } from './commands.js';
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';
@@ -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,6 +131,13 @@ export interface DataBinding {
126
131
  /** The XPath's namespace prefixes. */
127
132
  prefixMappings?: string;
128
133
  }
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
+ }
129
141
  /**
130
142
  * A content control's options, by kind: checkbox, date, list, plain text, or picture. A picture's size (1…1584 pt) is
131
143
  * its placeholder's, and the picture's once filled (fitted to it); `setControl` keeps a side not given.
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 {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twip/web",
3
- "version": "0.0.0-canary-84c6597",
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",