@@ -27,7 +27,7 @@ import {
2727 SYSTEM_VARIABLE_ID ,
2828 systemParameter ,
2929} from "@webstudio-is/sdk" ;
30- import type { PropMeta , Prop , Asset } from "@webstudio-is/sdk" ;
30+ import type { PropMeta , Prop , Asset , WsComponentMeta } from "@webstudio-is/sdk" ;
3131import { InfoCircleIcon } from "@webstudio-is/icons" ;
3232import {
3333 Label as BaseLabel ,
@@ -458,6 +458,35 @@ const attributeToMeta = (attribute: Attribute): PropMeta => {
458458 throw Error ( "impossible case" ) ;
459459} ;
460460
461+ // Derive tag → content-mode attribute names from registered component metas,
462+ // so a prop marked `contentMode: true` in a .ws.ts file also surfaces on
463+ // `ws:element` instances rendering the same tag.
464+ const getContentModeAttributesByTag = ( metas : Map < string , WsComponentMeta > ) => {
465+ const byTag = new Map < string , Set < string > > ( ) ;
466+ for ( const componentMeta of metas . values ( ) ) {
467+ const tags = Object . keys ( componentMeta . presetStyle ?? { } ) ;
468+ if ( tags . length === 0 ) {
469+ continue ;
470+ }
471+ for ( const [ propName , propMeta ] of Object . entries (
472+ componentMeta . props ?? { }
473+ ) ) {
474+ if ( propMeta . contentMode !== true ) {
475+ continue ;
476+ }
477+ for ( const tag of tags ) {
478+ let names = byTag . get ( tag ) ;
479+ if ( names === undefined ) {
480+ names = new Set ( ) ;
481+ byTag . set ( tag , names ) ;
482+ }
483+ names . add ( propName ) ;
484+ }
485+ }
486+ }
487+ return byTag ;
488+ } ;
489+
461490export const $selectedInstancePropsMetas = computed (
462491 [ $selectedInstance , $registeredComponentMetas , $instanceTags ] ,
463492 ( instance , metas , instanceTags ) : Map < string , PropMeta > => {
@@ -467,22 +496,32 @@ export const $selectedInstancePropsMetas = computed(
467496 const meta = metas . get ( instance . component ) ;
468497 const tag = instanceTags . get ( instance . id ) ;
469498 const propsMetas = new Map < Prop [ "name" ] , PropMeta > ( ) ;
499+ const contentModeAttributesByTag = getContentModeAttributesByTag ( metas ) ;
500+ const contentModeAttributes =
501+ tag === undefined ? undefined : contentModeAttributesByTag . get ( tag ) ;
502+ const toAttributeMeta = ( attribute : Attribute ) : PropMeta => {
503+ const propMeta = attributeToMeta ( attribute ) ;
504+ if ( contentModeAttributes ?. has ( attribute . name ) ) {
505+ return { ...propMeta , contentMode : true } ;
506+ }
507+ return propMeta ;
508+ } ;
470509 // add html attributes only when instance has tag
471510 if ( tag ) {
472511 if ( elementsByTag [ tag ] . categories . includes ( "html-element" ) ) {
473512 for ( const attribute of [ ...ariaAttributes ] . reverse ( ) ) {
474- propsMetas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
513+ propsMetas . set ( attribute . name , toAttributeMeta ( attribute ) ) ;
475514 }
476515 // include global attributes only for html elements
477516 if ( attributesByTag [ "*" ] ) {
478517 for ( const attribute of [ ...attributesByTag [ "*" ] ] . reverse ( ) ) {
479- propsMetas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
518+ propsMetas . set ( attribute . name , toAttributeMeta ( attribute ) ) ;
480519 }
481520 }
482521 }
483522 if ( attributesByTag [ tag ] ) {
484523 for ( const attribute of [ ...attributesByTag [ tag ] ] . reverse ( ) ) {
485- propsMetas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
524+ propsMetas . set ( attribute . name , toAttributeMeta ( attribute ) ) ;
486525 }
487526 }
488527 }
0 commit comments