From 63bee59cf347a4739c8f9370fab073322e50307e Mon Sep 17 00:00:00 2001 From: Guillermo Vaya Date: Sun, 10 Jul 2022 23:30:38 +0200 Subject: [PATCH] move caret --- packages/plugs/core/text.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugs/core/text.ts b/packages/plugs/core/text.ts index 924ae7e..2f72966 100644 --- a/packages/plugs/core/text.ts +++ b/packages/plugs/core/text.ts @@ -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) {