Skip to content
This repository was archived by the owner on Jul 28, 2021. It is now read-only.

Commit 9292252

Browse files
author
jung-han
committed
Merge branch 'master' into production
2 parents 79796a6 + 4cd189d commit 9292252

File tree

5 files changed

+36
-23
lines changed

5 files changed

+36
-23
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.DS_Store
3+
Thumbs.db
4+
Desktop.ini
5+
dist

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# TOAST UI Image Editor for React
22

3-
> This is a React component wrapping [TOAST UI Image Editor](https://github.com/nhnent/tui.image-editor).
3+
> This is a React component wrapping [TOAST UI Image Editor](https://github.com/nhn/tui.image-editor).
44
5-
[![github version](https://img.shields.io/github/release/nhnent/toast-ui.react-image-editor.svg)](https://github.com/nhnent/toast-ui.react-image-editor/releases/latest)
5+
[![github version](https://img.shields.io/github/release/nhn/toast-ui.react-image-editor.svg)](https://github.com/nhn/toast-ui.react-image-editor/releases/latest)
66
[![npm version](https://img.shields.io/npm/v/@toast-ui/react-image-editor.svg)](https://www.npmjs.com/package/@toast-ui/react-image-editor)
7-
[![license](https://img.shields.io/github/license/nhnent/toast-ui.vue-image-editor.svg)](https://github.com/nhnent/toast-ui.react-image-editor/blob/master/LICENSE)
8-
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](https://github.com/nhnent/toast-ui.react-image-editor/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
9-
[![code with hearth by NHN](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-NHN-ff1414.svg)](https://github.com/nhnent)
7+
[![license](https://img.shields.io/github/license/nhn/toast-ui.vue-image-editor.svg)](https://github.com/nhn/toast-ui.react-image-editor/blob/master/LICENSE)
8+
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](https://github.com/nhn/toast-ui.react-image-editor/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
9+
[![code with hearth by NHN](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-NHN-ff1414.svg)](https://github.com/nhn)
1010

1111
## 🚩 Table of Contents
1212
* [Collect statistics on the use of open source](#collect-statistics-on-the-use-of-open-source)
@@ -69,7 +69,7 @@ var ImageEditor = require('@toast-ui/react-image-editor');
6969

7070
### Props
7171

72-
[All the options of the TOAST UI Image Editor](http://nhnent.github.io/tui.image-editor/latest/ImageEditor.html) are supported in the form of props.
72+
[All the options of the TOAST UI Image Editor](http://nhn.github.io/tui.image-editor/latest/ImageEditor.html) are supported in the form of props.
7373

7474
```js
7575
const myTheme = {
@@ -108,7 +108,7 @@ Importing `black/white-theme.js` file is not working directly import yet. You wa
108108

109109
### Instance Methods
110110

111-
For using [instance methods of TOAST UI Image Editor](https://nhnent.github.io/tui.date-picker/latest/DatePicker.html#.createCalendar), first thing to do is creating Refs of wrapper component using [`createRef()`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs). But the wrapper component does not provide a way to call instance methods of TOAST UI Image Editor directly. Instead, you can call `getInstance()` method of the wrapper component to get the instance, and call the methods on it.
111+
For using [instance methods of TOAST UI Image Editor](https://nhn.github.io/tui.date-picker/latest/DatePicker.html#.createCalendar), first thing to do is creating Refs of wrapper component using [`createRef()`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs). But the wrapper component does not provide a way to call instance methods of TOAST UI Image Editor directly. Instead, you can call `getInstance()` method of the wrapper component to get the instance, and call the methods on it.
112112

113113
```js
114114
const imageEditorOptions = {
@@ -166,7 +166,7 @@ class MyComponent extends React.Component {
166166

167167
### Event
168168

169-
[All the events of TOAST UI Image Editor](https://nhnent.github.io/tui.image-editor/latest/ImageEditor.html#event:addText) are supported in the form of `on[EventName]` props. The first letter of each event name should be capitalized. For example, for using `mousedown` event you can use `onMousedown` prop like the example below.
169+
[All the events of TOAST UI Image Editor](https://nhn.github.io/tui.image-editor/latest/ImageEditor.html#event:addText) are supported in the form of `on[EventName]` props. The first letter of each event name should be capitalized. For example, for using `mousedown` event you can use `onMousedown` prop like the example below.
170170

171171
```js
172172
class MyComponent extends React.Component {
@@ -213,12 +213,12 @@ If it has no error, commit and then push it!
213213
For more information on PR's step, please see links of Contributing section.
214214

215215
## 📙 Documents
216-
* [Getting Started](https://github.com/nhnent/toast-ui.react-image-editor/blob/master/docs/getting-started.md)
216+
* [Getting Started](https://github.com/nhn/toast-ui.react-image-editor/blob/master/docs/getting-started.md)
217217

218218
## 💬 Contributing
219-
* [Code of Conduct](https://github.com/nhnent/toast-ui.react-image-editor/blob/master/CODE_OF_CONDUCT.md)
220-
* [Contributing guideline](https://github.com/nhnent/toast-ui.react-image-editor/blob/master/CONTRIBUTING.md)
221-
* [Commit convention](https://github.com/nhnent/toast-ui.react-image-editor/blob/master/docs/COMMIT_MESSAGE_CONVENTION.md)
219+
* [Code of Conduct](https://github.com/nhn/toast-ui.react-image-editor/blob/master/CODE_OF_CONDUCT.md)
220+
* [Contributing guideline](https://github.com/nhn/toast-ui.react-image-editor/blob/master/CONTRIBUTING.md)
221+
* [Commit convention](https://github.com/nhn/toast-ui.react-image-editor/blob/master/docs/COMMIT_MESSAGE_CONVENTION.md)
222222

223223
## 📜 License
224-
This software is licensed under the [MIT](./LICENSE) © [NHN.](https://github.com/nhnent)
224+
This software is licensed under the [MIT](./LICENSE) © [NHN.](https://github.com/nhn)

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toast-ui/react-image-editor",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "React wrapper component for tui.imageEditor",
55
"main": "dist/toastui-react-image-editor.js",
66
"files": [
@@ -14,10 +14,10 @@
1414
"storybook": "start-storybook -s ./node_modules/tui-image-editor/dist/svg,.storybook -p 6006",
1515
"build-storybook": "build-storybook"
1616
},
17-
"homepage": "https://github.com/nhnent/toast-ui.react-image-editor",
18-
"bugs": "https://github.com/nhnent/toast-ui.react-image-editor/issues",
17+
"homepage": "https://github.com/nhn/toast-ui.react-image-editor",
18+
"bugs": "https://github.com/nhn/toast-ui.react-image-editor/issues",
1919
"author": "NHN. FE Development Lab <dl_javascript@nhn.com>",
20-
"repository": "https://github.com/nhnent/toast-ui.react-image-editor.git",
20+
"repository": "https://github.com/nhn/toast-ui.react-image-editor.git",
2121
"license": "MIT",
2222
"browserslist": "last 2 versions, ie 9",
2323
"peerDependencies": {

src/index.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ export default class ImageEditor extends React.Component {
1515
...this.props
1616
});
1717

18-
this.bindEventHandlers();
18+
this.bindEventHandlers(this.props);
1919
}
2020

21-
shouldComponentUpdate() {
21+
shouldComponentUpdate(nextProps) {
22+
console.log('nextProps');
23+
this.bindEventHandlers(this.props, nextProps);
24+
2225
return false;
2326
}
2427

@@ -30,12 +33,17 @@ export default class ImageEditor extends React.Component {
3033
return this.rootEl.current;
3134
}
3235

33-
bindEventHandlers() {
34-
Object.keys(this.props)
36+
bindEventHandlers(props, prevProps) {
37+
Object.keys(props)
3538
.filter((key) => /on[A-Z][a-zA-Z]+/.test(key))
3639
.forEach((key) => {
3740
const eventName = key[2].toLowerCase() + key.slice(3);
38-
this.imageEditorInst.on(eventName, this.props[key]);
41+
// For <ImageEditor onFocus={condition ? onFocus1 : onFocus2} />
42+
if (prevProps && prevProps[key] !== props[key]) {
43+
console.log('ho?');
44+
this.imageEditorInst.off(eventName);
45+
}
46+
this.imageEditorInst.on(eventName, props[key]);
3947
});
4048
}
4149

0 commit comments

Comments
 (0)