Skip to content

Error on readonly editor - TypeError: Cannot read properties of undefined (reading 'FormattingToolbar') #889

Closed

Description

@softmarshmallow

I am building a CMS with BlockNote, need a way to render blocknote document,
Did some research, but did not found a reliable way to generateHtml from blocknote document.

Where I ended up using BlockNote component to display the content for now, below.

"use client";

import {
  BlockNoteViewProps,
  useCreateBlockNote,
  BlockNoteViewRaw,
} from "@blocknote/react";

export function RichText({
  children,
  value,
  ...props
}: React.PropsWithChildren<
  Omit<BlockNoteViewProps<any, any, any>, "editable" | "editor"> & {
    value: any;
  }
>) {
  const editor = useCreateBlockNote({
    initialContent: value,
    defaultStyles: false,
  });

  return (
    <BlockNoteViewRaw
      data-theming-ui-css-variables
      editor={editor}
      editable={false}
      {...props}
    />
  );
}

Even with the editable=false, seems like the block note is trying to draw some toolbars & stuff. raising below

TypeError: Cannot read properties of undefined (reading 'FormattingToolbar')

This happens when I drag the text content, but wierdly only occurs from second entry (second text selection)

Using the mantine works, but is this supposed to be like this? (looking for a headless & lightest way possible to render blocknote contents, without styles)

"use client";

import {
  BlockNoteViewProps,
  useCreateBlockNote,
  BlockNoteViewRaw,
} from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";

export function RichText({
  children,
  value,
  ...props
}: React.PropsWithChildren<
  Omit<BlockNoteViewProps<any, any, any>, "editable" | "editor"> & {
    value: any;
  }
>) {
  const editor = useCreateBlockNote({
    initialContent: value,
    defaultStyles: false,
  });

  return (
    <BlockNoteView
      data-theming-ui-css-variables
      editor={editor}
      editable={false}
      {...props}
    />
  );
}

Activity

  1. YousefED commented on Jul 1, 2024

    @YousefED
    Collaborator

    I think you're interested in #451

    But you also raise a good point, we could disable all UI extensions and react components when editable=false. wdyt @matthewlipski ?

  2. matthewlipski commented on Jul 2, 2024

    @matthewlipski
    Collaborator

    Makes sense imo, I think the non-editable state of the editor is not super robust right now and could use some work. Think it's worth spending a week or 2 at some point to iron out all the edge cases and cut out what isn't needed when the editor is non-editable.

  3. added
    needs-triage
    on Feb 5, 2026
  4. added
    bug:P2
    and removed
    needs-triage
    on Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions