mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 21:21:21 +02:00
fix bugs in rich text example
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user