Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { EditorView } from "prosemirror-view";

export async function handleVSCodePaste(
event: ClipboardEvent,
view: EditorView,
) {
export function handleVSCodePaste(event: ClipboardEvent, view: EditorView) {
const { schema } = view.state;

if (!event.clipboardData) {
Expand All @@ -17,8 +14,7 @@ export async function handleVSCodePaste(
}

if (!schema.nodes.codeBlock) {
view.pasteText(text);
return true;
return false;
}

const vscode = event.clipboardData!.getData("vscode-editor-data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ function defaultPasteHandler({
}

if (format === "vscode-editor-data") {
handleVSCodePaste(event, editor.prosemirrorView);
return true;
// If VSCode clipboard data cannot be parsed as a code block, try parsing
// `text/plain` as a fallback.
if (handleVSCodePaste(event, editor.prosemirrorView)) {
return true;
}

format = "text/plain";
}

if (format === "Files") {
Expand Down
Loading