-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to automatically copy to clipboard #348
base: main
Are you sure you want to change the base?
Conversation
Add option to automatically copy generated content to clipboard * Add a new setting in `src/core/popup.ts` to enable automatic copying to the clipboard * Implement the automatic copy to clipboard functionality in `src/core/popup.ts` * Update the `handleClip` function in `src/core/popup.ts` to check the new setting * Add a new keyboard hotkey for copying to the clipboard in `src/background.ts` * Implement the functionality to handle the new hotkey in `src/background.ts` * Add a new setting in the popup interface in `src/popup.html` to enable automatic copying to the clipboard * Add a new property to the `Settings` interface in `src/types/types.ts` for the automatic copy to clipboard setting
this pr addresses #327 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Testing this out, the UX doesn't match what I expected it to do based on the description.
The setting toggle is named Auto-copy to clipboard which made me think that the contents would be automatically copied as soon as the extension is opened — i.e. without requiring a click on the Add to Obsidian button. And when I click the Add to Obsidian button it doesn't actually add to Obsidian, it only copies to the clipboard. The add to clipboard functionality already exists in the secondary actions for the main button, so this is confusing.
I think we need to change the behavior in one of two ways — either:
- The toggle should remain, but we automatically copy to clipboard when the popup is opened, and anytime there is an update to the content, e.g. via Interpreter. This still allows the "Add to Obsidian" button to function as before.
OR
- Change the setting toggle to a dropdown that allows users to swap the primary action with one of the secondary actions. The setting would be called something like
Save behavior
with a dropdown that has three options:
Add to Obsidian
(default)Copy to clipboard
Save file...
When the user choses to make Copy to clipboard
the primary action we swap actions and put the Add to Obsidian
action into the secondary menu. That way the UI copy will match the behavior.
I am guessing that option 2 is more in line with what you and the user have in mind?
Also note that when adding new settings you need to at minimum add the new strings to the messages.json
in the English locale.
Thank your for your feedback, i probably should have explained more what i had in mind and thought about the whole UX ! I think your proposed option 2 with the dropdown on saving behaviour is probably the most intuitive way. So basically we have a dropdown which determines which is the main action in the popout and then swap them with the secondary ones. It would also enable more workflows imo. |
I made the change from the 2nd proposed solution. Basically how it is now is that you select the main function in the settings (default is add to obsidian). I tested it with every action as main and secondary action, with and without interpreter (gemini), and haven't got any issues on chrome. UI and UX should allign now. I added the english text to messages.json and if you approve this i can generate translations for other languages utilising deepl. |
Add option to automatically copy generated content to clipboard
This pull request introduces a new feature to automatically copy clipped content to the clipboard and includes several changes to integrate this feature across the codebase. The most important changes include adding the
autoCopyToClipboard
setting, updating the settings management functions, and modifying the relevant UI components.New Feature: Auto Copy to Clipboard
src/background.ts
: Added a new command listener forcopy_to_clipboard
to send a message to the content script.src/core/popup.ts
: Integrated the auto-copy feature into thehandleClip
function to copy content to the clipboard if the setting is enabled.src/managers/general-settings.ts
: Added the initialization and saving logic for the newautoCopyToClipboard
setting. [1] [2] [3] [4]src/settings.html
: Updated the settings UI to include a toggle for theautoCopyToClipboard
feature.src/types/types.ts
: Updated theSettings
interface to include theautoCopyToClipboard
property.Settings Management
src/utils/storage-utils.ts
: Updated the storage utility functions to handle the newautoCopyToClipboard
setting, including loading, saving, and default values. [1] [2] [3] [4] [5] [6] [7]Clipboard Integration
src/utils/obsidian-note-creator.ts
: Modified thesaveToObsidian
function to copy content to the clipboard if theautoCopyToClipboard
setting is enabled and skip saving to Obsidian. [1] [2]