diff --git a/dev/data/structured-content-overrides.css b/dev/data/structured-content-overrides.css index dca2b1839..0878eede2 100644 --- a/dev/data/structured-content-overrides.css +++ b/dev/data/structured-content-overrides.css @@ -28,18 +28,10 @@ .gloss-image-link:hover { /* remove-rule */ } -.gloss-image-container-overlay { - font-size: initial; - line-height: initial; - color: initial; -} :root[data-browser=firefox] .gloss-image-link[data-image-rendering=crisp-edges] .gloss-image, :root[data-browser=firefox-mobile] .gloss-image-link[data-image-rendering=crisp-edges] .gloss-image { /* remove-rule */ } -.gloss-image-link-text { - line-height: initial; -} .gloss-sc-thead, .gloss-sc-tfoot, .gloss-sc-th { diff --git a/ext/css/structured-content.css b/ext/css/structured-content.css index db15d4980..a79d9ddc4 100644 --- a/ext/css/structured-content.css +++ b/ext/css/structured-content.css @@ -19,14 +19,6 @@ /* Glossary images */ .gloss-image-container { display: inline-block; - white-space: nowrap; - max-width: 100%; - max-height: 100vh; - position: relative; - vertical-align: top; - line-height: 0; - font-size: calc(1em / var(--font-size-no-units)); - overflow: hidden; } .gloss-image-link[data-background=true]>.gloss-image-container { background-color: var(--gloss-image-background-color); @@ -45,28 +37,6 @@ .gloss-image-link[href]:hover { cursor: pointer; } -.gloss-image-container-overlay { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - font-size: calc(1em * var(--font-size-no-units)); - line-height: var(--line-height); - display: table; - table-layout: fixed; - white-space: normal; - color: var(--text-color-light3); -} -.gloss-image-link[data-has-image=true][data-image-load-state=load-error] .gloss-image-container-overlay::after { - content: 'Image failed to load'; - display: table-cell; - width: 100%; - height: 100%; - vertical-align: middle; - text-align: center; - padding: 0.25em; -} .gloss-image { display: inline-block; vertical-align: top; @@ -92,12 +62,6 @@ :root[data-browser=firefox-mobile] .gloss-image-link[data-image-rendering=crisp-edges] .gloss-image { image-rendering: auto; } -.gloss-image-link[data-has-aspect-ratio=true] .gloss-image-sizer { - display: inline-block; - width: 0; - vertical-align: top; - font-size: 0; -} .gloss-image-link[data-appearance=monochrome] .gloss-image { filter: grayscale(1); diff --git a/ext/data/structured-content-style.json b/ext/data/structured-content-style.json index c5bb7d38a..47b1e9951 100644 --- a/ext/data/structured-content-style.json +++ b/ext/data/structured-content-style.json @@ -2,7 +2,8 @@ { "selectors": [".gloss-image-container"], "styles": [ - ["display", "inline-block"] + ["display", "inline-block"], + ["font-size", "1px"] ] }, { @@ -22,56 +23,6 @@ ["cursor", "pointer"] ] }, - { - "selectors": [".gloss-image-container-overlay"], - "styles": [ - ["position", "absolute"], - ["left", "0"], - ["top", "0"], - ["width", "100%"], - ["height", "100%"], - ["display", "table"], - ["table-layout", "fixed"], - ["white-space", "normal"], - ["font-size", "initial"], - ["line-height", "initial"], - ["color", "initial"] - ] - }, - { - "selectors": [".gloss-image-link[data-has-image=true][data-image-load-state=load-error] .gloss-image-container-overlay::after"], - "styles": [ - ["content", "'Image failed to load'"], - ["display", "table-cell"], - ["width", "100%"], - ["height", "100%"], - ["vertical-align", "middle"], - ["text-align", "center"], - ["padding", "0.25em"] - ] - }, - { - "selectors": [".gloss-image-background"], - "styles": [ - ["--image", "none"], - ["position", "absolute"], - ["left", "0"], - ["top", "0"], - ["width", "100%"], - ["height", "100%"], - ["-webkit-mask-repeat", "no-repeat"], - ["-webkit-mask-position", "center center"], - ["-webkit-mask-mode", "alpha"], - ["-webkit-mask-size", "contain"], - ["-webkit-mask-image", "var(--image)"], - ["mask-repeat", "no-repeat"], - ["mask-position", "center center"], - ["mask-mode", "alpha"], - ["mask-size", "contain"], - ["mask-image", "var(--image)"], - ["background-color", "currentColor"] - ] - }, { "selectors": [".gloss-image"], "styles": [ @@ -79,25 +30,12 @@ ["vertical-align", "top"], ["object-fit", "contain"], ["border", "none"], - ["outline", "none"] + ["outline", "none"], + ["width", "100%"] ] }, { - "selectors": [".gloss-image-link[data-has-aspect-ratio=true] .gloss-image"], - "styles": [ - ] - }, - { - "selectors": [".gloss-image:not([src])"], - "styles": [ - ["display", "none"] - ] - }, - { - "selectors": [ - ".gloss-image-link[data-image-rendering=pixelated] .gloss-image", - ".gloss-image-link[data-image-rendering=pixelated] .gloss-image-background" - ], + "selectors": [".gloss-image-link[data-image-rendering=pixelated] .gloss-image"], "styles": [ ["image-rendering", "auto"], ["image-rendering", "-moz-crisp-edges"], @@ -107,10 +45,7 @@ ] }, { - "selectors": [ - ".gloss-image-link[data-image-rendering=crisp-edges] .gloss-image", - ".gloss-image-link[data-image-rendering=crisp-edges] .gloss-image-background" - ], + "selectors": [".gloss-image-link[data-image-rendering=crisp-edges] .gloss-image"], "styles": [ ["image-rendering", "auto"], ["image-rendering", "-moz-crisp-edges"], @@ -118,50 +53,10 @@ ["image-rendering", "crisp-edges"] ] }, - { - "selectors": [".gloss-image-link[data-has-aspect-ratio=true] .gloss-image-sizer"], - "styles": [ - ["display", "inline-block"], - ["width", "0"], - ["vertical-align", "top"], - ["font-size", "0"] - ] - }, - { - "selectors": [".gloss-image-link-text"], - "styles": [ - ["display", "none"], - ["line-height", "initial"] - ] - }, - { - "selectors": [".gloss-image-link-text::before"], - "styles": [ - ["content", "'['"] - ] - }, - { - "selectors": [".gloss-image-link-text::after"], - "styles": [ - ["content", "']'"] - ] - }, - { - "selectors": [".gloss-image-description"], - "styles": [ - ["display", "block"], - ["white-space", "pre-line"] - ] - }, { "selectors": [".gloss-image-link[data-appearance=monochrome] .gloss-image"], "styles": [ - ] - }, - { - "selectors": [".gloss-image-link:not([data-appearance=monochrome]) .gloss-image-background"], - "styles": [ - ["display", "none"] + ["filter", "grayscale(1)"] ] }, { @@ -261,24 +156,6 @@ ["display", "block"] ] }, - { - "selectors": [ - ".gloss-image-link[data-collapsed=true] .gloss-image-link-text", - ":root[data-glossary-layout-mode=compact] .gloss-image-link[data-collapsible=true] .gloss-image-link-text" - ], - "styles": [ - ["display", "inline"] - ] - }, - { - "selectors": [ - ".gloss-image-link[data-collapsed=true]~.gloss-image-description", - ":root[data-glossary-layout-mode=compact] .gloss-image-description" - ], - "styles": [ - ["display", "inline"] - ] - }, { "selectors": [".gloss-link-external-icon"], "styles": [ diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index b496d0b88..617464d3e 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -863,12 +863,12 @@ "frequency-average-occurrence": "0", "furigana": "画像がぞう", "furigana-plain": "画像[がぞう]", - "glossary": "
(n, termsDictAlias)
", - "glossary-brief": "
", - "glossary-no-dictionary": "
(n)
", - "glossary-first": "
(n, termsDictAlias)
", - "glossary-first-brief": "
", - "glossary-first-no-dictionary": "
(n)
", + "glossary": "
(n, termsDictAlias)
", + "glossary-brief": "
", + "glossary-no-dictionary": "
(n)
", + "glossary-first": "
(n, termsDictAlias)
", + "glossary-first-brief": "
", + "glossary-first-no-dictionary": "
(n)
", "part-of-speech": "Noun", "pitch-accents": "", "pitch-accent-graphs": "", @@ -1570,12 +1570,12 @@ "frequency-average-occurrence": "0", "furigana": "画像がぞう", "furigana-plain": "画像[がぞう]", - "glossary": "
(n, termsDictAlias)
", - "glossary-brief": "
", - "glossary-no-dictionary": "
(n)
", - "glossary-first": "
(n, termsDictAlias)
", - "glossary-first-brief": "
", - "glossary-first-no-dictionary": "
(n)
", + "glossary": "
(n, termsDictAlias)
", + "glossary-brief": "
", + "glossary-no-dictionary": "
(n)
", + "glossary-first": "
(n, termsDictAlias)
", + "glossary-first-brief": "
", + "glossary-first-no-dictionary": "
(n)
", "part-of-speech": "Noun", "pitch-accents": "", "pitch-accent-graphs": "", diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index 199046900..5fa0f3184 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -10869,7 +10869,6 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryAlias": "termsDictAlias", - "hasReading": true, "frequency": 10, "displayValue": null, @@ -19650,7 +19649,7 @@ ] }, { - "name": "Find term using primary reading 1", + "name": "Find terms using primary reading 1", "originalTextLength": 2, "dictionaryEntries": [ { @@ -19814,10 +19813,9 @@ ] }, { - "name": "Find term using primary reading 2", + "name": "Find terms using primary reading 2", "originalTextLength": 2, "dictionaryEntries": [ - { "type": "term", "isPrimary": true, diff --git a/test/database.test.js b/test/database.test.js index 8bc95ceb3..50fc21344 100644 --- a/test/database.test.js +++ b/test/database.test.js @@ -26,9 +26,11 @@ import {parseJson} from '../dev/json.js'; import {DictionaryDatabase} from '../ext/js/dictionary/dictionary-database.js'; import {DictionaryImporter} from '../ext/js/dictionary/dictionary-importer.js'; import {DictionaryImporterMediaLoader} from './mocks/dictionary-importer-media-loader.js'; +import {setupStubs} from './utilities/database.js'; const dirname = pathDirname(fileURLToPath(import.meta.url)); +setupStubs(); vi.stubGlobal('IDBKeyRange', IDBKeyRange); /** diff --git a/test/dictionary-data.test.js b/test/dictionary-data.test.js index cfb951d82..c3e9bb817 100644 --- a/test/dictionary-data.test.js +++ b/test/dictionary-data.test.js @@ -22,13 +22,17 @@ import {describe} from 'vitest'; import {parseJson} from '../dev/json.js'; import {createTranslatorTest} from './fixtures/translator-test.js'; import {createTestAnkiNoteData, getTemplateRenderResults} from './utilities/anki.js'; +import {setupStubs} from './utilities/database.js'; import {createFindKanjiOptions, createFindTermsOptions} from './utilities/translator.js'; +setupStubs(); + const dirname = path.dirname(fileURLToPath(import.meta.url)); const dictionaryName = 'Test Dictionary 2'; const test = await createTranslatorTest(void 0, path.join(dirname, 'data/dictionaries/valid-dictionary1'), dictionaryName); describe('Dictionary data', () => { + console.log('test'); const testInputsFilePath = path.join(dirname, 'data/translator-test-inputs.json'); /** @type {import('test/translator').TranslatorTestInputs} */ const {optionsPresets, tests} = parseJson(readFileSync(testInputsFilePath, {encoding: 'utf8'})); diff --git a/test/dictionary-data.write.js b/test/dictionary-data.write.js index 880d23798..0dc9f5c36 100644 --- a/test/dictionary-data.write.js +++ b/test/dictionary-data.write.js @@ -21,8 +21,11 @@ import path from 'path'; import {parseJson} from '../dev/json.js'; import {createTranslatorTest} from './fixtures/translator-test.js'; import {createTestAnkiNoteData, getTemplateRenderResults} from './utilities/anki.js'; +import {setupStubs} from './utilities/database.js'; import {createFindKanjiOptions, createFindTermsOptions} from './utilities/translator.js'; +setupStubs(); + /** * @param {string} fileName * @param {unknown} content