Files
d165d4da06 feat(embed): let a layout=viewer embed opt into drawing (#3154)
* feat(embed): let a layout=viewer embed opt into drawing

`layout=viewer` deactivates the geometry editor, so a host page that embeds
the read-only viewer cannot let the user draw, even though getDrawnFeatures
and featuresChanged (#3021) can read a drawing back.

Add a `draw` URL flag. With `?layout=viewer&draw` the geometry editor is
let through (`isViewerBlockedPlugin`), so `?plugin=geo-editor` or a project
that lists it can open its toolbar. Annotations and GeoAgent stay blocked.
The flag only takes effect when the deployment grants `project:edit`, and
without it nothing changes. `draw` is reserved so it never becomes a tool
parameter in a `?tool=` link.

The viewer also stops offering ways to edit or move data around the
deployment's capability gates: Identify no longer shows Edit geometry or
Edit attributes (this was already reachable in `layout=viewer` before this
change), and the editor toolbar drops its Open/Save file buttons.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(embed): set viewer file-tools flag during render, document drawing readback needs

The geometry editor reads its file-tools flag once at construction, and the
plugin restore and ?plugin= deep link construct it from effects. Setting the
flag from an effect in the guard hook could lose that race against a child's
effect, so set it while rendering, which precedes every effect. Add a render
test for it and record why an empty fileModes list is safe upstream.

Docs: reading drawings back needs the embed allowlist and the export:data
capability, not only project:edit; use a self-hosted placeholder URL in the
drawing example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Address review feedback

- Move the viewer gate on Identify's edit actions into
  useIdentifyEditActions and pass usePluginDeepLink the layout options
  instead of two booleans, so DesktopShell.tsx stays within the
  untested-module growth allowance (it had reached 1341 lines against a
  1334 cap once merged with main), which failed Build and test.
- Note in useViewerPluginGuard that layoutOptions.viewer comes from the
  launch URL and is fixed for the page's lifetime, so the render-time
  file-tools flag can never go stale and needs no reset on unmount.

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: giswqs <giswqs@gmail.com>
2026-10-19 20:58:04 -04:00
..