Add menu option to toggle dark mode for reader content
This commit is contained in:
parent
c549a96834
commit
c208325aeb
6 changed files with 19 additions and 2 deletions
|
@ -557,6 +557,8 @@ const ZoteroStandalone = new function() {
|
|||
}
|
||||
this.updateMenuItemCheckmark('view-menuitem-split-vertically', reader.splitType === 'vertical');
|
||||
this.updateMenuItemCheckmark('view-menuitem-split-horizontally', reader.splitType === 'horizontal');
|
||||
this.updateMenuItemCheckmark('view-menuitem-use-dark-mode-for-content', Zotero.Prefs.get('reader.useDarkModeForContent'));
|
||||
this.updateMenuItemEnabled('view-menuitem-use-dark-mode-for-content', window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
}
|
||||
|
||||
// Layout mode
|
||||
|
|
|
@ -215,6 +215,7 @@ class ReaderInstance {
|
|||
...Zotero.Intl.getPrefixedStrings('pdfReader.')
|
||||
},
|
||||
showAnnotations: true,
|
||||
useDarkModeForContent: Zotero.Prefs.get('reader.useDarkModeForContent'),
|
||||
fontFamily: Zotero.Prefs.get('reader.ebookFontFamily'),
|
||||
onOpenContextMenu: () => {
|
||||
// Functions can only be passed over wrappedJSObject (we call back onClick for context menu items)
|
||||
|
@ -507,6 +508,7 @@ class ReaderInstance {
|
|||
this._prefObserverIDs = [
|
||||
Zotero.Prefs.registerObserver('fontSize', this._handleFontSizeChange),
|
||||
Zotero.Prefs.registerObserver('tabs.title.reader', this._handleTabTitlePrefChange),
|
||||
Zotero.Prefs.registerObserver('reader.useDarkModeForContent', this._handleContentDarkModeChange),
|
||||
Zotero.Prefs.registerObserver('reader.ebookFontFamily', this._handleFontFamilyChange),
|
||||
];
|
||||
|
||||
|
@ -832,6 +834,10 @@ class ReaderInstance {
|
|||
await this.updateTitle();
|
||||
};
|
||||
|
||||
_handleContentDarkModeChange = () => {
|
||||
this._internalReader.useDarkModeForContent(Zotero.Prefs.get('reader.useDarkModeForContent'));
|
||||
};
|
||||
|
||||
_handleFontFamilyChange = () => {
|
||||
this._internalReader.setFontFamily(Zotero.Prefs.get('reader.ebookFontFamily'));
|
||||
};
|
||||
|
|
|
@ -515,7 +515,14 @@
|
|||
oncommand="ZoteroStandalone.currentReader.toggleVerticalSplit()"
|
||||
/>
|
||||
<menuseparator class="menu-type-reader"/>
|
||||
|
||||
<menuitem
|
||||
id="view-menuitem-use-dark-mode-for-content"
|
||||
class="menu-type-reader"
|
||||
type="checkbox"
|
||||
label="&zotero.pdfReader.useDarkModeForContent;"
|
||||
oncommand="Zotero.Prefs.set('reader.useDarkModeForContent', !Zotero.Prefs.get('reader.useDarkModeForContent'))"
|
||||
/>
|
||||
<menuseparator class="menu-type-reader"/>
|
||||
<menu id="layout-menu" label="&layout.label;">
|
||||
<menupopup oncommand="ZoteroStandalone.onViewMenuItemClick(event)">
|
||||
<menuitem
|
||||
|
|
|
@ -333,3 +333,4 @@
|
|||
<!ENTITY zotero.pdfReader.transferFromPDF "Import Annotations…">
|
||||
<!ENTITY zotero.pdfReader.rotatePageLeft "Rotate Page Left">
|
||||
<!ENTITY zotero.pdfReader.rotatePageRight "Rotate Page Right">
|
||||
<!ENTITY zotero.pdfReader.useDarkModeForContent "Use Dark Mode for Content">
|
||||
|
|
|
@ -219,6 +219,7 @@ pref("extensions.zotero.scaffold.eslint.enabled", true);
|
|||
pref("extensions.zotero.tabs.title.reader", "titleCreatorYear");
|
||||
|
||||
// Reader
|
||||
pref("extensions.zotero.reader.useDarkModeForContent", true);
|
||||
pref("extensions.zotero.reader.ebookFontFamily", "Georgia, serif");
|
||||
|
||||
// Set color scheme to auto by default
|
||||
|
|
2
reader
2
reader
|
@ -1 +1 @@
|
|||
Subproject commit 4b0c629ee10df3978abd84b665954b16fb176aeb
|
||||
Subproject commit 6a281b397531825a5bd973f0e8260eeb1c62b44d
|
Loading…
Reference in a new issue