mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 12:30:11 +02:00
26 lines
496 B
JavaScript
26 lines
496 B
JavaScript
|
|
import assert from 'assert'
|
|
|
|
export default function (state) {
|
|
const { document, selection } = state
|
|
const texts = document.getTexts()
|
|
const second = texts.get(1)
|
|
const fifth = texts.get(4)
|
|
const range = selection.merge({
|
|
anchorKey: second.key,
|
|
anchorOffset: 2,
|
|
focusKey: fifth.key,
|
|
focusOffset: 2
|
|
})
|
|
|
|
const next = state
|
|
.transform()
|
|
.moveTo(range)
|
|
.addMark('bold')
|
|
.apply()
|
|
|
|
assert.deepEqual(next.selection.toJS(), range.toJS())
|
|
|
|
return next
|
|
}
|