Files
Momento/memento-note/context/notebook-drag-context.tsx
Sepehr Ramezani e4d4e23dc7 chore: clean up repo for public release
- Remove BMAD framework, IDE configs, dev screenshots, test files,
  internal docs, and backup files
- Rename keep-notes/ to memento-note/
- Update all references from keep-notes to memento-note
- Add Apache 2.0 license with Commons Clause (non-commercial restriction)
- Add clean .gitignore and .env.docker.example
2026-04-20 22:48:06 +02:00

65 lines
1.6 KiB
TypeScript

'use client'
import { createContext, useContext, useState, useCallback, ReactNode } from 'react'
interface NotebookDragContextValue {
draggedNoteId: string | null
dragOverNotebookId: string | null
startDrag: (noteId: string) => void
endDrag: () => void
dragOver: (notebookId: string | null) => void
isDragging: boolean
isDragOver: boolean
}
const NotebookDragContext = createContext<NotebookDragContextValue | null>(null)
export function useNotebookDrag() {
const context = useContext(NotebookDragContext)
if (!context) {
throw new Error('useNotebookDrag must be used within NotebookDragProvider')
}
return context
}
interface NotebookDragProviderProps {
children: ReactNode
}
export function NotebookDragProvider({ children }: NotebookDragProviderProps) {
const [draggedNoteId, setDraggedNoteId] = useState<string | null>(null)
const [dragOverNotebookId, setDragOverNotebookId] = useState<string | null>(null)
const startDrag = useCallback((noteId: string) => {
setDraggedNoteId(noteId)
}, [])
const endDrag = useCallback(() => {
setDraggedNoteId(null)
setDragOverNotebookId(null)
}, [])
const dragOver = useCallback((notebookId: string | null) => {
setDragOverNotebookId(notebookId)
}, [])
const isDragging = draggedNoteId !== null
const isDragOver = dragOverNotebookId !== null
return (
<NotebookDragContext.Provider
value={{
draggedNoteId,
dragOverNotebookId,
startDrag,
endDrag,
dragOver,
isDragging,
isDragOver,
}}
>
{children}
</NotebookDragContext.Provider>
)
}