@@ -6,6 +6,8 @@ import { getSchema } from "@tiptap/core";
6
6
import { Transform , Step } from "@tiptap/pm/transform" ;
7
7
import { EditorState } from "@tiptap/pm/state" ;
8
8
import { extensions } from "../src/extensions" ;
9
+ import { Schema } from "@tiptap/pm/model" ;
10
+ import { BlockNoteEditor } from "@blocknote/core" ;
9
11
10
12
const prosemirrorSync = new ProsemirrorSync ( components . prosemirrorSync ) ;
11
13
export const {
@@ -27,10 +29,22 @@ export const {
27
29
// ...do something with the snapshot, like store a copy in another table,
28
30
// save a text version of the document for text search, or generate
29
31
// embeddings for vector search.
30
- const node = getSchema ( extensions ) . nodeFromJSON ( JSON . parse ( snapshot ) ) ;
32
+ const snapshotJSON = JSON . parse ( snapshot ) ;
33
+ let schema : Schema ;
34
+ // A hack for our demo which uses both BlockNote and Tiptap.
35
+ if ( id . endsWith ( "-blocknote" ) ) {
36
+ // Parse the snapshot from BlockNote.
37
+ const editor = BlockNoteEditor . create ( { _headless : true } ) ;
38
+ schema = editor . pmSchema ;
39
+ } else {
40
+ // Fetching the content from Tiptap, using your extensions.
41
+ schema = getSchema ( extensions ) ;
42
+ }
43
+ const node = schema . nodeFromJSON ( snapshotJSON ) ;
44
+ const content = node . textContent ;
31
45
await ctx . scheduler . runAfter ( 0 , internal . example . updateDocSearchIndex , {
32
46
id,
33
- content : node . textContent ,
47
+ content,
34
48
} ) ;
35
49
} ,
36
50
} ) ;
0 commit comments