Loading...
Loading...
Use utility components to render formatted text and media correctly. Use when (1) Rendering HTML text content from props, (2) Displaying images, (3) Working with formatted text or media. Covers FormattedText and Image utilities.
npx skill4agent add drupal-canvas/skills canvas-component-utilsdrupal-canvasimport { FormattedText, Image } from 'drupal-canvas';FormattedTextcontentMediaType: text/html# component.yml
props:
properties:
text:
title: Text
type: string
contentMediaType: text/html
x-formatting-context: block
examples:
- <p>This is <strong>formatted</strong> text.</p>import { FormattedText } from 'drupal-canvas';
const Text = ({ text, className }) => (
<FormattedText className={className}>{text}</FormattedText>
);contentMediaType: text/html<p><strong><em><a>Image# component.yml
props:
properties:
image:
title: Image
type: object
$ref: json-schema-definitions://canvas.module/image
examples:
- src: https://example.com/photo.jpg
alt: Description of image
width: 800
height: 600import { Image } from 'drupal-canvas';
const Card = ({ image }) => {
const { src, alt, width, height } = image;
return (
<Image
src={src}
alt={alt}
width={width}
height={height}
className="w-full rounded-lg object-cover"
/>
);
};srcaltwidthheightclassName