@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.9 → 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.
Files changed (67) hide show
  1. package/es/LcdpUeditor.d.ts +10 -4
  2. package/es/LcdpUeditor.d.ts.map +1 -0
  3. package/es/LcdpUeditor.js +78 -11
  4. package/es/ToolBottomBar/FormatModal/index.d.ts +9 -0
  5. package/es/ToolBottomBar/FormatModal/index.d.ts.map +1 -0
  6. package/es/ToolBottomBar/FormatModal/index.js +543 -0
  7. package/es/ToolBottomBar/FormatModal/index.less +276 -0
  8. package/es/ToolBottomBar/ProgressModal/index.d.ts +10 -0
  9. package/es/ToolBottomBar/ProgressModal/index.d.ts.map +1 -0
  10. package/es/ToolBottomBar/ProgressModal/index.js +53 -0
  11. package/es/ToolBottomBar/ProgressModal/index.less +16 -0
  12. package/es/ToolBottomBar/index.d.ts +32 -0
  13. package/es/ToolBottomBar/index.d.ts.map +1 -0
  14. package/es/ToolBottomBar/index.js +319 -0
  15. package/es/ToolBottomBar/index.less +75 -0
  16. package/es/const.d.ts.map +1 -0
  17. package/es/icon/ExportPDF.d.ts +3 -0
  18. package/es/icon/ExportPDF.d.ts.map +1 -0
  19. package/es/icon/ExportPDF.js +24 -0
  20. package/es/icon/TextCopy.d.ts +3 -0
  21. package/es/icon/TextCopy.d.ts.map +1 -0
  22. package/es/icon/TextCopy.js +25 -0
  23. package/es/icon/TextFileIcon.d.ts +3 -0
  24. package/es/icon/TextFileIcon.d.ts.map +1 -0
  25. package/es/icon/TextFileIcon.js +26 -0
  26. package/es/icon/TextIcon.d.ts +3 -0
  27. package/es/icon/TextIcon.d.ts.map +1 -0
  28. package/es/icon/TextIcon.js +28 -0
  29. package/es/index.d.ts.map +1 -0
  30. package/es/tools/UeditorResourceLoader.d.ts.map +1 -0
  31. package/es/tools/exportPDF.d.ts +27 -0
  32. package/es/tools/exportPDF.d.ts.map +1 -0
  33. package/es/tools/exportPDF.js +146 -0
  34. package/es/tools/filterHtmlNode.d.ts.map +1 -0
  35. package/es/tools/generateStylesFromSettings.d.ts +38 -0
  36. package/es/tools/generateStylesFromSettings.d.ts.map +1 -0
  37. package/es/tools/generateStylesFromSettings.js +24 -0
  38. package/es/tools/loadScript.d.ts.map +1 -0
  39. package/es/type.d.ts +20 -0
  40. package/es/type.d.ts.map +1 -0
  41. package/lib/LcdpUeditor.d.ts +10 -4
  42. package/lib/LcdpUeditor.js +63 -8
  43. package/lib/ToolBottomBar/FormatModal/index.d.ts +9 -0
  44. package/lib/ToolBottomBar/FormatModal/index.js +261 -0
  45. package/lib/ToolBottomBar/FormatModal/index.less +276 -0
  46. package/lib/ToolBottomBar/ProgressModal/index.d.ts +10 -0
  47. package/lib/ToolBottomBar/ProgressModal/index.js +73 -0
  48. package/lib/ToolBottomBar/ProgressModal/index.less +16 -0
  49. package/lib/ToolBottomBar/index.d.ts +32 -0
  50. package/lib/ToolBottomBar/index.js +254 -0
  51. package/lib/ToolBottomBar/index.less +75 -0
  52. package/lib/icon/ExportPDF.d.ts +3 -0
  53. package/lib/icon/ExportPDF.js +57 -0
  54. package/lib/icon/TextCopy.d.ts +3 -0
  55. package/lib/icon/TextCopy.js +39 -0
  56. package/lib/icon/TextFileIcon.d.ts +3 -0
  57. package/lib/icon/TextFileIcon.js +39 -0
  58. package/lib/icon/TextIcon.d.ts +3 -0
  59. package/lib/icon/TextIcon.js +39 -0
  60. package/lib/tools/exportPDF.d.ts +27 -0
  61. package/lib/tools/exportPDF.js +95 -0
  62. package/lib/tools/generateStylesFromSettings.d.ts +38 -0
  63. package/lib/tools/generateStylesFromSettings.js +77 -0
  64. package/lib/type.d.ts +20 -0
  65. package/package.json +8 -3
  66. package/ueditor-resource/themes/default/css/ueditor.css +1 -1
  67. package/ueditor-resource/ueditor.all.js +1 -1
@@ -37,19 +37,20 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
37
37
  * 上传文件函数
38
38
  */
39
39
  private uploadFunction;
40
- /**
41
- * 是否加载完成
42
- */
43
- private isReady;
44
40
  /**
45
41
  * 保存 compositionend 事件处理器引用
46
42
  */
47
43
  private compositionEndHandler?;
44
+ /**
45
+ * 是否全屏
46
+ */
47
+ private prefixCls;
48
48
  /**
49
49
  * 初始加载失败
50
50
  */
51
51
  state: Readonly<{
52
52
  initError: boolean;
53
+ isReady: boolean;
53
54
  }>;
54
55
  /**
55
56
  * 编辑器配置项
@@ -58,6 +59,7 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
58
59
  constructor(props: ILcdpUeditorProps);
59
60
  componentDidMount(): void;
60
61
  componentWillReceiveProps(nextProps: ILcdpUeditorProps): void;
62
+ componentDidUpdate(prevProps: Readonly<ILcdpUeditorProps>): void;
61
63
  componentWillUnmount(): void;
62
64
  private onContentChange;
63
65
  private getExtString;
@@ -80,6 +82,10 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
80
82
  * 初始化编辑器实例
81
83
  */
82
84
  initUeditor(): Promise<void>;
85
+ /**
86
+ * 渲染状态栏
87
+ */
88
+ renderStatusBar(): void;
83
89
  render(): React.ReactNode;
84
90
  }
85
91
  export default LcdpUeditor;
@@ -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;AAShD,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;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
@@ -8,11 +8,14 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
8
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
10
  import React from 'react';
11
+ import ReactDOM from 'react-dom';
11
12
  import { DEFAULT_UEDITOR_CONFIG, DEFAULT_UEDITOR_PATH } from "./const";
12
13
  import DefaultConfig from "./defaultConfig.json";
13
14
  import UeditorResourceLoader from "./tools/UeditorResourceLoader";
14
15
  import debounce from 'lodash/debounce';
15
16
  import { filterHtmlNode } from "./tools/filterHtmlNode";
17
+ import ToolBottomBar from "./ToolBottomBar";
18
+ var BOTTOM_STATUS_BAR_CLASS = 'ueditor-bottom-bar-with-status';
16
19
  var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
17
20
  _inherits(LcdpUeditor, _React$Component);
18
21
  var _super = _createSuper(LcdpUeditor);
@@ -56,25 +59,31 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
56
59
  * 上传文件函数
57
60
  */
58
61
  _defineProperty(_assertThisInitialized(_this), "uploadFunction", void 0);
59
- /**
60
- * 是否加载完成
61
- */
62
- _defineProperty(_assertThisInitialized(_this), "isReady", false);
63
62
  /**
64
63
  * 保存 compositionend 事件处理器引用
65
64
  */
66
65
  _defineProperty(_assertThisInitialized(_this), "compositionEndHandler", void 0);
66
+ /**
67
+ * 是否全屏
68
+ */
69
+ _defineProperty(_assertThisInitialized(_this), "prefixCls", 'pcfactory');
67
70
  /**
68
71
  * 初始加载失败
69
72
  */
70
73
  _defineProperty(_assertThisInitialized(_this), "state", {
71
- initError: false
74
+ initError: false,
75
+ /**
76
+ * 是否加载完成
77
+ */
78
+ isReady: false
72
79
  });
73
80
  /**
74
81
  * 编辑器配置项
75
82
  */
76
83
  _defineProperty(_assertThisInitialized(_this), "editorConfig", {});
77
- var config = props.config;
84
+ var config = props.config,
85
+ prefixCls = props.prefixCls,
86
+ onSettingChange = props.onSettingChange;
78
87
  _this.containerId = "ueditor_".concat(Date.now(), "_").concat(String(Math.random()).slice(2, 6));
79
88
  if (_this.props.ueditorPath) {
80
89
  _this.ueditorPath = _this.props.ueditorPath;
@@ -102,6 +111,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
102
111
  }
103
112
  return null;
104
113
  };
114
+ _this.prefixCls = prefixCls || 'pcfactory';
105
115
  _this.editorConfig = _objectSpread(_objectSpread({}, DefaultConfig), {}, {
106
116
  maximumWords: (config === null || config === void 0 ? void 0 : config.maximumWords) || 10000,
107
117
  initialFrameHeight: (config === null || config === void 0 ? void 0 : config.height) || 300,
@@ -111,7 +121,9 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
111
121
  },
112
122
  uploadFunction: _this.uploadFunction,
113
123
  initialContent: '',
114
- pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true
124
+ pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true,
125
+ onSettingChange: onSettingChange,
126
+ exportFileName: (config === null || config === void 0 ? void 0 : config.exportFileName) || '未命名'
115
127
  });
116
128
  _this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
117
129
  return _this;
@@ -124,7 +136,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
124
136
  }, {
125
137
  key: "componentWillReceiveProps",
126
138
  value: function componentWillReceiveProps(nextProps) {
127
- if (this.isReady) {
139
+ if (this.state.isReady) {
128
140
  if ('value' in nextProps && this.currentContent !== nextProps.value) {
129
141
  this.isReportFlag = false;
130
142
  this.ueditorInst.setContent(filterHtmlNode(nextProps.value || '').str);
@@ -139,10 +151,18 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
139
151
  }
140
152
  }
141
153
  }
154
+ }, {
155
+ key: "componentDidUpdate",
156
+ value: function componentDidUpdate(prevProps) {
157
+ var _prevProps$config, _this$props;
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))) {
159
+ this.renderStatusBar();
160
+ }
161
+ }
142
162
  }, {
143
163
  key: "componentWillUnmount",
144
164
  value: function componentWillUnmount() {
145
- if (this.isReady) {
165
+ if (this.state.isReady) {
146
166
  var _this$ueditorInst, _this$ueditorInst2, _this$ueditorInst2$de;
147
167
  var editorBody = (_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0 ? void 0 : _this$ueditorInst.body;
148
168
  if (editorBody && this.compositionEndHandler) {
@@ -336,7 +356,9 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
336
356
  if (nextValue) {
337
357
  _this3.ueditorInst.setContent(nextValue);
338
358
  }
339
- _this3.isReady = true;
359
+ _this3.setState({
360
+ isReady: true
361
+ });
340
362
  // 禁用状态设置
341
363
  if (_this3.props.disabled) {
342
364
  _this3.ueditorInst.setDisabled();
@@ -357,6 +379,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
357
379
  }
358
380
  _this3.initStyle();
359
381
  _this3.mountRef();
382
+ _this3.renderStatusBar();
360
383
  });
361
384
  };
362
385
  UeditorResourceLoader.onReady(readyFunc);
@@ -378,7 +401,51 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
378
401
  return _initUeditor.apply(this, arguments);
379
402
  }
380
403
  return initUeditor;
381
- }())
404
+ }()
405
+ /**
406
+ * 渲染状态栏
407
+ */
408
+ )
409
+ }, {
410
+ key: "renderStatusBar",
411
+ value: function renderStatusBar() {
412
+ var _this$containerRef$cu, _this$props2;
413
+ var _ref4 = this.ueditorInst.ui || {},
414
+ id = _ref4.id;
415
+ var bottomBarContainer = (_this$containerRef$cu = this.containerRef.current) === null || _this$containerRef$cu === void 0 ? void 0 : _this$containerRef$cu.querySelector("#".concat(id, "_bottombar"));
416
+ var comp = /*#__PURE__*/React.createElement(ToolBottomBar, {
417
+ ueditorInst: this.ueditorInst,
418
+ prefixCls: this.prefixCls,
419
+ containerRef: this.containerRef,
420
+ defaultSetting: this.props.defaultSetting,
421
+ onSettingChange: this.editorConfig.onSettingChange,
422
+ isReady: this.state.isReady,
423
+ bottomTypes: this.props.bottomTypes,
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
425
+ });
426
+ if (bottomBarContainer) {
427
+ var _this$props$bottomTyp;
428
+ // 获取底部状态组件
429
+ var statusContainer = bottomBarContainer.querySelector("#".concat(id, "_bottomStatusBar"));
430
+ // 移除底部状态栏的样式
431
+ bottomBarContainer.classList.remove(BOTTOM_STATUS_BAR_CLASS);
432
+ // 如果底部状态栏有类型,则添加样式
433
+ if ((_this$props$bottomTyp = this.props.bottomTypes) !== null && _this$props$bottomTyp !== void 0 && _this$props$bottomTyp.length) {
434
+ bottomBarContainer.classList.add(BOTTOM_STATUS_BAR_CLASS);
435
+ // 如果底部状态栏没有组件,则创建组件
436
+ if (!statusContainer) {
437
+ statusContainer = document.createElement('div');
438
+ statusContainer.id = "".concat(id, "_bottomStatusBar");
439
+ bottomBarContainer.appendChild(statusContainer);
440
+ }
441
+ // 渲染组件
442
+ ReactDOM.render(comp, statusContainer);
443
+ } else if (statusContainer) {
444
+ // 如果底部状态栏有类型,但是类型为空,则移除组件
445
+ statusContainer.remove();
446
+ }
447
+ }
448
+ }
382
449
  }, {
383
450
  key: "render",
384
451
  value: function render() {
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { FormatSettings } from '../../tools/generateStylesFromSettings';
4
+ interface FormatSettingsPanelProps {
5
+ onApply: (settings: FormatSettings) => void;
6
+ initialSettings?: Partial<FormatSettings>;
7
+ }
8
+ declare const FormatSettingsPanel: React.FC<React.PropsWithChildren<FormatSettingsPanelProps>>;
9
+ export default FormatSettingsPanel;
@@ -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"}