From 04426209680b1812624b0b6d311463414f4cf636 Mon Sep 17 00:00:00 2001 From: Manikya Rathore Date: Wed, 17 Dec 2025 21:51:01 +0530 Subject: [PATCH 1/2] Fixed Issue #1305 --- src/BookReader/Mode2UpLit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BookReader/Mode2UpLit.js b/src/BookReader/Mode2UpLit.js index cd5d8e8dd..955de0933 100644 --- a/src/BookReader/Mode2UpLit.js +++ b/src/BookReader/Mode2UpLit.js @@ -784,4 +784,4 @@ export class LeafEdges extends LitElement { mouseEventToPageIndex(e) { return Math.floor(this.leftIndex + (e.offsetX / this.offsetWidth) * (this.rightIndex - this.leftIndex + 1)); } -} +} \ No newline at end of file From aac7a96440b6f04f0733be964c5d475c273d30f5 Mon Sep 17 00:00:00 2001 From: Manikya Rathore Date: Mon, 2 Feb 2026 20:54:54 +0530 Subject: [PATCH 2/2] Fix plugin initialization order when reduceSet is invalid --- src/BookReader.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/BookReader.js b/src/BookReader.js index a307d3eba..a3c22be86 100644 --- a/src/BookReader.js +++ b/src/BookReader.js @@ -174,6 +174,17 @@ BookReader.prototype.setup = function(options) { /** @deprecated */ this.bookPath = options.bookPath; + if (options.reduceSet && !NAMED_REDUCE_SETS[options.reduceSet]) { + console.warn( + `Invalid reduceSet "${options.reduceSet}". Falling back to default.` + ); + } + this.reduceSet =NAMED_REDUCE_SETS[options.reduceSet] || NAMED_REDUCE_SETS[DEFAULT_OPTIONS.reduceSet]; + this.pageProgression = options.pageProgression; + this.protected = options.protected; + this.data = options.data; + this.book = new BookModel(this); + // Construct the usual plugins first to get type hints this.plugins = { archiveAnalytics: BookReader.PLUGINS.archiveAnalytics ? new BookReader.PLUGINS.archiveAnalytics(this) : null, @@ -247,12 +258,6 @@ BookReader.prototype.setup = function(options) { this.defaults = options.defaults; this.padding = options.padding; - this.reduceSet = NAMED_REDUCE_SETS[options.reduceSet]; - if (!this.reduceSet) { - console.warn(`Invalid reduceSet ${options.reduceSet}. Ignoring.`); - this.reduceSet = NAMED_REDUCE_SETS[DEFAULT_OPTIONS.reduceSet]; - } - /** @type {number} * can be 1 or 2 or 3 based on the display mode const value */ @@ -305,19 +310,10 @@ BookReader.prototype.setup = function(options) { this.enableExperimentalControls = options.enableExperimentalControls; this.el = options.el; - this.pageProgression = options.pageProgression; - this.protected = options.protected; this.getEmbedCode = options.getEmbedCode; this.popup = null; - // Assign the data methods - this.data = options.data; - /** @type {{[name: string]: JQuery}} */ - this.refs = {}; - - /** The book being displayed in BookReader*/ - this.book = new BookModel(this); if (options.getNumLeafs) this.book.getNumLeafs = options.getNumLeafs.bind(this); if (options.getPageWidth) this.book.getPageWidth = options.getPageWidth.bind(this); @@ -329,6 +325,11 @@ BookReader.prototype.setup = function(options) { if (options.getSpreadIndices) this.book.getSpreadIndices = options.getSpreadIndices.bind(this); if (options.leafNumToIndex) this.book.leafNumToIndex = options.leafNumToIndex.bind(this); + + /** @type {{[name: string]: JQuery}} */ + this.refs = {}; + + /** * @private Components are 'subchunks' of bookreader functionality, usually UI related * They should be relatively decoupled from each other/bookreader.