astro-tractstack 2.0.19 → 2.0.20
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 +6 -32
- package/package.json +1 -1
- package/templates/src/components/codehooks/BunnyVideoSetup.tsx +1 -4
- package/templates/src/components/codehooks/FeaturedArticleSetup.tsx +0 -4
- package/templates/src/components/codehooks/ListContentSetup.tsx +1 -8
- package/templates/src/components/codehooks/ProductCardSetup.tsx +0 -2
- package/templates/src/components/codehooks/ProductGridSetup.tsx +0 -2
- package/templates/src/components/compositor/Compositor.tsx +3 -6
- package/templates/src/components/compositor/Node.tsx +13 -32
- package/templates/src/components/compositor/NodeWithGuid.tsx +49 -5
- package/templates/src/components/compositor/nodes/Pane.tsx +4 -21
- package/templates/src/components/compositor/nodes/Pane_DesignLibrary.tsx +27 -7
- package/templates/src/components/compositor/nodes/tagElements/NodeBasicTag.tsx +3 -1
- package/templates/src/components/compositor/preview/OgImagePreview.tsx +0 -5
- package/templates/src/components/compositor/preview/PaneSnapshotGenerator.tsx +5 -6
- package/templates/src/components/compositor/preview/PanesPreviewGenerator.tsx +1 -0
- package/templates/src/components/edit/PanelSwitch.tsx +3 -24
- package/templates/src/components/edit/SettingsPanel.tsx +0 -1
- package/templates/src/components/edit/ToolMode.tsx +6 -14
- package/templates/src/components/edit/pane/AddPanePanel.tsx +45 -25
- package/templates/src/components/edit/pane/AddPanePanel_new.tsx +2 -8
- package/templates/src/components/edit/pane/AddPanePanel_paste.tsx +111 -0
- package/templates/src/components/edit/pane/RestylePaneModal.tsx +6 -13
- package/templates/src/components/edit/pane/steps/AiDesignStep.tsx +0 -5
- package/templates/src/components/edit/pane/steps/DesignLibraryStep.tsx +4 -11
- package/templates/src/components/edit/panels/StyleBreakPanel.tsx +1 -3
- package/templates/src/components/edit/panels/StyleElementPanel_update.tsx +0 -6
- package/templates/src/components/edit/panels/StyleImagePanel_update.tsx +0 -3
- package/templates/src/components/edit/panels/StyleLiElementPanel_update.tsx +0 -4
- package/templates/src/components/edit/panels/StyleLinkPanel_config.tsx +8 -5
- package/templates/src/components/edit/panels/StyleLinkPanel_update.tsx +1 -2
- package/templates/src/components/edit/panels/StyleParentPanel.tsx +1 -3
- package/templates/src/components/edit/panels/StyleParentPanel_update.tsx +2 -5
- package/templates/src/components/edit/panels/StyleWidgetPanel_config.tsx +2 -8
- package/templates/src/components/edit/panels/StyleWidgetPanel_update.tsx +0 -4
- package/templates/src/components/edit/state/SaveToLibraryModal.tsx +27 -16
- package/templates/src/components/edit/storyfragment/StoryFragmentConfigPanel.tsx +9 -26
- package/templates/src/components/edit/storyfragment/StoryFragmentPanel_og.tsx +7 -16
- package/templates/src/components/edit/storyfragment/StoryFragmentPanel_slug.tsx +5 -6
- package/templates/src/components/edit/widgets/InteractiveDisclosureWidget.tsx +0 -5
- package/templates/src/components/fields/BackgroundImageWrapper.tsx +1 -7
- package/templates/src/components/fields/ColorPickerCombo.tsx +8 -12
- package/templates/src/components/fields/ViewportComboBox.tsx +4 -6
- package/templates/src/stores/nodes.ts +14 -6
- package/templates/src/stores/storykeep.ts +3 -3
- package/templates/src/types/compositorTypes.ts +2 -0
- package/templates/src/utils/compositor/TemplatePanes.ts +0 -76
- package/templates/src/utils/compositor/aiPaneParser.ts +3 -1
- package/templates/src/utils/compositor/designLibraryHelper.ts +240 -17
- package/templates/src/utils/helpers.ts +5 -4
- package/utils/inject-files.ts +6 -32
- package/templates/src/components/compositor/preview/VisualBreakPreview.tsx +0 -154
- package/templates/src/components/edit/pane/PageGen_preview.tsx +0 -511
- package/templates/src/utils/compositor/processMarkdown.ts +0 -445
- package/templates/src/utils/compositor/templateMarkdownStyles.ts +0 -1273
package/utils/inject-files.ts
CHANGED
|
@@ -453,6 +453,12 @@ export async function injectTemplateFiles(
|
|
|
453
453
|
src: resolve('../templates/src/components/edit/pane/AddPanePanel.tsx'),
|
|
454
454
|
dest: 'src/components/edit/pane/AddPanePanel.tsx',
|
|
455
455
|
},
|
|
456
|
+
{
|
|
457
|
+
src: resolve(
|
|
458
|
+
'../templates/src/components/edit/pane/AddPanePanel_paste.tsx'
|
|
459
|
+
),
|
|
460
|
+
dest: 'src/components/edit/pane/AddPanePanel_paste.tsx',
|
|
461
|
+
},
|
|
456
462
|
{
|
|
457
463
|
src: resolve(
|
|
458
464
|
'../templates/src/components/edit/pane/AddPanePanel_break.tsx'
|
|
@@ -549,22 +555,6 @@ export async function injectTemplateFiles(
|
|
|
549
555
|
),
|
|
550
556
|
dest: 'src/components/edit/context/ContextPaneConfig_slug.tsx',
|
|
551
557
|
},
|
|
552
|
-
{
|
|
553
|
-
src: resolve('../templates/src/components/edit/pane/PageGenSelector.tsx'),
|
|
554
|
-
dest: 'src/components/edit/pane/PageGenSelector.tsx',
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
src: resolve('../templates/src/components/edit/pane/PageGenSpecial.tsx'),
|
|
558
|
-
dest: 'src/components/edit/pane/PageGenSpecial.tsx',
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
src: resolve('../templates/src/components/edit/pane/PageGen.tsx'),
|
|
562
|
-
dest: 'src/components/edit/pane/PageGen.tsx',
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
src: resolve('../templates/src/components/edit/pane/PageGen_preview.tsx'),
|
|
566
|
-
dest: 'src/components/edit/pane/PageGen_preview.tsx',
|
|
567
|
-
},
|
|
568
558
|
// Compositor previews
|
|
569
559
|
{
|
|
570
560
|
src: resolve(
|
|
@@ -584,12 +574,6 @@ export async function injectTemplateFiles(
|
|
|
584
574
|
),
|
|
585
575
|
dest: 'src/components/compositor/preview/OgImagePreview.tsx',
|
|
586
576
|
},
|
|
587
|
-
{
|
|
588
|
-
src: resolve(
|
|
589
|
-
'../templates/src/components/compositor/preview/VisualBreakPreview.tsx'
|
|
590
|
-
),
|
|
591
|
-
dest: 'src/components/compositor/preview/VisualBreakPreview.tsx',
|
|
592
|
-
},
|
|
593
577
|
{
|
|
594
578
|
src: resolve(
|
|
595
579
|
'../templates/src/components/compositor/preview/ListContentPreview.tsx'
|
|
@@ -653,16 +637,6 @@ export async function injectTemplateFiles(
|
|
|
653
637
|
src: resolve('../templates/src/utils/compositor/aiPaneParser.ts'),
|
|
654
638
|
dest: 'src/utils/compositor/aiPaneParser.ts',
|
|
655
639
|
},
|
|
656
|
-
{
|
|
657
|
-
src: resolve('../templates/src/utils/compositor/processMarkdown.ts'),
|
|
658
|
-
dest: 'src/utils/compositor/processMarkdown.ts',
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
src: resolve(
|
|
662
|
-
'../templates/src/utils/compositor/templateMarkdownStyles.ts'
|
|
663
|
-
),
|
|
664
|
-
dest: 'src/utils/compositor/templateMarkdownStyles.ts',
|
|
665
|
-
},
|
|
666
640
|
{
|
|
667
641
|
src: resolve(
|
|
668
642
|
'../templates/src/utils/compositor/nodesMarkdownGenerator.ts'
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { NodesContext } from '@/stores/nodes';
|
|
3
|
-
import { createEmptyStorykeep } from '@/utils/compositor/nodesHelper';
|
|
4
|
-
import { getTemplateVisualBreakPane } from '@/utils/compositor/TemplatePanes';
|
|
5
|
-
import {
|
|
6
|
-
PanesPreviewGenerator,
|
|
7
|
-
type PanePreviewRequest,
|
|
8
|
-
type PaneFragmentResult,
|
|
9
|
-
} from '@/components/compositor/preview/PanesPreviewGenerator';
|
|
10
|
-
import {
|
|
11
|
-
PaneSnapshotGenerator,
|
|
12
|
-
type SnapshotData,
|
|
13
|
-
} from '@/components/compositor/preview/PaneSnapshotGenerator';
|
|
14
|
-
|
|
15
|
-
interface VisualBreakPreviewProps {
|
|
16
|
-
bgColour: string;
|
|
17
|
-
fillColour: string;
|
|
18
|
-
variant?: string; // Optional variant name for the visual break
|
|
19
|
-
height?: number; // Optional height for the container
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// The state is managed as a single object since this component only ever handles one preview at a time.
|
|
23
|
-
// This is slightly simpler than managing an array with a single item.
|
|
24
|
-
type PreviewState = {
|
|
25
|
-
htmlFragment?: string;
|
|
26
|
-
snapshot?: SnapshotData;
|
|
27
|
-
error?: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Renders a preview of a single visual break variant.
|
|
32
|
-
*
|
|
33
|
-
* This component uses a modern two-step process for efficiency:
|
|
34
|
-
* 1. It uses PanesPreviewGenerator to fetch an HTML fragment of the break.
|
|
35
|
-
* 2. It then uses PaneSnapshotGenerator to convert that HTML into an image snapshot.
|
|
36
|
-
*/
|
|
37
|
-
export const VisualBreakPreview = ({
|
|
38
|
-
bgColour,
|
|
39
|
-
fillColour,
|
|
40
|
-
variant = 'cutwide2', // Default to cutwide2 as it's a commonly used break
|
|
41
|
-
height = 120, // Default height that works well for most breaks
|
|
42
|
-
}: VisualBreakPreviewProps) => {
|
|
43
|
-
const [previewState, setPreviewState] = useState<PreviewState | null>(null);
|
|
44
|
-
const [fragmentRequest, setFragmentRequest] = useState<PanePreviewRequest[]>(
|
|
45
|
-
[]
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
// Reset state whenever the props change to trigger a full regeneration
|
|
50
|
-
setPreviewState(null);
|
|
51
|
-
|
|
52
|
-
// STEP 1: Create a temporary NodesContext for the preview.
|
|
53
|
-
const ctx = new NodesContext();
|
|
54
|
-
ctx.addNode(createEmptyStorykeep('tmp')); // Add root node
|
|
55
|
-
|
|
56
|
-
// Get the template for the specified variant and apply the dynamic colours
|
|
57
|
-
const template = getTemplateVisualBreakPane(variant);
|
|
58
|
-
if (template) {
|
|
59
|
-
if (template.bgColour) template.bgColour = bgColour;
|
|
60
|
-
if (template.bgPane && template.bgPane.type === 'visual-break') {
|
|
61
|
-
if (template.bgPane.breakDesktop) {
|
|
62
|
-
template.bgPane.breakDesktop.svgFill = fillColour;
|
|
63
|
-
}
|
|
64
|
-
if (template.bgPane.breakTablet) {
|
|
65
|
-
template.bgPane.breakTablet.svgFill = fillColour;
|
|
66
|
-
}
|
|
67
|
-
if (template.bgPane.breakMobile) {
|
|
68
|
-
template.bgPane.breakMobile.svgFill = fillColour;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
ctx.addTemplatePane('tmp', template); // Add the template to the context
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Prepare a request for the PanesPreviewGenerator to get the HTML.
|
|
75
|
-
setFragmentRequest([{ id: 'visual-break-preview', ctx }]);
|
|
76
|
-
}, [variant, bgColour, fillColour]);
|
|
77
|
-
|
|
78
|
-
// Handler for when the HTML fragment has been generated
|
|
79
|
-
const handleFragmentComplete = (results: PaneFragmentResult[]) => {
|
|
80
|
-
const result = results[0];
|
|
81
|
-
if (result?.htmlString) {
|
|
82
|
-
setPreviewState({ htmlFragment: result.htmlString });
|
|
83
|
-
} else {
|
|
84
|
-
setPreviewState({
|
|
85
|
-
error: result?.error || 'Failed to generate HTML fragment.',
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
setFragmentRequest([]); // Clear the request to prevent re-fetching
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// Handler for when the image snapshot has been generated from the HTML.
|
|
92
|
-
// The 'id' parameter is unused here as we only manage one snapshot at a time.
|
|
93
|
-
const handleSnapshotComplete = (data: SnapshotData) => {
|
|
94
|
-
setPreviewState((prev) => (prev ? { ...prev, snapshot: data } : null));
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Display a pulsing placeholder while the process is running
|
|
98
|
-
if (!previewState) {
|
|
99
|
-
return <div className="my-4 h-12 animate-pulse bg-gray-200" />;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Display an error message if something went wrong
|
|
103
|
-
if (previewState.error) {
|
|
104
|
-
return (
|
|
105
|
-
<div className="flex items-center justify-center rounded-md border border-red-200 bg-red-50 p-4 text-sm text-red-700">
|
|
106
|
-
Preview could not be generated: {previewState.error}
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div
|
|
113
|
-
className="relative w-full overflow-hidden"
|
|
114
|
-
style={!previewState.snapshot ? { height: `${height}px` } : undefined}
|
|
115
|
-
>
|
|
116
|
-
{/* STEP 2: Render the generator to fetch the HTML fragment. This component renders nothing itself. */}
|
|
117
|
-
{fragmentRequest.length > 0 && (
|
|
118
|
-
<PanesPreviewGenerator
|
|
119
|
-
requests={fragmentRequest}
|
|
120
|
-
onComplete={handleFragmentComplete}
|
|
121
|
-
onError={(err) => setPreviewState({ error: err })}
|
|
122
|
-
/>
|
|
123
|
-
)}
|
|
124
|
-
|
|
125
|
-
{/* STEP 3: Once HTML is available, render the snapshot generator to create the image. This component also renders nothing. */}
|
|
126
|
-
{previewState.htmlFragment && !previewState.snapshot && (
|
|
127
|
-
<PaneSnapshotGenerator
|
|
128
|
-
id="visual-break-snapshot"
|
|
129
|
-
htmlString={previewState.htmlFragment}
|
|
130
|
-
outputWidth={800} // Matches the original output width
|
|
131
|
-
onComplete={(_id, data) => handleSnapshotComplete(data)}
|
|
132
|
-
onError={(_id, err) =>
|
|
133
|
-
setPreviewState((prev) =>
|
|
134
|
-
prev ? { ...prev, error: err } : { error: err }
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
/>
|
|
138
|
-
)}
|
|
139
|
-
|
|
140
|
-
{/* STEP 4: Once the snapshot is complete, display the final image. */}
|
|
141
|
-
{previewState.snapshot && (
|
|
142
|
-
<div className="w-full">
|
|
143
|
-
<img
|
|
144
|
-
src={previewState.snapshot.imageData}
|
|
145
|
-
alt={`Visual break ${variant}`}
|
|
146
|
-
className="w-full"
|
|
147
|
-
/>
|
|
148
|
-
</div>
|
|
149
|
-
)}
|
|
150
|
-
</div>
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export default VisualBreakPreview;
|