worktile / worktile/slate-angular

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

Open
#215 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
188
Forks
30
Avg merge
3d 13h
Merged PRs (30d)
4

Description

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)
        }
    }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TypeScript errors in the isBlockActive and toggleBlock methods, focusing on the Editor.nodes, Transforms.unwrapNodes, and Transforms.setNodes calls shown in the report. Determine how the element type is represented in this project and confirm the affected Slate typings; done means the reported errors are resolved without breaking block toggling.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.