Skip to content

Property 'type' does not exist on type 'BaseEditor | BaseElement'. #215

@milan-encodedots

Description

@milan-encodedots

Hi There

I am getting issues while loading block content. below is my code.

I have added the error I am getting in the code block beside the line I am getting error in.


isBlockActive = (format) => {
        const [match] = Editor.nodes(this.editor, {
            match: (n: Node) => !Editor.isEditor(n) && Element.isElement(n) && n.type === format, //Property 'type' does not exist on type 'BaseElement'.
        })

        return !!match
}
toggleBlock = (format) => {
        const isActive = this.isBlockActive(format)
        const isList = LIST_TYPES.includes(format)

        Transforms.unwrapNodes(this.editor, {
            match: n =>
                LIST_TYPES.includes(Element.isElement(n) && n.type), //  Property 'type' does not exist on type 'BaseEditor | BaseElement'.
            split: true,
        })
        const newProperties: Partial<Element> = {
            type: isActive ? 'paragraph' : isList ? 'list-item' : format, //Type '{ type: any; }' is not assignable to type 'Partial<BaseElement>'
        }
        Transforms.setNodes(this.editor, newProperties)

        if (!isActive && isList) {
            const block = {type: format, children: []}
            Transforms.wrapNodes(this.editor, block)
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions