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

Custom Block - Blockqute #1337

Open
1 task
jeroenalfes opened this issue Dec 19, 2024 · 0 comments
Open
1 task

Custom Block - Blockqute #1337

jeroenalfes opened this issue Dec 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jeroenalfes
Copy link

jeroenalfes commented Dec 19, 2024

Describe the bug
I have created a custom block called blockquote. It is working in preview. But everytime when i reload the page. The

is replaces with

and the class is deleted as well. When i load the HTML Content i am using the function "tryParseHTMLToBlocks" to convert everything from HTML to blocks and then "replaceBlocks". I think this is my main issue, but i have no idea how can i fix this.

To Reproduce

import { createReactBlockSpec } from "@blocknote/react";

import "./styles.css"

export const Blockquote = createReactBlockSpec(
  {
    type: "blockquote",
    propSchema: {
    },
    content: "inline",
  },
  {
    render: (props) => {
      return (
        <blockquote className={"bn-block"} data-text-color="red" ref={props.contentRef} >
        </blockquote>
      );
    },
  }
);

const schema = BlockNoteSchema.create({
    blockSpecs: {
      // Adds all default blocks.
      ...defaultBlockSpecs,
      // Adds the Alert block.
      blockquote: Alert
    },
  });
  const editor = useCreateBlockNote({
    schema: schema,
    uploadFile,
    trailingBlock: false,

  });
        const blocks = await editor.tryParseHTMLToBlocks(content.data.teaser);
        editor.replaceBlocks(editor.document, blocks);

         <BlockNoteView editor={editor} theme={"light"}  formattingToolbar={false}  onChange={() => {
          save(editor.document);
        }}>
            <FormattingToolbarController
        formattingToolbar={() => (
          <FormattingToolbar
            blockTypeSelectItems={[
              ...blockTypeSelectItems(editor.dictionary),
              {
                name: "Blockquote",
                type: "blockquote",
                icon: RiAlertFill,
                isSelected: (block:any) => block.type === "blockquote",
              } satisfies BlockTypeSelectItem,
            ]}
          />
        )}
      />
          </BlockNoteView>

I am not sure, but a blockquote is actually a standard in most common editors, but i couldnt find this custom block.

Thank you so much in advance.

Misc

  • Browser: Chrome
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖
@jeroenalfes jeroenalfes added the bug Something isn't working label Dec 19, 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
Projects
None yet
Development

No branches or pull requests

1 participant