Skip to content

Fix build issue on custom-blocks-api-changes #192

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"eslint-config-react-app": "^7.0.0",
"jsdom": "^21.1.0",
"prettier": "^2.7.1",
"typescript": "^4.5.4",
"typescript": "^5.0.4",
"vite": "^4.1.2",
"vite-plugin-eslint": "^1.8.1",
"vitest": "^0.28.5"
Expand All @@ -110,4 +110,4 @@
"registry": "https://registry.npmjs.org/"
},
"gitHead": "37614ab348dcc7faa830a9a88437b37197a2162d"
}
}
7 changes: 3 additions & 4 deletions packages/core/src/api/nodeConversions/nodeConversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,13 @@ export function nodeToBlock<BSchema extends BlockSchema>(
);
}

// TODO: fix types
const block: any = {
const block = {
id,
type: blockInfo.contentType.name as Block<BSchema>["type"],
type: blockInfo.contentType.name,
props,
content,
children,
};
} satisfies Block<BSchema>;

blockCache?.set(node, block);

Expand Down
14 changes: 9 additions & 5 deletions packages/core/src/extensions/Blocks/api/blockTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Define the main block types **/
import { Node, NodeConfig } from "@tiptap/core";
import { InlineContent, PartialInlineContent } from "./inlineContentTypes";
import { BlockNoteEditor } from "../../../BlockNoteEditor";
import { InlineContent, PartialInlineContent } from "./inlineContentTypes";

// A configuration for a TipTap node, but with stricter type constraints on the
// "name" and "group" properties. The "name" property is now always a string
Expand Down Expand Up @@ -75,10 +75,14 @@ export type BlockConfig<
render: (
block: () => Block<BSchema>,
editor: BlockNoteEditor<BSchema>
) => {
dom: HTMLElement;
contentDOM: ContainsInlineContent extends true ? HTMLElement : undefined;
};
) => ContainsInlineContent extends true
? {
dom: HTMLElement;
contentDOM: HTMLElement;
}
: {
dom: HTMLElement;
};
};

// Defines a single block spec, which includes the props that the block has and
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/extensions/Blocks/api/defaultBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BulletListItemBlockContent } from "../nodes/BlockContent/ListItemBlockC
import { NumberedListItemBlockContent } from "../nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent";
import { ParagraphBlockContent } from "../nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent";
import { createBlockSpec } from "./block";
import { TypesMatch } from "./blockTypes";
import { BlockSchema, PropSchema, TypesMatch } from "./blockTypes";

export const defaultProps = {
backgroundColor: {
Expand All @@ -16,7 +16,7 @@ export const defaultProps = {
default: "left" as const,
values: ["left", "center", "right", "justify"] as const,
},
} as const; // TODO: upgrade typescript and use satisfies PropSpec
} as const satisfies PropSchema;

export const defaultBlockSchema = {
paragraph: {
Expand All @@ -38,7 +38,7 @@ export const defaultBlockSchema = {
propSchema: defaultProps,
node: NumberedListItemBlockContent,
},
} as const;
} as const satisfies BlockSchema;

const imageProps = { src: { default: "gfr" } } as const;
export const onlyImageBlockSchema = {
Expand All @@ -52,7 +52,7 @@ export const onlyImageBlockSchema = {
return { dom: img };
},
}),
} as const;
} as const satisfies BlockSchema;

export type DefaultBlockSchema = TypesMatch<typeof defaultBlockSchema>;

Expand Down