Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCLD-17783 Removes usage of deprecated draftjs props #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"it": true
},
"rules": {
"comma-dangle": "off",
"quotes": ["error", "double"],
"react/jsx-filename-extension": 0,
"react/forbid-prop-types": 0,
"react/no-array-index-key": 0,
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
docs/.yalc/
docs/yalc.lock
stats.json
report.html
report.html
.idea/
6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

58 changes: 0 additions & 58 deletions .idea/workspace.xml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This is a fork of https://github.com/jpuri/react-draft-wysiwyg used to get a wor

We reverted to an earlier version due to a problem with a bugfix on v1.15.0 and the forked bugfix breaking ui unit tests

More details on problems with various verisons of the source repo: https://blinemedical.atlassian.net/browse/SCLD-10296
More details on problems with various versions of the source repo: https://blinemedical.atlassian.net/browse/SCLD-10296
54 changes: 35 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"dependencies": {
"classnames": "^2.2.6",
"draftjs-utils": "^0.10.2",
"fbjs": "^1.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the package that draft-js uses to get Keys

"html-to-draftjs": "^1.5.0",
"linkify-it": "^2.2.0",
"prop-types": "^15.7.2"
Expand Down
24 changes: 20 additions & 4 deletions src/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
convertFromRaw,
CompositeDecorator
} from "draft-js";
import getDefaultKeyBinding from "draft-js/lib/getDefaultKeyBinding";
import {
changeDepth,
handleNewLine,
Expand All @@ -18,7 +19,9 @@ import {
extractInlineStyle,
getSelectedBlocksType
} from "draftjs-utils";
import Keys from "fbjs/lib/Keys";
import classNames from "classnames";
import { DraftEditorCommand } from "draft-js/lib/DraftEditorCommand";
import ModalHandler from "../event-handler/modals";
import FocusHandler from "../event-handler/focus";
import KeyDownHandler from "../event-handler/keyDown";
Expand Down Expand Up @@ -196,6 +199,21 @@ export default class WysiwygEditor extends Component {
this.focusHandler.onEditorMouseDown();
};

keyBindingFn: Function = (e): ?DraftEditorCommand => {
// eslint-disable-next-line default-case
switch (e.keyCode) {
case Keys.TAB:
this.onTab(e);
break;
case Keys.UP:
case Keys.DOWN:
this.onUpDownArrow(e);
break;
}

return getDefaultKeyBinding(e);
}

onTab: Function = (event): boolean => {
const { onTab } = this.props;
if (!onTab || !onTab(event)) {
Expand Down Expand Up @@ -519,7 +537,7 @@ export default class WysiwygEditor extends Component {
toolbarCustomButtons.map((button, index) =>
React.cloneElement(button, { key: index, ...controlProps })
)}
</div>
</div>
)}
<div
ref={this.setWrapperReference}
Expand All @@ -533,9 +551,7 @@ export default class WysiwygEditor extends Component {
>
<Editor
ref={this.setEditorReference}
onTab={this.onTab}
onUpArrow={this.onUpDownArrow}
onDownArrow={this.onUpDownArrow}
keyBindingFn={this.keyBindingFn}
editorState={editorState}
onChange={this.onChange}
blockStyleFn={blockStyleFn}
Expand Down