@@ -38,6 +38,16 @@ let outcomeSelection = new CurricularOutcomesSection();
3838let fontSelect = document . getElementById ( "worksheet-font" ) as HTMLSelectElement ;
3939let fontSizeInput = document . getElementById ( "worksheet-font-size" ) as HTMLInputElement ;
4040
41+ function updatePageTitle ( ) {
42+ if ( topicInput . value || nameInput . value ) {
43+ document . title = nameInput . value + " - " + topicInput . value + " by " + authorInput . value ;
44+ } else if ( nameInput . value ) {
45+ document . title = nameInput . value + " by " + authorInput . value ;
46+ } else {
47+ document . title = "New Worksheet" ;
48+ }
49+ }
50+
4151function resolveFont ( value : string ) : string {
4252 switch ( value ) {
4353 case "latin" :
@@ -64,6 +74,7 @@ function applyWorksheetTypography() {
6474 document . documentElement . style . setProperty ( "--ws-font-family" , resolveFont ( fontKey ) ) ;
6575 document . documentElement . style . setProperty ( "--ws-font-size" , `${ pt } pt` ) ;
6676}
77+
6778fontSelect . addEventListener ( "change" , async ( ) => {
6879 worksheet . font = fontSelect . value ; // add to model (next section)
6980 applyWorksheetTypography ( ) ;
@@ -77,19 +88,23 @@ fontSizeInput.addEventListener("input", async () => {
7788 if ( ! worksheetLoaded ) return ;
7889 await preview . render ( ) ;
7990} ) ;
91+
8092topicInput . addEventListener ( "input" , async ( ) => {
93+ updatePageTitle ( ) ;
8194 worksheet . topic = topicInput . value ;
8295 if ( ! worksheetLoaded ) return ;
8396 await preview . render ( ) ;
8497} ) ;
8598
8699nameInput . addEventListener ( "input" , async ( ) => {
100+ updatePageTitle ( ) ;
87101 worksheet . name = nameInput . value ;
88102 if ( ! worksheetLoaded ) return ;
89103 await preview . render ( ) ;
90104} ) ;
91105
92106authorInput . addEventListener ( "input" , async ( ) => {
107+ updatePageTitle ( ) ;
93108 worksheet . author = authorInput . value ;
94109 if ( ! worksheetLoaded ) return ;
95110 await preview . render ( ) ;
@@ -526,7 +541,6 @@ document.addEventListener("DOMContentLoaded", async () => {
526541 bindAll ( "#add-block-paragraph" , ( el ) => {
527542 el . addEventListener ( "click" , async ( ) => {
528543 const newBlock = addNewBlock ( ) ;
529- newBlock . showPage ( WorksheetBlockType . Paragraph ) ;
530544 newBlock . setBlockType ( WorksheetBlockType . Paragraph ) ;
531545 newBlock . showPage ( `#${ newBlock . id } -${ WorksheetBlockType . Paragraph } ` ) ;
532546 blocks . push ( newBlock ) ;
@@ -612,6 +626,7 @@ document.addEventListener("DOMContentLoaded", async () => {
612626 // Remove loading overlay
613627 document . getElementById ( "progress" ) ?. remove ( ) ;
614628 document . querySelector ( "main" ) ?. classList . remove ( "hidden" ) ;
629+ updatePageTitle ( ) ;
615630} ) ;
616631
617632// -------------------------------
0 commit comments