Skip to content

Commit

Permalink
#184: Zotero.Reader.open少参数导致的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny committed Mar 1, 2023
1 parent c3d9a2a commit 2d1e922
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zotero-style",
"version": "2.3.1",
"version": "2.3.2",
"description": "让你的Zotero看起来更有趣",
"config": {
"addonName": "Zotero Style",
Expand Down
13 changes: 9 additions & 4 deletions src/modules/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class Tags {
width: "calc(100% - 10px)",
padding: "5px",
height: "auto",
overflowX: "hidden",
overflowX: "",
overflowY: "auto"
}
}, this.nestedTagsContainer) as HTMLDivElement;
Expand Down Expand Up @@ -718,17 +718,19 @@ export class Tags {
listener: () => {
// 从obsidian源码找到的过度
const duration = 100
const transition = `all ${duration}ms cubic-bezier(0.02, 0.01, 0.47, 1) 0s`
const transition = `height ${duration}ms cubic-bezier(0.02, 0.01, 0.47, 1) 0s`
this.state[key].collapse = !this.state[key].collapse
collapseNode!.style!.transform = this.state[key].collapse ? "rotate(-90deg)" : ""
tree.style.overflow = "hidden";
tree.style.transition = "none"
if (this.state[key].collapse) {
// 折叠
tree.style.height = window.getComputedStyle(tree).height;
// console.log("from", tree.style.height)
tree.style.transition = transition;
window.setTimeout(() => {
tree.style.transition = transition;
tree.style.height = "0px"
// console.log("to", tree.style.height)
})
window.setTimeout(() => {
tree.querySelectorAll("*").forEach(e => e.remove())
Expand All @@ -740,14 +742,17 @@ export class Tags {
this.render(...args)
const height = window.getComputedStyle(tree).height
tree.style.height = "0px"
// console.log("from", tree.style.height)
tree.style.transition = transition;
window.setTimeout(() => {
tree.style.transition = transition;
tree.style.height = height
// console.log("to", tree.style.height)
})
}
window.setTimeout(() => {
tree.style.height = ""
tree.style.overflow = "";
tree.style.transition = "";
}, duration)
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/modules/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3461,14 +3461,14 @@ export default class Views {
})
})

// await Zotero.OpenPDF.openToPage(ZoteroPane.getSelectedItems()[0], 2, "CJWKZXCB")
// Zotero.Reader.open(item.id, location
ztoolkit.patch(
Zotero.Reader,
"open",
config.addonRef,
(original) =>
async (id: number, location: { pageIndex: number, annotationKey: string }) => {
async (id: number, location: { pageIndex: number, annotationKey: string }, ...other: any) => {
console.log("open", location, other)
if (!location) {
const tagStart = tagsUI.getTagStart()
if (tagStart) {
Expand All @@ -3485,6 +3485,7 @@ export default class Views {
}
}
}
console.log("then", location)
window.setTimeout(async () => {
// 随着缩放它会一直闪烁,这个bug一直没修复
const win = (
Expand All @@ -3503,7 +3504,7 @@ export default class Views {
},
}, win.document.documentElement as any);
}, 0)
return original.call(Zotero.Reader, id, location)
return original.call(Zotero.Reader, id, location, ...other)
}
)
}
Expand Down
4 changes: 2 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[email protected]": {
"updates": [
{
"version": "2.3.1",
"version": "2.3.2",
"update_link": "https://github.com/muisedestiny/zotero-style/releases/latest/download/zotero-style.xpi",
"applications": {
"gecko": {
Expand All @@ -12,7 +12,7 @@
}
},
{
"version": "2.3.1",
"version": "2.3.2",
"update_link": "https://github.com/muisedestiny/zotero-style/releases/latest/download/zotero-style.xpi",
"applications": {
"zotero": {
Expand Down
2 changes: 1 addition & 1 deletion update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<em:version>2.3.1</em:version>
<em:version>2.3.2</em:version>
<em:targetApplication>
<rdf:Description>
<em:id>[email protected]</em:id>
Expand Down

0 comments on commit 2d1e922

Please sign in to comment.