Adds inline visual editing to Payload live preview. Editors click an Edit control in the admin document bar, then change text directly in the preview, and the changes sync to the admin form. Clicking Done saves a draft. A frontend listener component matches rendered text to field values automatically, so no data attributes are needed. Requires Payload 3, live preview configured on the collection, and the listener mounted in the preview layout.
Inline visual editing for Payload CMS live preview (text fields)
Installation
npm i payload-plugin-visual-editor7
Stars
0
Forks
1
Open Issues
5 months ago
Last Updated
17
Weekly Downloads
v1.0.4
npm Version
235.8 KB
Unpacked Size
1
Dependencies
7+2 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 7 |
| Dec 5, 2026 | 7 |
| Dec 4, 2026 | 7 |
| Dec 3, 2026 | 7 |
| Dec 2, 2026 | 7 |
| Dec 1, 2026 | 6 |
| Nov 30, 2026 | 6 |
| Nov 29, 2026 | 6 |
| Nov 28, 2026 | 6 |
| Nov 27, 2026 | 6 |
| Nov 26, 2026 | 6 |
| Nov 25, 2026 | 6 |
| Nov 24, 2026 | 6 |
| Nov 23, 2026 | 6 |
| Nov 22, 2026 | 6 |
| Nov 21, 2026 | 6 |
| Nov 20, 2026 | 6 |
| Nov 19, 2026 | 6 |
| Nov 18, 2026 | 6 |
| Nov 17, 2026 | 6 |
| Nov 16, 2026 | 6 |
| Nov 15, 2026 | 6 |
| Nov 14, 2026 | 6 |
| Nov 13, 2026 | 6 |
| Nov 12, 2026 | 6 |
| Nov 11, 2026 | 6 |
| Nov 10, 2026 | 6 |
| Nov 9, 2026 | 5 |
| Nov 8, 2026 | 5 |
| Nov 7, 2026 | 5 |
| Nov 6, 2026 | 5 |
| Nov 5, 2026 | 5 |
| Nov 4, 2026 | 5 |
| Nov 3, 2026 | 5 |
| Nov 2, 2026 | 5 |
| Nov 1, 2026 | 5 |
| Oct 31, 2026 | 5 |
| Oct 30, 2026 | 5 |
| Oct 29, 2026 | 5 |
| Oct 28, 2026 | 5 |
| Oct 27, 2026 | 5 |
| Oct 26, 2026 | 5 |
| Oct 25, 2026 | 5 |
| Oct 24, 2026 | 5 |
| Oct 23, 2026 | 5 |
| Oct 22, 2026 | 5 |
| Oct 21, 2026 | 5 |
| Oct 20, 2026 | 5 |
| Oct 19, 2026 | 5 |
| Oct 18, 2026 | 5 |
| Oct 17, 2026 | 5 |
| Oct 16, 2026 | 5 |
| Oct 15, 2026 | 5 |
| Oct 14, 2026 | 5 |
| Oct 13, 2026 | 5 |
| Oct 12, 2026 | 5 |
| Oct 11, 2026 | 5 |
| Oct 10, 2026 | 5 |
| Oct 9, 2026 | 5 |
| Oct 8, 2026 | 5 |
| Oct 7, 2026 | 5 |
| Oct 6, 2026 | 5 |
| Oct 5, 2026 | 5 |
| Oct 4, 2026 | 5 |
| Oct 3, 2026 | 5 |
| Oct 2, 2026 | 5 |
| Oct 1, 2026 | 5 |
| Sep 30, 2026 | 5 |
| Sep 29, 2026 | 5 |
| Sep 28, 2026 | 5 |
| Sep 27, 2026 | 5 |
| Sep 26, 2026 | 5 |
| Sep 25, 2026 | 5 |
| Sep 24, 2026 | 5 |
| Sep 23, 2026 | 5 |
| Sep 22, 2026 | 5 |
| Sep 21, 2026 | 5 |
| Sep 20, 2026 | 5 |
| Sep 19, 2026 | 5 |
| Sep 18, 2026 | 5 |
| Sep 17, 2026 | 5 |
| Sep 16, 2026 | 5 |
| Sep 15, 2026 | 5 |
| Sep 14, 2026 | 5 |
| Sep 13, 2026 | 5 |
| Sep 12, 2026 | 5 |
| Sep 11, 2026 | 5 |
| Sep 10, 2026 | 5 |
| Sep 9, 2026 | 5 |
| Sep 8, 2026 | 5 |
| Sep 7, 2026 | 5 |
17−21 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 17 |
| Dec 5, 2026 | 12 |
| Dec 4, 2026 | 7 |
| Dec 3, 2026 | 9 |
| Dec 2, 2026 | 12 |
| Dec 1, 2026 | 15 |
| Nov 30, 2026 | 15 |
| Nov 29, 2026 | 10 |
| Nov 28, 2026 | 11 |
| Nov 27, 2026 | 11 |
| Nov 26, 2026 | 15 |
| Nov 25, 2026 | 12 |
| Nov 24, 2026 | 9 |
| Nov 23, 2026 | 9 |
| Nov 22, 2026 | 11 |
| Nov 21, 2026 | 10 |
| Nov 20, 2026 | 11 |
| Nov 19, 2026 | 10 |
| Nov 18, 2026 | 11 |
| Nov 17, 2026 | 13 |
| Nov 16, 2026 | 15 |
| Nov 15, 2026 | 19 |
| Nov 14, 2026 | 20 |
| Nov 13, 2026 | 25 |
| Nov 12, 2026 | 28 |
| Nov 11, 2026 | 28 |
| Nov 10, 2026 | 27 |
| Nov 9, 2026 | 29 |
| Nov 8, 2026 | 30 |
| Nov 7, 2026 | 44 |
| Nov 6, 2026 | 40 |
| Nov 5, 2026 | 36 |
| Nov 4, 2026 | 39 |
| Nov 3, 2026 | 41 |
| Nov 2, 2026 | 72 |
| Nov 1, 2026 | 70 |
| Oct 31, 2026 | 59 |
| Oct 30, 2026 | 63 |
| Oct 29, 2026 | 59 |
| Oct 28, 2026 | 54 |
| Oct 27, 2026 | 65 |
| Oct 26, 2026 | 36 |
| Oct 25, 2026 | 34 |
| Oct 24, 2026 | 49 |
| Oct 23, 2026 | 42 |
| Oct 22, 2026 | 60 |
| Oct 21, 2026 | 76 |
| Oct 20, 2026 | 68 |
| Oct 19, 2026 | 70 |
| Oct 18, 2026 | 75 |
| Oct 17, 2026 | 62 |
| Oct 16, 2026 | 66 |
| Oct 15, 2026 | 52 |
| Oct 14, 2026 | 40 |
| Oct 13, 2026 | 42 |
| Oct 12, 2026 | 40 |
| Oct 11, 2026 | 36 |
| Oct 10, 2026 | 34 |
| Oct 9, 2026 | 35 |
| Oct 8, 2026 | 45 |
| Oct 7, 2026 | 52 |
| Oct 6, 2026 | 49 |
| Oct 5, 2026 | 72 |
| Oct 4, 2026 | 73 |
| Oct 3, 2026 | 75 |
| Oct 2, 2026 | 85 |
| Oct 1, 2026 | 88 |
| Sep 30, 2026 | 89 |
| Sep 29, 2026 | 112 |
| Sep 28, 2026 | 89 |
| Sep 27, 2026 | 95 |
| Sep 26, 2026 | 98 |
| Sep 25, 2026 | 90 |
| Sep 24, 2026 | 85 |
| Sep 23, 2026 | 83 |
| Sep 22, 2026 | 77 |
| Sep 21, 2026 | 76 |
| Sep 20, 2026 | 72 |
| Sep 19, 2026 | 161 |
| Sep 18, 2026 | 177 |
| Sep 17, 2026 | 244 |
| Sep 16, 2026 | 258 |
| Sep 15, 2026 | 253 |
| Sep 14, 2026 | 254 |
| Sep 13, 2026 | 253 |
| Sep 12, 2026 | 162 |
| Sep 11, 2026 | 144 |
| Sep 10, 2026 | 70 |
| Sep 9, 2026 | 52 |
| Sep 8, 2026 | 38 |
| Sep 7, 2026 | 38 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1241429177-root)<a href="https://payloaddirectory.dev/plugins/1241429177-root"><img src="https://payloaddirectory.dev/badge/1241429177-root.svg" alt="Payload Directory"></a>README
Inline visual editing for Payload CMS live preview.

Edit text directly in the preview iframe. Changes sync back to the admin document form and save as a draft when you click Done.
data-* attributes or field wrappers in your frontendtext-transform: uppercase on titles)^3.84.0@payloadcms/ui and @payloadcms/live-preview (peer dependencies)VisualEditorListener mounted in the frontend layout used for preview URLspnpm add payload-plugin-visual-editor
import { payloadVisualEditor } from 'payload-plugin-visual-editor'
export default buildConfig({
plugins: [
payloadVisualEditor({
collections: {
// Enable all editable field types for this collection
articles: true,
// Or restrict which fields can be edited in the preview
'static-pages': {
excludeFields: ['slug'],
},
// Allowlist only specific paths
pages: {
fields: ['title', 'hero.body'],
},
},
// Optional — defaults to text, textarea, number, richText
editableFieldTypes: ['text', 'textarea', 'number', 'richText'],
}),
],
})
The plugin registers the Edit / Done admin control automatically. You do not need to wire admin components manually.
After adding the plugin, regenerate your project's import map so Payload can resolve the admin UI:
payload generate:importmap
export const Articles: CollectionConfig = {
slug: 'articles',
admin: {
livePreview: {
url: ({ data }) => `/articles/${data?.slug}?payloadLivePreview=true`,
},
},
fields: [
{ name: 'title', type: 'text', required: true },
{ name: 'slug', type: 'text', required: true },
{ name: 'content', type: 'richText' },
],
}
Preview URLs must be served by the same frontend layout where you mount VisualEditorListener.
Add the listener once to the root layout of your live-preview frontend (not the admin layout):
import { VisualEditorListener } from 'payload-plugin-visual-editor/client'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
{children}
<VisualEditorListener />
</body>
</html>
)
}
| Value | Description |
|---|---|
true | All fields matching editableFieldTypes are editable |
{ fields?: string[] } | Only these dot-paths (e.g. meta.title) |
{ excludeFields?: string[] } | Remove paths from the editable set (e.g. slug) |
Edits update the admin form immediately. Draft saves are debounced while editing; Done flushes any pending save.
If your preview page subscribes to @payloadcms/live-preview and stores document data in React state, pause updates while the user is editing. Otherwise incoming preview events will re-render the page, wipe contenteditable state, and lose the cursor.
Use the hooks exported from the client entry:
'use client'
import { subscribe, unsubscribe } from '@payloadcms/live-preview'
import { useVisualEditorEditMode, useVisualEditorMode } from 'payload-plugin-visual-editor/client'
import { useEffect, useRef, useState } from 'react'
export function ArticlePreview({ initialArticle, serverURL }) {
const isLivePreview = useVisualEditorMode()
const isVisualEditing = useVisualEditorEditMode()
const [article, setArticle] = useState(initialArticle)
const pendingRef = useRef<typeof initialArticle | null>(null)
const editingRef = useRef(isVisualEditing)
editingRef.current = isVisualEditing
useEffect(() => {
if (!isLivePreview) return
const listener = subscribe({
callback: (data) => {
if (editingRef.current) {
pendingRef.current = data
return
}
setArticle(data)
},
initialData: initialArticle,
serverURL,
})
return () => unsubscribe(listener)
}, [initialArticle, isLivePreview, serverURL])
useEffect(() => {
if (!isVisualEditing && pendingRef.current) {
setArticle(pendingRef.current)
pendingRef.current = null
}
}, [isVisualEditing])
return (
<article>
<h1>{article.title}</h1>
{/* render other fields */}
</article>
)
}
See dev/components/PostPreview.tsx in this repo for a full working example.
The listener loads editable field paths from the plugin API, subscribes to live-preview document data, and builds a lookup from field values (including rich text plain text and paragraph segments). Visible DOM text is matched case-insensitively.
Your templates only need to render the same text as stored in Payload — no special markup. Text that does not appear in the DOM (hidden fields, computed-only values) cannot be edited visually.
GET /api/visual-editor/fields?collection={slug}Returns editable field descriptors for an enabled collection.
{
"collection": "articles",
"fields": [
{ "path": "title", "type": "text" },
{ "path": "richContent", "type": "richText" }
]
}
Returns 400 if the collection is not enabled for visual editing.
| Import | Description |
|---|---|
payload-plugin-visual-editor | Plugin (payloadVisualEditor) and types |
payload-plugin-visual-editor/client | VisualEditorListener, hooks, VisualEditorAdmin (registered by the plugin) |
payload-plugin-visual-editor/rsc | Re-exports for RSC-compatible setups |
| Issue | What to check |
|---|---|
| Edit button missing | Collection enabled in payloadVisualEditor({ collections }) and live preview configured |
| No blue outlines in preview | VisualEditorListener mounted in the preview frontend layout; field text is visible in the DOM |
| Edits lost while typing | Preview page re-renders on live-preview updates — use the pause/flush pattern above |
| Admin build error after install | Run payload generate:importmap in your project |
This repository is also a Payload plugin template. For local development, testing, and release workflow, see development.sketch.md.
The plugin's source lives in src/, but the dev app in dev/ (and Payload's auto-generated dev/app/(payload)/admin/importMap.js) imports it under its published name — payload-plugin-visual-editor/client and payload-plugin-visual-editor/rsc — so the dev environment mirrors what consumers see in their own projects.
Because the plugin is not actually installed in node_modules during local development, those subpath imports are wired up through two small pieces of glue (instead of a link:. self-dependency in package.json, which would pollute the published manifest):
dev/tsconfig.json — compilerOptions.paths maps payload-plugin-visual-editor, …/client, and …/rsc to the matching files under ../src/. This is what TypeScript and editors use for type checking and go-to-definition.dev/next.config.mjs — turbopack.resolveAlias and webpack.resolve.alias map the /client and /rsc subpaths to the same source files at runtime, so both pnpm dev --turbo and the standard webpack build resolve them without a real package install.dev/payload.config.ts is loaded by the Payload CLI (Node, not Next), so it imports payloadVisualEditor via a plain relative path (../src/index.js) — Node never sees the package name.
If you add a new public entry point under src/exports/, update both the tsconfig paths and the alias map in dev/next.config.mjs to keep the dev app resolving it.
MIT
This is open source work for self hosted Payload CMS instances. This plugin has no relation to the official Payload CMS enterprise visual editor.
payload inplace
Live inline editing for Payload-powered Next.js websites with block reordering and reviewed drafts
62175/wk6v3
plugin
On-page editing and draft preview links for Payload collections and globals on a Next.js frontend
6068/wk4v3 v4
payload better preview
Live preview with block hover highlighting and two-way scroll sync between the Payload admin and the preview
4846/wk16v3
payload better editor
Side-by-side live-preview iframe with a sidebar for editing individual blocks in the Payload edit view
781.2k/wk119v3
plugin
Click-to-edit inline visual editing and block operations on top of Payload Live Preview
581.3k/wk13v3
payload live nav
Section index and field focus bridge that syncs the Payload edit form with the Live Preview
5414/wk0v3