Skip to content

Commit

Permalink
Add ES5 examples back
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Mar 8, 2019
1 parent aab707b commit 2c62df1
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 3 deletions.
54 changes: 54 additions & 0 deletions packages/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ A component that renders all plugin fills in a hidden div.

**Usage**

```js
var el = wp.element.createElement;
var PluginArea = wp.plugins.PluginArea;

function Layout() {
return el(
'div',
{},
'Content of the page',
PluginArea
);
}
```

```js
const { PluginArea } = wp.plugins;

Expand All @@ -71,6 +85,40 @@ Registers a plugin to the editor.

**Usage**

```js
var el = wp.element.createElement;
var Fragment = wp.element.Fragment;
var PluginSidebar = wp.editPost.PluginSidebar;
var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
var registerPlugin = wp.plugins.registerPlugin;

function Component() {
return el(
Fragment,
{},
el(
PluginSidebarMoreMenuItem,
{
target: 'sidebar-name',
},
'My Sidebar'
),
el(
PluginSidebar,
{
name: 'sidebar-name',
title: 'My Sidebar',
},
'Content of the sidebar'
)
);
}
registerPlugin( 'plugin-name', {
icon: 'smiley',
render: Component,
} );
```

```js
const { Fragment } = wp.element;
const { PluginSidebar, PluginSidebarMoreMenuItem } = wp.editPost;
Expand Down Expand Up @@ -117,6 +165,12 @@ Unregisters a plugin by name.

**Usage**

```js
var unregisterPlugin = wp.plugins.unregisterPlugin;

unregisterPlugin( 'plugin-name' );
```

```js
const { unregisterPlugin } = wp.plugins;
unregisterPlugin( 'plugin-name' );
Expand Down
46 changes: 44 additions & 2 deletions packages/plugins/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,42 @@ const plugins = {};
* or an element (or function returning an element) if you choose to render your own SVG.
* @param {Function} settings.render A component containing the UI elements to be rendered.
*
* @example
* @example <caption>ES5</caption>
* ```js
* var el = wp.element.createElement;
* var Fragment = wp.element.Fragment;
* var PluginSidebar = wp.editPost.PluginSidebar;
* var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
* var registerPlugin = wp.plugins.registerPlugin;
*
* function Component() {
* return el(
* Fragment,
* {},
* el(
* PluginSidebarMoreMenuItem,
* {
* target: 'sidebar-name',
* },
* 'My Sidebar'
* ),
* el(
* PluginSidebar,
* {
* name: 'sidebar-name',
* title: 'My Sidebar',
* },
* 'Content of the sidebar'
* )
* );
* }
* registerPlugin( 'plugin-name', {
* icon: 'smiley',
* render: Component,
* } );
* ```
*
* @example <caption>ESNext</caption>
* ```js
* const { Fragment } = wp.element;
* const { PluginSidebar, PluginSidebarMoreMenuItem } = wp.editPost;
Expand Down Expand Up @@ -106,7 +141,14 @@ export function registerPlugin( name, settings ) {
*
* @param {string} name Plugin name.
*
* @example
* @example <caption>ES5</caption>
* ```js
* var unregisterPlugin = wp.plugins.unregisterPlugin;
*
* unregisterPlugin( 'plugin-name' );
* ```
*
* @example <caption>ESNext</caption>
* ```js
* const { unregisterPlugin } = wp.plugins;
* unregisterPlugin( 'plugin-name' );
Expand Down
17 changes: 16 additions & 1 deletion packages/plugins/src/components/plugin-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ import { getPlugins } from '../../api';
/**
* A component that renders all plugin fills in a hidden div.
*
* @example
* @example <caption>ES5</caption>
* ```js
* var el = wp.element.createElement;
* var PluginArea = wp.plugins.PluginArea;
*
* function Layout() {
* return el(
* 'div',
* {},
* 'Content of the page',
* PluginArea
* );
* }
* ```
*
* @example <caption>ESNext</caption>
* ```js
* const { PluginArea } = wp.plugins;
*
Expand Down

0 comments on commit 2c62df1

Please sign in to comment.