@internetarchive/bookreader 5.0.0-115 → 5.0.0-117
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/BookReader.css +44 -18
- package/BookReader/BookReader.js +1 -43
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +109 -67
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +2 -2
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.experiments.js +1 -1
- package/BookReader/plugins/plugin.experiments.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +63 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +65 -3
- package/BookReader/plugins/plugin.translate.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/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/README.md +3 -1
- package/jsconfig.json +2 -3
- package/package.json +38 -31
- package/src/BookReader.js +24 -20
- package/src/css/_TextSelection.scss +51 -18
- package/src/plugins/plugin.chapters.js +8 -4
- package/src/plugins/plugin.iframe.js +36 -37
- package/src/plugins/plugin.text_selection.js +40 -101
- package/src/plugins/search/plugin.search.js +4 -8
- package/src/plugins/tts/plugin.tts.js +3 -8
- package/src/plugins/url/UrlPlugin.js +12 -0
- package/src/util/TextSelectionManager.js +221 -154
- package/src/util/dom.js +88 -0
- package/src/util/generators.js +89 -0
package/jsconfig.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es6",
|
|
4
|
-
"moduleResolution": "
|
|
4
|
+
"moduleResolution": "bundler",
|
|
5
5
|
"experimentalDecorators": true,
|
|
6
|
-
"baseUrl": ".",
|
|
7
6
|
"paths": {
|
|
8
7
|
"@/*": ["./*"]
|
|
9
8
|
}
|
|
10
9
|
},
|
|
11
10
|
"include": [
|
|
12
11
|
"src/**/*.js",
|
|
13
|
-
"tests/**/*.js",
|
|
12
|
+
"tests/jest/**/*.js",
|
|
14
13
|
],
|
|
15
14
|
"exclude": [
|
|
16
15
|
"node_modules",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/bookreader",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-117",
|
|
4
4
|
"description": "The Internet Archive BookReader.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -32,22 +32,23 @@
|
|
|
32
32
|
"private": false,
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@internetarchive/bergamot-translator": "^0.4.9-ia.1",
|
|
35
|
-
"@internetarchive/ia-activity-indicator": "1.0.0",
|
|
36
|
-
"@internetarchive/ia-item-navigator": "2.2.3",
|
|
37
|
-
"@internetarchive/icon-bookmark": "1.4.1",
|
|
38
|
-
"@internetarchive/icon-close": "1.4.1",
|
|
39
|
-
"@internetarchive/icon-dl": "1.4.1",
|
|
40
|
-
"@internetarchive/icon-edit-pencil": "1.4.1",
|
|
41
|
-
"@internetarchive/icon-
|
|
42
|
-
"@internetarchive/icon-
|
|
43
|
-
"@internetarchive/icon-magnify-
|
|
44
|
-
"@internetarchive/icon-
|
|
45
|
-
"@internetarchive/icon-
|
|
46
|
-
"@internetarchive/icon-
|
|
47
|
-
"@internetarchive/icon-
|
|
48
|
-
"@internetarchive/
|
|
49
|
-
"@internetarchive/
|
|
50
|
-
"
|
|
35
|
+
"@internetarchive/ia-activity-indicator": "^1.0.0",
|
|
36
|
+
"@internetarchive/ia-item-navigator": "^2.2.3",
|
|
37
|
+
"@internetarchive/icon-bookmark": "^1.4.1",
|
|
38
|
+
"@internetarchive/icon-close": "^1.4.1",
|
|
39
|
+
"@internetarchive/icon-dl": "^1.4.1",
|
|
40
|
+
"@internetarchive/icon-edit-pencil": "^1.4.1",
|
|
41
|
+
"@internetarchive/icon-ellipses": "^1.4.1",
|
|
42
|
+
"@internetarchive/icon-ia-logo": "^1.4.1",
|
|
43
|
+
"@internetarchive/icon-magnify-minus": "^1.4.1",
|
|
44
|
+
"@internetarchive/icon-magnify-plus": "^1.4.1",
|
|
45
|
+
"@internetarchive/icon-search": "^1.4.1",
|
|
46
|
+
"@internetarchive/icon-share": "^1.4.1",
|
|
47
|
+
"@internetarchive/icon-toc": "^1.4.1",
|
|
48
|
+
"@internetarchive/icon-visual-adjustment": "^1.4.1",
|
|
49
|
+
"@internetarchive/modal-manager": "^2.0.6",
|
|
50
|
+
"@internetarchive/shared-resize-observer": "^0.2.0",
|
|
51
|
+
"interactjs": "1.10.18",
|
|
51
52
|
"iso-language-codes": "2.0.0",
|
|
52
53
|
"jquery": "3.6.1",
|
|
53
54
|
"jquery-colorbox": "1.6.4",
|
|
@@ -67,27 +68,29 @@
|
|
|
67
68
|
"@iiif/presentation-3": "2.2.3",
|
|
68
69
|
"@open-wc/testing-helpers": "3.0.1",
|
|
69
70
|
"@types/jest": "30.0.0",
|
|
70
|
-
"@webcomponents/webcomponentsjs": "
|
|
71
|
+
"@webcomponents/webcomponentsjs": "2.6.0",
|
|
71
72
|
"babel-loader": "10.1.1",
|
|
72
73
|
"concurrently": "10.0.3",
|
|
73
74
|
"core-js": "3.49.0",
|
|
74
75
|
"cpx2": "9.0.0",
|
|
76
|
+
"css-loader": "7.1.4",
|
|
75
77
|
"eslint": "7.32.0",
|
|
76
|
-
"eslint-plugin-no-jquery": "
|
|
78
|
+
"eslint-plugin-no-jquery": "2.7.0",
|
|
77
79
|
"eslint-plugin-testcafe": "0.2.1",
|
|
78
80
|
"http-server": "14.1.1",
|
|
79
|
-
"hypothesis": "
|
|
81
|
+
"hypothesis": "1.1627.0",
|
|
80
82
|
"jest": "30.4.2",
|
|
81
83
|
"jest-environment-jsdom": "30.4.1",
|
|
82
84
|
"live-server": "1.2.2",
|
|
83
85
|
"regenerator-runtime": "0.14.1",
|
|
84
|
-
"sass": "1.
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
86
|
+
"sass": "1.101.5",
|
|
87
|
+
"sass-loader": "17.0.0",
|
|
88
|
+
"sinon": "22.1.0",
|
|
89
|
+
"svgo": "4.0.2",
|
|
90
|
+
"testcafe": "3.7.6",
|
|
88
91
|
"testcafe-browser-provider-browserstack": "1.15.2",
|
|
89
|
-
"webpack": "5.
|
|
90
|
-
"webpack-cli": "7.
|
|
92
|
+
"webpack": "5.108.4",
|
|
93
|
+
"webpack-cli": "7.2.1"
|
|
91
94
|
},
|
|
92
95
|
"jest": {
|
|
93
96
|
"testEnvironment": "jsdom",
|
|
@@ -95,7 +98,8 @@
|
|
|
95
98
|
"node_modules/(?!(sinon|lit-html|lit-element|lit|@lit|@lit-labs|@internetarchive|@open-wc)/)"
|
|
96
99
|
],
|
|
97
100
|
"moduleNameMapper": {
|
|
98
|
-
"
|
|
101
|
+
"@/(.*)$": "<rootDir>/$1",
|
|
102
|
+
"\\.scss$": "<rootDir>/tests/jest/styleMock.js"
|
|
99
103
|
},
|
|
100
104
|
"setupFiles": [
|
|
101
105
|
"./src/jquery-wrapper.js",
|
|
@@ -132,14 +136,17 @@
|
|
|
132
136
|
"test:e2e": "npm run build && npx testcafe",
|
|
133
137
|
"test:e2e:dev": "npx testcafe --live --dev",
|
|
134
138
|
"DOCS:update:test-deps": "If CI succeeds, these should be good to update",
|
|
135
|
-
"update:test-deps": "npm i @babel/eslint-parser@latest @open-wc/testing-helpers@latest @types/jest@latest eslint@7 eslint-plugin-testcafe@latest jest@latest jest-environment-jsdom@latest sinon@latest testcafe@latest",
|
|
139
|
+
"update:test-deps": "npm i @babel/eslint-parser@latest @open-wc/testing-helpers@latest @types/jest@latest eslint@7 eslint-plugin-no-jquery@latest eslint-plugin-testcafe@latest jest@latest jest-environment-jsdom@latest sinon@latest testcafe@latest",
|
|
136
140
|
"update:test-deps:test": "npm run lint && npm run test && npm run test:e2e",
|
|
137
141
|
"DOCS:update:build-deps": "These can cause strange changes, so do an npm run build + check file size (git diff --stat), and check the site is as expected",
|
|
138
|
-
"update:build-deps": "npm i @babel/core@latest @babel/preset-env@latest @babel/plugin-proposal-class-properties@latest @babel/plugin-proposal-decorators@latest babel-loader@latest core-js@latest regenerator-runtime@latest sass@latest svgo@latest webpack@latest webpack-cli@latest",
|
|
142
|
+
"update:build-deps": "npm i @babel/core@latest @babel/preset-env@latest @babel/plugin-proposal-class-properties@latest @babel/plugin-proposal-decorators@latest babel-loader@latest core-js@latest css-loader@latest regenerator-runtime@latest sass@latest sass-loader@latest svgo@latest webpack@latest webpack-cli@latest",
|
|
139
143
|
"update:build-deps:test": "npm run build",
|
|
140
144
|
"DOCS:update:dev-deps": "Packages used for development",
|
|
141
|
-
"update:dev-deps": "npm i @iiif/presentation-2@latest @iiif/presentation-3@latest concurrently@latest cpx2@latest http-server@latest live-server@latest",
|
|
145
|
+
"update:dev-deps": "npm i @iiif/presentation-2@latest @iiif/presentation-3@latest concurrently@latest cpx2@latest http-server@latest hypothesis@latest live-server@latest testcafe-browser-provider-browserstack@latest",
|
|
146
|
+
"DOCS:update:runtime-deps": "Core runtime dependencies; do an npm run build + visual check after updating",
|
|
147
|
+
"update:runtime-deps": "npm i @webcomponents/webcomponentsjs@latest interactjs@latest iso-language-codes@latest jquery@latest jquery-colorbox@latest jquery-ui@latest jquery-ui-touch-punch@latest jquery.browser@latest lit@latest soundmanager2@latest",
|
|
148
|
+
"update:runtime-deps:test": "npm run build",
|
|
142
149
|
"DOCS:update:ia-deps": "Packages by @internetarchive",
|
|
143
|
-
"update:ia-deps": "npm i @internetarchive/ia-activity-indicator@latest @internetarchive/ia-item-navigator@latest @internetarchive/icon-bookmark@latest @internetarchive/icon-close@latest @internetarchive/icon-dl@latest @internetarchive/icon-edit-pencil@latest @internetarchive/icon-ia-logo@latest @internetarchive/icon-magnify-minus@latest @internetarchive/icon-magnify-plus@latest @internetarchive/icon-search@latest @internetarchive/icon-share@latest @internetarchive/icon-toc@latest @internetarchive/icon-visual-adjustment@latest @internetarchive/modal-manager@latest @internetarchive/shared-resize-observer@latest"
|
|
150
|
+
"update:ia-deps": "npm i @internetarchive/bergamot-translator@latest @internetarchive/ia-activity-indicator@latest @internetarchive/ia-item-navigator@latest @internetarchive/icon-bookmark@latest @internetarchive/icon-close@latest @internetarchive/icon-dl@latest @internetarchive/icon-edit-pencil@latest @internetarchive/icon-ellipses@latest @internetarchive/icon-ia-logo@latest @internetarchive/icon-magnify-minus@latest @internetarchive/icon-magnify-plus@latest @internetarchive/icon-search@latest @internetarchive/icon-share@latest @internetarchive/icon-toc@latest @internetarchive/icon-visual-adjustment@latest @internetarchive/modal-manager@latest @internetarchive/shared-resize-observer@latest"
|
|
144
151
|
}
|
|
145
152
|
}
|
package/src/BookReader.js
CHANGED
|
@@ -26,6 +26,7 @@ import 'jquery-ui-touch-punch';
|
|
|
26
26
|
|
|
27
27
|
import PACKAGE_JSON from '../package.json';
|
|
28
28
|
import * as utils from './BookReader/utils.js';
|
|
29
|
+
import { singleScrollIntoView } from './util/dom.js';
|
|
29
30
|
import { exposeOverrideable } from './BookReader/utils/classes.js';
|
|
30
31
|
import { Navbar } from './BookReader/Navbar/Navbar.js';
|
|
31
32
|
import { DEFAULT_OPTIONS, OptionsParseError } from './BookReader/options.js';
|
|
@@ -41,7 +42,6 @@ import { ModeThumb } from './BookReader/ModeThumb.js';
|
|
|
41
42
|
import { ImageCache } from './BookReader/ImageCache.js';
|
|
42
43
|
import { PageContainer } from './BookReader/PageContainer.js';
|
|
43
44
|
import { NAMED_REDUCE_SETS } from './BookReader/ReduceSet.js';
|
|
44
|
-
import {BookReaderTextFragment} from './util/TextSelectionManager.js';
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* BookReader
|
|
@@ -112,6 +112,8 @@ BookReader.PLUGINS = {
|
|
|
112
112
|
chapters: null,
|
|
113
113
|
/** @type {typeof import('./plugins/plugin.experiments.js').ExperimentsPlugin | null}*/
|
|
114
114
|
experiments: null,
|
|
115
|
+
/** @type {typeof import('./plugins/plugin.iframe.js').IframePlugin | null}*/
|
|
116
|
+
iframe: null,
|
|
115
117
|
/** @type {typeof import('./plugins/plugin.resume.js').ResumePlugin | null}*/
|
|
116
118
|
resume: null,
|
|
117
119
|
/** @type {typeof import('./plugins/search/plugin.search.js').SearchPlugin | null}*/
|
|
@@ -156,6 +158,7 @@ BookReader.optionOverrides = BookReader.optionOverrides || {};
|
|
|
156
158
|
/**
|
|
157
159
|
* Setup
|
|
158
160
|
* It is separate from the constructor, so plugins can extend.
|
|
161
|
+
* @constructor
|
|
159
162
|
* @param {BookReaderOptions} options
|
|
160
163
|
*/
|
|
161
164
|
BookReader.prototype.setup = function(options) {
|
|
@@ -181,6 +184,7 @@ BookReader.prototype.setup = function(options) {
|
|
|
181
184
|
autoplay: BookReader.PLUGINS.autoplay ? new BookReader.PLUGINS.autoplay(this) : null,
|
|
182
185
|
chapters: BookReader.PLUGINS.chapters ? new BookReader.PLUGINS.chapters(this) : null,
|
|
183
186
|
experiments: BookReader.PLUGINS.experiments ? new BookReader.PLUGINS.experiments(this) : null,
|
|
187
|
+
iframe: BookReader.PLUGINS.iframe ? new BookReader.PLUGINS.iframe(this) : null,
|
|
184
188
|
search: BookReader.PLUGINS.search ? new BookReader.PLUGINS.search(this) : null,
|
|
185
189
|
resume: BookReader.PLUGINS.resume ? new BookReader.PLUGINS.resume(this) : null,
|
|
186
190
|
textSelection: BookReader.PLUGINS.textSelection ? new BookReader.PLUGINS.textSelection(this) : null,
|
|
@@ -645,6 +649,7 @@ BookReader.prototype.init = function() {
|
|
|
645
649
|
this.pageScale = this.reduce; // preserve current reduce
|
|
646
650
|
|
|
647
651
|
const params = this.initParams();
|
|
652
|
+
this.urlPlugin?.pullFromAddressBar();
|
|
648
653
|
this.firstIndex = params.index ? params.index : 0;
|
|
649
654
|
|
|
650
655
|
// Setup Navbars and other UI
|
|
@@ -1030,6 +1035,18 @@ BookReader.prototype.resizeBRcontainer = function(animate) {
|
|
|
1030
1035
|
}
|
|
1031
1036
|
};
|
|
1032
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* Scrolls the given element into view within the active mode's scroll container.
|
|
1040
|
+
* @param {Element} el
|
|
1041
|
+
* @param {object} [options]
|
|
1042
|
+
* @param {'auto' | 'smooth'} [options.behavior]
|
|
1043
|
+
* @param {'start' | 'center' | 'end' | 'nearest'} [options.block]
|
|
1044
|
+
* @param {'start' | 'center' | 'end' | 'nearest'} [options.inline]
|
|
1045
|
+
*/
|
|
1046
|
+
BookReader.prototype.scrollIntoView = function(el, options) {
|
|
1047
|
+
singleScrollIntoView(el, { ...options, scrollContainer: this.activeMode.scrollContainer });
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1033
1050
|
BookReader.prototype.centerPageView = function() {
|
|
1034
1051
|
const scrollWidth = this.refs.$brContainer.prop('scrollWidth');
|
|
1035
1052
|
const clientWidth = this.refs.$brContainer.prop('clientWidth');
|
|
@@ -1960,6 +1977,10 @@ BookReader.prototype.queryStringFromParams = function(
|
|
|
1960
1977
|
) {
|
|
1961
1978
|
const newParams = new URLSearchParams(currQueryString);
|
|
1962
1979
|
|
|
1980
|
+
// Never write back UI-only params that are consumed on load
|
|
1981
|
+
// TODO: Should ideally stick around until next URL change
|
|
1982
|
+
newParams.delete('focus');
|
|
1983
|
+
|
|
1963
1984
|
if (params.view) {
|
|
1964
1985
|
// Set ?view=theater when fullscreen
|
|
1965
1986
|
newParams.set('view', params.view);
|
|
@@ -1972,25 +1993,8 @@ BookReader.prototype.queryStringFromParams = function(
|
|
|
1972
1993
|
newParams.set('q', params.search);
|
|
1973
1994
|
}
|
|
1974
1995
|
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
// Need to pull out text separately to avoid the spaces becoming encoded as +, which
|
|
1978
|
-
// the browser seems not to handle with the text fragment
|
|
1979
|
-
if (newParams.get('text')) {
|
|
1980
|
-
newParams.delete('text');
|
|
1981
|
-
textFragmentParam = BookReaderTextFragment.fromUrl(currQueryString, this.book, this.firstIndex);
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/toString
|
|
1985
|
-
// Note: This method returns the query string without the question mark.
|
|
1986
|
-
let result = newParams.toString();
|
|
1987
|
-
if (textFragmentParam) {
|
|
1988
|
-
if (result) result += '&';
|
|
1989
|
-
result += `text=${textFragmentParam.toUrlString()}`;
|
|
1990
|
-
}
|
|
1991
|
-
if (result) result = '?' + result;
|
|
1992
|
-
|
|
1993
|
-
return result;
|
|
1996
|
+
const result = newParams.toString();
|
|
1997
|
+
return result ? `?${result}` : '';
|
|
1994
1998
|
};
|
|
1995
1999
|
|
|
1996
2000
|
/**
|
|
@@ -145,16 +145,29 @@
|
|
|
145
145
|
display: none;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
|
|
149
|
+
$select-menu-radius: 25px;
|
|
150
|
+
$select-menu-extended-radius: 10px;
|
|
148
151
|
.br-select-menu__root {
|
|
149
152
|
display: none;
|
|
150
|
-
border-radius: 20px;
|
|
151
|
-
background-color: #333;
|
|
152
153
|
color: white;
|
|
153
154
|
color-scheme: dark;
|
|
154
155
|
padding: 2px;
|
|
155
156
|
overflow: hidden;
|
|
156
157
|
opacity: 1;
|
|
157
|
-
transition:
|
|
158
|
+
transition: opacity 0.2s;
|
|
159
|
+
gap: 5px;
|
|
160
|
+
|
|
161
|
+
&[open] {
|
|
162
|
+
display: flex;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&[showextended] {
|
|
166
|
+
display: block;
|
|
167
|
+
gap: 0px;
|
|
168
|
+
background-color: #333;
|
|
169
|
+
border-radius: $select-menu-extended-radius;
|
|
170
|
+
}
|
|
158
171
|
|
|
159
172
|
@starting-style {
|
|
160
173
|
opacity: 0;
|
|
@@ -164,13 +177,6 @@
|
|
|
164
177
|
opacity: 0;
|
|
165
178
|
pointer-events: none;
|
|
166
179
|
}
|
|
167
|
-
.br-select-menu__root:hover {
|
|
168
|
-
border-radius: 8px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.br-select-menu__root:hover .br-select-menu__option {
|
|
172
|
-
border-radius: 6px;
|
|
173
|
-
}
|
|
174
180
|
|
|
175
181
|
.br-select-menu__option {
|
|
176
182
|
--iconWidth: 15px;
|
|
@@ -179,18 +185,40 @@
|
|
|
179
185
|
background: transparent;
|
|
180
186
|
display: flex;
|
|
181
187
|
align-items: center;
|
|
182
|
-
border-radius:
|
|
188
|
+
border-radius: $select-menu-radius;
|
|
183
189
|
font-family: inherit;
|
|
184
190
|
color: inherit;
|
|
185
191
|
border: 0;
|
|
186
|
-
transition: background-color 0.2s, border-radius 0.2s;
|
|
187
192
|
cursor: pointer;
|
|
188
193
|
text-wrap: nowrap;
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
background-color: #333;
|
|
195
|
+
position: relative;
|
|
191
196
|
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
@media (pointer: coarse) and (hover: none) {
|
|
198
|
+
padding: 4px 8px;
|
|
199
|
+
#br-select-more & {
|
|
200
|
+
padding: 4px;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&:hover:after {
|
|
205
|
+
position: absolute;
|
|
206
|
+
left: 2px;
|
|
207
|
+
right: 2px;
|
|
208
|
+
top: 2px;
|
|
209
|
+
bottom: 2px;
|
|
210
|
+
content: "";
|
|
211
|
+
pointer-events: none;
|
|
212
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
213
|
+
border-radius: calc($select-menu-radius - 2px);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.br-select-menu__root[showextended] & {
|
|
217
|
+
width:100%;
|
|
218
|
+
&:hover:after {
|
|
219
|
+
border-radius: calc($select-menu-extended-radius - 2px);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
194
222
|
}
|
|
195
223
|
|
|
196
224
|
.br-select-menu__icon {
|
|
@@ -198,24 +226,29 @@
|
|
|
198
226
|
flex-shrink: 0;
|
|
199
227
|
width: 17px;
|
|
200
228
|
height: 17px;
|
|
229
|
+
padding: 2px;
|
|
201
230
|
}
|
|
202
231
|
|
|
203
232
|
.br-select-menu__label {
|
|
204
233
|
margin-left: 4px;
|
|
205
234
|
font-size: 12px;
|
|
235
|
+
margin-right: 4px;
|
|
206
236
|
}
|
|
207
237
|
|
|
208
238
|
@media (hover: hover) {
|
|
239
|
+
.br-select-menu__option {
|
|
240
|
+
padding: 4px;
|
|
241
|
+
}
|
|
209
242
|
.br-select-menu__label {
|
|
210
243
|
width: 0px;
|
|
211
|
-
margin
|
|
244
|
+
margin: 0;
|
|
212
245
|
opacity: 0;
|
|
213
246
|
interpolate-size: allow-keywords;
|
|
214
247
|
transition: width 0.2s;
|
|
215
248
|
}
|
|
216
249
|
.br-select-menu__root:hover .br-select-menu__label {
|
|
217
250
|
width: auto;
|
|
218
|
-
margin
|
|
251
|
+
margin: 0 4px;
|
|
219
252
|
opacity: 1;
|
|
220
253
|
}
|
|
221
254
|
}
|
|
@@ -7,6 +7,7 @@ import '@internetarchive/icon-toc/icon-toc.js';
|
|
|
7
7
|
import { BookReaderPlugin } from "../BookReaderPlugin.js";
|
|
8
8
|
import { applyVariables } from "../util/strings.js";
|
|
9
9
|
import { promisifyEvent } from "../BookReader/utils.js";
|
|
10
|
+
import { singleScrollIntoView } from "../util/dom.js";
|
|
10
11
|
/** @typedef {import('@/src/BookReader/BookModel.js').PageIndex} PageIndex */
|
|
11
12
|
/** @typedef {import('@/src/BookReader/BookModel.js').PageString} PageString */
|
|
12
13
|
/** @typedef {import('@/src/BookReader/BookModel.js').LeafNum} LeafNum */
|
|
@@ -323,10 +324,13 @@ export class BRChaptersPanel extends LitElement {
|
|
|
323
324
|
|
|
324
325
|
updated(changedProperties) {
|
|
325
326
|
if (changedProperties.has('currentChapter')) {
|
|
326
|
-
this.shadowRoot.querySelector('li.current')
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
const currentEl = this.shadowRoot.querySelector('li.current');
|
|
328
|
+
if (currentEl) {
|
|
329
|
+
singleScrollIntoView(currentEl, {
|
|
330
|
+
block: 'nearest',
|
|
331
|
+
behavior: 'smooth',
|
|
332
|
+
});
|
|
333
|
+
}
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
336
|
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* parent web page
|
|
5
|
-
*/
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { EVENTS } from '../BookReader/events.js';
|
|
3
|
+
import { BookReaderPlugin } from '../BookReaderPlugin.js';
|
|
6
4
|
|
|
7
5
|
const MESSAGE_TYPE_FRAGMENT_CHANGE = 'bookReaderFragmentChange';
|
|
8
6
|
|
|
9
|
-
BookReader.prototype.init = (function (super_) {
|
|
10
|
-
return function () {
|
|
11
|
-
super_.call(this);
|
|
12
|
-
_attachEventListeners(this);
|
|
13
|
-
};
|
|
14
|
-
})(BookReader.prototype.init);
|
|
15
|
-
|
|
16
7
|
/**
|
|
17
|
-
*
|
|
18
|
-
* Using window.postMessage() and event listeners, the
|
|
19
|
-
* parent window when pages change, and the parent
|
|
20
|
-
* explicitly request a page change by sending its own
|
|
21
|
-
*
|
|
22
|
-
* @param {BookReader} br
|
|
23
|
-
* @param {Window?} [parent]
|
|
8
|
+
* Plugin for two-way communication between a BookReader in an IFrame and the
|
|
9
|
+
* parent web page. Using window.postMessage() and event listeners, the
|
|
10
|
+
* plugin notifies the parent window when pages change, and the parent
|
|
11
|
+
* window can also explicitly request a page change by sending its own
|
|
12
|
+
* message.
|
|
24
13
|
*/
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return;
|
|
14
|
+
export class IframePlugin extends BookReaderPlugin {
|
|
15
|
+
options = {
|
|
16
|
+
enabled: true,
|
|
29
17
|
}
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
parent
|
|
35
|
-
{ type: MESSAGE_TYPE_FRAGMENT_CHANGE, fragment },
|
|
36
|
-
'*',
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
window.addEventListener('message', event => {
|
|
41
|
-
// Not a recognized message type, abort
|
|
42
|
-
if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
|
|
19
|
+
/** @override */
|
|
20
|
+
init() {
|
|
21
|
+
// Not enabled, or not embedded, abort
|
|
22
|
+
if (!this.options.enabled || !window.parent) {
|
|
43
23
|
return;
|
|
44
24
|
}
|
|
45
25
|
|
|
46
|
-
br.
|
|
47
|
-
|
|
26
|
+
this.br.bind(EVENTS.fragmentChange, () => {
|
|
27
|
+
const fragment = this.br.fragmentFromParams(this.br.paramsFromCurrent());
|
|
28
|
+
|
|
29
|
+
window.parent.postMessage(
|
|
30
|
+
{ type: MESSAGE_TYPE_FRAGMENT_CHANGE, fragment },
|
|
31
|
+
'*',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
window.addEventListener('message', event => {
|
|
36
|
+
// Not a recognized message type, abort
|
|
37
|
+
if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.br.updateFromParams(this.br.paramsFromFragment(event.data.fragment));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
48
44
|
}
|
|
45
|
+
|
|
46
|
+
const BookReader = /** @type {typeof import('../BookReader').default} */(window.BookReader);
|
|
47
|
+
BookReader?.registerPlugin('iframe', IframePlugin);
|