Merge pull request #302 from presenton/fix/new_slide_addition
fix(nextjs): New slide addition issue in presentation
This commit is contained in:
commit
df8167e5bb
4 changed files with 13 additions and 12 deletions
|
|
@ -37,8 +37,10 @@ const NewSlide = ({
|
|||
}
|
||||
};
|
||||
const { getFullDataByGroup, loading } = useLayout();
|
||||
|
||||
const fullData = getFullDataByGroup(group);
|
||||
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="my-6 w-full bg-gray-50 p-8 max-w-[1280px]">
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ const createCacheKey = (groupName: string, fileName: string): string =>
|
|||
|
||||
// Extract Babel compilation logic into a utility function
|
||||
const compileCustomLayout = (layoutCode: string, React: any, z: any) => {
|
||||
|
||||
|
||||
const cleanCode = layoutCode
|
||||
.replace(/import\s+React\s+from\s+'react';?/g, "")
|
||||
.replace(/import\s*{\s*z\s*}\s*from\s+'zod';?/g, "")
|
||||
|
|
@ -350,7 +350,7 @@ export const LayoutProvider: React.FC<{
|
|||
"/api/v1/ppt/template-management/summary"
|
||||
);
|
||||
const customGroupData = await customGroupResponse.json();
|
||||
|
||||
|
||||
const customFonts = new Map<string, string[]>();
|
||||
const customGroup = customGroupData.presentations;
|
||||
for (const group of customGroup) {
|
||||
|
|
@ -365,9 +365,9 @@ export const LayoutProvider: React.FC<{
|
|||
);
|
||||
const customLayoutsData = await customLayoutResponse.json();
|
||||
const allLayout = customLayoutsData.layouts;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const settings = {
|
||||
description: `Custom presentation layouts`,
|
||||
|
|
@ -541,7 +541,7 @@ export const LayoutProvider: React.FC<{
|
|||
layouts.push(layout);
|
||||
}
|
||||
}
|
||||
setCustomTemplateFonts(customFonts);
|
||||
setCustomTemplateFonts(customFonts);
|
||||
// Cache grouped layouts
|
||||
groupedLayouts.set(groupName, groupLayouts);
|
||||
fullDataByGroup.set(groupName, groupFullData);
|
||||
|
|
@ -549,7 +549,7 @@ export const LayoutProvider: React.FC<{
|
|||
} catch (err: any) {
|
||||
console.error("Compilation error:", err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return {
|
||||
layoutsById,
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ export const useLayoutSaving = (
|
|||
const uploadedFontUrls = UploadedFonts.map((font) => font.fontUrl);
|
||||
const googleFontCssUrls = fontsData?.internally_supported_fonts?.map(f => f.google_fonts_url).filter(Boolean) || [];
|
||||
const FontUrls = Array.from(new Set([...(uploadedFontUrls || []), ...googleFontCssUrls]));
|
||||
console.log("FontUrls", FontUrls);
|
||||
|
||||
for (let i = 0; i < slides.length; i++) {
|
||||
const slide = slides[i];
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ const SlideContent = ({ slide, index, presentationId }: SlideContentProps) => {
|
|||
try {
|
||||
trackEvent(MixpanelEvent.Slide_Delete_API_Call);
|
||||
// Add current state to past
|
||||
dispatch(addToHistory({
|
||||
dispatch(addToHistory({
|
||||
slides: presentationData?.slides,
|
||||
actionType: "DELETE_SLIDE"
|
||||
}));
|
||||
dispatch(deletePresentationSlide(slide.index));
|
||||
|
||||
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting slide:", error);
|
||||
toast.error("Error deleting slide.", {
|
||||
|
|
@ -176,12 +176,12 @@ const SlideContent = ({ slide, index, presentationId }: SlideContentProps) => {
|
|||
{showNewSlideSelection && !loading && (
|
||||
<NewSlide
|
||||
index={index}
|
||||
group={slide.layout_group}
|
||||
group={`${slide.layout.split(":")[0]}`}
|
||||
setShowNewSlideSelection={setShowNewSlideSelection}
|
||||
presentationId={presentationId}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
{!isStreaming && !loading && (
|
||||
<ToolTip content="Delete slide">
|
||||
<div
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue