@internetarchive/bookreader 5.0.0-61 → 5.0.0-63
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 +63 -14
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +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 +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReaderDemo/BookReaderDemo.css +2 -0
- package/BookReaderDemo/demo-internetarchive.html +91 -0
- package/CHANGELOG.md +9 -0
- package/package.json +6 -6
- package/src/BookReader/BookModel.js +2 -2
- package/src/BookReader/Mode2UpLit.js +3 -4
- package/src/BookReader/ModeThumb.js +1 -1
- package/src/BookReader/PageContainer.js +12 -0
- package/src/BookReader/events.js +0 -2
- package/src/BookReader/utils/SelectionObserver.js +43 -0
- package/src/BookReader.js +0 -264
- package/src/css/_BRpages.scss +2 -0
- package/src/css/_TextSelection.scss +84 -23
- package/src/plugins/plugin.text_selection.js +437 -112
- package/src/plugins/search/view.js +0 -9
- package/tests/jest/BookReader/BookModel.test.js +15 -0
- package/tests/jest/BookReader/utils/SelectionObserver.test.js +43 -0
- package/tests/jest/plugins/plugin.text_selection.test.js +166 -44
- package/src/BookReader/utils/SelectionStartedObserver.js +0 -46
- package/tests/jest/BookReader/utils/SelectionStartedObserver.test.js +0 -73
|
@@ -1,41 +1,70 @@
|
|
|
1
|
-
.
|
|
1
|
+
.BRtextLayer {
|
|
2
2
|
z-index: 2;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
position: absolute;
|
|
4
|
+
top: 0;
|
|
5
|
+
left: 0;
|
|
6
|
+
color: transparent;
|
|
7
|
+
transform-origin: 0 0;
|
|
8
|
+
// Make it so right-clicking on "blank" part of text layer sends events to the image (for saving)
|
|
5
9
|
pointer-events: none;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
cursor: text;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.BRparagraphElement {
|
|
14
|
+
margin: 0;
|
|
15
|
+
cursor: text;
|
|
16
|
+
font-family: Georgia, serif;
|
|
17
|
+
line-height: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.BRlineElement {
|
|
21
|
+
pointer-events: all;
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
display: inline-block;
|
|
24
|
+
|
|
25
|
+
// We use display: inline-block, otherwise this causes every line
|
|
26
|
+
// to have newlines at the end in safari. BUT, since they're inline,
|
|
27
|
+
// if the OCR has to short line in the same paragraph, they can wrap
|
|
28
|
+
// and one can go onto the other. This adds an arbitrary margin to
|
|
29
|
+
// the right of each line, forcing things to wrap.
|
|
30
|
+
// See eg https://www-drini.archive.org/details/countofmontecris00duma_7/page/261/mode/2up
|
|
31
|
+
// Page 261, second last line on the page.
|
|
32
|
+
.BRtextLayer[dir=ltr] & { margin-right: 100%; }
|
|
33
|
+
.BRtextLayer[dir=rtl] & { margin-left: 100%; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Highlight colors for text selection layer
|
|
37
|
+
.BRwordElement, .BRspace, .BRparagraphElement, .BRparagraphElement br {
|
|
38
|
+
// these 2 properties do not work if joined
|
|
39
|
+
&::selection {
|
|
14
40
|
background: hsla(210, 74%, 62%, 0.4);
|
|
15
41
|
}
|
|
16
|
-
|
|
42
|
+
|
|
43
|
+
&::-moz-selection {
|
|
17
44
|
background: hsla(210, 74%, 62%, 0.4);
|
|
18
|
-
color:
|
|
45
|
+
color:transparent;
|
|
19
46
|
}
|
|
47
|
+
}
|
|
20
48
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
.BRparagraphElement br {
|
|
50
|
+
visibility: hidden;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Use CSS pseudo-elements to render the hyphens. This makes them
|
|
54
|
+
// not selectable, so copy/pasting text doesn't include them.
|
|
55
|
+
.BRwordElement--hyphen::after {
|
|
56
|
+
content: "-";
|
|
27
57
|
}
|
|
28
58
|
|
|
29
59
|
// Hide text layer for performance during zooming & scrolling
|
|
30
60
|
.BRsmooth-zooming, .BRscrolling-active {
|
|
31
|
-
.
|
|
61
|
+
.BRpagecontainer:not(.BRpagecontainer--hasSelection) .BRtextLayer {
|
|
32
62
|
display: none;
|
|
33
63
|
}
|
|
34
64
|
}
|
|
35
65
|
|
|
36
|
-
// Hide text selection layers of off-screen pages
|
|
37
|
-
|
|
38
|
-
.BRmode1up .BRpagecontainer:not(.BRpage-visible) .textSelectionSVG {
|
|
66
|
+
// Hide text selection layers of off-screen pages
|
|
67
|
+
.BRmode1up .BRpagecontainer:not(.BRpage-visible) .BRtextLayer {
|
|
39
68
|
display: none;
|
|
40
69
|
}
|
|
41
70
|
|
|
@@ -45,3 +74,35 @@
|
|
|
45
74
|
-moz-user-select: none;
|
|
46
75
|
user-select: none;
|
|
47
76
|
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// These are Microsoft Edge specific fixed to make some of the
|
|
80
|
+
// browsers features work well. These are for the in-place
|
|
81
|
+
// translation.
|
|
82
|
+
.BRwordElement, .BRspace {
|
|
83
|
+
&[_istranslated="1"], &[_msttexthash] {
|
|
84
|
+
background-color: #e4dccd;
|
|
85
|
+
color: black;
|
|
86
|
+
letter-spacing: unset !important;
|
|
87
|
+
background: #ccbfa7;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.BRlineElement font[_mstmutation="1"] {
|
|
92
|
+
background: #ccbfa7;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.BRlineElement:has([_istranslated="1"], [_msttexthash]) {
|
|
96
|
+
background-color: #e4dccd;
|
|
97
|
+
color: black;
|
|
98
|
+
text-align: justify;
|
|
99
|
+
width: inherit;
|
|
100
|
+
&:not(:nth-last-child(2)) {
|
|
101
|
+
text-align-last: justify;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.BRlineElement[_msttexthash] {
|
|
106
|
+
background: #ccbfa7;
|
|
107
|
+
word-spacing: unset !important;
|
|
108
|
+
}
|