fix: One line editor can enter new line issue (#10514)

* fix one line editor issue

* change camel case
This commit is contained in:
Kent Wang authored and GitHub committed 2026-09-18 00:51:24 +00:00
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);