This repository carries a local patch against emdash@0.1.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.
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.
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/.
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.1.0.patch
- package wiring: package.json
- lockfile wiring: pnpm-lock.yaml
package.json contains:
{
"pnpm": {
"patchedDependencies": {
"emdash@0.1.0": "patches/emdash@0.1.0.patch"
}
}
}That means a normal pnpm install will reapply the patch automatically.
The patch was generated with pnpm's native patch commands:
pnpm patch emdash@0.1.0 --edit-dir /tmp/emdash-patch
pnpm patch-commit /tmp/emdash-patch --patches-dir patchesThis 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
If you need to change the EmDash editor behavior again:
- Run
pnpm patch emdash@0.1.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:
The minimum verification for this patch is:
pnpm exec vitest run src/lib/pwb-property-embed-roundtrip.test.tsThat 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
- 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.