From 586c227f224ba1f2e25b2bfc24d9d0ed54b9f24b Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Wed, 2 Jun 2021 23:21:30 +0000 Subject: [PATCH 1/2] Add jsonp support to textsel fetches --- src/css/_TextSelection.scss | 2 ++ src/plugins/plugin.text_selection.js | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/css/_TextSelection.scss b/src/css/_TextSelection.scss index e670b3409..af26189b0 100644 --- a/src/css/_TextSelection.scss +++ b/src/css/_TextSelection.scss @@ -1,4 +1,6 @@ .textSelectionSVG { + z-index: 2; + // Make it so right-clicking on "blank" part of svg sends events to the image (for saving) pointer-events: none; .BRwordElement { pointer-events: all; } diff --git a/src/plugins/plugin.text_selection.js b/src/plugins/plugin.text_selection.js index f3c1bb446..714e45df4 100644 --- a/src/plugins/plugin.text_selection.js +++ b/src/plugins/plugin.text_selection.js @@ -13,6 +13,8 @@ export const DEFAULT_OPTIONS = { fullDjvuXmlUrl: null, /** @type {StringWithVars} The URL to fetch a single page of the DJVU xml. Supports options.vars. Also has {{pageIndex}} */ singlePageDjvuXmlUrl: null, + /** Whether to fetch the XML as a jsonp */ + jsonp: false, }; /** @typedef {typeof DEFAULT_OPTIONS} TextSelectionPluginOptions */ @@ -74,7 +76,8 @@ export class TextSelectionPlugin { this.djvuPagesPromise = $.ajax({ type: "GET", url: applyVariables(this.options.fullDjvuXmlUrl, this.optionVariables), - dataType: "html", + dataType: this.options.jsonp ? "jsonp" : "html", + cache: true, error: (e) => undefined }).then((res) => { try { @@ -99,7 +102,8 @@ export class TextSelectionPlugin { const res = await $.ajax({ type: "GET", url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }), - dataType: "html", + dataType: this.options.jsonp ? "jsonp" : "html", + cache: true, error: (e) => undefined, }); try { From 0dfd0f694492b3316c062f5c81c764a10579846d Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Fri, 20 Jan 2023 11:05:00 -0500 Subject: [PATCH 2/2] Add netlify.toml to enable CORS from review apps --- netlify.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 netlify.toml diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 000000000..0291edc5e --- /dev/null +++ b/netlify.toml @@ -0,0 +1,5 @@ +[[headers]] + # Define which paths this specific [[headers]] block will cover. + for = "/BookReader/*" + [headers.values] + Access-Control-Allow-Origin = "*"