fix: paragraphCtrl cursor may be null (#855)

This commit is contained in:
Felix Häusler 2019-04-06 00:52:49 +02:00 committed by Ran Luo
parent 30a1423d02
commit b0ae437ba4

View File

@ -18,6 +18,10 @@ const getCurrentLevel = type => {
const paragraphCtrl = ContentState => {
ContentState.prototype.selectionChange = function (cursor) {
const { start, end } = cursor || selection.getCursorRange()
if (!start || !end) {
// TODO: Throw an exception and try to fix this later (GH#848).
throw new Error('selectionChange: expected cursor but cursor is null.')
}
const cursorCoords = selection.getCursorCoords()
const startBlock = this.getBlock(start.key)
const endBlock = this.getBlock(end.key)