@docen/docx 0.3.1 → 0.3.2

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.
Files changed (109) hide show
  1. package/dist/converters/docx.d.mts +199 -1
  2. package/dist/converters/docx.mjs +1273 -1
  3. package/dist/converters/html.d.mts +28 -1
  4. package/dist/converters/html.mjs +103 -1
  5. package/dist/converters/markdown.d.mts +12 -1
  6. package/dist/converters/markdown.mjs +17 -1
  7. package/dist/converters/patch.d.mts +52 -1
  8. package/dist/converters/patch.mjs +35 -1
  9. package/dist/converters/prepare.d.mts +62 -1
  10. package/dist/converters/prepare.mjs +121 -1
  11. package/dist/converters/styles.d.mts +84 -1
  12. package/dist/converters/styles.mjs +284 -1
  13. package/dist/core-C9VunJ8o.d.mts +174 -0
  14. package/dist/core-DT9IrTzN.mjs +670 -0
  15. package/dist/core.d.mts +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/editor.d.mts +20 -1
  18. package/dist/editor.mjs +20 -1
  19. package/dist/extensions/blockquote.d.mts +1 -1
  20. package/dist/extensions/blockquote.mjs +30 -2
  21. package/dist/extensions/code-block.d.mts +1 -1
  22. package/dist/extensions/code-block.mjs +22 -1
  23. package/dist/extensions/column-break.d.mts +1 -1
  24. package/dist/extensions/column-break.mjs +1 -1
  25. package/dist/extensions/details.d.mts +1 -1
  26. package/dist/extensions/details.mjs +17 -2
  27. package/dist/extensions/document.mjs +49 -1
  28. package/dist/extensions/extensions.d.mts +3 -4
  29. package/dist/extensions/extensions.mjs +13 -14
  30. package/dist/extensions/formatting-marks.d.mts +7 -1
  31. package/dist/extensions/formatting-marks.mjs +1 -1
  32. package/dist/extensions/heading.mjs +165 -1
  33. package/dist/extensions/image.d.mts +1 -1
  34. package/dist/extensions/image.mjs +395 -1
  35. package/dist/extensions/index.d.mts +3 -2
  36. package/dist/extensions/index.mjs +4 -3
  37. package/dist/extensions/mention.d.mts +1 -1
  38. package/dist/extensions/mention.mjs +43 -2
  39. package/dist/extensions/ordered-list.d.mts +1 -1
  40. package/dist/extensions/ordered-list.mjs +40 -2
  41. package/dist/extensions/page-break.d.mts +1 -33
  42. package/dist/extensions/page-break.mjs +1 -1
  43. package/dist/extensions/paragraph.mjs +150 -1
  44. package/dist/extensions/passthrough.d.mts +1 -1
  45. package/dist/extensions/passthrough.mjs +1 -1
  46. package/dist/extensions/section-break.d.mts +19 -2
  47. package/dist/extensions/section-break.mjs +1 -1
  48. package/dist/extensions/strike.mjs +49 -1
  49. package/dist/extensions/table-cell.mjs +111 -1
  50. package/dist/extensions/table-header.mjs +111 -1
  51. package/dist/extensions/table-row.mjs +83 -1
  52. package/dist/extensions/table.mjs +159 -1
  53. package/dist/extensions/task-item.d.mts +1 -1
  54. package/dist/extensions/task-item.mjs +36 -2
  55. package/dist/extensions/text-style.mjs +150 -1
  56. package/dist/extensions/tiptap.d.mts +2 -2
  57. package/dist/extensions/tiptap.mjs +31 -2
  58. package/dist/extensions/utils.d.mts +2 -62
  59. package/dist/extensions/utils.mjs +499 -2
  60. package/dist/extensions/wpg-group.d.mts +2 -0
  61. package/dist/extensions/wpg-group.mjs +2 -0
  62. package/dist/extensions/wps-shape.d.mts +2 -0
  63. package/dist/extensions/wps-shape.mjs +2 -0
  64. package/dist/index.d.mts +86 -27
  65. package/dist/index.mjs +13 -10
  66. package/dist/{tiptap-TErPjuNJ.d.mts → tiptap-pZsNPsvV.d.mts} +1 -3
  67. package/dist/utils-D87vukzp.d.mts +128 -0
  68. package/package.json +39 -40
  69. package/dist/blockquote-Ky9xD_Q-.mjs +0 -31
  70. package/dist/code-block-BgNjhADy.mjs +0 -23
  71. package/dist/core-DEqBHRzE.mjs +0 -406
  72. package/dist/core-fBMCCj4D.d.mts +0 -97
  73. package/dist/details-Dh8luWb2.mjs +0 -18
  74. package/dist/dist-B6B3HnVZ.mjs +0 -1838
  75. package/dist/document-CvTym-FM.mjs +0 -50
  76. package/dist/docx-C5wyjI-0.d.mts +0 -200
  77. package/dist/docx-CONyAedl.mjs +0 -1231
  78. package/dist/editor-Bf3CxQnY.mjs +0 -21
  79. package/dist/editor-DReY3Rb9.d.mts +0 -21
  80. package/dist/emoji-BZ1dJD7d.d.mts +0 -17
  81. package/dist/emoji-C2OsTWR7.mjs +0 -27
  82. package/dist/extensions/emoji.d.mts +0 -2
  83. package/dist/extensions/emoji.mjs +0 -2
  84. package/dist/extensions/image-group.d.mts +0 -6
  85. package/dist/extensions/image-group.mjs +0 -2
  86. package/dist/heading-DAubgJJN.mjs +0 -166
  87. package/dist/html-DCC_DSHv.d.mts +0 -18
  88. package/dist/html-DedDWPoO.mjs +0 -66
  89. package/dist/image-CuEIXoZl.mjs +0 -334
  90. package/dist/markdown-BzJmRsBs.mjs +0 -18
  91. package/dist/markdown-D0k0sRYS.d.mts +0 -13
  92. package/dist/mention-C-dTR6MK.mjs +0 -44
  93. package/dist/ordered-list-V-3xFQmV.mjs +0 -41
  94. package/dist/paragraph-BrWH-BOV.mjs +0 -147
  95. package/dist/patch-Cdp5WKJz.d.mts +0 -53
  96. package/dist/patch-IZ13tXTu.mjs +0 -36
  97. package/dist/prepare-Bdk8Cjkf.mjs +0 -122
  98. package/dist/prepare-CPAvcv6q.d.mts +0 -63
  99. package/dist/strike-hWxShOgb.mjs +0 -50
  100. package/dist/styles-QSX3RhxK.mjs +0 -285
  101. package/dist/styles-ugspkrxz.d.mts +0 -85
  102. package/dist/table-DrA12lxX.mjs +0 -159
  103. package/dist/table-cell-DmkfYwDc.mjs +0 -112
  104. package/dist/table-header-Bwr5GKWg.mjs +0 -112
  105. package/dist/table-row-vew1y7WH.mjs +0 -84
  106. package/dist/task-item-BnlXGrIG.mjs +0 -37
  107. package/dist/text-style-tMeBq5XQ.mjs +0 -151
  108. package/dist/tiptap-D7pl4I5U.mjs +0 -33
  109. package/dist/utils-BPT4tjcn.mjs +0 -333
package/dist/editor.d.mts CHANGED
@@ -1,2 +1,21 @@
1
- import { n as createDocxEditor, t as DocxEditorOptions } from "./editor-DReY3Rb9.mjs";
1
+ import { n as Editor, t as AnyExtension } from "./core-C9VunJ8o.mjs";
2
+
3
+ //#region src/editor.d.ts
4
+ interface DocxEditorOptions {
5
+ /** DOM element to mount the editor */
6
+ element: HTMLElement;
7
+ /** Additional Tiptap extensions */
8
+ extensions?: AnyExtension[];
9
+ /** Initial content (Tiptap JSON or HTML string) */
10
+ content?: Record<string, unknown> | string;
11
+ /** Enable spellcheck (disable for large documents) */
12
+ spellcheck?: boolean;
13
+ /** Editor is editable */
14
+ editable?: boolean;
15
+ }
16
+ /**
17
+ * Create a Tiptap editor configured for DOCX editing.
18
+ */
19
+ declare function createDocxEditor(options: DocxEditorOptions): Editor;
20
+ //#endregion
2
21
  export { DocxEditorOptions, createDocxEditor };
package/dist/editor.mjs CHANGED
@@ -1,2 +1,21 @@
1
- import { t as createDocxEditor } from "./editor-Bf3CxQnY.mjs";
1
+ import { s as docxExtensions, t as Editor } from "./core-DT9IrTzN.mjs";
2
+ //#region src/editor.ts
3
+ /**
4
+ * Create a Tiptap editor configured for DOCX editing.
5
+ */
6
+ function createDocxEditor(options) {
7
+ const { element, extensions: extraExtensions = [], content, spellcheck = true, editable = true } = options;
8
+ const extraNames = new Set(extraExtensions.map((e) => e.name).filter(Boolean));
9
+ return new Editor({
10
+ element,
11
+ extensions: [...docxExtensions.filter((e) => !extraNames.has(e.name)), ...extraExtensions],
12
+ content: content ?? {
13
+ type: "doc",
14
+ content: [{ type: "paragraph" }]
15
+ },
16
+ editable,
17
+ editorProps: { attributes: { spellcheck: spellcheck ? "true" : "false" } }
18
+ });
19
+ }
20
+ //#endregion
2
21
  export { createDocxEditor };
@@ -1,4 +1,4 @@
1
- import { t as Blockquote } from "../tiptap-TErPjuNJ.mjs";
1
+ import { t as Blockquote } from "../tiptap-pZsNPsvV.mjs";
2
2
 
3
3
  //#region src/extensions/blockquote.d.ts
4
4
  /**
@@ -1,3 +1,31 @@
1
- import { t as Blockquote } from "../tiptap-D7pl4I5U.mjs";
2
- import { n as BLOCKQUOTE_INDENT_LEFT, r as applyBlockquoteStyle, t as BLOCKQUOTE_BORDER } from "../blockquote-Ky9xD_Q-.mjs";
1
+ import { Blockquote } from "./tiptap.mjs";
2
+ //#region src/extensions/blockquote.ts
3
+ /**
4
+ * Blockquote extension — owns the DOCX expression of a blockquote.
5
+ *
6
+ * DOCX has no blockquote element; the convention is a left indent plus a left
7
+ * border on each contained paragraph. This module owns that signature; the
8
+ * DocxManager walks the blockquote's child paragraphs and applies it to each.
9
+ */
10
+ /** Left indent (twips, ~0.5 inch) marking a blockquote. */
11
+ const BLOCKQUOTE_INDENT_LEFT = 720;
12
+ /** Left border marking a blockquote. */
13
+ const BLOCKQUOTE_BORDER = {
14
+ style: "single",
15
+ size: 18,
16
+ space: 12,
17
+ color: "CCCCCC"
18
+ };
19
+ /** Apply the blockquote signature (left indent + left border) to paragraph opts. */
20
+ function applyBlockquoteStyle(paraObj) {
21
+ paraObj.indent = {
22
+ ...paraObj.indent ?? {},
23
+ left: 720
24
+ };
25
+ paraObj.border = {
26
+ ...paraObj.border ?? {},
27
+ left: BLOCKQUOTE_BORDER
28
+ };
29
+ }
30
+ //#endregion
3
31
  export { BLOCKQUOTE_BORDER, BLOCKQUOTE_INDENT_LEFT, Blockquote, applyBlockquoteStyle };
@@ -1,4 +1,4 @@
1
- import { a as JSONContent } from "../core-fBMCCj4D.mjs";
1
+ import { a as JSONContent } from "../core-C9VunJ8o.mjs";
2
2
 
3
3
  //#region src/extensions/code-block.d.ts
4
4
  /**
@@ -1,2 +1,23 @@
1
- import { n as renderDocx, t as CodeBlock } from "../code-block-BgNjhADy.mjs";
1
+ import { CodeBlockLowlight } from "./tiptap.mjs";
2
+ //#region src/extensions/code-block.ts
3
+ /**
4
+ * CodeBlock extension — CodeBlockLowlight with a DOCX renderDocx.
5
+ *
6
+ * DOCX has no dedicated code-block element. A code block maps to a single
7
+ * paragraph styled "Code" with a monospace run font. Inline marks (syntax-
8
+ * highlight tokens) and line breaks (`\n` → `<w:br/>`) are handled by
9
+ * DocxManager's shared inline-content compilation; resolveCodeBlock reassembles
10
+ * the text. This module owns only the paragraph-level style.
11
+ *
12
+ * `language` has no OOXML carrier and is intentionally dropped (known lossy).
13
+ */
14
+ /** codeBlock node → paragraph properties (style "Code" + monospace font). */
15
+ function renderDocx(_node) {
16
+ return {
17
+ style: "Code",
18
+ run: { font: "Consolas" }
19
+ };
20
+ }
21
+ const CodeBlock = CodeBlockLowlight.extend({ renderDocx });
22
+ //#endregion
2
23
  export { CodeBlock, renderDocx };
@@ -1,4 +1,4 @@
1
- import { s as Node } from "../core-fBMCCj4D.mjs";
1
+ import { s as Node } from "../core-C9VunJ8o.mjs";
2
2
 
3
3
  //#region src/extensions/column-break.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { h as ColumnBreak } from "../core-DEqBHRzE.mjs";
1
+ import { v as ColumnBreak } from "../core-DT9IrTzN.mjs";
2
2
  export { ColumnBreak };
@@ -1,4 +1,4 @@
1
- import { c as DetailsSummary, o as Details, s as DetailsContent } from "../tiptap-TErPjuNJ.mjs";
1
+ import { c as DetailsSummary, o as Details, s as DetailsContent } from "../tiptap-pZsNPsvV.mjs";
2
2
 
3
3
  //#region src/extensions/details.d.ts
4
4
  /**
@@ -1,3 +1,18 @@
1
- import { c as DetailsSummary, o as Details, s as DetailsContent } from "../tiptap-D7pl4I5U.mjs";
2
- import { n as DETAILS_TAG, t as DETAILS_SUMMARY_STYLE } from "../details-Dh8luWb2.mjs";
1
+ import { Details, DetailsContent, DetailsSummary } from "./tiptap.mjs";
2
+ //#region src/extensions/details.ts
3
+ /**
4
+ * Details extension — owns the DOCX expression of a collapsible details block.
5
+ *
6
+ * DOCX has no native collapsible region, but a block-level group-SDT is a
7
+ * reversible container. The details maps to one group-SDT tagged "docen-
8
+ * details"; the summary paragraph is marked with a fixed style so resolve can
9
+ * split it back out from the content paragraphs. Structure round-trips fully
10
+ * (summary + content); Word shows it expanded (no collapse) — an inherent
11
+ * DOCX limitation, not data loss.
12
+ */
13
+ /** SDT tag marking a details group content control. */
14
+ const DETAILS_TAG = "docen-details";
15
+ /** Paragraph style marking the summary line within a details group-SDT. */
16
+ const DETAILS_SUMMARY_STYLE = "DocenDetailsSummary";
17
+ //#endregion
3
18
  export { DETAILS_SUMMARY_STYLE, DETAILS_TAG, Details, DetailsContent, DetailsSummary };
@@ -1,2 +1,50 @@
1
- import { n as createDocument, t as Document } from "../document-CvTym-FM.mjs";
1
+ import { Document as Document$1 } from "./tiptap.mjs";
2
+ //#region src/extensions/document.ts
3
+ /**
4
+ * Document extension carrying DOCX document-level data through the Tiptap JSON
5
+ * for lossless round-trip (declared as attrs so editor setContent → getJSON
6
+ * preserves them, not just the standalone converters):
7
+ *
8
+ * - `attrs.styles` — office-open `StylesOptions` (styles.xml: importedStyles /
9
+ * docDefaultsXml / latentStylesXml as raw XML).
10
+ * - `attrs.core` — docProps/core.xml properties (title/creator/description/…,
11
+ * see DocxCoreProperties in converters/docx.ts).
12
+ * - `attrs.sectionProperties` — the last section's page layout (page size/margin/
13
+ * orientation, columns, type, grid; intermediate sections carry theirs on
14
+ * sectionBreak nodes).
15
+ *
16
+ * None rendered to HTML — phase 2 applies styles via injected CSS.
17
+ *
18
+ * Factory form (`createDocument`): the editor layer needs a different top-level
19
+ * content expression (`doc > page+` for the C-route editing schema) but the SAME
20
+ * DOCX attrs. Building it via this factory keeps the Document definition in ONE
21
+ * place (here) — the editor parameterizes only `content`, instead of `.extend`-
22
+ * overriding this Document and re-stating the attrs. `Document` is the default
23
+ * flat `doc > block+` shape used by the docx package itself.
24
+ */
25
+ const attrNative = () => ({
26
+ default: null,
27
+ parseHTML: () => null,
28
+ rendered: false
29
+ });
30
+ function createDocument(content = "block+") {
31
+ return Document$1.extend({
32
+ content,
33
+ addAttributes() {
34
+ return {
35
+ ...this.parent?.(),
36
+ styles: attrNative(),
37
+ core: attrNative(),
38
+ sectionProperties: attrNative(),
39
+ sectionHeaders: attrNative(),
40
+ sectionFooters: attrNative(),
41
+ background: attrNative(),
42
+ documentExtras: attrNative()
43
+ };
44
+ }
45
+ });
46
+ }
47
+ /** Default flat Document (`doc > block+`) — the DOCX round-trip shape. */
48
+ const Document = createDocument();
49
+ //#endregion
2
50
  export { Document, createDocument };
@@ -1,8 +1,7 @@
1
- import { B as UndoRedo, C as Mention, D as Subscript, F as Text, N as TaskItem, O as Superscript, P as TaskList, R as TrailingNode, S as Mathematics, a as CodeBlockLowlight, b as ListItem, c as DetailsSummary, f as Gapcursor, g as HorizontalRule, h as Highlight, i as Code, n as Bold, o as Details, p as HardBreak, r as BulletList, s as DetailsContent, t as Blockquote, u as Dropcursor, v as Italic, w as OrderedList, x as ListKeymap, y as Link, z as Underline } from "../tiptap-TErPjuNJ.mjs";
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
2
  import { t as Document } from "../document-BH1y4qHM.mjs";
3
- import { t as Emoji } from "../emoji-BZ1dJD7d.mjs";
4
3
  import { t as Heading } from "../heading-BvqBD2zX.mjs";
5
- import { c as DocxKit, d as docxExtensions, f as tiptapMarkExtensions, g as Image, l as DocxKitOptions, m as Passthrough, p as tiptapNodeExtensions, u as TextAlign } from "../core-fBMCCj4D.mjs";
4
+ import { S as Image, _ as WpgGroup, d as TextAlign, f as docxExtensions, g as WpsShape, h as Passthrough, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, u as DocxKitOptions } from "../core-C9VunJ8o.mjs";
6
5
  import { t as Paragraph } from "../paragraph-D8mpHo_o.mjs";
7
6
  import { t as TableRow } from "../table-row-kgzYkZlW.mjs";
8
7
  import { t as Table } from "../table-BFkfeRp9.mjs";
@@ -10,4 +9,4 @@ import { t as TableCell } from "../table-cell-D_FV4D2h.mjs";
10
9
  import { t as TableHeader } from "../table-header-KGQ2aEkP.mjs";
11
10
  import { t as Strike } from "../strike-BgWGvjKr.mjs";
12
11
  import { t as TextStyle } from "../text-style-BHdtXkMb.mjs";
13
- export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, DocxKit, DocxKitOptions, Dropcursor, Emoji, Gapcursor, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, ListKeymap, Mathematics, Mention, OrderedList, Paragraph, Passthrough, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TrailingNode, Underline, UndoRedo, 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, Underline, WpgGroup, WpsShape, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
@@ -1,14 +1,13 @@
1
- import { B as UndoRedo, C as Mention, D as Subscript, F as Text, N as TaskItem, O as Superscript, P as TaskList, R as TrailingNode, S as Mathematics, a as CodeBlockLowlight, b as ListItem, c as DetailsSummary, f as Gapcursor, g as HorizontalRule, h as Highlight, i as Code, n as Bold, o as Details, p as HardBreak, r as BulletList, s as DetailsContent, t as Blockquote, u as Dropcursor, v as Italic, w as OrderedList, x as ListKeymap, y as Link, z as Underline } from "../tiptap-D7pl4I5U.mjs";
2
- import { a as DocxKit, c as tiptapMarkExtensions, d as Passthrough, l as tiptapNodeExtensions, o as TextAlign, s as docxExtensions } from "../core-DEqBHRzE.mjs";
3
- import { t as Document } from "../document-CvTym-FM.mjs";
4
- import { t as Emoji } from "../emoji-C2OsTWR7.mjs";
5
- import { t as Heading } from "../heading-DAubgJJN.mjs";
6
- import { t as Image } from "../image-CuEIXoZl.mjs";
7
- import { t as Paragraph } from "../paragraph-BrWH-BOV.mjs";
8
- import { t as Strike } from "../strike-hWxShOgb.mjs";
9
- import { t as Table } from "../table-DrA12lxX.mjs";
10
- import { t as TableCell } from "../table-cell-DmkfYwDc.mjs";
11
- import { t as TableHeader } from "../table-header-Bwr5GKWg.mjs";
12
- import { t as TableRow } from "../table-row-vew1y7WH.mjs";
13
- import { t as TextStyle } from "../text-style-tMeBq5XQ.mjs";
14
- export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, DocxKit, Dropcursor, Emoji, Gapcursor, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, ListKeymap, Mathematics, Mention, OrderedList, Paragraph, Passthrough, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TrailingNode, Underline, UndoRedo, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
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, h as Passthrough, l as tiptapNodeExtensions, o as TextAlign, s as docxExtensions, u as WpsShape } from "../core-DT9IrTzN.mjs";
3
+ import { Document } from "./document.mjs";
4
+ import { Heading } from "./heading.mjs";
5
+ import { Image } from "./image.mjs";
6
+ import { Paragraph } from "./paragraph.mjs";
7
+ import { Strike } from "./strike.mjs";
8
+ import { Table } from "./table.mjs";
9
+ import { TableCell } from "./table-cell.mjs";
10
+ import { TableHeader } from "./table-header.mjs";
11
+ import { TableRow } from "./table-row.mjs";
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 };
@@ -1,4 +1,4 @@
1
- import { r as Extension } from "../core-fBMCCj4D.mjs";
1
+ import { r as Extension } from "../core-C9VunJ8o.mjs";
2
2
 
3
3
  //#region src/extensions/formatting-marks.d.ts
4
4
  /**
@@ -19,6 +19,12 @@ import { r as Extension } from "../core-fBMCCj4D.mjs";
19
19
  * leftwards" — the Enter-key glyph). Word/WPS use the pilcrow ¶ for paragraph
20
20
  * marks; that down-then-left arrow is Word's line-break glyph — adopted here as
21
21
  * the paragraph mark per the project's visual preference.
22
+ *
23
+ * Performance: the widget set is cached in plugin state and rebuilt only on a
24
+ * doc change or a marks toggle — NOT on every selectionUpdate. Without the
25
+ * cache, each caret move / selection re-traverses the whole document (one
26
+ * widget per textblock) and rebuilds the set, which costs 200ms+ on 1000-page
27
+ * documents. Pure selection transactions now reuse the cached set in O(1).
22
28
  */
23
29
  declare const FormattingMarks: Extension<any, any>;
24
30
  declare module "@tiptap/core" {
@@ -1,2 +1,2 @@
1
- import { m as FormattingMarks } from "../core-DEqBHRzE.mjs";
1
+ import { _ as FormattingMarks } from "../core-DT9IrTzN.mjs";
2
2
  export { FormattingMarks };
@@ -1,2 +1,166 @@
1
- import { n as parseDocx, r as renderDocx, t as Heading } from "../heading-DAubgJJN.mjs";
1
+ import { Heading as Heading$1 } from "./tiptap.mjs";
2
+ import { alignmentFromElement, bordersFromElement, indentFromElement, renderParagraphStyles, shadingFromElement, spacingFromElement } from "./utils.mjs";
3
+ //#region src/extensions/heading.ts
4
+ /**
5
+ * Heading extension with nested office-open attrs (mirrors Paragraph).
6
+ *
7
+ * Attrs mirror ParagraphPropertiesOptionsBase (alignment/indent/spacing/border/
8
+ * shading/frame as nested objects + scalar OOXML properties) plus the inherited
9
+ * Tiptap `level` (1-6, rendered: false). DOCX round-trip is near-identity:
10
+ * renderDocx/parseDocx pass attrs through and only map `level` ↔ OOXML
11
+ * `heading` (HeadingLevel literal). CSS conversion happens solely in
12
+ * renderHTML via utils mappers.
13
+ */
14
+ const HEADING_COMPILE_MAP = {
15
+ 1: "Heading1",
16
+ 2: "Heading2",
17
+ 3: "Heading3",
18
+ 4: "Heading4",
19
+ 5: "Heading5",
20
+ 6: "Heading6"
21
+ };
22
+ const HEADING_PARSE_MAP = {
23
+ Heading1: 1,
24
+ Heading2: 2,
25
+ Heading3: 3,
26
+ Heading4: 4,
27
+ Heading5: 5,
28
+ Heading6: 6,
29
+ Title: 1
30
+ };
31
+ /** Runtime-only attrs the TableOfContents extension injects on each heading
32
+ * (`id` / `data-toc-id`). They are regenerated on every load, so never persist
33
+ * them to DOCX — skip them in renderDocx. */
34
+ const TOC_RUNTIME_KEYS = new Set(["id", "data-toc-id"]);
35
+ function renderDocx(node) {
36
+ const attrs = node.attrs ?? {};
37
+ const opts = {};
38
+ const level = attrs.level;
39
+ const styleId = attrs.styleId;
40
+ if (styleId) opts.heading = styleId;
41
+ else if (level) opts.heading = HEADING_COMPILE_MAP[level] ?? "Heading1";
42
+ for (const [key, value] of Object.entries(attrs)) {
43
+ if (key === "level" || key === "styleId" || TOC_RUNTIME_KEYS.has(key)) continue;
44
+ if (value !== null && value !== void 0) opts[key] = value;
45
+ }
46
+ return opts;
47
+ }
48
+ /** Structural/semantic keys expressed elsewhere (heading handled separately, list handling, run children). */
49
+ const SKIP_KEYS = new Set([
50
+ "heading",
51
+ "style",
52
+ "bullet",
53
+ "numbering",
54
+ "run",
55
+ "children",
56
+ "text",
57
+ "thematicBreak"
58
+ ]);
59
+ function parseDocx(opts) {
60
+ const resolved = typeof opts === "string" ? { text: opts } : opts;
61
+ const attrs = {};
62
+ if (resolved.heading) {
63
+ const level = HEADING_PARSE_MAP[resolved.heading];
64
+ if (level) attrs.level = level;
65
+ attrs.styleId = resolved.heading;
66
+ }
67
+ if (resolved.style) attrs.styleId = resolved.style;
68
+ for (const [key, value] of Object.entries(resolved)) {
69
+ if (SKIP_KEYS.has(key)) continue;
70
+ attrs[key] = value ?? null;
71
+ }
72
+ return attrs;
73
+ }
74
+ const attrNative = () => ({
75
+ default: null,
76
+ parseHTML: () => null,
77
+ rendered: false
78
+ });
79
+ const Heading = Heading$1.extend({
80
+ addAttributes() {
81
+ return {
82
+ ...this.parent?.(),
83
+ styleId: {
84
+ default: null,
85
+ parseHTML: (el) => {
86
+ const m = (el.getAttribute("class") || "").match(/(?:^|\s)docx-style-(\S+)/);
87
+ return m ? m[1] : null;
88
+ }
89
+ },
90
+ alignment: {
91
+ default: null,
92
+ rendered: false,
93
+ parseHTML: (el) => alignmentFromElement(el)
94
+ },
95
+ indent: {
96
+ default: null,
97
+ rendered: false,
98
+ parseHTML: (el) => indentFromElement(el)
99
+ },
100
+ spacing: {
101
+ default: null,
102
+ rendered: false,
103
+ parseHTML: (el) => spacingFromElement(el)
104
+ },
105
+ shading: {
106
+ default: null,
107
+ rendered: false,
108
+ parseHTML: (el) => shadingFromElement(el)
109
+ },
110
+ border: {
111
+ default: null,
112
+ rendered: false,
113
+ parseHTML: (el) => bordersFromElement(el)
114
+ },
115
+ frame: attrNative(),
116
+ keepNext: attrNative(),
117
+ keepLines: attrNative(),
118
+ pageBreakBefore: attrNative(),
119
+ widowControl: attrNative(),
120
+ contextualSpacing: attrNative(),
121
+ bidirectional: attrNative(),
122
+ outlineLevel: attrNative(),
123
+ textDirection: attrNative(),
124
+ textAlignment: attrNative(),
125
+ suppressLineNumbers: attrNative(),
126
+ wordWrap: attrNative(),
127
+ overflowPunctuation: attrNative(),
128
+ autoSpaceEastAsianText: attrNative(),
129
+ suppressOverlap: attrNative(),
130
+ suppressAutoHyphens: attrNative(),
131
+ adjustRightInd: attrNative(),
132
+ snapToGrid: attrNative(),
133
+ mirrorIndents: attrNative(),
134
+ kinsoku: attrNative(),
135
+ topLinePunct: attrNative(),
136
+ autoSpaceDE: attrNative(),
137
+ textboxTightWrap: attrNative(),
138
+ rightTabStop: attrNative(),
139
+ leftTabStop: attrNative(),
140
+ divId: attrNative(),
141
+ tabStops: attrNative(),
142
+ cnfStyle: attrNative()
143
+ };
144
+ },
145
+ renderHTML({ node, HTMLAttributes }) {
146
+ let hasContent = false;
147
+ node.forEach?.((child) => {
148
+ if (child.isText || child.type?.name === "hardBreak" || child.type?.name === "image") hasContent = true;
149
+ });
150
+ const styles = renderParagraphStyles(node.attrs, { empty: !hasContent });
151
+ const level = node.attrs?.level ?? 1;
152
+ const attrs = { ...HTMLAttributes };
153
+ const styleId = node.attrs.styleId;
154
+ if (styleId) attrs.class = `docx-style-${styleId}`;
155
+ if (styles.length > 0) attrs.style = styles.join(";");
156
+ return [
157
+ `h${level}`,
158
+ attrs,
159
+ 0
160
+ ];
161
+ },
162
+ renderDocx,
163
+ parseDocx
164
+ });
165
+ //#endregion
2
166
  export { Heading, parseDocx, renderDocx };
@@ -1,2 +1,2 @@
1
- import { _ as parseDocx, g as Image, h as CropRenderContext, v as renderCropAttrs, y as renderDocx } from "../core-fBMCCj4D.mjs";
1
+ import { C as parseDocx, S as Image, T as renderDocx, w as renderCropAttrs, x as CropRenderContext } from "../core-C9VunJ8o.mjs";
2
2
  export { CropRenderContext, Image, parseDocx, renderCropAttrs, renderDocx };