@wordpress/plugins 6.22.0 → 6.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +3 -3
- package/build/api/index.js +7 -3
- package/build/api/index.js.map +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/plugin-area/index.js.map +1 -1
- package/build/components/plugin-context/index.js +4 -0
- package/build/components/plugin-context/index.js.map +1 -1
- package/build/components/plugin-error-boundary/index.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build-module/api/index.js +8 -3
- package/build-module/api/index.js.map +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/plugin-area/index.js.map +1 -1
- package/build-module/components/plugin-context/index.js.map +1 -1
- package/build-module/components/plugin-error-boundary/index.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-types/api/index.d.ts +3 -3
- package/build-types/components/plugin-context/index.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/api/index.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -88,8 +88,8 @@ _Usage_
|
|
|
88
88
|
// Using ES5 syntax
|
|
89
89
|
var el = React.createElement;
|
|
90
90
|
var Fragment = wp.element.Fragment;
|
|
91
|
-
var PluginSidebar = wp.
|
|
92
|
-
var PluginSidebarMoreMenuItem = wp.
|
|
91
|
+
var PluginSidebar = wp.editor.PluginSidebar;
|
|
92
|
+
var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
|
93
93
|
var registerPlugin = wp.plugins.registerPlugin;
|
|
94
94
|
var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
95
95
|
|
|
@@ -123,7 +123,7 @@ registerPlugin( 'plugin-name', {
|
|
|
123
123
|
|
|
124
124
|
```js
|
|
125
125
|
// Using ESNext syntax
|
|
126
|
-
import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/
|
|
126
|
+
import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
|
|
127
127
|
import { registerPlugin } from '@wordpress/plugins';
|
|
128
128
|
import { more } from '@wordpress/icons';
|
|
129
129
|
|
package/build/api/index.js
CHANGED
|
@@ -18,6 +18,10 @@ var _icons = require("@wordpress/icons");
|
|
|
18
18
|
* WordPress dependencies
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Defined behavior of a plugin type.
|
|
23
|
+
*/
|
|
24
|
+
|
|
21
25
|
/**
|
|
22
26
|
* Plugin definitions keyed by plugin name.
|
|
23
27
|
*/
|
|
@@ -35,8 +39,8 @@ const plugins = {};
|
|
|
35
39
|
* // Using ES5 syntax
|
|
36
40
|
* var el = React.createElement;
|
|
37
41
|
* var Fragment = wp.element.Fragment;
|
|
38
|
-
* var PluginSidebar = wp.
|
|
39
|
-
* var PluginSidebarMoreMenuItem = wp.
|
|
42
|
+
* var PluginSidebar = wp.editor.PluginSidebar;
|
|
43
|
+
* var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
|
40
44
|
* var registerPlugin = wp.plugins.registerPlugin;
|
|
41
45
|
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
42
46
|
*
|
|
@@ -71,7 +75,7 @@ const plugins = {};
|
|
|
71
75
|
* @example
|
|
72
76
|
* ```js
|
|
73
77
|
* // Using ESNext syntax
|
|
74
|
-
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/
|
|
78
|
+
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
|
|
75
79
|
* import { registerPlugin } from '@wordpress/plugins';
|
|
76
80
|
* import { more } from '@wordpress/icons';
|
|
77
81
|
*
|
package/build/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_hooks","require","_icons","plugins","registerPlugin","name","settings","console","error","test","applyFilters","render","scope","icon","pluginsIcon","doAction","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.
|
|
1
|
+
{"version":3,"names":["_hooks","require","_icons","plugins","registerPlugin","name","settings","console","error","test","applyFilters","render","scope","icon","pluginsIcon","doAction","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.editor.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var moreIcon = React.createElement( 'svg' ); //... svg element.\n *\n * function Component() {\n * \treturn el(\n * \t\tFragment,\n * \t\t{},\n * \t\tel(\n * \t\t\tPluginSidebarMoreMenuItem,\n * \t\t\t{\n * \t\t\t\ttarget: 'sidebar-name',\n * \t\t\t},\n * \t\t\t'My Sidebar'\n * \t\t),\n * \t\tel(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'sidebar-name',\n * \t\t\t\ttitle: 'My Sidebar',\n * \t\t\t},\n * \t\t\t'Content of the sidebar'\n * \t\t)\n * \t);\n * }\n * registerPlugin( 'plugin-name', {\n * \ticon: moreIcon,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';\n * import { registerPlugin } from '@wordpress/plugins';\n * import { more } from '@wordpress/icons';\n *\n * const Component = () => (\n * \t<>\n * \t\t<PluginSidebarMoreMenuItem\n * \t\t\ttarget=\"sidebar-name\"\n * \t\t>\n * \t\t\tMy Sidebar\n * \t\t</PluginSidebarMoreMenuItem>\n * \t\t<PluginSidebar\n * \t\t\tname=\"sidebar-name\"\n * \t\t\ttitle=\"My Sidebar\"\n * \t\t>\n * \t\t\tContent of the sidebar\n * \t\t</PluginSidebar>\n * \t</>\n * );\n *\n * registerPlugin( 'plugin-name', {\n * \ticon: more,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @return The final plugin settings object.\n */\nexport function registerPlugin(\n\tname: string,\n\tsettings: PluginSettings\n): PluginSettings | null {\n\tif ( typeof settings !== 'object' ) {\n\t\tconsole.error( 'No settings object provided!' );\n\t\treturn null;\n\t}\n\tif ( typeof name !== 'string' ) {\n\t\tconsole.error( 'Plugin name must be string.' );\n\t\treturn null;\n\t}\n\tif ( ! /^[a-z][a-z0-9-]*$/.test( name ) ) {\n\t\tconsole.error(\n\t\t\t'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-plugin\".'\n\t\t);\n\t\treturn null;\n\t}\n\tif ( plugins[ name ] ) {\n\t\tconsole.error( `Plugin \"${ name }\" is already registered.` );\n\t}\n\n\tsettings = applyFilters(\n\t\t'plugins.registerPlugin',\n\t\tsettings,\n\t\tname\n\t) as PluginSettings;\n\n\tconst { render, scope } = settings;\n\n\tif ( typeof render !== 'function' ) {\n\t\tconsole.error(\n\t\t\t'The \"render\" property must be specified and must be a valid function.'\n\t\t);\n\t\treturn null;\n\t}\n\n\tif ( scope ) {\n\t\tif ( typeof scope !== 'string' ) {\n\t\t\tconsole.error( 'Plugin scope must be string.' );\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( ! /^[a-z][a-z0-9-]*$/.test( scope ) ) {\n\t\t\tconsole.error(\n\t\t\t\t'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-page\".'\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tplugins[ name ] = {\n\t\tname,\n\t\ticon: pluginsIcon,\n\t\t...settings,\n\t};\n\n\tdoAction( 'plugins.pluginRegistered', settings, name );\n\n\treturn settings;\n}\n\n/**\n * Unregisters a plugin by name.\n *\n * @param name Plugin name.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var unregisterPlugin = wp.plugins.unregisterPlugin;\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { unregisterPlugin } from '@wordpress/plugins';\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @return The previous plugin settings object, if it has been\n * successfully unregistered; otherwise `undefined`.\n */\nexport function unregisterPlugin( name: string ): WPPlugin | undefined {\n\tif ( ! plugins[ name ] ) {\n\t\tconsole.error( 'Plugin \"' + name + '\" is not registered.' );\n\t\treturn;\n\t}\n\tconst oldPlugin = plugins[ name ];\n\tdelete plugins[ name ];\n\n\tdoAction( 'plugins.pluginUnregistered', oldPlugin, name );\n\n\treturn oldPlugin;\n}\n\n/**\n * Returns a registered plugin settings.\n *\n * @param name Plugin name.\n *\n * @return Plugin setting.\n */\nexport function getPlugin( name: string ): WPPlugin | undefined {\n\treturn plugins[ name ];\n}\n\n/**\n * Returns all registered plugins without a scope or for a given scope.\n *\n * @param scope The scope to be used when rendering inside\n * a plugin area. No scope by default.\n *\n * @return The list of plugins without a scope or for a given scope.\n */\nexport function getPlugins( scope?: string ): WPPlugin[] {\n\treturn Object.values( plugins ).filter(\n\t\t( plugin ) => plugin.scope === scope\n\t);\n}\n"],"mappings":";;;;;;;;;AASA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAVA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AA4BA;AACA;AACA;AACA,MA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]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_pluginArea","_interopRequireDefault","require","_pluginContext"],"sources":["@wordpress/plugins/src/components/index.js"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA"}
|
|
1
|
+
{"version":3,"names":["_pluginArea","_interopRequireDefault","require","_pluginContext"],"sources":["@wordpress/plugins/src/components/index.js"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_memize","_interopRequireDefault","require","_element","_hooks","_isShallowEqual","_pluginContext","_pluginErrorBoundary","_api","getPluginContext","memoize","icon","name","PluginArea","scope","onError","store","useMemo","lastValue","subscribe","listener","addAction","removeAction","getValue","nextValue","getPlugins","isShallowEqual","plugins","useSyncExternalStore","_react","createElement","style","display","map","render","Plugin","PluginContextProvider","key","value","PluginErrorBoundary","_default","exports","default"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAKA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAOA,MAAMO,gBAAgB,GAAG,IAAAC,eAAO,EAC/B,CAAEC,IAA6B,EAAEC,IAA6B,MAAQ;EACrED,IAAI;EACJC;AACD,CAAC,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AG,GAExC,IAAAiB,MAAA,CAAAC,aAAA,EAACvB,oBAAA,CAAAgC,mBAAmB;IAAC3B,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrD,IAAAc,MAAA,CAAAC,aAAA,EAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc7B,UAAU"}
|
|
1
|
+
{"version":3,"names":["_memize","_interopRequireDefault","require","_element","_hooks","_isShallowEqual","_pluginContext","_pluginErrorBoundary","_api","getPluginContext","memoize","icon","name","PluginArea","scope","onError","store","useMemo","lastValue","subscribe","listener","addAction","removeAction","getValue","nextValue","getPlugins","isShallowEqual","plugins","useSyncExternalStore","_react","createElement","style","display","map","render","Plugin","PluginContextProvider","key","value","PluginErrorBoundary","_default","exports","default"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAKA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAOA,MAAMO,gBAAgB,GAAG,IAAAC,eAAO,EAC/B,CAAEC,IAA6B,EAAEC,IAA6B,MAAQ;EACrED,IAAI;EACJC;AACD,CAAC,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAE;EACpBC,KAAK;EACLC;AAID,CAAC,EAAG;EACH,MAAMC,KAAK,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC5B,IAAIC,SAAqB,GAAG,EAAE;IAE9B,OAAO;MACNC,SAASA,CACRC,QAGS,EACR;QACD,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,6CAA6C,EAC7CD,QACD,CAAC;QACD,IAAAC,g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Context","createContext","name","icon","PluginContextProvider","exports","Provider","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","props","_react","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","Context","createContext","name","icon","PluginContextProvider","exports","Provider","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","props","_react","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAME,OAAO,GAAG,IAAAC,sBAAa,EAAmB;EAC/CC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEI,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAGJ,OAAO,CAACM,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAO,IAAAC,mBAAU,EAAER,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,iBAAiB,GAC7BC,iBAGsB,IAEtB,IAAAC,mCAA0B,EAAIC,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACb,IAAAC,MAAA,CAAAC,aAAA,EAACf,OAAO,CAACgB,QAAQ,QACZC,OAAO,IACV,IAAAH,MAAA,CAAAC,aAAA,EAACH,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLH,iBAAiB,CAAEO,OAAO,EAAEJ,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC;AAACR,OAAA,CAAAI,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","PluginErrorBoundary","Component","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children","exports"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\nexport class PluginErrorBoundary extends Component {\n\t/**\n\t * @param {Object} props\n\t */\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError() {\n\t\treturn { hasError: true };\n\t}\n\n\t/**\n\t * @param {Error} error Error object passed by React.\n\t */\n\tcomponentDidCatch( error ) {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,mBAAmB,SAASC,kBAAS,CAAC;EAClD;AACD;AACA;EACCC,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAG;IACjC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;;EAEA;AACD;AACA;EACCE,iBAAiBA,CAAEC,KAAK,EAAG;IAC1B,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAG;IACR,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD;AAACC,OAAA,CAAAb,mBAAA,GAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","PluginErrorBoundary","Component","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children","exports"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\nexport class PluginErrorBoundary extends Component {\n\t/**\n\t * @param {Object} props\n\t */\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError() {\n\t\treturn { hasError: true };\n\t}\n\n\t/**\n\t * @param {Error} error Error object passed by React.\n\t */\n\tcomponentDidCatch( error ) {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,mBAAmB,SAASC,kBAAS,CAAC;EAClD;AACD;AACA;EACCC,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAG;IACjC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;;EAEA;AACD;AACA;EACCE,iBAAiBA,CAAEC,KAAK,EAAG;IAC1B,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAG;IACR,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD;AAACC,OAAA,CAAAb,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_api"],"sources":["@wordpress/plugins/src/index.js"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,IAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,IAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,IAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,IAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_api"],"sources":["@wordpress/plugins/src/index.js"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,IAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,IAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,IAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,IAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { applyFilters, doAction } from '@wordpress/hooks';
|
|
10
10
|
import { plugins as pluginsIcon } from '@wordpress/icons';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Defined behavior of a plugin type.
|
|
14
|
+
*/
|
|
15
|
+
|
|
11
16
|
/**
|
|
12
17
|
* Plugin definitions keyed by plugin name.
|
|
13
18
|
*/
|
|
@@ -25,8 +30,8 @@ const plugins = {};
|
|
|
25
30
|
* // Using ES5 syntax
|
|
26
31
|
* var el = React.createElement;
|
|
27
32
|
* var Fragment = wp.element.Fragment;
|
|
28
|
-
* var PluginSidebar = wp.
|
|
29
|
-
* var PluginSidebarMoreMenuItem = wp.
|
|
33
|
+
* var PluginSidebar = wp.editor.PluginSidebar;
|
|
34
|
+
* var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
|
30
35
|
* var registerPlugin = wp.plugins.registerPlugin;
|
|
31
36
|
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
32
37
|
*
|
|
@@ -61,7 +66,7 @@ const plugins = {};
|
|
|
61
66
|
* @example
|
|
62
67
|
* ```js
|
|
63
68
|
* // Using ESNext syntax
|
|
64
|
-
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/
|
|
69
|
+
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
|
|
65
70
|
* import { registerPlugin } from '@wordpress/plugins';
|
|
66
71
|
* import { more } from '@wordpress/icons';
|
|
67
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["applyFilters","doAction","plugins","pluginsIcon","registerPlugin","name","settings","console","error","test","render","scope","icon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.
|
|
1
|
+
{"version":3,"names":["applyFilters","doAction","plugins","pluginsIcon","registerPlugin","name","settings","console","error","test","render","scope","icon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.editor.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var moreIcon = React.createElement( 'svg' ); //... svg element.\n *\n * function Component() {\n * \treturn el(\n * \t\tFragment,\n * \t\t{},\n * \t\tel(\n * \t\t\tPluginSidebarMoreMenuItem,\n * \t\t\t{\n * \t\t\t\ttarget: 'sidebar-name',\n * \t\t\t},\n * \t\t\t'My Sidebar'\n * \t\t),\n * \t\tel(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'sidebar-name',\n * \t\t\t\ttitle: 'My Sidebar',\n * \t\t\t},\n * \t\t\t'Content of the sidebar'\n * \t\t)\n * \t);\n * }\n * registerPlugin( 'plugin-name', {\n * \ticon: moreIcon,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';\n * import { registerPlugin } from '@wordpress/plugins';\n * import { more } from '@wordpress/icons';\n *\n * const Component = () => (\n * \t<>\n * \t\t<PluginSidebarMoreMenuItem\n * \t\t\ttarget=\"sidebar-name\"\n * \t\t>\n * \t\t\tMy Sidebar\n * \t\t</PluginSidebarMoreMenuItem>\n * \t\t<PluginSidebar\n * \t\t\tname=\"sidebar-name\"\n * \t\t\ttitle=\"My Sidebar\"\n * \t\t>\n * \t\t\tContent of the sidebar\n * \t\t</PluginSidebar>\n * \t</>\n * );\n *\n * registerPlugin( 'plugin-name', {\n * \ticon: more,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @return The final plugin settings object.\n */\nexport function registerPlugin(\n\tname: string,\n\tsettings: PluginSettings\n): PluginSettings | null {\n\tif ( typeof settings !== 'object' ) {\n\t\tconsole.error( 'No settings object provided!' );\n\t\treturn null;\n\t}\n\tif ( typeof name !== 'string' ) {\n\t\tconsole.error( 'Plugin name must be string.' );\n\t\treturn null;\n\t}\n\tif ( ! /^[a-z][a-z0-9-]*$/.test( name ) ) {\n\t\tconsole.error(\n\t\t\t'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-plugin\".'\n\t\t);\n\t\treturn null;\n\t}\n\tif ( plugins[ name ] ) {\n\t\tconsole.error( `Plugin \"${ name }\" is already registered.` );\n\t}\n\n\tsettings = applyFilters(\n\t\t'plugins.registerPlugin',\n\t\tsettings,\n\t\tname\n\t) as PluginSettings;\n\n\tconst { render, scope } = settings;\n\n\tif ( typeof render !== 'function' ) {\n\t\tconsole.error(\n\t\t\t'The \"render\" property must be specified and must be a valid function.'\n\t\t);\n\t\treturn null;\n\t}\n\n\tif ( scope ) {\n\t\tif ( typeof scope !== 'string' ) {\n\t\t\tconsole.error( 'Plugin scope must be string.' );\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( ! /^[a-z][a-z0-9-]*$/.test( scope ) ) {\n\t\t\tconsole.error(\n\t\t\t\t'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-page\".'\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tplugins[ name ] = {\n\t\tname,\n\t\ticon: pluginsIcon,\n\t\t...settings,\n\t};\n\n\tdoAction( 'plugins.pluginRegistered', settings, name );\n\n\treturn settings;\n}\n\n/**\n * Unregisters a plugin by name.\n *\n * @param name Plugin name.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var unregisterPlugin = wp.plugins.unregisterPlugin;\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { unregisterPlugin } from '@wordpress/plugins';\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @return The previous plugin settings object, if it has been\n * successfully unregistered; otherwise `undefined`.\n */\nexport function unregisterPlugin( name: string ): WPPlugin | undefined {\n\tif ( ! plugins[ name ] ) {\n\t\tconsole.error( 'Plugin \"' + name + '\" is not registered.' );\n\t\treturn;\n\t}\n\tconst oldPlugin = plugins[ name ];\n\tdelete plugins[ name ];\n\n\tdoAction( 'plugins.pluginUnregistered', oldPlugin, name );\n\n\treturn oldPlugin;\n}\n\n/**\n * Returns a registered plugin settings.\n *\n * @param name Plugin name.\n *\n * @return Plugin setting.\n */\nexport function getPlugin( name: string ): WPPlugin | undefined {\n\treturn plugins[ name ];\n}\n\n/**\n * Returns all registered plugins without a scope or for a given scope.\n *\n * @param scope The scope to be used when rendering inside\n * a plugin area. No scope by default.\n *\n * @return The list of plugins without a scope or for a given scope.\n */\nexport function getPlugins( scope?: string ): WPPlugin[] {\n\treturn Object.values( plugins ).filter(\n\t\t( plugin ) => plugin.scope === scope\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,kBAAkB;AACzD,SAASC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;;AAGzD;AACA;AACA;;AA4BA;AACA;AACA;AACA,MAAMD,OAAO,GAAG,CAAC,CAA+B;;AA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
1
|
-
{"version":3,"names":["default","PluginArea","usePluginContext","withPluginContext"],"sources":["@wordpress/plugins/src/components/index.js"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,eAAe;AACrD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,kBAAkB"}
|
|
1
|
+
{"version":3,"names":["default","PluginArea","usePluginContext","withPluginContext"],"sources":["@wordpress/plugins/src/components/index.js"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,eAAe;AACrD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,kBAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memoize","useMemo","useSyncExternalStore","addAction","removeAction","isShallowEqual","PluginContextProvider","PluginErrorBoundary","getPlugins","getPluginContext","icon","name","PluginArea","scope","onError","store","lastValue","subscribe","listener","getValue","nextValue","plugins","createElement","style","display","map","render","Plugin","key","value"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,OAAO,EAAEC,oBAAoB,QAAQ,oBAAoB;AAClE,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;AAC1D,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,SAASC,qBAAqB,QAAQ,mBAAmB;AACzD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,UAAU,QAAQ,WAAW;AAItC,MAAMC,gBAAgB,GAAGT,OAAO,CAC/B,CAAEU,IAA6B,EAAEC,IAA6B,MAAQ;EACrED,IAAI;EACJC;AACD,CAAC,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAE;EACpBC,KAAK;EACLC;AAID,CAAC,EAAG;EACH,MAAMC,KAAK,GAAGd,OAAO,CAAE,MAAM;IAC5B,IAAIe,SAAqB,GAAG,EAAE;IAE9B,OAAO;MACNC,SAASA,CACRC,QAGS,EACR;QACDf,SAAS,CACR,0BAA0B,EAC1B,6CAA6C,EAC7Ce,QACD,CAAC;QACDf,SAAS,CACR,4BAA4B,EAC5B,+CAA+C,EAC/Ce,QACD,CAAC;QACD,OAAO,MAAM;UACZd,YAAY,CACX,0BAA0B,EAC1B,6CACD,CAAC;UACDA,YAAY,CACX,4BAA4B,EAC5B,+CACD,CAAC;QACF,CAAC;MACF,CAAC;MACDe,QAAQA,CAAA,EAAG;QACV,MAAMC,SAAS,GAAGZ,UAAU,CAAEK,KAAM,CAAC;QAErC,IAAK,CAAER,cAAc,CAAEW,SAAS,EAAEI,SAAU,CAAC,EAAG;UAC/CJ,SAAS,GAAGI,SAAS;QACtB;QAEA,OAAOJ,SAAS;MACjB;IACD,CAAC;EACF,CAAC,EAAE,CAAEH,KAAK,CAAG,CAAC;EAEd,MAAMQ,OAAO,GAAGnB,oBAAoB,CAAEa,KAAK,CAACE,SAAS,EAAEF,KAAK,CAACI,QAAS,CAAC;EAEvE,OACCG,aAAA;IAAKC,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO;EAAG,GAC/BH,OAAO,CAACI,GAAG,CAAE,CAAE;IAAEf,IAAI;IAAEC,IAAI;IAAEe,MAAM,EAAEC;EAAO,CAAC,KAC9CL,aAAA,CAAChB,qBAAqB;IACrBsB,GAAG,EAAGjB,IAAM;IACZkB,KAAK,EAAGpB,gBAAgB,CAAEC,IAAI,EAAEC,IAAK;EAAG,GAExCW,aAAA,CAACf,mBAAmB;IAACI,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrDQ,aAAA,CAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAEA,eAAef,UAAU"}
|
|
1
|
+
{"version":3,"names":["memoize","useMemo","useSyncExternalStore","addAction","removeAction","isShallowEqual","PluginContextProvider","PluginErrorBoundary","getPlugins","getPluginContext","icon","name","PluginArea","scope","onError","store","lastValue","subscribe","listener","getValue","nextValue","plugins","createElement","style","display","map","render","Plugin","key","value"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,OAAO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AO,GAAGnB,oBAAoB,CAAEa,KAAK,CAACE,SAAS,EAAEF,KAAK,CAACI,QAAS,CAAC;EAEvE,OACCG,aAAA;IAAKC,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO;EAAG,GAC/BH,OAAO,CAACI,GAAG,CAAE,CAAE;IAAEf,IAAI;IAAEC,IAAI;IAAEe,MAAM,EAAEC;EAAO,CAAC,KAC9CL,aAAA,CAAChB,qBAAqB;IACrBsB,GAAG,EAAGjB,IAAM;IACZkB,KAAK,EAAGpB,gBAAgB,CAAEC,IAAI,EAAEC,IAAK;EAAG,GAExCW,aAAA,CAACf,mBAAmB;IAACI,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrDQ,aAAA,CAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAEA,eAAef,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","createHigherOrderComponent","Context","name","icon","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","props","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;;AAQA,MAAMC,OAAO,GAAGH,aAAa,CAAmB;EAC/CI,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEH,OAAO,MAAMC,qBAAqB,GAAGH,OAAO,CAACI,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAOP,UAAU,CAAEE,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,iBAAiB,GAC7BC,iBAGsB,IAEtBR,0BAA0B,CAAIS,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACbC,aAAA,CAACV,OAAO,CAACW,QAAQ,QACZC,OAAO,IACVF,aAAA,CAACF,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLF,iBAAiB,CAAEK,OAAO,EAAEH,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"names":["createContext","useContext","createHigherOrderComponent","Context","name","icon","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","props","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;;AAQA,MAAMC,OAAO,GAAGH,aAAa,CAAmB;EAC/CI,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEH,OAAO,MAAMC,qBAAqB,GAAGH,OAAO,CAACI,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAOP,UAAU,CAAEE,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,iBAAiB,GAC7BC,iBAGsB,IAEtBR,0BAA0B,CAAIS,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACbC,aAAA,CAACV,OAAO,CAACW,QAAQ,QACZC,OAAO,IACVF,aAAA,CAACF,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLF,iBAAiB,CAAEK,OAAO,EAAEH,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Component","PluginErrorBoundary","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\nexport class PluginErrorBoundary extends Component {\n\t/**\n\t * @param {Object} props\n\t */\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError() {\n\t\treturn { hasError: true };\n\t}\n\n\t/**\n\t * @param {Error} error Error object passed by React.\n\t */\n\tcomponentDidCatch( error ) {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAE9C,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAC;EAClD;AACD;AACA;EACCE,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAG;IACjC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;;EAEA;AACD;AACA;EACCE,iBAAiBA,CAAEC,KAAK,EAAG;IAC1B,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAG;IACR,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD"}
|
|
1
|
+
{"version":3,"names":["Component","PluginErrorBoundary","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\nexport class PluginErrorBoundary extends Component {\n\t/**\n\t * @param {Object} props\n\t */\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError() {\n\t\treturn { hasError: true };\n\t}\n\n\t/**\n\t * @param {Error} error Error object passed by React.\n\t */\n\tcomponentDidCatch( error ) {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAE9C,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAC;EAClD;AACD;AACA;EACCE,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAG;IACjC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;;EAEA;AACD;AACA;EACCE,iBAAiBA,CAAEC,KAAK,EAAG;IAC1B,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAG;IACR,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/plugins/src/index.js"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,OAAO"}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/plugins/src/index.js"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,OAAO","ignoreList":[]}
|
|
@@ -40,8 +40,8 @@ type PluginSettings = Omit<WPPlugin, 'name'>;
|
|
|
40
40
|
* // Using ES5 syntax
|
|
41
41
|
* var el = React.createElement;
|
|
42
42
|
* var Fragment = wp.element.Fragment;
|
|
43
|
-
* var PluginSidebar = wp.
|
|
44
|
-
* var PluginSidebarMoreMenuItem = wp.
|
|
43
|
+
* var PluginSidebar = wp.editor.PluginSidebar;
|
|
44
|
+
* var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
|
45
45
|
* var registerPlugin = wp.plugins.registerPlugin;
|
|
46
46
|
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
47
47
|
*
|
|
@@ -76,7 +76,7 @@ type PluginSettings = Omit<WPPlugin, 'name'>;
|
|
|
76
76
|
* @example
|
|
77
77
|
* ```js
|
|
78
78
|
* // Using ESNext syntax
|
|
79
|
-
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/
|
|
79
|
+
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
|
|
80
80
|
* import { registerPlugin } from '@wordpress/plugins';
|
|
81
81
|
* import { more } from '@wordpress/icons';
|
|
82
82
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-context/index.tsx"],"names":[],"mappings":";AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAC;IAChC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAC;CAChC;AAOD,eAAO,MAAM,qBAAqB,yCAAmB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,gBAAgB,kBAE/B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,mCAEnB,aAAa,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-context/index.tsx"],"names":[],"mappings":";AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAC;IAChC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAC;CAChC;AAOD,eAAO,MAAM,qBAAqB,yCAAmB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,gBAAgB,kBAE/B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,mCAEnB,aAAa,SACf,CAAC,KACJ,CAAC,GAAG,aAAa,+EAaE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/plugins",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.24.0",
|
|
4
4
|
"description": "Plugins module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"types": "build-types",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/components": "^27.
|
|
31
|
-
"@wordpress/compose": "^6.
|
|
32
|
-
"@wordpress/element": "^5.
|
|
33
|
-
"@wordpress/hooks": "^3.
|
|
34
|
-
"@wordpress/icons": "^9.
|
|
35
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
30
|
+
"@wordpress/components": "^27.4.0",
|
|
31
|
+
"@wordpress/compose": "^6.33.0",
|
|
32
|
+
"@wordpress/element": "^5.33.0",
|
|
33
|
+
"@wordpress/hooks": "^3.56.0",
|
|
34
|
+
"@wordpress/icons": "^9.47.0",
|
|
35
|
+
"@wordpress/is-shallow-equal": "^4.56.0",
|
|
36
36
|
"memize": "^2.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "280403b4c1cf6cc2c55a6c4d56f9ef91145e4191"
|
|
46
46
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -58,8 +58,8 @@ const plugins = {} as Record< string, WPPlugin >;
|
|
|
58
58
|
* // Using ES5 syntax
|
|
59
59
|
* var el = React.createElement;
|
|
60
60
|
* var Fragment = wp.element.Fragment;
|
|
61
|
-
* var PluginSidebar = wp.
|
|
62
|
-
* var PluginSidebarMoreMenuItem = wp.
|
|
61
|
+
* var PluginSidebar = wp.editor.PluginSidebar;
|
|
62
|
+
* var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
|
63
63
|
* var registerPlugin = wp.plugins.registerPlugin;
|
|
64
64
|
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
65
65
|
*
|
|
@@ -94,7 +94,7 @@ const plugins = {} as Record< string, WPPlugin >;
|
|
|
94
94
|
* @example
|
|
95
95
|
* ```js
|
|
96
96
|
* // Using ESNext syntax
|
|
97
|
-
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/
|
|
97
|
+
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
|
|
98
98
|
* import { registerPlugin } from '@wordpress/plugins';
|
|
99
99
|
* import { more } from '@wordpress/icons';
|
|
100
100
|
*
|