@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,396 @@
1
- import { i as renderDocx, n as parseDocx, r as renderCropAttrs, t as Image } from "../image-CuEIXoZl.mjs";
1
+ import { Image as Image$1 } from "./tiptap.mjs";
2
+ import { floatAnchorScope, floatingToStyles } from "./utils.mjs";
3
+ import { convertEmuToPixels } from "@office-open/core";
4
+ //#region src/extensions/image.ts
5
+ /**
6
+ * Custom Image extension with node-level renderHTML + renderDocx/parseDocx.
7
+ *
8
+ * Attrs:
9
+ * - src/alt/title/width/height: Tiptap structural names (kept verbatim so base
10
+ * image commands work).
11
+ * - rotation: editor display only (CSS transform) but also carried through DOCX
12
+ * via transformation.rotation (MediaTransformation.rotation).
13
+ * - floating/outline: nested office-open objects (Floating / OutlineOptions).
14
+ * - crop: nested office-open SourceRectangleOptions (srcRect).
15
+ * - display: editor-only display hint, no OOXML equivalent.
16
+ *
17
+ * DOCX round-trip is near-identity: renderDocx packs attrs into CoreImageOptions;
18
+ * parseDocx unpacks them back. src is a data URL ↔ { type, data } base64.
19
+ * Node-level renderHTML solves the style merge problem (rotation + floating).
20
+ */
21
+ /** Attribute spec for a nested office-open value stored as JSON in a data-* attr. */
22
+ const attrDataJson = (name) => ({
23
+ default: null,
24
+ rendered: false,
25
+ parseHTML: (element) => {
26
+ const raw = element.getAttribute(name);
27
+ if (!raw) return null;
28
+ try {
29
+ return JSON.parse(raw);
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+ });
35
+ /**
36
+ * Tiptap JSON image node → CoreImageOptions-shaped object.
37
+ *
38
+ * Returns `{ image: ImageOptions }` (structural wrapper) or null when no
39
+ * embedded image data is available (external URLs need pre-fetching).
40
+ * rotation is carried via transformation.rotation (not dropped).
41
+ */
42
+ function renderDocx(node) {
43
+ const attrs = node.attrs ?? {};
44
+ const imageOpts = {};
45
+ const src = attrs.src;
46
+ if (src?.startsWith("data:image/")) {
47
+ const match = src.match(/^data:image\/([\w.+-]+);base64,(.+)$/);
48
+ if (match) {
49
+ imageOpts.type = match[1] === "jpeg" ? "jpg" : match[1];
50
+ const binary = atob(match[2]);
51
+ const bytes = new Uint8Array(binary.length);
52
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
53
+ imageOpts.data = bytes;
54
+ }
55
+ }
56
+ if (!imageOpts.data) return null;
57
+ const width = attrs.width ?? 600;
58
+ const height = attrs.height ?? 400;
59
+ const transformation = {
60
+ width: `${width}px`,
61
+ height: `${height}px`
62
+ };
63
+ const rotation = attrs.rotation;
64
+ if (rotation != null) transformation.rotation = rotation;
65
+ imageOpts.transformation = transformation;
66
+ const altText = {};
67
+ if (attrs.alt) altText.name = attrs.alt;
68
+ if (attrs.title) altText.description = attrs.title;
69
+ if (Object.keys(altText).length > 0) imageOpts.altText = altText;
70
+ if (attrs.floating) imageOpts.floating = attrs.floating;
71
+ if (attrs.crop) imageOpts.sourceRectangle = attrs.crop;
72
+ if (attrs.outline) imageOpts.outline = attrs.outline;
73
+ if (attrs.nonVisualProperties) imageOpts.nonVisualProperties = attrs.nonVisualProperties;
74
+ if (attrs.effectExtent) transformation.effectExtent = attrs.effectExtent;
75
+ if (attrs.graphicFrameLocks) imageOpts.graphicFrameLocks = attrs.graphicFrameLocks;
76
+ if (attrs.blipEffects) imageOpts.blipEffects = attrs.blipEffects;
77
+ if (attrs.useLocalDpi !== null && attrs.useLocalDpi !== void 0) imageOpts.useLocalDpi = attrs.useLocalDpi;
78
+ if (attrs.fill) imageOpts.fill = attrs.fill;
79
+ if (attrs.effects) imageOpts.effects = attrs.effects;
80
+ if (attrs.tile) imageOpts.tile = attrs.tile;
81
+ if (attrs.runPropertiesRawXml) imageOpts.runPropertiesRawXml = attrs.runPropertiesRawXml;
82
+ return { image: imageOpts };
83
+ }
84
+ /**
85
+ * ImageOptions-shaped object → Tiptap attrs.
86
+ *
87
+ * Near-identity unpack: transformation → width/height/rotation, altText → alt/title,
88
+ * floating/srcRect(→crop)/outline passed through verbatim. src is reconstructed by
89
+ * DocxManager from the image data bytes (kept out of parseDocx).
90
+ */
91
+ function parseDocx(imageOpts) {
92
+ const opts = imageOpts ?? {};
93
+ const attrs = {};
94
+ const transformation = opts.transformation;
95
+ if (transformation) {
96
+ if (typeof transformation.width === "number") attrs.width = convertEmuToPixels(transformation.width);
97
+ if (typeof transformation.height === "number") attrs.height = convertEmuToPixels(transformation.height);
98
+ if (typeof transformation.rotation === "number") attrs.rotation = transformation.rotation;
99
+ }
100
+ const altText = opts.altText;
101
+ if (altText) {
102
+ if (altText.name) attrs.alt = altText.name;
103
+ if (altText.description) attrs.title = altText.description;
104
+ }
105
+ if (opts.floating) attrs.floating = opts.floating;
106
+ if (opts.sourceRectangle) attrs.crop = opts.sourceRectangle;
107
+ if (opts.outline) attrs.outline = opts.outline;
108
+ if (opts.nonVisualProperties) attrs.nonVisualProperties = opts.nonVisualProperties;
109
+ const effectExtent = opts.transformation?.effectExtent;
110
+ if (effectExtent) attrs.effectExtent = effectExtent;
111
+ if (opts.graphicFrameLocks) attrs.graphicFrameLocks = opts.graphicFrameLocks;
112
+ if (opts.blipEffects) attrs.blipEffects = opts.blipEffects;
113
+ if (opts.useLocalDpi !== void 0) attrs.useLocalDpi = opts.useLocalDpi;
114
+ if (opts.fill) attrs.fill = opts.fill;
115
+ if (opts.effects) attrs.effects = opts.effects;
116
+ if (opts.tile) attrs.tile = opts.tile;
117
+ if (opts.runPropertiesRawXml) attrs.runPropertiesRawXml = opts.runPropertiesRawXml;
118
+ return attrs;
119
+ }
120
+ /**
121
+ * Render crop as the inner <img> style for byte-accurate four-sided srcRect.
122
+ *
123
+ * object-fit:cover scales uniformly, so it only matches single-axis crops.
124
+ * Instead the inner <img> is sized to the un-cropped display size per axis
125
+ * (imgW = W/visibleW, imgH = H/visibleH) and translated so the visible srcRect
126
+ * region maps exactly onto the extent box; the outer box clips (overflow:hidden)
127
+ * the cropped-out left/top region. Mathematically equivalent to a
128
+ * background-size/background-position crop, but keeps a real <img> (alt,
129
+ * accessibility, semantics, drag-to-save).
130
+ */
131
+ function renderCropAttrs(crop, ctx = {}) {
132
+ const c = crop;
133
+ const leftPct = (c.left || 0) / 1e5;
134
+ const topPct = (c.top || 0) / 1e5;
135
+ const rightPct = (c.right || 0) / 1e5;
136
+ const bottomPct = (c.bottom || 0) / 1e5;
137
+ const visibleW = 1 - leftPct - rightPct;
138
+ const visibleH = 1 - topPct - bottomPct;
139
+ const w = ctx.width ?? 0;
140
+ const h = ctx.height ?? 0;
141
+ const imgW = visibleW > 0 ? w / visibleW : w;
142
+ const imgH = visibleH > 0 ? h / visibleH : h;
143
+ const offX = -(leftPct * imgW);
144
+ const offY = -(topPct * imgH);
145
+ return { style: [
146
+ "display:block",
147
+ `width:${imgW.toFixed(2)}px`,
148
+ `height:${imgH.toFixed(2)}px`,
149
+ `transform:translate(${offX.toFixed(2)}px,${offY.toFixed(2)}px)`,
150
+ "transform-origin:0 0"
151
+ ].join(";") };
152
+ }
153
+ function renderImageStyles(attrs) {
154
+ const styles = [];
155
+ if (attrs.display) styles.push(`display:${attrs.display}`);
156
+ else if (!attrs.floating) styles.push("display:inline-block");
157
+ if (attrs.rotation) styles.push(`transform:rotate(${attrs.rotation}deg)`);
158
+ if (attrs.floating) styles.push(...floatingToStyles(attrs.floating, attrs.src, attrs.width));
159
+ return styles;
160
+ }
161
+ /** Office vector (GDI) formats the browser cannot decode — EMF/WMF render as
162
+ * a labeled placeholder (Image.renderHTML) instead of an <img> that decodes
163
+ * to naturalWidth 0 (an empty box). */
164
+ function isVectorImage(src) {
165
+ return typeof src === "string" && /^data:image\/(?:x-)?(?:emf|wmf)/i.test(src);
166
+ }
167
+ /**
168
+ * Stamp the nested office-open attrs onto an HTML attribute map as JSON
169
+ * data-* pairs. Shared by the cropped-div and plain-img render branches so the
170
+ * fidelity fields (floating/outline/nonVisualProperties/…) round-trip through
171
+ * HTML identically. `crop` is handled separately (crop branch only).
172
+ */
173
+ const RAW_ATTR_DATA = [
174
+ ["floating", "data-floating"],
175
+ ["outline", "data-outline"],
176
+ ["nonVisualProperties", "data-non-visual"],
177
+ ["effectExtent", "data-effect-extent"],
178
+ ["graphicFrameLocks", "data-graphic-frame-locks"],
179
+ ["blipEffects", "data-blip-effects"],
180
+ ["useLocalDpi", "data-use-local-dpi"],
181
+ ["fill", "data-fill"],
182
+ ["effects", "data-effects"],
183
+ ["tile", "data-tile"],
184
+ ["runPropertiesRawXml", "data-run-properties-raw-xml"]
185
+ ];
186
+ function attachRawAttrs(target, attrs) {
187
+ for (const [attr, data] of RAW_ATTR_DATA) {
188
+ const value = attrs[attr];
189
+ if (value !== null && value !== void 0) target[data] = JSON.stringify(value);
190
+ }
191
+ }
192
+ const Image = Image$1.extend({
193
+ addAttributes() {
194
+ return {
195
+ ...this.parent?.(),
196
+ display: {
197
+ default: null,
198
+ rendered: false,
199
+ parseHTML: () => this.options.inline ? "inline-block" : null
200
+ },
201
+ rotation: {
202
+ default: null,
203
+ rendered: false,
204
+ parseHTML: (element) => {
205
+ const match = (element.getAttribute("style") || "").match(/transform:\s*rotate\(([\d.]+)deg\)/);
206
+ return match ? parseFloat(match[1]) : null;
207
+ }
208
+ },
209
+ width: { parseHTML: (element) => {
210
+ const attr = element.getAttribute("width");
211
+ if (attr != null) {
212
+ const n = parseFloat(attr);
213
+ if (!Number.isNaN(n)) return n;
214
+ }
215
+ const m = (element.getAttribute("style") || "").match(/(?:^|;)\s*width:\s*([\d.]+)px/);
216
+ return m ? parseFloat(m[1]) : null;
217
+ } },
218
+ height: { parseHTML: (element) => {
219
+ const attr = element.getAttribute("height");
220
+ if (attr != null) {
221
+ const n = parseFloat(attr);
222
+ if (!Number.isNaN(n)) return n;
223
+ }
224
+ const m = (element.getAttribute("style") || "").match(/(?:^|;)\s*height:\s*([\d.]+)px/);
225
+ return m ? parseFloat(m[1]) : null;
226
+ } },
227
+ floating: {
228
+ default: null,
229
+ rendered: false,
230
+ parseHTML: (element) => {
231
+ const raw = element.getAttribute("data-floating");
232
+ if (!raw) return null;
233
+ try {
234
+ return JSON.parse(raw);
235
+ } catch {
236
+ return null;
237
+ }
238
+ }
239
+ },
240
+ outline: {
241
+ default: null,
242
+ rendered: false,
243
+ parseHTML: (element) => {
244
+ const raw = element.getAttribute("data-outline");
245
+ if (!raw) return null;
246
+ try {
247
+ return JSON.parse(raw);
248
+ } catch {
249
+ return null;
250
+ }
251
+ }
252
+ },
253
+ crop: {
254
+ default: null,
255
+ rendered: false,
256
+ parseHTML: (element) => {
257
+ const raw = element.getAttribute("data-crop");
258
+ if (!raw) return null;
259
+ try {
260
+ return JSON.parse(raw);
261
+ } catch {
262
+ return null;
263
+ }
264
+ }
265
+ },
266
+ nonVisualProperties: attrDataJson("data-non-visual"),
267
+ effectExtent: attrDataJson("data-effect-extent"),
268
+ graphicFrameLocks: attrDataJson("data-graphic-frame-locks"),
269
+ blipEffects: attrDataJson("data-blip-effects"),
270
+ useLocalDpi: attrDataJson("data-use-local-dpi"),
271
+ fill: attrDataJson("data-fill"),
272
+ effects: attrDataJson("data-effects"),
273
+ tile: attrDataJson("data-tile"),
274
+ runPropertiesRawXml: attrDataJson("data-run-properties-raw-xml")
275
+ };
276
+ },
277
+ renderHTML({ node, HTMLAttributes }) {
278
+ const attrs = node.attrs;
279
+ const floatAnchor = attrs.floating && floatAnchorScope(attrs.floating) === "paragraph" ? "paragraph" : null;
280
+ if (isVectorImage(attrs.src)) {
281
+ const styles = renderImageStyles(attrs);
282
+ if (attrs.width != null) styles.push(`width:${attrs.width}px`);
283
+ if (attrs.height != null) styles.push(`height:${attrs.height}px`);
284
+ const divAttrs = {
285
+ "data-image": "vector",
286
+ role: "img",
287
+ "data-vector-src": attrs.src,
288
+ style: styles.join(";")
289
+ };
290
+ if (attrs.alt) divAttrs["aria-label"] = attrs.alt;
291
+ if (attrs.title) divAttrs["title"] = attrs.title;
292
+ attachRawAttrs(divAttrs, attrs);
293
+ if (floatAnchor) divAttrs["data-float-anchor"] = floatAnchor;
294
+ return [
295
+ "div",
296
+ divAttrs,
297
+ "Vector image"
298
+ ];
299
+ }
300
+ if (attrs.crop) {
301
+ const width = attrs.width;
302
+ const height = attrs.height;
303
+ const boxStyles = renderImageStyles(attrs);
304
+ boxStyles.push("overflow:hidden", `width:${width}px`, `height:${height}px`);
305
+ const crop = renderCropAttrs(attrs.crop, {
306
+ width,
307
+ height
308
+ });
309
+ const boxAttrs = {
310
+ "data-image": "crop",
311
+ style: boxStyles.join(";")
312
+ };
313
+ attachRawAttrs(boxAttrs, attrs);
314
+ boxAttrs["data-crop"] = JSON.stringify(attrs.crop);
315
+ if (floatAnchor) boxAttrs["data-float-anchor"] = floatAnchor;
316
+ const imgAttrs = {
317
+ src: attrs.src,
318
+ style: crop.style
319
+ };
320
+ if (attrs.alt) imgAttrs.alt = attrs.alt;
321
+ if (attrs.title) imgAttrs.title = attrs.title;
322
+ return [
323
+ "span",
324
+ boxAttrs,
325
+ ["img", imgAttrs]
326
+ ];
327
+ }
328
+ const htmlAttrs = { ...HTMLAttributes };
329
+ const styles = renderImageStyles(attrs);
330
+ if (styles.length > 0) htmlAttrs.style = styles.join(";");
331
+ attachRawAttrs(htmlAttrs, attrs);
332
+ if (floatAnchor) htmlAttrs["data-float-anchor"] = floatAnchor;
333
+ return ["img", htmlAttrs];
334
+ },
335
+ parseHTML() {
336
+ return [
337
+ {
338
+ tag: "span[data-image=crop]",
339
+ getAttrs: (el) => parseCropDiv(el)
340
+ },
341
+ {
342
+ tag: "div[data-image=vector]",
343
+ getAttrs: (el) => parseVectorDiv(el)
344
+ },
345
+ { tag: "img[src]" }
346
+ ];
347
+ },
348
+ renderDocx,
349
+ parseDocx
350
+ });
351
+ /**
352
+ * Reverse-parse a cropped span[extent-box] back into image attrs.
353
+ *
354
+ * src/alt/title live on the inner <img>; width/height on the outer box inline
355
+ * style (the extent box, not the img's un-cropped display size).
356
+ * rotation/crop/floating/outline are left to their attribute parseHTML rules,
357
+ * which read the style/data-* the box carries.
358
+ */
359
+ function parseCropDiv(el) {
360
+ const attrs = {};
361
+ const img = el.querySelector("img");
362
+ if (img) {
363
+ const src = img.getAttribute("src");
364
+ if (src) attrs.src = src;
365
+ const alt = img.getAttribute("alt");
366
+ if (alt) attrs.alt = alt;
367
+ const title = img.getAttribute("title");
368
+ if (title) attrs.title = title;
369
+ }
370
+ const style = el.getAttribute("style") || "";
371
+ const wMatch = style.match(/(?:^|;)\s*width:\s*([\d.]+)px/);
372
+ const hMatch = style.match(/(?:^|;)\s*height:\s*([\d.]+)px/);
373
+ if (wMatch) attrs.width = parseFloat(wMatch[1]);
374
+ if (hMatch) attrs.height = parseFloat(hMatch[1]);
375
+ return attrs;
376
+ }
377
+ /** Reverse-parse an EMF/WMF placeholder div back into image attrs: src from
378
+ * data-vector-src, extent from the inline width/height, alt/title from
379
+ * aria-label/title. Floating/rotation/etc. round-trip via attribute rules. */
380
+ function parseVectorDiv(el) {
381
+ const attrs = {};
382
+ const src = el.getAttribute("data-vector-src");
383
+ if (src) attrs.src = src;
384
+ const style = el.getAttribute("style") || "";
385
+ const wMatch = style.match(/(?:^|;)\s*width:\s*([\d.]+)px/);
386
+ const hMatch = style.match(/(?:^|;)\s*height:\s*([\d.]+)px/);
387
+ if (wMatch) attrs.width = parseFloat(wMatch[1]);
388
+ if (hMatch) attrs.height = parseFloat(hMatch[1]);
389
+ const ariaLabel = el.getAttribute("aria-label");
390
+ if (ariaLabel) attrs.alt = ariaLabel;
391
+ const title = el.getAttribute("title");
392
+ if (title) attrs.title = title;
393
+ return attrs;
394
+ }
395
+ //#endregion
2
396
  export { Image, parseDocx, renderCropAttrs, renderDocx };
@@ -1,3 +1,4 @@
1
1
  import { n as createDocument, t as Document } from "../document-BH1y4qHM.mjs";
2
- import { c as DocxKit, d as docxExtensions, f as tiptapMarkExtensions, l as DocxKitOptions, p as tiptapNodeExtensions } from "../core-fBMCCj4D.mjs";
3
- export { Document, DocxKit, type DocxKitOptions, createDocument, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
2
+ import { c as PageBreak, f as docxExtensions, l as DocxKit, m as tiptapNodeExtensions, p as tiptapMarkExtensions, u as DocxKitOptions } from "../core-C9VunJ8o.mjs";
3
+ import { b as sectionLinePitchCss, k as twipsToMm, v as resolveFontName, x as sectionMarginCss, y as resolvePageSize } from "../utils-D87vukzp.mjs";
4
+ export { Document, DocxKit, type DocxKitOptions, PageBreak, createDocument, docxExtensions, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
@@ -1,3 +1,4 @@
1
- import { a as DocxKit, c as tiptapMarkExtensions, l as tiptapNodeExtensions, s as docxExtensions } from "../core-DEqBHRzE.mjs";
2
- import { n as createDocument, t as Document } from "../document-CvTym-FM.mjs";
3
- export { Document, DocxKit, createDocument, docxExtensions, tiptapMarkExtensions, tiptapNodeExtensions };
1
+ import { a as DocxKit, c as tiptapMarkExtensions, g as PageBreak, l as tiptapNodeExtensions, s as docxExtensions } from "../core-DT9IrTzN.mjs";
2
+ import { Document, createDocument } from "./document.mjs";
3
+ import { resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, twipsToMm } from "./utils.mjs";
4
+ export { Document, DocxKit, PageBreak, createDocument, docxExtensions, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
@@ -1,4 +1,4 @@
1
- import { C as Mention } from "../tiptap-TErPjuNJ.mjs";
1
+ import { b as Mention } from "../tiptap-pZsNPsvV.mjs";
2
2
 
3
3
  //#region src/extensions/mention.d.ts
4
4
  /**
@@ -1,3 +1,44 @@
1
- import { C as Mention } from "../tiptap-D7pl4I5U.mjs";
2
- import { i as readMention, n as createMention, r as isMention, t as MENTION_TAG } from "../mention-C-dTR6MK.mjs";
1
+ import { Mention } from "./tiptap.mjs";
2
+ //#region src/extensions/mention.ts
3
+ /**
4
+ * Mention extension — owns the DOCX expression of an inline mention.
5
+ *
6
+ * A mention is an atom node carrying `{ id, label }`. DOCX has no mention
7
+ * element, but an inline text-SDT (CT_SdtRun) is a reversible carrier: the
8
+ * `id` rides in the SDT alias, the `label` as the SDT's run text, and a fixed
9
+ * tag marks the type so resolve can recover the mention. (customXml would also
10
+ * carry the id but triggers Word's i4i patent warning; SDT does not.)
11
+ */
12
+ /** SDT tag marking a mention content control. */
13
+ const MENTION_TAG = "docen-mention";
14
+ /** Inline text-SDT carrying a mention (id in alias, label as run text). */
15
+ function createMention(id, label) {
16
+ return { sdt: {
17
+ properties: {
18
+ tag: MENTION_TAG,
19
+ alias: id,
20
+ text: {}
21
+ },
22
+ children: [{ text: label }]
23
+ } };
24
+ }
25
+ /** True if an inline SDT child carries a mention. */
26
+ function isMention(child) {
27
+ if (typeof child !== "object" || child === null || !("sdt" in child)) return false;
28
+ return child.sdt?.properties?.tag === MENTION_TAG;
29
+ }
30
+ /** Read a mention SDT → `{ id, label }`. */
31
+ function readMention(child) {
32
+ const sdt = child.sdt;
33
+ const id = sdt?.properties?.alias ?? "";
34
+ let label = "";
35
+ const first = sdt?.children?.[0];
36
+ if (typeof first === "string") label = first;
37
+ else if (first && typeof first === "object" && "text" in first) label = String(first.text ?? "");
38
+ return {
39
+ id,
40
+ label
41
+ };
42
+ }
43
+ //#endregion
3
44
  export { MENTION_TAG, Mention, createMention, isMention, readMention };
@@ -1,4 +1,4 @@
1
- import { w as OrderedList } from "../tiptap-TErPjuNJ.mjs";
1
+ import { x as OrderedList } from "../tiptap-pZsNPsvV.mjs";
2
2
  import { LevelsOptions } from "@office-open/docx";
3
3
 
4
4
  //#region src/extensions/ordered-list.d.ts
@@ -1,3 +1,41 @@
1
- import { w as OrderedList } from "../tiptap-D7pl4I5U.mjs";
2
- import { n as ORDERED_REFERENCE_PREFIX, r as buildOrderedLevels, t as ORDERED_LEVEL_TEXT } from "../ordered-list-V-3xFQmV.mjs";
1
+ import { OrderedList } from "./tiptap.mjs";
2
+ import { LevelFormat } from "@office-open/docx";
3
+ //#region src/extensions/ordered-list.ts
4
+ /**
5
+ * OrderedList extension — owns the DOCX expression of an ordered list.
6
+ *
7
+ * A Tiptap orderedList maps to a sequence of paragraphs referencing one
8
+ * abstractNum (decimal). The reference is keyed by `start` so lists with the
9
+ * same start share a definition; DocxManager gives each list its own instance
10
+ * for independent counting. This module owns that abstractNum shape; DocxManager
11
+ * owns the cross-paragraph tree walk, start recovery, and numbering-instance
12
+ * bookkeeping.
13
+ */
14
+ /** Reference prefix for generated ordered-list abstractNum definitions. */
15
+ const ORDERED_REFERENCE_PREFIX = "docen-ordered";
16
+ /** lvlText per nesting depth (level 0 → "%1.", … level 8 → "%9."). */
17
+ const ORDERED_LEVEL_TEXT = [
18
+ "%1.",
19
+ "%2.",
20
+ "%3.",
21
+ "%4.",
22
+ "%5.",
23
+ "%6.",
24
+ "%7.",
25
+ "%8.",
26
+ "%9."
27
+ ];
28
+ /**
29
+ * Build nine decimal numbering levels for an ordered list. Level 0 carries
30
+ * `start`; deeper levels restart at 1 (Word convention).
31
+ */
32
+ function buildOrderedLevels(start) {
33
+ return Array.from({ length: 9 }, (_, level) => ({
34
+ level,
35
+ format: LevelFormat.DECIMAL,
36
+ start: level === 0 ? start : 1,
37
+ text: ORDERED_LEVEL_TEXT[level]
38
+ }));
39
+ }
40
+ //#endregion
3
41
  export { ORDERED_LEVEL_TEXT, ORDERED_REFERENCE_PREFIX, OrderedList, buildOrderedLevels };
@@ -1,34 +1,2 @@
1
- import { s as Node } from "../core-fBMCCj4D.mjs";
2
-
3
- //#region src/extensions/page-break.d.ts
4
- /**
5
- * PageBreak — inline atom node for DOCX page breaks (`<w:br w:type="page"/>`).
6
- *
7
- * OOXML page breaks live inside a run (inline), so the Tiptap node is inline
8
- * too (group "inline"). This keeps a break inside its paragraph on round-trip
9
- * — a break mid-paragraph stays mid-paragraph instead of splitting the
10
- * paragraph into separate blocks (which would lose the original structure).
11
- * Sibling to HardBreak: both render `<w:br>`, differing only by type.
12
- *
13
- * The DOCX payload (`{ pageBreak: true }`) is inlined in DocxManager — a
14
- * one-liner with no per-node variance, so no extension helper for it.
15
- *
16
- * Inserting a page break must also visually reflow (the C-route paginator only
17
- * forces a new page after a block *containing* a pageBreak atom). So
18
- * `setPageBreak` inserts the atom then splits the paragraph — the atom lands at
19
- * the end of the first half, the trailing text becomes a fresh paragraph, and
20
- * the paginator's `forcesPageBreakAfter` moves it to the next page (matching
21
- * Word's Ctrl+Enter behavior).
22
- */
23
- declare const PageBreak: Node<any, any>;
24
- declare module "@tiptap/core" {
25
- interface Commands<ReturnType> {
26
- pageBreak: {
27
- /** Insert a page break at the cursor and split the paragraph so the
28
- * trailing content reflows to the next page. */
29
- setPageBreak: () => ReturnType;
30
- };
31
- }
32
- }
33
- //#endregion
1
+ import { c as PageBreak } from "../core-C9VunJ8o.mjs";
34
2
  export { PageBreak };
@@ -1,2 +1,2 @@
1
- import { f as PageBreak } from "../core-DEqBHRzE.mjs";
1
+ import { g as PageBreak } from "../core-DT9IrTzN.mjs";
2
2
  export { PageBreak };