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

Update editor immediately for native insertion events #24

Merged
merged 22 commits into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c6a9e30
Update editor immediately for native insertion events
max-winderbaum Jan 31, 2017
5d407b8
Update package version
max-winderbaum Feb 1, 2017
e25e9ae
0.10.25
max-winderbaum Feb 1, 2017
35ffde3
switch to beta
Feb 1, 2017
f6cee34
0.10.25-ie-approach.1
Feb 1, 2017
bc97f2c
Change to rev and revbeta
Feb 1, 2017
47e0c77
0.10.25-ie-approach.2
Feb 1, 2017
7fde6d4
Add appropriate comments for the new functionality
max-winderbaum Feb 1, 2017
420dd27
Merge remote-tracking branch 'origin/0.10-textio' into topic-differen…
max-winderbaum Feb 1, 2017
f6fc6ff
Add extra logic to account for spellcheck, enter keypresses, and othe…
max-winderbaum Feb 2, 2017
be672b9
Remove console log statement
max-winderbaum Feb 2, 2017
d88d5ee
Beta branch build
max-winderbaum Feb 2, 2017
e0de6bc
0.10.26-different-approach.1
max-winderbaum Feb 2, 2017
0b003f3
Update .gitignore to ignore editor files - does not need merging with…
max-winderbaum Feb 2, 2017
fd3bda2
Merge branch '0.10-textio' into topic-different-ie-approach
max-winderbaum Feb 2, 2017
1d09fc9
Merge branch '0.10-textio' into topic-different-ie-approach
max-winderbaum Feb 2, 2017
cd1b788
0.10.30-different-approach.1
max-winderbaum Feb 2, 2017
4c599b8
Merge remote-tracking branch 'origin/0.10-textio' into topic-differen…
max-winderbaum Feb 3, 2017
c852dec
Merge branch '0.10-textio' into topic-different-ie-approach
Feb 7, 2017
90fdd49
merge down master
Feb 7, 2017
45c1e82
0.10.39-different-approach.1
Feb 7, 2017
b7f24a3
remove beta branch
Feb 8, 2017
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
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "draft-js",
"description": "A React framework for building text editors.",
"version": "0.10.20",
"version": "0.10.25-ie-approach.2",
"keywords": [
"draftjs",
"editor",
Expand All @@ -21,7 +21,9 @@
"license": "BSD-3-Clause",
"scripts": {
"prepublish": "npm run build",
"publish": "npm version patch && npm pack && s3-deploy *.tgz --region us-east-1 --bucket textio-web-deps",
"deploy": "npm pack && s3-deploy *.tgz --region us-east-1 --bucket textio-web-deps",
"rev": "npm run prepublish && npm version patch && npm run deploy && npm run postpublish",
"revbeta": "npm run prepublish && npm version prerelease && npm run deploy && npm run postpublish",
"postpublish": "git push && git push --tags",
"pretest": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
"build": "gulp",
Expand Down
2 changes: 1 addition & 1 deletion src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class DraftEditor extends React.Component {
_editorKey: string;
_placeholderAccessibilityID: string;
_latestEditorState: EditorState;
_pendingStateFromBeforeInput: void | EditorState;
_usingNativeRendering: void | EditorState;

/**
* Define proxies that can route events to the current handler.
Expand Down
14 changes: 2 additions & 12 deletions src/component/handlers/edit/editOnBeforeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ function replaceText(
* occurs on the relevant text nodes.
*/
function editOnBeforeInput(editor: DraftEditor, e: SyntheticInputEvent): void {
if (editor._pendingStateFromBeforeInput !== undefined) {
editor.update(editor._pendingStateFromBeforeInput);
editor._pendingStateFromBeforeInput = undefined;
}

var chars = e.data;

// In some cases (ex: IE ideographic space insertion) no character data
Expand Down Expand Up @@ -171,13 +166,8 @@ function editOnBeforeInput(editor: DraftEditor, e: SyntheticInputEvent): void {
// change the inserted text, we wait until the text is actually inserted

Choose a reason for hiding this comment

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

Make sure to update this comment since it's no longer accurate.

Copy link
Author

Choose a reason for hiding this comment

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

done

// before we actually update our state. That way when we rerender, the text
// we see in the DOM will already have been inserted properly.
editor._pendingStateFromBeforeInput = newEditorState;
setImmediate(() => {
if (editor._pendingStateFromBeforeInput !== undefined) {
editor.update(editor._pendingStateFromBeforeInput);
editor._pendingStateFromBeforeInput = undefined;
}
});
editor._usingNativeRendering = true;
editor.update(newEditorState);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/component/handlers/edit/editOnInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ var DOUBLE_NEWLINE = '\n\n';
* due to a spellcheck change, and we can incorporate it into our model.
*/
function editOnInput(editor: DraftEditor): void {
if (editor._pendingStateFromBeforeInput !== undefined) {
editor.update(editor._pendingStateFromBeforeInput);
editor._pendingStateFromBeforeInput = undefined;
if (editor._usingNativeRendering) {
editor._usingNativeRendering = false;
return;
}

var domSelection = global.getSelection();
Expand Down
3 changes: 1 addition & 2 deletions src/component/handlers/edit/editOnSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import type DraftEditor from 'DraftEditor.react';

function editOnSelect(editor: DraftEditor): void {
if (editor._blockSelectEvents ||
editor._latestEditorState !== editor.props.editorState ||
editor._pendingStateFromBeforeInput !== undefined) {
editor._latestEditorState !== editor.props.editorState) {
return;
}

Expand Down