sitesmith: narrow CANVAS_TYPES to just Container
The canonical Craft.js state from real saves shows that layout shells (Section, BackgroundSection, HeroSimple, FeaturesGrid, ColumnLayout, CTASection, FormContainer, Navbar, Footer) all serialize with isCanvas:false. Only Container instances are canvases. The shells use internal <Element canvas id="..."> linkedNodes for their drop targets. Our previous CANVAS_TYPES set claimed all those shells were canvases, which made Craft.js's toNodeTree walker hit an uncaught Invariant — the shell asserted "I'm a canvas" but its render ignores data.nodes, so the walker would chase phantom children.
This commit is contained in:
@@ -4,16 +4,13 @@ import { PageData } from '../types';
|
||||
import { SerializedTreeNode } from '../types/sitesmith';
|
||||
import { useSiteDesign, SiteDesign } from './SiteDesignContext';
|
||||
|
||||
/** Layout components that accept children. Must match the .craft.rules.canMoveIn
|
||||
* config of each component. Leaf components (Heading, TextBlock, ButtonLink, …)
|
||||
* are NOT canvases and must serialize with isCanvas:false or their rendered
|
||||
* content gets swallowed by an empty drop-target wrapper. */
|
||||
const CANVAS_TYPES = new Set<string>([
|
||||
'Container', 'Section', 'ColumnLayout', 'BackgroundSection',
|
||||
'HeaderZone', 'FooterZone',
|
||||
'HeroSimple', 'FeaturesGrid', 'CTASection',
|
||||
'FormContainer', 'Navbar', 'Footer',
|
||||
]);
|
||||
/** Only `Container` instances are "real" canvases in serialized state — they
|
||||
* directly render whatever is in node.data.nodes. Layout-shell components
|
||||
* (Section, HeroSimple, FeaturesGrid, ColumnLayout, CTASection, etc) use
|
||||
* Craft.js <Element canvas id="…"> linkedNodes internally; their own
|
||||
* isCanvas must be FALSE or Craft.js's toNodeTree walker trips an Invariant
|
||||
* because the shell claims to be a canvas but its render ignores `nodes`. */
|
||||
const CANVAS_TYPES = new Set<string>(['Container']);
|
||||
|
||||
interface PageContextValue {
|
||||
pages: PageData[];
|
||||
|
||||
Reference in New Issue
Block a user