summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--types/ext/dictionary-importer.d.ts21
-rw-r--r--types/ext/dom-text-scanner.d.ts22
-rw-r--r--types/ext/log.d.ts9
-rw-r--r--types/ext/text-scanner.d.ts12
10 files changed, 61 insertions, 57 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) {
diff --git a/types/ext/dictionary-importer.d.ts b/types/ext/dictionary-importer.d.ts
index cda1bd19..2d16dc5e 100644
--- a/types/ext/dictionary-importer.d.ts
+++ b/types/ext/dictionary-importer.d.ts
@@ -25,20 +25,13 @@ export type OnProgressCallback = (data: ProgressData) => void;
/**
* An enum representing the import step.
- *
- * `-2` `-1` Dictionary import is uninitialized.
- *
- * `0` Load dictionary archive and validate index step.
- *
- * `1` Load schemas and get archive files step.
- *
- * `2` Load and validate dictionary data step.
- *
- * `3` Format dictionary data and extended data support step.
- *
- * `4` Resolve async requirements and import media step.
- *
- * `5` Add dictionary descriptor and import data step.
+ * - `-2` `-1` - Dictionary import is uninitialized.
+ * - `0` - Load dictionary archive and validate index step.
+ * - `1` - Load schemas and get archive files step.
+ * - `2` - Load and validate dictionary data step.
+ * - `3` - Format dictionary data and extended data support step.
+ * - `4` - Resolve async requirements and import media step.
+ * - `5` - Add dictionary descriptor and import data step.
*/
export type ImportStep = -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5;
diff --git a/types/ext/dom-text-scanner.d.ts b/types/ext/dom-text-scanner.d.ts
index 33c01aa8..c3e26493 100644
--- a/types/ext/dom-text-scanner.d.ts
+++ b/types/ext/dom-text-scanner.d.ts
@@ -24,3 +24,25 @@
* - `3` - Character should be added to the content and is a newline.
*/
export type CharacterAttributes = 0 | 1 | 2 | 3;
+
+/**
+ * Seek information about an element.
+ * 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.
+ */
+export type ElementSeekInfo = {
+ enterable: boolean;
+ newlines: number;
+};
+
+/**
+ * Information about the whitespace.
+ * `preserveNewlines` indicates whether or not newline characters are treated as line breaks.
+ * `preserveWhitespace` indicates whether or not sequences of whitespace characters are collapsed.
+ */
+export type WhitespaceSettings = {
+ preserveNewlines: boolean;
+ preserveWhitespace: boolean;
+};
diff --git a/types/ext/log.d.ts b/types/ext/log.d.ts
index e8ca4c43..18616d58 100644
--- a/types/ext/log.d.ts
+++ b/types/ext/log.d.ts
@@ -25,12 +25,9 @@ export type LogContext = {
/**
* An enum representing the log error level.
- *
- * `0` _log_, _info_, _debug_ level.
- *
- * `1` _warn_ level.
- *
- * `2` _error_ level.
+ * - `0` - _log_, _info_, _debug_ level.
+ * - `1` - _warn_ level.
+ * - `2` - _error_ level.
*/
export type LogErrorLevelValue = 0 | 1 | 2;
diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts
index e2779e4d..d4214a1d 100644
--- a/types/ext/text-scanner.d.ts
+++ b/types/ext/text-scanner.d.ts
@@ -197,14 +197,10 @@ export type PointerEventType = (
/**
* An enum representing the pen pointer state.
- *
- * `0` Not active.
- *
- * `1` Hovering.
- *
- * `2` Touching.
- *
- * `3` Hovering after touching.
+ * - `0` - Not active.
+ * - `1` - Hovering.
+ * - `2` - Touching.
+ * - `3` - Hovering after touching.
*/
export type PenPointerState = 0 | 1 | 2 | 3;