diff --git a/test/transforms/fixtures/unwrap-block-at-range/across-inlines/index.js b/test/transforms/fixtures/unwrap-block-at-range/across-inlines/index.js index cd110a745..51951ec7a 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/across-inlines/index.js +++ b/test/transforms/fixtures/unwrap-block-at-range/across-inlines/index.js @@ -13,6 +13,6 @@ export default function (state) { return state .transform() - .wrapBlockAtRange(range, 'quote') + .unwrapBlockAtRange(range, 'quote') .apply() } diff --git a/test/transforms/fixtures/unwrap-block-at-range/across-inlines/input.yaml b/test/transforms/fixtures/unwrap-block-at-range/across-inlines/input.yaml index c31f583e3..f4bfc7303 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/across-inlines/input.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/across-inlines/input.yaml @@ -1,20 +1,23 @@ nodes: - kind: block - type: paragraph + type: quote nodes: - - kind: inline - type: link + - kind: block + type: paragraph nodes: - - kind: text - ranges: - - text: word - - kind: block - type: paragraph - nodes: - - kind: inline - type: link + - kind: inline + type: link + nodes: + - kind: text + ranges: + - text: word + - kind: block + type: paragraph nodes: - - kind: text - ranges: - - text: another + - kind: inline + type: link + nodes: + - kind: text + ranges: + - text: another diff --git a/test/transforms/fixtures/unwrap-block-at-range/across-inlines/output.yaml b/test/transforms/fixtures/unwrap-block-at-range/across-inlines/output.yaml index f4bfc7303..c31f583e3 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/across-inlines/output.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/across-inlines/output.yaml @@ -1,23 +1,20 @@ nodes: - kind: block - type: quote + type: paragraph nodes: - - kind: block - type: paragraph + - kind: inline + type: link nodes: - - kind: inline - type: link - nodes: - - kind: text - ranges: - - text: word - - kind: block - type: paragraph + - kind: text + ranges: + - text: word + - kind: block + type: paragraph + nodes: + - kind: inline + type: link nodes: - - kind: inline - type: link - nodes: - - kind: text - ranges: - - text: another + - kind: text + ranges: + - text: another diff --git a/test/transforms/fixtures/unwrap-block-at-range/nested-block/index.js b/test/transforms/fixtures/unwrap-block-at-range/nested-block/index.js index acb2e8288..02ad25b2d 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/nested-block/index.js +++ b/test/transforms/fixtures/unwrap-block-at-range/nested-block/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .wrapBlockAtRange(range, 'quote') + .unwrapBlockAtRange(range, 'quote') .apply() } diff --git a/test/transforms/fixtures/unwrap-block-at-range/nested-block/input.yaml b/test/transforms/fixtures/unwrap-block-at-range/nested-block/input.yaml index c4ac2e6c5..5dd1c2b59 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/nested-block/input.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/nested-block/input.yaml @@ -4,8 +4,11 @@ nodes: type: quote nodes: - kind: block - type: paragraph + type: quote nodes: - - kind: text - ranges: - - text: word + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/nested-block/output.yaml b/test/transforms/fixtures/unwrap-block-at-range/nested-block/output.yaml index 5dd1c2b59..c4ac2e6c5 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/nested-block/output.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/nested-block/output.yaml @@ -4,11 +4,8 @@ nodes: type: quote nodes: - kind: block - type: quote + type: paragraph nodes: - - kind: block - type: paragraph - nodes: - - kind: text - ranges: - - text: word + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/single-block/index.js b/test/transforms/fixtures/unwrap-block-at-range/single-block/index.js index acb2e8288..02ad25b2d 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/single-block/index.js +++ b/test/transforms/fixtures/unwrap-block-at-range/single-block/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .wrapBlockAtRange(range, 'quote') + .unwrapBlockAtRange(range, 'quote') .apply() } diff --git a/test/transforms/fixtures/unwrap-block-at-range/single-block/input.yaml b/test/transforms/fixtures/unwrap-block-at-range/single-block/input.yaml index b1be31e90..c4ac2e6c5 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/single-block/input.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/single-block/input.yaml @@ -1,8 +1,11 @@ nodes: - kind: block - type: paragraph + type: quote nodes: - - kind: text - ranges: - - text: word + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/single-block/output.yaml b/test/transforms/fixtures/unwrap-block-at-range/single-block/output.yaml index c4ac2e6c5..b1be31e90 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/single-block/output.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/single-block/output.yaml @@ -1,11 +1,8 @@ nodes: - kind: block - type: quote + type: paragraph nodes: - - kind: block - type: paragraph - nodes: - - kind: text - ranges: - - text: word + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/with-data-object/index.js b/test/transforms/fixtures/unwrap-block-at-range/with-data-object/index.js index 42a4d33a6..31a9faac3 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/with-data-object/index.js +++ b/test/transforms/fixtures/unwrap-block-at-range/with-data-object/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .wrapBlockAtRange(range, 'quote', { key: 'value' }) + .unwrapBlockAtRange(range, 'quote', { key: 'value' }) .apply() } diff --git a/test/transforms/fixtures/unwrap-block-at-range/with-data-object/input.yaml b/test/transforms/fixtures/unwrap-block-at-range/with-data-object/input.yaml index b1be31e90..ad222fcde 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/with-data-object/input.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/with-data-object/input.yaml @@ -1,8 +1,13 @@ nodes: - kind: block - type: paragraph + type: quote + data: + key: value nodes: - - kind: text - ranges: - - text: word + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/with-data-object/output.yaml b/test/transforms/fixtures/unwrap-block-at-range/with-data-object/output.yaml index ad222fcde..b1be31e90 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/with-data-object/output.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/with-data-object/output.yaml @@ -1,13 +1,8 @@ nodes: - kind: block - type: quote - data: - key: value + type: paragraph nodes: - - kind: block - type: paragraph - nodes: - - kind: text - ranges: - - text: word + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/with-data/index.js b/test/transforms/fixtures/unwrap-block-at-range/with-data/index.js index 803c87f7b..4aedeed52 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/with-data/index.js +++ b/test/transforms/fixtures/unwrap-block-at-range/with-data/index.js @@ -14,6 +14,6 @@ export default function (state) { return state .transform() - .wrapBlockAtRange(range, 'quote', Data.create({ key: 'value' })) + .unwrapBlockAtRange(range, 'quote', Data.create({ key: 'value' })) .apply() } diff --git a/test/transforms/fixtures/unwrap-block-at-range/with-data/input.yaml b/test/transforms/fixtures/unwrap-block-at-range/with-data/input.yaml index b1be31e90..ad222fcde 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/with-data/input.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/with-data/input.yaml @@ -1,8 +1,13 @@ nodes: - kind: block - type: paragraph + type: quote + data: + key: value nodes: - - kind: text - ranges: - - text: word + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block-at-range/with-data/output.yaml b/test/transforms/fixtures/unwrap-block-at-range/with-data/output.yaml index ad222fcde..b1be31e90 100644 --- a/test/transforms/fixtures/unwrap-block-at-range/with-data/output.yaml +++ b/test/transforms/fixtures/unwrap-block-at-range/with-data/output.yaml @@ -1,13 +1,8 @@ nodes: - kind: block - type: quote - data: - key: value + type: paragraph nodes: - - kind: block - type: paragraph - nodes: - - kind: text - ranges: - - text: word + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/across-blocks/index.js b/test/transforms/fixtures/unwrap-block/across-blocks/index.js new file mode 100644 index 000000000..01ce0e953 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/across-blocks/index.js @@ -0,0 +1,28 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const second = texts.last() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 2, + focusKey: second.key, + focusOffset: 2 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/across-blocks/input.yaml b/test/transforms/fixtures/unwrap-block/across-blocks/input.yaml new file mode 100644 index 000000000..87b381f13 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/across-blocks/input.yaml @@ -0,0 +1,17 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: another diff --git a/test/transforms/fixtures/unwrap-block/across-blocks/output.yaml b/test/transforms/fixtures/unwrap-block/across-blocks/output.yaml new file mode 100644 index 000000000..4960c06f9 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/across-blocks/output.yaml @@ -0,0 +1,14 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: another diff --git a/test/transforms/fixtures/unwrap-block/across-inlines/index.js b/test/transforms/fixtures/unwrap-block/across-inlines/index.js new file mode 100644 index 000000000..01ce0e953 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/across-inlines/index.js @@ -0,0 +1,28 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + const second = texts.last() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 2, + focusKey: second.key, + focusOffset: 2 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/across-inlines/input.yaml b/test/transforms/fixtures/unwrap-block/across-inlines/input.yaml new file mode 100644 index 000000000..f4bfc7303 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/across-inlines/input.yaml @@ -0,0 +1,23 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: inline + type: link + nodes: + - kind: text + ranges: + - text: word + - kind: block + type: paragraph + nodes: + - kind: inline + type: link + nodes: + - kind: text + ranges: + - text: another diff --git a/test/transforms/fixtures/unwrap-block/across-inlines/output.yaml b/test/transforms/fixtures/unwrap-block/across-inlines/output.yaml new file mode 100644 index 000000000..c31f583e3 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/across-inlines/output.yaml @@ -0,0 +1,20 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: inline + type: link + nodes: + - kind: text + ranges: + - text: word + - kind: block + type: paragraph + nodes: + - kind: inline + type: link + nodes: + - kind: text + ranges: + - text: another diff --git a/test/transforms/fixtures/unwrap-block/ending-child-blocks/index.js b/test/transforms/fixtures/unwrap-block/ending-child-blocks/index.js new file mode 100644 index 000000000..93af2976c --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/ending-child-blocks/index.js @@ -0,0 +1,28 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const fifth = texts.get(4) + const sixth = texts.get(5) + const range = selection.merge({ + anchorKey: fifth.key, + anchorOffset: 0, + focusKey: sixth.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/ending-child-blocks/input.yaml b/test/transforms/fixtures/unwrap-block/ending-child-blocks/input.yaml new file mode 100644 index 000000000..1279141e4 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/ending-child-blocks/input.yaml @@ -0,0 +1,41 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: one + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: two + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: three + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: four + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: five + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: six diff --git a/test/transforms/fixtures/unwrap-block/ending-child-blocks/output.yaml b/test/transforms/fixtures/unwrap-block/ending-child-blocks/output.yaml new file mode 100644 index 000000000..395624841 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/ending-child-blocks/output.yaml @@ -0,0 +1,41 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: one + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: two + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: three + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: four + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: five + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: six diff --git a/test/transforms/fixtures/unwrap-block/middle-child-blocks/index.js b/test/transforms/fixtures/unwrap-block/middle-child-blocks/index.js new file mode 100644 index 000000000..60034ea90 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/middle-child-blocks/index.js @@ -0,0 +1,28 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const third = texts.get(2) + const fourth = texts.get(3) + const range = selection.merge({ + anchorKey: third.key, + anchorOffset: 0, + focusKey: fourth.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/middle-child-blocks/input.yaml b/test/transforms/fixtures/unwrap-block/middle-child-blocks/input.yaml new file mode 100644 index 000000000..1279141e4 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/middle-child-blocks/input.yaml @@ -0,0 +1,41 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: one + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: two + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: three + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: four + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: five + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: six diff --git a/test/transforms/fixtures/unwrap-block/middle-child-blocks/output.yaml b/test/transforms/fixtures/unwrap-block/middle-child-blocks/output.yaml new file mode 100644 index 000000000..edf758d4a --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/middle-child-blocks/output.yaml @@ -0,0 +1,44 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: one + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: two + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: three + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: four + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: five + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: six diff --git a/test/transforms/fixtures/unwrap-block/nested-block/index.js b/test/transforms/fixtures/unwrap-block/nested-block/index.js new file mode 100644 index 000000000..774579eaa --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/nested-block/index.js @@ -0,0 +1,27 @@ + +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: 0, + focusKey: first.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/nested-block/input.yaml b/test/transforms/fixtures/unwrap-block/nested-block/input.yaml new file mode 100644 index 000000000..5dd1c2b59 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/nested-block/input.yaml @@ -0,0 +1,14 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/nested-block/output.yaml b/test/transforms/fixtures/unwrap-block/nested-block/output.yaml new file mode 100644 index 000000000..c4ac2e6c5 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/nested-block/output.yaml @@ -0,0 +1,11 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/single-block/index.js b/test/transforms/fixtures/unwrap-block/single-block/index.js new file mode 100644 index 000000000..774579eaa --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/single-block/index.js @@ -0,0 +1,27 @@ + +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: 0, + focusKey: first.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/single-block/input.yaml b/test/transforms/fixtures/unwrap-block/single-block/input.yaml new file mode 100644 index 000000000..c4ac2e6c5 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/single-block/input.yaml @@ -0,0 +1,11 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/single-block/output.yaml b/test/transforms/fixtures/unwrap-block/single-block/output.yaml new file mode 100644 index 000000000..b1be31e90 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/single-block/output.yaml @@ -0,0 +1,8 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/starting-child-blocks/index.js b/test/transforms/fixtures/unwrap-block/starting-child-blocks/index.js new file mode 100644 index 000000000..436d8fa4c --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/starting-child-blocks/index.js @@ -0,0 +1,28 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.get(0) + const second = texts.get(1) + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: second.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote') + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/starting-child-blocks/input.yaml b/test/transforms/fixtures/unwrap-block/starting-child-blocks/input.yaml new file mode 100644 index 000000000..1279141e4 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/starting-child-blocks/input.yaml @@ -0,0 +1,41 @@ + +nodes: + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: one + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: two + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: three + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: four + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: five + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: six diff --git a/test/transforms/fixtures/unwrap-block/starting-child-blocks/output.yaml b/test/transforms/fixtures/unwrap-block/starting-child-blocks/output.yaml new file mode 100644 index 000000000..580c42ce3 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/starting-child-blocks/output.yaml @@ -0,0 +1,41 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: one + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: two + - kind: block + type: quote + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: three + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: four + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: five + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: six diff --git a/test/transforms/fixtures/unwrap-block/with-data-object/index.js b/test/transforms/fixtures/unwrap-block/with-data-object/index.js new file mode 100644 index 000000000..5911ed141 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/with-data-object/index.js @@ -0,0 +1,27 @@ + +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: 0, + focusKey: first.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote', { key: 'value' }) + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/with-data-object/input.yaml b/test/transforms/fixtures/unwrap-block/with-data-object/input.yaml new file mode 100644 index 000000000..ad222fcde --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/with-data-object/input.yaml @@ -0,0 +1,13 @@ + +nodes: + - kind: block + type: quote + data: + key: value + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/with-data-object/output.yaml b/test/transforms/fixtures/unwrap-block/with-data-object/output.yaml new file mode 100644 index 000000000..b1be31e90 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/with-data-object/output.yaml @@ -0,0 +1,8 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/with-data/index.js b/test/transforms/fixtures/unwrap-block/with-data/index.js new file mode 100644 index 000000000..be0299735 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/with-data/index.js @@ -0,0 +1,28 @@ + +import { Data } from '../../../../..' +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: 0, + focusKey: first.key, + focusOffset: 0 + }) + + const next = state + .transform() + .moveTo(range) + .unwrapBlock('quote', Data.create({ key: 'value' })) + .apply() + + assert.deepEqual( + next.selection.toJS(), + range.toJS() + ) + + return next +} diff --git a/test/transforms/fixtures/unwrap-block/with-data/input.yaml b/test/transforms/fixtures/unwrap-block/with-data/input.yaml new file mode 100644 index 000000000..ad222fcde --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/with-data/input.yaml @@ -0,0 +1,13 @@ + +nodes: + - kind: block + type: quote + data: + key: value + nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/unwrap-block/with-data/output.yaml b/test/transforms/fixtures/unwrap-block/with-data/output.yaml new file mode 100644 index 000000000..b1be31e90 --- /dev/null +++ b/test/transforms/fixtures/unwrap-block/with-data/output.yaml @@ -0,0 +1,8 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word