mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 06:53:25 +02:00
fix basic copy pate
This commit is contained in:
@@ -415,7 +415,7 @@ const Node = {
|
|||||||
const text = this.getDescendant(startKey)
|
const text = this.getDescendant(startKey)
|
||||||
const previous = this.getPreviousText(startKey)
|
const previous = this.getPreviousText(startKey)
|
||||||
if (!previous) return marks
|
if (!previous) return marks
|
||||||
const char = text.characters.get(previous.length - 1)
|
const char = previous.characters.get(previous.length - 1)
|
||||||
return char.marks
|
return char.marks
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,6 +699,14 @@ const Node = {
|
|||||||
|
|
||||||
normalize() {
|
normalize() {
|
||||||
let node = this
|
let node = this
|
||||||
|
const texts = node.getTextNodes()
|
||||||
|
|
||||||
|
// If there are no text nodes, add one.
|
||||||
|
if (!texts.size) {
|
||||||
|
const text = Text.create()
|
||||||
|
const nodes = node.nodes.push(text)
|
||||||
|
return node.merge({ nodes })
|
||||||
|
}
|
||||||
|
|
||||||
// See if there are any adjacent text nodes.
|
// See if there are any adjacent text nodes.
|
||||||
let firstAdjacent = node.findDescendant((child) => {
|
let firstAdjacent = node.findDescendant((child) => {
|
||||||
|
@@ -400,9 +400,16 @@ class State extends Record(DEFAULTS) {
|
|||||||
insertText(text) {
|
insertText(text) {
|
||||||
let state = this
|
let state = this
|
||||||
let { document, selection } = state
|
let { document, selection } = state
|
||||||
|
let after = selection
|
||||||
|
|
||||||
|
// Determine what the selection should be after inserting.
|
||||||
|
if (selection.isExpanded) {
|
||||||
|
after = selection.moveToStart()
|
||||||
|
}
|
||||||
|
|
||||||
// Insert the text and update the selection.
|
// Insert the text and update the selection.
|
||||||
document = document.insertTextAtRange(selection, text)
|
document = document.insertTextAtRange(selection, text)
|
||||||
|
selection = after
|
||||||
selection = selection.moveForward(text.length)
|
selection = selection.moveForward(text.length)
|
||||||
state = state.merge({ document, selection })
|
state = state.merge({ document, selection })
|
||||||
return state
|
return state
|
||||||
|
Reference in New Issue
Block a user