All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Added CI (build, lint, and a pack dry-run) plus bug/feature issue templates and a PR template.
- Added an ESLint flat config and enabled the
lintscript; typed away twono-explicit-anyin the Lexical plugin. - Slimmed down
.gitignoreto the essentials.
- README: add notice at the top recommending
payload-better-editoras the successor — it covers the same hover / click-to-edit / admin↔preview-sync surface as this plugin and additionally provides a full side-by-side editor (live-preview iframe, native-field sidebar, viewport switching, undo/redo).
- made some repo adjustments
- RichText (Lexical) block sync — full bi-directional sync for blocks embedded inside Lexical richText fields
BetterPreviewLexicalFeature— server feature that stampsdata-block-idonto every block decorator element in the Lexical editor DOM; exported frompayload-better-previewBetterPreviewClientFeature— client feature exported frompayload-better-preview/lexicaldata-preview-ignoreattribute — add to any element (in preview or in admin custom block components) to prevent clicks on it from triggering scroll sync in either direction- New message types:
scroll-to-richtext-block,focus-richtext-block,scroll-to-richtext-nested-block; optionalrichTextBlockIdfield onFocusBlockMessage
- Fixed live preview iframe detection for Payload 3.81+ which no longer sets the
live-preview-iframeclass on the iframe element; selector now checks ID first (iframe#live-preview-iframe) with fallbacks for older versions
BetterPreviewLexicalFeaturerequires Payload 3.81+ — on older versions the plugin component is rendered outside of theLexicalComposerContextduring SSR and throws. The core block sync (hover, layout blocks, Admin ↔ Preview sync) still works on Payload ^3.0.0; only the new richText-block sync is gated on 3.81+.
- Nested block support — bi-directional sync works at any block nesting depth, ancestor rows are automatically expanded
- Customizable accent color via
accentColoroption (plugin config and<BetterPreview />prop) - Scroll alignment via
scrollAlignoption ('start'|'center'|'end') - Scroll offset via
scrollOffsetoption (px) — accounts for fixed headers or admin toolbar - Toggle button in the preview iframe to enable/disable block sync
showToggleprop to hide the built-in toggle buttontoggleComponentprop for rendering a custom toggle UITogglePropstype export frompayload-better-preview/client- Origin validation on postMessage — messages are only accepted from the preview iframe
- BREAKING: Block wrapper elements now require a
data-block-fieldattribute containing the Payload field path (e.g."layout") - BREAKING: Message protocol now includes a mandatory
fieldproperty inscroll-to-blockandfocus-blockmessages - Replaced hardcoded
ROW_ID_PREFIXwith generic regex-based row ID parsing — supports arbitrary field names - Colors are now generated dynamically via
makeColors()usingcolor-mix()instead of static RGBA values - Plugin options are passed as
clientPropstoAdminBlockSyncProviderinstead of using a plain string provider path
- Clicking the collapse toggle in the admin no longer triggers a scroll-to-block message
- Fixed
exportsin package.json pointing tosrc/instead ofdist/, causing "Module not found" errors when installed from npm
- BREAKING: Renamed
PreviewToolbartoBetterPreview— update imports toimport { BetterPreview } from 'payload-better-preview/client'
- Added
.d.tstype declarations to published package
- Prepared npm publish
- Flattened
src/structure: removedcomponents/,exports/,shared/subdirectories - Extracted shared constants (
COLORS,FLASH_DURATION, attribute names) intoconstants.ts - Extracted DOM helper functions (
createOverlay,createLabel,positionOverlay, etc.) intooverlay.ts - Replaced hardcoded color values in
AdminBlockSyncProviderwith sharedCOLORSconstants - Removed unused refs (
overlayRef,parentOverlayRef,labelRef) fromPreviewToolbar
- Preview → Admin sync: clicking a block in the preview scrolls the admin editor to the corresponding block row
- Auto-expand collapsed blocks when focused from preview
- Flash highlight on the admin block row (blue box-shadow, 1.5s fade-out)
cursor: pointeron hoverable blocks in previewFocusBlockMessagetype andisFocusBlockMessage()type guard in shared message protocol
- Admin → Preview sync: clicking a block row in the admin editor scrolls the preview to that block
- Flash highlight effect on synced block (blue overlay, 1.5s fade-out)
AdminBlockSyncProvidercomponent, auto-injected into admin UI- Shared message protocol (
better-preview:scroll-to-block) via postMessage
- Hover highlighting with blue overlay on blocks
- Block label badge showing
#N BlockType(e.g.#3 Headline) - Named block support, label includes block name:
#3 Headline "My Title" - Nested block detection with parent dashed overlay and breadcrumb label (
#2 Columns › #1 Text) - Scroll and resize tracking, overlay follows block position smoothly
- Draft-only rendering, zero impact on published pages
- Plugin config with
disabledoption <PreviewToolbar />client component with event-delegation-based interaction