mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-07 07:46:32 +02:00
Don't normalize on insertText if selection is not expanded
This commit is contained in:
@@ -441,7 +441,7 @@ export function insertInlineAtRange(transform, range, inline, options = {}) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function insertTextAtRange(transform, range, text, marks, options = {}) {
|
export function insertTextAtRange(transform, range, text, marks, options = {}) {
|
||||||
const { normalize = true } = options
|
let { normalize } = options
|
||||||
const { state } = transform
|
const { state } = transform
|
||||||
const { document } = state
|
const { document } = state
|
||||||
const { startKey, startOffset } = range
|
const { startKey, startOffset } = range
|
||||||
@@ -455,6 +455,11 @@ export function insertTextAtRange(transform, range, text, marks, options = {}) {
|
|||||||
transform = transform.deleteAtRange(range, { normalize: false })
|
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 })
|
return transform.insertTextByKey(startKey, startOffset, text, marks, { normalize })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user