@cj-tech-master/excelts 9.6.1 → 10.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/README.md +18 -3
- package/README_zh.md +18 -3
- package/dist/browser/modules/excel/cell.d.ts +4 -0
- package/dist/browser/modules/excel/note.js +5 -1
- package/dist/browser/modules/excel/row.js +35 -2
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +8 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +22 -2
- package/dist/browser/modules/excel/types.d.ts +81 -0
- package/dist/browser/modules/excel/utils/drawing-utils.d.ts +8 -0
- package/dist/browser/modules/excel/utils/drawing-utils.js +19 -2
- package/dist/browser/modules/excel/workbook.browser.d.ts +16 -0
- package/dist/browser/modules/excel/workbook.browser.js +32 -2
- package/dist/browser/modules/excel/worksheet.d.ts +31 -1
- package/dist/browser/modules/excel/worksheet.js +83 -0
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-shape-xform.d.ts +7 -0
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-shape-xform.js +42 -8
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +3 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +5 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +18 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/blip-xform.d.ts +6 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/blip-xform.js +38 -11
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +5 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/pic-xform.d.ts +2 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/pic-xform.js +2 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/shape-xform.d.ts +47 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/shape-xform.js +109 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +10 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +64 -1
- package/dist/browser/modules/pdf/builder/document-builder.js +22 -49
- package/dist/browser/modules/pdf/builder/pdf-editor.js +1 -1
- package/dist/browser/modules/pdf/core/pdf-stream.d.ts +28 -1
- package/dist/browser/modules/pdf/core/pdf-stream.js +38 -2
- package/dist/browser/modules/pdf/font/font-manager.d.ts +26 -0
- package/dist/browser/modules/pdf/font/font-manager.js +35 -18
- package/dist/browser/modules/pdf/render/page-renderer.d.ts +51 -3
- package/dist/browser/modules/pdf/render/page-renderer.js +111 -18
- package/dist/browser/modules/word/advanced/field-engine.js +45 -20
- package/dist/browser/modules/word/advanced/glossary.d.ts +10 -36
- package/dist/browser/modules/word/advanced/glossary.js +8 -9
- package/dist/browser/modules/word/advanced/math-convert.js +94 -12
- package/dist/browser/modules/word/advanced/ole-objects.d.ts +28 -0
- package/dist/browser/modules/word/advanced/ole-objects.js +122 -19
- package/dist/browser/modules/word/advanced/style-map.js +31 -10
- package/dist/browser/modules/word/builder/run-builders.d.ts +7 -1
- package/dist/browser/modules/word/builder/run-builders.js +7 -1
- package/dist/browser/modules/word/constants.d.ts +4 -0
- package/dist/browser/modules/word/constants.js +5 -1
- package/dist/browser/modules/word/convert/docx-to-semantic.d.ts +2 -1
- package/dist/browser/modules/word/convert/docx-to-semantic.js +135 -1
- package/dist/browser/modules/word/convert/html/html-import.d.ts +32 -1
- package/dist/browser/modules/word/convert/html/html-import.js +167 -14
- package/dist/browser/modules/word/convert/html/html.d.ts +2 -2
- package/dist/browser/modules/word/convert/html/html.js +1 -1
- package/dist/browser/modules/word/convert/markdown/markdown-import.d.ts +48 -18
- package/dist/browser/modules/word/convert/markdown/markdown-import.js +279 -69
- package/dist/browser/modules/word/convert/markdown/markdown.d.ts +1 -1
- package/dist/browser/modules/word/convert/odt/odt.js +407 -56
- package/dist/browser/modules/word/html.d.ts +2 -2
- package/dist/browser/modules/word/html.js +1 -1
- package/dist/browser/modules/word/index.base.d.ts +3 -3
- package/dist/browser/modules/word/index.base.js +1 -1
- package/dist/browser/modules/word/layout/layout-full.js +326 -19
- package/dist/browser/modules/word/layout/render-page.js +35 -8
- package/dist/browser/modules/word/markdown.d.ts +1 -1
- package/dist/browser/modules/word/query/compat.d.ts +10 -2
- package/dist/browser/modules/word/query/compat.js +29 -21
- package/dist/browser/modules/word/reader/docx-reader.js +105 -2
- package/dist/browser/modules/word/reader/math-parser.js +8 -2
- package/dist/browser/modules/word/security/cfb-reader.js +5 -5
- package/dist/browser/modules/word/types.d.ts +96 -1
- package/dist/browser/modules/word/writer/docx-packager.js +108 -2
- package/dist/browser/modules/word/writer/glossary-writer.d.ts +28 -0
- package/dist/browser/modules/word/writer/glossary-writer.js +121 -0
- package/dist/browser/modules/word/writer/header-footer-writer.js +105 -20
- package/dist/browser/modules/word/writer/math-writer.js +7 -2
- package/dist/browser/utils/font-metrics.d.ts +8 -0
- package/dist/browser/utils/font-metrics.js +43 -0
- package/dist/browser/utils/theme-colors.js +4 -1
- package/dist/cjs/modules/excel/note.js +5 -1
- package/dist/cjs/modules/excel/row.js +35 -2
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +22 -2
- package/dist/cjs/modules/excel/utils/drawing-utils.js +19 -2
- package/dist/cjs/modules/excel/workbook.browser.js +31 -1
- package/dist/cjs/modules/excel/worksheet.js +83 -0
- package/dist/cjs/modules/excel/xlsx/xform/comment/vml-shape-xform.js +42 -8
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +3 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +5 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +18 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/blip-xform.js +38 -11
- package/dist/cjs/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +5 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/pic-xform.js +2 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/shape-xform.js +112 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +10 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +64 -1
- package/dist/cjs/modules/pdf/builder/document-builder.js +21 -48
- package/dist/cjs/modules/pdf/builder/pdf-editor.js +1 -1
- package/dist/cjs/modules/pdf/core/pdf-stream.js +38 -2
- package/dist/cjs/modules/pdf/font/font-manager.js +35 -18
- package/dist/cjs/modules/pdf/render/page-renderer.js +112 -18
- package/dist/cjs/modules/word/advanced/field-engine.js +45 -20
- package/dist/cjs/modules/word/advanced/glossary.js +8 -9
- package/dist/cjs/modules/word/advanced/math-convert.js +94 -12
- package/dist/cjs/modules/word/advanced/ole-objects.js +123 -19
- package/dist/cjs/modules/word/advanced/style-map.js +31 -10
- package/dist/cjs/modules/word/builder/run-builders.js +7 -1
- package/dist/cjs/modules/word/constants.js +5 -1
- package/dist/cjs/modules/word/convert/docx-to-semantic.js +135 -1
- package/dist/cjs/modules/word/convert/html/html-import.js +168 -14
- package/dist/cjs/modules/word/convert/html/html.js +2 -1
- package/dist/cjs/modules/word/convert/markdown/markdown-import.js +279 -69
- package/dist/cjs/modules/word/convert/odt/odt.js +407 -56
- package/dist/cjs/modules/word/html.js +2 -1
- package/dist/cjs/modules/word/index.base.js +4 -3
- package/dist/cjs/modules/word/layout/layout-full.js +325 -18
- package/dist/cjs/modules/word/layout/render-page.js +35 -8
- package/dist/cjs/modules/word/query/compat.js +29 -21
- package/dist/cjs/modules/word/reader/docx-reader.js +104 -1
- package/dist/cjs/modules/word/reader/math-parser.js +8 -2
- package/dist/cjs/modules/word/security/cfb-reader.js +5 -5
- package/dist/cjs/modules/word/writer/docx-packager.js +108 -2
- package/dist/cjs/modules/word/writer/glossary-writer.js +124 -0
- package/dist/cjs/modules/word/writer/header-footer-writer.js +105 -20
- package/dist/cjs/modules/word/writer/math-writer.js +7 -2
- package/dist/cjs/utils/font-metrics.js +44 -0
- package/dist/cjs/utils/theme-colors.js +4 -1
- package/dist/esm/modules/excel/note.js +5 -1
- package/dist/esm/modules/excel/row.js +35 -2
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +22 -2
- package/dist/esm/modules/excel/utils/drawing-utils.js +19 -2
- package/dist/esm/modules/excel/workbook.browser.js +32 -2
- package/dist/esm/modules/excel/worksheet.js +83 -0
- package/dist/esm/modules/excel/xlsx/xform/comment/vml-shape-xform.js +42 -8
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +3 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +5 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +18 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/blip-xform.js +38 -11
- package/dist/esm/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +5 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/pic-xform.js +2 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/shape-xform.js +109 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +10 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +64 -1
- package/dist/esm/modules/pdf/builder/document-builder.js +22 -49
- package/dist/esm/modules/pdf/builder/pdf-editor.js +1 -1
- package/dist/esm/modules/pdf/core/pdf-stream.js +38 -2
- package/dist/esm/modules/pdf/font/font-manager.js +35 -18
- package/dist/esm/modules/pdf/render/page-renderer.js +111 -18
- package/dist/esm/modules/word/advanced/field-engine.js +45 -20
- package/dist/esm/modules/word/advanced/glossary.js +8 -9
- package/dist/esm/modules/word/advanced/math-convert.js +94 -12
- package/dist/esm/modules/word/advanced/ole-objects.js +122 -19
- package/dist/esm/modules/word/advanced/style-map.js +31 -10
- package/dist/esm/modules/word/builder/run-builders.js +7 -1
- package/dist/esm/modules/word/constants.js +5 -1
- package/dist/esm/modules/word/convert/docx-to-semantic.js +135 -1
- package/dist/esm/modules/word/convert/html/html-import.js +167 -14
- package/dist/esm/modules/word/convert/html/html.js +1 -1
- package/dist/esm/modules/word/convert/markdown/markdown-import.js +279 -69
- package/dist/esm/modules/word/convert/odt/odt.js +407 -56
- package/dist/esm/modules/word/html.js +1 -1
- package/dist/esm/modules/word/index.base.js +1 -1
- package/dist/esm/modules/word/layout/layout-full.js +326 -19
- package/dist/esm/modules/word/layout/render-page.js +35 -8
- package/dist/esm/modules/word/query/compat.js +29 -21
- package/dist/esm/modules/word/reader/docx-reader.js +105 -2
- package/dist/esm/modules/word/reader/math-parser.js +8 -2
- package/dist/esm/modules/word/security/cfb-reader.js +5 -5
- package/dist/esm/modules/word/writer/docx-packager.js +108 -2
- package/dist/esm/modules/word/writer/glossary-writer.js +121 -0
- package/dist/esm/modules/word/writer/header-footer-writer.js +105 -20
- package/dist/esm/modules/word/writer/math-writer.js +7 -2
- package/dist/esm/utils/font-metrics.js +43 -0
- package/dist/esm/utils/theme-colors.js +4 -1
- package/dist/iife/excelts.iife.js +496 -59
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +39 -39
- package/dist/types/modules/excel/cell.d.ts +4 -0
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +8 -1
- package/dist/types/modules/excel/types.d.ts +81 -0
- package/dist/types/modules/excel/utils/drawing-utils.d.ts +8 -0
- package/dist/types/modules/excel/workbook.browser.d.ts +16 -0
- package/dist/types/modules/excel/worksheet.d.ts +31 -1
- package/dist/types/modules/excel/xlsx/xform/comment/vml-shape-xform.d.ts +7 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/blip-xform.d.ts +6 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/pic-xform.d.ts +2 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/shape-xform.d.ts +47 -0
- package/dist/types/modules/pdf/core/pdf-stream.d.ts +28 -1
- package/dist/types/modules/pdf/font/font-manager.d.ts +26 -0
- package/dist/types/modules/pdf/render/page-renderer.d.ts +51 -3
- package/dist/types/modules/word/advanced/glossary.d.ts +10 -36
- package/dist/types/modules/word/advanced/ole-objects.d.ts +28 -0
- package/dist/types/modules/word/builder/run-builders.d.ts +7 -1
- package/dist/types/modules/word/constants.d.ts +4 -0
- package/dist/types/modules/word/convert/docx-to-semantic.d.ts +2 -1
- package/dist/types/modules/word/convert/html/html-import.d.ts +32 -1
- package/dist/types/modules/word/convert/html/html.d.ts +2 -2
- package/dist/types/modules/word/convert/markdown/markdown-import.d.ts +48 -18
- package/dist/types/modules/word/convert/markdown/markdown.d.ts +1 -1
- package/dist/types/modules/word/html.d.ts +2 -2
- package/dist/types/modules/word/index.base.d.ts +3 -3
- package/dist/types/modules/word/markdown.d.ts +1 -1
- package/dist/types/modules/word/query/compat.d.ts +10 -2
- package/dist/types/modules/word/types.d.ts +96 -1
- package/dist/types/modules/word/writer/glossary-writer.d.ts +28 -0
- package/dist/types/utils/font-metrics.d.ts +8 -0
- package/package.json +3 -1
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* const buffer = await toBuffer(Document.build(h));
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
import type { BodyContent } from "../../types.js";
|
|
23
|
+
import type { BodyContent, ImageDef } from "../../types.js";
|
|
24
24
|
/** Options for HTML to DOCX conversion. */
|
|
25
25
|
export interface HtmlImportOptions {
|
|
26
26
|
/** Default font size in half-points (default: 24 = 12pt). */
|
|
@@ -48,3 +48,34 @@ export interface HtmlImportOptions {
|
|
|
48
48
|
* @returns Array of BodyContent blocks.
|
|
49
49
|
*/
|
|
50
50
|
export declare function htmlToDocxBody(html: string, options?: HtmlImportOptions): BodyContent[];
|
|
51
|
+
/** Result of {@link htmlToDocx}: body content plus the images it references. */
|
|
52
|
+
export interface HtmlToDocxResult {
|
|
53
|
+
/** Parsed body content blocks. */
|
|
54
|
+
readonly body: BodyContent[];
|
|
55
|
+
/**
|
|
56
|
+
* Images decoded from base64 `data:` URLs in the HTML, each with a unique
|
|
57
|
+
* rId already referenced by the matching image run in `body`. Merge these
|
|
58
|
+
* into the document model's `images` array so the pictures are embedded as
|
|
59
|
+
* real media in the package instead of dropped as placeholders.
|
|
60
|
+
*/
|
|
61
|
+
readonly images: ImageDef[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Convert an HTML string into DOCX body content **and** embedded images.
|
|
65
|
+
*
|
|
66
|
+
* Unlike {@link htmlToDocxBody}, this decodes base64 `data:` image URLs into
|
|
67
|
+
* real {@link ImageDef}s and assigns each a unique rId that the emitted image
|
|
68
|
+
* runs reference. Merge the returned `images` into your document model so the
|
|
69
|
+
* pictures are embedded rather than dropped as placeholders.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const { body, images } = htmlToDocx(html);
|
|
74
|
+
* const doc = Document.create();
|
|
75
|
+
* for (const item of body) Document.addContent(doc, item);
|
|
76
|
+
* const built = Document.build(doc);
|
|
77
|
+
* const final = { ...built, images: [...(built.images ?? []), ...images] };
|
|
78
|
+
* const bytes = await toBuffer(final);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function htmlToDocx(html: string, options?: HtmlImportOptions): HtmlToDocxResult;
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export { renderToHtml } from "./html-renderer.js";
|
|
13
13
|
export type { HtmlRenderOptions, HtmlRenderResult } from "./html-renderer.js";
|
|
14
|
-
export { htmlToDocxBody } from "./html-import.js";
|
|
15
|
-
export type { HtmlImportOptions } from "./html-import.js";
|
|
14
|
+
export { htmlToDocxBody, htmlToDocx } from "./html-import.js";
|
|
15
|
+
export type { HtmlImportOptions, HtmlToDocxResult } from "./html-import.js";
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @stability experimental
|
|
18
18
|
*/
|
|
19
|
-
import type { BodyContent, DocxDocument } from "../../types.js";
|
|
19
|
+
import type { AbstractNumbering, BodyContent, DocxDocument, FootnoteDef, ImageDef, ImageMediaType, NumberingInstance } from "../../types.js";
|
|
20
20
|
/** Options for Markdown to DOCX conversion. */
|
|
21
21
|
export interface MarkdownImportOptions {
|
|
22
22
|
/** Default font family for body text. */
|
|
@@ -33,36 +33,66 @@ export interface MarkdownImportOptions {
|
|
|
33
33
|
/** Resolved image data for embedding. */
|
|
34
34
|
export interface MarkdownImageData {
|
|
35
35
|
readonly data: Uint8Array;
|
|
36
|
-
readonly mediaType:
|
|
36
|
+
readonly mediaType: ImageMediaType;
|
|
37
37
|
readonly width?: number;
|
|
38
38
|
readonly height?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Raster (PNG) fallback for vector images. Required by Word for `svg`
|
|
41
|
+
* images so non-SVG-aware viewers have something to display. When the
|
|
42
|
+
* media type is `svg` and this is omitted, the packager synthesizes a
|
|
43
|
+
* transparent placeholder PNG automatically.
|
|
44
|
+
*/
|
|
45
|
+
readonly fallbackData?: Uint8Array;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Result of {@link markdownToDocxBody} — the parsed body content plus the
|
|
49
|
+
* supporting document-level definitions it references.
|
|
50
|
+
*
|
|
51
|
+
* Lists, footnotes and images are *not* self-contained: a list paragraph
|
|
52
|
+
* references a numbering id, a footnote reference run references a
|
|
53
|
+
* `FootnoteDef`, and an inline image references an `ImageDef`. Splicing the
|
|
54
|
+
* `body` alone into a host document that lacks these definitions yields
|
|
55
|
+
* invalid OOXML. Merge the relevant arrays into the host document (or its
|
|
56
|
+
* builder state) alongside the body.
|
|
57
|
+
*/
|
|
58
|
+
export interface MarkdownBodyResult {
|
|
59
|
+
readonly body: BodyContent[];
|
|
60
|
+
readonly abstractNumberings: AbstractNumbering[];
|
|
61
|
+
readonly numberingInstances: NumberingInstance[];
|
|
62
|
+
readonly footnotes: FootnoteDef[];
|
|
63
|
+
readonly images: ImageDef[];
|
|
39
64
|
}
|
|
40
65
|
/**
|
|
41
66
|
* Convert a Markdown string into a complete DocxDocument.
|
|
42
67
|
*
|
|
68
|
+
* Supports the full GFM feature set including inline images (embedded via the
|
|
69
|
+
* `resolveImage` callback) and footnotes (`[^id]` references with `[^id]: …`
|
|
70
|
+
* definitions). Because image resolution and document packaging are inherently
|
|
71
|
+
* asynchronous, this function is async.
|
|
72
|
+
*
|
|
43
73
|
* @param markdown - The GFM Markdown string.
|
|
44
74
|
* @param options - Optional conversion settings.
|
|
45
|
-
* @returns A DocxDocument ready to be packaged.
|
|
75
|
+
* @returns A Promise resolving to a DocxDocument ready to be packaged.
|
|
46
76
|
*/
|
|
47
|
-
export declare function markdownToDocx(markdown: string, options?: MarkdownImportOptions): DocxDocument
|
|
77
|
+
export declare function markdownToDocx(markdown: string, options?: MarkdownImportOptions): Promise<DocxDocument>;
|
|
48
78
|
/**
|
|
49
|
-
* Convert a Markdown string into
|
|
79
|
+
* Convert a Markdown string into DOCX body content plus the supporting
|
|
80
|
+
* document-level definitions it references.
|
|
50
81
|
*
|
|
51
|
-
* **Caveat — body content is not self-contained.**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* - **
|
|
56
|
-
* - **
|
|
82
|
+
* **Caveat — body content is not self-contained.** The returned `body` may
|
|
83
|
+
* reference:
|
|
84
|
+
* - **Numbering** (`abstractNumberings` / `numberingInstances`) — used by
|
|
85
|
+
* bullet / numbered / task lists.
|
|
86
|
+
* - **Footnotes** (`footnotes`) — referenced by footnote-reference runs.
|
|
87
|
+
* - **Images** (`images`) — referenced by inline image runs.
|
|
88
|
+
* - The named `Quote` / `CodeBlock` styles (for block quotes / code blocks).
|
|
57
89
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* splicing, or use the higher-level {@link markdownToDocx} which returns a
|
|
62
|
-
* complete `DocxDocument` with the supporting definitions populated.
|
|
90
|
+
* Splice the relevant arrays into your host document alongside the body, or
|
|
91
|
+
* use the higher-level {@link markdownToDocx} which returns a complete
|
|
92
|
+
* `DocxDocument` with everything populated.
|
|
63
93
|
*
|
|
64
94
|
* @param markdown - The GFM Markdown string.
|
|
65
95
|
* @param options - Optional conversion settings.
|
|
66
|
-
* @returns
|
|
96
|
+
* @returns A Promise resolving to the body and its supporting definitions.
|
|
67
97
|
*/
|
|
68
|
-
export declare function markdownToDocxBody(markdown: string, options?: MarkdownImportOptions):
|
|
98
|
+
export declare function markdownToDocxBody(markdown: string, options?: MarkdownImportOptions): Promise<MarkdownBodyResult>;
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
export { renderToMarkdown } from "./markdown-renderer.js";
|
|
13
13
|
export type { MarkdownRenderOptions } from "./markdown-renderer.js";
|
|
14
14
|
export { markdownToDocx, markdownToDocxBody } from "./markdown-import.js";
|
|
15
|
-
export type { MarkdownImportOptions, MarkdownImageData } from "./markdown-import.js";
|
|
15
|
+
export type { MarkdownImportOptions, MarkdownImageData, MarkdownBodyResult } from "./markdown-import.js";
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* import { renderToHtml, htmlToDocxBody } from "excelts/word/html";
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export { renderToHtml, htmlToDocxBody } from "./convert/html/html.js";
|
|
14
|
-
export type { HtmlRenderOptions, HtmlRenderResult, HtmlImportOptions } from "./convert/html/html.js";
|
|
13
|
+
export { renderToHtml, htmlToDocxBody, htmlToDocx } from "./convert/html/html.js";
|
|
14
|
+
export type { HtmlRenderOptions, HtmlRenderResult, HtmlImportOptions, HtmlToDocxResult } from "./convert/html/html.js";
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/** @stability stable */
|
|
23
23
|
export type { HalfPoint, Twips, Emu, EighthPoint, HexColor, ShadingType, BorderStyle, PageOrientation, PageSize, PageMargins, ColumnDef, SectionColumns, SectionBreakType, PageNumberFormat, HeaderFooterType, HeaderFooterRef, PageVerticalAlign, DocumentGridType, Border, ArtBorderType, PageBorders, SectionProperties, UnderlineStyle, VerticalAlign, HighlightColor, FontSpec, Shading, UnderlineSpec, TextEffect, EmphasisMarkType, EastAsianCombineBrackets, EastAsianLayoutSpec, ColorSpec, RunProperties, RunContent, TextContent, BreakContent, TabContent, PositionalTabContent, RubyContent, RubyAlign, RubyProperties, SymbolContent, FootnoteRefContent, EndnoteRefContent, FieldContent, InlineImageContent, CarriageReturnContent, NoBreakHyphenContent, SoftHyphenContent, LastRenderedPageBreakContent, AnnotationReferenceContent, PageNumberType, DateFieldContent, Run, RevisionInfo, InsertedRun, DeletedRun, MovedFromRun, MovedToRun, MoveRangeMarker, CustomXmlTrackingMarker, ParagraphPropertyChange, RunPropertyChange, SectionPropertyChange, TableRowRevision, CommentDef, CommentRangeStart, CommentRangeEnd, CommentReference, Alignment, LineSpacingRule, LineSpacing, Indentation, TabStopType, TabStopLeader, TabStop, PositionalTabAlignment, PositionalTabRelativeTo, PositionalTabLeader, ParagraphBorders, NumberingRef, FrameAnchorType, DropCapType, ParagraphFrame, ParagraphProperties, Paragraph, Hyperlink, BookmarkStart, BookmarkEnd, ParagraphChild, TableWidth, TableBorders, TableCellMargins, TableLayout, TableLook, TableFloat, TableProperties, RowHeightRule, TableRowProperties, VerticalCellAlign, TextDirection, VerticalMerge, TableCellProperties, TableCell, TableRow, Table, HorizontalPositionRelative, VerticalPositionRelative, WrapStyle, WrapTextSide, WrapMargins, FloatingImage, DrawingShape, PresetShapeType, Chart, ChartType, ChartSeries, ChartLegendPosition, ChartAxis, ChartContent, ChartExContent, ChartExData, ChartExSeriesData, ChartTrendline, ChartTrendlineType, ChartErrorBars, ChartErrorBarDirection, ChartErrorBarType, ChartDataLabels, ChartDataLabelPosition, AltChunk, WebSettings, PersonInfo, NoteType, FootnoteProperties, EndnoteProperties, NoteNumberFormat, NoteNumberRestart, TablePropertyChange, TableRowPropertyChange, TableCellPropertyChange, CellMergeRevision, DocxDocumentType, TableOfContents, MathRun, MathFraction, MathSuperScript, MathSubScript, MathSubSuperScript, MathPreSubSuperScript, MathPhantom, MathGroupChar, MathBorderBox, MathRadical, MathDelimiter, MathNary, MathFunction, MathLimit, MathMatrix, MathAccent, MathBar, MathBox, MathEquationArray, MathContent, MathBlock, TextBox, CheckBox, SdtListItem, SdtDateProperties, SdtProperties, SdtDataBinding, SdtCheckboxProperties, SdtRepeatingSectionProperties, StructuredDocumentTag, CustomXmlPart, FormFieldType, FormField, TextFormField, CheckBoxFormField, DropDownFormField, Watermark, TextWatermark, ImageWatermark, BodyContent, StyleType, TableStyleConditionType, TableStyleConditionalFormat, StyleDef, DocDefaults, NumberFormat, LevelJustification, LevelSuffix, NumberingLevel, MultiLevelType, AbstractNumbering, LevelOverride, NumberingInstance, NumPicBullet, HeaderFooterContent, HeaderDef, FooterDef, FootnoteDef, EndnoteDef, ImageMediaType, ImageDef, FontFamily, FontPitch, FontDef, EmbeddedFont, ProtectionType, HyphenationSettings, DocumentSettings, CompatSetting, CompatFlag, DocumentBackground, DocumentTheme, ThemeColorScheme, ThemeFontScheme, ThemeFont, ThemeFormatScheme, ThemeColorName, CustomPropertyValue, CustomProperty, CoreProperties, AppProperties, DocxDocument, DocxOptions } from "./types.js";
|
|
24
24
|
/** @stability preserve-only */
|
|
25
|
-
export type { OpaquePart, OpaqueRelationship, OpaqueDrawing, OpaqueRunContent, OpaqueParagraphChild } from "./types.js";
|
|
25
|
+
export type { OpaquePart, OpaqueRelationship, OpaqueDrawing, OpaqueRunContent, OpaqueParagraphChild, OleObjectPart } from "./types.js";
|
|
26
26
|
/** @stability stable */
|
|
27
27
|
export { DocxError, DocxParseError, DocxWriteError, DocxMissingPartError, DocxInvalidStructureError, DocxUnsupportedFeatureError, DocxEncryptedError, DocxDecryptionError, DocxLimitExceededError, isDocxError } from "./errors.js";
|
|
28
28
|
/** @stability stable */
|
|
@@ -110,9 +110,9 @@ export { embedFont, embedFontFamily, addEmbeddedFonts, subsetFont } from "./font
|
|
|
110
110
|
/** @stability stable */
|
|
111
111
|
export type { FontEmbedStyle, EmbedFontOptions, EmbedFontResult } from "./font/font-embed.js";
|
|
112
112
|
/** @stability experimental */
|
|
113
|
-
export { extractOleObjects, hasOleObjects, getOleObjectData, createOleEmbedding } from "./advanced/ole-objects.js";
|
|
113
|
+
export { extractOleObjects, hasOleObjects, getOleObjectData, createOleEmbedding, addOleObject } from "./advanced/ole-objects.js";
|
|
114
114
|
/** @stability experimental */
|
|
115
|
-
export type { OleObject, OleObjectType, OleDisplayAs, OleExtractionResult } from "./advanced/ole-objects.js";
|
|
115
|
+
export type { OleObject, OleObjectType, OleDisplayAs, OleExtractionResult, OleEmbeddingResult } from "./advanced/ole-objects.js";
|
|
116
116
|
/** @stability experimental */
|
|
117
117
|
export { createBuildingBlock, createGlossaryDocument, findBuildingBlock, listBuildingBlocks, getAutoTextEntries, getQuickParts } from "./advanced/glossary.js";
|
|
118
118
|
/** @stability experimental */
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
13
|
export { renderToMarkdown, markdownToDocx, markdownToDocxBody } from "./convert/markdown/markdown.js";
|
|
14
|
-
export type { MarkdownRenderOptions, MarkdownImportOptions, MarkdownImageData } from "./convert/markdown/markdown.js";
|
|
14
|
+
export type { MarkdownRenderOptions, MarkdownImportOptions, MarkdownImageData, MarkdownBodyResult } from "./convert/markdown/markdown.js";
|
|
@@ -9,8 +9,12 @@ export type CompatibilityMode = 11 | 12 | 14 | 15;
|
|
|
9
9
|
/**
|
|
10
10
|
* Get the compatibility mode of a document.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* The mode is stored in `settings.compatibilityMode` (the canonical scalar
|
|
13
|
+
* field populated by the reader). For backward compatibility we also honour an
|
|
14
|
+
* explicit `compatibilityMode` entry in `settings.compatSettings` if present,
|
|
15
|
+
* since the writer accepts that advanced-override path.
|
|
16
|
+
*
|
|
17
|
+
* Returns 15 (Word 2013+) by default if nothing is stored.
|
|
14
18
|
*
|
|
15
19
|
* @param doc - The document to inspect.
|
|
16
20
|
* @returns The compatibility mode version number.
|
|
@@ -19,6 +23,10 @@ export declare function getCompatibilityMode(doc: DocxDocument): CompatibilityMo
|
|
|
19
23
|
/**
|
|
20
24
|
* Set the compatibility mode of a document (mutates settings in place).
|
|
21
25
|
*
|
|
26
|
+
* Writes the canonical `settings.compatibilityMode` scalar field and removes
|
|
27
|
+
* any stale `compatibilityMode` override entry from `settings.compatSettings`
|
|
28
|
+
* so the two sources never disagree.
|
|
29
|
+
*
|
|
22
30
|
* @param doc - The document to modify (mutated in place).
|
|
23
31
|
* @param mode - The target compatibility mode (11=Word 2003, 12=Word 2007, 14=Word 2010, 15=Word 2013+).
|
|
24
32
|
*/
|
|
@@ -1283,7 +1283,13 @@ export interface MathPreSubSuperScript {
|
|
|
1283
1283
|
export interface MathPhantom {
|
|
1284
1284
|
readonly type: "mathPhantom";
|
|
1285
1285
|
readonly content: readonly MathContent[];
|
|
1286
|
-
/**
|
|
1286
|
+
/**
|
|
1287
|
+
* Whether the phantom's base content is drawn. In OOXML `m:show` defaults to
|
|
1288
|
+
* ON, so the base stays visible unless this is explicitly set to `false`
|
|
1289
|
+
* (serialized as `<m:show m:val="0"/>`). Set `false` for the classic
|
|
1290
|
+
* "occupies space but invisible" phantom; leave undefined to keep the
|
|
1291
|
+
* default (visible) behaviour.
|
|
1292
|
+
*/
|
|
1287
1293
|
readonly show?: boolean;
|
|
1288
1294
|
/** Zero width (default: false). */
|
|
1289
1295
|
readonly zeroWidth?: boolean;
|
|
@@ -1714,6 +1720,10 @@ export interface ImageWatermark {
|
|
|
1714
1720
|
readonly scale?: number;
|
|
1715
1721
|
/** Washout effect. */
|
|
1716
1722
|
readonly washout?: boolean;
|
|
1723
|
+
/** Display width in points. Defaults to 415.2pt (full body width). */
|
|
1724
|
+
readonly widthPt?: number;
|
|
1725
|
+
/** Display height in points. Defaults to 415.2pt scaled to image ratio, or 233.5pt. */
|
|
1726
|
+
readonly heightPt?: number;
|
|
1717
1727
|
}
|
|
1718
1728
|
/** Watermark (text or image). */
|
|
1719
1729
|
export type Watermark = TextWatermark | ImageWatermark;
|
|
@@ -2403,6 +2413,39 @@ export interface PersonInfo {
|
|
|
2403
2413
|
* - "macroEnabledTemplate" — .dotm (macro-enabled template)
|
|
2404
2414
|
*/
|
|
2405
2415
|
export type DocxDocumentType = "document" | "template" | "macroEnabledDocument" | "macroEnabledTemplate";
|
|
2416
|
+
/** Building block gallery category. */
|
|
2417
|
+
export type BuildingBlockGallery = "autoText" | "quickParts" | "coverPages" | "tableOfContents" | "headers" | "footers" | "pageNumbers" | "tables" | "textBoxes" | "watermarks" | "equations" | "bibliographies" | "custom1" | "custom2" | "custom3" | "custom4" | "custom5";
|
|
2418
|
+
/** A single building block (AutoText/Quick Part) entry. */
|
|
2419
|
+
export interface BuildingBlock {
|
|
2420
|
+
/** Name of the building block (displayed in gallery). */
|
|
2421
|
+
readonly name: string;
|
|
2422
|
+
/** Gallery this block belongs to. */
|
|
2423
|
+
readonly gallery: BuildingBlockGallery;
|
|
2424
|
+
/** Category within the gallery. */
|
|
2425
|
+
readonly category?: string;
|
|
2426
|
+
/** Description/tooltip. */
|
|
2427
|
+
readonly description?: string;
|
|
2428
|
+
/** The content of the building block. */
|
|
2429
|
+
readonly content: readonly BodyContent[];
|
|
2430
|
+
/** Section properties specific to this building block. */
|
|
2431
|
+
readonly sectionProperties?: SectionProperties;
|
|
2432
|
+
/** Unique identifier (GUID). */
|
|
2433
|
+
readonly guid?: string;
|
|
2434
|
+
}
|
|
2435
|
+
/** The glossary document model. */
|
|
2436
|
+
export interface GlossaryDocument {
|
|
2437
|
+
/** Building block entries. */
|
|
2438
|
+
readonly blocks: readonly BuildingBlock[];
|
|
2439
|
+
/** Raw parts preserved for round-trip (style, settings, fontTable). */
|
|
2440
|
+
readonly rawParts?: ReadonlyMap<string, Uint8Array>;
|
|
2441
|
+
/**
|
|
2442
|
+
* Verbatim `word/glossary/document.xml` markup. Populated by the reader so a
|
|
2443
|
+
* read→write round-trip preserves the glossary byte-faithfully even though
|
|
2444
|
+
* the structured `blocks` are not reverse-parsed. When present the writer
|
|
2445
|
+
* emits this verbatim and ignores `blocks`.
|
|
2446
|
+
*/
|
|
2447
|
+
readonly rawXml?: string;
|
|
2448
|
+
}
|
|
2406
2449
|
export interface DocxDocument {
|
|
2407
2450
|
/**
|
|
2408
2451
|
* Document type. Determines the content type used in the package.
|
|
@@ -2468,6 +2511,24 @@ export interface DocxDocument {
|
|
|
2468
2511
|
readonly opaqueParts?: readonly OpaquePart[];
|
|
2469
2512
|
/** VBA project binary (word/vbaProject.bin) for .docm/.dotm round-trip. */
|
|
2470
2513
|
readonly vbaProject?: Uint8Array;
|
|
2514
|
+
/**
|
|
2515
|
+
* OLE embedded objects wired into the document. Unlike a bare
|
|
2516
|
+
* {@link OpaquePart}, each entry here is registered by the packager as a
|
|
2517
|
+
* relationship on `word/_rels/document.xml.rels` (so the `r:id` used by the
|
|
2518
|
+
* body `<w:object>`/`<o:OLEObject>` markup actually resolves) and gets a
|
|
2519
|
+
* `[Content_Types].xml` override. The body still references the object via
|
|
2520
|
+
* an {@link OpaqueDrawing} carrying the matching `r:id`. Mirrors the
|
|
2521
|
+
* `vbaProject` model-field pattern.
|
|
2522
|
+
*/
|
|
2523
|
+
readonly oleObjects?: readonly OleObjectPart[];
|
|
2524
|
+
/**
|
|
2525
|
+
* Glossary document (Building Blocks / AutoText / Quick Parts). When set,
|
|
2526
|
+
* the packager serialises it to `word/glossary/document.xml`, registers the
|
|
2527
|
+
* `glossaryDocument` relationship on `document.xml.rels`, and adds the
|
|
2528
|
+
* `[Content_Types].xml` override — the canonical OOXML location Word reads
|
|
2529
|
+
* Quick Parts from.
|
|
2530
|
+
*/
|
|
2531
|
+
readonly glossary?: GlossaryDocument;
|
|
2471
2532
|
}
|
|
2472
2533
|
/** A relationship entry preserved for round-trip. */
|
|
2473
2534
|
export interface OpaqueRelationship {
|
|
@@ -2508,6 +2569,40 @@ export interface OpaquePart {
|
|
|
2508
2569
|
/** Relationships of this part (from its .rels file). */
|
|
2509
2570
|
readonly relationships?: readonly OpaqueRelationship[];
|
|
2510
2571
|
}
|
|
2572
|
+
/**
|
|
2573
|
+
* An OLE embedded object that the packager wires into the main document.
|
|
2574
|
+
*
|
|
2575
|
+
* The binary is written at {@link path}, a relationship with the exact
|
|
2576
|
+
* {@link rId} is registered on `word/_rels/document.xml.rels` (so body
|
|
2577
|
+
* `<w:object r:id="…">` markup resolves), and a `[Content_Types].xml`
|
|
2578
|
+
* override is added. An optional preview image is wired the same way.
|
|
2579
|
+
*/
|
|
2580
|
+
export interface OleObjectPart {
|
|
2581
|
+
/** Part path of the OLE binary (e.g. "word/embeddings/oleObject1.bin"). */
|
|
2582
|
+
readonly path: string;
|
|
2583
|
+
/** Raw OLE binary data (ideally an OLE2 compound document). */
|
|
2584
|
+
readonly data: Uint8Array;
|
|
2585
|
+
/**
|
|
2586
|
+
* Relationship ID referenced from the body markup. Registered verbatim on
|
|
2587
|
+
* the document relationships so the reference always resolves.
|
|
2588
|
+
*/
|
|
2589
|
+
readonly rId: string;
|
|
2590
|
+
/** OLE ProgId (e.g. "Excel.Sheet.12", "Package"). Carried for round-trip. */
|
|
2591
|
+
readonly progId?: string;
|
|
2592
|
+
/**
|
|
2593
|
+
* Content type for the binary. Defaults to
|
|
2594
|
+
* `application/vnd.openxmlformats-officedocument.oleObject`.
|
|
2595
|
+
*/
|
|
2596
|
+
readonly contentType?: string;
|
|
2597
|
+
/** Optional preview image part path (e.g. "word/media/oleImage1.png"). */
|
|
2598
|
+
readonly previewPath?: string;
|
|
2599
|
+
/** Preview image bytes (when {@link previewPath} is set). */
|
|
2600
|
+
readonly previewData?: Uint8Array;
|
|
2601
|
+
/** Relationship ID for the preview image, registered on the document. */
|
|
2602
|
+
readonly previewRId?: string;
|
|
2603
|
+
/** Content type for the preview image (e.g. "image/png"). */
|
|
2604
|
+
readonly previewContentType?: string;
|
|
2605
|
+
}
|
|
2511
2606
|
/** An opaque drawing element (e.g. chart) preserved in a paragraph. */
|
|
2512
2607
|
export interface OpaqueDrawing {
|
|
2513
2608
|
readonly type: "opaqueDrawing";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOCX Module — Glossary (Building Blocks) Part Writer
|
|
3
|
+
*
|
|
4
|
+
* Serialises a {@link GlossaryDocument} into the canonical
|
|
5
|
+
* `word/glossary/document.xml` OOXML form:
|
|
6
|
+
*
|
|
7
|
+
* ```xml
|
|
8
|
+
* <w:glossaryDocument>
|
|
9
|
+
* <w:docParts>
|
|
10
|
+
* <w:docPart>
|
|
11
|
+
* <w:docPartPr>
|
|
12
|
+
* <w:name w:val="…"/>
|
|
13
|
+
* <w:category><w:name w:val="…"/><w:gallery w:val="…"/></w:category>
|
|
14
|
+
* <w:behaviors><w:behavior w:val="content"/></w:behaviors>
|
|
15
|
+
* <w:guid w:val="{…}"/>
|
|
16
|
+
* </w:docPartPr>
|
|
17
|
+
* <w:docPartBody>… body content …</w:docPartBody>
|
|
18
|
+
* </w:docPart>
|
|
19
|
+
* </w:docParts>
|
|
20
|
+
* </w:glossaryDocument>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Lives in the writer layer (not `advanced/`) so the packager can depend on
|
|
24
|
+
* it without creating a `advanced/ → writer/` import cycle.
|
|
25
|
+
*/
|
|
26
|
+
import type { GlossaryDocument } from "../types.js";
|
|
27
|
+
/** Render a {@link GlossaryDocument} to a `word/glossary/document.xml` string. */
|
|
28
|
+
export declare function renderGlossaryDocument(glossary: GlossaryDocument): string;
|
|
@@ -61,3 +61,11 @@ export declare function getStandardFontNames(): string[];
|
|
|
61
61
|
* Falls back to "Helvetica" for unknown fonts.
|
|
62
62
|
*/
|
|
63
63
|
export declare function mapToStandardFont(fontName: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Given a standard PDF base font and bold/italic flags, return the matching
|
|
66
|
+
* metric variant name (e.g. "Helvetica" + bold → "Helvetica-Bold"). This keeps
|
|
67
|
+
* width measurement consistent with the glyphs that are actually drawn, so
|
|
68
|
+
* bold/italic runs are measured with their true (wider) metrics rather than
|
|
69
|
+
* the regular ones. Falls back to the base name when a variant is unknown.
|
|
70
|
+
*/
|
|
71
|
+
export declare function styledFontVariant(baseFont: string, bold?: boolean, italic?: boolean): string;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cj-tech-master/excelts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Zero-dependency TypeScript toolkit — Excel (XLSX), PDF, CSV, Markdown, XML, ZIP/TAR, and streaming.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"archive",
|
|
7
7
|
"browser",
|
|
8
8
|
"bun",
|
|
9
9
|
"csv",
|
|
10
|
+
"docx",
|
|
10
11
|
"excel",
|
|
11
12
|
"formula",
|
|
12
13
|
"markdown",
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
"tar",
|
|
17
18
|
"toolkit",
|
|
18
19
|
"typescript",
|
|
20
|
+
"word",
|
|
19
21
|
"workbook",
|
|
20
22
|
"xlsx",
|
|
21
23
|
"xml",
|