import { Logger } from '@hocuspocus/extension-logger' ; import { Server } from '@hocuspocus/server' ; import { slateNodesToInsertDelta } from '@slate-yjs/core' ; import * as Y from 'yjs' ; import initialValue from './data/initialValue.json' ; const server = Server . configure ( { port : 1234 , extensions : [ new Logger ( ) ] , async onLoadDocument ( data ) { if ( data . document . isEmpty ( 'content' ) ) { const insertDelta = slateNodesToInsertDelta ( initialValue ) ; const sharedRoot = data . document . get ( 'content' , Y . XmlText ) as Y . XmlText ; sharedRoot . applyDelta ( insertDelta ) ; } return data . document ; } , } ) ; server . enableMessageLogging ( ) ; server . listen ( ) ;