@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.1 → 1.0.0-alpha.11
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.
- package/es/LcdpUeditor.d.ts +6 -0
- package/es/LcdpUeditor.js +37 -13
- package/es/type.d.ts +1 -1
- package/lib/LcdpUeditor.d.ts +80 -0
- package/lib/LcdpUeditor.js +260 -0
- package/lib/const.d.ts +12 -0
- package/lib/const.js +39 -0
- package/lib/defaultConfig.json +77 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +41 -0
- package/lib/tools/UeditorResourceLoader.d.ts +21 -0
- package/lib/tools/UeditorResourceLoader.js +90 -0
- package/lib/tools/loadScript.d.ts +5 -0
- package/lib/tools/loadScript.js +39 -0
- package/lib/type.d.ts +142 -0
- package/lib/type.js +17 -0
- package/package.json +5 -3
- package/ueditor-resource/dialogs/image/image.js +1 -1
- package/ueditor-resource/dialogs/video/video.js +1 -1
- package/ueditor-resource/index.html +146 -146
- package/ueditor-resource/lang/zh-tw/images/copy.png +0 -0
- package/ueditor-resource/lang/zh-tw/images/localimage.png +0 -0
- package/ueditor-resource/lang/zh-tw/images/music.png +0 -0
- package/ueditor-resource/lang/zh-tw/images/upload.png +0 -0
- package/ueditor-resource/lang/zh-tw/zh-tw.js +748 -0
- package/ueditor-resource/themes/default/css/ueditor.css +1 -1
- package/ueditor-resource/ueditor.all.js +2 -2
- package/ueditor-resource/ueditor.config.js +0 -1
package/es/LcdpUeditor.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
|
|
|
37
37
|
* 上传文件函数
|
|
38
38
|
*/
|
|
39
39
|
private uploadFunction;
|
|
40
|
+
/**
|
|
41
|
+
* 是否加载完成
|
|
42
|
+
*/
|
|
43
|
+
private isReady;
|
|
40
44
|
/**
|
|
41
45
|
* 初始加载失败
|
|
42
46
|
*/
|
|
@@ -48,7 +52,9 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
|
|
|
48
52
|
*/
|
|
49
53
|
editorConfig: any;
|
|
50
54
|
constructor(props: ILcdpUeditorProps);
|
|
55
|
+
componentDidMount(): void;
|
|
51
56
|
componentWillReceiveProps(nextProps: ILcdpUeditorProps): void;
|
|
57
|
+
componentWillUnmount(): void;
|
|
52
58
|
private onContentChange;
|
|
53
59
|
private getExtString;
|
|
54
60
|
/**
|
package/es/LcdpUeditor.js
CHANGED
|
@@ -65,6 +65,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
65
65
|
* 上传文件函数
|
|
66
66
|
*/
|
|
67
67
|
_defineProperty(_assertThisInitialized(_this), "uploadFunction", void 0);
|
|
68
|
+
/**
|
|
69
|
+
* 是否加载完成
|
|
70
|
+
*/
|
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "isReady", false);
|
|
68
72
|
/**
|
|
69
73
|
* 初始加载失败
|
|
70
74
|
*/
|
|
@@ -110,30 +114,43 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
110
114
|
selectCallback: function selectCallback(cb, type) {
|
|
111
115
|
_this.fileSelect(cb, type);
|
|
112
116
|
},
|
|
113
|
-
uploadFunction: _this.uploadFunction
|
|
117
|
+
uploadFunction: _this.uploadFunction,
|
|
118
|
+
initialContent: _this.props.value || ''
|
|
114
119
|
});
|
|
115
|
-
_this.initUeditor();
|
|
116
120
|
_this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
|
|
117
121
|
return _this;
|
|
118
122
|
}
|
|
119
123
|
_createClass(LcdpUeditor, [{
|
|
124
|
+
key: "componentDidMount",
|
|
125
|
+
value: function componentDidMount() {
|
|
126
|
+
this.initUeditor();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
120
129
|
key: "componentWillReceiveProps",
|
|
121
130
|
value: function componentWillReceiveProps(nextProps) {
|
|
122
|
-
if (
|
|
123
|
-
this.
|
|
124
|
-
|
|
131
|
+
if (this.isReady) {
|
|
132
|
+
if ('value' in nextProps && this.currentContent !== nextProps.value) {
|
|
133
|
+
this.isReportFlag = false;
|
|
125
134
|
this.ueditorInst.setContent(nextProps.value);
|
|
126
135
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
// 禁用操作需要调用指定的api进行操作
|
|
137
|
+
if (nextProps.disabled !== this.props.disabled) {
|
|
138
|
+
if (nextProps.disabled) {
|
|
139
|
+
this.ueditorInst.setDisabled();
|
|
140
|
+
} else {
|
|
141
|
+
this.ueditorInst.setEnabled();
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "componentWillUnmount",
|
|
148
|
+
value: function componentWillUnmount() {
|
|
149
|
+
if (this.isReady) {
|
|
150
|
+
var _this$ueditorInst, _this$ueditorInst$des;
|
|
151
|
+
(_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0 || (_this$ueditorInst$des = _this$ueditorInst.destroy) === null || _this$ueditorInst$des === void 0 || _this$ueditorInst$des.call(_this$ueditorInst);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
137
154
|
}, {
|
|
138
155
|
key: "onContentChange",
|
|
139
156
|
value: function onContentChange() {
|
|
@@ -284,6 +301,13 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
284
301
|
UeditorResourceLoader.onReady(function () {
|
|
285
302
|
_this3.ueditorInst = window.UE.getEditor(_this3.containerId, _this3.editorConfig);
|
|
286
303
|
_this3.ueditorInst.ready(function () {
|
|
304
|
+
_this3.isReady = true;
|
|
305
|
+
// 禁用状态设置
|
|
306
|
+
if (_this3.props.disabled) {
|
|
307
|
+
_this3.ueditorInst.setDisabled();
|
|
308
|
+
} else {
|
|
309
|
+
_this3.ueditorInst.setEnabled();
|
|
310
|
+
}
|
|
287
311
|
_this3.ueditorInst.addListener('contentChange', function () {
|
|
288
312
|
_this3.debounceContentChange();
|
|
289
313
|
});
|
|
@@ -291,7 +315,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
291
315
|
});
|
|
292
316
|
_this3.mountRef();
|
|
293
317
|
});
|
|
294
|
-
jsList = ["".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_CONFIG), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.GET_UEDITOR_LANG())];
|
|
318
|
+
jsList = ["".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_CONFIG), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.GET_UEDITOR_LANG(this.props.lang || 'zh-cn'))];
|
|
295
319
|
UeditorResourceLoader.onLoadError(function () {
|
|
296
320
|
_this3.setState({
|
|
297
321
|
initError: true
|
package/es/type.d.ts
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ILcdpUeditorProps } from './type';
|
|
3
|
+
declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
|
|
4
|
+
/**
|
|
5
|
+
* 静态资源地址
|
|
6
|
+
*/
|
|
7
|
+
ueditorPath: string;
|
|
8
|
+
/**
|
|
9
|
+
* 文件上传inputRef
|
|
10
|
+
*/
|
|
11
|
+
private inputRef;
|
|
12
|
+
/**
|
|
13
|
+
* 编辑器容器ref
|
|
14
|
+
*/
|
|
15
|
+
private containerRef;
|
|
16
|
+
/**
|
|
17
|
+
* 编辑器容器id
|
|
18
|
+
*/
|
|
19
|
+
private containerId;
|
|
20
|
+
/**
|
|
21
|
+
* 编辑器实例
|
|
22
|
+
*/
|
|
23
|
+
private ueditorInst;
|
|
24
|
+
/**
|
|
25
|
+
* 是否上报
|
|
26
|
+
*/
|
|
27
|
+
private isReportFlag;
|
|
28
|
+
/**
|
|
29
|
+
* 值变化节流函数
|
|
30
|
+
*/
|
|
31
|
+
private debounceContentChange;
|
|
32
|
+
/**
|
|
33
|
+
* 当前值
|
|
34
|
+
*/
|
|
35
|
+
private currentContent;
|
|
36
|
+
/**
|
|
37
|
+
* 上传文件函数
|
|
38
|
+
*/
|
|
39
|
+
private uploadFunction;
|
|
40
|
+
/**
|
|
41
|
+
* 是否加载完成
|
|
42
|
+
*/
|
|
43
|
+
private isReady;
|
|
44
|
+
/**
|
|
45
|
+
* 初始加载失败
|
|
46
|
+
*/
|
|
47
|
+
state: Readonly<{
|
|
48
|
+
initError: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* 编辑器配置项
|
|
52
|
+
*/
|
|
53
|
+
editorConfig: any;
|
|
54
|
+
constructor(props: ILcdpUeditorProps);
|
|
55
|
+
componentDidMount(): void;
|
|
56
|
+
componentWillReceiveProps(nextProps: ILcdpUeditorProps): void;
|
|
57
|
+
componentWillUnmount(): void;
|
|
58
|
+
private onContentChange;
|
|
59
|
+
private getExtString;
|
|
60
|
+
/**
|
|
61
|
+
* 文件选择
|
|
62
|
+
* @param cb 回调给编辑器
|
|
63
|
+
* @param type 类型
|
|
64
|
+
*/
|
|
65
|
+
private fileSelect;
|
|
66
|
+
/**
|
|
67
|
+
* 对外暴露编辑器实例
|
|
68
|
+
*/
|
|
69
|
+
private mountRef;
|
|
70
|
+
/**
|
|
71
|
+
* 初始化样式
|
|
72
|
+
*/
|
|
73
|
+
private initStyle;
|
|
74
|
+
/**
|
|
75
|
+
* 初始化编辑器实例
|
|
76
|
+
*/
|
|
77
|
+
initUeditor(): Promise<void>;
|
|
78
|
+
render(): React.ReactNode;
|
|
79
|
+
}
|
|
80
|
+
export default LcdpUeditor;
|
|
@@ -0,0 +1,260 @@
|
|
|
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_lodash = require("lodash");
|
|
40
|
+
var LcdpUeditor = class extends import_react.default.Component {
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
43
|
+
/**
|
|
44
|
+
* 静态资源地址
|
|
45
|
+
*/
|
|
46
|
+
this.ueditorPath = import_const.DEFAULT_UEDITOR_PATH;
|
|
47
|
+
/**
|
|
48
|
+
* 文件上传inputRef
|
|
49
|
+
*/
|
|
50
|
+
this.inputRef = import_react.default.createRef();
|
|
51
|
+
/**
|
|
52
|
+
* 编辑器容器ref
|
|
53
|
+
*/
|
|
54
|
+
this.containerRef = import_react.default.createRef();
|
|
55
|
+
/**
|
|
56
|
+
* 编辑器实例
|
|
57
|
+
*/
|
|
58
|
+
this.ueditorInst = null;
|
|
59
|
+
/**
|
|
60
|
+
* 是否上报
|
|
61
|
+
*/
|
|
62
|
+
this.isReportFlag = true;
|
|
63
|
+
/**
|
|
64
|
+
* 当前值
|
|
65
|
+
*/
|
|
66
|
+
this.currentContent = "";
|
|
67
|
+
/**
|
|
68
|
+
* 是否加载完成
|
|
69
|
+
*/
|
|
70
|
+
this.isReady = false;
|
|
71
|
+
/**
|
|
72
|
+
* 初始加载失败
|
|
73
|
+
*/
|
|
74
|
+
this.state = {
|
|
75
|
+
initError: false
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* 编辑器配置项
|
|
79
|
+
*/
|
|
80
|
+
this.editorConfig = {};
|
|
81
|
+
const { config } = props;
|
|
82
|
+
this.containerId = `ueditor_${Date.now()}_${String(Math.random()).slice(2, 6)}`;
|
|
83
|
+
if (this.props.ueditorPath) {
|
|
84
|
+
this.ueditorPath = this.props.ueditorPath;
|
|
85
|
+
}
|
|
86
|
+
this.currentContent = this.props.value;
|
|
87
|
+
this.uploadFunction = (file, type) => {
|
|
88
|
+
var _a;
|
|
89
|
+
if (type === "image" && ((_a = this.props.config) == null ? void 0 : _a.imageType) === "base64") {
|
|
90
|
+
const reader = new FileReader();
|
|
91
|
+
reader.readAsDataURL(file);
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
reader.onload = ({ target }) => resolve({
|
|
94
|
+
state: "SUCCESS",
|
|
95
|
+
url: target == null ? void 0 : target.result,
|
|
96
|
+
title: file.name,
|
|
97
|
+
original: file.name
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (this.props.uploadFunction) {
|
|
102
|
+
return this.props.uploadFunction(file);
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
this.editorConfig = {
|
|
107
|
+
...import_defaultConfig.default,
|
|
108
|
+
initialFrameHeight: (config == null ? void 0 : config.height) || 300,
|
|
109
|
+
autoHeightEnabled: false,
|
|
110
|
+
selectCallback: (cb, type) => {
|
|
111
|
+
this.fileSelect(cb, type);
|
|
112
|
+
},
|
|
113
|
+
uploadFunction: this.uploadFunction,
|
|
114
|
+
initialContent: this.props.value || ""
|
|
115
|
+
};
|
|
116
|
+
this.debounceContentChange = (0, import_lodash.debounce)(this.onContentChange.bind(this), 300);
|
|
117
|
+
}
|
|
118
|
+
componentDidMount() {
|
|
119
|
+
this.initUeditor();
|
|
120
|
+
}
|
|
121
|
+
componentWillReceiveProps(nextProps) {
|
|
122
|
+
if (this.isReady) {
|
|
123
|
+
if ("value" in nextProps && this.currentContent !== nextProps.value) {
|
|
124
|
+
this.isReportFlag = false;
|
|
125
|
+
this.ueditorInst.setContent(nextProps.value);
|
|
126
|
+
}
|
|
127
|
+
if (nextProps.disabled !== this.props.disabled) {
|
|
128
|
+
if (nextProps.disabled) {
|
|
129
|
+
this.ueditorInst.setDisabled();
|
|
130
|
+
} else {
|
|
131
|
+
this.ueditorInst.setEnabled();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
componentWillUnmount() {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
if (this.isReady) {
|
|
139
|
+
(_b = (_a = this.ueditorInst) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
onContentChange() {
|
|
143
|
+
if (!this.isReportFlag) {
|
|
144
|
+
this.isReportFlag = true;
|
|
145
|
+
} else if (this.props.onChange) {
|
|
146
|
+
this.currentContent = this.ueditorInst.getContent();
|
|
147
|
+
this.props.onChange(this.currentContent);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
getExtString(str) {
|
|
151
|
+
if (Array.isArray(str)) {
|
|
152
|
+
return str.join(",");
|
|
153
|
+
}
|
|
154
|
+
return str || "";
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* 文件选择
|
|
158
|
+
* @param cb 回调给编辑器
|
|
159
|
+
* @param type 类型
|
|
160
|
+
*/
|
|
161
|
+
async fileSelect(cb, type) {
|
|
162
|
+
if (this.inputRef.current) {
|
|
163
|
+
let accept = "";
|
|
164
|
+
switch (type) {
|
|
165
|
+
case "image":
|
|
166
|
+
accept = this.getExtString(this.editorConfig.imageAllowFiles);
|
|
167
|
+
break;
|
|
168
|
+
case "audio":
|
|
169
|
+
accept = this.getExtString(this.editorConfig.audioAllowFiles);
|
|
170
|
+
break;
|
|
171
|
+
case "video":
|
|
172
|
+
accept = this.getExtString(this.editorConfig.videoAllowFiles);
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
this.inputRef.current.accept = accept || "";
|
|
178
|
+
this.inputRef.current.click();
|
|
179
|
+
this.inputRef.current.onchange = async (e) => {
|
|
180
|
+
let file;
|
|
181
|
+
const fileList = e.target.files;
|
|
182
|
+
if ((fileList == null ? void 0 : fileList.length) > 0) {
|
|
183
|
+
file = fileList[0];
|
|
184
|
+
}
|
|
185
|
+
if (file) {
|
|
186
|
+
const res = await this.uploadFunction(file, type);
|
|
187
|
+
if (res.state === "SUCCESS" && res.url) {
|
|
188
|
+
cb(res);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
this.inputRef.current.value = "";
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 对外暴露编辑器实例
|
|
197
|
+
*/
|
|
198
|
+
mountRef() {
|
|
199
|
+
if (this.props.onMount) {
|
|
200
|
+
this.props.onMount(this.ueditorInst);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 初始化样式
|
|
205
|
+
*/
|
|
206
|
+
initStyle() {
|
|
207
|
+
var _a, _b;
|
|
208
|
+
const { toolbarColor, backgroundColor } = this.props.style || {};
|
|
209
|
+
if (this.containerRef.current) {
|
|
210
|
+
if (backgroundColor) {
|
|
211
|
+
const editor = this.containerRef.current.querySelector(".edui-editor");
|
|
212
|
+
(_a = editor.style) == null ? void 0 : _a.setProperty("background-color", backgroundColor);
|
|
213
|
+
}
|
|
214
|
+
if (toolbarColor) {
|
|
215
|
+
const toolBox = this.containerRef.current.querySelector(".edui-editor-toolbarboxouter");
|
|
216
|
+
(_b = toolBox.style) == null ? void 0 : _b.setProperty("background-color", toolbarColor);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 初始化编辑器实例
|
|
222
|
+
*/
|
|
223
|
+
async initUeditor() {
|
|
224
|
+
import_UeditorResourceLoader.default.onReady(() => {
|
|
225
|
+
this.ueditorInst = window.UE.getEditor(this.containerId, this.editorConfig);
|
|
226
|
+
this.ueditorInst.ready(() => {
|
|
227
|
+
this.isReady = true;
|
|
228
|
+
if (this.props.disabled) {
|
|
229
|
+
this.ueditorInst.setDisabled();
|
|
230
|
+
} else {
|
|
231
|
+
this.ueditorInst.setEnabled();
|
|
232
|
+
}
|
|
233
|
+
this.ueditorInst.addListener("contentChange", () => {
|
|
234
|
+
this.debounceContentChange();
|
|
235
|
+
});
|
|
236
|
+
this.initStyle();
|
|
237
|
+
});
|
|
238
|
+
this.mountRef();
|
|
239
|
+
});
|
|
240
|
+
const jsList = [
|
|
241
|
+
`${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.UEDITOR_CONFIG}`,
|
|
242
|
+
`${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL}`,
|
|
243
|
+
`${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.GET_UEDITOR_LANG(this.props.lang || "zh-cn")}`
|
|
244
|
+
];
|
|
245
|
+
import_UeditorResourceLoader.default.onLoadError(() => {
|
|
246
|
+
this.setState({
|
|
247
|
+
initError: true
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
import_UeditorResourceLoader.default.startLoad(jsList);
|
|
251
|
+
}
|
|
252
|
+
render() {
|
|
253
|
+
const { initError } = this.state;
|
|
254
|
+
if (initError) {
|
|
255
|
+
throw new Error("Load Ueditor Resource Fail");
|
|
256
|
+
}
|
|
257
|
+
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" }));
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
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
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;
|