From 5b81f0bd843abc1aef34c9bb3814a27337d06adb Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Tue, 22 Nov 2016 17:40:26 -0800 Subject: [PATCH] remove normalizeParentsByKey --- src/transforms/by-key.js | 4 ++-- src/transforms/index.js | 2 -- src/transforms/normalize.js | 47 ------------------------------------- 3 files changed, 2 insertions(+), 51 deletions(-) diff --git a/src/transforms/by-key.js b/src/transforms/by-key.js index 869a52fc3..3a128f803 100644 --- a/src/transforms/by-key.js +++ b/src/transforms/by-key.js @@ -201,8 +201,8 @@ export function removeTextByKey(transform, key, offset, length, options = {}) { transform.removeTextOperation(path, offset, length) if (normalize) { - const parent = document.getParent(key) - transform.normalizeParentsByKey(parent.key, SCHEMA) + const block = document.getClosestBlock(key) + transform.normalizeNodeByKey(block.key, SCHEMA) } } diff --git a/src/transforms/index.js b/src/transforms/index.js index 6ce9e61cf..8ee1eac6f 100644 --- a/src/transforms/index.js +++ b/src/transforms/index.js @@ -155,7 +155,6 @@ import { normalizeDocument, normalizeSelection, normalizeNodeByKey, - normalizeParentsByKey, } from './normalize' /** @@ -307,5 +306,4 @@ export default { normalizeDocument, normalizeSelection, normalizeNodeByKey, - normalizeParentsByKey, } diff --git a/src/transforms/normalize.js b/src/transforms/normalize.js index f0473c308..76ecbae59 100644 --- a/src/transforms/normalize.js +++ b/src/transforms/normalize.js @@ -50,28 +50,6 @@ export function normalizeNodeByKey(transform, key, 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. * @@ -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 * entirely by a transform.