@element-editor/react 0.2.1 → 0.2.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.
package/AGENTS.md CHANGED
@@ -30,12 +30,14 @@ React and React DOM `^19.2` are required everywhere (React 18 is not supported).
30
30
  | Peer | Range |
31
31
  |---|---|
32
32
  | `react`, `react-dom` | `^19.2.0` |
33
- | `maplibre-gl` | 5.5 or 6 (default entry, MapLibre adapter) |
33
+ | `maplibre-gl` | `^5.5.0 \|\| ^6.0.0` (default entry, MapLibre adapter) |
34
34
  | `leaflet` | `^1.9.0` (`/leaflet` entry, Leaflet adapter) |
35
35
  | `react-leaflet` | `^5.0.0` (`/leaflet` entry, Leaflet adapter) |
36
36
 
37
37
  `@element-editor/react` brings `@element-editor/core`, `@element-editor/ui` and `@element-editor/adapter-maplibre` as dependencies and re-exports the common types, so you rarely import those directly. With pnpm, add any `@element-editor/*` package you import from to your own `package.json`, on the same version.
38
38
 
39
+ MapLibre GL JS 6 (what a plain `maplibre-gl` install gets) loads its worker from a separate file, `maplibre-gl-worker.mjs`. The MapLibre drop-in sets it for you before creating its map: `config.network.maplibreWorker` (default: the jsDelivr copy of your installed version; a URL to self-host it; `false` = your app calls MapLibre's `setWorkerUrl`; a URL your app already set is left alone). With the default, a Content-Security-Policy needs `script-src https://cdn.jsdelivr.net` and `worker-src blob:`. The MapLibre adapter never creates the map, so on MapLibre 6 your app calls `setWorkerUrl` itself (see `node_modules/@element-editor/adapter-maplibre/AGENTS.md`). MapLibre 5 has the worker built in.
40
+
39
41
  ## CSS
40
42
 
41
43
  Import exactly one stylesheet, once (app entry or root layout). The JS entries import no CSS.
@@ -129,6 +131,9 @@ import * as maplibregl from 'maplibre-gl'
129
131
  import 'maplibre-gl/dist/maplibre-gl.css'
130
132
  import { ElementEditorUIProvider, GeoStoreProvider, ElementEditorControls } from '@element-editor/adapter-maplibre'
131
133
  import '@element-editor/adapter-maplibre/style.css'
134
+ // MapLibre GL JS 6 with Vite: the adapter doesn't set MapLibre's worker (delete on MapLibre 5)
135
+ import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'
136
+ maplibregl.setWorkerUrl(workerUrl)
132
137
 
133
138
  export default function MyMap() {
134
139
  const containerRef = useRef<HTMLDivElement>(null)
@@ -395,16 +400,17 @@ Removed or renamed in 0.2 (https://elementeditor.dev/docs/guides/migrating-to-0.
395
400
  - **No stylesheet, or the wrong one.** Unstyled panels, missing controls, broken tiles. One stylesheet per entry (table above); MapLibre adapter also needs `maplibre-gl.css`.
396
401
  - **Zero-height parent.** The root is 100% of its parent. Give the parent a height (`height: 600`, `100vh`, or `flex: 1; min-height: 0` in a flex column).
397
402
  - **Coordinate order.** Element's API (data, `initialView.center`, `bounds`, `flyTo({ center })`, `fitBounds`) is GeoJSON `[lng, lat]`. Leaflet and react-leaflet (`MapContainer center`, `L.latLng`) are `[lat, lng]`. Convert at the boundary.
398
- - **Missing or wrong peers.** `maplibre-gl` must be installed for the default entry (5.5 or 6); `@element-editor/adapter-leaflet`, `leaflet ^1.9` and `react-leaflet ^5` for `/leaflet`. React 18 and react-leaflet 4 do not work.
403
+ - **Missing or wrong peers.** `maplibre-gl` must be installed for the default entry (`^5.5.0 || ^6.0.0`); `@element-editor/adapter-leaflet`, `leaflet ^1.9` and `react-leaflet ^5` for `/leaflet`. React 18 and react-leaflet 4 do not work.
399
404
  - **SSR.** Render client-only (`next/dynamic` with `ssr: false`); `'use client'` alone is not enough.
400
405
  - **Expecting `initialData` to be reactive.** Use the ref or a `key` remount (see Loading and saving data).
406
+ - **Blank map with the MapLibre adapter on MapLibre 6.** Your app must call `setWorkerUrl` before creating the map (the drop-in does it for you).
401
407
  - **Adapters without providers.** `ElementEditorControls` throws outside `ElementEditorUIProvider`; it also needs a `GeoStoreProvider` (one per editor) and a `data-elm-theme="light" | "dark"` ancestor containing the map and all editor UI. Portaled UI of your own needs a `data-elm-portal` attribute.
402
408
  - **`onEvent` set "just to log".** It silences every built-in toast. Use `onError` for logging.
403
409
  - **Unstable `getFeatureStyle` or id-less inline basemap objects.** A new function re-sends every feature; a new id-less style object counts as a new basemap. Define them at module level or memoise.
404
410
  - **Your own `map.setStyle()` on the MapLibre drop-in.** It drops your layers (Element restores its own). Switch basemaps with `basemap` / `ref.setBasemap()`, which keep your layers; images added with `map.addImage` are never kept across a style change.
405
411
  - **Several editors on one origin.** They share `elm_*` localStorage keys (theme, view, basemap pick). Set `config.persistKey` per editor, or `config.persist: false`.
406
412
  - **The map reopens where the user left it**, not at your data. Pass `initialView` (`'data'` to always fit `initialData`).
407
- - **Production traffic on public services.** Defaults are OpenFreeMap/Mapterhorn tiles, Overpass, the OSRM demo router (car-only, not for production) and Nominatim. Configure `config.network` (https://elementeditor.dev/docs/guides/third-party-services).
413
+ - **Production traffic on public services.** Defaults are OpenFreeMap/Mapterhorn tiles, Overpass, the OSRM demo router (car-only, not for production), Nominatim, and jsDelivr for the sprite and the MapLibre 6 worker. Configure `config.network` (https://elementeditor.dev/docs/guides/third-party-services).
408
414
  - **Importing `@element-editor/ui/internal`.** Not covered by semver.
409
415
 
410
416
  ## Docs