Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix getting defaultView from this.editor
  • Loading branch information
haikyuu committed Sep 21, 2018
commit d27b28b4a050c0d7f5516fe54e8c50eee673ee3d
2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.js.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,11 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
if (isIE) {
// editor can be null after mounting
// https://stackoverflow.com/questions/44074747/componentdidmount-called-before-ref-callback

const castedEditor: HTMLElement = (this.editor: any);
(castedEditor ? castedEditor.editor.ownerDocument : global).execCommand(
'AutoUrlDetect',
false,
false,
);
if (!this.editor) {
global.execCommand('AutoUrlDetect', false, false);
} else {
this.editor.ownerDocument.execCommand('AutoUrlDetect', false, false);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/component/handlers/edit/editOnInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function editOnInput(editor: DraftEditor): void {
editor._pendingStateFromBeforeInput = undefined;
}
// at this point editor is not null for sure (after input)
const castedEditorElement: HTMLElement = (editor: any);
const domSelection = castedEditorElement.editor.ownerDocument.defaultView.getSelection();
const castedEditorElement: HTMLElement = (editor.editor: any);
const domSelection = castedEditorElement.ownerDocument.defaultView.getSelection();

const {anchorNode, isCollapsed} = domSelection;
const isNotTextNode = anchorNode.nodeType !== Node.TEXT_NODE;
Expand Down