@charisol/plexo-sdk 1.4.39 → 1.4.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13431 -17791
- package/dist/plexo-sdk.css +1 -1
- package/dist/toReact-BBzjWoFG.js +595 -0
- package/dist/v2/ai/commands.d.ts +616 -0
- package/dist/v2/ai/dispatch.d.ts +24 -0
- package/dist/v2/ai/nodeSchema.d.ts +196 -0
- package/dist/v2/brand/BrandColorSwatches.d.ts +4 -0
- package/dist/v2/brand/BrandPanel.d.ts +4 -0
- package/dist/v2/brand/ChangeSetGallery.d.ts +10 -0
- package/dist/v2/brand/StyleSetEditor.d.ts +22 -0
- package/dist/v2/canvas/CatalogDragContext.d.ts +27 -0
- package/dist/v2/canvas/ContextMenuContext.d.ts +16 -0
- package/dist/v2/canvas/DeviceModeContext.d.ts +20 -0
- package/dist/v2/canvas/DragEngineContext.d.ts +13 -0
- package/dist/v2/canvas/LayoutGuideContext.d.ts +22 -0
- package/dist/v2/canvas/PreviewModeContext.d.ts +15 -0
- package/dist/v2/canvas/SidebarContext.d.ts +21 -0
- package/dist/v2/canvas/StylePainterContext.d.ts +19 -0
- package/dist/v2/canvas/WorkspaceThemeContext.d.ts +19 -0
- package/dist/v2/canvas/aiTextTransforms.d.ts +24 -0
- package/dist/v2/canvas/animationPresets.d.ts +12 -0
- package/dist/v2/canvas/constants.d.ts +6 -0
- package/dist/v2/canvas/layoutRoles.d.ts +12 -0
- package/dist/v2/canvas/modelRect.d.ts +4 -0
- package/dist/v2/canvas/rectMath.d.ts +34 -0
- package/dist/v2/canvas/reorderMath.d.ts +8 -0
- package/dist/v2/canvas/resizeMath.d.ts +16 -0
- package/dist/v2/canvas/resolveBoxStyle.d.ts +12 -0
- package/dist/v2/canvas/resolveTargetSection.d.ts +10 -0
- package/dist/v2/canvas/sectionDividerShapes.d.ts +12 -0
- package/dist/v2/canvas/snapping.d.ts +28 -0
- package/dist/v2/canvas/useAlignNode.d.ts +10 -0
- package/dist/v2/canvas/useClipboardKeyBinding.d.ts +7 -0
- package/dist/v2/canvas/useDeleteKeyBinding.d.ts +3 -0
- package/dist/v2/canvas/useDragEngine.d.ts +44 -0
- package/dist/v2/canvas/useDraggableNode.d.ts +30 -0
- package/dist/v2/canvas/useInlineTextEdit.d.ts +29 -0
- package/dist/v2/canvas/usePointerEngine.d.ts +22 -0
- package/dist/v2/canvas/useResizeHandle.d.ts +12 -0
- package/dist/v2/canvas/useResolvedTextStyles.d.ts +13 -0
- package/dist/v2/canvas/useSelectionRects.d.ts +13 -0
- package/dist/v2/canvas/useUndoRedoKeyBinding.d.ts +8 -0
- package/dist/v2/catalog/elementCatalog.d.ts +31 -0
- package/dist/v2/catalog/imagePreset.d.ts +7 -0
- package/dist/v2/compile/index.d.ts +15 -0
- package/dist/v2/compile/toReact.d.ts +32 -0
- package/dist/v2/components/AdornmentLayer.d.ts +20 -0
- package/dist/v2/components/AskSolPanel.d.ts +19 -0
- package/dist/v2/components/CatalogDragGhost.d.ts +6 -0
- package/dist/v2/components/CellBoundary.d.ts +14 -0
- package/dist/v2/components/CenterCanvas.d.ts +3 -0
- package/dist/v2/components/ContentTabPanel.d.ts +12 -0
- package/dist/v2/components/ContextMenu.d.ts +5 -0
- package/dist/v2/components/ContextualToolbar.d.ts +25 -0
- package/dist/v2/components/ImagesTabPanel.d.ts +15 -0
- package/dist/v2/components/LayoutGuidePanel.d.ts +10 -0
- package/dist/v2/components/ManageLayersPanel.d.ts +13 -0
- package/dist/v2/components/NodeRenderer.d.ts +8 -0
- package/dist/v2/components/PreviewOverlay.d.ts +11 -0
- package/dist/v2/components/ResizeHandle.d.ts +6 -0
- package/dist/v2/components/RightRail.d.ts +13 -0
- package/dist/v2/components/SectionDividerOverlay.d.ts +8 -0
- package/dist/v2/components/SectionEdgeAddZone.d.ts +17 -0
- package/dist/v2/components/SectionGridOverlay.d.ts +10 -0
- package/dist/v2/components/SectionNamePill.d.ts +6 -0
- package/dist/v2/components/SectionNode.d.ts +5 -0
- package/dist/v2/components/SectionSideRail.d.ts +17 -0
- package/dist/v2/components/SelectionToolbar.d.ts +11 -0
- package/dist/v2/components/StylePainterToast.d.ts +5 -0
- package/dist/v2/components/V2Canvas.d.ts +56 -0
- package/dist/v2/components/nodes/ButtonNode.d.ts +4 -0
- package/dist/v2/components/nodes/ContainerNode.d.ts +11 -0
- package/dist/v2/components/nodes/EmbedNode.d.ts +4 -0
- package/dist/v2/components/nodes/ImageNode.d.ts +4 -0
- package/dist/v2/components/nodes/InputNode.d.ts +4 -0
- package/dist/v2/components/nodes/MenuNode.d.ts +18 -0
- package/dist/v2/components/nodes/TextNode.d.ts +4 -0
- package/dist/v2/index.d.ts +12 -0
- package/dist/v2/inspector/AiQuickEditPanel.d.ts +12 -0
- package/dist/v2/inspector/AnimationPanel.d.ts +11 -0
- package/dist/v2/inspector/DesignAccordions.d.ts +7 -0
- package/dist/v2/inspector/FieldRenderer.d.ts +9 -0
- package/dist/v2/inspector/IconPopoverButton.d.ts +9 -0
- package/dist/v2/inspector/MenuIconPanel.d.ts +7 -0
- package/dist/v2/inspector/MenuManagePanel.d.ts +8 -0
- package/dist/v2/inspector/Popover.d.ts +21 -0
- package/dist/v2/inspector/SectionDividerPanel.d.ts +9 -0
- package/dist/v2/inspector/fieldStyles.d.ts +15 -0
- package/dist/v2/inspector/fields/ColorField.d.ts +7 -0
- package/dist/v2/inspector/fields/NumberField.d.ts +7 -0
- package/dist/v2/inspector/fields/SelectField.d.ts +7 -0
- package/dist/v2/inspector/fields/TextField.d.ts +7 -0
- package/dist/v2/inspector/fields/TextStyleField.d.ts +11 -0
- package/dist/v2/inspector/fields/TextareaField.d.ts +7 -0
- package/dist/v2/inspector/schema.d.ts +25 -0
- package/dist/v2/inspector/useFieldCommit.d.ts +12 -0
- package/dist/v2/store/brandDefaults.d.ts +4 -0
- package/dist/v2/store/brandTypes.d.ts +40 -0
- package/dist/v2/store/cloneSubtree.d.ts +12 -0
- package/dist/v2/store/createBrandStore.d.ts +2 -0
- package/dist/v2/store/createCanvasStore.d.ts +2 -0
- package/dist/v2/store/seed.d.ts +17 -0
- package/dist/v2/store/types.d.ts +163 -0
- package/dist/v2/ui/theme.d.ts +85 -0
- package/dist/v2-compile.js +9 -0
- package/dist/v2.js +8508 -0
- package/dist/zoom-in-DL4pfiLG.js +4461 -0
- package/package.json +11 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SaveState } from './ContextualToolbar';
|
|
3
|
+
import type { AskSolMessage } from './AskSolPanel';
|
|
4
|
+
/**
|
|
5
|
+
* Everything a host app (plexo-web in production, PlaygroundHost.tsx in dev) can hand
|
|
6
|
+
* in rather than the SDK hardcoding or faking it. Persistence, uploads, and Ask SOL
|
|
7
|
+
* conversation history are all host concerns the SDK has no backend of its own for.
|
|
8
|
+
*/
|
|
9
|
+
/** One stock-photo provider the host wires up (Unsplash/Pixabay/Pexels/…) — labels only,
|
|
10
|
+
* the actual API keys and fetch logic live on the host's side. */
|
|
11
|
+
export interface StockImageProvider {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
/** One stock-photo search result, in the shape the Images tab needs to render a tile
|
|
16
|
+
* and give the source photographer/provider proper credit. */
|
|
17
|
+
export interface StockImageResult {
|
|
18
|
+
id: string;
|
|
19
|
+
src: string;
|
|
20
|
+
alt?: string;
|
|
21
|
+
credit?: string;
|
|
22
|
+
photographerUrl?: string;
|
|
23
|
+
provider: string;
|
|
24
|
+
}
|
|
25
|
+
export interface V2CanvasProps {
|
|
26
|
+
/** Uploading a file needs real storage the SDK doesn't have — given, the Images tab's
|
|
27
|
+
* Upload section calls this with the picked/dropped file and expects the hosted URL
|
|
28
|
+
* back; omitted, that section doesn't render (no dead button pretending to work). */
|
|
29
|
+
onUploadImage?: (file: File) => Promise<string>;
|
|
30
|
+
/** Stock photo search (Unsplash/Pixabay/…), consolidated into the same Images tab as
|
|
31
|
+
* uploads and document images per the user's own explicit request — the SDK has no
|
|
32
|
+
* API keys of its own, so both the provider list and the actual search call are the
|
|
33
|
+
* host's job. Omit both to just show uploads + images already used in the document. */
|
|
34
|
+
stockImageProviders?: StockImageProvider[];
|
|
35
|
+
onSearchStockImages?: (query: string, providerId: string) => Promise<StockImageResult[]>;
|
|
36
|
+
/** Ask SOL's conversation, scoped to "the particular template" by whatever the host
|
|
37
|
+
* passes in — the SDK has no concept of which template/document this is beyond the
|
|
38
|
+
* canvas store's own contents, so persisting history across sessions is the host's
|
|
39
|
+
* job. Omit both to get a normal in-memory-only conversation. */
|
|
40
|
+
askSolHistory?: AskSolMessage[];
|
|
41
|
+
onAskSolMessage?: (message: AskSolMessage) => void;
|
|
42
|
+
/** Left/right header slots — named to match V1's own `headerLeftContent`/
|
|
43
|
+
* `headerRightContent` props (PlexoBuilder.tsx) so a host already integrating V1
|
|
44
|
+
* can carry the same content over with no naming translation. The SDK renders each
|
|
45
|
+
* as-is and owns nothing about its content; per-element editing controls never live
|
|
46
|
+
* here (see SelectionToolbar.tsx, docked inside the canvas panel instead). */
|
|
47
|
+
headerLeftContent?: React.ReactNode;
|
|
48
|
+
headerRightContent?: React.ReactNode;
|
|
49
|
+
/** Also matching V1's naming: the Save button only renders when a handler is
|
|
50
|
+
* actually supplied (and `showSaveButton` isn't explicitly false) — no dead button
|
|
51
|
+
* that silently does nothing. */
|
|
52
|
+
onSave?: () => void;
|
|
53
|
+
showSaveButton?: boolean;
|
|
54
|
+
saveState?: SaveState;
|
|
55
|
+
}
|
|
56
|
+
export declare const V2Canvas: React.FC<V2CanvasProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A "Cell row": children lay out side by side via flexbox (not Phase 3's absolute x/y —
|
|
4
|
+
* see useDraggableNode's isFlexItem branch), with a real, draggable gap between each
|
|
5
|
+
* pair rendered as an actual flex sibling (CellBoundary) rather than the CSS `gap`
|
|
6
|
+
* property — that's what makes the gap itself hoverable/draggable/carrying Add-cell and
|
|
7
|
+
* Flip controls, matching the "add gap, add cell, flip cell" reference behavior.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ContainerNode: React.FC<{
|
|
10
|
+
id: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A real Menu — not a composed row of Buttons. On desktop it lays out `props.links`
|
|
4
|
+
* per `props.layout` (horizontal/vertical); on a mobile device-preview it collapses
|
|
5
|
+
* into a genuinely interactive hamburger (local open/close state) unless
|
|
6
|
+
* `styles.mobileMode` is explicitly `'alwaysExpanded'` — matching the user's own
|
|
7
|
+
* reference of switching to mobile mode and getting a real collapsible menu, not just
|
|
8
|
+
* a shrunk copy of the desktop one.
|
|
9
|
+
*
|
|
10
|
+
* The menu acts as one draggable/selectable unit — its links are inert previews (not
|
|
11
|
+
* live navigation) while editing, so clicking one just picks up the whole menu like
|
|
12
|
+
* clicking anywhere else on it, rather than fighting the browser's own link cursor/
|
|
13
|
+
* behavior. Double-clicking opens "Manage Menu" right there, instead of only being
|
|
14
|
+
* reachable via the toolbar icon.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MenuNode: React.FC<{
|
|
17
|
+
id: string;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry for the V2 canvas engine: `@charisol/plexo-sdk/v2` (a separate package entry
|
|
3
|
+
* from the V1 builder at the package root). Hosts render <V2Canvas>, load and read the
|
|
4
|
+
* design through useCanvasStore (hydrate / nodes / pageOrder), and compile pages to React
|
|
5
|
+
* with compilePageToReact.
|
|
6
|
+
*/
|
|
7
|
+
export { V2Canvas } from './components/V2Canvas';
|
|
8
|
+
export { useCanvasStore } from './store/createCanvasStore';
|
|
9
|
+
export { useBrandStore } from './store/createBrandStore';
|
|
10
|
+
export type { V2CanvasProps } from './components/V2Canvas';
|
|
11
|
+
export type { PlexoNode, PlexoNodeType, CanvasState, CanvasStore, SectionNode, TextNode, ImageNode, ButtonNode, ContainerNode, } from './store/types';
|
|
12
|
+
export { compilePageToReact, componentNameFor, DESIGN_WIDTH, type CompileOptions, type TextStyleSlots } from "./compile/toReact";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Per-selection "Quick edit" for Text/Button content — the concrete, honest version of
|
|
4
|
+
* "help me rewrite/shorten/lengthen this" the user asked for. Deliberately not called
|
|
5
|
+
* "AI rewrite": these are genuinely-applied local heuristic transforms
|
|
6
|
+
* (aiTextTransforms.ts), not a real model call, and the copy says so plainly rather
|
|
7
|
+
* than overclaiming. Picking an action shows candidate variants as chips; picking a
|
|
8
|
+
* chip applies it to the node's real content and commits one undo step.
|
|
9
|
+
*/
|
|
10
|
+
export declare const AiQuickEditPanel: React.FC<{
|
|
11
|
+
id: string;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Entrance animation only (Loop/Scroll/Mouse Effects are noted as future work in the
|
|
4
|
+
* plan's fidelity-bar section — this proves the real mechanism: Web Animations API
|
|
5
|
+
* keyframes, played on demand via "Preview", not a decorative preset list). Picking a
|
|
6
|
+
* type previews it immediately, matching the reference's "see it play when you pick
|
|
7
|
+
* it" feel.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AnimationPanel: React.FC<{
|
|
10
|
+
id: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Real Borders / Corners / Shadow controls, matching the reference's "Design" popover
|
|
3
|
+
* exactly in structure (three collapsible sections) — every value here actually
|
|
4
|
+
* renders (see resolveBoxStyle.ts, applied by every leaf node component). */
|
|
5
|
+
export declare const DesignAccordions: React.FC<{
|
|
6
|
+
id: string;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PlexoNode } from '../store/types';
|
|
3
|
+
import type { FieldDescriptor } from './schema';
|
|
4
|
+
/** Single dispatch point from a field descriptor to its control — mirrors NodeRenderer's
|
|
5
|
+
* role for canvas nodes: adding a new field kind touches this switch and one new file. */
|
|
6
|
+
export declare const FieldRenderer: React.FC<{
|
|
7
|
+
node: PlexoNode;
|
|
8
|
+
field: FieldDescriptor;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** "Customize Menu Icon" — icon glyph, color, and whether the mobile hamburger collapse
|
|
3
|
+
* is on at all ("Regular Mode" = collapses like normal; "Always expanded" = ignores
|
|
4
|
+
* the mobile device-preview and keeps rendering the full link list). */
|
|
5
|
+
export declare const MenuIconPanel: React.FC<{
|
|
6
|
+
id: string;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** "Manage Menu" — add/remove/edit links, matching V1's own `attrs.links` shape
|
|
3
|
+
* (`MenuPropertiesAccordion.tsx`) rather than inventing a new one. Real add/remove/
|
|
4
|
+
* edit; no "Sync from site pages" here since this SDK has no multi-page concept to
|
|
5
|
+
* sync from — an honest omission rather than a fake button. */
|
|
6
|
+
export declare const MenuManagePanel: React.FC<{
|
|
7
|
+
id: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Generic anchored popover — opens below its trigger, closes on outside click/Escape.
|
|
4
|
+
* Portaled straight to `document.body` and positioned in fixed/viewport coordinates
|
|
5
|
+
* from the trigger's own measured rect, rather than `position: absolute` inside
|
|
6
|
+
* whatever ancestor happens to wrap the trigger. That ancestor approach is what let the
|
|
7
|
+
* canvas's own selection-outline overlay (AdornmentLayer, z-index 9999 — needs to be
|
|
8
|
+
* high so it tracks drags above ordinary content) render on top of an open popover: two
|
|
9
|
+
* z-indexed elements only compare directly when they share the same stacking-context
|
|
10
|
+
* root, and a plain `position: relative` wrapper with no z-index of its own doesn't
|
|
11
|
+
* guarantee that. Portaling sidesteps the ambiguity entirely instead of chasing a
|
|
12
|
+
* higher and higher z-index.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Popover: React.FC<{
|
|
15
|
+
open: boolean;
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
width?: number;
|
|
18
|
+
align?: 'left' | 'right';
|
|
19
|
+
anchorRef: React.RefObject<HTMLElement | null>;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** "Section Dividers" popover: Bottom/Top placement, a shape gallery, and a
|
|
3
|
+
* "Customize Design" section (color + height) — matching the reference exactly.
|
|
4
|
+
* Stores everything as plain style fields on the Section node (dividerShape/
|
|
5
|
+
* dividerPlacement/dividerColor/dividerHeight); rendering lives in
|
|
6
|
+
* SectionDividerOverlay.tsx. */
|
|
7
|
+
export declare const SectionDividerPanel: React.FC<{
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/** Class every text/number/select/textarea control shares — declared once in
|
|
3
|
+
* Popover.tsx (a tinted background at rest, a real focus ring), so every field
|
|
4
|
+
* automatically gets the same premium treatment instead of each one drawing its own
|
|
5
|
+
* plain bordered box. */
|
|
6
|
+
export declare const FIELD_INPUT_CLASS = "plexo-field-input";
|
|
7
|
+
/** A compact, single-line label+control row (label left, control right) — the
|
|
8
|
+
* label-stacked-above-a-full-width-box layout used to double every field's vertical
|
|
9
|
+
* footprint and read like a plain web form; a design tool's own property fields
|
|
10
|
+
* (Figma, Framer) pair a short label directly beside its value. */
|
|
11
|
+
export declare const rowStyle: React.CSSProperties;
|
|
12
|
+
export declare const labelStyle: React.CSSProperties;
|
|
13
|
+
/** Kept for the few call sites that still need a plain inline style object rather than
|
|
14
|
+
* the shared class (e.g. building on top of it with extra one-off properties). */
|
|
15
|
+
export declare const inputStyle: React.CSSProperties;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Links a Text node to a global Text Style slot (Heading 1-6 / Paragraph 1-3) — the
|
|
4
|
+
* "Change All" behavior: editing the slot in the Brand panel updates every node linked
|
|
5
|
+
* to it, since TextNode reads its effective fontSize/fontWeight/lineHeight from the
|
|
6
|
+
* slot (not a local copy) whenever one is linked. Picking "Custom" clears the link and
|
|
7
|
+
* falls back to this node's own local Font size/Weight fields.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TextStyleField: React.FC<{
|
|
10
|
+
id: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PlexoNodeType } from '../store/types';
|
|
2
|
+
export type FieldKind = 'text' | 'textarea' | 'number' | 'color' | 'select';
|
|
3
|
+
export interface SelectOption {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FieldDescriptor {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
kind: FieldKind;
|
|
11
|
+
target: 'props' | 'styles';
|
|
12
|
+
key: string;
|
|
13
|
+
options?: SelectOption[];
|
|
14
|
+
}
|
|
15
|
+
/** Every non-Section node shares these — Phase 3's x/y/width/height, editable numerically. */
|
|
16
|
+
export declare const LAYOUT_FIELDS: FieldDescriptor[];
|
|
17
|
+
/**
|
|
18
|
+
* The per-type field list driving the schema-driven Inspector. Deliberately small in
|
|
19
|
+
* Phase 4 (a handful of real, working fields per type) rather than attempting the full
|
|
20
|
+
* "Enterprise fidelity bar" reference list (typography/animation/SEO panels etc.) in one
|
|
21
|
+
* pass — see the plan's fidelity-bar section for what a later pass adds. Adding a field
|
|
22
|
+
* here is the whole cost of exposing a new editable property: one array entry, no new
|
|
23
|
+
* field-kind component needed unless it's a genuinely new kind of control.
|
|
24
|
+
*/
|
|
25
|
+
export declare const FIELD_SCHEMA: Record<PlexoNodeType, FieldDescriptor[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FieldDescriptor } from './schema';
|
|
2
|
+
/**
|
|
3
|
+
* The Inspector-field equivalent of Phase 3's Ghost Drag: `setValue` writes straight to
|
|
4
|
+
* the store on every keystroke/scrub-tick so the canvas repaints instantly, while only
|
|
5
|
+
* one `commitSnapshot` call per edit gesture (blur, or scrub pointerup) lands in
|
|
6
|
+
* undo/redo — otherwise every keystroke or scrub pixel would be its own undo step.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useFieldCommit(id: string, field: FieldDescriptor): {
|
|
9
|
+
beginEdit: () => void;
|
|
10
|
+
setValue: (value: string | number | undefined) => void;
|
|
11
|
+
commit: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type BrandColorCategory = 'base' | 'shade' | 'accent' | 'saved';
|
|
2
|
+
export interface BrandColor {
|
|
3
|
+
id: string;
|
|
4
|
+
hex: string;
|
|
5
|
+
category: BrandColorCategory;
|
|
6
|
+
}
|
|
7
|
+
/** One named, editable slot within a style set — e.g. a set's "Primary" button or "Box 1". */
|
|
8
|
+
export interface StyleSlot {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
styles: Record<string, string | number>;
|
|
12
|
+
}
|
|
13
|
+
/** A wholesale, swappable style-language choice (Wix's "Change Set") — e.g. a pill-button
|
|
14
|
+
* set vs. a sharp-cornered set. Each set carries its own named slots. */
|
|
15
|
+
export interface StyleSet {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
slots: StyleSlot[];
|
|
19
|
+
}
|
|
20
|
+
export interface BrandKitState {
|
|
21
|
+
colors: BrandColor[];
|
|
22
|
+
buttonSets: StyleSet[];
|
|
23
|
+
activeButtonSetId: string;
|
|
24
|
+
boxSets: StyleSet[];
|
|
25
|
+
activeBoxSetId: string;
|
|
26
|
+
textStyleSets: StyleSet[];
|
|
27
|
+
activeTextStyleSetId: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BrandKitActions {
|
|
30
|
+
addSavedColor: (hex: string) => void;
|
|
31
|
+
removeSavedColor: (id: string) => void;
|
|
32
|
+
setActiveButtonSet: (setId: string) => void;
|
|
33
|
+
setActiveBoxSet: (setId: string) => void;
|
|
34
|
+
setActiveTextStyleSet: (setId: string) => void;
|
|
35
|
+
updateSlotStyles: (category: 'button' | 'box' | 'text', setId: string, slotId: string, patch: Record<string, string | number>) => void;
|
|
36
|
+
getActiveButtonSet: () => StyleSet;
|
|
37
|
+
getActiveBoxSet: () => StyleSet;
|
|
38
|
+
getActiveTextStyleSet: () => StyleSet;
|
|
39
|
+
}
|
|
40
|
+
export type BrandKitStore = BrandKitState & BrandKitActions;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlexoNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Deep-clones a subtree with brand-new ids throughout, remapping every internal
|
|
4
|
+
* parentId/children reference to the new ids — the root's own parentId is left as-is
|
|
5
|
+
* (it points outside the subtree, to wherever the caller decides to attach the clone).
|
|
6
|
+
* Used by both duplicateNode (clone in place) and pasteNode (clone from the clipboard,
|
|
7
|
+
* possibly repeatedly) so two pastes of the same copy never collide on id.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cloneSubtreeWithNewIds(nodes: Record<string, PlexoNode>, rootId: string): {
|
|
10
|
+
nodes: Record<string, PlexoNode>;
|
|
11
|
+
rootId: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlexoNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A function, not a static exported object — each call must produce fresh objects.
|
|
4
|
+
* React StrictMode double-invokes effects (main.tsx wraps <App> in <StrictMode>), and
|
|
5
|
+
* V2Canvas seeds on mount; sharing one object across both invocations would let a
|
|
6
|
+
* mutation from one "session" silently leak into the other.
|
|
7
|
+
*
|
|
8
|
+
* Every non-Section node carries explicit x/y/width/height (in its own parent's local
|
|
9
|
+
* coordinate space — Section for direct children, Container for its own) so Phase 3's
|
|
10
|
+
* drag/snap engine has real geometry to work with; Section itself gets an explicit
|
|
11
|
+
* pixel `height` since absolutely-positioned children no longer contribute to its
|
|
12
|
+
* natural flow height.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildSeedNodes(): {
|
|
15
|
+
nodes: Record<string, PlexoNode>;
|
|
16
|
+
pageOrder: string[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export type PlexoNodeType = 'Section' | 'Text' | 'Image' | 'Button' | 'Container' | 'Input' | 'Embed' | 'Menu';
|
|
2
|
+
interface BaseNode {
|
|
3
|
+
id: string;
|
|
4
|
+
parentId: string | null;
|
|
5
|
+
children: string[];
|
|
6
|
+
styles: Record<string, string | number | undefined>;
|
|
7
|
+
}
|
|
8
|
+
export interface SectionNode extends BaseNode {
|
|
9
|
+
type: 'Section';
|
|
10
|
+
props: {
|
|
11
|
+
name?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface TextNode extends BaseNode {
|
|
15
|
+
type: 'Text';
|
|
16
|
+
props: {
|
|
17
|
+
content: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface ImageNode extends BaseNode {
|
|
21
|
+
type: 'Image';
|
|
22
|
+
props: {
|
|
23
|
+
src: string;
|
|
24
|
+
alt?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface ButtonNode extends BaseNode {
|
|
28
|
+
type: 'Button';
|
|
29
|
+
props: {
|
|
30
|
+
label: string;
|
|
31
|
+
href?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface ContainerNode extends BaseNode {
|
|
35
|
+
type: 'Container';
|
|
36
|
+
props: Record<string, never>;
|
|
37
|
+
}
|
|
38
|
+
/** A single labeled form field — the primitive behind Form & Contact catalog presets
|
|
39
|
+
* (a "Contact form" is just several of these plus a submit Button in a Container). */
|
|
40
|
+
export interface InputNode extends BaseNode {
|
|
41
|
+
type: 'Input';
|
|
42
|
+
props: {
|
|
43
|
+
label: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
fieldType: 'text' | 'email' | 'tel' | 'textarea';
|
|
46
|
+
required?: boolean;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** A sandboxed embed — a real `<video>` for the Video & Music catalog, or an
|
|
50
|
+
* `iframe[sandbox]` for generic third-party embed HTML (never rendered unsandboxed,
|
|
51
|
+
* since embed HTML is effectively untrusted external content). */
|
|
52
|
+
export interface EmbedNode extends BaseNode {
|
|
53
|
+
type: 'Embed';
|
|
54
|
+
props: {
|
|
55
|
+
kind: 'video' | 'html';
|
|
56
|
+
url?: string;
|
|
57
|
+
html?: string;
|
|
58
|
+
coverImage?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** A real navigation menu — `props.links` mirrors V1's own actual shape
|
|
62
|
+
* (`MenuPropertiesAccordion.tsx`'s `attrs.links: {label,href}[]`), not a generic
|
|
63
|
+
* composed row of Buttons. `layout` is the desktop/tablet presentation; on a mobile
|
|
64
|
+
* device-preview (see DeviceModeContext) it collapses into a real interactive
|
|
65
|
+
* hamburger unless `styles.mobileMode === 'alwaysExpanded'` — see MenuNode.tsx. */
|
|
66
|
+
export interface MenuNode extends BaseNode {
|
|
67
|
+
type: 'Menu';
|
|
68
|
+
props: {
|
|
69
|
+
links: Array<{
|
|
70
|
+
label: string;
|
|
71
|
+
href: string;
|
|
72
|
+
}>;
|
|
73
|
+
layout: 'horizontal' | 'vertical';
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export type PlexoNode = SectionNode | TextNode | ImageNode | ButtonNode | ContainerNode | InputNode | EmbedNode | MenuNode;
|
|
77
|
+
export interface CanvasHistoryEntry {
|
|
78
|
+
nodes: Record<string, PlexoNode>;
|
|
79
|
+
pageOrder: string[];
|
|
80
|
+
}
|
|
81
|
+
export interface ClipboardEntry {
|
|
82
|
+
nodes: Record<string, PlexoNode>;
|
|
83
|
+
rootId: string;
|
|
84
|
+
}
|
|
85
|
+
export type ZOrderDirection = 'forward' | 'backward' | 'front' | 'back';
|
|
86
|
+
export type AlignDirection = 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';
|
|
87
|
+
export interface CanvasState {
|
|
88
|
+
nodes: Record<string, PlexoNode>;
|
|
89
|
+
pageOrder: string[];
|
|
90
|
+
selectedIds: string[];
|
|
91
|
+
past: CanvasHistoryEntry[];
|
|
92
|
+
future: CanvasHistoryEntry[];
|
|
93
|
+
clipboard: ClipboardEntry | null;
|
|
94
|
+
}
|
|
95
|
+
export interface CanvasActions {
|
|
96
|
+
hydrate: (nodes: Record<string, PlexoNode>, pageOrder: string[]) => void;
|
|
97
|
+
seed: () => void;
|
|
98
|
+
select: (id: string, opts?: {
|
|
99
|
+
additive?: boolean;
|
|
100
|
+
}) => void;
|
|
101
|
+
deselect: (id: string) => void;
|
|
102
|
+
clearSelection: () => void;
|
|
103
|
+
undo: () => void;
|
|
104
|
+
redo: () => void;
|
|
105
|
+
getNode: (id: string) => PlexoNode | undefined;
|
|
106
|
+
getChildren: (id: string) => PlexoNode[];
|
|
107
|
+
/** Commits a node's final x/y after a drag — the only action that pushes onto `past`
|
|
108
|
+
* (see createCanvasStore.ts): everything up to Phase 3 was read-only/selection-only. */
|
|
109
|
+
moveNode: (id: string, x: number, y: number) => void;
|
|
110
|
+
/** Immediate, no-history style patch — used for live Inspector feedback (e.g. every
|
|
111
|
+
* tick of a number-field scrub) so the canvas repaints instantly without flooding
|
|
112
|
+
* undo/redo with one entry per pixel. Pair with `commitSnapshot` once per gesture. */
|
|
113
|
+
setNodeStyles: (id: string, patch: Record<string, string | number | undefined>) => void;
|
|
114
|
+
setNodeProps: (id: string, patch: Record<string, unknown>) => void;
|
|
115
|
+
/** Pushes a pre-captured snapshot onto `past` and clears `future` — call once at the
|
|
116
|
+
* end of an editing gesture (pointerup, blur) with the state from *before* the
|
|
117
|
+
* gesture started, so the whole gesture becomes a single undo step. */
|
|
118
|
+
commitSnapshot: (snapshot: CanvasHistoryEntry) => void;
|
|
119
|
+
/** Macro-flow reordering (Section only) — swaps the section with its neighbor in
|
|
120
|
+
* `pageOrder`; a no-op at either end of the page. Each call is its own undo step. */
|
|
121
|
+
moveSectionUp: (id: string) => void;
|
|
122
|
+
moveSectionDown: (id: string) => void;
|
|
123
|
+
/** Phase 6 entry point: validates raw (e.g. AI-produced) JSON against the command
|
|
124
|
+
* schema, applies it if structurally sound, and commits one undo step per call — see
|
|
125
|
+
* src/v2/ai/dispatch.ts for the actual validation/reducer logic. */
|
|
126
|
+
dispatchAiCommand: (raw: unknown) => {
|
|
127
|
+
ok: boolean;
|
|
128
|
+
error?: string;
|
|
129
|
+
};
|
|
130
|
+
/** Basic editing operations — each is one undo step. All reuse dispatchAiCommand's
|
|
131
|
+
* validated insert/delete reducer internally rather than duplicating subtree logic. */
|
|
132
|
+
removeNode: (id: string) => void;
|
|
133
|
+
duplicateNode: (id: string) => void;
|
|
134
|
+
copyNode: (id: string) => void;
|
|
135
|
+
cutNode: (id: string) => void;
|
|
136
|
+
pasteNode: () => void;
|
|
137
|
+
bringForward: (id: string) => void;
|
|
138
|
+
sendBackward: (id: string) => void;
|
|
139
|
+
bringToFront: (id: string) => void;
|
|
140
|
+
sendToBack: (id: string) => void;
|
|
141
|
+
/** Inserts a blank Section at the given pageOrder index (0 = before the first
|
|
142
|
+
* section, pageOrder.length = after the last) — backs the hover "+ Add Section"
|
|
143
|
+
* zones between sections on the canvas. Returns the new section's id. */
|
|
144
|
+
insertBlankSection: (index: number) => string;
|
|
145
|
+
/** Inserts a blank Container acting as a "Cell" — a flex-row child of another
|
|
146
|
+
* Container — at the given child index. Returns the new cell's id. */
|
|
147
|
+
insertCell: (parentId: string, index: number) => string;
|
|
148
|
+
/** Pulls a node out of its flex-item parent (a Cell) and re-parents it, absolutely
|
|
149
|
+
* positioned, onto the nearest enclosing Section — backs "drag an element inside a
|
|
150
|
+
* column and it moves out of the cell" (useDraggableNode.ts). `x`/`y`/`width`/
|
|
151
|
+
* `height` are the node's already-measured screen position/size at the moment of
|
|
152
|
+
* detach (relative to the target Section), since a still-flexible cell child may
|
|
153
|
+
* have no explicit width/height of its own to fall back on. */
|
|
154
|
+
detachFromCell: (nodeId: string, x: number, y: number, width: number, height: number) => void;
|
|
155
|
+
/** Moves a node to a different Section entirely (any current parent — another
|
|
156
|
+
* Section, a Cell/row) — backs "move an element to another section" from Manage
|
|
157
|
+
* Layers/the context menu's "Move to Section" submenu. Appends at the target
|
|
158
|
+
* section's end, absolutely positioned near its top-left; a no-op if the node is
|
|
159
|
+
* already a direct child of that section. */
|
|
160
|
+
moveNodeToSection: (nodeId: string, sectionId: string) => void;
|
|
161
|
+
}
|
|
162
|
+
export type CanvasStore = CanvasState & CanvasActions;
|
|
163
|
+
export {};
|