@xignature/docx-editor 1.0.0
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/FindReplaceDialog-QIGO4OJT.mjs +35 -0
- package/dist/FootnotePropertiesDialog-JPXQGUW6.mjs +248 -0
- package/dist/HyperlinkDialog-FKJNYDPU.mjs +33 -0
- package/dist/ImagePositionDialog-GNWPNWDW.mjs +384 -0
- package/dist/ImagePropertiesDialog-X444B4VT.mjs +255 -0
- package/dist/PageSetupDialog-VVADE54Z.mjs +218 -0
- package/dist/SplitCellDialog-7LP6IJIJ.mjs +199 -0
- package/dist/TablePropertiesDialog-OKWY22PF.mjs +194 -0
- package/dist/chunk-625UL7ND.mjs +928 -0
- package/dist/chunk-IAU6OTCV.mjs +969 -0
- package/dist/chunk-K4JMXHBE.mjs +61 -0
- package/dist/chunk-OG6X5JJA.mjs +825 -0
- package/dist/chunk-QGDML3KL.mjs +258 -0
- package/dist/chunk-TSNYN4SV.mjs +589 -0
- package/dist/chunk-VOCY4R5S.mjs +1642 -0
- package/dist/executor-WLWTO7VJ.mjs +8 -0
- package/dist/index.css +483 -0
- package/dist/index.d.mts +8891 -0
- package/dist/index.d.ts +8891 -0
- package/dist/index.js +61000 -0
- package/dist/index.mjs +53887 -0
- package/dist/processTemplate-3HXKJ3EC.mjs +26 -0
- package/dist/selectionRects-I6KGVVI7.mjs +12 -0
- package/package.json +70 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TWIPS_PER_INCH
|
|
3
|
+
} from "./chunk-K4JMXHBE.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useTranslation
|
|
6
|
+
} from "./chunk-OG6X5JJA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/react/components/dialogs/PageSetupDialog.tsx
|
|
9
|
+
import { useState, useCallback, useEffect } from "react";
|
|
10
|
+
import {
|
|
11
|
+
Modal,
|
|
12
|
+
ModalContent,
|
|
13
|
+
ModalHeader,
|
|
14
|
+
ModalBody,
|
|
15
|
+
ModalFooter,
|
|
16
|
+
Button,
|
|
17
|
+
Select,
|
|
18
|
+
SelectItem,
|
|
19
|
+
Input
|
|
20
|
+
} from "@heroui/react";
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
var PAGE_SIZES = [
|
|
23
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.letter", width: 12240, height: 15840 },
|
|
24
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.a4", width: 11906, height: 16838 },
|
|
25
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.legal", width: 12240, height: 20160 },
|
|
26
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.a3", width: 16838, height: 23811 },
|
|
27
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.a5", width: 8391, height: 11906 },
|
|
28
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.b5", width: 9979, height: 14175 },
|
|
29
|
+
{ labelKey: "dialogs.pageSetup.pageSizes.executive", width: 10440, height: 15120 }
|
|
30
|
+
];
|
|
31
|
+
function twipsToInches(twips) {
|
|
32
|
+
return Math.round(twips / TWIPS_PER_INCH * 100) / 100;
|
|
33
|
+
}
|
|
34
|
+
function inchesToTwips(inches) {
|
|
35
|
+
return Math.round(inches * TWIPS_PER_INCH);
|
|
36
|
+
}
|
|
37
|
+
function findPageSizeIndex(w, h) {
|
|
38
|
+
const pw = Math.min(w, h);
|
|
39
|
+
const ph = Math.max(w, h);
|
|
40
|
+
return PAGE_SIZES.findIndex((s) => Math.abs(s.width - pw) < 20 && Math.abs(s.height - ph) < 20);
|
|
41
|
+
}
|
|
42
|
+
var sectionLabelStyle = {
|
|
43
|
+
fontSize: 12,
|
|
44
|
+
fontWeight: 600,
|
|
45
|
+
color: "var(--doc-text-muted)",
|
|
46
|
+
textTransform: "uppercase",
|
|
47
|
+
letterSpacing: "0.5px"
|
|
48
|
+
};
|
|
49
|
+
var DEFAULT_WIDTH = 12240;
|
|
50
|
+
var DEFAULT_HEIGHT = 15840;
|
|
51
|
+
var DEFAULT_MARGIN = 1440;
|
|
52
|
+
function PageSetupDialog({
|
|
53
|
+
isOpen,
|
|
54
|
+
onClose,
|
|
55
|
+
onApply,
|
|
56
|
+
currentProps
|
|
57
|
+
}) {
|
|
58
|
+
const { t } = useTranslation();
|
|
59
|
+
const [pageWidth, setPageWidth] = useState(DEFAULT_WIDTH);
|
|
60
|
+
const [pageHeight, setPageHeight] = useState(DEFAULT_HEIGHT);
|
|
61
|
+
const [orientation, setOrientation] = useState("portrait");
|
|
62
|
+
const [marginTop, setMarginTop] = useState(DEFAULT_MARGIN);
|
|
63
|
+
const [marginBottom, setMarginBottom] = useState(DEFAULT_MARGIN);
|
|
64
|
+
const [marginLeft, setMarginLeft] = useState(DEFAULT_MARGIN);
|
|
65
|
+
const [marginRight, setMarginRight] = useState(DEFAULT_MARGIN);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!isOpen) return;
|
|
68
|
+
const w = currentProps?.pageWidth || DEFAULT_WIDTH;
|
|
69
|
+
const h = currentProps?.pageHeight || DEFAULT_HEIGHT;
|
|
70
|
+
const orient = currentProps?.orientation || (w > h ? "landscape" : "portrait");
|
|
71
|
+
setPageWidth(w);
|
|
72
|
+
setPageHeight(h);
|
|
73
|
+
setOrientation(orient);
|
|
74
|
+
setMarginTop(currentProps?.marginTop ?? DEFAULT_MARGIN);
|
|
75
|
+
setMarginBottom(currentProps?.marginBottom ?? DEFAULT_MARGIN);
|
|
76
|
+
setMarginLeft(currentProps?.marginLeft ?? DEFAULT_MARGIN);
|
|
77
|
+
setMarginRight(currentProps?.marginRight ?? DEFAULT_MARGIN);
|
|
78
|
+
}, [isOpen, currentProps]);
|
|
79
|
+
const handlePageSizeChange = useCallback(
|
|
80
|
+
(key) => {
|
|
81
|
+
const index = Number(key);
|
|
82
|
+
if (index < 0) return;
|
|
83
|
+
const size = PAGE_SIZES[index];
|
|
84
|
+
if (orientation === "landscape") {
|
|
85
|
+
setPageWidth(size.height);
|
|
86
|
+
setPageHeight(size.width);
|
|
87
|
+
} else {
|
|
88
|
+
setPageWidth(size.width);
|
|
89
|
+
setPageHeight(size.height);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[orientation]
|
|
93
|
+
);
|
|
94
|
+
const handleOrientationChange = useCallback(
|
|
95
|
+
(newOrientation) => {
|
|
96
|
+
if (newOrientation === orientation) return;
|
|
97
|
+
setOrientation(newOrientation);
|
|
98
|
+
setPageWidth(pageHeight);
|
|
99
|
+
setPageHeight(pageWidth);
|
|
100
|
+
},
|
|
101
|
+
[orientation, pageWidth, pageHeight]
|
|
102
|
+
);
|
|
103
|
+
const handleApply = useCallback(() => {
|
|
104
|
+
onApply({
|
|
105
|
+
pageWidth,
|
|
106
|
+
pageHeight,
|
|
107
|
+
orientation,
|
|
108
|
+
marginTop,
|
|
109
|
+
marginBottom,
|
|
110
|
+
marginLeft,
|
|
111
|
+
marginRight
|
|
112
|
+
});
|
|
113
|
+
onClose();
|
|
114
|
+
}, [
|
|
115
|
+
pageWidth,
|
|
116
|
+
pageHeight,
|
|
117
|
+
orientation,
|
|
118
|
+
marginTop,
|
|
119
|
+
marginBottom,
|
|
120
|
+
marginLeft,
|
|
121
|
+
marginRight,
|
|
122
|
+
onApply,
|
|
123
|
+
onClose
|
|
124
|
+
]);
|
|
125
|
+
const sizeIndex = findPageSizeIndex(pageWidth, pageHeight);
|
|
126
|
+
return /* @__PURE__ */ jsx(Modal, { isOpen, onClose, size: "md", scrollBehavior: "inside", children: /* @__PURE__ */ jsxs(ModalContent, { children: [
|
|
127
|
+
/* @__PURE__ */ jsx(ModalHeader, { className: "flex flex-col gap-1", children: t("dialogs.pageSetup.title") }),
|
|
128
|
+
/* @__PURE__ */ jsx(ModalBody, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
129
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
130
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: t("dialogs.pageSetup.pageSize") }),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Select,
|
|
133
|
+
{
|
|
134
|
+
label: t("dialogs.pageSetup.sizeLabel"),
|
|
135
|
+
selectedKeys: [sizeIndex.toString()],
|
|
136
|
+
onChange: (e) => handlePageSizeChange(e.target.value),
|
|
137
|
+
variant: "bordered",
|
|
138
|
+
children: [
|
|
139
|
+
...PAGE_SIZES.map((size, i) => /* @__PURE__ */ jsx(SelectItem, { textValue: t(size.labelKey), children: t(size.labelKey) }, i.toString())),
|
|
140
|
+
...sizeIndex < 0 ? [
|
|
141
|
+
/* @__PURE__ */ jsx(SelectItem, { textValue: t("dialogs.pageSetup.custom"), children: t("dialogs.pageSetup.custom") }, "-1")
|
|
142
|
+
] : []
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ jsxs(
|
|
147
|
+
Select,
|
|
148
|
+
{
|
|
149
|
+
label: t("dialogs.pageSetup.orientation"),
|
|
150
|
+
selectedKeys: [orientation],
|
|
151
|
+
onChange: (e) => handleOrientationChange(e.target.value),
|
|
152
|
+
variant: "bordered",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx(SelectItem, { textValue: t("dialogs.pageSetup.portrait"), children: t("dialogs.pageSetup.portrait") }, "portrait"),
|
|
155
|
+
/* @__PURE__ */ jsx(SelectItem, { textValue: t("dialogs.pageSetup.landscape"), children: t("dialogs.pageSetup.landscape") }, "landscape")
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
161
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: t("dialogs.pageSetup.margins") }),
|
|
162
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
163
|
+
/* @__PURE__ */ jsx(
|
|
164
|
+
Input,
|
|
165
|
+
{
|
|
166
|
+
type: "number",
|
|
167
|
+
label: t("dialogs.pageSetup.top"),
|
|
168
|
+
endContent: /* @__PURE__ */ jsx("span", { className: "text-default-400 text-small", children: "in" }),
|
|
169
|
+
value: twipsToInches(marginTop).toString(),
|
|
170
|
+
onChange: (e) => setMarginTop(inchesToTwips(Number(e.target.value) || 0)),
|
|
171
|
+
variant: "bordered"
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
/* @__PURE__ */ jsx(
|
|
175
|
+
Input,
|
|
176
|
+
{
|
|
177
|
+
type: "number",
|
|
178
|
+
label: t("dialogs.pageSetup.bottom"),
|
|
179
|
+
endContent: /* @__PURE__ */ jsx("span", { className: "text-default-400 text-small", children: "in" }),
|
|
180
|
+
value: twipsToInches(marginBottom).toString(),
|
|
181
|
+
onChange: (e) => setMarginBottom(inchesToTwips(Number(e.target.value) || 0)),
|
|
182
|
+
variant: "bordered"
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsx(
|
|
186
|
+
Input,
|
|
187
|
+
{
|
|
188
|
+
type: "number",
|
|
189
|
+
label: t("dialogs.pageSetup.left"),
|
|
190
|
+
endContent: /* @__PURE__ */ jsx("span", { className: "text-default-400 text-small", children: "in" }),
|
|
191
|
+
value: twipsToInches(marginLeft).toString(),
|
|
192
|
+
onChange: (e) => setMarginLeft(inchesToTwips(Number(e.target.value) || 0)),
|
|
193
|
+
variant: "bordered"
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ jsx(
|
|
197
|
+
Input,
|
|
198
|
+
{
|
|
199
|
+
type: "number",
|
|
200
|
+
label: t("dialogs.pageSetup.right"),
|
|
201
|
+
endContent: /* @__PURE__ */ jsx("span", { className: "text-default-400 text-small", children: "in" }),
|
|
202
|
+
value: twipsToInches(marginRight).toString(),
|
|
203
|
+
onChange: (e) => setMarginRight(inchesToTwips(Number(e.target.value) || 0)),
|
|
204
|
+
variant: "bordered"
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] })
|
|
208
|
+
] })
|
|
209
|
+
] }) }),
|
|
210
|
+
/* @__PURE__ */ jsxs(ModalFooter, { children: [
|
|
211
|
+
/* @__PURE__ */ jsx(Button, { variant: "flat", onPress: onClose, children: t("common.cancel") }),
|
|
212
|
+
/* @__PURE__ */ jsx(Button, { color: "primary", onPress: handleApply, children: t("common.apply") })
|
|
213
|
+
] })
|
|
214
|
+
] }) });
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
PageSetupDialog
|
|
218
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTranslation
|
|
3
|
+
} from "./chunk-OG6X5JJA.mjs";
|
|
4
|
+
|
|
5
|
+
// src/react/components/dialogs/SplitCellDialog.tsx
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var overlayStyle = {
|
|
9
|
+
position: "fixed",
|
|
10
|
+
top: 0,
|
|
11
|
+
left: 0,
|
|
12
|
+
right: 0,
|
|
13
|
+
bottom: 0,
|
|
14
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
15
|
+
display: "flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
zIndex: 1e4
|
|
19
|
+
};
|
|
20
|
+
var dialogStyle = {
|
|
21
|
+
backgroundColor: "white",
|
|
22
|
+
borderRadius: 8,
|
|
23
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
24
|
+
minWidth: 360,
|
|
25
|
+
maxWidth: 440,
|
|
26
|
+
width: "100%",
|
|
27
|
+
margin: 20
|
|
28
|
+
};
|
|
29
|
+
var headerStyle = {
|
|
30
|
+
padding: "16px 20px 12px",
|
|
31
|
+
borderBottom: "1px solid var(--doc-border)",
|
|
32
|
+
fontSize: 16,
|
|
33
|
+
fontWeight: 600
|
|
34
|
+
};
|
|
35
|
+
var bodyStyle = {
|
|
36
|
+
padding: "16px 20px",
|
|
37
|
+
display: "flex",
|
|
38
|
+
flexDirection: "column",
|
|
39
|
+
gap: 12
|
|
40
|
+
};
|
|
41
|
+
var rowStyle = {
|
|
42
|
+
display: "flex",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
gap: 12
|
|
45
|
+
};
|
|
46
|
+
var labelStyle = {
|
|
47
|
+
width: 88,
|
|
48
|
+
fontSize: 13,
|
|
49
|
+
color: "var(--doc-text-muted)"
|
|
50
|
+
};
|
|
51
|
+
var inputStyle = {
|
|
52
|
+
flex: 1,
|
|
53
|
+
padding: "6px 8px",
|
|
54
|
+
border: "1px solid var(--doc-border)",
|
|
55
|
+
borderRadius: 4,
|
|
56
|
+
fontSize: 13
|
|
57
|
+
};
|
|
58
|
+
var helperStyle = {
|
|
59
|
+
fontSize: 12,
|
|
60
|
+
color: "var(--doc-text-muted)",
|
|
61
|
+
lineHeight: 1.5
|
|
62
|
+
};
|
|
63
|
+
var errorStyle = {
|
|
64
|
+
...helperStyle,
|
|
65
|
+
color: "var(--doc-error)"
|
|
66
|
+
};
|
|
67
|
+
var footerStyle = {
|
|
68
|
+
padding: "12px 20px 16px",
|
|
69
|
+
borderTop: "1px solid var(--doc-border)",
|
|
70
|
+
display: "flex",
|
|
71
|
+
justifyContent: "flex-end",
|
|
72
|
+
gap: 8
|
|
73
|
+
};
|
|
74
|
+
var btnStyle = {
|
|
75
|
+
padding: "6px 16px",
|
|
76
|
+
fontSize: 13,
|
|
77
|
+
border: "1px solid var(--doc-border)",
|
|
78
|
+
borderRadius: 4,
|
|
79
|
+
cursor: "pointer"
|
|
80
|
+
};
|
|
81
|
+
function SplitCellDialog({
|
|
82
|
+
isOpen,
|
|
83
|
+
onClose,
|
|
84
|
+
onApply,
|
|
85
|
+
initialRows = 1,
|
|
86
|
+
initialCols = 1,
|
|
87
|
+
minRows = 1,
|
|
88
|
+
minCols = 1
|
|
89
|
+
}) {
|
|
90
|
+
const { t } = useTranslation();
|
|
91
|
+
const [rows, setRows] = useState(initialRows);
|
|
92
|
+
const [cols, setCols] = useState(initialCols);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (isOpen) {
|
|
95
|
+
setRows(initialRows);
|
|
96
|
+
setCols(initialCols);
|
|
97
|
+
}
|
|
98
|
+
}, [initialCols, initialRows, isOpen]);
|
|
99
|
+
const validationError = useMemo(() => {
|
|
100
|
+
if (rows < minRows || cols < minCols) {
|
|
101
|
+
return t("dialogs.splitCell.minValue", { rows: minRows, cols: minCols });
|
|
102
|
+
}
|
|
103
|
+
if (rows === 1 && cols === 1) {
|
|
104
|
+
return t("dialogs.splitCell.notOneByOne");
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}, [cols, minCols, minRows, rows, t]);
|
|
108
|
+
const handleApply = useCallback(() => {
|
|
109
|
+
if (validationError) return;
|
|
110
|
+
onApply(rows, cols);
|
|
111
|
+
onClose();
|
|
112
|
+
}, [cols, onApply, onClose, rows, validationError]);
|
|
113
|
+
const handleKeyDown = useCallback(
|
|
114
|
+
(event) => {
|
|
115
|
+
if (event.key === "Escape") onClose();
|
|
116
|
+
if (event.key === "Enter") handleApply();
|
|
117
|
+
},
|
|
118
|
+
[handleApply, onClose]
|
|
119
|
+
);
|
|
120
|
+
if (!isOpen) return null;
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
style: overlayStyle,
|
|
125
|
+
onClick: onClose,
|
|
126
|
+
onKeyDown: handleKeyDown,
|
|
127
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
128
|
+
children: /* @__PURE__ */ jsxs(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
style: dialogStyle,
|
|
132
|
+
onClick: (event) => event.stopPropagation(),
|
|
133
|
+
role: "dialog",
|
|
134
|
+
"aria-label": t("dialogs.splitCell.title"),
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsx("div", { style: headerStyle, children: t("dialogs.splitCell.title") }),
|
|
137
|
+
/* @__PURE__ */ jsxs("div", { style: bodyStyle, children: [
|
|
138
|
+
/* @__PURE__ */ jsx("div", { style: helperStyle, children: t("dialogs.splitCell.description") }),
|
|
139
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
140
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.splitCell.rowsLabel") }),
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"input",
|
|
143
|
+
{
|
|
144
|
+
type: "number",
|
|
145
|
+
style: inputStyle,
|
|
146
|
+
min: minRows,
|
|
147
|
+
step: 1,
|
|
148
|
+
value: rows,
|
|
149
|
+
onChange: (event) => setRows(Math.max(0, Number(event.target.value) || 0))
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
154
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.splitCell.columnsLabel") }),
|
|
155
|
+
/* @__PURE__ */ jsx(
|
|
156
|
+
"input",
|
|
157
|
+
{
|
|
158
|
+
type: "number",
|
|
159
|
+
style: inputStyle,
|
|
160
|
+
min: minCols,
|
|
161
|
+
step: 1,
|
|
162
|
+
value: cols,
|
|
163
|
+
onChange: (event) => setCols(Math.max(0, Number(event.target.value) || 0))
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ jsx("div", { style: validationError ? errorStyle : helperStyle, children: validationError ?? t("dialogs.splitCell.currentMinimum", { rows: minRows, cols: minCols }) })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsxs("div", { style: footerStyle, children: [
|
|
170
|
+
/* @__PURE__ */ jsx("button", { type: "button", style: btnStyle, onClick: onClose, children: t("common.cancel") }),
|
|
171
|
+
/* @__PURE__ */ jsx(
|
|
172
|
+
"button",
|
|
173
|
+
{
|
|
174
|
+
type: "button",
|
|
175
|
+
style: {
|
|
176
|
+
...btnStyle,
|
|
177
|
+
backgroundColor: "var(--doc-primary)",
|
|
178
|
+
color: "white",
|
|
179
|
+
borderColor: "var(--doc-primary)",
|
|
180
|
+
opacity: validationError ? 0.6 : 1,
|
|
181
|
+
cursor: validationError ? "not-allowed" : "pointer"
|
|
182
|
+
},
|
|
183
|
+
disabled: !!validationError,
|
|
184
|
+
onClick: handleApply,
|
|
185
|
+
children: t("common.apply")
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
] })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
var SplitCellDialog_default = SplitCellDialog;
|
|
196
|
+
export {
|
|
197
|
+
SplitCellDialog,
|
|
198
|
+
SplitCellDialog_default as default
|
|
199
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTranslation
|
|
3
|
+
} from "./chunk-OG6X5JJA.mjs";
|
|
4
|
+
|
|
5
|
+
// src/react/components/dialogs/TablePropertiesDialog.tsx
|
|
6
|
+
import { useState, useCallback, useEffect } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var overlayStyle = {
|
|
9
|
+
position: "fixed",
|
|
10
|
+
top: 0,
|
|
11
|
+
left: 0,
|
|
12
|
+
right: 0,
|
|
13
|
+
bottom: 0,
|
|
14
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
15
|
+
display: "flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
zIndex: 1e4
|
|
19
|
+
};
|
|
20
|
+
var dialogStyle = {
|
|
21
|
+
backgroundColor: "white",
|
|
22
|
+
borderRadius: 8,
|
|
23
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
24
|
+
minWidth: 360,
|
|
25
|
+
maxWidth: 440,
|
|
26
|
+
width: "100%",
|
|
27
|
+
margin: 20
|
|
28
|
+
};
|
|
29
|
+
var headerStyle = {
|
|
30
|
+
padding: "16px 20px 12px",
|
|
31
|
+
borderBottom: "1px solid var(--doc-border)",
|
|
32
|
+
fontSize: 16,
|
|
33
|
+
fontWeight: 600
|
|
34
|
+
};
|
|
35
|
+
var bodyStyle = {
|
|
36
|
+
padding: "16px 20px",
|
|
37
|
+
display: "flex",
|
|
38
|
+
flexDirection: "column",
|
|
39
|
+
gap: 12
|
|
40
|
+
};
|
|
41
|
+
var rowStyle = {
|
|
42
|
+
display: "flex",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
gap: 12
|
|
45
|
+
};
|
|
46
|
+
var labelStyle = {
|
|
47
|
+
width: 80,
|
|
48
|
+
fontSize: 13,
|
|
49
|
+
color: "var(--doc-text-muted)"
|
|
50
|
+
};
|
|
51
|
+
var inputStyle = {
|
|
52
|
+
flex: 1,
|
|
53
|
+
padding: "6px 8px",
|
|
54
|
+
border: "1px solid var(--doc-border)",
|
|
55
|
+
borderRadius: 4,
|
|
56
|
+
fontSize: 13
|
|
57
|
+
};
|
|
58
|
+
var selectStyle = {
|
|
59
|
+
...inputStyle
|
|
60
|
+
};
|
|
61
|
+
var footerStyle = {
|
|
62
|
+
padding: "12px 20px 16px",
|
|
63
|
+
borderTop: "1px solid var(--doc-border)",
|
|
64
|
+
display: "flex",
|
|
65
|
+
justifyContent: "flex-end",
|
|
66
|
+
gap: 8
|
|
67
|
+
};
|
|
68
|
+
var btnStyle = {
|
|
69
|
+
padding: "6px 16px",
|
|
70
|
+
fontSize: 13,
|
|
71
|
+
border: "1px solid var(--doc-border)",
|
|
72
|
+
borderRadius: 4,
|
|
73
|
+
cursor: "pointer"
|
|
74
|
+
};
|
|
75
|
+
function TablePropertiesDialog({
|
|
76
|
+
isOpen,
|
|
77
|
+
onClose,
|
|
78
|
+
onApply,
|
|
79
|
+
currentProps
|
|
80
|
+
}) {
|
|
81
|
+
const { t } = useTranslation();
|
|
82
|
+
const [width, setWidth] = useState(currentProps?.width || 0);
|
|
83
|
+
const [widthType, setWidthType] = useState(currentProps?.widthType || "auto");
|
|
84
|
+
const [justification, setJustification] = useState(currentProps?.justification || "left");
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (isOpen) {
|
|
87
|
+
setWidth(currentProps?.width || 0);
|
|
88
|
+
setWidthType(currentProps?.widthType || "auto");
|
|
89
|
+
setJustification(currentProps?.justification || "left");
|
|
90
|
+
}
|
|
91
|
+
}, [isOpen, currentProps]);
|
|
92
|
+
const handleApply = useCallback(() => {
|
|
93
|
+
const props = {};
|
|
94
|
+
if (widthType === "auto") {
|
|
95
|
+
props.width = null;
|
|
96
|
+
props.widthType = "auto";
|
|
97
|
+
} else {
|
|
98
|
+
props.width = width;
|
|
99
|
+
props.widthType = widthType;
|
|
100
|
+
}
|
|
101
|
+
props.justification = justification;
|
|
102
|
+
onApply(props);
|
|
103
|
+
onClose();
|
|
104
|
+
}, [width, widthType, justification, onApply, onClose]);
|
|
105
|
+
const handleKeyDown = useCallback(
|
|
106
|
+
(e) => {
|
|
107
|
+
if (e.key === "Escape") onClose();
|
|
108
|
+
if (e.key === "Enter") handleApply();
|
|
109
|
+
},
|
|
110
|
+
[onClose, handleApply]
|
|
111
|
+
);
|
|
112
|
+
if (!isOpen) return null;
|
|
113
|
+
return /* @__PURE__ */ jsx("div", { style: overlayStyle, onClick: onClose, onKeyDown: handleKeyDown, children: /* @__PURE__ */ jsxs(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
style: dialogStyle,
|
|
117
|
+
onClick: (e) => e.stopPropagation(),
|
|
118
|
+
role: "dialog",
|
|
119
|
+
"aria-label": t("dialogs.tableProperties.title"),
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx("div", { style: headerStyle, children: t("dialogs.tableProperties.title") }),
|
|
122
|
+
/* @__PURE__ */ jsxs("div", { style: bodyStyle, children: [
|
|
123
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
124
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.tableProperties.widthType") }),
|
|
125
|
+
/* @__PURE__ */ jsxs(
|
|
126
|
+
"select",
|
|
127
|
+
{
|
|
128
|
+
style: selectStyle,
|
|
129
|
+
value: widthType,
|
|
130
|
+
onChange: (e) => setWidthType(e.target.value),
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsx("option", { value: "auto", children: t("dialogs.tableProperties.widthTypes.auto") }),
|
|
133
|
+
/* @__PURE__ */ jsx("option", { value: "dxa", children: t("dialogs.tableProperties.widthTypes.fixed") }),
|
|
134
|
+
/* @__PURE__ */ jsx("option", { value: "pct", children: t("dialogs.tableProperties.widthTypes.percentage") })
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] }),
|
|
139
|
+
widthType !== "auto" && /* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
140
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.tableProperties.widthLabel") }),
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"input",
|
|
143
|
+
{
|
|
144
|
+
type: "number",
|
|
145
|
+
style: inputStyle,
|
|
146
|
+
min: 0,
|
|
147
|
+
step: widthType === "pct" ? 5 : 100,
|
|
148
|
+
value: width,
|
|
149
|
+
onChange: (e) => setWidth(Number(e.target.value) || 0)
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, color: "var(--doc-text-muted)" }, children: widthType === "pct" ? t("dialogs.tableProperties.units.fiftiethsPercent") : t("dialogs.tableProperties.units.twips") })
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
155
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.tableProperties.alignmentLabel") }),
|
|
156
|
+
/* @__PURE__ */ jsxs(
|
|
157
|
+
"select",
|
|
158
|
+
{
|
|
159
|
+
style: selectStyle,
|
|
160
|
+
value: justification,
|
|
161
|
+
onChange: (e) => setJustification(e.target.value),
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx("option", { value: "left", children: t("dialogs.tableProperties.alignOptions.left") }),
|
|
164
|
+
/* @__PURE__ */ jsx("option", { value: "center", children: t("dialogs.tableProperties.alignOptions.center") }),
|
|
165
|
+
/* @__PURE__ */ jsx("option", { value: "right", children: t("dialogs.tableProperties.alignOptions.right") })
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] })
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ jsxs("div", { style: footerStyle, children: [
|
|
172
|
+
/* @__PURE__ */ jsx("button", { type: "button", style: btnStyle, onClick: onClose, children: t("common.cancel") }),
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
type: "button",
|
|
177
|
+
style: {
|
|
178
|
+
...btnStyle,
|
|
179
|
+
backgroundColor: "var(--doc-primary)",
|
|
180
|
+
color: "white",
|
|
181
|
+
borderColor: "var(--doc-primary)"
|
|
182
|
+
},
|
|
183
|
+
onClick: handleApply,
|
|
184
|
+
children: t("common.apply")
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
] })
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
) });
|
|
191
|
+
}
|
|
192
|
+
export {
|
|
193
|
+
TablePropertiesDialog
|
|
194
|
+
};
|