Skip to content

Commit

Permalink
🧑‍💻 add dev tools
Browse files Browse the repository at this point in the history
clean code
  • Loading branch information
volatile-static committed Dec 7, 2023
1 parent 8bfd7f8 commit 61c9d46
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
2 changes: 1 addition & 1 deletion addon/locale/en-US/chartero-preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ compressHistory = Compress history data
historySize = Current history size: <b>{ $size }</b> KB
maxSummaryItems = Do not render Summary when the number of items exceeds this value:
lastAuthorSankey = Index of the last author in Sankey graph:
translate = Auto translate locale strings using <i>PDFTranslate</i> Plugin
translate = Auto translate locale strings using <i>PDFTranslate</i> Plugin (Experimental)
2 changes: 1 addition & 1 deletion addon/locale/zh-CN/chartero-preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ compressHistory = 清理记录数据
historySize = 当前历史记录共占用存储空间:<b>{ $size }</b> KB
maxSummaryItems = 条目数量超过多少时不再渲染侧边栏:
lastAuthorSankey = 作者关系图中通讯作者名次:
translate = 调用<i>PDFTranslate</i>插件自动翻译界面语言
translate = 调用<i>PDFTranslate</i>插件自动翻译界面语言(Beta)
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"highcharts": "^11.2.0",
"highcharts-vue": "^1.4.3",
"segmentit": "^2.0.3",
"tdesign-vue-next": "^1.7.0",
"tdesign-vue-next": "^1.7.1",
"zotero-plugin-toolkit": "^2.3.11"
},
"devDependencies": {
Expand All @@ -82,11 +82,11 @@
"replace-in-file": "^7.0.2",
"tdesign-icons-vue-next": "^0.2.2",
"ts-node": "^10.9.1",
"unplugin-auto-import": "^0.17.1",
"unplugin-vue-components": "^0.25.2",
"vite": "^5.0.4",
"vue": "^3.3.9",
"vue-tsc": "^1.8.24",
"unplugin-auto-import": "^0.17.2",
"unplugin-vue-components": "^0.26.0",
"vite": "^5.0.6",
"vue": "^3.3.10",
"vue-tsc": "^1.8.25",
"zotero-types": "file:../zotero-types"
},
"eslintConfig": {
Expand Down Expand Up @@ -114,4 +114,4 @@
"publish": false
}
}
}
}
44 changes: 44 additions & 0 deletions src/bootstrap/modules/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,48 @@ export function addDebugMenu() {
icon: `chrome://${config.addonName}/content/icons/icon@16px.png`,
commandListener: () => addon.log((<any>addon.history)._mainItems)
});
addon.menu.register('menuHelp', {
tag: 'menuitem',
label: 'open dev tools',
icon: `chrome://${config.addonName}/content/icons/icon@16px.png`,
commandListener: () => {
const env =
Services.env ||
Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);

env.set("MOZ_BROWSER_TOOLBOX_PORT", 6100);
Zotero.openInViewer(
"chrome://devtools/content/framework/browser-toolbox/window.html",
{
onLoad: (doc: Document) => {
doc.getElementById("status-message-container")!.style.visibility = "collapse";
let toolboxBody: HTMLElement;
waitUntil(
() => {
toolboxBody = doc
.querySelector(".devtools-toolbox-browsertoolbox-iframe")
?.contentDocument?.querySelector(".theme-body");
return toolboxBody;
},
() => {
toolboxBody.style = "pointer-events: all !important";
}
);
},
}
);

function waitUntil(condition: () => unknown, callback: Function, interval = 100, timeout = 10000) {
const start = Date.now();
const intervalId = setInterval(() => {
if (condition()) {
clearInterval(intervalId);
callback();
} else if (Date.now() - start > timeout) {
clearInterval(intervalId);
}
}, interval);
}
}
});
}
6 changes: 5 additions & 1 deletion src/vue/summary/components/sankey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ export default {
nodes.push({ id: journal, column: 2, color });
}
const maxRows = Math.max(
...[0, 1, 2].map(col => nodes.filter(n => n.column === col).length)
journalSet.size,
firstCreatorSet.size,
lastCreatorSet.size
// ...[0, 1, 2].map(col => nodes.filter(n => n.column === col).length)
);
addon.log(nodes)
return {
chart: { animation: undefined, height: maxRows * 26 + 50 },
exporting: { menuItemDefinitions: helpMessageOption(this.locale.doc.sankey) },
Expand Down

0 comments on commit 61c9d46

Please sign in to comment.