@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,406 +0,0 @@
1
- import { B as UndoRedo, C as Mention, D as Subscript, F as Text, I as TextAlign$1, 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 "./blockquote-Ky9xD_Q-.mjs";
3
- import { t as CodeBlock } from "./code-block-BgNjhADy.mjs";
4
- import "./details-Dh8luWb2.mjs";
5
- import { t as Document } from "./document-CvTym-FM.mjs";
6
- import { t as Emoji } from "./emoji-C2OsTWR7.mjs";
7
- import { t as Heading } from "./heading-DAubgJJN.mjs";
8
- import { t as Image } from "./image-CuEIXoZl.mjs";
9
- import { t as encodeBase64 } from "./dist-B6B3HnVZ.mjs";
10
- import "./mention-C-dTR6MK.mjs";
11
- import "./ordered-list-V-3xFQmV.mjs";
12
- import { t as Paragraph } from "./paragraph-BrWH-BOV.mjs";
13
- import { t as Strike } from "./strike-hWxShOgb.mjs";
14
- import { t as Table } from "./table-DrA12lxX.mjs";
15
- import { t as TableCell } from "./table-cell-DmkfYwDc.mjs";
16
- import { t as TableHeader } from "./table-header-Bwr5GKWg.mjs";
17
- import { t as TableRow } from "./table-row-vew1y7WH.mjs";
18
- import "./task-item-BnlXGrIG.mjs";
19
- import { t as TextStyle } from "./text-style-tMeBq5XQ.mjs";
20
- import { Editor, Extension, Mark, Node } from "@tiptap/core";
21
- import { all, createLowlight } from "lowlight";
22
- import { TextAlign } from "@tiptap/extension-text-align";
23
- import { Plugin, PluginKey } from "@tiptap/pm/state";
24
- import { Decoration, DecorationSet } from "@tiptap/pm/view";
25
- //#region src/extensions/column-break.ts
26
- /**
27
- * ColumnBreak — inline atom node for DOCX column breaks (`<w:br w:type="column"/>`).
28
- *
29
- * Sibling to PageBreak and HardBreak: all three render `<w:br>`, differing only
30
- * by type. Inline (group "inline") to match the run-internal OOXML position,
31
- * keeping a column break inside its paragraph on round-trip. Visual column
32
- * layout (paged.js multi-column) is a future concern; the node preserves the
33
- * break losslessly regardless.
34
- *
35
- * The DOCX payload (`{ columnBreak: true }`) is inlined in DocxManager — a
36
- * one-liner with no per-node variance, so no extension helper for it.
37
- *
38
- * `setColumnBreak` only inserts the atom (no paragraph split): a column break
39
- * does not start a new page, and there is no column layout to reflow yet, so
40
- * the node is purely for round-trip fidelity until multi-column lands.
41
- */
42
- const ColumnBreak = Node.create({
43
- name: "columnBreak",
44
- inline: true,
45
- group: "inline",
46
- atom: true,
47
- parseHTML() {
48
- return [{ tag: "span[data-type=\"columnBreak\"]" }, { tag: "br[data-type=\"columnBreak\"]" }];
49
- },
50
- renderHTML() {
51
- return ["span", {
52
- "data-type": "columnBreak",
53
- style: "break-after:column"
54
- }];
55
- },
56
- addCommands() {
57
- return { setColumnBreak: () => ({ commands }) => commands.insertContent({ type: "columnBreak" }) };
58
- }
59
- });
60
- //#endregion
61
- //#region src/extensions/formatting-marks.ts
62
- /** Plugin key holding the on/off boolean for formatting marks. Toggled via a
63
- * transaction meta so `decorations` recomputes when the user flips the Show/
64
- * Hide button. */
65
- const FORMAT_MARKS_KEY = new PluginKey("docen-formatting-marks");
66
- /**
67
- * FormattingMarks — paints the non-printing paragraph mark via ProseMirror
68
- * widget decorations.
69
- *
70
- * CSS `p::after { content: "…" }` does NOT work on a ProseMirror-managed
71
- * paragraph: the view owns the DOM and the trailing-break kludge pushes the
72
- * pseudo-element off the visible line, so the mark never appears (verified).
73
- * Marijn Haverbeke endorses widget decorations for exactly this use case
74
- * (https://discuss.prosemirror.net/t/1442). Each textblock gets a widget at its
75
- * closing position (inside the textblock, so it stays on the content's line)
76
- * holding a non-editable `<span class="docen-para-mark">`. `side: 1` keeps the
77
- * mark to the right of a cursor resting at the paragraph end (the cursor always
78
- * precedes its own paragraph mark).
79
- *
80
- * Glyph: a down-then-left return arrow (↲, U+21B2 "downwards arrow with tip
81
- * leftwards" — the Enter-key glyph). Word/WPS use the pilcrow ¶ for paragraph
82
- * marks; that down-then-left arrow is Word's line-break glyph — adopted here as
83
- * the paragraph mark per the project's visual preference.
84
- */
85
- const FormattingMarks = Extension.create({
86
- name: "formattingMarks",
87
- addProseMirrorPlugins() {
88
- return [new Plugin({
89
- key: FORMAT_MARKS_KEY,
90
- state: {
91
- init: () => false,
92
- apply: (tr, value) => {
93
- if (tr.getMeta(FORMAT_MARKS_KEY) === "toggle") return !value;
94
- return value;
95
- }
96
- },
97
- props: { decorations(state) {
98
- if (!FORMAT_MARKS_KEY.getState(state)) return DecorationSet.empty;
99
- const decos = [];
100
- state.doc.descendants((node, pos) => {
101
- if (!node.isTextblock) return;
102
- decos.push(Decoration.widget(pos + node.nodeSize - 1, () => {
103
- const span = document.createElement("span");
104
- span.className = "docen-para-mark";
105
- span.contentEditable = "false";
106
- span.textContent = "↲";
107
- return span;
108
- }, { side: 1 }));
109
- });
110
- return DecorationSet.create(state.doc, decos);
111
- } }
112
- })];
113
- },
114
- addCommands() {
115
- return { toggleFormattingMarks: () => ({ tr, dispatch }) => {
116
- if (dispatch) dispatch(tr.setMeta(FORMAT_MARKS_KEY, "toggle"));
117
- return true;
118
- } };
119
- }
120
- });
121
- //#endregion
122
- //#region src/extensions/image-group.ts
123
- /**
124
- * ImageGroup — inline atom node carrying a DOCX drawing group (wpg:
125
- * wordprocessingGroup) as an opaque blob. A group bundles pictures, shapes, and
126
- * nested groups behind a shared transform; the editor doesn't model its
127
- * interior — the full WpgGroupRunOptions round-trips verbatim in attrs.wpgGroup.
128
- *
129
- * renderHTML paints the first picture (common case: a single-logo header group)
130
- * so the group is visible; shapes/nested groups fall back to a placeholder.
131
- * Structured group/shape editing is a separate phase.
132
- */
133
- const EMU_PER_PX = 9525;
134
- /** Extract the first picture (pic/MediaData) from a group for display. */
135
- function firstPicture(group) {
136
- const pic = group?.children?.find((c) => {
137
- const t = c.type;
138
- return typeof t === "string" && t !== "wps" && t !== "wpg";
139
- });
140
- if (!pic?.data) return null;
141
- const bytes = pic.data instanceof Uint8Array ? pic.data : new Uint8Array(Object.values(pic.data));
142
- const width = pic.transformation?.width;
143
- const height = pic.transformation?.height;
144
- return {
145
- src: `data:image/${pic.type};base64,${encodeBase64(bytes)}`,
146
- width: typeof width === "number" ? Math.round(width / EMU_PER_PX) : void 0,
147
- height: typeof height === "number" ? Math.round(height / EMU_PER_PX) : void 0
148
- };
149
- }
150
- const attrWpgGroup = () => ({
151
- default: null,
152
- rendered: false,
153
- parseHTML: (element) => {
154
- const raw = element.getAttribute("data-wpg-group");
155
- if (!raw) return null;
156
- try {
157
- return JSON.parse(raw);
158
- } catch {
159
- return null;
160
- }
161
- }
162
- });
163
- const ImageGroup = Node.create({
164
- name: "imageGroup",
165
- group: "inline",
166
- inline: true,
167
- atom: true,
168
- addAttributes() {
169
- return { wpgGroup: attrWpgGroup() };
170
- },
171
- parseHTML() {
172
- return [{ tag: "span[data-image-group]" }];
173
- },
174
- renderHTML({ node }) {
175
- const attrs = {
176
- "data-image-group": "",
177
- contenteditable: "false"
178
- };
179
- const pic = firstPicture(node.attrs.wpgGroup);
180
- if (pic) {
181
- const imgAttrs = {
182
- src: pic.src,
183
- alt: ""
184
- };
185
- if (pic.width && pic.height) imgAttrs.style = `width:${pic.width}px;height:${pic.height}px`;
186
- return [
187
- "span",
188
- attrs,
189
- ["img", imgAttrs]
190
- ];
191
- }
192
- return [
193
- "span",
194
- attrs,
195
- "♢"
196
- ];
197
- }
198
- });
199
- //#endregion
200
- //#region src/extensions/page-break.ts
201
- /**
202
- * PageBreak — inline atom node for DOCX page breaks (`<w:br w:type="page"/>`).
203
- *
204
- * OOXML page breaks live inside a run (inline), so the Tiptap node is inline
205
- * too (group "inline"). This keeps a break inside its paragraph on round-trip
206
- * — a break mid-paragraph stays mid-paragraph instead of splitting the
207
- * paragraph into separate blocks (which would lose the original structure).
208
- * Sibling to HardBreak: both render `<w:br>`, differing only by type.
209
- *
210
- * The DOCX payload (`{ pageBreak: true }`) is inlined in DocxManager — a
211
- * one-liner with no per-node variance, so no extension helper for it.
212
- *
213
- * Inserting a page break must also visually reflow (the C-route paginator only
214
- * forces a new page after a block *containing* a pageBreak atom). So
215
- * `setPageBreak` inserts the atom then splits the paragraph — the atom lands at
216
- * the end of the first half, the trailing text becomes a fresh paragraph, and
217
- * the paginator's `forcesPageBreakAfter` moves it to the next page (matching
218
- * Word's Ctrl+Enter behavior).
219
- */
220
- const PageBreak = Node.create({
221
- name: "pageBreak",
222
- inline: true,
223
- group: "inline",
224
- atom: true,
225
- parseHTML() {
226
- return [{ tag: "span[data-type=\"pageBreak\"]" }, { tag: "br[data-type=\"pageBreak\"]" }];
227
- },
228
- renderHTML() {
229
- return ["span", {
230
- "data-type": "pageBreak",
231
- style: "break-after:page"
232
- }];
233
- },
234
- addCommands() {
235
- return { setPageBreak: () => ({ tr, state, dispatch }) => {
236
- if (!dispatch) return true;
237
- tr.replaceSelectionWith(state.schema.nodes.pageBreak.create());
238
- tr.split(tr.selection.from, 1);
239
- tr.scrollIntoView();
240
- return true;
241
- } };
242
- }
243
- });
244
- //#endregion
245
- //#region src/extensions/passthrough.ts
246
- /**
247
- * Passthrough — block atom carrying an opaque {@link SectionChild} that has
248
- * no native Tiptap representation (rawXml, bookmarkStart/End, toc, textbox,
249
- * altChunk, subDoc, customXml).
250
- *
251
- * The full SectionChild is stored as JSON in `attrs.data` so the DOCX→JSON→DOCX
252
- * round-trip stays byte-faithful: office-open's stringify handles the inner
253
- * structure verbatim (including a textbox's nested children, which remain as
254
- * structured ParagraphOptions inside the blob rather than editable Tiptap
255
- * nodes). The node is not editable — it renders a read-only placeholder in HTML.
256
- *
257
- * DOCX serialization is inlined in DocxManager (compile/resolve read/write
258
- * `attrs.data` directly), so no renderDocx/parseDocx is needed here.
259
- */
260
- const Passthrough = Node.create({
261
- name: "passthrough",
262
- group: "block",
263
- atom: true,
264
- addAttributes() {
265
- return { data: {
266
- default: "{}",
267
- rendered: false
268
- } };
269
- },
270
- parseHTML() {
271
- return [{ tag: "div[data-passthrough]" }];
272
- },
273
- renderHTML({ node }) {
274
- let label = "DOCX";
275
- try {
276
- const parsed = JSON.parse(node.attrs.data || "{}");
277
- const key = Object.keys(parsed)[0];
278
- if (key) label = key;
279
- } catch {}
280
- return [
281
- "div",
282
- {
283
- "data-passthrough": label,
284
- contenteditable: "false",
285
- style: "display:block;padding:0.5em 0.75em;margin:0.5em 0;border:1px dashed #bbb;border-radius:4px;color:#888;font-size:0.85em;background:#fafafa"
286
- },
287
- [
288
- "span",
289
- {},
290
- `[${label}]`
291
- ]
292
- ];
293
- }
294
- });
295
- //#endregion
296
- //#region src/extensions/section-break.ts
297
- /**
298
- * SectionBreak — command extension that marks a paragraph as a section boundary.
299
- *
300
- * OOXML sections (sectPr) attach to a section's LAST paragraph's pPr, NOT a
301
- * standalone node. So this extension provides only the `setSectionBreak`
302
- * command (stamps sectionProperties on the current paragraph); the paragraph
303
- * extension carries the sectionProperties/sectionHeaders/sectionFooters attrs,
304
- * and DocxManager splits/merges sections in compile/resolve by reading them off
305
- * the paragraph.
306
- *
307
- * The final section's sectPr rides on doc.attrs.sectionProperties (it lives at
308
- * <w:body>'s end in OOXML). Single-section documents have no section-carrying
309
- * paragraph at all.
310
- */
311
- const SectionBreak = Extension.create({
312
- name: "sectionBreak",
313
- addCommands() {
314
- return { setSectionBreak: () => ({ commands }) => commands.updateAttributes("paragraph", { sectionProperties: {} }) };
315
- }
316
- });
317
- //#endregion
318
- //#region src/extensions/extensions.ts
319
- const tiptapNodeExtensions = [
320
- Document,
321
- Paragraph,
322
- Text,
323
- HardBreak,
324
- PageBreak,
325
- ColumnBreak,
326
- SectionBreak,
327
- Passthrough,
328
- Blockquote,
329
- OrderedList,
330
- BulletList,
331
- ListItem,
332
- CodeBlock.configure({ lowlight: createLowlight(all) }),
333
- Details,
334
- DetailsSummary,
335
- DetailsContent,
336
- Emoji,
337
- HorizontalRule,
338
- Image.configure({ inline: true }),
339
- ImageGroup,
340
- Mathematics,
341
- Mention,
342
- Table,
343
- TableRow,
344
- TableCell,
345
- TableHeader,
346
- TaskList,
347
- TaskItem,
348
- Heading,
349
- TextAlign$1.configure({ types: ["heading", "paragraph"] })
350
- ];
351
- const tiptapMarkExtensions = [
352
- Bold,
353
- Code,
354
- Highlight,
355
- Italic,
356
- Link,
357
- Strike,
358
- Subscript,
359
- Superscript,
360
- TextStyle,
361
- Underline
362
- ];
363
- const docxExtensions = [
364
- ...tiptapNodeExtensions,
365
- ...tiptapMarkExtensions,
366
- FormattingMarks,
367
- UndoRedo,
368
- Dropcursor,
369
- Gapcursor,
370
- TrailingNode,
371
- ListKeymap
372
- ];
373
- const DocxKit = Extension.create({
374
- name: "docxKit",
375
- addExtensions() {
376
- const extensions = [];
377
- if (this.options.bold !== false) extensions.push(Bold.configure(this.options.bold));
378
- if (this.options.blockquote !== false) extensions.push(Blockquote.configure(this.options.blockquote));
379
- if (this.options.bulletList !== false) extensions.push(BulletList.configure(this.options.bulletList));
380
- if (this.options.code !== false) extensions.push(Code.configure(this.options.code));
381
- if (this.options.codeBlock !== false) extensions.push(CodeBlockLowlight.configure({
382
- lowlight: createLowlight(all),
383
- ...this.options.codeBlock
384
- }));
385
- if (this.options.document !== false) extensions.push(Document);
386
- if (this.options.dropcursor !== false) extensions.push(Dropcursor.configure(this.options.dropcursor));
387
- if (this.options.gapcursor !== false) extensions.push(Gapcursor);
388
- if (this.options.hardBreak !== false) extensions.push(HardBreak.configure(this.options.hardBreak));
389
- if (this.options.heading !== false) extensions.push(Heading.configure(this.options.heading));
390
- if (this.options.undoRedo !== false) extensions.push(UndoRedo.configure(this.options.undoRedo));
391
- if (this.options.horizontalRule !== false) extensions.push(HorizontalRule.configure(this.options.horizontalRule));
392
- if (this.options.italic !== false) extensions.push(Italic.configure(this.options.italic));
393
- if (this.options.listItem !== false) extensions.push(ListItem.configure(this.options.listItem));
394
- if (this.options.listKeymap !== false) extensions.push(ListKeymap.configure(this.options.listKeymap));
395
- if (this.options.link !== false) extensions.push(Link.configure(this.options.link));
396
- if (this.options.orderedList !== false) extensions.push(OrderedList.configure(this.options.orderedList));
397
- if (this.options.paragraph !== false) extensions.push(Paragraph.configure(this.options.paragraph));
398
- if (this.options.strike !== false) extensions.push(Strike.configure(this.options.strike));
399
- if (this.options.text !== false) extensions.push(Text);
400
- if (this.options.underline !== false) extensions.push(Underline.configure(this.options.underline));
401
- if (this.options.trailingNode !== false) extensions.push(TrailingNode.configure(this.options.trailingNode));
402
- return extensions;
403
- }
404
- });
405
- //#endregion
406
- export { DocxKit as a, tiptapMarkExtensions as c, Passthrough as d, PageBreak as f, ColumnBreak as h, Node as i, tiptapNodeExtensions as l, FormattingMarks as m, Extension as n, TextAlign as o, ImageGroup as p, Mark as r, docxExtensions as s, Editor as t, SectionBreak as u };
@@ -1,97 +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
- /** 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 };
@@ -1,18 +0,0 @@
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 };