@gramps-connect/story 0.5.0 → 0.6.1
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/README.md +1 -1
- package/dist/editor.js +11 -7
- package/dist/editor.js.map +3 -3
- package/dist/types/editor/model.d.ts +12 -11
- package/package.json +1 -1
- package/src/editor/MapEditor.tsx +19 -7
- package/src/editor/model.ts +12 -11
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ dependencies `@mantine/core` and `@mantine/hooks`, needed only by the
|
|
|
197
197
|
editor): wrap it in a `MantineProvider` and load Mantine's stylesheet. The
|
|
198
198
|
pieces it's made of (`SlideList`, `StoryTextField`, `DateField`,
|
|
199
199
|
`PlaceField`, `PhotosField`, `MapEditor`, `PlaceMapDialog`) and its editing functions (`addSlide`, `moveSlide`,
|
|
200
|
-
`updateSlide`, `addImage`, undo history, ...) are exported too.
|
|
200
|
+
`updateSlide`, `addImage`, undo history (`History<T>`, for any document), ...) are exported too.
|
|
201
201
|
|
|
202
202
|
## Writing stories from Python: `python/gramps_connect_story.py`
|
|
203
203
|
|
package/dist/editor.js
CHANGED
|
@@ -3802,6 +3802,7 @@ var COLOR_SWATCHES = [
|
|
|
3802
3802
|
"#e0678a",
|
|
3803
3803
|
"#555555"
|
|
3804
3804
|
];
|
|
3805
|
+
var UNSET_OPACITY = 0.25;
|
|
3805
3806
|
var EMPTY_LABEL_PREVIEW = { type: "FeatureCollection", features: [] };
|
|
3806
3807
|
var OVERLAY_ANCHOR_LAYER = "image-overlay-anchor";
|
|
3807
3808
|
var TERRA_DRAW_LAYERS = ["td-polygon", "td-polygon-outline", "td-linestring", "td-point", "td-point-marker"];
|
|
@@ -3905,9 +3906,11 @@ var MapEditor = forwardRef(function MapEditor2({
|
|
|
3905
3906
|
const [color, setColor] = useState7(() => defaultColor ?? defaultColors(dark).mark);
|
|
3906
3907
|
const colorRef = useRef8(color);
|
|
3907
3908
|
colorRef.current = color;
|
|
3908
|
-
const [opacity, setOpacity] = useState7(
|
|
3909
|
+
const [opacity, setOpacity] = useState7(UNSET_OPACITY);
|
|
3909
3910
|
const opacityRef = useRef8(opacity);
|
|
3910
3911
|
opacityRef.current = opacity;
|
|
3912
|
+
const unsetColorRef = useRef8(defaultColor ?? defaultColors(dark).mark);
|
|
3913
|
+
unsetColorRef.current = defaultColor ?? defaultColors(dark).mark;
|
|
3911
3914
|
const [labelText, setLabelText] = useState7("");
|
|
3912
3915
|
const refreshLabelPreviewRef = useRef8(null);
|
|
3913
3916
|
const [selectedId, setSelectedId] = useState7(null);
|
|
@@ -3970,8 +3973,8 @@ var MapEditor = forwardRef(function MapEditor2({
|
|
|
3970
3973
|
map.dragRotate.disable();
|
|
3971
3974
|
map.touchZoomRotate.disableRotation();
|
|
3972
3975
|
map.keyboard.disableRotation();
|
|
3973
|
-
const readColor = (feature) => feature.properties.color ??
|
|
3974
|
-
const readOpacity = (feature) => feature.properties.opacity ??
|
|
3976
|
+
const readColor = (feature) => feature.properties.color ?? unsetColorRef.current;
|
|
3977
|
+
const readOpacity = (feature) => feature.properties.opacity ?? UNSET_OPACITY;
|
|
3975
3978
|
const draw = new TerraDraw({
|
|
3976
3979
|
adapter: new TerraDrawMapLibreGLAdapter({ map }),
|
|
3977
3980
|
modes: [
|
|
@@ -4060,8 +4063,8 @@ var MapEditor = forwardRef(function MapEditor2({
|
|
|
4060
4063
|
const feature = id ? draw.getSnapshot().find((f) => String(f.id) === id) : void 0;
|
|
4061
4064
|
setLabelText(feature?.properties?.name ?? "");
|
|
4062
4065
|
if (feature) {
|
|
4063
|
-
setColor(feature.properties?.color ??
|
|
4064
|
-
setOpacity(feature.properties?.opacity ??
|
|
4066
|
+
setColor(feature.properties?.color ?? unsetColorRef.current);
|
|
4067
|
+
setOpacity(feature.properties?.opacity ?? UNSET_OPACITY);
|
|
4065
4068
|
setSelectedOverlayId(null);
|
|
4066
4069
|
}
|
|
4067
4070
|
}
|
|
@@ -4471,12 +4474,13 @@ var MapEditor = forwardRef(function MapEditor2({
|
|
|
4471
4474
|
getResult() {
|
|
4472
4475
|
const savedParts = (drawRef.current?.getSnapshot() ?? []).filter((f) => f.geometry != null && !f.properties?.selectionPoint && !f.properties?.midPoint).map((f) => {
|
|
4473
4476
|
const name = f.properties?.name?.trim();
|
|
4474
|
-
const regionOpacity = f.geometry.type === "Polygon" ? f.properties?.opacity
|
|
4477
|
+
const regionOpacity = f.geometry.type === "Polygon" ? f.properties?.opacity : void 0;
|
|
4478
|
+
const color2 = f.properties?.color;
|
|
4475
4479
|
const sourceKey = f.properties?.sourceKey;
|
|
4476
4480
|
return {
|
|
4477
4481
|
...typeof sourceKey === "string" ? { sourceKey } : {},
|
|
4478
4482
|
geometry: f.geometry,
|
|
4479
|
-
color:
|
|
4483
|
+
...color2 !== void 0 ? { color: color2 } : {},
|
|
4480
4484
|
...name ? { name } : {},
|
|
4481
4485
|
...regionOpacity !== void 0 ? { opacity: regionOpacity } : {}
|
|
4482
4486
|
};
|