@bendyline/squisq-react 2.12.34 → 2.12.36
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/dist/{chunk-IPTOV4W7.js → chunk-2MUOWKDD.js} +225 -104
- package/dist/{chunk-ZZ5ZY5JD.js → chunk-4T52YEO6.js} +1 -1
- package/dist/{chunk-MLONAXXN.js → chunk-BTQ6MFGI.js} +2 -2
- package/dist/{chunk-ARBI4PTE.js → chunk-CNUP52LX.js} +5 -3
- package/dist/{chunk-EQCHV3QH.js → chunk-HLL7ENG5.js} +5 -2
- package/dist/{chunk-755MBX5E.js → chunk-PQFZGOAN.js} +15 -6
- package/dist/{chunk-TCBV3WXF.js → chunk-QT2EVNNF.js} +1 -1
- package/dist/{chunk-GIRDBU3E.js → chunk-V22O3WRT.js} +1 -1
- package/dist/diagram-pictures/index.js +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.js +171 -8
- package/dist/json-view/index.js +2 -2
- package/dist/layers/index.js +1 -1
- package/dist/markdown/index.js +1 -1
- package/dist/page/index.js +5 -5
- package/dist/player/index.d.ts +1 -1
- package/dist/player/index.js +6 -6
- package/dist/{player-Wc6Nd4p5.d.ts → player-CcdlXneC.d.ts} +200 -75
- package/dist/squisq-player.full.global.js +509 -508
- package/dist/squisq-player.global.js +97 -96
- package/dist/standalone-player-full.js +1 -1
- package/dist/standalone-source.js +1 -1
- package/package.json +2 -2
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinearDocView
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BTQ6MFGI.js";
|
|
4
4
|
import {
|
|
5
5
|
useAudioSync,
|
|
6
6
|
useDocPlayback,
|
|
7
7
|
useMediaSchedule,
|
|
8
8
|
useScreenWakeLock,
|
|
9
9
|
useViewportOrientation
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HLL7ENG5.js";
|
|
11
11
|
import {
|
|
12
12
|
useAutoSurface
|
|
13
13
|
} from "./chunk-TT6ENR6T.js";
|
|
14
14
|
import {
|
|
15
15
|
MarkdownRenderer
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-CNUP52LX.js";
|
|
17
17
|
import {
|
|
18
18
|
BlockRenderer
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-QT2EVNNF.js";
|
|
20
20
|
import {
|
|
21
21
|
applyMediaLevel,
|
|
22
22
|
blockVideoSourceTime,
|
|
@@ -1048,13 +1048,45 @@ function formatTime(seconds) {
|
|
|
1048
1048
|
import { useRef as useRef2, useState as useState3, useCallback as useCallback2 } from "react";
|
|
1049
1049
|
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1050
1050
|
var PLAYER_ACCENT = "var(--squisq-player-accent, #5b9bd5)";
|
|
1051
|
+
var VARIANTS = {
|
|
1052
|
+
overlay: {
|
|
1053
|
+
height: 24,
|
|
1054
|
+
track: 6,
|
|
1055
|
+
trackColor: "rgba(255,255,255,0.2)",
|
|
1056
|
+
chapter: 14,
|
|
1057
|
+
chapterFill: "rgba(255,255,255,0.75)",
|
|
1058
|
+
chapterActive: "#ffffff",
|
|
1059
|
+
chapterShadow: "0 1px 3px rgba(0,0,0,0.5)",
|
|
1060
|
+
bead: 12,
|
|
1061
|
+
beadFill: "rgba(255,255,255,0.55)",
|
|
1062
|
+
beadActive: "#ffffff",
|
|
1063
|
+
hoverLine: 16,
|
|
1064
|
+
hoverLineColor: "rgba(255,255,255,0.6)"
|
|
1065
|
+
},
|
|
1066
|
+
inline: {
|
|
1067
|
+
height: 16,
|
|
1068
|
+
track: 4,
|
|
1069
|
+
trackColor: "color-mix(in srgb, currentColor 22%, transparent)",
|
|
1070
|
+
chapter: 10,
|
|
1071
|
+
chapterFill: "var(--squisq-player-surface, Canvas)",
|
|
1072
|
+
chapterActive: PLAYER_ACCENT,
|
|
1073
|
+
chapterShadow: "none",
|
|
1074
|
+
bead: 10,
|
|
1075
|
+
beadFill: "color-mix(in srgb, currentColor 45%, transparent)",
|
|
1076
|
+
beadActive: "currentColor",
|
|
1077
|
+
hoverLine: 12,
|
|
1078
|
+
hoverLineColor: "color-mix(in srgb, currentColor 60%, transparent)"
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1051
1081
|
function DocProgressBar({
|
|
1052
1082
|
state,
|
|
1053
1083
|
actions,
|
|
1054
1084
|
blockMarkers,
|
|
1055
1085
|
expandedBlocks,
|
|
1056
|
-
getBlockTitle
|
|
1086
|
+
getBlockTitle,
|
|
1087
|
+
variant = "overlay"
|
|
1057
1088
|
}) {
|
|
1089
|
+
const look = VARIANTS[variant];
|
|
1058
1090
|
const progressBarRef = useRef2(null);
|
|
1059
1091
|
const [hoverPosition, setHoverPosition] = useState3(null);
|
|
1060
1092
|
const playProgress = state.totalDuration > 0 ? Math.max(0, Math.min(1, state.currentTime / state.totalDuration)) : 0;
|
|
@@ -1118,9 +1150,12 @@ function DocProgressBar({
|
|
|
1118
1150
|
ref: progressBarRef,
|
|
1119
1151
|
role: "group",
|
|
1120
1152
|
"aria-label": "Playback timeline",
|
|
1153
|
+
"data-variant": variant,
|
|
1121
1154
|
style: {
|
|
1122
1155
|
flex: 1,
|
|
1123
|
-
|
|
1156
|
+
// The clickable strip; the track stays centered in it. The inline
|
|
1157
|
+
// variant lets its host make it taller for a finger.
|
|
1158
|
+
height: variant === "inline" ? `var(--squisq-player-scrub-height, ${look.height}px)` : `${look.height}px`,
|
|
1124
1159
|
cursor: "pointer",
|
|
1125
1160
|
position: "relative",
|
|
1126
1161
|
display: "flex",
|
|
@@ -1150,9 +1185,9 @@ function DocProgressBar({
|
|
|
1150
1185
|
position: "absolute",
|
|
1151
1186
|
left: 0,
|
|
1152
1187
|
right: 0,
|
|
1153
|
-
height:
|
|
1154
|
-
background:
|
|
1155
|
-
borderRadius:
|
|
1188
|
+
height: `${look.track}px`,
|
|
1189
|
+
background: look.trackColor,
|
|
1190
|
+
borderRadius: `${look.track / 2}px`
|
|
1156
1191
|
}
|
|
1157
1192
|
}
|
|
1158
1193
|
),
|
|
@@ -1164,9 +1199,9 @@ function DocProgressBar({
|
|
|
1164
1199
|
position: "absolute",
|
|
1165
1200
|
left: 0,
|
|
1166
1201
|
width: `${playProgress * 100}%`,
|
|
1167
|
-
height:
|
|
1202
|
+
height: `${look.track}px`,
|
|
1168
1203
|
background: PLAYER_ACCENT,
|
|
1169
|
-
borderRadius:
|
|
1204
|
+
borderRadius: `${look.track / 2}px`
|
|
1170
1205
|
}
|
|
1171
1206
|
}
|
|
1172
1207
|
),
|
|
@@ -1188,19 +1223,19 @@ function DocProgressBar({
|
|
|
1188
1223
|
cursor: "pointer",
|
|
1189
1224
|
transition: "transform 0.15s, background-color 0.15s",
|
|
1190
1225
|
...chapter ? {
|
|
1191
|
-
width:
|
|
1192
|
-
height:
|
|
1226
|
+
width: `${look.chapter}px`,
|
|
1227
|
+
height: `${look.chapter}px`,
|
|
1193
1228
|
padding: 0,
|
|
1194
|
-
backgroundColor: active ?
|
|
1229
|
+
backgroundColor: active ? look.chapterActive : look.chapterFill,
|
|
1195
1230
|
border: `2px solid ${PLAYER_ACCENT}`,
|
|
1196
|
-
boxShadow:
|
|
1231
|
+
boxShadow: look.chapterShadow,
|
|
1197
1232
|
zIndex: 3
|
|
1198
1233
|
} : {
|
|
1199
|
-
width:
|
|
1200
|
-
height:
|
|
1234
|
+
width: `${look.bead}px`,
|
|
1235
|
+
height: `${look.bead}px`,
|
|
1201
1236
|
padding: "3px",
|
|
1202
1237
|
backgroundClip: "content-box",
|
|
1203
|
-
backgroundColor: active ?
|
|
1238
|
+
backgroundColor: active ? look.beadActive : look.beadFill,
|
|
1204
1239
|
border: "none",
|
|
1205
1240
|
zIndex: 2
|
|
1206
1241
|
}
|
|
@@ -1259,8 +1294,8 @@ function DocProgressBar({
|
|
|
1259
1294
|
top: "50%",
|
|
1260
1295
|
transform: "translate(-50%, -50%)",
|
|
1261
1296
|
width: "2px",
|
|
1262
|
-
height:
|
|
1263
|
-
background:
|
|
1297
|
+
height: `${look.hoverLine}px`,
|
|
1298
|
+
background: look.hoverLineColor,
|
|
1264
1299
|
pointerEvents: "none",
|
|
1265
1300
|
zIndex: 1
|
|
1266
1301
|
}
|
|
@@ -1369,7 +1404,13 @@ function PlayPauseIcon({ isPlaying, isBuffering = false, size }) {
|
|
|
1369
1404
|
}
|
|
1370
1405
|
|
|
1371
1406
|
// src/DocControlsOverlay.tsx
|
|
1372
|
-
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1407
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1408
|
+
function PlaybackControls({
|
|
1409
|
+
render,
|
|
1410
|
+
...controls
|
|
1411
|
+
}) {
|
|
1412
|
+
return /* @__PURE__ */ jsx6(Fragment2, { children: render ? render(controls) : /* @__PURE__ */ jsx6(DocControlsOverlay, { ...controls }) });
|
|
1413
|
+
}
|
|
1373
1414
|
function DocControlsOverlay({
|
|
1374
1415
|
state,
|
|
1375
1416
|
actions,
|
|
@@ -1510,7 +1551,13 @@ function DocControlsOverlay({
|
|
|
1510
1551
|
|
|
1511
1552
|
// src/DocControlsSlideshow.tsx
|
|
1512
1553
|
import { useCallback as useCallback3, useEffect as useEffect4, useId, useLayoutEffect, useRef as useRef3, useState as useState4 } from "react";
|
|
1513
|
-
import { Fragment as
|
|
1554
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1555
|
+
function SlideshowControls({
|
|
1556
|
+
controls,
|
|
1557
|
+
render
|
|
1558
|
+
}) {
|
|
1559
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: render ? render(controls) : /* @__PURE__ */ jsx7(DocControlsSlideshow, { ...controls }) });
|
|
1560
|
+
}
|
|
1514
1561
|
function DocControlsSlideshow({
|
|
1515
1562
|
state,
|
|
1516
1563
|
slideNav,
|
|
@@ -1782,7 +1829,7 @@ function DocControlsSlideshow({
|
|
|
1782
1829
|
})
|
|
1783
1830
|
}
|
|
1784
1831
|
),
|
|
1785
|
-
!!state.buildCount && /* @__PURE__ */ jsxs4(
|
|
1832
|
+
!!state.buildCount && /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
1786
1833
|
/* @__PURE__ */ jsxs4("span", { role: "status", style: { color: "inherit", fontSize: 12 }, children: [
|
|
1787
1834
|
"Build ",
|
|
1788
1835
|
state.buildStep ?? 0,
|
|
@@ -1867,7 +1914,7 @@ async function decodeSvgImages(root) {
|
|
|
1867
1914
|
}
|
|
1868
1915
|
|
|
1869
1916
|
// src/DashboardView.tsx
|
|
1870
|
-
import { Fragment as
|
|
1917
|
+
import { Fragment as Fragment4, useEffect as useEffect5, useMemo as useMemo4, useRef as useRef4 } from "react";
|
|
1871
1918
|
import { materializeDashboard, resolveThemeForDoc, VIEWPORT_PRESETS } from "@bendyline/squisq/doc";
|
|
1872
1919
|
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1873
1920
|
async function waitForDashboardAssets(root) {
|
|
@@ -2004,7 +2051,7 @@ function DashboardView({
|
|
|
2004
2051
|
theme: activeTheme
|
|
2005
2052
|
}
|
|
2006
2053
|
) }),
|
|
2007
|
-
materialization.cells.map((cell) => /* @__PURE__ */ jsxs5(
|
|
2054
|
+
materialization.cells.map((cell) => /* @__PURE__ */ jsxs5(Fragment4, { children: [
|
|
2008
2055
|
cell.frame && /* @__PURE__ */ jsx8(
|
|
2009
2056
|
"div",
|
|
2010
2057
|
{
|
|
@@ -2158,7 +2205,16 @@ import {
|
|
|
2158
2205
|
resolvePageBlock,
|
|
2159
2206
|
resolveThemeForDoc as resolveThemeForDoc2
|
|
2160
2207
|
} from "@bendyline/squisq/doc";
|
|
2208
|
+
import { SeededRandom, hashString } from "@bendyline/squisq/random";
|
|
2161
2209
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2210
|
+
function cardRef(card) {
|
|
2211
|
+
return {
|
|
2212
|
+
id: card.id,
|
|
2213
|
+
kind: card.kind,
|
|
2214
|
+
sourceBlockId: card.sourceBlockId,
|
|
2215
|
+
...card.ownerBlockId ? { ownerBlockId: card.ownerBlockId } : {}
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2162
2218
|
var VISUAL_TEMPLATES = /* @__PURE__ */ new Set([
|
|
2163
2219
|
"diagram",
|
|
2164
2220
|
"tree",
|
|
@@ -2258,29 +2314,8 @@ function FaceContent(props) {
|
|
|
2258
2314
|
function FlashcardFaceView(props) {
|
|
2259
2315
|
return /* @__PURE__ */ jsx9(FaceContent, { ...props, viewport: props.viewport ?? VIEWPORT_PRESETS2.landscape });
|
|
2260
2316
|
}
|
|
2261
|
-
function hashSeed(value) {
|
|
2262
|
-
let hash = 2166136261;
|
|
2263
|
-
for (let index = 0; index < value.length; index++) {
|
|
2264
|
-
hash ^= value.charCodeAt(index);
|
|
2265
|
-
hash = Math.imul(hash, 16777619);
|
|
2266
|
-
}
|
|
2267
|
-
return hash >>> 0;
|
|
2268
|
-
}
|
|
2269
2317
|
function shuffled(values, seed) {
|
|
2270
|
-
|
|
2271
|
-
let state = hashSeed(seed) || 1;
|
|
2272
|
-
const random = () => {
|
|
2273
|
-
state += 1831565813;
|
|
2274
|
-
let next = state;
|
|
2275
|
-
next = Math.imul(next ^ next >>> 15, next | 1);
|
|
2276
|
-
next ^= next + Math.imul(next ^ next >>> 7, next | 61);
|
|
2277
|
-
return ((next ^ next >>> 14) >>> 0) / 4294967296;
|
|
2278
|
-
};
|
|
2279
|
-
for (let index = result.length - 1; index > 0; index--) {
|
|
2280
|
-
const other = Math.floor(random() * (index + 1));
|
|
2281
|
-
[result[index], result[other]] = [result[other], result[index]];
|
|
2282
|
-
}
|
|
2283
|
-
return result;
|
|
2318
|
+
return new SeededRandom(hashString(seed) || 1).shuffled(values);
|
|
2284
2319
|
}
|
|
2285
2320
|
function ChoiceContent(props) {
|
|
2286
2321
|
return /* @__PURE__ */ jsx9(FaceContent, { ...props, face: props.choice.content });
|
|
@@ -2306,12 +2341,25 @@ function FlashcardView({
|
|
|
2306
2341
|
fenceRenderers,
|
|
2307
2342
|
viewport = VIEWPORT_PRESETS2.landscape,
|
|
2308
2343
|
density = "comfortable",
|
|
2309
|
-
className
|
|
2344
|
+
className,
|
|
2345
|
+
renderControls,
|
|
2346
|
+
kinds,
|
|
2347
|
+
onRate,
|
|
2348
|
+
onAnswer,
|
|
2349
|
+
onComplete
|
|
2310
2350
|
}) {
|
|
2311
2351
|
const compact = density === "compact";
|
|
2352
|
+
const hostControls = !!renderControls;
|
|
2312
2353
|
const rootClassName = "squisq-flashcards" + (compact ? " squisq-flashcards--compact" : "") + (className ? ` ${className}` : "");
|
|
2313
2354
|
const activeTheme = useMemo5(() => theme ?? resolveThemeForDoc2(doc), [doc, theme]);
|
|
2314
|
-
const
|
|
2355
|
+
const kindsKey = kinds?.join(",");
|
|
2356
|
+
const deck = useMemo5(() => {
|
|
2357
|
+
const built = materializeFlashcards(doc, { source });
|
|
2358
|
+
const wanted = kindsKey?.split(",");
|
|
2359
|
+
return wanted ? { ...built, cards: built.cards.filter((card) => wanted.includes(card.kind)) } : built;
|
|
2360
|
+
}, [doc, source, kindsKey]);
|
|
2361
|
+
const callbacks = useRef5({ onRate, onAnswer, onComplete });
|
|
2362
|
+
callbacks.current = { onRate, onAnswer, onComplete };
|
|
2315
2363
|
const [shuffleEnabled, setShuffleEnabled] = useState5(initialShuffle);
|
|
2316
2364
|
const [sessionSeed, setSessionSeed] = useState5(1);
|
|
2317
2365
|
const [cardIndex, setCardIndex] = useState5(0);
|
|
@@ -2332,6 +2380,28 @@ function FlashcardView({
|
|
|
2332
2380
|
);
|
|
2333
2381
|
const currentCard = sessionCards[cardIndex];
|
|
2334
2382
|
const finished = sessionCards.length > 0 && cardIndex >= sessionCards.length;
|
|
2383
|
+
const choices = useMemo5(
|
|
2384
|
+
() => currentCard?.choices ? shuffled(currentCard.choices, `${currentCard.id}:${sessionSeed}`) : [],
|
|
2385
|
+
[currentCard, sessionSeed]
|
|
2386
|
+
);
|
|
2387
|
+
const complete = useCallback4(
|
|
2388
|
+
(finalRatings) => {
|
|
2389
|
+
const handler = callbacks.current.onComplete;
|
|
2390
|
+
if (!handler) return;
|
|
2391
|
+
const results = sessionCards.map((card) => ({
|
|
2392
|
+
card: cardRef(card),
|
|
2393
|
+
rating: finalRatings[card.id] ?? null
|
|
2394
|
+
}));
|
|
2395
|
+
handler({
|
|
2396
|
+
results,
|
|
2397
|
+
remembered: results.filter((result) => result.rating === "got-it").length,
|
|
2398
|
+
missed: results.filter((result) => result.rating === "again").length,
|
|
2399
|
+
total: results.length,
|
|
2400
|
+
retry: retryIds !== null
|
|
2401
|
+
});
|
|
2402
|
+
},
|
|
2403
|
+
[retryIds, sessionCards]
|
|
2404
|
+
);
|
|
2335
2405
|
const resetPosition = useCallback4(() => {
|
|
2336
2406
|
setCardIndex(0);
|
|
2337
2407
|
setRevealed(false);
|
|
@@ -2363,7 +2433,7 @@ function FlashcardView({
|
|
|
2363
2433
|
if (delta > 0) viewport2.scrollTop += delta;
|
|
2364
2434
|
}, [revealed, cardIndex, retryIds]);
|
|
2365
2435
|
useLayoutEffect2(() => {
|
|
2366
|
-
if (compact || !deckElement) return;
|
|
2436
|
+
if (compact || hostControls || !deckElement) return;
|
|
2367
2437
|
const measure = () => {
|
|
2368
2438
|
const { width, height } = deckElement.getBoundingClientRect();
|
|
2369
2439
|
setSideRails((current) => wantsSideRails(width, height, current));
|
|
@@ -2373,24 +2443,31 @@ function FlashcardView({
|
|
|
2373
2443
|
const observer = new ResizeObserver(measure);
|
|
2374
2444
|
observer.observe(deckElement);
|
|
2375
2445
|
return () => observer.disconnect();
|
|
2376
|
-
}, [compact, deckElement]);
|
|
2446
|
+
}, [compact, hostControls, deckElement]);
|
|
2377
2447
|
const revealAnswer = useCallback4(() => {
|
|
2378
2448
|
if (!currentCard) return;
|
|
2379
2449
|
setRevealed(true);
|
|
2380
2450
|
if (currentCard.kind === "multiple-choice" && selectedChoiceId === null) {
|
|
2381
2451
|
setRatings((current) => ({ ...current, [currentCard.id]: "again" }));
|
|
2452
|
+
callbacks.current.onAnswer?.({
|
|
2453
|
+
card: cardRef(currentCard),
|
|
2454
|
+
choiceId: null,
|
|
2455
|
+
correct: false,
|
|
2456
|
+
retry: retryIds !== null
|
|
2457
|
+
});
|
|
2382
2458
|
}
|
|
2383
|
-
}, [currentCard, selectedChoiceId]);
|
|
2459
|
+
}, [currentCard, retryIds, selectedChoiceId]);
|
|
2384
2460
|
const nextCard = useCallback4(() => {
|
|
2385
2461
|
if (!currentCard) return;
|
|
2386
2462
|
if (!revealed) {
|
|
2387
2463
|
revealAnswer();
|
|
2388
2464
|
return;
|
|
2389
2465
|
}
|
|
2466
|
+
if (cardIndex === sessionCards.length - 1) complete(ratings);
|
|
2390
2467
|
setCardIndex((index) => index + 1);
|
|
2391
2468
|
setRevealed(false);
|
|
2392
2469
|
setSelectedChoiceId(null);
|
|
2393
|
-
}, [currentCard, revealAnswer, revealed]);
|
|
2470
|
+
}, [cardIndex, complete, currentCard, ratings, revealAnswer, revealed, sessionCards.length]);
|
|
2394
2471
|
const previousCard = useCallback4(() => {
|
|
2395
2472
|
if (finished) {
|
|
2396
2473
|
setCardIndex(Math.max(0, sessionCards.length - 1));
|
|
@@ -2417,24 +2494,37 @@ function FlashcardView({
|
|
|
2417
2494
|
...current,
|
|
2418
2495
|
[currentCard.id]: choice.correct ? "got-it" : "again"
|
|
2419
2496
|
}));
|
|
2497
|
+
callbacks.current.onAnswer?.({
|
|
2498
|
+
card: cardRef(currentCard),
|
|
2499
|
+
choiceId: choice.id,
|
|
2500
|
+
correct: choice.correct,
|
|
2501
|
+
retry: retryIds !== null
|
|
2502
|
+
});
|
|
2420
2503
|
},
|
|
2421
|
-
[currentCard, revealed]
|
|
2504
|
+
[currentCard, retryIds, revealed]
|
|
2422
2505
|
);
|
|
2423
2506
|
const rate = useCallback4(
|
|
2424
2507
|
(rating) => {
|
|
2425
2508
|
if (!currentCard) return;
|
|
2426
|
-
|
|
2509
|
+
const next = { ...ratings, [currentCard.id]: rating };
|
|
2510
|
+
setRatings(next);
|
|
2511
|
+
callbacks.current.onRate?.({
|
|
2512
|
+
card: cardRef(currentCard),
|
|
2513
|
+
rating,
|
|
2514
|
+
retry: retryIds !== null
|
|
2515
|
+
});
|
|
2516
|
+
if (cardIndex === sessionCards.length - 1) complete(next);
|
|
2427
2517
|
setCardIndex((index) => index + 1);
|
|
2428
2518
|
setRevealed(false);
|
|
2429
2519
|
setSelectedChoiceId(null);
|
|
2430
2520
|
},
|
|
2431
|
-
[currentCard]
|
|
2521
|
+
[cardIndex, complete, currentCard, ratings, retryIds, sessionCards.length]
|
|
2432
2522
|
);
|
|
2433
2523
|
const handleShortcut = useCallback4(
|
|
2434
2524
|
(event) => {
|
|
2435
2525
|
if (event.defaultPrevented || isInteractiveTarget(event.target)) return;
|
|
2436
2526
|
if (/^[1-9]$/.test(event.key) && currentCard?.kind === "multiple-choice" && !revealed) {
|
|
2437
|
-
const choice =
|
|
2527
|
+
const choice = choices[Number(event.key) - 1];
|
|
2438
2528
|
if (choice) {
|
|
2439
2529
|
event.preventDefault();
|
|
2440
2530
|
choose(choice);
|
|
@@ -2449,7 +2539,7 @@ function FlashcardView({
|
|
|
2449
2539
|
nextCard();
|
|
2450
2540
|
}
|
|
2451
2541
|
},
|
|
2452
|
-
[choose, currentCard, nextCard, previousCard, revealed]
|
|
2542
|
+
[choices, choose, currentCard, nextCard, previousCard, revealed]
|
|
2453
2543
|
);
|
|
2454
2544
|
useEffect6(() => {
|
|
2455
2545
|
if (!globalKeyboardShortcuts) return;
|
|
@@ -2483,6 +2573,33 @@ function FlashcardView({
|
|
|
2483
2573
|
};
|
|
2484
2574
|
const missedIds = deck.cards.filter((card) => ratings[card.id] === "again").map((card) => card.id);
|
|
2485
2575
|
const gotItCount = deck.cards.filter((card) => ratings[card.id] === "got-it").length;
|
|
2576
|
+
const lastCard = cardIndex === sessionCards.length - 1;
|
|
2577
|
+
const toggleShuffle = () => {
|
|
2578
|
+
setShuffleEnabled((enabled) => !enabled);
|
|
2579
|
+
restart();
|
|
2580
|
+
};
|
|
2581
|
+
const retryMissed = () => {
|
|
2582
|
+
setRetryIds(missedIds);
|
|
2583
|
+
resetPosition();
|
|
2584
|
+
};
|
|
2585
|
+
const controls = {
|
|
2586
|
+
cardIndex: Math.min(cardIndex, sessionCards.length),
|
|
2587
|
+
cardCount: sessionCards.length,
|
|
2588
|
+
revealed,
|
|
2589
|
+
finished,
|
|
2590
|
+
cardKind: currentCard?.kind,
|
|
2591
|
+
lastCard,
|
|
2592
|
+
progress: sessionCards.length ? Math.min(1, (cardIndex + (revealed ? 1 : 0)) / sessionCards.length) : 0,
|
|
2593
|
+
shuffled: shuffleEnabled,
|
|
2594
|
+
missedCount: missedIds.length,
|
|
2595
|
+
canGoBack: cardIndex > 0 || revealed,
|
|
2596
|
+
previous: previousCard,
|
|
2597
|
+
next: nextCard,
|
|
2598
|
+
rate,
|
|
2599
|
+
toggleShuffle,
|
|
2600
|
+
restart,
|
|
2601
|
+
retryMissed
|
|
2602
|
+
};
|
|
2486
2603
|
if (deck.cards.length === 0) {
|
|
2487
2604
|
return /* @__PURE__ */ jsx9(
|
|
2488
2605
|
"div",
|
|
@@ -2500,7 +2617,7 @@ function FlashcardView({
|
|
|
2500
2617
|
);
|
|
2501
2618
|
}
|
|
2502
2619
|
if (finished) {
|
|
2503
|
-
return /* @__PURE__ */
|
|
2620
|
+
return /* @__PURE__ */ jsxs6(
|
|
2504
2621
|
"div",
|
|
2505
2622
|
{
|
|
2506
2623
|
className: rootClassName,
|
|
@@ -2509,39 +2626,37 @@ function FlashcardView({
|
|
|
2509
2626
|
"aria-label": "Flashcard session summary",
|
|
2510
2627
|
tabIndex: 0,
|
|
2511
2628
|
onKeyDown: globalKeyboardShortcuts ? void 0 : handleShortcut,
|
|
2512
|
-
children:
|
|
2513
|
-
/* @__PURE__ */
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2629
|
+
children: [
|
|
2630
|
+
/* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__summary", children: [
|
|
2631
|
+
/* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__eyebrow", children: "Session complete" }),
|
|
2632
|
+
/* @__PURE__ */ jsxs6("h2", { children: [
|
|
2633
|
+
gotItCount,
|
|
2634
|
+
" remembered"
|
|
2635
|
+
] }),
|
|
2636
|
+
/* @__PURE__ */ jsx9("p", { children: missedIds.length === 0 ? `You completed all ${deck.cards.length} cards.` : `${missedIds.length} ${missedIds.length === 1 ? "card needs" : "cards need"} another look.` }),
|
|
2637
|
+
/* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__summary-actions", children: [
|
|
2638
|
+
missedIds.length > 0 && /* @__PURE__ */ jsx9(
|
|
2639
|
+
"button",
|
|
2640
|
+
{
|
|
2641
|
+
type: "button",
|
|
2642
|
+
className: "squisq-flashcards__button squisq-flashcards__button--primary",
|
|
2643
|
+
onClick: retryMissed,
|
|
2644
|
+
children: "Retry missed"
|
|
2645
|
+
}
|
|
2646
|
+
),
|
|
2647
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__button", onClick: restart, children: "Study again" }),
|
|
2648
|
+
!hostControls && /* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__button", onClick: previousCard, children: "Previous card" })
|
|
2649
|
+
] })
|
|
2517
2650
|
] }),
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
missedIds.length > 0 && /* @__PURE__ */ jsx9(
|
|
2521
|
-
"button",
|
|
2522
|
-
{
|
|
2523
|
-
type: "button",
|
|
2524
|
-
className: "squisq-flashcards__button squisq-flashcards__button--primary",
|
|
2525
|
-
onClick: () => {
|
|
2526
|
-
setRetryIds(missedIds);
|
|
2527
|
-
resetPosition();
|
|
2528
|
-
},
|
|
2529
|
-
children: "Retry missed"
|
|
2530
|
-
}
|
|
2531
|
-
),
|
|
2532
|
-
/* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__button", onClick: restart, children: "Study again" }),
|
|
2533
|
-
/* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__button", onClick: previousCard, children: "Previous card" })
|
|
2534
|
-
] })
|
|
2535
|
-
] })
|
|
2651
|
+
renderControls?.(controls)
|
|
2652
|
+
]
|
|
2536
2653
|
}
|
|
2537
2654
|
);
|
|
2538
2655
|
}
|
|
2539
|
-
const choices = currentCard?.choices ? shuffled(currentCard.choices, `${currentCard.id}:${sessionSeed}`) : [];
|
|
2540
2656
|
const selectedChoice = choices.find((choice) => choice.id === selectedChoiceId);
|
|
2541
2657
|
const position = `Card ${cardIndex + 1} of ${sessionCards.length}`;
|
|
2542
|
-
const lastCard = cardIndex === sessionCards.length - 1;
|
|
2543
2658
|
const nextLabel = revealed ? lastCard ? "Finish" : "Next card" : "Reveal";
|
|
2544
|
-
const railsActive = sideRails && !compact;
|
|
2659
|
+
const railsActive = sideRails && !compact && !hostControls;
|
|
2545
2660
|
const tools = /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__tools", children: [
|
|
2546
2661
|
/* @__PURE__ */ jsx9(
|
|
2547
2662
|
"button",
|
|
@@ -2549,10 +2664,7 @@ function FlashcardView({
|
|
|
2549
2664
|
type: "button",
|
|
2550
2665
|
className: "squisq-flashcards__tool",
|
|
2551
2666
|
"aria-pressed": shuffleEnabled,
|
|
2552
|
-
onClick:
|
|
2553
|
-
setShuffleEnabled((enabled) => !enabled);
|
|
2554
|
-
restart();
|
|
2555
|
-
},
|
|
2667
|
+
onClick: toggleShuffle,
|
|
2556
2668
|
children: "Shuffle"
|
|
2557
2669
|
}
|
|
2558
2670
|
),
|
|
@@ -2624,9 +2736,9 @@ function FlashcardView({
|
|
|
2624
2736
|
/* @__PURE__ */ jsxs6("header", { className: "squisq-flashcards__header", children: [
|
|
2625
2737
|
/* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__deck-copy", children: [
|
|
2626
2738
|
deck.title && /* @__PURE__ */ jsx9("h1", { title: compact ? deck.title : void 0, children: deck.title }),
|
|
2627
|
-
compact && /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__position", children: position })
|
|
2739
|
+
compact && !hostControls && /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__position", children: position })
|
|
2628
2740
|
] }),
|
|
2629
|
-
compact ? /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__controls", children: [
|
|
2741
|
+
hostControls ? null : compact ? /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__controls", children: [
|
|
2630
2742
|
tools,
|
|
2631
2743
|
/* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__navigation", children: [
|
|
2632
2744
|
previousButton,
|
|
@@ -2634,7 +2746,7 @@ function FlashcardView({
|
|
|
2634
2746
|
] })
|
|
2635
2747
|
] }) : tools
|
|
2636
2748
|
] }),
|
|
2637
|
-
compact && progressBar,
|
|
2749
|
+
compact && !hostControls && progressBar,
|
|
2638
2750
|
/* @__PURE__ */ jsxs6(
|
|
2639
2751
|
"main",
|
|
2640
2752
|
{
|
|
@@ -2692,7 +2804,7 @@ function FlashcardView({
|
|
|
2692
2804
|
]
|
|
2693
2805
|
}
|
|
2694
2806
|
),
|
|
2695
|
-
!compact && /* @__PURE__ */ jsxs6("footer", { className: "squisq-flashcards__footer", children: [
|
|
2807
|
+
!compact && !hostControls && /* @__PURE__ */ jsxs6("footer", { className: "squisq-flashcards__footer", children: [
|
|
2696
2808
|
/* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__back", children: [
|
|
2697
2809
|
previousButton,
|
|
2698
2810
|
/* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__progress-group", children: [
|
|
@@ -2701,7 +2813,8 @@ function FlashcardView({
|
|
|
2701
2813
|
] })
|
|
2702
2814
|
] }),
|
|
2703
2815
|
primaryActions
|
|
2704
|
-
] })
|
|
2816
|
+
] }),
|
|
2817
|
+
renderControls?.(controls)
|
|
2705
2818
|
]
|
|
2706
2819
|
}
|
|
2707
2820
|
);
|
|
@@ -2786,7 +2899,7 @@ function resolveDocPlayerAppearance(doc, overrides = {}) {
|
|
|
2786
2899
|
|
|
2787
2900
|
// src/DocPlayer.tsx
|
|
2788
2901
|
import {
|
|
2789
|
-
Fragment as
|
|
2902
|
+
Fragment as Fragment5,
|
|
2790
2903
|
useId as useId2,
|
|
2791
2904
|
useRef as useRef7,
|
|
2792
2905
|
useState as useState7,
|
|
@@ -3050,6 +3163,7 @@ function DocPlayer(props) {
|
|
|
3050
3163
|
return /* @__PURE__ */ jsx10("div", { className: "doc-player doc-player--flashcards", children: /* @__PURE__ */ jsx10(
|
|
3051
3164
|
FlashcardView,
|
|
3052
3165
|
{
|
|
3166
|
+
...props.flashcards,
|
|
3053
3167
|
doc: resolvedDoc,
|
|
3054
3168
|
basePath: props.basePath,
|
|
3055
3169
|
theme: props.theme,
|
|
@@ -3113,7 +3227,9 @@ function DocPlayerContent({
|
|
|
3113
3227
|
showCodeCopyButton = false,
|
|
3114
3228
|
onCopyCode,
|
|
3115
3229
|
fenceRenderers,
|
|
3116
|
-
tableContentRenderer
|
|
3230
|
+
tableContentRenderer,
|
|
3231
|
+
renderSlideshowControls,
|
|
3232
|
+
renderPlaybackControls
|
|
3117
3233
|
}) {
|
|
3118
3234
|
const isSlideshowMode = displayMode === "slideshow";
|
|
3119
3235
|
const isLinearMode = displayMode === "linear";
|
|
@@ -4363,7 +4479,7 @@ function DocPlayerContent({
|
|
|
4363
4479
|
hasCaptions && (() => {
|
|
4364
4480
|
const debugPhrase = getCaptionAtTime2(doc.captions, currentTime);
|
|
4365
4481
|
const debugEnabled = captionsEnabled && captionClockRunning;
|
|
4366
|
-
return /* @__PURE__ */ jsxs7(
|
|
4482
|
+
return /* @__PURE__ */ jsxs7(Fragment5, { children: [
|
|
4367
4483
|
/* @__PURE__ */ jsxs7("div", { children: [
|
|
4368
4484
|
/* @__PURE__ */ jsx10("span", { style: { color: "#888" }, children: "captions:" }),
|
|
4369
4485
|
" ",
|
|
@@ -4436,8 +4552,9 @@ function DocPlayerContent({
|
|
|
4436
4552
|
}
|
|
4437
4553
|
),
|
|
4438
4554
|
!renderMode && !isSlideshowMode && showControls && /* @__PURE__ */ jsx10(
|
|
4439
|
-
|
|
4555
|
+
PlaybackControls,
|
|
4440
4556
|
{
|
|
4557
|
+
render: renderPlaybackControls,
|
|
4441
4558
|
state: playbackState,
|
|
4442
4559
|
actions: playbackActions,
|
|
4443
4560
|
blockMarkers,
|
|
@@ -4473,13 +4590,16 @@ function DocPlayerContent({
|
|
|
4473
4590
|
}
|
|
4474
4591
|
),
|
|
4475
4592
|
!renderMode && isSlideshowMode && showControls && /* @__PURE__ */ jsx10(
|
|
4476
|
-
|
|
4593
|
+
SlideshowControls,
|
|
4477
4594
|
{
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4595
|
+
controls: {
|
|
4596
|
+
state: playbackState,
|
|
4597
|
+
slideNav: stepNavActions,
|
|
4598
|
+
slides: slideshowPickerItems,
|
|
4599
|
+
pickerOpen: isSlideshowPickerOpen,
|
|
4600
|
+
onPickerOpenChange: setIsSlideshowPickerOpen
|
|
4601
|
+
},
|
|
4602
|
+
render: renderSlideshowControls
|
|
4483
4603
|
}
|
|
4484
4604
|
),
|
|
4485
4605
|
!isSlideshowMode && tapFeedback && /* @__PURE__ */ jsx10("div", { className: "doc-player__tap-feedback", children: /* @__PURE__ */ jsx10("svg", { viewBox: "0 0 24 24", fill: "white", width: "48", height: "48", children: tapFeedback === "pause" ? /* @__PURE__ */ jsx10("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }) : /* @__PURE__ */ jsx10("path", { d: "M8 5v14l11-7z" }) }) }, tapFeedback)
|
|
@@ -4722,6 +4842,7 @@ export {
|
|
|
4722
4842
|
CaptionOverlay,
|
|
4723
4843
|
formatTime,
|
|
4724
4844
|
DocProgressBar,
|
|
4845
|
+
PlayPauseIcon,
|
|
4725
4846
|
DocControlsOverlay,
|
|
4726
4847
|
DocControlsSlideshow,
|
|
4727
4848
|
decodeSvgImages,
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
InlineVideoPlayer,
|
|
6
6
|
MarkdownRenderer,
|
|
7
7
|
VideoEmbedFrame
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CNUP52LX.js";
|
|
9
9
|
import {
|
|
10
10
|
BlockRenderer
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QT2EVNNF.js";
|
|
12
12
|
import {
|
|
13
13
|
svgDataImageSrc,
|
|
14
14
|
useMediaUrl
|
|
@@ -420,7 +420,8 @@ import {
|
|
|
420
420
|
sanitizeHtmlNodes,
|
|
421
421
|
mediaKindForUrl,
|
|
422
422
|
sanitizeUrl,
|
|
423
|
-
videoEmbedFromIframe
|
|
423
|
+
videoEmbedFromIframe,
|
|
424
|
+
withoutAccessorySectionNodes
|
|
424
425
|
} from "@bendyline/squisq/markdown";
|
|
425
426
|
import { mediaEditValuesFromAttributes, parseMediaEdits } from "@bendyline/squisq/mediaEdit";
|
|
426
427
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -993,8 +994,9 @@ function MarkdownRenderer({
|
|
|
993
994
|
cancelled = true;
|
|
994
995
|
};
|
|
995
996
|
}, [mediaProvider]);
|
|
996
|
-
|
|
997
|
-
|
|
997
|
+
const shown = nodes && withoutAccessorySectionNodes(nodes);
|
|
998
|
+
if (!shown || shown.length === 0) return null;
|
|
999
|
+
return /* @__PURE__ */ jsx6("div", { className: `squisq-md ${className || ""}`, children: renderBlocks(shown, "", {
|
|
998
1000
|
htmlPolicy,
|
|
999
1001
|
linkSchemes,
|
|
1000
1002
|
theme,
|