Skip to content

Commit 30fd598

Browse files
committed
Merge branch 'master' into production
2 parents e498e01 + 41a1d24 commit 30fd598

File tree

9 files changed

+54
-23
lines changed

9 files changed

+54
-23
lines changed

apps/image-editor/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/image-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tui-image-editor",
33
"author": "NHN. FE Development Lab <[email protected]>",
4-
"version": "3.14.0",
4+
"version": "3.14.1",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

apps/image-editor/src/js/component/zoom.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ const DEFAULT_HORIZONTAL_SCROLL_RATIO = {
3232
BORDER_RADIUS: 0.003,
3333
};
3434
const DEFAULT_ZOOM_LEVEL = 1.0;
35+
const {
36+
ZOOM_CHANGED,
37+
ADD_TEXT,
38+
TEXT_EDITING,
39+
OBJECT_MODIFIED,
40+
KEY_DOWN,
41+
KEY_UP,
42+
HAND_STARTED,
43+
HAND_STOPPED,
44+
} = eventNames;
3545

3646
/**
3747
* Zoom components
@@ -88,8 +98,8 @@ class Zoom extends Component {
8898
moveHand: this._onMouseMoveWithHandMode.bind(this),
8999
stopHand: this._onMouseUpWithHandMode.bind(this),
90100
zoomChanged: this._changeScrollState.bind(this),
91-
keydown: this._onKeyDown.bind(this),
92-
keyup: this._onKeyUp.bind(this),
101+
keydown: this._startHandModeWithSpaceBar.bind(this),
102+
keyup: this._endHandModeWithSpaceBar.bind(this),
93103
};
94104

95105
const canvas = this.getCanvas();
@@ -114,19 +124,38 @@ class Zoom extends Component {
114124
*/
115125
this._horizontalScroll = new fabric.Rect(DEFAULT_SCROLL_OPTION);
116126

117-
canvas.on(eventNames.ZOOM_CHANGED, this._listeners.zoomChanged);
127+
canvas.on(ZOOM_CHANGED, this._listeners.zoomChanged);
118128

119-
fabric.util.addListener(document, 'keydown', this._listeners.keydown);
120-
fabric.util.addListener(document, 'keyup', this._listeners.keyup);
129+
this.graphics.on(ADD_TEXT, this._startTextEditingHandler.bind(this));
130+
this.graphics.on(TEXT_EDITING, this._startTextEditingHandler.bind(this));
131+
this.graphics.on(OBJECT_MODIFIED, this._stopTextEditingHandler.bind(this));
132+
fabric.util.addListener(document, KEY_DOWN, this._listeners.keydown);
133+
fabric.util.addListener(document, KEY_UP, this._listeners.keyup);
121134
}
122135

123136
/**
124-
* Keydown event handler
137+
* Handler when you started editing text
138+
* @private
139+
*/
140+
_startTextEditingHandler() {
141+
this.isTextEditing = true;
142+
}
143+
144+
/**
145+
* Handler when you stopped editing text
146+
* @private
147+
*/
148+
_stopTextEditingHandler() {
149+
this.isTextEditing = false;
150+
}
151+
152+
/**
153+
* Handler who turns on hand mode when the space bar is down
125154
* @param {KeyboardEvent} e - Event object
126155
* @private
127156
*/
128-
_onKeyDown(e) {
129-
if (this.withSpace) {
157+
_startHandModeWithSpaceBar(e) {
158+
if (this.withSpace || this.isTextEditing) {
130159
return;
131160
}
132161

@@ -138,11 +167,11 @@ class Zoom extends Component {
138167
}
139168

140169
/**
141-
* Keyup event handler
170+
* Handler who turns off hand mode when space bar is up
142171
* @param {KeyboardEvent} e - Event object
143172
* @private
144173
*/
145-
_onKeyUp(e) {
174+
_endHandModeWithSpaceBar(e) {
146175
if (e.keyCode === keyCodes.SPACE) {
147176
e.preventDefault();
148177
this.withSpace = false;
@@ -239,7 +268,7 @@ class Zoom extends Component {
239268
canvas.selection = false;
240269
canvas.defaultCursor = 'grab';
241270

242-
canvas.fire(eventNames.HAND_STARTED);
271+
canvas.fire(HAND_STARTED);
243272
}
244273

245274
/**
@@ -257,7 +286,7 @@ class Zoom extends Component {
257286

258287
this._startHandPoint = null;
259288

260-
canvas.fire(eventNames.HAND_STOPPED);
289+
canvas.fire(HAND_STOPPED);
261290
}
262291

263292
/**
@@ -657,7 +686,7 @@ class Zoom extends Component {
657686
* @param {number} zoomLevel - 'zoomChanged' event params
658687
*/
659688
_fireZoomChanged(canvas, zoomLevel) {
660-
canvas.fire(eventNames.ZOOM_CHANGED, { viewport: canvas.calcViewportBoundaries(), zoomLevel });
689+
canvas.fire(ZOOM_CHANGED, { viewport: canvas.calcViewportBoundaries(), zoomLevel });
661690
}
662691

663692
/**

apps/image-editor/src/js/consts.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ export const eventNames = {
167167
ZOOM_CHANGED: 'zoomChanged',
168168
HAND_STARTED: 'handStarted',
169169
HAND_STOPPED: 'handStopped',
170+
KEY_DOWN: 'keydown',
171+
KEY_UP: 'keyup',
170172
};
171173

172174
/**

apps/react-image-editor/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/react-image-editor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toast-ui/react-image-editor",
3-
"version": "3.14.0",
3+
"version": "3.14.1",
44
"description": "TOAST UI Image-Editor for React",
55
"main": "dist/toastui-react-image-editor.js",
66
"files": [
@@ -53,6 +53,6 @@
5353
},
5454
"dependencies": {
5555
"fabric": "^4.2.0",
56-
"tui-image-editor": "^3.14.0"
56+
"tui-image-editor": "^3.14.1"
5757
}
5858
}

apps/vue-image-editor/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/vue-image-editor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toast-ui/vue-image-editor",
3-
"version": "3.14.0",
3+
"version": "3.14.1",
44
"description": "TOAST UI Image-Editor for Vue",
55
"main": "dist/toastui-vue-image-editor.js",
66
"files": [
@@ -43,6 +43,6 @@
4343
},
4444
"dependencies": {
4545
"fabric": "^4.2.0",
46-
"tui-image-editor": "^3.14.0"
46+
"tui-image-editor": "^3.14.1"
4747
}
4848
}

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"apps/*"
44
],
5-
"version": "3.14.0"
5+
"version": "3.14.1"
66
}

0 commit comments

Comments
 (0)