@@ -140,7 +140,7 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
140140 } ;
141141
142142 // tiptap options, undocumented
143- _tiptapOptions : any ;
143+ _tiptapOptions : Partial < EditorOptions > ;
144144} ;
145145
146146const blockNoteTipTapOptions = {
@@ -228,10 +228,11 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
228228 } ,
229229 ] ) ;
230230
231- const tiptapOptions : EditorOptions = {
231+ const tiptapOptions : Partial < EditorOptions > = {
232232 ...blockNoteTipTapOptions ,
233233 ...newOptions . _tiptapOptions ,
234234 onBeforeCreate ( editor ) {
235+ newOptions . _tiptapOptions ?. onBeforeCreate ?.( editor ) ;
235236 if ( ! initialContent ) {
236237 // when using collaboration
237238 return ;
@@ -250,7 +251,8 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
250251 ) ;
251252 editor . editor . options . content = root . toJSON ( ) ;
252253 } ,
253- onCreate : ( ) => {
254+ onCreate : ( editor ) => {
255+ newOptions . _tiptapOptions ?. onCreate ?.( editor ) ;
254256 // We need to wait for the TipTap editor to init before we can set the
255257 // initial content, as the schema may contain custom blocks which need
256258 // it to render.
@@ -261,7 +263,8 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
261263 newOptions . onEditorReady ?.( this ) ;
262264 this . ready = true ;
263265 } ,
264- onUpdate : ( ) => {
266+ onUpdate : ( editor ) => {
267+ newOptions . _tiptapOptions ?. onUpdate ?.( editor ) ;
265268 // This seems to be necessary due to a bug in TipTap:
266269 // https://github.com/ueberdosis/tiptap/issues/2583
267270 if ( ! this . ready ) {
@@ -270,7 +273,8 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
270273
271274 newOptions . onEditorContentChange ?.( this ) ;
272275 } ,
273- onSelectionUpdate : ( ) => {
276+ onSelectionUpdate : ( editor ) => {
277+ newOptions . _tiptapOptions ?. onSelectionUpdate ?.( editor ) ;
274278 // This seems to be necessary due to a bug in TipTap:
275279 // https://github.com/ueberdosis/tiptap/issues/2583
276280 if ( ! this . ready ) {
@@ -279,17 +283,25 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
279283
280284 newOptions . onTextCursorPositionChange ?.( this ) ;
281285 } ,
282- editable : options . editable === undefined ? true : options . editable ,
286+ editable :
287+ options . editable !== undefined
288+ ? options . editable
289+ : newOptions . _tiptapOptions ?. editable !== undefined
290+ ? newOptions . _tiptapOptions ?. editable
291+ : true ,
283292 extensions :
284293 newOptions . enableBlockNoteExtensions === false
285- ? newOptions . _tiptapOptions ?. extensions
294+ ? newOptions . _tiptapOptions ?. extensions || [ ]
286295 : [ ...( newOptions . _tiptapOptions ?. extensions || [ ] ) , ...extensions ] ,
287296 editorProps : {
297+ ...newOptions . _tiptapOptions ?. editorProps ,
288298 attributes : {
299+ ...newOptions . _tiptapOptions ?. editorProps ?. attributes ,
289300 ...newOptions . domAttributes ?. editor ,
290301 class : mergeCSSClasses (
291302 styles . bnEditor ,
292303 styles . bnRoot ,
304+ newOptions . domAttributes ?. editor ?. class || "" ,
293305 newOptions . defaultStyles ? styles . defaultStyles : "" ,
294306 newOptions . domAttributes ?. editor ?. class || ""
295307 ) ,
0 commit comments