mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 14:41:23 +02:00
fix basic copy pate
This commit is contained in:
@@ -415,7 +415,7 @@ const Node = {
|
||||
const text = this.getDescendant(startKey)
|
||||
const previous = this.getPreviousText(startKey)
|
||||
if (!previous) return marks
|
||||
const char = text.characters.get(previous.length - 1)
|
||||
const char = previous.characters.get(previous.length - 1)
|
||||
return char.marks
|
||||
}
|
||||
|
||||
@@ -699,6 +699,14 @@ const Node = {
|
||||
|
||||
normalize() {
|
||||
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.
|
||||
let firstAdjacent = node.findDescendant((child) => {
|
||||
|
@@ -400,9 +400,16 @@ class State extends Record(DEFAULTS) {
|
||||
insertText(text) {
|
||||
let state = this
|
||||
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.
|
||||
document = document.insertTextAtRange(selection, text)
|
||||
selection = after
|
||||
selection = selection.moveForward(text.length)
|
||||
state = state.merge({ document, selection })
|
||||
return state
|
||||
|
Reference in New Issue
Block a user