From 90d4eced95cbd86272d125d327b15893dcc58c51 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Tue, 9 Aug 2016 09:32:46 -0700 Subject: [PATCH] add wrapTextAtRange tests, cleanup wrapText style and backwards handling --- docs/reference/models/transform.md | 8 ++--- lib/models/state.js | 31 +++++++++------- lib/models/transforms.js | 25 +++++++------ .../wrap-text-at-range/across-blocks/index.js | 18 ++++++++++ .../across-blocks/input.yaml | 12 +++++++ .../across-blocks/output.yaml | 12 +++++++ .../across-inlines/index.js | 18 ++++++++++ .../across-inlines/input.yaml | 15 ++++++++ .../across-inlines/output.yaml | 15 ++++++++ .../backwards-selection/index.js | 18 ++++++++++ .../backwards-selection/input.yaml | 7 ++++ .../backwards-selection/output.yaml | 7 ++++ .../wrap-text-at-range/empty-block/index.js | 17 +++++++++ .../wrap-text-at-range/empty-block/input.yaml | 7 ++++ .../empty-block/output.yaml | 7 ++++ .../wrap-text-at-range/end-of-block/index.js | 17 +++++++++ .../end-of-block/input.yaml | 7 ++++ .../end-of-block/output.yaml | 7 ++++ .../middle-of-block/index.js | 17 +++++++++ .../middle-of-block/input.yaml | 7 ++++ .../middle-of-block/output.yaml | 7 ++++ .../start-of-block/index.js | 17 +++++++++ .../start-of-block/input.yaml | 7 ++++ .../start-of-block/output.yaml | 7 ++++ .../wrap-text-at-range/whole-block/index.js | 17 +++++++++ .../wrap-text-at-range/whole-block/input.yaml | 7 ++++ .../whole-block/output.yaml | 7 ++++ .../without-suffix/index.js | 17 +++++++++ .../without-suffix/input.yaml | 7 ++++ .../without-suffix/output.yaml | 7 ++++ .../wrap-text/backwards-selection/index.js | 36 +++++++++++++++++++ .../wrap-text/backwards-selection/input.yaml | 7 ++++ .../wrap-text/backwards-selection/output.yaml | 7 ++++ 33 files changed, 395 insertions(+), 27 deletions(-) create mode 100644 test/transforms/fixtures/wrap-text-at-range/across-blocks/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/across-blocks/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/across-blocks/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/across-inlines/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/across-inlines/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/across-inlines/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/backwards-selection/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/backwards-selection/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/backwards-selection/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/empty-block/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/empty-block/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/empty-block/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/end-of-block/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/end-of-block/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/end-of-block/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/middle-of-block/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/middle-of-block/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/middle-of-block/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/start-of-block/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/start-of-block/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/start-of-block/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/whole-block/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/whole-block/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/whole-block/output.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/without-suffix/index.js create mode 100644 test/transforms/fixtures/wrap-text-at-range/without-suffix/input.yaml create mode 100644 test/transforms/fixtures/wrap-text-at-range/without-suffix/output.yaml create mode 100644 test/transforms/fixtures/wrap-text/backwards-selection/index.js create mode 100644 test/transforms/fixtures/wrap-text/backwards-selection/input.yaml create mode 100644 test/transforms/fixtures/wrap-text/backwards-selection/output.yaml diff --git a/docs/reference/models/transform.md b/docs/reference/models/transform.md index 48f2a2379a..49398c5d3f 100644 --- a/docs/reference/models/transform.md +++ b/docs/reference/models/transform.md @@ -188,9 +188,9 @@ Wrap the [`Block`](./block.md) nodes in the current selection with a new [`Block Wrap the [`Inline`](./inline.md) nodes in the current selection with a new [`Inline`](./inline.md) node of `type`, with optional `data`. ### `wrapText` -`wrapText(before: String, after: String) => Transform` +`wrapText(prefix: String, [suffix: String]) => Transform` -Surround the text in the current selection. +Surround the text in the current selection with `prefix` and `suffix` strings. If the `suffix` is ommitted, the `prefix` will be used instead. ## Selection Transforms @@ -378,9 +378,9 @@ Wrap the [`Block`](./block.md) nodes in a `range` with a new [`Block`](./block.m Wrap the [`Inline`](./inline.md) nodes in a `range` with a new [`Inline`](./inline.md) node with `properties`. For convenience, you can pass a `type` string or `properties` object. ### `wrapTextAtRange` -`wrapTextAtRange(range: Selection, prefix: String, suffix: String) => Transform` +`wrapTextAtRange(range: Selection, prefix: String, [suffix: String]) => Transform` -Surround the text in a `range`. +Surround the text in a `range` with `prefix` and `suffix` strings. If the `suffix` is ommitted, the `prefix` will be used instead. ## History Transforms diff --git a/lib/models/state.js b/lib/models/state.js index 911ca42eaf..fba38c24bb 100644 --- a/lib/models/state.js +++ b/lib/models/state.js @@ -1146,21 +1146,28 @@ class State extends new Record(DEFAULTS) { */ wrapText(prefix, suffix = prefix) { - let { document, selection } = this - let { startKey, endKey, startOffset, endOffset } = selection - let acrossBlocks = (startKey !== endKey) + let state = this + let { document, selection } = state + let { anchorOffset, anchorKey, focusOffset, focusKey, isBackward } = selection + let after - document = document.wrapTextAtRange(selection, prefix, suffix) + // Determine what the selection should be after wrapping. + if (anchorKey == focusKey) { + after = selection.moveForward(prefix.length) + } - selection = selection - .merge({ - anchorKey: startKey, - anchorOffset: startOffset + prefix.length, - focusKey: endKey, - focusOffset: acrossBlocks ? endOffset : endOffset + prefix.length - }) + else { + after = selection.merge({ + anchorOffset: isBackward ? anchorOffset : anchorOffset + prefix.length, + focusOffset: isBackward ? focusOffset + prefix.length : focusOffset + }) + } - return this.merge({ document, selection }) + // Wrap the text and update the state. + document = document.wrapTextAtRange(selection, prefix, suffix) + selection = after + state = state.merge({ document, selection }) + return state } /** diff --git a/lib/models/transforms.js b/lib/models/transforms.js index c26f5609a9..7a6cdc03b0 100644 --- a/lib/models/transforms.js +++ b/lib/models/transforms.js @@ -1017,7 +1017,7 @@ const Transforms = { }) return node.normalize() -}, + }, /** * Wrap the text in a `range` in a prefix/suffix. @@ -1029,16 +1029,19 @@ const Transforms = { */ wrapTextAtRange(range, prefix, suffix = prefix) { - let withPrefix = this.insertTextAtRange(range.collapseToAnchor(), prefix) - let acrossBlocks = (range.startKey !== range.endKey) - let withSuffix = withPrefix.insertTextAtRange( - range - .collapseToFocus() - .moveForward(acrossBlocks ? 0 : prefix.length), - suffix - ) - - return withSuffix + let node = this + + // Insert text at the starting edge. + const { startKey, endKey } = range + const start = range.collapseToStart() + node = node.insertTextAtRange(start, prefix) + + // Determine the new ending edge, and insert text there. + let end = range.collapseToEnd() + if (startKey == endKey) end = end.moveForward(prefix.length) + node = node.insertTextAtRange(end, suffix) + + return node } } diff --git a/test/transforms/fixtures/wrap-text-at-range/across-blocks/index.js b/test/transforms/fixtures/wrap-text-at-range/across-blocks/index.js new file mode 100644 index 0000000000..745f842890 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/across-blocks/index.js @@ -0,0 +1,18 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const last = texts.last() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 2, + focusKey: last.key, + focusOffset: 2 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/across-blocks/input.yaml b/test/transforms/fixtures/wrap-text-at-range/across-blocks/input.yaml new file mode 100644 index 0000000000..881deb1d97 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/across-blocks/input.yaml @@ -0,0 +1,12 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word + - kind: block + type: paragraph + nodes: + - kind: text + text: another diff --git a/test/transforms/fixtures/wrap-text-at-range/across-blocks/output.yaml b/test/transforms/fixtures/wrap-text-at-range/across-blocks/output.yaml new file mode 100644 index 0000000000..1d855199c3 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/across-blocks/output.yaml @@ -0,0 +1,12 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: wo[[rd + - kind: block + type: paragraph + nodes: + - kind: text + text: an]]other diff --git a/test/transforms/fixtures/wrap-text-at-range/across-inlines/index.js b/test/transforms/fixtures/wrap-text-at-range/across-inlines/index.js new file mode 100644 index 0000000000..745f842890 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/across-inlines/index.js @@ -0,0 +1,18 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const last = texts.last() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 2, + focusKey: last.key, + focusOffset: 2 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/across-inlines/input.yaml b/test/transforms/fixtures/wrap-text-at-range/across-inlines/input.yaml new file mode 100644 index 0000000000..c17ccbcf23 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/across-inlines/input.yaml @@ -0,0 +1,15 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: inline + type: link + nodes: + - kind: text + text: word + - kind: inline + type: link + nodes: + - kind: text + text: another diff --git a/test/transforms/fixtures/wrap-text-at-range/across-inlines/output.yaml b/test/transforms/fixtures/wrap-text-at-range/across-inlines/output.yaml new file mode 100644 index 0000000000..780ee42bda --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/across-inlines/output.yaml @@ -0,0 +1,15 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: inline + type: link + nodes: + - kind: text + text: wo[[rd + - kind: inline + type: link + nodes: + - kind: text + text: an]]other diff --git a/test/transforms/fixtures/wrap-text-at-range/backwards-selection/index.js b/test/transforms/fixtures/wrap-text-at-range/backwards-selection/index.js new file mode 100644 index 0000000000..f676c98e01 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/backwards-selection/index.js @@ -0,0 +1,18 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 3, + focusKey: first.key, + focusOffset: 1, + isBackward: true + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/backwards-selection/input.yaml b/test/transforms/fixtures/wrap-text-at-range/backwards-selection/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/backwards-selection/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text-at-range/backwards-selection/output.yaml b/test/transforms/fixtures/wrap-text-at-range/backwards-selection/output.yaml new file mode 100644 index 0000000000..d6bdaa3c17 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/backwards-selection/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: w[[or]]d diff --git a/test/transforms/fixtures/wrap-text-at-range/empty-block/index.js b/test/transforms/fixtures/wrap-text-at-range/empty-block/index.js new file mode 100644 index 0000000000..41cb0f9863 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/empty-block/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 0 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/empty-block/input.yaml b/test/transforms/fixtures/wrap-text-at-range/empty-block/input.yaml new file mode 100644 index 0000000000..f6de4d08a6 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/empty-block/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: "" diff --git a/test/transforms/fixtures/wrap-text-at-range/empty-block/output.yaml b/test/transforms/fixtures/wrap-text-at-range/empty-block/output.yaml new file mode 100644 index 0000000000..aae1e88b1f --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/empty-block/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: "[[]]" diff --git a/test/transforms/fixtures/wrap-text-at-range/end-of-block/index.js b/test/transforms/fixtures/wrap-text-at-range/end-of-block/index.js new file mode 100644 index 0000000000..0287baf4ad --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/end-of-block/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 2, + focusKey: first.key, + focusOffset: 4 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/end-of-block/input.yaml b/test/transforms/fixtures/wrap-text-at-range/end-of-block/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/end-of-block/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text-at-range/end-of-block/output.yaml b/test/transforms/fixtures/wrap-text-at-range/end-of-block/output.yaml new file mode 100644 index 0000000000..d6f4e2b536 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/end-of-block/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: wo[[rd]] diff --git a/test/transforms/fixtures/wrap-text-at-range/middle-of-block/index.js b/test/transforms/fixtures/wrap-text-at-range/middle-of-block/index.js new file mode 100644 index 0000000000..a77220934a --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/middle-of-block/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 1, + focusKey: first.key, + focusOffset: 3 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/middle-of-block/input.yaml b/test/transforms/fixtures/wrap-text-at-range/middle-of-block/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/middle-of-block/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text-at-range/middle-of-block/output.yaml b/test/transforms/fixtures/wrap-text-at-range/middle-of-block/output.yaml new file mode 100644 index 0000000000..d6bdaa3c17 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/middle-of-block/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: w[[or]]d diff --git a/test/transforms/fixtures/wrap-text-at-range/start-of-block/index.js b/test/transforms/fixtures/wrap-text-at-range/start-of-block/index.js new file mode 100644 index 0000000000..a5c04ebb5b --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/start-of-block/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 2 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/start-of-block/input.yaml b/test/transforms/fixtures/wrap-text-at-range/start-of-block/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/start-of-block/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text-at-range/start-of-block/output.yaml b/test/transforms/fixtures/wrap-text-at-range/start-of-block/output.yaml new file mode 100644 index 0000000000..2e61de8bcb --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/start-of-block/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: "[[wo]]rd" diff --git a/test/transforms/fixtures/wrap-text-at-range/whole-block/index.js b/test/transforms/fixtures/wrap-text-at-range/whole-block/index.js new file mode 100644 index 0000000000..a12a606ace --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/whole-block/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 4 + }) + + return state + .transform() + .wrapTextAtRange(range, '[[', ']]') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/whole-block/input.yaml b/test/transforms/fixtures/wrap-text-at-range/whole-block/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/whole-block/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text-at-range/whole-block/output.yaml b/test/transforms/fixtures/wrap-text-at-range/whole-block/output.yaml new file mode 100644 index 0000000000..6ca0333a29 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/whole-block/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: "[[word]]" diff --git a/test/transforms/fixtures/wrap-text-at-range/without-suffix/index.js b/test/transforms/fixtures/wrap-text-at-range/without-suffix/index.js new file mode 100644 index 0000000000..80f6a18745 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/without-suffix/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 1, + focusKey: first.key, + focusOffset: 3 + }) + + return state + .transform() + .wrapTextAtRange(range, '**') + .apply() +} diff --git a/test/transforms/fixtures/wrap-text-at-range/without-suffix/input.yaml b/test/transforms/fixtures/wrap-text-at-range/without-suffix/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/without-suffix/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text-at-range/without-suffix/output.yaml b/test/transforms/fixtures/wrap-text-at-range/without-suffix/output.yaml new file mode 100644 index 0000000000..6140323dca --- /dev/null +++ b/test/transforms/fixtures/wrap-text-at-range/without-suffix/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: w**or**d diff --git a/test/transforms/fixtures/wrap-text/backwards-selection/index.js b/test/transforms/fixtures/wrap-text/backwards-selection/index.js new file mode 100644 index 0000000000..a3d5bedac8 --- /dev/null +++ b/test/transforms/fixtures/wrap-text/backwards-selection/index.js @@ -0,0 +1,36 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 3, + focusKey: first.key, + focusOffset: 1, + isBackward: true + }) + + const next = state + .transform() + .moveTo(range) + .wrapText('[[', ']]') + .apply() + + + const updated = next.document.getTexts().get(0) + + assert.deepEqual( + next.selection.toJS(), + range.merge({ + anchorKey: updated.key, + anchorOffset: 5, + focusKey: updated.key, + focusOffset: 3 + }).toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/wrap-text/backwards-selection/input.yaml b/test/transforms/fixtures/wrap-text/backwards-selection/input.yaml new file mode 100644 index 0000000000..27f668fe22 --- /dev/null +++ b/test/transforms/fixtures/wrap-text/backwards-selection/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: word diff --git a/test/transforms/fixtures/wrap-text/backwards-selection/output.yaml b/test/transforms/fixtures/wrap-text/backwards-selection/output.yaml new file mode 100644 index 0000000000..d6bdaa3c17 --- /dev/null +++ b/test/transforms/fixtures/wrap-text/backwards-selection/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: w[[or]]d