@docen/docx 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{blockquote-DY80QC06.d.mts → blockquote-D-1aSxEn.d.mts} +5 -1
- package/dist/converters/docx.d.mts +40 -66
- package/dist/converters/docx.mjs +248 -665
- package/dist/converters/html.d.mts +1 -1
- package/dist/converters/html.mjs +3 -4
- 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 +58 -14
- package/dist/converters/styles.mjs +124 -16
- package/dist/{core-DC0_-WcE.d.mts → core-BqyLL84S.d.mts} +34 -13
- package/dist/{core-BnF8XhVE.mjs → core-wNNPJiKr.mjs} +357 -25
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/details-DsJhDP5K.d.mts +31 -0
- package/dist/editor.d.mts +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/extensions/blockquote.d.mts +2 -3
- package/dist/extensions/blockquote.mjs +50 -2
- package/dist/extensions/bullet-list.mjs +1 -1
- package/dist/extensions/code-block.d.mts +2 -2
- package/dist/extensions/code-block.mjs +51 -5
- package/dist/extensions/column-break.d.mts +2 -2
- package/dist/extensions/column-break.mjs +2 -2
- package/dist/extensions/details.d.mts +2 -3
- package/dist/extensions/details.mjs +48 -2
- package/dist/extensions/document.mjs +1 -1
- package/dist/extensions/extensions.d.mts +13 -9
- package/dist/extensions/extensions.mjs +7 -3
- package/dist/extensions/formatting-marks.d.mts +1 -1
- package/dist/extensions/formatting-marks.mjs +1 -1
- package/dist/extensions/heading.d.mts +2 -2
- package/dist/extensions/heading.mjs +61 -5
- package/dist/extensions/image.d.mts +2 -2
- package/dist/extensions/image.mjs +23 -4
- package/dist/extensions/index.d.mts +14 -10
- package/dist/extensions/index.mjs +8 -4
- package/dist/extensions/link.d.mts +2 -2
- package/dist/extensions/link.mjs +30 -2
- package/dist/extensions/list-aggregator.d.mts +8 -0
- package/dist/extensions/list-aggregator.mjs +2 -0
- package/dist/extensions/marks.d.mts +2 -0
- package/dist/extensions/marks.mjs +41 -0
- package/dist/extensions/mention.d.mts +2 -3
- package/dist/extensions/mention.mjs +16 -2
- package/dist/extensions/ordered-list.mjs +1 -1
- package/dist/extensions/page-break.d.mts +2 -2
- package/dist/extensions/page-break.mjs +2 -2
- package/dist/extensions/paragraph.mjs +3 -3
- package/dist/extensions/passthrough.d.mts +1 -1
- package/dist/extensions/passthrough.mjs +1 -1
- package/dist/extensions/scroll.d.mts +1 -1
- package/dist/extensions/scroll.mjs +30 -5
- package/dist/extensions/section-break.d.mts +1 -1
- package/dist/extensions/section-break.mjs +1 -1
- package/dist/extensions/strike.d.mts +2 -2
- package/dist/extensions/strike.mjs +5 -24
- package/dist/extensions/tab.d.mts +2 -2
- package/dist/extensions/tab.mjs +2 -2
- package/dist/extensions/table-cell.mjs +2 -2
- package/dist/extensions/table-header.mjs +2 -2
- package/dist/extensions/table-row.mjs +2 -2
- package/dist/extensions/table.d.mts +2 -2
- package/dist/extensions/table.mjs +122 -11
- package/dist/extensions/task-item.d.mts +2 -3
- package/dist/extensions/task-item.mjs +2 -2
- package/dist/extensions/text-style.d.mts +2 -2
- package/dist/extensions/text-style.mjs +27 -28
- package/dist/extensions/toc-field.d.mts +2 -2
- package/dist/extensions/toc-field.mjs +2 -2
- package/dist/extensions/track-change.d.mts +2 -0
- package/dist/extensions/track-change.mjs +2 -0
- package/dist/extensions/types.d.mts +127 -8
- package/dist/extensions/utils.d.mts +2 -2
- package/dist/extensions/utils.mjs +74 -1
- package/dist/extensions/wpg-group.d.mts +2 -2
- package/dist/extensions/wpg-group.mjs +2 -2
- package/dist/extensions/wps-shape.d.mts +2 -2
- package/dist/extensions/wps-shape.mjs +2 -2
- package/dist/heading-Bwpa8iZY.d.mts +24 -0
- package/dist/index.d.mts +29 -11
- package/dist/index.mjs +9 -5
- package/dist/{link-BawPjQZR.d.mts → link-gUqW45mE.d.mts} +3 -1
- package/dist/marks-Dz9Vb22Q.d.mts +10 -0
- package/dist/{mention-BGLzLVYw.d.mts → mention-CkONDrw9.d.mts} +5 -1
- package/dist/{scroll-ZNeThJsJ.d.mts → scroll-BARiZ5Gm.d.mts} +9 -3
- package/dist/strike-Brn9sWFy.d.mts +16 -0
- package/dist/table-CdcjR6HD.d.mts +18 -0
- package/dist/{task-item-B0ntvQ1Y.d.mts → task-item-CCAC4QLi.d.mts} +3 -1
- package/dist/text-style-BzfcbufI.d.mts +4 -0
- package/dist/{utils-BJwDQts7.d.mts → utils-CfwwOowz.d.mts} +25 -1
- package/package.json +1 -1
- package/dist/details-Dd5MqqmR.d.mts +0 -17
- package/dist/extensions/tiptap.d.mts +0 -2
- package/dist/extensions/tiptap.mjs +0 -31
- package/dist/heading-BvqBD2zX.d.mts +0 -8
- package/dist/strike-BgWGvjKr.d.mts +0 -33
- package/dist/table-BFkfeRp9.d.mts +0 -9
- package/dist/text-style-BHdtXkMb.d.mts +0 -8
- package/dist/tiptap-BKqn41uT.d.mts +0 -31
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { CodeBlockLowlight } from "
|
|
1
|
+
import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
|
|
2
2
|
//#region src/extensions/code-block.ts
|
|
3
3
|
/**
|
|
4
|
-
* CodeBlock extension — CodeBlockLowlight with a DOCX renderDocx.
|
|
4
|
+
* CodeBlock extension — CodeBlockLowlight with a DOCX renderDocx + parse rule.
|
|
5
5
|
*
|
|
6
6
|
* DOCX has no dedicated code-block element. A code block maps to a single
|
|
7
7
|
* paragraph styled "Code" with a monospace run font. Inline marks (syntax-
|
|
8
8
|
* highlight tokens) and line breaks (`\n` → `<w:br/>`) are handled by
|
|
9
9
|
* DocxManager's shared inline-content compilation; resolveCodeBlock reassembles
|
|
10
|
-
* the text. This module owns
|
|
10
|
+
* the text. This module owns the paragraph-level style + the parse rule that
|
|
11
|
+
* recognizes a "Code"-styled paragraph.
|
|
11
12
|
*
|
|
12
13
|
* `language` has no OOXML carrier and is intentionally dropped (known lossy).
|
|
13
14
|
*/
|
|
@@ -18,6 +19,51 @@ function renderDocx(_node) {
|
|
|
18
19
|
run: { font: "Consolas" }
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
/** ParagraphOptions styled "Code" → codeBlock node. Reassembles code: a break
|
|
23
|
+
* child → "\n" (merged into the previous text node), a text child keeps its
|
|
24
|
+
* run marks (syntax-highlight tokens). Mirrors the old resolveCodeBlock. */
|
|
25
|
+
function resolveCodeBlock(opts, ctx) {
|
|
26
|
+
const children = opts.children;
|
|
27
|
+
const content = [];
|
|
28
|
+
if (children) {
|
|
29
|
+
for (const child of children) if (typeof child === "string") {
|
|
30
|
+
if (child) content.push({
|
|
31
|
+
type: "text",
|
|
32
|
+
text: child
|
|
33
|
+
});
|
|
34
|
+
} else if (typeof child === "object" && child !== null) {
|
|
35
|
+
if ("break" in child) {
|
|
36
|
+
const prev = content[content.length - 1];
|
|
37
|
+
if (prev && prev.type === "text") prev.text = (prev.text ?? "") + "\n";
|
|
38
|
+
else content.push({
|
|
39
|
+
type: "text",
|
|
40
|
+
text: "\n"
|
|
41
|
+
});
|
|
42
|
+
} else if ("text" in child) {
|
|
43
|
+
const marks = ctx.resolveMarks(child);
|
|
44
|
+
const textNode = {
|
|
45
|
+
type: "text",
|
|
46
|
+
text: child.text
|
|
47
|
+
};
|
|
48
|
+
if (marks) textNode.marks = marks;
|
|
49
|
+
content.push(textNode);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} else if (opts.text) content.push({
|
|
53
|
+
type: "text",
|
|
54
|
+
text: opts.text
|
|
55
|
+
});
|
|
56
|
+
const node = { type: "codeBlock" };
|
|
57
|
+
if (content.length > 0) node.content = content;
|
|
58
|
+
return node;
|
|
59
|
+
}
|
|
60
|
+
const parseDocxParagraph = {
|
|
61
|
+
match: (para) => para.style === "Code",
|
|
62
|
+
convert: (para, ctx) => resolveCodeBlock(para, ctx)
|
|
63
|
+
};
|
|
64
|
+
const CodeBlock = CodeBlockLowlight.extend({
|
|
65
|
+
renderDocx,
|
|
66
|
+
parseDocxParagraph
|
|
67
|
+
});
|
|
22
68
|
//#endregion
|
|
23
|
-
export { CodeBlock, renderDocx };
|
|
69
|
+
export { CodeBlock, parseDocxParagraph, renderDocx };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ColumnBreak };
|
|
1
|
+
import { $ as parseDocxInline, Q as ColumnBreak } from "../core-BqyLL84S.mjs";
|
|
2
|
+
export { ColumnBreak, parseDocxInline };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ColumnBreak };
|
|
1
|
+
import { H as parseDocxInline, V as ColumnBreak } from "../core-wNNPJiKr.mjs";
|
|
2
|
+
export { ColumnBreak, parseDocxInline };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { DETAILS_SUMMARY_STYLE, DETAILS_TAG, Details, DetailsContent, DetailsSummary };
|
|
1
|
+
import { a as DetailsSummaryBase, i as DetailsContentBase, n as DETAILS_TAG, o as parseDocxBlock, r as Details, t as DETAILS_SUMMARY_STYLE } from "../details-DsJhDP5K.mjs";
|
|
2
|
+
export { DETAILS_SUMMARY_STYLE, DETAILS_TAG, Details, DetailsContentBase as DetailsContent, DetailsSummaryBase as DetailsSummary, parseDocxBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Details, DetailsContent, DetailsSummary } from "
|
|
1
|
+
import { Details as Details$1, DetailsContent as DetailsContentBase, DetailsSummary as DetailsSummaryBase } from "@tiptap/extension-details";
|
|
2
2
|
//#region src/extensions/details.ts
|
|
3
3
|
/**
|
|
4
4
|
* Details extension — owns the DOCX expression of a collapsible details block.
|
|
@@ -9,10 +9,56 @@ import { Details, DetailsContent, DetailsSummary } from "./tiptap.mjs";
|
|
|
9
9
|
* split it back out from the content paragraphs. Structure round-trips fully
|
|
10
10
|
* (summary + content); Word shows it expanded (no collapse) — an inherent
|
|
11
11
|
* DOCX limitation, not data loss.
|
|
12
|
+
*
|
|
13
|
+
* The `parseDocxBlock` rule (below) recognizes a details group-SDT during
|
|
14
|
+
* resolve and rebuilds the details/detailsSummary/detailsContent nodes; the
|
|
15
|
+
* extensions themselves carry no DOCX attrs of their own.
|
|
12
16
|
*/
|
|
13
17
|
/** SDT tag marking a details group content control. */
|
|
14
18
|
const DETAILS_TAG = "docen-details";
|
|
15
19
|
/** Paragraph style marking the summary line within a details group-SDT. */
|
|
16
20
|
const DETAILS_SUMMARY_STYLE = "DocenDetailsSummary";
|
|
21
|
+
/**
|
|
22
|
+
* Declarative block parse rule: recognize a group-SDT tagged "docen-details"
|
|
23
|
+
* and rebuild it as a details node (summary + content). DocxManager dispatches
|
|
24
|
+
* every SectionChild through this rule before the paragraph/passthrough
|
|
25
|
+
* fallbacks; a non-details SDT falls through to passthrough. */
|
|
26
|
+
const parseDocxBlock = {
|
|
27
|
+
match: (child) => "sdt" in child && child.sdt?.properties?.tag === "docen-details",
|
|
28
|
+
convert: (child, ctx) => resolveDetailsSdt(child.sdt, ctx)
|
|
29
|
+
};
|
|
30
|
+
/** Resolve a details group-SDT: the summary-style paragraph becomes
|
|
31
|
+
* detailsSummary, the remaining blocks fold into detailsContent. */
|
|
32
|
+
function resolveDetailsSdt(sdt, ctx) {
|
|
33
|
+
const content = [];
|
|
34
|
+
let summary = null;
|
|
35
|
+
for (const child of sdt.children ?? []) {
|
|
36
|
+
if ("paragraph" in child) {
|
|
37
|
+
const para = child.paragraph;
|
|
38
|
+
if (para.style === "DocenDetailsSummary") {
|
|
39
|
+
summary = ctx.resolveInlineContent(para);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const node = ctx.resolveBlock(child);
|
|
44
|
+
if (!node) continue;
|
|
45
|
+
if (Array.isArray(node)) content.push(...node);
|
|
46
|
+
else content.push(node);
|
|
47
|
+
}
|
|
48
|
+
const details = {
|
|
49
|
+
type: "details",
|
|
50
|
+
content: []
|
|
51
|
+
};
|
|
52
|
+
if (summary !== null) details.content.push({
|
|
53
|
+
type: "detailsSummary",
|
|
54
|
+
content: summary
|
|
55
|
+
});
|
|
56
|
+
if (content.length > 0) details.content.push({
|
|
57
|
+
type: "detailsContent",
|
|
58
|
+
content
|
|
59
|
+
});
|
|
60
|
+
return details;
|
|
61
|
+
}
|
|
62
|
+
const Details = Details$1.extend({ parseDocxBlock });
|
|
17
63
|
//#endregion
|
|
18
|
-
export { DETAILS_SUMMARY_STYLE, DETAILS_TAG, Details, DetailsContent, DetailsSummary };
|
|
64
|
+
export { DETAILS_SUMMARY_STYLE, DETAILS_TAG, Details, DetailsContentBase as DetailsContent, DetailsSummaryBase as DetailsSummary, parseDocxBlock };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Document as Document$1 } from "./tiptap.mjs";
|
|
2
1
|
import { attrNative } from "./utils.mjs";
|
|
2
|
+
import { Document as Document$1 } from "@tiptap/extension-document";
|
|
3
3
|
//#region src/extensions/document.ts
|
|
4
4
|
/**
|
|
5
5
|
* Document extension carrying DOCX document-level data through the Tiptap JSON
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Subscript, i as Italic, n as Code, o as Superscript, r as Highlight, s as Underline, t as Bold } from "../marks-Dz9Vb22Q.mjs";
|
|
2
2
|
import { n as createDocument, t as Document } from "../document-Cws7XTYL.mjs";
|
|
3
3
|
import { t as Paragraph } from "../paragraph-D8mpHo_o.mjs";
|
|
4
|
-
import { t as Heading } from "../heading-
|
|
4
|
+
import { t as Heading } from "../heading-Bwpa8iZY.mjs";
|
|
5
|
+
import { r as Blockquote } from "../blockquote-D-1aSxEn.mjs";
|
|
5
6
|
import { t as BulletList } from "../bullet-list-DF60pnSL.mjs";
|
|
6
7
|
import { r as OrderedList } from "../ordered-list-DFAe-YEV.mjs";
|
|
7
|
-
import { A as
|
|
8
|
-
import {
|
|
8
|
+
import { A as WpgGroup, B as PageBreak, D as Passthrough, E as InlinePassthrough, H as FormattingMarks, K as Image, M as WpsShapeStandalone, N as WpsShapeStyles, O as WpsShape, Q as ColumnBreak, S as Tab, U as Deletion, W as Insertion, Z as SectionBreak, _ as Text, b as tiptapMarkExtensions, c as CodeBlockLowlight, d as Emoji, et as CodeBlock, f as HardBreak, g as TaskList, h as Mathematics, l as DocxKit, m as ListItem, p as HorizontalRule, u as DocxKitOptions, v as TextAlign, w as TocField, x as tiptapNodeExtensions, y as docxExtensions, z as wpsShapeStyles } from "../core-BqyLL84S.mjs";
|
|
9
|
+
import { a as DetailsSummaryBase, i as DetailsContentBase, r as Details } from "../details-DsJhDP5K.mjs";
|
|
10
|
+
import { n as TaskItemBase } from "../task-item-CCAC4QLi.mjs";
|
|
11
|
+
import { n as Mention } from "../mention-CkONDrw9.mjs";
|
|
12
|
+
import { t as Table } from "../table-CdcjR6HD.mjs";
|
|
9
13
|
import { t as TableRow } from "../table-row-kgzYkZlW.mjs";
|
|
10
14
|
import { t as TableCell } from "../table-cell-D_FV4D2h.mjs";
|
|
11
15
|
import { t as TableHeader } from "../table-header-KGQ2aEkP.mjs";
|
|
12
|
-
import { t as Link } from "../link-
|
|
13
|
-
import { t as Strike } from "../strike-
|
|
14
|
-
import { t as TextStyle } from "../text-style-
|
|
15
|
-
import { n as scrollContainerOf, t as scrollCaretToTop } from "../scroll-
|
|
16
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Details, DetailsContent, DetailsSummary, Document, DocxKit, DocxKitOptions, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, type WpsShapeStandalone, type WpsShapeStyles, createDocument, docxExtensions, scrollCaretToTop, scrollContainerOf, tiptapMarkExtensions, tiptapNodeExtensions, wpsShapeStyles };
|
|
16
|
+
import { t as Link } from "../link-gUqW45mE.mjs";
|
|
17
|
+
import { t as Strike } from "../strike-Brn9sWFy.mjs";
|
|
18
|
+
import { t as TextStyle } from "../text-style-BzfcbufI.mjs";
|
|
19
|
+
import { n as scrollContainerOf, t as scrollCaretToTop } from "../scroll-BARiZ5Gm.mjs";
|
|
20
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Deletion, Details, DetailsContentBase as DetailsContent, DetailsSummaryBase as DetailsSummary, Document, DocxKit, DocxKitOptions, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Insertion, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItemBase as TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, type WpsShapeStandalone, type WpsShapeStyles, createDocument, docxExtensions, scrollCaretToTop, scrollContainerOf, tiptapMarkExtensions, tiptapNodeExtensions, wpsShapeStyles };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { Blockquote
|
|
1
|
+
import { Blockquote } from "./blockquote.mjs";
|
|
2
2
|
import { BulletList } from "./bullet-list.mjs";
|
|
3
3
|
import { CodeBlock } from "./code-block.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { B as FormattingMarks, D as Deletion, E as wpsShapeStyles, F as Passthrough, I as PageBreak, N as SectionBreak, O as Insertion, P as InlinePassthrough, V as ColumnBreak, _ as tiptapNodeExtensions, a as CodeBlockLowlight, b as WpgGroup, c as HardBreak, d as Mathematics, f as TaskList, g as tiptapMarkExtensions, h as docxExtensions, j as Tab, k as TocField, l as HorizontalRule, m as TextAlign, o as DocxKit, p as Text, s as Emoji, u as ListItem, v as WpsShape } from "../core-wNNPJiKr.mjs";
|
|
5
|
+
import { Details, DetailsContent as DetailsContentBase, DetailsSummary as DetailsSummaryBase } from "./details.mjs";
|
|
5
6
|
import { Document, createDocument } from "./document.mjs";
|
|
6
7
|
import { Heading } from "./heading.mjs";
|
|
7
8
|
import { Image } from "./image.mjs";
|
|
8
9
|
import { scrollCaretToTop, scrollContainerOf } from "./scroll.mjs";
|
|
9
10
|
import { Link } from "./link.mjs";
|
|
11
|
+
import { TaskItem as TaskItemBase } from "./task-item.mjs";
|
|
12
|
+
import { Bold, Code, Highlight, Italic, Subscript, Superscript, Underline } from "./marks.mjs";
|
|
13
|
+
import { Mention } from "./mention.mjs";
|
|
10
14
|
import { OrderedList } from "./ordered-list.mjs";
|
|
11
15
|
import { Paragraph } from "./paragraph.mjs";
|
|
12
16
|
import { Strike } from "./strike.mjs";
|
|
@@ -15,4 +19,4 @@ import { TableCell } from "./table-cell.mjs";
|
|
|
15
19
|
import { TableHeader } from "./table-header.mjs";
|
|
16
20
|
import { TableRow } from "./table-row.mjs";
|
|
17
21
|
import { TextStyle } from "./text-style.mjs";
|
|
18
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Details, DetailsContent, DetailsSummary, Document, DocxKit, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, createDocument, docxExtensions, scrollCaretToTop, scrollContainerOf, tiptapMarkExtensions, tiptapNodeExtensions, wpsShapeStyles };
|
|
22
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Deletion, Details, DetailsContentBase as DetailsContent, DetailsSummaryBase as DetailsSummary, Document, DocxKit, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Insertion, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItemBase as TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, createDocument, docxExtensions, scrollCaretToTop, scrollContainerOf, tiptapMarkExtensions, tiptapNodeExtensions, wpsShapeStyles };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as FormattingMarks } from "../core-BqyLL84S.mjs";
|
|
2
2
|
export { FormattingMarks };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as FormattingMarks } from "../core-wNNPJiKr.mjs";
|
|
2
2
|
export { FormattingMarks };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export { Heading, parseDocx, renderDocx };
|
|
1
|
+
import { a as renderDocx, i as parseDocxParagraph, n as detectHeadingLevel, r as parseDocx, t as Heading } from "../heading-Bwpa8iZY.mjs";
|
|
2
|
+
export { Heading, detectHeadingLevel, parseDocx, parseDocxParagraph, renderDocx };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Heading as Heading$1 } from "./tiptap.mjs";
|
|
2
1
|
import { alignmentFromElement, attrNative, bordersFromElement, indentFromElement, renderParagraphStyles, shadingFromElement, spacingFromElement } from "./utils.mjs";
|
|
2
|
+
import { buildTextBlock, indexParagraphStyles } from "../converters/styles.mjs";
|
|
3
|
+
import { Heading as Heading$1 } from "@tiptap/extension-heading";
|
|
3
4
|
//#region src/extensions/heading.ts
|
|
4
5
|
/**
|
|
5
6
|
* Heading extension with nested office-open attrs (mirrors Paragraph).
|
|
@@ -34,10 +35,64 @@ const HEADING_PARSE_MAP = {
|
|
|
34
35
|
Heading9: 9,
|
|
35
36
|
Title: 1
|
|
36
37
|
};
|
|
38
|
+
/** Heading level (1-9) from a localized style NAME: "heading 1"/"标题 1" → 1,
|
|
39
|
+
* "title" → 1. office-open's built-in names are English ("heading 1"), but
|
|
40
|
+
* zh-CN Word labels the same styles "标题 1"; both map to the same level. */
|
|
41
|
+
function headingLevelFromName(name) {
|
|
42
|
+
if (!name) return void 0;
|
|
43
|
+
const m = /^heading\s+(\d)$/i.exec(name) ?? /^标题\s*(\d)$/.exec(name);
|
|
44
|
+
if (m) {
|
|
45
|
+
const lvl = Number(m[1]);
|
|
46
|
+
if (lvl >= 1 && lvl <= 9) return lvl;
|
|
47
|
+
}
|
|
48
|
+
return /^title$/i.test(name) ? 1 : void 0;
|
|
49
|
+
}
|
|
50
|
+
/** Heading level (1-9) for a paragraph, or undefined when it isn't a heading.
|
|
51
|
+
* DOCX marks a heading several ways, checked in priority order:
|
|
52
|
+
* 1. office-open lifts a HeadingLevel pStyle ("Heading1".."Title") into `heading`.
|
|
53
|
+
* 2. An explicit `outlineLevel` (0-8 → 1-9) — Word's outline/TOC key off this
|
|
54
|
+
* even without a heading pStyle; the Heading1-9 styles carry outlineLvl 0-8.
|
|
55
|
+
* 3. A pStyle that names a heading style: directly ("Heading7", which stays on
|
|
56
|
+
* `style` because office-open's HeadingLevel type caps at 6), by localized
|
|
57
|
+
* NAME ("heading 1"/"标题 1"), or via the `basedOn` chain (a custom style
|
|
58
|
+
* "MyTitle" basedOn="Heading1"). `heading` and `style` carry the same pStyle.
|
|
59
|
+
* `outlineLevel` is read loosely — office-open's public type omits the field
|
|
60
|
+
* even though it round-trips (w:outlineLvl) at runtime. Pure (no `this`):
|
|
61
|
+
* resolved + the document styles snapshot are all it reads. */
|
|
62
|
+
function detectHeadingLevel(resolved, styles) {
|
|
63
|
+
if (resolved.heading) {
|
|
64
|
+
const lvl = HEADING_PARSE_MAP[resolved.heading];
|
|
65
|
+
if (lvl) return lvl;
|
|
66
|
+
}
|
|
67
|
+
const outline = resolved.outlineLevel;
|
|
68
|
+
if (typeof outline === "number" && outline >= 0 && outline <= 8) return outline + 1;
|
|
69
|
+
const styleId = resolved.style;
|
|
70
|
+
if (!styleId || !styles) return void 0;
|
|
71
|
+
const byId = indexParagraphStyles(styles);
|
|
72
|
+
const visited = /* @__PURE__ */ new Set();
|
|
73
|
+
let curId = styleId;
|
|
74
|
+
while (curId && !visited.has(curId)) {
|
|
75
|
+
visited.add(curId);
|
|
76
|
+
if (HEADING_PARSE_MAP[curId]) return HEADING_PARSE_MAP[curId];
|
|
77
|
+
const style = byId.get(curId);
|
|
78
|
+
if (!style) break;
|
|
79
|
+
const lvl = headingLevelFromName(style.name);
|
|
80
|
+
if (lvl) return lvl;
|
|
81
|
+
curId = style.basedOn ?? void 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const parseDocxParagraph = {
|
|
85
|
+
match: (para, ctx) => detectHeadingLevel(para, ctx.styles) != null,
|
|
86
|
+
convert: (para, ctx) => {
|
|
87
|
+
const level = detectHeadingLevel(para, ctx.styles);
|
|
88
|
+
if (!level) return null;
|
|
89
|
+
return buildTextBlock("heading", para, ctx, level);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
37
92
|
/** Runtime-only attrs the TableOfContents extension injects on each heading
|
|
38
93
|
* (`id` / `data-toc-id`). They are regenerated on every load, so never persist
|
|
39
94
|
* them to DOCX — skip them in renderDocx. */
|
|
40
|
-
const TOC_RUNTIME_KEYS = new Set(["id", "data-toc-id"]);
|
|
95
|
+
const TOC_RUNTIME_KEYS = /* @__PURE__ */ new Set(["id", "data-toc-id"]);
|
|
41
96
|
function renderDocx(node) {
|
|
42
97
|
const attrs = node.attrs ?? {};
|
|
43
98
|
const opts = {};
|
|
@@ -52,7 +107,7 @@ function renderDocx(node) {
|
|
|
52
107
|
return opts;
|
|
53
108
|
}
|
|
54
109
|
/** Structural/semantic keys expressed elsewhere (heading handled separately, list handling, run children). */
|
|
55
|
-
const SKIP_KEYS = new Set([
|
|
110
|
+
const SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
56
111
|
"heading",
|
|
57
112
|
"style",
|
|
58
113
|
"bullet",
|
|
@@ -182,7 +237,8 @@ const Heading = Heading$1.extend({
|
|
|
182
237
|
];
|
|
183
238
|
},
|
|
184
239
|
renderDocx,
|
|
185
|
-
parseDocx
|
|
240
|
+
parseDocx,
|
|
241
|
+
parseDocxParagraph
|
|
186
242
|
});
|
|
187
243
|
//#endregion
|
|
188
|
-
export { Heading, parseDocx, renderDocx };
|
|
244
|
+
export { Heading, detectHeadingLevel, parseDocx, parseDocxParagraph, renderDocx };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { CropRenderContext, Image, parseDocx, renderCropAttrs, renderDocx };
|
|
1
|
+
import { G as CropRenderContext, J as parseDocxInline, K as Image, X as renderDocx, Y as renderCropAttrs, q as parseDocx } from "../core-BqyLL84S.mjs";
|
|
2
|
+
export { CropRenderContext, Image, parseDocx, parseDocxInline, renderCropAttrs, renderDocx };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Image as Image$1 } from "./tiptap.mjs";
|
|
2
1
|
import { floatAnchorScope, floatingToStyles } from "./utils.mjs";
|
|
3
|
-
import { convertEmuToPixels } from "@office-open/core";
|
|
2
|
+
import { convertEmuToPixels, encodeBase64 } from "@office-open/core";
|
|
3
|
+
import { Image as Image$1 } from "@tiptap/extension-image";
|
|
4
4
|
//#region src/extensions/image.ts
|
|
5
5
|
/**
|
|
6
6
|
* Custom Image extension with node-level renderHTML + renderDocx/parseDocx.
|
|
@@ -117,6 +117,24 @@ function parseDocx(imageOpts) {
|
|
|
117
117
|
if (opts.runPropertiesRawXml) attrs.runPropertiesRawXml = opts.runPropertiesRawXml;
|
|
118
118
|
return attrs;
|
|
119
119
|
}
|
|
120
|
+
/** ParagraphChild `{ image: ImageOptions }` → image node. Mirrors the old
|
|
121
|
+
* DocxManager.resolveImage: reflective attrs parse, then rebuild the data URL
|
|
122
|
+
* from the embedded bytes (encodeBase64 handles platform dispatch + stack
|
|
123
|
+
* guard). */
|
|
124
|
+
function resolveImage(imageOpts, ctx) {
|
|
125
|
+
const attrs = ctx.parseNodeAttrs("image", imageOpts);
|
|
126
|
+
const data = imageOpts.data;
|
|
127
|
+
const type = imageOpts.type;
|
|
128
|
+
if (data && type) attrs.src = `data:image/${type};base64,${encodeBase64(data instanceof ArrayBuffer ? new Uint8Array(data) : data)}`;
|
|
129
|
+
return {
|
|
130
|
+
type: "image",
|
|
131
|
+
attrs
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const parseDocxInline = {
|
|
135
|
+
match: (child) => "image" in child,
|
|
136
|
+
convert: (child, ctx) => resolveImage(child.image, ctx)
|
|
137
|
+
};
|
|
120
138
|
/**
|
|
121
139
|
* Render crop as the inner <img> style for byte-accurate four-sided srcRect.
|
|
122
140
|
*
|
|
@@ -362,7 +380,8 @@ const Image = Image$1.extend({
|
|
|
362
380
|
];
|
|
363
381
|
},
|
|
364
382
|
renderDocx,
|
|
365
|
-
parseDocx
|
|
383
|
+
parseDocx,
|
|
384
|
+
parseDocxInline
|
|
366
385
|
});
|
|
367
386
|
/**
|
|
368
387
|
* Reverse-parse a cropped span[extent-box] back into image attrs.
|
|
@@ -409,4 +428,4 @@ function parseVectorDiv(el) {
|
|
|
409
428
|
return attrs;
|
|
410
429
|
}
|
|
411
430
|
//#endregion
|
|
412
|
-
export { Image, parseDocx, renderCropAttrs, renderDocx };
|
|
431
|
+
export { Image, parseDocx, parseDocxInline, renderCropAttrs, renderDocx };
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Subscript, i as Italic, n as Code, o as Superscript, r as Highlight, s as Underline, t as Bold } from "../marks-Dz9Vb22Q.mjs";
|
|
2
2
|
import { n as createDocument, t as Document } from "../document-Cws7XTYL.mjs";
|
|
3
3
|
import { t as Paragraph } from "../paragraph-D8mpHo_o.mjs";
|
|
4
|
-
import { t as Heading } from "../heading-
|
|
4
|
+
import { t as Heading } from "../heading-Bwpa8iZY.mjs";
|
|
5
|
+
import { r as Blockquote } from "../blockquote-D-1aSxEn.mjs";
|
|
5
6
|
import { t as BulletList } from "../bullet-list-DF60pnSL.mjs";
|
|
6
7
|
import { r as OrderedList } from "../ordered-list-DFAe-YEV.mjs";
|
|
7
|
-
import { A as
|
|
8
|
-
import {
|
|
8
|
+
import { A as WpgGroup, B as PageBreak, D as Passthrough, E as InlinePassthrough, H as FormattingMarks, K as Image, M as WpsShapeStandalone, N as WpsShapeStyles, O as WpsShape, Q as ColumnBreak, S as Tab, U as Deletion, W as Insertion, Z as SectionBreak, _ as Text, b as tiptapMarkExtensions, c as CodeBlockLowlight, d as Emoji, et as CodeBlock, f as HardBreak, g as TaskList, h as Mathematics, l as DocxKit, m as ListItem, p as HorizontalRule, u as DocxKitOptions, v as TextAlign, w as TocField, x as tiptapNodeExtensions, y as docxExtensions, z as wpsShapeStyles } from "../core-BqyLL84S.mjs";
|
|
9
|
+
import { a as DetailsSummaryBase, i as DetailsContentBase, r as Details } from "../details-DsJhDP5K.mjs";
|
|
10
|
+
import { n as TaskItemBase } from "../task-item-CCAC4QLi.mjs";
|
|
11
|
+
import { n as Mention } from "../mention-CkONDrw9.mjs";
|
|
12
|
+
import { t as Table } from "../table-CdcjR6HD.mjs";
|
|
9
13
|
import { t as TableRow } from "../table-row-kgzYkZlW.mjs";
|
|
10
14
|
import { t as TableCell } from "../table-cell-D_FV4D2h.mjs";
|
|
11
15
|
import { t as TableHeader } from "../table-header-KGQ2aEkP.mjs";
|
|
12
|
-
import { t as Link } from "../link-
|
|
13
|
-
import { t as Strike } from "../strike-
|
|
14
|
-
import { t as TextStyle } from "../text-style-
|
|
15
|
-
import { n as scrollContainerOf, t as scrollCaretToTop } from "../scroll-
|
|
16
|
-
import {
|
|
17
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Details, DetailsContent, DetailsSummary, Document, DocxKit, DocxKitOptions, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, type WpsShapeStandalone, type WpsShapeStyles, createDocument, docxExtensions, resolveFontName, resolvePageSize, scrollCaretToTop, scrollContainerOf, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm, wpsShapeStyles };
|
|
16
|
+
import { t as Link } from "../link-gUqW45mE.mjs";
|
|
17
|
+
import { t as Strike } from "../strike-Brn9sWFy.mjs";
|
|
18
|
+
import { t as TextStyle } from "../text-style-BzfcbufI.mjs";
|
|
19
|
+
import { n as scrollContainerOf, t as scrollCaretToTop } from "../scroll-BARiZ5Gm.mjs";
|
|
20
|
+
import { S as sectionMarginCss, b as resolvePageSize, j as twipsToMm, x as sectionLinePitchCss, y as resolveFontName } from "../utils-CfwwOowz.mjs";
|
|
21
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Deletion, Details, DetailsContentBase as DetailsContent, DetailsSummaryBase as DetailsSummary, Document, DocxKit, DocxKitOptions, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Insertion, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItemBase as TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, type WpsShapeStandalone, type WpsShapeStyles, createDocument, docxExtensions, resolveFontName, resolvePageSize, scrollCaretToTop, scrollContainerOf, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm, wpsShapeStyles };
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, twipsToMm } from "./utils.mjs";
|
|
2
|
+
import { Blockquote } from "./blockquote.mjs";
|
|
2
3
|
import { BulletList } from "./bullet-list.mjs";
|
|
3
4
|
import { CodeBlock } from "./code-block.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { B as FormattingMarks, D as Deletion, E as wpsShapeStyles, F as Passthrough, I as PageBreak, N as SectionBreak, O as Insertion, P as InlinePassthrough, V as ColumnBreak, _ as tiptapNodeExtensions, a as CodeBlockLowlight, b as WpgGroup, c as HardBreak, d as Mathematics, f as TaskList, g as tiptapMarkExtensions, h as docxExtensions, j as Tab, k as TocField, l as HorizontalRule, m as TextAlign, o as DocxKit, p as Text, s as Emoji, u as ListItem, v as WpsShape } from "../core-wNNPJiKr.mjs";
|
|
6
|
+
import { Details, DetailsContent as DetailsContentBase, DetailsSummary as DetailsSummaryBase } from "./details.mjs";
|
|
6
7
|
import { Document, createDocument } from "./document.mjs";
|
|
7
8
|
import { Heading } from "./heading.mjs";
|
|
8
9
|
import { Image } from "./image.mjs";
|
|
9
10
|
import { scrollCaretToTop, scrollContainerOf } from "./scroll.mjs";
|
|
10
11
|
import { Link } from "./link.mjs";
|
|
12
|
+
import { TaskItem as TaskItemBase } from "./task-item.mjs";
|
|
13
|
+
import { Bold, Code, Highlight, Italic, Subscript, Superscript, Underline } from "./marks.mjs";
|
|
14
|
+
import { Mention } from "./mention.mjs";
|
|
11
15
|
import { OrderedList } from "./ordered-list.mjs";
|
|
12
16
|
import { Paragraph } from "./paragraph.mjs";
|
|
13
17
|
import { Strike } from "./strike.mjs";
|
|
@@ -16,4 +20,4 @@ import { TableCell } from "./table-cell.mjs";
|
|
|
16
20
|
import { TableHeader } from "./table-header.mjs";
|
|
17
21
|
import { TableRow } from "./table-row.mjs";
|
|
18
22
|
import { TextStyle } from "./text-style.mjs";
|
|
19
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Details, DetailsContent, DetailsSummary, Document, DocxKit, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, createDocument, docxExtensions, resolveFontName, resolvePageSize, scrollCaretToTop, scrollContainerOf, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm, wpsShapeStyles };
|
|
23
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Deletion, Details, DetailsContentBase as DetailsContent, DetailsSummaryBase as DetailsSummary, Document, DocxKit, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Insertion, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItemBase as TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, createDocument, docxExtensions, resolveFontName, resolvePageSize, scrollCaretToTop, scrollContainerOf, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm, wpsShapeStyles };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Link } from "../link-
|
|
2
|
-
export { Link };
|
|
1
|
+
import { n as parseDocxInline, t as Link } from "../link-gUqW45mE.mjs";
|
|
2
|
+
export { Link, parseDocxInline };
|
package/dist/extensions/link.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { mergeTextNodes } from "../converters/styles.mjs";
|
|
1
2
|
import { scrollCaretToTop } from "./scroll.mjs";
|
|
2
|
-
import { Link as Link$1 } from "@tiptap/extension-link";
|
|
3
3
|
import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
|
4
|
+
import { Link as Link$1 } from "@tiptap/extension-link";
|
|
4
5
|
//#region src/extensions/link.ts
|
|
5
6
|
/**
|
|
6
7
|
* Link — overrides {@link LinkBase}'s click behavior to match MS Word: a plain
|
|
@@ -41,7 +42,34 @@ function docxLinkClickHandler() {
|
|
|
41
42
|
} }
|
|
42
43
|
});
|
|
43
44
|
}
|
|
45
|
+
/** ParagraphChild `{ hyperlink: {...} }` → text[] carrying a link mark. Mirrors
|
|
46
|
+
* the old DocxManager.resolveHyperlink: recurse the container's runs via ctx,
|
|
47
|
+
* merge adjacent text, then stamp every text node with the link mark. Returns
|
|
48
|
+
* null for an empty container or a missing href. */
|
|
49
|
+
function resolveHyperlink(hyperlink, ctx) {
|
|
50
|
+
const href = hyperlink.link ?? (hyperlink.anchor ? `#${hyperlink.anchor}` : "");
|
|
51
|
+
if (!href) return null;
|
|
52
|
+
const content = ctx.resolveInlineChildren((hyperlink.children ?? []).map((c) => c));
|
|
53
|
+
if (content.length === 0) return null;
|
|
54
|
+
const merged = mergeTextNodes(content);
|
|
55
|
+
for (const node of merged) if (node.type === "text") node.marks = [...node.marks ?? [], {
|
|
56
|
+
type: "link",
|
|
57
|
+
attrs: {
|
|
58
|
+
href,
|
|
59
|
+
target: href.startsWith("#") ? null : "_blank",
|
|
60
|
+
rel: "noopener noreferrer nofollow",
|
|
61
|
+
class: null,
|
|
62
|
+
title: hyperlink.tooltip ?? null
|
|
63
|
+
}
|
|
64
|
+
}];
|
|
65
|
+
return merged;
|
|
66
|
+
}
|
|
67
|
+
const parseDocxInline = {
|
|
68
|
+
match: (child) => "hyperlink" in child,
|
|
69
|
+
convert: (child, ctx) => resolveHyperlink(child.hyperlink, ctx)
|
|
70
|
+
};
|
|
44
71
|
const Link = Link$1.extend({
|
|
72
|
+
parseDocxInline,
|
|
45
73
|
addOptions() {
|
|
46
74
|
return {
|
|
47
75
|
...this.parent?.(),
|
|
@@ -53,4 +81,4 @@ const Link = Link$1.extend({
|
|
|
53
81
|
}
|
|
54
82
|
});
|
|
55
83
|
//#endregion
|
|
56
|
-
export { Link };
|
|
84
|
+
export { Link, parseDocxInline };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParseAggregatorRule } from "./types.mjs";
|
|
2
|
+
import { r as Extension } from "../core-BqyLL84S.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/extensions/list-aggregator.d.ts
|
|
5
|
+
declare const parseDocxAggregator: ParseAggregatorRule;
|
|
6
|
+
declare const ListAggregator: Extension<any, any>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ListAggregator, parseDocxAggregator };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Bold as Bold$1 } from "@tiptap/extension-bold";
|
|
2
|
+
import { Code as Code$1 } from "@tiptap/extension-code";
|
|
3
|
+
import { Highlight as Highlight$1 } from "@tiptap/extension-highlight";
|
|
4
|
+
import { Italic as Italic$1 } from "@tiptap/extension-italic";
|
|
5
|
+
import { Subscript as Subscript$1 } from "@tiptap/extension-subscript";
|
|
6
|
+
import { Superscript as Superscript$1 } from "@tiptap/extension-superscript";
|
|
7
|
+
import { Underline as Underline$1 } from "@tiptap/extension-underline";
|
|
8
|
+
//#region src/extensions/marks.ts
|
|
9
|
+
const Bold = Bold$1.extend({
|
|
10
|
+
renderDocx: () => ({ bold: true }),
|
|
11
|
+
parseDocx: (opts) => opts.bold ? {} : null
|
|
12
|
+
});
|
|
13
|
+
const Italic = Italic$1.extend({
|
|
14
|
+
renderDocx: () => ({ italic: true }),
|
|
15
|
+
parseDocx: (opts) => opts.italic ? {} : null
|
|
16
|
+
});
|
|
17
|
+
const Underline = Underline$1.extend({
|
|
18
|
+
renderDocx: () => ({ underline: { type: "single" } }),
|
|
19
|
+
parseDocx: (opts) => opts.underline ? {} : null
|
|
20
|
+
});
|
|
21
|
+
const Code = Code$1.extend({
|
|
22
|
+
renderDocx: () => ({
|
|
23
|
+
style: "CodeChar",
|
|
24
|
+
font: "Consolas"
|
|
25
|
+
}),
|
|
26
|
+
parseDocx: (opts) => opts.style === "CodeChar" ? {} : null
|
|
27
|
+
});
|
|
28
|
+
const Highlight = Highlight$1.extend({
|
|
29
|
+
renderDocx: (attrs) => ({ highlight: attrs.color ?? "yellow" }),
|
|
30
|
+
parseDocx: (opts) => opts.highlight ? { color: opts.highlight } : null
|
|
31
|
+
});
|
|
32
|
+
const Subscript = Subscript$1.extend({
|
|
33
|
+
renderDocx: () => ({ subScript: true }),
|
|
34
|
+
parseDocx: (opts) => opts.subScript ? {} : null
|
|
35
|
+
});
|
|
36
|
+
const Superscript = Superscript$1.extend({
|
|
37
|
+
renderDocx: () => ({ superScript: true }),
|
|
38
|
+
parseDocx: (opts) => opts.superScript ? {} : null
|
|
39
|
+
});
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Bold, Code, Highlight, Italic, Subscript, Superscript, Underline };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { MENTION_TAG, Mention, createMention, isMention, readMention };
|
|
1
|
+
import { a as parseDocxInline, i as isMention, n as Mention, o as readMention, r as createMention, t as MENTION_TAG } from "../mention-CkONDrw9.mjs";
|
|
2
|
+
export { MENTION_TAG, Mention, createMention, isMention, parseDocxInline, readMention };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mention } from "
|
|
1
|
+
import { Mention as Mention$1 } from "@tiptap/extension-mention";
|
|
2
2
|
//#region src/extensions/mention.ts
|
|
3
3
|
/**
|
|
4
4
|
* Mention extension — owns the DOCX expression of an inline mention.
|
|
@@ -40,5 +40,19 @@ function readMention(child) {
|
|
|
40
40
|
label
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
const parseDocxInline = {
|
|
44
|
+
match: (child) => isMention(child),
|
|
45
|
+
convert: (child) => {
|
|
46
|
+
const { id, label } = readMention(child);
|
|
47
|
+
return {
|
|
48
|
+
type: "mention",
|
|
49
|
+
attrs: {
|
|
50
|
+
id,
|
|
51
|
+
label
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const Mention = Mention$1.extend({ parseDocxInline });
|
|
43
57
|
//#endregion
|
|
44
|
-
export { MENTION_TAG, Mention, createMention, isMention, readMention };
|
|
58
|
+
export { MENTION_TAG, Mention, createMention, isMention, parseDocxInline, readMention };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OrderedList as OrderedList$1 } from "./tiptap.mjs";
|
|
2
1
|
import { LevelFormat } from "@office-open/docx";
|
|
2
|
+
import { OrderedList as OrderedList$1 } from "@tiptap/extension-ordered-list";
|
|
3
3
|
//#region src/extensions/ordered-list.ts
|
|
4
4
|
/**
|
|
5
5
|
* OrderedList extension — owns the DOCX expression of an ordered list.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { PageBreak };
|
|
1
|
+
import { B as PageBreak, V as parseDocxInline } from "../core-BqyLL84S.mjs";
|
|
2
|
+
export { PageBreak, parseDocxInline };
|