mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-09 06:30:40 +02:00
add tests for calling wrapInline twice (#197)
This commit is contained in:
committed by
Ian Storm Taylor
parent
21a002ad63
commit
84829f5439
23
test/transforms/fixtures/wrap-inline/twice/index.js
Normal file
23
test/transforms/fixtures/wrap-inline/twice/index.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
|
export default function (state) {
|
||||||
|
const { document, selection } = state
|
||||||
|
const texts = document.getTexts()
|
||||||
|
const text = texts.first()
|
||||||
|
const range = selection.merge({
|
||||||
|
anchorKey: text.key,
|
||||||
|
anchorOffset: 7,
|
||||||
|
focusKey: text.key,
|
||||||
|
focusOffset: 11
|
||||||
|
})
|
||||||
|
|
||||||
|
const next = state
|
||||||
|
.transform()
|
||||||
|
.moveTo(range)
|
||||||
|
.wrapInline('inner')
|
||||||
|
.wrapInline('outer')
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
return next
|
||||||
|
}
|
7
test/transforms/fixtures/wrap-inline/twice/input.yaml
Normal file
7
test/transforms/fixtures/wrap-inline/twice/input.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
text: before word after
|
16
test/transforms/fixtures/wrap-inline/twice/output.yaml
Normal file
16
test/transforms/fixtures/wrap-inline/twice/output.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
text: "before "
|
||||||
|
- kind: inline
|
||||||
|
type: outer
|
||||||
|
nodes:
|
||||||
|
- kind: inline
|
||||||
|
type: inner
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
text: word
|
||||||
|
- kind: text
|
||||||
|
text: " after"
|
Reference in New Issue
Block a user