fix(annotator): don't copy selection to notebook with keyboard shortcut by default, closes #2603 (#2605)

This commit is contained in:
Huang Xin
2025-12-03 14:08:00 +08:00
committed by GitHub
parent 1b0c2afad7
commit 18d65a2c5b
@@ -385,8 +385,13 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
setShowWikipediaPopup(false);
};
const handleCopy = () => {
const handleCopy = (copyToNotebook = true) => {
if (!selection || !selection.text) return;
navigator.clipboard?.writeText(selection.text);
handleDismissPopupAndSelection();
if (!copyToNotebook) return;
eventDispatcher.dispatch('toast', {
type: 'info',
message: _('Copied to notebook'),
@@ -395,7 +400,6 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
});
const { booknotes: annotations = [] } = config;
if (selection) navigator.clipboard?.writeText(selection.text);
const cfi = view?.getCFI(selection.index, selection.range);
if (!cfi) return;
const annotation: BookNote = {
@@ -421,7 +425,6 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
if (updatedConfig) {
saveConfig(envConfig, bookKey, updatedConfig, settings);
}
handleDismissPopupAndSelection();
if (!appService?.isMobile) {
setNotebookVisible(true);
}
@@ -535,7 +538,7 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
handleSearch();
},
onCopySelection: () => {
handleCopy();
handleCopy(false);
},
onTranslateSelection: () => {
handleTranslation();