1
0

move caret

This commit is contained in:
Guillermo Vaya 2022-07-10 23:30:38 +02:00
parent 86823918cc
commit 63bee59cf3

View File

@ -61,16 +61,18 @@ export async function linkSelection() {
const selection = await getSelection();
const textSelection = text.slice(selection.from, selection.to);
let linkedText = `[]()`;
let pos = 1;
if (textSelection.length > 0) {
try {
new URL(textSelection);
linkedText = `[](${textSelection})`;
} catch {
linkedText = `[${textSelection}]()`;
pos = linkedText.length - 1;
}
}
await replaceRange(selection.from, selection.to, linkedText)
await moveCursor(selection.from + pos);
}
export function wrapSelection(cmdDef: any) {