@ecoding/components.antd 0.2.38 → 0.3.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.
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/style/style.less +16 -0
- package/package.json +16 -17
- package/lib/core/quill/index.d.ts +0 -13
- package/lib/core/quill/index.js +0 -137
package/lib/index.d.ts
CHANGED
|
@@ -18,5 +18,4 @@ export { default as FormList } from "./core/form.list";
|
|
|
18
18
|
export { default as AsyncSelect } from "./core/async-select";
|
|
19
19
|
export { default as AsyncTransfer } from "./core/async-transfer";
|
|
20
20
|
export { default as TablePro } from "./core/table-pro";
|
|
21
|
-
export { default as Quill } from "./core/quill";
|
|
22
21
|
export { default as http } from "./helpers/http";
|
package/lib/index.js
CHANGED
|
@@ -18,5 +18,4 @@ export { default as FormList } from "./core/form.list";
|
|
|
18
18
|
export { default as AsyncSelect } from "./core/async-select";
|
|
19
19
|
export { default as AsyncTransfer } from "./core/async-transfer";
|
|
20
20
|
export { default as TablePro } from "./core/table-pro";
|
|
21
|
-
export { default as Quill } from "./core/quill";
|
|
22
21
|
export { default as http } from "./helpers/http";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.m-form-list{
|
|
2
|
+
.ant-form-item{
|
|
3
|
+
margin-bottom: 0 !important;
|
|
4
|
+
}
|
|
5
|
+
// 末列固定
|
|
6
|
+
tbody tr:nth-child(even){
|
|
7
|
+
background-color: #f5fafc;
|
|
8
|
+
}
|
|
9
|
+
tbody tr:hover{
|
|
10
|
+
background-color: #fcfcfc;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ant_select_no_padding > .ant-select-selector{
|
|
15
|
+
padding: 0 !important;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,28 +21,27 @@
|
|
|
21
21
|
"unlink": "npm unlink",
|
|
22
22
|
"link": "npm link",
|
|
23
23
|
"dev": "tsc -w",
|
|
24
|
-
"build": "rm -rf lib && tsc"
|
|
24
|
+
"build": "rm -rf lib && tsc && rollup -c"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@ecoding/helper.event": "
|
|
28
|
-
"@ecoding/helper.is": "
|
|
29
|
-
"@ecoding/helper.json": "
|
|
30
|
-
"@ecoding/helper.request
|
|
31
|
-
"@ecoding/helper.
|
|
32
|
-
"
|
|
27
|
+
"@ecoding/helper.event": "*",
|
|
28
|
+
"@ecoding/helper.is": "*",
|
|
29
|
+
"@ecoding/helper.json": "*",
|
|
30
|
+
"@ecoding/helper.request": "*",
|
|
31
|
+
"@ecoding/helper.request.hook": "*",
|
|
32
|
+
"@ecoding/helper.url": "*",
|
|
33
|
+
"antd": ">=5.8.4",
|
|
33
34
|
"axios": ">=1.1.2"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@ecoding/helper.event": "
|
|
37
|
-
"@ecoding/helper.is": "
|
|
38
|
-
"@ecoding/helper.json": "
|
|
39
|
-
"@ecoding/helper.request
|
|
40
|
-
"@ecoding/helper.
|
|
37
|
+
"@ecoding/helper.event": "*",
|
|
38
|
+
"@ecoding/helper.is": "*",
|
|
39
|
+
"@ecoding/helper.json": "*",
|
|
40
|
+
"@ecoding/helper.request": "*",
|
|
41
|
+
"@ecoding/helper.request.hook": "*",
|
|
42
|
+
"@ecoding/helper.url": "*",
|
|
41
43
|
"antd": "^5.8.4",
|
|
42
44
|
"axios": "^1.1.2"
|
|
43
45
|
},
|
|
44
|
-
"
|
|
45
|
-
"react-quill": "^2.0.0"
|
|
46
|
-
},
|
|
47
|
-
"gitHead": "9b5a9f3404ebd8d8cf7d355c8dab89c77bd388f1"
|
|
46
|
+
"gitHead": "02da2b1b4eb83c6ee361a446973669aedb9d0cff"
|
|
48
47
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface IProps {
|
|
3
|
-
action?: string;
|
|
4
|
-
value?: string;
|
|
5
|
-
className?: string;
|
|
6
|
-
style?: any;
|
|
7
|
-
onChange?: any;
|
|
8
|
-
gif?: boolean;
|
|
9
|
-
size?: number;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
declare const Quill: React.FC<IProps>;
|
|
13
|
-
export default Quill;
|
package/lib/core/quill/index.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import React, { useMemo, useCallback, useState, useRef, lazy } from "react";
|
|
11
|
-
import { Upload, message } from "antd";
|
|
12
|
-
import Toast from "../../core/toast";
|
|
13
|
-
import http from "../../helpers/http";
|
|
14
|
-
const ReactQuill = lazy(() => import(/* webpackChunkName: "ReactQuill" */ /* webpackPrefetch: true */ "react-quill"));
|
|
15
|
-
const Quill = (props) => {
|
|
16
|
-
const r = http.getRequest();
|
|
17
|
-
const upRef = useRef();
|
|
18
|
-
const quillRef = useRef();
|
|
19
|
-
const [urlParams, setUrlParams] = useState("");
|
|
20
|
-
const modules = useMemo(() => {
|
|
21
|
-
return {
|
|
22
|
-
toolbar: {
|
|
23
|
-
container: [
|
|
24
|
-
["bold", "italic", "underline", "strike"],
|
|
25
|
-
["blockquote", "code-block"],
|
|
26
|
-
[{ header: 1 }, { header: 2 }],
|
|
27
|
-
[{ list: "ordered" }, { list: "bullet" }],
|
|
28
|
-
[{ script: "sub" }, { script: "super" }],
|
|
29
|
-
[{ indent: "-1" }, { indent: "+1" }],
|
|
30
|
-
[{ direction: "rtl" }],
|
|
31
|
-
[{ size: ["small", false, "large", "huge"] }],
|
|
32
|
-
[{ header: [1, 2, 3, 4, 5, 6, false] }],
|
|
33
|
-
[{ color: [] }, { background: [] }],
|
|
34
|
-
[{ font: [] }],
|
|
35
|
-
[{ align: [] }],
|
|
36
|
-
["link", "image"],
|
|
37
|
-
["clean"]
|
|
38
|
-
],
|
|
39
|
-
handlers: {
|
|
40
|
-
image: (value) => {
|
|
41
|
-
if (value) {
|
|
42
|
-
// ref.current && upRef.current.upload.uploader.uploadFiles([file]);
|
|
43
|
-
upRef.current && upRef.current.upload.uploader.fileInput.click();
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
quillRef.current.format("image", false);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}, []);
|
|
53
|
-
const getBase64 = useCallback((imgFile) => {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
const reader = new FileReader();
|
|
56
|
-
reader.addEventListener("load", () => resolve(reader.result));
|
|
57
|
-
reader.readAsDataURL(imgFile);
|
|
58
|
-
});
|
|
59
|
-
}, []);
|
|
60
|
-
const getImgwh = useCallback((base64) => {
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
const img = new Image();
|
|
63
|
-
img.onload = () => {
|
|
64
|
-
// 宽度固定
|
|
65
|
-
resolve({
|
|
66
|
-
w: img.width,
|
|
67
|
-
h: img.height
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
img.onerror = () => reject();
|
|
71
|
-
img.src = base64;
|
|
72
|
-
});
|
|
73
|
-
}, []);
|
|
74
|
-
const beforeUpload = useCallback((file) => {
|
|
75
|
-
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
const ary = ["jpg", "jpeg", "png"];
|
|
77
|
-
if (props.gif) {
|
|
78
|
-
ary.push("gif");
|
|
79
|
-
}
|
|
80
|
-
const isLt2M = file.size / 1024 / 1024 < (props.size || 1);
|
|
81
|
-
if (!isLt2M) {
|
|
82
|
-
message.error(`图片大小必须小于${props.size} MB!`);
|
|
83
|
-
reject();
|
|
84
|
-
}
|
|
85
|
-
if (ary.indexOf(file.type.toLowerCase().replace(/image\//g, "")) === -1) {
|
|
86
|
-
message.error(`请上传 ${ary.join(",")} 格式的图片!`);
|
|
87
|
-
reject();
|
|
88
|
-
}
|
|
89
|
-
const base64 = yield getBase64(file);
|
|
90
|
-
const wh = yield getImgwh(base64);
|
|
91
|
-
setUrlParams(`height=${wh.h}`);
|
|
92
|
-
resolve();
|
|
93
|
-
}));
|
|
94
|
-
}, []);
|
|
95
|
-
const handleChange = (info) => {
|
|
96
|
-
switch (info.file.status) {
|
|
97
|
-
case "uploading":
|
|
98
|
-
break;
|
|
99
|
-
case "done":
|
|
100
|
-
const url = info.file.response.data && info.file.response.data[0].imageUrl;
|
|
101
|
-
// setImageUrl(url);
|
|
102
|
-
// 获取富文本组件实例
|
|
103
|
-
const quill = quillRef.current.getEditor();
|
|
104
|
-
// 获取光标所在位置
|
|
105
|
-
const length = quill.getSelection().index;
|
|
106
|
-
// 插入图片,res为服务器返回的图片链接地址
|
|
107
|
-
quill.insertEmbed(length, "image", url);
|
|
108
|
-
// 调整光标到最后
|
|
109
|
-
quill.setSelection(length + 1);
|
|
110
|
-
break;
|
|
111
|
-
case "error":
|
|
112
|
-
Toast.error({
|
|
113
|
-
mask: true,
|
|
114
|
-
title: info.file.response
|
|
115
|
-
? info.file.response.retDesc || info.file.response.desc || info.file.response.message
|
|
116
|
-
: "服务出错,图片上传失败"
|
|
117
|
-
});
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const action = /^http|^\/\//i.test(props.action) ? `${props.action}?${urlParams}` : `${r.domain}${props.action}?${urlParams}`;
|
|
124
|
-
return (React.createElement(React.Suspense, { fallback: null },
|
|
125
|
-
React.createElement(ReactQuill, { onChange: props.onChange, defaultValue: props.value, ref: quillRef, modules: modules, theme: "snow", className: props.className, style: props.style }),
|
|
126
|
-
React.createElement("span", { style: { display: "none" } },
|
|
127
|
-
React.createElement(Upload, { ref: upRef, withCredentials: true, beforeUpload: beforeUpload, name: "file", listType: "picture-card", showUploadList: false, action: action, onChange: handleChange }))));
|
|
128
|
-
};
|
|
129
|
-
Quill.defaultProps = {
|
|
130
|
-
action: "/upload/img",
|
|
131
|
-
value: "",
|
|
132
|
-
gif: false,
|
|
133
|
-
size: 1,
|
|
134
|
-
className: "",
|
|
135
|
-
style: {}
|
|
136
|
-
};
|
|
137
|
-
export default Quill;
|