diff --git a/packages/block-editor/tsconfig.json b/packages/block-editor/tsconfig.json index a3c7d1ffd88077..2579b40fc3e81b 100644 --- a/packages/block-editor/tsconfig.json +++ b/packages/block-editor/tsconfig.json @@ -9,6 +9,7 @@ { "path": "../a11y" }, { "path": "../api-fetch" }, { "path": "../block-serialization-default-parser" }, + { "path": "../blocks" }, { "path": "../blob" }, { "path": "../components" }, { "path": "../compose" }, diff --git a/packages/block-library/tsconfig.json b/packages/block-library/tsconfig.json index 2a2cb1653d4285..1922ab342daa53 100644 --- a/packages/block-library/tsconfig.json +++ b/packages/block-library/tsconfig.json @@ -13,6 +13,7 @@ { "path": "../autop" }, { "path": "../blob" }, { "path": "../block-editor" }, + { "path": "../blocks" }, { "path": "../components" }, { "path": "../compose" }, { "path": "../core-data" }, diff --git a/packages/blocks/package.json b/packages/blocks/package.json index e94bb60f5aa348..260e27cba8218f 100644 --- a/packages/blocks/package.json +++ b/packages/blocks/package.json @@ -26,6 +26,7 @@ "module": "build-module/index.js", "react-native": "src/index", "wpScript": true, + "types": "build-types", "sideEffects": [ "{src,build,build-module}/{index.js,store/index.js}" ], diff --git a/packages/blocks/src/api/types.ts b/packages/blocks/src/api/types.ts new file mode 100644 index 00000000000000..8629ec05771729 --- /dev/null +++ b/packages/blocks/src/api/types.ts @@ -0,0 +1,55 @@ +/** + * Describes options for Block serialization. + * + * Used by the Block [serializer](./serializer.js). + * + * @public + */ +export type BlockSerializationOptions = { + /** + * Whether to output HTML comments around blocks. + */ + isCommentDelimited?: boolean; + + /** + * Whether the serialization process has descended into the inner blocks. + */ + isInnerBlocks?: boolean; + + /** + * If a block is migrated from a deprecated version, skip logging the migration details. + * + * @internal + */ + __unstableSkipMigrationLogs?: boolean; + + /** + * Whether to skip autop when processing freeform content. + * + * @internal + */ + __unstableSkipAutop?: boolean; +}; + +/** + * Describes options for Block parsing. + * + * Used by the block [parser](./parser/index.js). + * + * @public + */ +export type BlockParseOptions = { + /** + * If a block is migrated from a deprecated version, skip logging the migration details. + * + * @internal + */ + __unstableSkipMigrationLogs?: boolean; + + /** + * Whether to skip autop when processing freeform content. + * + * @internal + */ + __unstableSkipAutop?: boolean; +}; diff --git a/packages/blocks/src/store/types.ts b/packages/blocks/src/store/types.ts new file mode 100644 index 00000000000000..8311b7dc9e9d6c --- /dev/null +++ b/packages/blocks/src/store/types.ts @@ -0,0 +1,67 @@ +/** + * Internal dependencies + */ +import type { + BlockCategory, + BlockCollection, + BlockVariation, + BlockStyle, + BlockType, +} from '../types'; + +/** + * The state of the `core/blocks` redux store. + * + * @public + */ +export type BlockStoreState = { + /** + * Block variations by block name. + */ + blockVariations: Record< string, BlockVariation[] >; + + /** + * Block styles by block name. + */ + blockStyles: Record< string, BlockStyle[] >; + + /** + * Block type by name. + */ + blockTypes: Record< string, BlockType< any > >; + + /** + * The available block categories. + */ + categories: BlockCategory[]; + + /** + * The available collections. + */ + collections: BlockCollection[]; + + /** + * Name of the default block name. + */ + defaultBlockName?: string; + + /** + * Name of the block for handling non-block content. + */ + freeformFallbackBlockName?: string; + + /** + * Name of the block for handling unregistered blocks. + */ + unregisteredFallbackBlockName?: string; + + /** + * Name of the block for handling the grouping of blocks. + */ + groupingBlockName?: string; + + /** + * Unprocessed block types. + */ + unprocessedBlockTypes?: any[]; +}; diff --git a/packages/blocks/src/types/block-attributes.ts b/packages/blocks/src/types/block-attributes.ts new file mode 100644 index 00000000000000..a1265eca40ef1b --- /dev/null +++ b/packages/blocks/src/types/block-attributes.ts @@ -0,0 +1,312 @@ +/** + * Block Attribute Interfaces + * + * @module BlockAttributes + */ + +/** + * External dependencies + */ +import type { ReactChild } from 'react'; + +/** + * Types of data stored by block attributes. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#type-validation Type Validation} on developer.wordpress.org + */ +export type AttributeSchemaType = + | 'string' + | 'boolean' + | 'object' + | 'null' + | 'array' + | 'integer' + | 'number'; + +export type BaseAttributeSource = { + type: AttributeSchemaType | AttributeSchemaType[]; +}; + +/** + * Used in [get-block-attributes.js](../api/parser/get-block-attributes.js) + * + * - [ ] TODO this isn't defined in {@link https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/block.json block.json} + * - [ ] TODO is this only used internally? + * + * @internal + */ +export interface Raw { + source: 'raw'; + type: 'string'; // TODO is this correct? +} + +/** + * Attribute sourced from an attribute of a tag in the markup. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#attribute-source Attribute Source} on developer.wordpress.org + * @public + */ +export type Attribute = { + source: 'attribute'; + attribute: string; + selector?: string; +} & ( + | { + type: 'boolean'; + default?: boolean; + } + | { + type: 'number'; + default?: number; + } + | { + type: 'string'; + default?: string; + } +); + +/** + * Used in [get-block-attributes.js](../api/parser/get-block-attributes.js) + * + * - [ ] TODO this isn't defined in {@link https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/block.json block.json} + * - [ ] TODO is this only used internally? + * + * @internal + */ +export interface Property { + source: 'property'; + type: 'string'; // TODO is this correct? +} + +/** + * @internal + */ +export interface Children { + source: 'children'; + type: 'array'; + selector?: string; +} + +/** + * Used in [get-block-attributes.js](../api/parser/get-block-attributes.js) + * + * - [ ] TODO this isn't defined in {@link https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/block.json block.json} + * - [ ] TODO is this only used internally? + * + * @internal + */ +export interface Node { + source: 'node'; + type: 'string'; // TODO is this correct? + selector?: string; +} + +/** + * Used in [get-block-attributes.js](../api/parser/get-block-attributes.js) + * + * - [ ] TODO this isn't defined in {@link https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/block.json block.json} + * - [ ] TODO is this only used internally? + * + * @internal + */ +export interface Tag { + source: 'tag'; + type: 'string'; // TODO is this correct? + selector?: string; +} + +/** + * Attribute sourced from the inner HTML from markup. + * + * Typically used by RichText. Note that text is returned according to the rules of {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML innerHTML} on developer.wordpress.org + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#html-source HTML Source} on developer.wordpress.org + * @public + */ +export interface HTML { + source: 'html'; + type: 'string'; + multiline?: 'li' | 'p'; + selector?: string; + default?: string; +} + +/** + * Attribute sourced from a post’s meta. + * + * {@link https://github.com/WordPress/gutenberg/blob/c367c4e2765f9e6b890d1565db770147efca5d66/packages/core-data/src/entity-provider.js EntityProvider and related hook APIs} should be used instead. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#meta-source-deprecated Meta Source} on developer.wordpress.org + * @deprecated + * @public + */ +export interface Meta { + source: 'meta'; + type: 'string'; + meta: string; + default?: string; +} + +/** + * Attribute sourced from array of values from markup. + * + * Entries of the array are determined by the selector argument, where each matched element within + * the block will have an entry structured corresponding to the second argument, an object of + * attribute sources. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#query-source Query Source} on developer.wordpress.org + * @public + */ +export interface Query< T > { + source: 'query'; + type: 'array'; + selector: string; + query: { + [ k in keyof T ]: BlockAttribute< + T[ k ] extends Array< infer U > ? U : T[ k ] + >; + }; + default?: any[]; +} + +/** + * Use text to extract the inner text from markup. + * + * Note that HTML is returned according to the rules of {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent textContent }. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#text-source Text Source} on developer.wordpress.org + * @public + */ +export interface Text { + source: 'text'; + type: 'string'; + selector?: string; + default?: string; +} + +/** + * @internal + */ +export type None = { + source?: never; +} & ( + | { + type: 'array'; + default?: any[]; + } + | { + type: 'object'; + default?: object; + } + | { + type: 'boolean'; + default?: boolean; + } + | { + type: 'number'; + default?: number; + } + | { + type: 'string'; + default?: string; + } +); + +/** + * @internal + */ +export type Primitive = 'array' | 'object' | 'boolean' | 'number' | 'string'; + +/** + * Union of block attribute schemas. + * + * @public + */ +export type BlockAttributeSchema< T > = ( + | Raw + | Attribute + | Property + | Children + | Node + | Tag + | HTML + | Meta + | Query< T > + | Text + | None +) & { + /** + * Role of the block. + * + * Used in [selectors.js](../store/selectors.js) and [utils.js](../api/utils.js) + * + * @internal + */ + __experimentalRole?: string; +}; + +/** + * @public + */ +export type BlockAttribute< T > = BlockAttributeSchema< T > | Primitive; + +/** + * Attributes definition providing information about the data stored by a block. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/ Attributes} + * @public + */ +export type BlockAttributes< T extends Record< string, any > = {} > = Record< + string, + BlockAttribute< T > +> & { + /** + * Provide an additional `className`, which used to be supported in the `core/comments-query-loop` block. + * + * Used in [convert-legacy-block.js](../api/parser/convert-legacy-block.js) and + * [fix-custom-classname.js](../api/parser/fix-custom-classname.js) + * + * @deprecated This is a legacy property and should not be used. + */ + className?: string; + + /** + * Used in [convert-legacy-block.js](../api/parser/convert-legacy-block.js) + * + * @deprecated This is a legacy property and should not be used. + */ + legacy?: boolean; + + /** + * Used in [convert-legacy-block.js](../api/parser/convert-legacy-block.js) + * + * @deprecated This is a legacy property and should not be used. + */ + responsive?: boolean; + + /** + * Used in [convert-legacy-block.js](../api/parser/convert-legacy-block.js) + * + * @deprecated This is a legacy property and should not be used. + */ + service?: string; +}; + +/** + * Return type of [`parseWithAttributeSchema`](../api/parser/get-block-attributes.js). + */ +export type SourceReturnValue< T > = T extends Attribute & { type: 'boolean' } + ? boolean | undefined + : T extends Children + ? ReactChild[] + : T extends Node + ? Element | null + : T extends Tag + ? keyof ( HTMLElementTagNameMap & SVGElementTagNameMap ) | undefined + : T extends Query< infer U > + ? { + [ k in keyof U ]: U[ k ] extends Query< infer V > + ? SourceReturnValue< Query< V > > + : SourceReturnValue< U[ k ] >; + } + : string | undefined; diff --git a/packages/blocks/src/types/block-category.ts b/packages/blocks/src/types/block-category.ts new file mode 100644 index 00000000000000..ca54f8fb636dec --- /dev/null +++ b/packages/blocks/src/types/block-category.ts @@ -0,0 +1,35 @@ +/** + * Block Category Interface + * + * @module BlockCategory + */ + +/** + * Internal dependencies + */ +import type { BlockType } from './block-type'; +import type { BlockIconRenderer } from './block-icon'; + +/** + * Custom category of {@link BlockType}. + * + * Note, similar in concept but differs from {@link BlockType.category} which are core categories. + * + * @public + */ +export interface BlockCategory { + /** + * Unique category slug. + */ + slug: string; + + /** + * Category label, for display in user interface. + */ + title: string; + + /** + * Optional icon, for display in user interface. + */ + icon?: BlockIconRenderer; +} diff --git a/packages/blocks/src/types/block-collection.ts b/packages/blocks/src/types/block-collection.ts new file mode 100644 index 00000000000000..cddf34bd227de1 --- /dev/null +++ b/packages/blocks/src/types/block-collection.ts @@ -0,0 +1,16 @@ +/** + * Internal dependencies + */ +import type { BlockIconRenderer } from './block-icon'; +import type { BlockStoreState } from '../store/types'; + +/** + * Describes a block collection. + * + * @see {@link BlockStoreState.collections} + * @public + */ +export interface BlockCollection { + title: string; + icon?: BlockIconRenderer; +} diff --git a/packages/blocks/src/types/block-deprecation.ts b/packages/blocks/src/types/block-deprecation.ts new file mode 100644 index 00000000000000..41b7d16361993a --- /dev/null +++ b/packages/blocks/src/types/block-deprecation.ts @@ -0,0 +1,42 @@ +/** + * Internal dependencies + */ +import type { Block } from './block'; +import type { BlockType } from './block-type'; + +/** + * {@link BlockType} depreciation handler. + * + * Defines migration of deprecated blocks to the current version. + * + * @see {@link BlockType.deprecated} + * @public + */ +export interface BlockDeprecation< + // The new block attribute types. + NewAttributes extends Record< string, any > = {}, + // The old block attribute types. + OldAttributes extends Record< string, any > = {}, +> extends Pick< + BlockType< OldAttributes >, + 'attributes' | 'save' | 'supports' + > { + /** + * A function which, given the attributes and inner blocks of the + * parsed block, returns true if the deprecation can handle the block + * migration. This is particularly useful in cases where a block is + * technically valid even once deprecated, and requires updates to its + * attributes or inner blocks. + */ + isEligible?: ( attributes: OldAttributes, innerBlocks: Block[] ) => boolean; + + /** + * A function which, given the old attributes and inner blocks is + * expected to return either the new attributes or a tuple array of + * [attributes, innerBlocks] compatible with the block. + */ + migrate?: ( + attributes: OldAttributes, + innerBlocks: Block[] + ) => NewAttributes | [ NewAttributes, Block[] ]; +} diff --git a/packages/blocks/src/types/block-icon.ts b/packages/blocks/src/types/block-icon.ts new file mode 100644 index 00000000000000..8934418b1e0170 --- /dev/null +++ b/packages/blocks/src/types/block-icon.ts @@ -0,0 +1,61 @@ +/** + * Block Icon Interfaces + * + * @module BlockIcon + */ + +/** + * External dependencies + */ +import type { ComponentType } from 'react'; + +/** + * Internal dependencies + */ +import type { BlockType } from './block-type'; + +/** + * An icon type definition. One of a Dashicon slug, an element, + * or a component. + * + * @see {@link https://developer.wordpress.org/resource/dashicons/ Dashicons} on developer.wordpress.org + * @public + */ +export type BlockIconRenderer< T = {} > = string | Element | ComponentType< T >; + +/** + * Describes a normalized block type icon. + * + * @see {@link BlockType.icon} + * @public + */ +export interface BlockIconNormalized { + /** + * Render behavior of the icon, one of a Dashicon slug, an element, or a component. + */ + src: BlockIconRenderer; + + /** + * Optimal background hex string color when displaying icon. + */ + background?: string; + + /** + * Optimal foreground hex string color when displaying icon. + */ + foreground?: string; + + /** + * Optimal shadow hex string color when displaying icon. + */ + shadowColor?: string; +} + +/** + * Type for rendering the icon of a {@link BlockType} in an editor interface, + * either a Dashicon slug, an element, a component, or an object describing + * the icon. + * + * @public + */ +export type BlockIcon = BlockIconRenderer | BlockIconNormalized; diff --git a/packages/blocks/src/types/block-node.ts b/packages/blocks/src/types/block-node.ts new file mode 100644 index 00000000000000..d5b4e38c31ff4b --- /dev/null +++ b/packages/blocks/src/types/block-node.ts @@ -0,0 +1,53 @@ +/** + * Block Node Interface + * + * @module BlockNode + */ + +/** + * The "block node" represents a transition from serialized block data + * into a fully-loaded block with its implementation. It contains the + * information parsed from the input document; be that serialized HTML + * as is the default case in WordPress, or directly loaded from a + * structured data store. + * + * Block nodes do not indicate all of a block's attributes, as some of + * its attributes may be sourced later on from the `innerHTML` by the + * block implementation. This is one example of where the block node + * is not a complete "block" and requires further processing. + * + * Block validation only examines `innerHTML` and delegates the validation + * of any inner blocks to the block loading process for those blocks. + * This prevents an issue with a potentially deeply-nested inner block + * from cascading up and invalidating all of its parent blocks. + * + * @public + */ +export type BlockNode = { + /** + * Name indicating namespaced block type, e.g. for example, "myplugin/my-interesting-block". + * A `null` block name is given to a section of freeform HTML content. + */ + blockName?: string; + + /** + * Attributes sourced from parsed JSON in the block comment delimiters. + * When unable to parse block comment attributes, `attrs` will be `null`. + */ + attrs?: Record< string, any >; + + /** + * Full text inside block boundaries excluding inner block content. + */ + innerHTML: string; + + /** + * Indicates arrangement of text chunks and inner blocks. + */ + innerContent: Array< string | null >; + + /** + * Nested block nodes; may be empty. + */ + innerBlocks: BlockNode[]; +}; diff --git a/packages/blocks/src/types/block-props.ts b/packages/blocks/src/types/block-props.ts new file mode 100644 index 00000000000000..59af104c756c36 --- /dev/null +++ b/packages/blocks/src/types/block-props.ts @@ -0,0 +1,29 @@ +/** + * Internal dependencies + */ +import type { BlockType } from './block-type'; + +/** + * Describes the `save` component props of a {@link BlockType}. + * + * @see {@link BlockType.save} + * @public + */ +export interface BlockSaveProps< Attributes extends Record< string, any > > { + className: string; + attributes: Attributes; +} + +/** + * Describes the `edit` component props of a {@link BlockType}. + * + * @see {@link BlockType.edit} + * @public + */ +export interface BlockEditProps< Attributes extends Record< string, any > > + extends BlockSaveProps< Attributes > { + clientId: string; + isSelected: boolean; + setAttributes: ( attrs: Partial< Attributes > ) => void; + context: Record< string, any >; +} diff --git a/packages/blocks/src/types/block-supports.ts b/packages/blocks/src/types/block-supports.ts new file mode 100644 index 00000000000000..9268acfd35158a --- /dev/null +++ b/packages/blocks/src/types/block-supports.ts @@ -0,0 +1,375 @@ +/** + * Internal dependencies + */ +import type { BlockType } from './block-type'; + +/** + * Control type used to indicate axial (column/row) block spacing controls. + * + * @see {@link BlockSupports.spacing} + * @public + */ +export type AxialDirection = 'horizontal' | 'vertical'; + +/** + * Control type used to indicate CSS spacing for arbitrary sides. + * + * @see {@link BlockSupports.spacing} + * @public + */ +export type CSSDirection = 'top' | 'right' | 'bottom' | 'left'; + +/** + * Control type used to indicate block’s alignment. + * + * @see {@link BlockSupports.align} + * @public + */ +export type BlockAlignment = 'left' | 'center' | 'right' | 'wide' | 'full'; + +/** + * CSS style properties related to dimensions of {@link BlockSupports}. + * + * When it does, the block editor will show UI controls for the user to set their values if + * {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/#opt-in-into-ui-controls the theme declares support}. + * + * @see {@link BlockSupports.dimensions} + * @public + */ +export type BlockDimensions = { + /** + * Enable min height control. + */ + minHeight: boolean; +}; + +/** + * {@link BlockSupports} interface to enable CSS style properties related to position. + * + * When it does, the block editor will show UI controls for the user to set their values if + * {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/#opt-in-into-ui-controls the theme declares support}. + * + * @see {@link BlockSupports.position} + * @public + */ +export type BlockPosition = { + /** + * Enable selecting sticky position. + */ + sticky: boolean; +}; + +/** + * {@link BlockSupports} interface to enable some of the properties related to color. + * + * Enables UI color controls in the block editor. + * + * @see {@link BlockSupports.color} + * @public + */ +export interface ColorProps { + /** + * This property adds UI controls which allow the user to apply + * a solid background color to a block. + * + * When the block declares support for `color.background`, + * the attributes of a block will include two new entries: + * `backgroundColor` and `style`. + * + * (default) true + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-background https://developer.wordpress.org} + */ + background: boolean; + + /** + * This property adds UI controls which allow the user to apply + * a gradient background to a block. + * + * When the block declares support for `color.background`, + * the attributes of a block will include two new entries: + * `gradient` and `style`. + * + * (default) false + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-gradients color.gradients} on developer.wordpress.org + */ + gradients: boolean; + + /** + * This property adds block controls which allow the user + * to set link color in a block, link color is disabled by default. + * + * (default) false + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-link color.link} on developer.wordpress.org + */ + link: boolean; + + /** + * This property adds block controls which allow the user + * to set text color in a block. + * + * (default) true + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-text color.text} on developer.wordpress.org + */ + text: boolean; + + /** + * This property adds UI controls which allow to apply a duotone filter + * to a block or part of a block. + * + * (default) undefined + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-__experimentalduotone __experimentalDuotone} on developer.wordpress.org + * @internal + */ + __experimentalDuotone?: string; +} + +/** + * {@link BlockSupports} interface to enable some typography related properties. + * + * When it does, the block editor will show a typography UI allowing the user to control their values. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography typography} on developer.wordpress.org + * @public + */ + +export interface TypographyProps { + /** + * This value signals that a block supports the font-size + * CSS style property. When it does, the block editor will + * show an UI control for the user to set its value. + * + * The values shown in this control are the ones declared + * by the theme via the editor-font-sizes theme support, + * or the default ones if none are provided. + * + * (default) false + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize fontSize} on developer.wordpress.org + * @see {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#block-font-sizes Font Size} on developer.wordpress.org + */ + fontSize: boolean; + + /** + * This value signals that a block supports the line-height + * CSS style property. When it does, the block editor will + * show an UI control for the user to set its value if the + * theme declares support. + * + * (default) false + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight lineHeight} on developer.wordpress.org + * @see {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#supporting-custom-line-heights Line Heights} on developer.wordpress.org + */ + lineHeight: boolean; +} + +/** + * {@link BlockSupports} interface to enable some of the CSS style properties related to spacing. + * + * When it does, the block editor will show UI controls for the user to set their values if + * {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/#opt-in-into-ui-controls the theme declares support}. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing spacing} on developer.wordpress.org + * @public + */ +export interface SpacingProps { + blockGap: boolean | AxialDirection[]; + /** + * Enable margin control UI for all or specified element directions + * + * (default) false + */ + margin: boolean | CSSDirection[]; + + /** + * Enable padding control UI for all or specified element directions + * + * (default) false + */ + padding: boolean | CSSDirection[]; + + /** + * Whether to skip the serialization to HTML markup. + * Provide `true` to skip serialization for all block supports. + * Alternatively, provide an array of block supports for which skip + * serialization to HTML markup. + * + * Used in [private-selectors.js]()./store/private-selectors.js) + * + * @internal + */ + __experimentalSkipSerialization?: true | string[]; +} + +/** + * Interface to allow alternative styles to be applied to existing blocks. + * + * Works by adding a className to the block’s wrapper. This className can be used to provide + * an alternative styling for the block if the block style is selected. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/ Styles} on developer.wordpress.org + * @public + */ +export interface BlockStyle { + name: string; + label: string; + isDefault?: boolean; +} + +/** + * Description of {@link BlockType} support for editor features. + * + * @see {@link BlockType.supports} + * @public + */ +export interface BlockSupports { + /** + * This property adds block controls which allow to change block's + * alignment. + * + * (default) false + */ + align?: boolean | BlockAlignment[]; + + /** + * Enable wide alignment (depends on `align`). + * + * (default) true + */ + alignWide?: boolean; + + /** + * Anchors let you link directly to a specific block on a page. This + * property adds a field to define an id for the block and a button to + * copy the direct link. + * + * (default) false + */ + anchor?: boolean; + + /** + * This value signals that a block supports some of the properties + * related to color. When it does, the block editor will show + * UI controls for the user to set their values. + * + * NOTE: The `background` and `text` keys have a default value + * of `true`, so if the color property is present they’ll also + * be considered enabled. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color BlockSupports.color} on developer.wordpress.org + */ + color?: Partial< ColorProps >; + + /** + * This property adds a field to define a custom className for the + * block's wrapper. + * + * (default) true + */ + customClassName?: boolean; + + /** + * By default, Gutenberg adds a class with the form + * `.wp-block-your-block-name` to the root element of your saved + * markup. + * + * (default) true + */ + className?: boolean; + + /** + * By default, Gutenberg will allow a block's markup to be edited + * individually. To disable this behavior, set `html` to `false` + * + * (default) true + */ + html?: boolean; + + /** + * By default, all blocks will appear in the Gutenberg inserter. To + * hide a block so that it can only be inserted programmatically, set + * to false + * + * (default) true + */ + inserter?: boolean; + + /** + * A non-multiple block can be inserted into each post, one time only. + * + * (default) true + */ + multiple?: boolean; + + /** + * By default all blocks can be converted to a reusable block. + * + * (default) true + */ + reusable?: boolean; + + /** + * This value signals that a block supports some of the CSS style + * properties related to spacing. + * + * When the block declares support for a specific spacing property, + * the attributes definition is extended to include the `style` attribute. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing BlockSupports.spacing} on developer.wordpress.org + */ + spacing?: Partial< SpacingProps >; + + /** + * A block may want to disable the ability to toggle the lock state. + * It can be locked/unlocked by a user from the block “Options” + * dropdown by default. To disable this behavior, set `lock` to `false`. + * + * (default) true + */ + lock?: boolean; + + /** + * A block may want to disable the ability to toggle the lock state. + * It can be locked/unlocked by a user from the block “Options” + * dropdown by default. To disable this behavior, set `lock` to `false`. + */ + typography?: Partial< TypographyProps >; + + /** + * This value signals that a block supports some of the CSS style properties related to shadow. + * + * Used in [private-selector.js](./store/private-selector.js) + */ + shadow: any; + + /** + * This value signals that a block supports some of the CSS style properties related to + * dimensions. + * + * (default) null + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions BlockSupports.dimensions} on developer.wordpress.org + */ + dimensions: BlockDimensions; + + /** + * This value signals that a block supports some of the CSS style properties related to position. + * + * (default) null + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#position BlockSupports.position} on developer.wordpress.org + */ + position: BlockPosition; + + /** + * CSS selector to use instead of the default `.wp-block-` selector. + * + * @internal + */ + __experimentalSelector: any; +} diff --git a/packages/blocks/src/types/block-type.ts b/packages/blocks/src/types/block-type.ts new file mode 100644 index 00000000000000..f2fb41c6b86425 --- /dev/null +++ b/packages/blocks/src/types/block-type.ts @@ -0,0 +1,287 @@ +/** + * External dependencies + */ + +import type { ComponentType } from 'react'; + +/** + * Internal dependencies + */ +import type { BlockAttribute, BlockAttributes } from './block-attributes'; +import type { BlockCategory } from './block-category'; +import type { BlockDeprecation } from './block-deprecation'; +import type { BlockIcon, BlockIconNormalized } from './block-icon'; +import type { BlockEditProps, BlockSaveProps } from './block-props'; +import type { BlockStyle, BlockSupports } from './block-supports'; +import type { Transform } from './transform'; + +/** + * Core provided {@link BlockType} category type. + * + * Plugins and Themes can also register other custom {@link BlockCategory block categories}. + * + * @public + */ +export type BlockTypeCategory = + | 'text' + | 'media' + | 'design' + | 'widgets' + | 'theme' + | 'embed'; + +/** + * Internal type for the innerBlocks property inside of the example + * + * @see BlockType.example + * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55245#discussion_r692208988} + * @internal + */ +export type BlockExampleInnerBlock = Partial< BlockType > & + Pick< BlockType, 'name' | 'attributes' > & { + innerBlocks?: BlockExampleInnerBlock[]; + }; + +/** + * Configuration of a {@link BlockType}. + * + * Used by `registerBlockType` in [registration.js](../api/registration.js) + * + * @public + */ +export type BlockConfiguration< + Attributes extends Record< string, any > = {}, +> = Partial< Omit< BlockType< Attributes >, 'icon' > > & + Pick< BlockType< Attributes >, 'attributes' | 'category' | 'title' > & { + icon?: BlockIcon; + }; + +/** + * Defined behavior of a block type. + * + * @memberof module:blocks/BlockType + * @public + */ +export interface BlockType< Attributes extends Record< string, any > = {} > { + /** + * The version of the Block API used by the block. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#api-version} + */ + apiVersion?: number; + + /** + * Attributes for the block. + */ + attributes: { + [ k in keyof Attributes ]: BlockAttribute< + Attributes[ k ] extends Array< infer U > ? U : Attributes[ k ] + >; + }; + + /** + * The block category (determines placement in the inserter). + */ + category: BlockTypeCategory; + + /** + * Array of deprecation handlers for the block. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-deprecation/ Deprecation} + */ + deprecated?: BlockDeprecation< Attributes >[]; + + /** + * This is a short description for your block, which can be translated + * with our translation functions. + */ + description?: string; + + /** + * Component to render in the editor. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit Edit and Save} on developer.wordpress.org + */ + edit?: ComponentType< BlockEditProps< Attributes > >; + + /** + * Block type editor script definition. + * It will only be enqueued in the context of the editor. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-script} + */ + editorScript?: string; + + /** + * Block type editor style definition. + * It will only be enqueued in the context of the editor. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style} + */ + editorStyle?: string; + + /** + * It provides structured example data for the block. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#example} + */ + + example?: Partial< BlockType > & { + innerBlocks?: BlockExampleInnerBlock[]; + }; + + /** + * Icon for the block. + */ + icon: BlockIconNormalized; + + /** + * Searchable keywords for discovery. + */ + keywords?: string[]; + + /** + * Setting `parent` lets a block require that it is only available when + * nested within the specified blocks. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#parent} + */ + parent?: string[]; + + /** + * Setting `ancestor` lets a block require that it is only available when + * nested within the specified blocks. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#ancestor} + */ + ancestor?: string[]; + + /** + * Context provided for available access by descendants of blocks of this + * type, in the form of an object which maps a context name to one of the + * block’s own attribute. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#provides-context} + */ + providesContext?: Record< string, keyof Attributes >; + + /** + * This is set internally when registering the type. + */ + name: string; + + /** + * Component to render on the frontend. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit Edit and Save} on developer.wordpress.org + */ + save: ComponentType< BlockSaveProps< Attributes > >; + + /** + * Block type frontend script definition. + * It will be enqueued both in the editor and when viewing the content on + * the front of the site. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#script} + */ + script?: string; + + /** + * Block type editor style definition. + * It will only be enqueued in the context of the editor. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style} + */ + style?: string; + + /** + * Block styles. + * + * @see {@link https://wordpress.org/gutenberg/handbook/extensibility/extending-blocks/#block-style-variations} + */ + styles?: BlockStyle[]; + + /** + * Optional block extended support features. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/ Block Supports} on developer.wordpress.org + */ + supports?: BlockSupports; + + /** + * The gettext text domain of the plugin/block. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#text-domain} + */ + textdomain?: string; + + /** + * This is the display title for your block, which can be translated + * with our translation functions. + */ + title: string; + + /** + * Block transformations. + */ + transforms?: + | { + /** + * Transforms from another block type to this block type. + */ + from?: Transform< Attributes >[]; + /** + * Transforms from this block type to another block type. + */ + to?: Transform[]; + /** + * The transformations available for mobile devices. + * + * Used in [factory.js](../api/factory.js) + */ + supportedMobileTransforms?: string[]; + } + | undefined; + + /** + * Array of the names of context values to inherit from an ancestor + * provider. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#context} + */ + usesContext?: string[]; + + /** + * The current version number of the block, such as 1.0 or 1.0.3. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#version} + */ + version?: string; + + /** + * Sets attributes on the topmost parent element of the current block. + */ + getEditWrapperProps?: ( + attrs: Attributes + ) => Record< string, string | number | boolean >; + + /** + * A function that defines how new attributes are merged with existing ones. + * + * Used in [paragraph](../../../block-library/src/paragraph/index.js) + */ + merge?: ( + attributes: Attributes, + attributesToMerge: Attributes + ) => Partial< Attributes >; + + /** + * Custom block label callback function + * + * @internal + */ + __experimentalLabel: ( + attributes: BlockAttributes, + settings: { context: 'accessibility' | 'visual' } // TODO find all context types + ) => string; +} diff --git a/packages/blocks/src/types/block-variation.ts b/packages/blocks/src/types/block-variation.ts new file mode 100644 index 00000000000000..a51c142762cfa3 --- /dev/null +++ b/packages/blocks/src/types/block-variation.ts @@ -0,0 +1,115 @@ +/** + * Internal dependencies + */ +import type { Block } from './block'; +import type { BlockAttributes } from './block-attributes'; +import type { BlockIcon } from './block-icon'; +import type { BlockExampleInnerBlock, BlockType } from './block-type'; +/** + * Type to scope where a variation is applicable. + * + * @public + */ +export type BlockVariationScope = 'block' | 'inserter' | 'transform'; + +/** + * TODO Undocumented + * + * @public + */ +export type InnerBlockTemplate = [ + string, + BlockAttributes?, + InnerBlockTemplate[]?, +]; + +/** + * Describes a related variations of a {@link BlockType}. + * + * Differentiated by setting some initial attributes or inner blocks. + * + * Used in [registration.js](../api/registration.js) + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/ Block Variations} + * @public + */ +export interface BlockVariation< + Attributes extends BlockAttributes = BlockAttributes, +> { + /** + * The unique and machine-readable name. + */ + name: string; + + /** + * A human-readable variation title. + */ + title: string; + + /** + * A detailed variation description. + */ + description?: string; + + /** + * Block type category classification, used in search interfaces to arrange block types by category. + */ + category?: string; + + /** + * An icon helping to visualize the variation. + */ + icon?: BlockIcon; + + /** + * Indicates whether the current variation is the default one. Defaults to `false`. + */ + isDefault?: boolean; + + /** + * Values which override block attributes. + */ + attributes?: Attributes; + + /** + * Initial configuration of nested blocks. + */ + innerBlocks?: Block | InnerBlockTemplate[]; + + /** + * Example provides structured data for the block preview. You can set to `undefined` to disable + * the preview shown for the block type. + */ + example?: + | BlockExampleInnerBlock + | { + attributes: Attributes; + innerBlocks?: InnerBlockTemplate[]; + }; + + /** + * The list of scopes where the variation is applicable. When not provided, it assumes all available scopes. + */ + scope?: BlockVariationScope[]; + + /** + * An array of terms (which can be translated) that help users discover the variation while searching. + */ + keywords?: string[]; + + /** + * This can be a function or an array of block attributes. Function that accepts a block's + * attributes and the variation's attributes and determines if a variation is active. This + * function doesn't try to find a match dynamically based on all block's attributes, as in many + * cases some attributes are irrelevant. An example would be for `embed` block where we only care + * about `providerNameSlug` attribute's value. We can also use a `string[]` to tell which + * attributes should be compared as a shorthand. Each attributes will be matched and the variation + * will be active if all of them are matching. + */ + isActive?: + | ( ( + blockAttributes: Attributes, + variationAttributes: Attributes + ) => boolean ) + | string[]; +} diff --git a/packages/blocks/src/types/block.ts b/packages/blocks/src/types/block.ts new file mode 100644 index 00000000000000..1f75b1aeb4d20e --- /dev/null +++ b/packages/blocks/src/types/block.ts @@ -0,0 +1,87 @@ +/** + * Block Interface + * + * @module blocks/Block + */ + +/** + * Internal dependencies + */ +import type { BlockNode } from './block-node'; + +/** + * Instance of a [BlockType](./block-type.ts). + * + * @public + */ +export interface Block< Attributes extends Record< string, any > = {} > { + /** + * Name used to uniquely identify block type, e.g. core/paragraph. + * + * The block name comprises a namespace part and a name part separated + * by a "/". The namespace is usually the name of the plugin providing + * the block, for example, "myplugin/my-interesting-block". + * + * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#block-name + */ + name: string; + + /** + * Description of block's attribute types. + * + * These define how to source the attributes for a block and + * may provide default values in case they aren't available. + * + * Example + * { + * "url": { + * "type": "string", + * "source": "attribute", + * "selector": "img", + * "attribute": "src" + * } + * } + * + * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/ + */ + attributes: Attributes; + + /** + * Auto-generated ID unique to the loaded block inside the editor. + * + * Many functions in the editor reference blocks by their client id + * in order to modify or rearrange blocks. This is set when loading + * blocks and does not persist between edit sessions. + * + * Example: + * const clientId = select( blockEditorStore ).getSelectedBlockClientId(); + * const prevId = select( blockEditorStore ).getPreviousBlockClientId( clientId ); + * useDispatch( blockEditorStore ).replaceBlock( prevId, newBlock ); + */ + clientId: string; + + /** + * Array of inner blocks, if the block has any. + */ + innerBlocks: Block[]; + + /** + * Indicates whether or not the block is valid. + */ + isValid: boolean; + + /** + * Original block HTML from source document, used by the unrecognized block type. + */ + originalContent?: string; + + /** + * Contains descriptions of any block validation issues that appear in loading the block. + */ + validationIssues?: Array< Record< string, any > >; + + /** + * Un-processed original copy of block, used for preserving invalid blocks. + */ + __unstableBlockSource?: BlockNode; +} diff --git a/packages/blocks/src/types/index.ts b/packages/blocks/src/types/index.ts new file mode 100644 index 00000000000000..371236544cfcd7 --- /dev/null +++ b/packages/blocks/src/types/index.ts @@ -0,0 +1,12 @@ +export * from './block-attributes'; +export * from './block-category'; +export * from './block-collection'; +export * from './block-deprecation'; +export * from './block-icon'; +export * from './block-node'; +export * from './block-props'; +export * from './block-supports'; +export * from './block-type'; +export * from './block-variation'; +export * from './block'; +export * from './transform'; diff --git a/packages/blocks/src/types/transform.ts b/packages/blocks/src/types/transform.ts new file mode 100644 index 00000000000000..39423e4ff676c2 --- /dev/null +++ b/packages/blocks/src/types/transform.ts @@ -0,0 +1,164 @@ +/** + * Block Transform Interfaces + * + * @module blocks/Transform + */ + +/** + * Internal dependencies + */ +import type { Block } from './block'; +import type { BlockType } from './block-type'; + +/** + * A content model used to validate and process pasted {@link TransformRaw raw} content. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#schemas-and-content-models Transforms Schema and Content Models} on developer.wordpress.org + * @public + */ +export type TransformRawSchema = { + [ k in keyof HTMLElementTagNameMap | '#text' ]?: { + attributes?: string[]; + require?: Array< keyof HTMLElementTagNameMap >; + classes?: Array< string | RegExp >; + children?: TransformRawSchema; + }; +}; + +/** + * Transform block into a different {@link BlockType }. + * + * Supports both _from_ and _to_ directions. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#block Transforms Block} on developer.wordpress.org + * @public + */ +export type TransformBlock< Attributes extends Record< string, any > > = { + type: 'block'; + blocks: string[]; + isMatch?: ( attributes: Attributes, block: string | string[] ) => boolean; + isMultiBlock?: boolean; + transform: ( attributes: Attributes ) => Block< Partial< Attributes > >; +}; + +/** + * Transform allowing blocks to be created from content introduced by the user. + * + * Supports the _from_ direction. Applied in a new block line after the user has introduced some + * content and hit the ENTER key. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#enter Transforms Enter} on developer.wordpress.org + * @public + */ +export type TransformEnter< Attributes extends Record< string, any > > = { + type: 'enter'; + regExp: RegExp; + transform: () => Block< Partial< Attributes > >; +}; + +/** + * Transform allowing blocks to be created from files dropped into the editor. + * + * Supports the _from_ direction, + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#files Transforms Files} on developer.wordpress.org + * @public + */ +export type TransformFiles< Attributes extends Record< string, any > > = { + type: 'files'; + isMatch?: ( files: FileList ) => boolean; + transform: ( + files: FileList, + onChange?: ( id: string, attrs: Attributes ) => void + ) => Block< Partial< Attributes > >; +}; + +/** + * Transform allowing blocks to be created from text typed by the user. + * + * Supports the _from_ direction. Applied when, in a new block line, the user types some text and + * then adds a trailing space. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#prefix Transforms Prefix} on developer.wordpress.org + * @public + */ +export type TransformPrefix< Attributes extends Record< string, any > > = { + type: 'prefix'; + prefix: string; + transform: ( content: string ) => Block< Partial< Attributes > >; +}; + +/** + * Transform allowing blocks to be created from raw HTML nodes. + * + * Supports the _from_ direction. Applied when the user executes the “Convert to Blocks” action + * from within the block setting UI menu, as well as when some content is pasted or dropped into + * the editor. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#raw Transforms Raw} on developer.wordpress.org + * @public + */ +export type TransformRaw< Attributes extends Record< string, any > > = { + type: 'raw'; + /** + * Comma-separated list of selectors, no spaces. + * + * @example 'p,div,h1,.css-class,#id' + */ + selector?: string; + schema?: TransformRawSchema; + isMatch?: ( node: Node ) => boolean; + transform?: ( node: Node ) => Block< Partial< Attributes > > | void; +}; + +/** + * Transform allowing blocks to be created from shortcodes. + * + * Support the _from_ direction. Applied as part of the raw transformation process. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#shortcode Transforms Shortcode} on developer.wordpress.org + * @public + */ +export type TransformShortcode< Attributes extends Record< string, any > > = { + type: 'shortcode'; + tag: string; + transform?: ( + attributes: any, + match: Record< string, any > // TODO type shortcode + ) => Block< Attributes >; + attributes?: any; // TODO find type +}; + +/** + * Transform a block to and from other blocks types, as well as from other entities. + * + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/ Transforms} on developer.wordpress.org + * @public + */ +export type Transform< T extends Record< string, any > = {} > = ( + | TransformBlock< T > + | TransformEnter< T > + | TransformFiles< T > + | TransformPrefix< T > + | TransformRaw< T > + | TransformShortcode< T > +) & { + priority?: number; + + /** + * Whether there are any mobile block transforms. + * + * Used in [factory.js](../api/factory.js) + */ + usingMobileTransformations?: boolean; + + /** + * Function that defines how blocks are transformed from particular block types. + * + * @param blocks Block or Blocks to convert. + * @internal + */ + __experimentalConvert: ( + blocks: Block | Block[] + ) => Block | Block[] | null; +}; diff --git a/packages/blocks/tsconfig.json b/packages/blocks/tsconfig.json new file mode 100644 index 00000000000000..ba86c49dbd19a4 --- /dev/null +++ b/packages/blocks/tsconfig.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "build-types", + "noUnusedParameters": false, + "checkJs": false, + "noImplicitAny": false + }, + "references": [ + { "path": "../autop" }, + { "path": "../blob" }, + { "path": "../block-serialization-default-parser" }, + { "path": "../compose" }, + { "path": "../data" }, + { "path": "../deprecated" }, + { "path": "../dom" }, + { "path": "../element" }, + { "path": "../hooks" }, + { "path": "../html-entities" }, + { "path": "../i18n" }, + { "path": "../is-shallow-equal" }, + { "path": "../private-apis" }, + { "path": "../rich-text" }, + { "path": "../shortcode" }, + { "path": "../warning" } + ], + + "include": [ "src/**/*", "src/api/i18n-block.json" ] +} diff --git a/packages/core-data/tsconfig.json b/packages/core-data/tsconfig.json index 26602d82ab0c01..2b5bafcd993751 100644 --- a/packages/core-data/tsconfig.json +++ b/packages/core-data/tsconfig.json @@ -11,6 +11,7 @@ { "path": "../api-fetch" }, { "path": "../compose" }, { "path": "../block-editor" }, + { "path": "../blocks" }, { "path": "../data" }, { "path": "../deprecated" }, { "path": "../element" }, diff --git a/packages/editor/tsconfig.json b/packages/editor/tsconfig.json index 3c45fbcb10db3d..c3bebea2c1024f 100644 --- a/packages/editor/tsconfig.json +++ b/packages/editor/tsconfig.json @@ -11,6 +11,7 @@ { "path": "../api-fetch" }, { "path": "../blob" }, { "path": "../block-editor" }, + { "path": "../blocks" }, { "path": "../components" }, { "path": "../compose" }, { "path": "../core-data" }, diff --git a/packages/fields/tsconfig.json b/packages/fields/tsconfig.json index 46ac86d48e11ee..35a9d70542ab6c 100644 --- a/packages/fields/tsconfig.json +++ b/packages/fields/tsconfig.json @@ -9,6 +9,7 @@ "references": [ { "path": "../api-fetch" }, { "path": "../blob" }, + { "path": "../blocks" }, { "path": "../components" }, { "path": "../compose" }, { "path": "../core-data" }, diff --git a/tsconfig.json b/tsconfig.json index 93d0bd976dd005..a5d65c08b3f352 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ { "path": "packages/api-fetch" }, { "path": "packages/autop" }, { "path": "packages/blob" }, + { "path": "packages/blocks" }, { "path": "packages/block-editor" }, { "path": "packages/block-library" }, { "path": "packages/block-serialization-default-parser" },