File tree Expand file tree Collapse file tree
packages/core/src/api/clipboard/fromClipboard Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { EditorView } from "prosemirror-view" ;
22
3- export async function handleVSCodePaste (
4- event : ClipboardEvent ,
5- view : EditorView ,
6- ) {
3+ export function handleVSCodePaste ( event : ClipboardEvent , view : EditorView ) {
74 const { schema } = view . state ;
85
96 if ( ! event . clipboardData ) {
@@ -17,8 +14,7 @@ export async function handleVSCodePaste(
1714 }
1815
1916 if ( ! schema . nodes . codeBlock ) {
20- view . pasteText ( text ) ;
21- return true ;
17+ return false ;
2218 }
2319
2420 const vscode = event . clipboardData ! . getData ( "vscode-editor-data" ) ;
Original file line number Diff line number Diff line change @@ -57,8 +57,13 @@ function defaultPasteHandler({
5757 }
5858
5959 if ( format === "vscode-editor-data" ) {
60- handleVSCodePaste ( event , editor . prosemirrorView ) ;
61- return true ;
60+ // If VSCode clipboard data cannot be parsed as a code block, try parsing
61+ // `text/plain` as a fallback.
62+ if ( handleVSCodePaste ( event , editor . prosemirrorView ) ) {
63+ return true ;
64+ }
65+
66+ format = "text/plain" ;
6267 }
6368
6469 if ( format === "Files" ) {
You can’t perform that action at this time.
0 commit comments