mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:27:04 +00:00
fix(client): fix special white space happens when paste content (#5497)
This commit is contained in:
parent
4203b7c7d5
commit
4a6bf09737
@ -210,7 +210,7 @@ function getCurrentRange(element: HTMLElement): RangeIndexes {
|
|||||||
|
|
||||||
export function TextArea(props) {
|
export function TextArea(props) {
|
||||||
const { wrapSSR, hashId, componentCls } = useStyles();
|
const { wrapSSR, hashId, componentCls } = useStyles();
|
||||||
const { value = '', scope, onChange, multiline = true, changeOnSelect, style } = props;
|
const { value = '', scope, onChange, changeOnSelect, style } = props;
|
||||||
const inputRef = useRef<HTMLDivElement>(null);
|
const inputRef = useRef<HTMLDivElement>(null);
|
||||||
const [options, setOptions] = useState([]);
|
const [options, setOptions] = useState([]);
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
@ -420,9 +420,10 @@ export function TextArea(props) {
|
|||||||
hashId,
|
hashId,
|
||||||
'ant-input',
|
'ant-input',
|
||||||
{ 'ant-input-disabled': disabled },
|
{ 'ant-input-disabled': disabled },
|
||||||
|
// NOTE: `pre-wrap` here for avoid the ` ` (\x160) issue when paste content, we need normal space (\x32).
|
||||||
css`
|
css`
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
white-space: ${multiline ? 'normal' : 'nowrap'};
|
white-space: pre-wrap;
|
||||||
|
|
||||||
&[placeholder]:empty::before {
|
&[placeholder]:empty::before {
|
||||||
content: attr(placeholder);
|
content: attr(placeholder);
|
||||||
|
@ -25,8 +25,8 @@ export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params'
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ContentTypeTransformers = {
|
const ContentTypeTransformers = {
|
||||||
'application/json'(data) {
|
'text/plain'(data) {
|
||||||
return data;
|
return data.toString();
|
||||||
},
|
},
|
||||||
'application/x-www-form-urlencoded'(data: { name: string; value: string }[]) {
|
'application/x-www-form-urlencoded'(data: { name: string; value: string }[]) {
|
||||||
return new URLSearchParams(
|
return new URLSearchParams(
|
||||||
@ -52,6 +52,7 @@ async function request(config) {
|
|||||||
|
|
||||||
// TODO(feat): only support JSON type for now, should support others in future
|
// TODO(feat): only support JSON type for now, should support others in future
|
||||||
headers['Content-Type'] = contentType;
|
headers['Content-Type'] = contentType;
|
||||||
|
const transformer = ContentTypeTransformers[contentType];
|
||||||
|
|
||||||
return axios.request({
|
return axios.request({
|
||||||
url: trim(url),
|
url: trim(url),
|
||||||
@ -61,7 +62,7 @@ async function request(config) {
|
|||||||
timeout,
|
timeout,
|
||||||
...(method.toLowerCase() !== 'get' && data != null
|
...(method.toLowerCase() !== 'get' && data != null
|
||||||
? {
|
? {
|
||||||
data: ContentTypeTransformers[contentType](data),
|
data: transformer ? transformer(data) : data,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user