@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (132) hide show
  1. package/es/LcdpUeditor.d.ts +4 -0
  2. package/es/LcdpUeditor.js +76 -51
  3. package/es/const.js +4 -4
  4. package/es/defaultConfig.json +76 -76
  5. package/es/tools/UeditorResourceLoader.js +6 -6
  6. package/es/tools/filterHtmlNode.d.ts +5 -0
  7. package/es/tools/filterHtmlNode.js +41 -0
  8. package/es/tools/loadScript.js +3 -3
  9. package/es/type.d.ts +7 -1
  10. package/lib/LcdpUeditor.d.ts +80 -0
  11. package/lib/LcdpUeditor.js +268 -0
  12. package/lib/const.d.ts +12 -0
  13. package/lib/const.js +39 -0
  14. package/lib/defaultConfig.json +77 -0
  15. package/lib/index.d.ts +4 -0
  16. package/lib/index.js +41 -0
  17. package/lib/tools/UeditorResourceLoader.d.ts +21 -0
  18. package/lib/tools/UeditorResourceLoader.js +90 -0
  19. package/lib/tools/filterHtmlNode.d.ts +5 -0
  20. package/lib/tools/filterHtmlNode.js +61 -0
  21. package/lib/tools/loadScript.d.ts +5 -0
  22. package/lib/tools/loadScript.js +39 -0
  23. package/lib/type.d.ts +148 -0
  24. package/lib/type.js +17 -0
  25. package/package.json +32 -32
  26. package/ueditor-resource/dialogs/anchor/anchor.html +62 -62
  27. package/ueditor-resource/dialogs/attachment/attachment.css +716 -716
  28. package/ueditor-resource/dialogs/attachment/attachment.html +61 -61
  29. package/ueditor-resource/dialogs/attachment/attachment.js +803 -803
  30. package/ueditor-resource/dialogs/audio/audio.css +879 -879
  31. package/ueditor-resource/dialogs/audio/audio.html +93 -93
  32. package/ueditor-resource/dialogs/audio/audio.js +815 -815
  33. package/ueditor-resource/dialogs/background/background.css +193 -193
  34. package/ueditor-resource/dialogs/background/background.html +59 -59
  35. package/ueditor-resource/dialogs/background/background.js +370 -370
  36. package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -176
  37. package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -91
  38. package/ueditor-resource/dialogs/emotion/emotion.css +129 -129
  39. package/ueditor-resource/dialogs/emotion/emotion.html +70 -70
  40. package/ueditor-resource/dialogs/emotion/emotion.js +186 -186
  41. package/ueditor-resource/dialogs/formula/formula.html +98 -98
  42. package/ueditor-resource/dialogs/formula/formula.js +147 -147
  43. package/ueditor-resource/dialogs/help/help.css +37 -37
  44. package/ueditor-resource/dialogs/help/help.html +82 -82
  45. package/ueditor-resource/dialogs/help/help.js +57 -57
  46. package/ueditor-resource/dialogs/image/image.css +768 -768
  47. package/ueditor-resource/dialogs/image/image.html +144 -144
  48. package/ueditor-resource/dialogs/image/image.js +1060 -1060
  49. package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -135
  50. package/ueditor-resource/dialogs/internal.js +81 -81
  51. package/ueditor-resource/dialogs/link/link.html +148 -148
  52. package/ueditor-resource/dialogs/preview/preview.html +45 -45
  53. package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -324
  54. package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -95
  55. package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -682
  56. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -144
  57. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -174
  58. package/ueditor-resource/dialogs/spechars/spechars.html +42 -42
  59. package/ueditor-resource/dialogs/spechars/spechars.js +86 -86
  60. package/ueditor-resource/dialogs/table/edittable.css +85 -85
  61. package/ueditor-resource/dialogs/table/edittable.html +69 -69
  62. package/ueditor-resource/dialogs/table/edittable.js +241 -241
  63. package/ueditor-resource/dialogs/table/edittd.html +62 -62
  64. package/ueditor-resource/dialogs/table/edittip.html +33 -33
  65. package/ueditor-resource/dialogs/template/config.js +42 -42
  66. package/ueditor-resource/dialogs/template/template.css +99 -99
  67. package/ueditor-resource/dialogs/template/template.html +26 -26
  68. package/ueditor-resource/dialogs/template/template.js +53 -53
  69. package/ueditor-resource/dialogs/video/video.css +909 -909
  70. package/ueditor-resource/dialogs/video/video.html +114 -114
  71. package/ueditor-resource/dialogs/video/video.js +867 -867
  72. package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -221
  73. package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -93
  74. package/ueditor-resource/lang/en/en.js +686 -686
  75. package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -748
  76. package/ueditor-resource/lang/zh-tw/images/copy.png +0 -0
  77. package/ueditor-resource/lang/zh-tw/images/localimage.png +0 -0
  78. package/ueditor-resource/lang/zh-tw/images/music.png +0 -0
  79. package/ueditor-resource/lang/zh-tw/images/upload.png +0 -0
  80. package/ueditor-resource/lang/zh-tw/zh-tw.js +748 -0
  81. package/ueditor-resource/plugins/demo/demo.js +3 -3
  82. package/ueditor-resource/themes/default/css/ueditor.css +2148 -2148
  83. package/ueditor-resource/themes/default/dialog.css +17 -17
  84. package/ueditor-resource/themes/default/dialogbase.css +132 -132
  85. package/ueditor-resource/themes/default/exts/ai.svg +12 -12
  86. package/ueditor-resource/themes/default/exts/apk.svg +12 -12
  87. package/ueditor-resource/themes/default/exts/chm.svg +12 -12
  88. package/ueditor-resource/themes/default/exts/css.svg +12 -12
  89. package/ueditor-resource/themes/default/exts/doc.svg +22 -22
  90. package/ueditor-resource/themes/default/exts/docx.svg +22 -22
  91. package/ueditor-resource/themes/default/exts/dwg.svg +16 -16
  92. package/ueditor-resource/themes/default/exts/folder.svg +3 -3
  93. package/ueditor-resource/themes/default/exts/gif.svg +14 -14
  94. package/ueditor-resource/themes/default/exts/html.svg +12 -12
  95. package/ueditor-resource/themes/default/exts/jpeg.svg +14 -14
  96. package/ueditor-resource/themes/default/exts/jpg.svg +14 -14
  97. package/ueditor-resource/themes/default/exts/log.svg +12 -12
  98. package/ueditor-resource/themes/default/exts/mp3.svg +14 -14
  99. package/ueditor-resource/themes/default/exts/mp4.svg +12 -12
  100. package/ueditor-resource/themes/default/exts/pdf.svg +14 -14
  101. package/ueditor-resource/themes/default/exts/png.svg +14 -14
  102. package/ueditor-resource/themes/default/exts/ppt.svg +24 -24
  103. package/ueditor-resource/themes/default/exts/pptx.svg +24 -24
  104. package/ueditor-resource/themes/default/exts/psd.svg +12 -12
  105. package/ueditor-resource/themes/default/exts/rar.svg +12 -12
  106. package/ueditor-resource/themes/default/exts/svg.svg +12 -12
  107. package/ueditor-resource/themes/default/exts/torrent.svg +14 -14
  108. package/ueditor-resource/themes/default/exts/txt.svg +14 -14
  109. package/ueditor-resource/themes/default/exts/unknown.svg +12 -12
  110. package/ueditor-resource/themes/default/exts/xls.svg +25 -25
  111. package/ueditor-resource/themes/default/exts/xlsx.svg +25 -25
  112. package/ueditor-resource/themes/default/exts/zip.svg +12 -12
  113. package/ueditor-resource/themes/iframe.css +63 -63
  114. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -3655
  115. package/ueditor-resource/third-party/clipboard/clipboard.js +752 -752
  116. package/ueditor-resource/third-party/codemirror/codemirror.css +106 -106
  117. package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -3581
  118. package/ueditor-resource/third-party/jquery-3.5.1.js +1 -1
  119. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -4314
  120. package/ueditor-resource/third-party/webuploader/webuploader.css +88 -88
  121. package/ueditor-resource/third-party/webuploader/webuploader.js +3 -3
  122. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
  123. package/ueditor-resource/ueditor.all.js +5271 -5270
  124. package/ueditor-resource/ueditor.config.js +655 -656
  125. package/ueditor-resource/ueditor.parse.js +13 -13
  126. package/es/LcdpUeditor.d.ts.map +0 -1
  127. package/es/const.d.ts.map +0 -1
  128. package/es/index.d.ts.map +0 -1
  129. package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
  130. package/es/tools/loadScript.d.ts.map +0 -1
  131. package/es/type.d.ts.map +0 -1
  132. package/ueditor-resource/index.html +0 -146
@@ -0,0 +1,268 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/LcdpUeditor.tsx
30
+ var LcdpUeditor_exports = {};
31
+ __export(LcdpUeditor_exports, {
32
+ default: () => LcdpUeditor_default
33
+ });
34
+ module.exports = __toCommonJS(LcdpUeditor_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_const = require("./const");
37
+ var import_defaultConfig = __toESM(require("./defaultConfig.json"));
38
+ var import_UeditorResourceLoader = __toESM(require("./tools/UeditorResourceLoader"));
39
+ var import_debounce = __toESM(require("lodash/debounce"));
40
+ var import_filterHtmlNode = require("./tools/filterHtmlNode");
41
+ var LcdpUeditor = class extends import_react.default.Component {
42
+ constructor(props) {
43
+ super(props);
44
+ /**
45
+ * 静态资源地址
46
+ */
47
+ this.ueditorPath = import_const.DEFAULT_UEDITOR_PATH;
48
+ /**
49
+ * 文件上传inputRef
50
+ */
51
+ this.inputRef = import_react.default.createRef();
52
+ /**
53
+ * 编辑器容器ref
54
+ */
55
+ this.containerRef = import_react.default.createRef();
56
+ /**
57
+ * 编辑器实例
58
+ */
59
+ this.ueditorInst = null;
60
+ /**
61
+ * 是否上报
62
+ */
63
+ this.isReportFlag = true;
64
+ /**
65
+ * 当前值
66
+ */
67
+ this.currentContent = "";
68
+ /**
69
+ * 是否加载完成
70
+ */
71
+ this.isReady = false;
72
+ /**
73
+ * 初始加载失败
74
+ */
75
+ this.state = {
76
+ initError: false
77
+ };
78
+ /**
79
+ * 编辑器配置项
80
+ */
81
+ this.editorConfig = {};
82
+ const { config } = props;
83
+ this.containerId = `ueditor_${Date.now()}_${String(Math.random()).slice(2, 6)}`;
84
+ if (this.props.ueditorPath) {
85
+ this.ueditorPath = this.props.ueditorPath;
86
+ }
87
+ const nextValue = (0, import_filterHtmlNode.filterHtmlNode)(this.props.value || "").str;
88
+ this.currentContent = nextValue;
89
+ this.uploadFunction = (file, type) => {
90
+ var _a;
91
+ if (type === "image" && ((_a = this.props.config) == null ? void 0 : _a.imageType) === "base64") {
92
+ const reader = new FileReader();
93
+ reader.readAsDataURL(file);
94
+ return new Promise((resolve, reject) => {
95
+ reader.onload = ({ target }) => resolve({
96
+ state: "SUCCESS",
97
+ url: target == null ? void 0 : target.result,
98
+ title: file.name,
99
+ original: file.name
100
+ });
101
+ });
102
+ }
103
+ if (this.props.uploadFunction) {
104
+ return this.props.uploadFunction(file);
105
+ }
106
+ return null;
107
+ };
108
+ this.editorConfig = {
109
+ ...import_defaultConfig.default,
110
+ maximumWords: (config == null ? void 0 : config.maximumWords) || 1e4,
111
+ initialFrameHeight: (config == null ? void 0 : config.height) || 300,
112
+ autoHeightEnabled: false,
113
+ selectCallback: (cb, type) => {
114
+ this.fileSelect(cb, type);
115
+ },
116
+ uploadFunction: this.uploadFunction,
117
+ initialContent: nextValue || "",
118
+ pasteplain: (config == null ? void 0 : config.pasteplain) === true
119
+ };
120
+ this.debounceContentChange = (0, import_debounce.default)(this.onContentChange.bind(this), 300);
121
+ }
122
+ componentDidMount() {
123
+ this.initUeditor();
124
+ }
125
+ componentWillReceiveProps(nextProps) {
126
+ if (this.isReady) {
127
+ if ("value" in nextProps && this.currentContent !== nextProps.value) {
128
+ this.isReportFlag = false;
129
+ this.ueditorInst.setContent((0, import_filterHtmlNode.filterHtmlNode)(nextProps.value || "").str);
130
+ }
131
+ if (nextProps.disabled !== this.props.disabled) {
132
+ if (nextProps.disabled) {
133
+ this.ueditorInst.setDisabled();
134
+ } else {
135
+ this.ueditorInst.setEnabled();
136
+ }
137
+ }
138
+ }
139
+ }
140
+ componentWillUnmount() {
141
+ var _a, _b;
142
+ if (this.isReady) {
143
+ (_b = (_a = this.ueditorInst) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a);
144
+ }
145
+ }
146
+ onContentChange() {
147
+ if (!this.isReportFlag) {
148
+ this.isReportFlag = true;
149
+ } else if (this.props.onChange) {
150
+ this.currentContent = this.ueditorInst.getContent() || "";
151
+ const { str, flag, source } = (0, import_filterHtmlNode.filterHtmlNode)(this.currentContent);
152
+ this.props.onChange(flag ? str : source);
153
+ }
154
+ }
155
+ getExtString(str) {
156
+ if (Array.isArray(str)) {
157
+ return str.join(",");
158
+ }
159
+ return str || "";
160
+ }
161
+ /**
162
+ * 文件选择
163
+ * @param cb 回调给编辑器
164
+ * @param type 类型
165
+ */
166
+ async fileSelect(cb, type) {
167
+ if (this.inputRef.current) {
168
+ let accept = "";
169
+ switch (type) {
170
+ case "image":
171
+ accept = this.getExtString(this.editorConfig.imageAllowFiles);
172
+ break;
173
+ case "audio":
174
+ accept = this.getExtString(this.editorConfig.audioAllowFiles);
175
+ break;
176
+ case "video":
177
+ accept = this.getExtString(this.editorConfig.videoAllowFiles);
178
+ break;
179
+ default:
180
+ break;
181
+ }
182
+ this.inputRef.current.accept = accept || "";
183
+ this.inputRef.current.click();
184
+ this.inputRef.current.onchange = async (e) => {
185
+ let file;
186
+ const fileList = e.target.files;
187
+ if ((fileList == null ? void 0 : fileList.length) > 0) {
188
+ file = fileList[0];
189
+ }
190
+ if (file) {
191
+ const res = await this.uploadFunction(file, type);
192
+ if (res.state === "SUCCESS" && res.url) {
193
+ cb(res);
194
+ }
195
+ }
196
+ this.inputRef.current.value = "";
197
+ };
198
+ }
199
+ }
200
+ /**
201
+ * 对外暴露编辑器实例
202
+ */
203
+ mountRef() {
204
+ if (this.props.onMount) {
205
+ this.props.onMount(this.ueditorInst);
206
+ }
207
+ }
208
+ /**
209
+ * 初始化样式
210
+ */
211
+ initStyle() {
212
+ var _a, _b;
213
+ const { toolbarColor, backgroundColor } = this.props.style || {};
214
+ if (this.containerRef.current) {
215
+ if (backgroundColor) {
216
+ const editor = this.containerRef.current.querySelector(".edui-editor");
217
+ (_a = editor.style) == null ? void 0 : _a.setProperty("background-color", backgroundColor);
218
+ }
219
+ if (toolbarColor) {
220
+ const toolBox = this.containerRef.current.querySelector(".edui-editor-toolbarboxouter");
221
+ (_b = toolBox.style) == null ? void 0 : _b.setProperty("background-color", toolbarColor);
222
+ }
223
+ }
224
+ }
225
+ /**
226
+ * 初始化编辑器实例
227
+ */
228
+ async initUeditor() {
229
+ import_UeditorResourceLoader.default.onReady(() => {
230
+ if (this.props.toolbars) {
231
+ this.editorConfig.toolbars = this.props.toolbars;
232
+ }
233
+ this.ueditorInst = window.UE.getEditor(this.containerId, this.editorConfig);
234
+ this.ueditorInst.ready(() => {
235
+ this.isReady = true;
236
+ if (this.props.disabled) {
237
+ this.ueditorInst.setDisabled();
238
+ } else {
239
+ this.ueditorInst.setEnabled();
240
+ }
241
+ this.ueditorInst.addListener("contentChange", () => {
242
+ this.debounceContentChange();
243
+ });
244
+ this.initStyle();
245
+ });
246
+ this.mountRef();
247
+ });
248
+ const jsList = [
249
+ `${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.UEDITOR_CONFIG}`,
250
+ `${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL}`,
251
+ `${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.GET_UEDITOR_LANG(this.props.lang || "zh-cn")}`
252
+ ];
253
+ import_UeditorResourceLoader.default.onLoadError(() => {
254
+ this.setState({
255
+ initError: true
256
+ });
257
+ });
258
+ import_UeditorResourceLoader.default.startLoad(jsList);
259
+ }
260
+ render() {
261
+ const { initError } = this.state;
262
+ if (initError) {
263
+ throw new Error("Load Ueditor Resource Fail");
264
+ }
265
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: this.containerRef, style: this.props.style, className: this.props.className }, /* @__PURE__ */ import_react.default.createElement("script", { id: this.containerId, type: "text/plain" }), /* @__PURE__ */ import_react.default.createElement("input", { hidden: true, ref: this.inputRef, type: "file" }));
266
+ }
267
+ };
268
+ var LcdpUeditor_default = LcdpUeditor;
package/lib/const.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 默认的ueditor资源路径
3
+ */
4
+ export declare const DEFAULT_UEDITOR_PATH = "./ueditor-resource";
5
+ /**
6
+ * ueditor 资源文件名
7
+ */
8
+ export declare const DEFAULT_UEDITOR_CONFIG: {
9
+ UEDITOR_CONFIG: string;
10
+ UEDITOR_ALL: string;
11
+ GET_UEDITOR_LANG: (lang?: string) => string;
12
+ };
package/lib/const.js ADDED
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/const.ts
20
+ var const_exports = {};
21
+ __export(const_exports, {
22
+ DEFAULT_UEDITOR_CONFIG: () => DEFAULT_UEDITOR_CONFIG,
23
+ DEFAULT_UEDITOR_PATH: () => DEFAULT_UEDITOR_PATH
24
+ });
25
+ module.exports = __toCommonJS(const_exports);
26
+ var DEFAULT_UEDITOR_PATH = "./ueditor-resource";
27
+ var DEFAULT_UEDITOR_CONFIG = {
28
+ // 配置文件
29
+ UEDITOR_CONFIG: "ueditor.config.js",
30
+ // 主文件
31
+ UEDITOR_ALL: "ueditor.all.js",
32
+ // 语言文件
33
+ GET_UEDITOR_LANG: (lang = "zh-cn") => `lang/${lang}/${lang}.js`
34
+ };
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ DEFAULT_UEDITOR_CONFIG,
38
+ DEFAULT_UEDITOR_PATH
39
+ });
@@ -0,0 +1,77 @@
1
+ {
2
+ "imageActionName": "image",
3
+ "imageFieldName": "file",
4
+ "imageMaxSize": 10485760,
5
+ "imageAllowFiles": [
6
+ ".jpg",
7
+ ".png",
8
+ ".jpeg"
9
+ ],
10
+ "imageCompressEnable": true,
11
+ "imageCompressBorder": 5000,
12
+ "imageInsertAlign": "none",
13
+ "imageUrlPrefix": "",
14
+ "scrawlActionName": "crawl",
15
+ "scrawlFieldName": "file",
16
+ "scrawlMaxSize": 10485760,
17
+ "scrawlUrlPrefix": "",
18
+ "scrawlInsertAlign": "none",
19
+ "snapscreenActionName": "snap",
20
+ "snapscreenUrlPrefix": "",
21
+ "snapscreenInsertAlign": "none",
22
+ "catcherLocalDomain": [
23
+ "127.0.0.1",
24
+ "localhost"
25
+ ],
26
+ "catcherActionName": "catch",
27
+ "catcherFieldName": "source",
28
+ "catcherUrlPrefix": "",
29
+ "catcherMaxSize": 10485760,
30
+ "catcherAllowFiles": [
31
+ ".jpg",
32
+ ".png",
33
+ ".jpeg"
34
+ ],
35
+ "videoActionName": "video",
36
+ "videoFieldName": "file",
37
+ "videoUrlPrefix": "",
38
+ "videoMaxSize": 104857600,
39
+ "videoAllowFiles": [
40
+ ".mp4",
41
+ ".webm",
42
+ ".mkv"
43
+ ],
44
+ "audioActionName": "audio",
45
+ "audioFieldName": "file",
46
+ "audioUrlPrefix": "",
47
+ "audioMaxSize": 104857600,
48
+ "audioAllowFiles": [
49
+ ".mp3"
50
+ ],
51
+ "fileActionName": "file",
52
+ "fileFieldName": "file",
53
+ "fileUrlPrefix": "",
54
+ "fileMaxSize": 104857600,
55
+ "fileAllowFiles": [
56
+ ".zip",
57
+ ".pdf",
58
+ ".doc"
59
+ ],
60
+ "imageManagerActionName": "listImage",
61
+ "imageManagerListSize": 20,
62
+ "imageManagerUrlPrefix": "",
63
+ "imageManagerInsertAlign": "none",
64
+ "imageManagerAllowFiles": [
65
+ ".jpg",
66
+ ".png",
67
+ ".jpeg"
68
+ ],
69
+ "fileManagerActionName": "listFile",
70
+ "fileManagerUrlPrefix": "",
71
+ "fileManagerListSize": 20,
72
+ "fileManagerAllowFiles": [
73
+ ".zip",
74
+ ".pdf",
75
+ ".doc"
76
+ ]
77
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import LcdpUeditor from './LcdpUeditor';
2
+ import type { ILcdpUeditorProps } from './type';
3
+ export { LcdpUeditor, ILcdpUeditorProps, };
4
+ export default LcdpUeditor;
package/lib/index.js ADDED
@@ -0,0 +1,41 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.tsx
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ LcdpUeditor: () => import_LcdpUeditor.default,
33
+ default: () => src_default
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ var import_LcdpUeditor = __toESM(require("./LcdpUeditor"));
37
+ var src_default = import_LcdpUeditor.default;
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ LcdpUeditor
41
+ });
@@ -0,0 +1,21 @@
1
+ declare class UeditorResourceLoader {
2
+ private static instance;
3
+ private callbackList;
4
+ private errorCallbackList;
5
+ private isReady;
6
+ private loading;
7
+ private initError;
8
+ static startLoad(jsList: string[]): Promise<void>;
9
+ static getInstance(): UeditorResourceLoader;
10
+ /**
11
+ * 加载完成执行
12
+ * @param callback 回调函数
13
+ */
14
+ static onReady(callback: Function): void;
15
+ /**
16
+ * 资源加载失败执行
17
+ * @param callback
18
+ */
19
+ static onLoadError(callback: Function): void;
20
+ }
21
+ export default UeditorResourceLoader;
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/tools/UeditorResourceLoader.ts
20
+ var UeditorResourceLoader_exports = {};
21
+ __export(UeditorResourceLoader_exports, {
22
+ default: () => UeditorResourceLoader_default
23
+ });
24
+ module.exports = __toCommonJS(UeditorResourceLoader_exports);
25
+ var import_loadScript = require("./loadScript");
26
+ var UeditorResourceLoader = class {
27
+ constructor() {
28
+ this.callbackList = [];
29
+ this.errorCallbackList = [];
30
+ this.isReady = false;
31
+ this.loading = false;
32
+ this.initError = false;
33
+ }
34
+ static async startLoad(jsList) {
35
+ const inst = this.getInstance();
36
+ if (!inst.loading && !inst.isReady || inst.initError) {
37
+ inst.loading = true;
38
+ inst.initError = false;
39
+ try {
40
+ await (0, import_loadScript.loadScriptSync)(jsList);
41
+ if (window.UE) {
42
+ inst.isReady = true;
43
+ inst.loading = false;
44
+ while (inst.callbackList.length) {
45
+ const cb = inst.callbackList.pop();
46
+ cb && cb();
47
+ }
48
+ } else {
49
+ inst.loading = false;
50
+ inst.isReady = false;
51
+ inst.initError = true;
52
+ while (inst.errorCallbackList.length) {
53
+ const cb = inst.errorCallbackList.pop();
54
+ cb && cb();
55
+ }
56
+ }
57
+ } catch (error) {
58
+ inst.loading = false;
59
+ inst.isReady = false;
60
+ }
61
+ }
62
+ }
63
+ static getInstance() {
64
+ if (!this.instance) {
65
+ this.instance = new UeditorResourceLoader();
66
+ }
67
+ return this.instance;
68
+ }
69
+ /**
70
+ * 加载完成执行
71
+ * @param callback 回调函数
72
+ */
73
+ static onReady(callback) {
74
+ const inst = this.getInstance();
75
+ if (inst.isReady) {
76
+ callback();
77
+ } else {
78
+ inst.callbackList.push(callback);
79
+ }
80
+ }
81
+ /**
82
+ * 资源加载失败执行
83
+ * @param callback
84
+ */
85
+ static onLoadError(callback) {
86
+ const inst = this.getInstance();
87
+ inst.errorCallbackList.push(callback);
88
+ }
89
+ };
90
+ var UeditorResourceLoader_default = UeditorResourceLoader;
@@ -0,0 +1,5 @@
1
+ export declare const filterHtmlNode: (str: string) => {
2
+ str: string;
3
+ flag: boolean;
4
+ source: string;
5
+ };
@@ -0,0 +1,61 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/tools/filterHtmlNode.ts
20
+ var filterHtmlNode_exports = {};
21
+ __export(filterHtmlNode_exports, {
22
+ filterHtmlNode: () => filterHtmlNode
23
+ });
24
+ module.exports = __toCommonJS(filterHtmlNode_exports);
25
+ var filterHtmlNode = (str) => {
26
+ let flag = false;
27
+ if (typeof str !== "string")
28
+ return str || "";
29
+ const blacklist = ["script", "style", "iframe"];
30
+ const parser = new DOMParser();
31
+ const doc = parser.parseFromString(str, "text/html");
32
+ function cleanNode(node) {
33
+ var _a;
34
+ if (node.nodeType === 1) {
35
+ if (blacklist.indexOf(node.nodeName.toLowerCase()) !== -1) {
36
+ (_a = node.parentNode) == null ? void 0 : _a.removeChild(node);
37
+ return;
38
+ }
39
+ for (let i = node.attributes.length - 1; i >= 0; i -= 1) {
40
+ const attr = node.attributes[i];
41
+ if (attr.name.startsWith("on") || String(node.getAttribute(attr.name)).toLowerCase().indexOf("javascript:") !== -1) {
42
+ node.removeAttribute(attr.name);
43
+ flag = true;
44
+ }
45
+ }
46
+ }
47
+ for (let i = 0; i < node.childNodes.length; i += 1) {
48
+ cleanNode(node.childNodes[i]);
49
+ }
50
+ }
51
+ cleanNode(doc.body);
52
+ return {
53
+ str: doc.body.innerHTML,
54
+ flag,
55
+ source: str
56
+ };
57
+ };
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ filterHtmlNode
61
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 同步加载js
3
+ * @param strs 路径地址
4
+ */
5
+ export declare const loadScriptSync: (strs: string[]) => Promise<void>;
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/tools/loadScript.ts
20
+ var loadScript_exports = {};
21
+ __export(loadScript_exports, {
22
+ loadScriptSync: () => loadScriptSync
23
+ });
24
+ module.exports = __toCommonJS(loadScript_exports);
25
+ var loadScriptSync = async (strs) => {
26
+ for (let i = 0; i < strs.length; i += 1) {
27
+ const script = document.createElement("script");
28
+ script.src = strs[i];
29
+ script.async = false;
30
+ document.body.appendChild(script);
31
+ await new Promise((resolve) => {
32
+ script.onload = resolve;
33
+ });
34
+ }
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ loadScriptSync
39
+ });