@lingxiteam/lcdp-ueditor-react 1.0.4-alpha.1 → 1.0.4-alpha.3
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.js +17 -12
- package/es/ToolBottomBar/FormatModal/index.js +79 -75
- package/es/ToolBottomBar/index.d.ts +2 -3
- package/es/ToolBottomBar/index.js +55 -46
- package/es/tools/generateStylesFromSettings.d.ts +16 -2
- package/es/tools/generateStylesFromSettings.js +187 -7
- package/es/type.d.ts +4 -5
- package/lib/LcdpUeditor.d.ts +1 -0
- package/lib/LcdpUeditor.js +12 -7
- package/lib/ToolBottomBar/FormatModal/index.js +49 -38
- package/lib/ToolBottomBar/index.d.ts +2 -3
- package/lib/ToolBottomBar/index.js +45 -35
- package/lib/tools/generateStylesFromSettings.d.ts +16 -2
- package/lib/tools/generateStylesFromSettings.js +167 -48
- package/lib/type.d.ts +4 -5
- 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.map +0 -1
- package/es/ToolBottomBar/FormatModal/index.d.ts.map +0 -1
- package/es/ToolBottomBar/ProgressModal/index.d.ts.map +0 -1
- package/es/ToolBottomBar/index.d.ts.map +0 -1
- package/es/const.d.ts.map +0 -1
- package/es/icon/ExportPDF.d.ts.map +0 -1
- package/es/icon/TextCopy.d.ts.map +0 -1
- package/es/icon/TextFileIcon.d.ts.map +0 -1
- package/es/icon/TextIcon.d.ts.map +0 -1
- package/es/index.d.ts.map +0 -1
- package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
- package/es/tools/exportPDF.d.ts.map +0 -1
- package/es/tools/filterHtmlNode.d.ts.map +0 -1
- package/es/tools/generateStylesFromSettings.d.ts.map +0 -1
- package/es/tools/loadScript.d.ts.map +0 -1
- package/es/type.d.ts.map +0 -1
package/es/LcdpUeditor.d.ts
CHANGED
package/es/LcdpUeditor.js
CHANGED
|
@@ -15,6 +15,7 @@ import UeditorResourceLoader from "./tools/UeditorResourceLoader";
|
|
|
15
15
|
import debounce from 'lodash/debounce';
|
|
16
16
|
import { filterHtmlNode } from "./tools/filterHtmlNode";
|
|
17
17
|
import ToolBottomBar from "./ToolBottomBar";
|
|
18
|
+
var BOTTOM_STATUS_BAR_CLASS = 'ueditor-bottom-bar-with-status';
|
|
18
19
|
var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
19
20
|
_inherits(LcdpUeditor, _React$Component);
|
|
20
21
|
var _super = _createSuper(LcdpUeditor);
|
|
@@ -80,9 +81,13 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
80
81
|
* 编辑器配置项
|
|
81
82
|
*/
|
|
82
83
|
_defineProperty(_assertThisInitialized(_this), "editorConfig", {});
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "onSettingChange", function (setting) {
|
|
85
|
+
_this.editorConfig.onSettingChange(setting);
|
|
86
|
+
_this.onContentChange();
|
|
87
|
+
});
|
|
83
88
|
var config = props.config,
|
|
84
89
|
prefixCls = props.prefixCls,
|
|
85
|
-
|
|
90
|
+
onSettingChange = props.onSettingChange;
|
|
86
91
|
_this.containerId = "ueditor_".concat(Date.now(), "_").concat(String(Math.random()).slice(2, 6));
|
|
87
92
|
if (_this.props.ueditorPath) {
|
|
88
93
|
_this.ueditorPath = _this.props.ueditorPath;
|
|
@@ -121,7 +126,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
121
126
|
uploadFunction: _this.uploadFunction,
|
|
122
127
|
initialContent: '',
|
|
123
128
|
pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true,
|
|
124
|
-
|
|
129
|
+
onSettingChange: onSettingChange,
|
|
125
130
|
exportFileName: (config === null || config === void 0 ? void 0 : config.exportFileName) || '未命名'
|
|
126
131
|
});
|
|
127
132
|
_this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
|
|
@@ -154,7 +159,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
154
159
|
key: "componentDidUpdate",
|
|
155
160
|
value: function componentDidUpdate(prevProps) {
|
|
156
161
|
var _prevProps$config, _this$props;
|
|
157
|
-
if (this.state.isReady && (prevProps.
|
|
162
|
+
if (this.state.isReady && (prevProps.defaultSetting !== this.props.defaultSetting || prevProps.bottomTypes !== this.props.bottomTypes || (prevProps === null || prevProps === void 0 || (_prevProps$config = prevProps.config) === null || _prevProps$config === void 0 ? void 0 : _prevProps$config.exportFileName) !== ((_this$props = this.props) === null || _this$props === void 0 || (_this$props = _this$props.config) === null || _this$props === void 0 ? void 0 : _this$props.exportFileName))) {
|
|
158
163
|
this.renderStatusBar();
|
|
159
164
|
}
|
|
160
165
|
}
|
|
@@ -400,14 +405,14 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
400
405
|
return _initUeditor.apply(this, arguments);
|
|
401
406
|
}
|
|
402
407
|
return initUeditor;
|
|
403
|
-
}()
|
|
408
|
+
}())
|
|
409
|
+
}, {
|
|
410
|
+
key: "renderStatusBar",
|
|
411
|
+
value:
|
|
404
412
|
/**
|
|
405
413
|
* 渲染状态栏
|
|
406
414
|
*/
|
|
407
|
-
)
|
|
408
|
-
}, {
|
|
409
|
-
key: "renderStatusBar",
|
|
410
|
-
value: function renderStatusBar() {
|
|
415
|
+
function renderStatusBar() {
|
|
411
416
|
var _this$containerRef$cu, _this$props2;
|
|
412
417
|
var _ref4 = this.ueditorInst.ui || {},
|
|
413
418
|
id = _ref4.id;
|
|
@@ -416,8 +421,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
416
421
|
ueditorInst: this.ueditorInst,
|
|
417
422
|
prefixCls: this.prefixCls,
|
|
418
423
|
containerRef: this.containerRef,
|
|
419
|
-
|
|
420
|
-
|
|
424
|
+
defaultSetting: this.props.defaultSetting,
|
|
425
|
+
onSettingChange: this.onSettingChange,
|
|
421
426
|
isReady: this.state.isReady,
|
|
422
427
|
bottomTypes: this.props.bottomTypes,
|
|
423
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
|
|
@@ -427,10 +432,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
427
432
|
// 获取底部状态组件
|
|
428
433
|
var statusContainer = bottomBarContainer.querySelector("#".concat(id, "_bottomStatusBar"));
|
|
429
434
|
// 移除底部状态栏的样式
|
|
430
|
-
bottomBarContainer.classList.remove(
|
|
435
|
+
bottomBarContainer.classList.remove(BOTTOM_STATUS_BAR_CLASS);
|
|
431
436
|
// 如果底部状态栏有类型,则添加样式
|
|
432
437
|
if ((_this$props$bottomTyp = this.props.bottomTypes) !== null && _this$props$bottomTyp !== void 0 && _this$props$bottomTyp.length) {
|
|
433
|
-
bottomBarContainer.classList.add(
|
|
438
|
+
bottomBarContainer.classList.add(BOTTOM_STATUS_BAR_CLASS);
|
|
434
439
|
// 如果底部状态栏没有组件,则创建组件
|
|
435
440
|
if (!statusContainer) {
|
|
436
441
|
statusContainer = document.createElement('div');
|
|
@@ -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,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FormatSettings } from '../tools/generateStylesFromSettings';
|
|
3
2
|
import './index.less';
|
|
4
3
|
import { ILcdpUeditorProps } from '../type';
|
|
5
4
|
declare const ToolBottomBar: (props: {
|
|
@@ -15,8 +14,8 @@ declare const ToolBottomBar: (props: {
|
|
|
15
14
|
* 容器引用
|
|
16
15
|
*/
|
|
17
16
|
containerRef?: React.RefObject<HTMLDivElement> | undefined;
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
defaultSetting?: Record<"chineseCount" | "charCount" | "pageWidth" | "formatSetting" | "exportPdf" | "fullScreen" | "copy", any> | undefined;
|
|
18
|
+
onSettingChange?: ((setting: Partial<Record<Required<ILcdpUeditorProps>['bottomTypes'][number], any>>) => void) | undefined;
|
|
20
19
|
/**
|
|
21
20
|
* 是否准备就绪
|
|
22
21
|
*/
|
|
@@ -20,13 +20,12 @@ 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,
|
|
27
26
|
containerRef = props.containerRef,
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
defaultSetting = props.defaultSetting,
|
|
28
|
+
onSettingChange = props.onSettingChange,
|
|
30
29
|
isReady = props.isReady,
|
|
31
30
|
bottomTypes = props.bottomTypes,
|
|
32
31
|
exportFileName = props.exportFileName;
|
|
@@ -54,6 +53,10 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
54
53
|
setPageWidth = _useState10[1];
|
|
55
54
|
var timer = useRef(undefined);
|
|
56
55
|
var progressModalRef = useRef(null);
|
|
56
|
+
var _useState11 = useState(undefined),
|
|
57
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
58
|
+
formatSetting = _useState12[0],
|
|
59
|
+
setFormatSetting = _useState12[1];
|
|
57
60
|
var debounceContentChange = debounce(function () {
|
|
58
61
|
try {
|
|
59
62
|
var _plainTxt$match;
|
|
@@ -141,34 +144,58 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
141
144
|
* @param settings 格式设置
|
|
142
145
|
*/
|
|
143
146
|
var handleApply = function handleApply(settings) {
|
|
144
|
-
var _containerRef$current, _contentDocument;
|
|
145
147
|
var isUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var styleEl = frame === null || frame === void 0 || (_contentDocument2 = frame.contentDocument) === null || _contentDocument2 === void 0 ? void 0 : _contentDocument2.getElementById(STYLE_ID);
|
|
155
|
-
if (!styleEl) {
|
|
156
|
-
styleEl = document.createElement('style');
|
|
157
|
-
styleEl.id = STYLE_ID;
|
|
158
|
-
frame.contentDocument.head.appendChild(styleEl);
|
|
148
|
+
if (!settings) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
setFormatSetting(settings);
|
|
152
|
+
if (isUpdate) {
|
|
153
|
+
// 生成样式
|
|
154
|
+
if (ueditorInst.body) {
|
|
155
|
+
generateStylesFromSettings(settings, ueditorInst.body);
|
|
159
156
|
}
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
onSettingChange === null || onSettingChange === void 0 || onSettingChange({
|
|
158
|
+
formatSetting: settings,
|
|
159
|
+
pageWidth: pageWidth
|
|
160
|
+
});
|
|
162
161
|
}
|
|
162
|
+
};
|
|
163
|
+
useEffect(function () {
|
|
164
|
+
handleApply(defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting, false);
|
|
165
|
+
}, [defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting]);
|
|
166
|
+
var handlePageWidthChange = function handlePageWidthChange(key) {
|
|
167
|
+
var isUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
168
|
+
// 设置编辑器宽度
|
|
169
|
+
var newClass = "ueditor-rich-status-content-".concat(key);
|
|
170
|
+
var oldClass = "ueditor-rich-status-content-".concat(pageWidth);
|
|
171
|
+
if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
|
|
172
|
+
var frame = containerRef.current.querySelector("#".concat(uiId, "_iframeholder"));
|
|
173
|
+
var frameContainer = ueditorInst.container || containerRef.current.querySelector("#".concat(uiId));
|
|
174
|
+
if (frame) {
|
|
175
|
+
frame.classList.remove(oldClass);
|
|
176
|
+
frame.classList.add(newClass);
|
|
177
|
+
}
|
|
178
|
+
if (frameContainer) {
|
|
179
|
+
if (key === 'a0') {
|
|
180
|
+
frameContainer.classList.remove('ueditor-rich-status-not-full');
|
|
181
|
+
} else {
|
|
182
|
+
frameContainer.classList.add('ueditor-rich-status-not-full');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
setPageWidth(key);
|
|
163
187
|
if (isUpdate) {
|
|
164
|
-
|
|
188
|
+
onSettingChange === null || onSettingChange === void 0 || onSettingChange({
|
|
189
|
+
pageWidth: key,
|
|
190
|
+
formatSetting: formatSetting
|
|
191
|
+
});
|
|
165
192
|
}
|
|
166
193
|
};
|
|
167
194
|
useEffect(function () {
|
|
168
|
-
if (
|
|
169
|
-
|
|
195
|
+
if (defaultSetting !== null && defaultSetting !== void 0 && defaultSetting.pageWidth) {
|
|
196
|
+
handlePageWidthChange(defaultSetting.pageWidth, false);
|
|
170
197
|
}
|
|
171
|
-
}, [
|
|
198
|
+
}, [defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.pageWidth]);
|
|
172
199
|
var onProgress = function onProgress(progress, title) {
|
|
173
200
|
var _progressModalRef$cur;
|
|
174
201
|
(_progressModalRef$cur = progressModalRef.current) === null || _progressModalRef$cur === void 0 || _progressModalRef$cur.updateProgress(progress, title);
|
|
@@ -200,25 +227,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
200
227
|
overlay: /*#__PURE__*/React.createElement(Menu, {
|
|
201
228
|
onClick: function onClick(_ref2) {
|
|
202
229
|
var key = _ref2.key;
|
|
203
|
-
|
|
204
|
-
var newClass = "ueditor-rich-status-content-".concat(key);
|
|
205
|
-
var oldClass = "ueditor-rich-status-content-".concat(pageWidth);
|
|
206
|
-
if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
|
|
207
|
-
var frame = containerRef.current.querySelector("#".concat(uiId, "_iframeholder"));
|
|
208
|
-
var frameContainer = ueditorInst.container || containerRef.current.querySelector("#".concat(uiId));
|
|
209
|
-
if (frame) {
|
|
210
|
-
frame.classList.remove(oldClass);
|
|
211
|
-
frame.classList.add(newClass);
|
|
212
|
-
}
|
|
213
|
-
if (frameContainer) {
|
|
214
|
-
if (key === 'a0') {
|
|
215
|
-
frameContainer.classList.remove('ueditor-rich-status-not-full');
|
|
216
|
-
} else {
|
|
217
|
-
frameContainer.classList.add('ueditor-rich-status-not-full');
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
setPageWidth(key);
|
|
230
|
+
handlePageWidthChange(key);
|
|
222
231
|
}
|
|
223
232
|
}, Object.keys(MENU_OPTIONS).map(function (k) {
|
|
224
233
|
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
@@ -230,7 +239,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
230
239
|
extraNode: /*#__PURE__*/React.createElement(DownOutlined, null)
|
|
231
240
|
})), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('formatSetting')) && /*#__PURE__*/React.createElement(FormatModal, {
|
|
232
241
|
onApply: handleApply,
|
|
233
|
-
initialSettings:
|
|
242
|
+
initialSettings: defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting
|
|
234
243
|
}, getStatusBarItem({
|
|
235
244
|
icon: /*#__PURE__*/React.createElement(SettingOutlined, null),
|
|
236
245
|
content: '格式设置'
|
|
@@ -256,7 +265,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
256
265
|
content: '导出文档',
|
|
257
266
|
onClick: function () {
|
|
258
267
|
var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
259
|
-
var
|
|
268
|
+
var _contentDocument, frame, _contentDocument2;
|
|
260
269
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
261
270
|
while (1) switch (_context.prev = _context.next) {
|
|
262
271
|
case 0:
|
|
@@ -265,12 +274,12 @@ var ToolBottomBar = function ToolBottomBar(props) {
|
|
|
265
274
|
break;
|
|
266
275
|
}
|
|
267
276
|
frame = ueditorInst.frame || containerRef.current.querySelector("#".concat(uiId, "_iframeholder > iframe"));
|
|
268
|
-
if (!(frame !== null && frame !== void 0 && (
|
|
277
|
+
if (!(frame !== null && frame !== void 0 && (_contentDocument = frame.contentDocument) !== null && _contentDocument !== void 0 && _contentDocument.body)) {
|
|
269
278
|
_context.next = 6;
|
|
270
279
|
break;
|
|
271
280
|
}
|
|
272
281
|
_context.next = 5;
|
|
273
|
-
return domloadPdf(frame === null || frame === void 0 || (
|
|
282
|
+
return domloadPdf(frame === null || frame === void 0 || (_contentDocument2 = frame.contentDocument) === null || _contentDocument2 === void 0 ? void 0 : _contentDocument2.body, pageWidth || 'a0', exportFileName, onProgress);
|
|
274
283
|
case 5:
|
|
275
284
|
onProgress(100, '导出完成');
|
|
276
285
|
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 {};
|