Skip to content

Commit

Permalink
fix: Add "ImageEditor.ui.resizeEditor()" type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
junghwan-park committed May 2, 2019
1 parent 6cddc22 commit 610c238
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
22 changes: 22 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,30 @@ declare namespace tuiImageEditor {
selectionStyle?: ISelectionStyleConfig;
}

interface IUIDimension {
height?: string;
width?: string;
}

interface IImageDimension {
oldHeight?: number;
oldWidth?: number;
newHeight?: number;
newWidth?: number;
}

interface IEditorSize {
uiSize?: IUIDimension,
imageSize?: IImageDimension
}

interface UI {
resizeEditor(dimension: IEditorSize): Promise<void>;
}

class ImageEditor {
constructor(wrapper: string | Element, options: IOptions);
public ui: UI;

public addIcon(type: string, options?: IIconOptions): Promise<IObjectProps>;
public addImageObject(imgUrl: string): Promise<void>;
Expand Down
10 changes: 5 additions & 5 deletions src/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const BI_EXPRESSION_MINSIZE_WHEN_TOP_POSITION = '1300';
* @param {Object} [options.uiSize] - ui size of editor
* @param {string} options.uiSize.width - width of ui
* @param {string} options.uiSize.height - height of ui
* @param {Objecdt} actions - ui action instance
* @param {Object} actions - ui action instance
*/
class Ui {
constructor(element, options, actions) {
Expand Down Expand Up @@ -103,8 +103,8 @@ class Ui {
* Change editor size
* @param {Object} resizeInfo - ui & image size info
* @param {Object} resizeInfo.uiSize - image size dimension
* @param {Number} resizeInfo.uiSize.width - ui width
* @param {Number} resizeInfo.uiSize.height - ui height
* @param {string} resizeInfo.uiSize.width - ui width
* @param {string} resizeInfo.uiSize.height - ui height
* @param {Object} resizeInfo.imageSize - image size dimension
* @param {Number} resizeInfo.imageSize.oldWidth - old width
* @param {Number} resizeInfo.imageSize.oldHeight - old height
Expand Down Expand Up @@ -247,8 +247,8 @@ class Ui {
/**
* Set ui container size
* @param {Object} uiSize - ui dimension
* @param {number} width - width
* @param {number} height - height
* @param {string} uiSize.width - width
* @param {string} uiSize.height - height
* @private
*/
_setUiSize(uiSize = this.options.uiSize) {
Expand Down
2 changes: 2 additions & 0 deletions test/types/type-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,5 @@ imageEditor.on('addText', pos => {
console.log(`text position on canvas : ${pos.originPosition}`);
console.log(`text position on browser : ${pos.clientPosition}`);
});
imageEditor.ui.resizeEditor({uiSize: {width: '600px', height: '1200px'}});
imageEditor.ui.resizeEditor({imageSize: {newWidth: 300, newHeight: 140}});

0 comments on commit 610c238

Please sign in to comment.