@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.9 → 1.0.4-alpha.1
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/es/LcdpUeditor.d.ts +10 -4
- package/es/LcdpUeditor.d.ts.map +1 -0
- package/es/LcdpUeditor.js +77 -11
- package/es/ToolBottomBar/FormatModal/index.d.ts +9 -0
- package/es/ToolBottomBar/FormatModal/index.d.ts.map +1 -0
- package/es/ToolBottomBar/FormatModal/index.js +543 -0
- package/es/ToolBottomBar/FormatModal/index.less +276 -0
- package/es/ToolBottomBar/ProgressModal/index.d.ts +10 -0
- package/es/ToolBottomBar/ProgressModal/index.d.ts.map +1 -0
- package/es/ToolBottomBar/ProgressModal/index.js +53 -0
- package/es/ToolBottomBar/ProgressModal/index.less +16 -0
- package/es/ToolBottomBar/index.d.ts +33 -0
- package/es/ToolBottomBar/index.d.ts.map +1 -0
- package/es/ToolBottomBar/index.js +296 -0
- package/es/ToolBottomBar/index.less +75 -0
- package/es/const.d.ts.map +1 -0
- package/es/icon/ExportPDF.d.ts +3 -0
- package/es/icon/ExportPDF.d.ts.map +1 -0
- package/es/icon/ExportPDF.js +24 -0
- package/es/icon/TextCopy.d.ts +3 -0
- package/es/icon/TextCopy.d.ts.map +1 -0
- package/es/icon/TextCopy.js +25 -0
- package/es/icon/TextFileIcon.d.ts +3 -0
- package/es/icon/TextFileIcon.d.ts.map +1 -0
- package/es/icon/TextFileIcon.js +26 -0
- package/es/icon/TextIcon.d.ts +3 -0
- package/es/icon/TextIcon.d.ts.map +1 -0
- package/es/icon/TextIcon.js +28 -0
- package/es/index.d.ts.map +1 -0
- package/es/tools/UeditorResourceLoader.d.ts.map +1 -0
- package/es/tools/exportPDF.d.ts +27 -0
- package/es/tools/exportPDF.d.ts.map +1 -0
- package/es/tools/exportPDF.js +146 -0
- package/es/tools/filterHtmlNode.d.ts.map +1 -0
- package/es/tools/generateStylesFromSettings.d.ts +38 -0
- package/es/tools/generateStylesFromSettings.d.ts.map +1 -0
- package/es/tools/generateStylesFromSettings.js +24 -0
- package/es/tools/loadScript.d.ts.map +1 -0
- package/es/type.d.ts +21 -0
- package/es/type.d.ts.map +1 -0
- package/lib/LcdpUeditor.d.ts +10 -4
- package/lib/LcdpUeditor.js +62 -8
- package/lib/ToolBottomBar/FormatModal/index.d.ts +9 -0
- package/lib/ToolBottomBar/FormatModal/index.js +261 -0
- package/lib/ToolBottomBar/FormatModal/index.less +276 -0
- package/lib/ToolBottomBar/ProgressModal/index.d.ts +10 -0
- package/lib/ToolBottomBar/ProgressModal/index.js +73 -0
- package/lib/ToolBottomBar/ProgressModal/index.less +16 -0
- package/lib/ToolBottomBar/index.d.ts +33 -0
- package/lib/ToolBottomBar/index.js +235 -0
- package/lib/ToolBottomBar/index.less +75 -0
- package/lib/icon/ExportPDF.d.ts +3 -0
- package/lib/icon/ExportPDF.js +57 -0
- package/lib/icon/TextCopy.d.ts +3 -0
- package/lib/icon/TextCopy.js +39 -0
- package/lib/icon/TextFileIcon.d.ts +3 -0
- package/lib/icon/TextFileIcon.js +39 -0
- package/lib/icon/TextIcon.d.ts +3 -0
- package/lib/icon/TextIcon.js +39 -0
- package/lib/tools/exportPDF.d.ts +27 -0
- package/lib/tools/exportPDF.js +95 -0
- package/lib/tools/generateStylesFromSettings.d.ts +38 -0
- package/lib/tools/generateStylesFromSettings.js +77 -0
- package/lib/type.d.ts +21 -0
- package/package.json +8 -3
- package/ueditor-resource/themes/default/css/ueditor.css +1 -1
- package/ueditor-resource/ueditor.all.js +1 -1
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import { Button, Col, Form, Input, InputNumber, Popover, Row, Select } from 'antd';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
import "./index.less";
|
|
8
|
+
var suffixCls = 'ueditor-format';
|
|
9
|
+
|
|
10
|
+
// 系统字体实际对应内容
|
|
11
|
+
var SYSTEM_FONT_STACK = "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Helvetica, Arial, sans-serif";
|
|
12
|
+
|
|
13
|
+
// 默认设置 - 与theme.less中的样式保持一致
|
|
14
|
+
var defaultSettings = {
|
|
15
|
+
headings: {
|
|
16
|
+
h1: {
|
|
17
|
+
fontSize: '28px',
|
|
18
|
+
fontFamily: '系统字体',
|
|
19
|
+
fontWeight: '700',
|
|
20
|
+
lineHeight: '1.3',
|
|
21
|
+
color: '#1a202c',
|
|
22
|
+
marginTop: '2.5rem',
|
|
23
|
+
marginBottom: '1.2rem'
|
|
24
|
+
},
|
|
25
|
+
h2: {
|
|
26
|
+
fontSize: '24px',
|
|
27
|
+
fontFamily: '系统字体',
|
|
28
|
+
fontWeight: '600',
|
|
29
|
+
lineHeight: '1.3',
|
|
30
|
+
color: '#1a202c',
|
|
31
|
+
marginTop: '2.5rem',
|
|
32
|
+
marginBottom: '1.2rem'
|
|
33
|
+
},
|
|
34
|
+
h3: {
|
|
35
|
+
fontSize: '20px',
|
|
36
|
+
fontFamily: '系统字体',
|
|
37
|
+
fontWeight: '600',
|
|
38
|
+
lineHeight: '1.3',
|
|
39
|
+
color: '#1a202c',
|
|
40
|
+
marginTop: '2rem',
|
|
41
|
+
marginBottom: '0.8rem'
|
|
42
|
+
},
|
|
43
|
+
h4: {
|
|
44
|
+
fontSize: '18px',
|
|
45
|
+
fontFamily: '系统字体',
|
|
46
|
+
fontWeight: '600',
|
|
47
|
+
lineHeight: '1.3',
|
|
48
|
+
color: '#1a202c',
|
|
49
|
+
marginTop: '2rem',
|
|
50
|
+
marginBottom: '0.8rem'
|
|
51
|
+
},
|
|
52
|
+
h5: {
|
|
53
|
+
fontSize: '16px',
|
|
54
|
+
fontFamily: '系统字体',
|
|
55
|
+
fontWeight: '600',
|
|
56
|
+
lineHeight: '1.3',
|
|
57
|
+
color: '#1a202c',
|
|
58
|
+
marginTop: '2rem',
|
|
59
|
+
marginBottom: '0.8rem'
|
|
60
|
+
},
|
|
61
|
+
h6: {
|
|
62
|
+
fontSize: '16px',
|
|
63
|
+
fontFamily: '系统字体',
|
|
64
|
+
fontWeight: '600',
|
|
65
|
+
lineHeight: '1.3',
|
|
66
|
+
color: '#1a202c',
|
|
67
|
+
marginTop: '2rem',
|
|
68
|
+
marginBottom: '0.8rem'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
paragraph: {
|
|
72
|
+
fontSize: '16px',
|
|
73
|
+
fontFamily: '系统字体',
|
|
74
|
+
fontWeight: 'normal',
|
|
75
|
+
lineHeight: '1.7',
|
|
76
|
+
color: '#2c3e50'
|
|
77
|
+
},
|
|
78
|
+
lists: {
|
|
79
|
+
ul: {
|
|
80
|
+
fontSize: '16px',
|
|
81
|
+
fontFamily: '系统字体',
|
|
82
|
+
fontWeight: 'normal',
|
|
83
|
+
lineHeight: '1.7',
|
|
84
|
+
color: '#2c3e50',
|
|
85
|
+
paddingLeft: '1rem',
|
|
86
|
+
marginTop: '1rem',
|
|
87
|
+
marginBottom: '1rem'
|
|
88
|
+
},
|
|
89
|
+
ol: {
|
|
90
|
+
fontSize: '16px',
|
|
91
|
+
fontFamily: '系统字体',
|
|
92
|
+
fontWeight: 'normal',
|
|
93
|
+
lineHeight: '1.7',
|
|
94
|
+
color: '#2c3e50',
|
|
95
|
+
paddingLeft: '1rem',
|
|
96
|
+
marginTop: '1rem',
|
|
97
|
+
marginBottom: '1rem'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// 检测操作系统类型
|
|
103
|
+
var getOSType = function getOSType() {
|
|
104
|
+
var userAgent = navigator.userAgent.toLowerCase();
|
|
105
|
+
if (userAgent.includes('win')) return 'windows';
|
|
106
|
+
if (userAgent.includes('mac')) return 'mac';
|
|
107
|
+
if (userAgent.includes('linux')) return 'linux';
|
|
108
|
+
return 'unknown';
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// 改进的字体可用性检测
|
|
112
|
+
var isFontAvailable = function isFontAvailable(fontName) {
|
|
113
|
+
// 跳过特殊的系统字体和复合字体栈
|
|
114
|
+
if (fontName === '系统字体' || fontName.includes(',') || fontName.includes('sans-serif') || fontName.includes('serif') || fontName.includes('monospace')) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 使用document.fonts API (现代浏览器)
|
|
119
|
+
if ('fonts' in document) {
|
|
120
|
+
try {
|
|
121
|
+
// @ts-ignore - TypeScript可能不包含fonts API的完整类型定义
|
|
122
|
+
return document.fonts.check("12px \"".concat(fontName, "\""));
|
|
123
|
+
} catch (e) {
|
|
124
|
+
// 降级到canvas方法
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 降级方案:使用canvas检测
|
|
129
|
+
try {
|
|
130
|
+
var canvas = document.createElement('canvas');
|
|
131
|
+
var context = canvas.getContext('2d');
|
|
132
|
+
if (!context) return false;
|
|
133
|
+
|
|
134
|
+
// 测试文本,包含中英文字符
|
|
135
|
+
var testText = 'abcdefghijklmnopqrstuvwxyz测试字体ABCDEFG';
|
|
136
|
+
|
|
137
|
+
// 设置基线字体并测量
|
|
138
|
+
context.font = '72px monospace';
|
|
139
|
+
var baselineWidth = context.measureText(testText).width;
|
|
140
|
+
|
|
141
|
+
// 设置测试字体并测量
|
|
142
|
+
context.font = "72px \"".concat(fontName, "\", monospace");
|
|
143
|
+
var testWidth = context.measureText(testText).width;
|
|
144
|
+
|
|
145
|
+
// 如果宽度有显著差异,说明字体存在
|
|
146
|
+
return Math.abs(testWidth - baselineWidth) > 2;
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.warn("\u5B57\u4F53\u68C0\u6D4B\u5931\u8D25: ".concat(fontName), e);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// 根据操作系统生成字体选项
|
|
154
|
+
var generateFontOptions = function generateFontOptions() {
|
|
155
|
+
var osType = getOSType();
|
|
156
|
+
|
|
157
|
+
// 基础通用字体
|
|
158
|
+
var baseFonts = [{
|
|
159
|
+
value: '系统字体',
|
|
160
|
+
label: '系统字体(推荐)'
|
|
161
|
+
}, {
|
|
162
|
+
value: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Helvetica, Arial, sans-serif",
|
|
163
|
+
label: '完整系统字体栈'
|
|
164
|
+
}];
|
|
165
|
+
|
|
166
|
+
// 各平台特定字体
|
|
167
|
+
var platformFonts = {
|
|
168
|
+
windows: [{
|
|
169
|
+
value: '微软雅黑',
|
|
170
|
+
label: '微软雅黑'
|
|
171
|
+
}, {
|
|
172
|
+
value: '仿宋',
|
|
173
|
+
label: '仿宋'
|
|
174
|
+
}, {
|
|
175
|
+
value: '黑体',
|
|
176
|
+
label: '黑体'
|
|
177
|
+
}, {
|
|
178
|
+
value: '楷体',
|
|
179
|
+
label: '楷体'
|
|
180
|
+
}, {
|
|
181
|
+
value: '宋体',
|
|
182
|
+
label: '宋体'
|
|
183
|
+
}, {
|
|
184
|
+
value: '等线',
|
|
185
|
+
label: '等线'
|
|
186
|
+
}, {
|
|
187
|
+
value: 'Segoe UI',
|
|
188
|
+
label: 'Segoe UI'
|
|
189
|
+
}, {
|
|
190
|
+
value: 'Calibri',
|
|
191
|
+
label: 'Calibri'
|
|
192
|
+
}],
|
|
193
|
+
mac: [{
|
|
194
|
+
value: 'PingFang SC',
|
|
195
|
+
label: '苹方(简)'
|
|
196
|
+
}, {
|
|
197
|
+
value: 'PingFang TC',
|
|
198
|
+
label: '苹方(繁)'
|
|
199
|
+
}, {
|
|
200
|
+
value: 'Hiragino Sans GB',
|
|
201
|
+
label: '冬青黑体'
|
|
202
|
+
}, {
|
|
203
|
+
value: 'STHeiti',
|
|
204
|
+
label: '华文黑体'
|
|
205
|
+
}, {
|
|
206
|
+
value: 'STKaiti',
|
|
207
|
+
label: '华文楷体'
|
|
208
|
+
}, {
|
|
209
|
+
value: 'STSong',
|
|
210
|
+
label: '华文宋体'
|
|
211
|
+
}, {
|
|
212
|
+
value: 'STFangsong',
|
|
213
|
+
label: '华文仿宋'
|
|
214
|
+
}, {
|
|
215
|
+
value: 'San Francisco',
|
|
216
|
+
label: '旧金山字体'
|
|
217
|
+
}, {
|
|
218
|
+
value: 'Helvetica Neue',
|
|
219
|
+
label: 'Helvetica Neue'
|
|
220
|
+
}],
|
|
221
|
+
linux: [{
|
|
222
|
+
value: 'Noto Sans CJK SC',
|
|
223
|
+
label: '思源黑体'
|
|
224
|
+
}, {
|
|
225
|
+
value: 'Noto Serif CJK SC',
|
|
226
|
+
label: '思源宋体'
|
|
227
|
+
}, {
|
|
228
|
+
value: 'Source Han Sans',
|
|
229
|
+
label: 'Source Han Sans'
|
|
230
|
+
}, {
|
|
231
|
+
value: 'WenQuanYi Micro Hei',
|
|
232
|
+
label: '文泉驿微米黑'
|
|
233
|
+
}, {
|
|
234
|
+
value: 'WenQuanYi Zen Hei',
|
|
235
|
+
label: '文泉驿正黑'
|
|
236
|
+
}, {
|
|
237
|
+
value: 'DejaVu Sans',
|
|
238
|
+
label: 'DejaVu Sans'
|
|
239
|
+
}, {
|
|
240
|
+
value: 'Liberation Sans',
|
|
241
|
+
label: 'Liberation Sans'
|
|
242
|
+
}]
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// 通用Web安全字体
|
|
246
|
+
var webSafeFonts = [{
|
|
247
|
+
value: 'Arial',
|
|
248
|
+
label: 'Arial'
|
|
249
|
+
}, {
|
|
250
|
+
value: 'Helvetica',
|
|
251
|
+
label: 'Helvetica'
|
|
252
|
+
}, {
|
|
253
|
+
value: 'Times New Roman',
|
|
254
|
+
label: 'Times New Roman'
|
|
255
|
+
}, {
|
|
256
|
+
value: 'Times',
|
|
257
|
+
label: 'Times'
|
|
258
|
+
}, {
|
|
259
|
+
value: 'Courier New',
|
|
260
|
+
label: 'Courier New'
|
|
261
|
+
}, {
|
|
262
|
+
value: 'Georgia',
|
|
263
|
+
label: 'Georgia'
|
|
264
|
+
}, {
|
|
265
|
+
value: 'Verdana',
|
|
266
|
+
label: 'Verdana'
|
|
267
|
+
}, {
|
|
268
|
+
value: 'sans-serif',
|
|
269
|
+
label: '系统无衬线字体'
|
|
270
|
+
}, {
|
|
271
|
+
value: 'serif',
|
|
272
|
+
label: '系统衬线字体'
|
|
273
|
+
}, {
|
|
274
|
+
value: 'monospace',
|
|
275
|
+
label: '系统等宽字体'
|
|
276
|
+
}];
|
|
277
|
+
|
|
278
|
+
// 合并字体列表
|
|
279
|
+
var allFonts = [].concat(baseFonts);
|
|
280
|
+
|
|
281
|
+
// 添加平台特定字体
|
|
282
|
+
if (platformFonts[osType]) {
|
|
283
|
+
allFonts.push.apply(allFonts, _toConsumableArray(platformFonts[osType]));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// 添加Web安全字体
|
|
287
|
+
allFonts.push.apply(allFonts, webSafeFonts);
|
|
288
|
+
|
|
289
|
+
// 启用字体检测,但不阻塞界面
|
|
290
|
+
var availableFonts = allFonts.map(function (font) {
|
|
291
|
+
return _objectSpread(_objectSpread({}, font), {}, {
|
|
292
|
+
available: isFontAvailable(font.value)
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// 将不可用的字体标记出来
|
|
297
|
+
return availableFonts.map(function (font) {
|
|
298
|
+
return {
|
|
299
|
+
value: font.value,
|
|
300
|
+
label: font.available ? font.label : "".concat(font.label, " (\u4E0D\u53EF\u7528)"),
|
|
301
|
+
disabled: !font.available && !['系统字体', '完整系统字体栈'].includes(font.label)
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// 字体选项 - 动态生成
|
|
307
|
+
var fontFamilyOptions = generateFontOptions();
|
|
308
|
+
|
|
309
|
+
// 字重选项
|
|
310
|
+
var fontWeightOptions = [{
|
|
311
|
+
value: 'normal',
|
|
312
|
+
label: '常规'
|
|
313
|
+
}, {
|
|
314
|
+
value: '500',
|
|
315
|
+
label: '中等'
|
|
316
|
+
}, {
|
|
317
|
+
value: '600',
|
|
318
|
+
label: '半粗'
|
|
319
|
+
}, {
|
|
320
|
+
value: 'bold',
|
|
321
|
+
label: '粗体'
|
|
322
|
+
}];
|
|
323
|
+
|
|
324
|
+
// 字号选项
|
|
325
|
+
var fontSizeOptions = [{
|
|
326
|
+
value: '12px',
|
|
327
|
+
label: '12px'
|
|
328
|
+
}, {
|
|
329
|
+
value: '14px',
|
|
330
|
+
label: '14px'
|
|
331
|
+
}, {
|
|
332
|
+
value: '16px',
|
|
333
|
+
label: '16px'
|
|
334
|
+
}, {
|
|
335
|
+
value: '18px',
|
|
336
|
+
label: '18px'
|
|
337
|
+
}, {
|
|
338
|
+
value: '20px',
|
|
339
|
+
label: '20px'
|
|
340
|
+
}, {
|
|
341
|
+
value: '22px',
|
|
342
|
+
label: '22px'
|
|
343
|
+
}, {
|
|
344
|
+
value: '24px',
|
|
345
|
+
label: '24px'
|
|
346
|
+
}, {
|
|
347
|
+
value: '28px',
|
|
348
|
+
label: '28px'
|
|
349
|
+
}, {
|
|
350
|
+
value: '32px',
|
|
351
|
+
label: '32px'
|
|
352
|
+
}, {
|
|
353
|
+
value: '36px',
|
|
354
|
+
label: '36px'
|
|
355
|
+
}, {
|
|
356
|
+
value: '1.0em',
|
|
357
|
+
label: '1.0em'
|
|
358
|
+
}, {
|
|
359
|
+
value: '1.2em',
|
|
360
|
+
label: '1.2em'
|
|
361
|
+
}, {
|
|
362
|
+
value: '1.5em',
|
|
363
|
+
label: '1.5em'
|
|
364
|
+
}, {
|
|
365
|
+
value: '1.8em',
|
|
366
|
+
label: '1.8em'
|
|
367
|
+
}];
|
|
368
|
+
var FormatSettingsPanel = function FormatSettingsPanel(_ref) {
|
|
369
|
+
var onApply = _ref.onApply,
|
|
370
|
+
initialSettings = _ref.initialSettings,
|
|
371
|
+
children = _ref.children;
|
|
372
|
+
var _Form$useForm = Form.useForm(),
|
|
373
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
374
|
+
form = _Form$useForm2[0];
|
|
375
|
+
var _useState = useState(false),
|
|
376
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
377
|
+
open = _useState2[0],
|
|
378
|
+
setOpen = _useState2[1];
|
|
379
|
+
var _useState3 = useState(_objectSpread({}, defaultSettings)),
|
|
380
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
381
|
+
settings = _useState4[0],
|
|
382
|
+
setSettings = _useState4[1];
|
|
383
|
+
var _useState5 = useState(''),
|
|
384
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
385
|
+
currentOS = _useState6[0],
|
|
386
|
+
setCurrentOS = _useState6[1];
|
|
387
|
+
useEffect(function () {
|
|
388
|
+
if (initialSettings) {
|
|
389
|
+
// 递归处理所有字体设置
|
|
390
|
+
var processFontFamily = function processFontFamily(obj) {
|
|
391
|
+
for (var _key in obj) {
|
|
392
|
+
if (_typeof(obj[_key]) === 'object' && obj[_key] !== null) {
|
|
393
|
+
processFontFamily(obj[_key]);
|
|
394
|
+
} else if (_key === 'fontFamily' && obj[_key] === SYSTEM_FONT_STACK) {
|
|
395
|
+
obj[_key] = '系统字体';
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
processFontFamily(initialSettings);
|
|
400
|
+
setSettings(function (pre) {
|
|
401
|
+
return _objectSpread(_objectSpread({}, pre), initialSettings);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}, [initialSettings]);
|
|
405
|
+
useEffect(function () {
|
|
406
|
+
// 检测并设置当前操作系统信息
|
|
407
|
+
var osType = getOSType();
|
|
408
|
+
var osNames = {
|
|
409
|
+
windows: 'Windows',
|
|
410
|
+
mac: 'macOS',
|
|
411
|
+
linux: 'Linux',
|
|
412
|
+
unknown: '未知系统'
|
|
413
|
+
};
|
|
414
|
+
setCurrentOS(osNames[osType] || '未知系统');
|
|
415
|
+
}, []);
|
|
416
|
+
useEffect(function () {
|
|
417
|
+
if (open) {
|
|
418
|
+
form.setFieldsValue(settings);
|
|
419
|
+
}
|
|
420
|
+
}, [open, form, settings]);
|
|
421
|
+
var handleValuesChange = function handleValuesChange(changedValues, allValues) {
|
|
422
|
+
setSettings(function (prev) {
|
|
423
|
+
return _objectSpread(_objectSpread({}, prev), allValues);
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
var handleApply = function handleApply() {
|
|
427
|
+
form.validateFields().then(function (values) {
|
|
428
|
+
// 处理"系统字体"映射为实际的系统字体栈
|
|
429
|
+
var processedValues = JSON.parse(JSON.stringify(values)); // 深拷贝避免修改原值
|
|
430
|
+
|
|
431
|
+
// 递归处理所有字体设置
|
|
432
|
+
var processFontFamily = function processFontFamily(obj) {
|
|
433
|
+
for (var _key2 in obj) {
|
|
434
|
+
if (_typeof(obj[_key2]) === 'object' && obj[_key2] !== null) {
|
|
435
|
+
processFontFamily(obj[_key2]);
|
|
436
|
+
} else if (_key2 === 'fontFamily' && obj[_key2] === '系统字体') {
|
|
437
|
+
obj[_key2] = SYSTEM_FONT_STACK;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
processFontFamily(processedValues);
|
|
442
|
+
onApply(processedValues);
|
|
443
|
+
setOpen(false);
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
var handleCancel = function handleCancel() {
|
|
447
|
+
setOpen(false);
|
|
448
|
+
};
|
|
449
|
+
var renderStyleRow = function renderStyleRow(prefix, label, style) {
|
|
450
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
451
|
+
className: "".concat(suffixCls, "-style-row")
|
|
452
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
453
|
+
className: "".concat(suffixCls, "-row-label")
|
|
454
|
+
}, label), /*#__PURE__*/React.createElement(Row, {
|
|
455
|
+
gutter: 12
|
|
456
|
+
}, /*#__PURE__*/React.createElement(Col, {
|
|
457
|
+
span: 7
|
|
458
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
459
|
+
name: [].concat(_toConsumableArray(prefix.split('.')), ['fontFamily']),
|
|
460
|
+
noStyle: true
|
|
461
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
462
|
+
placeholder: "\u5B57\u4F53",
|
|
463
|
+
options: fontFamilyOptions,
|
|
464
|
+
size: "small"
|
|
465
|
+
}))), /*#__PURE__*/React.createElement(Col, {
|
|
466
|
+
span: 5
|
|
467
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
468
|
+
name: [].concat(_toConsumableArray(prefix.split('.')), ['fontSize']),
|
|
469
|
+
noStyle: true
|
|
470
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
471
|
+
placeholder: "\u5B57\u53F7",
|
|
472
|
+
options: fontSizeOptions,
|
|
473
|
+
size: "small"
|
|
474
|
+
}))), /*#__PURE__*/React.createElement(Col, {
|
|
475
|
+
span: 4
|
|
476
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
477
|
+
name: [].concat(_toConsumableArray(prefix.split('.')), ['fontWeight']),
|
|
478
|
+
noStyle: true
|
|
479
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
480
|
+
placeholder: "\u5B57\u91CD",
|
|
481
|
+
options: fontWeightOptions,
|
|
482
|
+
size: "small"
|
|
483
|
+
}))), /*#__PURE__*/React.createElement(Col, {
|
|
484
|
+
span: 4
|
|
485
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
486
|
+
name: [].concat(_toConsumableArray(prefix.split('.')), ['lineHeight']),
|
|
487
|
+
noStyle: true
|
|
488
|
+
}, /*#__PURE__*/React.createElement(InputNumber, {
|
|
489
|
+
placeholder: "\u884C\u9AD8",
|
|
490
|
+
step: 0.1,
|
|
491
|
+
min: 1,
|
|
492
|
+
max: 3,
|
|
493
|
+
size: "small",
|
|
494
|
+
style: {
|
|
495
|
+
width: '100%'
|
|
496
|
+
}
|
|
497
|
+
}))), /*#__PURE__*/React.createElement(Col, {
|
|
498
|
+
span: 4
|
|
499
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
500
|
+
name: [].concat(_toConsumableArray(prefix.split('.')), ['color']),
|
|
501
|
+
noStyle: true
|
|
502
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
503
|
+
type: "color",
|
|
504
|
+
style: {
|
|
505
|
+
width: '100%',
|
|
506
|
+
padding: 0,
|
|
507
|
+
height: 24
|
|
508
|
+
}
|
|
509
|
+
})))));
|
|
510
|
+
};
|
|
511
|
+
var content = /*#__PURE__*/React.createElement("div", {
|
|
512
|
+
className: "".concat(suffixCls, "-popover-content")
|
|
513
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
514
|
+
className: "".concat(suffixCls, "-system-info")
|
|
515
|
+
}, "\u5F53\u524D\u7CFB\u7EDF: ", currentOS, " | \u5B57\u4F53\u9009\u9879\u5DF2\u9488\u5BF9\u60A8\u7684\u7CFB\u7EDF\u4F18\u5316"), /*#__PURE__*/React.createElement(Form, {
|
|
516
|
+
form: form,
|
|
517
|
+
layout: "vertical",
|
|
518
|
+
initialValues: settings,
|
|
519
|
+
onValuesChange: handleValuesChange,
|
|
520
|
+
size: "small"
|
|
521
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
522
|
+
className: "".concat(suffixCls, "-section")
|
|
523
|
+
}, renderStyleRow('paragraph', '正文', settings.paragraph), renderStyleRow('headings.h1', '主标题', settings.headings.h1), renderStyleRow('headings.h2', '二级标题', settings.headings.h2), renderStyleRow('headings.h3', '三级标题', settings.headings.h3), renderStyleRow('headings.h4', '四级标题', settings.headings.h4), renderStyleRow('headings.h5', '五级标题', settings.headings.h5), renderStyleRow('headings.h6', '六级标题', settings.headings.h6), renderStyleRow('lists.ul', '无序列表', settings.lists.ul), renderStyleRow('lists.ol', '有序列表', settings.lists.ol)), /*#__PURE__*/React.createElement("div", {
|
|
524
|
+
className: "".concat(suffixCls, "-footer")
|
|
525
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
526
|
+
size: "small",
|
|
527
|
+
onClick: handleCancel
|
|
528
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
529
|
+
size: "small",
|
|
530
|
+
type: "primary",
|
|
531
|
+
onClick: handleApply
|
|
532
|
+
}, "\u5E94\u7528"))));
|
|
533
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
534
|
+
content: content,
|
|
535
|
+
title: "\u683C\u5F0F\u8BBE\u7F6E",
|
|
536
|
+
trigger: "click",
|
|
537
|
+
visible: open,
|
|
538
|
+
onVisibleChange: setOpen,
|
|
539
|
+
placement: "bottomRight",
|
|
540
|
+
overlayClassName: "".concat(suffixCls, "-settings-popover")
|
|
541
|
+
}, children);
|
|
542
|
+
};
|
|
543
|
+
export default FormatSettingsPanel;
|