mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 18:09:49 +02:00
add more mark tests
This commit is contained in:
22
test/transforms/fixtures/add-mark/with-mark-object/index.js
Normal file
22
test/transforms/fixtures/add-mark/with-mark-object/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
import { Mark } from '../../../../..'
|
||||
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
|
||||
return state
|
||||
.transform()
|
||||
.moveTo({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusOffset: 1
|
||||
})
|
||||
.addMark(Mark.create({
|
||||
type: 'bold',
|
||||
data: { key: 'value' }
|
||||
}))
|
||||
.apply()
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
@@ -0,0 +1,13 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: w
|
||||
marks:
|
||||
- type: bold
|
||||
data:
|
||||
key: value
|
||||
- text: ord
|
20
test/transforms/fixtures/add-mark/with-plain-object/index.js
Normal file
20
test/transforms/fixtures/add-mark/with-plain-object/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
|
||||
return state
|
||||
.transform()
|
||||
.moveTo({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusOffset: 1
|
||||
})
|
||||
.addMark({
|
||||
type: 'bold',
|
||||
data: { key: 'value' }
|
||||
})
|
||||
.apply()
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
@@ -0,0 +1,13 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: w
|
||||
marks:
|
||||
- type: bold
|
||||
data:
|
||||
key: value
|
||||
- text: ord
|
Reference in New Issue
Block a user