@@ -84,8 +84,12 @@ export class CustomBlockNoteSchema<
8484 const defaultSet = new Set < string > ( ) ;
8585 dag . set ( "default" , defaultSet ) ;
8686
87- for ( const [ key , specDef ] of Object . entries ( this . opts . blockSpecs ) ) {
88- if ( specDef . implementation . runsBefore ) {
87+ for ( const [ key , specDef ] of Object . entries ( {
88+ ...this . opts . blockSpecs ,
89+ ...this . opts . inlineContentSpecs ,
90+ ...this . opts . styleSpecs ,
91+ } ) ) {
92+ if ( specDef . implementation ?. runsBefore ) {
8993 dag . set ( key , new Set ( specDef . implementation . runsBefore ) ) ;
9094 } else {
9195 defaultSet . add ( key ) ;
@@ -130,19 +134,58 @@ export class CustomBlockNoteSchema<
130134 : never ;
131135 } ;
132136
137+ const inlineContentSpecs = Object . fromEntries (
138+ Object . entries ( this . opts . inlineContentSpecs ) . map (
139+ ( [ key , inlineContentSpec ] ) => {
140+ // Case for text and links.
141+ if ( typeof inlineContentSpec . config !== "object" ) {
142+ return [ key , inlineContentSpec ] ;
143+ }
144+
145+ return [
146+ key ,
147+ {
148+ ...inlineContentSpec ,
149+ implementation : {
150+ ...inlineContentSpec . implementation ,
151+ node : inlineContentSpec . implementation ?. node . extend ( {
152+ priority : getPriority ( key ) ,
153+ } ) ,
154+ } ,
155+ } ,
156+ ] ;
157+ } ,
158+ ) ,
159+ ) as InlineContentSpecs ;
160+
161+ const styleSpecs = Object . fromEntries (
162+ Object . entries ( this . opts . styleSpecs ) . map ( ( [ key , styleSpec ] ) => [
163+ key ,
164+ {
165+ ...styleSpec ,
166+ implementation : {
167+ ...styleSpec . implementation ,
168+ mark : styleSpec . implementation ?. mark . extend ( {
169+ priority : getPriority ( key ) ,
170+ } ) ,
171+ } ,
172+ } ,
173+ ] ) ,
174+ ) as StyleSpecs ;
175+
133176 return {
134177 blockSpecs,
135178 blockSchema : Object . fromEntries (
136179 Object . entries ( blockSpecs ) . map ( ( [ key , blockDef ] ) => {
137180 return [ key , blockDef . config ] ;
138181 } ) ,
139182 ) as any ,
140- inlineContentSpecs : removeUndefined ( this . opts . inlineContentSpecs ) ,
141- styleSpecs : removeUndefined ( this . opts . styleSpecs ) ,
183+ inlineContentSpecs : removeUndefined ( inlineContentSpecs ) ,
184+ styleSpecs : removeUndefined ( styleSpecs ) ,
142185 inlineContentSchema : getInlineContentSchemaFromSpecs (
143- this . opts . inlineContentSpecs ,
186+ inlineContentSpecs ,
144187 ) as any ,
145- styleSchema : getStyleSchemaFromSpecs ( this . opts . styleSpecs ) as any ,
188+ styleSchema : getStyleSchemaFromSpecs ( styleSpecs ) as any ,
146189 } ;
147190 }
148191
0 commit comments