1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 18:09:49 +02:00

fix #342, Uncaught Error: Invalid key argument when removeNodeByKey (#365)

* fix #342, Uncaught Error: Invalid `key` argument when `removeNodeByKey`

* return List() and use selection.isUnset instead

* fix default value when this.selection.isUnset
This commit is contained in:
LiJung Chi
2016-10-12 00:41:42 +08:00
committed by Ian Storm Taylor
parent 3061b6e607
commit b7eb15dfad

View File

@@ -5,7 +5,7 @@ import Mark from './mark'
import Selection from './selection' import Selection from './selection'
import Transform from './transform' import Transform from './transform'
import uid from '../utils/uid' import uid from '../utils/uid'
import { Record, Set, Stack } from 'immutable' import { Record, Set, Stack, List } from 'immutable'
/** /**
* History. * History.
@@ -361,7 +361,9 @@ class State extends new Record(DEFAULTS) {
*/ */
get marks() { get marks() {
return this.selection.marks || this.document.getMarksAtRange(this.selection) return this.selection.isUnset
? new Set()
: this.selection.marks || this.document.getMarksAtRange(this.selection)
} }
/** /**
@@ -371,7 +373,9 @@ class State extends new Record(DEFAULTS) {
*/ */
get blocks() { get blocks() {
return this.document.getBlocksAtRange(this.selection) return this.selection.isUnset
? new List()
: this.document.getBlocksAtRange(this.selection)
} }
/** /**
@@ -381,7 +385,9 @@ class State extends new Record(DEFAULTS) {
*/ */
get fragment() { get fragment() {
return this.document.getFragmentAtRange(this.selection) return this.selection.isUnset
? Document.create()
: this.document.getFragmentAtRange(this.selection)
} }
/** /**
@@ -391,7 +397,9 @@ class State extends new Record(DEFAULTS) {
*/ */
get inlines() { get inlines() {
return this.document.getInlinesAtRange(this.selection) return this.selection.isUnset
? new List()
: this.document.getInlinesAtRange(this.selection)
} }
/** /**
@@ -401,7 +409,9 @@ class State extends new Record(DEFAULTS) {
*/ */
get texts() { get texts() {
return this.document.getTextsAtRange(this.selection) return this.selection.isUnset
? new List()
: this.document.getTextsAtRange(this.selection)
} }
/** /**