Skip to content

Commit

Permalink
Nested Tags
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny committed Feb 28, 2023
1 parent 9485314 commit 231ea44
Show file tree
Hide file tree
Showing 15 changed files with 1,257 additions and 281 deletions.
7 changes: 4 additions & 3 deletions addon/chrome/content/dialog.xul
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

<dialog xmlns="http:https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="cancel,accept"
onload="Dialog.init()"
ondialogaccept="Dialog.accept()"
ondialogcancel="Dialog.cancel()"
onload="window.Dialog.init()"
ondialogaccept="window.Dialog.accept()"
ondialogcancel="window.Dialog.cancel()"
style="background-color: #fff;"
>
<script src="include.js"/>
<script src="dialog.js"/>
Expand Down
Binary file added addon/chrome/content/icons/excel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/chrome/content/icons/picture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/chrome/content/icons/ppt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/chrome/content/icons/word.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/chrome/content/icons/zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions addon/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pref("extensions.zotero.__addonRef__.titleColumn.tags", false);
pref("extensions.zotero.__addonRef__.titleColumn.opacity", "0.7");
pref("extensions.zotero.__addonRef__.titleColumn.odd", "");
pref("extensions.zotero.__addonRef__.titleColumn.even", "");
pref("extensions.zotero.__addonRef__.titleColumn.selected", "");



pref("extensions.zotero.__addonRef__.function.IFColumn.enable", true);
Expand Down Expand Up @@ -66,6 +68,8 @@ pref("extensions.zotero.__addonRef__.annotationColorsGroups", '[["Untitled",[["g

pref("extensions.zotero.__addonRef__.function.itemTypeFilter.enable", true);

pref("extensions.zotero.__addonRef__.nestedTags.sortord", "0");




Expand Down
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.2.6",
"version": "2.3.0",
"description": "让你的Zotero看起来更有趣",
"config": {
"addonName": "Zotero Style",
Expand Down
5 changes: 3 additions & 2 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function onStartup() {
const views = new Views(addonItem)
Zotero.ZoteroStyle.data.views = views

await views.initTags()
await views.renderTitleProgress()
await views.createTagsColumn()
await views.createTextTagsColumn()
Expand Down Expand Up @@ -82,13 +83,13 @@ async function onNotify(
extraData: { [key: string]: any }
) {
// You can add your code to the corresponding notify type
console.log("notify", event, type, ids, extraData);
ztoolkit.log("notify", event, type, ids, extraData);
if (
event == "select" &&
type == "tab" &&
extraData[ids[0]].type == "reader"
) {
console.log("select reader tab")
ztoolkit.log("select reader tab")
let reader = await ztoolkit.Reader.getReader();
// 重置等待更新
addonItem.set(
Expand Down
19 changes: 9 additions & 10 deletions src/modules/item.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const log = console.log
export default class AddonItem {
public item!: _ZoteroItem;
public title = "Addon Item"
Expand All @@ -12,16 +11,16 @@ export default class AddonItem {
* @returns
*/
public async init() {
log("******\n\n")
log("AddonItem init is called")
ztoolkit.log("******\n\n")
ztoolkit.log("AddonItem init is called")
let item: _ZoteroItem;
let addonItemKey = Zotero.Prefs.get(this.prefKey)
if (addonItemKey) {
item = await Zotero.Items.getByLibraryAndKeyAsync(1, addonItemKey)
if (item) {
this.item = item
log("From prefKey")
log("\n\n******")
ztoolkit.log("From prefKey")
ztoolkit.log("\n\n******")
this.hiddenNotes()
return
}
Expand All @@ -30,22 +29,22 @@ export default class AddonItem {
s.addCondition("title", "contains", this.title);
var ids = await s.search();
let items = await Zotero.Items.getAsync(ids);
console.log(items)
ztoolkit.log(items)
if (ids.length) {
// exist
item = items[0]
log("From local")
ztoolkit.log("From local")
} else {
// @ts-ignore
item = new Zotero.Item('computerProgram');
item.setField('title', this.title);
await item.saveTx({ skipSelect : true})
log("From new")
ztoolkit.log("From new")
}
Zotero.Prefs.set(this.prefKey, item.key)
this.item = item
this.hiddenNotes()
log("\n\n******")
ztoolkit.log("\n\n******")
}

/**
Expand Down Expand Up @@ -137,7 +136,7 @@ export default class AddonItem {
Zotero.Items.get(ids[0]).itemTypeID == 26 &&
Zotero.Items.get(ids.slice(-1)[0]).itemTypeID == 26
) {
log("hook ids", ids.length)
ztoolkit.log("hook ids", ids.length)
return ids.filter((id: number) => {
const parentID = Zotero.Items.get(id).parentID
if (!parentID) { return true }
Expand Down
1 change: 0 additions & 1 deletion src/modules/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class LocalStorage {
const temp = Zotero.getTempDirectory();
// @ts-ignore
this.filename = window.OS.Path.join(temp.path.replace(temp.leafName, ""), `${name}.json`);
console.log(this.filename)
window.setTimeout(async () => {
await this.init()
})
Expand Down
Loading

0 comments on commit 231ea44

Please sign in to comment.