@docen/docx 0.3.2 → 0.3.3
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/converters/docx.d.mts +25 -4
- package/dist/converters/docx.mjs +96 -17
- package/dist/converters/html.d.mts +1 -1
- package/dist/converters/html.mjs +1 -1
- package/dist/converters/markdown.d.mts +1 -1
- package/dist/converters/markdown.mjs +1 -1
- package/dist/converters/patch.d.mts +1 -1
- package/dist/converters/prepare.d.mts +1 -1
- package/dist/converters/styles.d.mts +7 -1
- package/dist/converters/styles.mjs +31 -8
- package/dist/{core-DT9IrTzN.mjs → core-B8ba_FNi.mjs} +50 -3
- package/dist/{core-C9VunJ8o.d.mts → core-DRaLI8nd.d.mts} +31 -2
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/document-Cws7XTYL.d.mts +28 -0
- package/dist/editor.d.mts +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/extensions/code-block.d.mts +1 -1
- package/dist/extensions/column-break.d.mts +1 -1
- package/dist/extensions/column-break.mjs +1 -1
- package/dist/extensions/document.d.mts +1 -1
- package/dist/extensions/document.mjs +1 -5
- package/dist/extensions/extensions.d.mts +3 -3
- package/dist/extensions/extensions.mjs +2 -2
- package/dist/extensions/formatting-marks.d.mts +1 -1
- package/dist/extensions/formatting-marks.mjs +1 -1
- package/dist/extensions/heading.mjs +31 -9
- package/dist/extensions/image.d.mts +1 -1
- package/dist/extensions/index.d.mts +3 -3
- package/dist/extensions/index.mjs +2 -2
- package/dist/extensions/page-break.d.mts +1 -1
- package/dist/extensions/page-break.mjs +1 -1
- package/dist/extensions/paragraph.mjs +1 -6
- package/dist/extensions/passthrough.d.mts +1 -1
- package/dist/extensions/passthrough.mjs +1 -1
- package/dist/extensions/section-break.d.mts +1 -1
- package/dist/extensions/section-break.mjs +1 -1
- package/dist/extensions/strike.mjs +1 -5
- package/dist/extensions/table-cell.mjs +3 -8
- package/dist/extensions/table-header.mjs +1 -6
- package/dist/extensions/table-row.mjs +1 -6
- package/dist/extensions/table.mjs +1 -6
- package/dist/extensions/text-style.mjs +1 -6
- package/dist/extensions/toc-field.d.mts +2 -0
- package/dist/extensions/toc-field.mjs +2 -0
- package/dist/extensions/utils.d.mts +2 -2
- package/dist/extensions/utils.mjs +10 -1
- package/dist/extensions/wpg-group.d.mts +1 -1
- package/dist/extensions/wpg-group.mjs +1 -1
- package/dist/extensions/wps-shape.d.mts +1 -1
- package/dist/extensions/wps-shape.mjs +1 -1
- package/dist/index.d.mts +19 -6
- package/dist/index.mjs +3 -3
- package/dist/{utils-D87vukzp.d.mts → utils-BJwDQts7.d.mts} +10 -1
- package/package.json +3 -3
- package/dist/document-BH1y4qHM.d.mts +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as JSONContent } from "../core-
|
|
1
|
+
import { a as JSONContent } from "../core-DRaLI8nd.mjs";
|
|
2
2
|
import { PrepareStep } from "./prepare.mjs";
|
|
3
3
|
import { DocumentOptions, OutputByType, OutputType, PackerOptions, parseDocument } from "@office-open/docx";
|
|
4
4
|
|
|
@@ -68,15 +68,36 @@ declare class DocxManager {
|
|
|
68
68
|
private resolveSectionChild;
|
|
69
69
|
/** Wrap an opaque SectionChild in a passthrough atom (attrs.data = JSON). */
|
|
70
70
|
private resolvePassthrough;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a table of contents into an editable `tableOfContents` container:
|
|
73
|
+
* `attrs.options` carries the field switches, `content` is the entry
|
|
74
|
+
* paragraphs. Each entry's inner HYPERLINK field has content-less runs that
|
|
75
|
+
* office-open parses as `null`; resolving the entries through
|
|
76
|
+
* `resolveSectionChild` → `resolveParagraphChildren` drops those nulls, so the
|
|
77
|
+
* TOC no longer reaches the generate path as an opaque blob of nulls (the
|
|
78
|
+
* `stringifyRunInline(null).break` crash). When `entries` is absent/empty
|
|
79
|
+
* (a fresh, unrendered TOC), keep the node valid for `content: "block+"` with
|
|
80
|
+
* a placeholder empty paragraph.
|
|
81
|
+
*/
|
|
82
|
+
private resolveToc;
|
|
71
83
|
/**
|
|
72
84
|
* Resolve a details group-SDT: the summary-style paragraph becomes
|
|
73
85
|
* detailsSummary, the remaining blocks fold into detailsContent.
|
|
74
86
|
*/
|
|
75
87
|
private resolveDetailsSdt;
|
|
76
88
|
private resolveParagraph;
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
|
|
89
|
+
/** Heading level (1-9) for a paragraph, or undefined when it isn't a heading.
|
|
90
|
+
* DOCX marks a heading several ways, checked in priority order:
|
|
91
|
+
* 1. office-open lifts a HeadingLevel pStyle ("Heading1".."Title") into `heading`.
|
|
92
|
+
* 2. An explicit `outlineLevel` (0-8 → 1-9) — Word's outline/TOC key off this
|
|
93
|
+
* even without a heading pStyle; the Heading1-9 styles carry outlineLvl 0-8.
|
|
94
|
+
* 3. A pStyle that names a heading style: directly ("Heading7", which stays on
|
|
95
|
+
* `style` because office-open's HeadingLevel type caps at 6), by localized
|
|
96
|
+
* NAME ("heading 1"/"标题 1"), or via the `basedOn` chain (a custom style
|
|
97
|
+
* "MyTitle" basedOn="Heading1"). `heading` and `style` carry the same pStyle.
|
|
98
|
+
* `outlineLevel` is read loosely — office-open's public type omits the field
|
|
99
|
+
* even though it round-trips (w:outlineLvl) at runtime. */
|
|
100
|
+
private detectHeadingLevel;
|
|
80
101
|
/** reference → level-0 format/start, for classifying numbering paragraphs. */
|
|
81
102
|
private buildNumberingLookup;
|
|
82
103
|
/**
|
package/dist/converters/docx.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { parseDocx as parseDocx$7, renderDocx as renderDocx$8 } from "../extensi
|
|
|
14
14
|
import { createTaskCheckbox, isTaskCheckbox, readCheckboxState } from "../extensions/task-item.mjs";
|
|
15
15
|
import { parseDocx as parseDocx$8, renderDocx as renderDocx$9 } from "../extensions/text-style.mjs";
|
|
16
16
|
import { prepareDocument } from "./prepare.mjs";
|
|
17
|
+
import { indexParagraphStyles } from "./styles.mjs";
|
|
17
18
|
import { emojis, shortcodeToEmoji } from "@tiptap/extension-emoji";
|
|
18
19
|
import { generateDocument, generateDocumentStream, generateDocumentSync, parseDocument } from "@office-open/docx";
|
|
19
20
|
import { encodeBase64 } from "@office-open/core";
|
|
@@ -266,6 +267,20 @@ var DocxManager = class {
|
|
|
266
267
|
case "orderedList":
|
|
267
268
|
case "taskList": return this.compileListFromNode(node, 0);
|
|
268
269
|
case "details": return this.compileDetailsNode(node);
|
|
270
|
+
case "tocField": {
|
|
271
|
+
const options = node.attrs?.options ?? {};
|
|
272
|
+
const entries = [];
|
|
273
|
+
for (const child of node.content ?? []) {
|
|
274
|
+
const compiled = this.compileSectionChild(child);
|
|
275
|
+
if (!compiled) continue;
|
|
276
|
+
if (Array.isArray(compiled)) entries.push(...compiled);
|
|
277
|
+
else entries.push(compiled);
|
|
278
|
+
}
|
|
279
|
+
return { toc: {
|
|
280
|
+
...options,
|
|
281
|
+
entries
|
|
282
|
+
} };
|
|
283
|
+
}
|
|
269
284
|
case "passthrough": {
|
|
270
285
|
const data = node.attrs?.data ?? "{}";
|
|
271
286
|
try {
|
|
@@ -645,6 +660,7 @@ var DocxManager = class {
|
|
|
645
660
|
if (sdt.properties?.tag === "docen-details") return this.resolveDetailsSdt(sdt);
|
|
646
661
|
return this.resolvePassthrough(child);
|
|
647
662
|
}
|
|
663
|
+
if ("toc" in child) return this.resolveToc(child.toc);
|
|
648
664
|
return this.resolvePassthrough(child);
|
|
649
665
|
}
|
|
650
666
|
/** Wrap an opaque SectionChild in a passthrough atom (attrs.data = JSON). */
|
|
@@ -655,6 +671,35 @@ var DocxManager = class {
|
|
|
655
671
|
};
|
|
656
672
|
}
|
|
657
673
|
/**
|
|
674
|
+
* Resolve a table of contents into an editable `tableOfContents` container:
|
|
675
|
+
* `attrs.options` carries the field switches, `content` is the entry
|
|
676
|
+
* paragraphs. Each entry's inner HYPERLINK field has content-less runs that
|
|
677
|
+
* office-open parses as `null`; resolving the entries through
|
|
678
|
+
* `resolveSectionChild` → `resolveParagraphChildren` drops those nulls, so the
|
|
679
|
+
* TOC no longer reaches the generate path as an opaque blob of nulls (the
|
|
680
|
+
* `stringifyRunInline(null).break` crash). When `entries` is absent/empty
|
|
681
|
+
* (a fresh, unrendered TOC), keep the node valid for `content: "block+"` with
|
|
682
|
+
* a placeholder empty paragraph.
|
|
683
|
+
*/
|
|
684
|
+
resolveToc(toc) {
|
|
685
|
+
const { entries, ...options } = toc;
|
|
686
|
+
const content = [];
|
|
687
|
+
for (const entry of entries ?? []) {
|
|
688
|
+
const node = this.resolveSectionChild(entry);
|
|
689
|
+
if (!node) continue;
|
|
690
|
+
if (Array.isArray(node)) content.push(...node);
|
|
691
|
+
else content.push(node);
|
|
692
|
+
}
|
|
693
|
+
if (content.length === 0) content.push({ type: "paragraph" });
|
|
694
|
+
const node = {
|
|
695
|
+
type: "tocField",
|
|
696
|
+
content
|
|
697
|
+
};
|
|
698
|
+
const cleanOptions = cleanAttrs(options);
|
|
699
|
+
if (Object.keys(cleanOptions).length > 0) node.attrs = { options: cleanOptions };
|
|
700
|
+
return node;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
658
703
|
* Resolve a details group-SDT: the summary-style paragraph becomes
|
|
659
704
|
* detailsSummary, the remaining blocks fold into detailsContent.
|
|
660
705
|
*/
|
|
@@ -692,20 +737,10 @@ var DocxManager = class {
|
|
|
692
737
|
const resolved = typeof opts === "string" ? { text: opts } : opts;
|
|
693
738
|
if (resolved.thematicBreak) return { type: "horizontalRule" };
|
|
694
739
|
if (resolved.style === "Code") return this.resolveCodeBlock(resolved);
|
|
695
|
-
|
|
696
|
-
if (!headingLevel && resolved.style) {
|
|
697
|
-
const name = this.styleNameOf(resolved.style);
|
|
698
|
-
if (name) {
|
|
699
|
-
const m = /^heading\s+(\d)$/i.exec(name);
|
|
700
|
-
if (m) {
|
|
701
|
-
const lvl = Number(m[1]);
|
|
702
|
-
if (lvl >= 1 && lvl <= 6) headingLevel = lvl;
|
|
703
|
-
} else if (/^title$/i.test(name)) headingLevel = 1;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
if (headingLevel && !resolved.heading) resolved.heading = `Heading${headingLevel}`;
|
|
740
|
+
const headingLevel = this.detectHeadingLevel(resolved);
|
|
707
741
|
const nodeType = headingLevel ? "heading" : "paragraph";
|
|
708
742
|
const attrs = headingLevel ? parseDocx(resolved) : parseDocx$2(resolved);
|
|
743
|
+
if (headingLevel && attrs.level == null) attrs.level = headingLevel;
|
|
709
744
|
const content = this.resolveInlineContent(resolved);
|
|
710
745
|
const cleanAttrsObj = cleanAttrs(attrs);
|
|
711
746
|
const node = { type: nodeType };
|
|
@@ -713,10 +748,38 @@ var DocxManager = class {
|
|
|
713
748
|
if (content.length > 0) node.content = content;
|
|
714
749
|
return node;
|
|
715
750
|
}
|
|
716
|
-
/**
|
|
717
|
-
*
|
|
718
|
-
|
|
719
|
-
|
|
751
|
+
/** Heading level (1-9) for a paragraph, or undefined when it isn't a heading.
|
|
752
|
+
* DOCX marks a heading several ways, checked in priority order:
|
|
753
|
+
* 1. office-open lifts a HeadingLevel pStyle ("Heading1".."Title") into `heading`.
|
|
754
|
+
* 2. An explicit `outlineLevel` (0-8 → 1-9) — Word's outline/TOC key off this
|
|
755
|
+
* even without a heading pStyle; the Heading1-9 styles carry outlineLvl 0-8.
|
|
756
|
+
* 3. A pStyle that names a heading style: directly ("Heading7", which stays on
|
|
757
|
+
* `style` because office-open's HeadingLevel type caps at 6), by localized
|
|
758
|
+
* NAME ("heading 1"/"标题 1"), or via the `basedOn` chain (a custom style
|
|
759
|
+
* "MyTitle" basedOn="Heading1"). `heading` and `style` carry the same pStyle.
|
|
760
|
+
* `outlineLevel` is read loosely — office-open's public type omits the field
|
|
761
|
+
* even though it round-trips (w:outlineLvl) at runtime. */
|
|
762
|
+
detectHeadingLevel(resolved) {
|
|
763
|
+
if (resolved.heading) {
|
|
764
|
+
const lvl = HEADING_LEVEL_MAP[resolved.heading];
|
|
765
|
+
if (lvl) return lvl;
|
|
766
|
+
}
|
|
767
|
+
const outline = resolved.outlineLevel;
|
|
768
|
+
if (typeof outline === "number" && outline >= 0 && outline <= 8) return outline + 1;
|
|
769
|
+
const styleId = resolved.style;
|
|
770
|
+
if (!styleId || !this.resolveStyles) return void 0;
|
|
771
|
+
const byId = indexParagraphStyles(this.resolveStyles);
|
|
772
|
+
const visited = /* @__PURE__ */ new Set();
|
|
773
|
+
let curId = styleId;
|
|
774
|
+
while (curId && !visited.has(curId)) {
|
|
775
|
+
visited.add(curId);
|
|
776
|
+
if (HEADING_LEVEL_MAP[curId]) return HEADING_LEVEL_MAP[curId];
|
|
777
|
+
const style = byId.get(curId);
|
|
778
|
+
if (!style) break;
|
|
779
|
+
const lvl = headingLevelFromName(style.name);
|
|
780
|
+
if (lvl) return lvl;
|
|
781
|
+
curId = style.basedOn ?? void 0;
|
|
782
|
+
}
|
|
720
783
|
}
|
|
721
784
|
/** reference → level-0 format/start, for classifying numbering paragraphs. */
|
|
722
785
|
buildNumberingLookup(docOpts) {
|
|
@@ -909,9 +972,10 @@ var DocxManager = class {
|
|
|
909
972
|
*/
|
|
910
973
|
resolveListItemParagraph(para, info) {
|
|
911
974
|
const resolved = typeof para === "string" ? { text: para } : para;
|
|
912
|
-
const headingLevel =
|
|
975
|
+
const headingLevel = this.detectHeadingLevel(resolved);
|
|
913
976
|
const nodeType = headingLevel ? "heading" : "paragraph";
|
|
914
977
|
const attrs = headingLevel ? parseDocx(resolved) : parseDocx$2(resolved);
|
|
978
|
+
if (headingLevel && attrs.level == null) attrs.level = headingLevel;
|
|
915
979
|
const stripped = info.kind === "task" ? this.stripTaskCheckbox(resolved) : resolved;
|
|
916
980
|
const content = this.resolveInlineContent(stripped);
|
|
917
981
|
const node = { type: nodeType };
|
|
@@ -1190,8 +1254,23 @@ const HEADING_LEVEL_MAP = {
|
|
|
1190
1254
|
Heading4: 4,
|
|
1191
1255
|
Heading5: 5,
|
|
1192
1256
|
Heading6: 6,
|
|
1257
|
+
Heading7: 7,
|
|
1258
|
+
Heading8: 8,
|
|
1259
|
+
Heading9: 9,
|
|
1193
1260
|
Title: 1
|
|
1194
1261
|
};
|
|
1262
|
+
/** Heading level (1-9) from a localized style NAME: "heading 1"/"标题 1" → 1,
|
|
1263
|
+
* "title" → 1. office-open's built-in names are English ("heading 1"), but
|
|
1264
|
+
* zh-CN Word labels the same styles "标题 1"; both map to the same level. */
|
|
1265
|
+
function headingLevelFromName(name) {
|
|
1266
|
+
if (!name) return void 0;
|
|
1267
|
+
const m = /^heading\s+(\d)$/i.exec(name) ?? /^标题\s*(\d)$/.exec(name);
|
|
1268
|
+
if (m) {
|
|
1269
|
+
const lvl = Number(m[1]);
|
|
1270
|
+
if (lvl >= 1 && lvl <= 9) return lvl;
|
|
1271
|
+
}
|
|
1272
|
+
return /^title$/i.test(name) ? 1 : void 0;
|
|
1273
|
+
}
|
|
1195
1274
|
const defaultManager = new DocxManager();
|
|
1196
1275
|
/**
|
|
1197
1276
|
* Parse a DOCX file into Tiptap JSON (runtime model).
|
package/dist/converters/html.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as docxExtensions } from "../core-
|
|
1
|
+
import { s as docxExtensions } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
import { sectionLinePitchCss, sectionMarginCss } from "../extensions/utils.mjs";
|
|
3
3
|
import { getSchema } from "@tiptap/core";
|
|
4
4
|
import { encodeBase64 } from "@office-open/core";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as docxExtensions } from "../core-
|
|
1
|
+
import { s as docxExtensions } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
import { Markdown, MarkdownManager } from "@tiptap/markdown";
|
|
3
3
|
//#region src/converters/markdown.ts
|
|
4
4
|
const markdownManager = new MarkdownManager({ extensions: [...docxExtensions, Markdown] });
|
|
@@ -2,6 +2,11 @@ import { JSONContent } from "@tiptap/core";
|
|
|
2
2
|
import { StylesOptions } from "@office-open/docx";
|
|
3
3
|
|
|
4
4
|
//#region src/converters/styles.d.ts
|
|
5
|
+
/** A named style entry as office-open models it: BaseParagraphStyleOptions or
|
|
6
|
+
* BaseCharacterStyleOptions (both extend the internal StyleOptions, carrying
|
|
7
|
+
* name/uiPriority/quickFormat). Derived from the public StylesOptions — not
|
|
8
|
+
* imported — because StyleOptions is not a public export of @office-open/docx. */
|
|
9
|
+
type StyleEntry = NonNullable<StylesOptions["paragraphStyles"]>[number] | NonNullable<StylesOptions["characterStyles"]>[number];
|
|
5
10
|
/** The styleId of the document's default paragraph style (`w:default="1"`
|
|
6
11
|
* type="paragraph") — the implicit style applied to every paragraph WITHOUT an
|
|
7
12
|
* explicit pStyle. OOXML renders a pStyle-less paragraph as this style (usually
|
|
@@ -29,6 +34,7 @@ declare function defaultParagraphStyleId(styles: StylesOptions | null | undefine
|
|
|
29
34
|
* carries its full ancestor chain rather than relying on source order.
|
|
30
35
|
*/
|
|
31
36
|
declare function stylesToCss(styles: StylesOptions | null | undefined, scope: string): string;
|
|
37
|
+
declare function indexParagraphStyles(styles: StylesOptions): Map<string, StyleEntry>;
|
|
32
38
|
/** A gallery-ready paragraph-style entry for the Styles combobox. */
|
|
33
39
|
interface QuickStyleEntry {
|
|
34
40
|
id: string;
|
|
@@ -82,4 +88,4 @@ declare function effectiveRunProps(styles: StylesOptions | null | undefined, sty
|
|
|
82
88
|
*/
|
|
83
89
|
declare function inlineStyles(json: JSONContent, styles?: StylesOptions | null): JSONContent;
|
|
84
90
|
//#endregion
|
|
85
|
-
export { QuickStyleEntry, type StylesOptions, defaultParagraphStyleId, effectiveRunProps, inlineStyles, quickStyles, stylesToCss };
|
|
91
|
+
export { QuickStyleEntry, StyleEntry, type StylesOptions, defaultParagraphStyleId, effectiveRunProps, indexParagraphStyles, inlineStyles, quickStyles, stylesToCss };
|
|
@@ -85,7 +85,10 @@ function stylesToCss(styles, scope) {
|
|
|
85
85
|
* (key → pStyle id via pStyleIdFromKey). `document` is docDefaults, not a
|
|
86
86
|
* named style, so it is excluded. A built-in that also appears in
|
|
87
87
|
* paragraphStyles is deduped by id (paragraphStyles wins on insertion order). */
|
|
88
|
+
const styleIndexCache = /* @__PURE__ */ new WeakMap();
|
|
88
89
|
function indexParagraphStyles(styles) {
|
|
90
|
+
const cached = styleIndexCache.get(styles);
|
|
91
|
+
if (cached) return cached;
|
|
89
92
|
const byId = /* @__PURE__ */ new Map();
|
|
90
93
|
for (const ps of styles.paragraphStyles ?? []) byId.set(ps.id, ps);
|
|
91
94
|
const defaults = styles.default;
|
|
@@ -93,14 +96,34 @@ function indexParagraphStyles(styles) {
|
|
|
93
96
|
if (key === "document" || !style) continue;
|
|
94
97
|
byId.set(pStyleIdFromKey(key), style);
|
|
95
98
|
}
|
|
99
|
+
styleIndexCache.set(styles, byId);
|
|
96
100
|
return byId;
|
|
97
101
|
}
|
|
102
|
+
/** Whether `v` is a plain object — an OOXML property group (spacing/indent/
|
|
103
|
+
* border/shading/font) that merges key by key — as opposed to an array
|
|
104
|
+
* (tabStops) or scalar, which replace. */
|
|
105
|
+
function isPlainObject(v) {
|
|
106
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
107
|
+
}
|
|
108
|
+
/** Deep-merge `source` into `target` (mutates target) per the OOXML `basedOn`
|
|
109
|
+
* model: nested property groups merge key by key (a child's spacing.before
|
|
110
|
+
* merges with, not replaces, the parent's spacing.line); arrays and scalars
|
|
111
|
+
* replace. Nullish source values are skipped so an unset child key doesn't
|
|
112
|
+
* clobber an inherited value. */
|
|
113
|
+
function deepMergeInto(target, source) {
|
|
114
|
+
for (const [key, srcVal] of Object.entries(source)) {
|
|
115
|
+
if (srcVal === null || srcVal === void 0) continue;
|
|
116
|
+
const tgtVal = target[key];
|
|
117
|
+
target[key] = isPlainObject(srcVal) && isPlainObject(tgtVal) ? deepMergeInto({ ...tgtVal }, srcVal) : isPlainObject(srcVal) ? { ...srcVal } : srcVal;
|
|
118
|
+
}
|
|
119
|
+
return target;
|
|
120
|
+
}
|
|
98
121
|
/** Merge a paragraph style's run/paragraph properties with its `basedOn` chain
|
|
99
|
-
* (root first, child overrides per-property) — the OOXML inheritance model.
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
122
|
+
* (root first, child overrides per-property) — the OOXML inheritance model.
|
|
123
|
+
* Nested property groups (spacing/indent/border/font) merge key by key; arrays
|
|
124
|
+
* and scalars replace. Shared by stylesToCss (rendering) and effectiveRunProps
|
|
125
|
+
* (the caret resolver) so the gallery box and the rendered page resolve
|
|
126
|
+
* identical values. */
|
|
104
127
|
function mergeStyleChain(byId, styleId) {
|
|
105
128
|
const chain = [];
|
|
106
129
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -116,8 +139,8 @@ function mergeStyleChain(byId, styleId) {
|
|
|
116
139
|
const paragraph = {};
|
|
117
140
|
for (const style of chain) {
|
|
118
141
|
const s = style;
|
|
119
|
-
if (s.run)
|
|
120
|
-
if (s.paragraph)
|
|
142
|
+
if (s.run) deepMergeInto(run, s.run);
|
|
143
|
+
if (s.paragraph) deepMergeInto(paragraph, s.paragraph);
|
|
121
144
|
}
|
|
122
145
|
return {
|
|
123
146
|
run,
|
|
@@ -282,4 +305,4 @@ function inlineStyles(json, styles) {
|
|
|
282
305
|
return resolveNode(json, indexParagraphStyles(docStyles), indexCharacterRunStyles(docStyles));
|
|
283
306
|
}
|
|
284
307
|
//#endregion
|
|
285
|
-
export { defaultParagraphStyleId, effectiveRunProps, inlineStyles, quickStyles, stylesToCss };
|
|
308
|
+
export { defaultParagraphStyleId, effectiveRunProps, indexParagraphStyles, inlineStyles, quickStyles, stylesToCss };
|
|
@@ -2,8 +2,8 @@ import { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, Details
|
|
|
2
2
|
import "./extensions/blockquote.mjs";
|
|
3
3
|
import { CodeBlock } from "./extensions/code-block.mjs";
|
|
4
4
|
import "./extensions/details.mjs";
|
|
5
|
+
import { attrNative, floatAnchorScope, floatingToStyles, normalizeColorToHex, renderRunStyles } from "./extensions/utils.mjs";
|
|
5
6
|
import { Document } from "./extensions/document.mjs";
|
|
6
|
-
import { floatAnchorScope, floatingToStyles, normalizeColorToHex, renderRunStyles } from "./extensions/utils.mjs";
|
|
7
7
|
import { Heading } from "./extensions/heading.mjs";
|
|
8
8
|
import { Image } from "./extensions/image.mjs";
|
|
9
9
|
import "./extensions/mention.mjs";
|
|
@@ -224,7 +224,7 @@ const PageBreak = Node.create({
|
|
|
224
224
|
//#region src/extensions/passthrough.ts
|
|
225
225
|
/**
|
|
226
226
|
* Passthrough — block atom carrying an opaque {@link SectionChild} that has
|
|
227
|
-
* no native Tiptap representation (rawXml, bookmarkStart/End,
|
|
227
|
+
* no native Tiptap representation (rawXml, bookmarkStart/End, textbox,
|
|
228
228
|
* altChunk, subDoc, customXml).
|
|
229
229
|
*
|
|
230
230
|
* The full SectionChild is stored as JSON in `attrs.data` so the DOCX→JSON→DOCX
|
|
@@ -342,6 +342,52 @@ const SectionBreak = Extension.create({
|
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
//#endregion
|
|
345
|
+
//#region src/extensions/toc-field.ts
|
|
346
|
+
/**
|
|
347
|
+
* TOC field (`tocField`) — a block container representing a DOCX table of
|
|
348
|
+
* contents, with the rendered entries as editable `content` and the TOC field
|
|
349
|
+
* switches on `attrs.options`.
|
|
350
|
+
*
|
|
351
|
+
* Named `tocField` (not `tableOfContents`) to avoid colliding with the official
|
|
352
|
+
* `@tiptap/extension-table-of-contents`, which is an `Extension` (a live outline
|
|
353
|
+
* generator injected into the editor) that already owns the `tableOfContents`
|
|
354
|
+
* name. Same-name extensions dedupe in Tiptap, and since the official one is not
|
|
355
|
+
* a node it would erase this node type from the schema. The two coexist for
|
|
356
|
+
* different purposes: this node persists a DOCX's rendered TOC; the official
|
|
357
|
+
* extension drives the heading-outline pane.
|
|
358
|
+
*
|
|
359
|
+
* Structuring the TOC as a node (instead of opaque passthrough) is what fixes
|
|
360
|
+
* the export crash. Each entry paragraph's `w:hyperlink` wraps a HYPERLINK field
|
|
361
|
+
* whose content-less runs (fldChar begin/separate/end) office-open parses as
|
|
362
|
+
* `null`. As opaque passthrough those nulls survived verbatim to
|
|
363
|
+
* `generateDocument`, where office-open's `stringifyRunInline(null).break`
|
|
364
|
+
* crashed. Resolving the entries through `resolveParagraphChildren` drops the
|
|
365
|
+
* nulls (the existing `child !== null` guard), so compile rebuilds clean entries
|
|
366
|
+
* and the generate path never sees a null — no office-open change required.
|
|
367
|
+
*
|
|
368
|
+
* DOCX serialization is inlined in DocxManager (resolve/compile read/write
|
|
369
|
+
* `attrs.options` + the entry content directly), so no renderDocx/parseDocx is
|
|
370
|
+
* needed here — the same pattern as the details extension.
|
|
371
|
+
*/
|
|
372
|
+
const TocField = Node.create({
|
|
373
|
+
name: "tocField",
|
|
374
|
+
group: "block",
|
|
375
|
+
content: "block+",
|
|
376
|
+
addAttributes() {
|
|
377
|
+
return { options: attrNative() };
|
|
378
|
+
},
|
|
379
|
+
parseHTML() {
|
|
380
|
+
return [{ tag: "div.docx-toc" }];
|
|
381
|
+
},
|
|
382
|
+
renderHTML() {
|
|
383
|
+
return [
|
|
384
|
+
"div",
|
|
385
|
+
{ class: "docx-toc" },
|
|
386
|
+
0
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
//#endregion
|
|
345
391
|
//#region src/extensions/wpg-group.ts
|
|
346
392
|
/**
|
|
347
393
|
* wpgGroup — inline atom carrying a DOCX drawing group (wpg: wordprocessingGroup)
|
|
@@ -598,6 +644,7 @@ const tiptapNodeExtensions = [
|
|
|
598
644
|
ColumnBreak,
|
|
599
645
|
SectionBreak,
|
|
600
646
|
Passthrough,
|
|
647
|
+
TocField,
|
|
601
648
|
Blockquote,
|
|
602
649
|
OrderedList,
|
|
603
650
|
BulletList,
|
|
@@ -667,4 +714,4 @@ const DocxKit = Extension.create({
|
|
|
667
714
|
}
|
|
668
715
|
});
|
|
669
716
|
//#endregion
|
|
670
|
-
export {
|
|
717
|
+
export { PageBreak as _, DocxKit as a, tiptapMarkExtensions as c, WpgGroup as d, renderWpsInterior as f, Passthrough as g, SectionBreak as h, Node as i, tiptapNodeExtensions as l, TocField as m, Extension as n, TextAlign as o, renderWpsText as p, Mark as r, docxExtensions as s, Editor as t, WpsShape as u, FormattingMarks as v, ColumnBreak as y };
|
|
@@ -101,7 +101,7 @@ declare const WpsShape: Node<any, any>;
|
|
|
101
101
|
//#region src/extensions/passthrough.d.ts
|
|
102
102
|
/**
|
|
103
103
|
* Passthrough — block atom carrying an opaque {@link SectionChild} that has
|
|
104
|
-
* no native Tiptap representation (rawXml, bookmarkStart/End,
|
|
104
|
+
* no native Tiptap representation (rawXml, bookmarkStart/End, textbox,
|
|
105
105
|
* altChunk, subDoc, customXml).
|
|
106
106
|
*
|
|
107
107
|
* The full SectionChild is stored as JSON in `attrs.data` so the DOCX→JSON→DOCX
|
|
@@ -115,6 +115,35 @@ declare const WpsShape: Node<any, any>;
|
|
|
115
115
|
*/
|
|
116
116
|
declare const Passthrough: Node<any, any>;
|
|
117
117
|
//#endregion
|
|
118
|
+
//#region src/extensions/toc-field.d.ts
|
|
119
|
+
/**
|
|
120
|
+
* TOC field (`tocField`) — a block container representing a DOCX table of
|
|
121
|
+
* contents, with the rendered entries as editable `content` and the TOC field
|
|
122
|
+
* switches on `attrs.options`.
|
|
123
|
+
*
|
|
124
|
+
* Named `tocField` (not `tableOfContents`) to avoid colliding with the official
|
|
125
|
+
* `@tiptap/extension-table-of-contents`, which is an `Extension` (a live outline
|
|
126
|
+
* generator injected into the editor) that already owns the `tableOfContents`
|
|
127
|
+
* name. Same-name extensions dedupe in Tiptap, and since the official one is not
|
|
128
|
+
* a node it would erase this node type from the schema. The two coexist for
|
|
129
|
+
* different purposes: this node persists a DOCX's rendered TOC; the official
|
|
130
|
+
* extension drives the heading-outline pane.
|
|
131
|
+
*
|
|
132
|
+
* Structuring the TOC as a node (instead of opaque passthrough) is what fixes
|
|
133
|
+
* the export crash. Each entry paragraph's `w:hyperlink` wraps a HYPERLINK field
|
|
134
|
+
* whose content-less runs (fldChar begin/separate/end) office-open parses as
|
|
135
|
+
* `null`. As opaque passthrough those nulls survived verbatim to
|
|
136
|
+
* `generateDocument`, where office-open's `stringifyRunInline(null).break`
|
|
137
|
+
* crashed. Resolving the entries through `resolveParagraphChildren` drops the
|
|
138
|
+
* nulls (the existing `child !== null` guard), so compile rebuilds clean entries
|
|
139
|
+
* and the generate path never sees a null — no office-open change required.
|
|
140
|
+
*
|
|
141
|
+
* DOCX serialization is inlined in DocxManager (resolve/compile read/write
|
|
142
|
+
* `attrs.options` + the entry content directly), so no renderDocx/parseDocx is
|
|
143
|
+
* needed here — the same pattern as the details extension.
|
|
144
|
+
*/
|
|
145
|
+
declare const TocField: Node<any, any>;
|
|
146
|
+
//#endregion
|
|
118
147
|
//#region src/extensions/extensions.d.ts
|
|
119
148
|
declare const tiptapNodeExtensions: AnyExtension[];
|
|
120
149
|
declare const tiptapMarkExtensions: AnyExtension[];
|
|
@@ -171,4 +200,4 @@ declare module "@tiptap/core" {
|
|
|
171
200
|
}
|
|
172
201
|
}
|
|
173
202
|
//#endregion
|
|
174
|
-
export {
|
|
203
|
+
export { Image as C, renderDocx as E, CropRenderContext as S, renderCropAttrs as T, WpsShape as _, JSONContent$1 as a, renderWpsInterior as b, PageBreak as c, TextAlign as d, docxExtensions as f, Passthrough as g, TocField as h, Extensions as i, DocxKit as l, tiptapNodeExtensions as m, Editor as n, Mark as o, tiptapMarkExtensions as p, Extension as r, Node as s, AnyExtension as t, DocxKitOptions as u, WpgGroup as v, parseDocx as w, renderWpsText as x, WpsData as y };
|
package/dist/core.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSONContent, f as docxExtensions, i as Extensions, n as Editor, o as Mark, r as Extension, s as Node, t as AnyExtension } from "./core-
|
|
1
|
+
import { a as JSONContent, f as docxExtensions, i as Extensions, n as Editor, o as Mark, r as Extension, s as Node, t as AnyExtension } from "./core-DRaLI8nd.mjs";
|
|
2
2
|
export { type AnyExtension, Editor, Extension, type Extensions, type JSONContent, Mark, Node, docxExtensions };
|
package/dist/core.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as Node, n as Extension, r as Mark, s as docxExtensions, t as Editor } from "./core-
|
|
1
|
+
import { i as Node, n as Extension, r as Mark, s as docxExtensions, t as Editor } from "./core-B8ba_FNi.mjs";
|
|
2
2
|
export { Editor, Extension, Mark, Node, docxExtensions };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/extensions/document.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Document extension carrying DOCX document-level data through the Tiptap JSON
|
|
4
|
+
* for lossless round-trip (declared as attrs so editor setContent → getJSON
|
|
5
|
+
* preserves them, not just the standalone converters):
|
|
6
|
+
*
|
|
7
|
+
* - `attrs.styles` — office-open `StylesOptions` (styles.xml: importedStyles /
|
|
8
|
+
* docDefaultsXml / latentStylesXml as raw XML).
|
|
9
|
+
* - `attrs.core` — docProps/core.xml properties (title/creator/description/…,
|
|
10
|
+
* see DocxCoreProperties in converters/docx.ts).
|
|
11
|
+
* - `attrs.sectionProperties` — the last section's page layout (page size/margin/
|
|
12
|
+
* orientation, columns, type, grid; intermediate sections carry theirs on
|
|
13
|
+
* sectionBreak nodes).
|
|
14
|
+
*
|
|
15
|
+
* None rendered to HTML — phase 2 applies styles via injected CSS.
|
|
16
|
+
*
|
|
17
|
+
* Factory form (`createDocument`): the editor layer needs a different top-level
|
|
18
|
+
* content expression (`doc > page+` for the C-route editing schema) but the SAME
|
|
19
|
+
* DOCX attrs. Building it via this factory keeps the Document definition in ONE
|
|
20
|
+
* place (here) — the editor parameterizes only `content`, instead of `.extend`-
|
|
21
|
+
* overriding this Document and re-stating the attrs. `Document` is the default
|
|
22
|
+
* flat `doc > block+` shape used by the docx package itself.
|
|
23
|
+
*/
|
|
24
|
+
declare function createDocument(content?: string): import("@tiptap/core").Node<any, any>;
|
|
25
|
+
/** Default flat Document (`doc > block+`) — the DOCX round-trip shape. */
|
|
26
|
+
declare const Document: import("@tiptap/core").Node<any, any>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createDocument as n, Document as t };
|
package/dist/editor.d.mts
CHANGED
package/dist/editor.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as ColumnBreak } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { ColumnBreak };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createDocument, t as Document } from "../document-
|
|
1
|
+
import { n as createDocument, t as Document } from "../document-Cws7XTYL.mjs";
|
|
2
2
|
export { Document, createDocument };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Document as Document$1 } from "./tiptap.mjs";
|
|
2
|
+
import { attrNative } from "./utils.mjs";
|
|
2
3
|
//#region src/extensions/document.ts
|
|
3
4
|
/**
|
|
4
5
|
* Document extension carrying DOCX document-level data through the Tiptap JSON
|
|
@@ -22,11 +23,6 @@ import { Document as Document$1 } from "./tiptap.mjs";
|
|
|
22
23
|
* overriding this Document and re-stating the attrs. `Document` is the default
|
|
23
24
|
* flat `doc > block+` shape used by the docx package itself.
|
|
24
25
|
*/
|
|
25
|
-
const attrNative = () => ({
|
|
26
|
-
default: null,
|
|
27
|
-
parseHTML: () => null,
|
|
28
|
-
rendered: false
|
|
29
|
-
});
|
|
30
26
|
function createDocument(content = "block+") {
|
|
31
27
|
return Document$1.extend({
|
|
32
28
|
content,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as TaskItem, F as Underline, M as Text, T as Superscript, _ as Link, a as CodeBlockLowlight, b as Mention, c as DetailsSummary, d as HardBreak, g as Italic, i as Code, j as TaskList, m as HorizontalRule, n as Bold, o as Details, p as Highlight, r as BulletList, s as DetailsContent, t as Blockquote, u as Emoji, v as ListItem, w as Subscript, x as OrderedList, y as Mathematics } from "../tiptap-pZsNPsvV.mjs";
|
|
2
|
-
import { t as Document } from "../document-
|
|
2
|
+
import { t as Document } from "../document-Cws7XTYL.mjs";
|
|
3
3
|
import { t as Heading } from "../heading-BvqBD2zX.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { C as Image, _ as WpsShape, d as TextAlign, f as docxExtensions, g as Passthrough, h as TocField, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, u as DocxKitOptions, v as WpgGroup } from "../core-DRaLI8nd.mjs";
|
|
5
5
|
import { t as Paragraph } from "../paragraph-D8mpHo_o.mjs";
|
|
6
6
|
import { t as TableRow } from "../table-row-kgzYkZlW.mjs";
|
|
7
7
|
import { t as Table } from "../table-BFkfeRp9.mjs";
|
|
@@ -9,4 +9,4 @@ import { t as TableCell } from "../table-cell-D_FV4D2h.mjs";
|
|
|
9
9
|
import { t as TableHeader } from "../table-header-KGQ2aEkP.mjs";
|
|
10
10
|
import { t as Strike } from "../strike-BgWGvjKr.mjs";
|
|
11
11
|
import { t as TextStyle } from "../text-style-BHdtXkMb.mjs";
|
|
12
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, DocxKit, DocxKitOptions, Emoji, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Paragraph, Passthrough, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, Underline, WpgGroup, WpsShape, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
|
|
12
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, DocxKit, DocxKitOptions, Emoji, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Paragraph, Passthrough, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Emoji, HardBreak, Highlight, HorizontalRule, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Subscript, Superscript, TaskItem, TaskList, Text, Underline } from "./tiptap.mjs";
|
|
2
|
-
import { a as DocxKit, c as tiptapMarkExtensions, d as WpgGroup,
|
|
2
|
+
import { a as DocxKit, c as tiptapMarkExtensions, d as WpgGroup, g as Passthrough, l as tiptapNodeExtensions, m as TocField, o as TextAlign, s as docxExtensions, u as WpsShape } from "../core-B8ba_FNi.mjs";
|
|
3
3
|
import { Document } from "./document.mjs";
|
|
4
4
|
import { Heading } from "./heading.mjs";
|
|
5
5
|
import { Image } from "./image.mjs";
|
|
@@ -10,4 +10,4 @@ import { TableCell } from "./table-cell.mjs";
|
|
|
10
10
|
import { TableHeader } from "./table-header.mjs";
|
|
11
11
|
import { TableRow } from "./table-row.mjs";
|
|
12
12
|
import { TextStyle } from "./text-style.mjs";
|
|
13
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, DocxKit, Emoji, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Paragraph, Passthrough, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, Underline, WpgGroup, WpsShape, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
|
|
13
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, DocxKit, Emoji, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Paragraph, Passthrough, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as FormattingMarks } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { FormattingMarks };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Heading as Heading$1 } from "./tiptap.mjs";
|
|
2
|
-
import { alignmentFromElement, bordersFromElement, indentFromElement, renderParagraphStyles, shadingFromElement, spacingFromElement } from "./utils.mjs";
|
|
2
|
+
import { alignmentFromElement, attrNative, bordersFromElement, indentFromElement, renderParagraphStyles, shadingFromElement, spacingFromElement } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/heading.ts
|
|
4
4
|
/**
|
|
5
5
|
* Heading extension with nested office-open attrs (mirrors Paragraph).
|
|
@@ -17,7 +17,10 @@ const HEADING_COMPILE_MAP = {
|
|
|
17
17
|
3: "Heading3",
|
|
18
18
|
4: "Heading4",
|
|
19
19
|
5: "Heading5",
|
|
20
|
-
6: "Heading6"
|
|
20
|
+
6: "Heading6",
|
|
21
|
+
7: "Heading7",
|
|
22
|
+
8: "Heading8",
|
|
23
|
+
9: "Heading9"
|
|
21
24
|
};
|
|
22
25
|
const HEADING_PARSE_MAP = {
|
|
23
26
|
Heading1: 1,
|
|
@@ -26,6 +29,9 @@ const HEADING_PARSE_MAP = {
|
|
|
26
29
|
Heading4: 4,
|
|
27
30
|
Heading5: 5,
|
|
28
31
|
Heading6: 6,
|
|
32
|
+
Heading7: 7,
|
|
33
|
+
Heading8: 8,
|
|
34
|
+
Heading9: 9,
|
|
29
35
|
Title: 1
|
|
30
36
|
};
|
|
31
37
|
/** Runtime-only attrs the TableOfContents extension injects on each heading
|
|
@@ -35,7 +41,7 @@ const TOC_RUNTIME_KEYS = new Set(["id", "data-toc-id"]);
|
|
|
35
41
|
function renderDocx(node) {
|
|
36
42
|
const attrs = node.attrs ?? {};
|
|
37
43
|
const opts = {};
|
|
38
|
-
const level = attrs.level;
|
|
44
|
+
const level = typeof attrs.level === "number" ? attrs.level : void 0;
|
|
39
45
|
const styleId = attrs.styleId;
|
|
40
46
|
if (styleId) opts.heading = styleId;
|
|
41
47
|
else if (level) opts.heading = HEADING_COMPILE_MAP[level] ?? "Heading1";
|
|
@@ -71,12 +77,26 @@ function parseDocx(opts) {
|
|
|
71
77
|
}
|
|
72
78
|
return attrs;
|
|
73
79
|
}
|
|
74
|
-
const attrNative = () => ({
|
|
75
|
-
default: null,
|
|
76
|
-
parseHTML: () => null,
|
|
77
|
-
rendered: false
|
|
78
|
-
});
|
|
79
80
|
const Heading = Heading$1.extend({
|
|
81
|
+
parseHTML() {
|
|
82
|
+
return [{
|
|
83
|
+
tag: "h6[data-heading-level]",
|
|
84
|
+
getAttrs: (el) => {
|
|
85
|
+
const level = Number(el.getAttribute("data-heading-level"));
|
|
86
|
+
return { level: Number.isInteger(level) && level >= 1 && level <= 9 ? level : 6 };
|
|
87
|
+
}
|
|
88
|
+
}, ...[
|
|
89
|
+
1,
|
|
90
|
+
2,
|
|
91
|
+
3,
|
|
92
|
+
4,
|
|
93
|
+
5,
|
|
94
|
+
6
|
|
95
|
+
].map((level) => ({
|
|
96
|
+
tag: `h${level}`,
|
|
97
|
+
attrs: { level }
|
|
98
|
+
}))];
|
|
99
|
+
},
|
|
80
100
|
addAttributes() {
|
|
81
101
|
return {
|
|
82
102
|
...this.parent?.(),
|
|
@@ -153,8 +173,10 @@ const Heading = Heading$1.extend({
|
|
|
153
173
|
const styleId = node.attrs.styleId;
|
|
154
174
|
if (styleId) attrs.class = `docx-style-${styleId}`;
|
|
155
175
|
if (styles.length > 0) attrs.style = styles.join(";");
|
|
176
|
+
const tag = level >= 1 && level <= 6 ? `h${level}` : "h6";
|
|
177
|
+
if (level >= 7) attrs["data-heading-level"] = String(level);
|
|
156
178
|
return [
|
|
157
|
-
|
|
179
|
+
tag,
|
|
158
180
|
attrs,
|
|
159
181
|
0
|
|
160
182
|
];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as Image, E as renderDocx, S as CropRenderContext, T as renderCropAttrs, w as parseDocx } from "../core-DRaLI8nd.mjs";
|
|
2
2
|
export { CropRenderContext, Image, parseDocx, renderCropAttrs, renderDocx };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createDocument, t as Document } from "../document-
|
|
2
|
-
import { c as PageBreak, f as docxExtensions, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, u as DocxKitOptions } from "../core-
|
|
3
|
-
import {
|
|
1
|
+
import { n as createDocument, t as Document } from "../document-Cws7XTYL.mjs";
|
|
2
|
+
import { c as PageBreak, f as docxExtensions, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, u as DocxKitOptions } from "../core-DRaLI8nd.mjs";
|
|
3
|
+
import { A as twipsToMm, S as sectionMarginCss, b as resolvePageSize, x as sectionLinePitchCss, y as resolveFontName } from "../utils-BJwDQts7.mjs";
|
|
4
4
|
export { Document, DocxKit, type DocxKitOptions, PageBreak, createDocument, docxExtensions, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Document, createDocument } from "./document.mjs";
|
|
1
|
+
import { _ as PageBreak, a as DocxKit, c as tiptapMarkExtensions, l as tiptapNodeExtensions, s as docxExtensions } from "../core-B8ba_FNi.mjs";
|
|
3
2
|
import { resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, twipsToMm } from "./utils.mjs";
|
|
3
|
+
import { Document, createDocument } from "./document.mjs";
|
|
4
4
|
export { Document, DocxKit, PageBreak, createDocument, docxExtensions, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as PageBreak } from "../core-
|
|
1
|
+
import { c as PageBreak } from "../core-DRaLI8nd.mjs";
|
|
2
2
|
export { PageBreak };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as PageBreak } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { PageBreak };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Paragraph as Paragraph$1 } from "./tiptap.mjs";
|
|
2
|
-
import { alignmentFromElement, bordersFromElement, indentFromElement, renderParagraphStyles, shadingFromElement, spacingFromElement } from "./utils.mjs";
|
|
2
|
+
import { alignmentFromElement, attrNative, bordersFromElement, indentFromElement, renderParagraphStyles, shadingFromElement, spacingFromElement } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/paragraph.ts
|
|
4
4
|
/**
|
|
5
5
|
* Paragraph extension with nested office-open attrs.
|
|
@@ -53,11 +53,6 @@ function parseDocx(opts) {
|
|
|
53
53
|
}
|
|
54
54
|
return attrs;
|
|
55
55
|
}
|
|
56
|
-
const attrNative = () => ({
|
|
57
|
-
default: null,
|
|
58
|
-
parseHTML: () => null,
|
|
59
|
-
rendered: false
|
|
60
|
-
});
|
|
61
56
|
const Paragraph = Paragraph$1.extend({
|
|
62
57
|
addAttributes() {
|
|
63
58
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as Passthrough } from "../core-DRaLI8nd.mjs";
|
|
2
2
|
export { Passthrough };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as Passthrough } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { Passthrough };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as SectionBreak } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { SectionBreak };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Strike as Strike$1 } from "./tiptap.mjs";
|
|
2
|
+
import { attrNative } from "./utils.mjs";
|
|
2
3
|
//#region src/extensions/strike.ts
|
|
3
4
|
/**
|
|
4
5
|
* Strike mark extension with nested office-open attrs.
|
|
@@ -31,11 +32,6 @@ function renderDocx(attrs) {
|
|
|
31
32
|
function parseDocx(runOpts) {
|
|
32
33
|
return { doubleStrike: runOpts.doubleStrike ?? null };
|
|
33
34
|
}
|
|
34
|
-
const attrNative = () => ({
|
|
35
|
-
default: null,
|
|
36
|
-
parseHTML: () => null,
|
|
37
|
-
rendered: false
|
|
38
|
-
});
|
|
39
35
|
const Strike = Strike$1.extend({
|
|
40
36
|
addAttributes() {
|
|
41
37
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TableCell as TableCell$1 } from "./tiptap.mjs";
|
|
2
|
-
import { bordersFromElement, renderTableCellStyles, shadingFromElement } from "./utils.mjs";
|
|
2
|
+
import { attrNative, bordersFromElement, renderTableCellStyles, shadingFromElement } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/table-cell.ts
|
|
4
4
|
/**
|
|
5
5
|
* Table cell extension with nested office-open attrs.
|
|
@@ -22,9 +22,9 @@ const SKIP_KEYS = new Set([
|
|
|
22
22
|
function renderDocx(node) {
|
|
23
23
|
const attrs = node.attrs ?? {};
|
|
24
24
|
const opts = {};
|
|
25
|
-
const colspan = attrs.colspan;
|
|
25
|
+
const colspan = typeof attrs.colspan === "number" ? attrs.colspan : void 0;
|
|
26
26
|
if (colspan && colspan > 1) opts.columnSpan = colspan;
|
|
27
|
-
const rowspan = attrs.rowspan;
|
|
27
|
+
const rowspan = typeof attrs.rowspan === "number" ? attrs.rowspan : void 0;
|
|
28
28
|
if (rowspan && rowspan > 1) opts.rowSpan = rowspan;
|
|
29
29
|
const colwidth = attrs.colwidth;
|
|
30
30
|
if (colwidth && colwidth.length > 0) {
|
|
@@ -55,11 +55,6 @@ function parseDocx(opts) {
|
|
|
55
55
|
}
|
|
56
56
|
return attrs;
|
|
57
57
|
}
|
|
58
|
-
const attrNative = () => ({
|
|
59
|
-
default: null,
|
|
60
|
-
parseHTML: () => null,
|
|
61
|
-
rendered: false
|
|
62
|
-
});
|
|
63
58
|
const TableCell = TableCell$1.extend({
|
|
64
59
|
addAttributes() {
|
|
65
60
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TableHeader as TableHeader$1 } from "./tiptap.mjs";
|
|
2
|
-
import { bordersFromElement, renderTableCellStyles, shadingFromElement } from "./utils.mjs";
|
|
2
|
+
import { attrNative, bordersFromElement, renderTableCellStyles, shadingFromElement } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/table-header.ts
|
|
4
4
|
/**
|
|
5
5
|
* Table header extension with nested office-open attrs (mirrors TableCell).
|
|
@@ -55,11 +55,6 @@ function parseDocx(opts) {
|
|
|
55
55
|
}
|
|
56
56
|
return attrs;
|
|
57
57
|
}
|
|
58
|
-
const attrNative = () => ({
|
|
59
|
-
default: null,
|
|
60
|
-
parseHTML: () => null,
|
|
61
|
-
rendered: false
|
|
62
|
-
});
|
|
63
58
|
const TableHeader = TableHeader$1.extend({
|
|
64
59
|
addAttributes() {
|
|
65
60
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TableRow as TableRow$1 } from "./tiptap.mjs";
|
|
2
|
-
import { cssToTwip } from "./utils.mjs";
|
|
2
|
+
import { attrNative, cssToTwip } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/table-row.ts
|
|
4
4
|
/**
|
|
5
5
|
* Table row extension with nested office-open attrs.
|
|
@@ -30,11 +30,6 @@ function parseDocx(opts) {
|
|
|
30
30
|
}
|
|
31
31
|
return attrs;
|
|
32
32
|
}
|
|
33
|
-
const attrNative = () => ({
|
|
34
|
-
default: null,
|
|
35
|
-
parseHTML: () => null,
|
|
36
|
-
rendered: false
|
|
37
|
-
});
|
|
38
33
|
const TableRow = TableRow$1.extend({
|
|
39
34
|
addAttributes() {
|
|
40
35
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Table as Table$1 } from "./tiptap.mjs";
|
|
2
|
-
import { alignmentFromElement, alignmentToCss, bordersFromElement, renderBorderCSS, shadingFromElement, shadingToCss, twipToCss } from "./utils.mjs";
|
|
2
|
+
import { alignmentFromElement, alignmentToCss, attrNative, bordersFromElement, renderBorderCSS, shadingFromElement, shadingToCss, twipToCss } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/table.ts
|
|
4
4
|
/**
|
|
5
5
|
* Table extension with nested office-open attrs.
|
|
@@ -28,11 +28,6 @@ function parseDocx(opts) {
|
|
|
28
28
|
}
|
|
29
29
|
return attrs;
|
|
30
30
|
}
|
|
31
|
-
const attrNative = () => ({
|
|
32
|
-
default: null,
|
|
33
|
-
parseHTML: () => null,
|
|
34
|
-
rendered: false
|
|
35
|
-
});
|
|
36
31
|
const Table = Table$1.extend({
|
|
37
32
|
addAttributes() {
|
|
38
33
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextStyle as TextStyle$1 } from "./tiptap.mjs";
|
|
2
|
-
import { characterSpacingFromCss, characterSpacingToCss, normalizeColorToHex, resolveFontFamilyCss, shadingFromCss, shadingToCss, sizeFromCss, sizeToCss } from "./utils.mjs";
|
|
2
|
+
import { attrNative, characterSpacingFromCss, characterSpacingToCss, normalizeColorToHex, resolveFontFamilyCss, shadingFromCss, shadingToCss, sizeFromCss, sizeToCss } from "./utils.mjs";
|
|
3
3
|
//#region src/extensions/text-style.ts
|
|
4
4
|
/**
|
|
5
5
|
* TextStyle mark with office-open attrs.
|
|
@@ -45,11 +45,6 @@ function parseDocx(opts) {
|
|
|
45
45
|
}
|
|
46
46
|
return attrs;
|
|
47
47
|
}
|
|
48
|
-
const attrNative = () => ({
|
|
49
|
-
default: null,
|
|
50
|
-
parseHTML: () => null,
|
|
51
|
-
rendered: false
|
|
52
|
-
});
|
|
53
48
|
const TextStyle = TextStyle$1.extend({
|
|
54
49
|
addAttributes() {
|
|
55
50
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { alignmentFromCss, alignmentFromElement, alignmentToCss, bordersFromElement, characterSpacingFromCss, characterSpacingToCss, cssToTwip, floatAnchorScope, floatingToStyles, indentFromElement, lineSpacingToCss, normalizeColorToHex, renderBorderCSS, renderParagraphStyles, renderRunStyles, renderTableCellStyles, resolveFontFamilyCss, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, shadingFromCss, shadingFromElement, shadingToCss, sizeFromCss, sizeToCss, spacingFromElement, twipToCss, twipsToMm };
|
|
1
|
+
import { A as twipsToMm, C as shadingFromCss, D as sizeToCss, E as sizeFromCss, O as spacingFromElement, S as sectionMarginCss, T as shadingToCss, _ as renderTableCellStyles, a as bordersFromElement, b as resolvePageSize, c as cssToTwip, d as indentFromElement, f as lineSpacingToCss, g as renderRunStyles, h as renderParagraphStyles, i as attrNative, k as twipToCss, l as floatAnchorScope, m as renderBorderCSS, n as alignmentFromElement, o as characterSpacingFromCss, p as normalizeColorToHex, r as alignmentToCss, s as characterSpacingToCss, t as alignmentFromCss, u as floatingToStyles, v as resolveFontFamilyCss, w as shadingFromElement, x as sectionLinePitchCss, y as resolveFontName } from "../utils-BJwDQts7.mjs";
|
|
2
|
+
export { alignmentFromCss, alignmentFromElement, alignmentToCss, attrNative, bordersFromElement, characterSpacingFromCss, characterSpacingToCss, cssToTwip, floatAnchorScope, floatingToStyles, indentFromElement, lineSpacingToCss, normalizeColorToHex, renderBorderCSS, renderParagraphStyles, renderRunStyles, renderTableCellStyles, resolveFontFamilyCss, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, shadingFromCss, shadingFromElement, shadingToCss, sizeFromCss, sizeToCss, spacingFromElement, twipToCss, twipsToMm };
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { sectionMarginDefaults, sectionPageSizeDefaults } from "@office-open/docx";
|
|
2
2
|
//#region src/extensions/utils.ts
|
|
3
|
+
/** Factory for a Tiptap attr that carries an office-open native value: never
|
|
4
|
+
* parsed from HTML nor rendered to it, defaulting to null (ProseMirror stores
|
|
5
|
+
* every declared attr). Shared by every extension carrying OOXML attrs
|
|
6
|
+
* (paragraph/heading/table/table-cell/…). */
|
|
7
|
+
const attrNative = () => ({
|
|
8
|
+
default: null,
|
|
9
|
+
parseHTML: () => null,
|
|
10
|
+
rendered: false
|
|
11
|
+
});
|
|
3
12
|
/** Common CSS named colors → hex */
|
|
4
13
|
const CSS_COLORS = {
|
|
5
14
|
black: "#000000",
|
|
@@ -496,4 +505,4 @@ function shadingFromElement(el) {
|
|
|
496
505
|
return shadingFromCss(el.style.backgroundColor || null);
|
|
497
506
|
}
|
|
498
507
|
//#endregion
|
|
499
|
-
export { alignmentFromCss, alignmentFromElement, alignmentToCss, bordersFromElement, characterSpacingFromCss, characterSpacingToCss, cssToTwip, floatAnchorScope, floatingToStyles, indentFromElement, lineSpacingToCss, normalizeColorToHex, renderBorderCSS, renderParagraphStyles, renderRunStyles, renderTableCellStyles, resolveFontFamilyCss, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, shadingFromCss, shadingFromElement, shadingToCss, sizeFromCss, sizeToCss, spacingFromElement, twipToCss, twipsToMm };
|
|
508
|
+
export { alignmentFromCss, alignmentFromElement, alignmentToCss, attrNative, bordersFromElement, characterSpacingFromCss, characterSpacingToCss, cssToTwip, floatAnchorScope, floatingToStyles, indentFromElement, lineSpacingToCss, normalizeColorToHex, renderBorderCSS, renderParagraphStyles, renderRunStyles, renderTableCellStyles, resolveFontFamilyCss, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, shadingFromCss, shadingFromElement, shadingToCss, sizeFromCss, sizeToCss, spacingFromElement, twipToCss, twipsToMm };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as renderWpsInterior, v as WpgGroup, x as renderWpsText, y as WpsData } from "../core-DRaLI8nd.mjs";
|
|
2
2
|
export { WpgGroup, WpsData, renderWpsInterior, renderWpsText };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as WpgGroup, f as renderWpsInterior, p as renderWpsText } from "../core-
|
|
1
|
+
import { d as WpgGroup, f as renderWpsInterior, p as renderWpsText } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { WpgGroup, renderWpsInterior, renderWpsText };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as WpsShape } from "../core-DRaLI8nd.mjs";
|
|
2
2
|
export { WpsShape };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { u as WpsShape } from "../core-
|
|
1
|
+
import { u as WpsShape } from "../core-B8ba_FNi.mjs";
|
|
2
2
|
export { WpsShape };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as createDocument, t as Document } from "./document-
|
|
2
|
-
import { a as JSONContent, c as PageBreak, f as docxExtensions, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, t as AnyExtension, u as DocxKitOptions } from "./core-
|
|
3
|
-
import {
|
|
1
|
+
import { n as createDocument, t as Document } from "./document-Cws7XTYL.mjs";
|
|
2
|
+
import { a as JSONContent, c as PageBreak, f as docxExtensions, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, t as AnyExtension, u as DocxKitOptions } from "./core-DRaLI8nd.mjs";
|
|
3
|
+
import { A as twipsToMm, S as sectionMarginCss, b as resolvePageSize, x as sectionLinePitchCss, y as resolveFontName } from "./utils-BJwDQts7.mjs";
|
|
4
4
|
import { ImageFetchHandler, PrepareStep, fetchImageHandler, prepareDocument, prepareImages } from "./converters/prepare.mjs";
|
|
5
5
|
import { DocxGenerateOptions, DocxManager, compileDocument, generateDOCX, generateDOCXStream, generateDOCXSync, parseDOCX, resolveDocument } from "./converters/docx.mjs";
|
|
6
6
|
import { generateHTML, parseHTML } from "./converters/html.mjs";
|
|
@@ -175,7 +175,7 @@ interface ParagraphNode extends TiptapJSONContent {
|
|
|
175
175
|
interface HeadingNode extends TiptapJSONContent {
|
|
176
176
|
type: "heading";
|
|
177
177
|
attrs: {
|
|
178
|
-
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
178
|
+
level: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
179
179
|
} & ParagraphAttrs;
|
|
180
180
|
content?: Array<TextNode | HardBreakNode>;
|
|
181
181
|
}
|
|
@@ -308,6 +308,19 @@ interface DetailsNode extends TiptapJSONContent {
|
|
|
308
308
|
type: "details";
|
|
309
309
|
content?: Array<DetailsSummaryNode | DetailsContentNode>;
|
|
310
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* TOC field node (`tocField`) — a block container whose `content` is the
|
|
313
|
+
* editable TOC entry paragraphs. `attrs.options` carries the TOC field switches
|
|
314
|
+
* (hyperlink, headingStyleRange, …). Named `tocField` (not `tableOfContents`)
|
|
315
|
+
* to avoid the @tiptap/extension-table-of-contents name. See TocField extension.
|
|
316
|
+
*/
|
|
317
|
+
interface TocFieldNode extends TiptapJSONContent {
|
|
318
|
+
type: "tocField";
|
|
319
|
+
attrs?: {
|
|
320
|
+
options: Record<string, unknown> | null;
|
|
321
|
+
};
|
|
322
|
+
content?: Array<BlockNode>;
|
|
323
|
+
}
|
|
311
324
|
interface DetailsSummaryNode extends TiptapJSONContent {
|
|
312
325
|
type: "detailsSummary";
|
|
313
326
|
content?: Array<TextNode | HardBreakNode>;
|
|
@@ -317,6 +330,6 @@ interface DetailsContentNode extends TiptapJSONContent {
|
|
|
317
330
|
content?: Array<BlockNode>;
|
|
318
331
|
}
|
|
319
332
|
type InlineContent = TextNode | HardBreakNode | ImageNode | EmojiNode | PageBreakNode | ColumnBreakNode | MentionNode | InlineMathNode;
|
|
320
|
-
type BlockNode = ParagraphNode | HeadingNode | BlockquoteNode | CodeBlockNode | HorizontalRuleNode | BulletListNode | OrderedListNode | TaskListNode | TableNode | WpsShapeNode | WpgGroupNode | DetailsNode | PassthroughNode | BlockMathNode;
|
|
333
|
+
type BlockNode = ParagraphNode | HeadingNode | BlockquoteNode | CodeBlockNode | HorizontalRuleNode | BulletListNode | OrderedListNode | TaskListNode | TableNode | WpsShapeNode | WpgGroupNode | DetailsNode | TocFieldNode | PassthroughNode | BlockMathNode;
|
|
321
334
|
//#endregion
|
|
322
|
-
export { type AlignmentType, type AnyExtension, type AttrNullable, type BlockMathNode, type BlockNode, type BlockquoteNode, type BookmarkOptions, type BorderOptions, type BordersOptions, type BulletListNode, type CodeBlockNode, type ColumnBreakNode, type DetailsContentNode, type DetailsNode, type DetailsSummaryNode, Document, type DocumentOptions, type DocxEditorOptions, type DocxGenerateOptions, DocxKit, type DocxKitOptions, DocxManager, type DocxPatchContent, type DocxPatchOptions, type EmojiAttrs, type EmojiNode, type EmphasisMarkType, type ExternalHyperlinkOptions, type Floating, type FontAttributesProperties, type FrameOptions, type HardBreakNode, type HeaderFooterSlots, type HeadingLevel, type HeadingNode, type HeightRule, type HighlightColor, type HorizontalRuleNode, type ImageAttrs, type ImageFetchHandler, type ImageNode, type ImageOptions, type IndentAttributesProperties, type InlineContent, type InlineMathNode, type InternalHyperlinkOptions, type JSONContent, type LeaderType, type LevelParagraphStylePropertiesOptions, type LineRuleType, type LinkAttrs, type ListItemNode, type Margins, type Mark, type MathAttrs, type MathInput, type MediaTransformation, type MentionAttrs, type MentionNode, type OrderedListNode, PageBreak, type PageBreakNode, type ParagraphAttrs, type ParagraphChild, type ParagraphNode, type ParagraphOptions, type ParagraphPropertiesOptions, type ParagraphPropertiesOptionsBase, type ParagraphRunPropertiesOptions, type ParagraphStylePropertiesOptions, type PassthroughNode, type PrepareStep, type QuickStyleEntry, type RubyOptions, type RunOptions, type RunPropertiesOptions, type RunStylePropertiesOptions, type SectionChild, type SectionOptions, type SectionPropertiesOptions, type ShadingAttributesProperties, type SpacingProperties, type StrikeAttrs, type StylesOptions, type TabStopDefinition, type TabStopPosition, type TabStopType, type TableAttrs, type TableBordersOptions, type TableCellAttrs, type TableCellBordersOptions, type TableCellNode, type TableCellOptions, type TableFloatOptions, type TableHeaderNode, type TableLayoutType, type TableLookOptions, type TableNode, type TableOptions, type TableRowAttrs, type TableRowNode, type TableRowOptions, type TableRowPropertiesOptionsBase, type TableVerticalAlign, type TableWidthProperties, type TaskItemNode, type TaskListNode, type TextAlignmentType, type TextNode, type TextStyleAttrs, type UnderlineType, type WidthType, type WpgGroupNode, type WpsShapeNode, compileDocument, convertMillimetersToTwip, createDocument, createDocxEditor, docxExtensions, effectiveRunProps, fetchImageHandler, generateDOCX, generateDOCXStream, generateDOCXSync, generateHTML, generateMarkdown, inlineStyles, parseDOCX, parseHTML, parseMarkdown, patchDOCX, prepareDocument, prepareImages, quickStyles, resolveDocument, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, sectionMarginDefaults, sectionPageSizeDefaults, stylesToCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
|
|
335
|
+
export { type AlignmentType, type AnyExtension, type AttrNullable, type BlockMathNode, type BlockNode, type BlockquoteNode, type BookmarkOptions, type BorderOptions, type BordersOptions, type BulletListNode, type CodeBlockNode, type ColumnBreakNode, type DetailsContentNode, type DetailsNode, type DetailsSummaryNode, Document, type DocumentOptions, type DocxEditorOptions, type DocxGenerateOptions, DocxKit, type DocxKitOptions, DocxManager, type DocxPatchContent, type DocxPatchOptions, type EmojiAttrs, type EmojiNode, type EmphasisMarkType, type ExternalHyperlinkOptions, type Floating, type FontAttributesProperties, type FrameOptions, type HardBreakNode, type HeaderFooterSlots, type HeadingLevel, type HeadingNode, type HeightRule, type HighlightColor, type HorizontalRuleNode, type ImageAttrs, type ImageFetchHandler, type ImageNode, type ImageOptions, type IndentAttributesProperties, type InlineContent, type InlineMathNode, type InternalHyperlinkOptions, type JSONContent, type LeaderType, type LevelParagraphStylePropertiesOptions, type LineRuleType, type LinkAttrs, type ListItemNode, type Margins, type Mark, type MathAttrs, type MathInput, type MediaTransformation, type MentionAttrs, type MentionNode, type OrderedListNode, PageBreak, type PageBreakNode, type ParagraphAttrs, type ParagraphChild, type ParagraphNode, type ParagraphOptions, type ParagraphPropertiesOptions, type ParagraphPropertiesOptionsBase, type ParagraphRunPropertiesOptions, type ParagraphStylePropertiesOptions, type PassthroughNode, type PrepareStep, type QuickStyleEntry, type RubyOptions, type RunOptions, type RunPropertiesOptions, type RunStylePropertiesOptions, type SectionChild, type SectionOptions, type SectionPropertiesOptions, type ShadingAttributesProperties, type SpacingProperties, type StrikeAttrs, type StylesOptions, type TabStopDefinition, type TabStopPosition, type TabStopType, type TableAttrs, type TableBordersOptions, type TableCellAttrs, type TableCellBordersOptions, type TableCellNode, type TableCellOptions, type TableFloatOptions, type TableHeaderNode, type TableLayoutType, type TableLookOptions, type TableNode, type TableOptions, type TableRowAttrs, type TableRowNode, type TableRowOptions, type TableRowPropertiesOptionsBase, type TableVerticalAlign, type TableWidthProperties, type TaskItemNode, type TaskListNode, type TextAlignmentType, type TextNode, type TextStyleAttrs, type TocFieldNode, type UnderlineType, type WidthType, type WpgGroupNode, type WpsShapeNode, compileDocument, convertMillimetersToTwip, createDocument, createDocxEditor, docxExtensions, effectiveRunProps, fetchImageHandler, generateDOCX, generateDOCXStream, generateDOCXSync, generateHTML, generateMarkdown, inlineStyles, parseDOCX, parseHTML, parseMarkdown, patchDOCX, prepareDocument, prepareImages, quickStyles, resolveDocument, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, sectionMarginDefaults, sectionPageSizeDefaults, stylesToCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Document, createDocument } from "./extensions/document.mjs";
|
|
1
|
+
import { _ as PageBreak, a as DocxKit, c as tiptapMarkExtensions, l as tiptapNodeExtensions, s as docxExtensions } from "./core-B8ba_FNi.mjs";
|
|
3
2
|
import { resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, twipsToMm } from "./extensions/utils.mjs";
|
|
3
|
+
import { Document, createDocument } from "./extensions/document.mjs";
|
|
4
4
|
import { createDocxEditor } from "./editor.mjs";
|
|
5
5
|
import { fetchImageHandler, prepareDocument, prepareImages } from "./converters/prepare.mjs";
|
|
6
|
+
import { effectiveRunProps, inlineStyles, quickStyles, stylesToCss } from "./converters/styles.mjs";
|
|
6
7
|
import { DocxManager, compileDocument, generateDOCX, generateDOCXStream, generateDOCXSync, parseDOCX, resolveDocument } from "./converters/docx.mjs";
|
|
7
8
|
import { patchDOCX } from "./converters/patch.mjs";
|
|
8
9
|
import { generateHTML, parseHTML } from "./converters/html.mjs";
|
|
9
10
|
import { generateMarkdown, parseMarkdown } from "./converters/markdown.mjs";
|
|
10
|
-
import { effectiveRunProps, inlineStyles, quickStyles, stylesToCss } from "./converters/styles.mjs";
|
|
11
11
|
import { sectionMarginDefaults, sectionPageSizeDefaults } from "@office-open/docx";
|
|
12
12
|
import { convertMillimetersToTwip } from "@office-open/core";
|
|
13
13
|
export { Document, DocxKit, DocxManager, PageBreak, compileDocument, convertMillimetersToTwip, createDocument, createDocxEditor, docxExtensions, effectiveRunProps, fetchImageHandler, generateDOCX, generateDOCXStream, generateDOCXSync, generateHTML, generateMarkdown, inlineStyles, parseDOCX, parseHTML, parseMarkdown, patchDOCX, prepareDocument, prepareImages, quickStyles, resolveDocument, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, sectionMarginDefaults, sectionPageSizeDefaults, stylesToCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { BorderOptions, BordersOptions, IndentAttributesProperties, ShadingAttributesProperties, SpacingProperties } from "@office-open/docx";
|
|
2
2
|
|
|
3
3
|
//#region src/extensions/utils.d.ts
|
|
4
|
+
/** Factory for a Tiptap attr that carries an office-open native value: never
|
|
5
|
+
* parsed from HTML nor rendered to it, defaulting to null (ProseMirror stores
|
|
6
|
+
* every declared attr). Shared by every extension carrying OOXML attrs
|
|
7
|
+
* (paragraph/heading/table/table-cell/…). */
|
|
8
|
+
declare const attrNative: () => {
|
|
9
|
+
default: null;
|
|
10
|
+
parseHTML: () => null;
|
|
11
|
+
rendered: boolean;
|
|
12
|
+
};
|
|
4
13
|
/** Normalize a CSS color value to hex (e.g., "red" → "#FF0000", "#ff0000" → "#FF0000").
|
|
5
14
|
* Accepts a string (CSS name/hex or bare OOXML hex), or an OOXML ColorOptions
|
|
6
15
|
* object ({ val, themeColor, themeTint, themeShade }) — the object form
|
|
@@ -125,4 +134,4 @@ declare function bordersFromElement(el: HTMLElement): BordersOptions | null;
|
|
|
125
134
|
/** Parse background-color → OOXML shading. */
|
|
126
135
|
declare function shadingFromElement(el: HTMLElement): ShadingAttributesProperties | null;
|
|
127
136
|
//#endregion
|
|
128
|
-
export {
|
|
137
|
+
export { twipsToMm as A, shadingFromCss as C, sizeToCss as D, sizeFromCss as E, spacingFromElement as O, sectionMarginCss as S, shadingToCss as T, renderTableCellStyles as _, bordersFromElement as a, resolvePageSize as b, cssToTwip as c, indentFromElement as d, lineSpacingToCss as f, renderRunStyles as g, renderParagraphStyles as h, attrNative as i, twipToCss as k, floatAnchorScope as l, renderBorderCSS as m, alignmentFromElement as n, characterSpacingFromCss as o, normalizeColorToHex as p, alignmentToCss as r, characterSpacingToCss as s, alignmentFromCss as t, floatingToStyles as u, resolveFontFamilyCss as v, shadingFromElement as w, sectionLinePitchCss as x, resolveFontName as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docen/docx",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "DOCX editor and converter powered by @office-open/docx with Tiptap editing layer, supporting bidirectional conversion between DOCX, HTML, and Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"converter",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@office-open/core": "0.10.
|
|
63
|
-
"@office-open/docx": "0.10.
|
|
62
|
+
"@office-open/core": "0.10.9",
|
|
63
|
+
"@office-open/docx": "0.10.9",
|
|
64
64
|
"@tiptap/core": "3.27.1",
|
|
65
65
|
"@tiptap/extension-blockquote": "3.27.1",
|
|
66
66
|
"@tiptap/extension-bold": "3.27.1",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/extensions/document.d.ts
|
|
2
|
-
declare function createDocument(content?: string): import("@tiptap/core").Node<any, any>;
|
|
3
|
-
/** Default flat Document (`doc > block+`) — the DOCX round-trip shape. */
|
|
4
|
-
declare const Document: import("@tiptap/core").Node<any, any>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { createDocument as n, Document as t };
|