diff --git a/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/index.js b/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/index.js new file mode 100644 index 000000000..c39c752a5 --- /dev/null +++ b/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/index.js @@ -0,0 +1,28 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const firstText = texts.first() + + const nextSelection = selection.merge({ + anchorKey: firstText.key, + focusKey: firstText.key, + anchorOffset: 2, + focusOffset: 2 + }) + + const next = state + .transform() + .moveTo(nextSelection) + .insertTextByKey(firstText.key, 5, 'XX') + .apply() + + assert.deepEqual( + next.selection.toJS(), + nextSelection.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/input.yaml b/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/input.yaml new file mode 100644 index 000000000..98adb1781 --- /dev/null +++ b/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: hello diff --git a/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/output.yaml b/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/output.yaml new file mode 100644 index 000000000..c3dba6a90 --- /dev/null +++ b/test/transforms/fixtures/by-key/insert-text-by-key/after-selection/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: helloXX