Skip to content

Commit

Permalink
docs: add jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Mar 21, 2024
1 parent e2de4a6 commit ac6afee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/primitives/src/block-editor/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { isBlobURL } from '@wordpress/blob';
import { ImagePrimitive, ImagePrimitiveValue } from '../shared/types.js';
import { useBlockPrimitiveProps } from './block.js';

/**

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.name" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.onPrimitiveSelect" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.mediaURL" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.mediaId" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.title" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.value" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.accept" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @param "root0.allowedTypes" declaration

Check warning on line 8 in packages/primitives/src/block-editor/image.tsx

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Missing JSDoc @returns declaration
* The Image Block Editor Primitive
*
* Expects an attribute of type {@link ImagePrimitiveValue}
*/
const Image = ({
name,
onPrimitiveSelect,
Expand Down
57 changes: 56 additions & 1 deletion packages/primitives/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,83 @@ export type MediaReplaceFlow = {
popoverProps?: DropdownProps['popoverProps'];
};

/**
* Represents an image stored with {@link ImagePrimitive}
*/
export type ImagePrimitiveValue = {
/**
* Image ID
*/
id: number;

/**
* Image URL
*/
url: string;

/**
* Image alt text
*/
alt: string;
};

/**
* The ImagePrimitive interface
*/
export interface ImagePrimitive extends Omit<MediaReplaceFlow, 'onSelect'> {
/**
* The name of the attribute where image data should be stored
*/
name: string;

/**
* The name/label of the toolbar control
*/
title?: string;

/**
* The actual value
*/
value?: ImagePrimitiveValue;

/**
* Optional custom onSelect handler
*
* @param name The name of the attribute
* @param media The media object
* @param setAttributes The setAttributes handler
* @param attributes The attributes object
*
*/
onPrimitiveSelect?: (
name: string,
value: Parameters<MediaReplaceFlow['onSelect']>['0'],
media: Parameters<MediaReplaceFlow['onSelect']>['0'],
setAttributes: SetAttributes,
attributes: Attributes,
) => void;
}

export interface RichTextPrimitive<T extends keyof HTMLElementTagNameMap>
extends Omit<RichText.Props<T>, 'onChange' | 'value'> {
/**
* The name of the attribute where image data should be stored
*/
name: string;

/**
* The actual value
*/
value?: string;

/**
* Optional custom onSelect handler
*
* @param name The name of the attribute
* @param value The value
* @param setAttributes The setAttributes handler
* @param attributes The attributes object
*
*/
onPrimitiveChange?: (
name: string,
value: string,
Expand Down

0 comments on commit ac6afee

Please sign in to comment.