6.0.0 • Published 1 month ago

@types/wordpress__plugins v6.0.0

Weekly downloads
3,012
License
MIT
Repository
-
Last release
1 month ago

Installation

npm install --save @types/wordpress__plugins

Summary

This package contains type definitions for @wordpress/plugins (https://github.com/WordPress/gutenberg/tree/master/packages/plugins/README.md).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/wordpress__plugins.

index.d.ts

// Type definitions for @wordpress/plugins 3.0
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/plugins/README.md
// Definitions by: Derek Sifford <https://github.com/dsifford>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.6

import { Dashicon } from '@wordpress/components';
import { ComponentType } from 'react';

export interface PluginSettings {
    /**
     * An icon to be shown in the UI. It can be a slug of the Dashicon, or an
     * element (or function returning an element) if you choose to render your
     * own SVG.
     */
    icon: Dashicon.Icon | ComponentType;
    /**
     * A component containing the UI elements to be rendered.
     */
    render: ComponentType;
}

export interface Plugin extends PluginSettings {
    /**
     * A string identifying the plugin. Must be unique across all registered
     * plugins.
     */
    name: string;
}

export type PluginContext = Omit<Plugin, 'render'>;

/**
 * A component that renders all plugin fills in a hidden div.
 */
export const PluginArea: ComponentType;

/**
 * Returns a registered plugin settings.
 *
 * @param name - Plugin name.
 */
export function getPlugin(name: string): Plugin | undefined;

/**
 * Returns all registered plugins.
 */
export function getPlugins(): Plugin[];

/**
 * Registers a plugin to the editor.
 *
 * @param name - A string identifying the plugin. Must be unique across all registered plugins.
 * @param settings - The settings for this plugin.
 * @returns The final plugin settings object.
 */
export function registerPlugin(name: string, settings: PluginSettings): PluginSettings;

/**
 * Unregisters a plugin by name.
 *
 * @param name - Plugin name.
 * @returns The previous plugin settings object, if it has been successfully
 *     unregistered; otherwise `undefined`.
 */
export function unregisterPlugin(name: string): Plugin | undefined;

/**
 * A Higher Order Component used to inject Plugin context to the wrapped component.
 */
export function withPluginContext<CP = {}, OP = {}>(
    mapContextToProps: (context: PluginContext, props: OP) => CP
): (Component: ComponentType<CP & OP>) => ComponentType<OP>;

Additional Details

Credits

These definitions were written by Derek Sifford.

6.0.0

1 month ago

3.0.3

6 months ago

3.0.2

7 months ago

3.0.1

8 months ago

3.0.0

3 years ago

2.3.7

4 years ago

2.3.6

4 years ago

2.3.5

4 years ago

2.3.4

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago