# Newsletter editor UI integration, local contributor

This unit extends the separately reviewed server foundation on the accepted
local #2957 integration target `316174719085440548a6df255e35b3b3faaa8379`.
The editor session owns `/var/www/nuhet-editor-ui-3967`, branch
`codex/3967-editor-ui`; the parent branch/worktree is read only.
No publication, deployment, cohort activation, real send or customer database
migration is part of this contributor unit.

## Implemented boundary

The default remains disabled with an empty company allowlist in
`config/newsletter_editor.php`. Opted-in authorized companies see an additional
draft entry on either newsletter list design. Existing newsletter actions and
the Angular/TinyMCE editor remain available. Draft data stays in its own tables.

- `/newsletter-editor`: own-company draft list, paginated to 20 rows.
- `/newsletter-editor/create` and `/newsletter-editor/open/{id}`: full-width
  workspace, draft name, save status, saved preview and history metadata.
- `POST /newsletter-editor/render`: same pinned server compiler as persistence;
  compiling alone creates no draft or revision.
- The SDK palette and font/settings options are restricted to the server
  contract. The seven native types support bounded borders/radii, visibility,
  image links, paragraph spacing and percentage dividers. Raw blocks, nested
  sections, wrapper frames, custom fonts/conditions and unsafe URLs/styles remain
  rejected. Server validation remains authoritative for every field and block.
  Rich-text validation compares parsed trees with sanitized trees, accepting
  native formatting whitespace while rejecting any removed tag/attribute/style.
  Pipeline identity is `nuhet-templatical-0.46.0-mjml-5.4.0-v2` for this expanded
  validated native contract; earlier saved artifacts retain their own identity.
- Save uses the acknowledged revision; stale writes keep local edits and show
  a conflict. Session expiry preserves local content. Concurrent saves and
  ambiguous first-write replay are prevented. Structural fingerprints ignore
  object-key ordering while retaining content/array order, including edits made
  during a request.
- Phone UI presents saved status/history/preview and the default SDK larger-
  screen notice. Authoring remains desktop/larger-tablet only for the local
  spike. This is not a waiver of final phone-authoring or pilot acceptance.

## Build and source boundary

Existing application assets: root `npm ci && npm run production`.
Isolated editor assets: `cd tools/newsletter-editor && npm ci && npm run build`.
The latter produces ignored, reproducible `public/newsletter-editor/` assets.
It also retains the editor's full license text alongside the bundle and adds
content-hash versions to the existing Mix manifest, preserving its other entries.
Always build the root application first, then the isolated editor. The
renderer still has its own independently pinned package and build/runtime path.

The editor is built from source tag `v0.46.0`, commit
`22f9c68ab10e09058437d4085fdef05e2175bfe0`, tree
`007d90b4494f99b8df733f959f91625a01266986`. The same pinned published package is
retained as a dependency reference; the bundle aliases explicitly select the
patched source build, including its stylesheet. The actual license is **FSL-1.1-MIT with the
additional embedding permission**, not the renderer's MIT license. Its examples
explicitly include embedded newsletter products and customization. Preserve
license/copyright notices. No paid license or external fork has been created.

The published package has no Swedish locale or runtime registration API. The
tracked additive patch supplies 531 translated SDK keys and six recipient-facing
defaults, with exact key/interpolation parity and English retained. Preparation
fails on a missing translation or unexpected source modification. The workspace
also refuses unsupported locales explicitly. A third tiny source patch hides
decorative-image mode: that mode emits an MJML attribute rejected by the pinned
strict compiler. Images require descriptions; server validation rejects attempts
to enable unsupported decorative output. No validation error is suppressed.

Acquire the exact source using the approved `Invoke-WslGitHub.ps1`, Access Read,
repository `templatical/sdk`, `git clone --depth 1 --branch v0.46.0`, into this
tool's ignored `upstream/` directory. Never substitute direct network Git/HTTP.
In that source directory install the immutable workspace lock with
`npm exec --yes --package=pnpm@12.11.2 -- pnpm install --frozen-lockfile --ignore-scripts --filter @templatical/editor...`.
Then, from this tool directory, run `npm run build:sdk`, followed by `npm run build`.
`upstream.json` retains source tree, lock/license/locale hashes and tool versions;
`patches/` retains the exact minimal source changes and `licenses/` the full terms.
This builds a private application dependency, not a published SDK package.

## Verification and cleanup

`php vendor/phpunit/phpunit/phpunit tests/Feature/NewsletterEditorDraftTest.php`
checks real PHP-to-Node persistence/rendering, permissions, tenant isolation,
workspace output escaping and opt-in entry visibility. Node's test runner also
checks the browser adapter's request/revision/error semantics.

The independent review of frozen `6759ba35` found four ordinary authoring/
recovery defects. Its original report and frozen receipts are retained in the
approved scratch folder. Corrections allow only hex6/RGB color on native rich-
text anchors, align button font sizes to the visible 10–36px controls, and define
optional background Clear as removing the property. The maintained source
profile hides Clear for required colors, retains it for optional/inherited
colors, uses transparent for an unset button fill, and bounds neighboring
template width, image size, border width and spacing controls to the server
contract. Server rejection of unsafe declarations, URLs and unknown fields
remains strict; it does not silently sanitize away author content.

Each mounted page carries an authenticated encrypted actor/company context.
The editor API verifies that context when supplied, including on writes. After
a definite session-expired response, the next explicit save obtains a fresh
CSRF token from the authenticated, opt-in, no-store `/newsletter-editor/session`
endpoint only if the original actor and company still match. It never retries
a write automatically. An unacknowledged first create remains latched for any
network/body/identity failure or potentially committed server error, including
malformed successful JSON, so another click cannot create a duplicate draft.

`cd tools/newsletter-editor && node verify-native.mjs` launches only an owned
loopback PHP process and headless Chromium, with a fresh exact-identity SQLite
fixture under `K:\AI_docs_tmp\nuhet-3967-editor`. It checks ordinary application
routes through a test-only router. Authentication is explicitly synthetic;
production auth is unchanged and its separate feature tests remain required.
All connection aliases are guarded to the same owned database before writes.
The router is outside `public/`, rejects unrelated mutation routes, and never
serves PHP files as static assets. The finite harness closes browser/server and
removes only its uniquely marked directory, recording absence after cleanup.

`NUHET_EDITOR_VERIFY_REVIEW_FIXES=1 node verify-native.mjs` adds a focused
mounted-control/session check using real Laravel file sessions, browser cookies,
CSRF rejection, second-tab session bootstrap and original-page recovery. Its
test-only login/invalidation route lives solely in the guarded fixture router;
it uses disposable users and no production credentials or login form. It also
checks refusal of different actors/tenants and corrupts a real committed201
acknowledgment to verify that a second click sends no duplicate create. This
supplements the normal Sv/En, keyboard, phone and asset receipts above.

Retain original failure and corrected receipts; do not claim before screenshots
from a fixture-induced legacy load error. A valid comparison requires the actual
legacy data-read routes to succeed on the isolated fixture. Source/evidence
bindings, native desktop/phone/tablet captures, saved Swedish copy, actual asset
MIME/status checks and a fresh independent UI reviewer are required before this
unit can be accepted. The original server review is reused only for unchanged
boundaries; the new render endpoint and warning response are reviewed with UI.

## Open acceptance

The local checks include a combined PHP suite (1,229 tests / 9,410 assertions,
one existing configuration deprecation), compiler/adapter tests, upstream locale
key/interpolation tests and real Sv/En native browser receipts. Browser evidence
includes exact replacement and bold formatting of an inserted paragraph,
save/reopen, keyboard save, stale-tab protection, history, ordinary asset
status/MIME, phone saved preview and 820px layout. The phone notice is hidden
while a saved preview/history panel is open, without enabling phone authoring.

Visual comparisons and complete change records are under
`K:\AI_docs_tmp\nuhet-3967-editor`. The workspace before image shows the actual
unchanged legacy starter chooser with an empty synthetic template catalog, not a
customer newsletter. The entry comparison renders the actual shared Blade
component in a labeled isolated header harness; it is not a full-page newsletter
list capture. These limits are retained in the change records. Native captures
have original desktop/phone dimensions and capture-time hashes. No screenshot
is a resized desktop substituted for phone evidence.

Root accepted the bounded UI contributor54e268. Revision4's local media,
restoration and duplication extension is documented in
`newsletter-editor-lifecycle-media-3967.md`; its independent evidence and root
acceptance remain a separate unit. Also open: publication/shared
output integration, three real Nuhet templates including social/video, byte-
equivalence before substitutions, and the original email-client/dark/blocked-
image matrix. The accepted54 UI lists revision metadata without restore controls;
revision4 adds explicit saved-draft actions. No existing newsletter conversion is implied. Server
lint remains authoritative, with translated host messages; the SDK's separate
client lint panel is disabled to avoid a second compiler/locale path.

See `newsletter-editor-3967.md` for the original server contract, safeguards and
maintenance recommendations. Its historical no-browser/no-process statements
describe that earlier server-only unit; parent decision revision3 explicitly
authorizes the isolated native browser harness above, while Computer Use and
desktop Chrome connector authority remain absent.

In this combined base `routes/web.php` is 830 lines and the unchanged legacy
`public/js/editor/editorapp.js` is 1,361. The earlier historical server base's
route count is not this target's count. Retain the suggested later extraction of
customer/admin/public route groups and legacy state/network versus block modules,
with route/security and Angular registration checks. No broad refactor is part
of this unit. The generated Swedish locale is 646 lines; new handwritten modules
remain bounded. Lockfiles and generated locale patches are data/build artifacts.
