@@ -38,7 +38,6 @@ import {
3838import { Heading , Text } from '@keystar/ui/typography' ;
3939
4040import { Config } from '../config' ;
41- import { ComponentSchema } from '../form/api' ;
4241import { sortBy } from './collection-sort' ;
4342import l10nMessages from './l10n' ;
4443import { useRouter } from './router' ;
@@ -567,10 +566,13 @@ function CollectionTable(
567566 nameCell ,
568567 ...collection . columns . map ( column => {
569568 const raw = item . data ?. [ column ] ;
570- const isImage = isImageColumn (
571- collection . schema ,
572- column
573- ) ;
569+ const field = collection . schema [ column ] ;
570+ const FieldCell =
571+ field &&
572+ 'kind' in field &&
573+ field . kind === 'form' &&
574+ 'Cell' in field &&
575+ field . Cell ;
574576
575577 if ( raw == null ) {
576578 return (
@@ -585,13 +587,13 @@ function CollectionTable(
585587
586588 const strVal = raw + '' ;
587589
588- if ( isImage && isImagePath ( strVal ) ) {
590+ if ( FieldCell ) {
589591 return (
590592 < Cell
591593 key = { column + item . name }
592594 textValue = { strVal }
593595 >
594- < ImageThumbnail src = { strVal } />
596+ < FieldCell value = { raw } />
595597 </ Cell >
596598 ) ;
597599 }
@@ -620,55 +622,6 @@ function CollectionTable(
620622 ) ;
621623}
622624
623- const IMAGE_EXTENSIONS = new Set ( [
624- 'jpg' ,
625- 'jpeg' ,
626- 'png' ,
627- 'gif' ,
628- 'webp' ,
629- 'avif' ,
630- 'svg' ,
631- 'ico' ,
632- 'bmp' ,
633- ] ) ;
634-
635- function isImagePath ( value : string ) : boolean {
636- const ext = value . split ( '.' ) . pop ( ) ?. toLowerCase ( ) ;
637- return ext != null && IMAGE_EXTENSIONS . has ( ext ) ;
638- }
639-
640- function isImageColumn (
641- schema : Record < string , ComponentSchema > ,
642- columnKey : string
643- ) : boolean {
644- const field = schema [ columnKey ] ;
645- return field != null && 'formKind' in field && field . formKind === 'asset' ;
646- }
647-
648- function ImageThumbnail ( { src } : { src : string } ) {
649- const [ errored , setErrored ] = useState ( false ) ;
650- if ( errored ) {
651- return (
652- < Text color = "neutralTertiary" size = "small" >
653- { src }
654- </ Text >
655- ) ;
656- }
657- return (
658- < img
659- src = { src }
660- alt = ""
661- onError = { ( ) => setErrored ( true ) }
662- className = { css ( {
663- width : tokenSchema . size . scale [ 400 ] ,
664- height : tokenSchema . size . scale [ 400 ] ,
665- objectFit : 'cover' ,
666- borderRadius : tokenSchema . size . radius . small ,
667- flexShrink : 0 ,
668- } ) }
669- />
670- ) ;
671- }
672625
673626function getItemPath (
674627 basePath : string ,
0 commit comments