Skip to content

Commit fab647f

Browse files
authored
Merge pull request #2111 from TypeCellOS/refactor/remove-partials
refactor: less use of PartialBlocks and type cleanup
2 parents 984a21b + 7b44f98 commit fab647f

File tree

136 files changed

+1707
-1442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1707
-1442
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"editor.defaultFormatter": "esbenp.prettier-vscode",
33
"editor.formatOnSave": true,
4+
"editor.codeActionsOnSave": {
5+
"source.addMissingImports": "explicit"
6+
},
47
"[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
58
"[typescriptreact]": {
69
"editor.defaultFormatter": "esbenp.prettier-vscode"

examples/03-ui-components/03-formatting-toolbar-block-type-items/src/Alert.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { defaultProps } from "@blocknote/core";
21
import { createReactBlockSpec } from "@blocknote/react";
32
import { Menu } from "@mantine/core";
43
import { MdCancel, MdCheckCircle, MdError, MdInfo } from "react-icons/md";
54
import { z } from "zod/v4";
65

6+
import { createPropSchemaFromZod, defaultZodPropSchema } from "@blocknote/core";
77
import "./styles.css";
88

99
// The types of alerts that users can choose from.
@@ -54,16 +54,18 @@ export const alertTypes = [
5454
export const Alert = createReactBlockSpec(
5555
{
5656
type: "alert",
57-
propSchema: defaultProps
58-
.pick({
59-
textAlignment: true,
60-
textColor: true,
61-
})
62-
.extend({
63-
type: z
64-
.enum(["warning", "error", "info", "success"])
65-
.default("warning"),
66-
}),
57+
propSchema: createPropSchemaFromZod(
58+
defaultZodPropSchema
59+
.pick({
60+
textAlignment: true,
61+
textColor: true,
62+
})
63+
.extend({
64+
type: z
65+
.enum(["warning", "error", "info", "success"])
66+
.default("warning"),
67+
}),
68+
),
6769
content: "inline",
6870
},
6971
{

examples/03-ui-components/10-suggestion-menus-grid-mentions/src/Mention.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
import { createPropSchemaFromZod } from "@blocknote/core";
12
import { createReactInlineContentSpec } from "@blocknote/react";
23
import { z } from "zod/v4";
34

45
// The Mention inline content.
56
export const Mention = createReactInlineContentSpec(
67
{
78
type: "mention",
8-
propSchema: z.object({
9-
user: z.string().default("Unknown"),
10-
}),
9+
propSchema: createPropSchemaFromZod(
10+
z.object({
11+
user: z.string().default("Unknown"),
12+
}),
13+
),
1114
content: "none",
1215
},
1316
{

examples/03-ui-components/11-uppy-file-panel/src/FileReplaceButton.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {
2-
baseFilePropSchema,
2+
baseFileZodPropSchema,
33
blockHasType,
44
BlockSchema,
55
InlineContentSchema,
6-
optionalFileProps,
6+
optionalFileZodPropSchema,
77
StyleSchema,
8+
createPropSchemaFromZod
89
} from "@blocknote/core";
910
import {
1011
useBlockNoteEditor,
@@ -47,9 +48,10 @@ export const FileReplaceButton = () => {
4748
block,
4849
editor,
4950
block.type,
50-
baseFilePropSchema.extend({
51-
...optionalFileProps.pick({ url: true }).shape,
52-
}),
51+
// TODO
52+
createPropSchemaFromZod(baseFileZodPropSchema.extend({
53+
...optionalFileZodPropSchema.pick({ url: true }).shape,
54+
})),
5355
) ||
5456
!editor.isEditable
5557
) {

examples/06-custom-schema/01-alert-block/src/Alert.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defaultProps } from "@blocknote/core";
1+
import { createPropSchemaFromZod, defaultZodPropSchema } from "@blocknote/core";
22
import { createReactBlockSpec } from "@blocknote/react";
33
import { Menu } from "@mantine/core";
44
import { MdCancel, MdCheckCircle, MdError, MdInfo } from "react-icons/md";
@@ -54,16 +54,18 @@ export const alertTypes = [
5454
export const createAlert = createReactBlockSpec(
5555
{
5656
type: "alert",
57-
propSchema: defaultProps
58-
.pick({
59-
textAlignment: true,
60-
textColor: true,
61-
})
62-
.extend({
63-
type: z
64-
.enum(["warning", "error", "info", "success"])
65-
.default("warning"),
66-
}),
57+
propSchema: createPropSchemaFromZod(
58+
defaultZodPropSchema
59+
.pick({
60+
textAlignment: true,
61+
textColor: true,
62+
})
63+
.extend({
64+
type: z
65+
.enum(["warning", "error", "info", "success"])
66+
.default("warning"),
67+
}),
68+
),
6769
content: "inline",
6870
},
6971
{

examples/06-custom-schema/02-suggestion-menus-mentions/src/Mention.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
import { createPropSchemaFromZod } from "@blocknote/core";
12
import { createReactInlineContentSpec } from "@blocknote/react";
23
import { z } from "zod/v4";
34

45
// The Mention inline content.
56
export const Mention = createReactInlineContentSpec(
67
{
78
type: "mention",
8-
propSchema: z.object({
9-
user: z.string().default("Unknown"),
10-
}),
9+
propSchema: createPropSchemaFromZod(
10+
z.object({
11+
user: z.string().default("Unknown"),
12+
}),
13+
),
1114
content: "none",
1215
},
1316
{

examples/06-custom-schema/04-pdf-file-block/src/PDF.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
2-
baseFilePropSchema,
2+
baseFileZodPropSchema,
3+
createPropSchemaFromZod,
34
FileBlockConfig,
4-
optionalFileProps,
5+
optionalFileZodPropSchema,
56
} from "@blocknote/core";
67
import {
78
createReactBlockSpec,
@@ -38,14 +39,16 @@ export const PDFPreview = (
3839
export const PDF = createReactBlockSpec(
3940
{
4041
type: "pdf",
41-
propSchema: z.object({}).extend({
42-
...baseFilePropSchema.shape,
43-
...optionalFileProps.pick({
44-
url: true,
45-
showPreview: true,
46-
previewWidth: true,
47-
}).shape,
48-
}),
42+
propSchema: createPropSchemaFromZod(
43+
z.object({}).extend({
44+
...baseFileZodPropSchema.shape,
45+
...optionalFileZodPropSchema.pick({
46+
url: true,
47+
showPreview: true,
48+
previewWidth: true,
49+
}).shape,
50+
}),
51+
),
4952
content: "none",
5053
},
5154
{

examples/06-custom-schema/05-alert-block-full-ux/src/Alert.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defaultProps } from "@blocknote/core";
1+
import { createPropSchemaFromZod, defaultZodPropSchema } from "@blocknote/core";
22
import { createReactBlockSpec } from "@blocknote/react";
33
import { Menu } from "@mantine/core";
44
import { MdCancel, MdCheckCircle, MdError, MdInfo } from "react-icons/md";
@@ -54,16 +54,18 @@ export const alertTypes = [
5454
export const createAlert = createReactBlockSpec(
5555
{
5656
type: "alert",
57-
propSchema: defaultProps
58-
.pick({
59-
textAlignment: true,
60-
textColor: true,
61-
})
62-
.extend({
63-
type: z
64-
.enum(["warning", "error", "info", "success"])
65-
.default("warning"),
66-
}),
57+
propSchema: createPropSchemaFromZod(
58+
defaultZodPropSchema
59+
.pick({
60+
textAlignment: true,
61+
textColor: true,
62+
})
63+
.extend({
64+
type: z
65+
.enum(["warning", "error", "info", "success"])
66+
.default("warning"),
67+
}),
68+
),
6769
content: "inline",
6870
},
6971
{

examples/06-custom-schema/06-toggleable-blocks/src/Toggle.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { defaultProps } from "@blocknote/core";
1+
import { defaultPropSchema } from "@blocknote/core";
22
import { createReactBlockSpec, ToggleWrapper } from "@blocknote/react";
33

44
// The Toggle block that we want to add to our editor.
55
export const ToggleBlock = createReactBlockSpec(
66
{
77
type: "toggle",
8-
propSchema: {
9-
...defaultProps,
10-
} as typeof defaultProps,
8+
propSchema: defaultPropSchema,
119
content: "inline",
1210
},
1311
{

examples/06-custom-schema/draggable-inline-content/src/App.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { BlockNoteSchema, defaultInlineContentSpecs } from "@blocknote/core";
1+
import {
2+
BlockNoteSchema,
3+
createPropSchemaFromZod,
4+
defaultInlineContentSpecs,
5+
} from "@blocknote/core";
26
import "@blocknote/core/fonts/inter.css";
37
import { BlockNoteView } from "@blocknote/mantine";
48
import "@blocknote/mantine/style.css";
@@ -11,9 +15,11 @@ import { z } from "zod/v4";
1115
const draggableButton = createReactInlineContentSpec(
1216
{
1317
type: "draggableButton",
14-
propSchema: z.object({
15-
title: z.string().default(""),
16-
}),
18+
propSchema: createPropSchemaFromZod(
19+
z.object({
20+
title: z.string().default(""),
21+
}),
22+
),
1723
content: "none",
1824
},
1925
{

0 commit comments

Comments
 (0)