import { HttpErrorResponse } from '@angular/common/http'; import { CdkDrag, CdkDragDrop } from '@angular/cdk/drag-drop'; import { MatButtonToggleChange } from '@angular/material/button-toggle'; import { Observable } from 'rxjs'; import { IStructure, IUserTemplate } from '../../interfaces/interfaces'; import { TBlocks } from '../../classes/Elements'; import { IPEmail } from '../../classes/DefaultEmail'; import { TPreviewDevice } from '../../components/preview.component'; /** * Email editor export file types. */ export declare type TExportType = 'html' | 'json' | 'mjml'; /** * Email editor import file types. 'mjml' type is under development - don't use it yet. */ export declare type TImportType = 'json' | 'mjml'; /** * Add new Structure within email body event */ export interface IAddStructureEvent extends CdkDragDrop, Set> { item: CdkDrag; } /** * Add new Block within structures' columns event */ export interface IAddBlockEvent extends CdkDragDrop { item: CdkDrag; } /** * Preview device buttons */ export interface IPreviewToggleButton extends MatButtonToggleChange { value: TPreviewDevice; } /** * This service allows you to control all your users' abilities within this builder. Lets say you want to implement user Roles or just * need to disable some functionality for certain users based on purchase plan or on something else. You can allow or disallow almost * everything. * * All the methods must return an Observable, so, in my opinion, that's the best part of this service, you can either return an * [EMPTY Observable]{@link https://rxjs.dev/api/index/const/EMPTY}, a modified object or an (Info Modal).pipe(mapTo(EMPTY)) - I think you * got the idea. * * I recommend always using a Modal or a Toast for forbidden actions. * * It won't work if you have a Regular/Free License - you'll get an error on running the project, * you need either an [Extended or Commercial License]{@link https://wlocalhost.org} key for this purpose. * * @example * // Create a custom service * class YourOwnMiddlewareService extends IpUserMiddlewaresService {} * * // Rewrite it into AppModule * { provide: IpUserMiddlewaresService, useClass: YourOwnMiddlewareService } */ export declare abstract class IpUserMiddlewaresService { /** * This method is called before sending the request to MJML Convertor. Use it to add some additional blocks or anything else to * the IPEmail object. * @param email IPEmail object that's being sent to MJML Convertor. */ createHTMLTemplate(email: IPEmail): Observable; /** * Allow or Disallow preview window. * @param state Coming Preview state */ togglePreview(state: boolean): Observable; /** * Allow or Disallow preview devices. * @param button Device's button that has been clicked */ togglePreviewDevice(button: IPreviewToggleButton): Observable; /** * Allow or disallow users to select certain templates based either on category or template object. * @param category Template's category user has selected * @param template Template user has selected */ chooseTemplate(category: string, template: IUserTemplate): Observable<{ category: string; template: IUserTemplate; }>; /** * Allow, disallow or return the same path for all user's uploaded images. * @param path Path of uploaded image * * @TODO Check if this middleware is being called before image has been uploaded */ uploadImage(path: string): Observable; /** * Allow or disallow users to add blocks within email structures. * @param event Event of dropped block * @param column Column that block has been dropped * * @TODO add parent structure as a parameter */ addBlock(event: IAddBlockEvent, column: TBlocks[]): Observable<{ column: TBlocks[]; event: IAddBlockEvent; }>; /** * Prevent user to edit blocks within email body. * @param block Block that user intends to edit */ editBlock(block: TBlocks): Observable; /** * Prevent user to remove blocks within email body. * @param index Block's Index * @param column Block's parent column * @param block Block that user intends to remove */ removeBlock(index: number, column: TBlocks[], block: TBlocks): Observable<{ index: number; column: TBlocks[]; }>; /** * Prevent user to duplicate blocks within email body. * @param index Block's Index * @param column Block's parent column * @param block Block that user intends to duplicate */ duplicateBlock(index: number, column: TBlocks[], block: TBlocks): Observable<{ index: number; column: TBlocks[]; block: TBlocks; }>; /** * Disable Drag and Drop certain blocks from Blocks list to Email body. * Return TRUE to disable all blocks - no matter on block's data. * @param block Block to allow or disallow from being dragged */ disableBlockDragFromList(block: TBlocks): Observable; /** * Prevent users to sort blocks within email body. * @param block Block that user intends to change the order */ disableBlockDragWithinEmailBody(block: TBlocks): Observable; /** * Prevent user to add new structure. * @param event Event of dropped structure */ addStructure(event: IAddStructureEvent): Observable; /** * Prevent user to edit the structure. * @param structure Structure that user intends to edit */ editStructure(structure: IStructure): Observable; /** * Prevent user to remove the structure. * @param index Index of the structure * @param structure Structure that user intends to remove */ removeStructure(index: number, structure: IStructure): Observable; /** * Prevent user to duplicate the structure within email body. * @param index Index of structure * @param structure Structure that user intends to duplicate */ duplicateStructure(index: number, structure: IStructure): Observable; /** * Disable Drag and Drop certain structures from Structures list to Email body. * Return TRUE to disable all structures. * @param structure Structure to prevent from being dragged */ disableStructureDragFromList(structure: IStructure): Observable; /** * Allow or disallow users to sort structures within email body. * @param structure Structure that user intends to change the order */ disableStructureDragWithinEmailBody(structure: IStructure): Observable; /** * I don't know why would you do that, but you can disable OnExit confirm modal. * @param event Window [BeforeUnloadEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/BeforeUnloadEvent} */ preventWindowExit(event: BeforeUnloadEvent): Observable; /** * Allow or disallow user to export certain types of file * @param type Type that user intends to download */ exportFile(type: TExportType): Observable; /** * Allow or disallow user to import certain types of file * @param file Web APIs [FILE]{@link https://developer.mozilla.org/en-US/docs/Web/API/File} */ importFile(file: File): Observable; /** * Catch all errors within email editor, it might not work 100%, it's still on working process. * @param error Throwable Error */ catchError(error: Error | HttpErrorResponse): Observable; }