Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠ TS Errors need to be fixed on null of editor for lastest version of Novel #382

Open
lumpinif opened this issue Apr 24, 2024 · 2 comments

Comments

@lumpinif
Copy link

lumpinif commented Apr 24, 2024

In the ai-selector.tsx and generative-menu-switch.tsx, the const { editor } = useEditor() object destructuring returns const editor: Editor | null in the new version of tiptap/core + /react + /pm @2.2.4 which was included in the latest version of novel.

image

The null of editor can lead to ⚠ TS Errors on null.

image image image

Screenshots from novel repo clone demo:

image image

We can see the useEditor() returns just editor from tiptap/core + /react + /pm @2.2.2

Another⚠ TS Error in the advanced-editor.tsx from line 95.
It means that we are trying to call a function on an object that might not exist at runtime. It seems like EditorCommandItem might be undefined.

image

This issue is also coming from the latest version of novel.

@lumpinif lumpinif changed the title ⚠ TS Errors on null of editor for lastest version of Novel ⚠ TS Errors need to be fixed on null of editor for lastest version of Novel Apr 24, 2024
@akdeb
Copy link

akdeb commented Apr 25, 2024

I've added a null check to resolve a lot of these


    if (!editor) return null;

And something like:

        {
            name: "bold",
            isActive: (editor) => editor!.isActive("bold"),
            command: (editor) => editor!.chain().focus().toggleBold().run(),
            icon: BoldIcon,
        },
        {
            name: "italic",
            isActive: (editor) => editor!.isActive("italic"),
            command: (editor) => editor!.chain().focus().toggleItalic().run(),
            icon: ItalicIcon,
        },

in text-buttons.tsx

@lumpinif
Copy link
Author

@akdeb I also had to add a bunch of null checks to address the ts errors. However, the wired thing is useEditor() from original package doesn't return null but only Editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants