@hw-component/form 1.10.29 → 1.10.31
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/RichEditor/hooks.js +4 -9
- package/es/config.js +3 -1
- package/lib/RichEditor/hooks.js +4 -9
- package/lib/config.js +3 -1
- package/package.json +1 -1
- package/src/components/RichEditor/hooks.ts +5 -14
- package/src/components/RichEditor/index.tsx +1 -1
- package/src/components/config.ts +3 -1
- package/src/pages/Form/index.tsx +7 -0
package/es/RichEditor/hooks.js
CHANGED
|
@@ -13,13 +13,12 @@ var useProps = function useProps(_ref) {
|
|
|
13
13
|
var fileRequest = _ref.fileRequest,
|
|
14
14
|
valueType = _ref.valueType;
|
|
15
15
|
var _useFormConfigContext = useFormConfigContext("richEditorProps"),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
contextValueType = _useFormConfigContext3 === void 0 ? valueType : _useFormConfigContext3;
|
|
16
|
+
contextFileRequest = _useFormConfigContext.fileRequest,
|
|
17
|
+
_useFormConfigContext2 = _useFormConfigContext.valueType,
|
|
18
|
+
contextValueType = _useFormConfigContext2 === void 0 ? valueType : _useFormConfigContext2;
|
|
20
19
|
var cuRequest = fileRequest === null ? (_baseConfig$richEdito = baseConfig.richEditorProps) === null || _baseConfig$richEdito === void 0 ? void 0 : _baseConfig$richEdito.fileRequest : contextFileRequest;
|
|
21
20
|
return {
|
|
22
|
-
fileRequest: cuRequest,
|
|
21
|
+
fileRequest: fileRequest || cuRequest,
|
|
23
22
|
valueType: contextValueType
|
|
24
23
|
};
|
|
25
24
|
};
|
|
@@ -57,10 +56,6 @@ var useVC = function useVC(_ref3) {
|
|
|
57
56
|
var richValue = valueType === "html" ? BraftEditor.createEditorState(value) : value;
|
|
58
57
|
var change = function change(editorState) {
|
|
59
58
|
var changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
60
|
-
var isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
61
|
-
if (isEmpty && editorState.isEmpty()) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
59
|
onChange === null || onChange === void 0 || onChange(changeVal);
|
|
65
60
|
};
|
|
66
61
|
return {
|
package/es/config.js
CHANGED
|
@@ -78,7 +78,9 @@ var baseConfig = {
|
|
|
78
78
|
while (1) switch (_context2.prev = _context2.next) {
|
|
79
79
|
case 0:
|
|
80
80
|
_context2.next = 2;
|
|
81
|
-
return fileToBase64(
|
|
81
|
+
return fileToBase64({
|
|
82
|
+
originFileObj: file
|
|
83
|
+
});
|
|
82
84
|
case 2:
|
|
83
85
|
url = _context2.sent;
|
|
84
86
|
return _context2.abrupt("return", {
|
package/lib/RichEditor/hooks.js
CHANGED
|
@@ -14,13 +14,12 @@ var useProps = function useProps(_ref) {
|
|
|
14
14
|
var fileRequest = _ref.fileRequest,
|
|
15
15
|
valueType = _ref.valueType;
|
|
16
16
|
var _useFormConfigContext = FormConfigProvider.useFormConfigContext("richEditorProps"),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
contextValueType = _useFormConfigContext3 === void 0 ? valueType : _useFormConfigContext3;
|
|
17
|
+
contextFileRequest = _useFormConfigContext.fileRequest,
|
|
18
|
+
_useFormConfigContext2 = _useFormConfigContext.valueType,
|
|
19
|
+
contextValueType = _useFormConfigContext2 === void 0 ? valueType : _useFormConfigContext2;
|
|
21
20
|
var cuRequest = fileRequest === null ? (_baseConfig$richEdito = config.baseConfig.richEditorProps) === null || _baseConfig$richEdito === void 0 ? void 0 : _baseConfig$richEdito.fileRequest : contextFileRequest;
|
|
22
21
|
return {
|
|
23
|
-
fileRequest: cuRequest,
|
|
22
|
+
fileRequest: fileRequest || cuRequest,
|
|
24
23
|
valueType: contextValueType
|
|
25
24
|
};
|
|
26
25
|
};
|
|
@@ -58,10 +57,6 @@ var useVC = function useVC(_ref3) {
|
|
|
58
57
|
var richValue = valueType === "html" ? BraftEditor.createEditorState(value) : value;
|
|
59
58
|
var change = function change(editorState) {
|
|
60
59
|
var changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
61
|
-
var isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
62
|
-
if (isEmpty && editorState.isEmpty()) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
60
|
onChange === null || onChange === void 0 || onChange(changeVal);
|
|
66
61
|
};
|
|
67
62
|
return {
|
package/lib/config.js
CHANGED
|
@@ -79,7 +79,9 @@ var baseConfig = {
|
|
|
79
79
|
while (1) switch (_context2.prev = _context2.next) {
|
|
80
80
|
case 0:
|
|
81
81
|
_context2.next = 2;
|
|
82
|
-
return util.fileToBase64(
|
|
82
|
+
return util.fileToBase64({
|
|
83
|
+
originFileObj: file
|
|
84
|
+
});
|
|
83
85
|
case 2:
|
|
84
86
|
url = _context2.sent;
|
|
85
87
|
return _context2.abrupt("return", {
|
package/package.json
CHANGED
|
@@ -2,21 +2,18 @@ import { useFormConfigContext } from "../Form/Context/FormConfigProvider";
|
|
|
2
2
|
import { baseConfig } from "../config";
|
|
3
3
|
import type { IHRichEditorProps } from "src/components/RichEditor/modal";
|
|
4
4
|
import { useClassName } from "../hooks";
|
|
5
|
-
import {
|
|
5
|
+
import { useState } from "react";
|
|
6
6
|
import type { EditorState } from "braft-editor";
|
|
7
7
|
import BraftEditor from "braft-editor";
|
|
8
8
|
|
|
9
9
|
export const useProps = ({ fileRequest, valueType }: IHRichEditorProps) => {
|
|
10
10
|
const {
|
|
11
|
-
fileRequest: contextFileRequest
|
|
11
|
+
fileRequest: contextFileRequest,
|
|
12
12
|
valueType: contextValueType = valueType,
|
|
13
13
|
} = useFormConfigContext("richEditorProps");
|
|
14
|
-
const cuRequest =
|
|
15
|
-
fileRequest === null
|
|
16
|
-
? baseConfig.richEditorProps?.fileRequest
|
|
17
|
-
: contextFileRequest;
|
|
14
|
+
const cuRequest = fileRequest === null ? baseConfig.richEditorProps?.fileRequest : contextFileRequest;
|
|
18
15
|
return {
|
|
19
|
-
fileRequest: cuRequest,
|
|
16
|
+
fileRequest: fileRequest||cuRequest,
|
|
20
17
|
valueType: contextValueType,
|
|
21
18
|
};
|
|
22
19
|
};
|
|
@@ -49,15 +46,9 @@ export const useFocusClassname = ({
|
|
|
49
46
|
|
|
50
47
|
export const useVC = ({ value, onChange, valueType }: IHRichEditorProps) => {
|
|
51
48
|
const richValue: EditorState | undefined =
|
|
52
|
-
valueType === "html"
|
|
53
|
-
? BraftEditor.createEditorState(value)
|
|
54
|
-
: (value as EditorState);
|
|
49
|
+
valueType === "html" ? BraftEditor.createEditorState(value) : (value as EditorState);
|
|
55
50
|
const change = (editorState) => {
|
|
56
51
|
const changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
57
|
-
const isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
58
|
-
if (isEmpty && editorState.isEmpty()) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
52
|
onChange?.(changeVal);
|
|
62
53
|
};
|
|
63
54
|
return {
|
|
@@ -49,7 +49,7 @@ const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
|
49
49
|
inputValue: (item, initValue) => {
|
|
50
50
|
const { name = "" } = item;
|
|
51
51
|
const keyName = name as string;
|
|
52
|
-
|
|
52
|
+
const itemVal = initValue[keyName];
|
|
53
53
|
const initVal =
|
|
54
54
|
typeof itemVal === "string"
|
|
55
55
|
? BraftEditor.createEditorState(itemVal)
|
package/src/components/config.ts
CHANGED
|
@@ -51,7 +51,9 @@ export const baseConfig: IFormConfigContextProps = {
|
|
|
51
51
|
itemProps: {},
|
|
52
52
|
richEditorProps: {
|
|
53
53
|
fileRequest: async (file: any) => {
|
|
54
|
-
const url = await fileToBase64(
|
|
54
|
+
const url = await fileToBase64({
|
|
55
|
+
originFileObj:file
|
|
56
|
+
});
|
|
55
57
|
return {
|
|
56
58
|
url,
|
|
57
59
|
};
|