@docxkit/plugin-watermark 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,6 +7,6 @@ Watermark plugin for docx-kit.
7
7
  ```ts
8
8
  import { watermarkPlugin } from '@docxkit/plugin-watermark'
9
9
 
10
- builder.use(watermarkPlugin)
10
+ builder.use(watermarkPlugin())
11
11
  builder.watermark({ text: 'CONFIDENTIAL', opacity: 0.1 })
12
12
  ```
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { AlignmentType } from "docx";
2
-
3
2
  //#region ../../packages/types/dist/utility.d.ts
4
3
  /** Hexadecimal CSS color string, e.g. `"#ff0000"`. */
5
4
  type HexColor = `#${string}`;
@@ -146,12 +145,18 @@ interface ParagraphStyleRule {
146
145
  marginRight?: UnitValue;
147
146
  /** Top margin. */
148
147
  marginTop?: UnitValue;
148
+ /** Outline level used by Word navigation and table-of-contents fields (0–9). */
149
+ outlineLevel?: number;
149
150
  /** Force page break before this paragraph. */
150
151
  pageBreakBefore?: boolean;
152
+ /** Custom tab stops for this paragraph. */
153
+ tabStops?: TabStopRule[];
151
154
  /** Horizontal text alignment. */
152
155
  textAlign?: TextAlign;
153
156
  /** First-line indent. */
154
157
  textIndent?: UnitValue;
158
+ /** Prevent isolated first or last lines across page boundaries. */
159
+ widowControl?: boolean;
155
160
  /**
156
161
  * CSS-like margin shorthand.
157
162
  *
@@ -193,6 +198,15 @@ interface StyleSheetEntry extends DocxStyleRule {
193
198
  /** Inherit style properties from one or more other style classes. */
194
199
  extends?: string | string[];
195
200
  }
201
+ /** A paragraph tab stop. */
202
+ interface TabStopRule {
203
+ /** Position from the paragraph's left edge. */
204
+ position: UnitValue;
205
+ /** Optional leader characters before the tab stop. */
206
+ leader?: 'dot' | 'hyphen' | 'middleDot' | 'none' | 'underscore';
207
+ /** Tab alignment. */
208
+ type: 'bar' | 'center' | 'clear' | 'decimal' | 'end' | 'left' | 'num' | 'right' | 'start';
209
+ }
196
210
  /** Horizontal text alignment. */
197
211
  type TextAlign = 'center' | 'justify' | 'left' | 'right';
198
212
  /**
@@ -216,7 +230,7 @@ interface TextStyleRule {
216
230
  * Takes precedence over `fontWeight` when both are set.
217
231
  */
218
232
  bold?: boolean;
219
- /** Character spacing (letter-spacing). */
233
+ /** Raw OOXML character spacing in twips. Prefer `letterSpacing` for CSS units. */
220
234
  characterSpacing?: number;
221
235
  /** Text / foreground color (hex, named, or theme token like `"$colors.primary"`). */
222
236
  color?: HexColor | StyleToken<string>;
@@ -225,6 +239,10 @@ interface TextStyleRule {
225
239
  * Use for properties not yet covered by the CSS-like mapping.
226
240
  */
227
241
  docx?: Record<string, unknown>;
242
+ /** Double strikethrough toggle. */
243
+ doubleStrike?: boolean;
244
+ /** Embossed text effect. */
245
+ emboss?: boolean;
228
246
  /**
229
247
  * Font family name (e.g. `"Arial"`, or theme token like `"$fonts.heading"`).
230
248
  */
@@ -237,13 +255,17 @@ interface TextStyleRule {
237
255
  fontWeight?: FontWeight;
238
256
  /** Text highlight color (background marker). */
239
257
  highlight?: HighlightColor;
258
+ /** Imprinted (engraved) text effect. */
259
+ imprint?: boolean;
240
260
  /**
241
261
  * Convenience boolean: `true` maps to `fontStyle: 'italic'`.
242
262
  * Takes precedence over `fontStyle` when both are set.
243
263
  */
244
264
  italic?: boolean;
245
- /** Character spacing. */
265
+ /** CSS-like character spacing with unit conversion. */
246
266
  letterSpacing?: UnitValue;
267
+ /** Right-to-left run direction. */
268
+ rightToLeft?: boolean;
247
269
  /** Small caps text variant. */
248
270
  smallCaps?: boolean;
249
271
  /** Strikethrough toggle. */
@@ -281,17 +303,29 @@ interface BaseNode<TStyles extends StyleSheet = StyleSheet> {
281
303
  *
282
304
  * @template TStyles — The user's stylesheet type
283
305
  */
284
- type BlockNode<TStyles extends StyleSheet = StyleSheet> = BulletListNode<TStyles> | HeadingNode<TStyles> | HyperlinkNode<TStyles> | ImageNode<TStyles> | NumberedListNode<TStyles> | PageBreakNode | ParagraphNode<TStyles> | PluginNode<string, unknown, TStyles> | SectionBreakNode | TableNode<Record<string, unknown>, TStyles>;
306
+ type BlockNode<TStyles extends StyleSheet = StyleSheet> = BookmarkNode<TStyles> | BulletListNode<TStyles> | CheckboxNode<TStyles> | ColumnBreakNode | CommentNode<TStyles> | FootnoteNode<TStyles> | HeadingNode<TStyles> | HyperlinkNode<TStyles> | ImageNode<TStyles> | MathNode | NumberedListNode<TStyles> | PageBreakNode | ParagraphNode<TStyles> | PluginNode<string, unknown, TStyles> | RevisionNode<TStyles> | SectionBreakNode | TableNode<Record<string, unknown>, TStyles> | TextBoxNode<TStyles> | ThematicBreakNode<TStyles>;
307
+ /**
308
+ * A named bookmark that can be targeted by an internal hyperlink.
309
+ */
310
+ interface BookmarkNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
311
+ /** Text or styled text runs contained by the bookmark. */
312
+ children: (string | TextNode<TStyles>)[];
313
+ /** Stable bookmark name. */
314
+ name: string;
315
+ type: 'bookmark';
316
+ }
285
317
  /**
286
318
  * A structured list item (for rich bullet/numbered items).
287
319
  *
288
320
  * @template TStyles — The user's stylesheet type
289
321
  */
290
322
  interface BulletItem<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
291
- /** Item text content. */
292
- text: string;
293
323
  /** Optional inline children override (instead of text). */
294
324
  children?: InlineNode<TStyles>[];
325
+ /** Per-item nested list level (0–8). Overrides the list-level default. */
326
+ level?: number;
327
+ /** Item text content, used when `children` is absent. */
328
+ text?: string;
295
329
  }
296
330
  /**
297
331
  * A bullet list node.
@@ -309,12 +343,65 @@ interface BulletListNode<TStyles extends StyleSheet = StyleSheet> extends BaseNo
309
343
  /** Nested list level (0 = top-level). */
310
344
  level?: number;
311
345
  }
346
+ /**
347
+ * A Word checkbox content control.
348
+ */
349
+ interface CheckboxNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
350
+ type: 'checkbox';
351
+ /** Accessible alias for the checkbox control. */
352
+ alias?: string;
353
+ /** Whether the checkbox is checked. */
354
+ checked?: boolean;
355
+ /** Checked-state glyph and font. */
356
+ checkedState?: CheckboxSymbol;
357
+ /** Optional label rendered after the checkbox. */
358
+ label?: string;
359
+ /** Unchecked-state glyph and font. */
360
+ uncheckedState?: CheckboxSymbol;
361
+ }
362
+ /** Checkbox glyph customization. */
363
+ interface CheckboxSymbol {
364
+ /** Font containing the glyph. */
365
+ font?: string;
366
+ /** Unicode code point expressed as a hexadecimal string. */
367
+ value?: string;
368
+ }
312
369
  /**
313
370
  * Extract valid class name keys from a stylesheet type.
314
371
  *
315
372
  * @template TStyles — The user's stylesheet type
316
373
  */
317
374
  type ClassName<TStyles extends StyleSheet> = Extract<keyof TStyles, string>;
375
+ /**
376
+ * A forced column break.
377
+ */
378
+ interface ColumnBreakNode {
379
+ type: 'columnBreak';
380
+ }
381
+ /**
382
+ * An annotated content range backed by a Word comment.
383
+ */
384
+ interface CommentNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
385
+ /** Comment author. */
386
+ author: string;
387
+ /** Annotated inline content. */
388
+ children: InlineNode<TStyles>[];
389
+ /** Comment body paragraphs or plain text. */
390
+ comment: (string | ParagraphNode<TStyles>)[];
391
+ type: 'comment';
392
+ /** ISO-8601 creation timestamp. */
393
+ date?: string;
394
+ /** Author initials. */
395
+ initials?: string;
396
+ }
397
+ /**
398
+ * A footnote reference and its document-level footnote content.
399
+ */
400
+ interface FootnoteNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
401
+ /** Footnote body paragraphs or plain text. */
402
+ content: (string | ParagraphNode<TStyles>)[];
403
+ type: 'footnote';
404
+ }
318
405
  /**
319
406
  * A heading node (h1–h6).
320
407
  *
@@ -336,8 +423,10 @@ interface HyperlinkNode<TStyles extends StyleSheet = StyleSheet> extends BaseNod
336
423
  /** Display text or inline children. */
337
424
  children: (string | TextNode<TStyles>)[];
338
425
  type: 'hyperlink';
339
- /** Link target URL. */
340
- url: string;
426
+ /** Internal bookmark target (used instead of `url`). */
427
+ anchor?: string;
428
+ /** External link target URL. */
429
+ url?: string;
341
430
  }
342
431
  /**
343
432
  * An image node.
@@ -365,8 +454,11 @@ interface ImageNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TS
365
454
  * - Object allows wrap mode and position offsets
366
455
  */
367
456
  floating?: boolean | {
368
- /** Text wrap mode. */wrap?: 'square' | 'tight' | 'topAndBottom'; /** Horizontal offset. */
369
- x?: UnitValue; /** Vertical offset. */
457
+ /** Text wrap mode. */
458
+ wrap?: 'square' | 'tight' | 'topAndBottom';
459
+ /** Horizontal offset. */
460
+ x?: UnitValue;
461
+ /** Vertical offset. */
370
462
  y?: UnitValue;
371
463
  };
372
464
  }
@@ -375,7 +467,63 @@ interface ImageNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TS
375
467
  *
376
468
  * @template TStyles — The user's stylesheet type
377
469
  */
378
- type InlineNode<TStyles extends StyleSheet = StyleSheet> = HyperlinkNode<TStyles> | ImageNode<TStyles> | TextNode<TStyles>;
470
+ type InlineNode<TStyles extends StyleSheet = StyleSheet> = BookmarkNode<TStyles> | CheckboxNode<TStyles> | CommentNode<TStyles> | FootnoteNode<TStyles> | HyperlinkNode<TStyles> | ImageNode<TStyles> | MathNode | RevisionNode<TStyles> | TextNode<TStyles>;
471
+ /**
472
+ * A recursive expression used by {@link MathNode}.
473
+ */
474
+ type MathExpression = MathFractionExpression | MathFunctionExpression | MathIntegralExpression | MathRadicalExpression | MathScriptExpression | MathSumExpression | MathTextExpression;
475
+ /** A mathematical fraction. */
476
+ interface MathFractionExpression {
477
+ denominator: MathExpression[];
478
+ numerator: MathExpression[];
479
+ type: 'fraction';
480
+ }
481
+ /** A named mathematical function. */
482
+ interface MathFunctionExpression {
483
+ arguments: MathExpression[];
484
+ name: MathExpression[];
485
+ type: 'function';
486
+ }
487
+ /** A mathematical integral. */
488
+ interface MathIntegralExpression {
489
+ children: MathExpression[];
490
+ type: 'integral';
491
+ subScript?: MathExpression[];
492
+ superScript?: MathExpression[];
493
+ }
494
+ /**
495
+ * An Office Math (OMML) expression.
496
+ */
497
+ interface MathNode {
498
+ /** Structured mathematical expression tree. */
499
+ children: MathExpression[];
500
+ type: 'math';
501
+ }
502
+ /** A mathematical radical with an optional degree. */
503
+ interface MathRadicalExpression {
504
+ children: MathExpression[];
505
+ type: 'radical';
506
+ degree?: MathExpression[];
507
+ }
508
+ /** Subscript, superscript, or combined script. */
509
+ interface MathScriptExpression {
510
+ children: MathExpression[];
511
+ type: 'script';
512
+ subScript?: MathExpression[];
513
+ superScript?: MathExpression[];
514
+ }
515
+ /** A mathematical sum. */
516
+ interface MathSumExpression {
517
+ children: MathExpression[];
518
+ type: 'sum';
519
+ subScript?: MathExpression[];
520
+ superScript?: MathExpression[];
521
+ }
522
+ /** Plain text inside a mathematical expression. */
523
+ interface MathTextExpression {
524
+ text: string;
525
+ type: 'text';
526
+ }
379
527
  /**
380
528
  * A numbered / ordered list node.
381
529
  *
@@ -431,6 +579,21 @@ interface PluginNode<TName extends string = string, TOptions = unknown, TStyles
431
579
  options: TOptions;
432
580
  type: 'plugin';
433
581
  }
582
+ /**
583
+ * An inserted or deleted text revision.
584
+ */
585
+ interface RevisionNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
586
+ /** Revision author. */
587
+ author: string;
588
+ /** Text or styled text runs in the revision. */
589
+ children: (string | TextNode<TStyles>)[];
590
+ /** ISO-8601 revision timestamp. */
591
+ date: string;
592
+ /** Document-unique revision identifier. */
593
+ revisionId: number;
594
+ /** Revision kind. */
595
+ type: 'deletedText' | 'insertedText';
596
+ }
434
597
  /**
435
598
  * Internal marker node that represents a section boundary.
436
599
  *
@@ -445,6 +608,17 @@ interface SectionBreakNode {
445
608
  /** Optional per-section page/header/footer overrides. */
446
609
  config?: SectionConfig;
447
610
  }
611
+ /** Table-level border configuration. */
612
+ interface TableBordersConfig {
613
+ bottom?: BorderRule;
614
+ insideHorizontal?: BorderRule;
615
+ insideVertical?: BorderRule;
616
+ left?: BorderRule;
617
+ right?: BorderRule;
618
+ top?: BorderRule;
619
+ }
620
+ /** Per-cell style resolver. */
621
+ type TableCellStyleResolver<TData extends Record<string, unknown> = Record<string, unknown>> = (value: TData[keyof TData], row: TData, rowIndex: number, column: TableColumn<TData>) => DocxStyleRule;
448
622
  /**
449
623
  * A column definition for a table.
450
624
  *
@@ -457,17 +631,22 @@ interface TableColumn<TData extends Record<string, unknown> = Record<string, unk
457
631
  title: string;
458
632
  /** Cell text alignment. */
459
633
  align?: 'center' | 'left' | 'right';
634
+ /** Per-column data cell style or resolver. */
635
+ cellStyle?: DocxStyleRule | TableCellStyleResolver<TData>;
460
636
  /**
461
637
  * Span multiple columns horizontally.
462
638
  *
463
639
  * Applied to all cells in this column.
464
640
  */
465
641
  colSpan?: number;
642
+ /** Per-column header cell style. */
643
+ headerCellStyle?: DocxStyleRule;
466
644
  /**
467
645
  * Span multiple rows vertically (per-cell via data hints).
468
646
  *
469
- * Set `rowSpan` on individual data objects using `_rowSpan: N` or keep it
470
- * as a static column default.
647
+ * Set a keyed `_${key}_rowSpan: N` hint on an individual data object,
648
+ * use `_rowSpan: N` for every cell in that row, or keep this as a static
649
+ * column default.
471
650
  */
472
651
  rowSpan?: number;
473
652
  /** Column width. Supports percentage strings (e.g. `"30%"`). */
@@ -480,6 +659,40 @@ interface TableColumn<TData extends Record<string, unknown> = Record<string, unk
480
659
  */
481
660
  render?: (value: TData[keyof TData], row: TData, index: number) => string | InlineNode[];
482
661
  }
662
+ /** Floating table positioning. */
663
+ interface TableFloatingOptions {
664
+ /** Bottom distance from surrounding text. */
665
+ bottomFromText?: UnitValue;
666
+ /** Horizontal anchor. */
667
+ horizontalAnchor?: 'margin' | 'page' | 'text';
668
+ /** Left distance from surrounding text. */
669
+ leftFromText?: UnitValue;
670
+ /** Whether the table may overlap other floating objects. */
671
+ overlap?: boolean;
672
+ /** Right distance from surrounding text. */
673
+ rightFromText?: UnitValue;
674
+ /** Top distance from surrounding text. */
675
+ topFromText?: UnitValue;
676
+ /** Vertical anchor. */
677
+ verticalAnchor?: 'margin' | 'page' | 'text';
678
+ /** Absolute horizontal offset. */
679
+ x?: UnitValue;
680
+ /** Absolute vertical offset. */
681
+ y?: UnitValue;
682
+ /** Relative horizontal placement. */
683
+ relativeHorizontalPosition?: 'center' | 'inside' | 'left' | 'outside' | 'right';
684
+ /** Relative vertical placement. */
685
+ relativeVerticalPosition?: 'bottom' | 'center' | 'inline' | 'inside' | 'outside' | 'top';
686
+ }
687
+ /** Native Word table-look flags. */
688
+ interface TableLookOptions {
689
+ firstColumn?: boolean;
690
+ firstRow?: boolean;
691
+ lastColumn?: boolean;
692
+ lastRow?: boolean;
693
+ noHBand?: boolean;
694
+ noVBand?: boolean;
695
+ }
483
696
  /**
484
697
  * A table node with column definitions and data rows.
485
698
  *
@@ -492,16 +705,59 @@ interface TableNode<TData extends Record<string, unknown> = Record<string, unkno
492
705
  /** Row data objects. */
493
706
  data: TData[];
494
707
  type: 'table';
708
+ /** Horizontal table alignment. */
709
+ alignment?: 'center' | 'left' | 'right';
495
710
  /** Show table borders. */
496
711
  bordered?: boolean;
497
- /** Default cell style for data rows. */
498
- cellStyle?: DocxStyleRule;
712
+ /** Explicit outer and inner table borders. */
713
+ borders?: TableBordersConfig;
714
+ /** Default data cell style or per-cell resolver. */
715
+ cellStyle?: DocxStyleRule | TableCellStyleResolver<TData>;
716
+ /** Floating table positioning. Enables side-by-side layouts. */
717
+ floating?: TableFloatingOptions;
499
718
  /** Show header row (default: `true`). */
500
719
  header?: boolean;
501
720
  /** Style for header cells. */
502
721
  headerCellStyle?: DocxStyleRule;
722
+ /** Word table layout algorithm. */
723
+ layout?: 'autofit' | 'fixed';
503
724
  /** Alternate row shading. */
504
725
  striped?: boolean;
726
+ /** Native Word table style ID. */
727
+ styleName?: string;
728
+ /** Native Word table-look flags. */
729
+ tableLook?: TableLookOptions;
730
+ /** Render the table grid from right to left. */
731
+ visuallyRightToLeft?: boolean;
732
+ /** Overall table width. */
733
+ width?: UnitValue;
734
+ }
735
+ /**
736
+ * A legacy Word text box positioned as a block-level shape.
737
+ */
738
+ interface TextBoxNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
739
+ /** Text box dimensions and positioning. */
740
+ box: TextBoxOptions;
741
+ type: 'textBox';
742
+ /** Inline children (used instead of `text`). */
743
+ children?: InlineNode<TStyles>[];
744
+ /** Plain text content. */
745
+ text?: string;
746
+ }
747
+ /** Text box dimensions and positioning. */
748
+ interface TextBoxOptions {
749
+ /** Text box width. */
750
+ width: UnitValue;
751
+ /** Text box height. */
752
+ height?: UnitValue;
753
+ /** Horizontal offset. */
754
+ left?: UnitValue;
755
+ /** Shape positioning mode. */
756
+ position?: 'absolute' | 'relative' | 'static';
757
+ /** Vertical offset. */
758
+ top?: UnitValue;
759
+ /** Text wrapping behavior. */
760
+ wrap?: 'none' | 'square';
505
761
  }
506
762
  /**
507
763
  * A text run node (inline content).
@@ -513,8 +769,31 @@ interface TextNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TSt
513
769
  text: string;
514
770
  type: 'text';
515
771
  }
772
+ /**
773
+ * A horizontal thematic break rendered as a paragraph border.
774
+ */
775
+ interface ThematicBreakNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
776
+ type: 'thematicBreak';
777
+ }
516
778
  //#endregion
517
779
  //#region ../../packages/types/dist/document.d.ts
780
+ /** OOXML document properties shown in Word's File → Info panel. */
781
+ interface DocumentMetadata {
782
+ /** Document author. */
783
+ creator?: string;
784
+ /** Application-specific string properties. */
785
+ customProperties?: Record<string, string>;
786
+ /** Document description / summary. */
787
+ description?: string;
788
+ /** Keywords / tags. */
789
+ keywords?: string[];
790
+ /** Last editor. */
791
+ lastModifiedBy?: string;
792
+ /** Document subject. */
793
+ subject?: string;
794
+ /** Document title. */
795
+ title?: string;
796
+ }
518
797
  /**
519
798
  * Top-level configuration passed to `createDocx()`.
520
799
  *
@@ -524,6 +803,10 @@ interface TextNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TSt
524
803
  * @template TStyles — The user's stylesheet type (inferred from `styles`).
525
804
  */
526
805
  interface DocxKitConfig<TStyles extends StyleSheet = StyleSheet> {
806
+ /** Font files embedded into the generated DOCX package. */
807
+ fonts?: EmbeddedFont[];
808
+ /** OOXML core properties (appear in File → Info). */
809
+ metadata?: DocumentMetadata;
527
810
  /** Page dimensions and margins. */
528
811
  page?: PageConfig;
529
812
  /** Named style classes (class → style rule map). */
@@ -532,20 +815,23 @@ interface DocxKitConfig<TStyles extends StyleSheet = StyleSheet> {
532
815
  theme?: DocxTheme;
533
816
  /** Default styles applied as base for each element type. */
534
817
  defaults?: {
535
- /** Default table cell style. */cell?: DocxStyleRule; /** Default image style (applied to the paragraph wrapping the image). */
536
- image?: DocxStyleRule; /** Default paragraph style. */
537
- paragraph?: DocxStyleRule; /** Default table style. */
538
- table?: DocxStyleRule; /** Default text run style. */
818
+ /** Default table cell style. */
819
+ cell?: DocxStyleRule;
820
+ /** Default image style (applied to the paragraph wrapping the image). */
821
+ image?: DocxStyleRule;
822
+ /** Default paragraph style. */
823
+ paragraph?: DocxStyleRule;
824
+ /** Default table style. */
825
+ table?: DocxStyleRule;
826
+ /** Default text run style. */
539
827
  text?: DocxStyleRule;
540
828
  };
541
- /** OOXML core properties (appear in File → Info). */
542
- metadata?: {
543
- /** Document author. */creator?: string; /** Document description / summary. */
544
- description?: string; /** Keywords / tags. */
545
- keywords?: string[]; /** Last editor. */
546
- lastModifiedBy?: string; /** Document subject. */
547
- subject?: string; /** Document title. */
548
- title?: string;
829
+ /** Document-level Word feature switches. */
830
+ features?: {
831
+ /** Enable tracked revision display and behavior. */
832
+ trackRevisions?: boolean;
833
+ /** Ask Word to update fields when the document opens. */
834
+ updateFields?: boolean;
549
835
  };
550
836
  }
551
837
  /**
@@ -565,6 +851,13 @@ interface DocxTheme {
565
851
  /** Spacing tokens (name → value). */
566
852
  spacing?: ThemeSpacing;
567
853
  }
854
+ /** A TrueType/OpenType font embedded into the DOCX package. */
855
+ interface EmbeddedFont {
856
+ /** Raw font-file bytes. */
857
+ data: Uint8Array;
858
+ /** Font family name written to the OOXML font table. */
859
+ name: string;
860
+ }
568
861
  /**
569
862
  * Header/footer configuration for a section.
570
863
  *
@@ -590,12 +883,39 @@ interface HeaderFooterContent {
590
883
  }
591
884
  /** Page orientation. */
592
885
  type Orientation = 'landscape' | 'portrait';
886
+ /** Page border configuration. */
887
+ interface PageBorderConfig {
888
+ /** Bottom page border. */
889
+ bottom?: BorderRule;
890
+ /** Pages that display the border. */
891
+ display?: 'allPages' | 'firstPage' | 'notFirstPage';
892
+ /** Left page border. */
893
+ left?: BorderRule;
894
+ /** Measure border offsets from the page edge or text area. */
895
+ offsetFrom?: 'page' | 'text';
896
+ /** Right page border. */
897
+ right?: BorderRule;
898
+ /** Top page border. */
899
+ top?: BorderRule;
900
+ /** Render the border behind or in front of document content. */
901
+ zOrder?: 'back' | 'front';
902
+ }
593
903
  /**
594
904
  * Page configuration (size, orientation, margin).
595
905
  */
596
906
  interface PageConfig {
907
+ /** Page border configuration. */
908
+ borders?: PageBorderConfig;
909
+ /** Distance between the footer and the page edge. */
910
+ footerDistance?: UnitValue;
911
+ /** Extra gutter width for binding. */
912
+ gutter?: UnitValue;
913
+ /** Distance between the header and the page edge. */
914
+ headerDistance?: UnitValue;
597
915
  /** Page orientation (`"portrait"` default). */
598
916
  orientation?: Orientation;
917
+ /** Page-number sequence configuration for this section. */
918
+ pageNumber?: PageNumberConfig;
599
919
  /** Page size: preset name or explicit dimensions. */
600
920
  size?: PageSize | {
601
921
  height: UnitValue;
@@ -609,8 +929,35 @@ interface PageConfig {
609
929
  */
610
930
  margin?: `${string} ${string}` | `${string} ${string} ${string} ${string}` | UnitValue;
611
931
  }
932
+ /** Per-section page-number sequence configuration. */
933
+ interface PageNumberConfig {
934
+ /** First page number in the section. */
935
+ start?: number;
936
+ /** Page number format. */
937
+ format?: 'decimal' | 'lowerLetter' | 'lowerRoman' | 'upperLetter' | 'upperRoman';
938
+ }
612
939
  /** Available page size presets. */
613
940
  type PageSize = 'A3' | 'A4' | 'Legal' | 'Letter';
941
+ /** An explicitly sized section column. */
942
+ interface SectionColumn {
943
+ /** Column width. */
944
+ width: UnitValue;
945
+ /** Space after this column. */
946
+ spacing?: UnitValue;
947
+ }
948
+ /** Multi-column layout for a section. */
949
+ interface SectionColumnsConfig {
950
+ /** Explicit column widths for unequal-width layouts. */
951
+ columns?: SectionColumn[];
952
+ /** Number of equal-width columns. */
953
+ count?: number;
954
+ /** Whether Word should keep columns equally sized. */
955
+ equalWidth?: boolean;
956
+ /** Draw a separator line between columns. */
957
+ separator?: boolean;
958
+ /** Default spacing between columns. */
959
+ spacing?: UnitValue;
960
+ }
614
961
  /**
615
962
  * Per-section configuration.
616
963
  *
@@ -619,13 +966,32 @@ type PageSize = 'A3' | 'A4' | 'Legal' | 'Letter';
619
966
  * sections.
620
967
  */
621
968
  interface SectionConfig {
969
+ /** Multi-column layout. */
970
+ columns?: SectionColumnsConfig;
622
971
  /** Section footer(s). */
623
972
  footer?: HeaderFooterConfig;
624
973
  /** Section header(s). */
625
974
  header?: HeaderFooterConfig;
975
+ /** Line numbering. */
976
+ lineNumbers?: SectionLineNumberConfig;
626
977
  /** Section-specific page dimensions (overrides document-level `page`). */
627
978
  page?: PageConfig;
979
+ /** Section break behavior. */
980
+ type?: SectionType;
981
+ }
982
+ /** Line-numbering configuration for a section. */
983
+ interface SectionLineNumberConfig {
984
+ /** Number every Nth line. */
985
+ countBy?: number;
986
+ /** Distance between line numbers and text. */
987
+ distance?: UnitValue;
988
+ /** When line numbering restarts. */
989
+ restart?: 'continuous' | 'newPage' | 'newSection';
990
+ /** Starting line number. */
991
+ start?: number;
628
992
  }
993
+ /** Section break behavior. */
994
+ type SectionType = 'continuous' | 'evenPage' | 'nextColumn' | 'nextPage' | 'oddPage';
629
995
  /**
630
996
  * Theme color palette — semantic color tokens referenced by name.
631
997
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docxkit/plugin-watermark",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Text watermark — docx-kit plugin",
6
6
  "keywords": [
7
7
  "docx",
@@ -35,10 +35,10 @@
35
35
  "sideEffects": false,
36
36
  "peerDependencies": {
37
37
  "docx": "^9.7.1",
38
- "@docxkit/core": "0.3.0"
38
+ "@docxkit/core": "0.4.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@docxkit/pdk": "0.3.0"
41
+ "@docxkit/pdk": "0.4.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsdown",