@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
@@ -1,2 +1,285 @@
1
- import { a as stylesToCss, i as quickStyles, n as effectiveRunProps, r as inlineStyles, t as defaultParagraphStyleId } from "../styles-QSX3RhxK.mjs";
1
+ import { renderParagraphStyles, renderRunStyles, resolveFontName } from "../extensions/utils.mjs";
2
+ //#region src/converters/styles.ts
3
+ /** Escape a style id for safe use in a CSS class selector. OOXML style ids are
4
+ * NCNames so this is rarely needed, but it keeps arbitrary ids safe. */
5
+ function escapeClass(id) {
6
+ return id.replace(/[^A-Za-z0-9_-]/g, (ch) => `\\${ch}`);
7
+ }
8
+ /** The pStyle val (class hook `docx-style-{id}`) for a built-in named style
9
+ * nested under DefaultStylesOptions: the key with its first letter upper-cased
10
+ * ("heading1" → "Heading1", "title" → "Title", "listParagraph" → "ListParagraph").
11
+ * This matches office-open's HeadingLevel literals / pStyle ids, so we derive
12
+ * the id from the key instead of hard-coding a name table. */
13
+ function pStyleIdFromKey(key) {
14
+ return key.charAt(0).toUpperCase() + key.slice(1);
15
+ }
16
+ /** The styleId of the document's default paragraph style (`w:default="1"`
17
+ * type="paragraph") — the implicit style applied to every paragraph WITHOUT an
18
+ * explicit pStyle. OOXML renders a pStyle-less paragraph as this style (usually
19
+ * "Normal"), so the editor's `.docx-default` class — emitted by Paragraph/
20
+ * Heading renderHTML on a styleId-less node — targets it. Searched in
21
+ * `paragraphStyles` and the built-in named styles nested under `default`
22
+ * (key → pStyle id). null when the document declares none. */
23
+ function defaultParagraphStyleId(styles) {
24
+ if (!styles) return null;
25
+ for (const ps of styles.paragraphStyles ?? []) if (ps.default) return ps.id;
26
+ const defaults = styles.default;
27
+ for (const [key, style] of Object.entries(defaults ?? {})) {
28
+ if (key === "document" || !style) continue;
29
+ if (style.default) return pStyleIdFromKey(key);
30
+ }
31
+ return null;
32
+ }
33
+ /**
34
+ * Generate scoped CSS from a document's `styles.xml` model (`StylesOptions`) so
35
+ * named paragraph/character styles and the document defaults render correctly
36
+ * in the editor. All rules are scoped to `.docen-page` (the editor's page
37
+ * surface); the editor injects the result into a `<style>` after load.
38
+ *
39
+ * - `default.document` → `.docen-page` base run + paragraph defaults (the doc's
40
+ * default font/size, line spacing, …).
41
+ * - `paragraphStyles[]` → `.docen-page .docx-style-{id}` (run + paragraph CSS).
42
+ * Paragraph nodes carry `class="docx-style-{styleId}"` (see the Paragraph /
43
+ * Heading extensions' pStyle ↔ styleId round-trip).
44
+ * - `characterStyles[]` → `.docen-page .docx-char-{id}` (run CSS).
45
+ *
46
+ * `basedOn` inheritance is deep-merged per-property into each named style's
47
+ * rule (root first, child overrides) — see mergeStyleChain. CSS inheritance
48
+ * follows the DOM tree, not a style's basedOn, so each `.docx-style-{id}` rule
49
+ * carries its full ancestor chain rather than relying on source order.
50
+ */
51
+ function stylesToCss(styles, scope) {
52
+ if (!styles) return "";
53
+ const rules = [];
54
+ const within = scope ? `${scope} ` : "";
55
+ const doc = styles.default?.document;
56
+ if (doc) {
57
+ const runDecls = doc.run ? renderRunStyles(doc.run) : [];
58
+ if (runDecls.length && scope) rules.push(`${scope} { ${runDecls.join(";")} }`);
59
+ const paraDecls = doc.paragraph ? renderParagraphStyles(doc.paragraph) : [];
60
+ if (paraDecls.length) {
61
+ const paraSel = `${within}p, ${within}h1, ${within}h2, ${within}h3, ${within}h4, ${within}h5, ${within}h6`;
62
+ rules.push(`${paraSel} { ${paraDecls.join(";")} }`);
63
+ }
64
+ }
65
+ const byId = indexParagraphStyles(styles);
66
+ const defaultId = defaultParagraphStyleId(styles);
67
+ for (const id of byId.keys()) {
68
+ const { run, paragraph } = mergeStyleChain(byId, id);
69
+ const decls = [];
70
+ if (Object.keys(run).length) decls.push(...renderRunStyles(run));
71
+ if (Object.keys(paragraph).length) decls.push(...renderParagraphStyles(paragraph));
72
+ if (!decls.length) continue;
73
+ const selector = id === defaultId ? `${within}.docx-default, ${within}.docx-style-${escapeClass(id)}` : `${within}.docx-style-${escapeClass(id)}`;
74
+ rules.push(`${selector} { ${decls.join(";")} }`);
75
+ }
76
+ for (const cs of styles.characterStyles ?? []) {
77
+ const decls = [];
78
+ if (cs.run) decls.push(...renderRunStyles(cs.run));
79
+ if (decls.length) rules.push(`${within}.docx-char-${escapeClass(cs.id)} { ${decls.join(";")} }`);
80
+ }
81
+ return rules.join("\n");
82
+ }
83
+ /** Build an id → style-entry index over every paragraph style: the explicit
84
+ * `paragraphStyles` plus the built-in named styles nested under `default`
85
+ * (key → pStyle id via pStyleIdFromKey). `document` is docDefaults, not a
86
+ * named style, so it is excluded. A built-in that also appears in
87
+ * paragraphStyles is deduped by id (paragraphStyles wins on insertion order). */
88
+ function indexParagraphStyles(styles) {
89
+ const byId = /* @__PURE__ */ new Map();
90
+ for (const ps of styles.paragraphStyles ?? []) byId.set(ps.id, ps);
91
+ const defaults = styles.default;
92
+ for (const [key, style] of Object.entries(defaults ?? {})) {
93
+ if (key === "document" || !style) continue;
94
+ byId.set(pStyleIdFromKey(key), style);
95
+ }
96
+ return byId;
97
+ }
98
+ /** Merge a paragraph style's run/paragraph properties with its `basedOn` chain
99
+ * (root first, child overrides per-property) — the OOXML inheritance model. A
100
+ * flat property-level merge: a child property overrides the parent's; an unset
101
+ * property is inherited. Shared by stylesToCss (rendering) and
102
+ * effectiveRunProps (the caret resolver) so the gallery box and the rendered
103
+ * page resolve identical values. */
104
+ function mergeStyleChain(byId, styleId) {
105
+ const chain = [];
106
+ const visited = /* @__PURE__ */ new Set();
107
+ let curId = styleId || void 0;
108
+ while (curId && !visited.has(curId)) {
109
+ visited.add(curId);
110
+ const style = byId.get(curId);
111
+ if (!style) break;
112
+ chain.unshift(style);
113
+ curId = style.basedOn ?? void 0;
114
+ }
115
+ const run = {};
116
+ const paragraph = {};
117
+ for (const style of chain) {
118
+ const s = style;
119
+ if (s.run) Object.assign(run, s.run);
120
+ if (s.paragraph) Object.assign(paragraph, s.paragraph);
121
+ }
122
+ return {
123
+ run,
124
+ paragraph
125
+ };
126
+ }
127
+ /** The `DefaultStylesOptions` keys whose values are character styles, not
128
+ * paragraph styles. The Quick Styles gallery is paragraph-only, so these are
129
+ * excluded even when flagged `quickFormat` (the authoritative source is
130
+ * office-open's DefaultStylesOptions interface). */
131
+ const CHARACTER_DEFAULT_KEYS = new Set([
132
+ "hyperlink",
133
+ "footnoteReference",
134
+ "footnoteTextChar",
135
+ "endnoteReference",
136
+ "endnoteTextChar"
137
+ ]);
138
+ /**
139
+ * The paragraph styles to list in the Quick Styles gallery, matching Word's
140
+ * default behavior: the gallery is a *paragraph-style* selector (it applies a
141
+ * pStyle), so only paragraph styles appear — never character styles, even
142
+ * those flagged `quickFormat` (those live in the Styles task pane). Among
143
+ * paragraph styles, only those flagged `quickFormat` are listed, ordered by
144
+ * `uiPriority` (Word orders the gallery this way).
145
+ *
146
+ * Reads `quickFormat`/`uiPriority`/`name` straight from office-open's styles
147
+ * model (`StylesOptions`): `paragraphStyles` (Normal + custom) and the built-in
148
+ * named paragraph styles nested under `default` (title/heading1-9/quote/…). The
149
+ * `default` keys that hold character styles are excluded via
150
+ * `CHARACTER_DEFAULT_KEYS`. When a document carries no quickFormat flags at all
151
+ * (e.g. some LibreOffice-generated files), fall back to all paragraph styles so
152
+ * the gallery is never empty.
153
+ */
154
+ function quickStyles(styles) {
155
+ if (!styles) return [];
156
+ const all = [];
157
+ const seen = /* @__PURE__ */ new Set();
158
+ const push = (id, style) => {
159
+ if (seen.has(id)) return;
160
+ seen.add(id);
161
+ all.push({
162
+ id,
163
+ name: style.name || id,
164
+ uiPriority: style.uiPriority ?? 9999,
165
+ quick: !!style.quickFormat
166
+ });
167
+ };
168
+ for (const ps of styles.paragraphStyles ?? []) push(ps.id, ps);
169
+ const defaults = styles.default;
170
+ for (const [key, style] of Object.entries(defaults)) {
171
+ if (key === "document" || CHARACTER_DEFAULT_KEYS.has(key) || !style) continue;
172
+ push(pStyleIdFromKey(key), style);
173
+ }
174
+ const byPriority = (a, b) => a.uiPriority - b.uiPriority;
175
+ const quick = all.filter((s) => s.quick).sort(byPriority);
176
+ return (quick.length > 0 ? quick : all).map(({ id, name }) => ({
177
+ id,
178
+ name
179
+ }));
180
+ }
181
+ /** Resolve the effective run-level properties (font name, size in points) at the
182
+ * caret, staying in the document's own units — no px conversion. Priority:
183
+ * direct run props (the textStyle mark) → the paragraph style (`styleId`) →
184
+ * its `basedOn` chain → the document defaults. `font` is resolved to a single
185
+ * display name (ascii/hAnsi/eastAsia). Returns null where nothing in the chain
186
+ * sets a property, so the caller can leave the box empty. */
187
+ function effectiveRunProps(styles, styleId, direct) {
188
+ let font = null;
189
+ let size = null;
190
+ if (direct) {
191
+ font = resolveFontName(direct.font);
192
+ if (typeof direct.size === "number" && direct.size > 0) size = direct.size;
193
+ }
194
+ if ((font == null || size == null) && styles) {
195
+ const effStyleId = styleId || defaultParagraphStyleId(styles);
196
+ const { run } = mergeStyleChain(indexParagraphStyles(styles), effStyleId);
197
+ if (font == null) font = resolveFontName(run.font);
198
+ if (size == null && typeof run.size === "number" && run.size > 0) size = run.size;
199
+ if (font == null || size == null) {
200
+ const docRun = styles.default?.document?.run;
201
+ if (docRun) {
202
+ if (font == null) font = resolveFontName(docRun.font);
203
+ if (size == null && typeof docRun.size === "number" && docRun.size > 0) size = docRun.size;
204
+ }
205
+ }
206
+ }
207
+ return {
208
+ font,
209
+ size
210
+ };
211
+ }
212
+ /** Index a document's character styles (explicit `characterStyles` + the
213
+ * built-in character keys under `default`) by pStyle id → run properties. Core
214
+ * phase: a character style's own run only (its basedOn chain is not walked —
215
+ * rare in practice; paragraph styles above already deep-merge). */
216
+ function indexCharacterRunStyles(styles) {
217
+ const byId = /* @__PURE__ */ new Map();
218
+ for (const cs of styles.characterStyles ?? []) if (cs.run) byId.set(cs.id, cs.run);
219
+ const defaults = styles.default;
220
+ for (const [key, style] of Object.entries(defaults ?? {})) {
221
+ if (!style || !style.run || key === "document") continue;
222
+ if (!CHARACTER_DEFAULT_KEYS.has(key)) continue;
223
+ byId.set(pStyleIdFromKey(key), style.run);
224
+ }
225
+ return byId;
226
+ }
227
+ /** Resolve one node's style inheritance: a paragraph/heading absorbs its
228
+ * styleId's basedOn chain (paragraph properties + the default `run`); a
229
+ * textStyle mark absorbs its character style's run. Explicit attrs/marks
230
+ * override the inherited values; styleId is preserved. Pure JSON — no DOM, no
231
+ * marks pushed onto text. */
232
+ function resolveNode(node, paraById, charRunById) {
233
+ const out = { ...node };
234
+ const attrs = node.attrs;
235
+ const type = node.type;
236
+ if ((type === "paragraph" || type === "heading") && attrs?.styleId) {
237
+ const { paragraph, run } = mergeStyleChain(paraById, attrs.styleId);
238
+ const mergedRun = {
239
+ ...run,
240
+ ...attrs.run
241
+ };
242
+ out.attrs = {
243
+ ...paragraph,
244
+ ...attrs,
245
+ run: mergedRun
246
+ };
247
+ }
248
+ if (node.marks) out.marks = node.marks.map((m) => {
249
+ if (m.type !== "textStyle") return m;
250
+ const sid = m.attrs?.styleId;
251
+ const crun = sid ? charRunById.get(sid) : void 0;
252
+ return crun ? {
253
+ ...m,
254
+ attrs: {
255
+ ...crun,
256
+ ...m.attrs
257
+ }
258
+ } : m;
259
+ });
260
+ if (node.content) out.content = node.content.map((c) => resolveNode(c, paraById, charRunById));
261
+ return out;
262
+ }
263
+ /**
264
+ * Inline a document's styles into each node's attrs — a self-contained
265
+ * JSONContent that round-trips and renders without the styles context. A
266
+ * paragraph/heading absorbs its styleId's `basedOn` chain (paragraph properties
267
+ * + the paragraph's default `run`); a textStyle mark absorbs its character
268
+ * style's run. Explicit attrs/marks always override the inherited values;
269
+ * styleId is preserved (the semantic reference is kept). The style definitions
270
+ * themselves are untouched — only properties are copied onto nodes.
271
+ *
272
+ * Styles default to the document's own `attrs.styles` (the round-tripped
273
+ * styles.xml model carried on the doc node), so `inlineStyles(doc)` needs no
274
+ * second argument; pass `styles` explicitly to override. Use cases:
275
+ * cross-document paste (the snippet carries its styling) and self-contained
276
+ * export. The editor still renders via global styles — this only merges JSON
277
+ * properties.
278
+ */
279
+ function inlineStyles(json, styles) {
280
+ const docStyles = styles ?? json.attrs?.styles;
281
+ if (!docStyles) return json;
282
+ return resolveNode(json, indexParagraphStyles(docStyles), indexCharacterRunStyles(docStyles));
283
+ }
284
+ //#endregion
2
285
  export { defaultParagraphStyleId, effectiveRunProps, inlineStyles, quickStyles, stylesToCss };
@@ -0,0 +1,174 @@
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 };