From 6f5f2db271b55ce962d91b211ceb065eb612bd63 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Fri, 29 Dec 2017 13:48:28 -0500 Subject: [PATCH] fix #1487 (#1488) --- packages/slate/src/changes/at-range.js | 2 +- .../history/undo/wrap-inline-across-blocks.js | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 packages/slate/test/history/undo/wrap-inline-across-blocks.js diff --git a/packages/slate/src/changes/at-range.js b/packages/slate/src/changes/at-range.js index c195b5396..88378c840 100644 --- a/packages/slate/src/changes/at-range.js +++ b/packages/slate/src/changes/at-range.js @@ -1351,7 +1351,7 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { const startNode = inline.regenerateKey() const endNode = inline.regenerateKey() - change.insertNodeByKey(startBlock.key, startIndex - 1, startNode, { normalize: false }) + change.insertNodeByKey(startBlock.key, startIndex + 1, startNode, { normalize: false }) change.insertNodeByKey(endBlock.key, endIndex, endNode, { normalize: false }) startInlines.forEach((child, i) => { diff --git a/packages/slate/test/history/undo/wrap-inline-across-blocks.js b/packages/slate/test/history/undo/wrap-inline-across-blocks.js new file mode 100644 index 000000000..0b406fd93 --- /dev/null +++ b/packages/slate/test/history/undo/wrap-inline-across-blocks.js @@ -0,0 +1,28 @@ +/** @jsx h */ + +import h from '../../helpers/h' + +export default function (value) { + return value + .change() + .wrapInline('hashtag') + .value + .change() + .undo() + .value +} + +export const input = ( + + + + word + + + another + + + +) + +export const output = input