@@ -23,6 +23,7 @@ import { TextButtons } from "./selectors/text-buttons";
2323import { ColorSelector } from "./selectors/color-selector" ;
2424
2525import { useDebouncedCallback } from "use-debounce" ;
26+ import { useUpdatePage } from "@/hooks/usePages" ;
2627
2728const extensions = [ ...defaultExtensions , slashCommand ] ;
2829
@@ -32,10 +33,12 @@ interface EditorProp {
3233 onChange ?: ( value : JSONContent ) => void ;
3334}
3435
36+ // TODO: 나중에 title input 추가해야함
3537const Editor = ( { pageId, initialValue } : EditorProp ) => {
3638 const [ initialContent , setInitialContent ] = useState < null | JSONContent > (
3739 initialValue === undefined ? null : initialValue ,
3840 ) ;
41+ const updateMutation = useUpdatePage ( pageId ) ;
3942
4043 const [ openNode , setOpenNode ] = useState ( false ) ;
4144 const [ openColor , setOpenColor ] = useState ( false ) ;
@@ -56,6 +59,13 @@ const Editor = ({ pageId, initialValue }: EditorProp) => {
5659 if ( pageId === undefined ) return ;
5760
5861 const json = editor . getJSON ( ) ;
62+ updateMutation . mutate ( {
63+ id : pageId ,
64+ pageData : {
65+ title : "제목 없음" ,
66+ content : json ,
67+ } ,
68+ } ) ;
5969 window . localStorage . setItem (
6070 "html-content" ,
6171 highlightCodeblocks ( editor . getHTML ( ) ) ,
0 commit comments