@wordpress/boot 0.23.0 → 0.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 +6 -0
- package/build-module/components/canvas/index.mjs +2 -1
- package/build-module/components/canvas/index.mjs.map +2 -2
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +1 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +2 -2
- package/build-types/components/canvas/index.d.ts.map +1 -1
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts +1 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/navigation/items.d.ts +1 -1
- package/build-types/components/navigation/items.d.ts.map +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts.map +1 -1
- package/package.json +28 -27
- package/src/components/canvas/index.tsx +2 -2
- package/src/components/canvas/use-navigate-to-entity-record.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.24.0 (2026-10-07)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Use the `inertValue` helper to set `inert` attributes, for better React 18/19 compatibility ([#83871](https://github.com/WordPress/gutenberg/pull/83871)).
|
|
10
|
+
|
|
5
11
|
## 0.23.0 (2026-09-23)
|
|
6
12
|
|
|
7
13
|
## 0.22.0 (2026-09-10)
|
|
@@ -3,6 +3,7 @@ import { useState, useEffect, useMemo } from "@wordpress/element";
|
|
|
3
3
|
import { Spinner } from "@wordpress/components";
|
|
4
4
|
import { useNavigate, useSearch } from "@wordpress/route";
|
|
5
5
|
import { __ } from "@wordpress/i18n";
|
|
6
|
+
import { inertValue } from "@wordpress/react-inert-value";
|
|
6
7
|
import { useSelect } from "@wordpress/data";
|
|
7
8
|
import { store as coreStore } from "@wordpress/core-data";
|
|
8
9
|
import { store as bootStore } from "../../store/index.mjs";
|
|
@@ -91,7 +92,7 @@ function Canvas({ canvas }) {
|
|
|
91
92
|
"div",
|
|
92
93
|
{
|
|
93
94
|
style: { height: "100%" },
|
|
94
|
-
inert: canvas.isPreview
|
|
95
|
+
inert: inertValue(canvas.isPreview),
|
|
95
96
|
children: /* @__PURE__ */ jsx(
|
|
96
97
|
Editor,
|
|
97
98
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/canvas/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useState, useEffect, useMemo } from '@wordpress/element';\nimport { Spinner } from '@wordpress/components';\nimport { useNavigate, useSearch } from '@wordpress/route';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as bootStore } from '../../store';\nimport type { CanvasData } from '../../store/types';\nimport BootBackButton from './back-button';\nimport SitePreview from './site-preview';\nimport useNavigateToEntityRecord, {\n\tuseActionPerformed,\n} from './use-navigate-to-entity-record';\nimport { getDeviceType } from './viewport';\n\ninterface CanvasProps {\n\tcanvas: CanvasData;\n}\n\n/**\n * Canvas component that dynamically loads and renders the lazy editor.\n *\n * @param {Object} props - Component props\n * @param {Object} props.canvas - Canvas data containing postType and postId\n * @return Canvas surface with editor\n */\nexport default function Canvas( { canvas }: CanvasProps ) {\n\tconst [ Editor, setEditor ] = useState< any >( null );\n\tconst navigate = useNavigate();\n\tconst { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord } =\n\t\tuseNavigateToEntityRecord();\n\tconst onActionPerformed = useActionPerformed( canvas.postType );\n\n\t/*\n\t * An entity can be asked to be edited at a particular width — a navigation\n\t * overlay meant for mobile — and carries the width it was left at when\n\t * returned to. Anything else opens at the default.\n\t */\n\tconst viewport = useSearch( {\n\t\tstrict: false,\n\t\tselect: ( search ) => ( search as { viewport?: string } ).viewport,\n\t} ) as string | undefined;\n\n\t/*\n\t * Where clicking a previewed canvas goes, resolved the same way the editor\n\t * resolves anywhere else it sends you to edit an entity, and whether it\n\t * should go anywhere at all: a trashed entity has to be restored before it\n\t * can be edited.\n\t *\n\t * The record is the one the editor loads for this canvas, so reading it\n\t * here costs no request of its own.\n\t */\n\t/*\n\t * A route that names no entity leaves the editor to resolve one, which it\n\t * does from the block templates only a block theme has. `undefined` while\n\t * the theme is still being read.\n\t */\n\tconst hasEntity = !! ( canvas.postType && canvas.postId );\n\tconst isBlockTheme = useSelect(\n\t\t( select ) =>\n\t\t\t(\n\t\t\t\tselect( coreStore ).getCurrentTheme() as\n\t\t\t\t\t{ is_block_theme?: boolean } | undefined\n\t\t\t )?.is_block_theme,\n\t\t[]\n\t);\n\n\tconst { editLink, isTrashed } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! canvas.postType || ! canvas.postId ) {\n\t\t\t\treturn { editLink: undefined, isTrashed: false };\n\t\t\t}\n\n\t\t\tconst record = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcanvas.postType,\n\t\t\t\tcanvas.postId\n\t\t\t) as { status?: string } | undefined;\n\n\t\t\treturn {\n\t\t\t\teditLink: select( bootStore ).getEntityLink(\n\t\t\t\t\tcanvas.postType,\n\t\t\t\t\tcanvas.postId\n\t\t\t\t),\n\t\t\t\tisTrashed: record?.status === 'trash',\n\t\t\t};\n\t\t},\n\t\t[ canvas.postType, canvas.postId ]\n\t);\n\n\t/*\n\t * Memoized because the editor provider pushes these settings into the store\n\t * whenever their identity changes, and the callbacks have to stay stable for\n\t * the block inspector to keep offering the same affordance.\n\t */\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\tisPreviewMode: canvas.isPreview,\n\t\t\tstyles: canvas.isPreview\n\t\t\t\t? [ { css: 'body{min-height:100vh;}' } ]\n\t\t\t\t: [],\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t} ),\n\t\t[\n\t\t\tcanvas.isPreview,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseEffect( () => {\n\t\t// Dynamically import the lazy-editor module\n\t\timport( '@wordpress/lazy-editor' )\n\t\t\t.then( ( module ) => {\n\t\t\t\tsetEditor( () => module.Editor );\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( 'Failed to load lazy editor:', error );\n\t\t\t} );\n\t}, [] );\n\n\t// Nothing for the editor to open, so show the site the route configures.\n\tif ( ! hasEntity && isBlockTheme === false ) {\n\t\treturn <SitePreview />;\n\t}\n\n\t// Show spinner while loading the editor module, and until it is known which\n\t// of the two this canvas is, so the wrong one is never shown first.\n\tif ( ! Editor || ( ! hasEntity && isBlockTheme === undefined ) ) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\talignItems: 'center',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tpadding: '2rem',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Render back button in full-screen mode (when not preview)\n\t// Uses render prop pattern to receive fillProps from Slot\n\tconst backButton = ! canvas.isPreview\n\t\t? ( { length }: { length: number } ) => (\n\t\t\t\t<BootBackButton length={ length } />\n\t\t\t)\n\t\t: undefined;\n\n\t// Render the editor with canvas data\n\treturn (\n\t\t<div style={ { height: '100%', position: 'relative' } }>\n\t\t\t<div\n\t\t\t\tstyle={ { height: '100%' } }\n\t\t\t\
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU,WAAW,eAAe;AAC7C,SAAS,eAAe;AACxB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1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,MACJ;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,YAAW,MAAM;AAEhB,WAAQ,wBAAyB,EAC/B,KAAM,CAAE,WAAY;AACpB,gBAAW,MAAM,OAAO,MAAO;AAAA,IAChC,CAAE,EACD,MAAO,CAAE,UAAW;AAEpB,cAAQ,MAAO,+BAA+B,KAAM;AAAA,IACrD,CAAE;AAAA,EACJ,GAAG,CAAC,CAAE;AAGN,MAAK,CAAE,aAAa,iBAAiB,OAAQ;AAC5C,WAAO,oBAAC,eAAY;AAAA,EACrB;AAIA,MAAK,CAAE,UAAY,CAAE,aAAa,iBAAiB,QAAc;AAChE,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,UACP,SAAS;AAAA,UACT,gBAAgB;AAAA,UAChB,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,SAAS;AAAA,QACV;AAAA,QAEA,8BAAC,WAAQ;AAAA;AAAA,IACV;AAAA,EAEF;AAIA,QAAM,aAAa,CAAE,OAAO,YACzB,CAAE,EAAE,OAAO,MACX,oBAAC,kBAAe,QAAkB,IAElC;AAGH,SACC,qBAAC,SAAI,OAAQ,EAAE,QAAQ,QAAQ,UAAU,WAAW,GACnD;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,EAAE,QAAQ,OAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import { useState, useEffect, useMemo } from '@wordpress/element';\nimport { Spinner } from '@wordpress/components';\nimport { useNavigate, useSearch } from '@wordpress/route';\nimport { __ } from '@wordpress/i18n';\nimport { inertValue } from '@wordpress/react-inert-value';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as bootStore } from '../../store';\nimport type { CanvasData } from '../../store/types';\nimport BootBackButton from './back-button';\nimport SitePreview from './site-preview';\nimport useNavigateToEntityRecord, {\n\tuseActionPerformed,\n} from './use-navigate-to-entity-record';\nimport { getDeviceType } from './viewport';\n\ninterface CanvasProps {\n\tcanvas: CanvasData;\n}\n\n/**\n * Canvas component that dynamically loads and renders the lazy editor.\n *\n * @param {Object} props - Component props\n * @param {Object} props.canvas - Canvas data containing postType and postId\n * @return Canvas surface with editor\n */\nexport default function Canvas( { canvas }: CanvasProps ) {\n\tconst [ Editor, setEditor ] = useState< any >( null );\n\tconst navigate = useNavigate();\n\tconst { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord } =\n\t\tuseNavigateToEntityRecord();\n\tconst onActionPerformed = useActionPerformed( canvas.postType );\n\n\t/*\n\t * An entity can be asked to be edited at a particular width — a navigation\n\t * overlay meant for mobile — and carries the width it was left at when\n\t * returned to. Anything else opens at the default.\n\t */\n\tconst viewport = useSearch( {\n\t\tstrict: false,\n\t\tselect: ( search ) => ( search as { viewport?: string } ).viewport,\n\t} ) as string | undefined;\n\n\t/*\n\t * Where clicking a previewed canvas goes, resolved the same way the editor\n\t * resolves anywhere else it sends you to edit an entity, and whether it\n\t * should go anywhere at all: a trashed entity has to be restored before it\n\t * can be edited.\n\t *\n\t * The record is the one the editor loads for this canvas, so reading it\n\t * here costs no request of its own.\n\t */\n\t/*\n\t * A route that names no entity leaves the editor to resolve one, which it\n\t * does from the block templates only a block theme has. `undefined` while\n\t * the theme is still being read.\n\t */\n\tconst hasEntity = !! ( canvas.postType && canvas.postId );\n\tconst isBlockTheme = useSelect(\n\t\t( select ) =>\n\t\t\t(\n\t\t\t\tselect( coreStore ).getCurrentTheme() as\n\t\t\t\t\t{ is_block_theme?: boolean } | undefined\n\t\t\t )?.is_block_theme,\n\t\t[]\n\t);\n\n\tconst { editLink, isTrashed } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! canvas.postType || ! canvas.postId ) {\n\t\t\t\treturn { editLink: undefined, isTrashed: false };\n\t\t\t}\n\n\t\t\tconst record = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcanvas.postType,\n\t\t\t\tcanvas.postId\n\t\t\t) as { status?: string } | undefined;\n\n\t\t\treturn {\n\t\t\t\teditLink: select( bootStore ).getEntityLink(\n\t\t\t\t\tcanvas.postType,\n\t\t\t\t\tcanvas.postId\n\t\t\t\t),\n\t\t\t\tisTrashed: record?.status === 'trash',\n\t\t\t};\n\t\t},\n\t\t[ canvas.postType, canvas.postId ]\n\t);\n\n\t/*\n\t * Memoized because the editor provider pushes these settings into the store\n\t * whenever their identity changes, and the callbacks have to stay stable for\n\t * the block inspector to keep offering the same affordance.\n\t */\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\tisPreviewMode: canvas.isPreview,\n\t\t\tstyles: canvas.isPreview\n\t\t\t\t? [ { css: 'body{min-height:100vh;}' } ]\n\t\t\t\t: [],\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t} ),\n\t\t[\n\t\t\tcanvas.isPreview,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseEffect( () => {\n\t\t// Dynamically import the lazy-editor module\n\t\timport( '@wordpress/lazy-editor' )\n\t\t\t.then( ( module ) => {\n\t\t\t\tsetEditor( () => module.Editor );\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( 'Failed to load lazy editor:', error );\n\t\t\t} );\n\t}, [] );\n\n\t// Nothing for the editor to open, so show the site the route configures.\n\tif ( ! hasEntity && isBlockTheme === false ) {\n\t\treturn <SitePreview />;\n\t}\n\n\t// Show spinner while loading the editor module, and until it is known which\n\t// of the two this canvas is, so the wrong one is never shown first.\n\tif ( ! Editor || ( ! hasEntity && isBlockTheme === undefined ) ) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\talignItems: 'center',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tpadding: '2rem',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Render back button in full-screen mode (when not preview)\n\t// Uses render prop pattern to receive fillProps from Slot\n\tconst backButton = ! canvas.isPreview\n\t\t? ( { length }: { length: number } ) => (\n\t\t\t\t<BootBackButton length={ length } />\n\t\t\t)\n\t\t: undefined;\n\n\t// Render the editor with canvas data\n\treturn (\n\t\t<div style={ { height: '100%', position: 'relative' } }>\n\t\t\t<div\n\t\t\t\tstyle={ { height: '100%' } }\n\t\t\t\tinert={ inertValue( canvas.isPreview ) }\n\t\t\t>\n\t\t\t\t<Editor\n\t\t\t\t\tpostType={ canvas.postType }\n\t\t\t\t\tpostId={ canvas.postId }\n\t\t\t\t\trenderingMode={ canvas.renderingMode }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tbackButton={ backButton }\n\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\tinitialViewport={ getDeviceType( viewport ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{ canvas.isPreview && editLink && (\n\t\t\t\t<div\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tisTrashed\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: () => navigate( { to: editLink } )\n\t\t\t\t\t}\n\t\t\t\t\tonKeyDown={ ( e ) => {\n\t\t\t\t\t\tif ( isTrashed ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( e.key === 'Enter' || e.key === ' ' ) {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tnavigate( { to: editLink } );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\tcursor: isTrashed ? 'default' : 'pointer',\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t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,SAAU;AAAA,QAErC;AAAA,UAAC;AAAA;AAAA,YACA,UAAW,OAAO;AAAA,YAClB,QAAS,OAAO;AAAA,YAChB,eAAgB,OAAO;AAAA,YACvB;AAAA,YACA;AAAA,YACA;AAAA,YACA,iBAAkB,cAAe,QAAS;AAAA;AAAA,QAC3C;AAAA;AAAA,IACD;AAAA,IACE,OAAO,aAAa,YACrB;AAAA,MAAC;AAAA;AAAA,QACA,SACC,YACG,SACA,MAAM,SAAU,EAAE,IAAI,SAAS,CAAE;AAAA,QAErC,WAAY,CAAE,MAAO;AACpB,cAAK,WAAY;AAChB;AAAA,UACD;AACA,cAAK,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAM;AACzC,cAAE,eAAe;AACjB,qBAAU,EAAE,IAAI,SAAS,CAAE;AAAA,UAC5B;AAAA,QACD;AAAA,QACA,OAAQ;AAAA,UACP,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ,YAAY,YAAY;AAAA,UAChC,QAAQ;AAAA,QACT;AAAA,QACA,MAAK;AAAA,QACL,UAAW;AAAA,QACX,iBAAgB;AAAA,QAChB,cAAa,GAAI,MAAO;AAAA;AAAA,IACzB;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/canvas/use-navigate-to-entity-record.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useMemo } from '@wordpress/element';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseNavigate,\n\tuseSearch,\n\tprivateApis as routePrivateApis,\n} from '@wordpress/route';\nimport { store as bootStore } from '../../store';\nimport { isValidViewport } from './viewport';\nimport { unlock } from '../../lock-unlock';\n\nconst { useCanGoBack, useRouter } = unlock( routePrivateApis );\n\n/*\n * The route tree is assembled from routes registered at runtime, so TanStack has\n * no search schema to infer and types `search` against a placeholder. Describe\n * the two calls this module makes instead.\n */\ntype Navigate = ( options: {\n\tto?: string;\n\treplace?: boolean;\n\tsearch?: (\n\t\tprevious: Record< string, unknown >\n\t) => Record< string, unknown >;\n} ) => void;\n\ninterface NavigateParams {\n\tpostType: string;\n\tpostId: string;\n\tviewport?: string;\n}\n\n/**\n * Builds the editor's entity navigation callbacks.\n *\n * The editor uses these to move between an entity and one nested inside it —\n * a template part or a synced pattern reached from the block inspector. They\n * are passed through the editor settings, where `onNavigateToEntityRecord`\n * gates the inspector's edit affordance and `onNavigateToPreviousEntityRecord`\n * gates the document bar's back button.\n *\n * @return The two callbacks, for spreading into the editor settings.\n */\nexport default function useNavigateToEntityRecord() {\n\tconst navigate = useNavigate() as Navigate;\n\tconst search = useSearch( { strict: false } ) as { focusMode?: unknown };\n\tconst registry = useRegistry();\n\tconst getEntityLink = useSelect(\n\t\t( select ) => select( bootStore ).getEntityLink,\n\t\t[]\n\t);\n\tconst router = useRouter();\n\tconst canGoBack = useCanGoBack();\n\n\tconst onNavigateToEntityRecord = useCallback(\n\t\t( params: NavigateParams ) => {\n\t\t\t/*\n\t\t\t * Stash the block selected in the entity being left, so returning to\n\t\t\t * it can restore the user's place. The edits hold the external\n\t\t\t * client ID, which `onChangeSelection` has already resolved.\n\t\t\t */\n\t\t\tconst currentPostType = (\n\t\t\t\tregistry.select( editorStore ) as any\n\t\t\t ).getCurrentPostType();\n\t\t\tconst currentPostId = (\n\t\t\t\tregistry.select( editorStore ) as any\n\t\t\t ).getCurrentPostId();\n\t\t\tconst edits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPostType,\n\t\t\t\t\tcurrentPostId\n\t\t\t\t) as { selection?: { selectionStart?: { clientId?: string } } };\n\t\t\tconst selectedBlock = edits?.selection?.selectionStart?.clientId;\n\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tnavigate( {\n\t\t\t\t\tsearch: ( previous: Record< string, unknown > ) => ( {\n\t\t\t\t\t\t...previous,\n\t\t\t\t\t\tselectedBlock,\n\t\t\t\t\t} ),\n\t\t\t\t\treplace: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * An entity can ask to be edited at a particular width — a\n\t\t\t * navigation overlay meant for mobile. The width is where the entity\n\t\t\t * opens, not something the entity being left carries away: a width\n\t\t\t * set from the device preview is view state, and an entity that asks\n\t\t\t * for none opens at the default.\n\t\t\t */\n\t\t\tconst requestedViewport = params.viewport?.toLowerCase();\n\t\t\tconst hasRequestedViewport = isValidViewport( requestedViewport );\n\n\t\t\t/*\n\t\t\t * `focusMode` marks the entity as one navigated into rather than\n\t\t\t * opened directly, which is what offers the way back out. The search\n\t\t\t * is replaced rather than extended so the block stashed above stays\n\t\t\t * with the entity it belongs to.\n\t\t\t */\n\t\t\tconst to = getEntityLink( params.postType, params.postId );\n\n\t\t\tif ( to ) {\n\t\t\t\tnavigate( {\n\t\t\t\t\tto,\n\t\t\t\t\tsearch: () => ( {\n\t\t\t\t\t\tfocusMode: true,\n\t\t\t\t\t\t...( hasRequestedViewport\n\t\t\t\t\t\t\t? { viewport: requestedViewport }\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ navigate, registry, getEntityLink ]\n\t);\n\n\t/*\n\t * Only entities navigated into offer a way back out. The editor reads this\n\t * as the entity being a focused one, giving it the document bar's back\n\t * button and the surrounding padding, so an entity opened directly — from a\n\t * list, say — must not have it. `canGoBack` covers reloading such a URL,\n\t * where the marker survives but the history to return to does not.\n\t */\n\tconst isFocusMode = !! search.focusMode;\n\tconst onNavigateToPreviousEntityRecord = useMemo(\n\t\t() =>\n\t\t\tisFocusMode && canGoBack ? () => router.history.back() : undefined,\n\t\t[ isFocusMode, canGoBack, router ]\n\t);\n\n\treturn { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord };\n}\n\ninterface ActionItem {\n\tid: string | number;\n\ttype: string;\n\ttitle?: string | { rendered?: string };\n}\n\n/**\n * Builds the callback the editor runs after a post action.\n *\n * Actions taken from inside the editor act on the entity being edited, so\n * trashing or deleting one leaves the canvas showing something that is no\n * longer there, and duplicating one gives no way to reach the copy.\n *\n * @param postType Post type rendered in the canvas.\n * @return The callback, for passing to the editor.\n */\nexport function useActionPerformed( postType?: string ) {\n\tconst navigate = useNavigate() as Navigate;\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst getEntityLink = useSelect(\n\t\t( select ) => select( bootStore ).getEntityLink,\n\t\t[]\n\t);\n\n\treturn useCallback(\n\t\t( actionId: string, items: ActionItem[] ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\tcase 'delete-post': {\n\t\t\t\t\tconst to = postType && getEntityLink( postType );\n\n\t\t\t\t\tif ( to ) {\n\t\t\t\t\t\tnavigate( { to, search: () => ( {} ) } );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'duplicate-post': {\n\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\tconst to = getEntityLink( newItem.type, newItem.id );\n\n\t\t\t\t\tif ( ! to ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst title =\n\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t: newItem.title?.rendered;\n\n\t\t\t\t\t/*\n\t\t\t\t\t * The action has already announced the copy under this id.\n\t\t\t\t\t * Reissuing it under the same id replaces that notice rather\n\t\t\t\t\t * than stacking a second one, and adds the way to reach it.\n\t\t\t\t\t */\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t// translators: %s: Title of the created post, e.g: \"Hello world\".\n\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\tdecodeEntities( title ?? '' ) || __( '(no title)' )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\tonClick: () => navigate( { to } ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ navigate, createSuccessNotice, getEntityLink, postType ]\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,oBAAoB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,uBAAuB;AAChC,SAAS,cAAc;AAEvB,IAAM,EAAE,cAAc,UAAU,IAAI,OAAQ,gBAAiB;AAgC9C,SAAR,4BAA6C;AACnD,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS,UAAW,EAAE,QAAQ,MAAM,CAAE;AAC5C,QAAM,WAAW,YAAY;AAC7B,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,SAAU,EAAE;AAAA,IAClC,CAAC;AAAA,EACF;AACA,QAAM,SAAS,UAAU;AACzB,QAAM,YAAY,aAAa;AAE/B,QAAM,2BAA2B;A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AA,QACnB,KAAK;AAAA,QACL,KAAK,eAAe;AACnB,gBAAM,KAAK,YAAY,cAAe,QAAS;AAE/C,cAAK,IAAK;AACT,qBAAU,EAAE,IAAI,QAAQ,OAAQ,CAAC,GAAI,CAAE;AAAA,UACxC;AACA;AAAA,QACD;AAAA,QAEA,KAAK,kBAAkB;AACtB,gBAAM,UAAU,MAAO,CAAE;AACzB,gBAAM,KAAK,cAAe,QAAQ,MAAM,QAAQ,EAAG;AAEnD,cAAK,CAAE,IAAK;AACX;AAAA,UACD;AAEA,gBAAM,QACL,OAAO,QAAQ,UAAU,WACtB,QAAQ,QACR,QAAQ,OAAO;AAOnB;AAAA,YACC;AAAA;AAAA,cAEC,GAAI,4BAA6B;AAAA,cACjC,eAAgB,SAAS,EAAG,KAAK,GAAI,YAAa;AAAA,YACnD;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,IAAI;AAAA,cACJ,SAAS;AAAA,gBACR;AAAA,kBACC,OAAO,GAAI,MAAO;AAAA,kBAClB,SAAS,MAAM,SAAU,EAAE,GAAG,CAAE;AAAA,gBACjC;AAAA,cACD;AAAA,YACD;AAAA,UACD;AACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,UAAU,qBAAqB,eAAe,QAAS;AAAA,EAC1D;AACD;",
|
|
4
|
+
"sourcesContent": ["import { useCallback, useMemo } from '@wordpress/element';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseNavigate,\n\tuseSearch,\n\tprivateApis as routePrivateApis,\n} from '@wordpress/route';\nimport { store as bootStore } from '../../store';\nimport { isValidViewport } from './viewport';\nimport { unlock } from '../../lock-unlock';\n\nconst { useCanGoBack, useRouter } = unlock( routePrivateApis );\n\n/*\n * The route tree is assembled from routes registered at runtime, so TanStack has\n * no search schema to infer and types `search` against a placeholder. Describe\n * the two calls this module makes instead.\n */\ntype Navigate = ( options: {\n\tto?: string;\n\treplace?: boolean;\n\tsearch?: (\n\t\tprevious: Record< string, unknown >\n\t) => Record< string, unknown >;\n} ) => void;\n\ninterface NavigateParams {\n\tpostType: string;\n\tpostId: string;\n\tviewport?: string;\n}\n\n/**\n * Builds the editor's entity navigation callbacks.\n *\n * The editor uses these to move between an entity and one nested inside it —\n * a template part or a synced pattern reached from the block inspector. They\n * are passed through the editor settings, where `onNavigateToEntityRecord`\n * gates the inspector's edit affordance and `onNavigateToPreviousEntityRecord`\n * gates the document bar's back button.\n *\n * @return The two callbacks, for spreading into the editor settings.\n */\nexport default function useNavigateToEntityRecord() {\n\tconst navigate = useNavigate() as Navigate;\n\tconst search = useSearch( { strict: false } ) as { focusMode?: unknown };\n\tconst registry = useRegistry();\n\tconst getEntityLink = useSelect(\n\t\t( select ) => select( bootStore ).getEntityLink,\n\t\t[]\n\t);\n\tconst router = useRouter();\n\tconst canGoBack = useCanGoBack();\n\n\tconst onNavigateToEntityRecord = useCallback(\n\t\t( params: NavigateParams ) => {\n\t\t\t/*\n\t\t\t * Stash the block selected in the entity being left, so returning to\n\t\t\t * it can restore the user's place. The edits hold the external\n\t\t\t * client ID, which `onChangeSelection` has already resolved.\n\t\t\t */\n\t\t\tconst currentPostType = (\n\t\t\t\tregistry.select( editorStore ) as any\n\t\t\t ).getCurrentPostType();\n\t\t\tconst currentPostId = (\n\t\t\t\tregistry.select( editorStore ) as any\n\t\t\t ).getCurrentPostId();\n\t\t\tconst edits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPostType,\n\t\t\t\t\tcurrentPostId\n\t\t\t\t) as { selection?: { selectionStart?: { clientId?: string } } };\n\t\t\tconst selectedBlock = edits?.selection?.selectionStart?.clientId;\n\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tnavigate( {\n\t\t\t\t\tsearch: ( previous: Record< string, unknown > ) => ( {\n\t\t\t\t\t\t...previous,\n\t\t\t\t\t\tselectedBlock,\n\t\t\t\t\t} ),\n\t\t\t\t\treplace: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * An entity can ask to be edited at a particular width — a\n\t\t\t * navigation overlay meant for mobile. The width is where the entity\n\t\t\t * opens, not something the entity being left carries away: a width\n\t\t\t * set from the device preview is view state, and an entity that asks\n\t\t\t * for none opens at the default.\n\t\t\t */\n\t\t\tconst requestedViewport = params.viewport?.toLowerCase();\n\t\t\tconst hasRequestedViewport = isValidViewport( requestedViewport );\n\n\t\t\t/*\n\t\t\t * `focusMode` marks the entity as one navigated into rather than\n\t\t\t * opened directly, which is what offers the way back out. The search\n\t\t\t * is replaced rather than extended so the block stashed above stays\n\t\t\t * with the entity it belongs to.\n\t\t\t */\n\t\t\tconst to = getEntityLink( params.postType, params.postId );\n\n\t\t\tif ( to ) {\n\t\t\t\tnavigate( {\n\t\t\t\t\tto,\n\t\t\t\t\tsearch: () => ( {\n\t\t\t\t\t\tfocusMode: true,\n\t\t\t\t\t\t...( hasRequestedViewport\n\t\t\t\t\t\t\t? { viewport: requestedViewport }\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ navigate, registry, getEntityLink ]\n\t);\n\n\t/*\n\t * Only entities navigated into offer a way back out. The editor reads this\n\t * as the entity being a focused one, giving it the document bar's back\n\t * button and the surrounding padding, so an entity opened directly — from a\n\t * list, say — must not have it. `canGoBack` covers reloading such a URL,\n\t * where the marker survives but the history to return to does not.\n\t */\n\tconst isFocusMode = !! search.focusMode;\n\tconst onNavigateToPreviousEntityRecord = useMemo(\n\t\t() =>\n\t\t\tisFocusMode && canGoBack ? () => router.history.back() : undefined,\n\t\t[ isFocusMode, canGoBack, router ]\n\t);\n\n\treturn { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord };\n}\n\ninterface ActionItem {\n\tid: string | number;\n\ttype: string;\n\ttitle?: string | { rendered?: string };\n}\n\n/**\n * Builds the callback the editor runs after a post action.\n *\n * Actions taken from inside the editor act on the entity being edited, so\n * trashing or deleting one leaves the canvas showing something that is no\n * longer there, and duplicating one gives no way to reach the copy.\n *\n * @param postType Post type rendered in the canvas.\n * @return The callback, for passing to the editor.\n */\nexport function useActionPerformed( postType?: string ) {\n\tconst navigate = useNavigate() as Navigate;\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst getEntityLink = useSelect(\n\t\t( select ) => select( bootStore ).getEntityLink,\n\t\t[]\n\t);\n\n\treturn useCallback(\n\t\t( actionId: string, items: ActionItem[] ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\tcase 'permanently-delete':\n\t\t\t\tcase 'delete-post': {\n\t\t\t\t\tconst to = postType && getEntityLink( postType );\n\n\t\t\t\t\tif ( to ) {\n\t\t\t\t\t\tnavigate( { to, search: () => ( {} ) } );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'duplicate-post': {\n\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\tconst to = getEntityLink( newItem.type, newItem.id );\n\n\t\t\t\t\tif ( ! to ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst title =\n\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t: newItem.title?.rendered;\n\n\t\t\t\t\t/*\n\t\t\t\t\t * The action has already announced the copy under this id.\n\t\t\t\t\t * Reissuing it under the same id replaces that notice rather\n\t\t\t\t\t * than stacking a second one, and adds the way to reach it.\n\t\t\t\t\t */\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t// translators: %s: Title of the created post, e.g: \"Hello world\".\n\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\tdecodeEntities( title ?? '' ) || __( '(no title)' )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\tonClick: () => navigate( { to } ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ navigate, createSuccessNotice, getEntityLink, postType ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,oBAAoB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,uBAAuB;AAChC,SAAS,cAAc;AAEvB,IAAM,EAAE,cAAc,UAAU,IAAI,OAAQ,gBAAiB;AAgC9C,SAAR,4BAA6C;AACnD,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS,UAAW,EAAE,QAAQ,MAAM,CAAE;AAC5C,QAAM,WAAW,YAAY;AAC7B,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,SAAU,EAAE;AAAA,IAClC,CAAC;AAAA,EACF;AACA,QAAM,SAAS,UAAU;AACzB,QAAM,YAAY,aAAa;AAE/B,QAAM,2BAA2B;AAAA,IAChC,CAAE,WAA4B;AAM7B,YAAM,kBACL,SAAS,OAAQ,W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nB,gBAAM,KAAK,YAAY,cAAe,QAAS;AAE/C,cAAK,IAAK;AACT,qBAAU,EAAE,IAAI,QAAQ,OAAQ,CAAC,GAAI,CAAE;AAAA,UACxC;AACA;AAAA,QACD;AAAA,QAEA,KAAK,kBAAkB;AACtB,gBAAM,UAAU,MAAO,CAAE;AACzB,gBAAM,KAAK,cAAe,QAAQ,MAAM,QAAQ,EAAG;AAEnD,cAAK,CAAE,IAAK;AACX;AAAA,UACD;AAEA,gBAAM,QACL,OAAO,QAAQ,UAAU,WACtB,QAAQ,QACR,QAAQ,OAAO;AAOnB;AAAA,YACC;AAAA;AAAA,cAEC,GAAI,4BAA6B;AAAA,cACjC,eAAgB,SAAS,EAAG,KAAK,GAAI,YAAa;AAAA,YACnD;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,IAAI;AAAA,cACJ,SAAS;AAAA,gBACR;AAAA,kBACC,OAAO,GAAI,MAAO;AAAA,kBAClB,SAAS,MAAM,SAAU,EAAE,GAAG,CAAE;AAAA,gBACjC;AAAA,cACD;AAAA,YACD;AAAA,UACD;AACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,UAAU,qBAAqB,eAAe,QAAS;AAAA,EAC1D;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQpD,UAAU,WAAW;IACpB,MAAM,EAAE,UAAU,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,EAAE,MAAM,EAAE,EAAE,WAAW,+BA+KtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-navigate-to-entity-record.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/use-navigate-to-entity-record.ts"],"names":[],"mappings":"AA+BA,UAAU,cAAc;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB;uCAYrC,cAAc;;EA+EzB;AAED,UAAU,UAAU;IACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAE,QAAQ,CAAC,EAAE,MAAM,cASvC,MAAM,SAAS,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"use-navigate-to-entity-record.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/use-navigate-to-entity-record.ts"],"names":[],"mappings":"AA+BA,UAAU,cAAc;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB;uCAYrC,cAAc;;EA+EzB;AAED,UAAU,UAAU;IACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAE,QAAQ,CAAC,EAAE,MAAM,cASvC,MAAM,SAAS,UAAU,EAAE,UAsDxC"}
|
|
@@ -16,7 +16,7 @@ interface State {
|
|
|
16
16
|
export default class ErrorBoundary extends Component<Props, State> {
|
|
17
17
|
constructor(props: Props);
|
|
18
18
|
static getDerivedStateFromError(error: Error): State;
|
|
19
|
-
render(): string | number | boolean | import("react").JSX.Element | Iterable<ReactNode> | null | undefined;
|
|
19
|
+
render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
20
20
|
}
|
|
21
21
|
export {};
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/error-boundary/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,UAAU,KAAK;IACd,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,UAAU,KAAK;IACd,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAYD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS,CAAE,KAAK,EAAE,KAAK,CAAE;IACnE,YAAa,KAAK,EAAE,KAAK,EAGxB;IAED,MAAM,CAAC,wBAAwB,CAAE,KAAK,EAAE,KAAK,GAAI,KAAK,CAErD;IAED,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/error-boundary/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,UAAU,KAAK;IACd,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,UAAU,KAAK;IACd,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAYD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS,CAAE,KAAK,EAAE,KAAK,CAAE;IACnE,YAAa,KAAK,EAAE,KAAK,EAGxB;IAED,MAAM,CAAC,wBAAwB,CAAE,KAAK,EAAE,KAAK,GAAI,KAAK,CAErD;IAED,MAAM,gUAyBL;CACD"}
|
|
@@ -9,5 +9,5 @@ import type { IconType } from '../../store/types';
|
|
|
9
9
|
* @param shouldShowPlaceholder - Whether to show placeholder when no icon is provided
|
|
10
10
|
* @return The converted icon as a JSX element
|
|
11
11
|
*/
|
|
12
|
-
export declare function wrapIcon(icon?: IconType, shouldShowPlaceholder?: boolean): string | number | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | null;
|
|
12
|
+
export declare function wrapIcon(icon?: IconType, shouldShowPlaceholder?: boolean): string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null;
|
|
13
13
|
//# sourceMappingURL=items.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/items.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAelD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACvB,IAAI,CAAC,EAAE,QAAQ,EACf,qBAAqB,GAAE,OAAc,
|
|
1
|
+
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/items.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAelD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACvB,IAAI,CAAC,EAAE,QAAQ,EACf,qBAAqB,GAAE,OAAc,gVAuDrC"}
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @return Ref to attach to the layout root element.
|
|
11
11
|
*/
|
|
12
|
-
export default function useSyncBodyBackground(): import("react").
|
|
12
|
+
export default function useSyncBodyBackground(): import("react").RefObject<HTMLDivElement | null>;
|
|
13
13
|
//# sourceMappingURL=use-sync-body-background.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sync-body-background.d.ts","sourceRoot":"","sources":["../../../src/components/root/use-sync-body-background.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,
|
|
1
|
+
{"version":3,"file":"use-sync-body-background.d.ts","sourceRoot":"","sources":["../../../src/components/root/use-sync-body-background.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,qDAuB5C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/boot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Minimal boot package for WordPress admin pages.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -39,31 +39,32 @@
|
|
|
39
39
|
"wpScriptModuleExports": "./build-module/index.mjs",
|
|
40
40
|
"types": "build-types",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@wordpress/a11y": "^4.
|
|
43
|
-
"@wordpress/admin-ui": "^2.
|
|
44
|
-
"@wordpress/base-styles": "^13.
|
|
45
|
-
"@wordpress/components": "^
|
|
46
|
-
"@wordpress/compose": "^8.
|
|
47
|
-
"@wordpress/core-data": "^8.
|
|
48
|
-
"@wordpress/data": "^10.
|
|
49
|
-
"@wordpress/dom": "^4.
|
|
50
|
-
"@wordpress/editor": "^15.
|
|
51
|
-
"@wordpress/element": "^
|
|
52
|
-
"@wordpress/html-entities": "^4.
|
|
53
|
-
"@wordpress/i18n": "^6.
|
|
54
|
-
"@wordpress/icons": "^
|
|
55
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
56
|
-
"@wordpress/keycodes": "^4.
|
|
57
|
-
"@wordpress/lazy-editor": "^1.
|
|
58
|
-
"@wordpress/notices": "^5.
|
|
59
|
-
"@wordpress/plugins": "^7.
|
|
60
|
-
"@wordpress/primitives": "^4.
|
|
61
|
-
"@wordpress/private-apis": "^
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
64
|
-
"@wordpress/
|
|
65
|
-
"@wordpress/
|
|
66
|
-
"@wordpress/
|
|
42
|
+
"@wordpress/a11y": "^4.57.0",
|
|
43
|
+
"@wordpress/admin-ui": "^2.12.0",
|
|
44
|
+
"@wordpress/base-styles": "^13.3.0",
|
|
45
|
+
"@wordpress/components": "^42.0.0",
|
|
46
|
+
"@wordpress/compose": "^8.10.0",
|
|
47
|
+
"@wordpress/core-data": "^8.2.0",
|
|
48
|
+
"@wordpress/data": "^10.57.0",
|
|
49
|
+
"@wordpress/dom": "^4.57.0",
|
|
50
|
+
"@wordpress/editor": "^15.2.0",
|
|
51
|
+
"@wordpress/element": "^9.0.0",
|
|
52
|
+
"@wordpress/html-entities": "^4.57.0",
|
|
53
|
+
"@wordpress/i18n": "^6.30.0",
|
|
54
|
+
"@wordpress/icons": "^18.0.0",
|
|
55
|
+
"@wordpress/keyboard-shortcuts": "^5.57.0",
|
|
56
|
+
"@wordpress/keycodes": "^4.57.0",
|
|
57
|
+
"@wordpress/lazy-editor": "^1.23.0",
|
|
58
|
+
"@wordpress/notices": "^5.57.0",
|
|
59
|
+
"@wordpress/plugins": "^7.57.0",
|
|
60
|
+
"@wordpress/primitives": "^4.57.0",
|
|
61
|
+
"@wordpress/private-apis": "^2.0.0",
|
|
62
|
+
"@wordpress/react-inert-value": "^1.0.0",
|
|
63
|
+
"@wordpress/route": "^0.23.0",
|
|
64
|
+
"@wordpress/style-runtime": "^0.13.0",
|
|
65
|
+
"@wordpress/theme": "^2.3.0",
|
|
66
|
+
"@wordpress/ui": "^0.24.0",
|
|
67
|
+
"@wordpress/url": "^4.57.0",
|
|
67
68
|
"clsx": "^2.1.1"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"publishConfig": {
|
|
80
81
|
"access": "public"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "12441e2520c78b2254a792a8cba40c34110be060"
|
|
83
84
|
}
|
|
@@ -2,6 +2,7 @@ import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
|
2
2
|
import { Spinner } from '@wordpress/components';
|
|
3
3
|
import { useNavigate, useSearch } from '@wordpress/route';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { inertValue } from '@wordpress/react-inert-value';
|
|
5
6
|
import { useSelect } from '@wordpress/data';
|
|
6
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
8
|
import { store as bootStore } from '../../store';
|
|
@@ -157,8 +158,7 @@ export default function Canvas( { canvas }: CanvasProps ) {
|
|
|
157
158
|
<div style={ { height: '100%', position: 'relative' } }>
|
|
158
159
|
<div
|
|
159
160
|
style={ { height: '100%' } }
|
|
160
|
-
|
|
161
|
-
inert={ canvas.isPreview ? 'true' : undefined }
|
|
161
|
+
inert={ inertValue( canvas.isPreview ) }
|
|
162
162
|
>
|
|
163
163
|
<Editor
|
|
164
164
|
postType={ canvas.postType }
|
|
@@ -167,6 +167,7 @@ export function useActionPerformed( postType?: string ) {
|
|
|
167
167
|
( actionId: string, items: ActionItem[] ) => {
|
|
168
168
|
switch ( actionId ) {
|
|
169
169
|
case 'move-to-trash':
|
|
170
|
+
case 'permanently-delete':
|
|
170
171
|
case 'delete-post': {
|
|
171
172
|
const to = postType && getEntityLink( postType );
|
|
172
173
|
|