Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,15 @@
"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
}
},
"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"
Expand Down
28 changes: 13 additions & 15 deletions apps/desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) => {
Expand Down
12 changes: 11 additions & 1 deletion apps/desktop/src/command/CommandBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ interface Props {

export function CommandBar({ files, onSelect, onClose }: Props) {
return (
<div className="cmdk-overlay" onClick={onClose}>
<div
className="cmdk-overlay"
onClick={onClose}
onKeyDown={(e) => {
if (e.key === "Escape" || e.key === "Enter" || e.key === " ") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enter and Space handlers prevent command selection. Users navigating with arrows can't select items with Enter because overlay closes first. Only Escape should close the overlay on keydown.

e.preventDefault();
onClose();
}
}}
tabIndex={-1}
>
<Command className="cmdk-palette" onClick={(e) => e.stopPropagation()}>
<Command.Input autoFocus placeholder="Find file…" />
<Command.List>
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/src/editor/markdown.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 1 addition & 4 deletions apps/desktop/src/editor/plugins/caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion apps/desktop/src/hooks/useAutoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, []);
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/hooks/useFileSystem.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions apps/desktop/src/styles/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
}

@keyframes pm-caret-blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
0%,
100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
4 changes: 1 addition & 3 deletions apps/desktop/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]
}
4 changes: 2 additions & 2 deletions apps/desktop/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 2 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
"quoteStyle": "double"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
"assists": {
"enabled": true
}
}
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@
"node": ">=18"
},
"packageManager": "bun@1.3.9",
"workspaces": [
"apps/*"
]
"workspaces": ["apps/*"]
}