@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.16 → 1.0.3-alpha.18

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.
@@ -59,15 +59,10 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
59
59
  constructor(props: ILcdpUeditorProps);
60
60
  componentDidMount(): void;
61
61
  componentWillReceiveProps(nextProps: ILcdpUeditorProps): void;
62
+ componentDidUpdate(prevProps: Readonly<ILcdpUeditorProps>): void;
62
63
  componentWillUnmount(): void;
63
64
  private onContentChange;
64
65
  private getExtString;
65
- getStatusBarItem: (params: {
66
- icon: React.ReactNode;
67
- content: React.ReactNode;
68
- onClick?: () => void;
69
- extraNode?: React.ReactNode;
70
- }) => JSX.Element;
71
66
  private initConfig;
72
67
  /**
73
68
  * 文件选择
@@ -0,0 +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;IAMhE,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;IA6Bf,MAAM,IAAI,KAAK,CAAC,SAAS;CAY1B;AAED,eAAe,WAAW,CAAC"}
package/es/LcdpUeditor.js CHANGED
@@ -80,20 +80,6 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
80
80
  * 编辑器配置项
81
81
  */
82
82
  _defineProperty(_assertThisInitialized(_this), "editorConfig", {});
83
- _defineProperty(_assertThisInitialized(_this), "getStatusBarItem", function (params) {
84
- var icon = params.icon,
85
- content = params.content,
86
- onClick = params.onClick,
87
- extraNode = params.extraNode;
88
- return /*#__PURE__*/React.createElement("span", {
89
- className: "ueditor-rich-status-bar-item",
90
- onClick: onClick
91
- }, /*#__PURE__*/React.createElement("span", {
92
- className: "ueditor-rich-status-bar-icon"
93
- }, icon), /*#__PURE__*/React.createElement("span", {
94
- className: "ueditor-rich-status-bar-content"
95
- }, content), extraNode);
96
- });
97
83
  var config = props.config,
98
84
  prefixCls = props.prefixCls,
99
85
  onFormatChange = props.onFormatChange;
@@ -135,7 +121,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
135
121
  uploadFunction: _this.uploadFunction,
136
122
  initialContent: '',
137
123
  pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true,
138
- onFormatChange: onFormatChange
124
+ onFormatChange: onFormatChange,
125
+ exportFileName: (config === null || config === void 0 ? void 0 : config.exportFileName) || '未命名'
139
126
  });
140
127
  _this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
141
128
  return _this;
@@ -163,6 +150,13 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
163
150
  }
164
151
  }
165
152
  }
153
+ }, {
154
+ key: "componentDidUpdate",
155
+ value: function componentDidUpdate(prevProps) {
156
+ if (this.state.isReady && prevProps.defaultFormatSetting !== this.props.defaultFormatSetting) {
157
+ this.renderStatusBar();
158
+ }
159
+ }
166
160
  }, {
167
161
  key: "componentWillUnmount",
168
162
  value: function componentWillUnmount() {
@@ -413,8 +407,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
413
407
  }, {
414
408
  key: "renderStatusBar",
415
409
  value: function renderStatusBar() {
416
- var _this$containerRef$cu, _this$props$bottomTyp;
417
- var bottomBarContainer = (_this$containerRef$cu = this.containerRef.current) === null || _this$containerRef$cu === void 0 ? void 0 : _this$containerRef$cu.querySelector('#edui1_bottombar');
410
+ var _this$containerRef$cu, _this$props, _this$props$bottomTyp;
411
+ var _ref4 = this.ueditorInst.ui || {},
412
+ id = _ref4.id;
413
+ var bottomBarContainer = (_this$containerRef$cu = this.containerRef.current) === null || _this$containerRef$cu === void 0 ? void 0 : _this$containerRef$cu.querySelector("#".concat(id, "_bottombar"));
418
414
  var comp = /*#__PURE__*/React.createElement(ToolBottomBar, {
419
415
  ueditorInst: this.ueditorInst,
420
416
  prefixCls: this.prefixCls,
@@ -422,10 +418,20 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
422
418
  defaultFormatSetting: this.props.defaultFormatSetting,
423
419
  onFormatChange: this.editorConfig.onFormatChange,
424
420
  isReady: this.state.isReady,
425
- bottomTypes: this.props.bottomTypes
421
+ bottomTypes: this.props.bottomTypes,
422
+ 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
426
423
  });
427
424
  if (bottomBarContainer && (_this$props$bottomTyp = this.props.bottomTypes) !== null && _this$props$bottomTyp !== void 0 && _this$props$bottomTyp.length) {
428
- ReactDOM.render(comp, bottomBarContainer);
425
+ if (!bottomBarContainer.classList.contains('ueditor-bottom-bar-with-status')) {
426
+ bottomBarContainer.classList.add('ueditor-bottom-bar-with-status');
427
+ }
428
+ var statusContainer = bottomBarContainer.querySelector("#".concat(id, "_bottomStatusBar"));
429
+ if (!statusContainer) {
430
+ statusContainer = document.createElement('div');
431
+ statusContainer.id = "".concat(id, "_bottomStatusBar");
432
+ bottomBarContainer.appendChild(statusContainer);
433
+ }
434
+ ReactDOM.render(comp, statusContainer);
429
435
  }
430
436
  }
431
437
  }, {
@@ -0,0 +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;AA6LD,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CA8JpF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;CAClC;AAGD,QAAA,MAAM,aAAa,6FAkCjB,CAAC;AAIH,eAAe,aAAa,CAAC"}
@@ -3,12 +3,31 @@ import { FormatSettings } from '../tools/generateStylesFromSettings';
3
3
  import './index.less';
4
4
  import { ILcdpUeditorProps } from '../type';
5
5
  declare const ToolBottomBar: (props: {
6
+ /**
7
+ * 编辑器实例
8
+ */
6
9
  ueditorInst: any;
10
+ /**
11
+ * 前缀类名
12
+ */
7
13
  prefixCls?: string | undefined;
14
+ /**
15
+ * 容器引用
16
+ */
8
17
  containerRef?: React.RefObject<HTMLDivElement> | undefined;
9
18
  defaultFormatSetting?: FormatSettings | undefined;
10
19
  onFormatChange?: ((val: FormatSettings) => void) | undefined;
20
+ /**
21
+ * 是否准备就绪
22
+ */
11
23
  isReady?: boolean | undefined;
24
+ /**
25
+ * 底部功能类型
26
+ */
12
27
  bottomTypes?: ILcdpUeditorProps['bottomTypes'];
28
+ /**
29
+ * 导出文件名
30
+ */
31
+ exportFileName?: string | undefined;
13
32
  }) => JSX.Element;
14
33
  export default ToolBottomBar;
@@ -0,0 +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"}
@@ -28,7 +28,10 @@ var ToolBottomBar = function ToolBottomBar(props) {
28
28
  defaultFormatSetting = props.defaultFormatSetting,
29
29
  onFormatChange = props.onFormatChange,
30
30
  isReady = props.isReady,
31
- bottomTypes = props.bottomTypes;
31
+ bottomTypes = props.bottomTypes,
32
+ exportFileName = props.exportFileName;
33
+ var _ref = ueditorInst.ui || {},
34
+ uiId = _ref.id;
32
35
  var _useState = useState(0),
33
36
  _useState2 = _slicedToArray(_useState, 2),
34
37
  chineseTextCount = _useState2[0],
@@ -139,11 +142,12 @@ var ToolBottomBar = function ToolBottomBar(props) {
139
142
  */
140
143
  var handleApply = function handleApply(settings) {
141
144
  var _containerRef$current, _contentDocument;
145
+ var isUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
142
146
  // 生成样式
143
147
  var cssStyles = generateStylesFromSettings(settings);
144
148
 
145
149
  // 触发编辑器视图更新
146
- var frame = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector('#edui1_iframeholder > iframe');
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")));
147
151
  if (frame !== null && frame !== void 0 && (_contentDocument = frame.contentDocument) !== null && _contentDocument !== void 0 && _contentDocument.documentElement) {
148
152
  var _contentDocument2;
149
153
  // 查找或创建样式元素
@@ -156,11 +160,13 @@ var ToolBottomBar = function ToolBottomBar(props) {
156
160
  // 设置样式内容
157
161
  styleEl.textContent = cssStyles;
158
162
  }
159
- onFormatChange === null || onFormatChange === void 0 || onFormatChange(settings);
163
+ if (isUpdate) {
164
+ onFormatChange === null || onFormatChange === void 0 || onFormatChange(settings);
165
+ }
160
166
  };
161
167
  useEffect(function () {
162
168
  if (defaultFormatSetting) {
163
- handleApply(defaultFormatSetting);
169
+ handleApply(defaultFormatSetting, false);
164
170
  }
165
171
  }, [defaultFormatSetting]);
166
172
  var onProgress = function onProgress(progress, title) {
@@ -192,14 +198,14 @@ var ToolBottomBar = function ToolBottomBar(props) {
192
198
  }, (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('pageWidth')) && /*#__PURE__*/React.createElement(Dropdown, {
193
199
  trigger: ['click'],
194
200
  overlay: /*#__PURE__*/React.createElement(Menu, {
195
- onClick: function onClick(_ref) {
196
- var key = _ref.key;
201
+ onClick: function onClick(_ref2) {
202
+ var key = _ref2.key;
197
203
  // 设置编辑器宽度
198
204
  var newClass = "ueditor-rich-status-content-".concat(key);
199
205
  var oldClass = "ueditor-rich-status-content-".concat(pageWidth);
200
206
  if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
201
- var frame = containerRef.current.querySelector('#edui1_iframeholder');
202
- var frameContainer = containerRef.current.querySelector('#edui1');
207
+ var frame = containerRef.current.querySelector("#".concat(uiId, "_iframeholder"));
208
+ var frameContainer = ueditorInst.container || containerRef.current.querySelector("#".concat(uiId));
203
209
  if (frame) {
204
210
  frame.classList.remove(oldClass);
205
211
  frame.classList.add(newClass);
@@ -258,13 +264,13 @@ var ToolBottomBar = function ToolBottomBar(props) {
258
264
  _context.next = 7;
259
265
  break;
260
266
  }
261
- frame = containerRef.current.querySelector('#edui1_iframeholder > iframe');
267
+ frame = ueditorInst.frame || containerRef.current.querySelector("#".concat(uiId, "_iframeholder > iframe"));
262
268
  if (!(frame !== null && frame !== void 0 && (_contentDocument3 = frame.contentDocument) !== null && _contentDocument3 !== void 0 && _contentDocument3.body)) {
263
269
  _context.next = 6;
264
270
  break;
265
271
  }
266
272
  _context.next = 5;
267
- return domloadPdf(frame === null || frame === void 0 || (_contentDocument4 = frame.contentDocument) === null || _contentDocument4 === void 0 ? void 0 : _contentDocument4.body, pageWidth || 'a0', '未命名', onProgress);
273
+ return domloadPdf(frame === null || frame === void 0 || (_contentDocument4 = frame.contentDocument) === null || _contentDocument4 === void 0 ? void 0 : _contentDocument4.body, pageWidth || 'a0', exportFileName, onProgress);
268
274
  case 5:
269
275
  onProgress(100, '导出完成');
270
276
  case 6:
@@ -1,3 +1,8 @@
1
+ .ueditor-bottom-bar-with-status {
2
+ .edui-default {
3
+ display: none;
4
+ }
5
+ }
1
6
  .ueditor-rich-status-bar {
2
7
  display: flex;
3
8
  align-items: center;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["const.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;8BAMR,MAAM;CAChC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportPDF.d.ts","sourceRoot":"","sources":["ExportPDF.tsx"],"names":[],"mappings":";AAEA,QAAA,MAAM,UAAU,mBAoBf,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextCopy.d.ts","sourceRoot":"","sources":["TextCopy.tsx"],"names":[],"mappings":";AAEA,QAAA,MAAM,QAAQ,mBAIb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextFileIcon.d.ts","sourceRoot":"","sources":["TextFileIcon.tsx"],"names":[],"mappings":";AAEA,QAAA,MAAM,QAAQ,mBAIb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextIcon.d.ts","sourceRoot":"","sources":["TextIcon.tsx"],"names":[],"mappings":";AAEA,QAAA,MAAM,QAAQ,mBAIb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EACL,WAAW,EACX,iBAAiB,GAClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UeditorResourceLoader.d.ts","sourceRoot":"","sources":["UeditorResourceLoader.ts"],"names":[],"mappings":"AAGA,cAAM,qBAAqB;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAwB;IAG/C,OAAO,CAAC,MAAM,CAAC,aAAa;IAI5B,OAAO,CAAC,YAAY,CAAkB;IAEtC,OAAO,CAAC,iBAAiB,CAAkB;IAE3C,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,SAAS,CAAkB;WAEf,SAAS,CAAE,MAAM,EAAE,MAAM,EAAE;WAgCjC,WAAW;IAWzB;;;OAGG;WACW,OAAO,CAAC,QAAQ,EAAE,QAAQ;IASxC;;;OAGG;WACW,WAAW,CAAC,QAAQ,EAAE,QAAQ;CAI7C;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportPDF.d.ts","sourceRoot":"","sources":["exportPDF.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,gBAAuB,WAAW,YAAW;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;QACvC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QACjC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;KACpC,CAAA;CACF,2BACsB,MAAM,SAAS,MAAM,KAAK,IAAI,+BAiDpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,QAAe,WAAW,aAAa,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,aAAY,MAAM,2BAChF,MAAM,SAAS,MAAM,KAAK,IAAI,+BAatD,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterHtmlNode.d.ts","sourceRoot":"","sources":["filterHtmlNode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAS,MAAM;;;;CA2CzC,CAAC"}
@@ -0,0 +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;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,aAAc,cAAc,KAAG,MAuDrE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["loadScript.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,cAAc,SAAgB,MAAM,EAAE,kBAUlD,CAAC"}
package/es/type.d.ts CHANGED
@@ -69,6 +69,10 @@ export interface ILcdpUeditorProps {
69
69
  */
70
70
  videoAllowFiles?: string[];
71
71
  maximumWords?: number;
72
+ /**
73
+ * 导出文件名
74
+ */
75
+ exportFileName?: string;
72
76
  };
73
77
  toolbars?: string[][];
74
78
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["type.ts"],"names":[],"mappings":"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"}
@@ -59,15 +59,10 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
59
59
  constructor(props: ILcdpUeditorProps);
60
60
  componentDidMount(): void;
61
61
  componentWillReceiveProps(nextProps: ILcdpUeditorProps): void;
62
+ componentDidUpdate(prevProps: Readonly<ILcdpUeditorProps>): void;
62
63
  componentWillUnmount(): void;
63
64
  private onContentChange;
64
65
  private getExtString;
65
- getStatusBarItem: (params: {
66
- icon: React.ReactNode;
67
- content: React.ReactNode;
68
- onClick?: () => void;
69
- extraNode?: React.ReactNode;
70
- }) => JSX.Element;
71
66
  private initConfig;
72
67
  /**
73
68
  * 文件选择
@@ -85,10 +85,6 @@ var LcdpUeditor = class extends import_react.default.Component {
85
85
  * 编辑器配置项
86
86
  */
87
87
  this.editorConfig = {};
88
- this.getStatusBarItem = (params) => {
89
- const { icon, content, onClick, extraNode } = params;
90
- return /* @__PURE__ */ import_react.default.createElement("span", { className: "ueditor-rich-status-bar-item", onClick }, /* @__PURE__ */ import_react.default.createElement("span", { className: "ueditor-rich-status-bar-icon" }, icon), /* @__PURE__ */ import_react.default.createElement("span", { className: "ueditor-rich-status-bar-content" }, content), extraNode);
91
- };
92
88
  const { config, prefixCls, onFormatChange } = props;
93
89
  this.containerId = `ueditor_${Date.now()}_${String(Math.random()).slice(2, 6)}`;
94
90
  if (this.props.ueditorPath) {
@@ -125,7 +121,8 @@ var LcdpUeditor = class extends import_react.default.Component {
125
121
  uploadFunction: this.uploadFunction,
126
122
  initialContent: "",
127
123
  pasteplain: (config == null ? void 0 : config.pasteplain) === true,
128
- onFormatChange
124
+ onFormatChange,
125
+ exportFileName: (config == null ? void 0 : config.exportFileName) || "未命名"
129
126
  };
130
127
  this.debounceContentChange = (0, import_debounce.default)(this.onContentChange.bind(this), 300);
131
128
  }
@@ -147,6 +144,11 @@ var LcdpUeditor = class extends import_react.default.Component {
147
144
  }
148
145
  }
149
146
  }
147
+ componentDidUpdate(prevProps) {
148
+ if (this.state.isReady && prevProps.defaultFormatSetting !== this.props.defaultFormatSetting) {
149
+ this.renderStatusBar();
150
+ }
151
+ }
150
152
  componentWillUnmount() {
151
153
  var _a, _b, _c;
152
154
  if (this.state.isReady) {
@@ -307,8 +309,9 @@ var LcdpUeditor = class extends import_react.default.Component {
307
309
  * 渲染状态栏
308
310
  */
309
311
  renderStatusBar() {
310
- var _a, _b;
311
- const bottomBarContainer = (_a = this.containerRef.current) == null ? void 0 : _a.querySelector("#edui1_bottombar");
312
+ var _a, _b, _c, _d;
313
+ const { id } = this.ueditorInst.ui || {};
314
+ const bottomBarContainer = (_a = this.containerRef.current) == null ? void 0 : _a.querySelector(`#${id}_bottombar`);
312
315
  const comp = /* @__PURE__ */ import_react.default.createElement(
313
316
  import_ToolBottomBar.default,
314
317
  {
@@ -318,11 +321,21 @@ var LcdpUeditor = class extends import_react.default.Component {
318
321
  defaultFormatSetting: this.props.defaultFormatSetting,
319
322
  onFormatChange: this.editorConfig.onFormatChange,
320
323
  isReady: this.state.isReady,
321
- bottomTypes: this.props.bottomTypes
324
+ bottomTypes: this.props.bottomTypes,
325
+ exportFileName: (_c = (_b = this.props) == null ? void 0 : _b.config) == null ? void 0 : _c.exportFileName
322
326
  }
323
327
  );
324
- if (bottomBarContainer && ((_b = this.props.bottomTypes) == null ? void 0 : _b.length)) {
325
- import_react_dom.default.render(comp, bottomBarContainer);
328
+ if (bottomBarContainer && ((_d = this.props.bottomTypes) == null ? void 0 : _d.length)) {
329
+ if (!bottomBarContainer.classList.contains("ueditor-bottom-bar-with-status")) {
330
+ bottomBarContainer.classList.add("ueditor-bottom-bar-with-status");
331
+ }
332
+ let statusContainer = bottomBarContainer.querySelector(`#${id}_bottomStatusBar`);
333
+ if (!statusContainer) {
334
+ statusContainer = document.createElement("div");
335
+ statusContainer.id = `${id}_bottomStatusBar`;
336
+ bottomBarContainer.appendChild(statusContainer);
337
+ }
338
+ import_react_dom.default.render(comp, statusContainer);
326
339
  }
327
340
  }
328
341
  render() {
@@ -3,12 +3,31 @@ import { FormatSettings } from '../tools/generateStylesFromSettings';
3
3
  import './index.less';
4
4
  import { ILcdpUeditorProps } from '../type';
5
5
  declare const ToolBottomBar: (props: {
6
+ /**
7
+ * 编辑器实例
8
+ */
6
9
  ueditorInst: any;
10
+ /**
11
+ * 前缀类名
12
+ */
7
13
  prefixCls?: string | undefined;
14
+ /**
15
+ * 容器引用
16
+ */
8
17
  containerRef?: React.RefObject<HTMLDivElement> | undefined;
9
18
  defaultFormatSetting?: FormatSettings | undefined;
10
19
  onFormatChange?: ((val: FormatSettings) => void) | undefined;
20
+ /**
21
+ * 是否准备就绪
22
+ */
11
23
  isReady?: boolean | undefined;
24
+ /**
25
+ * 底部功能类型
26
+ */
12
27
  bottomTypes?: ILcdpUeditorProps['bottomTypes'];
28
+ /**
29
+ * 导出文件名
30
+ */
31
+ exportFileName?: string | undefined;
13
32
  }) => JSX.Element;
14
33
  export default ToolBottomBar;
@@ -53,7 +53,8 @@ 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 } = props;
56
+ const { ueditorInst, prefixCls, containerRef, defaultFormatSetting, onFormatChange, isReady, bottomTypes, exportFileName } = props;
57
+ const { id: uiId } = ueditorInst.ui || {};
57
58
  const [chineseTextCount, setChineseTextCount] = (0, import_react.useState)(0);
58
59
  const [totalTextCount, setTotalTextCount] = (0, import_react.useState)(0);
59
60
  const [innerFullScreen, setInnerFullScreen] = (0, import_react.useState)(false);
@@ -122,10 +123,10 @@ var ToolBottomBar = (props) => {
122
123
  }, 1e3);
123
124
  }
124
125
  };
125
- const handleApply = (settings) => {
126
+ const handleApply = (settings, isUpdate = true) => {
126
127
  var _a, _b, _c;
127
128
  const cssStyles = (0, import_generateStylesFromSettings.generateStylesFromSettings)(settings);
128
- const frame = (_a = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a.querySelector("#edui1_iframeholder > iframe");
129
+ const frame = ueditorInst.frame || ((_a = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a.querySelector(`#${uiId}_iframeholder > iframe`));
129
130
  if ((_b = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _b.documentElement) {
130
131
  let styleEl = (_c = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _c.getElementById(STYLE_ID);
131
132
  if (!styleEl) {
@@ -135,11 +136,13 @@ var ToolBottomBar = (props) => {
135
136
  }
136
137
  styleEl.textContent = cssStyles;
137
138
  }
138
- onFormatChange == null ? void 0 : onFormatChange(settings);
139
+ if (isUpdate) {
140
+ onFormatChange == null ? void 0 : onFormatChange(settings);
141
+ }
139
142
  };
140
143
  (0, import_react.useEffect)(() => {
141
144
  if (defaultFormatSetting) {
142
- handleApply(defaultFormatSetting);
145
+ handleApply(defaultFormatSetting, false);
143
146
  }
144
147
  }, [defaultFormatSetting]);
145
148
  const onProgress = (progress, title) => {
@@ -165,8 +168,8 @@ var ToolBottomBar = (props) => {
165
168
  const newClass = `ueditor-rich-status-content-${key}`;
166
169
  const oldClass = `ueditor-rich-status-content-${pageWidth}`;
167
170
  if (containerRef == null ? void 0 : containerRef.current) {
168
- const frame = containerRef.current.querySelector("#edui1_iframeholder");
169
- const frameContainer = containerRef.current.querySelector("#edui1");
171
+ const frame = containerRef.current.querySelector(`#${uiId}_iframeholder`);
172
+ const frameContainer = ueditorInst.container || containerRef.current.querySelector(`#${uiId}`);
170
173
  if (frame) {
171
174
  frame.classList.remove(oldClass);
172
175
  frame.classList.add(newClass);
@@ -216,9 +219,9 @@ var ToolBottomBar = (props) => {
216
219
  onClick: async () => {
217
220
  var _a, _b;
218
221
  if (containerRef == null ? void 0 : containerRef.current) {
219
- const frame = containerRef.current.querySelector("#edui1_iframeholder > iframe");
222
+ const frame = ueditorInst.frame || containerRef.current.querySelector(`#${uiId}_iframeholder > iframe`);
220
223
  if ((_a = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _a.body) {
221
- await (0, import_exportPDF.domloadPdf)((_b = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _b.body, pageWidth || "a0", "未命名", onProgress);
224
+ await (0, import_exportPDF.domloadPdf)((_b = frame == null ? void 0 : frame.contentDocument) == null ? void 0 : _b.body, pageWidth || "a0", exportFileName, onProgress);
222
225
  onProgress(100, "导出完成");
223
226
  }
224
227
  setTimeout(() => {
@@ -1,3 +1,8 @@
1
+ .ueditor-bottom-bar-with-status {
2
+ .edui-default {
3
+ display: none;
4
+ }
5
+ }
1
6
  .ueditor-rich-status-bar {
2
7
  display: flex;
3
8
  align-items: center;
package/lib/type.d.ts CHANGED
@@ -69,6 +69,10 @@ export interface ILcdpUeditorProps {
69
69
  */
70
70
  videoAllowFiles?: string[];
71
71
  maximumWords?: number;
72
+ /**
73
+ * 导出文件名
74
+ */
75
+ exportFileName?: string;
72
76
  };
73
77
  toolbars?: string[][];
74
78
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/lcdp-ueditor-react",
3
- "version": "1.0.3-alpha.16",
3
+ "version": "1.0.3-alpha.18",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",