@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.
Files changed (37) hide show
  1. package/es/LcdpUeditor.d.ts +1 -0
  2. package/es/LcdpUeditor.js +17 -12
  3. package/es/ToolBottomBar/FormatModal/index.js +79 -75
  4. package/es/ToolBottomBar/index.d.ts +2 -3
  5. package/es/ToolBottomBar/index.js +55 -46
  6. package/es/tools/generateStylesFromSettings.d.ts +16 -2
  7. package/es/tools/generateStylesFromSettings.js +187 -7
  8. package/es/type.d.ts +4 -5
  9. package/lib/LcdpUeditor.d.ts +1 -0
  10. package/lib/LcdpUeditor.js +12 -7
  11. package/lib/ToolBottomBar/FormatModal/index.js +49 -38
  12. package/lib/ToolBottomBar/index.d.ts +2 -3
  13. package/lib/ToolBottomBar/index.js +45 -35
  14. package/lib/tools/generateStylesFromSettings.d.ts +16 -2
  15. package/lib/tools/generateStylesFromSettings.js +167 -48
  16. package/lib/type.d.ts +4 -5
  17. package/package.json +1 -1
  18. package/ueditor-resource/lang/en/en.js +1 -1
  19. package/ueditor-resource/lang/zh-cn/zh-cn.js +1 -1
  20. package/ueditor-resource/lang/zh-tw/zh-tw.js +1 -1
  21. package/ueditor-resource/ueditor.all.js +21 -20
  22. package/es/LcdpUeditor.d.ts.map +0 -1
  23. package/es/ToolBottomBar/FormatModal/index.d.ts.map +0 -1
  24. package/es/ToolBottomBar/ProgressModal/index.d.ts.map +0 -1
  25. package/es/ToolBottomBar/index.d.ts.map +0 -1
  26. package/es/const.d.ts.map +0 -1
  27. package/es/icon/ExportPDF.d.ts.map +0 -1
  28. package/es/icon/TextCopy.d.ts.map +0 -1
  29. package/es/icon/TextFileIcon.d.ts.map +0 -1
  30. package/es/icon/TextIcon.d.ts.map +0 -1
  31. package/es/index.d.ts.map +0 -1
  32. package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
  33. package/es/tools/exportPDF.d.ts.map +0 -1
  34. package/es/tools/filterHtmlNode.d.ts.map +0 -1
  35. package/es/tools/generateStylesFromSettings.d.ts.map +0 -1
  36. package/es/tools/loadScript.d.ts.map +0 -1
  37. package/es/type.d.ts.map +0 -1
@@ -82,6 +82,7 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
82
82
  * 初始化编辑器实例
83
83
  */
84
84
  initUeditor(): Promise<void>;
85
+ onSettingChange: (setting: any) => void;
85
86
  /**
86
87
  * 渲染状态栏
87
88
  */
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
- onFormatChange = props.onFormatChange;
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
- onFormatChange: onFormatChange,
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.defaultFormatSetting !== this.props.defaultFormatSetting || 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))) {
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
- defaultFormatSetting: this.props.defaultFormatSetting,
420
- onFormatChange: this.editorConfig.onFormatChange,
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('ueditor-bottom-bar-with-status');
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('ueditor-bottom-bar-with-status');
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: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Helvetica, Arial, sans-serif",
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: 'Segoe UI'
217
+ label: fontFamilyTranslations.segoeUI
189
218
  }, {
190
219
  value: 'Calibri',
191
- label: 'Calibri'
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: 'Helvetica Neue'
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: 'Source Han Sans'
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: 'DejaVu Sans'
261
+ label: fontFamilyTranslations.dejaVuSans
239
262
  }, {
240
263
  value: 'Liberation Sans',
241
- label: 'Liberation Sans'
264
+ label: fontFamilyTranslations.liberationSans
242
265
  }]
243
266
  };
244
267
 
245
268
  // 通用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
- }];
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.apply(allFonts, webSafeFonts);
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
- defaultFormatSetting?: FormatSettings | undefined;
19
- onFormatChange?: ((val: FormatSettings) => void) | undefined;
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
- defaultFormatSetting = props.defaultFormatSetting,
29
- onFormatChange = props.onFormatChange,
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
- var cssStyles = generateStylesFromSettings(settings);
148
-
149
- // 触发编辑器视图更新
150
- 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")));
151
- if (frame !== null && frame !== void 0 && (_contentDocument = frame.contentDocument) !== null && _contentDocument !== void 0 && _contentDocument.documentElement) {
152
- var _contentDocument2;
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
- styleEl.textContent = cssStyles;
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
- onFormatChange === null || onFormatChange === void 0 || onFormatChange(settings);
188
+ onSettingChange === null || onSettingChange === void 0 || onSettingChange({
189
+ pageWidth: key,
190
+ formatSetting: formatSetting
191
+ });
165
192
  }
166
193
  };
167
194
  useEffect(function () {
168
- if (defaultFormatSetting) {
169
- handleApply(defaultFormatSetting, false);
195
+ if (defaultSetting !== null && defaultSetting !== void 0 && defaultSetting.pageWidth) {
196
+ handlePageWidthChange(defaultSetting.pageWidth, false);
170
197
  }
171
- }, [defaultFormatSetting]);
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: defaultFormatSetting
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 _contentDocument3, frame, _contentDocument4;
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 && (_contentDocument3 = frame.contentDocument) !== null && _contentDocument3 !== void 0 && _contentDocument3.body)) {
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 || (_contentDocument4 = frame.contentDocument) === null || _contentDocument4 === void 0 ? void 0 : _contentDocument4.body, pageWidth || 'a0', exportFileName, onProgress);
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 {};