1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 04:20:26 +02:00

speed up decorator examples

This commit is contained in:
Ian Storm Taylor
2017-04-06 11:21:41 -07:00
parent d24dffc390
commit 50593f9335
2 changed files with 4 additions and 3 deletions

View File

@@ -70,12 +70,13 @@ function codeBlockDecorator(text, block) {
const length = offset + token.content.length
const type = `highlight-${token.type}`
const mark = Mark.create({ type })
for (let i = offset; i < length; i++) {
let char = characters.get(i)
let { marks } = char
marks = marks.add(Mark.create({ type }))
char = char.merge({ marks })
marks = marks.add(mark)
char = char.set('marks', marks)
characters.set(i, char)
}

View File

@@ -41,7 +41,7 @@ function addMarks(characters, tokens, offset) {
let char = characters.get(i)
let { marks } = char
marks = marks.add(mark)
char = char.merge({ marks })
char = char.set('marks', marks)
characters.set(i, char)
}