Skip to content

A RangeError: No value supplied for attribute previewWidth has occurred #2170

@MyungJiwoo

Description

@MyungJiwoo

When using the /image command in the default editor setup following the documentation, the image is not added, and the console displays the following error.

This issue occurs in both v0.41.1, v0.42.0.

Image

According to the documentation, previewWidth: number = 512; is specified, but in the actual code, it was declared as undefined.

In the current version, applying the following temporary fix allowed the editor to work without any errors.

import {
  BlockNoteSchema,
  defaultBlockSpecs,
  createCodeBlockSpec,
} from "@blocknote/core";

const createSchema = () => {
  const blockSpecs = {
    ...defaultBlockSpecs,

    image: {
      ...defaultBlockSpecs.image,
      config: {
        ...defaultBlockSpecs.image.config,
        propSchema: {
          ...defaultBlockSpecs.image.config.propSchema,
          previewWidth: {
            ...defaultBlockSpecs.image.config.propSchema.previewWidth,
            default: 512 as const,
          },
        },
      },
    },

    codeBlock: createCodeBlockSpec({}),
  };

  return BlockNoteSchema.create({ blockSpecs });
};
const editor = useCreateBlockNote({ schema: createSchema() });

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions