mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 17:23:07 +01:00
33 lines
652 B
JavaScript
33 lines
652 B
JavaScript
|
|
/**
|
|
* Normalize the document.
|
|
*
|
|
* @param {Transform} transform
|
|
* @return {Transform}
|
|
*/
|
|
|
|
export function normalizeDocument(transform) {
|
|
let { state } = transform
|
|
let { document } = state
|
|
document = document.normalize()
|
|
state = state.merge({ document })
|
|
transform.state = state
|
|
return transform
|
|
}
|
|
|
|
/**
|
|
* Normalize the selection.
|
|
*
|
|
* @param {Transform} transform
|
|
* @return {Transform}
|
|
*/
|
|
|
|
export function normalizeSelection(transform) {
|
|
let { state } = transform
|
|
let { document, selection } = state
|
|
selection = selection.normalize(document)
|
|
state = state.merge({ selection })
|
|
transform.state = state
|
|
return transform
|
|
}
|