refactoring
This commit is contained in:
@@ -83,27 +83,24 @@ export class AnnotationState {
|
|||||||
const { doc, type, binding } = ystate
|
const { doc, type, binding } = ystate
|
||||||
const decorations: Decoration[] = []
|
const decorations: Decoration[] = []
|
||||||
|
|
||||||
Array
|
map.forEach((annotation, id) => {
|
||||||
.from(map.keys())
|
const from = relativePositionToAbsolutePosition(doc, type, annotation.from, binding.mapping)
|
||||||
.forEach(id => {
|
const to = relativePositionToAbsolutePosition(doc, type, annotation.to, binding.mapping)
|
||||||
const annotation = map.get(id)
|
|
||||||
const from = relativePositionToAbsolutePosition(doc, type, annotation.from, binding.mapping)
|
|
||||||
const to = relativePositionToAbsolutePosition(doc, type, annotation.to, binding.mapping)
|
|
||||||
|
|
||||||
if (!from || !to) {
|
if (!from || !to) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[${this.options.instance}] Decoration.inline()`, from, to, HTMLAttributes, { id, data: annotation.data })
|
console.log(`[${this.options.instance}] Decoration.inline()`, from, to, HTMLAttributes, { id, data: annotation.data })
|
||||||
|
|
||||||
if (from === to) {
|
if (from === to) {
|
||||||
console.warn(`[${this.options.instance}] corrupt decoration `, annotation.from, from, annotation.to, to)
|
console.warn(`[${this.options.instance}] corrupt decoration `, annotation.from, from, annotation.to, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
decorations.push(
|
decorations.push(
|
||||||
Decoration.inline(from, to, HTMLAttributes, { id, data: annotation.data, inclusiveEnd: true }),
|
Decoration.inline(from, to, HTMLAttributes, { id, data: annotation.data, inclusiveEnd: true }),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.decorations = DecorationSet.create(state.doc, decorations)
|
this.decorations = DecorationSet.create(state.doc, decorations)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user