From bb221109f1ce332336e2c92fceed526481b0a61e Mon Sep 17 00:00:00 2001 From: airslice Date: Wed, 25 Sep 2024 13:29:32 +0800 Subject: [PATCH 1/7] refactor: support edit sketch geometry on editor --- .../LayerInspector/FeatureInspector/index.tsx | 71 ++++++++-- .../InspectorPanel/LayerInspector/index.tsx | 24 +++- .../Editor/Map/InspectorPanel/index.tsx | 10 +- web/src/beta/features/Editor/Map/context.tsx | 6 +- .../beta/features/Editor/Visualizer/index.tsx | 6 + web/src/beta/features/Editor/hooks/index.ts | 28 +++- .../beta/features/Editor/hooks/useSketch.ts | 131 +++++++++++++++--- web/src/beta/features/Editor/index.tsx | 7 +- .../Visualizer/Crust/Plugins/hooks/index.ts | 2 + .../Crust/Plugins/hooks/useSketch.ts | 19 ++- .../Crust/Plugins/pluginAPI/types/sketch.ts | 1 + .../Visualizer/Crust/Plugins/types.ts | 1 + .../beta/features/Visualizer/Crust/index.tsx | 2 + web/src/beta/features/Visualizer/index.tsx | 6 + 14 files changed, 270 insertions(+), 44 deletions(-) diff --git a/web/src/beta/features/Editor/Map/InspectorPanel/LayerInspector/FeatureInspector/index.tsx b/web/src/beta/features/Editor/Map/InspectorPanel/LayerInspector/FeatureInspector/index.tsx index ccba0c1f1d..ded4c43b88 100644 --- a/web/src/beta/features/Editor/Map/InspectorPanel/LayerInspector/FeatureInspector/index.tsx +++ b/web/src/beta/features/Editor/Map/InspectorPanel/LayerInspector/FeatureInspector/index.tsx @@ -25,6 +25,10 @@ type Props = { sketchFeature?: SketchFeature; onGeoJsonFeatureUpdate?: (inp: GeoJsonFeatureUpdateProps) => void; onGeoJsonFeatureDelete?: (inp: GeoJsonFeatureDeleteProps) => void; + isEditingGeometry?: boolean; + onSketchGeometryEditStart?: () => void; + onSketchGeometryEditApply?: () => void; + onSketchGeometryEditCancel?: () => void; }; export type ValueProp = string | number | boolean | undefined; @@ -40,7 +44,11 @@ const FeatureData: FC = ({ layer, sketchFeature, onGeoJsonFeatureUpdate, - onGeoJsonFeatureDelete + onGeoJsonFeatureDelete, + isEditingGeometry, + onSketchGeometryEditStart, + onSketchGeometryEditApply, + onSketchGeometryEditCancel }) => { const t = useT(); const theme = useTheme(); @@ -110,6 +118,7 @@ const FeatureData: FC = ({ newProperties, ...fields.map((f) => ({ [f.title]: f.value })) ); + onGeoJsonFeatureUpdate?.({ layerId: layer.id, featureId: sketchFeature.id, @@ -144,6 +153,44 @@ const FeatureData: FC = ({ return ( + {!!layer?.isSketch && sketchFeature?.id && ( + + + {isEditingGeometry ? ( + <> +