Skip to content

ImageEditor 2.0.0 Migration guide

์œ ๋™์‹ edited this page May 24, 2017 · 10 revisions

(translating)

There are a lot of changes for ImageEditor 2.0.0 including API changes and new features. This migration document will be nicely moving 2.0.0.

New drawing mode change APIs

  • New APIs

    • startDrawingMode(modeName) starts a drawing mode
    • stopDrawingMode() stops current drawing mode and back to 'NORMAL' mode
    • getDrawingMode() returns current drawing mode name.
    • getCropzoneRect() returns cropping rect in 'CROPPER' drawing mode.
    • crop(rect) crops image given area
  • Removed APIs

    • startCropping, endCropping
    • startDrawingShapeMode, endDrawingShapeMode
    • startFreeDrawing, endFreeDrawing
    • startLineDrawing, endLineDrawing
    • startTextMode, endTextMode
    • endAll
    • endCropping is divided into three APIs
var rect = imageEditor.getCropzoneRect();
imageEditor.crop(rect).then(() => {
    imageEditor.stopDrawingMode();
});

Changed APIs

  • removeActiveObject() ==> removeObject(id)

Use object is with all drawing APIs

  • In versions prior to 1.4.1, the users should select an object and manipulate it which is called 'active object'. There was no way to manipulate non-selected object. After 2.0.0 version, you can manipulate not only selected object, but also non-selected objects by receiving the Object Id.
  • To get the Object Id, use the parameter.id in Promise.then() and the event callback.
imageEditor.addShape('circle', {
    fill: 'red',
    stroke: 'blue',
    strokeWidth: 3,
    rx: 10,
    ry: 100,
    isRegular: false
}).then(function(props) {
    console.log(props.id);

    imageEditor.changeShape(props.id, { // change circle
        fill: '#FFFF00',
        strokeWidth: 10
    });
});
/*
{
    id: number
    type: type
    left: number,
    top: number,
    width: number,
    fill: string
    stroke: string
    strokeWidth: number
    opacity: number,

    // text object
    text: string,
    fontFamily: string,
    fontSize: number,
    fontStyle: string,
    fontWeight: string,
    textAlign: string,
    textDecoration: string
}
*/
imageEditor.on('objectActivated', function(props) {
    console.log(props);
    console.log(props.type);
    console.log(props.id);
});

Support Promise API

  • All drawing APIs returns Promise and supports Undo/Redo.
  • List of related APIs
    • addIcon, addImageObject, addShape, changeIconColor
    • changeShape, addText, changeText, changeTextStyle,
    • resizeCanvasDimension, applyFilter, removeFilter,
    • clearObjects, flipX, flipY, loadImageFromFile,
    • loadImageFromURL, redo, undo, removeObject,
    • resetFlip, rotate, setAngle, crop,
    • setObjectPosition, setObjectProperties

์ด๋ฒคํŠธ ๋ณ€๊ฒฝ ๋‚ด์—ญ

As-Is To-Be ๋ณ€๊ฒฝ ์ด์œ 
activateText addText ์ด๋ฆ„ ๋ณ€๊ฒฝ 'TEXT' ๋ชจ๋“œ์—์„œ mousedown์ด ์™”์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ
๋ณดํ†ต ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์•„ addText()๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
addObject N/A ์ œ๊ฑฐ ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์ถ”๊ฐ€๋œ ๊ฒฝ์šฐ์ธ๋ฐ, ํ•„์š”์„ฑ์ด ์—†์–ด ์ œ๊ฑฐ๋จ
adjustObject objectMoved
objectScaled
์ด๋ฆ„ ๋ฐ ๊ธฐ๋Šฅ ๋ณ€๊ฒฝ ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์ด๋™ํ•˜๊ฑฐ๋‚˜ ์Šค์ผ€์ผ๊ฐ’์ด ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ ๋ฐœ์ƒ
applyFilter N/A ์ œ๊ฑฐ applyFilter() API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
clearImage N/A ์ œ๊ฑฐ loadImageFromFile(), loadImageFromURL() API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
clearObjects N/A ์ œ๊ฑฐ clearObjects() API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
editText textEditing ์ด๋ฆ„ ๋ณ€๊ฒฝ ํ…์ŠคํŠธ ์ž…๋ ฅ์ด ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ ๋ฐœ์ƒ
emptyRedoStack redoStackChanged ์ด๋ฆ„ ๋ฐ ๊ธฐ๋Šฅ ๋ณ€๊ฒฝ redoStack์˜ ๊ฐฏ์ˆ˜๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์Šคํƒ ๊ฐฏ์ˆ˜๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.
emptyUndoStack undoStackChanged ์ด๋ฆ„ ๋ฐ ๊ธฐ๋Šฅ ๋ณ€๊ฒฝ undoStack์˜ ๊ฐฏ์ˆ˜๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์Šคํƒ ๊ฐฏ์ˆ˜๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.
endCropping N/A ์ œ๊ฑฐ ์ƒํƒœ ๋ชจ๋“œ ๋ณ€๊ฒฝ์€ ์ด๋ฒคํŠธ ํ•„์š” ์—†์Œ.
endFreeDrawing N/A ์ œ๊ฑฐ ์ƒํƒœ ๋ชจ๋“œ ๋ณ€๊ฒฝ์€ ์ด๋ฒคํŠธ ํ•„์š” ์—†์Œ.
endLineDrawing N/A ์ œ๊ฑฐ ์ƒํƒœ ๋ชจ๋“œ ๋ณ€๊ฒฝ์€ ์ด๋ฒคํŠธ ํ•„์š” ์—†์Œ.
flipImage N/A ์ œ๊ฑฐ flipX(), flipY() API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
loadImage N/A ์ œ๊ฑฐ loadImageFromFile(), loadImageFromURL() API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
mousedown mousedown ์œ ์ง€
pushRedoStack redoStackChanged ์ด๋ฆ„ ๋ฐ ๊ธฐ๋Šฅ ๋ณ€๊ฒฝ redoStack์˜ ๊ฐฏ์ˆ˜๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์Šคํƒ ๊ฐฏ์ˆ˜๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.
pushUndoStack undoStackChanged ์ด๋ฆ„ ๋ฐ ๊ธฐ๋Šฅ ๋ณ€๊ฒฝ undoStack์˜ ๊ฐฏ์ˆ˜๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์Šคํƒ ๊ฐฏ์ˆ˜๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.
removeObject N/A ์ œ๊ฑฐ removeObject()API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
rotateImage N/A ์ œ๊ฑฐ rotate(), setAngle() API์˜ Promise.then()์œผ๋กœ ๋Œ€์ฒด
selectObject objectActivated ์ด๋ฆ„ ๋ฐ ๊ธฐ๋Šฅ ๋ณ€๊ฒฝ ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์„ ํƒ๋œ ๊ฒฝ์šฐ, activateText์—์„œ ์ฃผ๋˜ ํ…์ŠคํŠธ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ
์—ฌ๊ธฐ์—์„œ ์ „๋‹ฌํ•œ๋‹ค.ex> params.text, params.fontSize
startCropping N/A ์ œ๊ฑฐ ์ƒํƒœ ๋ชจ๋“œ ๋ณ€๊ฒฝ์€ ์ด๋ฒคํŠธ ํ•„์š” ์—†์Œ.
startFreeDrawing N/A ์ œ๊ฑฐ ์ƒํƒœ ๋ชจ๋“œ ๋ณ€๊ฒฝ์€ ์ด๋ฒคํŠธ ํ•„์š” ์—†์Œ.
startLineDrawing N/A ์ œ๊ฑฐ ์ƒํƒœ ๋ชจ๋“œ ๋ณ€๊ฒฝ์€ ์ด๋ฒคํŠธ ํ•„์š” ์—†์Œ.

Other changes and bug fixed

Clone this wiki locally