diff --git a/packages/admin/src/components/bindingFacade/fields/TextField.tsx b/packages/admin/src/components/bindingFacade/fields/TextField.tsx index 81299cecdb..e57df57f9a 100644 --- a/packages/admin/src/components/bindingFacade/fields/TextField.tsx +++ b/packages/admin/src/components/bindingFacade/fields/TextField.tsx @@ -2,18 +2,25 @@ import { TextInput, TextInputProps } from '@contember/ui' import { SimpleRelativeSingleField, SimpleRelativeSingleFieldProps } from '../auxiliary' import { stringFieldParser, useTextInput } from './useTextInput' -export type TextFieldProps = SimpleRelativeSingleFieldProps & - Omit +export type TextFieldProps = + & SimpleRelativeSingleFieldProps + & Omit + & { + wrapLines?: boolean + } + +const removeNewLines = (text: string) => text.replace(/[\r\n]/g, '') export const TextField = SimpleRelativeSingleField( - (fieldMetadata, { defaultValue, name, label, onBlur, ...props }) => { + (fieldMetadata, { defaultValue, name, label, onBlur, wrapLines = false, allowNewlines = false, ...props }) => { const inputProps = useTextInput({ fieldMetadata, onBlur, - parse: stringFieldParser, + parse: wrapLines && !allowNewlines ? removeNewLines : stringFieldParser, }) return ( diff --git a/packages/admin/src/components/bindingFacade/richText/blockEditor/BlockEditor.tsx b/packages/admin/src/components/bindingFacade/richText/blockEditor/BlockEditor.tsx index 2fc24c7016..faa54e3fae 100644 --- a/packages/admin/src/components/bindingFacade/richText/blockEditor/BlockEditor.tsx +++ b/packages/admin/src/components/bindingFacade/richText/blockEditor/BlockEditor.tsx @@ -299,7 +299,6 @@ export const BlockEditor = Object.assign< ContentOutlet, }) - const useFieldBackedElementFields = (elements: FieldBackedElement[]) => { return <> {elements.map(el => { @@ -309,7 +308,7 @@ const useFieldBackedElementFields = (elements: FieldBackedElement[]) => { if (el.format === 'plainText') { return ( + size={el.size} wrapLines /> ) } return