Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Examples cleanup
Browse files Browse the repository at this point in the history
Summary:
**Cleanup Examples code**
I linted code in the  `/examples` folder with ESLint config that ships with `create-react-app` and I found a few warnings.

Changes made:
- Removed unused variables, imports
- Refactored switch statement to a simple if statement
- Removed unnecessary escape in Regex

Please let me know if you want me to squash commits or make changes 😄
Closes facebookarchive#1649

Differential Revision: D7085257

fbshipit-source-id: 3292462da3926377537e840dc45ca206a41a8a1b
  • Loading branch information
hibiken authored and facebook-github-bot committed Feb 26, 2018
1 parent 084bdb6 commit 67f3586
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
1 change: 0 additions & 1 deletion examples/draft-0-10-0/convertFromHTML/convert.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

const {
CompositeDecorator,
ContentBlock,
ContentState,
Editor,
EditorState,
Expand Down
1 change: 0 additions & 1 deletion examples/draft-0-10-0/entity/entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
convertFromRaw,
convertToRaw,
CompositeDecorator,
ContentState,
Editor,
EditorState,
} = Draft;
Expand Down
1 change: 0 additions & 1 deletion examples/draft-0-10-0/link/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
const {
convertToRaw,
CompositeDecorator,
ContentState,
Editor,
EditorState,
RichUtils,
Expand Down
1 change: 0 additions & 1 deletion examples/draft-0-10-0/media/media.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
}

_promptForMedia(type) {
const {editorState} = this.state;
this.setState({
showURLInput: true,
urlValue: '',
Expand Down
21 changes: 10 additions & 11 deletions examples/draft-0-10-0/rich/rich.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@
}

_mapKeyToEditorCommand(e) {
switch (e.keyCode) {
case 9: // TAB
const newEditorState = RichUtils.onTab(
e,
this.state.editorState,
4, /* maxDepth */
);
if (newEditorState !== this.state.editorState) {
this.onChange(newEditorState);
}
return;
if (e.keyCode === 9 /* TAB */) {
const newEditorState = RichUtils.onTab(
e,
this.state.editorState,
4, /* maxDepth */
);
if (newEditorState !== this.state.editorState) {
this.onChange(newEditorState);
}
return;
}
return getDefaultKeyBinding(e);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/draft-0-10-0/tweet/tweet.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
* Super simple decorators for handles and hashtags, for demonstration
* purposes only. Don't reuse these regexes.
*/
const HANDLE_REGEX = /\@[\w]+/g;
const HASHTAG_REGEX = /\#[\w\u0590-\u05ff]+/g;
const HANDLE_REGEX = /@[\w]+/g;
const HASHTAG_REGEX = /#[\w\u0590-\u05ff]+/g;

function handleStrategy(contentBlock, callback, contentState) {
findWithRegex(HANDLE_REGEX, contentBlock, callback);
Expand Down

0 comments on commit 67f3586

Please sign in to comment.