🐛 Merge scoped preview updates and fix duplicate Vue instances - #9
Merged
Merged
Conversation
The editor sends CONTENT_UPDATE scoped to the edited block, which the preview store applied as the new root and collapsed the page to that block. Merge by block id instead, and make the root block addressable. - PreviewStore.applyContentUpdate / mergeContentUpdate merge by id - toRootBlock(entry) carries the entry id into the root block - getConfig() returns the config entry id so v-editable="config" works - Vue injection keys use Symbol.for so a duplicated @b10cks/vue copy cannot break useB10cksApi() during hydration - Nuxt dedupes/excludes the b10cks packages in Vite and transpiles them by bare specifier Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E6isfVxvUpARWAFeWhxUko
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Editing a block in the visual editor collapsed the preview to just that block, and Nuxt apps could fail hydration with "B10cks data API was not found in Vue injection context".
The editor sends
CONTENT_UPDATEscoped to the edited block (payload = that block, carrying itsid); only editing the root pushes the whole tree.PreviewStoreassigned the payload as the new root, so any nested edit replaced the page.What changed
@b10cks/clientPreviewStore.applyContentUpdate()/mergeContentUpdate()merge an update byid: no id → whole tree, root id → replace root, nested id → immutable in-place replace, unknown id → ignored (no notify).findPathById()backs the lookup.toRootBlock(entry)→{ ...entry.content, id, block }. An entry'scontenthas noidof its own, so without it the root block is neither selectable viav-editablenor matchable by root-level updates.getConfig()now includes the config entry'sid, sov-editable="config"works for config-driven regions (header/footer). Breaking only for a config schema with its ownidfield, which is now shadowed.@b10cks/vueSymbol.for(...)so two copies of the package (Vite dep pre-bundling vs. SSR resolution) still match. Values stay per app instance.toRootBlock/RootBlock.@b10cks/nuxt@b10cks/vue,@b10cks/client,@b10cks/richtextinvite.resolve.dedupeandoptimizeDeps.exclude, and transpiles them by bare specifier — the previousresolver.resolve('@b10cks/vue')produced a nonexistent path under the module directory.toRootBlock.READMEs for all three packages updated with the new preview pattern.
Tests
New coverage for
toRootBlock,findPathById,mergeContentUpdate, scoped/root/unknownapplyContentUpdate, and the configid.pnpm lint,pnpm format,pnpm build,pnpm typecheck,pnpm testall pass locally (client: 75 tests).Changeset: minor for
@b10cks/client,@b10cks/vue,@b10cks/nuxt.🤖 Generated with Claude Code
https://claude.ai/code/session_01E6isfVxvUpARWAFeWhxUko