From 466f0d1735cf8287633966472cfbecf83e304f99 Mon Sep 17 00:00:00 2001 From: RussCoder Date: Sun, 9 Apr 2023 12:17:01 +0300 Subject: [PATCH] V:: v.0.9.2 Data URLs --- extension/manifest.json | 2 +- viewer/CHANGELOG.md | 4 ++++ viewer/src/DjVuViewer.js | 2 +- viewer/src/components/InitialScreen/LinkBlock.jsx | 7 ++++--- viewer/src/hotkeys.js | 2 ++ viewer/src/locales/ChineseSimplified.js | 4 ++-- viewer/src/locales/English.js | 4 ++-- viewer/src/locales/French.js | 4 ++-- viewer/src/locales/Italian.js | 4 ++-- viewer/src/locales/Portuguese.js | 4 ++-- viewer/src/locales/Russian.js | 4 ++-- viewer/src/locales/Spanish.js | 4 ++-- viewer/src/locales/Swedish.js | 2 +- viewer/src/sagas/rootSaga.js | 2 +- 14 files changed, 28 insertions(+), 21 deletions(-) diff --git a/extension/manifest.json b/extension/manifest.json index be4ed65..978d7e2 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "DjVu.js Viewer", "short_name": "DV", - "version": "0.9.1.0", + "version": "0.9.2.0", "author": "RussCoder", "homepage_url": "https://github.com/RussCoder/djvujs", "description": "Opens links to .djvu files. Allows opening files from a local disk. Processes & tags.", diff --git a/viewer/CHANGELOG.md b/viewer/CHANGELOG.md index c871cc7..c8107f7 100644 --- a/viewer/CHANGELOG.md +++ b/viewer/CHANGELOG.md @@ -1,5 +1,9 @@ # DjVu.js Viewer's Changelog +## v.0.9.2 (09.04.2023) + +- Support for "data:" URLs + ## v.0.9.1 (01.02.2023) - Spanish translation update. diff --git a/viewer/src/DjVuViewer.js b/viewer/src/DjVuViewer.js index ef1fb5d..814f997 100644 --- a/viewer/src/DjVuViewer.js +++ b/viewer/src/DjVuViewer.js @@ -17,7 +17,7 @@ const Events = constant({ export default class DjVuViewer extends EventEmitter { - static VERSION = '0.9.1'; + static VERSION = '0.9.2'; static Events = Events; static Constants = Constants; diff --git a/viewer/src/components/InitialScreen/LinkBlock.jsx b/viewer/src/components/InitialScreen/LinkBlock.jsx index f9d6578..5dada0d 100644 --- a/viewer/src/components/InitialScreen/LinkBlock.jsx +++ b/viewer/src/components/InitialScreen/LinkBlock.jsx @@ -41,13 +41,14 @@ const LinkBlock = () => { return ( { e.preventDefault(); - if (/^https?:\/\/.+/.test(url.trim())) { + const trimmedUrl = url.trim(); + if (/((^https?:\/\/)|(^data:)).+/.test(trimmedUrl)) { dispatch({ type: ActionTypes.LOAD_DOCUMENT_BY_URL, - url: url, + url: trimmedUrl, }); } else { - alert(t('Enter a valid URL (it should start with "http(s)://")')); + alert(t('Enter a valid URL (it should start with "http(s)://" | "data:")')); } }}> { + if (!get.isDocumentLoaded(store.getState())) return; + if ((e.key === 's' || e.code === 'KeyS') && e.ctrlKey) { // code property isn't supported in Edge yet e.preventDefault(); store.dispatch(Actions.tryToSaveDocument()); diff --git a/viewer/src/locales/ChineseSimplified.js b/viewer/src/locales/ChineseSimplified.js index 87be31a..4d0e3c2 100644 --- a/viewer/src/locales/ChineseSimplified.js +++ b/viewer/src/locales/ChineseSimplified.js @@ -46,8 +46,8 @@ export default { "在此处粘贴djvu文件的地址", "Open URL": "打开地址", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - '输入一个有效的地址 (应当以 "http(s)://" 开头)', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + '输入一个有效的地址 (应当以 "http(s)://" | "data:" 开头)', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/English.js b/viewer/src/locales/English.js index 2512f78..0b985ba 100644 --- a/viewer/src/locales/English.js +++ b/viewer/src/locales/English.js @@ -46,8 +46,8 @@ export default { "Paste a URL to a djvu file here", "Open URL": "Open URL", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - 'Enter a valid URL (it should start with "http(s)://")', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + 'Enter a valid URL (it should start with "http(s)://" | "data:")', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/French.js b/viewer/src/locales/French.js index 0463446..fdc2e7f 100644 --- a/viewer/src/locales/French.js +++ b/viewer/src/locales/French.js @@ -46,8 +46,8 @@ export default { "Copier un lien vers un fichier .djvu", "Open URL": "Ouvrir le lien", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - 'Insérer une URL valide (doit commencer par "http(s)://")', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + 'Insérer une URL valide (doit commencer par "http(s)://" | "data:")', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/Italian.js b/viewer/src/locales/Italian.js index 312cab2..1fae21a 100644 --- a/viewer/src/locales/Italian.js +++ b/viewer/src/locales/Italian.js @@ -46,8 +46,8 @@ export default { "Incolla qui l'URL al file DjVu", "Open URL": "Apri URL", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - 'Inserire un URL valido (deve iniziare con "http(s)://")', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + 'Inserire un URL valido (deve iniziare con "http(s)://" | "data:")', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/Portuguese.js b/viewer/src/locales/Portuguese.js index ee254b6..f0df667 100644 --- a/viewer/src/locales/Portuguese.js +++ b/viewer/src/locales/Portuguese.js @@ -46,8 +46,8 @@ export default { "Colar aqui um URL a um ficheiro djvu", "Open URL": "Abrir URL", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - 'Introduza um URL válido (deve começar com "http(s)://")', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + 'Introduza um URL válido (deve começar com "http(s)://" | "data:")', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/Russian.js b/viewer/src/locales/Russian.js index c5c4b91..cc801b7 100644 --- a/viewer/src/locales/Russian.js +++ b/viewer/src/locales/Russian.js @@ -59,8 +59,8 @@ export default { "Вставьте ссылку на .djvu файл", "Open URL": "Открыть ссылку", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - 'Введите корректную ссылку (она должна начинаться с "http(s)://")', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + 'Введите корректную ссылку (она должна начинаться с "http(s)://" | "data:")', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/Spanish.js b/viewer/src/locales/Spanish.js index 45993d6..601e8ee 100644 --- a/viewer/src/locales/Spanish.js +++ b/viewer/src/locales/Spanish.js @@ -46,8 +46,8 @@ export default { "Pegar una URL al archivo djvu aquí", "Open URL": "Abrir URL", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL - 'Introducir una URL válida (debe comenzar con "http(s)://")', + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL + 'Introducir una URL válida (debe comenzar con "http(s)://" | "data:")', // Errors. Usually there is a header and a message for each error type. // For the web request error there are different types of messages depending on the HTTP status. diff --git a/viewer/src/locales/Swedish.js b/viewer/src/locales/Swedish.js index d781c6d..cd6ff83 100644 --- a/viewer/src/locales/Swedish.js +++ b/viewer/src/locales/Swedish.js @@ -46,7 +46,7 @@ export default { "Klistra in en URL till en .djvu-fil här", "Open URL": "Öppna URL", - 'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL + 'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL 'Ange en giltig URL (den ska börja med "http (s): //")', // Errors. Usually there is a header and a message for each error type. diff --git a/viewer/src/sagas/rootSaga.js b/viewer/src/sagas/rootSaga.js index 95dee82..a06eefb 100644 --- a/viewer/src/sagas/rootSaga.js +++ b/viewer/src/sagas/rootSaga.js @@ -414,7 +414,7 @@ class RootSaga { } // responseUrl is the URL after all redirects - config.djvuOptions = { baseUrl: new URL('./', responseURL).href }; + config.djvuOptions = { baseUrl: url.startsWith('data:') ? null : new URL('./', responseURL).href }; yield* this.createDocumentFromArrayBuffer({ arrayBuffer: buffer, fileName: config.name === undefined ? getFileNameFromUrl(url) : config.name,