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

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 (109) hide show
  1. package/es/LcdpUeditor.d.ts +10 -4
  2. package/es/LcdpUeditor.d.ts.map +1 -0
  3. package/es/LcdpUeditor.js +77 -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 +33 -0
  13. package/es/ToolBottomBar/index.d.ts.map +1 -0
  14. package/es/ToolBottomBar/index.js +296 -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 +21 -0
  40. package/es/type.d.ts.map +1 -0
  41. package/lib/LcdpUeditor.d.ts +10 -4
  42. package/lib/LcdpUeditor.js +62 -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 +33 -0
  50. package/lib/ToolBottomBar/index.js +235 -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 +21 -0
  65. package/package.json +8 -3
  66. package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
  67. package/ueditor-resource/dialogs/attachment/attachment.html +3 -3
  68. package/ueditor-resource/dialogs/attachment/attachment.js +1 -1
  69. package/ueditor-resource/dialogs/audio/audio.js +1 -1
  70. package/ueditor-resource/dialogs/background/background.html +2 -2
  71. package/ueditor-resource/dialogs/background/background.js +1 -1
  72. package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
  73. package/ueditor-resource/dialogs/contentimport/contentimport.js +1 -1
  74. package/ueditor-resource/dialogs/emotion/emotion.html +2 -2
  75. package/ueditor-resource/dialogs/emotion/emotion.js +1 -1
  76. package/ueditor-resource/dialogs/formula/formula.html +4 -4
  77. package/ueditor-resource/dialogs/formula/formula.js +1 -1
  78. package/ueditor-resource/dialogs/help/help.html +2 -2
  79. package/ueditor-resource/dialogs/help/help.js +1 -1
  80. package/ueditor-resource/dialogs/image/image.js +1 -1
  81. package/ueditor-resource/dialogs/insertframe/insertframe.html +1 -1
  82. package/ueditor-resource/dialogs/internal.js +1 -1
  83. package/ueditor-resource/dialogs/preview/preview.html +2 -2
  84. package/ueditor-resource/dialogs/scrawl/scrawl.html +2 -2
  85. package/ueditor-resource/dialogs/scrawl/scrawl.js +1 -1
  86. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
  87. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +1 -1
  88. package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
  89. package/ueditor-resource/dialogs/spechars/spechars.js +1 -1
  90. package/ueditor-resource/dialogs/table/edittable.html +2 -2
  91. package/ueditor-resource/dialogs/table/edittable.js +1 -1
  92. package/ueditor-resource/dialogs/table/edittd.html +1 -1
  93. package/ueditor-resource/dialogs/table/edittip.html +1 -1
  94. package/ueditor-resource/dialogs/template/template.html +2 -2
  95. package/ueditor-resource/dialogs/template/template.js +1 -1
  96. package/ueditor-resource/dialogs/video/video.js +1 -1
  97. package/ueditor-resource/dialogs/wordimage/wordimage.html +4 -4
  98. package/ueditor-resource/dialogs/wordimage/wordimage.js +1 -1
  99. package/ueditor-resource/plugins/browser-image-compression.js +9 -0
  100. package/ueditor-resource/plugins/demo/demo.js +3 -1
  101. package/ueditor-resource/themes/default/css/ueditor.css +1 -1
  102. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3 -3
  103. package/ueditor-resource/third-party/clipboard/clipboard.js +1 -1
  104. package/ueditor-resource/third-party/codemirror/codemirror.js +3 -2
  105. package/ueditor-resource/third-party/jquery-3.5.1.js +3 -3
  106. package/ueditor-resource/third-party/jquery-3.5.1_1.js +3 -3
  107. package/ueditor-resource/ueditor.all.js +22 -19
  108. package/ueditor-resource/ueditor.config.js +1 -1
  109. package/ueditor-resource/ueditor.parse.js +1 -1
@@ -0,0 +1,276 @@
1
+ @prefixCls: pcfactory;
2
+ @suffixCls: ueditor-format;
3
+ .@{suffixCls}-settings-popover {
4
+ max-width: 720px;
5
+
6
+ input[type="color"] {
7
+ -webkit-appearance: none;
8
+ border: none;
9
+ padding: 0;
10
+ cursor: pointer;
11
+
12
+ &::-webkit-color-swatch-wrapper {
13
+ padding: 0;
14
+ border-radius: 2px;
15
+ }
16
+
17
+ &::-webkit-color-swatch {
18
+ border: none;
19
+ border-radius: 2px;
20
+ }
21
+ }
22
+
23
+ .@{prefixCls}-form-item {
24
+ margin-bottom: 0;
25
+ }
26
+
27
+ .@{prefixCls}-form-item-control-input {
28
+ min-height: 28px;
29
+ }
30
+
31
+ .@{suffixCls}-popover-content {
32
+ width: 680px;
33
+ padding: 0;
34
+ }
35
+
36
+ .@{prefixCls}-popover-inner-content {
37
+ padding: 16px 20px;
38
+ border-radius: 8px;
39
+ }
40
+
41
+ .@{prefixCls}-popover-title {
42
+ font-weight: 600;
43
+ text-align: center;
44
+ font-size: 16px;
45
+ color: #1a202c;
46
+ padding: 16px 20px 12px;
47
+ border-bottom: 1px solid #e2e8f0;
48
+ margin-bottom: 0;
49
+ }
50
+ }
51
+
52
+ .@{suffixCls}-section {
53
+ overflow-y: auto;
54
+ padding: 0;
55
+ max-height: 400px;
56
+ }
57
+
58
+ .@{suffixCls}-style-row {
59
+ margin-bottom: 8px;
60
+ padding: 12px 16px;
61
+ border-bottom: 1px solid #f0f0f0;
62
+ border-radius: 6px;
63
+ background-color: #fafbfc;
64
+ transition: all 0.2s ease;
65
+ display: flex;
66
+ align-items: center;
67
+
68
+ &:hover {
69
+ background-color: #f1f5f9;
70
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
71
+ }
72
+
73
+ &:last-child {
74
+ border-bottom: none;
75
+ margin-bottom: 0;
76
+ }
77
+
78
+ .@{suffixCls}-row-label {
79
+ font-weight: 600;
80
+ font-size: 14px;
81
+ width: 80px;
82
+ color: #374151;
83
+ flex-shrink: 0;
84
+ margin-right: 12px;
85
+ margin-bottom: 0;
86
+ }
87
+
88
+ .@{prefixCls}-row {
89
+ flex: 1;
90
+ align-items: center;
91
+ margin: 0;
92
+ .@{prefixCls}-select-selector {
93
+ width: 100%;
94
+ }
95
+ }
96
+
97
+ .@{prefixCls}-col {
98
+ margin-bottom: 0;
99
+ display: flex;
100
+ align-items: center;
101
+ }
102
+
103
+ .@{prefixCls}-select {
104
+ width: 100%;
105
+
106
+ .@{prefixCls}-select-selector {
107
+ border-radius: 4px;
108
+ border-color: #d1d5db;
109
+ transition: all 0.2s ease;
110
+ height: 28px;
111
+
112
+ .@{prefixCls}-select-selection-item {
113
+ line-height: 26px;
114
+ }
115
+
116
+ &:hover {
117
+ border-color: #6366f1;
118
+ }
119
+ }
120
+
121
+ &.@{prefixCls}-select-focused .@{prefixCls}-select-selector {
122
+ border-color: #6366f1 !important;
123
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1) !important;
124
+ }
125
+ }
126
+
127
+ .@{prefixCls}-input-number {
128
+ width: 100%;
129
+ border-radius: 4px;
130
+ border-color: #d1d5db;
131
+ height: 28px;
132
+
133
+ .@{prefixCls}-input-number-input {
134
+ height: 26px;
135
+ }
136
+
137
+ &:hover {
138
+ border-color: #6366f1;
139
+ }
140
+
141
+ &:focus,
142
+ &.@{prefixCls}-input-number-focused {
143
+ border-color: #6366f1 !important;
144
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1) !important;
145
+ }
146
+ }
147
+
148
+ input[type="color"] {
149
+ width: 100%;
150
+ height: 28px;
151
+ border-radius: 4px;
152
+ border: 1px solid #d1d5db;
153
+ cursor: pointer;
154
+
155
+ &:hover {
156
+ border-color: #6366f1;
157
+ }
158
+ }
159
+ }
160
+
161
+ .@{suffixCls}-footer {
162
+ display: flex;
163
+ justify-content: flex-end;
164
+ gap: 12px;
165
+ margin-top: 16px;
166
+ padding-top: 12px;
167
+ border-top: 1px solid #e2e8f0;
168
+
169
+ .@{prefixCls}-btn {
170
+ height: 32px;
171
+ padding: 0 16px;
172
+ border-radius: 4px;
173
+ font-weight: 500;
174
+ transition: all 0.2s ease;
175
+
176
+ &.@{prefixCls}-btn-default {
177
+ border-color: #d1d5db;
178
+ color: #6b7280;
179
+
180
+ &:hover {
181
+ border-color: #9ca3af;
182
+ color: #374151;
183
+ }
184
+ }
185
+
186
+ &.@{prefixCls}-btn-primary {
187
+ background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
188
+ border: none;
189
+ box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
190
+
191
+ &:hover {
192
+ background: linear-gradient(135deg, #5b61f0 0%, #7c3aed 100%);
193
+ box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
194
+ transform: translateY(-1px);
195
+ }
196
+ }
197
+ }
198
+ }
199
+
200
+ @media (max-width: 768px) {
201
+ .@{suffixCls}-settings-popover {
202
+ max-width: 95vw;
203
+
204
+ .@{suffixCls}-popover-content {
205
+ width: calc(95vw - 40px);
206
+ }
207
+ }
208
+
209
+ .@{suffixCls}-style-row {
210
+ flex-direction: column;
211
+ align-items: stretch;
212
+
213
+ .@{suffixCls}-row-label {
214
+ width: 100%;
215
+ margin-right: 0;
216
+ margin-bottom: 8px;
217
+ }
218
+
219
+ .@{prefixCls}-row {
220
+ width: 100%;
221
+ }
222
+
223
+ .@{prefixCls}-col {
224
+ margin-bottom: 8px;
225
+
226
+ &:last-child {
227
+ margin-bottom: 0;
228
+ }
229
+ }
230
+ }
231
+ }
232
+
233
+ .@{suffixCls}-style-section {
234
+ margin-bottom: 15px;
235
+ }
236
+
237
+ .@{suffixCls}-section-title {
238
+ font-weight: 500;
239
+ margin-bottom: 10px;
240
+ font-size: 15px;
241
+ }
242
+
243
+ .@{suffixCls}-system-info {
244
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
245
+ color: white !important;
246
+ border-radius: 8px !important;
247
+ padding: 12px 16px !important;
248
+ margin-bottom: 16px !important;
249
+ text-align: center !important;
250
+ font-size: 13px !important;
251
+ font-weight: 500 !important;
252
+ box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2) !important;
253
+ }
254
+
255
+ .@{suffixCls}-section::-webkit-scrollbar {
256
+ width: 6px;
257
+ }
258
+
259
+ .@{suffixCls}-section::-webkit-scrollbar-track {
260
+ background: #f1f5f9;
261
+ border-radius: 3px;
262
+ }
263
+
264
+ .@{suffixCls}-section::-webkit-scrollbar-thumb {
265
+ background: #cbd5e1;
266
+ border-radius: 3px;
267
+
268
+ &:hover {
269
+ background: #94a3b8;
270
+ }
271
+ }
272
+
273
+ .@{suffixCls}-section.loading {
274
+ opacity: 0.6;
275
+ pointer-events: none;
276
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface ProgressModalRef {
4
+ updateProgress: (progress: number, title?: string) => void;
5
+ updateVisible: (open: boolean) => void;
6
+ }
7
+ export interface ProgressModalProps {
8
+ }
9
+ declare const ProgressModal: React.ForwardRefExoticComponent<ProgressModalProps & React.RefAttributes<ProgressModalRef>>;
10
+ export default ProgressModal;
@@ -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"}
@@ -0,0 +1,53 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { forwardRef, useImperativeHandle, useState } from 'react';
3
+ import { Modal, Progress } from 'antd';
4
+ import "./index.less";
5
+ var suffixCls = 'ueditor-progress-modal';
6
+ var ProgressModal = /*#__PURE__*/forwardRef(function (props, ref) {
7
+ var _useState = useState(false),
8
+ _useState2 = _slicedToArray(_useState, 2),
9
+ visible = _useState2[0],
10
+ setVisible = _useState2[1];
11
+ var _useState3 = useState(0),
12
+ _useState4 = _slicedToArray(_useState3, 2),
13
+ progress = _useState4[0],
14
+ setProgress = _useState4[1];
15
+ var _useState5 = useState('准备中...'),
16
+ _useState6 = _slicedToArray(_useState5, 2),
17
+ title = _useState6[0],
18
+ setTitle = _useState6[1];
19
+ useImperativeHandle(ref, function () {
20
+ return {
21
+ updateProgress: function updateProgress(newProgress, title) {
22
+ if (!visible) {
23
+ setVisible(true);
24
+ }
25
+ setProgress(newProgress);
26
+ if (title) {
27
+ setTitle(title);
28
+ }
29
+ },
30
+ updateVisible: function updateVisible(open) {
31
+ setVisible(open);
32
+ }
33
+ };
34
+ });
35
+ return /*#__PURE__*/React.createElement(Modal, {
36
+ title: null,
37
+ visible: visible,
38
+ footer: null,
39
+ closable: false,
40
+ maskClosable: false,
41
+ wrapClassName: suffixCls
42
+ }, /*#__PURE__*/React.createElement("div", {
43
+ className: "".concat(suffixCls, "-title")
44
+ }, "\u6B63\u5728\u751F\u6210PDF\u6587\u4EF6..."), /*#__PURE__*/React.createElement(Progress, {
45
+ percent: progress,
46
+ status: "active",
47
+ showInfo: false
48
+ }), title && /*#__PURE__*/React.createElement("div", {
49
+ className: "".concat(suffixCls, "-sub-title")
50
+ }, title, " ", progress, "%"));
51
+ });
52
+ ProgressModal.displayName = 'ProgressModal';
53
+ export default ProgressModal;
@@ -0,0 +1,16 @@
1
+ @suffixCls: ~'ueditor-progress-modal';
2
+
3
+ .@{suffixCls} {
4
+ &-title {
5
+ font-size: 16px;
6
+ font-weight: 500;
7
+ margin-bottom: 12px;
8
+ color: #333;
9
+ }
10
+ &-sub-title {
11
+ font-size: 14px;
12
+ color: #666;
13
+ text-align: center;
14
+ margin-top: 8px;
15
+ }
16
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { FormatSettings } from '../tools/generateStylesFromSettings';
3
+ import './index.less';
4
+ import { ILcdpUeditorProps } from '../type';
5
+ declare const ToolBottomBar: (props: {
6
+ /**
7
+ * 编辑器实例
8
+ */
9
+ ueditorInst: any;
10
+ /**
11
+ * 前缀类名
12
+ */
13
+ prefixCls?: string | undefined;
14
+ /**
15
+ * 容器引用
16
+ */
17
+ containerRef?: React.RefObject<HTMLDivElement> | undefined;
18
+ defaultFormatSetting?: FormatSettings | undefined;
19
+ onFormatChange?: ((val: FormatSettings) => void) | undefined;
20
+ /**
21
+ * 是否准备就绪
22
+ */
23
+ isReady?: boolean | undefined;
24
+ /**
25
+ * 底部功能类型
26
+ */
27
+ bottomTypes?: ILcdpUeditorProps['bottomTypes'];
28
+ /**
29
+ * 导出文件名
30
+ */
31
+ exportFileName?: string | undefined;
32
+ }) => JSX.Element;
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"}
@@ -0,0 +1,296 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import React, { useState, useEffect, useRef } from 'react';
5
+ import debounce from 'lodash/debounce';
6
+ import Icon, { SettingOutlined, CheckOutlined, FullscreenOutlined, FullscreenExitOutlined, DownOutlined } from '@ant-design/icons';
7
+ import { Dropdown, Menu, ConfigProvider } from 'antd';
8
+ import exportFile from "../icon/ExportPDF";
9
+ import textFileIcon from "../icon/TextFileIcon";
10
+ import textIcon from "../icon/TextIcon";
11
+ import textCopy from "../icon/TextCopy";
12
+ import { domloadPdf } from "../tools/exportPDF";
13
+ import FormatModal from "./FormatModal";
14
+ import { generateStylesFromSettings } from "../tools/generateStylesFromSettings";
15
+ import "./index.less";
16
+ import ProgressModal from "./ProgressModal";
17
+ var MENU_OPTIONS = {
18
+ a3: 'A3',
19
+ a4: 'A4',
20
+ a5: 'A5',
21
+ a0: '铺满'
22
+ };
23
+ var STYLE_ID = 'ueditor-custom-styles';
24
+ var ToolBottomBar = function ToolBottomBar(props) {
25
+ var ueditorInst = props.ueditorInst,
26
+ prefixCls = props.prefixCls,
27
+ containerRef = props.containerRef,
28
+ defaultFormatSetting = props.defaultFormatSetting,
29
+ onFormatChange = props.onFormatChange,
30
+ isReady = props.isReady,
31
+ bottomTypes = props.bottomTypes,
32
+ exportFileName = props.exportFileName;
33
+ var _ref = ueditorInst.ui || {},
34
+ uiId = _ref.id;
35
+ var _useState = useState(0),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ chineseTextCount = _useState2[0],
38
+ setChineseTextCount = _useState2[1];
39
+ var _useState3 = useState(0),
40
+ _useState4 = _slicedToArray(_useState3, 2),
41
+ totalTextCount = _useState4[0],
42
+ setTotalTextCount = _useState4[1];
43
+ var _useState5 = useState(false),
44
+ _useState6 = _slicedToArray(_useState5, 2),
45
+ innerFullScreen = _useState6[0],
46
+ setInnerFullScreen = _useState6[1];
47
+ var _useState7 = useState(false),
48
+ _useState8 = _slicedToArray(_useState7, 2),
49
+ isCopying = _useState8[0],
50
+ setIsCopying = _useState8[1];
51
+ var _useState9 = useState(undefined),
52
+ _useState10 = _slicedToArray(_useState9, 2),
53
+ pageWidth = _useState10[0],
54
+ setPageWidth = _useState10[1];
55
+ var timer = useRef(undefined);
56
+ var progressModalRef = useRef(null);
57
+ var debounceContentChange = debounce(function () {
58
+ try {
59
+ var _plainTxt$match;
60
+ var plainTxt = ueditorInst.getContentTxt() || '';
61
+ var _chineseTextCount = ((_plainTxt$match = plainTxt.match(/[\u4e00-\u9fa5]/g)) === null || _plainTxt$match === void 0 ? void 0 : _plainTxt$match.length) || 0;
62
+ var _totalTextCount = plainTxt.length;
63
+ setChineseTextCount(_chineseTextCount);
64
+ setTotalTextCount(_totalTextCount);
65
+ } catch (e) {
66
+ //
67
+ }
68
+ }, 300);
69
+ useEffect(function () {
70
+ if (isReady) {
71
+ ueditorInst.addListener('beforefullscreenchange', function (_, v) {
72
+ setInnerFullScreen(v);
73
+ });
74
+ ueditorInst.addListener('contentChange', function () {
75
+ debounceContentChange();
76
+ });
77
+ // 初始化调用一次
78
+ setTimeout(function () {
79
+ debounceContentChange();
80
+ }, 1000);
81
+ }
82
+ }, [ueditorInst, isReady]);
83
+ useEffect(function () {
84
+ return function () {
85
+ if (timer.current) {
86
+ clearTimeout(timer.current);
87
+ }
88
+ };
89
+ }, []);
90
+ var getStatusBarItem = function getStatusBarItem(params) {
91
+ var icon = params.icon,
92
+ content = params.content,
93
+ onClick = params.onClick,
94
+ extraNode = params.extraNode,
95
+ _params$className = params.className,
96
+ className = _params$className === void 0 ? '' : _params$className;
97
+ return /*#__PURE__*/React.createElement("span", {
98
+ className: "ueditor-rich-status-bar-item ".concat(className),
99
+ onClick: onClick
100
+ }, /*#__PURE__*/React.createElement("span", {
101
+ className: "ueditor-rich-status-bar-icon"
102
+ }, icon), /*#__PURE__*/React.createElement("span", {
103
+ className: "ueditor-rich-status-bar-content"
104
+ }, content), extraNode && /*#__PURE__*/React.createElement("span", {
105
+ className: "ueditor-rich-status-bar-extra"
106
+ }, extraNode));
107
+ };
108
+ var copyAll = function copyAll() {
109
+ var txt = ueditorInst.getPlainTxt();
110
+ var copy = function copy(t) {
111
+ // 复制使用传统方式
112
+ var input = document.createElement('textarea');
113
+ input.value = t;
114
+ document.body.appendChild(input);
115
+ input.select();
116
+ document.execCommand('copy');
117
+ document.body.removeChild(input);
118
+ setIsCopying(true);
119
+ };
120
+ if (txt) {
121
+ try {
122
+ navigator.clipboard.writeText(txt).then(function () {
123
+ setIsCopying(true);
124
+ // 复制成功
125
+ }).catch(function () {
126
+ // 复制失败,使用传统方式
127
+ copy(txt);
128
+ });
129
+ } catch (e) {
130
+ // 浏览器不支持 clipboard API,使用传统方式
131
+ copy(txt);
132
+ }
133
+ timer.current = setTimeout(function () {
134
+ setIsCopying(false);
135
+ }, 1000);
136
+ }
137
+ };
138
+
139
+ /**
140
+ * 应用格式设置
141
+ * @param settings 格式设置
142
+ */
143
+ var handleApply = function handleApply(settings) {
144
+ var _containerRef$current, _contentDocument;
145
+ 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);
159
+ }
160
+ // 设置样式内容
161
+ styleEl.textContent = cssStyles;
162
+ }
163
+ if (isUpdate) {
164
+ onFormatChange === null || onFormatChange === void 0 || onFormatChange(settings);
165
+ }
166
+ };
167
+ useEffect(function () {
168
+ if (defaultFormatSetting) {
169
+ handleApply(defaultFormatSetting, false);
170
+ }
171
+ }, [defaultFormatSetting]);
172
+ var onProgress = function onProgress(progress, title) {
173
+ var _progressModalRef$cur;
174
+ (_progressModalRef$cur = progressModalRef.current) === null || _progressModalRef$cur === void 0 || _progressModalRef$cur.updateProgress(progress, title);
175
+ };
176
+ return /*#__PURE__*/React.createElement(ConfigProvider, {
177
+ prefixCls: prefixCls
178
+ }, /*#__PURE__*/React.createElement("div", {
179
+ className: "ueditor-rich-status-bar"
180
+ }, /*#__PURE__*/React.createElement("div", {
181
+ className: "ueditor-rich-status-bar-box"
182
+ }, (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('charCount')) && getStatusBarItem({
183
+ icon: /*#__PURE__*/React.createElement(Icon, {
184
+ component: textIcon,
185
+ className: "ueditor-rich-status-bar-icon-svg"
186
+ }),
187
+ content: "".concat(totalTextCount, " \u5B57\u7B26"),
188
+ className: 'ueditor-rich-status-bar-text'
189
+ }), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('chineseCount')) && getStatusBarItem({
190
+ icon: /*#__PURE__*/React.createElement(Icon, {
191
+ component: textFileIcon,
192
+ className: "ueditor-rich-status-bar-icon-svg"
193
+ }),
194
+ content: "".concat(chineseTextCount, " \u4E2D\u6587"),
195
+ className: 'ueditor-rich-status-bar-text'
196
+ })), /*#__PURE__*/React.createElement("div", {
197
+ className: "ueditor-rich-status-bar-box"
198
+ }, (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('pageWidth')) && /*#__PURE__*/React.createElement(Dropdown, {
199
+ trigger: ['click'],
200
+ overlay: /*#__PURE__*/React.createElement(Menu, {
201
+ onClick: function onClick(_ref2) {
202
+ 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);
222
+ }
223
+ }, Object.keys(MENU_OPTIONS).map(function (k) {
224
+ return /*#__PURE__*/React.createElement(Menu.Item, {
225
+ key: k
226
+ }, /*#__PURE__*/React.createElement("span", null, "\u9875\u9762\u5BBD\u5EA6 ", MENU_OPTIONS[k]));
227
+ }))
228
+ }, getStatusBarItem({
229
+ content: "\u9875\u9762\u5BBD\u5EA6".concat(pageWidth ? " ".concat(MENU_OPTIONS[pageWidth]) : ''),
230
+ extraNode: /*#__PURE__*/React.createElement(DownOutlined, null)
231
+ })), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('formatSetting')) && /*#__PURE__*/React.createElement(FormatModal, {
232
+ onApply: handleApply,
233
+ initialSettings: defaultFormatSetting
234
+ }, getStatusBarItem({
235
+ icon: /*#__PURE__*/React.createElement(SettingOutlined, null),
236
+ content: '格式设置'
237
+ })), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('copy')) && getStatusBarItem({
238
+ icon: isCopying ? /*#__PURE__*/React.createElement(CheckOutlined, null) : /*#__PURE__*/React.createElement(Icon, {
239
+ component: textCopy,
240
+ className: "ueditor-rich-status-bar-icon-svg"
241
+ }),
242
+ content: '复制全文',
243
+ onClick: copyAll,
244
+ className: isCopying ? 'isActive' : undefined
245
+ }), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('fullScreen')) && getStatusBarItem({
246
+ icon: innerFullScreen ? /*#__PURE__*/React.createElement(FullscreenExitOutlined, null) : /*#__PURE__*/React.createElement(FullscreenOutlined, null),
247
+ content: innerFullScreen ? '退出全屏' : '全屏预览',
248
+ onClick: function onClick() {
249
+ ueditorInst.ui.setFullScreen(!innerFullScreen);
250
+ }
251
+ }), (bottomTypes === null || bottomTypes === void 0 ? void 0 : bottomTypes.includes('exportPdf')) && getStatusBarItem({
252
+ icon: /*#__PURE__*/React.createElement(Icon, {
253
+ component: exportFile,
254
+ className: "ueditor-rich-status-bar-icon-svg"
255
+ }),
256
+ content: '导出文档',
257
+ onClick: function () {
258
+ var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
259
+ var _contentDocument3, frame, _contentDocument4;
260
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
261
+ while (1) switch (_context.prev = _context.next) {
262
+ case 0:
263
+ if (!(containerRef !== null && containerRef !== void 0 && containerRef.current)) {
264
+ _context.next = 7;
265
+ break;
266
+ }
267
+ 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)) {
269
+ _context.next = 6;
270
+ break;
271
+ }
272
+ _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);
274
+ case 5:
275
+ onProgress(100, '导出完成');
276
+ case 6:
277
+ setTimeout(function () {
278
+ var _progressModalRef$cur2;
279
+ (_progressModalRef$cur2 = progressModalRef.current) === null || _progressModalRef$cur2 === void 0 || _progressModalRef$cur2.updateVisible(false);
280
+ }, 500);
281
+ case 7:
282
+ case "end":
283
+ return _context.stop();
284
+ }
285
+ }, _callee);
286
+ }));
287
+ function onClick() {
288
+ return _onClick.apply(this, arguments);
289
+ }
290
+ return onClick;
291
+ }()
292
+ }), /*#__PURE__*/React.createElement(ProgressModal, {
293
+ ref: progressModalRef
294
+ }))));
295
+ };
296
+ export default ToolBottomBar;