Clipboard operations handle reading, writing, and syncing clipboard content across devices. These functions manage the core functionality of ClipSync.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/SudhansuuRanjan/clipsync/llms.txt
Use this file to discover all available pages before exploring further.
updateClipboard
Updates the clipboard content and syncs it to all devices in the session. Source:src/App.jsx:167
Parameters
This function uses component state rather than direct parameters:The text content to be synced. Maximum length of 15,000 characters.
Optional file attachment object containing
url, path, name, and type properties.Flag indicating whether the content contains sensitive information that should be hidden.
Behavior
- Validates that either text or file content exists
- Checks content length (15,000 character limit)
- Creates a new session if one doesn’t exist
- Inserts clipboard data into the database
- Clears the input fields and resets state
fetchClipboardHistory
Retrieves all clipboard entries for the current session. Source:src/App.jsx:31
Parameters
The session code to fetch clipboard history for (from component state).
Return Value
ReturnsPromise<void>. Updates component state with the fetched clipboard history.
copyToClipboard
Copies text content to the system clipboard. Source:src/App.jsx:207
Parameters
The text content to copy to the system clipboard.
Behavior
Uses the browser’s Clipboard API (navigator.clipboard.writeText) to write content to the system clipboard and displays a success notification.
addClipboardText
Reads text from the system clipboard and adds it to the input field. Source:src/App.jsx:212
Behavior
- Requests clipboard read permission from the browser
- Reads text content from the system clipboard
- Updates the input field with the clipboard text
- Shows appropriate success or error messages
Browser Permissions
Requires theclipboard-read permission. Users may be prompted to grant permission on first use.
deleteAll
Deletes all clipboard entries for the current session, including associated files. Source:src/App.jsx:225
Behavior
- Shows a confirmation dialog to the user
- Iterates through all history items and deletes associated files from storage
- Deletes all database records for the current session
- Clears the local history state
handleEdit
Loads a clipboard entry into the editor for modification. Source:src/App.jsx:249
Parameters
The unique identifier of the clipboard entry to edit.
Behavior
- Finds the entry in the history by ID
- Loads the content and file (if any) into the editor
- Deletes the entry from the database
- Updates the local history state
- Allows the user to modify and re-save the content
Real-time Subscription
ClipSync uses Supabase’s real-time features to sync clipboard updates across devices. Source:src/App.jsx:385
Behavior
- INSERT events: Adds new clipboard entries to the history in real-time
- DELETE events: Removes deleted entries from the history
- Session filtering: Only processes events matching the current session code
- Cleanup: Unsubscribes from the channel when the component unmounts
Event Types
INSERT: New clipboard content addedDELETE: Clipboard content removed- Automatically syncs across all connected devices in the session