mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-06 21:14:38 -04:00
fix: One line editor can enter new line issue (#10514)
* fix one line editor issue * change camel case
This commit is contained in:
1 parent
aa5cf57a55
commit
976d136abd
1 file changed
+5
-2
@@ -204,14 +204,17 @@ export const OneLineEditor = forwardRef<OneLineEditorHandle, OneLineEditorProps>
|
||||
};
|
||||
codeMirror.current = CodeMirror.fromTextArea(textAreaRef.current, initialOptions);
|
||||
codeMirror.current.on('beforeChange', (_: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => {
|
||||
const isPaste = change.origin === 'paste' && change.update;
|
||||
if (isPaste) {
|
||||
const isMultiLineInsert = change.text && change.text.length > 1;
|
||||
const isSingleLinePaste = change.origin === 'paste' && change.update && change.text.length === 1;
|
||||
if (isMultiLineInsert || isSingleLinePaste) {
|
||||
const pastedText = change.text.join('\n');
|
||||
const hasContent = pastedText.trim();
|
||||
// Cancel the change if it's a curl command or has no content
|
||||
if (isCurlCommand(pastedText) || !hasContent) {
|
||||
change.cancel();
|
||||
return;
|
||||
}
|
||||
// Replace vault tags id if needed
|
||||
let editorPasteText = change.text.join('').replace(/\n/g, ' ');
|
||||
if (containsExternalVaultTag(editorPasteText)) {
|
||||
editorPasteText = replaceVaultTagIdIfNeeded(editorPasteText);
|
||||
|
||||
Reference in new issue
Block a user