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) {
|
hasBlock(type) {
|
||||||
const { state } = this.state
|
const { state } = this.state
|
||||||
const { currentWrappingNodes } = state
|
const { currentBlockNodes } = state
|
||||||
return currentWrappingNodes.some(node => node.type == type)
|
return currentBlockNodes.some(node => node.type == type)
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickMark(e, type) {
|
onClickMark(e, type) {
|
||||||
|
@@ -549,16 +549,11 @@ const Node = {
|
|||||||
|
|
||||||
hasNode(key) {
|
hasNode(key) {
|
||||||
key = normalizeKey(key)
|
key = normalizeKey(key)
|
||||||
|
return !! this.nodes.find((node) => {
|
||||||
const shallow = this.nodes.has(key)
|
return node.kind == 'text'
|
||||||
if (shallow) return true
|
? node.key == key
|
||||||
|
: node.key == key || node.hasNode(key)
|
||||||
const deep = this.nodes
|
})
|
||||||
.map(node => node.kind == 'text' ? false : node.hasNode(key))
|
|
||||||
.some(has => has)
|
|
||||||
if (deep) return true
|
|
||||||
|
|
||||||
return false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -200,12 +200,12 @@ class State extends Record(DEFAULTS) {
|
|||||||
const { startKey } = selection
|
const { startKey } = selection
|
||||||
const startNode = document.getNode(startKey)
|
const startNode = document.getNode(startKey)
|
||||||
|
|
||||||
if (selection.isAtStartOf(document)) {
|
if (selection.isExpanded) {
|
||||||
after = selection
|
after = selection.moveToStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (selection.isExpanded) {
|
else if (selection.isAtStartOf(document)) {
|
||||||
after = selection.moveToStart()
|
after = selection
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (selection.isAtStartOf(startNode)) {
|
else if (selection.isAtStartOf(startNode)) {
|
||||||
|
Reference in New Issue
Block a user