@lingxiteam/lcdp-ueditor-react 1.0.4-alpha.1 → 1.0.4-alpha.2

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.
@@ -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;AAQhD,cAAM,WAAY,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAE,CAAC;IAC9D;;OAEG;IACH,WAAW,EAAE,MAAM,CAAwB;IAE3C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAwD;IAExE;;OAEG;IACH,OAAO,CAAC,YAAY,CAAwD;IAE5E;;OAEG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;OAEG;IACH,OAAO,CAAC,WAAW,CAAa;IAEhC;;OAEG;IACH,OAAO,CAAC,YAAY,CAAiB;IAErC;;OAEG;IACH,OAAO,CAAC,qBAAqB,CAAW;IAExC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAc;IAEpC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAM;IAE5B;;OAEG;IACH,OAAO,CAAC,qBAAqB,CAAC,CAAa;IAE3C;;OAEG;IACH,OAAO,CAAC,SAAS,CAAuB;IAExC;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAOvD;IAEF;;OAEG;IACH,YAAY,EAAE,GAAG,CAAM;gBAEX,KAAK,EAAE,iBAAiB;IAgDpC,iBAAiB,IAAI,IAAI;IAIzB,yBAAyB,CAAC,SAAS,EAAE,iBAAiB;IAiBtD,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI;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AM;gBAEX,KAAK,EAAE,iBAAiB;IAgDpC,iBAAiB,IAAI,IAAI;IAIzB,yBAAyB,CAAC,SAAS,EAAE,iBAAiB;IAiBtD,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAUhE,oBAAoB,IAAI,IAAI;IAY5B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,UAAU;IAWlB;;;;OAIG;YACW,UAAU;IAqCxB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAMhB;;OAEG;IACH,OAAO,CAAC,SAAS;IAcjB;;OAEG;IACG,WAAW;IA4DjB;;OAEG;IACH,eAAe;IAsCf,MAAM,IAAI,KAAK,CAAC,SAAS;CAY1B;AAED,eAAe,WAAW,CAAC"}
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);
@@ -82,7 +83,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
82
83
  _defineProperty(_assertThisInitialized(_this), "editorConfig", {});
83
84
  var config = props.config,
84
85
  prefixCls = props.prefixCls,
85
- onFormatChange = props.onFormatChange;
86
+ onSettingChange = props.onSettingChange;
86
87
  _this.containerId = "ueditor_".concat(Date.now(), "_").concat(String(Math.random()).slice(2, 6));
87
88
  if (_this.props.ueditorPath) {
88
89
  _this.ueditorPath = _this.props.ueditorPath;
@@ -121,7 +122,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
121
122
  uploadFunction: _this.uploadFunction,
122
123
  initialContent: '',
123
124
  pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true,
124
- onFormatChange: onFormatChange,
125
+ onSettingChange: onSettingChange,
125
126
  exportFileName: (config === null || config === void 0 ? void 0 : config.exportFileName) || '未命名'
126
127
  });
127
128
  _this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
@@ -154,7 +155,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
154
155
  key: "componentDidUpdate",
155
156
  value: function componentDidUpdate(prevProps) {
156
157
  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))) {
158
+ 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
159
  this.renderStatusBar();
159
160
  }
160
161
  }
@@ -416,8 +417,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
416
417
  ueditorInst: this.ueditorInst,
417
418
  prefixCls: this.prefixCls,
418
419
  containerRef: this.containerRef,
419
- defaultFormatSetting: this.props.defaultFormatSetting,
420
- onFormatChange: this.editorConfig.onFormatChange,
420
+ defaultSetting: this.props.defaultSetting,
421
+ onSettingChange: this.editorConfig.onSettingChange,
421
422
  isReady: this.state.isReady,
422
423
  bottomTypes: this.props.bottomTypes,
423
424
  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 +428,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
427
428
  // 获取底部状态组件
428
429
  var statusContainer = bottomBarContainer.querySelector("#".concat(id, "_bottomStatusBar"));
429
430
  // 移除底部状态栏的样式
430
- bottomBarContainer.classList.remove('ueditor-bottom-bar-with-status');
431
+ bottomBarContainer.classList.remove(BOTTOM_STATUS_BAR_CLASS);
431
432
  // 如果底部状态栏有类型,则添加样式
432
433
  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');
434
+ bottomBarContainer.classList.add(BOTTOM_STATUS_BAR_CLASS);
434
435
  // 如果底部状态栏没有组件,则创建组件
435
436
  if (!statusContainer) {
436
437
  statusContainer = document.createElement('div');
@@ -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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAW3D,OAAO,EAAE,cAAc,EAA8B,MAAM,qCAAqC,CAAC;AACjG,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAU5C,QAAA,MAAM,aAAa;IAEjB;;OAEG;iBACU,GAAG;IAEhB;;OAEG;;IAGH;;OAEG;;;4BAGoB,cAAc,KAAK,IAAI;IAE9C;;OAEG;;IAGH;;OAEG;kBACW,iBAAiB,CAAC,aAAa,CAAC;IAE9C;;OAEG;;iBAuOJ,CAAC;AAEF,eAAe,aAAa,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;AAU5C,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;;iBA4PJ,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -25,8 +25,8 @@ var ToolBottomBar = function ToolBottomBar(props) {
25
25
  var ueditorInst = props.ueditorInst,
26
26
  prefixCls = props.prefixCls,
27
27
  containerRef = props.containerRef,
28
- defaultFormatSetting = props.defaultFormatSetting,
29
- onFormatChange = props.onFormatChange,
28
+ defaultSetting = props.defaultSetting,
29
+ onSettingChange = props.onSettingChange,
30
30
  isReady = props.isReady,
31
31
  bottomTypes = props.bottomTypes,
32
32
  exportFileName = props.exportFileName;
@@ -54,6 +54,10 @@ var ToolBottomBar = function ToolBottomBar(props) {
54
54
  setPageWidth = _useState10[1];
55
55
  var timer = useRef(undefined);
56
56
  var progressModalRef = useRef(null);
57
+ var _useState11 = useState(undefined),
58
+ _useState12 = _slicedToArray(_useState11, 2),
59
+ formatSetting = _useState12[0],
60
+ setFormatSetting = _useState12[1];
57
61
  var debounceContentChange = debounce(function () {
58
62
  try {
59
63
  var _plainTxt$match;
@@ -160,15 +164,52 @@ var ToolBottomBar = function ToolBottomBar(props) {
160
164
  // 设置样式内容
161
165
  styleEl.textContent = cssStyles;
162
166
  }
167
+ setFormatSetting(settings);
163
168
  if (isUpdate) {
164
- onFormatChange === null || onFormatChange === void 0 || onFormatChange(settings);
169
+ onSettingChange === null || onSettingChange === void 0 || onSettingChange({
170
+ formatSetting: settings,
171
+ pageWidth: pageWidth
172
+ });
165
173
  }
166
174
  };
167
175
  useEffect(function () {
168
- if (defaultFormatSetting) {
169
- handleApply(defaultFormatSetting, false);
176
+ if (defaultSetting !== null && defaultSetting !== void 0 && defaultSetting.formatSetting) {
177
+ handleApply(defaultSetting.formatSetting, false);
178
+ }
179
+ }, [defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting]);
180
+ var handlePageWidthChange = function handlePageWidthChange(key) {
181
+ var isUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
182
+ // 设置编辑器宽度
183
+ var newClass = "ueditor-rich-status-content-".concat(key);
184
+ var oldClass = "ueditor-rich-status-content-".concat(pageWidth);
185
+ if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
186
+ var frame = containerRef.current.querySelector("#".concat(uiId, "_iframeholder"));
187
+ var frameContainer = ueditorInst.container || containerRef.current.querySelector("#".concat(uiId));
188
+ if (frame) {
189
+ frame.classList.remove(oldClass);
190
+ frame.classList.add(newClass);
191
+ }
192
+ if (frameContainer) {
193
+ if (key === 'a0') {
194
+ frameContainer.classList.remove('ueditor-rich-status-not-full');
195
+ } else {
196
+ frameContainer.classList.add('ueditor-rich-status-not-full');
197
+ }
198
+ }
170
199
  }
171
- }, [defaultFormatSetting]);
200
+ setPageWidth(key);
201
+ if (isUpdate) {
202
+ onSettingChange === null || onSettingChange === void 0 || onSettingChange({
203
+ pageWidth: key,
204
+ formatSetting: formatSetting
205
+ });
206
+ }
207
+ };
208
+ useEffect(function () {
209
+ if (defaultSetting !== null && defaultSetting !== void 0 && defaultSetting.pageWidth) {
210
+ handlePageWidthChange(defaultSetting.pageWidth, false);
211
+ }
212
+ }, [defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.pageWidth]);
172
213
  var onProgress = function onProgress(progress, title) {
173
214
  var _progressModalRef$cur;
174
215
  (_progressModalRef$cur = progressModalRef.current) === null || _progressModalRef$cur === void 0 || _progressModalRef$cur.updateProgress(progress, title);
@@ -200,25 +241,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
200
241
  overlay: /*#__PURE__*/React.createElement(Menu, {
201
242
  onClick: function onClick(_ref2) {
202
243
  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);
244
+ handlePageWidthChange(key);
222
245
  }
223
246
  }, Object.keys(MENU_OPTIONS).map(function (k) {
224
247
  return /*#__PURE__*/React.createElement(Menu.Item, {
@@ -230,7 +253,7 @@ var ToolBottomBar = function ToolBottomBar(props) {
230
253
  extraNode: /*#__PURE__*/React.createElement(DownOutlined, null)
231
254
  })), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('formatSetting')) && /*#__PURE__*/React.createElement(FormatModal, {
232
255
  onApply: handleApply,
233
- initialSettings: defaultFormatSetting
256
+ initialSettings: defaultSetting === null || defaultSetting === void 0 ? void 0 : defaultSetting.formatSetting
234
257
  }, getStatusBarItem({
235
258
  icon: /*#__PURE__*/React.createElement(SettingOutlined, null),
236
259
  content: '格式设置'
package/es/type.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { FormatSettings } from './tools/generateStylesFromSettings';
3
2
  interface IUeditorStype extends React.CSSProperties {
4
3
  toolbarColor?: string;
5
4
  }
@@ -110,13 +109,13 @@ export interface ILcdpUeditorProps {
110
109
  */
111
110
  prefixCls?: string;
112
111
  /**
113
- * 格式设置变化
112
+ * 设置变化
114
113
  */
115
- onFormatChange?(val: FormatSettings): void;
114
+ onSettingChange?(val: Record<Required<ILcdpUeditorProps>['bottomTypes'][number], any>): void;
116
115
  /**
117
- * 默认格式设置
116
+ * 默认设置
118
117
  */
119
- defaultFormatSetting?: FormatSettings;
118
+ defaultSetting?: Record<Required<ILcdpUeditorProps>['bottomTypes'][number], any>;
120
119
  /**
121
120
  * 底部功能类型
122
121
  */
package/es/type.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE,UAAU,aAAc,SAAQ,KAAK,CAAC,aAAa;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,iBAAiB;IAE9B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,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;IAEf;;;OAGG;IACH,QAAQ,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAE7F;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;IAEjF;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,CAAC,CAAC;CAC3H;AAGD,MAAM,WAAW,gBAAgB;IAE7B;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtD;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,IAAI,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC;IAEnB;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;IAEhB;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;CAC3B"}
@@ -40,6 +40,7 @@ var import_UeditorResourceLoader = __toESM(require("./tools/UeditorResourceLoade
40
40
  var import_debounce = __toESM(require("lodash/debounce"));
41
41
  var import_filterHtmlNode = require("./tools/filterHtmlNode");
42
42
  var import_ToolBottomBar = __toESM(require("./ToolBottomBar"));
43
+ var BOTTOM_STATUS_BAR_CLASS = "ueditor-bottom-bar-with-status";
43
44
  var LcdpUeditor = class extends import_react.default.Component {
44
45
  constructor(props) {
45
46
  super(props);
@@ -85,7 +86,7 @@ var LcdpUeditor = class extends import_react.default.Component {
85
86
  * 编辑器配置项
86
87
  */
87
88
  this.editorConfig = {};
88
- const { config, prefixCls, onFormatChange } = props;
89
+ const { config, prefixCls, onSettingChange } = props;
89
90
  this.containerId = `ueditor_${Date.now()}_${String(Math.random()).slice(2, 6)}`;
90
91
  if (this.props.ueditorPath) {
91
92
  this.ueditorPath = this.props.ueditorPath;
@@ -121,7 +122,7 @@ var LcdpUeditor = class extends import_react.default.Component {
121
122
  uploadFunction: this.uploadFunction,
122
123
  initialContent: "",
123
124
  pasteplain: (config == null ? void 0 : config.pasteplain) === true,
124
- onFormatChange,
125
+ onSettingChange,
125
126
  exportFileName: (config == null ? void 0 : config.exportFileName) || "未命名"
126
127
  };
127
128
  this.debounceContentChange = (0, import_debounce.default)(this.onContentChange.bind(this), 300);
@@ -146,7 +147,7 @@ var LcdpUeditor = class extends import_react.default.Component {
146
147
  }
147
148
  componentDidUpdate(prevProps) {
148
149
  var _a, _b, _c;
149
- if (this.state.isReady && (prevProps.defaultFormatSetting !== this.props.defaultFormatSetting || prevProps.bottomTypes !== this.props.bottomTypes || ((_a = prevProps == null ? void 0 : prevProps.config) == null ? void 0 : _a.exportFileName) !== ((_c = (_b = this.props) == null ? void 0 : _b.config) == null ? void 0 : _c.exportFileName))) {
150
+ if (this.state.isReady && (prevProps.defaultSetting !== this.props.defaultSetting || prevProps.bottomTypes !== this.props.bottomTypes || ((_a = prevProps == null ? void 0 : prevProps.config) == null ? void 0 : _a.exportFileName) !== ((_c = (_b = this.props) == null ? void 0 : _b.config) == null ? void 0 : _c.exportFileName))) {
150
151
  this.renderStatusBar();
151
152
  }
152
153
  }
@@ -319,8 +320,8 @@ var LcdpUeditor = class extends import_react.default.Component {
319
320
  ueditorInst: this.ueditorInst,
320
321
  prefixCls: this.prefixCls,
321
322
  containerRef: this.containerRef,
322
- defaultFormatSetting: this.props.defaultFormatSetting,
323
- onFormatChange: this.editorConfig.onFormatChange,
323
+ defaultSetting: this.props.defaultSetting,
324
+ onSettingChange: this.editorConfig.onSettingChange,
324
325
  isReady: this.state.isReady,
325
326
  bottomTypes: this.props.bottomTypes,
326
327
  exportFileName: (_c = (_b = this.props) == null ? void 0 : _b.config) == null ? void 0 : _c.exportFileName
@@ -328,9 +329,9 @@ var LcdpUeditor = class extends import_react.default.Component {
328
329
  );
329
330
  if (bottomBarContainer) {
330
331
  let statusContainer = bottomBarContainer.querySelector(`#${id}_bottomStatusBar`);
331
- bottomBarContainer.classList.remove("ueditor-bottom-bar-with-status");
332
+ bottomBarContainer.classList.remove(BOTTOM_STATUS_BAR_CLASS);
332
333
  if ((_d = this.props.bottomTypes) == null ? void 0 : _d.length) {
333
- bottomBarContainer.classList.add("ueditor-bottom-bar-with-status");
334
+ bottomBarContainer.classList.add(BOTTOM_STATUS_BAR_CLASS);
334
335
  if (!statusContainer) {
335
336
  statusContainer = document.createElement("div");
336
337
  statusContainer.id = `${id}_bottomStatusBar`;
@@ -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
  */
@@ -53,7 +53,7 @@ var MENU_OPTIONS = {
53
53
  };
54
54
  var STYLE_ID = "ueditor-custom-styles";
55
55
  var ToolBottomBar = (props) => {
56
- const { ueditorInst, prefixCls, containerRef, defaultFormatSetting, onFormatChange, isReady, bottomTypes, exportFileName } = props;
56
+ const { ueditorInst, prefixCls, containerRef, defaultSetting, onSettingChange, isReady, bottomTypes, exportFileName } = props;
57
57
  const { id: uiId } = ueditorInst.ui || {};
58
58
  const [chineseTextCount, setChineseTextCount] = (0, import_react.useState)(0);
59
59
  const [totalTextCount, setTotalTextCount] = (0, import_react.useState)(0);
@@ -62,6 +62,7 @@ var ToolBottomBar = (props) => {
62
62
  const [pageWidth, setPageWidth] = (0, import_react.useState)(void 0);
63
63
  const timer = (0, import_react.useRef)(void 0);
64
64
  const progressModalRef = (0, import_react.useRef)(null);
65
+ const [formatSetting, setFormatSetting] = (0, import_react.useState)(void 0);
65
66
  const debounceContentChange = (0, import_debounce.default)(() => {
66
67
  var _a;
67
68
  try {
@@ -136,15 +137,50 @@ var ToolBottomBar = (props) => {
136
137
  }
137
138
  styleEl.textContent = cssStyles;
138
139
  }
140
+ setFormatSetting(settings);
139
141
  if (isUpdate) {
140
- onFormatChange == null ? void 0 : onFormatChange(settings);
142
+ onSettingChange == null ? void 0 : onSettingChange({
143
+ formatSetting: settings,
144
+ pageWidth
145
+ });
146
+ }
147
+ };
148
+ (0, import_react.useEffect)(() => {
149
+ if (defaultSetting == null ? void 0 : defaultSetting.formatSetting) {
150
+ handleApply(defaultSetting.formatSetting, false);
151
+ }
152
+ }, [defaultSetting == null ? void 0 : defaultSetting.formatSetting]);
153
+ const handlePageWidthChange = (key, isUpdate = true) => {
154
+ const newClass = `ueditor-rich-status-content-${key}`;
155
+ const oldClass = `ueditor-rich-status-content-${pageWidth}`;
156
+ if (containerRef == null ? void 0 : containerRef.current) {
157
+ const frame = containerRef.current.querySelector(`#${uiId}_iframeholder`);
158
+ const frameContainer = ueditorInst.container || containerRef.current.querySelector(`#${uiId}`);
159
+ if (frame) {
160
+ frame.classList.remove(oldClass);
161
+ frame.classList.add(newClass);
162
+ }
163
+ if (frameContainer) {
164
+ if (key === "a0") {
165
+ frameContainer.classList.remove("ueditor-rich-status-not-full");
166
+ } else {
167
+ frameContainer.classList.add("ueditor-rich-status-not-full");
168
+ }
169
+ }
170
+ }
171
+ setPageWidth(key);
172
+ if (isUpdate) {
173
+ onSettingChange == null ? void 0 : onSettingChange({
174
+ pageWidth: key,
175
+ formatSetting
176
+ });
141
177
  }
142
178
  };
143
179
  (0, import_react.useEffect)(() => {
144
- if (defaultFormatSetting) {
145
- handleApply(defaultFormatSetting, false);
180
+ if (defaultSetting == null ? void 0 : defaultSetting.pageWidth) {
181
+ handlePageWidthChange(defaultSetting.pageWidth, false);
146
182
  }
147
- }, [defaultFormatSetting]);
183
+ }, [defaultSetting == null ? void 0 : defaultSetting.pageWidth]);
148
184
  const onProgress = (progress, title) => {
149
185
  var _a;
150
186
  (_a = progressModalRef.current) == null ? void 0 : _a.updateProgress(progress, title);
@@ -165,24 +201,7 @@ var ToolBottomBar = (props) => {
165
201
  import_antd.Menu,
166
202
  {
167
203
  onClick: ({ key }) => {
168
- const newClass = `ueditor-rich-status-content-${key}`;
169
- const oldClass = `ueditor-rich-status-content-${pageWidth}`;
170
- if (containerRef == null ? void 0 : containerRef.current) {
171
- const frame = containerRef.current.querySelector(`#${uiId}_iframeholder`);
172
- const frameContainer = ueditorInst.container || containerRef.current.querySelector(`#${uiId}`);
173
- if (frame) {
174
- frame.classList.remove(oldClass);
175
- frame.classList.add(newClass);
176
- }
177
- if (frameContainer) {
178
- if (key === "a0") {
179
- frameContainer.classList.remove("ueditor-rich-status-not-full");
180
- } else {
181
- frameContainer.classList.add("ueditor-rich-status-not-full");
182
- }
183
- }
184
- }
185
- setPageWidth(key);
204
+ handlePageWidthChange(key);
186
205
  }
187
206
  },
188
207
  Object.keys(MENU_OPTIONS).map((k) => /* @__PURE__ */ import_react.default.createElement(import_antd.Menu.Item, { key: k }, /* @__PURE__ */ import_react.default.createElement("span", null, "页面宽度 ", MENU_OPTIONS[k])))
@@ -196,7 +215,7 @@ var ToolBottomBar = (props) => {
196
215
  import_FormatModal.default,
197
216
  {
198
217
  onApply: handleApply,
199
- initialSettings: defaultFormatSetting
218
+ initialSettings: defaultSetting == null ? void 0 : defaultSetting.formatSetting
200
219
  },
201
220
  getStatusBarItem({
202
221
  icon: /* @__PURE__ */ import_react.default.createElement(import_icons.SettingOutlined, null),
package/lib/type.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { FormatSettings } from './tools/generateStylesFromSettings';
3
2
  interface IUeditorStype extends React.CSSProperties {
4
3
  toolbarColor?: string;
5
4
  }
@@ -110,13 +109,13 @@ export interface ILcdpUeditorProps {
110
109
  */
111
110
  prefixCls?: string;
112
111
  /**
113
- * 格式设置变化
112
+ * 设置变化
114
113
  */
115
- onFormatChange?(val: FormatSettings): void;
114
+ onSettingChange?(val: Record<Required<ILcdpUeditorProps>['bottomTypes'][number], any>): void;
116
115
  /**
117
- * 默认格式设置
116
+ * 默认设置
118
117
  */
119
- defaultFormatSetting?: FormatSettings;
118
+ defaultSetting?: Record<Required<ILcdpUeditorProps>['bottomTypes'][number], any>;
120
119
  /**
121
120
  * 底部功能类型
122
121
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/lcdp-ueditor-react",
3
- "version": "1.0.4-alpha.1",
3
+ "version": "1.0.4-alpha.2",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",