This evening, I started playing with the Linting Example. The example makes sense to me; however, I’m making a mistake I don’t see. When I generate the inline decorations I create the first one, but the others are null.
What might cause a null result from a call to Decoration.inline(from, to, attrs)
?
TypeScript Snippet
function parseDocument(doc: ProsemirrorNode) {
let decorations: Decoration[] = []
doc.descendants((node: ProsemirrorNode, pos: number) => {
if (node.isText && node.text) {
parse(node.text, mockServices).tokens.forEach((t: Token) => {
decorations.push(
Decoration.inline(
t.start,
t.start + t.text.length - 1,
{ class: t.uiMark }
)
)
})
}
})
return DecorationSet.create(doc, decorations)
}
Example of the Tokens I Parse:
[
{
"itemKind": "text",
"start": 0,
"text": "if ",
"uiMark": "text"
},
{
"itemKind": "user",
"start": 3,
"text": "@paula",
"uiMark": "user",
"data": {
"id": 1980
}
},
{
"itemKind": "text",
"start": 9,
"text": " is ",
"uiMark": "text"
},
{
"itemKind": "hash",
"start": 13,
"text": "#hashtag",
"uiMark": "hashInvalid",
"data": {
"id": -1
}
},
{
"itemKind": "text",
"start": 21,
"text": " cool",
"uiMark": "text"
}
]
Thanks for your time and help.