Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/BookReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ BookReader.PLUGINS = {
textSelection: null,
/** @type {typeof import('./plugins/tts/plugin.tts.js').TtsPlugin | null}*/
tts: null,
/** @type {typeof import('./plugins/url/plugin.url.js').UrlPlugin | null}*/
url: null,
};

/**
Expand Down Expand Up @@ -142,6 +144,7 @@ BookReader.prototype.setup = function(options) {
resume: BookReader.PLUGINS.resume ? new BookReader.PLUGINS.resume(this) : null,
textSelection: BookReader.PLUGINS.textSelection ? new BookReader.PLUGINS.textSelection(this) : null,
tts: BookReader.PLUGINS.tts ? new BookReader.PLUGINS.tts(this) : null,
url: BookReader.PLUGINS.url ? new BookReader.PLUGINS.url(this) : null,
};

// Delete anything that's null
Expand Down Expand Up @@ -440,14 +443,14 @@ BookReader.prototype.initParams = function() {
}

// Check for URL plugin
if (this.options.enableUrlPlugin) {
if (this._plugins.url?.options.enabled) {
// Params explicitly set in URL take precedence over all other methods
let urlParams = this.paramsFromFragment(this.urlReadFragment());
let urlParams = this.paramsFromFragment(this._plugins.url.urlReadFragment());

// Get params if hash fragment available with 'history' urlMode
const hasHashURL = !Object.keys(urlParams).length && this.urlReadHashFragment();
if (hasHashURL && (this.options.urlMode === 'history')) {
urlParams = this.paramsFromFragment(this.urlReadHashFragment());
const hasHashURL = !Object.keys(urlParams).length && this._plugins.url.urlReadHashFragment();
if (hasHashURL && (this._plugins.url?.options.urlMode === 'history')) {
urlParams = this.paramsFromFragment(this._plugins.url.urlReadHashFragment());
}

// If there were any parameters
Expand Down
2 changes: 2 additions & 0 deletions src/BookReader/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export const DEFAULT_OPTIONS = {
textSelection: null,
/** @type {Partial<import('../plugins/tts/plugin.tts.js').TtsPlugin['options']>} */
tts: null,
/** @type {Partial<import('../plugins/url/plugin.url.js').UrlPlugin['options']>} */
url: null,
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/url/UrlPlugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class UrlPlugin {
export class UrlPluginV2 {
constructor(options = {}) {
this.bookReaderOptions = options;

Expand Down
Loading
Loading