@@ -56,6 +56,7 @@ function PublishView(props: PublishViewProps) {
5656 current : number ;
5757 } > ( ) ;
5858 const passwordInput = useRef < HTMLInputElement > ( null ) ;
59+ const titleInput = useRef < HTMLInputElement > ( null ) ;
5960 const publishNote = useStore ( ( store ) => store . publish ) ;
6061 const unpublishNote = useStore ( ( store ) => store . unpublish ) ;
6162 const [ monograph , setMonograph ] = useState ( props . monograph ) ;
@@ -125,6 +126,26 @@ function PublishView(props: PublishViewProps) {
125126 borderRadius : "default"
126127 } }
127128 >
129+ < Flex
130+ sx = { {
131+ alignItems : "center" ,
132+ justifyContent : "space-between" ,
133+ px : 1 ,
134+ height : 30 ,
135+
136+ "& label" : { width : "auto" , flexShrink : 0 }
137+ } }
138+ >
139+ < Text variant = "body" > { strings . title ( ) } *</ Text >
140+ < Input
141+ ref = { titleInput }
142+ type = "text"
143+ variant = "clean"
144+ placeholder = { strings . enterTitle ( ) }
145+ defaultValue = { monograph ? monograph . title : note . title }
146+ sx = { { textAlign : "right" , p : 0 } }
147+ />
148+ </ Flex >
128149 { monograph ?. publishedAt ? (
129150 < Flex
130151 sx = { {
@@ -286,8 +307,14 @@ function PublishView(props: PublishViewProps) {
286307 try {
287308 setStatus ( { action : "publish" } ) ;
288309 const password = passwordInput . current ?. value ;
310+ const title = titleInput . current ?. value ;
311+
312+ if ( ! title || title . trim ( ) . length === 0 ) {
313+ showToast ( "error" , "Title cannot be empty." ) ;
314+ return ;
315+ }
289316
290- await publishNote ( note . id , {
317+ await publishNote ( note . id , title , {
291318 selfDestruct,
292319 password
293320 } ) ;
@@ -425,6 +452,7 @@ type ResolvedMonograph = {
425452 selfDestruct : boolean ;
426453 publishedAt ?: number ;
427454 password ?: string ;
455+ title : string ;
428456} ;
429457
430458async function resolveMonograph (
@@ -436,6 +464,7 @@ async function resolveMonograph(
436464 id : monographId ,
437465 selfDestruct : ! ! monograph . selfDestruct ,
438466 publishedAt : monograph . datePublished ,
467+ title : monograph . title ,
439468 password : monograph . password
440469 ? await db . monographs . decryptPassword ( monograph . password )
441470 : undefined
0 commit comments