Skip to content

Commit

Permalink
Copy over misc. changes from Facebook
Browse files Browse the repository at this point in the history
**what is the change?:**
In order to enable auto-syncing between Github and www we need to get
both to a point were they are in sync.

This copies some misc. changes from the www version of Draft into the
Github version of Draft. We are pulling in some changes as well.

Includes changes from
D5070771 Fix errors with single new in context
  (Note about above: TIL "by design you're not supposed to use new with Immutable.js data structures (well, except Records).")
D5172412 [codemod] disable automock by default on as many remaining tests in www as possible @bypass-lint
D5070207 [www][flowify] Start adding Flow typechecks to Style
D4966517 [TF] Minor comments and nits for the DraftJs Composer
D5109581 Add logging to catch Firefox Draft.js error

**why make this change?:**
To enable auto-syncing, to speed up speed of development.

**test plan:**
`yarn test`
I'm pretty confident of these changes since they have all been present
in FB Draft for some time.

**issue:**
facebookarchive#1244
  • Loading branch information
flarnie committed Jun 11, 2017
1 parent 722701c commit 64f2ab9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/component/contents/__tests__/DraftEditorTextNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

'use strict';

jest.unmock('DraftEditorTextNode.react')
.mock('UserAgent');
jest.disableAutomock().mock('UserAgent');

var BLOCK_DELIMITER_CHAR = '\n';
var TEST_A = 'Hello';
Expand Down
1 change: 1 addition & 0 deletions src/component/handlers/edit/editOnCut.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function editOnCut(editor: DraftEditor, e: SyntheticClipboardEvent): void {

// Track the current scroll position so that it can be forced back in place
// after the editor regains control of the DOM.
// $FlowFixMe e.target should be an instanceof Node
const scrollParent = Style.getScrollParent(e.target);
const {x, y} = getScrollPosition(scrollParent);

Expand Down
4 changes: 4 additions & 0 deletions src/component/handlers/edit/editOnInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function editOnInput(editor: DraftEditor): void {

// No change -- the DOM is up to date. Nothing to do here.
if (domText === modelText) {
// This can be buggy for some Android keyboards because they don't fire
// standard onkeydown/pressed events and only fired editOnInput
// so domText is already changed by the browser and ends up being equal
// to modelText unexpectedly
return;
}

Expand Down
15 changes: 14 additions & 1 deletion src/component/selection/setDraftEditorSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,20 @@ function addFocusToSelection(
selectionState: JSON.stringify(selectionState.toJS()),
});
}
selection.extend(node, offset);

// logging to catch bug that is being reported in t18110632
try {
selection.extend(node, offset);
} catch (e) {
DraftJsDebugLogging.logSelectionStateFailure({
anonymizedDom: getAnonymizedEditorDOM(node),
extraParams: JSON.stringify({offset: offset}),
selectionState: JSON.stringify(selectionState.toJS()),
});
// allow the error to be thrown -
// better than continuing in a broken state
throw e;
}
} else {
// IE doesn't support extend. This will mean no backward selection.
// Extract the existing selection range and add focus to it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @typechecks
*/

jest.unmock('CompositeDraftDecorator');
jest.disableAutomock().mock('ContentState');

var CompositeDraftDecorator = require('CompositeDraftDecorator');
const ContentState = require('ContentState');
Expand Down
2 changes: 1 addition & 1 deletion src/model/encoding/convertFromHTMLToContentBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function getBlockMapSupportedTags(
blockRenderMap: DraftBlockRenderMap,
): Array<string> {
const unstyledElement = blockRenderMap.get('unstyled').element;
let tags = new Set([]);
let tags = Set([]);

blockRenderMap.forEach((draftBlock: DraftBlockRenderConfig) => {
if (draftBlock.aliasedElements) {
Expand Down

0 comments on commit 64f2ab9

Please sign in to comment.