@json-to-office/core-docx 0.37.0 → 0.38.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.
@@ -2,6 +2,7 @@
2
2
  * Bookmark Registry
3
3
  * Utilities for managing document bookmarks for internal hyperlinks
4
4
  */
5
+ import type { ParagraphChild } from 'docx';
5
6
  export interface BookmarkInfo {
6
7
  id: string;
7
8
  title: string;
@@ -35,6 +36,17 @@ export declare class BookmarkRegistry {
35
36
  * Register a bookmark
36
37
  */
37
38
  register(id: string, title: string, type: string): void;
39
+ /**
40
+ * A `w:id` no other bookmark in this document will use.
41
+ *
42
+ * docx's own `Bookmark` cannot supply one: its constructor builds a fresh
43
+ * id generator per instance (`bookmarkUniqueNumericIdGen()`), so every
44
+ * bookmark it emits carries `w:id="1"`. Reported upstream as dolanmiu/docx
45
+ * #3478, still unreleased as of 9.7.1. Duplicated ids leave the start/end
46
+ * pairing ambiguous, which is why a `REF` field could not read a target's
47
+ * text even though navigating to it by name worked.
48
+ */
49
+ allocateLinkId(): number;
38
50
  /**
39
51
  * Generate a unique bookmark ID from text
40
52
  * Converts text to a URL-friendly format
@@ -63,4 +75,12 @@ export declare class BookmarkRegistry {
63
75
  validateReferences(referencedIds: string[]): string[];
64
76
  }
65
77
  export declare const globalBookmarkRegistry: BookmarkRegistry;
78
+ /**
79
+ * A bookmark around `children`, as the three elements OOXML actually wants:
80
+ * `w:bookmarkStart`, the content, `w:bookmarkEnd`.
81
+ *
82
+ * Replaces docx's `Bookmark`, which pairs every start/end with `w:id="1"`
83
+ * (see `allocateLinkId`). Spread the result into a paragraph's children.
84
+ */
85
+ export declare function createBookmarkedContent(name: string, children: readonly ParagraphChild[]): ParagraphChild[];
66
86
  //# sourceMappingURL=bookmarkRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bookmarkRegistry.d.ts","sourceRoot":"","sources":["../../src/utils/bookmarkRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;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AuB,CACrC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,cAAc,EAAE,CAOlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-to-office/core-docx",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "Core DOCX document generation engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "adm-zip": "0.5.16",
24
24
  "date-fns": "3.6.0",
25
25
  "probe-image-size": "7.2.3",
26
- "@json-to-office/shared-docx": "^0.37.0",
27
- "@json-to-office/shared": "^0.35.0"
26
+ "@json-to-office/shared": "^0.35.0",
27
+ "@json-to-office/shared-docx": "^0.38.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "docx": "9.7.1"