Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Copy over misc. changes from Facebook #1245

Merged
merged 1 commit into from
Jun 11, 2017
Merged
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
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