Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Mar 19, 2023
1 parent 8a44e2d commit e964079
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# Platforms to build on/for
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-latest, ubuntu-latest]

steps:
- name: Check out Git repository
Expand Down
1 change: 0 additions & 1 deletion src/components/popups/popupMenu/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PopupMenu extends React.Component<PopupMenuProps, PopupMenuStates> {
this.state = {
deleteKey: "",
rect: this.props.rect,
isDisablePopup: StorageUtil.getReaderConfig("isDisablePopup") === "yes",
};
}

Expand Down
1 change: 0 additions & 1 deletion src/components/popups/popupMenu/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface PopupMenuProps {
}
export interface PopupMenuStates {
deleteKey: string;
isDisablePopup: boolean;
// cfiRange: string;
rect: DOMRect | null;
}
9 changes: 9 additions & 0 deletions src/containers/htmlViewer/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
RecordLocation.getHtmlLocation(this.props.currentBook.key)
.chapterTitle || "",
readerMode: StorageUtil.getReaderConfig("readerMode") || "double",
isDisablePopup: StorageUtil.getReaderConfig("isDisablePopup") === "yes",

margin: parseInt(StorageUtil.getReaderConfig("margin")) || 30,
extraMargin: 0,
chapterDocIndex: parseInt(
Expand Down Expand Up @@ -317,6 +319,13 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
this.props.handleLeaveReader("bottom");
});
doc.addEventListener("mouseup", () => {
if (this.state.isDisablePopup) return;
if (!doc!.getSelection() || doc!.getSelection()!.rangeCount === 0) return;
var rect = doc!.getSelection()!.getRangeAt(0).getBoundingClientRect();
this.setState({ rect });
});
doc.addEventListener("dblclick", (event) => {
event.preventDefault();
if (!doc!.getSelection() || doc!.getSelection()!.rangeCount === 0) return;
var rect = doc!.getSelection()!.getRangeAt(0).getBoundingClientRect();
this.setState({ rect });
Expand Down
1 change: 1 addition & 0 deletions src/containers/htmlViewer/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ViewerState {
scale: string;
isFirst: boolean;
chapterTitle: string;
isDisablePopup: boolean;
margin: number;
extraMargin: number;
readerMode: string;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/readUtils/linkUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const handleLinkJump = async (event: any, rendition: any = {}) => {
}
let id = href.split("#").reverse()[0];
await rendition.goToNode(doc.body.querySelector("#" + id) || doc.body);
} else if (rendition.resolveChapter(href)) {
} else if (href && rendition.resolveChapter(href)) {
let chapterInfo = rendition.resolveChapter(href);
rendition.goToChapter(
chapterInfo.index,
Expand Down

0 comments on commit e964079

Please sign in to comment.