Restore the option to set light/dark mode for chromium and generic builds
This commit is contained in:
parent
ffbfd680ec
commit
53101b379b
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"viewerCssTheme": {
|
||||||
|
"title": "Theme",
|
||||||
|
"description": "The theme to use.\n0 = Use system theme.\n1 = Light theme.\n2 = Dark theme.",
|
||||||
|
"type": "integer",
|
||||||
|
"enum": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"default": 2
|
||||||
|
},
|
||||||
"showPreviousViewOnLoad": {
|
"showPreviousViewOnLoad": {
|
||||||
"description": "DEPRECATED. Set viewOnLoad to 1 to disable showing the last page/position on load.",
|
"description": "DEPRECATED. Set viewOnLoad to 1 to disable showing the last page/position on load.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -25,6 +25,7 @@ import merge from "merge-stream";
|
|||||||
import { mkdirp } from "mkdirp";
|
import { mkdirp } from "mkdirp";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import postcss from "gulp-postcss";
|
import postcss from "gulp-postcss";
|
||||||
|
import postcssDarkThemeClass from "postcss-dark-theme-class";
|
||||||
import postcssDirPseudoClass from "postcss-dir-pseudo-class";
|
import postcssDirPseudoClass from "postcss-dir-pseudo-class";
|
||||||
import postcssDiscardComments from "postcss-discard-comments";
|
import postcssDiscardComments from "postcss-discard-comments";
|
||||||
import postcssNesting from "postcss-nesting";
|
import postcssNesting from "postcss-nesting";
|
||||||
@ -1004,6 +1005,7 @@ function buildGeneric(defines, dir) {
|
|||||||
postcssDirPseudoClass(),
|
postcssDirPseudoClass(),
|
||||||
discardCommentsCSS(),
|
discardCommentsCSS(),
|
||||||
postcssNesting(),
|
postcssNesting(),
|
||||||
|
postcssDarkThemeClass(),
|
||||||
autoprefixer(AUTOPREFIXER_CONFIG),
|
autoprefixer(AUTOPREFIXER_CONFIG),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@ -1495,6 +1497,7 @@ gulp.task(
|
|||||||
postcssDirPseudoClass(),
|
postcssDirPseudoClass(),
|
||||||
discardCommentsCSS(),
|
discardCommentsCSS(),
|
||||||
postcssNesting(),
|
postcssNesting(),
|
||||||
|
postcssDarkThemeClass(),
|
||||||
autoprefixer(AUTOPREFIXER_CONFIG),
|
autoprefixer(AUTOPREFIXER_CONFIG),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
23
package-lock.json
generated
23
package-lock.json
generated
@ -47,6 +47,7 @@
|
|||||||
"path2d-polyfill": "^2.0.1",
|
"path2d-polyfill": "^2.0.1",
|
||||||
"pngjs": "^7.0.0",
|
"pngjs": "^7.0.0",
|
||||||
"postcss": "^8.4.31",
|
"postcss": "^8.4.31",
|
||||||
|
"postcss-dark-theme-class": "^1.0.0",
|
||||||
"postcss-dir-pseudo-class": "^8.0.0",
|
"postcss-dir-pseudo-class": "^8.0.0",
|
||||||
"postcss-discard-comments": "^6.0.0",
|
"postcss-discard-comments": "^6.0.0",
|
||||||
"postcss-nesting": "^12.0.1",
|
"postcss-nesting": "^12.0.1",
|
||||||
@ -16724,6 +16725,28 @@
|
|||||||
"node": "^10 || ^12 || >=14"
|
"node": "^10 || ^12 || >=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/postcss-dark-theme-class": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/postcss-dark-theme-class/-/postcss-dark-theme-class-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-7XiFx8Ahvot3YmHjs4/jlxyUggomSNZzoF1hyS5xIZpLyfcPY8vb/3q4QPP8CqhnnA911OrDOZL7OTkjHoEjdw==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/postcss/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"postcss": "^8.2.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/postcss-dir-pseudo-class": {
|
"node_modules/postcss-dir-pseudo-class": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-8.0.0.tgz",
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
"@babel/core": "^7.23.3",
|
"@babel/core": "^7.23.3",
|
||||||
"@babel/preset-env": "^7.23.3",
|
"@babel/preset-env": "^7.23.3",
|
||||||
"@babel/runtime": "^7.23.2",
|
"@babel/runtime": "^7.23.2",
|
||||||
|
"@fluent/bundle": "^0.18.0",
|
||||||
|
"@fluent/dom": "^0.9.0",
|
||||||
"@javascript-obfuscator/escodegen": "2.3.0",
|
"@javascript-obfuscator/escodegen": "2.3.0",
|
||||||
"acorn": "^8.11.2",
|
"acorn": "^8.11.2",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
@ -24,8 +26,6 @@
|
|||||||
"eslint-plugin-prettier": "^5.0.1",
|
"eslint-plugin-prettier": "^5.0.1",
|
||||||
"eslint-plugin-sort-exports": "^0.8.0",
|
"eslint-plugin-sort-exports": "^0.8.0",
|
||||||
"eslint-plugin-unicorn": "^49.0.0",
|
"eslint-plugin-unicorn": "^49.0.0",
|
||||||
"@fluent/bundle": "^0.18.0" ,
|
|
||||||
"@fluent/dom": "^0.9.0",
|
|
||||||
"globals": "^13.23.0",
|
"globals": "^13.23.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-postcss": "^9.0.1",
|
"gulp-postcss": "^9.0.1",
|
||||||
@ -41,6 +41,7 @@
|
|||||||
"path2d-polyfill": "^2.0.1",
|
"path2d-polyfill": "^2.0.1",
|
||||||
"pngjs": "^7.0.0",
|
"pngjs": "^7.0.0",
|
||||||
"postcss": "^8.4.31",
|
"postcss": "^8.4.31",
|
||||||
|
"postcss-dark-theme-class": "^1.0.0",
|
||||||
"postcss-dir-pseudo-class": "^8.0.0",
|
"postcss-dir-pseudo-class": "^8.0.0",
|
||||||
"postcss-discard-comments": "^6.0.0",
|
"postcss-discard-comments": "^6.0.0",
|
||||||
"postcss-nesting": "^12.0.1",
|
"postcss-nesting": "^12.0.1",
|
||||||
|
15
web/app.js
15
web/app.js
@ -228,6 +228,21 @@ const PDFViewerApplication = {
|
|||||||
await this._parseHashParams();
|
await this._parseHashParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
let mode;
|
||||||
|
switch (AppOptions.get("viewerCssTheme")) {
|
||||||
|
case 1:
|
||||||
|
mode = "is-light";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
mode = "is-dark";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mode) {
|
||||||
|
document.documentElement.classList.add(mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure that the `L10n`-instance has been initialized before creating
|
// Ensure that the `L10n`-instance has been initialized before creating
|
||||||
// e.g. the various viewer components.
|
// e.g. the various viewer components.
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
|
@ -329,6 +329,13 @@ const defaultOptions = {
|
|||||||
kind: OptionKind.WORKER,
|
kind: OptionKind.WORKER,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
defaultOptions.viewerCssTheme = {
|
||||||
|
/** @type {number} */
|
||||||
|
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME") ? 2 : 0,
|
||||||
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
|
};
|
||||||
|
}
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
defaultOptions.defaultUrl = {
|
defaultOptions.defaultUrl = {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
|
Loading…
Reference in New Issue
Block a user