From 8c9cea2aaa225a79ad349f9c11a75674579e16da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 26 Oct 2016 12:19:57 +0200 Subject: [PATCH] Add test.js for insertTExtByKey --- test.js | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/test.js b/test.js index ef1faf612..159b27faa 100644 --- a/test.js +++ b/test.js @@ -29,28 +29,9 @@ const state = Raw.deserialize({ key: 'container', nodes: [ { - key: 'in1', - kind: 'inline', - type: 'link', - nodes: [ - { - key: 'sometext', - kind: 'text', - text: 'Hello' - }, - { - key: 'in2', - kind: 'inline', - type: 'image', - isVoid: true, - nodes: [ - { - kind: 'text', - text: ' ' - } - ] - } - ] + key: 'sometext', + kind: 'text', + text: 'Hello' } ] } @@ -60,7 +41,14 @@ const state = Raw.deserialize({ print(state) const newState = state.transform() - .moveNodeByKey('in2', 'container') + .moveTo({ + anchorKey: 'sometext', + focusKey: 'sometext', + anchorOffset: 3, + focusOffset: 3 + }) + .insertTextByKey('sometext', 1, 'X') .apply() +console.log(newState.selection.toJS()) print(newState)