Skip to content

Commit f24fb77

Browse files
authored
fix(components): event props not firing correctly (#13)
- Updated package.json dependencies - Fixed issues with event props
1 parent 0da5971 commit f24fb77

File tree

8 files changed

+473
-430
lines changed

8 files changed

+473
-430
lines changed

.babelrc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
{
22
"plugins": ["@babel/plugin-proposal-class-properties"],
3-
"presets": [
4-
[
5-
"@babel/preset-env",
6-
{
7-
"loose": true
8-
}
9-
],
10-
"@babel/preset-react",
11-
[
12-
"@emotion/babel-preset-css-prop",
13-
{
14-
"autoLabel": false,
15-
"labelFormat": "[filename]--[local]"
16-
}
17-
]
18-
]
3+
"presets": ["@babel/preset-env", "@babel/preset-react"]
194
}

dist/react-editable-textbox.js

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

dist/react-editable-textbox.min.js

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

examples/advanced/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ const App = () => (
5555
allowedAttributes={{
5656
a: ['href']
5757
}}
58-
onFocus={(resp) => {}}
59-
onBlur={(resp) => {}}
60-
onInput={(resp) => {}}
58+
onFocus={(resp) => console.log(resp)}
59+
onBlur={(resp) => console.log(resp)}
60+
onInput={(resp) => console.log(resp)}
6161
/>
6262
);
6363

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,18 @@
3737
"@emotion/core": "^10.0.28",
3838
"@emotion/css": "^10.0.27",
3939
"@emotion/styled": "^10.0.27",
40-
"coveralls": "^3.1.0",
4140
"dompurify": "^2.0.10",
4241
"emotion-theming": "^10.0.27"
4342
},
4443
"devDependencies": {
45-
"@babel/core": "^7.9.0",
44+
"@babel/core": "^7.9.6",
4645
"@babel/plugin-proposal-class-properties": "^7.8.3",
47-
"@emotion/babel-preset-css-prop": "^10.0.27",
46+
"@babel/preset-env": "^7.9.6",
47+
"@babel/preset-react": "^7.9.4",
4848
"babel-eslint": "^10.1.0",
4949
"babel-loader": "^8.1.0",
50-
"babel-plugin-add-module-exports": "^1.0.2",
51-
"babel-preset-react-app": "^9.1.2",
5250
"commitizen": "^4.0.4",
51+
"coveralls": "^3.1.0",
5352
"cross-env": "^7.0.2",
5453
"cz-customizable": "^6.2.0",
5554
"cz-customizable-ghooks": "^1.5.0",

src/editor/Editor.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
cleanHtml,
1111
getTheme,
1212
getCustomStyling,
13-
createEvents,
1413
handleEvent,
1514
setText
1615
} from './utils';
@@ -47,10 +46,6 @@ const Container = styled('div')`
4746
`;
4847

4948
class Editor extends PureComponent {
50-
static propTypes = propTypes.editor;
51-
52-
static defaultProps = defaultProps.editor;
53-
5449
constructor(props) {
5550
super(props);
5651
const { defaultText, allowedTags, allowedAttributes } = props;
@@ -132,7 +127,8 @@ class Editor extends PureComponent {
132127
const propManager = {
133128
[EDITOR]: {
134129
ref: (ref) => this.createRef(ref, EDITOR),
135-
...createEvents([onFocus, onBlur], this.state),
130+
onFocus: () => handleEvent(onFocus, this.state),
131+
onBlur: () => handleEvent(onBlur, this.state),
136132
...getCustomStyling(EDITOR, styles),
137133
disabled
138134
},
@@ -176,4 +172,7 @@ class Editor extends PureComponent {
176172
};
177173
}
178174

175+
Editor.propTypes = propTypes.editor;
176+
Editor.defaultProps = defaultProps.editor;
177+
179178
export default Editor;

src/editor/utils.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ const getEvent = (ev, props) => callEvent(ev)(props);
99

1010
export const handleEvent = (ev, props) => getEvent(ev, props);
1111

12-
export const createEvents = (events, props) =>
13-
events.map((ev) => {
14-
return {
15-
[ev]: handleEvent(ev, props)
16-
};
17-
});
18-
1912
export const cleanHtml = ({ text, allowedAttributes, allowedTags, tags }) => {
2013
return sanitize(text, {
2114
ALLOWED_ATTR: allowedAttributes,
@@ -27,7 +20,7 @@ export const setText = (text) => text || DEFAULT_ELEMENT;
2720

2821
export const getCustomStyling = (element, styles) => {
2922
return {
30-
customStyling: styles[element]
23+
customStyling: styles[element] || {}
3124
};
3225
};
3326

0 commit comments

Comments
 (0)