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

Manipulate block after connecting with collaboration service #632

Closed
zrg-team opened this issue Mar 10, 2024 · 2 comments
Closed

Manipulate block after connecting with collaboration service #632

zrg-team opened this issue Mar 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@zrg-team
Copy link

Describe the bug

I can not manipulate block structure after connecting with collaboration services

  • replaceBlocks
  • removeBlocks

To Reproduce

connect to collaboration provider

const editor = useBlockNote(
    {
      defaultStyles: false,
      slashMenuItems: specificationPageMenuItems,
      collaboration: {
        // The Yjs Provider responsible for transporting updates:
        provider,
        // Where to store BlockNote data in the Y.Doc:
        fragment: getXmlFragment(),
        // Information (name and color) for this user:
        user
      }
    }, []
  )

After replace with Db blocks

useEffect(() => {
   if (editor && !isReady && (currentBlockPageContentForSpecification?.length > 0 || blockPageForSpecification?.[blockPageId]?.children?.length === 0)) {
      console.log('look like it ready')
      setTimeout(() => {
        const deleteIds = editor.topLevelBlocks.map((block) => block.id)
        editor.removeBlocks(deleteIds)
        editor.replaceBlocks(
           editor.topLevelBlocks.,
           [...currentBlockPageContentForSpecification],
           true
        )
        console.log('manually update to socket')
        setIsReady(true)
      }, 2000)
    }
  }, [isReady, editor, currentBlockPageContentForSpecification, blockPageForSpecification?.[blockPageId]])

Misc

  • Node version: 20
  • Package manager: yarn
  • Browser: Edge MacOS
@zrg-team zrg-team added the bug Something isn't working label Mar 10, 2024
@zrg-team
Copy link
Author

I found that if only block
['initialBlockId'] then all maninuplate block will not wor

@YousefED
Copy link
Collaborator

Hi @zrg-team, could you try upgrading to 0.12? If the issue still occurs, I'll reopen the issue. it's easiest for us to fix it if you can provide a codesandbox / stackblitz as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants