@internetarchive/bookreader 5.0.0-120 → 5.0.0-121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/ia-bookreader.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +1 -1
- package/BookReader/plugins/plugin.translate.js.map +1 -1
- package/dist/esm/ia-bookreader.js +1 -1
- package/dist/esm/plugins/plugin.text_selection.js +1 -1
- package/dist/esm/plugins/plugin.text_selection.js.map +1 -1
- package/dist/esm/plugins/plugin.translate.js +1 -1
- package/dist/esm/plugins/plugin.translate.js.map +1 -1
- package/package.json +1 -1
- package/src/plugins/plugin.text_selection.js +1 -1
- package/src/util/TextSelectionManager.js +15 -8
package/package.json
CHANGED
|
@@ -97,7 +97,7 @@ export class TextSelectionPlugin extends BookReaderPlugin {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
async initTextFragment() {
|
|
100
|
-
if (this.br.options.verifyTextFragment && !await this.br.options.verifyTextFragment(this.br.targetTextFragment)) {
|
|
100
|
+
if (this.br.options.verifyTextFragment && !await this.br.options.verifyTextFragment.call(this, this.br.targetTextFragment)) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -1277,18 +1277,25 @@ export class BookReaderTextFragment {
|
|
|
1277
1277
|
}
|
|
1278
1278
|
|
|
1279
1279
|
/**
|
|
1280
|
-
* Generates a URL pointing to the page with the text fragment highlighted.
|
|
1281
|
-
* parameters in the url.
|
|
1280
|
+
* Generates a URL pointing to the page with the text fragment highlighted.
|
|
1282
1281
|
*/
|
|
1283
1282
|
toUrl() {
|
|
1284
|
-
|
|
1285
|
-
params
|
|
1283
|
+
// Strip all other parameters
|
|
1284
|
+
const params = new URLSearchParams({
|
|
1285
|
+
text: this.toNormalizedString(),
|
|
1286
|
+
});
|
|
1286
1287
|
|
|
1287
1288
|
const currentUrl = window.location;
|
|
1288
|
-
const pageNum = this.pageNumber || `n${this.pageIndex}
|
|
1289
|
-
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1289
|
+
const pageNum = encodeURIComponent(this.pageNumber || `n${this.pageIndex}`);
|
|
1290
|
+
// In urlMode 'hash' the BookReader state lives in the hash (e.g. #page/4/mode/2up)
|
|
1291
|
+
const isHashMode = /^#\/?page\//.test(currentUrl.hash);
|
|
1292
|
+
if (isHashMode) {
|
|
1293
|
+
return `${currentUrl.origin}${currentUrl.pathname}?${params}#page/${pageNum}`;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
// urlMode 'history': only keep /page/X in the path, adding it if missing
|
|
1297
|
+
const basePath = currentUrl.pathname.replace(/\/page\/.*/, '').replace(/\/+$/, '');
|
|
1298
|
+
return `${currentUrl.origin}${basePath}/page/${pageNum}?${params}`;
|
|
1292
1299
|
}
|
|
1293
1300
|
|
|
1294
1301
|
/**
|