diff --git a/src/components/Editor/Article/Summary/index.tsx b/src/components/Editor/Article/Summary/index.tsx index b9658af965..022e7f80b5 100644 --- a/src/components/Editor/Article/Summary/index.tsx +++ b/src/components/Editor/Article/Summary/index.tsx @@ -57,6 +57,13 @@ const EditorSummary: React.FC = ({ } } + const handlePaste = () => { + // FIXME: triggers the height adjustment on paste + setTimeout(() => { + autosize.update(instance.current) + }) + } + React.useEffect(() => { if (enable && instance) { autosize(instance.current) @@ -86,6 +93,7 @@ const EditorSummary: React.FC = ({ id: '16zJ3o', })} value={value} + onPaste={handlePaste} onBlur={handleBlur} onChange={handleChange} onKeyDown={handleKeyDown} diff --git a/src/components/Editor/Article/Title/index.tsx b/src/components/Editor/Article/Title/index.tsx index a0b83180af..b5c958605d 100644 --- a/src/components/Editor/Article/Title/index.tsx +++ b/src/components/Editor/Article/Title/index.tsx @@ -23,7 +23,9 @@ const EditorTitle: React.FC = ({ defaultValue = '', update }) => { }, INPUT_DEBOUNCE) const handleChange = (event: React.ChangeEvent) => { - const title = event.target.value.slice(0, MAX_ARTICE_TITLE_LENGTH) + const title = event.target.value + .replace(/\r\n|\r|\n/g, '') + .slice(0, MAX_ARTICE_TITLE_LENGTH) setValue(title) debouncedUpdate() } @@ -37,6 +39,13 @@ const EditorTitle: React.FC = ({ defaultValue = '', update }) => { } } + const handlePaste = () => { + // FIXME: triggers the height adjustment on paste + setTimeout(() => { + autosize.update(instance.current) + }) + } + React.useEffect(() => { if (instance) { autosize(instance.current) @@ -57,6 +66,7 @@ const EditorTitle: React.FC = ({ defaultValue = '', update }) => { id: '//QMqf', })} value={value} + onPaste={handlePaste} onChange={handleChange} onBlur={handleBlur} onKeyDown={handleKeyDown}