How can i check whether a decoration object is of type widget or inline. I filter a decoration from set as
const filteredDecos = this.decorationSet.find().filter((decoration: any) => {
const { spec: annotationSpec } = decoration
return annotationSpec.annotationId === annotationId
})
For inline, a decoration that is pushed into decoration set is created as
const newDeco = Decoration.inline(
from,
to,
{
class: classNames.join(' '),
},
{
annotationId: annotationId,
}
)
And for a decoration created using widget static method :
Decoration.widget(
startPos,
(view, getPos) =>
this.renderWidget(
view,
getPos,
classNames,
annotationId,
),
{
key: annotationId,
ignoreSelection: true,
annotationId,
},
)
From the array of filteredDecos
, I need need to determine if a decoration is created using inline or widget static methods. I checked the object in console, say filteredDecos[0] which is has a key type of WidgetType. Accessing filteredDecos[0].type, gives error that ‘type’ property doesnot exist on Decoration. I have filteredDecos[0].inline as false in browser console, but when coding this condition, I get typescript error:
Property 'inline' does not exist on type 'Decoration'. Did you mean to access the static member 'Decoration.inline' instead?ts(2576)