EmDash Plugin Block Attr Patch
May 10, 2026 ยท View on GitHub
This repository carries a local patch against emdash@0.10.0 so Portable Text plugin
blocks can persist arbitrary attributes through the editor roundtrip.
This is not an optional implementation detail. The patch is required for rich
propertyEmbed blocks to retain fields like:
slugvariantctaLabel
Without the patch, EmDash collapses custom plugin blocks to a narrower stored shape and those additional fields are lost during edit/save cycles.
Why This Patch Exists
The original local behavior in EmDash's editor only safely persisted:
{
"_type": "propertyEmbed",
"_key": "abc123",
"id": "beautiful-villa-marbella"
}
That forced the first propertyEmbed implementation in this repo to overload id with
the property slug and avoid exposing richer embed settings.
The product requirement is broader. We need to support blocks like:
{
"_type": "propertyEmbed",
"_key": "abc123",
"slug": "beautiful-villa-marbella",
"variant": "compact",
"ctaLabel": "View Property"
}
That requires the editor to preserve arbitrary plugin-block attrs rather than only a
minimal id.
What The Patch Changes
The patch updates the EmDash editor implementation so:
- Portable Text plugin blocks are converted into ProseMirror attrs without discarding custom keys.
- ProseMirror
pluginBlocknodes are converted back into Portable Text blocks with the original attrs restored. _typeand_keyare reconstructed correctly.- Custom attrs like
slug,variant,ctaLabel, booleans, and other primitive fields survive editor roundtrips.
The patch currently affects:
src/components/InlinePortableTextEditor.tsxsrc/components/plugin-block-attrs.ts
Those paths are inside the patched emdash package, not this repo's own src/.
Reproducible Patch Workflow
This repository does not rely on hand-edited node_modules as the source of truth.
The patch is tracked using pnpm's patched dependency workflow:
- patch file: patches/emdash@0.10.0.patch
- package wiring: package.json
- lockfile wiring: pnpm-lock.yaml
package.json contains:
{
"pnpm": {
"patchedDependencies": {
"emdash@0.10.0": "patches/emdash@0.10.0.patch"
}
}
}
That means a normal pnpm install will reapply the patch automatically.
How The Patch Was Created
The patch was generated with pnpm's native patch commands:
pnpm patch emdash@0.10.0 --edit-dir /tmp/emdash-patch
pnpm patch-commit /tmp/emdash-patch --patches-dir patches
This approach is preferable to force-adding files from node_modules because:
- the patch is tracked in a single reviewable file
- installs are reproducible
- upgrading
emdashlater has a clear rebase point - CI and other developers can apply the same fix automatically
How To Update The Patch Later
If you need to change the EmDash editor behavior again:
- Run
pnpm patch emdash@0.10.0 --edit-dir /tmp/emdash-patch - Update the extracted package files in
/tmp/emdash-patch - Run tests in this repository before committing
- Run
pnpm patch-commit /tmp/emdash-patch --patches-dir patches - Review changes in:
Verification
The minimum verification for this patch is:
pnpm exec vitest run src/lib/pwb-property-embed-roundtrip.test.ts
That test suite covers:
- helper roundtrip behavior for arbitrary plugin-block attrs
- fallback key generation
- plugin block registration for
slug,variant, andctaLabel - repository wiring for the
pnpmpatched dependency
For manual verification:
- run
npx emdash dev - open the admin editor
- insert a
Propertyblock - set
slug,variant, andctaLabel - save and reload the entry
- confirm all three fields survive the editor roundtrip
Known Constraints
- This remains a local repository patch until the change is upstreamed into EmDash.
- If
emdashis upgraded, the patch may need to be regenerated or rebased. - The public renderer still supports legacy
id-based blocks for backward compatibility, but new embeds should useslug.