mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-21 13:51:59 +02:00
Don't normalize on insertText if selection is not expanded
This commit is contained in:
parent
dc8a588e41
commit
0bd52d35cd
@ -441,7 +441,7 @@ export function insertInlineAtRange(transform, range, inline, options = {}) {
|
||||
*/
|
||||
|
||||
export function insertTextAtRange(transform, range, text, marks, options = {}) {
|
||||
const { normalize = true } = options
|
||||
let { normalize } = options
|
||||
const { state } = transform
|
||||
const { document } = state
|
||||
const { startKey, startOffset } = range
|
||||
@ -455,6 +455,11 @@ export function insertTextAtRange(transform, range, text, marks, options = {}) {
|
||||
transform = transform.deleteAtRange(range, { normalize: false })
|
||||
}
|
||||
|
||||
// Unless specified, don't normalize if only inserting text
|
||||
if (normalize !== undefined) {
|
||||
normalize = range.isExpanded
|
||||
}
|
||||
|
||||
return transform.insertTextByKey(startKey, startOffset, text, marks, { normalize })
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user