# @imgly/idml-importer

## 1.5.3

### Patch Changes

- Fixed IDML import failing with `TypeError: getTextRuns is not a function` on CE.SDK engines older than 1.77. The line-height handling called `getTextRuns` (added in engine 1.77) unconditionally, even though the package supports `@cesdk/engine` from 1.72, so any text-containing document failed to import on 1.72–1.76 hosts. The call is now feature-detected and falls back to the block-level font (`text/fontFileUri`) when the API is unavailable, so imports succeed across the full supported engine range.

## 1.5.2

### Patch Changes

- Per-paragraph line height is temporarily disabled; the importer once again applies a single block-level line height to each text block. The editor UI does not yet read or edit per-paragraph line height — it exposes only the block-level value and would collapse a block's paragraphs to that single value on the first edit — so importing per-paragraph leading produced scenes the editor silently degraded. Multi-paragraph blocks with differing leading now adopt the first paragraph's line height, and `TEXT_LEADING_APPROX` is again emitted whenever a block combines explicit leading with mixed font sizes. This reverts the per-paragraph leading behavior shipped in 1.5.1; it will return once the editor supports it.

## 1.5.1

### Patch Changes

- Gradient-filled `TextFrame`s are now imported instead of dropping their fill. CE.SDK text blocks cannot carry a gradient background fill, so a gradient-filled text frame previously lost its fill entirely; it is now rendered as a separate graphic block placed behind the text — the same split already used for solid fills and strokes — sized before the fill is applied so the gradient control points resolve against the frame's dimensions.
- Fixed imported line height (leading) and paragraph spacing rendering too tall under the engine's default text layout. Since CE.SDK 1.73 the default layout (`features/fontLineGapEnabled`, on by default) folds the font's line gap into the line height, but the importer still mapped InDesign's leading — which ignores the line gap — onto the pre-1.73 model. The importer now reads each block's resolved font metrics and converts the leading into the line-gap model, so text matches InDesign regardless of how the editor's `fontLineGapEnabled` setting is configured.
- Fixed text blocks occasionally being imported without a typeface. When a paragraph's styled character ranges produced no per-range content, the run covering the start of the text was left with no font, so it rendered with the engine's default and its leading was silently skipped. Every text block is now guaranteed a typeface, so font metrics — and therefore correct leading — are always available.
- Leading is now resolved per paragraph instead of per block. InDesign stores leading per paragraph and the points→multiplier conversion is font-metric-specific, but the importer collapsed each text block to a single line height derived from the first paragraph — so a small body paragraph stacked under a large headline inherited the headline's spacing. Each paragraph's line height is now computed from its own font metrics via `setTextLineHeight(block, value, paragraphIndex)` (CE.SDK ≥ 1.76), falling back to the block-level default on older engines and for paragraphs whose character offset cannot be resolved. `TEXT_LEADING_APPROX` is now emitted only when a single paragraph mixes font sizes.
- Fixed gradient fills running the wrong way across flipped or 180°-rotated elements. The shape was mirrored via its `ItemTransform` but the normalized gradient control points were left untouched, so the ramp ran backwards across the shape; the control points are now mirrored across any axis whose transform diagonal entry is negative.
- Fixed clipped gradient (and solid) fills rendering as a white block. Clipping composed an image-style crop onto the fill, displacing it out of view; the bounds-delta crop is now applied only to image fills, while gradient and solid fills re-map to the clipped shape automatically.
- Fixed embedded SVGs being stretched to the frame aspect and pushed off-frame. The image crop extent was derived from the IDML `GraphicBounds` (the artwork's ink box), but CE.SDK rasterizes the full SVG viewport; the SVG's intrinsic size (absolute `width`/`height` when present, else the `viewBox`) is now used as the crop extent for SVG elements. Raster images still use `GraphicBounds`.
- Fixed text nested in inline wrapper elements being dropped on import. `CharacterStyleRange` content was read from direct children only, so runs inside wrappers — most commonly hyperlinked text (`HyperlinkTextSource`) — vanished. Content is now extracted recursively, descending into inline wrappers while skipping containers whose text is not part of the inline flow (`Properties`, `Footnote`, `Note`, `Table`).

## 1.5.0

### Minor Changes

- Embedded PDFs (and Adobe Illustrator `.ai` files, which are PDF-format internally) can now be imported as editable CE.SDK blocks via `@imgly/pdf-importer` instead of being replaced with a placeholder image. The feature is opt-in: install `@imgly/pdf-importer` and register its adapter explicitly via the new `embeddedImporters` option on `IDMLParser.fromFile`:

  ```ts
  import { PDFParser } from "@imgly/pdf-importer";
  import {
    IDMLParser,
    createPdfEmbeddedImporter,
  } from "@imgly/idml-importer";

  await IDMLParser.fromFile(engine, file, DOMParser, {
    embeddedImporters: [createPdfEmbeddedImporter(PDFParser)],
  });
  ```

  Without the adapter, embedded PDFs fall through to a placeholder (existing behavior). `@imgly/idml-importer` does not import `@imgly/pdf-importer` itself — there is no peer dependency, no dynamic import, and no install/bundle cost for consumers who don't enable the feature.

- Added an `EmbeddedImporter` extension point with new public exports: `createPdfEmbeddedImporter` and the types `EmbeddedFormatParser`, `EmbeddedBlockLoader`, `EmbeddedImporter`, `EmbeddedImporterContext`, `EmbeddedImporterResult`, and `EmbeddedContentPlacementResult`. Each `create…EmbeddedImporter(ParserClass)` factory takes a parser class that satisfies the structural `EmbeddedFormatParser` contract and returns an adapter for the `embeddedImporters` array. The same shape will apply to future PSD / EPS adapters — they'll be added as additional `createPsdEmbeddedImporter`, `createEpsEmbeddedImporter` factories without touching the IDML parser core.

- `IDMLParser.fromFile` now takes its non-DOM arguments as an options object: `IDMLParser.fromFile(engine, file, DOMParser, { fontResolver?, embeddedImporters? })`. The previous positional `fontResolver` 4th-argument form still works (with `@deprecated`) for back-compat with code on the public 1.4.0 release line.

- Embedded content placement now composes the full ancestor `ItemTransform` chain (rectangle → group wrappers → inner content) before decomposing into page-local coordinates, so rotated and flipped frames land correctly. Existing axis-aligned cases are unchanged.

### Patch Changes

- JSZip is no longer bundled into the package output. It is now externalized and resolved from the consumer's installed copy (still declared as a runtime `dependency`), so projects that also use other IMG.LY importers (e.g. `@imgly/pptx-importer`) share a single JSZip instance instead of shipping duplicate copies.

## 1.4.0

### Minor Changes

- **BREAKING**: Renamed exported helper `addGoogleFontsAssetLibrary` → `addGfontsAssetLibrary`. Update your imports and call sites. The new helper registers two CDN-hosted asset sources — `ly.img.gfonts` (1,394 Google Fonts) and `ly.img.gfonts-fallbacks` (16 proprietary-font aliases like Helvetica→Roboto) — from the new shared `@imgly/gfonts` package. The package no longer ships `assets/google-fonts/`. Customers who referenced the previous `ly.img.google-fonts` asset source ID directly (e.g. via `engine.asset.findAssets` or `addAssetToSource`) must also update to `ly.img.gfonts`. The `TypefaceResolver` extension point is unchanged.
- **BREAKING**: Minimum required `@cesdk/engine` / `@cesdk/node` version is now **1.72.0** (previously 1.70.0).
- Added text decorations (underline, strikethrough) with stroke style mapping, color, weight, and offset.
- Added text lists (bullet and numbered lists with nesting level support).
- Added drop shadow effects (offset, blur, color with CMYK→RGB conversion, opacity).
- Added TextFrame strokes and border radii rendered via a background graphic block.
- Added paragraph spacing (`SpaceAfter`) support.
- Added support for multiple page sizes within a single document.
- Non-rectangular TextFrame fills are now rendered as vector path shapes.
- Warning messages rewritten per the new `WARNING_GUIDELINES.md` for consistent wording and severity levels.
- Font-resolver logic simplified. The hardcoded alias map and local asset helpers have been removed.

### Patch Changes

- Full ObjectStyle inheritance chain resolution via `BasedOn` traversal, including text style cascade and `FillTint` support.
- Style lookup now correctly resolves IDs containing URL-encoded characters (switched from `querySelector` to iteration).
- Font weight normalization now applied on both sides of the comparison.
- Correct gradient direction, with explicit gradient-geometry support.
- Nested frame children are clipped to their parent shape using boolean intersection.
- Horizontal flip detection added for element transforms.
- Image crop now uses raw `GraphicBounds` values for rotated content.
- Rounded corners are now applied to image-filled frames.
- Corner radius is now scaled by the element transform factor, and skipped when `CornerOption` is `None`.
- Font metrics adjustment now applied to all leading types (not only auto leading).
- Scoped `queryChild` `paraRange` selector to prevent sibling leakage across paragraph ranges.
- Warning emitted when explicit leading is used with mixed font sizes within a paragraph.
- Vertical and diagonal `GraphicLine` element rendering fixed.
- Gradient-stop color warning now routed through the logger.
- Proprietary-font fallback lookups now use strict case-insensitive id/label matching against the fallbacks asset source, preventing fuzzy matches on the 16-entry fallback source from silently aliasing unrelated fonts (notably CJK fonts) to arbitrary substitutes.

## 1.3.0

### Minor Changes

- **BREAKING**: Minimum required `@cesdk/engine` / `@cesdk/node` version is now **1.70.0** (previously 1.40.0). Update your CE.SDK dependency before upgrading this package.
- Replaced `opentype.js` and `woff2-encoder` dependencies with the built-in `engine.editor.getFontMetrics()` API for font metrics extraction. This reduces bundle size and eliminates redundant font fetching. No rendering changes.

## 1.2.2

### Patch Changes

- Fixed embedded image detection for InDesign 2026+ (v21.3) IDML files where ImageTypeName is no longer populated by adding base64 magic bytes fallback for MIME type detection (JPEG, PNG, BMP, WebP)

## 1.2.1

### Patch Changes

- Added line height (leading) support for text frames with explicit values and Auto leading
- Added vertical alignment support for text frames (Top, Center, Bottom)
- Added font metrics extraction module for accurate line height conversion between InDesign and CE.SDK

## 1.2.0

### Minor Changes

- Added support for transient resource relocation using CE.SDK native APIs
- Images now use internal buffer URLs instead of data URIs, enabling `findAllTransientResources()`, `getBufferData()`, and `relocateResource()` APIs
- Added documentation for saving scenes with stable URLs

## 1.1.13

### Patch Changes

- Fix: Curvy edges for image clipping not being applied

## 1.1.12

### Patch Changes

- 3fbd62e: Fixes an issue where shaped images with Bézier curves gets flattened.

## 1.1.11

### Patch Changes

- 6d68514: Add: Support nested frames as groups of shapes

- 82d29d0: Fix: Dependencies

## 1.1.10

### Patch Changes

- ecfa619: Fix: Dependencies

## 1.1.8

### Patch Changes

- d71a4d7: Fixes vector rendering issues
