Skip to content

Conversation

@matthewlipski
Copy link
Collaborator

No description provided.

@vercel
Copy link

vercel bot commented May 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocknote-website ❌ Failed (Inspect) May 11, 2023 6:28pm

@matthewlipski matthewlipski changed the base branch from custom-elements-api-fix to custom-blocks-proposal May 1, 2023 13:43
Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

  • I think the way schemas (props / blocks) now work is a good improvement
  • I'm not 100% convinced about the NumberedListItemBlockContent, TipTapNodeConfig, TypesMatch. It feels like this is quite some code (complexity) for a small (maybe I'm wrong here) gain in type-correctness. I think for these scenarios it's find to do a quick runtime check

Overall, great work. I've left some minor comments. I'll review the parse / renderhtml etc. when the first custom block tests have been added

console.log("test");
// apply defaults
options = {
const newOptions: Omit<typeof options, "defaultStyles" | "blockSchema"> & {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why first the omit and then the addition with &?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because options is Partial, so defaultStyles and blockSchema might be undefined. Since we're applying defaults to them this changes those 2 fields to always be defined.

const propSchema = blockSpec.propSchema;

if (validAttrs.find((prop) => prop.name === attr)) {
if (attr in propSchema) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice improvement now that we don't use an array anymore :)

: string;
};

// Defines the config for a single block. Meant to be used as an argument to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice docs!

},
} as const;

const imageProps = { src: { default: "gfr" } } as const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO, move to test

// Gets BlockNote editor instance
const editor = this.options.editor!;
// Gets position of the node
const pos = typeof getPos === "function" ? getPos() : undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw error if pos is undefined, so you don't need pos! below


// Render elements
const rendered = blockConfig.render(props);
const rendered = blockConfig.render(getDummyBlock, editor);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss this

@YousefED
Copy link
Collaborator

superseded by #191

@YousefED YousefED closed this May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants