@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,384 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTranslation
|
|
3
|
+
} from "./chunk-OG6X5JJA.mjs";
|
|
4
|
+
|
|
5
|
+
// src/react/components/dialogs/ImagePositionDialog.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: 400,
|
|
25
|
+
maxWidth: 480,
|
|
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: 16
|
|
40
|
+
};
|
|
41
|
+
var sectionStyle = {
|
|
42
|
+
display: "flex",
|
|
43
|
+
flexDirection: "column",
|
|
44
|
+
gap: 8
|
|
45
|
+
};
|
|
46
|
+
var sectionLabelStyle = {
|
|
47
|
+
fontSize: 13,
|
|
48
|
+
fontWeight: 600,
|
|
49
|
+
color: "var(--doc-text)"
|
|
50
|
+
};
|
|
51
|
+
var rowStyle = {
|
|
52
|
+
display: "flex",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
gap: 8
|
|
55
|
+
};
|
|
56
|
+
var labelStyle = {
|
|
57
|
+
width: 75,
|
|
58
|
+
fontSize: 12,
|
|
59
|
+
color: "var(--doc-text-muted)"
|
|
60
|
+
};
|
|
61
|
+
var inputStyle = {
|
|
62
|
+
flex: 1,
|
|
63
|
+
padding: "4px 6px",
|
|
64
|
+
border: "1px solid var(--doc-border)",
|
|
65
|
+
borderRadius: 4,
|
|
66
|
+
fontSize: 12
|
|
67
|
+
};
|
|
68
|
+
var selectStyle = {
|
|
69
|
+
...inputStyle
|
|
70
|
+
};
|
|
71
|
+
var footerStyle = {
|
|
72
|
+
padding: "12px 20px 16px",
|
|
73
|
+
borderTop: "1px solid var(--doc-border)",
|
|
74
|
+
display: "flex",
|
|
75
|
+
justifyContent: "flex-end",
|
|
76
|
+
gap: 8
|
|
77
|
+
};
|
|
78
|
+
var btnStyle = {
|
|
79
|
+
padding: "6px 16px",
|
|
80
|
+
fontSize: 13,
|
|
81
|
+
border: "1px solid var(--doc-border)",
|
|
82
|
+
borderRadius: 4,
|
|
83
|
+
cursor: "pointer"
|
|
84
|
+
};
|
|
85
|
+
function ImagePositionDialog({
|
|
86
|
+
isOpen,
|
|
87
|
+
onClose,
|
|
88
|
+
onApply,
|
|
89
|
+
currentData
|
|
90
|
+
}) {
|
|
91
|
+
const { t } = useTranslation();
|
|
92
|
+
const [hMode, setHMode] = useState("align");
|
|
93
|
+
const [hAlign, setHAlign] = useState("center");
|
|
94
|
+
const [hRelativeTo, setHRelativeTo] = useState("column");
|
|
95
|
+
const [hOffset, setHOffset] = useState(0);
|
|
96
|
+
const [vMode, setVMode] = useState("align");
|
|
97
|
+
const [vAlign, setVAlign] = useState("top");
|
|
98
|
+
const [vRelativeTo, setVRelativeTo] = useState("paragraph");
|
|
99
|
+
const [vOffset, setVOffset] = useState(0);
|
|
100
|
+
const [distTop, setDistTop] = useState(0);
|
|
101
|
+
const [distBottom, setDistBottom] = useState(0);
|
|
102
|
+
const [distLeft, setDistLeft] = useState(0);
|
|
103
|
+
const [distRight, setDistRight] = useState(0);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!isOpen) return;
|
|
106
|
+
const h = currentData?.horizontal;
|
|
107
|
+
const v = currentData?.vertical;
|
|
108
|
+
if (h?.align) {
|
|
109
|
+
setHMode("align");
|
|
110
|
+
setHAlign(h.align);
|
|
111
|
+
} else if (h?.posOffset != null) {
|
|
112
|
+
setHMode("offset");
|
|
113
|
+
setHOffset(h.posOffset);
|
|
114
|
+
}
|
|
115
|
+
if (h?.relativeTo) setHRelativeTo(h.relativeTo);
|
|
116
|
+
if (v?.align) {
|
|
117
|
+
setVMode("align");
|
|
118
|
+
setVAlign(v.align);
|
|
119
|
+
} else if (v?.posOffset != null) {
|
|
120
|
+
setVMode("offset");
|
|
121
|
+
setVOffset(v.posOffset);
|
|
122
|
+
}
|
|
123
|
+
if (v?.relativeTo) setVRelativeTo(v.relativeTo);
|
|
124
|
+
setDistTop(currentData?.distTop ?? 0);
|
|
125
|
+
setDistBottom(currentData?.distBottom ?? 0);
|
|
126
|
+
setDistLeft(currentData?.distLeft ?? 0);
|
|
127
|
+
setDistRight(currentData?.distRight ?? 0);
|
|
128
|
+
}, [isOpen, currentData]);
|
|
129
|
+
const handleApply = useCallback(() => {
|
|
130
|
+
const data = {};
|
|
131
|
+
data.horizontal = {
|
|
132
|
+
relativeTo: hRelativeTo,
|
|
133
|
+
...hMode === "align" ? { align: hAlign } : { posOffset: hOffset }
|
|
134
|
+
};
|
|
135
|
+
data.vertical = {
|
|
136
|
+
relativeTo: vRelativeTo,
|
|
137
|
+
...vMode === "align" ? { align: vAlign } : { posOffset: vOffset }
|
|
138
|
+
};
|
|
139
|
+
data.distTop = distTop;
|
|
140
|
+
data.distBottom = distBottom;
|
|
141
|
+
data.distLeft = distLeft;
|
|
142
|
+
data.distRight = distRight;
|
|
143
|
+
onApply(data);
|
|
144
|
+
onClose();
|
|
145
|
+
}, [
|
|
146
|
+
hMode,
|
|
147
|
+
hAlign,
|
|
148
|
+
hRelativeTo,
|
|
149
|
+
hOffset,
|
|
150
|
+
vMode,
|
|
151
|
+
vAlign,
|
|
152
|
+
vRelativeTo,
|
|
153
|
+
vOffset,
|
|
154
|
+
distTop,
|
|
155
|
+
distBottom,
|
|
156
|
+
distLeft,
|
|
157
|
+
distRight,
|
|
158
|
+
onApply,
|
|
159
|
+
onClose
|
|
160
|
+
]);
|
|
161
|
+
const handleKeyDown = useCallback(
|
|
162
|
+
(e) => {
|
|
163
|
+
if (e.key === "Escape") onClose();
|
|
164
|
+
if (e.key === "Enter") handleApply();
|
|
165
|
+
},
|
|
166
|
+
[onClose, handleApply]
|
|
167
|
+
);
|
|
168
|
+
if (!isOpen) return null;
|
|
169
|
+
return /* @__PURE__ */ jsx("div", { style: overlayStyle, onClick: onClose, onKeyDown: handleKeyDown, children: /* @__PURE__ */ jsxs(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
style: dialogStyle,
|
|
173
|
+
onClick: (e) => e.stopPropagation(),
|
|
174
|
+
role: "dialog",
|
|
175
|
+
"aria-label": t("dialogs.imagePosition.title"),
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsx("div", { style: headerStyle, children: t("dialogs.imagePosition.title") }),
|
|
178
|
+
/* @__PURE__ */ jsxs("div", { style: bodyStyle, children: [
|
|
179
|
+
/* @__PURE__ */ jsxs("div", { style: sectionStyle, children: [
|
|
180
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: t("dialogs.imagePosition.horizontal") }),
|
|
181
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
182
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.position") }),
|
|
183
|
+
/* @__PURE__ */ jsxs(
|
|
184
|
+
"select",
|
|
185
|
+
{
|
|
186
|
+
style: selectStyle,
|
|
187
|
+
value: hMode,
|
|
188
|
+
onChange: (e) => setHMode(e.target.value),
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx("option", { value: "align", children: t("dialogs.imagePosition.alignment") }),
|
|
191
|
+
/* @__PURE__ */ jsx("option", { value: "offset", children: t("dialogs.imagePosition.offset") })
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] }),
|
|
196
|
+
hMode === "align" ? /* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
197
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.align") }),
|
|
198
|
+
/* @__PURE__ */ jsxs(
|
|
199
|
+
"select",
|
|
200
|
+
{
|
|
201
|
+
style: selectStyle,
|
|
202
|
+
value: hAlign,
|
|
203
|
+
onChange: (e) => setHAlign(e.target.value),
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx("option", { value: "left", children: t("dialogs.imagePosition.alignOptions.left") }),
|
|
206
|
+
/* @__PURE__ */ jsx("option", { value: "center", children: t("dialogs.imagePosition.alignOptions.center") }),
|
|
207
|
+
/* @__PURE__ */ jsx("option", { value: "right", children: t("dialogs.imagePosition.alignOptions.right") })
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
] }) : /* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
212
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.offsetPx") }),
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
"input",
|
|
215
|
+
{
|
|
216
|
+
type: "number",
|
|
217
|
+
style: inputStyle,
|
|
218
|
+
value: hOffset,
|
|
219
|
+
onChange: (e) => setHOffset(Number(e.target.value) || 0)
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
224
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.relativeTo") }),
|
|
225
|
+
/* @__PURE__ */ jsxs(
|
|
226
|
+
"select",
|
|
227
|
+
{
|
|
228
|
+
style: selectStyle,
|
|
229
|
+
value: hRelativeTo,
|
|
230
|
+
onChange: (e) => setHRelativeTo(e.target.value),
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsx("option", { value: "page", children: t("dialogs.imagePosition.relativeOptions.page") }),
|
|
233
|
+
/* @__PURE__ */ jsx("option", { value: "column", children: t("dialogs.imagePosition.relativeOptions.column") }),
|
|
234
|
+
/* @__PURE__ */ jsx("option", { value: "margin", children: t("dialogs.imagePosition.relativeOptions.margin") }),
|
|
235
|
+
/* @__PURE__ */ jsx("option", { value: "character", children: t("dialogs.imagePosition.relativeOptions.character") })
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] })
|
|
240
|
+
] }),
|
|
241
|
+
/* @__PURE__ */ jsxs("div", { style: sectionStyle, children: [
|
|
242
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: t("dialogs.imagePosition.vertical") }),
|
|
243
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
244
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.position") }),
|
|
245
|
+
/* @__PURE__ */ jsxs(
|
|
246
|
+
"select",
|
|
247
|
+
{
|
|
248
|
+
style: selectStyle,
|
|
249
|
+
value: vMode,
|
|
250
|
+
onChange: (e) => setVMode(e.target.value),
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ jsx("option", { value: "align", children: t("dialogs.imagePosition.alignment") }),
|
|
253
|
+
/* @__PURE__ */ jsx("option", { value: "offset", children: t("dialogs.imagePosition.offset") })
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
] }),
|
|
258
|
+
vMode === "align" ? /* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
259
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.align") }),
|
|
260
|
+
/* @__PURE__ */ jsxs(
|
|
261
|
+
"select",
|
|
262
|
+
{
|
|
263
|
+
style: selectStyle,
|
|
264
|
+
value: vAlign,
|
|
265
|
+
onChange: (e) => setVAlign(e.target.value),
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ jsx("option", { value: "top", children: t("dialogs.imagePosition.alignOptions.top") }),
|
|
268
|
+
/* @__PURE__ */ jsx("option", { value: "center", children: t("dialogs.imagePosition.alignOptions.center") }),
|
|
269
|
+
/* @__PURE__ */ jsx("option", { value: "bottom", children: t("dialogs.imagePosition.alignOptions.bottom") })
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
] }) : /* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
274
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.offsetPx") }),
|
|
275
|
+
/* @__PURE__ */ jsx(
|
|
276
|
+
"input",
|
|
277
|
+
{
|
|
278
|
+
type: "number",
|
|
279
|
+
style: inputStyle,
|
|
280
|
+
value: vOffset,
|
|
281
|
+
onChange: (e) => setVOffset(Number(e.target.value) || 0)
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
286
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imagePosition.relativeTo") }),
|
|
287
|
+
/* @__PURE__ */ jsxs(
|
|
288
|
+
"select",
|
|
289
|
+
{
|
|
290
|
+
style: selectStyle,
|
|
291
|
+
value: vRelativeTo,
|
|
292
|
+
onChange: (e) => setVRelativeTo(e.target.value),
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ jsx("option", { value: "page", children: t("dialogs.imagePosition.relativeOptions.page") }),
|
|
295
|
+
/* @__PURE__ */ jsx("option", { value: "margin", children: t("dialogs.imagePosition.relativeOptions.margin") }),
|
|
296
|
+
/* @__PURE__ */ jsx("option", { value: "paragraph", children: t("dialogs.imagePosition.relativeOptions.paragraph") }),
|
|
297
|
+
/* @__PURE__ */ jsx("option", { value: "line", children: t("dialogs.imagePosition.relativeOptions.line") })
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
] })
|
|
302
|
+
] }),
|
|
303
|
+
/* @__PURE__ */ jsxs("div", { style: sectionStyle, children: [
|
|
304
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: "Distance from text (px)" }),
|
|
305
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
|
|
306
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
307
|
+
/* @__PURE__ */ jsx("label", { style: { ...labelStyle, width: 45 }, children: t("dialogs.imagePosition.alignOptions.top") }),
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
"input",
|
|
310
|
+
{
|
|
311
|
+
type: "number",
|
|
312
|
+
style: inputStyle,
|
|
313
|
+
min: 0,
|
|
314
|
+
value: distTop,
|
|
315
|
+
onChange: (e) => setDistTop(Number(e.target.value) || 0)
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
320
|
+
/* @__PURE__ */ jsx("label", { style: { ...labelStyle, width: 45 }, children: t("dialogs.imagePosition.alignOptions.bottom") }),
|
|
321
|
+
/* @__PURE__ */ jsx(
|
|
322
|
+
"input",
|
|
323
|
+
{
|
|
324
|
+
type: "number",
|
|
325
|
+
style: inputStyle,
|
|
326
|
+
min: 0,
|
|
327
|
+
value: distBottom,
|
|
328
|
+
onChange: (e) => setDistBottom(Number(e.target.value) || 0)
|
|
329
|
+
}
|
|
330
|
+
)
|
|
331
|
+
] }),
|
|
332
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
333
|
+
/* @__PURE__ */ jsx("label", { style: { ...labelStyle, width: 45 }, children: t("dialogs.imagePosition.alignOptions.left") }),
|
|
334
|
+
/* @__PURE__ */ jsx(
|
|
335
|
+
"input",
|
|
336
|
+
{
|
|
337
|
+
type: "number",
|
|
338
|
+
style: inputStyle,
|
|
339
|
+
min: 0,
|
|
340
|
+
value: distLeft,
|
|
341
|
+
onChange: (e) => setDistLeft(Number(e.target.value) || 0)
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] }),
|
|
345
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
346
|
+
/* @__PURE__ */ jsx("label", { style: { ...labelStyle, width: 45 }, children: t("dialogs.imagePosition.alignOptions.right") }),
|
|
347
|
+
/* @__PURE__ */ jsx(
|
|
348
|
+
"input",
|
|
349
|
+
{
|
|
350
|
+
type: "number",
|
|
351
|
+
style: inputStyle,
|
|
352
|
+
min: 0,
|
|
353
|
+
value: distRight,
|
|
354
|
+
onChange: (e) => setDistRight(Number(e.target.value) || 0)
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
] })
|
|
358
|
+
] })
|
|
359
|
+
] })
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ jsxs("div", { style: footerStyle, children: [
|
|
362
|
+
/* @__PURE__ */ jsx("button", { type: "button", style: btnStyle, onClick: onClose, children: t("common.cancel") }),
|
|
363
|
+
/* @__PURE__ */ jsx(
|
|
364
|
+
"button",
|
|
365
|
+
{
|
|
366
|
+
type: "button",
|
|
367
|
+
style: {
|
|
368
|
+
...btnStyle,
|
|
369
|
+
backgroundColor: "var(--doc-primary)",
|
|
370
|
+
color: "white",
|
|
371
|
+
borderColor: "var(--doc-primary)"
|
|
372
|
+
},
|
|
373
|
+
onClick: handleApply,
|
|
374
|
+
children: t("common.apply")
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
] })
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
) });
|
|
381
|
+
}
|
|
382
|
+
export {
|
|
383
|
+
ImagePositionDialog
|
|
384
|
+
};
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTranslation
|
|
3
|
+
} from "./chunk-OG6X5JJA.mjs";
|
|
4
|
+
|
|
5
|
+
// src/react/components/dialogs/ImagePropertiesDialog.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: 380,
|
|
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: 16
|
|
40
|
+
};
|
|
41
|
+
var sectionStyle = {
|
|
42
|
+
display: "flex",
|
|
43
|
+
flexDirection: "column",
|
|
44
|
+
gap: 8
|
|
45
|
+
};
|
|
46
|
+
var sectionLabelStyle = {
|
|
47
|
+
fontSize: 13,
|
|
48
|
+
fontWeight: 600,
|
|
49
|
+
color: "var(--doc-text)"
|
|
50
|
+
};
|
|
51
|
+
var rowStyle = {
|
|
52
|
+
display: "flex",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
gap: 8
|
|
55
|
+
};
|
|
56
|
+
var labelStyle = {
|
|
57
|
+
width: 60,
|
|
58
|
+
fontSize: 12,
|
|
59
|
+
color: "var(--doc-text-muted)"
|
|
60
|
+
};
|
|
61
|
+
var inputStyle = {
|
|
62
|
+
flex: 1,
|
|
63
|
+
padding: "4px 6px",
|
|
64
|
+
border: "1px solid var(--doc-border)",
|
|
65
|
+
borderRadius: 4,
|
|
66
|
+
fontSize: 12
|
|
67
|
+
};
|
|
68
|
+
var selectStyle = {
|
|
69
|
+
...inputStyle
|
|
70
|
+
};
|
|
71
|
+
var textareaStyle = {
|
|
72
|
+
...inputStyle,
|
|
73
|
+
minHeight: 60,
|
|
74
|
+
resize: "vertical",
|
|
75
|
+
fontFamily: "inherit"
|
|
76
|
+
};
|
|
77
|
+
var footerStyle = {
|
|
78
|
+
padding: "12px 20px 16px",
|
|
79
|
+
borderTop: "1px solid var(--doc-border)",
|
|
80
|
+
display: "flex",
|
|
81
|
+
justifyContent: "flex-end",
|
|
82
|
+
gap: 8
|
|
83
|
+
};
|
|
84
|
+
var btnStyle = {
|
|
85
|
+
padding: "6px 16px",
|
|
86
|
+
fontSize: 13,
|
|
87
|
+
border: "1px solid var(--doc-border)",
|
|
88
|
+
borderRadius: 4,
|
|
89
|
+
cursor: "pointer"
|
|
90
|
+
};
|
|
91
|
+
function ImagePropertiesDialog({
|
|
92
|
+
isOpen,
|
|
93
|
+
onClose,
|
|
94
|
+
onApply,
|
|
95
|
+
currentData
|
|
96
|
+
}) {
|
|
97
|
+
const { t } = useTranslation();
|
|
98
|
+
const [alt, setAlt] = useState("");
|
|
99
|
+
const [borderWidth, setBorderWidth] = useState(0);
|
|
100
|
+
const [borderColor, setBorderColor] = useState("#000000");
|
|
101
|
+
const [borderStyle, setBorderStyle] = useState("solid");
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!isOpen) return;
|
|
104
|
+
setAlt(currentData?.alt ?? "");
|
|
105
|
+
setBorderWidth(currentData?.borderWidth ?? 0);
|
|
106
|
+
setBorderColor(currentData?.borderColor ?? "#000000");
|
|
107
|
+
setBorderStyle(currentData?.borderStyle ?? "solid");
|
|
108
|
+
}, [isOpen, currentData]);
|
|
109
|
+
const handleApply = useCallback(() => {
|
|
110
|
+
onApply({
|
|
111
|
+
alt: alt || void 0,
|
|
112
|
+
borderWidth: borderWidth > 0 ? borderWidth : void 0,
|
|
113
|
+
borderColor: borderWidth > 0 ? borderColor : void 0,
|
|
114
|
+
borderStyle: borderWidth > 0 ? borderStyle : void 0
|
|
115
|
+
});
|
|
116
|
+
onClose();
|
|
117
|
+
}, [alt, borderWidth, borderColor, borderStyle, onApply, onClose]);
|
|
118
|
+
const handleKeyDown = useCallback(
|
|
119
|
+
(e) => {
|
|
120
|
+
if (e.key === "Escape") onClose();
|
|
121
|
+
if (e.key === "Enter" && !e.shiftKey) handleApply();
|
|
122
|
+
},
|
|
123
|
+
[onClose, handleApply]
|
|
124
|
+
);
|
|
125
|
+
if (!isOpen) return null;
|
|
126
|
+
return /* @__PURE__ */ jsx("div", { style: overlayStyle, onClick: onClose, onKeyDown: handleKeyDown, children: /* @__PURE__ */ jsxs(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
style: dialogStyle,
|
|
130
|
+
onClick: (e) => e.stopPropagation(),
|
|
131
|
+
role: "dialog",
|
|
132
|
+
"aria-label": t("dialogs.imageProperties.title"),
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx("div", { style: headerStyle, children: t("dialogs.imageProperties.title") }),
|
|
135
|
+
/* @__PURE__ */ jsxs("div", { style: bodyStyle, children: [
|
|
136
|
+
/* @__PURE__ */ jsxs("div", { style: sectionStyle, children: [
|
|
137
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: t("dialogs.imageProperties.altText") }),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
"textarea",
|
|
140
|
+
{
|
|
141
|
+
style: textareaStyle,
|
|
142
|
+
value: alt,
|
|
143
|
+
onChange: (e) => setAlt(e.target.value),
|
|
144
|
+
placeholder: t("dialogs.imageProperties.altTextPlaceholder")
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { style: sectionStyle, children: [
|
|
149
|
+
/* @__PURE__ */ jsx("div", { style: sectionLabelStyle, children: t("dialogs.imageProperties.border") }),
|
|
150
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
151
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imageProperties.width") }),
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
"input",
|
|
154
|
+
{
|
|
155
|
+
type: "number",
|
|
156
|
+
style: { ...inputStyle, maxWidth: 80 },
|
|
157
|
+
min: 0,
|
|
158
|
+
max: 20,
|
|
159
|
+
step: 0.5,
|
|
160
|
+
value: borderWidth,
|
|
161
|
+
onChange: (e) => setBorderWidth(Number(e.target.value) || 0)
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "var(--doc-text-muted)" }, children: t("common.px") })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
167
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imageProperties.style") }),
|
|
168
|
+
/* @__PURE__ */ jsxs(
|
|
169
|
+
"select",
|
|
170
|
+
{
|
|
171
|
+
style: selectStyle,
|
|
172
|
+
value: borderStyle,
|
|
173
|
+
onChange: (e) => setBorderStyle(e.target.value),
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsx("option", { value: "solid", children: t("dialogs.imageProperties.borderStyles.solid") }),
|
|
176
|
+
/* @__PURE__ */ jsx("option", { value: "dashed", children: t("dialogs.imageProperties.borderStyles.dashed") }),
|
|
177
|
+
/* @__PURE__ */ jsx("option", { value: "dotted", children: t("dialogs.imageProperties.borderStyles.dotted") }),
|
|
178
|
+
/* @__PURE__ */ jsx("option", { value: "double", children: t("dialogs.imageProperties.borderStyles.double") }),
|
|
179
|
+
/* @__PURE__ */ jsx("option", { value: "groove", children: t("dialogs.imageProperties.borderStyles.groove") }),
|
|
180
|
+
/* @__PURE__ */ jsx("option", { value: "ridge", children: t("dialogs.imageProperties.borderStyles.ridge") }),
|
|
181
|
+
/* @__PURE__ */ jsx("option", { value: "inset", children: t("dialogs.imageProperties.borderStyles.inset") }),
|
|
182
|
+
/* @__PURE__ */ jsx("option", { value: "outset", children: t("dialogs.imageProperties.borderStyles.outset") })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ jsxs("div", { style: rowStyle, children: [
|
|
188
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: t("dialogs.imageProperties.color") }),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
"input",
|
|
191
|
+
{
|
|
192
|
+
type: "color",
|
|
193
|
+
value: borderColor,
|
|
194
|
+
onChange: (e) => setBorderColor(e.target.value),
|
|
195
|
+
style: {
|
|
196
|
+
width: 32,
|
|
197
|
+
height: 24,
|
|
198
|
+
padding: 0,
|
|
199
|
+
border: "1px solid var(--doc-border)",
|
|
200
|
+
borderRadius: 4,
|
|
201
|
+
cursor: "pointer"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ jsx(
|
|
206
|
+
"input",
|
|
207
|
+
{
|
|
208
|
+
type: "text",
|
|
209
|
+
style: { ...inputStyle, maxWidth: 90 },
|
|
210
|
+
value: borderColor,
|
|
211
|
+
onChange: (e) => setBorderColor(e.target.value)
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
] }),
|
|
215
|
+
borderWidth > 0 && /* @__PURE__ */ jsx(
|
|
216
|
+
"div",
|
|
217
|
+
{
|
|
218
|
+
style: {
|
|
219
|
+
marginTop: 4,
|
|
220
|
+
padding: 8,
|
|
221
|
+
border: `${borderWidth}px ${borderStyle} ${borderColor}`,
|
|
222
|
+
borderRadius: 4,
|
|
223
|
+
fontSize: 11,
|
|
224
|
+
color: "var(--doc-text-muted)",
|
|
225
|
+
textAlign: "center"
|
|
226
|
+
},
|
|
227
|
+
children: t("dialogs.imageProperties.preview")
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
] })
|
|
231
|
+
] }),
|
|
232
|
+
/* @__PURE__ */ jsxs("div", { style: footerStyle, children: [
|
|
233
|
+
/* @__PURE__ */ jsx("button", { type: "button", style: btnStyle, onClick: onClose, children: t("common.cancel") }),
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
"button",
|
|
236
|
+
{
|
|
237
|
+
type: "button",
|
|
238
|
+
style: {
|
|
239
|
+
...btnStyle,
|
|
240
|
+
backgroundColor: "var(--doc-primary)",
|
|
241
|
+
color: "white",
|
|
242
|
+
borderColor: "var(--doc-primary)"
|
|
243
|
+
},
|
|
244
|
+
onClick: handleApply,
|
|
245
|
+
children: t("common.apply")
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
] })
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
) });
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
ImagePropertiesDialog
|
|
255
|
+
};
|