forked from akai/readest
Temporary fix to disable Back button navigation
This commit is contained in:
@@ -48,6 +48,9 @@ const FoliateViewer: React.FC<{
|
||||
};
|
||||
|
||||
const handleKeydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Backspace') {
|
||||
event.preventDefault();
|
||||
}
|
||||
window.postMessage(
|
||||
{
|
||||
type: 'iframe-keydown',
|
||||
@@ -82,9 +85,12 @@ const FoliateViewer: React.FC<{
|
||||
const detail = (event as CustomEvent).detail;
|
||||
if (detail.doc) {
|
||||
if (!detail.doc.isEventListenersAdded) {
|
||||
detail.doc.isEventListenersAdded = true;
|
||||
detail.doc.addEventListener('keydown', handleKeydown);
|
||||
detail.doc.addEventListener('mousedown', handleMousedown);
|
||||
detail.doc.isEventListenersAdded = true;
|
||||
detail.doc.addEventListener('contextmenu', (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,6 +13,14 @@ interface KeyActionHandlers {
|
||||
const useShortcuts = (actions: KeyActionHandlers, dependencies: React.DependencyList = []) => {
|
||||
const [shortcuts, setShortcuts] = useState<ShortcutConfig>(loadShortcuts);
|
||||
|
||||
useEffect(() => {
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
document.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleShortcutUpdate = () => {
|
||||
setShortcuts(loadShortcuts());
|
||||
@@ -58,6 +66,8 @@ const useShortcuts = (actions: KeyActionHandlers, dependencies: React.Dependency
|
||||
metaKey: boolean,
|
||||
shiftKey: boolean,
|
||||
) => {
|
||||
// FIXME: This is a temporary fix to disable Back button navigation
|
||||
if (key === 'backspace') return true;
|
||||
if (
|
||||
shortcuts.switchSidebar.some((shortcut) =>
|
||||
isShortcutMatch(shortcut, key, ctrlKey, altKey, metaKey, shiftKey),
|
||||
|
||||
Reference in New Issue
Block a user