Rend les liens entre notes visibles et persistants (sync NoteLink au save, auto-save, graphe réseau rafraîchi), ajoute living blocks, Memory Echo, recherche globale, consentement IA explicite et consolide les prototypes design en architectural-grid. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
'use client'
|
|
|
|
import { createContext, useContext, useState, useEffect, type ReactNode } from 'react'
|
|
import { SearchModal } from '@/components/search-modal'
|
|
|
|
interface SearchModalContextValue {
|
|
open: () => void
|
|
close: () => void
|
|
}
|
|
|
|
const SearchModalContext = createContext<SearchModalContextValue>({
|
|
open: () => {},
|
|
close: () => {},
|
|
})
|
|
|
|
export function useSearchModal() {
|
|
return useContext(SearchModalContext)
|
|
}
|
|
|
|
export function SearchModalProvider({ children }: { children: ReactNode }) {
|
|
const [isOpen, setIsOpen] = useState(false)
|
|
|
|
const open = () => setIsOpen(true)
|
|
const close = () => setIsOpen(false)
|
|
|
|
// Global keyboard shortcut: Ctrl+K or Cmd+K
|
|
useEffect(() => {
|
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
|
e.preventDefault()
|
|
setIsOpen(prev => !prev)
|
|
}
|
|
}
|
|
window.addEventListener('keydown', handleKeyDown)
|
|
return () => window.removeEventListener('keydown', handleKeyDown)
|
|
}, [])
|
|
|
|
return (
|
|
<SearchModalContext.Provider value={{ open, close }}>
|
|
{children}
|
|
<SearchModal isOpen={isOpen} onClose={close} />
|
|
</SearchModalContext.Provider>
|
|
)
|
|
}
|