Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Dec 17, 2023
1 parent 57e3a16 commit ba8525a
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 144 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@vitalets/google-translate-api": "^8.0.0",
"adm-zip": "^0.5.2",
"axios": "^0.19.2",
"bing-translate-api": "^2.7.0",
"bing-translate-api": "^2.10.0",
"buffer": "^6.0.3",
"copy-text-to-clipboard": "^2.2.0",
"dompurify": "^3.0.1",
Expand Down
6 changes: 3 additions & 3 deletions public/lib/kookit/kookit.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/components/background/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Background extends React.Component<BackgroundProps, BackgroundState> {
<div
className="spine-shadow-left"
style={
this.state.isSingle ? { display: "none" } : { opacity: "0.2" }
this.state.isSingle ? { display: "none" } : { opacity: "0.15" }
}
></div>
)}
Expand Down Expand Up @@ -120,9 +120,9 @@ class Background extends React.Component<BackgroundProps, BackgroundState> {
? {
position: "relative",
right: 0,
opacity: 0.2,
opacity: 0.15,
}
: { opacity: 0.2 }
: { opacity: 0.15 }
}
></div>
)}
Expand Down
8 changes: 7 additions & 1 deletion src/components/bookCardItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ class BookCardItem extends React.Component<BookCardProps, BookCardState> {
this.setState({ isHover: false });
event?.stopPropagation();
}}
style={this.props.isSelected ? { opacity: 1 } : { color: "#eee" }}
style={
this.props.isSelected
? { opacity: 1 }
: {
color: "#eee",
}
}
></span>
) : null}

Expand Down
58 changes: 12 additions & 46 deletions src/components/popups/popupNote/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@ import {
removePDFHighlight,
} from "../../../utils/fileUtils/pdfUtil";
import { getIframeDoc } from "../../../utils/serviceUtils/docUtil";
import { renderHighlighters } from "../../../utils/serviceUtils/noteUtil";
import {
createOneNote,
removeOneNote,
} from "../../../utils/serviceUtils/noteUtil";
import { classes } from "../../../constants/themeList";
declare var window: any;
let classes = [
"color-0",
"color-1",
"color-2",
"color-3",
"line-0",
"line-1",
"line-2",
"line-3",
];

class PopupNote extends React.Component<PopupNoteProps, PopupNoteState> {
constructor(props: PopupNoteProps) {
super(props);
Expand Down Expand Up @@ -62,38 +57,11 @@ class PopupNote extends React.Component<PopupNoteProps, PopupNoteState> {
handleTag = (tag: string[]) => {
this.setState({ tag });
};
handleHighlight = () => {
let highlighters: any = this.props.notes;
if (!highlighters) return;
let highlightersByChapter = highlighters.filter((item: Note) => {
if (this.props.currentBook.format !== "PDF") {
return (
(item.chapter ===
this.props.htmlBook.rendition.getChapterDoc()[
this.props.chapterDocIndex
].label ||
item.chapterIndex === this.props.chapterDocIndex) &&
item.bookKey === this.props.currentBook.key
);
} else {
return (
item.chapterIndex === this.props.chapterDocIndex &&
item.bookKey === this.props.currentBook.key
);
}
});
renderHighlighters(
highlightersByChapter,
this.props.currentBook.format,
this.handleNoteClick
);
};

handleNoteClick = (event: Event) => {
if (event && event.target) {
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
}
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
};
createNote() {
let notes = (document.querySelector(".editor-box") as HTMLInputElement)
Expand Down Expand Up @@ -123,7 +91,6 @@ class PopupNote extends React.Component<PopupNoteProps, PopupNoteState> {
this.props.handleFetchNotes();
this.props.handleMenuMode("");
this.props.handleNoteKey("");
this.handleHighlight();
});
} else {
//创建笔记
Expand Down Expand Up @@ -174,7 +141,7 @@ class PopupNote extends React.Component<PopupNoteProps, PopupNoteState> {
toast.success(this.props.t("Add Successfully"));
this.props.handleFetchNotes();
this.props.handleMenuMode("");
this.handleHighlight();
createOneNote(note, this.handleNoteClick);
});
}
}
Expand Down Expand Up @@ -203,15 +170,14 @@ class PopupNote extends React.Component<PopupNoteProps, PopupNoteState> {
this.props.handleMenuMode("");
this.props.handleFetchNotes();
this.props.handleNoteKey("");
this.handleHighlight();
removeOneNote(note.key);
this.props.handleOpenMenu(false);
});
}
} else {
this.props.handleOpenMenu(false);
this.props.handleMenuMode("");
this.props.handleNoteKey("");
this.handleHighlight();
}
};

Expand Down
39 changes: 6 additions & 33 deletions src/components/popups/popupOption/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getHightlightCoords } from "../../../utils/fileUtils/pdfUtil";
import { getIframeDoc } from "../../../utils/serviceUtils/docUtil";
import { openExternalUrl } from "../../../utils/serviceUtils/urlUtil";
import { isElectron } from "react-device-detect";
import { renderHighlighters } from "../../../utils/serviceUtils/noteUtil";
import { createOneNote } from "../../../utils/serviceUtils/noteUtil";

declare var window: any;

Expand Down Expand Up @@ -118,41 +118,14 @@ class PopupOption extends React.Component<PopupOptionProps> {
toast.success(this.props.t("Add Successfully"));
this.props.handleFetchNotes();
this.props.handleMenuMode("");
this.handleHighlight();
createOneNote(digest, this.handleNoteClick);
});
};
handleHighlight = () => {
let highlighters: any = this.props.notes;
if (!highlighters) return;
let highlightersByChapter = highlighters.filter((item: Note) => {
if (this.props.currentBook.format !== "PDF") {
return (
(item.chapter ===
this.props.htmlBook.rendition.getChapterDoc()[
this.props.chapterDocIndex
].label ||
item.chapterIndex === this.props.chapterDocIndex) &&
item.bookKey === this.props.currentBook.key
);
} else {
return (
item.chapterIndex === this.props.chapterDocIndex &&
item.bookKey === this.props.currentBook.key
);
}
});
renderHighlighters(
highlightersByChapter,
this.props.currentBook.format,
this.handleNoteClick
);
};

handleNoteClick = (event: Event) => {
if (event && event.target) {
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
}
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
};
handleJump = (url: string) => {
openExternalUrl(url);
Expand Down
1 change: 1 addition & 0 deletions src/components/popups/popupTrans/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
});
})
.catch((err) => {
console.log(err);
this.setState({
translatedText: this.props.t("Error happens"),
});
Expand Down
10 changes: 10 additions & 0 deletions src/constants/themeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ export const themeList = [
title: "Purple",
},
];
export const classes = [
"color-0",
"color-1",
"color-2",
"color-3",
"line-0",
"line-1",
"line-2",
"line-3",
];
10 changes: 4 additions & 6 deletions src/containers/htmlViewer/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
);
};
handleNoteClick = (event: Event) => {
if (event && event.target) {
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
}
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
};
handleRenderBook = async () => {
if (lock) return;
Expand Down Expand Up @@ -346,7 +344,7 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
id="page-area"
style={
document.body.clientWidth < 570
? { left: 0, right: 0 }
? { left: 20, right: 20 }
: this.state.readerMode === "scroll"
? {
marginLeft: `calc(50vw - ${
Expand Down
8 changes: 3 additions & 5 deletions src/pages/pdfReader/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,9 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
);
};
handleNoteClick = (event: Event) => {
if (event && event.target) {
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
}
this.props.handleNoteKey((event.target as any).dataset.key);
this.props.handleMenuMode("note");
this.props.handleOpenMenu(true);
};
render() {
return (
Expand Down
1 change: 0 additions & 1 deletion src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const Router = () => {
if (lng) {
//Compatile with 1.6.0 and older
if (lng === "zh") {
console.log(lng);
i18n.changeLanguage("zhCN");
} else if (lng === "cht") {
i18n.changeLanguage("zhTW");
Expand Down
11 changes: 9 additions & 2 deletions src/utils/fileUtils/pdfUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const showPDFHighlight = (
selected: any,
colorCode: string,
noteKey: string,
handlePDFClick: any
handleNoteClick: any
) => {
let iWin = getPDFIframeDoc();
if (!iWin) return;
Expand Down Expand Up @@ -180,7 +180,14 @@ export const showPDFHighlight = (
el?.setAttribute("data-key", noteKey);
el?.setAttribute("class", "pdf-note");
el?.addEventListener("click", (event: any) => {
handlePDFClick(event);
if (event && event.target) {
if (
(event.target as any).dataset &&
(event.target as any).dataset.key
) {
handleNoteClick(event);
}
}
});

pageElement.appendChild(el);
Expand Down
Loading

0 comments on commit ba8525a

Please sign in to comment.