Open History to see the last commit
1import { isAbsolutePath } from "~/terminal-links";
2
3export const isMarkdownPreviewFile = (path: string): boolean => /\.(?:md|mdx)$/i.test(path);
4
5export function shouldShowFileExplorer(input: {
6 readonly relativePath: string | null;
7 readonly explorerOpen: boolean;
8 readonly attachmentOpen: boolean;
9}): boolean {
10 if (input.attachmentOpen || (input.relativePath && isAbsolutePath(input.relativePath))) {
11 return false;
12 }
13 return input.explorerOpen || input.relativePath === null;
14}
15
16export function setMarkdownTaskChecked(
17 markdown: string,
18 markerOffset: number,
19 checked: boolean,
20): string {
21 if (
22 markerOffset < 0 ||
23 markdown[markerOffset] !== "[" ||
24 !/[ xX]/.test(markdown[markerOffset + 1] ?? "") ||
25 markdown[markerOffset + 2] !== "]"
26 ) {
27 return markdown;
28 }
29
30 return `${markdown.slice(0, markerOffset + 1)}${checked ? "x" : " "}${markdown.slice(markerOffset + 2)}`;
31}