fix: Revert removal of protocol on pasted links (turns out folks didn't like this change)

This commit is contained in:
Tom Moor
2024-01-09 22:04:11 -05:00
parent 5a0c8e41cb
commit a032f2e7e5

View File

@@ -111,18 +111,17 @@ export default class PasteHandler extends Extension {
const vscode = event.clipboardData.getData("vscode-editor-data"); const vscode = event.clipboardData.getData("vscode-editor-data");
function insertLink(href: string, title?: string) { function insertLink(href: string, title?: string) {
const normalized = href.replace(/^https?:\/\//, "");
// If it's not an embed and there is no text selected just go ahead and insert the // If it's not an embed and there is no text selected just go ahead and insert the
// link directly // link directly
const transaction = view.state.tr const transaction = view.state.tr
.insertText( .insertText(
title ?? normalized, title ?? href,
state.selection.from, state.selection.from,
state.selection.to state.selection.to
) )
.addMark( .addMark(
state.selection.from, state.selection.from,
state.selection.to + (title ?? normalized).length, state.selection.to + (title ?? href).length,
state.schema.marks.link.create({ href }) state.schema.marks.link.create({ href })
); );
view.dispatch(transaction); view.dispatch(transaction);