mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-23 15:32:59 +02:00
remove normalizeParentsByKey
This commit is contained in:
@@ -201,8 +201,8 @@ export function removeTextByKey(transform, key, offset, length, options = {}) {
|
|||||||
transform.removeTextOperation(path, offset, length)
|
transform.removeTextOperation(path, offset, length)
|
||||||
|
|
||||||
if (normalize) {
|
if (normalize) {
|
||||||
const parent = document.getParent(key)
|
const block = document.getClosestBlock(key)
|
||||||
transform.normalizeParentsByKey(parent.key, SCHEMA)
|
transform.normalizeNodeByKey(block.key, SCHEMA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -155,7 +155,6 @@ import {
|
|||||||
normalizeDocument,
|
normalizeDocument,
|
||||||
normalizeSelection,
|
normalizeSelection,
|
||||||
normalizeNodeByKey,
|
normalizeNodeByKey,
|
||||||
normalizeParentsByKey,
|
|
||||||
} from './normalize'
|
} from './normalize'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -307,5 +306,4 @@ export default {
|
|||||||
normalizeDocument,
|
normalizeDocument,
|
||||||
normalizeSelection,
|
normalizeSelection,
|
||||||
normalizeNodeByKey,
|
normalizeNodeByKey,
|
||||||
normalizeParentsByKey,
|
|
||||||
}
|
}
|
||||||
|
@@ -50,28 +50,6 @@ export function normalizeNodeByKey(transform, key, schema) {
|
|||||||
normalizeNodeAndChildren(transform, node, schema)
|
normalizeNodeAndChildren(transform, node, schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize a `node` and its parents with a `schema`.
|
|
||||||
*
|
|
||||||
* @param {Transform} transform
|
|
||||||
* @param {Node|String} key
|
|
||||||
* @param {Schema} schema
|
|
||||||
*/
|
|
||||||
|
|
||||||
export function normalizeParentsByKey(transform, key, schema) {
|
|
||||||
assertSchema(schema)
|
|
||||||
|
|
||||||
// If the schema has no validation rules, there's nothing to normalize.
|
|
||||||
if (!schema.hasValidators) return
|
|
||||||
|
|
||||||
key = Normalize.key(key)
|
|
||||||
const { state } = transform
|
|
||||||
const { document } = state
|
|
||||||
const node = document.assertNode(key)
|
|
||||||
|
|
||||||
normalizeNodeAndParents(transform, node, schema)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize the selection.
|
* Normalize the selection.
|
||||||
*
|
*
|
||||||
@@ -137,31 +115,6 @@ function normalizeNodeAndChildren(transform, node, schema) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize a `node` and its parents with a `schema`.
|
|
||||||
*
|
|
||||||
* @param {Transform} transform
|
|
||||||
* @param {Node} node
|
|
||||||
* @param {Schema} schema
|
|
||||||
*/
|
|
||||||
|
|
||||||
function normalizeNodeAndParents(transform, node, schema) {
|
|
||||||
normalizeNode(transform, node, schema)
|
|
||||||
|
|
||||||
// We're at the top of the document.
|
|
||||||
if (node.kind == 'document') return
|
|
||||||
|
|
||||||
// Re-find the node first.
|
|
||||||
node = refindNode(transform, node)
|
|
||||||
if (!node) return
|
|
||||||
|
|
||||||
const { state } = transform
|
|
||||||
const { document } = state
|
|
||||||
const parent = document.getParent(node.key)
|
|
||||||
|
|
||||||
normalizeNodeAndParents(transform, parent, schema)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-find a reference to a node that may have been modified or removed
|
* Re-find a reference to a node that may have been modified or removed
|
||||||
* entirely by a transform.
|
* entirely by a transform.
|
||||||
|
Reference in New Issue
Block a user