@@ -62,6 +62,14 @@ const CAPTION_POSITIONS = new Set([
6262 "bottom-right" ,
6363] ) ;
6464const CAPTION_LAYOUTS = new Set ( [ "stacked" , "inline" ] ) ;
65+ // Named font weights surfaced in the editor, mapped to their CSS values.
66+ const CAPTION_WEIGHT_MAP = {
67+ light : 300 ,
68+ normal : 400 ,
69+ medium : 500 ,
70+ semibold : 600 ,
71+ bold : 700 ,
72+ } ;
6573const DATE_FORMAT_PRESETS = {
6674 full : { year : "numeric" , month : "long" , day : "numeric" } ,
6775 long : { year : "numeric" , month : "long" , day : "numeric" } ,
@@ -205,6 +213,8 @@ function createAlbumSlideshowCardClass(Base) {
205213 typeof raw . font_size === "string" && raw . font_size . trim ( )
206214 ? raw . font_size . trim ( )
207215 : "14px" ;
216+ let fontWeight = String ( raw . font_weight || "medium" ) . toLowerCase ( ) ;
217+ if ( ! ( fontWeight in CAPTION_WEIGHT_MAP ) ) fontWeight = "medium" ;
208218 return {
209219 show,
210220 position,
@@ -213,6 +223,7 @@ function createAlbumSlideshowCardClass(Base) {
213223 date_format : raw . date_format != null ? String ( raw . date_format ) : "medium" ,
214224 color,
215225 font_size : fontSize ,
226+ font_weight : fontWeight ,
216227 shadow : raw . shadow !== false ,
217228 } ;
218229 }
@@ -345,7 +356,7 @@ function createAlbumSlideshowCardClass(Base) {
345356 align-items: baseline;
346357 gap: 0.15em 0.6em;
347358 }
348- .cap-line { font-weight: 500 ; }
359+ .cap-line { font-weight: inherit ; }
349360 .cap-box.cap-shadow {
350361 text-shadow:
351362 0 1px 2px rgba(0, 0, 0, 0.9),
@@ -702,6 +713,7 @@ function createAlbumSlideshowCardClass(Base) {
702713 if ( cap . shadow ) box . classList . add ( "cap-shadow" ) ;
703714 box . style . color = cap . color ;
704715 box . style . fontSize = cap . font_size ;
716+ box . style . fontWeight = CAPTION_WEIGHT_MAP [ cap . font_weight ] || 500 ;
705717 box . style . textAlign = h === "center" ? "center" : h ;
706718
707719 for ( const line of lines ) {
@@ -907,6 +919,14 @@ const CAPTION_LAYOUT_OPTIONS = [
907919 { value : "inline" , label : "Inline (same line)" } ,
908920] ;
909921
922+ const CAPTION_WEIGHT_OPTIONS = [
923+ { value : "light" , label : "Light" } ,
924+ { value : "normal" , label : "Normal" } ,
925+ { value : "medium" , label : "Medium" } ,
926+ { value : "semibold" , label : "Semi-bold" } ,
927+ { value : "bold" , label : "Bold" } ,
928+ ] ;
929+
910930const CAPTION_DATE_FORMAT_OPTIONS = [
911931 { value : "medium" , label : "Medium (Aug 16, 2014)" } ,
912932 { value : "full" , label : "Full (August 16, 2014)" } ,
@@ -936,6 +956,7 @@ const CAPTION_DEFAULTS = {
936956 date_format : "medium" ,
937957 color : "#ffffff" ,
938958 font_size : "14px" ,
959+ font_weight : "medium" ,
939960 shadow : true ,
940961} ;
941962
@@ -1303,6 +1324,12 @@ function createAlbumSlideshowCardEditorClass(Base) {
13031324 { name : "caption_font_size" , selector : { text : { } } } ,
13041325 ] ,
13051326 } ,
1327+ {
1328+ name : "caption_font_weight" ,
1329+ selector : {
1330+ select : { mode : "dropdown" , options : CAPTION_WEIGHT_OPTIONS } ,
1331+ } ,
1332+ } ,
13061333 { name : "caption_shadow" , selector : { boolean : { } } } ,
13071334 ] ,
13081335 } ,
@@ -1358,6 +1385,7 @@ function createAlbumSlideshowCardEditorClass(Base) {
13581385 caption_date_format : c . date_format || CAPTION_DEFAULTS . date_format ,
13591386 caption_color : c . color || CAPTION_DEFAULTS . color ,
13601387 caption_font_size : c . font_size || CAPTION_DEFAULTS . font_size ,
1388+ caption_font_weight : c . font_weight || CAPTION_DEFAULTS . font_weight ,
13611389 caption_shadow : c . shadow !== false ,
13621390 } ;
13631391 }
@@ -1410,6 +1438,7 @@ function createAlbumSlideshowCardEditorClass(Base) {
14101438 caption_date_format : "Date format" ,
14111439 caption_color : "Text color" ,
14121440 caption_font_size : "Font size" ,
1441+ caption_font_weight : "Font weight" ,
14131442 caption_shadow : "Text shadow" ,
14141443 ...LIVE_LABELS ,
14151444 } ;
@@ -1426,6 +1455,8 @@ function createAlbumSlideshowCardEditorClass(Base) {
14261455 "Pick a preset or type a custom format (YYYY, MMMM, MMM, MM, DD, D)." ,
14271456 caption_per_image :
14281457 "When a portrait pair is shown, caption each photo with its own date and location." ,
1458+ caption_layout :
1459+ "How date and location stack when both are shown: stacked (one per line) or inline (same line). No effect with a single field." ,
14291460 caption_color : "CSS color, e.g. #ffffff or white." ,
14301461 caption_font_size : "CSS size, e.g. 14px, 1.1em." ,
14311462 live_paused :
@@ -1645,6 +1676,8 @@ function createAlbumSlideshowCardEditorClass(Base) {
16451676 if ( col && col . toLowerCase ( ) !== CAPTION_DEFAULTS . color ) cap . color = col ;
16461677 const fs = ( data . caption_font_size || "" ) . trim ( ) ;
16471678 if ( fs && fs !== CAPTION_DEFAULTS . font_size ) cap . font_size = fs ;
1679+ const fw = data . caption_font_weight || CAPTION_DEFAULTS . font_weight ;
1680+ if ( fw !== CAPTION_DEFAULTS . font_weight ) cap . font_weight = fw ;
16481681 if ( data . caption_shadow === false ) cap . shadow = false ;
16491682 n . caption = cap ;
16501683 }
0 commit comments