Merge pull request #17222 from Snuffleupagus/rm-viewerCssTheme
Remove the `viewerCssTheme`-option, since it's partially broken
This commit is contained in:
commit
50f52b43a5
@ -1,17 +1,6 @@
|
|||||||
{
|
{
|
||||||
"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",
|
||||||
|
48
web/app.js
48
web/app.js
@ -85,12 +85,6 @@ const ViewOnLoad = {
|
|||||||
INITIAL: 1,
|
INITIAL: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ViewerCssTheme = {
|
|
||||||
AUTOMATIC: 0, // Default value.
|
|
||||||
LIGHT: 1,
|
|
||||||
DARK: 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
class DefaultExternalServices {
|
class DefaultExternalServices {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Cannot initialize DefaultExternalServices.");
|
throw new Error("Cannot initialize DefaultExternalServices.");
|
||||||
@ -233,7 +227,6 @@ const PDFViewerApplication = {
|
|||||||
if (AppOptions.get("pdfBugEnabled")) {
|
if (AppOptions.get("pdfBugEnabled")) {
|
||||||
await this._parseHashParams();
|
await this._parseHashParams();
|
||||||
}
|
}
|
||||||
this._forceCssTheme();
|
|
||||||
|
|
||||||
// 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.
|
||||||
@ -347,47 +340,6 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_forceCssTheme() {
|
|
||||||
const cssTheme = AppOptions.get("viewerCssTheme");
|
|
||||||
if (
|
|
||||||
cssTheme === ViewerCssTheme.AUTOMATIC ||
|
|
||||||
!Object.values(ViewerCssTheme).includes(cssTheme)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const styleSheet = document.styleSheets[0];
|
|
||||||
const cssRules = styleSheet?.cssRules || [];
|
|
||||||
for (let i = 0, ii = cssRules.length; i < ii; i++) {
|
|
||||||
const rule = cssRules[i];
|
|
||||||
if (
|
|
||||||
rule instanceof CSSMediaRule &&
|
|
||||||
rule.media?.[0] === "(prefers-color-scheme: dark)"
|
|
||||||
) {
|
|
||||||
if (cssTheme === ViewerCssTheme.LIGHT) {
|
|
||||||
styleSheet.deleteRule(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// cssTheme === ViewerCssTheme.DARK
|
|
||||||
const darkRules =
|
|
||||||
/^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(
|
|
||||||
rule.cssText
|
|
||||||
);
|
|
||||||
if (darkRules?.[1]) {
|
|
||||||
styleSheet.deleteRule(i);
|
|
||||||
styleSheet.insertRule(darkRules[1], i);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (reason) {
|
|
||||||
console.error(`_forceCssTheme: "${reason?.message}".`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -218,11 +218,6 @@ const defaultOptions = {
|
|||||||
value: 1,
|
value: 1,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
viewerCssTheme: {
|
|
||||||
/** @type {number} */
|
|
||||||
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME") ? 2 : 0,
|
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
|
||||||
},
|
|
||||||
viewOnLoad: {
|
viewOnLoad: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: 0,
|
value: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user