1- import { BlockNoteEditor , editorHasBlockWithType } from "@blocknote/core" ;
1+ import {
2+ BlockNoteEditor ,
3+ createPropSchemaFromZod ,
4+ editorHasBlockWithType ,
5+ } from "@blocknote/core" ;
26import { describe , expect , it } from "vitest" ;
37import * as z from "zod/v4" ;
48import { createTestEditor } from "../createTestEditor.js" ;
@@ -26,10 +30,12 @@ describe("Editor block schema type guard tests", () => {
2630 editorHasBlockWithType (
2731 getEditor ( ) ,
2832 "heading" ,
29- z . object ( {
30- level : z . number ( ) ,
31- textColor : z . string ( ) ,
32- } ) ,
33+ createPropSchemaFromZod (
34+ z . object ( {
35+ level : z . number ( ) ,
36+ textColor : z . string ( ) ,
37+ } ) ,
38+ ) ,
3339 ) ,
3440 ) . toBeTruthy ( ) ;
3541 } ) ;
@@ -39,10 +45,12 @@ describe("Editor block schema type guard tests", () => {
3945 editorHasBlockWithType (
4046 getEditor ( ) ,
4147 "heading" ,
42- z . object ( {
43- level : z . number ( ) ,
44- textColor : z . number ( ) ,
45- } ) ,
48+ createPropSchemaFromZod (
49+ z . object ( {
50+ level : z . number ( ) ,
51+ textColor : z . number ( ) ,
52+ } ) ,
53+ ) ,
4654 ) ,
4755 ) . toBeFalsy ( ) ;
4856 } ) ;
@@ -52,10 +60,14 @@ describe("Editor block schema type guard tests", () => {
5260 editorHasBlockWithType (
5361 getEditor ( ) ,
5462 "heading" ,
55- z . object ( {
56- level : z . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] ) . default ( 1 ) ,
57- textColor : z . string ( ) . default ( "default" ) ,
58- } ) ,
63+ createPropSchemaFromZod (
64+ z . object ( {
65+ level : z
66+ . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] )
67+ . default ( 1 ) ,
68+ textColor : z . string ( ) . default ( "default" ) ,
69+ } ) ,
70+ ) ,
5971 ) ,
6072 ) . toBeTruthy ( ) ;
6173 } ) ;
@@ -65,10 +77,14 @@ describe("Editor block schema type guard tests", () => {
6577 editorHasBlockWithType (
6678 getEditor ( ) ,
6779 "heading" ,
68- z . object ( {
69- level : z . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] ) . default ( 1 ) ,
70- textColor : z . number ( ) . default ( 1 ) ,
71- } ) ,
80+ createPropSchemaFromZod (
81+ z . object ( {
82+ level : z
83+ . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] )
84+ . default ( 1 ) ,
85+ textColor : z . number ( ) . default ( 1 ) ,
86+ } ) ,
87+ ) ,
7288 ) ,
7389 ) . toBeFalsy ( ) ;
7490 } ) ;
@@ -78,10 +94,14 @@ describe("Editor block schema type guard tests", () => {
7894 editorHasBlockWithType (
7995 getEditor ( ) ,
8096 "heading" ,
81- z . object ( {
82- level : z . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] ) . default ( 1 ) ,
83- textColor : z . string ( ) . default ( "default" ) ,
84- } ) ,
97+ createPropSchemaFromZod (
98+ z . object ( {
99+ level : z
100+ . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] )
101+ . default ( 1 ) ,
102+ textColor : z . string ( ) . default ( "default" ) ,
103+ } ) ,
104+ ) ,
85105 ) ,
86106 ) . toBeFalsy ( ) ;
87107 } ) ;
@@ -91,10 +111,12 @@ describe("Editor block schema type guard tests", () => {
91111 editorHasBlockWithType (
92112 getEditor ( ) ,
93113 "numberedListItem" ,
94- z . object ( {
95- start : z . number ( ) ,
96- textColor : z . string ( ) ,
97- } ) ,
114+ createPropSchemaFromZod (
115+ z . object ( {
116+ start : z . number ( ) ,
117+ textColor : z . string ( ) ,
118+ } ) ,
119+ ) ,
98120 ) ,
99121 ) . toBeTruthy ( ) ;
100122 } ) ;
@@ -104,10 +126,12 @@ describe("Editor block schema type guard tests", () => {
104126 editorHasBlockWithType (
105127 getEditor ( ) ,
106128 "numberedListItem" ,
107- z . object ( {
108- start : z . string ( ) ,
109- textColor : z . string ( ) ,
110- } ) ,
129+ createPropSchemaFromZod (
130+ z . object ( {
131+ start : z . string ( ) ,
132+ textColor : z . string ( ) ,
133+ } ) ,
134+ ) ,
111135 ) ,
112136 ) . toBeFalsy ( ) ;
113137 } ) ;
@@ -121,10 +145,12 @@ describe("Editor block schema type guard tests", () => {
121145 editorHasBlockWithType (
122146 getEditor ( ) ,
123147 "simpleImage" ,
124- z . object ( {
125- name : z . string ( ) ,
126- url : z . string ( ) ,
127- } ) ,
148+ createPropSchemaFromZod (
149+ z . object ( {
150+ name : z . string ( ) ,
151+ url : z . string ( ) ,
152+ } ) ,
153+ ) ,
128154 ) ,
129155 ) . toBeTruthy ( ) ;
130156 } ) ;
@@ -134,10 +160,12 @@ describe("Editor block schema type guard tests", () => {
134160 editorHasBlockWithType (
135161 getEditor ( ) ,
136162 "simpleImage" ,
137- z . object ( {
138- name : z . string ( ) ,
139- url : z . number ( ) ,
140- } ) ,
163+ createPropSchemaFromZod (
164+ z . object ( {
165+ name : z . string ( ) ,
166+ url : z . number ( ) ,
167+ } ) ,
168+ ) ,
141169 ) ,
142170 ) . toBeFalsy ( ) ;
143171 } ) ;
@@ -147,10 +175,12 @@ describe("Editor block schema type guard tests", () => {
147175 editorHasBlockWithType (
148176 getEditor ( ) ,
149177 "simpleImage" ,
150- z . object ( {
151- name : z . string ( ) . default ( "" ) ,
152- url : z . string ( ) . default ( "" ) ,
153- } ) ,
178+ createPropSchemaFromZod (
179+ z . object ( {
180+ name : z . string ( ) . default ( "" ) ,
181+ url : z . string ( ) . default ( "" ) ,
182+ } ) ,
183+ ) ,
154184 ) ,
155185 ) . toBeTruthy ( ) ;
156186 } ) ;
@@ -160,10 +190,12 @@ describe("Editor block schema type guard tests", () => {
160190 editorHasBlockWithType (
161191 getEditor ( ) ,
162192 "simpleImage" ,
163- z . object ( {
164- name : z . boolean ( ) . default ( false ) ,
165- url : z . string ( ) . default ( "" ) ,
166- } ) ,
193+ createPropSchemaFromZod (
194+ z . object ( {
195+ name : z . boolean ( ) . default ( false ) ,
196+ url : z . string ( ) . default ( "" ) ,
197+ } ) ,
198+ ) ,
167199 ) ,
168200 ) . toBeFalsy ( ) ;
169201 } ) ;
@@ -173,12 +205,14 @@ describe("Editor block schema type guard tests", () => {
173205 editorHasBlockWithType (
174206 getEditor ( ) ,
175207 "simpleImage" ,
176- z . object ( {
177- name : z
178- . union ( [ z . literal ( "image" ) , z . literal ( "photo" ) ] )
179- . default ( "photo" ) ,
180- url : z . string ( ) . default ( "" ) ,
181- } ) ,
208+ createPropSchemaFromZod (
209+ z . object ( {
210+ name : z
211+ . union ( [ z . literal ( "image" ) , z . literal ( "photo" ) ] )
212+ . default ( "photo" ) ,
213+ url : z . string ( ) . default ( "" ) ,
214+ } ) ,
215+ ) ,
182216 ) ,
183217 ) . toBeFalsy ( ) ;
184218 } ) ;
0 commit comments