@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.
- package/dist/converters/docx.d.mts +199 -1
- package/dist/converters/docx.mjs +1273 -1
- package/dist/converters/html.d.mts +28 -1
- package/dist/converters/html.mjs +103 -1
- package/dist/converters/markdown.d.mts +12 -1
- package/dist/converters/markdown.mjs +17 -1
- package/dist/converters/patch.d.mts +52 -1
- package/dist/converters/patch.mjs +35 -1
- package/dist/converters/prepare.d.mts +62 -1
- package/dist/converters/prepare.mjs +121 -1
- package/dist/converters/styles.d.mts +84 -1
- package/dist/converters/styles.mjs +284 -1
- package/dist/core-C9VunJ8o.d.mts +174 -0
- package/dist/core-DT9IrTzN.mjs +670 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/editor.d.mts +20 -1
- package/dist/editor.mjs +20 -1
- package/dist/extensions/blockquote.d.mts +1 -1
- package/dist/extensions/blockquote.mjs +30 -2
- package/dist/extensions/code-block.d.mts +1 -1
- package/dist/extensions/code-block.mjs +22 -1
- package/dist/extensions/column-break.d.mts +1 -1
- package/dist/extensions/column-break.mjs +1 -1
- package/dist/extensions/details.d.mts +1 -1
- package/dist/extensions/details.mjs +17 -2
- package/dist/extensions/document.mjs +49 -1
- package/dist/extensions/extensions.d.mts +3 -4
- package/dist/extensions/extensions.mjs +13 -14
- package/dist/extensions/formatting-marks.d.mts +7 -1
- package/dist/extensions/formatting-marks.mjs +1 -1
- package/dist/extensions/heading.mjs +165 -1
- package/dist/extensions/image.d.mts +1 -1
- package/dist/extensions/image.mjs +395 -1
- package/dist/extensions/index.d.mts +3 -2
- package/dist/extensions/index.mjs +4 -3
- package/dist/extensions/mention.d.mts +1 -1
- package/dist/extensions/mention.mjs +43 -2
- package/dist/extensions/ordered-list.d.mts +1 -1
- package/dist/extensions/ordered-list.mjs +40 -2
- package/dist/extensions/page-break.d.mts +1 -33
- package/dist/extensions/page-break.mjs +1 -1
- package/dist/extensions/paragraph.mjs +150 -1
- package/dist/extensions/passthrough.d.mts +1 -1
- package/dist/extensions/passthrough.mjs +1 -1
- package/dist/extensions/section-break.d.mts +19 -2
- package/dist/extensions/section-break.mjs +1 -1
- package/dist/extensions/strike.mjs +49 -1
- package/dist/extensions/table-cell.mjs +111 -1
- package/dist/extensions/table-header.mjs +111 -1
- package/dist/extensions/table-row.mjs +83 -1
- package/dist/extensions/table.mjs +159 -1
- package/dist/extensions/task-item.d.mts +1 -1
- package/dist/extensions/task-item.mjs +36 -2
- package/dist/extensions/text-style.mjs +150 -1
- package/dist/extensions/tiptap.d.mts +2 -2
- package/dist/extensions/tiptap.mjs +31 -2
- package/dist/extensions/utils.d.mts +2 -62
- package/dist/extensions/utils.mjs +499 -2
- package/dist/extensions/wpg-group.d.mts +2 -0
- package/dist/extensions/wpg-group.mjs +2 -0
- package/dist/extensions/wps-shape.d.mts +2 -0
- package/dist/extensions/wps-shape.mjs +2 -0
- package/dist/index.d.mts +86 -27
- package/dist/index.mjs +13 -10
- package/dist/{tiptap-TErPjuNJ.d.mts → tiptap-pZsNPsvV.d.mts} +1 -3
- package/dist/utils-D87vukzp.d.mts +128 -0
- package/package.json +39 -40
- package/dist/blockquote-Ky9xD_Q-.mjs +0 -31
- package/dist/code-block-BgNjhADy.mjs +0 -23
- package/dist/core-DEqBHRzE.mjs +0 -406
- package/dist/core-fBMCCj4D.d.mts +0 -97
- package/dist/details-Dh8luWb2.mjs +0 -18
- package/dist/dist-B6B3HnVZ.mjs +0 -1838
- package/dist/document-CvTym-FM.mjs +0 -50
- package/dist/docx-C5wyjI-0.d.mts +0 -200
- package/dist/docx-CONyAedl.mjs +0 -1231
- package/dist/editor-Bf3CxQnY.mjs +0 -21
- package/dist/editor-DReY3Rb9.d.mts +0 -21
- package/dist/emoji-BZ1dJD7d.d.mts +0 -17
- package/dist/emoji-C2OsTWR7.mjs +0 -27
- package/dist/extensions/emoji.d.mts +0 -2
- package/dist/extensions/emoji.mjs +0 -2
- package/dist/extensions/image-group.d.mts +0 -6
- package/dist/extensions/image-group.mjs +0 -2
- package/dist/heading-DAubgJJN.mjs +0 -166
- package/dist/html-DCC_DSHv.d.mts +0 -18
- package/dist/html-DedDWPoO.mjs +0 -66
- package/dist/image-CuEIXoZl.mjs +0 -334
- package/dist/markdown-BzJmRsBs.mjs +0 -18
- package/dist/markdown-D0k0sRYS.d.mts +0 -13
- package/dist/mention-C-dTR6MK.mjs +0 -44
- package/dist/ordered-list-V-3xFQmV.mjs +0 -41
- package/dist/paragraph-BrWH-BOV.mjs +0 -147
- package/dist/patch-Cdp5WKJz.d.mts +0 -53
- package/dist/patch-IZ13tXTu.mjs +0 -36
- package/dist/prepare-Bdk8Cjkf.mjs +0 -122
- package/dist/prepare-CPAvcv6q.d.mts +0 -63
- package/dist/strike-hWxShOgb.mjs +0 -50
- package/dist/styles-QSX3RhxK.mjs +0 -285
- package/dist/styles-ugspkrxz.d.mts +0 -85
- package/dist/table-DrA12lxX.mjs +0 -159
- package/dist/table-cell-DmkfYwDc.mjs +0 -112
- package/dist/table-header-Bwr5GKWg.mjs +0 -112
- package/dist/table-row-vew1y7WH.mjs +0 -84
- package/dist/task-item-BnlXGrIG.mjs +0 -37
- package/dist/text-style-tMeBq5XQ.mjs +0 -151
- package/dist/tiptap-D7pl4I5U.mjs +0 -33
- package/dist/utils-BPT4tjcn.mjs +0 -333
|
@@ -1,2 +1,160 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table as Table$1 } from "./tiptap.mjs";
|
|
2
|
+
import { alignmentFromElement, alignmentToCss, bordersFromElement, renderBorderCSS, shadingFromElement, shadingToCss, twipToCss } from "./utils.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
|
+
styles.push("max-width:100%");
|
|
97
|
+
if (a.indent && typeof a.indent === "object") {
|
|
98
|
+
const ind = a.indent;
|
|
99
|
+
if (ind.size != null) {
|
|
100
|
+
const css = twipToCss(ind.size);
|
|
101
|
+
if (css) styles.push(`margin-left:${css}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (a.cellSpacing && typeof a.cellSpacing === "object") {
|
|
105
|
+
const cs = a.cellSpacing;
|
|
106
|
+
if (cs.value != null) {
|
|
107
|
+
const css = twipToCss(cs.value);
|
|
108
|
+
if (css) styles.push(`border-spacing:${css}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const bg = shadingToCss(a.shading);
|
|
112
|
+
if (bg) styles.push(`background-color:${bg}`);
|
|
113
|
+
if (a.borders && typeof a.borders === "object") {
|
|
114
|
+
const b = a.borders;
|
|
115
|
+
const sides = [
|
|
116
|
+
["top", b.top],
|
|
117
|
+
["bottom", b.bottom],
|
|
118
|
+
["left", b.left],
|
|
119
|
+
["right", b.right]
|
|
120
|
+
];
|
|
121
|
+
for (const [side, border] of sides) {
|
|
122
|
+
const css = renderBorderCSS(border);
|
|
123
|
+
if (css) styles.push(`border-${side}:${css}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const firstRow = node.firstChild;
|
|
127
|
+
const cellPx = [];
|
|
128
|
+
if (firstRow) for (let i = 0; i < firstRow.childCount; i++) {
|
|
129
|
+
const cw = firstRow.child(i).attrs.colwidth;
|
|
130
|
+
if (Array.isArray(cw) && cw.length) for (const w of cw) cellPx.push(w || 0);
|
|
131
|
+
else cellPx.push(0);
|
|
132
|
+
}
|
|
133
|
+
const hasCellWidths = cellPx.some((w) => w > 0);
|
|
134
|
+
const tblGridPx = (a.columnWidths ?? []).map((w) => Math.round((w || 0) / 15));
|
|
135
|
+
const gridPx = tblGridPx.some((w) => w > 0) ? tblGridPx : hasCellWidths ? cellPx : tblGridPx;
|
|
136
|
+
if (styles.length > 0) attrs.style = styles.join(";");
|
|
137
|
+
if (gridPx.some((w) => w > 0)) {
|
|
138
|
+
const gridTotal = gridPx.reduce((sum, w) => sum + w, 0);
|
|
139
|
+
return [
|
|
140
|
+
"table",
|
|
141
|
+
attrs,
|
|
142
|
+
[
|
|
143
|
+
"colgroup",
|
|
144
|
+
{},
|
|
145
|
+
...gridPx.map((w) => ["col", { style: `width:${gridTotal > 0 ? (w / gridTotal * 100).toFixed(2) : 0}%` }])
|
|
146
|
+
],
|
|
147
|
+
["tbody", 0]
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
return [
|
|
151
|
+
"table",
|
|
152
|
+
attrs,
|
|
153
|
+
0
|
|
154
|
+
];
|
|
155
|
+
},
|
|
156
|
+
renderDocx,
|
|
157
|
+
parseDocx
|
|
158
|
+
});
|
|
159
|
+
//#endregion
|
|
2
160
|
export { Table, parseDocx, renderDocx };
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TaskItem } from "./tiptap.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
|
|
3
37
|
export { TASK_CHECKBOX_TAG, TaskItem, createTaskCheckbox, isTaskCheckbox, readCheckboxState };
|
|
@@ -1,2 +1,151 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextStyle as TextStyle$1 } from "./tiptap.mjs";
|
|
2
|
+
import { characterSpacingFromCss, characterSpacingToCss, normalizeColorToHex, resolveFontFamilyCss, shadingFromCss, shadingToCss, sizeFromCss, sizeToCss } from "./utils.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 = resolveFontFamilyCss(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
|
|
2
151
|
export { TextStyle, parseDocx, renderDocx };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document,
|
|
1
|
+
import { A as TaskItem, C as Strike, D as TableCell, E as Table, F as Underline, M as Text, N as TextAlign, O as TableHeader, P as TextStyle, S as Paragraph, T as Superscript, _ as Link, a as CodeBlockLowlight, b as Mention, c as DetailsSummary, d as HardBreak, f as Heading, g as Italic, h as Image, i as Code, j as TaskList, k as TableRow, l as Document, m as HorizontalRule, n as Bold, o as Details, p as Highlight, r as BulletList, s as DetailsContent, t as Blockquote, u as Emoji, v as ListItem, w as Subscript, x as OrderedList, y as Mathematics } from "../tiptap-pZsNPsvV.mjs";
|
|
2
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, Emoji, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Paragraph, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, Underline };
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Document, Emoji, HardBreak, Heading, Highlight, HorizontalRule, Image, Italic, Link, ListItem, Mathematics, Mention, OrderedList, Paragraph, Strike, Subscript, Superscript, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, Underline };
|
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/extensions/utils.d.ts
|
|
4
|
-
/** Normalize a CSS color value to hex (e.g., "red" → "#FF0000", "#ff0000" → "#FF0000").
|
|
5
|
-
* Accepts a string (CSS name/hex or bare OOXML hex), or an OOXML ColorOptions
|
|
6
|
-
* object ({ val, themeColor, themeTint, themeShade }) — the object form
|
|
7
|
-
* resolves to its val (the RGB fallback Word stores alongside themeColor) for
|
|
8
|
-
* CSS rendering. The themeColor/tint/shade are preserved verbatim in the attrs
|
|
9
|
-
* and round-trip back to the DOCX (see text-style/paragraph parseDocx), so
|
|
10
|
-
* theme semantics survive even though only val is rendered here. A pure theme
|
|
11
|
-
* reference with no val (rare — Word usually stores both) would need theme.xml
|
|
12
|
-
* to resolve and is left unset. */
|
|
13
|
-
declare function normalizeColorToHex(color: unknown): string | undefined;
|
|
14
|
-
/** Resolve a font value (string or OOXML rFonts { ascii, eastAsia, hAnsi, cs }) to a CSS family name. */
|
|
15
|
-
declare function resolveFontName(font: unknown): string | null;
|
|
16
|
-
/** CSS value (e.g., "18pt") → twip number. 1 pt = 20 twips, 1 px = 15 twips (96 DPI). */
|
|
17
|
-
declare function cssToTwip(value: string | undefined): number | undefined;
|
|
18
|
-
/** Twip value → CSS string (e.g., 360 → "18pt"). */
|
|
19
|
-
declare function twipToCss(value: number | string | undefined): string | null;
|
|
20
|
-
/** OOXML alignment → CSS text-align. */
|
|
21
|
-
declare function alignmentToCss(alignment: string | null | undefined): string | null;
|
|
22
|
-
/** CSS text-align → OOXML alignment. */
|
|
23
|
-
declare function alignmentFromCss(css: string | null | undefined): string | null;
|
|
24
|
-
/** Shading.fill → CSS background-color hex. */
|
|
25
|
-
declare function shadingToCss(shading: ShadingAttributesProperties | null | undefined): string | null;
|
|
26
|
-
/** CSS background-color → ShadingAttributesProperties (fill normalized to hex). */
|
|
27
|
-
declare function shadingFromCss(css: string | null | undefined): ShadingAttributesProperties | null;
|
|
28
|
-
declare function lineSpacingToCss(spacing: SpacingProperties | null | undefined): string | null;
|
|
29
|
-
declare function sizeToCss(size: number | null | undefined): string | null;
|
|
30
|
-
declare function sizeFromCss(css: string | null | undefined): number | null;
|
|
31
|
-
declare function characterSpacingToCss(spacing: number | null | undefined): string | null;
|
|
32
|
-
declare function characterSpacingFromCss(css: string | null | undefined): number | null;
|
|
33
|
-
/** Render a BorderOptions to CSS string. OOXML border.size is in eighths of a point. */
|
|
34
|
-
declare function renderBorderCSS(border: BorderOptions): string | null;
|
|
35
|
-
/**
|
|
36
|
-
* Compute all paragraph-level CSS styles from nested attrs.
|
|
37
|
-
* Shared by Paragraph and Heading extensions for node-level renderHTML.
|
|
38
|
-
* Attrs store office-open native values; mappers here convert to CSS.
|
|
39
|
-
*/
|
|
40
|
-
declare function renderParagraphStyles(attrs: Record<string, unknown>): string[];
|
|
41
|
-
/**
|
|
42
|
-
* Compute run-level CSS (font/size/color/weight/…) from office-open run attrs.
|
|
43
|
-
* Shared by text-style marks and the styles→CSS generator (stylesToCss).
|
|
44
|
-
*/
|
|
45
|
-
declare function renderRunStyles(attrs: Record<string, unknown>): string[];
|
|
46
|
-
/**
|
|
47
|
-
* Compute table cell CSS styles from nested attrs.
|
|
48
|
-
* Shared by TableCell and TableHeader extensions.
|
|
49
|
-
*/
|
|
50
|
-
declare function renderTableCellStyles(attrs: Record<string, unknown>): string[];
|
|
51
|
-
/** Parse text-align → OOXML alignment. */
|
|
52
|
-
declare function alignmentFromElement(el: HTMLElement): string | null;
|
|
53
|
-
/** Parse margin-left/right + text-indent → OOXML indent (twips). */
|
|
54
|
-
declare function indentFromElement(el: HTMLElement): IndentAttributesProperties | null;
|
|
55
|
-
/** Parse margin-top/bottom + line-height → OOXML spacing (twips). */
|
|
56
|
-
declare function spacingFromElement(el: HTMLElement): SpacingProperties | null;
|
|
57
|
-
/** Parse border-* → OOXML BordersOptions. */
|
|
58
|
-
declare function bordersFromElement(el: HTMLElement): BordersOptions | null;
|
|
59
|
-
/** Parse background-color → OOXML shading. */
|
|
60
|
-
declare function shadingFromElement(el: HTMLElement): ShadingAttributesProperties | null;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { alignmentFromCss, alignmentFromElement, alignmentToCss, bordersFromElement, characterSpacingFromCss, characterSpacingToCss, cssToTwip, indentFromElement, lineSpacingToCss, normalizeColorToHex, renderBorderCSS, renderParagraphStyles, renderRunStyles, renderTableCellStyles, resolveFontName, shadingFromCss, shadingFromElement, shadingToCss, sizeFromCss, sizeToCss, spacingFromElement, twipToCss };
|
|
1
|
+
import { C as shadingFromElement, D as spacingFromElement, E as sizeToCss, O as twipToCss, S as shadingFromCss, T as sizeFromCss, _ as resolveFontFamilyCss, a as characterSpacingFromCss, b as sectionLinePitchCss, c as floatAnchorScope, d as lineSpacingToCss, f as normalizeColorToHex, g as renderTableCellStyles, h as renderRunStyles, i as bordersFromElement, k as twipsToMm, l as floatingToStyles, m as renderParagraphStyles, n as alignmentFromElement, o as characterSpacingToCss, p as renderBorderCSS, r as alignmentToCss, s as cssToTwip, t as alignmentFromCss, u as indentFromElement, v as resolveFontName, w as shadingToCss, x as sectionMarginCss, y as resolvePageSize } from "../utils-D87vukzp.mjs";
|
|
2
|
+
export { alignmentFromCss, alignmentFromElement, alignmentToCss, bordersFromElement, characterSpacingFromCss, characterSpacingToCss, cssToTwip, floatAnchorScope, floatingToStyles, indentFromElement, lineSpacingToCss, normalizeColorToHex, renderBorderCSS, renderParagraphStyles, renderRunStyles, renderTableCellStyles, resolveFontFamilyCss, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, shadingFromCss, shadingFromElement, shadingToCss, sizeFromCss, sizeToCss, spacingFromElement, twipToCss, twipsToMm };
|