Skip to content

Restore thin scalar inline-edit helper (formerly useEditable) #2

@developer-1px

Description

@developer-1px

Context

zod-admin-ui (https://github.com/developer-1px/zod-admin-ui) used useEditable<T>({ getValue, onCommit }) from @p/anyeditable v0.4.x for scalar inline editing — the double-click-to-edit pattern over a single string value backed by a zod-crud RFC 6902 pointer.

After v0.5 migration to block-based composer, useEditable no longer exports. The new useEditableSurface / useEditableDocumentSurface operate over ComposerDoc (multi-block document) — overkill for a single scalar that lives at a JSON Pointer in an external doc.

Missing surface

useEditable<Id>({
  getValue: (id) => string,
  onCommit: (id, next: string) => void,
}): {
  editing: Id | null
  inputProps: React.InputHTMLAttributes<HTMLInputElement>  // onBlur=commit, Enter=commit, Esc=cancel
  startEdit: (id: Id) => void
}

Why thin shape matters

For NCloud-style admin we have hundreds of leaf strings (headline, eyebrow, button labels) edited inline within a preview tree. Each leaf is one JSON pointer of an external doc — not a block document. Spinning up useEditableSurface per leaf is wrong layer.

Asks

  1. Restore (or add) a thin useEditable scalar helper alongside the block surface.
  2. Or document the canonical pattern for "edit one string at a JSON pointer" in admin context.

Impacted consumer code

  • src/auto/preview/inline-edit/EditableText.tsx
  • src/auto/preview/inline-edit/useDocEditable.ts

We are using a local thin replacement until this surface returns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions