refactor(transclusion): unify the ProseMirror collectors into collectNodes (#94)
The three collect*FromPmJson collectors shared the same recursion (and the #55 depth cap) but were copy-pasted, so a future edit could diverge them. Extract a generic collectNodes(doc, {type, map, key, lastWins, skipChildrenOfType}) and reimplement all three on it, byte-output-identical (transclusions last-wins; references/embeds first-wins + transclusionSource skip). Documents (not removes) the write-only page_template_references graph and the near-duplicate client lookup-context as tracked follow-ups, per the issue's guidance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,15 @@ const PageEmbedLookupContext = createContext<ContextValue | null>(null);
|
||||
* transclusion lookup context but keys purely on `sourcePageId`. On public
|
||||
* shares there is no lookup in MVP, so the context simply isn't mounted (the
|
||||
* node view renders a placeholder when the context is absent).
|
||||
*
|
||||
* NOTE (intentional near-duplicate of `transclusion-lookup-context.tsx`): this
|
||||
* provider duplicates that file's batching / de-dup / cache machinery; only the
|
||||
* lookup key (sourcePageId here vs sourcePageId+transclusionId there) and the
|
||||
* API call differ. Unifying them now would mean a generic, parameterised lookup
|
||||
* provider — a larger client refactor that isn't worth it for just two
|
||||
* consumers. Per Gitea #94, extract a shared generic provider when a THIRD
|
||||
* lookup consumer appears; until then keep the two in sync by hand. (Tracked,
|
||||
* deliberately deferred — not forgotten.)
|
||||
*/
|
||||
export function PageEmbedLookupProvider({
|
||||
children,
|
||||
|
||||
Reference in New Issue
Block a user