move caret
This commit is contained in:
parent
86823918cc
commit
63bee59cf3
@ -61,16 +61,18 @@ export async function linkSelection() {
|
|||||||
const selection = await getSelection();
|
const selection = await getSelection();
|
||||||
const textSelection = text.slice(selection.from, selection.to);
|
const textSelection = text.slice(selection.from, selection.to);
|
||||||
let linkedText = `[]()`;
|
let linkedText = `[]()`;
|
||||||
|
let pos = 1;
|
||||||
if (textSelection.length > 0) {
|
if (textSelection.length > 0) {
|
||||||
try {
|
try {
|
||||||
new URL(textSelection);
|
new URL(textSelection);
|
||||||
linkedText = `[](${textSelection})`;
|
linkedText = `[](${textSelection})`;
|
||||||
} catch {
|
} catch {
|
||||||
linkedText = `[${textSelection}]()`;
|
linkedText = `[${textSelection}]()`;
|
||||||
|
pos = linkedText.length - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await replaceRange(selection.from, selection.to, linkedText)
|
await replaceRange(selection.from, selection.to, linkedText)
|
||||||
|
await moveCursor(selection.from + pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function wrapSelection(cmdDef: any) {
|
export function wrapSelection(cmdDef: any) {
|
||||||
|
Loading…
Reference in New Issue
Block a user