@imgly/idml-importer
Version:
Import IDML files into the Creative Editor Ecosystem
114 lines (110 loc) • 3.47 kB
TypeScript
// Generated by dts-bundle-generator v8.0.1
import CreativeEngine from '@cesdk/engine';
import { Font, Typeface } from '@cesdk/engine';
export interface TypefaceParams {
family: string;
style: Font["style"];
weight: Font["weight"];
}
export type TypefaceResolver = (fontParameters: TypefaceParams, engine: CreativeEngine) => Promise<FontResolverResult | null>;
export declare function addGoogleFontsAssetLibrary(engine: CreativeEngine, url?: string): Promise<boolean | void>;
export interface FontResolverResult {
typeface: Typeface;
font: Font;
}
export type LogMessage = {
message: string;
type: "error" | "warning" | "info";
};
export declare class Logger {
private static instance;
constructor();
private messages;
log(message: string, type?: "error" | "warning" | "info"): void;
getMessages(): LogMessage[];
}
export declare class IDMLParser {
private engine;
private scene;
private idml;
private fontResolver;
private colors;
private gradients;
private spreads;
private logger;
private constructor();
/**
* Instantiate a new IDMLParser from a File or Blob
*
* @param cesdk The CreativeEditorSDK instance
* @param file The IDML file
* @param fontResolver A function that resolves the font URI from the font name and style
* @returns A new IDMLParser instance
*/
static fromFile(engine: CreativeEngine, file: Blob | File | ArrayBuffer, DOMParser: any, fontResolver?: TypefaceResolver): Promise<IDMLParser>;
parse(): Promise<{
scene: number;
logger: Logger;
}>;
private getSpreads;
private getBleedMargins;
private generatePagesFromSpreads;
private processMultiFrameStories;
/**
* Loop over the page elements and render the CESDK blocks based on the element type
*
* @param element The page element
* @param spread The page element's parent page
* @param pageBlock The page block to append the rendered blocks to
* @returns An array of the rendered blocks
*/
private renderPageElements;
/**
* Parses the name of an IDML element and applies it to a CE.SDK block
*
* @param element The IDML element
* @param block The CE.SDK block
* @returns void
*/
private copyElementName;
/**
* Parses the fill styles of an IDML element and applies them to a CESDK block
*
* @param block The CESDK block to apply the fill to
* @param element The IDML element
* @param attributeName The name of the attribute to use as the fill color
* @returns void
*/
private applyFill;
/**
* Parses the stroke styles of an IDML element and applies them to a CESDK block
*
* @param block The CESDK block to apply the stroke to
* @param element The IDML element
* @returns void
*/
private applyStroke;
/**
* Parses the transparency styles of an IDML element and applies them to a CESDK block
*
* @param block The CESDK block to apply the transparency to
* @param element The IDML element
* @returns void
*/
private applyTransparency;
/**
* Parses the image fill of an IDML element and applies it to a CESDK block
* @param block The CESDK block to apply the image fill to
* @param element The IDML element
* @returns Promise<boolean> True if the image fill was applied, false otherwise
*/
private applyImageFill;
/**
* Parses the corner radius of an IDML element and applies it to a CESDK block
* @param block The CESDK block to apply the corner radius to
* @param element The IDML element
* @returns void
*/
private applyBorderRadius;
}
export {};