Update the browser, editor, settings, and installer
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { replacement, type TextSelection } from "./markdownCommands.ts";
|
||||
|
||||
export function externalLinkText(source: string, selection: TextSelection) {
|
||||
const label = source.slice(selection.from, selection.to).replace(/[\\[\]]/g, "\\$&").replace(/\r?\n/g, " ");
|
||||
// Select the empty URL when a label exists. Otherwise start in the label.
|
||||
const cursor = label ? label.length + 3 : 1;
|
||||
return replacement(selection, `[${label}]()`, cursor, cursor);
|
||||
}
|
||||
|
||||
export function workspaceLinkText(source: string, selection: TextSelection, path: string) {
|
||||
const label = source.slice(selection.from, selection.to).replace(/[\[\]|]/g, "").replace(/\s+/g, " ").trim();
|
||||
// Root paths avoid a same-name note in the current folder. Encode syntax characters.
|
||||
const target = "/" + path.replaceAll("\\", "/").replace(/^\/+/, "").split("/").map(encodeURIComponent).join("/");
|
||||
return replacement(selection, `[[${target}${label ? "|" + label : ""}]]`);
|
||||
}
|
||||
Reference in New Issue
Block a user