@docen/docx 0.3.0 → 0.3.1

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 (110) hide show
  1. package/README.md +2 -3
  2. package/dist/blockquote-Ky9xD_Q-.mjs +31 -0
  3. package/dist/code-block-BgNjhADy.mjs +23 -0
  4. package/dist/converters/docx.d.mts +1 -109
  5. package/dist/converters/docx.mjs +1 -623
  6. package/dist/converters/html.d.mts +1 -13
  7. package/dist/converters/html.mjs +1 -17
  8. package/dist/converters/markdown.d.mts +1 -12
  9. package/dist/converters/markdown.mjs +1 -17
  10. package/dist/converters/patch.d.mts +1 -52
  11. package/dist/converters/patch.mjs +1 -36
  12. package/dist/converters/prepare.d.mts +2 -51
  13. package/dist/converters/prepare.mjs +2 -76
  14. package/dist/converters/styles.d.mts +2 -0
  15. package/dist/converters/styles.mjs +2 -0
  16. package/dist/core-DEqBHRzE.mjs +406 -0
  17. package/dist/core-fBMCCj4D.d.mts +97 -0
  18. package/dist/core.d.mts +1 -1
  19. package/dist/core.mjs +1 -1
  20. package/dist/details-Dh8luWb2.mjs +18 -0
  21. package/dist/dist-B6B3HnVZ.mjs +1838 -0
  22. package/dist/document-BH1y4qHM.d.mts +6 -0
  23. package/dist/document-CvTym-FM.mjs +50 -0
  24. package/dist/docx-C5wyjI-0.d.mts +200 -0
  25. package/dist/docx-CONyAedl.mjs +1231 -0
  26. package/dist/editor-Bf3CxQnY.mjs +21 -0
  27. package/dist/editor-DReY3Rb9.d.mts +21 -0
  28. package/dist/editor.d.mts +1 -20
  29. package/dist/editor.mjs +1 -19
  30. package/dist/emoji-BZ1dJD7d.d.mts +17 -0
  31. package/dist/emoji-C2OsTWR7.mjs +27 -0
  32. package/dist/extensions/blockquote.d.mts +23 -0
  33. package/dist/extensions/blockquote.mjs +3 -0
  34. package/dist/extensions/code-block.d.mts +19 -0
  35. package/dist/extensions/code-block.mjs +2 -0
  36. package/dist/extensions/column-break.d.mts +31 -0
  37. package/dist/extensions/column-break.mjs +2 -0
  38. package/dist/extensions/details.d.mts +19 -0
  39. package/dist/extensions/details.mjs +3 -0
  40. package/dist/extensions/document.d.mts +2 -0
  41. package/dist/extensions/document.mjs +2 -0
  42. package/dist/extensions/emoji.d.mts +2 -0
  43. package/dist/extensions/emoji.mjs +2 -0
  44. package/dist/extensions/extensions.d.mts +6 -5
  45. package/dist/extensions/extensions.mjs +14 -12
  46. package/dist/extensions/formatting-marks.d.mts +32 -0
  47. package/dist/extensions/formatting-marks.mjs +2 -0
  48. package/dist/extensions/heading.mjs +1 -144
  49. package/dist/extensions/image-group.d.mts +6 -0
  50. package/dist/extensions/image-group.mjs +2 -0
  51. package/dist/extensions/image.d.mts +2 -2
  52. package/dist/extensions/image.mjs +1 -200
  53. package/dist/extensions/index.d.mts +3 -2
  54. package/dist/extensions/index.mjs +3 -2
  55. package/dist/extensions/mention.d.mts +25 -0
  56. package/dist/extensions/mention.mjs +3 -0
  57. package/dist/extensions/ordered-list.d.mts +25 -0
  58. package/dist/extensions/ordered-list.mjs +3 -0
  59. package/dist/extensions/page-break.d.mts +34 -0
  60. package/dist/extensions/page-break.mjs +2 -0
  61. package/dist/extensions/paragraph.d.mts +1 -1
  62. package/dist/extensions/paragraph.mjs +1 -115
  63. package/dist/extensions/passthrough.d.mts +2 -0
  64. package/dist/extensions/passthrough.mjs +2 -0
  65. package/dist/extensions/section-break.d.mts +27 -0
  66. package/dist/extensions/section-break.mjs +2 -0
  67. package/dist/extensions/strike.mjs +1 -49
  68. package/dist/extensions/table-cell.mjs +1 -111
  69. package/dist/extensions/table-header.mjs +1 -111
  70. package/dist/extensions/table-row.mjs +1 -83
  71. package/dist/extensions/table.mjs +1 -133
  72. package/dist/extensions/task-item.d.mts +27 -0
  73. package/dist/extensions/task-item.mjs +3 -0
  74. package/dist/extensions/text-style.mjs +1 -133
  75. package/dist/extensions/tiptap.mjs +1 -32
  76. package/dist/extensions/types.d.mts +7 -5
  77. package/dist/extensions/utils.d.mts +16 -3
  78. package/dist/extensions/utils.mjs +2 -289
  79. package/dist/heading-DAubgJJN.mjs +166 -0
  80. package/dist/html-DCC_DSHv.d.mts +18 -0
  81. package/dist/html-DedDWPoO.mjs +66 -0
  82. package/dist/image-CuEIXoZl.mjs +334 -0
  83. package/dist/index.d.mts +68 -18
  84. package/dist/index.mjs +10 -8
  85. package/dist/markdown-BzJmRsBs.mjs +18 -0
  86. package/dist/markdown-D0k0sRYS.d.mts +13 -0
  87. package/dist/mention-C-dTR6MK.mjs +44 -0
  88. package/dist/ordered-list-V-3xFQmV.mjs +41 -0
  89. package/dist/paragraph-BrWH-BOV.mjs +147 -0
  90. package/dist/paragraph-D8mpHo_o.d.mts +8 -0
  91. package/dist/patch-Cdp5WKJz.d.mts +53 -0
  92. package/dist/patch-IZ13tXTu.mjs +36 -0
  93. package/dist/prepare-Bdk8Cjkf.mjs +122 -0
  94. package/dist/prepare-CPAvcv6q.d.mts +63 -0
  95. package/dist/strike-hWxShOgb.mjs +50 -0
  96. package/dist/styles-QSX3RhxK.mjs +285 -0
  97. package/dist/styles-ugspkrxz.d.mts +85 -0
  98. package/dist/table-DrA12lxX.mjs +159 -0
  99. package/dist/table-cell-DmkfYwDc.mjs +112 -0
  100. package/dist/table-header-Bwr5GKWg.mjs +112 -0
  101. package/dist/table-row-vew1y7WH.mjs +84 -0
  102. package/dist/task-item-BnlXGrIG.mjs +37 -0
  103. package/dist/text-style-tMeBq5XQ.mjs +151 -0
  104. package/dist/tiptap-D7pl4I5U.mjs +33 -0
  105. package/dist/utils-BPT4tjcn.mjs +333 -0
  106. package/package.json +3 -2
  107. package/dist/core-CFIQVRfx.mjs +0 -88
  108. package/dist/core-omBKMRtl.d.mts +0 -34
  109. package/dist/image-Ge1y6uam.d.mts +0 -47
  110. package/dist/paragraph-fhEXtAN2.d.mts +0 -16
@@ -0,0 +1,97 @@
1
+ import { AnyExtension, Editor, Extension, Extensions, JSONContent as JSONContent$1, Mark, Node } from "@tiptap/core";
2
+ import { TextAlign } from "@tiptap/extension-text-align";
3
+
4
+ //#region src/extensions/image.d.ts
5
+ type CropRect = {
6
+ left?: number;
7
+ top?: number;
8
+ right?: number;
9
+ bottom?: number;
10
+ };
11
+ /**
12
+ * Tiptap JSON image node → CoreImageOptions-shaped object.
13
+ *
14
+ * Returns `{ image: ImageOptions }` (structural wrapper) or null when no
15
+ * embedded image data is available (external URLs need pre-fetching).
16
+ * rotation is carried via transformation.rotation (not dropped).
17
+ */
18
+ declare function renderDocx(node: JSONContent$1): Record<string, unknown> | null;
19
+ /**
20
+ * ImageOptions-shaped object → Tiptap attrs.
21
+ *
22
+ * Near-identity unpack: transformation → width/height/rotation, altText → alt/title,
23
+ * floating/srcRect(→crop)/outline passed through verbatim. src is reconstructed by
24
+ * DocxManager from the image data bytes (kept out of parseDocx).
25
+ */
26
+ declare function parseDocx(imageOpts: Record<string, unknown>): Record<string, unknown>;
27
+ /** Dimensions + source needed to size the background image to the extent box. */
28
+ interface CropRenderContext {
29
+ width?: number;
30
+ height?: number;
31
+ src?: string;
32
+ }
33
+ /**
34
+ * Render crop as background-image styles for byte-accurate four-sided srcRect.
35
+ *
36
+ * object-fit:cover scales uniformly, so it only matches single-axis crops; for
37
+ * two-sided crops it shrinks the whole image and shows too much. background-size
38
+ * scales each axis independently (W/visibleW × H/visibleH), so the visible
39
+ * srcRect region always maps exactly onto the extent box. background-position
40
+ * then shifts the original so the cropped-left/top region falls outside the box.
41
+ *
42
+ * Requires a div[role=img] host (see Image.renderHTML) — an <img> cannot
43
+ * background-crop itself, since its src is always painted in the foreground.
44
+ */
45
+ declare function renderCropAttrs(crop: Record<string, unknown> | CropRect, ctx?: CropRenderContext): {
46
+ style: string;
47
+ };
48
+ declare const Image: import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>;
49
+ //#endregion
50
+ //#region src/extensions/passthrough.d.ts
51
+ /**
52
+ * Passthrough — block atom carrying an opaque {@link SectionChild} that has
53
+ * no native Tiptap representation (rawXml, bookmarkStart/End, toc, textbox,
54
+ * altChunk, subDoc, customXml).
55
+ *
56
+ * The full SectionChild is stored as JSON in `attrs.data` so the DOCX→JSON→DOCX
57
+ * round-trip stays byte-faithful: office-open's stringify handles the inner
58
+ * structure verbatim (including a textbox's nested children, which remain as
59
+ * structured ParagraphOptions inside the blob rather than editable Tiptap
60
+ * nodes). The node is not editable — it renders a read-only placeholder in HTML.
61
+ *
62
+ * DOCX serialization is inlined in DocxManager (compile/resolve read/write
63
+ * `attrs.data` directly), so no renderDocx/parseDocx is needed here.
64
+ */
65
+ declare const Passthrough: Node<any, any>;
66
+ //#endregion
67
+ //#region src/extensions/extensions.d.ts
68
+ declare const tiptapNodeExtensions: AnyExtension[];
69
+ declare const tiptapMarkExtensions: AnyExtension[];
70
+ declare const docxExtensions: AnyExtension[];
71
+ interface DocxKitOptions {
72
+ bold?: Record<string, any> | false;
73
+ blockquote?: Record<string, any> | false;
74
+ bulletList?: Record<string, any> | false;
75
+ code?: Record<string, any> | false;
76
+ codeBlock?: Record<string, any> | false;
77
+ document?: false;
78
+ dropcursor?: Record<string, any> | false;
79
+ gapcursor?: false;
80
+ hardBreak?: Record<string, any> | false;
81
+ heading?: Record<string, any> | false;
82
+ undoRedo?: Record<string, any> | false;
83
+ horizontalRule?: Record<string, any> | false;
84
+ italic?: Record<string, any> | false;
85
+ listItem?: Record<string, any> | false;
86
+ listKeymap?: Record<string, any> | false;
87
+ link?: Record<string, any> | false;
88
+ orderedList?: Record<string, any> | false;
89
+ paragraph?: Record<string, any> | false;
90
+ strike?: Record<string, any> | false;
91
+ text?: false;
92
+ underline?: Record<string, any> | false;
93
+ trailingNode?: Record<string, any> | false;
94
+ }
95
+ declare const DocxKit: Extension<DocxKitOptions, any>;
96
+ //#endregion
97
+ export { parseDocx as _, JSONContent$1 as a, DocxKit as c, docxExtensions as d, tiptapMarkExtensions as f, Image as g, CropRenderContext as h, Extensions as i, DocxKitOptions as l, Passthrough as m, Editor as n, Mark as o, tiptapNodeExtensions as p, Extension as r, Node as s, AnyExtension as t, TextAlign as u, renderCropAttrs as v, renderDocx as y };
package/dist/core.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as JSONContent, d as docxExtensions, i as Extensions, n as Editor, o as Mark, r as Extension, s as Node, t as AnyExtension } from "./core-omBKMRtl.mjs";
1
+ import { a as JSONContent, d as docxExtensions, i as Extensions, n as Editor, o as Mark, r as Extension, s as Node, t as AnyExtension } from "./core-fBMCCj4D.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-CFIQVRfx.mjs";
1
+ import { i as Node, n as Extension, r as Mark, s as docxExtensions, t as Editor } from "./core-DEqBHRzE.mjs";
2
2
  export { Editor, Extension, Mark, Node, docxExtensions };
@@ -0,0 +1,18 @@
1
+ import "./tiptap-D7pl4I5U.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
18
+ export { DETAILS_TAG as n, DETAILS_SUMMARY_STYLE as t };