From a072c91cc0dc26e417c51f666e8547e08ef40942 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Tue, 12 Mar 2024 23:18:23 +0000 Subject: Add import from file system --- utils/util.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 utils/util.ts (limited to 'utils/util.ts') diff --git a/utils/util.ts b/utils/util.ts new file mode 100644 index 0000000..cc500e0 --- /dev/null +++ b/utils/util.ts @@ -0,0 +1,29 @@ +const COLOR_CODE_REGEX = /&([0-9a-fk-or]|#[0-9A-F]{6})/ig; + +export function stripColorCodes(str: string): string { + return str.replace(COLOR_CODE_REGEX, ''); +} + +export function navigateToEditorPane(type: 'quest' | 'category' | 'item' | null, id?: string) { + if (id) { + if (type === 'category') { + navigateTo({ path: '/category/' + id }) + } else if (type === 'quest') { + navigateTo({ path: '/quest/' + id }) + } else if (type === 'item') { + navigateTo({ path: '/item/' + id }) + } + } else if (!id && !type) { + navigateTo({ path: '/' }) + } +} + +export type BrowserCapabilities = { + canUseFsApi: boolean +} + +export function getBrowserCapabilities(): BrowserCapabilities { + return { + canUseFsApi: typeof (window as any)?.showDirectoryPicker === 'function' + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2