Skip to content

Commit 25afce2

Browse files
committed
Added Ctrl+C Functionality
1 parent adb97de commit 25afce2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/routes/Reader/ReaderView/functions/registerHandlers.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
QUICKBAR_MODAL_WIDTH
1414
} from "./ModalUtility";
1515
import { handleLinkClick } from "@shared/scripts/handleLinkClick";
16+
import { writeText } from "@tauri-apps/api/clipboard";
17+
import toast from "react-hot-toast";
1618

1719
// import {bookStateStructure} from 'src/store/slices/EpubJSBackend/epubjsManager.d'
1820

@@ -151,6 +153,23 @@ export default (renditionInstance:Rendition, view:number)=>{
151153
}
152154

153155
}
156+
157+
if (event.ctrlKey && event.key === 'c') {
158+
const result:any = renditionInstance?.getRange(selectedCFI)?.cloneContents().textContent
159+
if(!result) return
160+
161+
renditionInstance.annotations.remove(selectedCFI, "highlight")
162+
store.dispatch(MoveQuickbarModal({
163+
x:0,
164+
y:0,
165+
visible: false
166+
}))
167+
writeText(result);
168+
toast.success('Text Copied',
169+
{
170+
icon: '📋',
171+
})
172+
}
154173
if(event.keyCode === 114 || (event.ctrlKey && event.keyCode === 70)){
155174
// This will prevent the native browser searchbar from showing when
156175
// the user presses ctrl + f

0 commit comments

Comments
 (0)