Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
acc7114
zod refactor
YousefED Oct 13, 2025
6847a09
add zod to examples
YousefED Oct 13, 2025
bd154ed
refactor types and partial / full
YousefED Oct 16, 2025
30c5581
remove unneeded code
YousefED Oct 16, 2025
f2d191e
fix !
YousefED Oct 16, 2025
75bd4e5
fix build
YousefED Oct 16, 2025
5eb10ec
remove SpecificBlock
YousefED Oct 16, 2025
b99822a
fix build
YousefED Oct 16, 2025
53bd6d7
fix core tests
YousefED Oct 16, 2025
750a942
refactor: move all instances of `BlockNoteSchema` to `CustomBlockNote…
nperez0111 Oct 16, 2025
a5099b3
chore: kludges to get the build working
nperez0111 Oct 16, 2025
f9842b6
Merge branch 'main' into refactor/zod-props-v2
nperez0111 Oct 16, 2025
c3bb8d0
chore: update lockfile
nperez0111 Oct 16, 2025
3e0148b
chore: fix the lint
nperez0111 Oct 16, 2025
f2559f4
chore: bump zod to same version
nperez0111 Oct 16, 2025
e905344
chore: get the tests to pass by parsing an empty object
nperez0111 Oct 16, 2025
e79e0fe
refactor: use type defs to declare defaultBlocks properties for perf …
nperez0111 Oct 17, 2025
984a21b
copy in tests from matthew
YousefED Oct 17, 2025
cba8abb
createPropSchemaFromZod
YousefED Oct 29, 2025
c37934c
fix
YousefED Oct 29, 2025
0920bf9
address feedback
YousefED Oct 29, 2025
56f4245
Merge branch 'refactor/zod-props-v2' into refactor/remove-partials
YousefED Oct 29, 2025
d15becc
merge and build
YousefED Oct 29, 2025
b028a1b
fix build
YousefED Oct 29, 2025
6ffa70e
fix build
YousefED Oct 29, 2025
553932b
empty spans added
YousefED Oct 29, 2025
cbda9e7
fix odt test
YousefED Oct 29, 2025
0dcd4f8
fix tests
YousefED Oct 29, 2025
b8383f7
update snap
YousefED Oct 29, 2025
2cfa627
fix tests
YousefED Oct 29, 2025
282a966
fix "as never"
YousefED Oct 29, 2025
bbe2299
small fixes
YousefED Oct 29, 2025
7b44f98
fix build
YousefED Oct 29, 2025
fab647f
Merge pull request #2111 from TypeCellOS/refactor/remove-partials
YousefED Oct 29, 2025
7a53cca
Merge remote-tracking branch 'origin/main' into refactor/zod-props-v2
YousefED Oct 30, 2025
60871a6
fix merge
YousefED Oct 30, 2025
5a685a1
Merge remote-tracking branch 'origin/main' into refactor/zod-props-v2
YousefED Oct 30, 2025
34bbf49
implement tests + first example
YousefED Oct 30, 2025
39e428a
clean
YousefED Nov 3, 2025
95c99df
test: add test cases for complex attributes
nperez0111 Nov 3, 2025
e3d9917
chore: disable
nperez0111 Nov 3, 2025
bd0c5eb
fix type guards
YousefED Nov 12, 2025
94f2317
Merge remote-tracking branch 'origin/main' into refactor/zod-props-v2
YousefED Nov 12, 2025
57602da
Merge remote-tracking branch 'origin/zod-tests' into refactor/zod-pro…
YousefED Nov 12, 2025
724c3d1
Merge remote-tracking branch 'origin/main' into refactor/zod-props-v2
YousefED Nov 12, 2025
7727893
mark test todos
YousefED Nov 12, 2025
8d5139a
mark todos
YousefED Nov 12, 2025
a2a5a5a
test: better testing of custom-paragraph using a custom tag name
nperez0111 Nov 12, 2025
be41682
test: add react tests for complex attributes
nperez0111 Nov 12, 2025
334b5c9
fix build
YousefED Nov 13, 2025
6bfbfa9
fix slash menu and blocktypeselect
YousefED Nov 13, 2025
c35fdb3
fix
YousefED Nov 14, 2025
f27297d
fix
YousefED Nov 14, 2025
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
Prev Previous commit
Next Next commit
refactor: move all instances of BlockNoteSchema to `CustomBlockNote…
…Schema`
  • Loading branch information
nperez0111 committed Oct 16, 2025
commit 750a942d8548d35c39da89e43fc3b214976fabd3
10 changes: 3 additions & 7 deletions packages/core/src/api/pmUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Node, Schema } from "prosemirror-model";
import { Transform } from "prosemirror-transform";
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
import { CustomBlockNoteSchema } from "../schema/schema.js";
import type { BlockSchema } from "../schema/blocks/types.js";
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
import type { StyleSchema } from "../schema/styles/types.js";
Expand All @@ -25,12 +25,8 @@ export function getBlockNoteSchema<
BSchema extends BlockSchema,
I extends InlineContentSchema,
S extends StyleSchema,
>(schema: Schema): BlockNoteSchema<BSchema, I, S> {
return getBlockNoteEditor(schema).schema as unknown as BlockNoteSchema<
BSchema,
I,
S
>;
>(schema: Schema): CustomBlockNoteSchema<BSchema, I, S> {
return getBlockNoteEditor(schema).schema as any;
}

export function getBlockSchema<BSchema extends BlockSchema>(
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/blocks/BlockNoteSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class BlockNoteSchema<
* A list of custom Styles that should be available in the editor.
*/
styleSpecs?: SSpecs;
}): BlockNoteSchema<
}): CustomBlockNoteSchema<
BSpecs extends undefined
? BlockSchemaFromSpecs<typeof defaultBlockSpecs>
: BlockSchemaFromSpecs<NonNullable<BSpecs>>,
Expand All @@ -49,7 +49,7 @@ export class BlockNoteSchema<
? StyleSchemaFromSpecs<typeof defaultStyleSpecs>
: StyleSchemaFromSpecs<NonNullable<SSpecs>>
> {
return new BlockNoteSchema<any, any, any>({
return new CustomBlockNoteSchema<any, any, any>({
blockSpecs: options?.blockSpecs ?? defaultBlockSpecs,
inlineContentSpecs:
options?.inlineContentSpecs ?? defaultInlineContentSpecs,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/editor/BlockNoteExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
BlockNoteDOMAttributes,
BlockSchema,
BlockSpecs,
CustomBlockNoteSchema,
InlineContentSchema,
InlineContentSpecs,
StyleSchema,
Expand All @@ -59,7 +60,6 @@ import type {
BlockNoteEditorOptions,
SupportedExtension,
} from "./BlockNoteEditor.js";
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";

type ExtensionOptions<
BSchema extends BlockSchema,
Expand Down Expand Up @@ -94,7 +94,7 @@ type ExtensionOptions<
>;
tabBehavior?: "prefer-navigate-ui" | "prefer-indent";
comments?: {
schema?: BlockNoteSchema<any, any, any>;
schema?: CustomBlockNoteSchema;
threadStore: ThreadStore;
resolveUsers?: (userIds: string[]) => Promise<User[]>;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/exporter/Exporter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
import { COLORS_DEFAULT } from "../editor/defaultColors.js";
import {
BlockFromConfig,
BlockSchema,
CustomBlockNoteSchema,
InlineContent,
InlineContentSchema,
StyleSchema,
Expand Down Expand Up @@ -45,7 +45,7 @@ export abstract class Exporter<
TS,
> {
public constructor(
_schema: BlockNoteSchema<B, I, S>, // only used for type inference
_schema: CustomBlockNoteSchema<B, I, S>, // only used for type inference
protected readonly mappings: {
blockMapping: BlockMapping<B, I, S, RB, RI>;
inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/exporter/mapping.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
import {
BlockFromConfigNoChildren,
BlockSchema,
CustomBlockNoteSchema,
InlineContentFromConfig,
InlineContentSchema,
StyleSchema,
Expand Down Expand Up @@ -64,7 +64,7 @@ export function mappingFactory<
B extends BlockSchema,
I extends InlineContentSchema,
S extends StyleSchema,
>(_schema: BlockNoteSchema<B, I, S>) {
>(_schema: CustomBlockNoteSchema<B, I, S>) {
return {
createBlockMapping: <R, RI>(mapping: BlockMapping<B, I, S, R, RI>) =>
mapping,
Expand Down
36 changes: 33 additions & 3 deletions packages/core/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,40 @@ function removeUndefined<T extends Record<string, any> | undefined>(obj: T): T {
) as T;
}

/**
* Do note that this is separate from the `BlockNoteSchema` which is now reduced to a simple factory for instantiating a {@link CustomBlockNoteSchema} instance.
* In the future, we will rename the `BlockNoteSchema` to `DefaultBlockNoteSchema` and this will be the default schema that is used when no schema is passed to the editor.
* At that time, `CustomBlockNoteSchema` will be renamed to `BlockNoteSchema` and this will be the base class for all schemas.
*/

/**
* The CustomBlockNoteSchema class defines the shape of the schema that BlockNote uses, it defines all of the blocks, inline content, and styles that are available in the editor.
* You can create a custom schema by extending the CustomBlockNoteSchema class and passing in the blocks, inline content, and styles that you want to use.
*
* @example
* ```typescript
* const schema = new CustomBlockNoteSchema({
* blockSpecs: {
* block: { type: "block", content: "styled" },
* },
* });
* // extending the schema
* const extendedSchema = schema.extend({
* blockSpecs: {
* block: { type: "block", content: "styled" },
* },
* });
*
* // using the schema
* const editor = new BlockNoteEditor({
* schema: extendedSchema,
* });
* ```
*/
export class CustomBlockNoteSchema<
BSchema extends BlockSchema,
ISchema extends InlineContentSchema,
SSchema extends StyleSchema,
BSchema extends BlockSchema = Record<string, never>,
ISchema extends InlineContentSchema = Record<string, never>,
SSchema extends StyleSchema = Record<string, never>,
> {
// Helper so that you can use typeof schema.BlockNoteEditor
public readonly BlockNoteEditor: BlockNoteEditor<BSchema, ISchema, SSchema> =
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/editor/BlockNoteContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
BlockNoteEditor,
BlockNoteSchema,
CustomBlockNoteSchema,
BlockSchema,
DefaultBlockSchema,
DefaultInlineContentSchema,
Expand Down Expand Up @@ -33,7 +33,7 @@ export function useBlockNoteContext<
ISchema extends InlineContentSchema = DefaultInlineContentSchema,
SSchema extends StyleSchema = DefaultStyleSchema,
>(
_schema?: BlockNoteSchema<BSchema, ISchema, SSchema>,
_schema?: CustomBlockNoteSchema<BSchema, ISchema, SSchema>,
): BlockNoteContextValue<BSchema, ISchema, SSchema> | undefined {
const context = useContext(BlockNoteContext) as any;

Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/hooks/useBlockNoteEditor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
BlockNoteEditor,
BlockNoteSchema,
CustomBlockNoteSchema,
BlockSchema,
DefaultBlockSchema,
DefaultInlineContentSchema,
Expand All @@ -20,7 +20,7 @@ export function useBlockNoteEditor<
ISchema extends InlineContentSchema = DefaultInlineContentSchema,
SSchema extends StyleSchema = DefaultStyleSchema,
>(
_schema?: BlockNoteSchema<BSchema, ISchema, SSchema>,
_schema?: CustomBlockNoteSchema<BSchema, ISchema, SSchema>,
): BlockNoteEditor<BSchema, ISchema, SSchema> {
const context = useBlockNoteContext(_schema);

Expand Down
12 changes: 8 additions & 4 deletions packages/xl-ai/src/api/schema/schemaToJSONSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
BlockNoteSchema,
CustomBlockNoteSchema,
BlockSchema,
InlineContentSchema,
PropSchema,
Expand Down Expand Up @@ -262,7 +262,7 @@ function blockSchemaToJSONSchema(schema: BlockSchema) {
}

function schemaOps(
schema: BlockNoteSchema<BlockSchema, InlineContentSchema, StyleSchema>,
schema: CustomBlockNoteSchema<BlockSchema, InlineContentSchema, StyleSchema>,
) {
const clone = {
blockSchema: schema.blockSchema,
Expand Down Expand Up @@ -309,12 +309,16 @@ function schemaOps(
}

export function blockNoteSchemaToJSONSchema(
schema: BlockNoteSchema<any, any, any>,
schema: CustomBlockNoteSchema<any, any, any>,
) {
schema = schemaOps(schema)
.removeFileBlocks()
.removeDefaultProps()
.get() as BlockNoteSchema<BlockSchema, InlineContentSchema, StyleSchema>;
.get() as CustomBlockNoteSchema<
BlockSchema,
InlineContentSchema,
StyleSchema
>;
return {
$defs: {
styles: styleSchemaToJSONSchema(schema.styleSchema),
Expand Down
4 changes: 2 additions & 2 deletions packages/xl-docx-exporter/src/docx/docxExporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Block,
BlockNoteSchema,
CustomBlockNoteSchema,
BlockSchema,
COLORS_DEFAULT,
InlineContentSchema,
Expand Down Expand Up @@ -54,7 +54,7 @@ export class DOCXExporter<
/**
* The schema of your editor. The mappings are automatically typed checked against this schema.
*/
protected readonly schema: BlockNoteSchema<B, I, S>,
protected readonly schema: CustomBlockNoteSchema<B, I, S>,
/**
* The mappings that map the BlockNote schema to the docxjs content.
* Pass {@link docxDefaultSchemaMappings} for the default schema.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Block,
BlockNoteSchema,
BlockSchema,
COLORS_DEFAULT,
DefaultProps,
Expand All @@ -9,6 +8,7 @@ import {
InlineContentSchema,
StyleSchema,
StyledText,
CustomBlockNoteSchema,
} from "@blocknote/core";
import {
Body,
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ReactEmailExporter<
React.ReactElement<HTMLSpanElement>
> {
public constructor(
public readonly schema: BlockNoteSchema<B, I, S>,
public readonly schema: CustomBlockNoteSchema<B, I, S>,
mappings: Exporter<
NoInfer<B>,
NoInfer<I>,
Expand Down
3 changes: 2 additions & 1 deletion packages/xl-multi-column/src/blocks/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CustomBlockNoteSchema,
BlockNoteSchema,
BlockSchema,
InlineContentSchema,
Expand All @@ -21,7 +22,7 @@ export const withMultiColumn = <
I extends InlineContentSchema,
S extends StyleSchema,
>(
schema: BlockNoteSchema<B, I, S>,
schema: CustomBlockNoteSchema<B, I, S>,
) => {
return schema.extend({
blockSpecs: {
Expand Down
4 changes: 2 additions & 2 deletions packages/xl-odt-exporter/src/odt/odtExporter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Block,
BlockNoteSchema,
CustomBlockNoteSchema,
BlockSchema,
COLORS_DEFAULT,
Exporter,
Expand Down Expand Up @@ -49,7 +49,7 @@ export class ODTExporter<
public readonly options: ExporterOptions;

constructor(
protected readonly schema: BlockNoteSchema<B, I, S>,
protected readonly schema: CustomBlockNoteSchema<B, I, S>,
mappings: Exporter<
NoInfer<B>,
NoInfer<I>,
Expand Down
4 changes: 2 additions & 2 deletions packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
Block,
BlockNoteSchema,
BlockSchema,
COLORS_DEFAULT,
CustomBlockNoteSchema,
DefaultProps,
Exporter,
ExporterOptions,
Expand Down Expand Up @@ -78,7 +78,7 @@ export class PDFExporter<
/**
* The schema of your editor. The mappings are automatically typed checked against this schema.
*/
protected readonly schema: BlockNoteSchema<B, I, S>,
protected readonly schema: CustomBlockNoteSchema<B, I, S>,
/**
* The mappings that map the BlockNote schema to the react-pdf content.
*
Expand Down
Loading