aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/js/app/frontend.js1
-rw-r--r--ext/js/background/backend.js4
-rw-r--r--ext/js/core.js2
-rw-r--r--ext/js/display/display.js2
-rw-r--r--ext/js/dom/dom-text-scanner.js15
-rw-r--r--ext/js/templates/sandbox/anki-template-renderer.js30
6 files changed, 25 insertions, 29 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js
index 9dafde7a..eb88beef 100644
--- a/ext/js/app/frontend.js
+++ b/ext/js/app/frontend.js
@@ -864,7 +864,6 @@ export class Frontend {
case 'web': return preventMiddleMouseOptions.onWebPages;
case 'popup': return preventMiddleMouseOptions.onPopupPages;
case 'search': return preventMiddleMouseOptions.onSearchPages;
- default: return false;
}
}
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 481567b5..3f3c6063 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -2629,14 +2629,14 @@ export class Backend {
}
/**
+ * Only request this permission for Firefox versions >= 77.
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1630413
* @returns {Promise<void>}
*/
async _requestPersistentStorage() {
try {
if (await navigator.storage.persisted()) { return; }
- // Only request this permission for Firefox versions >= 77.
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1630413
const {vendor, version} = await browser.runtime.getBrowserInfo();
if (vendor !== 'Mozilla') { return; }
diff --git a/ext/js/core.js b/ext/js/core.js
index 726b037c..854099e8 100644
--- a/ext/js/core.js
+++ b/ext/js/core.js
@@ -686,11 +686,11 @@ export class Logger extends EventDispatcher {
/* eslint-disable no-console */
switch (level) {
+ case 'log': console.log(message); break;
case 'info': console.info(message); break;
case 'debug': console.debug(message); break;
case 'warn': console.warn(message); break;
case 'error': console.error(message); break;
- default: console.log(message); break;
}
/* eslint-enable no-console */
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index cae394f8..ff77d203 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -480,7 +480,7 @@ export class Display extends EventDispatcher {
case 'overwrite':
this._history.replaceState(state, content, url);
break;
- default: // 'new'
+ case 'new':
this._updateHistoryState();
this._history.pushState(state, content, url);
break;
diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js
index 21770a70..e9105741 100644
--- a/ext/js/dom/dom-text-scanner.js
+++ b/ext/js/dom/dom-text-scanner.js
@@ -212,10 +212,8 @@ export class DOMTextScanner {
/**
* Gets information about how whitespace characters are treated.
- * @param {Text} textNode The text node to check.
- * @returns {{preserveNewlines: boolean, preserveWhitespace: boolean}} Information about the whitespace.
- * The value of `preserveNewlines` indicates whether or not newline characters are treated as line breaks.
- * The value of `preserveWhitespace` indicates whether or not sequences of whitespace characters are collapsed.
+ * @param {Text} textNode
+ * @returns {import('dom-text-scanner').WhitespaceSettings}
*/
_getWhitespaceSettings(textNode) {
if (this._forcePreserveWhitespace) {
@@ -412,13 +410,8 @@ export class DOMTextScanner {
}
/**
- * Gets seek information about an element.
- * @param {Element} element The element to check.
- * @returns {{enterable: boolean, newlines: number}} The seek information.
- * The `enterable` value indicates whether the content of this node should be entered.
- * The `newlines` value corresponds to the number of newline characters that should be added.
- * - 1 newline corresponds to a simple new line in the layout.
- * - 2 newlines corresponds to a significant visual distinction since the previous content.
+ * @param {Element} element
+ * @returns {import('dom-text-scanner').ElementSeekInfo}
*/
static getElementSeekInfo(element) {
let enterable = true;
diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js
index 15810239..3311097f 100644
--- a/ext/js/templates/sandbox/anki-template-renderer.js
+++ b/ext/js/templates/sandbox/anki-template-renderer.js
@@ -235,14 +235,16 @@ export class AnkiTemplateRenderer {
return this._stringToMultiLineHtml(this._computeValueString(options, context));
}
- /** @type {import('template-renderer').HelperFunction<string>} */
+ /**
+ * Usage:
+ * ```{{#regexReplace regex string [flags] [content]...}}content{{/regexReplace}}```
+ * - regex: regular expression string
+ * - string: string to replace
+ * - flags: optional flags for regular expression.
+ * e.g. "i" for case-insensitive, "g" for replace all
+ * @type {import('template-renderer').HelperFunction<string>}
+ */
_regexReplace(args, context, options) {
- // Usage:
- // {{#regexReplace regex string [flags] [content]...}}content{{/regexReplace}}
- // regex: regular expression string
- // string: string to replace
- // flags: optional flags for regular expression
- // e.g. "i" for case-insensitive, "g" for replace all
const argCount = args.length;
let value = this._computeValueString(options, context);
if (argCount > 3) {
@@ -262,13 +264,15 @@ export class AnkiTemplateRenderer {
return value;
}
- /** @type {import('template-renderer').HelperFunction<string>} */
+ /**
+ * Usage:
+ * {{#regexMatch regex [flags] [content]...}}content{{/regexMatch}}
+ * - regex: regular expression string
+ * - flags: optional flags for regular expression
+ * e.g. "i" for case-insensitive, "g" for match all
+ * @type {import('template-renderer').HelperFunction<string>}
+ */
_regexMatch(args, context, options) {
- // Usage:
- // {{#regexMatch regex [flags] [content]...}}content{{/regexMatch}}
- // regex: regular expression string
- // flags: optional flags for regular expression
- // e.g. "i" for case-insensitive, "g" for match all
const argCount = args.length;
let value = this._computeValueString(options, context);
if (argCount > 2) {