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

The program crashes when the cursor hovers over a custom block. #863

Open
bigfly0416 opened this issue Jun 25, 2024 · 4 comments
Open

The program crashes when the cursor hovers over a custom block. #863

bigfly0416 opened this issue Jun 25, 2024 · 4 comments
Assignees
Labels
bug Something isn't working prio:high High priority

Comments

@bigfly0416
Copy link

In simple terms, I created a custom Mermaid block, but the program crashes when the mouse cursor passes over its middle section. In the console, I receive the following error message:

SideMenuPlugin.ts:568 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at bn.update (SideMenuPlugin.ts:568:43)
    at EditorView.updatePluginViews (index.js:5407:32)
    at EditorView.updateStateInner (index.js:5354:14)
    at EditorView.updateState (index.js:5282:14)
    at Wn.dispatchTransaction (Editor.ts:368:15)
    at EditorView.dispatch (index.js:5637:33)
    at updateSelection (index.js:3145:10)
    at selectClickedLeaf (index.js:3152:9)
    at handleSingleClick (index.js:3186:57)
    at MouseDown.up (index.js:3327:18)

9a99e24ef750a0b8abbb74b25f499365

I expect the runtime effect to be as shown in the following image:
5947c6640d3d175f02b8b9a8e4f985c0

** To Reproduce **
here is demo

  1. Following the tutorial, created a custom Mermaid block.
  2. Add custom block schema to editor
  3. Start programe open in the broswer
  4. Resize broswer to 1024*768
  5. Add the custom mermaid block in the editor
  6. Use the cursor moves over the block, from top to bottom
  7. Finally can get the error info

Unfortunately, as a backend programmer, I'm unable to provide more detailed information about the issue. However, I speculate that the issue might stem from modifications to the DOM elements during the Mermaid rendering process, which could be causing problems with the mouse event triggers. i do not sure...

Misc

  • Node version: v20.12.1
  • Package manager:
    npm: v20.12.1
  • Browser:
    edge
    chrome
    safari
@bigfly0416 bigfly0416 added the bug Something isn't working label Jun 25, 2024
@Munna5553
Copy link

import { BlockNoteEditor, PartialBlock } from "@blocknote/core";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine"
import "@blocknote/mantine/style.css";

interface editorProps {
initialContent?: string;
editable?: boolean;
}

const TextEditor: React.FC = ({ initialContent, editable }) => {

const editor = useCreateBlockNote({
    initialContent: initialContent ? (JSON.parse(initialContent) as PartialBlock[]) : undefined,
}) as BlockNoteEditor;

return (
    <BlockNoteView
        onChange={() => { console.log(JSON.stringify(editor.domElement.innerHTML)) }}
        editor={editor}
        editable={editable}
        theme={"light"}
    />
)

}

export default TextEditor;

use this code i work now, but still one issue is that.
if you are call/use this component how to get the value from this

@bigfly0416
Copy link
Author

import { BlockNoteEditor, PartialBlock } from "@blocknote/core"; import { useCreateBlockNote } from "@blocknote/react"; import { BlockNoteView } from "@blocknote/mantine" import "@blocknote/mantine/style.css";

interface editorProps { initialContent?: string; editable?: boolean; }

const TextEditor: React.FC = ({ initialContent, editable }) => {

const editor = useCreateBlockNote({
    initialContent: initialContent ? (JSON.parse(initialContent) as PartialBlock[]) : undefined,
}) as BlockNoteEditor;

return (
    <BlockNoteView
        onChange={() => { console.log(JSON.stringify(editor.domElement.innerHTML)) }}
        editor={editor}
        editable={editable}
        theme={"light"}
    />
)

}

export default TextEditor;

use this code i work now, but still one issue is that. if you are call/use this component how to get the value from this

sorry, perhaps the question you answered is unrelated to this issue.

@bigfly0416
Copy link
Author

I get some more info:
I found a repo blocknote-mermaid has the same issue, look the follow video

Kapture.2024-06-26.at.16.16.02.mp4

It looks like an exception happens when trying to get the block information as the cursor goes over it, leading to the block variable being undefined.

886ad18ddd0e5703febc3be820a3beea

@mfanselmo
Copy link

Hey! Subscribing into this issue. I am having the same problem with a custom block. Tomorrow I will investigate more and see if I can give more information

@matthewlipski matthewlipski added prio:high High priority and removed prio:mid Medium priority labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prio:high High priority
Projects
None yet
Development

No branches or pull requests

4 participants