@hw-component/form 1.10.30 → 1.10.32
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
CHANGED
|
@@ -56,10 +56,6 @@ var useVC = function useVC(_ref3) {
|
|
|
56
56
|
var richValue = valueType === "html" ? BraftEditor.createEditorState(value) : value;
|
|
57
57
|
var change = function change(editorState) {
|
|
58
58
|
var changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
59
|
-
var isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
60
|
-
if (isEmpty && editorState.isEmpty()) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
59
|
onChange === null || onChange === void 0 || onChange(changeVal);
|
|
64
60
|
};
|
|
65
61
|
return {
|
|
@@ -76,10 +72,9 @@ var useUploadFn = function useUploadFn(_ref4) {
|
|
|
76
72
|
while (1) switch (_context.prev = _context.next) {
|
|
77
73
|
case 0:
|
|
78
74
|
file = params.file, id = params.id;
|
|
79
|
-
|
|
80
|
-
_context.next = 4;
|
|
75
|
+
_context.next = 3;
|
|
81
76
|
return fileRequest === null || fileRequest === void 0 ? void 0 : fileRequest(file, params);
|
|
82
|
-
case
|
|
77
|
+
case 3:
|
|
83
78
|
_yield$fileRequest = _context.sent;
|
|
84
79
|
url = _yield$fileRequest.url;
|
|
85
80
|
params.success({
|
|
@@ -94,7 +89,7 @@ var useUploadFn = function useUploadFn(_ref4) {
|
|
|
94
89
|
poster: url
|
|
95
90
|
}
|
|
96
91
|
});
|
|
97
|
-
case
|
|
92
|
+
case 6:
|
|
98
93
|
case "end":
|
|
99
94
|
return _context.stop();
|
|
100
95
|
}
|
package/es/RichEditor/index.js
CHANGED
|
@@ -62,6 +62,9 @@ var Index = function Index(_ref, ref) {
|
|
|
62
62
|
name = _item$name === void 0 ? "" : _item$name;
|
|
63
63
|
var keyName = name;
|
|
64
64
|
var itemVal = initValue[keyName];
|
|
65
|
+
if (valueType === "state") {
|
|
66
|
+
return _defineProperty({}, keyName, itemVal);
|
|
67
|
+
}
|
|
65
68
|
var initVal = typeof itemVal === "string" ? BraftEditor.createEditorState(itemVal) : itemVal;
|
|
66
69
|
return _defineProperty({}, keyName, initVal);
|
|
67
70
|
},
|
|
@@ -70,6 +73,9 @@ var Index = function Index(_ref, ref) {
|
|
|
70
73
|
name = _item$name2 === void 0 ? "" : _item$name2;
|
|
71
74
|
var keyName = name;
|
|
72
75
|
var itemVal = _outputValue[keyName];
|
|
76
|
+
if (valueType === "state") {
|
|
77
|
+
return _defineProperty({}, keyName, itemVal);
|
|
78
|
+
}
|
|
73
79
|
var outputVal = typeof itemVal === "string" ? itemVal : itemVal === null || itemVal === void 0 ? void 0 : itemVal.toHTML();
|
|
74
80
|
return _defineProperty({}, keyName, outputVal);
|
|
75
81
|
}
|
package/lib/RichEditor/hooks.js
CHANGED
|
@@ -57,10 +57,6 @@ var useVC = function useVC(_ref3) {
|
|
|
57
57
|
var richValue = valueType === "html" ? BraftEditor.createEditorState(value) : value;
|
|
58
58
|
var change = function change(editorState) {
|
|
59
59
|
var changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
60
|
-
var isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
61
|
-
if (isEmpty && editorState.isEmpty()) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
60
|
onChange === null || onChange === void 0 || onChange(changeVal);
|
|
65
61
|
};
|
|
66
62
|
return {
|
|
@@ -77,10 +73,9 @@ var useUploadFn = function useUploadFn(_ref4) {
|
|
|
77
73
|
while (1) switch (_context.prev = _context.next) {
|
|
78
74
|
case 0:
|
|
79
75
|
file = params.file, id = params.id;
|
|
80
|
-
|
|
81
|
-
_context.next = 4;
|
|
76
|
+
_context.next = 3;
|
|
82
77
|
return fileRequest === null || fileRequest === void 0 ? void 0 : fileRequest(file, params);
|
|
83
|
-
case
|
|
78
|
+
case 3:
|
|
84
79
|
_yield$fileRequest = _context.sent;
|
|
85
80
|
url = _yield$fileRequest.url;
|
|
86
81
|
params.success({
|
|
@@ -95,7 +90,7 @@ var useUploadFn = function useUploadFn(_ref4) {
|
|
|
95
90
|
poster: url
|
|
96
91
|
}
|
|
97
92
|
});
|
|
98
|
-
case
|
|
93
|
+
case 6:
|
|
99
94
|
case "end":
|
|
100
95
|
return _context.stop();
|
|
101
96
|
}
|
package/lib/RichEditor/index.js
CHANGED
|
@@ -65,6 +65,9 @@ var Index = function Index(_ref, ref) {
|
|
|
65
65
|
name = _item$name === void 0 ? "" : _item$name;
|
|
66
66
|
var keyName = name;
|
|
67
67
|
var itemVal = initValue[keyName];
|
|
68
|
+
if (valueType === "state") {
|
|
69
|
+
return _defineProperty({}, keyName, itemVal);
|
|
70
|
+
}
|
|
68
71
|
var initVal = typeof itemVal === "string" ? BraftEditor.createEditorState(itemVal) : itemVal;
|
|
69
72
|
return _defineProperty({}, keyName, initVal);
|
|
70
73
|
},
|
|
@@ -73,6 +76,9 @@ var Index = function Index(_ref, ref) {
|
|
|
73
76
|
name = _item$name2 === void 0 ? "" : _item$name2;
|
|
74
77
|
var keyName = name;
|
|
75
78
|
var itemVal = _outputValue[keyName];
|
|
79
|
+
if (valueType === "state") {
|
|
80
|
+
return _defineProperty({}, keyName, itemVal);
|
|
81
|
+
}
|
|
76
82
|
var outputVal = typeof itemVal === "string" ? itemVal : itemVal === null || itemVal === void 0 ? void 0 : itemVal.toHTML();
|
|
77
83
|
return _defineProperty({}, keyName, outputVal);
|
|
78
84
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ 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
|
|
|
@@ -46,15 +46,9 @@ export const useFocusClassname = ({
|
|
|
46
46
|
|
|
47
47
|
export const useVC = ({ value, onChange, valueType }: IHRichEditorProps) => {
|
|
48
48
|
const richValue: EditorState | undefined =
|
|
49
|
-
valueType === "html"
|
|
50
|
-
? BraftEditor.createEditorState(value)
|
|
51
|
-
: (value as EditorState);
|
|
49
|
+
valueType === "html" ? BraftEditor.createEditorState(value) : (value as EditorState);
|
|
52
50
|
const change = (editorState) => {
|
|
53
51
|
const changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
54
|
-
const isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
55
|
-
if (isEmpty && editorState.isEmpty()) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
52
|
onChange?.(changeVal);
|
|
59
53
|
};
|
|
60
54
|
return {
|
|
@@ -66,7 +60,6 @@ export const useVC = ({ value, onChange, valueType }: IHRichEditorProps) => {
|
|
|
66
60
|
export const useUploadFn = ({ fileRequest }: IHRichEditorProps) => {
|
|
67
61
|
return async (params) => {
|
|
68
62
|
const { file, id } = params;
|
|
69
|
-
console.log(params,"pppppp")
|
|
70
63
|
const { url } = await fileRequest?.(file, params);
|
|
71
64
|
params.success({
|
|
72
65
|
url,
|
|
@@ -50,6 +50,11 @@ const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
|
50
50
|
const { name = "" } = item;
|
|
51
51
|
const keyName = name as string;
|
|
52
52
|
const itemVal = initValue[keyName];
|
|
53
|
+
if (valueType==="state"){
|
|
54
|
+
return {
|
|
55
|
+
[keyName]: itemVal,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
53
58
|
const initVal =
|
|
54
59
|
typeof itemVal === "string"
|
|
55
60
|
? BraftEditor.createEditorState(itemVal)
|
|
@@ -62,6 +67,11 @@ const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
|
62
67
|
const { name = "" } = item;
|
|
63
68
|
const keyName = name as string;
|
|
64
69
|
const itemVal = outputValue[keyName];
|
|
70
|
+
if (valueType==="state"){
|
|
71
|
+
return {
|
|
72
|
+
[keyName]: itemVal,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
65
75
|
const outputVal =
|
|
66
76
|
typeof itemVal === "string" ? itemVal : itemVal?.toHTML();
|
|
67
77
|
return {
|