1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 13:11:17 +02:00

fix bugs in rich text example

This commit is contained in:
Ian Storm Taylor
2016-06-21 17:08:15 -07:00
parent c3257a37d4
commit 38b85fe720
3 changed files with 11 additions and 16 deletions

View File

@@ -22,8 +22,8 @@ class App extends React.Component {
hasBlock(type) {
const { state } = this.state
const { currentWrappingNodes } = state
return currentWrappingNodes.some(node => node.type == type)
const { currentBlockNodes } = state
return currentBlockNodes.some(node => node.type == type)
}
onClickMark(e, type) {

View File

@@ -549,16 +549,11 @@ const Node = {
hasNode(key) {
key = normalizeKey(key)
const shallow = this.nodes.has(key)
if (shallow) return true
const deep = this.nodes
.map(node => node.kind == 'text' ? false : node.hasNode(key))
.some(has => has)
if (deep) return true
return false
return !! this.nodes.find((node) => {
return node.kind == 'text'
? node.key == key
: node.key == key || node.hasNode(key)
})
},
/**

View File

@@ -200,12 +200,12 @@ class State extends Record(DEFAULTS) {
const { startKey } = selection
const startNode = document.getNode(startKey)
if (selection.isAtStartOf(document)) {
after = selection
if (selection.isExpanded) {
after = selection.moveToStart()
}
else if (selection.isExpanded) {
after = selection.moveToStart()
else if (selection.isAtStartOf(document)) {
after = selection
}
else if (selection.isAtStartOf(startNode)) {