@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.13 → 1.0.3-alpha.15

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 (49) hide show
  1. package/es/LcdpUeditor.d.ts +15 -4
  2. package/es/LcdpUeditor.js +59 -10
  3. package/es/ToolBottomBar/FormatModal/index.d.ts +9 -0
  4. package/es/ToolBottomBar/FormatModal/index.js +543 -0
  5. package/es/ToolBottomBar/FormatModal/index.less +276 -0
  6. package/es/ToolBottomBar/ProgressModal/index.d.ts +10 -0
  7. package/es/ToolBottomBar/ProgressModal/index.js +53 -0
  8. package/es/ToolBottomBar/ProgressModal/index.less +16 -0
  9. package/es/ToolBottomBar/index.d.ts +14 -0
  10. package/es/ToolBottomBar/index.js +290 -0
  11. package/es/ToolBottomBar/index.less +70 -0
  12. package/es/icon/ExportPDF.d.ts +3 -0
  13. package/es/icon/ExportPDF.js +24 -0
  14. package/es/icon/TextCopy.d.ts +3 -0
  15. package/es/icon/TextCopy.js +25 -0
  16. package/es/icon/TextFileIcon.d.ts +3 -0
  17. package/es/icon/TextFileIcon.js +26 -0
  18. package/es/icon/TextIcon.d.ts +3 -0
  19. package/es/icon/TextIcon.js +28 -0
  20. package/es/tools/exportPDF.d.ts +27 -0
  21. package/es/tools/exportPDF.js +146 -0
  22. package/es/tools/generateStylesFromSettings.d.ts +38 -0
  23. package/es/tools/generateStylesFromSettings.js +24 -0
  24. package/es/type.d.ts +17 -0
  25. package/lib/LcdpUeditor.d.ts +15 -4
  26. package/lib/LcdpUeditor.js +45 -8
  27. package/lib/ToolBottomBar/FormatModal/index.d.ts +9 -0
  28. package/lib/ToolBottomBar/FormatModal/index.js +261 -0
  29. package/lib/ToolBottomBar/FormatModal/index.less +276 -0
  30. package/lib/ToolBottomBar/ProgressModal/index.d.ts +10 -0
  31. package/lib/ToolBottomBar/ProgressModal/index.js +73 -0
  32. package/lib/ToolBottomBar/ProgressModal/index.less +16 -0
  33. package/lib/ToolBottomBar/index.d.ts +14 -0
  34. package/lib/ToolBottomBar/index.js +232 -0
  35. package/lib/ToolBottomBar/index.less +70 -0
  36. package/lib/icon/ExportPDF.d.ts +3 -0
  37. package/lib/icon/ExportPDF.js +57 -0
  38. package/lib/icon/TextCopy.d.ts +3 -0
  39. package/lib/icon/TextCopy.js +39 -0
  40. package/lib/icon/TextFileIcon.d.ts +3 -0
  41. package/lib/icon/TextFileIcon.js +39 -0
  42. package/lib/icon/TextIcon.d.ts +3 -0
  43. package/lib/icon/TextIcon.js +39 -0
  44. package/lib/tools/exportPDF.d.ts +27 -0
  45. package/lib/tools/exportPDF.js +95 -0
  46. package/lib/tools/generateStylesFromSettings.d.ts +38 -0
  47. package/lib/tools/generateStylesFromSettings.js +77 -0
  48. package/lib/type.d.ts +17 -0
  49. package/package.json +12 -3
@@ -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
  * 编辑器配置项
@@ -80,6 +81,16 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
80
81
  * 初始化编辑器实例
81
82
  */
82
83
  initUeditor(): Promise<void>;
84
+ getStatusBarItem: (params: {
85
+ icon: React.ReactNode;
86
+ content: React.ReactNode;
87
+ onClick?: () => void;
88
+ extraNode?: React.ReactNode;
89
+ }) => JSX.Element;
90
+ /**
91
+ * 渲染状态栏
92
+ */
93
+ renderStatusBar(): void;
83
94
  render(): React.ReactNode;
84
95
  }
85
96
  export default LcdpUeditor;
package/es/LcdpUeditor.js CHANGED
@@ -8,11 +8,13 @@ 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";
16
18
  var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
17
19
  _inherits(LcdpUeditor, _React$Component);
18
20
  var _super = _createSuper(LcdpUeditor);
@@ -56,25 +58,45 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
56
58
  * 上传文件函数
57
59
  */
58
60
  _defineProperty(_assertThisInitialized(_this), "uploadFunction", void 0);
59
- /**
60
- * 是否加载完成
61
- */
62
- _defineProperty(_assertThisInitialized(_this), "isReady", false);
63
61
  /**
64
62
  * 保存 compositionend 事件处理器引用
65
63
  */
66
64
  _defineProperty(_assertThisInitialized(_this), "compositionEndHandler", void 0);
65
+ /**
66
+ * 是否全屏
67
+ */
68
+ _defineProperty(_assertThisInitialized(_this), "prefixCls", 'pcfactory');
67
69
  /**
68
70
  * 初始加载失败
69
71
  */
70
72
  _defineProperty(_assertThisInitialized(_this), "state", {
71
- initError: false
73
+ initError: false,
74
+ /**
75
+ * 是否加载完成
76
+ */
77
+ isReady: false
72
78
  });
73
79
  /**
74
80
  * 编辑器配置项
75
81
  */
76
82
  _defineProperty(_assertThisInitialized(_this), "editorConfig", {});
77
- var config = props.config;
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
+ var config = props.config,
98
+ prefixCls = props.prefixCls,
99
+ onFormatChange = props.onFormatChange;
78
100
  _this.containerId = "ueditor_".concat(Date.now(), "_").concat(String(Math.random()).slice(2, 6));
79
101
  if (_this.props.ueditorPath) {
80
102
  _this.ueditorPath = _this.props.ueditorPath;
@@ -102,6 +124,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
102
124
  }
103
125
  return null;
104
126
  };
127
+ _this.prefixCls = prefixCls || 'pcfactory';
105
128
  _this.editorConfig = _objectSpread(_objectSpread({}, DefaultConfig), {}, {
106
129
  maximumWords: (config === null || config === void 0 ? void 0 : config.maximumWords) || 10000,
107
130
  initialFrameHeight: (config === null || config === void 0 ? void 0 : config.height) || 300,
@@ -111,7 +134,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
111
134
  },
112
135
  uploadFunction: _this.uploadFunction,
113
136
  initialContent: '',
114
- pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true
137
+ pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true,
138
+ onFormatChange: onFormatChange
115
139
  });
116
140
  _this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
117
141
  return _this;
@@ -124,7 +148,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
124
148
  }, {
125
149
  key: "componentWillReceiveProps",
126
150
  value: function componentWillReceiveProps(nextProps) {
127
- if (this.isReady) {
151
+ if (this.state.isReady) {
128
152
  if ('value' in nextProps && this.currentContent !== nextProps.value) {
129
153
  this.isReportFlag = false;
130
154
  this.ueditorInst.setContent(filterHtmlNode(nextProps.value || '').str);
@@ -142,7 +166,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
142
166
  }, {
143
167
  key: "componentWillUnmount",
144
168
  value: function componentWillUnmount() {
145
- if (this.isReady) {
169
+ if (this.state.isReady) {
146
170
  var _this$ueditorInst, _this$ueditorInst2, _this$ueditorInst2$de;
147
171
  var editorBody = (_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0 ? void 0 : _this$ueditorInst.body;
148
172
  if (editorBody && this.compositionEndHandler) {
@@ -336,7 +360,9 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
336
360
  if (nextValue) {
337
361
  _this3.ueditorInst.setContent(nextValue);
338
362
  }
339
- _this3.isReady = true;
363
+ _this3.setState({
364
+ isReady: true
365
+ });
340
366
  // 禁用状态设置
341
367
  if (_this3.props.disabled) {
342
368
  _this3.ueditorInst.setDisabled();
@@ -357,6 +383,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
357
383
  }
358
384
  _this3.initStyle();
359
385
  _this3.mountRef();
386
+ _this3.renderStatusBar();
360
387
  });
361
388
  };
362
389
  UeditorResourceLoader.onReady(readyFunc);
@@ -379,6 +406,28 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
379
406
  }
380
407
  return initUeditor;
381
408
  }())
409
+ }, {
410
+ key: "renderStatusBar",
411
+ value:
412
+ /**
413
+ * 渲染状态栏
414
+ */
415
+ 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');
418
+ var comp = /*#__PURE__*/React.createElement(ToolBottomBar, {
419
+ ueditorInst: this.ueditorInst,
420
+ prefixCls: this.prefixCls,
421
+ containerRef: this.containerRef,
422
+ defaultFormatSetting: this.props.defaultFormatSetting,
423
+ onFormatChange: this.editorConfig.onFormatChange,
424
+ isReady: this.state.isReady,
425
+ bottomTypes: this.props.bottomTypes
426
+ });
427
+ if (bottomBarContainer && (_this$props$bottomTyp = this.props.bottomTypes) !== null && _this$props$bottomTyp !== void 0 && _this$props$bottomTyp.length) {
428
+ ReactDOM.render(comp, bottomBarContainer);
429
+ }
430
+ }
382
431
  }, {
383
432
  key: "render",
384
433
  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;