@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.
- package/README.md +2 -3
- package/dist/blockquote-Ky9xD_Q-.mjs +31 -0
- package/dist/code-block-BgNjhADy.mjs +23 -0
- package/dist/converters/docx.d.mts +1 -109
- package/dist/converters/docx.mjs +1 -623
- package/dist/converters/html.d.mts +1 -13
- package/dist/converters/html.mjs +1 -17
- package/dist/converters/markdown.d.mts +1 -12
- package/dist/converters/markdown.mjs +1 -17
- package/dist/converters/patch.d.mts +1 -52
- package/dist/converters/patch.mjs +1 -36
- package/dist/converters/prepare.d.mts +2 -51
- package/dist/converters/prepare.mjs +2 -76
- package/dist/converters/styles.d.mts +2 -0
- package/dist/converters/styles.mjs +2 -0
- package/dist/core-DEqBHRzE.mjs +406 -0
- package/dist/core-fBMCCj4D.d.mts +97 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/details-Dh8luWb2.mjs +18 -0
- package/dist/dist-B6B3HnVZ.mjs +1838 -0
- package/dist/document-BH1y4qHM.d.mts +6 -0
- package/dist/document-CvTym-FM.mjs +50 -0
- package/dist/docx-C5wyjI-0.d.mts +200 -0
- package/dist/docx-CONyAedl.mjs +1231 -0
- package/dist/editor-Bf3CxQnY.mjs +21 -0
- package/dist/editor-DReY3Rb9.d.mts +21 -0
- package/dist/editor.d.mts +1 -20
- package/dist/editor.mjs +1 -19
- package/dist/emoji-BZ1dJD7d.d.mts +17 -0
- package/dist/emoji-C2OsTWR7.mjs +27 -0
- package/dist/extensions/blockquote.d.mts +23 -0
- package/dist/extensions/blockquote.mjs +3 -0
- package/dist/extensions/code-block.d.mts +19 -0
- package/dist/extensions/code-block.mjs +2 -0
- package/dist/extensions/column-break.d.mts +31 -0
- package/dist/extensions/column-break.mjs +2 -0
- package/dist/extensions/details.d.mts +19 -0
- package/dist/extensions/details.mjs +3 -0
- package/dist/extensions/document.d.mts +2 -0
- package/dist/extensions/document.mjs +2 -0
- package/dist/extensions/emoji.d.mts +2 -0
- package/dist/extensions/emoji.mjs +2 -0
- package/dist/extensions/extensions.d.mts +6 -5
- package/dist/extensions/extensions.mjs +14 -12
- package/dist/extensions/formatting-marks.d.mts +32 -0
- package/dist/extensions/formatting-marks.mjs +2 -0
- package/dist/extensions/heading.mjs +1 -144
- package/dist/extensions/image-group.d.mts +6 -0
- package/dist/extensions/image-group.mjs +2 -0
- package/dist/extensions/image.d.mts +2 -2
- package/dist/extensions/image.mjs +1 -200
- package/dist/extensions/index.d.mts +3 -2
- package/dist/extensions/index.mjs +3 -2
- package/dist/extensions/mention.d.mts +25 -0
- package/dist/extensions/mention.mjs +3 -0
- package/dist/extensions/ordered-list.d.mts +25 -0
- package/dist/extensions/ordered-list.mjs +3 -0
- package/dist/extensions/page-break.d.mts +34 -0
- package/dist/extensions/page-break.mjs +2 -0
- package/dist/extensions/paragraph.d.mts +1 -1
- package/dist/extensions/paragraph.mjs +1 -115
- package/dist/extensions/passthrough.d.mts +2 -0
- package/dist/extensions/passthrough.mjs +2 -0
- package/dist/extensions/section-break.d.mts +27 -0
- package/dist/extensions/section-break.mjs +2 -0
- package/dist/extensions/strike.mjs +1 -49
- package/dist/extensions/table-cell.mjs +1 -111
- package/dist/extensions/table-header.mjs +1 -111
- package/dist/extensions/table-row.mjs +1 -83
- package/dist/extensions/table.mjs +1 -133
- package/dist/extensions/task-item.d.mts +27 -0
- package/dist/extensions/task-item.mjs +3 -0
- package/dist/extensions/text-style.mjs +1 -133
- package/dist/extensions/tiptap.mjs +1 -32
- package/dist/extensions/types.d.mts +7 -5
- package/dist/extensions/utils.d.mts +16 -3
- package/dist/extensions/utils.mjs +2 -289
- package/dist/heading-DAubgJJN.mjs +166 -0
- package/dist/html-DCC_DSHv.d.mts +18 -0
- package/dist/html-DedDWPoO.mjs +66 -0
- package/dist/image-CuEIXoZl.mjs +334 -0
- package/dist/index.d.mts +68 -18
- package/dist/index.mjs +10 -8
- package/dist/markdown-BzJmRsBs.mjs +18 -0
- package/dist/markdown-D0k0sRYS.d.mts +13 -0
- package/dist/mention-C-dTR6MK.mjs +44 -0
- package/dist/ordered-list-V-3xFQmV.mjs +41 -0
- package/dist/paragraph-BrWH-BOV.mjs +147 -0
- package/dist/paragraph-D8mpHo_o.d.mts +8 -0
- package/dist/patch-Cdp5WKJz.d.mts +53 -0
- package/dist/patch-IZ13tXTu.mjs +36 -0
- package/dist/prepare-Bdk8Cjkf.mjs +122 -0
- package/dist/prepare-CPAvcv6q.d.mts +63 -0
- package/dist/strike-hWxShOgb.mjs +50 -0
- package/dist/styles-QSX3RhxK.mjs +285 -0
- package/dist/styles-ugspkrxz.d.mts +85 -0
- package/dist/table-DrA12lxX.mjs +159 -0
- package/dist/table-cell-DmkfYwDc.mjs +112 -0
- package/dist/table-header-Bwr5GKWg.mjs +112 -0
- package/dist/table-row-vew1y7WH.mjs +84 -0
- package/dist/task-item-BnlXGrIG.mjs +37 -0
- package/dist/text-style-tMeBq5XQ.mjs +151 -0
- package/dist/tiptap-D7pl4I5U.mjs +33 -0
- package/dist/utils-BPT4tjcn.mjs +333 -0
- package/package.json +3 -2
- package/dist/core-CFIQVRfx.mjs +0 -88
- package/dist/core-omBKMRtl.d.mts +0 -34
- package/dist/image-Ge1y6uam.d.mts +0 -47
- 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-
|
|
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-
|
|
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 };
|