UNPKG

@imgly/idml-importer

Version:

Import IDML files into the Creative Editor Ecosystem

169 lines (165 loc) 6.08 kB
// Generated by dts-bundle-generator v9.5.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 addGfontsAssetLibrary(engine: CreativeEngine): Promise<void>; export interface FontResolverResult { typeface: Typeface; font: Font; substitutedFrom?: string; } 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 fontMetricsCache; private loggedFontSubstitutions; private constructor(); private loadFontMetrics; /** * 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 ctx The style context for the IDML element * @param attributeName The name of the attribute to use as the fill color * @returns void */ private applyFill; /** * Creates a graphic rect block with a stroke outline and no fill. * InDesign TextFrame strokes are borders around the frame rectangle, * but CE.SDK text strokes outline individual glyphs. This helper creates * a separate graphic block to faithfully represent the frame border. * * @param scale The element's combined transform scale, forwarded to * applyBorderRadius so corner radii stay proportional to the block size. */ private createStrokeRectBlock; /** * 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 ctx The style context for 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 ctx The style context for the IDML element * @returns void */ private applyTransparency; /** * Parses the drop shadow settings of an IDML element and applies them to a CESDK block. * * @param block The CESDK block to apply the drop shadow to * @param transparencySetting The TransparencySetting element containing the DropShadowSetting */ private applyDropShadow; /** * 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; /** * Extracts the image content transform from the IDML Image element's ItemTransform * and applies it as CE.SDK crop parameters (rotation, scale, translation). * * In IDML, the Image element inside a frame has its own ItemTransform [a,b,c,d,tx,ty] * that maps image pixel coordinates to the frame's local point coordinates. * The FrameFittingOption crop values define how far the image extends beyond * (positive) or falls short of (negative) the frame edges. */ private applyImageContentTransform; /** * 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 ctx The style context for the IDML element * @param scale The element's combined transform scale factor. IDML corner * radii are in the element's local coordinate space (points), but the * block's width/height have already been scaled by the transform. The * radius must be scaled by the same factor to remain proportional. */ private applyBorderRadius; /** * Creates a graphic block with a vector_path shape from the parent element's * PathGeometry, suitable for use as a clipping mask with engine.block.combine(). */ private createClipMaskBlock; /** * Clips a child block to the parent element's shape using boolean intersection. * Preserves pre-existing crop transforms on image blocks. * For group blocks, recursively clips each child in the group. */ private applyClipMask; /** * Extracts the line height multiplier from IDML paragraph/character style elements. * Leading can be specified as an explicit value in points or as "Auto". * * @param paragraphStyleRange - The ParagraphStyleRange element from the story * @param appliedParagraphStyle - The resolved ParagraphStyle from Styles.xml * @returns The line height as a multiplier and whether it's auto-based leading */ private getLineHeightFromIDML; } export {};