bloom-player 2.10.2 → 2.10.3
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A library for displaying Bloom books in iframes or WebViews",
|
|
4
4
|
"author": "SIL Global",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.10.
|
|
6
|
+
"version": "2.10.3",
|
|
7
7
|
"private": false,
|
|
8
8
|
"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working": "",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -97,7 +97,8 @@ export function prepareActivity(
|
|
|
97
97
|
adjustDraggablesForLanguage(page);
|
|
98
98
|
currentChangePageAction = changePageAction;
|
|
99
99
|
doShowAnswersInTargets(
|
|
100
|
-
page.getAttribute("data-show-answers-in-targets") === "true"
|
|
100
|
+
page.getAttribute("data-show-answers-in-targets") === "true" ||
|
|
101
|
+
page.getAttribute("data-show-target-as-shadow") === "true",
|
|
101
102
|
page,
|
|
102
103
|
);
|
|
103
104
|
// not sure we need this in BP, but definitely for when Bloom desktop goes to another tab.
|
|
@@ -1106,7 +1107,10 @@ function checkRandomSentences(page: HTMLElement) {
|
|
|
1106
1107
|
}
|
|
1107
1108
|
|
|
1108
1109
|
export const doShowAnswersInTargets = (showNow: boolean, page: HTMLElement) => {
|
|
1109
|
-
|
|
1110
|
+
// Restrict the search to the current page, so that we don't accidentally find a target on another page.
|
|
1111
|
+
// This is important because the targetId is not necessarily unique across pages if users use the default
|
|
1112
|
+
// draggables that come with the page.
|
|
1113
|
+
const draggables = page.querySelectorAll(":scope [data-draggable-id]");
|
|
1110
1114
|
if (showNow) {
|
|
1111
1115
|
draggables.forEach((draggable) => {
|
|
1112
1116
|
copyContentToTarget(draggable as HTMLElement);
|
|
@@ -1178,6 +1182,14 @@ export function copyContentToTarget(draggable: HTMLElement) {
|
|
|
1178
1182
|
// same cropping.
|
|
1179
1183
|
imageContainer.style.width = draggable.style.width;
|
|
1180
1184
|
imageContainer.style.height = draggable.style.height;
|
|
1185
|
+
// The swiper lazy loading code converts the data-background attribute to the style
|
|
1186
|
+
// attribute's backgroundImage property for the draggable element. If this hasn't
|
|
1187
|
+
// happened yet, we need to adjust the target to match what the draggable will become.
|
|
1188
|
+
const background = imageContainer.getAttribute("data-background");
|
|
1189
|
+
if (background && !imageContainer.style.backgroundImage) {
|
|
1190
|
+
imageContainer.style.backgroundImage = background;
|
|
1191
|
+
imageContainer.removeAttribute("data-background");
|
|
1192
|
+
}
|
|
1181
1193
|
}
|
|
1182
1194
|
if (target.innerHTML !== throwAway.innerHTML) {
|
|
1183
1195
|
target.innerHTML = throwAway.innerHTML;
|
|
@@ -1189,9 +1201,12 @@ export const getTarget = (draggable: HTMLElement): HTMLElement | undefined => {
|
|
|
1189
1201
|
if (!targetId) {
|
|
1190
1202
|
return undefined;
|
|
1191
1203
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1204
|
+
// Restrict the search to the current page, so that we don't accidentally find a target on another page.
|
|
1205
|
+
// This is important because the targetId is not necessarily unique across pages if users use the default
|
|
1206
|
+
// draggables that come with the page.
|
|
1207
|
+
return draggable
|
|
1208
|
+
.closest(".bloom-page")
|
|
1209
|
+
.querySelector(`[data-target-of="${targetId}"]`) as HTMLElement;
|
|
1195
1210
|
};
|
|
1196
1211
|
|
|
1197
1212
|
function removeContentFromTarget(draggable: HTMLElement) {
|