@lingxiteam/lcdp-ueditor-react 1.0.4-alpha.2 → 1.0.4-alpha.4
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 +1 -0
- package/es/LcdpUeditor.d.ts.map +1 -1
- package/es/LcdpUeditor.js +10 -6
- package/es/ToolBottomBar/FormatModal/index.d.ts.map +1 -1
- package/es/ToolBottomBar/FormatModal/index.js +79 -75
- package/es/ToolBottomBar/index.d.ts.map +1 -1
- package/es/ToolBottomBar/index.js +16 -24
- package/es/ToolBottomBar/index.less +3 -0
- package/es/tools/generateStylesFromSettings.d.ts +16 -2
- package/es/tools/generateStylesFromSettings.d.ts.map +1 -1
- package/es/tools/generateStylesFromSettings.js +187 -7
- package/lib/LcdpUeditor.d.ts +1 -0
- package/lib/LcdpUeditor.js +5 -1
- package/lib/ToolBottomBar/FormatModal/index.js +49 -38
- package/lib/ToolBottomBar/index.js +11 -15
- package/lib/ToolBottomBar/index.less +3 -0
- package/lib/tools/generateStylesFromSettings.d.ts +16 -2
- package/lib/tools/generateStylesFromSettings.js +167 -48
- package/package.json +1 -1
- package/ueditor-resource/lang/en/en.js +1 -1
- package/ueditor-resource/lang/zh-cn/zh-cn.js +1 -1
- package/ueditor-resource/lang/zh-tw/zh-tw.js +1 -1
- package/ueditor-resource/ueditor.all.js +21 -20
package/es/LcdpUeditor.d.ts
CHANGED
package/es/LcdpUeditor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LcdpUeditor.d.ts","sourceRoot":"","sources":["LcdpUeditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAShD,cAAM,WAAY,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAE,CAAC;IAC9D;;OAEG;IACH,WAAW,EAAE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AAa,GAAG,UAG7B;IAEF;;OAEG;IACH,eAAe;IAsCf,MAAM,IAAI,KAAK,CAAC,SAAS;CAY1B;AAED,eAAe,WAAW,CAAC"}
|
package/es/LcdpUeditor.js
CHANGED
|
@@ -81,6 +81,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
81
81
|
* 编辑器配置项
|
|
82
82
|
*/
|
|
83
83
|
_defineProperty(_assertThisInitialized(_this), "editorConfig", {});
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "onSettingChange", function (setting) {
|
|
85
|
+
_this.editorConfig.onSettingChange(setting);
|
|
86
|
+
_this.onContentChange();
|
|
87
|
+
});
|
|
84
88
|
var config = props.config,
|
|
85
89
|
prefixCls = props.prefixCls,
|
|
86
90
|
onSettingChange = props.onSettingChange;
|
|
@@ -401,14 +405,14 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
401
405
|
return _initUeditor.apply(this, arguments);
|
|
402
406
|
}
|
|
403
407
|
return initUeditor;
|
|
404
|
-
}()
|
|
408
|
+
}())
|
|
409
|
+
}, {
|
|
410
|
+
key: "renderStatusBar",
|
|
411
|
+
value:
|
|
405
412
|
/**
|
|
406
413
|
* 渲染状态栏
|
|
407
414
|
*/
|
|
408
|
-
)
|
|
409
|
-
}, {
|
|
410
|
-
key: "renderStatusBar",
|
|
411
|
-
value: function renderStatusBar() {
|
|
415
|
+
function renderStatusBar() {
|
|
412
416
|
var _this$containerRef$cu, _this$props2;
|
|
413
417
|
var _ref4 = this.ueditorInst.ui || {},
|
|
414
418
|
id = _ref4.id;
|
|
@@ -418,7 +422,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
418
422
|
prefixCls: this.prefixCls,
|
|
419
423
|
containerRef: this.containerRef,
|
|
420
424
|
defaultSetting: this.props.defaultSetting,
|
|
421
|
-
onSettingChange: this.
|
|
425
|
+
onSettingChange: this.onSettingChange,
|
|
422
426
|
isReady: this.state.isReady,
|
|
423
427
|
bottomTypes: this.props.bottomTypes,
|
|
424
428
|
exportFileName: (_this$props2 = this.props) === null || _this$props2 === void 0 || (_this$props2 = _this$props2.config) === null || _this$props2 === void 0 ? void 0 : _this$props2.exportFileName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAa,MAAM,wCAAwC,CAAC;AAEnF,UAAU,wBAAwB;IAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAa,MAAM,wCAAwC,CAAC;AAEnF,UAAU,wBAAwB;IAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC3C;AAuND,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CA8JpF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -99,6 +99,33 @@ var defaultSettings = {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
// 字体翻译映射 - 从简体中文国际化文件获取
|
|
103
|
+
var fontFamilyTranslations = {
|
|
104
|
+
default: '默认',
|
|
105
|
+
songti: '宋体',
|
|
106
|
+
kaiti: '楷体',
|
|
107
|
+
heiti: '黑体',
|
|
108
|
+
lishu: '隶书',
|
|
109
|
+
yahei: '微软雅黑',
|
|
110
|
+
fangsong: '仿宋',
|
|
111
|
+
dengxian: '等线',
|
|
112
|
+
segoeUI: 'Segoe UI',
|
|
113
|
+
calibri: 'Calibri',
|
|
114
|
+
arial: 'arial',
|
|
115
|
+
timesNewRoman: 'times new roman',
|
|
116
|
+
pingfangSC: '苹方(简)',
|
|
117
|
+
pingfangTC: '苹方(繁)',
|
|
118
|
+
hiraginoSansGB: '冬青黑体',
|
|
119
|
+
stFangsong: '华文仿宋',
|
|
120
|
+
sanFrancisco: '旧金山字体',
|
|
121
|
+
helveticaNeue: 'Helvetica Neue',
|
|
122
|
+
sourceHanSans: 'Source Han Sans',
|
|
123
|
+
wenQuanYiMicroHei: '文泉驿微米黑',
|
|
124
|
+
wenQuanYiZenHei: '文泉驿正黑',
|
|
125
|
+
dejaVuSans: 'DejaVu Sans',
|
|
126
|
+
liberationSans: 'Liberation Sans'
|
|
127
|
+
};
|
|
128
|
+
|
|
102
129
|
// 检测操作系统类型
|
|
103
130
|
var getOSType = function getOSType() {
|
|
104
131
|
var userAgent = navigator.userAgent.toLowerCase();
|
|
@@ -159,121 +186,98 @@ var generateFontOptions = function generateFontOptions() {
|
|
|
159
186
|
value: '系统字体',
|
|
160
187
|
label: '系统字体(推荐)'
|
|
161
188
|
}, {
|
|
162
|
-
value:
|
|
163
|
-
label:
|
|
164
|
-
}
|
|
189
|
+
value: 'STHeiti, 黑体, SimHei, "Noto Sans CJK SC"',
|
|
190
|
+
label: fontFamilyTranslations.heiti
|
|
191
|
+
}, {
|
|
192
|
+
value: 'STSong, 宋体, SimSun, "Noto Serif CJK SC"',
|
|
193
|
+
label: fontFamilyTranslations.songti
|
|
194
|
+
}
|
|
195
|
+
// { value: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Helvetica, Arial, sans-serif", label: '完整系统字体栈' },
|
|
196
|
+
];
|
|
165
197
|
|
|
166
|
-
// 各平台特定字体
|
|
198
|
+
// 各平台特定字体 - 参考font.js中的getFontList定义,相同label的字体value已合并
|
|
167
199
|
var platformFonts = {
|
|
168
200
|
windows: [{
|
|
169
|
-
value: '
|
|
170
|
-
label:
|
|
201
|
+
value: '微软雅黑,Microsoft YaHei',
|
|
202
|
+
label: fontFamilyTranslations.yahei
|
|
171
203
|
}, {
|
|
172
204
|
value: '仿宋',
|
|
173
|
-
label:
|
|
174
|
-
}, {
|
|
175
|
-
value: '黑体',
|
|
176
|
-
label: '黑体'
|
|
205
|
+
label: fontFamilyTranslations.fangsong
|
|
177
206
|
}, {
|
|
178
|
-
value: '楷体',
|
|
179
|
-
label:
|
|
207
|
+
value: 'STKaiti, 楷体, 楷体_GB2312, SimKai',
|
|
208
|
+
label: fontFamilyTranslations.kaiti
|
|
180
209
|
}, {
|
|
181
|
-
value: '
|
|
182
|
-
label:
|
|
210
|
+
value: '隶书,SimLi',
|
|
211
|
+
label: fontFamilyTranslations.lishu
|
|
183
212
|
}, {
|
|
184
213
|
value: '等线',
|
|
185
|
-
label:
|
|
214
|
+
label: fontFamilyTranslations.dengxian
|
|
186
215
|
}, {
|
|
187
216
|
value: 'Segoe UI',
|
|
188
|
-
label:
|
|
217
|
+
label: fontFamilyTranslations.segoeUI
|
|
189
218
|
}, {
|
|
190
219
|
value: 'Calibri',
|
|
191
|
-
label:
|
|
220
|
+
label: fontFamilyTranslations.calibri
|
|
221
|
+
}, {
|
|
222
|
+
value: 'arial,helvetica,sans-serif',
|
|
223
|
+
label: fontFamilyTranslations.arial
|
|
224
|
+
}, {
|
|
225
|
+
value: 'times new roman',
|
|
226
|
+
label: fontFamilyTranslations.timesNewRoman
|
|
192
227
|
}],
|
|
193
228
|
mac: [{
|
|
229
|
+
value: 'STKaiti, 楷体, 楷体_GB2312, SimKai',
|
|
230
|
+
label: fontFamilyTranslations.kaiti
|
|
231
|
+
}, {
|
|
194
232
|
value: 'PingFang SC',
|
|
195
|
-
label:
|
|
233
|
+
label: fontFamilyTranslations.pingfangSC
|
|
196
234
|
}, {
|
|
197
235
|
value: 'PingFang TC',
|
|
198
|
-
label:
|
|
236
|
+
label: fontFamilyTranslations.pingfangTC
|
|
199
237
|
}, {
|
|
200
238
|
value: 'Hiragino Sans GB',
|
|
201
|
-
label:
|
|
202
|
-
}, {
|
|
203
|
-
value: 'STHeiti',
|
|
204
|
-
label: '华文黑体'
|
|
205
|
-
}, {
|
|
206
|
-
value: 'STKaiti',
|
|
207
|
-
label: '华文楷体'
|
|
208
|
-
}, {
|
|
209
|
-
value: 'STSong',
|
|
210
|
-
label: '华文宋体'
|
|
239
|
+
label: fontFamilyTranslations.hiraginoSansGB
|
|
211
240
|
}, {
|
|
212
241
|
value: 'STFangsong',
|
|
213
|
-
label:
|
|
242
|
+
label: fontFamilyTranslations.stFangsong
|
|
214
243
|
}, {
|
|
215
244
|
value: 'San Francisco',
|
|
216
|
-
label:
|
|
245
|
+
label: fontFamilyTranslations.sanFrancisco
|
|
217
246
|
}, {
|
|
218
247
|
value: 'Helvetica Neue',
|
|
219
|
-
label:
|
|
248
|
+
label: fontFamilyTranslations.helveticaNeue
|
|
220
249
|
}],
|
|
221
250
|
linux: [{
|
|
222
|
-
value: 'Noto Sans CJK SC',
|
|
223
|
-
label: '思源黑体'
|
|
224
|
-
}, {
|
|
225
|
-
value: 'Noto Serif CJK SC',
|
|
226
|
-
label: '思源宋体'
|
|
227
|
-
}, {
|
|
228
251
|
value: 'Source Han Sans',
|
|
229
|
-
label:
|
|
252
|
+
label: fontFamilyTranslations.sourceHanSans
|
|
230
253
|
}, {
|
|
231
254
|
value: 'WenQuanYi Micro Hei',
|
|
232
|
-
label:
|
|
255
|
+
label: fontFamilyTranslations.wenQuanYiMicroHei
|
|
233
256
|
}, {
|
|
234
257
|
value: 'WenQuanYi Zen Hei',
|
|
235
|
-
label:
|
|
258
|
+
label: fontFamilyTranslations.wenQuanYiZenHei
|
|
236
259
|
}, {
|
|
237
260
|
value: 'DejaVu Sans',
|
|
238
|
-
label:
|
|
261
|
+
label: fontFamilyTranslations.dejaVuSans
|
|
239
262
|
}, {
|
|
240
263
|
value: 'Liberation Sans',
|
|
241
|
-
label:
|
|
264
|
+
label: fontFamilyTranslations.liberationSans
|
|
242
265
|
}]
|
|
243
266
|
};
|
|
244
267
|
|
|
245
268
|
// 通用Web安全字体
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
}];
|
|
269
|
+
// const webSafeFonts = [
|
|
270
|
+
// { value: 'Arial', label: 'Arial' },
|
|
271
|
+
// { value: 'Helvetica', label: 'Helvetica' },
|
|
272
|
+
// { value: 'Times New Roman', label: 'Times New Roman' },
|
|
273
|
+
// { value: 'Times', label: 'Times' },
|
|
274
|
+
// { value: 'Courier New', label: 'Courier New' },
|
|
275
|
+
// { value: 'Georgia', label: 'Georgia' },
|
|
276
|
+
// { value: 'Verdana', label: 'Verdana' },
|
|
277
|
+
// { value: 'sans-serif', label: '系统无衬线字体' },
|
|
278
|
+
// { value: 'serif', label: '系统衬线字体' },
|
|
279
|
+
// { value: 'monospace', label: '系统等宽字体' },
|
|
280
|
+
// ];
|
|
277
281
|
|
|
278
282
|
// 合并字体列表
|
|
279
283
|
var allFonts = [].concat(baseFonts);
|
|
@@ -284,7 +288,7 @@ var generateFontOptions = function generateFontOptions() {
|
|
|
284
288
|
}
|
|
285
289
|
|
|
286
290
|
// 添加Web安全字体
|
|
287
|
-
allFonts.push
|
|
291
|
+
// allFonts.push(...webSafeFonts);
|
|
288
292
|
|
|
289
293
|
// 启用字体检测,但不阻塞界面
|
|
290
294
|
var availableFonts = allFonts.map(function (font) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAS5C,QAAA,MAAM,aAAa;IAEjB;;OAEG;iBACU,GAAG;IAEhB;;OAEG;;IAGH;;OAEG;;;iCAGyB,QAAQ,OAAO,SAAS,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI;IAE7G;;OAEG;;IAGH;;OAEG;kBACW,iBAAiB,CAAC,aAAa,CAAC;IAE9C;;OAEG;;iBAyPJ,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -20,7 +20,6 @@ var MENU_OPTIONS = {
|
|
|
20
20
|
a5: 'A5',
|
|
21
21
|
a0: '铺满'
|
|
22
22
|
};
|
|
23
|
-
var STYLE_ID = 'ueditor-custom-styles';
|
|
24
23
|
var ToolBottomBar = function ToolBottomBar(props) {
|
|
25
24
|
var ueditorInst = props.ueditorInst,
|
|
26
25
|
prefixCls = props.prefixCls,
|
|
@@ -58,6 +57,8 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
58
57
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
59
58
|
formatSetting = _useState12[0],
|
|
60
59
|
setFormatSetting = _useState12[1];
|
|
60
|
+
var formatSettingRef = useRef(undefined);
|
|
61
|
+
formatSettingRef.current = formatSetting;
|
|
61
62
|
var debounceContentChange = debounce(function () {
|
|
62
63
|
try {
|
|
63
64
|
var _plainTxt$match;
|
|
@@ -66,6 +67,10 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
66
67
|
var _totalTextCount = plainTxt.length;
|
|
67
68
|
setChineseTextCount(_chineseTextCount);
|
|
68
69
|
setTotalTextCount(_totalTextCount);
|
|
70
|
+
// 内容变化时更新样式
|
|
71
|
+
if (ueditorInst.body && formatSettingRef.current) {
|
|
72
|
+
generateStylesFromSettings(formatSettingRef.current, ueditorInst.body);
|
|
73
|
+
}
|
|
69
74
|
} catch (e) {
|
|
70
75
|
//
|
|
71
76
|
}
|
|
@@ -145,27 +150,16 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
145
150
|
* @param settings 格式设置
|
|
146
151
|
*/
|
|
147
152
|
var handleApply = function handleApply(settings) {
|
|
148
|
-
var _containerRef$current, _contentDocument;
|
|
149
153
|
var isUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// 触发编辑器视图更新
|
|
154
|
-
var frame = ueditorInst.frame || (containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("#".concat(uiId, "_iframeholder > iframe")));
|
|
155
|
-
if (frame !== null && frame !== void 0 && (_contentDocument = frame.contentDocument) !== null && _contentDocument !== void 0 && _contentDocument.documentElement) {
|
|
156
|
-
var _contentDocument2;
|
|
157
|
-
// 查找或创建样式元素
|
|
158
|
-
var styleEl = frame === null || frame === void 0 || (_contentDocument2 = frame.contentDocument) === null || _contentDocument2 === void 0 ? void 0 : _contentDocument2.getElementById(STYLE_ID);
|
|
159
|
-
if (!styleEl) {
|
|
160
|
-
styleEl = document.createElement('style');
|
|
161
|
-
styleEl.id = STYLE_ID;
|
|
162
|
-
frame.contentDocument.head.appendChild(styleEl);
|
|
163
|
-
}
|
|
164
|
-
// 设置样式内容
|
|
165
|
-
styleEl.textContent = cssStyles;
|
|
154
|
+
if (!settings) {
|
|
155
|
+
return;
|
|
166
156
|
}
|
|
167
157
|
setFormatSetting(settings);
|
|
168
158
|
if (isUpdate) {
|
|
159
|
+
// 生成样式
|
|
160
|
+
if (ueditorInst.body) {
|
|
161
|
+
generateStylesFromSettings(settings, ueditorInst.body);
|
|
162
|
+
}
|
|
169
163
|
onSettingChange === null || onSettingChange === void 0 || onSettingChange({
|
|
170
164
|
formatSetting: settings,
|
|
171
165
|
pageWidth: pageWidth
|
|
@@ -173,9 +167,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
173
167
|
}
|
|
174
168
|
};
|
|
175
169
|
useEffect(function () {
|
|
176
|
-
|
|
177
|
-
handleApply(defaultSetting.formatSetting, false);
|
|
178
|
-
}
|
|
170
|
+
handleApply(defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting, false);
|
|
179
171
|
}, [defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting]);
|
|
180
172
|
var handlePageWidthChange = function handlePageWidthChange(key) {
|
|
181
173
|
var isUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
@@ -279,7 +271,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
279
271
|
content: '导出文档',
|
|
280
272
|
onClick: function () {
|
|
281
273
|
var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
282
|
-
var
|
|
274
|
+
var _contentDocument, frame, _contentDocument2;
|
|
283
275
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
284
276
|
while (1) switch (_context.prev = _context.next) {
|
|
285
277
|
case 0:
|
|
@@ -288,12 +280,12 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
288
280
|
break;
|
|
289
281
|
}
|
|
290
282
|
frame = ueditorInst.frame || containerRef.current.querySelector("#".concat(uiId, "_iframeholder > iframe"));
|
|
291
|
-
if (!(frame !== null && frame !== void 0 && (
|
|
283
|
+
if (!(frame !== null && frame !== void 0 && (_contentDocument = frame.contentDocument) !== null && _contentDocument !== void 0 && _contentDocument.body)) {
|
|
292
284
|
_context.next = 6;
|
|
293
285
|
break;
|
|
294
286
|
}
|
|
295
287
|
_context.next = 5;
|
|
296
|
-
return domloadPdf(frame === null || frame === void 0 || (
|
|
288
|
+
return domloadPdf(frame === null || frame === void 0 || (_contentDocument2 = frame.contentDocument) === null || _contentDocument2 === void 0 ? void 0 : _contentDocument2.body, pageWidth || 'a0', exportFileName, onProgress);
|
|
297
289
|
case 5:
|
|
298
290
|
onProgress(100, '导出完成');
|
|
299
291
|
case 6:
|
|
@@ -29,10 +29,24 @@ export interface FormatSettings {
|
|
|
29
29
|
ol: ListStyle;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
export declare const STYLE_ID = "ueditor-custom-styles";
|
|
33
|
+
export declare const FORMAT_STYLE_TAG = "format-style";
|
|
32
34
|
/**
|
|
33
35
|
* 生成CSS样式内容
|
|
36
|
+
* 将css设置到元素上
|
|
34
37
|
* @param settings 格式设置
|
|
35
|
-
* @returns CSS样式字符串
|
|
36
38
|
*/
|
|
37
|
-
export declare const generateStylesFromSettings: (settings: FormatSettings) => string;
|
|
39
|
+
export declare const generateStylesFromSettings: (settings: FormatSettings, body: HTMLElement) => string;
|
|
40
|
+
/**
|
|
41
|
+
* 从现有样式标签中提取格式设置
|
|
42
|
+
* @param body HTML body元素
|
|
43
|
+
* @returns 格式设置对象,如果未找到样式标签则返回undefined
|
|
44
|
+
*/
|
|
45
|
+
export declare const extractSettingsFromStyles: (body: HTMLElement) => FormatSettings | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* 设置格式设置
|
|
48
|
+
* @param body
|
|
49
|
+
* @param settings
|
|
50
|
+
*/
|
|
51
|
+
export declare const setFormatSettings: (body: HTMLElement, cssStyles: string) => void;
|
|
38
52
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateStylesFromSettings.d.ts","sourceRoot":"","sources":["generateStylesFromSettings.ts"],"names":[],"mappings":"AAAA,UAAU,YAAa,SAAQ,SAAS;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,SAAU,SAAQ,SAAS;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE;QACR,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;KAClB,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE;QACL,EAAE,EAAE,SAAS,CAAC;QACd,EAAE,EAAE,SAAS,CAAC;KACf,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"generateStylesFromSettings.d.ts","sourceRoot":"","sources":["generateStylesFromSettings.ts"],"names":[],"mappings":"AAAA,UAAU,YAAa,SAAQ,SAAS;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,SAAU,SAAQ,SAAS;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE;QACR,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;QACjB,EAAE,EAAE,YAAY,CAAC;KAClB,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE;QACL,EAAE,EAAE,SAAS,CAAC;QACd,EAAE,EAAE,SAAS,CAAC;KACf,CAAC;CACH;AACD,eAAO,MAAM,QAAQ,0BAA0B,CAAC;AAGhD,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,aAAc,cAAc,QAAQ,WAAW,KAAG,MA+FxF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,SAAU,WAAW,KAAG,cAAc,GAAG,SAkF9E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,SAAU,WAAW,aAAa,MAAM,SAoBrE,CAAC"}
|
|
@@ -1,24 +1,204 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
export var STYLE_ID = 'ueditor-custom-styles';
|
|
4
|
+
|
|
5
|
+
// 自定义格式设置标签,用于回填格式设置
|
|
6
|
+
export var FORMAT_STYLE_TAG = 'format-style';
|
|
7
|
+
|
|
2
8
|
/**
|
|
3
9
|
* 生成CSS样式内容
|
|
10
|
+
* 将css设置到元素上
|
|
4
11
|
* @param settings 格式设置
|
|
5
|
-
* @returns CSS样式字符串
|
|
6
12
|
*/
|
|
7
|
-
export var generateStylesFromSettings = function generateStylesFromSettings(settings) {
|
|
8
|
-
var
|
|
13
|
+
export var generateStylesFromSettings = function generateStylesFromSettings(settings, body) {
|
|
14
|
+
var cssMap = {
|
|
15
|
+
h1: undefined,
|
|
16
|
+
h2: undefined,
|
|
17
|
+
h3: undefined,
|
|
18
|
+
h4: undefined,
|
|
19
|
+
h5: undefined,
|
|
20
|
+
h6: undefined,
|
|
21
|
+
p: undefined,
|
|
22
|
+
ul: undefined,
|
|
23
|
+
ol: undefined
|
|
24
|
+
};
|
|
25
|
+
var cssStyles = '';
|
|
9
26
|
|
|
10
27
|
// 处理标题样式
|
|
11
28
|
Object.entries(settings.headings).forEach(function (_ref) {
|
|
12
29
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
13
30
|
heading = _ref2[0],
|
|
14
31
|
style = _ref2[1];
|
|
15
|
-
|
|
32
|
+
cssMap[heading] = {
|
|
33
|
+
fontFamily: style.fontFamily,
|
|
34
|
+
fontSize: style.fontSize,
|
|
35
|
+
fontWeight: style.fontWeight,
|
|
36
|
+
lineHeight: style.lineHeight,
|
|
37
|
+
color: style.color
|
|
38
|
+
};
|
|
16
39
|
});
|
|
17
40
|
|
|
18
41
|
// 处理段落样式
|
|
19
|
-
|
|
42
|
+
cssMap.p = {
|
|
43
|
+
fontFamily: settings.paragraph.fontFamily,
|
|
44
|
+
fontSize: settings.paragraph.fontSize,
|
|
45
|
+
fontWeight: settings.paragraph.fontWeight,
|
|
46
|
+
lineHeight: settings.paragraph.lineHeight,
|
|
47
|
+
color: settings.paragraph.color
|
|
48
|
+
};
|
|
20
49
|
|
|
21
50
|
// 处理列表样式
|
|
22
|
-
|
|
23
|
-
|
|
51
|
+
cssMap.ul = {
|
|
52
|
+
fontFamily: settings.lists.ul.fontFamily,
|
|
53
|
+
fontSize: settings.lists.ul.fontSize,
|
|
54
|
+
fontWeight: settings.lists.ul.fontWeight,
|
|
55
|
+
lineHeight: settings.lists.ul.lineHeight,
|
|
56
|
+
color: settings.lists.ul.color,
|
|
57
|
+
paddingLeft: settings.lists.ul.paddingLeft,
|
|
58
|
+
marginTop: settings.lists.ul.marginTop,
|
|
59
|
+
marginBottom: settings.lists.ul.marginBottom
|
|
60
|
+
};
|
|
61
|
+
cssMap.ol = {
|
|
62
|
+
fontFamily: settings.lists.ol.fontFamily,
|
|
63
|
+
fontSize: settings.lists.ol.fontSize,
|
|
64
|
+
fontWeight: settings.lists.ol.fontWeight,
|
|
65
|
+
lineHeight: settings.lists.ol.lineHeight,
|
|
66
|
+
color: settings.lists.ol.color,
|
|
67
|
+
paddingLeft: settings.lists.ol.paddingLeft,
|
|
68
|
+
marginTop: settings.lists.ol.marginTop,
|
|
69
|
+
marginBottom: settings.lists.ol.marginBottom
|
|
70
|
+
};
|
|
71
|
+
Object.entries(cssMap).forEach(function (_ref3) {
|
|
72
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
73
|
+
key = _ref4[0],
|
|
74
|
+
value = _ref4[1];
|
|
75
|
+
if (value) {
|
|
76
|
+
cssStyles += "".concat(key, " {").concat(value.fontFamily ? "font-family: ".concat(value.fontFamily, ";\n") : '').concat(value.fontSize ? "font-size: ".concat(value.fontSize, ";\n") : '').concat(value.fontWeight ? "font-weight: ".concat(value.fontWeight, ";\n") : '').concat(value.lineHeight ? "line-height: ".concat(value.lineHeight, ";\n") : '').concat(value.color ? "color: ".concat(value.color, ";\n") : '').concat(value.marginTop ? "margin-top: ".concat(value.marginTop, ";\n") : '').concat(value.marginBottom ? "margin-bottom: ".concat(value.marginBottom, ";\n") : '').concat(value.paddingLeft ? "padding-left: ".concat(value.paddingLeft, ";\n") : '', "\n }");
|
|
77
|
+
body.querySelectorAll(key).forEach(function (item) {
|
|
78
|
+
// 遍历样式属性,仅在元素没有该样式时设置
|
|
79
|
+
Object.entries(value).forEach(function (_ref5) {
|
|
80
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
81
|
+
styleName = _ref6[0],
|
|
82
|
+
styleValue = _ref6[1];
|
|
83
|
+
if (styleValue) {
|
|
84
|
+
item.style[styleName] = styleValue;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return cssStyles;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 从现有样式标签中提取格式设置
|
|
95
|
+
* @param body HTML body元素
|
|
96
|
+
* @returns 格式设置对象,如果未找到样式标签则返回undefined
|
|
97
|
+
*/
|
|
98
|
+
export var extractSettingsFromStyles = function extractSettingsFromStyles(body) {
|
|
99
|
+
var styleElement = body.querySelector("#".concat(STYLE_ID));
|
|
100
|
+
if (!styleElement || !styleElement.textContent) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
var cssText = styleElement.textContent;
|
|
104
|
+
|
|
105
|
+
// 解析CSS规则
|
|
106
|
+
var parseCSSRule = function parseCSSRule(selector) {
|
|
107
|
+
var regex = new RegExp("".concat(selector, "\\s*{([^}]+)}"), 'g');
|
|
108
|
+
var match = regex.exec(cssText);
|
|
109
|
+
if (!match) return {};
|
|
110
|
+
var styleText = match[1];
|
|
111
|
+
var styles = {};
|
|
112
|
+
|
|
113
|
+
// 解析样式属性
|
|
114
|
+
var styleRegex = /([a-zA-Z-]+)\s*:\s*([^;]+);/g;
|
|
115
|
+
var styleMatch = styleRegex.exec(styleText);
|
|
116
|
+
while (styleMatch !== null) {
|
|
117
|
+
var _styleMatch = styleMatch,
|
|
118
|
+
_styleMatch2 = _slicedToArray(_styleMatch, 3),
|
|
119
|
+
property = _styleMatch2[1],
|
|
120
|
+
value = _styleMatch2[2];
|
|
121
|
+
styles[property.trim()] = value.trim();
|
|
122
|
+
styleMatch = styleRegex.exec(styleText);
|
|
123
|
+
}
|
|
124
|
+
return styles;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// 提取文本样式
|
|
128
|
+
var extractTextStyle = function extractTextStyle(selector) {
|
|
129
|
+
var styles = parseCSSRule(selector);
|
|
130
|
+
return {
|
|
131
|
+
fontSize: styles['font-size'] || '16px',
|
|
132
|
+
fontFamily: styles['font-family'] || 'Arial, sans-serif',
|
|
133
|
+
fontWeight: styles['font-weight'] || 'normal',
|
|
134
|
+
lineHeight: styles['line-height'] || '1.5',
|
|
135
|
+
color: styles.color || '#000000'
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// 提取标题样式
|
|
140
|
+
var extractHeadingStyle = function extractHeadingStyle(selector) {
|
|
141
|
+
var textStyle = extractTextStyle(selector);
|
|
142
|
+
var styles = parseCSSRule(selector);
|
|
143
|
+
return _objectSpread(_objectSpread({}, textStyle), {}, {
|
|
144
|
+
marginTop: styles['margin-top'] || '0',
|
|
145
|
+
marginBottom: styles['margin-bottom'] || '0'
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// 提取列表样式
|
|
150
|
+
var extractListStyle = function extractListStyle(selector) {
|
|
151
|
+
var textStyle = extractTextStyle(selector);
|
|
152
|
+
var styles = parseCSSRule(selector);
|
|
153
|
+
return _objectSpread(_objectSpread({}, textStyle), {}, {
|
|
154
|
+
paddingLeft: styles['padding-left'] || '0',
|
|
155
|
+
marginTop: styles['margin-top'] || '0',
|
|
156
|
+
marginBottom: styles['margin-bottom'] || '0'
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// 构建FormatSettings对象
|
|
161
|
+
var formatSettings = {
|
|
162
|
+
headings: {
|
|
163
|
+
h1: extractHeadingStyle('h1'),
|
|
164
|
+
h2: extractHeadingStyle('h2'),
|
|
165
|
+
h3: extractHeadingStyle('h3'),
|
|
166
|
+
h4: extractHeadingStyle('h4'),
|
|
167
|
+
h5: extractHeadingStyle('h5'),
|
|
168
|
+
h6: extractHeadingStyle('h6')
|
|
169
|
+
},
|
|
170
|
+
paragraph: extractTextStyle('p'),
|
|
171
|
+
lists: {
|
|
172
|
+
ul: extractListStyle('ul'),
|
|
173
|
+
ol: extractListStyle('ol')
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return formatSettings;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 设置格式设置
|
|
181
|
+
* @param body
|
|
182
|
+
* @param settings
|
|
183
|
+
*/
|
|
184
|
+
export var setFormatSettings = function setFormatSettings(body, cssStyles) {
|
|
185
|
+
var styleEl = body.querySelector("#".concat(STYLE_ID));
|
|
186
|
+
if (!styleEl || !cssStyles) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (cssStyles) {
|
|
190
|
+
// 触发编辑器视图更新
|
|
191
|
+
if (body) {
|
|
192
|
+
// 查找或创建样式元素
|
|
193
|
+
var _styleEl = body === null || body === void 0 ? void 0 : body.querySelector("#".concat(STYLE_ID));
|
|
194
|
+
if (!_styleEl) {
|
|
195
|
+
_styleEl = document.createElement(FORMAT_STYLE_TAG);
|
|
196
|
+
_styleEl.style.display = 'none';
|
|
197
|
+
_styleEl.id = STYLE_ID;
|
|
198
|
+
body.insertBefore(_styleEl, body.firstChild);
|
|
199
|
+
}
|
|
200
|
+
// 设置样式内容
|
|
201
|
+
_styleEl.textContent = cssStyles;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
24
204
|
};
|