From 59a7197f81c61151f0dd150b06d4ef9cc1491e1a Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Thu, 16 Nov 2017 12:20:30 -0800 Subject: [PATCH] fix inverting of split_node and merge_node operations --- packages/slate/src/changes/by-key.js | 1 + packages/slate/src/constants/operation-attributes.js | 1 + packages/slate/src/models/operation.js | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/slate/src/changes/by-key.js b/packages/slate/src/changes/by-key.js index 270ffe5ec..d3bf33892 100644 --- a/packages/slate/src/changes/by-key.js +++ b/packages/slate/src/changes/by-key.js @@ -186,6 +186,7 @@ Changes.mergeNodeByKey = (change, key, options = {}) => { value, path, position, + target: null, }) if (normalize) { diff --git a/packages/slate/src/constants/operation-attributes.js b/packages/slate/src/constants/operation-attributes.js index 6f07057d2..1a62f0bef 100644 --- a/packages/slate/src/constants/operation-attributes.js +++ b/packages/slate/src/constants/operation-attributes.js @@ -29,6 +29,7 @@ const OPERATION_ATTRIBUTES = { 'value', 'path', 'position', + 'target', ], move_node: [ 'value', diff --git a/packages/slate/src/models/operation.js b/packages/slate/src/models/operation.js index 6cc29fd63..c25941893 100644 --- a/packages/slate/src/models/operation.js +++ b/packages/slate/src/models/operation.js @@ -104,7 +104,6 @@ class Operation extends Record(DEFAULTS) { if (key == 'document') continue if (key == 'selection') continue if (key == 'node' && type != 'insert_node') continue - if (key == 'target' && type == 'split_node') continue throw new Error(`\`Operation.fromJSON\` was passed a "${type}" operation without the required "${key}" attribute.`) } @@ -224,7 +223,6 @@ class Operation extends Record(DEFAULTS) { if (key == 'selection') continue if (key == 'value') continue if (key == 'node' && type != 'insert_node') continue - if (key == 'target' && type == 'split_node') continue if (key == 'mark' || key == 'marks' || key == 'node') { value = value.toJSON()