mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-02 19:52:32 +02:00
Accept Node as argument type for normalizeNodeByKey
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import warning from '../utils/warning'
|
import warning from '../utils/warning'
|
||||||
import { default as defaultSchema } from '../plugins/schema'
|
import { default as defaultSchema } from '../plugins/schema'
|
||||||
|
import Normalize from '../utils/normalize'
|
||||||
|
|
||||||
// Maximum recursive calls for normalization
|
// Maximum recursive calls for normalization
|
||||||
const MAX_CALLS = 50
|
const MAX_CALLS = 50
|
||||||
@@ -41,7 +42,7 @@ function _normalizeChildrenWith(transform, schema, node, prevNode) {
|
|||||||
|
|
||||||
return node.nodes.reduce(
|
return node.nodes.reduce(
|
||||||
(t, child) => {
|
(t, child) => {
|
||||||
const prevChild = prevNode ? prevNode.getChild(child) : null
|
const prevChild = prevNode ? prevNode.getChild(child.key) : null
|
||||||
return t.normalizeNodeWith(schema, child, prevChild)
|
return t.normalizeNodeWith(schema, child, prevChild)
|
||||||
},
|
},
|
||||||
transform
|
transform
|
||||||
@@ -216,6 +217,7 @@ export function normalizeDocument(transform) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function normalizeNodeByKey(transform, key) {
|
export function normalizeNodeByKey(transform, key) {
|
||||||
|
key = Normalize.key(key)
|
||||||
const { state, prevState } = transform
|
const { state, prevState } = transform
|
||||||
const { document } = state
|
const { document } = state
|
||||||
const { document: prevDocument } = prevState || {}
|
const { document: prevDocument } = prevState || {}
|
||||||
@@ -236,6 +238,7 @@ export function normalizeNodeByKey(transform, key) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function normalizeParentsByKey(transform, key) {
|
export function normalizeParentsByKey(transform, key) {
|
||||||
|
key = Normalize.key(key)
|
||||||
const { state, prevState } = transform
|
const { state, prevState } = transform
|
||||||
const { document } = state
|
const { document } = state
|
||||||
const { document: prevDocument } = prevState || {}
|
const { document: prevDocument } = prevState || {}
|
||||||
|
Reference in New Issue
Block a user