Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
add: preview dark mode
Browse files Browse the repository at this point in the history
change: make 'auto preview' false by default
change: 'auto preview' label text
  • Loading branch information
xiangyu committed Jul 16, 2022
1 parent a63c4ba commit 482fe53
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions addon/chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<preferences id="zotero-preferences-__addonRef__">
<preference id="pref-__addonRef__-enable" name="extensions.zotero.__addonRef__.enable" type="bool" />
<preference id="pref-__addonRef__-autoPreview" name="extensions.zotero.__addonRef__.autoPreview" type="bool" />
<preference id="pref-__addonRef__-darkMode" name="extensions.zotero.__addonRef__.darkMode" type="bool" />
<preference id="pref-__addonRef__-previewPageNum" name="extensions.zotero.__addonRef__.previewPageNum" type="string" />
<preference id="pref-__addonRef__-previewTabName" name="extensions.zotero.__addonRef__.previewTabName" type="string" />
</preferences>
Expand All @@ -18,6 +19,9 @@
<row>
<checkbox id="zotero-prefpane-__addonRef__-settings-autoPreview" preference="pref-__addonRef__-autoPreview" label="&zotero.__addonRef__.pref.autoPreview.label;" />
</row>
<row>
<checkbox id="zotero-prefpane-__addonRef__-settings-darkMode" preference="pref-__addonRef__-darkMode" label="&zotero.__addonRef__.pref.darkMode.label;" />
</row>
<row>
<label control="zotero-prefpane-__addonRef__-settings-previewPageNum" value="&zotero.__addonRef__.pref.previewPageNumBefore.label;" />
<textbox id="zotero-prefpane-__addonRef__-settings-previewPageNum" preference="pref-__addonRef__-previewPageNum" />
Expand Down
6 changes: 6 additions & 0 deletions addon/chrome/content/previewPDF.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
// let item = Zotero.PDFPreview.preview.item;
// Block other possible renders
Zotero.PDFPreview.preview._loadingPromise = Zotero.Promise.defer();
const viewerContainer = document.getElementById("pdf-viewer");
if (Zotero.Prefs.get("pdfpreview.darkMode")) {
viewerContainer.style.filter = "invert(100%)";
} else {
viewerContainer.style.removeProperty("filter");
}

try {
viewer = document.getElementById("pdf-viewer");
Expand Down
3 changes: 2 additions & 1 deletion addon/chrome/locale/en-US/overlay.dtd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!ENTITY zotero.__addonRef__.pref.label "Preview">
<!ENTITY zotero.__addonRef__.pref.enable.label "Enable Preview">
<!ENTITY zotero.__addonRef__.pref.autoPreview.label "Auto Preview PDF">
<!ENTITY zotero.__addonRef__.pref.autoPreview.label "Auto Focus Preview Tab">
<!ENTITY zotero.__addonRef__.pref.darkMode.label "Dark Mode">
<!ENTITY zotero.__addonRef__.pref.previewPageNumBefore.label "Preview First">
<!ENTITY zotero.__addonRef__.pref.previewPageNumAfter.label "Pages">
<!ENTITY zotero.__addonRef__.pref.previewTabNameBefore.label "Preview Tab Name">
Expand Down
3 changes: 2 additions & 1 deletion addon/chrome/locale/zh-CN/overlay.dtd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!ENTITY zotero.__addonRef__.pref.label "预览">
<!ENTITY zotero.__addonRef__.pref.enable.label "启用预览">
<!ENTITY zotero.__addonRef__.pref.autoPreview.label "自动预览PDF">
<!ENTITY zotero.__addonRef__.pref.autoPreview.label "自动选中预览">
<!ENTITY zotero.__addonRef__.pref.darkMode.label "黑暗模式">
<!ENTITY zotero.__addonRef__.pref.previewPageNumBefore.label "预览前">
<!ENTITY zotero.__addonRef__.pref.previewPageNumAfter.label "页">
<!ENTITY zotero.__addonRef__.pref.previewTabNameBefore.label "预览标签名称">
Expand Down
3 changes: 2 additions & 1 deletion addon/defaults/preferences/defaults.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pref("extensions.zotero.pdfpreview.enable", true);
pref("extensions.zotero.pdfpreview.autoPreview", true);
pref("extensions.zotero.pdfpreview.autoPreview", false);
pref("extensions.zotero.pdfpreview.darkMode", false);
pref("extensions.zotero.pdfpreview.previewPageNum", "10");
pref("extensions.zotero.pdfpreview.previewTabName", "Preview");

0 comments on commit 482fe53

Please sign in to comment.