@internetarchive/bookreader 5.0.0-32-1 → 5.0.0-35
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.css +1 -1
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +28 -28
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReaderDemo/IADemoBr.js +13 -0
- package/BookReaderDemo/demo-internetarchive.html +6 -3
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
- package/CHANGELOG.md +16 -0
- package/package.json +10 -10
- package/src/BookNavigator/book-navigator.js +36 -14
- package/src/BookReader/Toolbar/Toolbar.js +2 -2
- package/src/css/_colorbox.scss +2 -2
- package/src/ia-bookreader/ia-bookreader.js +7 -4
- package/src/plugins/tts/PageChunk.js +4 -1
- package/src/plugins/url/UrlPlugin.js +1 -1
- package/tests/jest/plugins/url/UrlPlugin.test.js +15 -0
- package/tests/karma/BookNavigator/book-navigator.test.js +21 -5
package/src/css/_colorbox.scss
CHANGED
@@ -52,6 +52,10 @@ export class IaBookReader extends LitElement {
|
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
55
|
+
get itemNav() {
|
56
|
+
return this.shadowRoot.querySelector('ia-item-navigator');
|
57
|
+
}
|
58
|
+
|
55
59
|
/** Creates modal DOM & attaches to `<body>` */
|
56
60
|
setModalManager() {
|
57
61
|
let modalManager = document.querySelector('modal-manager');
|
@@ -95,11 +99,10 @@ export class IaBookReader extends LitElement {
|
|
95
99
|
}
|
96
100
|
|
97
101
|
if (action === 'open') {
|
98
|
-
this.itemNav
|
99
|
-
this.openShortcut(menuId);
|
102
|
+
this.itemNav?.openShortcut(menuId);
|
100
103
|
} else if (action === 'toggle') {
|
101
|
-
this.itemNav
|
102
|
-
this.itemNav
|
104
|
+
this.itemNav?.openMenu(menuId);
|
105
|
+
this.itemNav?.toggleMenu();
|
103
106
|
}
|
104
107
|
}
|
105
108
|
|
@@ -97,7 +97,10 @@ export default class PageChunk {
|
|
97
97
|
* @return {string}
|
98
98
|
*/
|
99
99
|
static _removeDanglingHyphens(text) {
|
100
|
-
|
100
|
+
// Some books mis-OCR a dangling hyphen as a ¬ (mathematical not sign) . Since in math
|
101
|
+
// the not sign should not appear followed by a space, we think we can safely assume
|
102
|
+
// this should be replaced.
|
103
|
+
return text.replace(/[-¬]\s+/g, '');
|
101
104
|
}
|
102
105
|
}
|
103
106
|
|
@@ -140,7 +140,7 @@ export class UrlPlugin {
|
|
140
140
|
const concatenatedPath = urlStrPath !== '/' ? urlStrPath : '';
|
141
141
|
if (this.urlMode == 'history') {
|
142
142
|
if (window.history && window.history.replaceState) {
|
143
|
-
const newUrlPath = `${this.urlHistoryBasePath}${concatenatedPath}
|
143
|
+
const newUrlPath = `${this.urlHistoryBasePath}${concatenatedPath}`.trim().replace(/(\/+)/g, '/');
|
144
144
|
window.history.replaceState({}, null, newUrlPath);
|
145
145
|
}
|
146
146
|
} else {
|
@@ -170,6 +170,21 @@ describe('UrlPlugin tests', () => {
|
|
170
170
|
const locationUrl = `${window.location.pathname}${window.location.search}`;
|
171
171
|
expect(locationUrl).toEqual('/details/foo/page/12?q=hello&view=theater');
|
172
172
|
});
|
173
|
+
|
174
|
+
test('strips leading slash of incoming path name for no double slash', () => {
|
175
|
+
const urlPlugin = new UrlPlugin();
|
176
|
+
urlPlugin.urlMode = 'history';
|
177
|
+
|
178
|
+
urlPlugin.urlHistoryBasePath = '/details/SubBookTest/book1/GPORFP/';
|
179
|
+
urlPlugin.urlState = {
|
180
|
+
"mode": "1up",
|
181
|
+
};
|
182
|
+
|
183
|
+
urlPlugin.setUrlParam('sort', 'title_asc');
|
184
|
+
urlPlugin.setUrlParam('mode', 'thumb');
|
185
|
+
|
186
|
+
expect(window.location.href).toEqual('http://localhost/details/SubBookTest/book1/GPORFP/mode/thumb?sort=title_asc');
|
187
|
+
});
|
173
188
|
});
|
174
189
|
|
175
190
|
});
|
@@ -111,11 +111,6 @@ describe('<book-navigator>', () => {
|
|
111
111
|
|
112
112
|
it('creates an item image from metadata', async () => {
|
113
113
|
const el = fixtureSync(container());
|
114
|
-
el.item = {
|
115
|
-
metadata: { identifier: 'foo' },
|
116
|
-
};
|
117
|
-
await elementUpdated(el);
|
118
|
-
|
119
114
|
const itemImage = fixtureSync(el.itemImage);
|
120
115
|
expect(itemImage).to.be.instanceOf(HTMLImageElement);
|
121
116
|
expect(itemImage.getAttribute('class')).to.equal('cover-img');
|
@@ -225,6 +220,18 @@ describe('<book-navigator>', () => {
|
|
225
220
|
|
226
221
|
describe('Controlling Menu Side Panel & Shortcuts', () => {
|
227
222
|
describe('Side Menu Panels', () => {
|
223
|
+
it('`isWideEnoughToOpenMenu` checks if menu should be open', async () => {
|
224
|
+
const el = fixtureSync(container());
|
225
|
+
el.brWidth = 300;
|
226
|
+
await el.elementUpdated;
|
227
|
+
|
228
|
+
expect(el.isWideEnoughToOpenMenu).to.equal(false);
|
229
|
+
|
230
|
+
el.brWidth = 641;
|
231
|
+
await el.elementUpdated;
|
232
|
+
|
233
|
+
expect(el.isWideEnoughToOpenMenu).to.equal(true);
|
234
|
+
});
|
228
235
|
describe('Control which side menu to toggle open by using: `this.updateSideMenu`', () => {
|
229
236
|
it('Emits `@updateSideMenu` to signal which menu gets the update', async () => {
|
230
237
|
const el = fixtureSync(container());
|
@@ -316,6 +323,10 @@ describe('<book-navigator>', () => {
|
|
316
323
|
const el = fixtureSync(container());
|
317
324
|
const brStub = {
|
318
325
|
resize: sinon.fake(),
|
326
|
+
options: {},
|
327
|
+
refs: {
|
328
|
+
$brContainer: document.createElement('div')
|
329
|
+
}
|
319
330
|
};
|
320
331
|
el.bookreader = brStub;
|
321
332
|
await elementUpdated(el);
|
@@ -342,7 +353,12 @@ describe('<book-navigator>', () => {
|
|
342
353
|
const brStub = {
|
343
354
|
animating: false,
|
344
355
|
resize: sinon.fake(),
|
356
|
+
options: {},
|
357
|
+
refs: {
|
358
|
+
$brContainer: document.createElement('div')
|
359
|
+
}
|
345
360
|
};
|
361
|
+
|
346
362
|
el.bookreader = brStub;
|
347
363
|
await elementUpdated(el);
|
348
364
|
expect(el.brWidth).to.equal(0);
|