Replaces TSX/Babel compilation pipeline with a JSON element model:
- New _do_parse_v2(): 1 LLM call/layout (vs 2) classifies OXML geometry
elements into placeholder types → JSON stored in layout_code
- SlideRenderer.tsx: renders JSON element model as %-positioned divs,
no Babel compilation or runtime errors
- parseLayoutSchema.ts: isJsonLayoutCode() / parseLayoutSchema() /
mergeElementsWithContent() — full JSON schema parsing layer
- useCustomTemplates.ts: transparent dual-format support (JSON + TSX)
via parsedLayoutToCompiled() adapter
Template management improvements:
- PresentationLayoutCodeModel: +is_enabled (bool) +thumbnail_path (str)
- Migration 005: adds both columns to presentation_layout_codes
- DELETE /master-decks/{id}: hard delete (files + TemplateModel +
PresentationLayoutCodeModel rows + MasterDeckModel)
- PATCH /template-management/layouts/{db_id}/toggle-enabled: new endpoint
- LayoutData response: +db_id, +is_enabled, +thumbnail_path
- _register_as_template(): stores thumbnail_path + is_enabled per layout
Admin UI:
- /admin/templates/ — list all custom templates with delete
- /admin/templates/[id]/ — layout grid with screenshots + enable/disable
- AdminSidebar: Templates nav item
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
from datetime import datetime
|
|
from typing import Optional, List
|
|
import uuid
|
|
from sqlalchemy import Column, DateTime, Text, JSON, Boolean, String
|
|
from sqlmodel import SQLModel, Field
|
|
|
|
from utils.datetime_utils import get_current_utc_datetime
|
|
|
|
|
|
class PresentationLayoutCodeModel(SQLModel, table=True):
|
|
"""Model for storing presentation layout codes"""
|
|
|
|
__tablename__ = "presentation_layout_codes"
|
|
|
|
id: Optional[int] = Field(default=None, primary_key=True)
|
|
presentation: uuid.UUID = Field(index=True, description="UUID of the presentation")
|
|
layout_id: str = Field(description="Unique identifier for the layout")
|
|
layout_name: str = Field(description="Display name of the layout")
|
|
layout_code: str = Field(
|
|
sa_column=Column(Text), description="TSX/React component code for the layout"
|
|
)
|
|
fonts: Optional[List[str]] = Field(
|
|
sa_column=Column(JSON), default=None, description="Optional list of font links"
|
|
)
|
|
is_enabled: bool = Field(
|
|
sa_column=Column(Boolean, default=True, nullable=True),
|
|
default=True,
|
|
description="Whether this layout is enabled for selection"
|
|
)
|
|
thumbnail_path: Optional[str] = Field(
|
|
sa_column=Column(String, nullable=True),
|
|
default=None,
|
|
description="Path to screenshot/thumbnail for this layout"
|
|
)
|
|
created_at: datetime = Field(
|
|
sa_column=Column(
|
|
DateTime(timezone=True), nullable=False, default=get_current_utc_datetime
|
|
)
|
|
)
|
|
updated_at: datetime = Field(
|
|
sa_column=Column(
|
|
DateTime(timezone=True),
|
|
nullable=False,
|
|
default=get_current_utc_datetime,
|
|
onupdate=get_current_utc_datetime,
|
|
),
|
|
)
|