Skip to content

v2.0.0

Choose a tag to compare

@github-actions github-actions released this 05 Jun 19:32

This release is a behavior-preserving migration of the v1 image editor onto a TypeScript and Fabric.js v7 foundation, published in multiple module formats from a single source tree. On-screen behavior is carried forward from v1.5.2 — sizing, scroll, overflow, rollback, mask metadata, history snapshots, export framing, crop session lifecycle, and dispose ordering all match v1. The only intentional default change is crop.preserveMasksAfterCrop (see Changed). The public API is canonical to v2: every v1 alias introduced as deprecated in v1.3.0 has been removed.

Added

  • Publish ESM, CJS (.cjs), UMD, and TypeScript declaration files (.d.ts) from a single npm run build. The package.json exports map exposes the documented entry points (import, require, default, types), and the UMD bundle declares fabric as an external global.
  • Add fabric@^7 as a peer dependency. Consumers pass the Fabric module to the editor explicitly through the constructor, with a globalThis.fabric fallback for UMD usage.
  • Add setLayoutMode('fit' | 'cover' | 'expand') as the public way to select the layout strategy for future image loads without exposing internal options.
  • Add maxExportPixels as a public export-size guard. Invalid values fall back to the default budget, and oversized multiplier exports reject before rendering.

Changed

  • Migrate the runtime source tree to TypeScript and decompose the editor into one module per subsystem under src/<subsystem>/ (animation, history, image, mask, crop, export, ui, core, fabric, utils). ImageEditor remains the only public class and the package facade.
  • Upgrade the rendering engine to Fabric.js v7 and use Fabric v7 promise APIs (FabricImage.fromURL, canvas.loadFromJSON) plus the local Promise wrapper around Fabric v7 animation handles throughout the async control flow for image load, scale, rotate, merge, crop, and export.
  • Change crop.preserveMasksAfterCrop to default to false. v1 defaulted to true; callers that relied on the old default must now pass crop: { preserveMasksAfterCrop: true } explicitly.
  • Change the CommonJS root entry to return the v2 namespace object ({ ImageEditor, default, isMaskObject }) instead of returning the constructor function directly.

Removed

  • Remove every v1 alias from runtime, type declarations, demo, and documentation in favor of the canonical v2 names that were introduced alongside the deprecated aliases in v1.3.0:
    • reset()resetImageTransform()
    • addMask()createMask()
    • merge()mergeMasks()
    • getImageBase64()exportImageBase64() (and exportImageFile() for direct File exports)
    • canvasEl, containerEl, placeholderEl public DOM fields → removed; DOM references are now private to the editor and are not part of the public surface.
  • Remove deprecated v1 DOM binding keys from the v2 ElementIdMap, runtime defaults, demo, and declarations:
    • imgPlaceholderimagePlaceholder
    • scaleRatescalePercentageInput
    • rotationLeftInputrotateLeftDegreesInput
    • rotationRightInputrotateRightDegreesInput
    • rotateLeftBtnrotateLeftButton
    • rotateRightBtnrotateRightButton
    • addMaskBtncreateMaskButton
    • removeMaskBtnremoveSelectedMaskButton
    • removeAllMasksBtnremoveAllMasksButton
    • mergeBtnmergeMasksButton
    • downloadBtndownloadImageButton
    • zoomInBtnzoomInButton
    • zoomOutBtnzoomOutButton
    • resetBtnresetImageTransformButton
    • undoBtnundoButton
    • redoBtnredoButton
    • cropBtnenterCropModeButton
    • applyCropBtnapplyCropButton
    • cancelCropBtncancelCropButton
  • Remove root-level exports of internal helpers such as AnimationQueue, Command, HistoryManager, subsystem controllers, services, managers, and utility modules. The package root exports only ImageEditor (default and named), isMaskObject, and the documented public types.

Security

  • Upgrade @rollup/plugin-terser to ^1.0.0 so the development build chain resolves serialize-javascript@7.0.5, clearing the high-severity npm audit finding from the release verification pass.

Fixed

  • Replace the setLayoutMode test's private editor.options assertions with black-box load/export behavior checks.
  • Loosen the public FabricModule type so new ImageEditor(fabric, options) type-checks with the standard import * as fabric from 'fabric' namespace form.
  • Allow integration tests to pass from a clean tree before dist/ has been built, while still failing when a partial dist/ directory is present.