@gramps-connect/story 0.7.1 → 0.7.2

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.
Files changed (67) hide show
  1. package/dist/editor.js +34 -6
  2. package/dist/editor.js.map +2 -2
  3. package/dist/embed.js +41 -41
  4. package/dist/index.js.map +1 -1
  5. package/dist/map-edit.js.map +1 -1
  6. package/dist/player.js +32 -5
  7. package/dist/player.js.map +2 -2
  8. package/dist/types/editor/DateField.d.ts +3 -3
  9. package/dist/types/editor/MapEditor.d.ts +5 -4
  10. package/dist/types/editor/PhotosField.d.ts +2 -2
  11. package/dist/types/editor/PlaceField.d.ts +4 -4
  12. package/dist/types/editor/PlaceMap.d.ts +2 -2
  13. package/dist/types/editor/PlaceMapDialog.d.ts +4 -4
  14. package/dist/types/editor/StoryEditor.d.ts +7 -7
  15. package/dist/types/editor/index.d.ts +14 -14
  16. package/dist/types/editor/model.d.ts +1 -1
  17. package/dist/types/editor/placeShapes.d.ts +2 -2
  18. package/dist/types/editor/strings.d.ts +1 -1
  19. package/dist/types/editor/translations/de.d.ts +2 -2
  20. package/dist/types/editor/translations/es.d.ts +2 -2
  21. package/dist/types/editor/translations/fr.d.ts +2 -2
  22. package/dist/types/editor/translations/index.d.ts +2 -2
  23. package/dist/types/editor/translations/nl.d.ts +2 -2
  24. package/dist/types/index.d.ts +5 -5
  25. package/dist/types/mapEdit/index.d.ts +3 -3
  26. package/dist/types/mapEdit/mapFile.d.ts +1 -1
  27. package/dist/types/player/MapBackground.d.ts +3 -3
  28. package/dist/types/player/MapModeControl.d.ts +2 -2
  29. package/dist/types/player/StoryPlayer.d.ts +4 -4
  30. package/dist/types/player/TimelineStrip.d.ts +1 -1
  31. package/dist/types/player/dates.d.ts +1 -1
  32. package/dist/types/player/geo.d.ts +1 -1
  33. package/dist/types/player/index.d.ts +10 -10
  34. package/dist/types/version.d.ts +1 -1
  35. package/dist/types/zip.d.ts +3 -3
  36. package/package.json +2 -2
  37. package/src/editor/DateField.tsx +5 -5
  38. package/src/editor/MapEditor.tsx +10 -8
  39. package/src/editor/PhotosField.tsx +2 -2
  40. package/src/editor/PlaceField.tsx +6 -6
  41. package/src/editor/PlaceMap.tsx +5 -5
  42. package/src/editor/PlaceMapDialog.tsx +11 -11
  43. package/src/editor/StoryEditor.tsx +18 -18
  44. package/src/editor/index.ts +14 -14
  45. package/src/editor/mapEditorStrings.ts +1 -1
  46. package/src/editor/model.ts +2 -2
  47. package/src/editor/placeShapes.ts +3 -3
  48. package/src/editor/strings.ts +1 -1
  49. package/src/editor/translations/de.ts +2 -2
  50. package/src/editor/translations/es.ts +2 -2
  51. package/src/editor/translations/fr.ts +2 -2
  52. package/src/editor/translations/index.ts +6 -6
  53. package/src/editor/translations/nl.ts +2 -2
  54. package/src/embed/index.tsx +2 -2
  55. package/src/index.ts +5 -5
  56. package/src/mapEdit/index.ts +3 -3
  57. package/src/mapEdit/mapFile.ts +1 -1
  58. package/src/player/MapBackground.tsx +5 -5
  59. package/src/player/MapModeControl.tsx +2 -2
  60. package/src/player/StoryPlayer.tsx +50 -13
  61. package/src/player/TimelineStrip.tsx +2 -2
  62. package/src/player/dates.ts +1 -1
  63. package/src/player/geo.ts +1 -1
  64. package/src/player/index.ts +10 -10
  65. package/src/validate.ts +2 -2
  66. package/src/version.ts +1 -1
  67. package/src/zip.ts +3 -3
package/dist/editor.js CHANGED
@@ -2441,6 +2441,8 @@ function TimelineStrip({ points, currentIndex, onSelect, colors }) {
2441
2441
  import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
2442
2442
  var PANEL_FRACTION = 0.62;
2443
2443
  var BAR_HEIGHT = 56;
2444
+ var BAR_GAP = 8;
2445
+ var MODE_ROW_HEIGHT = 40;
2444
2446
  function initialMapMode(story) {
2445
2447
  return story.presentation?.basemap === "historical" ? "auto" : "standard";
2446
2448
  }
@@ -2479,7 +2481,7 @@ function SlidePhoto({ mediaKey, item, caption, credit, resolveMedia, colors }) {
2479
2481
  style: { maxHeight: "42vh", maxWidth: "100%", width: "auto", height: "auto", objectFit: "contain", borderRadius: 4 }
2480
2482
  }
2481
2483
  ),
2482
- (caption || credit) && /* @__PURE__ */ jsx4("figcaption", { style: { fontSize: 13, color: colors.muted }, children: [caption, credit && `\xA9 ${credit}`].filter(Boolean).join(" \xB7 ") })
2484
+ (caption || credit) && /* @__PURE__ */ jsx4("figcaption", { style: { fontSize: 13, color: colors.muted }, children: [caption, credit].filter(Boolean).join(" \xB7 ") })
2483
2485
  ] });
2484
2486
  }
2485
2487
  function PhotoThumb({ mediaKey, item, label, selected, onSelect, resolveMedia, colors }) {
@@ -2625,6 +2627,28 @@ function StoryPlayer({
2625
2627
  [story.language, stringOverrides]
2626
2628
  );
2627
2629
  const rootRef = useRef3(null);
2630
+ const titleRef = useRef3(null);
2631
+ const modeRef = useRef3(null);
2632
+ const actionsRef = useRef3(null);
2633
+ const [modeBelowBar, setModeBelowBar] = useState3(false);
2634
+ useEffect3(() => {
2635
+ const root = rootRef.current;
2636
+ if (!root || typeof ResizeObserver === "undefined") return;
2637
+ const check = () => {
2638
+ const mode = modeRef.current;
2639
+ if (!mode) return;
2640
+ const rootBox = root.getBoundingClientRect();
2641
+ const half = mode.offsetWidth / 2;
2642
+ const center = rootBox.width / 2;
2643
+ const titleRight = titleRef.current ? titleRef.current.getBoundingClientRect().right - rootBox.left : 0;
2644
+ const actionsLeft = actionsRef.current ? actionsRef.current.getBoundingClientRect().left - rootBox.left : rootBox.width - 60;
2645
+ setModeBelowBar(center - half < titleRight + BAR_GAP || center + half > actionsLeft - BAR_GAP);
2646
+ };
2647
+ const observer = new ResizeObserver(check);
2648
+ for (const el of [root, titleRef.current, modeRef.current, actionsRef.current]) if (el) observer.observe(el);
2649
+ check();
2650
+ return () => observer.disconnect();
2651
+ }, [story, Boolean(actions), Boolean(onClose)]);
2628
2652
  const slides = story.slides;
2629
2653
  const [index, setIndex] = useState3(initialSlide);
2630
2654
  const slide = slides[index];
@@ -2758,6 +2782,7 @@ function StoryPlayer({
2758
2782
  /* @__PURE__ */ jsxs3(
2759
2783
  "div",
2760
2784
  {
2785
+ ref: titleRef,
2761
2786
  dir: "auto",
2762
2787
  style: {
2763
2788
  position: "absolute",
@@ -2782,22 +2807,23 @@ function StoryPlayer({
2782
2807
  {
2783
2808
  style: {
2784
2809
  position: "absolute",
2785
- top: 0,
2810
+ top: modeBelowBar ? BAR_HEIGHT : 0,
2786
2811
  left: 0,
2787
2812
  right: 0,
2788
- height: BAR_HEIGHT,
2813
+ height: modeBelowBar ? MODE_ROW_HEIGHT : BAR_HEIGHT,
2789
2814
  zIndex: 3,
2790
2815
  display: "flex",
2791
2816
  alignItems: "center",
2792
2817
  justifyContent: "center",
2793
2818
  pointerEvents: "none"
2794
2819
  },
2795
- children: /* @__PURE__ */ jsx4("div", { style: { pointerEvents: "auto" }, children: renderMapModeControl ? renderMapModeControl(modeControlProps) : /* @__PURE__ */ jsx4(MapModeControl, { ...modeControlProps, strings, colors }) })
2820
+ children: /* @__PURE__ */ jsx4("div", { ref: modeRef, style: { pointerEvents: "auto" }, children: renderMapModeControl ? renderMapModeControl(modeControlProps) : /* @__PURE__ */ jsx4(MapModeControl, { ...modeControlProps, strings, colors }) })
2796
2821
  }
2797
2822
  ),
2798
2823
  actions && /* @__PURE__ */ jsx4(
2799
2824
  "div",
2800
2825
  {
2826
+ ref: actionsRef,
2801
2827
  style: {
2802
2828
  position: "absolute",
2803
2829
  top: 0,
@@ -2844,7 +2870,8 @@ function StoryPlayer({
2844
2870
  right: 0,
2845
2871
  width: `${PANEL_FRACTION * 100}%`,
2846
2872
  zIndex: 1,
2847
- padding: `${BAR_HEIGHT}px 32px ${showTimeline ? TIMELINE_HEIGHT : 32}px`,
2873
+ // Below the map-mode switch too, when it has a row of its own.
2874
+ padding: `${BAR_HEIGHT + (modeBelowBar ? MODE_ROW_HEIGHT : 0)}px 32px ${showTimeline ? TIMELINE_HEIGHT : 32}px`,
2848
2875
  boxSizing: "border-box",
2849
2876
  display: "flex",
2850
2877
  flexDirection: "column",
@@ -5166,7 +5193,7 @@ var MapEditor = forwardRef(function MapEditor2({
5166
5193
  for (const overlay of overlaysRef.current) for (const corner of overlay.corners) bounds.extend(corner);
5167
5194
  return bounds.isEmpty() ? null : bounds.toArray().flat();
5168
5195
  },
5169
- async addImage(image) {
5196
+ async addImage(image, name) {
5170
5197
  if (overlaysRef.current.some((o) => o.image === image)) return false;
5171
5198
  const map = mapRef.current;
5172
5199
  if (!map) return false;
@@ -5181,6 +5208,7 @@ var MapEditor = forwardRef(function MapEditor2({
5181
5208
  const draft = {
5182
5209
  id: crypto.randomUUID(),
5183
5210
  image,
5211
+ ...name?.trim() ? { name: name.trim() } : {},
5184
5212
  corners: [
5185
5213
  [topLeft.lng, topLeft.lat],
5186
5214
  [bottomRight.lng, topLeft.lat],