@json-to-office/core-docx 0.38.0 → 1.0.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/dist/components/highcharts.d.ts +16 -6
- package/dist/components/highcharts.d.ts.map +1 -1
- package/dist/components/index.d.ts +8 -14
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/visual.d.ts +60 -18
- package/dist/components/visual.d.ts.map +1 -1
- package/dist/core/collectTocHeadings.d.ts +15 -1
- package/dist/core/collectTocHeadings.d.ts.map +1 -1
- package/dist/core/componentTransform.d.ts +30 -0
- package/dist/core/componentTransform.d.ts.map +1 -0
- package/dist/core/desugarExternals.d.ts +35 -0
- package/dist/core/desugarExternals.d.ts.map +1 -0
- package/dist/core/flattenVisuals.d.ts.map +1 -1
- package/dist/core/generateFromIr.d.ts +78 -0
- package/dist/core/generateFromIr.d.ts.map +1 -0
- package/dist/core/generationContext.d.ts +2 -2
- package/dist/core/generationContext.d.ts.map +1 -1
- package/dist/core/generator.d.ts +48 -39
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/imageResources.d.ts +35 -0
- package/dist/core/imageResources.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/layout.d.ts +15 -3
- package/dist/core/layout.d.ts.map +1 -1
- package/dist/core/markdownList.d.ts +21 -0
- package/dist/core/markdownList.d.ts.map +1 -0
- package/dist/core/prerasterizeVisuals.d.ts +2 -3
- package/dist/core/prerasterizeVisuals.d.ts.map +1 -1
- package/dist/core/sectionBookmarks.d.ts +15 -40
- package/dist/core/sectionBookmarks.d.ts.map +1 -1
- package/dist/core/tableModel.d.ts +188 -0
- package/dist/core/tableModel.d.ts.map +1 -0
- package/dist/core/tocField.d.ts +70 -0
- package/dist/core/tocField.d.ts.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8060 -7269
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts +49 -0
- package/dist/ir/compiler.d.ts.map +1 -0
- package/dist/ir/debug.d.ts +15 -0
- package/dist/ir/debug.d.ts.map +1 -0
- package/dist/ir/features.d.ts +19 -0
- package/dist/ir/features.d.ts.map +1 -0
- package/dist/ir/index.d.ts +16 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/inline.d.ts +126 -0
- package/dist/ir/inline.d.ts.map +1 -0
- package/dist/ir/types.d.ts +774 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/units.d.ts +57 -0
- package/dist/ir/units.d.ts.map +1 -0
- package/dist/ir/validation.d.ts +19 -0
- package/dist/ir/validation.d.ts.map +1 -0
- package/dist/plugin/createDocumentGenerator.d.ts +10 -3
- package/dist/plugin/createDocumentGenerator.d.ts.map +1 -1
- package/dist/plugin/example/index.d.ts.map +1 -1
- package/dist/plugin/example/index.js +8083 -7149
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/schema.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +13 -26
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/renderers/docxjs/emit.d.ts +41 -0
- package/dist/renderers/docxjs/emit.d.ts.map +1 -0
- package/dist/renderers/docxjs/index.d.ts +22 -0
- package/dist/renderers/docxjs/index.d.ts.map +1 -0
- package/dist/renderers/docxjs/styles.d.ts +12 -0
- package/dist/renderers/docxjs/styles.d.ts.map +1 -0
- package/dist/renderers/office-open/emit.d.ts +63 -0
- package/dist/renderers/office-open/emit.d.ts.map +1 -0
- package/dist/renderers/office-open/index.d.ts +25 -0
- package/dist/renderers/office-open/index.d.ts.map +1 -0
- package/dist/renderers/office-open/styles.d.ts +13 -0
- package/dist/renderers/office-open/styles.d.ts.map +1 -0
- package/dist/renderers/registry.d.ts +15 -0
- package/dist/renderers/registry.d.ts.map +1 -0
- package/dist/renderers/types.d.ts +35 -0
- package/dist/renderers/types.d.ts.map +1 -0
- package/dist/styles/themeToStyles.d.ts +12 -0
- package/dist/styles/themeToStyles.d.ts.map +1 -0
- package/dist/styles/utils/borderUtils.d.ts +13 -6
- package/dist/styles/utils/borderUtils.d.ts.map +1 -1
- package/dist/styles/utils/layoutUtils.d.ts +10 -14
- package/dist/styles/utils/layoutUtils.d.ts.map +1 -1
- package/dist/styles/utils/styleHelpers.d.ts +6 -2
- package/dist/styles/utils/styleHelpers.d.ts.map +1 -1
- package/dist/themes/overrides.d.ts +0 -2
- package/dist/themes/overrides.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +18 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/bookmarkRegistry.d.ts +13 -77
- package/dist/utils/bookmarkRegistry.d.ts.map +1 -1
- package/dist/utils/commentRegistry.d.ts +5 -43
- package/dist/utils/commentRegistry.d.ts.map +1 -1
- package/dist/utils/exampleRunner.d.ts.map +1 -1
- package/dist/utils/imageUtils.d.ts +23 -19
- package/dist/utils/imageUtils.d.ts.map +1 -1
- package/dist/utils/numberingConfig.d.ts +7 -87
- package/dist/utils/numberingConfig.d.ts.map +1 -1
- package/dist/utils/packageDocument.d.ts +0 -3
- package/dist/utils/packageDocument.d.ts.map +1 -1
- package/dist/utils/revisionUtils.d.ts +6 -67
- package/dist/utils/revisionUtils.d.ts.map +1 -1
- package/dist/utils/warningsDocument.d.ts.map +1 -1
- package/package.json +12 -4
- package/dist/cache/index.d.ts +0 -7
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/key-generator.d.ts +0 -34
- package/dist/cache/key-generator.d.ts.map +0 -1
- package/dist/components/columns.d.ts +0 -12
- package/dist/components/columns.d.ts.map +0 -1
- package/dist/components/heading.d.ts +0 -12
- package/dist/components/heading.d.ts.map +0 -1
- package/dist/components/image.d.ts +0 -12
- package/dist/components/image.d.ts.map +0 -1
- package/dist/components/list.d.ts +0 -12
- package/dist/components/list.d.ts.map +0 -1
- package/dist/components/paragraph.d.ts +0 -12
- package/dist/components/paragraph.d.ts.map +0 -1
- package/dist/components/section.d.ts +0 -12
- package/dist/components/section.d.ts.map +0 -1
- package/dist/components/statistic.d.ts +0 -12
- package/dist/components/statistic.d.ts.map +0 -1
- package/dist/components/table.d.ts +0 -13
- package/dist/components/table.d.ts.map +0 -1
- package/dist/components/text-box.d.ts +0 -9
- package/dist/components/text-box.d.ts.map +0 -1
- package/dist/components/toc/index.d.ts +0 -30
- package/dist/components/toc/index.d.ts.map +0 -1
- package/dist/core/cached-render.d.ts +0 -92
- package/dist/core/cached-render.d.ts.map +0 -1
- package/dist/core/content.d.ts +0 -319
- package/dist/core/content.d.ts.map +0 -1
- package/dist/core/render.d.ts +0 -48
- package/dist/core/render.d.ts.map +0 -1
- package/dist/styles/themeToDocxAdapter.d.ts +0 -22
- package/dist/styles/themeToDocxAdapter.d.ts.map +0 -1
- package/dist/styles/utils/cellUtils.d.ts +0 -55
- package/dist/styles/utils/cellUtils.d.ts.map +0 -1
- package/dist/utils/alignmentUtils.d.ts +0 -10
- package/dist/utils/alignmentUtils.d.ts.map +0 -1
- package/dist/utils/commentAnchors.d.ts +0 -39
- package/dist/utils/commentAnchors.d.ts.map +0 -1
- package/dist/utils/componentAnnotations.d.ts +0 -23
- package/dist/utils/componentAnnotations.d.ts.map +0 -1
- package/dist/utils/docxImagePositioning.d.ts +0 -19
- package/dist/utils/docxImagePositioning.d.ts.map +0 -1
- package/dist/utils/noteRegistry.d.ts +0 -43
- package/dist/utils/noteRegistry.d.ts.map +0 -1
- package/dist/utils/noteResolver.d.ts +0 -31
- package/dist/utils/noteResolver.d.ts.map +0 -1
- package/dist/utils/numberedItemsRegistry.d.ts +0 -38
- package/dist/utils/numberedItemsRegistry.d.ts.map +0 -1
- package/dist/utils/placeholderImage.d.ts +0 -31
- package/dist/utils/placeholderImage.d.ts.map +0 -1
- package/dist/utils/placeholderProcessor.d.ts +0 -58
- package/dist/utils/placeholderProcessor.d.ts.map +0 -1
- package/dist/utils/textParser.d.ts +0 -117
- package/dist/utils/textParser.d.ts.map +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { ISectionOptions } from 'docx';
|
|
2
1
|
import type { ThemeName } from '../styles';
|
|
3
2
|
import type { TocHeadingEntry } from '../core/collectTocHeadings';
|
|
4
3
|
import type { ServicesConfig, PptxRasterizeBatchSlideResult, RasterizeFontFace } from '@json-to-office/shared';
|
|
5
|
-
import type { ComponentDefinition as SharedComponentDefinition, ReportComponent, SectionComponent, ColumnsComponent, HeadingComponent, ParagraphComponent, ImageComponent, HighchartsComponent, VisualComponent, StatisticComponent, TableComponent, ListComponent, TocComponent, TextBoxComponent, ReportProps as SharedReportProps, SectionProps as SharedSectionProps, HeadingProps as SharedHeadingProps, ParagraphProps as SharedParagraphProps, ColumnsProps as SharedColumnsProps, ImageProps as SharedImageProps, VisualProps as SharedVisualProps, StatisticProps as SharedStatisticProps, TableProps as SharedTableProps, ListProps as SharedListProps, TocProps as SharedTocProps, TextBoxProps as SharedTextBoxProps } from '@json-to-office/shared-docx';
|
|
4
|
+
import type { ComponentDefinition as SharedComponentDefinition, ReportComponent, ReportComponentFor, SectionComponent, ColumnsComponent, HeadingComponent, ParagraphComponent, ImageComponent, HighchartsComponent, VisualComponent, StatisticComponent, TableComponent, ListComponent, TocComponent, TextBoxComponent, ReportProps as SharedReportProps, SectionProps as SharedSectionProps, HeadingProps as SharedHeadingProps, ParagraphProps as SharedParagraphProps, ColumnsProps as SharedColumnsProps, ImageProps as SharedImageProps, VisualProps as SharedVisualProps, StatisticProps as SharedStatisticProps, TableProps as SharedTableProps, ListProps as SharedListProps, TocProps as SharedTocProps, TextBoxProps as SharedTextBoxProps } from '@json-to-office/shared-docx';
|
|
6
5
|
export { isReportComponent, isSectionComponent, isHeadingComponent, isParagraphComponent, isColumnsComponent, isImageComponent, isTextBoxComponent, isStatisticComponent, isTableComponent, isListComponent, isTocComponent, isHighchartsComponent, isVisualComponent, } from '@json-to-office/shared-docx';
|
|
7
6
|
export type ComponentDefinition = SharedComponentDefinition;
|
|
8
7
|
export type ReportComponentDefinition = ReportComponent & {
|
|
9
8
|
/** Optional schema field for JSON validation */
|
|
10
9
|
$schema?: string;
|
|
11
10
|
};
|
|
11
|
+
export type ReportComponentDefinitionFor<R extends import('@json-to-office/shared-docx').DocxRendererId> = ReportComponentFor<R> & {
|
|
12
|
+
$schema?: string;
|
|
13
|
+
};
|
|
12
14
|
export type SectionComponentDefinition = SectionComponent;
|
|
13
15
|
export type HeadingComponentDefinition = HeadingComponent;
|
|
14
16
|
export type ParagraphComponentDefinition = ParagraphComponent;
|
|
@@ -92,8 +94,20 @@ export interface SectionProperties {
|
|
|
92
94
|
};
|
|
93
95
|
column?: ColumnSettings;
|
|
94
96
|
type?: 'continuous' | 'nextColumn' | 'nextPage' | 'evenPage' | 'oddPage';
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Header and footer parts, by slot.
|
|
99
|
+
*
|
|
100
|
+
* Content is deliberately opaque here: a section's chrome is authored as
|
|
101
|
+
* components and resolved into IR blocks, and naming a renderer's part type
|
|
102
|
+
* would put that renderer back into a public type.
|
|
103
|
+
*/
|
|
104
|
+
headers?: HeaderFooterSlots;
|
|
105
|
+
footers?: HeaderFooterSlots;
|
|
106
|
+
}
|
|
107
|
+
export interface HeaderFooterSlots {
|
|
108
|
+
default?: unknown;
|
|
109
|
+
first?: unknown;
|
|
110
|
+
even?: unknown;
|
|
97
111
|
}
|
|
98
112
|
export interface ImageContent {
|
|
99
113
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,W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AAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;IACzE;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC3C;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CAC1C"}
|
|
@@ -1,86 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Slug a piece of text into a bookmark id candidate.
|
|
2
|
+
* Naming a bookmark.
|
|
3
|
+
*
|
|
4
|
+
* A heading with no author-supplied id is addressable by a slug of its text, so
|
|
5
|
+
* the slug has to be derivable identically by whoever writes the bookmark and
|
|
6
|
+
* whoever points at it — the compiler and the document-outline pre-pass both
|
|
7
|
+
* call this, and a disagreement would be a cross-reference resolving against an
|
|
8
|
+
* id that never gets written.
|
|
13
9
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* cannot live inside the registry.
|
|
10
|
+
* This used to be a registry with per-render state; the compiler numbers its
|
|
11
|
+
* own bookmarks now, so what is left is the naming.
|
|
17
12
|
*/
|
|
13
|
+
/** Slug a piece of text into a bookmark id candidate. */
|
|
18
14
|
export declare function slugifyBookmarkText(text: string): string;
|
|
19
15
|
/**
|
|
20
16
|
* Disambiguate a slug against ids already taken, appending `-1`, `-2`, … .
|
|
21
|
-
* Gives up after 100 attempts and returns the colliding id, exactly as
|
|
22
|
-
* `generateId` always has.
|
|
23
|
-
*/
|
|
24
|
-
export declare function dedupeBookmarkId(base: string, taken: (id: string) => boolean): string;
|
|
25
|
-
/**
|
|
26
|
-
* Registry for managing document bookmarks
|
|
27
|
-
* Used to track bookmark IDs and validate internal hyperlink targets
|
|
28
|
-
*/
|
|
29
|
-
export declare class BookmarkRegistry {
|
|
30
|
-
private readonly fallback;
|
|
31
|
-
private readonly scopes;
|
|
32
|
-
private get state();
|
|
33
|
-
/** Run work with an isolated registry that follows its async call chain. */
|
|
34
|
-
runScoped<T>(callback: () => T): T;
|
|
35
|
-
/**
|
|
36
|
-
* Register a bookmark
|
|
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;
|
|
50
|
-
/**
|
|
51
|
-
* Generate a unique bookmark ID from text
|
|
52
|
-
* Converts text to a URL-friendly format
|
|
53
|
-
*/
|
|
54
|
-
generateId(text: string, _type?: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* Check if a bookmark exists
|
|
57
|
-
*/
|
|
58
|
-
exists(id: string): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Get bookmark info by ID
|
|
61
|
-
*/
|
|
62
|
-
get(id: string): BookmarkInfo | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Get all registered bookmarks
|
|
65
|
-
*/
|
|
66
|
-
getAll(): BookmarkInfo[];
|
|
67
|
-
/**
|
|
68
|
-
* Clear all bookmarks
|
|
69
|
-
*/
|
|
70
|
-
clear(): void;
|
|
71
|
-
/**
|
|
72
|
-
* Validate that all internal hyperlink references exist
|
|
73
|
-
* Returns array of missing bookmark IDs
|
|
74
|
-
*/
|
|
75
|
-
validateReferences(referencedIds: string[]): string[];
|
|
76
|
-
}
|
|
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
17
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
18
|
+
* Gives up after 100 attempts and returns the colliding id: a document with a
|
|
19
|
+
* hundred headings slugging identically has a naming problem no suffix fixes.
|
|
84
20
|
*/
|
|
85
|
-
export declare function
|
|
21
|
+
export declare function dedupeBookmarkId(base: string, taken: (id: string) => boolean): string;
|
|
86
22
|
//# sourceMappingURL=bookmarkRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bookmarkRegistry.d.ts","sourceRoot":"","sources":["../../src/utils/bookmarkRegistry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"bookmarkRegistry.d.ts","sourceRoot":"","sources":["../../src/utils/bookmarkRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,yDAAyD;AACzD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAC7B,MAAM,CAOR"}
|
|
@@ -1,49 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Review-comment defaults.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* same `runScoped` nest, or two concurrent generations interleave counters and
|
|
8
|
-
* a comment anchor points at another document's body.
|
|
9
|
-
*
|
|
10
|
-
* The registry holds both halves of a comment: the id used by the anchor in
|
|
11
|
-
* `word/document.xml`, and the body that `renderDocument` hands to docx for
|
|
12
|
-
* `word/comments.xml`.
|
|
4
|
+
* The ids and the bodies live in the compiler now — it numbers every comment
|
|
5
|
+
* itself, per compilation, and carries the bodies in the IR. What is left is
|
|
6
|
+
* the two values a comment falls back to when the author states neither.
|
|
13
7
|
*/
|
|
14
|
-
import type { ICommentOptions } from 'docx';
|
|
15
|
-
import type { Comment } from '@json-to-office/shared-docx';
|
|
16
8
|
export declare const DEFAULT_COMMENT_AUTHOR = "json-to-office";
|
|
9
|
+
/** A fixed instant, so identical inputs produce byte-identical XML. */
|
|
17
10
|
export declare const DEFAULT_COMMENT_DATE = "1970-01-01T00:00:00Z";
|
|
18
|
-
declare class CommentRegistry {
|
|
19
|
-
private fallback;
|
|
20
|
-
private readonly scopes;
|
|
21
|
-
private get state();
|
|
22
|
-
/** Run work with an isolated registry that follows its async call chain. */
|
|
23
|
-
runScoped<T>(callback: () => T): T;
|
|
24
|
-
/**
|
|
25
|
-
* Register a comment thread and return every id its anchors must carry — the
|
|
26
|
-
* root first, then each reply in order. Word anchors every comment in a
|
|
27
|
-
* thread over the same range, so all of them need a range and a reference.
|
|
28
|
-
*
|
|
29
|
-
* Ids are unique and monotonic within a render. `parentId` is derived here
|
|
30
|
-
* rather than authored; docx turns it into the `w15:paraIdParent` links in
|
|
31
|
-
* `word/commentsExtended.xml`.
|
|
32
|
-
*/
|
|
33
|
-
register(comment: Comment): number[];
|
|
34
|
-
private toOptions;
|
|
35
|
-
/**
|
|
36
|
-
* Every comment registered in this scope, in id order.
|
|
37
|
-
*
|
|
38
|
-
* docx writes `word/commentsExtended.xml` — and therefore any `w15:done` —
|
|
39
|
-
* only when at least one comment in the document carries a `parentId`. A
|
|
40
|
-
* document whose only resolved comment has no replies would silently lose
|
|
41
|
-
* that state, so say so rather than dropping it quietly.
|
|
42
|
-
*/
|
|
43
|
-
getAll(): ICommentOptions[];
|
|
44
|
-
/** Test-only: reset the current scope's counter and bodies. */
|
|
45
|
-
clear(): void;
|
|
46
|
-
}
|
|
47
|
-
export declare const globalCommentRegistry: CommentRegistry;
|
|
48
|
-
export {};
|
|
49
11
|
//# sourceMappingURL=commentRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commentRegistry.d.ts","sourceRoot":"","sources":["../../src/utils/commentRegistry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"commentRegistry.d.ts","sourceRoot":"","sources":["../../src/utils/commentRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exampleRunner.d.ts","sourceRoot":"","sources":["../../src/utils/exampleRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,yBAAyB,EAClC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"exampleRunner.d.ts","sourceRoot":"","sources":["../../src/utils/exampleRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,yBAAyB,EAClC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAqCf"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Rasterize inline SVG for the `fallback` slot of an SVG `ImageRun`.
|
|
4
|
+
*
|
|
5
|
+
* Word 2016+ draws the vector, but every older Word and non-SVG consumer
|
|
6
|
+
* renders the fallback instead — so shipping the SVG bytes under a `png` type
|
|
7
|
+
* gave those readers a broken image. Returns `undefined` when rasterization is
|
|
8
|
+
* unavailable or fails; the caller then keeps the historical bytes, which is
|
|
9
|
+
* no worse than before and never fails the render.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rasterizeSvgFallback(svg: Buffer, transformation: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}): Promise<Buffer | undefined>;
|
|
3
15
|
export interface ImageDimensions {
|
|
4
16
|
width: number;
|
|
5
17
|
height: number;
|
|
@@ -66,24 +78,6 @@ export declare function detectImageTypeFromMimeType(mimeType: string): 'jpg' | '
|
|
|
66
78
|
* @returns Image type (jpg, png, gif, bmp, svg)
|
|
67
79
|
*/
|
|
68
80
|
export declare function detectImageType(imagePath: string, responseContentType?: string): 'jpg' | 'png' | 'gif' | 'bmp' | 'svg';
|
|
69
|
-
/**
|
|
70
|
-
* Create an ImageRun with correct type handling, including SVG fallback.
|
|
71
|
-
*
|
|
72
|
-
* An SVG run carries a raster `fallback` for readers that cannot draw the
|
|
73
|
-
* vector — Word before 2016, and anything else consuming the package. That
|
|
74
|
-
* fallback is rasterized here; if rasterization is unavailable the run keeps
|
|
75
|
-
* the SVG bytes, which renders in Word 2016+ and reports a warning for the
|
|
76
|
-
* rest rather than failing the document.
|
|
77
|
-
*/
|
|
78
|
-
export declare function createTypedImageRun(opts: {
|
|
79
|
-
type: 'jpg' | 'png' | 'gif' | 'bmp' | 'svg';
|
|
80
|
-
data: Buffer;
|
|
81
|
-
transformation: {
|
|
82
|
-
width: number;
|
|
83
|
-
height: number;
|
|
84
|
-
};
|
|
85
|
-
floating?: IFloating;
|
|
86
|
-
}): Promise<ImageRun>;
|
|
87
81
|
/**
|
|
88
82
|
* Download image from URL and return buffer
|
|
89
83
|
* Uses native fetch with automatic redirect following and proper headers
|
|
@@ -110,6 +104,16 @@ export declare function getImageBuffer(imagePath: string): Promise<ImageBufferRe
|
|
|
110
104
|
* Get the dimensions of an image file or URL
|
|
111
105
|
*/
|
|
112
106
|
export declare function getImageDimensions(imagePath: string): Promise<ImageDimensions>;
|
|
107
|
+
/**
|
|
108
|
+
* Get the dimensions of bytes already in hand.
|
|
109
|
+
*
|
|
110
|
+
* The point is that it takes bytes rather than a location. A caller that has
|
|
111
|
+
* loaded an image and then asks `getImageDimensions` for its size fetches the
|
|
112
|
+
* same URL twice — doubling the network traffic, and, if the response changes
|
|
113
|
+
* between the two, embedding one image while sizing it from another (#267).
|
|
114
|
+
* `label` is only used in the message.
|
|
115
|
+
*/
|
|
116
|
+
export declare function readImageDimensions(bytes: Buffer, label: string): ImageDimensions;
|
|
113
117
|
/**
|
|
114
118
|
* Calculate missing dimension while preserving aspect ratio
|
|
115
119
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/imageUtils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"imageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/imageUtils.ts"],"names":[],"mappings":";AAoEA;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,cAAc,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoD7B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE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ED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,CAAC,CAyC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,GAAG,SAAS,CAYrB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,iBAAiB,CAAC,CAY5B;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,CAS1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,eAAe,CAQjB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,GACpB,oBAAoB,CA0BtB;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,aAAa,GAAE,MAAY,EAC3B,cAAc,GAAE,MAAY,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CA+B/B"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* How a list numbers itself.
|
|
3
|
+
*
|
|
4
|
+
* The level shapes an author can state, plus the two constants a numbered
|
|
5
|
+
* heading needs. Turning any of it into OOXML is the compiler's and the
|
|
6
|
+
* adapter's job — this module builds nothing, so both the outline pre-pass and
|
|
7
|
+
* the compiler can read the same declarations without either pulling in a
|
|
8
|
+
* renderer.
|
|
4
9
|
*/
|
|
5
|
-
import type { ILevelsOptions } from 'docx';
|
|
6
10
|
/**
|
|
7
11
|
* Styling for the marker glyph itself (`w:lvl/w:rPr`), independent of the list
|
|
8
12
|
* text. `color` must already be resolved to a 6-char hex without '#'.
|
|
@@ -29,52 +33,12 @@ export interface ListLevelConfig {
|
|
|
29
33
|
start?: number;
|
|
30
34
|
font?: ListMarkerFontConfig;
|
|
31
35
|
}
|
|
32
|
-
export interface NumberingConfig {
|
|
33
|
-
reference: string;
|
|
34
|
-
levels: ListLevelConfig[];
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create numbering configuration from list config
|
|
38
|
-
* Returns a single config item that can be added to INumberingOptions.config array
|
|
39
|
-
*/
|
|
40
|
-
export declare function createNumberingConfig(config: NumberingConfig): {
|
|
41
|
-
levels: ILevelsOptions[];
|
|
42
|
-
reference: string;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Create a simple bullet list configuration
|
|
46
|
-
*/
|
|
47
|
-
export declare function createBulletListConfig(reference: string, bullet?: string): {
|
|
48
|
-
levels: ILevelsOptions[];
|
|
49
|
-
reference: string;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Create a simple numbered list configuration
|
|
53
|
-
*/
|
|
54
|
-
export declare function createNumberedListConfig(reference: string, start?: number): {
|
|
55
|
-
levels: ILevelsOptions[];
|
|
56
|
-
reference: string;
|
|
57
|
-
};
|
|
58
36
|
/**
|
|
59
37
|
* The one multilevel definition every numbered heading in a document shares —
|
|
60
38
|
* shared so that 1., 1.1., 1.1.1. is a single continuous sequence rather than
|
|
61
39
|
* one restarting per heading.
|
|
62
40
|
*/
|
|
63
41
|
export declare const HEADING_NUMBERING_REFERENCE = "jto-heading-numbering";
|
|
64
|
-
/**
|
|
65
|
-
* Word's built-in heading numbering: decimal at every level, each level's text
|
|
66
|
-
* accumulating the ones above it, bound to `Heading1`..`Heading6` through
|
|
67
|
-
* `w:lvl/w:pStyle` so Word's own "restart/continue numbering" UI and the `\r`
|
|
68
|
-
* cross-reference switch recognise it.
|
|
69
|
-
*
|
|
70
|
-
* The levels are built here rather than through `createNumberingConfig`
|
|
71
|
-
* because that helper applies list indents; a numbered heading stays flush
|
|
72
|
-
* left and takes its indentation from the heading style.
|
|
73
|
-
*/
|
|
74
|
-
export declare function createHeadingNumberingConfig(): {
|
|
75
|
-
levels: ILevelsOptions[];
|
|
76
|
-
reference: string;
|
|
77
|
-
};
|
|
78
42
|
/**
|
|
79
43
|
* The heading number as Word draws it in the document — the bare dotted number
|
|
80
44
|
* plus the trailing period `lvlText` ends with.
|
|
@@ -86,48 +50,4 @@ export declare function createHeadingNumberingConfig(): {
|
|
|
86
50
|
* switch is defined as the paragraph number *without* trailing periods.
|
|
87
51
|
*/
|
|
88
52
|
export declare function headingNumberLabel(number: string): string;
|
|
89
|
-
/**
|
|
90
|
-
* Registry for managing numbering configurations
|
|
91
|
-
*/
|
|
92
|
-
export declare class NumberingRegistry {
|
|
93
|
-
private readonly fallback;
|
|
94
|
-
private readonly scopes;
|
|
95
|
-
private get state();
|
|
96
|
-
/** Run work with an isolated registry that follows its async call chain. */
|
|
97
|
-
runScoped<T>(callback: () => T): T;
|
|
98
|
-
/**
|
|
99
|
-
* Register a numbering configuration
|
|
100
|
-
*/
|
|
101
|
-
register(config: {
|
|
102
|
-
levels: ILevelsOptions[];
|
|
103
|
-
reference: string;
|
|
104
|
-
}): string;
|
|
105
|
-
/**
|
|
106
|
-
* Generate a unique reference ID
|
|
107
|
-
*/
|
|
108
|
-
generateReference(prefix?: string): string;
|
|
109
|
-
/**
|
|
110
|
-
* Get all registered configurations as an array suitable for INumberingOptions
|
|
111
|
-
*/
|
|
112
|
-
getAll(): {
|
|
113
|
-
levels: ILevelsOptions[];
|
|
114
|
-
reference: string;
|
|
115
|
-
}[];
|
|
116
|
-
/**
|
|
117
|
-
* Clear all configurations
|
|
118
|
-
*/
|
|
119
|
-
clear(): void;
|
|
120
|
-
/**
|
|
121
|
-
* Check if a reference exists
|
|
122
|
-
*/
|
|
123
|
-
has(reference: string): boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Get a configuration by reference
|
|
126
|
-
*/
|
|
127
|
-
get(reference: string): {
|
|
128
|
-
levels: ILevelsOptions[];
|
|
129
|
-
reference: string;
|
|
130
|
-
} | undefined;
|
|
131
|
-
}
|
|
132
|
-
export declare const globalNumberingRegistry: NumberingRegistry;
|
|
133
53
|
//# sourceMappingURL=numberingConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberingConfig.d.ts","sourceRoot":"","sources":["../../src/utils/numberingConfig.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"numberingConfig.d.ts","sourceRoot":"","sources":["../../src/utils/numberingConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAEnE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { type Document } from 'docx';
|
|
3
2
|
export interface DocumentPackageOptions {
|
|
4
3
|
/** Normalize volatile OOXML metadata and ZIP timestamps. Defaults to true. */
|
|
5
4
|
deterministic?: boolean;
|
|
@@ -15,6 +14,4 @@ export declare function resolveGenerationDate(options?: DocumentPackageOptions):
|
|
|
15
14
|
* timezone; this produces identical header bits in every locale.
|
|
16
15
|
*/
|
|
17
16
|
export declare function canonicalizeDocxBuffer(buffer: Buffer, generatedAt?: Date): Buffer;
|
|
18
|
-
/** Package a DOCX and apply all required OOXML post-processing once. */
|
|
19
|
-
export declare function packageDocument(document: Document, options?: DocumentPackageOptions): Promise<Buffer>;
|
|
20
17
|
//# sourceMappingURL=packageDocument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageDocument.d.ts","sourceRoot":"","sources":["../../src/utils/packageDocument.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"packageDocument.d.ts","sourceRoot":"","sources":["../../src/utils/packageDocument.ts"],"names":[],"mappings":";AAEA,MAAM,WAAW,sBAAsB;IACrC,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,MAAuC,CAAC;AAE5E,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAiB5E;AAuGD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,IAA8B,GAC1C,MAAM,CA+BR"}
|
|
@@ -1,73 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Tracked-change defaults.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The ids, the runs and the registry that used to hand them out all live in the
|
|
5
|
+
* compiler now — it allocates every `w:ins`/`w:del` id itself, per compilation,
|
|
6
|
+
* in document order. What is left is the two values a revision falls back to
|
|
7
|
+
* when the author states neither, which are shared with the schema.
|
|
6
8
|
*/
|
|
7
|
-
import { TextRun, InsertedTextRun, DeletedTextRun } from 'docx';
|
|
8
|
-
import type { IRunOptions, ParagraphChild } from 'docx';
|
|
9
|
-
import type { Revision, RevisionMark } from '@json-to-office/shared-docx';
|
|
10
|
-
import { type MaybeComponent } from './componentAnnotations';
|
|
11
9
|
export declare const DEFAULT_REVISION_AUTHOR = "json-to-office";
|
|
10
|
+
/** A fixed instant, so identical inputs produce byte-identical XML. */
|
|
12
11
|
export declare const DEFAULT_REVISION_DATE = "1970-01-01T00:00:00Z";
|
|
13
|
-
/**
|
|
14
|
-
* OOXML requires a numeric id on every w:ins / w:del element, unique within
|
|
15
|
-
* one document. Async-local state gives each render its own deterministic
|
|
16
|
-
* counter without collisions when documents render concurrently.
|
|
17
|
-
*/
|
|
18
|
-
declare class RevisionIdRegistry {
|
|
19
|
-
private fallbackCounter;
|
|
20
|
-
private readonly scopes;
|
|
21
|
-
runScoped<T>(callback: () => T): T;
|
|
22
|
-
next(): number;
|
|
23
|
-
/** Test-only: deterministic ids for snapshot assertions. */
|
|
24
|
-
clear(): void;
|
|
25
|
-
}
|
|
26
|
-
export declare const globalRevisionIdRegistry: RevisionIdRegistry;
|
|
27
|
-
export type RevisionRun = TextRun | InsertedTextRun | DeletedTextRun;
|
|
28
|
-
type RevisionBaseStyle = Omit<IRunOptions, 'text' | 'children'>;
|
|
29
|
-
/**
|
|
30
|
-
* Build paragraph children from revision segments.
|
|
31
|
-
*
|
|
32
|
-
* Segment text is rendered literally (no markdown parsing): a `**` opened in
|
|
33
|
-
* one segment could close in another, so decorator parsing cannot work
|
|
34
|
-
* per-segment. The diff engine strips markdown before diffing for this
|
|
35
|
-
* reason. Placeholders ({DATE}, {PAGE}, ...) are resolved for unchanged
|
|
36
|
-
* segments; inside inserted/deleted text they render literally (the diff
|
|
37
|
-
* summary reports those).
|
|
38
|
-
*/
|
|
39
|
-
export declare function createRevisionRuns(revision: Revision, baseStyle: RevisionBaseStyle): ParagraphChild[];
|
|
40
|
-
/**
|
|
41
|
-
* True when a component carries revision data anywhere in its subtree,
|
|
42
|
-
* meaning its render output embeds document-scoped w:ins/w:del ids and must not
|
|
43
|
-
* be served from the cross-document component cache.
|
|
44
|
-
*/
|
|
45
|
-
export declare function componentHasRevision(component: MaybeComponent): boolean;
|
|
46
|
-
/** docx's shape for a structural tracked change (`w:ins` / `w:del` attrs). */
|
|
47
|
-
export interface RevisionMarkAttributes {
|
|
48
|
-
id: number;
|
|
49
|
-
author: string;
|
|
50
|
-
date: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Turn a structural revision into the attribute triple docx wants, allocating
|
|
54
|
-
* the document-scoped id.
|
|
55
|
-
*
|
|
56
|
-
* Callers must invoke this in a synchronous prefix — before any `await` — or
|
|
57
|
-
* ids end up ordered by I/O completion rather than document order.
|
|
58
|
-
*/
|
|
59
|
-
export declare function createRevisionMark(mark: RevisionMark): {
|
|
60
|
-
insertion?: RevisionMarkAttributes;
|
|
61
|
-
deletion?: RevisionMarkAttributes;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Render a cell's text as runs that are wholly inserted or wholly deleted,
|
|
65
|
-
* matching the structural mark on the row they sit in.
|
|
66
|
-
*
|
|
67
|
-
* A `w:trPr/w:del` alone leaves the cell text un-struck, and accepting the
|
|
68
|
-
* change would leave an empty row behind rather than removing it. Word needs
|
|
69
|
-
* both halves: the row mark and every run inside it marked the same way.
|
|
70
|
-
*/
|
|
71
|
-
export declare function createMarkedTextRuns(text: string, mark: RevisionMark, baseStyle: RevisionBaseStyle): ParagraphChild[];
|
|
72
|
-
export {};
|
|
73
12
|
//# sourceMappingURL=revisionUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revisionUtils.d.ts","sourceRoot":"","sources":["../../src/utils/revisionUtils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"revisionUtils.d.ts","sourceRoot":"","sources":["../../src/utils/revisionUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AACxD,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warningsDocument.d.ts","sourceRoot":"","sources":["../../src/utils/warningsDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAuB,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE/E;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAI,GACnC,yBAAyB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"warningsDocument.d.ts","sourceRoot":"","sources":["../../src/utils/warningsDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAuB,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE/E;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAI,GACnC,yBAAyB,GAAG,IAAI,CAkFlC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAI,GACnC,MAAM,CAuCR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@json-to-office/core-docx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Core DOCX document generation engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,13 +23,21 @@
|
|
|
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": "^0.
|
|
27
|
-
"@json-to-office/shared-docx": "^0.
|
|
26
|
+
"@json-to-office/shared": "^1.0.0",
|
|
27
|
+
"@json-to-office/shared-docx": "^1.0.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"docx": "9.7.1"
|
|
30
|
+
"docx": "9.7.1",
|
|
31
|
+
"@office-open/docx": "0.11.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"@office-open/docx": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
39
|
+
"@office-open/core": "0.11.0",
|
|
40
|
+
"@office-open/docx": "0.11.0",
|
|
33
41
|
"@types/adm-zip": "0.5.7",
|
|
34
42
|
"@types/node": "20.11.0",
|
|
35
43
|
"@types/probe-image-size": "7.2.4",
|
package/dist/cache/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache Key Generator
|
|
3
|
-
* Generates deterministic cache keys for components
|
|
4
|
-
*/
|
|
5
|
-
import { ComponentDefinition, RenderContext } from '../types';
|
|
6
|
-
import { CacheKeyOptions } from '@json-to-office/shared/cache';
|
|
7
|
-
/**
|
|
8
|
-
* Cache key generator with deterministic hashing
|
|
9
|
-
*/
|
|
10
|
-
export declare class CacheKeyGenerator {
|
|
11
|
-
private readonly version;
|
|
12
|
-
constructor(version?: string);
|
|
13
|
-
/**
|
|
14
|
-
* Generate cache key for a component
|
|
15
|
-
*/
|
|
16
|
-
generateKey(component: ComponentDefinition, context: RenderContext, options?: CacheKeyOptions): string;
|
|
17
|
-
/**
|
|
18
|
-
* Hash component props
|
|
19
|
-
*/
|
|
20
|
-
hashProps(props: any): string;
|
|
21
|
-
/**
|
|
22
|
-
* Hash render context
|
|
23
|
-
*/
|
|
24
|
-
private hashContext;
|
|
25
|
-
/**
|
|
26
|
-
* Normalize object for consistent hashing
|
|
27
|
-
*/
|
|
28
|
-
private normalizeObject;
|
|
29
|
-
/**
|
|
30
|
-
* Create hash
|
|
31
|
-
*/
|
|
32
|
-
private hash;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=key-generator.d.ts.map
|