@docen/docx 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockquote-DY80QC06.d.mts +21 -0
- package/dist/bullet-list-DF60pnSL.d.mts +12 -0
- package/dist/converters/docx.d.mts +25 -4
- package/dist/converters/docx.mjs +217 -41
- package/dist/converters/html.d.mts +1 -1
- package/dist/converters/html.mjs +1 -1
- package/dist/converters/markdown.d.mts +1 -1
- package/dist/converters/markdown.mjs +1 -1
- package/dist/converters/patch.d.mts +1 -1
- package/dist/converters/prepare.d.mts +1 -1
- package/dist/converters/prepare.mjs +6 -9
- package/dist/converters/styles.d.mts +7 -1
- package/dist/converters/styles.mjs +31 -8
- package/dist/{core-DT9IrTzN.mjs → core-BnF8XhVE.mjs} +229 -33
- package/dist/core-DC0_-WcE.d.mts +387 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/details-Dd5MqqmR.d.mts +17 -0
- package/dist/document-Cws7XTYL.d.mts +28 -0
- package/dist/editor.d.mts +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/extensions/blockquote.d.mts +2 -22
- package/dist/extensions/bullet-list.d.mts +2 -0
- package/dist/extensions/bullet-list.mjs +21 -0
- package/dist/extensions/code-block.d.mts +1 -18
- package/dist/extensions/column-break.d.mts +1 -30
- package/dist/extensions/column-break.mjs +1 -1
- package/dist/extensions/details.d.mts +2 -18
- package/dist/extensions/document.d.mts +1 -1
- package/dist/extensions/document.mjs +3 -6
- package/dist/extensions/extensions.d.mts +10 -6
- package/dist/extensions/extensions.mjs +9 -4
- package/dist/extensions/formatting-marks.d.mts +1 -37
- package/dist/extensions/formatting-marks.mjs +1 -1
- package/dist/extensions/heading.mjs +31 -9
- package/dist/extensions/image.d.mts +1 -1
- package/dist/extensions/image.mjs +20 -4
- package/dist/extensions/index.d.mts +17 -4
- package/dist/extensions/index.mjs +18 -3
- package/dist/extensions/link.d.mts +2 -0
- package/dist/extensions/link.mjs +56 -0
- package/dist/extensions/mention.d.mts +2 -24
- package/dist/extensions/ordered-list.d.mts +1 -24
- package/dist/extensions/ordered-list.mjs +10 -1
- package/dist/extensions/page-break.d.mts +1 -1
- package/dist/extensions/page-break.mjs +1 -1
- package/dist/extensions/paragraph.mjs +14 -6
- package/dist/extensions/passthrough.d.mts +2 -2
- package/dist/extensions/passthrough.mjs +2 -2
- package/dist/extensions/scroll.d.mts +2 -0
- package/dist/extensions/scroll.mjs +33 -0
- package/dist/extensions/section-break.d.mts +1 -43
- package/dist/extensions/section-break.mjs +1 -1
- package/dist/extensions/strike.mjs +1 -5
- package/dist/extensions/tab.d.mts +2 -0
- package/dist/extensions/tab.mjs +2 -0
- package/dist/extensions/table-cell.mjs +3 -8
- package/dist/extensions/table-header.mjs +1 -6
- package/dist/extensions/table-row.mjs +1 -6
- package/dist/extensions/table.mjs +1 -6
- package/dist/extensions/task-item.d.mts +2 -26
- package/dist/extensions/text-style.mjs +1 -6
- package/dist/extensions/tiptap.d.mts +1 -1
- package/dist/extensions/toc-field.d.mts +2 -0
- package/dist/extensions/toc-field.mjs +2 -0
- package/dist/extensions/utils.d.mts +2 -2
- package/dist/extensions/utils.mjs +10 -1
- package/dist/extensions/wpg-group.d.mts +2 -2
- package/dist/extensions/wpg-group.mjs +2 -2
- package/dist/extensions/wps-shape.d.mts +1 -1
- package/dist/extensions/wps-shape.mjs +1 -1
- package/dist/index.d.mts +48 -11
- package/dist/index.mjs +19 -4
- package/dist/link-BawPjQZR.d.mts +6 -0
- package/dist/mention-BGLzLVYw.d.mts +23 -0
- package/dist/ordered-list-DFAe-YEV.d.mts +25 -0
- package/dist/scroll-ZNeThJsJ.d.mts +18 -0
- package/dist/task-item-B0ntvQ1Y.d.mts +25 -0
- package/dist/{tiptap-pZsNPsvV.d.mts → tiptap-BKqn41uT.d.mts} +2 -2
- package/dist/{utils-D87vukzp.d.mts → utils-BJwDQts7.d.mts} +10 -1
- package/package.json +3 -3
- package/dist/core-C9VunJ8o.d.mts +0 -174
- package/dist/document-BH1y4qHM.d.mts +0 -6
package/dist/core-C9VunJ8o.d.mts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
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
|
-
/** Extent-box dimensions needed to size the inner <img> for a cropped image. */
|
|
28
|
-
interface CropRenderContext {
|
|
29
|
-
width?: number;
|
|
30
|
-
height?: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Render crop as the inner <img> style for byte-accurate four-sided srcRect.
|
|
34
|
-
*
|
|
35
|
-
* object-fit:cover scales uniformly, so it only matches single-axis crops.
|
|
36
|
-
* Instead the inner <img> is sized to the un-cropped display size per axis
|
|
37
|
-
* (imgW = W/visibleW, imgH = H/visibleH) and translated so the visible srcRect
|
|
38
|
-
* region maps exactly onto the extent box; the outer box clips (overflow:hidden)
|
|
39
|
-
* the cropped-out left/top region. Mathematically equivalent to a
|
|
40
|
-
* background-size/background-position crop, but keeps a real <img> (alt,
|
|
41
|
-
* accessibility, semantics, drag-to-save).
|
|
42
|
-
*/
|
|
43
|
-
declare function renderCropAttrs(crop: Record<string, unknown> | CropRect, ctx?: CropRenderContext): {
|
|
44
|
-
style: string;
|
|
45
|
-
};
|
|
46
|
-
declare const Image: import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/extensions/wpg-group.d.ts
|
|
49
|
-
interface FillColor {
|
|
50
|
-
value?: string;
|
|
51
|
-
}
|
|
52
|
-
interface Fill {
|
|
53
|
-
type?: string;
|
|
54
|
-
color?: FillColor;
|
|
55
|
-
}
|
|
56
|
-
interface Outline {
|
|
57
|
-
type?: string;
|
|
58
|
-
color?: FillColor;
|
|
59
|
-
width?: number;
|
|
60
|
-
dash?: string;
|
|
61
|
-
}
|
|
62
|
-
/** wps shape data (WpsShapeCoreOptions subset used for rendering). */
|
|
63
|
-
interface WpsBodyProperties {
|
|
64
|
-
rotation?: number;
|
|
65
|
-
lIns?: number;
|
|
66
|
-
tIns?: number;
|
|
67
|
-
rIns?: number;
|
|
68
|
-
bIns?: number;
|
|
69
|
-
vert?: string;
|
|
70
|
-
}
|
|
71
|
-
interface WpsData {
|
|
72
|
-
fill?: Fill;
|
|
73
|
-
outline?: Outline;
|
|
74
|
-
bodyProperties?: WpsBodyProperties & Record<string, unknown>;
|
|
75
|
-
children?: unknown[];
|
|
76
|
-
}
|
|
77
|
-
type Spec = ReadonlyArray<unknown>;
|
|
78
|
-
/** wps text-body paragraphs (office-open ParagraphOptions[]) → inline HTML runs
|
|
79
|
-
* so a text-box shape shows its text. Each paragraph's run defaults merge with
|
|
80
|
-
* each text run; renderRunStyles converts font/color/size/… to CSS. Advanced run
|
|
81
|
-
* props (shadow w14RawXml, kern) are carried in attrs but not rendered. */
|
|
82
|
-
declare function renderWpsText(children: unknown): Spec[];
|
|
83
|
-
/**
|
|
84
|
-
* Render a wps shape's interior (fill/outline/insets/rotation/writing-mode + text
|
|
85
|
-
* body) as a positioned div. Shared by the wpg group's inline wps children and
|
|
86
|
-
* the standalone wpsShape node, so a text-box shape renders identically whether
|
|
87
|
-
* it floats alone (wp:anchor > wps:wsp) or sits inside a group. `positionStyle`
|
|
88
|
-
* carries the placement — absolute group coords for a group child, the floating
|
|
89
|
-
* anchor CSS for a standalone shape. `opts.rotation` overrides bodyPr rotation
|
|
90
|
-
* (a group child's rotation may come from the group transform, not bodyPr).
|
|
91
|
-
*/
|
|
92
|
-
declare function renderWpsInterior(data: WpsData, positionStyle: string, opts?: {
|
|
93
|
-
rotation?: number;
|
|
94
|
-
attrs?: Record<string, string>;
|
|
95
|
-
}): Spec;
|
|
96
|
-
declare const WpgGroup: Node<any, any>;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/extensions/wps-shape.d.ts
|
|
99
|
-
declare const WpsShape: Node<any, any>;
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/extensions/passthrough.d.ts
|
|
102
|
-
/**
|
|
103
|
-
* Passthrough — block atom carrying an opaque {@link SectionChild} that has
|
|
104
|
-
* no native Tiptap representation (rawXml, bookmarkStart/End, toc, textbox,
|
|
105
|
-
* altChunk, subDoc, customXml).
|
|
106
|
-
*
|
|
107
|
-
* The full SectionChild is stored as JSON in `attrs.data` so the DOCX→JSON→DOCX
|
|
108
|
-
* round-trip stays byte-faithful: office-open's stringify handles the inner
|
|
109
|
-
* structure verbatim (including a textbox's nested children, which remain as
|
|
110
|
-
* structured ParagraphOptions inside the blob rather than editable Tiptap
|
|
111
|
-
* nodes). The node is not editable — it renders a read-only placeholder in HTML.
|
|
112
|
-
*
|
|
113
|
-
* DOCX serialization is inlined in DocxManager (compile/resolve read/write
|
|
114
|
-
* `attrs.data` directly), so no renderDocx/parseDocx is needed here.
|
|
115
|
-
*/
|
|
116
|
-
declare const Passthrough: Node<any, any>;
|
|
117
|
-
//#endregion
|
|
118
|
-
//#region src/extensions/extensions.d.ts
|
|
119
|
-
declare const tiptapNodeExtensions: AnyExtension[];
|
|
120
|
-
declare const tiptapMarkExtensions: AnyExtension[];
|
|
121
|
-
declare const docxExtensions: AnyExtension[];
|
|
122
|
-
interface DocxKitOptions {
|
|
123
|
-
bold?: Record<string, any> | false;
|
|
124
|
-
blockquote?: Record<string, any> | false;
|
|
125
|
-
bulletList?: Record<string, any> | false;
|
|
126
|
-
code?: Record<string, any> | false;
|
|
127
|
-
codeBlock?: Record<string, any> | false;
|
|
128
|
-
document?: false;
|
|
129
|
-
hardBreak?: Record<string, any> | false;
|
|
130
|
-
heading?: Record<string, any> | false;
|
|
131
|
-
horizontalRule?: Record<string, any> | false;
|
|
132
|
-
italic?: Record<string, any> | false;
|
|
133
|
-
listItem?: Record<string, any> | false;
|
|
134
|
-
link?: Record<string, any> | false;
|
|
135
|
-
orderedList?: Record<string, any> | false;
|
|
136
|
-
paragraph?: Record<string, any> | false;
|
|
137
|
-
strike?: Record<string, any> | false;
|
|
138
|
-
text?: false;
|
|
139
|
-
underline?: Record<string, any> | false;
|
|
140
|
-
}
|
|
141
|
-
declare const DocxKit: Extension<DocxKitOptions, any>;
|
|
142
|
-
//#endregion
|
|
143
|
-
//#region src/extensions/page-break.d.ts
|
|
144
|
-
/**
|
|
145
|
-
* PageBreak — inline atom node for DOCX page breaks (`<w:br w:type="page"/>`).
|
|
146
|
-
*
|
|
147
|
-
* OOXML page breaks live inside a run (inline), so the Tiptap node is inline
|
|
148
|
-
* too (group "inline"). This keeps a break inside its paragraph on round-trip
|
|
149
|
-
* — a break mid-paragraph stays mid-paragraph instead of splitting the
|
|
150
|
-
* paragraph into separate blocks (which would lose the original structure).
|
|
151
|
-
* Sibling to HardBreak: both render `<w:br>`, differing only by type.
|
|
152
|
-
*
|
|
153
|
-
* The DOCX payload (`{ pageBreak: true }`) is inlined in DocxManager — a
|
|
154
|
-
* one-liner with no per-node variance, so no extension helper for it.
|
|
155
|
-
*
|
|
156
|
-
* Inserting a page break must also visually reflow (the C-route paginator only
|
|
157
|
-
* forces a new page after a block *containing* a pageBreak atom). So
|
|
158
|
-
* `setPageBreak` inserts the atom then splits the paragraph — the atom lands at
|
|
159
|
-
* the end of the first half, the trailing text becomes a fresh paragraph, and
|
|
160
|
-
* the paginator's `forcesPageBreakAfter` moves it to the next page (matching
|
|
161
|
-
* Word's Ctrl+Enter behavior).
|
|
162
|
-
*/
|
|
163
|
-
declare const PageBreak: Node<any, any>;
|
|
164
|
-
declare module "@tiptap/core" {
|
|
165
|
-
interface Commands<ReturnType> {
|
|
166
|
-
pageBreak: {
|
|
167
|
-
/** Insert a page break at the cursor and split the paragraph so the
|
|
168
|
-
* trailing content reflows to the next page. */
|
|
169
|
-
setPageBreak: () => ReturnType;
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
//#endregion
|
|
174
|
-
export { parseDocx as C, Image as S, renderDocx as T, WpgGroup as _, JSONContent$1 as a, renderWpsText as b, PageBreak as c, TextAlign as d, docxExtensions as f, WpsShape as g, Passthrough as h, Extensions as i, DocxKit as l, tiptapNodeExtensions as m, Editor as n, Mark as o, tiptapMarkExtensions as p, Extension as r, Node as s, AnyExtension as t, DocxKitOptions as u, WpsData as v, renderCropAttrs as w, CropRenderContext as x, renderWpsInterior as y };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/extensions/document.d.ts
|
|
2
|
-
declare function createDocument(content?: string): import("@tiptap/core").Node<any, any>;
|
|
3
|
-
/** Default flat Document (`doc > block+`) — the DOCX round-trip shape. */
|
|
4
|
-
declare const Document: import("@tiptap/core").Node<any, any>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { createDocument as n, Document as t };
|