@@ -140,7 +140,7 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
140
140
} ;
141
141
142
142
// tiptap options, undocumented
143
- _tiptapOptions : any ;
143
+ _tiptapOptions : Partial < EditorOptions > ;
144
144
} ;
145
145
146
146
const blockNoteTipTapOptions = {
@@ -228,10 +228,11 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
228
228
} ,
229
229
] ) ;
230
230
231
- const tiptapOptions : EditorOptions = {
231
+ const tiptapOptions : Partial < EditorOptions > = {
232
232
...blockNoteTipTapOptions ,
233
233
...newOptions . _tiptapOptions ,
234
234
onBeforeCreate ( editor ) {
235
+ newOptions . _tiptapOptions ?. onBeforeCreate ?.( editor ) ;
235
236
if ( ! initialContent ) {
236
237
// when using collaboration
237
238
return ;
@@ -250,7 +251,8 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
250
251
) ;
251
252
editor . editor . options . content = root . toJSON ( ) ;
252
253
} ,
253
- onCreate : ( ) => {
254
+ onCreate : ( editor ) => {
255
+ newOptions . _tiptapOptions ?. onCreate ?.( editor ) ;
254
256
// We need to wait for the TipTap editor to init before we can set the
255
257
// initial content, as the schema may contain custom blocks which need
256
258
// it to render.
@@ -261,7 +263,8 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
261
263
newOptions . onEditorReady ?.( this ) ;
262
264
this . ready = true ;
263
265
} ,
264
- onUpdate : ( ) => {
266
+ onUpdate : ( editor ) => {
267
+ newOptions . _tiptapOptions ?. onUpdate ?.( editor ) ;
265
268
// This seems to be necessary due to a bug in TipTap:
266
269
// https://github.com/ueberdosis/tiptap/issues/2583
267
270
if ( ! this . ready ) {
@@ -270,7 +273,8 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
270
273
271
274
newOptions . onEditorContentChange ?.( this ) ;
272
275
} ,
273
- onSelectionUpdate : ( ) => {
276
+ onSelectionUpdate : ( editor ) => {
277
+ newOptions . _tiptapOptions ?. onSelectionUpdate ?.( editor ) ;
274
278
// This seems to be necessary due to a bug in TipTap:
275
279
// https://github.com/ueberdosis/tiptap/issues/2583
276
280
if ( ! this . ready ) {
@@ -279,17 +283,25 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
279
283
280
284
newOptions . onTextCursorPositionChange ?.( this ) ;
281
285
} ,
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 ,
283
292
extensions :
284
293
newOptions . enableBlockNoteExtensions === false
285
- ? newOptions . _tiptapOptions ?. extensions
294
+ ? newOptions . _tiptapOptions ?. extensions || [ ]
286
295
: [ ...( newOptions . _tiptapOptions ?. extensions || [ ] ) , ...extensions ] ,
287
296
editorProps : {
297
+ ...newOptions . _tiptapOptions ?. editorProps ,
288
298
attributes : {
299
+ ...newOptions . _tiptapOptions ?. editorProps ?. attributes ,
289
300
...newOptions . domAttributes ?. editor ,
290
301
class : mergeCSSClasses (
291
302
styles . bnEditor ,
292
303
styles . bnRoot ,
304
+ newOptions . domAttributes ?. editor ?. class || "" ,
293
305
newOptions . defaultStyles ? styles . defaultStyles : "" ,
294
306
newOptions . domAttributes ?. editor ?. class || ""
295
307
) ,
0 commit comments