File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,16 @@ type YMapEdge = {
3737 sourceHandle : string ;
3838 targetHandle : string ;
3939} ;
40+
41+ // Y.Doc에는 name 컬럼이 없어서 생성했습니다.
42+ class CustomDoc extends Y . Doc {
43+ name : string ;
44+
45+ constructor ( name : string ) {
46+ super ( ) ;
47+ this . name = name ;
48+ }
49+ }
4050@WebSocketGateway ( 1234 )
4151export class YjsService
4252 implements OnGatewayInit , OnGatewayConnection , OnGatewayDisconnect
@@ -65,14 +75,15 @@ export class YjsService
6575
6676 this . ysocketio . initialize ( ) ;
6777
68- this . ysocketio . on ( 'document-loaded' , ( doc : any ) => {
78+ this . ysocketio . on ( 'document-loaded' , ( doc : Y . Doc ) => {
6979 const nodes = doc . getMap ( 'nodes' ) ;
7080 const edges = doc . getMap ( 'edges' ) ;
7181 const editorDoc = doc . getXmlFragment ( 'default' ) ;
7282
7383 // page content의 변경 사항을 감지한다.
7484 editorDoc . observeDeep ( ( ) => {
75- const pageId = editorDoc . doc . name . split ( '-' ) [ 1 ] ;
85+ const document = editorDoc . doc as CustomDoc ;
86+ const pageId = parseInt ( document . name . split ( '-' ) [ 1 ] ) ;
7687 this . pageService . updatePage (
7788 pageId ,
7889 JSON . parse ( JSON . stringify ( yXmlFragmentToProsemirrorJSON ( editorDoc ) ) ) ,
You can’t perform that action at this time.
0 commit comments