Skip to content
Merged
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
19 changes: 3 additions & 16 deletions src/components/MarkdownCodeEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef, useCallback, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { EditorView, basicSetup } from 'codemirror';
import { markdown } from '@codemirror/lang-markdown';
import { languages } from '@codemirror/language-data';
Expand All @@ -24,12 +24,12 @@ interface Props {
}

export function MarkdownCodeEditor({
content, filePath, vaultPath, viewMode,
content, filePath: _filePath, vaultPath, viewMode,
onContentChange, onSave, onCursorChange, onNavigateWikilink,
}: Props) {
const containerRef = useRef<HTMLDivElement>(null);
const viewRef = useRef<EditorView | null>(null);
const saveTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
const saveTimeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
const mdFileNamesRef = useRef<string[]>([]);
const tagsRef = useRef<MdTagInfo[]>([]);
const [previewContent, setPreviewContent] = useState(content);
Expand Down Expand Up @@ -112,19 +112,6 @@ export function MarkdownCodeEditor({
}
}, [content]);

const gotoLine = useCallback((line: number) => {
const view = viewRef.current;
if (!view) return;
const doc = view.state.doc;
const lineNum = Math.min(line, doc.lines);
const lineInfo = doc.line(lineNum);
view.dispatch({
selection: { anchor: lineInfo.from },
effects: EditorView.scrollIntoView(lineInfo.from, { y: 'center' }),
});
view.focus();
}, []);

return (
<div className={`md-editor-split ${viewMode === 'split' ? 'split-mode' : ''}`}>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/components/MarkdownFileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function MarkdownFileTree({ entries, selectedPath, gitFiles, onSelectFile
);
}

function FileTreeItem({ entry, selectedPath, gitFiles, onSelectFile, onDelete, onRename, depth }: Props & { entry: MdFileEntry; depth: number }) {
function FileTreeItem({ entry, selectedPath, gitFiles, onSelectFile, onDelete, onRename, depth }: Omit<Props, 'entries'> & { entry: MdFileEntry; depth: number }) {
const [expanded, setExpanded] = useState(depth < 1);
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null);

Expand Down
4 changes: 2 additions & 2 deletions src/components/MarkdownSearchPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useCallback, useRef, useEffect } from 'react';
import { invoke } from '@tauri-apps/api/core';
import { Search, Replace, CaseSensitive, X } from 'lucide-react';
import { Search, Replace, CaseSensitive } from 'lucide-react';
import type { MdSearchMatch } from './markdownTypes';

interface Props {
Expand All @@ -17,7 +17,7 @@ export function MarkdownSearchPanel({ vaultPath, onNavigate }: Props) {
const [searching, setSearching] = useState(false);
const [selectedIndex, setSelectedIndex] = useState(-1);
const inputRef = useRef<HTMLInputElement>(null);
const debounceRef = useRef<ReturnType<typeof setTimeout>>();
const debounceRef = useRef<ReturnType<typeof setTimeout>>(null);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Search debounce ref error 🐞 Bug ✓ Correctness

MarkdownSearchPanel initializes debounceRef with null but types it as non-null
ReturnType<typeof setTimeout>, which is incompatible with strict TypeScript settings and will
fail the build.
Agent Prompt
### Issue description
`debounceRef` is declared as a non-null timeout type but initialized with `null`, which is a compile error under `strictNullChecks`.

### Issue Context
`tsconfig.app.json` sets `strict: true`. The codebase already uses `ReturnType<typeof setTimeout> | null` for debounce refs.

### Fix Focus Areas
- src/components/MarkdownSearchPanel.tsx[18-21]
- tsconfig.app.json[25-31]
- src/components/NoteEditor.tsx[18-22]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


useEffect(() => {
inputRef.current?.focus();
Expand Down
12 changes: 6 additions & 6 deletions src/components/SourcePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ export function SourcePanel({
onAddSnippet,
onDeleteSnippet,
onCopySnippet,
clipEntries = [],
selectedClipId,
onSelectClip,
onPasteClip,
onDeleteClip,
onTogglePinClip,
clipEntries: _clipEntries = [],
selectedClipId: _selectedClipId,
onSelectClip: _onSelectClip,
onPasteClip: _onPasteClip,
onDeleteClip: _onDeleteClip,
onTogglePinClip: _onTogglePinClip,
}: SourcePanelProps) {
const { isPro, showUpgradeModal } = usePro();
const [paletteOpen, setPaletteOpen] = useState(false);
Expand Down
1 change: 0 additions & 1 deletion src/components/SuperClipboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState, useCallback, useRef, useMemo, useEffect } from 'react';
import type { ClipEntry } from './ClipboardHistoryList';
import { getClipClickAction } from './ClipboardSettingsPanel';

interface SuperClipboardProps {
entries: ClipEntry[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/SuperMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
searchQuery?: string;
}

export function SuperMarkdown({ searchQuery }: Props) {
export function SuperMarkdown({ searchQuery: _searchQuery }: Props) {
// Vault state
const [vaultPath, setVaultPath] = useState<string | null>(() => localStorage.getItem(VAULT_PATH_KEY));
const [fileTree, setFileTree] = useState<MdFileEntry[]>([]);
Expand Down
2 changes: 1 addition & 1 deletion src/components/SuperTranslate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function SuperTranslate() {
const [targetLang, setTargetLang] = useState('fr');
const [detectedLang, setDetectedLang] = useState('');
const [isTranslating, setIsTranslating] = useState(false);
const debounceRef = useRef<ReturnType<typeof setTimeout>>();
const debounceRef = useRef<ReturnType<typeof setTimeout>>(null);
const abortRef = useRef(0);

const doTranslate = useCallback(async (text: string, sl: string, tl: string) => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/markdown-editor/live-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { RangeSet } from '@codemirror/state';
import type { Range } from '@codemirror/state';

class ImageWidget extends WidgetType {
constructor(readonly src: string, readonly alt: string) { super(); }
src: string;
alt: string;
constructor(src: string, alt: string) { super(); this.src = src; this.alt = alt; }
toDOM(): HTMLElement {
const wrapper = document.createElement('span');
wrapper.className = 'cm-lp-image-wrapper';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useFeedStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface FeedStore {
addFeed: (url: string, name: string, source: FeedSource) => Promise<Feed>;
removeFeed: (feedId: string) => void;
renameFeed: (feedId: string, newName: string) => void;
syncFeed: (feedId: string) => Promise<void>;
syncFeed: (feedId: string) => Promise<{ feed: Feed; newItems: FeedItem[] } | null>;
syncAll: () => Promise<void>;
markAsRead: (itemId: string) => void;
markAllAsRead: (feedId?: string) => void;
Expand Down