CWA 2 is a prerelease (2.0.0-alpha), heading for a beta. It runs production sites; configuration can still change between releases, always with upgrade notes. View versions and support
Cwa Api

cwa.admin

Admin edit mode, the component selection stack, the internal event bus, and the navigation guard.

Controls admin edit mode and the component selection stack. Mostly used internally, but exposed for custom admin UIs.

cwa.admin.isEditing              // boolean (reactive, no .value) — whether edit mode is on
cwa.admin.toggleEdit(true)       // open edit mode
cwa.admin.toggleEdit(false)      // close edit mode
cwa.admin.toggleEdit()           // toggle
cwa.admin.emptyStack()           // clear the selected component stack
cwa.admin.emitRedraw()           // force re-render of the component overlay
cwa.admin.setNavigationGuardDisabled(true) // turn the edit-mode navigation block off (false turns it back on)
cwa.admin.navigationGuardDisabled          // boolean — whether the block has been turned off

Event Bus

cwa.admin.eventBus is a global mitt emitter that the admin uses to coordinate between the resource manager, the focus overlay, and the components on the page.

These are internal events and may change without notice. They exist to wire the admin UI together, not as a public integration point — event names, payload shapes, and firing conditions can be added, renamed, or removed in any release, including patch releases, with no deprecation period. Nothing here follows the module's public API contract. If you depend on one, pin your module version and re-test on every upgrade.
const cwa = useCwa()

const onSelect = (iri: string) => console.log('selected', iri)

onMounted(() => cwa.admin.eventBus.on('selectResource', onSelect))
onBeforeUnmount(() => cwa.admin.eventBus.off('selectResource', onSelect))

The full surface is mitt's — on, off, emit, the '*' wildcard, and the raw all handler Map. There is no once, and on() returns nothing rather than an unsubscribe function, so keep a reference to your handler and pass the same function to off(). Calling off(type) with no handler removes every listener for that event, including the module's own.

Events

EventPayloadFired when
manageableComponentMountedstring — resource IRIA component using the resource manager mounts.
componentMountedstring — resource IRIA component mounts with the manager disabled, a placeholder or hotspot mounts, or a parent re-emits as the mount cascades up the tree.
selectResourcestring — resource IRIA resource should become the admin's selection — a newly added component, or an admin jumping to the component behind a page-data position.
reorderReorderEventAn admin changes a component's order, via the up/down buttons or by typing an order number.
redrawFocusundefinedThe focus overlay needs redrawing — after mounts, on window resize, and when the manager opens or closes. Emit with no second argument.

ReorderEvent is the one payload type the module exports:

import type { ReorderEvent } from '#cwa/admin/admin'

type ReorderEvent = {
  positionIri: string
  location: 'previous' | 'next' | number
}

A location of 'previous' or 'next' moves the position one step; a number sets an absolute position and is 1-based. Groups that aren't reordering ignore the event, so it is safe to broadcast.

Caveats

Beyond the "may change without notice" warning above, a few behaviours are easy to trip over:

  • Mount events fire for every visitor, but only the admin listens. The initial emit in useCwaResource has no admin guard. What is admin-only is the listener side: the handler that re-emits componentMounted as the mount cascades up the tree is only registered for signed-in admins, so the cascade you see while editing is not what a visitor's page emits.
  • componentMounted payloads aren't always resource IRIs. Placeholders and hotspots emit <iri>_placeholder, so don't feed the payload straight into getResource() without checking.
  • redrawFocus is throttled to 40ms. Emitting it in a tight loop won't produce a redraw per call.
  • The events map isn't exported. Handlers passed inline to on() are still type-checked and narrowed correctly, and an unknown event name is a compile error — but to type a standalone handler you'll need to hand-write the signature ((iri: string) => void) or import ReorderEvent.

While edit mode is on, the admin blocks programmatic router navigation (push, replace, go, back, forward) so you can't leave a page mid-edit. That includes <NuxtLink> clicks, which go through router.push. The browser's own back and forward buttons, and query-only changes on the same path, are not blocked.

cwa.navigationDisabled                          // boolean (reactive, no .value) — isEditing && guard not disabled
cwa.adminNavigationGuardFn                      // already applied by the module's global route middleware
No confirmation dialog is shown — the navigation is simply refused (the guard returns false). To navigate anyway, add ?cwa_force=true to the target route or call cwa.admin.setNavigationGuardDisabled(true).

The guard then removes cwa_force from the URL with one redirect. It does this for any value, but only true bypasses the block. Keep cwa_force out of any cache query allowlist: see Query parameters on pages.

Separately, navigating away while a component is being added, before it's saved, opens a dialog asking whether to discard it. Cancel it and the navigation is refused. This check runs on every navigation, whether or not edit mode's guard is on.