diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index edf6341..94a2841 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -26,13 +26,7 @@ "active": true, "targets": "all", "createUpdaterArtifacts": true, - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ], + "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"], "macOS": { "signingIdentity": null } @@ -40,9 +34,7 @@ "plugins": { "updater": { "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDg4RTRDMDREMjdGNjYxODcKUldTSFlmWW5UY0RraUlaTjZwYmV6MjRnWGs3QWs3U3o2YmpGbEJ5akV0MER2b2I1M3V4LzNoem4K", - "endpoints": [ - "https://github.com/usamaasfar/superscript/releases/latest/download/latest.json" - ] + "endpoints": ["https://github.com/usamaasfar/superscript/releases/latest/download/latest.json"] } }, "version": "../../../package.json" diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx index d9807e5..65e0373 100644 --- a/apps/desktop/src/App.tsx +++ b/apps/desktop/src/App.tsx @@ -5,8 +5,8 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { CommandBar } from "~/command/CommandBar"; import { Editor } from "~/editor/Editor"; import { useAppearance } from "~/hooks/useAppearance"; -import { useAutoUpdate } from "~/hooks/useAutoUpdate"; import { useAutoSave } from "~/hooks/useAutoSave"; +import { useAutoUpdate } from "~/hooks/useAutoUpdate"; import { useFileSystem } from "~/hooks/useFileSystem"; import { useRename } from "~/hooks/useRename"; import { getFileStem } from "~/utils/file"; @@ -44,21 +44,19 @@ function App() { setActivePath, }); - const { isRenaming, renameValue, setRenameValue, renameInputRef, startRename, submitRename, resetRename } = useRename( - { - activePath, - files, - flushSave, - loadDir, - setActivePath, - setActiveContent, - setEditorKey: (updater) => { - const next = updater(editorKeyRef.current); - editorKeyRef.current = next; - setEditorKey(next); - }, + const { isRenaming, renameValue, setRenameValue, renameInputRef, startRename, submitRename, resetRename } = useRename({ + activePath, + files, + flushSave, + loadDir, + setActivePath, + setActiveContent, + setEditorKey: (updater) => { + const next = updater(editorKeyRef.current); + editorKeyRef.current = next; + setEditorKey(next); }, - ); + }); const openFile = useCallback( async (path: string) => { diff --git a/apps/desktop/src/command/CommandBar.tsx b/apps/desktop/src/command/CommandBar.tsx index 17f22c2..8fed9b5 100644 --- a/apps/desktop/src/command/CommandBar.tsx +++ b/apps/desktop/src/command/CommandBar.tsx @@ -8,7 +8,17 @@ interface Props { export function CommandBar({ files, onSelect, onClose }: Props) { return ( -
+
{ + if (e.key === "Escape" || e.key === "Enter" || e.key === " ") { + e.preventDefault(); + onClose(); + } + }} + tabIndex={-1} + > e.stopPropagation()}> diff --git a/apps/desktop/src/editor/Editor.tsx b/apps/desktop/src/editor/Editor.tsx index 2a41f18..c8b8f5d 100644 --- a/apps/desktop/src/editor/Editor.tsx +++ b/apps/desktop/src/editor/Editor.tsx @@ -8,6 +8,7 @@ import { EditorView } from "prosemirror-view"; import { useEffect, useRef } from "react"; import { caretPlugin } from "./plugins/caret"; import { parseMarkdown, schema, serializeMarkdown } from "./markdown"; +import { caretPlugin } from "./plugins/caret"; function buildInputRules() { return inputRules({ diff --git a/apps/desktop/src/editor/markdown.ts b/apps/desktop/src/editor/markdown.ts index ece55c8..74bf044 100644 --- a/apps/desktop/src/editor/markdown.ts +++ b/apps/desktop/src/editor/markdown.ts @@ -1,6 +1,6 @@ import MarkdownIt from "markdown-it"; import type Token from "markdown-it/lib/token.mjs"; -import { defaultMarkdownSerializer, MarkdownParser, MarkdownSerializer } from "prosemirror-markdown"; +import { MarkdownParser, MarkdownSerializer, defaultMarkdownSerializer } from "prosemirror-markdown"; import { Schema } from "prosemirror-model"; // schema: CommonMark nodes + strikethrough mark @@ -168,7 +168,8 @@ export const schema = new Schema({ }); function listIsTight(tokens: Token[], i: number) { - while (++i < tokens.length) if (tokens[i].type !== "list_item_open") return tokens[i].hidden; + let index = i; + while (++index < tokens.length) if (tokens[index].type !== "list_item_open") return tokens[index].hidden; return false; } diff --git a/apps/desktop/src/editor/plugins/caret.ts b/apps/desktop/src/editor/plugins/caret.ts index 25d114f..db1cdf4 100644 --- a/apps/desktop/src/editor/plugins/caret.ts +++ b/apps/desktop/src/editor/plugins/caret.ts @@ -37,10 +37,7 @@ function updateCaret(view: EditorView, el: HTMLElement) { const lineHeight = cursorRect.bottom - cursorRect.top; el.setAttribute("data-style", caretStyle); el.style.left = `${cursorRect.left - containerRect.left}px`; - el.style.top = - caretStyle === "underline" - ? `${cursorRect.bottom - containerRect.top - 2}px` - : `${cursorRect.top - containerRect.top}px`; + el.style.top = caretStyle === "underline" ? `${cursorRect.bottom - containerRect.top - 2}px` : `${cursorRect.top - containerRect.top}px`; el.style.height = caretStyle === "underline" ? "2px" : `${lineHeight}px`; // restart blink so caret stays solid while typing diff --git a/apps/desktop/src/hooks/useAutoUpdate.ts b/apps/desktop/src/hooks/useAutoUpdate.ts index aefb013..fcca0ed 100644 --- a/apps/desktop/src/hooks/useAutoUpdate.ts +++ b/apps/desktop/src/hooks/useAutoUpdate.ts @@ -6,7 +6,11 @@ export function useAutoUpdate(): void { useEffect(() => { check() .then((update) => { - if (update) update.downloadAndInstall().then(() => relaunch()).catch(console.error); + if (update) + update + .downloadAndInstall() + .then(() => relaunch()) + .catch(console.error); }) .catch(console.error); }, []); diff --git a/apps/desktop/src/hooks/useFileSystem.ts b/apps/desktop/src/hooks/useFileSystem.ts index a0ce3ce..9c7906a 100644 --- a/apps/desktop/src/hooks/useFileSystem.ts +++ b/apps/desktop/src/hooks/useFileSystem.ts @@ -1,6 +1,6 @@ +import { homeDir } from "@tauri-apps/api/path"; import { open } from "@tauri-apps/plugin-dialog"; import { mkdir, readDir, stat } from "@tauri-apps/plugin-fs"; -import { homeDir } from "@tauri-apps/api/path"; import { useCallback, useEffect, useState } from "react"; interface UseFileSystemOptions { diff --git a/apps/desktop/src/styles/editor.css b/apps/desktop/src/styles/editor.css index 7ac3dee..b0c17cc 100644 --- a/apps/desktop/src/styles/editor.css +++ b/apps/desktop/src/styles/editor.css @@ -142,6 +142,11 @@ } @keyframes pm-caret-blink { - 0%, 100% { opacity: 1; } - 50% { opacity: 0; } + 0%, + 100% { + opacity: 1; + } + 50% { + opacity: 0; + } } diff --git a/apps/desktop/src/styles/globals.css b/apps/desktop/src/styles/globals.css index 9dcb86a..5e54449 100644 --- a/apps/desktop/src/styles/globals.css +++ b/apps/desktop/src/styles/globals.css @@ -84,9 +84,7 @@ body { border-radius: 0; background: transparent; color: var(--fg); - font-family: - -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", - sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; font-size: 0.78rem; font-weight: 500; line-height: 1.1; diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json index d2ca536..ed874c1 100644 --- a/apps/desktop/tsconfig.json +++ b/apps/desktop/tsconfig.json @@ -20,8 +20,8 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, + "noFallthroughCasesInSwitch": true }, "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/apps/desktop/vite.config.ts b/apps/desktop/vite.config.ts index daf85d2..55c0ad4 100644 --- a/apps/desktop/vite.config.ts +++ b/apps/desktop/vite.config.ts @@ -1,7 +1,7 @@ +import { resolve } from "node:path"; import tailwindcss from "@tailwindcss/vite"; -import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; -import { resolve } from "path"; +import { defineConfig } from "vite"; // @ts-expect-error process is a nodejs global const host = process.env.TAURI_DEV_HOST; diff --git a/biome.json b/biome.json index 069488e..41a8ded 100644 --- a/biome.json +++ b/biome.json @@ -24,12 +24,7 @@ "quoteStyle": "double" } }, - "assist": { - "enabled": true, - "actions": { - "source": { - "organizeImports": "on" - } - } + "assists": { + "enabled": true } } diff --git a/package.json b/package.json index 44c6b0c..02e8c2b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,5 @@ "node": ">=18" }, "packageManager": "bun@1.3.9", - "workspaces": [ - "apps/*" - ] + "workspaces": ["apps/*"] }