@docen/docx 0.3.1 → 0.3.3

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 (114) hide show
  1. package/dist/converters/docx.d.mts +220 -1
  2. package/dist/converters/docx.mjs +1352 -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 +91 -2
  12. package/dist/converters/styles.mjs +308 -2
  13. package/dist/core-B8ba_FNi.mjs +717 -0
  14. package/dist/core-DRaLI8nd.d.mts +203 -0
  15. package/dist/core.d.mts +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/document-Cws7XTYL.d.mts +28 -0
  18. package/dist/editor.d.mts +20 -1
  19. package/dist/editor.mjs +20 -1
  20. package/dist/extensions/blockquote.d.mts +1 -1
  21. package/dist/extensions/blockquote.mjs +30 -2
  22. package/dist/extensions/code-block.d.mts +1 -1
  23. package/dist/extensions/code-block.mjs +22 -1
  24. package/dist/extensions/column-break.d.mts +1 -1
  25. package/dist/extensions/column-break.mjs +1 -1
  26. package/dist/extensions/details.d.mts +1 -1
  27. package/dist/extensions/details.mjs +17 -2
  28. package/dist/extensions/document.d.mts +1 -1
  29. package/dist/extensions/document.mjs +45 -1
  30. package/dist/extensions/extensions.d.mts +4 -5
  31. package/dist/extensions/extensions.mjs +13 -14
  32. package/dist/extensions/formatting-marks.d.mts +7 -1
  33. package/dist/extensions/formatting-marks.mjs +1 -1
  34. package/dist/extensions/heading.mjs +187 -1
  35. package/dist/extensions/image.d.mts +1 -1
  36. package/dist/extensions/image.mjs +395 -1
  37. package/dist/extensions/index.d.mts +4 -3
  38. package/dist/extensions/index.mjs +4 -3
  39. package/dist/extensions/mention.d.mts +1 -1
  40. package/dist/extensions/mention.mjs +43 -2
  41. package/dist/extensions/ordered-list.d.mts +1 -1
  42. package/dist/extensions/ordered-list.mjs +40 -2
  43. package/dist/extensions/page-break.d.mts +1 -33
  44. package/dist/extensions/page-break.mjs +1 -1
  45. package/dist/extensions/paragraph.mjs +145 -1
  46. package/dist/extensions/passthrough.d.mts +1 -1
  47. package/dist/extensions/passthrough.mjs +1 -1
  48. package/dist/extensions/section-break.d.mts +19 -2
  49. package/dist/extensions/section-break.mjs +1 -1
  50. package/dist/extensions/strike.mjs +45 -1
  51. package/dist/extensions/table-cell.mjs +106 -1
  52. package/dist/extensions/table-header.mjs +106 -1
  53. package/dist/extensions/table-row.mjs +78 -1
  54. package/dist/extensions/table.mjs +154 -1
  55. package/dist/extensions/task-item.d.mts +1 -1
  56. package/dist/extensions/task-item.mjs +36 -2
  57. package/dist/extensions/text-style.mjs +145 -1
  58. package/dist/extensions/tiptap.d.mts +2 -2
  59. package/dist/extensions/tiptap.mjs +31 -2
  60. package/dist/extensions/toc-field.d.mts +2 -0
  61. package/dist/extensions/toc-field.mjs +2 -0
  62. package/dist/extensions/utils.d.mts +2 -62
  63. package/dist/extensions/utils.mjs +508 -2
  64. package/dist/extensions/wpg-group.d.mts +2 -0
  65. package/dist/extensions/wpg-group.mjs +2 -0
  66. package/dist/extensions/wps-shape.d.mts +2 -0
  67. package/dist/extensions/wps-shape.mjs +2 -0
  68. package/dist/index.d.mts +101 -29
  69. package/dist/index.mjs +13 -10
  70. package/dist/{tiptap-TErPjuNJ.d.mts → tiptap-pZsNPsvV.d.mts} +1 -3
  71. package/dist/utils-BJwDQts7.d.mts +137 -0
  72. package/package.json +39 -40
  73. package/dist/blockquote-Ky9xD_Q-.mjs +0 -31
  74. package/dist/code-block-BgNjhADy.mjs +0 -23
  75. package/dist/core-DEqBHRzE.mjs +0 -406
  76. package/dist/core-fBMCCj4D.d.mts +0 -97
  77. package/dist/details-Dh8luWb2.mjs +0 -18
  78. package/dist/dist-B6B3HnVZ.mjs +0 -1838
  79. package/dist/document-BH1y4qHM.d.mts +0 -6
  80. package/dist/document-CvTym-FM.mjs +0 -50
  81. package/dist/docx-C5wyjI-0.d.mts +0 -200
  82. package/dist/docx-CONyAedl.mjs +0 -1231
  83. package/dist/editor-Bf3CxQnY.mjs +0 -21
  84. package/dist/editor-DReY3Rb9.d.mts +0 -21
  85. package/dist/emoji-BZ1dJD7d.d.mts +0 -17
  86. package/dist/emoji-C2OsTWR7.mjs +0 -27
  87. package/dist/extensions/emoji.d.mts +0 -2
  88. package/dist/extensions/emoji.mjs +0 -2
  89. package/dist/extensions/image-group.d.mts +0 -6
  90. package/dist/extensions/image-group.mjs +0 -2
  91. package/dist/heading-DAubgJJN.mjs +0 -166
  92. package/dist/html-DCC_DSHv.d.mts +0 -18
  93. package/dist/html-DedDWPoO.mjs +0 -66
  94. package/dist/image-CuEIXoZl.mjs +0 -334
  95. package/dist/markdown-BzJmRsBs.mjs +0 -18
  96. package/dist/markdown-D0k0sRYS.d.mts +0 -13
  97. package/dist/mention-C-dTR6MK.mjs +0 -44
  98. package/dist/ordered-list-V-3xFQmV.mjs +0 -41
  99. package/dist/paragraph-BrWH-BOV.mjs +0 -147
  100. package/dist/patch-Cdp5WKJz.d.mts +0 -53
  101. package/dist/patch-IZ13tXTu.mjs +0 -36
  102. package/dist/prepare-Bdk8Cjkf.mjs +0 -122
  103. package/dist/prepare-CPAvcv6q.d.mts +0 -63
  104. package/dist/strike-hWxShOgb.mjs +0 -50
  105. package/dist/styles-QSX3RhxK.mjs +0 -285
  106. package/dist/styles-ugspkrxz.d.mts +0 -85
  107. package/dist/table-DrA12lxX.mjs +0 -159
  108. package/dist/table-cell-DmkfYwDc.mjs +0 -112
  109. package/dist/table-header-Bwr5GKWg.mjs +0 -112
  110. package/dist/table-row-vew1y7WH.mjs +0 -84
  111. package/dist/task-item-BnlXGrIG.mjs +0 -37
  112. package/dist/text-style-tMeBq5XQ.mjs +0 -151
  113. package/dist/tiptap-D7pl4I5U.mjs +0 -33
  114. package/dist/utils-BPT4tjcn.mjs +0 -333
@@ -1,159 +0,0 @@
1
- import { k as Table$1 } from "./tiptap-D7pl4I5U.mjs";
2
- import { S as twipToCss, _ as shadingFromElement, d as renderBorderCSS, i as bordersFromElement, n as alignmentFromElement, r as alignmentToCss, v as shadingToCss } from "./utils-BPT4tjcn.mjs";
3
- //#region src/extensions/table.ts
4
- /**
5
- * Table extension with nested office-open attrs.
6
- *
7
- * Attrs mirror TableOptions (width/float/layout/borders/alignment/margins/indent/
8
- * cellSpacing/tableLook/columnWidths/etc.). DOCX round-trip is near-identity:
9
- * renderDocx/parseDocx pass attrs through (omitting only `rows`, which DocxManager
10
- * rebuilds from the row/cell nodes). CSS conversion happens only in renderHTML.
11
- */
12
- /** Structural key rebuilt by DocxManager (compileTableNode walks the row nodes). */
13
- const SKIP_KEYS = new Set(["rows", "columnWidthsRevision"]);
14
- function renderDocx(node) {
15
- const attrs = node.attrs ?? {};
16
- const opts = {};
17
- for (const [key, value] of Object.entries(attrs)) {
18
- if (SKIP_KEYS.has(key)) continue;
19
- if (value !== null && value !== void 0) opts[key] = value;
20
- }
21
- return opts;
22
- }
23
- function parseDocx(opts) {
24
- const attrs = {};
25
- for (const [key, value] of Object.entries(opts)) {
26
- if (SKIP_KEYS.has(key)) continue;
27
- attrs[key] = value ?? null;
28
- }
29
- return attrs;
30
- }
31
- const attrNative = () => ({
32
- default: null,
33
- parseHTML: () => null,
34
- rendered: false
35
- });
36
- const Table = Table$1.extend({
37
- addAttributes() {
38
- return {
39
- ...this.parent?.(),
40
- width: attrNative(),
41
- columnWidths: attrNative(),
42
- indent: attrNative(),
43
- margins: attrNative(),
44
- float: attrNative(),
45
- borders: {
46
- default: null,
47
- rendered: false,
48
- parseHTML: (el) => bordersFromElement(el)
49
- },
50
- shading: {
51
- default: null,
52
- rendered: false,
53
- parseHTML: (el) => shadingFromElement(el)
54
- },
55
- alignment: {
56
- default: null,
57
- rendered: false,
58
- parseHTML: (el) => alignmentFromElement(el)
59
- },
60
- layout: {
61
- default: null,
62
- rendered: false,
63
- parseHTML: (el) => el.style.tableLayout === "fixed" ? "fixed" : null
64
- },
65
- style: attrNative(),
66
- visuallyRightToLeft: attrNative(),
67
- tableLook: attrNative(),
68
- cellSpacing: attrNative(),
69
- styleRowBandSize: attrNative(),
70
- styleColBandSize: attrNative(),
71
- caption: attrNative(),
72
- description: attrNative()
73
- };
74
- },
75
- renderHTML({ node, HTMLAttributes }) {
76
- const a = node.attrs;
77
- const attrs = { ...HTMLAttributes };
78
- const styles = [];
79
- const align = alignmentToCss(a.alignment);
80
- if (align === "center") styles.push("margin-left:auto", "margin-right:auto");
81
- else if (align === "right") styles.push("margin-left:auto", "margin-right:0");
82
- else if (align) styles.push("margin-left:0", "margin-right:auto");
83
- if (a.layout === "fixed") styles.push("table-layout:fixed");
84
- if (a.width && typeof a.width === "object") {
85
- const w = a.width;
86
- const numSize = typeof w.size === "string" ? parseFloat(w.size) : w.size;
87
- if (w.type === "pct") {
88
- if (typeof w.size === "string" && w.size.includes("%")) styles.push(`width:${w.size}`);
89
- else if (!Number.isNaN(numSize)) styles.push(`width:${numSize / 50}%`);
90
- } else if (w.type === "auto") styles.push("width:100%");
91
- else if (numSize != null) {
92
- const css = twipToCss(numSize);
93
- if (css) styles.push(`width:${css}`);
94
- }
95
- } else styles.push("width:100%");
96
- if (a.indent && typeof a.indent === "object") {
97
- const ind = a.indent;
98
- if (ind.size != null) {
99
- const css = twipToCss(ind.size);
100
- if (css) styles.push(`margin-left:${css}`);
101
- }
102
- }
103
- if (a.cellSpacing && typeof a.cellSpacing === "object") {
104
- const cs = a.cellSpacing;
105
- if (cs.value != null) {
106
- const css = twipToCss(cs.value);
107
- if (css) styles.push(`border-spacing:${css}`);
108
- }
109
- }
110
- const bg = shadingToCss(a.shading);
111
- if (bg) styles.push(`background-color:${bg}`);
112
- if (a.borders && typeof a.borders === "object") {
113
- const b = a.borders;
114
- const sides = [
115
- ["top", b.top],
116
- ["bottom", b.bottom],
117
- ["left", b.left],
118
- ["right", b.right]
119
- ];
120
- for (const [side, border] of sides) {
121
- const css = renderBorderCSS(border);
122
- if (css) styles.push(`border-${side}:${css}`);
123
- }
124
- }
125
- const firstRow = node.firstChild;
126
- const cellPx = [];
127
- if (firstRow) for (let i = 0; i < firstRow.childCount; i++) {
128
- const cw = firstRow.child(i).attrs.colwidth;
129
- if (Array.isArray(cw) && cw.length) for (const w of cw) cellPx.push(w || 0);
130
- else cellPx.push(0);
131
- }
132
- const hasCellWidths = cellPx.some((w) => w > 0);
133
- const tblGridPx = (a.columnWidths ?? []).map((w) => Math.round((w || 0) / 15));
134
- const gridPx = tblGridPx.some((w) => w > 0) ? tblGridPx : hasCellWidths ? cellPx : tblGridPx;
135
- if (styles.length > 0) attrs.style = styles.join(";");
136
- if (gridPx.some((w) => w > 0)) {
137
- const gridTotal = gridPx.reduce((sum, w) => sum + w, 0);
138
- return [
139
- "table",
140
- attrs,
141
- [
142
- "colgroup",
143
- {},
144
- ...gridPx.map((w) => ["col", { style: `width:${gridTotal > 0 ? (w / gridTotal * 100).toFixed(2) : 0}%` }])
145
- ],
146
- ["tbody", 0]
147
- ];
148
- }
149
- return [
150
- "table",
151
- attrs,
152
- 0
153
- ];
154
- },
155
- renderDocx,
156
- parseDocx
157
- });
158
- //#endregion
159
- export { parseDocx as n, renderDocx as r, Table as t };
@@ -1,112 +0,0 @@
1
- import { A as TableCell$1 } from "./tiptap-D7pl4I5U.mjs";
2
- import { _ as shadingFromElement, i as bordersFromElement, m as renderTableCellStyles } from "./utils-BPT4tjcn.mjs";
3
- //#region src/extensions/table-cell.ts
4
- /**
5
- * Table cell extension with nested office-open attrs.
6
- *
7
- * Attrs mirror TableCellPropertiesOptionsBase (shading/margins/borders/width as
8
- * nested objects + scalar OOXML properties) plus the inherited Tiptap structural
9
- * names colspan/rowspan/colwidth/align (rendered: false for the OOXML-named ones).
10
- * DOCX round-trip is near-identity: renderDocx/parseDocx pass OOXML-native attrs
11
- * through and only map the Tiptap structural names colspan/rowspan/colwidth to
12
- * OOXML columnSpan/rowSpan/width. CSS conversion happens solely in renderHTML via
13
- * utils.renderTableCellStyles (consuming nested shading/verticalAlign/noWrap).
14
- */
15
- /** Tiptap structural attrs expressed via OOXML structural fields, not passed through. */
16
- const SKIP_KEYS = new Set([
17
- "colspan",
18
- "rowspan",
19
- "colwidth",
20
- "children"
21
- ]);
22
- function renderDocx(node) {
23
- const attrs = node.attrs ?? {};
24
- const opts = {};
25
- const colspan = attrs.colspan;
26
- if (colspan && colspan > 1) opts.columnSpan = colspan;
27
- const rowspan = attrs.rowspan;
28
- if (rowspan && rowspan > 1) opts.rowSpan = rowspan;
29
- const colwidth = attrs.colwidth;
30
- if (colwidth && colwidth.length > 0) {
31
- const totalPx = colwidth.reduce((sum, w) => sum + (w || 0), 0);
32
- if (totalPx > 0) opts.width = {
33
- size: totalPx * 15,
34
- type: "dxa"
35
- };
36
- }
37
- for (const [key, value] of Object.entries(attrs)) {
38
- if (SKIP_KEYS.has(key)) continue;
39
- if (value !== null && value !== void 0) opts[key] = value;
40
- }
41
- return opts;
42
- }
43
- function parseDocx(opts) {
44
- const resolved = typeof opts === "string" ? { text: opts } : opts;
45
- const attrs = {};
46
- if (resolved.columnSpan != null) attrs.colspan = resolved.columnSpan;
47
- if (resolved.rowSpan != null) attrs.rowspan = resolved.rowSpan;
48
- if (resolved.width) {
49
- const twips = resolved.width.size ?? 0;
50
- if (twips) attrs.colwidth = [Math.round(twips / 15)];
51
- }
52
- for (const [key, value] of Object.entries(resolved)) {
53
- if (key === "columnSpan" || key === "rowSpan" || key === "width" || key === "children") continue;
54
- attrs[key] = value ?? null;
55
- }
56
- return attrs;
57
- }
58
- const attrNative = () => ({
59
- default: null,
60
- parseHTML: () => null,
61
- rendered: false
62
- });
63
- const TableCell = TableCell$1.extend({
64
- addAttributes() {
65
- return {
66
- ...this.parent?.(),
67
- shading: {
68
- default: null,
69
- rendered: false,
70
- parseHTML: (el) => shadingFromElement(el)
71
- },
72
- borders: {
73
- default: null,
74
- rendered: false,
75
- parseHTML: (el) => bordersFromElement(el)
76
- },
77
- verticalAlign: {
78
- default: null,
79
- rendered: false,
80
- parseHTML: (el) => el.style.verticalAlign || null
81
- },
82
- textDirection: attrNative(),
83
- width: attrNative(),
84
- margins: attrNative(),
85
- noWrap: {
86
- default: null,
87
- rendered: false,
88
- parseHTML: (el) => el.style.whiteSpace === "nowrap" ? true : null
89
- },
90
- verticalMerge: attrNative(),
91
- horizontalMerge: attrNative(),
92
- fitText: attrNative(),
93
- hideMark: attrNative(),
94
- headers: attrNative(),
95
- cnfStyle: attrNative()
96
- };
97
- },
98
- renderHTML({ node, HTMLAttributes }) {
99
- const styles = renderTableCellStyles(node.attrs);
100
- const attrs = { ...HTMLAttributes };
101
- if (styles.length > 0) attrs.style = styles.join(";");
102
- return [
103
- "td",
104
- attrs,
105
- 0
106
- ];
107
- },
108
- renderDocx,
109
- parseDocx
110
- });
111
- //#endregion
112
- export { parseDocx as n, renderDocx as r, TableCell as t };
@@ -1,112 +0,0 @@
1
- import { j as TableHeader$1 } from "./tiptap-D7pl4I5U.mjs";
2
- import { _ as shadingFromElement, i as bordersFromElement, m as renderTableCellStyles } from "./utils-BPT4tjcn.mjs";
3
- //#region src/extensions/table-header.ts
4
- /**
5
- * Table header extension with nested office-open attrs (mirrors TableCell).
6
- *
7
- * Attrs mirror TableCellPropertiesOptionsBase (shading/margins/borders/width as
8
- * nested objects + scalar OOXML properties) plus the inherited Tiptap structural
9
- * names colspan/rowspan/colwidth/align (rendered: false for the OOXML-named ones).
10
- * DOCX round-trip is near-identity: renderDocx/parseDocx pass OOXML-native attrs
11
- * through and only map the Tiptap structural names colspan/rowspan/colwidth to
12
- * OOXML columnSpan/rowSpan/width. CSS conversion happens solely in renderHTML via
13
- * utils.renderTableCellStyles (consuming nested shading/verticalAlign/noWrap).
14
- */
15
- /** Tiptap structural attrs expressed via OOXML structural fields, not passed through. */
16
- const SKIP_KEYS = new Set([
17
- "colspan",
18
- "rowspan",
19
- "colwidth",
20
- "children"
21
- ]);
22
- function renderDocx(node) {
23
- const attrs = node.attrs ?? {};
24
- const opts = {};
25
- const colspan = attrs.colspan;
26
- if (colspan && colspan > 1) opts.columnSpan = colspan;
27
- const rowspan = attrs.rowspan;
28
- if (rowspan && rowspan > 1) opts.rowSpan = rowspan;
29
- const colwidth = attrs.colwidth;
30
- if (colwidth && colwidth.length > 0) {
31
- const totalPx = colwidth.reduce((sum, w) => sum + (w || 0), 0);
32
- if (totalPx > 0) opts.width = {
33
- size: totalPx * 15,
34
- type: "dxa"
35
- };
36
- }
37
- for (const [key, value] of Object.entries(attrs)) {
38
- if (SKIP_KEYS.has(key)) continue;
39
- if (value !== null && value !== void 0) opts[key] = value;
40
- }
41
- return opts;
42
- }
43
- function parseDocx(opts) {
44
- const resolved = typeof opts === "string" ? { text: opts } : opts;
45
- const attrs = {};
46
- if (resolved.columnSpan != null) attrs.colspan = resolved.columnSpan;
47
- if (resolved.rowSpan != null) attrs.rowspan = resolved.rowSpan;
48
- if (resolved.width) {
49
- const twips = resolved.width.size ?? 0;
50
- if (twips) attrs.colwidth = [Math.round(twips / 15)];
51
- }
52
- for (const [key, value] of Object.entries(resolved)) {
53
- if (key === "columnSpan" || key === "rowSpan" || key === "width" || key === "children") continue;
54
- attrs[key] = value ?? null;
55
- }
56
- return attrs;
57
- }
58
- const attrNative = () => ({
59
- default: null,
60
- parseHTML: () => null,
61
- rendered: false
62
- });
63
- const TableHeader = TableHeader$1.extend({
64
- addAttributes() {
65
- return {
66
- ...this.parent?.(),
67
- shading: {
68
- default: null,
69
- rendered: false,
70
- parseHTML: (el) => shadingFromElement(el)
71
- },
72
- borders: {
73
- default: null,
74
- rendered: false,
75
- parseHTML: (el) => bordersFromElement(el)
76
- },
77
- verticalAlign: {
78
- default: null,
79
- rendered: false,
80
- parseHTML: (el) => el.style.verticalAlign || null
81
- },
82
- textDirection: attrNative(),
83
- width: attrNative(),
84
- margins: attrNative(),
85
- noWrap: {
86
- default: null,
87
- rendered: false,
88
- parseHTML: (el) => el.style.whiteSpace === "nowrap" ? true : null
89
- },
90
- verticalMerge: attrNative(),
91
- horizontalMerge: attrNative(),
92
- fitText: attrNative(),
93
- hideMark: attrNative(),
94
- headers: attrNative(),
95
- cnfStyle: attrNative()
96
- };
97
- },
98
- renderHTML({ node, HTMLAttributes }) {
99
- const styles = renderTableCellStyles(node.attrs);
100
- const attrs = { ...HTMLAttributes };
101
- if (styles.length > 0) attrs.style = styles.join(";");
102
- return [
103
- "th",
104
- attrs,
105
- 0
106
- ];
107
- },
108
- renderDocx,
109
- parseDocx
110
- });
111
- //#endregion
112
- export { parseDocx as n, renderDocx as r, TableHeader as t };
@@ -1,84 +0,0 @@
1
- import { M as TableRow$1 } from "./tiptap-D7pl4I5U.mjs";
2
- import { s as cssToTwip } from "./utils-BPT4tjcn.mjs";
3
- //#region src/extensions/table-row.ts
4
- /**
5
- * Table row extension with nested office-open attrs.
6
- *
7
- * Attrs mirror TableRowPropertiesOptionsBase (cantSplit/tableHeader/hidden as
8
- * booleans; height as a nested { value, rule } object; cellSpacing as a native
9
- * value; widthBefore/widthAfter as TableWidthProperties; etc.). DOCX round-trip
10
- * is near-identity: renderDocx/parseDocx pass attrs through (omitting the
11
- * `cells` structural key that DocxManager owns). CSS conversion happens only
12
- * in renderHTML.
13
- */
14
- /** Structural keys filled by DocxManager (compileTableNode). */
15
- const SKIP_KEYS = new Set(["cells"]);
16
- function renderDocx(node) {
17
- const attrs = node.attrs ?? {};
18
- const opts = {};
19
- for (const [key, value] of Object.entries(attrs)) {
20
- if (SKIP_KEYS.has(key)) continue;
21
- if (value !== null && value !== void 0) opts[key] = value;
22
- }
23
- return opts;
24
- }
25
- function parseDocx(opts) {
26
- const attrs = {};
27
- for (const [key, value] of Object.entries(opts)) {
28
- if (SKIP_KEYS.has(key)) continue;
29
- attrs[key] = value ?? null;
30
- }
31
- return attrs;
32
- }
33
- const attrNative = () => ({
34
- default: null,
35
- parseHTML: () => null,
36
- rendered: false
37
- });
38
- const TableRow = TableRow$1.extend({
39
- addAttributes() {
40
- return {
41
- ...this.parent?.(),
42
- height: {
43
- default: null,
44
- rendered: false,
45
- parseHTML: (el) => {
46
- const twips = cssToTwip(el.style.height || el.getAttribute("height") || "");
47
- return twips != null ? {
48
- value: twips,
49
- rule: "atLeast"
50
- } : null;
51
- }
52
- },
53
- cantSplit: attrNative(),
54
- tableHeader: attrNative(),
55
- hidden: attrNative(),
56
- divId: attrNative(),
57
- gridBefore: attrNative(),
58
- gridAfter: attrNative(),
59
- rowAlignment: attrNative(),
60
- cnfStyle: attrNative(),
61
- cellSpacing: attrNative(),
62
- widthBefore: attrNative(),
63
- widthAfter: attrNative()
64
- };
65
- },
66
- renderHTML({ node, HTMLAttributes }) {
67
- const attrs = { ...HTMLAttributes };
68
- const styles = [];
69
- if (node.attrs.height && typeof node.attrs.height === "object") {
70
- const h = node.attrs.height;
71
- if (h.value != null) styles.push(`height:${h.value / 20}pt`);
72
- }
73
- if (styles.length > 0) attrs.style = styles.join(";");
74
- return [
75
- "tr",
76
- attrs,
77
- 0
78
- ];
79
- },
80
- renderDocx,
81
- parseDocx
82
- });
83
- //#endregion
84
- export { parseDocx as n, renderDocx as r, TableRow as t };
@@ -1,37 +0,0 @@
1
- import "./tiptap-D7pl4I5U.mjs";
2
- //#region src/extensions/task-item.ts
3
- /**
4
- * TaskItem extension — owns the DOCX expression of a task-list checkbox.
5
- *
6
- * DOCX has no native task list, but a clickable checkbox is reversible via an
7
- * inline content-control SDT (w14:checkbox). Each task paragraph carries a
8
- * leading checkbox SDT tagged "docen-task" so resolve can tell task items apart
9
- * from ordinary paragraphs that happen to contain an SDT. The checked state
10
- * round-trips through the SDT; DocxManager injects/strips the SDT at the
11
- * paragraph boundary and rebuilds the taskList/taskItem tree.
12
- */
13
- /** SDT tag marking our task-item checkbox content control. */
14
- const TASK_CHECKBOX_TAG = "docen-task";
15
- /**
16
- * Inline checkbox SDT (w14:checkbox) for a task item, as a ParagraphChild.
17
- * Tagged so resolve can distinguish task items from ordinary SDT-bearing
18
- * paragraphs.
19
- */
20
- function createTaskCheckbox(checked) {
21
- return { sdt: { properties: {
22
- tag: TASK_CHECKBOX_TAG,
23
- checkbox: { checked }
24
- } } };
25
- }
26
- /** True if an inline ParagraphChild is our task checkbox SDT. */
27
- function isTaskCheckbox(child) {
28
- if (typeof child !== "object" || child === null || !("sdt" in child)) return false;
29
- return (child.sdt?.properties)?.tag === TASK_CHECKBOX_TAG;
30
- }
31
- /** Read the checked state of a task checkbox SDT child (false if not one). */
32
- function readCheckboxState(child) {
33
- if (!isTaskCheckbox(child)) return false;
34
- return Boolean(child.sdt?.properties?.checkbox?.checked);
35
- }
36
- //#endregion
37
- export { readCheckboxState as i, createTaskCheckbox as n, isTaskCheckbox as r, TASK_CHECKBOX_TAG as t };
@@ -1,151 +0,0 @@
1
- import { L as TextStyle$1 } from "./tiptap-D7pl4I5U.mjs";
2
- import { a as characterSpacingFromCss, b as sizeToCss, g as shadingFromCss, h as resolveFontName, o as characterSpacingToCss, u as normalizeColorToHex, v as shadingToCss, y as sizeFromCss } from "./utils-BPT4tjcn.mjs";
3
- //#region src/extensions/text-style.ts
4
- /**
5
- * TextStyle mark with office-open attrs.
6
- *
7
- * Attrs mirror RunStylePropertiesOptions (bold/italic/strike/subScript/
8
- * superScript handled by dedicated marks and therefore omitted). DOCX
9
- * round-trip is near-identity: renderDocx/parseDocx pass attrs through;
10
- * CSS conversion happens only in attribute-level renderHTML/parseHTML.
11
- */
12
- /** Structural/semantic keys expressed elsewhere (run children/text, style name). */
13
- const SKIP_KEYS = new Set([
14
- "children",
15
- "text",
16
- "style",
17
- "break",
18
- "bold",
19
- "italic",
20
- "strike",
21
- "doubleStrike",
22
- "subScript",
23
- "superScript"
24
- ]);
25
- function renderDocx(attrs) {
26
- const opts = {};
27
- for (const [key, value] of Object.entries(attrs)) {
28
- if (SKIP_KEYS.has(key)) continue;
29
- if (value === null || value === void 0) continue;
30
- if (key === "styleId") {
31
- opts.style = value;
32
- continue;
33
- }
34
- opts[key] = value;
35
- }
36
- return opts;
37
- }
38
- function parseDocx(opts) {
39
- const resolved = typeof opts === "string" ? { text: opts } : opts;
40
- const attrs = {};
41
- if (resolved.style) attrs.styleId = resolved.style;
42
- for (const [key, value] of Object.entries(resolved)) {
43
- if (SKIP_KEYS.has(key)) continue;
44
- attrs[key] = value ?? null;
45
- }
46
- return attrs;
47
- }
48
- const attrNative = () => ({
49
- default: null,
50
- parseHTML: () => null,
51
- rendered: false
52
- });
53
- const TextStyle = TextStyle$1.extend({
54
- addAttributes() {
55
- return {
56
- ...this.parent?.(),
57
- styleId: {
58
- default: null,
59
- parseHTML: (element) => {
60
- const m = (element.getAttribute("class") || "").match(/(?:^|\s)docx-char-(\S+)/);
61
- return m ? m[1] : null;
62
- },
63
- renderHTML: (attributes) => {
64
- const id = attributes.styleId;
65
- return id ? { class: `docx-char-${id}` } : {};
66
- }
67
- },
68
- color: {
69
- default: null,
70
- parseHTML: (element) => normalizeColorToHex(element.style.color || void 0) ?? null,
71
- renderHTML: (attributes) => {
72
- if (attributes.color === "auto") return {};
73
- const hex = normalizeColorToHex(attributes.color);
74
- return hex ? { style: `color:${hex}` } : {};
75
- }
76
- },
77
- characterSpacing: {
78
- default: null,
79
- parseHTML: (element) => characterSpacingFromCss(element.style.letterSpacing || null),
80
- renderHTML: (attributes) => {
81
- const css = characterSpacingToCss(attributes.characterSpacing);
82
- return css ? { style: `letter-spacing:${css}` } : {};
83
- }
84
- },
85
- font: {
86
- default: null,
87
- parseHTML: (element) => element.style.fontFamily || null,
88
- renderHTML: (attributes) => {
89
- const name = resolveFontName(attributes.font);
90
- return name ? { style: `font-family:${name}` } : {};
91
- }
92
- },
93
- rightToLeft: {
94
- default: null,
95
- parseHTML: (element) => element.dir === "rtl" ? true : null,
96
- renderHTML: (attributes) => attributes.rightToLeft ? { style: "direction:rtl" } : {}
97
- },
98
- size: {
99
- default: null,
100
- parseHTML: (element) => sizeFromCss(element.style.fontSize),
101
- renderHTML: (attributes) => {
102
- const css = sizeToCss(attributes.size);
103
- return css ? { style: `font-size:${css}` } : {};
104
- }
105
- },
106
- shading: {
107
- default: null,
108
- parseHTML: (element) => shadingFromCss(element.style.backgroundColor),
109
- renderHTML: (attributes) => {
110
- const css = shadingToCss(attributes.shading);
111
- return css ? { style: `background-color:${css};color:contrast-color(${css})` } : {};
112
- }
113
- },
114
- underline: attrNative(),
115
- emphasisMark: attrNative(),
116
- highlight: attrNative(),
117
- smallCaps: attrNative(),
118
- allCaps: attrNative(),
119
- kern: attrNative(),
120
- position: attrNative(),
121
- effect: attrNative(),
122
- noProof: attrNative(),
123
- sizeComplexScript: attrNative(),
124
- highlightComplexScript: attrNative(),
125
- boldComplexScript: attrNative(),
126
- italicComplexScript: attrNative(),
127
- doubleStrike: attrNative(),
128
- emboss: attrNative(),
129
- imprint: attrNative(),
130
- revision: attrNative(),
131
- language: attrNative(),
132
- border: attrNative(),
133
- snapToGrid: attrNative(),
134
- vanish: attrNative(),
135
- specVanish: attrNative(),
136
- scale: attrNative(),
137
- math: attrNative(),
138
- outline: attrNative(),
139
- shadow: attrNative(),
140
- webHidden: attrNative(),
141
- fitText: attrNative(),
142
- complexScript: attrNative(),
143
- eastAsianLayout: attrNative(),
144
- contentPartRId: attrNative()
145
- };
146
- },
147
- renderDocx,
148
- parseDocx
149
- });
150
- //#endregion
151
- export { parseDocx as n, renderDocx as r, TextStyle as t };
@@ -1,33 +0,0 @@
1
- import { Document } from "@tiptap/extension-document";
2
- import { Text } from "@tiptap/extension-text";
3
- import { Paragraph } from "@tiptap/extension-paragraph";
4
- import { Heading } from "@tiptap/extension-heading";
5
- import { Blockquote } from "@tiptap/extension-blockquote";
6
- import { HorizontalRule } from "@tiptap/extension-horizontal-rule";
7
- import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
8
- import { BulletList } from "@tiptap/extension-bullet-list";
9
- import { OrderedList } from "@tiptap/extension-ordered-list";
10
- import { ListItem } from "@tiptap/extension-list-item";
11
- import { TaskList } from "@tiptap/extension-task-list";
12
- import { TaskItem } from "@tiptap/extension-task-item";
13
- import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
14
- import { Image } from "@tiptap/extension-image";
15
- import { HardBreak } from "@tiptap/extension-hard-break";
16
- import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details";
17
- import { Emoji } from "@tiptap/extension-emoji";
18
- import { Mention } from "@tiptap/extension-mention";
19
- import { Mathematics } from "@tiptap/extension-mathematics";
20
- import { Bold } from "@tiptap/extension-bold";
21
- import { Italic } from "@tiptap/extension-italic";
22
- import { Underline } from "@tiptap/extension-underline";
23
- import { Strike } from "@tiptap/extension-strike";
24
- import { Code } from "@tiptap/extension-code";
25
- import { Link } from "@tiptap/extension-link";
26
- import { Highlight } from "@tiptap/extension-highlight";
27
- import { Subscript } from "@tiptap/extension-subscript";
28
- import { Superscript } from "@tiptap/extension-superscript";
29
- import { TextStyle } from "@tiptap/extension-text-style";
30
- import { TextAlign } from "@tiptap/extension-text-align";
31
- import { Dropcursor, Gapcursor, TrailingNode, UndoRedo } from "@tiptap/extensions";
32
- import { ListKeymap } from "@tiptap/extension-list";
33
- export { TableCell as A, UndoRedo as B, Mention as C, Subscript as D, Strike as E, Text as F, TextAlign as I, TextStyle as L, TableRow as M, TaskItem as N, Superscript as O, TaskList as P, TrailingNode as R, Mathematics as S, Paragraph as T, Image as _, CodeBlockLowlight as a, ListItem as b, DetailsSummary as c, Emoji as d, Gapcursor as f, HorizontalRule as g, Highlight as h, Code as i, TableHeader as j, Table as k, Document as l, Heading as m, Bold as n, Details as o, HardBreak as p, BulletList as r, DetailsContent as s, Blockquote as t, Dropcursor as u, Italic as v, OrderedList as w, ListKeymap as x, Link as y, Underline as z };