The Email Template Editor is a comprehensive drag-and-drop email template creation system that allows users to design, edit, and manage email templates for review requests. Built around the Stripo email editor API, this feature provides a WYSIWYG interface where users can create personalized email templates with merge tags, validate content structure, import designs from other stores, and support multilingual content. The editor integrates with Yotpo's review request system, enabling users to craft engaging emails that drive customer engagement and review collection across different email types including reminders, targeted product requests, and site review requests.
graph TB
Container[EmailTemplateEditorContainerComponent] --> TemplateEditor[TemplateEditorComponent]
Container --> ToolbarMenu[TemplateEditorToolbarMenuComponent]
Container --> ImportModal[ImportEmailTemplateConfirmationModalComponent]
TemplateEditor --> StripoService[StripoService]
Container --> StripoService
Container --> StoresService[StoresService]
Container --> BlockValidator[StripoBlockValidationService]
Container --> MergeTagValidator[StripoMergeTagValidationService]
Container --> LoyaltyTracking[LoyaltyTrackingAnalyticsService]
subgraph "External Dependencies"
StripoAPI[Stripo API]
YotpoAPI[Yotpo Backend]
EmailTemplatesService[EmailTemplatesService]
end
StripoService --> StripoAPI
StoresService --> YotpoAPI
Container --> EmailTemplatesService
subgraph "Data Flow"
TemplateContent[TemplateContent]
EditorConfig[EditorConfig]
Store[Store]
end
Container --> TemplateContent
Container --> EditorConfig
Container --> Store
flowchart TD
User[User Action] --> Container[Container Component]
Container --> Init[Initialize Editor]
Init --> LoadTemplate[Load Template from API]
LoadTemplate --> StripoService[Stripo Service]
StripoService --> StripoAPI[Stripo API]
StripoAPI --> EditorReady[Editor Ready]
EditorReady --> UserEdit[User Edits Template]
UserEdit --> ContentChange[Content Change Event]
ContentChange --> Validation[Content Validation]
Validation --> BlockValidator[Block Validation Service]
Validation --> MergeTagValidator[Merge Tag Validation]
Validation --> ContentValidator[Content Validator]
BlockValidator --> ValidationResult[Validation Result]
MergeTagValidator --> ValidationResult
ContentValidator --> ValidationResult
ValidationResult --> SaveTemplate[Save Template]
SaveTemplate --> YotpoAPI[Yotpo Backend]
YotpoAPI --> SaveResult[Save Result]
SaveResult --> User[User Feedback]
subgraph "Import Flow"
ImportRequest[Import Request] --> StoresService[Stores Service]
StoresService --> GetStores[Get Available Stores]
GetStores --> ImportDesign[Import Design]
ImportDesign --> TemplateUpdate[Update Template]
end
- Purpose: Main container component that orchestrates the entire email template editing experience, managing state, validation, and user interactions.
- Inputs (
@Input
):- None (root component)
- Outputs (
@Output
):- None (handles events internally)
- Key Methods:
init()
: Initializes the editor with template data and configurationonSaveButtonClick()
: Handles template saving with validationswitchLanguage()
: Manages multilingual template switching
- Purpose: Wrapper component that integrates the Stripo email editor and manages editor lifecycle events.
- Inputs (
@Input
):storeId: string
- Identifier for the current storeemailType: EmailType
- Type of email being edited (reminder, targeted request, etc.)reminderId: number
- ID of the reminder being editedname: string
- Display name for the templatecontent: TemplateContent
- HTML and CSS content of the templateconfig: EditorConfig
- Configuration object for the Stripo editor
- Outputs (
@Output
):onError: EventEmitter<Event>
- Emitted when editor encounters an erroronLoad: EventEmitter<Event>
- Emitted when editor is fully loadedonContentChange: EventEmitter<Event>
- Emitted when template content changesonResetToDefault: EventEmitter<void>
- Emitted when user requests template reset
- Key Methods:
onEditorLoaded()
: Handles editor initialization and Stripo API setuponContentChanged()
: Processes content change events from the editor
- Purpose: Simple toolbar component that provides reset functionality for the template editor.
- Inputs (
@Input
):- None
- Outputs (
@Output
):onResetToDefault: EventEmitter<void>
- Emitted when reset button is clicked
- Key Methods:
handleResetToDefaultButtonClicked()
: Triggers the reset event
- Purpose: Modal component that allows users to import email template designs from other stores.
- Inputs (
@Input
):open: boolean
- Controls modal visibilityisLoading: boolean
- Shows loading state during importrelatedStores: Store[]
- List of available stores to import from
- Outputs (
@Output
):onClose: EventEmitter<boolean>
- Emitted when modal is closedonImportDesign: EventEmitter<string>
- Emitted when import is confirmed with store ID
- Key Methods:
importDesign()
: Triggers the import processhideImportEmailTemplateConfirmationModal()
: Closes the modal
- Purpose: Core service that manages the Stripo email editor integration, handles API communication, and provides editor lifecycle management.
- Key Public Methods:
addCommonServicesToWindow(useGraphQLAPIFF: boolean): void
- Injects required services into global window object for Stripo editorsetStripoApi(stripoApi: StripoApi): void
- Sets the Stripo API instance for editor operationsstopEditor(): void
- Stops and cleans up the editor instanceget isAllDataSaved(): boolean
- Checks if all editor data is saved
- State Management: Maintains
stripoApi
instance andemailId
for current editing session
- Purpose: Service for managing store-related operations, particularly for importing email template designs from other stores.
- Key Public Methods:
getStores(): Observable<Store[]>
- Retrieves list of available stores for import operationsimportDesign(sourceStoreId: string): Observable<Object>
- Imports email design from specified source store
- State Management: No internal state, provides stateless API operations
- Purpose: Service responsible for validating the structure and content of email template blocks, ensuring proper email composition.
- Key Public Methods:
isStarsBlockValid(block: Element): boolean
- Validates that stars rating block contains required elementsgetStarsRatingBlockError(html: string): string[]
- Returns validation errors for stars rating blocksgetEmailBodyBlockError(html: string): string
- Validates presence of required email body blocks
- State Management: No internal state, provides validation logic
- Purpose: Service for validating merge tags in email templates, ensuring proper syntax and allowed tag usage.
- Key Public Methods:
getAllTagsFromHTML(html: string): string[]
- Extracts all merge tags from HTML contentgetValidTagsFromHTML(html: string): string[]
- Filters and validates merge tag syntaxgetMergeTagsValidationErrors(tags: string[], emailType): string[]
- Validates mandatory merge tags for specific email typesgetAllowedTagsErrors(tags: string[]): string[]
- Validates that only allowed merge tags are used
- State Management: No internal state, provides validation logic
- Purpose: Service for tracking user interactions and events within the email template editor for analytics purposes.
- Key Public Methods:
trackEvent(event: Partial<TrackingEvent>, additionalData?: any): void
- Tracks user events with optional additional data
- State Management: No internal state, provides analytics tracking functionality
TemplateContent
: Defines the structure of email template content withhtml: string
andcss: string
propertiesTemplateParams
: Contains template identification parameters includingemailId: number
,emailType: EmailType
, andstoreId: string
TemplateEditorErrors
: Defines validation error structure with properties for parse errors, merge tag errors, and block validation errors
StripoApi
: Interface defining the contract for Stripo editor API methods including initialization, template retrieval, and compilationApiRequestData
: Basic request data structure for API calls withemailId: number
and optionalstoreId: string
FeatureState
: Type for feature flag states combining feature name and boolean value
Store
: Represents a store entity with properties for identification, creation date, enabled product categories, and store detailsContextData
: Simple context data structure with optionalstoreUrl
propertyTrackingEvent
: Analytics event structure witheventName: string
andproduct: string
properties
MERGE_TAGS_MANDATORY
: Object containing required merge tags for standard email templatesMERGE_TAGS_MANDATORY_DISCOUNT
: Required merge tags specifically for discount-related emailsallowedTags
: Array of all permitted merge tags for email templatesMERGE_TAGS_OPTIONAL
: Object containing optional merge tags for enhanced personalization
The email template editor feature provides a comprehensive solution for creating and managing email templates within the Yotpo review request system, with robust validation, multilingual support, and seamless integration with external email editing services.