@wordpress/editor 13.24.0 → 13.24.1

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.
@@ -104,7 +104,7 @@ function useBlockEditorProps(post, template, mode) {
104
104
  const [templateBlocks, onInputTemplate, onChangeTemplate] = (0, _coreData.useEntityBlockEditor)('postType', template?.type, {
105
105
  id: template?.id
106
106
  });
107
- const blocks = (0, _element.useMemo)(() => {
107
+ const maybeNavigationBlocks = (0, _element.useMemo)(() => {
108
108
  if (post.type === 'wp_navigation') {
109
109
  return [(0, _blocks.createBlock)('core/navigation', {
110
110
  ref: post.id,
@@ -114,6 +114,8 @@ function useBlockEditorProps(post, template, mode) {
114
114
  templateLock: false
115
115
  })];
116
116
  }
117
+ }, [post.type, post.id]);
118
+ const maybePostOnlyBlocks = (0, _element.useMemo)(() => {
117
119
  if (mode === 'post-only') {
118
120
  const postContentBlocks = extractPageContentBlockTypesFromTemplateBlocks(templateBlocks);
119
121
  return [(0, _blocks.createBlock)('core/group', {
@@ -129,11 +131,26 @@ function useBlockEditorProps(post, template, mode) {
129
131
  }
130
132
  }, postContentBlocks.length ? postContentBlocks : [(0, _blocks.createBlock)('core/post-title'), (0, _blocks.createBlock)('core/post-content')])];
131
133
  }
134
+ }, [templateBlocks, mode]);
135
+
136
+ // It is important that we don't create a new instance of blocks on every change
137
+ // We should only create a new instance if the blocks them selves change, not a dependency of them.
138
+ const blocks = (0, _element.useMemo)(() => {
139
+ if (maybeNavigationBlocks) {
140
+ return maybeNavigationBlocks;
141
+ }
142
+ if (maybePostOnlyBlocks) {
143
+ return maybePostOnlyBlocks;
144
+ }
132
145
  if (rootLevelPost === 'template') {
133
146
  return templateBlocks;
134
147
  }
135
148
  return postBlocks;
136
- }, [templateBlocks, postBlocks, rootLevelPost, post.type, post.id, mode]);
149
+ }, [maybeNavigationBlocks, maybePostOnlyBlocks, rootLevelPost, templateBlocks, postBlocks]);
150
+
151
+ // Handle fallback to postBlocks outside of the above useMemo, to ensure
152
+ // that constructed block templates that call `createBlock` are not generated
153
+ // too frequently. This ensures that clientIds are stable.
137
154
  const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation' || mode === 'post-only';
138
155
  const navigationBlockClientId = post.type === 'wp_navigation' && blocks && blocks[0]?.clientId;
139
156
  useForceFocusModeForNavigation(navigationBlockClientId);
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_i18n","_coreData","_blockEditor","_notices","_patterns","_blocks","_withRegistryProvider","_interopRequireDefault","_store","_useBlockEditorSettings","_lockUnlock","_disableNonPageContentBlocks","_constants","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","noop","useForceFocusModeForNavigation","navigationBlockClientId","setBlockEditingMode","unsetBlockEditingMode","useDispatch","blockEditorStore","useEffect","extractPageContentBlockTypesFromTemplateBlocks","blocks","result","i","length","name","PAGE_CONTENT_BLOCK_TYPES","includes","push","createBlock","innerBlocks","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","useEntityBlockEditor","type","id","templateBlocks","onInputTemplate","onChangeTemplate","useMemo","ref","templateLock","postContentBlocks","layout","style","spacing","margin","top","disableRootLevelChanges","clientId","ExperimentalEditorProvider","withRegistryProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","useSelect","select","editorStore","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","useBlockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","noticesStore","useLayoutEffect","postLock","autosave","__","actions","label","url","editLink","_react","createElement","EntityProvider","kind","BlockContextProvider","value","useSubRegistry","default","exports","EditorProvider","props","BlockEditorProvider","_default"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n *\n * @param {string} navigationBlockClientId ClientId.\n */\nfunction useForceFocusModeForNavigation( navigationBlockClientId ) {\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! navigationBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( navigationBlockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( navigationBlockClientId );\n\t\t};\n\t}, [\n\t\tnavigationBlockClientId,\n\t\tunsetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n}\n\n/**\n * Helper method to extract the post content block types from a template.\n *\n * @param {Array} blocks Template blocks.\n *\n * @return {Array} Flattened object.\n */\nfunction extractPageContentBlockTypesFromTemplateBlocks( blocks ) {\n\tconst result = [];\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\t// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,\n\t\t// we skip it because we only want to render stand-alone page content blocks in the block list.\n\t\tif ( blocks[ i ].name === 'core/query' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {\n\t\t\tresult.push( createBlock( blocks[ i ].name ) );\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tresult.push(\n\t\t\t\t...extractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst blocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\n\t\tif ( mode === 'post-only' ) {\n\t\t\tconst postContentBlocks =\n\t\t\t\textractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\ttemplateBlocks\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\ttop: '4em', // Mimics the post editor.\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\tpostContentBlocks.length\n\t\t\t\t\t\t? postContentBlocks\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-title' ),\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-content' ),\n\t\t\t\t\t\t ]\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [\n\t\ttemplateBlocks,\n\t\tpostBlocks,\n\t\trootLevelPost,\n\t\tpost.type,\n\t\tpost.id,\n\t\tmode,\n\t] );\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation' ||\n\t\tmode === 'post-only';\n\tconst navigationBlockClientId =\n\t\tpost.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;\n\tuseForceFocusModeForNavigation( navigationBlockClientId );\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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);\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ [ 'post-only', 'template-locked' ].includes(\n\t\t\t\t\t\t\t\tmode\n\t\t\t\t\t\t\t) && <DisableNonPageContentBlocks /> }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAMA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,qBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,4BAAA,GAAAJ,sBAAA,CAAAT,OAAA;AACA,IAAAc,UAAA,GAAAd,OAAA;AAzBA;AACA;AACA;;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AAA,CAAAyG,cAAc;IACdC,IAAI,EAAC,UAAU;IACf7D,IAAI,EAAGR,IAAI,CAACQ,IAAM;IAClBC,EAAE,EAAGT,IAAI,CAACS;EAAI,GAEd,IAAAyD,MAAA,CAAAC,aAAA,EAACvG,YAAA,CAAA0G,oBAAoB;IAACC,KAAK,EAAGlC;EAAqB,GAClD,IAAA6B,MAAA,CAAAC,aAAA,EAACrC,4BAA4B;IAC5ByC,KAAK,EAAGlF,MAAQ;IAChBiB,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnBwC,SAAS,EAAGA,SAAW;IACvBnB,QAAQ,EAAGwB,mBAAqB;IAChCsB,cAAc,EAAG;EAAO,GAEtB3C,QAAQ,EACV,IAAAqC,MAAA,CAAAC,aAAA,EAACzF,iBAAiB,MAAE,CAAC,EACnB,CAAE,WAAW,EAAE,iBAAiB,CAAE,CAACiB,QAAQ,CAC5CO,IACD,CAAC,IAAI,IAAAgE,MAAA,CAAAC,aAAA,EAAC9F,4BAAA,CAAAoG,OAA2B,MAAE,CACN,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAACC,OAAA,CAAAlD,0BAAA,GAAAA,0BAAA;AAEK,SAASmD,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACC,IAAAV,MAAA,CAAAC,aAAA,EAAC3C,0BAA0B;IAAA,GACrBoD,KAAK;IACV9C,4BAA4B,EAAG+C;EAAqB,GAElDD,KAAK,CAAC/C,QACmB,CAAC;AAE/B;AAAC,IAAAiD,QAAA,GAEcH,cAAc;AAAAD,OAAA,CAAAD,OAAA,GAAAK,QAAA"}
1
+ {"version":3,"names":["_element","require","_data","_i18n","_coreData","_blockEditor","_notices","_patterns","_blocks","_withRegistryProvider","_interopRequireDefault","_store","_useBlockEditorSettings","_lockUnlock","_disableNonPageContentBlocks","_constants","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","noop","useForceFocusModeForNavigation","navigationBlockClientId","setBlockEditingMode","unsetBlockEditingMode","useDispatch","blockEditorStore","useEffect","extractPageContentBlockTypesFromTemplateBlocks","blocks","result","i","length","name","PAGE_CONTENT_BLOCK_TYPES","includes","push","createBlock","innerBlocks","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","useEntityBlockEditor","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","useMemo","ref","templateLock","maybePostOnlyBlocks","postContentBlocks","layout","style","spacing","margin","top","disableRootLevelChanges","clientId","ExperimentalEditorProvider","withRegistryProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","useSelect","select","editorStore","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","useBlockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","noticesStore","useLayoutEffect","postLock","autosave","__","actions","label","url","editLink","_react","createElement","EntityProvider","kind","BlockContextProvider","value","useSubRegistry","default","exports","EditorProvider","props","BlockEditorProvider","_default"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n *\n * @param {string} navigationBlockClientId ClientId.\n */\nfunction useForceFocusModeForNavigation( navigationBlockClientId ) {\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! navigationBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( navigationBlockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( navigationBlockClientId );\n\t\t};\n\t}, [\n\t\tnavigationBlockClientId,\n\t\tunsetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n}\n\n/**\n * Helper method to extract the post content block types from a template.\n *\n * @param {Array} blocks Template blocks.\n *\n * @return {Array} Flattened object.\n */\nfunction extractPageContentBlockTypesFromTemplateBlocks( blocks ) {\n\tconst result = [];\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\t// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,\n\t\t// we skip it because we only want to render stand-alone page content blocks in the block list.\n\t\tif ( blocks[ i ].name === 'core/query' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {\n\t\t\tresult.push( createBlock( blocks[ i ].name ) );\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tresult.push(\n\t\t\t\t...extractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\tconst maybePostOnlyBlocks = useMemo( () => {\n\t\tif ( mode === 'post-only' ) {\n\t\t\tconst postContentBlocks =\n\t\t\t\textractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\ttemplateBlocks\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\ttop: '4em', // Mimics the post editor.\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\tpostContentBlocks.length\n\t\t\t\t\t\t? postContentBlocks\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-title' ),\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-content' ),\n\t\t\t\t\t\t ]\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t}, [ templateBlocks, mode ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( maybePostOnlyBlocks ) {\n\t\t\treturn maybePostOnlyBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [\n\t\tmaybeNavigationBlocks,\n\t\tmaybePostOnlyBlocks,\n\t\trootLevelPost,\n\t\ttemplateBlocks,\n\t\tpostBlocks,\n\t] );\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation' ||\n\t\tmode === 'post-only';\n\tconst navigationBlockClientId =\n\t\tpost.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;\n\tuseForceFocusModeForNavigation( navigationBlockClientId );\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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);\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ [ 'post-only', 'template-locked' ].includes(\n\t\t\t\t\t\t\t\tmode\n\t\t\t\t\t\t\t) && <DisableNonPageContentBlocks /> }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAMA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,qBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,4BAAA,GAAAJ,sBAAA,CAAAT,OAAA;AACA,IAAAc,UAAA,GAAAd,OAAA;AAzBA;AACA;AACA;;AAeA;AACA;AACA;;AAQA,MAAM;EA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D,KAAK,CAAC/C,QACmB,CAAC;AAE/B;AAAC,IAAAiD,QAAA,GAEcH,cAAc;AAAAD,OAAA,CAAAD,OAAA,GAAAK,QAAA"}
@@ -95,7 +95,7 @@ function useBlockEditorProps(post, template, mode) {
95
95
  const [templateBlocks, onInputTemplate, onChangeTemplate] = useEntityBlockEditor('postType', template?.type, {
96
96
  id: template?.id
97
97
  });
98
- const blocks = useMemo(() => {
98
+ const maybeNavigationBlocks = useMemo(() => {
99
99
  if (post.type === 'wp_navigation') {
100
100
  return [createBlock('core/navigation', {
101
101
  ref: post.id,
@@ -105,6 +105,8 @@ function useBlockEditorProps(post, template, mode) {
105
105
  templateLock: false
106
106
  })];
107
107
  }
108
+ }, [post.type, post.id]);
109
+ const maybePostOnlyBlocks = useMemo(() => {
108
110
  if (mode === 'post-only') {
109
111
  const postContentBlocks = extractPageContentBlockTypesFromTemplateBlocks(templateBlocks);
110
112
  return [createBlock('core/group', {
@@ -120,11 +122,26 @@ function useBlockEditorProps(post, template, mode) {
120
122
  }
121
123
  }, postContentBlocks.length ? postContentBlocks : [createBlock('core/post-title'), createBlock('core/post-content')])];
122
124
  }
125
+ }, [templateBlocks, mode]);
126
+
127
+ // It is important that we don't create a new instance of blocks on every change
128
+ // We should only create a new instance if the blocks them selves change, not a dependency of them.
129
+ const blocks = useMemo(() => {
130
+ if (maybeNavigationBlocks) {
131
+ return maybeNavigationBlocks;
132
+ }
133
+ if (maybePostOnlyBlocks) {
134
+ return maybePostOnlyBlocks;
135
+ }
123
136
  if (rootLevelPost === 'template') {
124
137
  return templateBlocks;
125
138
  }
126
139
  return postBlocks;
127
- }, [templateBlocks, postBlocks, rootLevelPost, post.type, post.id, mode]);
140
+ }, [maybeNavigationBlocks, maybePostOnlyBlocks, rootLevelPost, templateBlocks, postBlocks]);
141
+
142
+ // Handle fallback to postBlocks outside of the above useMemo, to ensure
143
+ // that constructed block templates that call `createBlock` are not generated
144
+ // too frequently. This ensures that clientIds are stable.
128
145
  const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation' || mode === 'post-only';
129
146
  const navigationBlockClientId = post.type === 'wp_navigation' && blocks && blocks[0]?.clientId;
130
147
  useForceFocusModeForNavigation(navigationBlockClientId);
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","blockEditorStore","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","PAGE_CONTENT_BLOCK_TYPES","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","useForceFocusModeForNavigation","navigationBlockClientId","setBlockEditingMode","unsetBlockEditingMode","extractPageContentBlockTypesFromTemplateBlocks","blocks","result","i","length","name","includes","push","innerBlocks","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","ref","templateLock","postContentBlocks","layout","style","spacing","margin","top","disableRootLevelChanges","clientId","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","postLock","autosave","actions","label","url","editLink","createElement","kind","value","useSubRegistry","EditorProvider","props"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n *\n * @param {string} navigationBlockClientId ClientId.\n */\nfunction useForceFocusModeForNavigation( navigationBlockClientId ) {\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! navigationBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( navigationBlockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( navigationBlockClientId );\n\t\t};\n\t}, [\n\t\tnavigationBlockClientId,\n\t\tunsetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n}\n\n/**\n * Helper method to extract the post content block types from a template.\n *\n * @param {Array} blocks Template blocks.\n *\n * @return {Array} Flattened object.\n */\nfunction extractPageContentBlockTypesFromTemplateBlocks( blocks ) {\n\tconst result = [];\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\t// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,\n\t\t// we skip it because we only want to render stand-alone page content blocks in the block list.\n\t\tif ( blocks[ i ].name === 'core/query' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {\n\t\t\tresult.push( createBlock( blocks[ i ].name ) );\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tresult.push(\n\t\t\t\t...extractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst blocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\n\t\tif ( mode === 'post-only' ) {\n\t\t\tconst postContentBlocks =\n\t\t\t\textractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\ttemplateBlocks\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\ttop: '4em', // Mimics the post editor.\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\tpostContentBlocks.length\n\t\t\t\t\t\t? postContentBlocks\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-title' ),\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-content' ),\n\t\t\t\t\t\t ]\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [\n\t\ttemplateBlocks,\n\t\tpostBlocks,\n\t\trootLevelPost,\n\t\tpost.type,\n\t\tpost.id,\n\t\tmode,\n\t] );\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation' ||\n\t\tmode === 'post-only';\n\tconst navigationBlockClientId =\n\t\tpost.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;\n\tuseForceFocusModeForNavigation( navigationBlockClientId );\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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);\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ [ 'post-only', 'template-locked' ].includes(\n\t\t\t\t\t\t\t\tmode\n\t\t\t\t\t\t\t) && <DisableNonPageContentBlocks /> }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,eAAe,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC3E,SACCC,mBAAmB,EACnBC,oBAAoB,EACpBC,WAAW,IAAIC,sBAAsB,EACrCC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASJ,WAAW,IAAIK,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,MAAM;EAAEC;AAAgC,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C,KAAK,EAAGpE,MAAQ;IAChBe,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnBmC,SAAS,EAAGA,SAAW;IACvBjB,QAAQ,EAAGsB,mBAAqB;IAChCe,cAAc,EAAG;EAAO,GAEtBlC,QAAQ,EACV+B,aAAA,CAACzE,iBAAiB,MAAE,CAAC,EACnB,CAAE,WAAW,EAAE,iBAAiB,CAAE,CAACY,QAAQ,CAC5CM,IACD,CAAC,IAAIuD,aAAA,CAAC5E,2BAA2B,MAAE,CACN,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASgF,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACnC,0BAA0B;IAAA,GACrBwC,KAAK;IACVnC,4BAA4B,EAAG3D;EAAqB,GAElD8F,KAAK,CAACpC,QACmB,CAAC;AAE/B;AAEA,eAAemC,cAAc"}
1
+ {"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","blockEditorStore","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","PAGE_CONTENT_BLOCK_TYPES","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","useForceFocusModeForNavigation","navigationBlockClientId","setBlockEditingMode","unsetBlockEditingMode","extractPageContentBlockTypesFromTemplateBlocks","blocks","result","i","length","name","includes","push","innerBlocks","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","ref","templateLock","maybePostOnlyBlocks","postContentBlocks","layout","style","spacing","margin","top","disableRootLevelChanges","clientId","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","postLock","autosave","actions","label","url","editLink","createElement","kind","value","useSubRegistry","EditorProvider","props"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n *\n * @param {string} navigationBlockClientId ClientId.\n */\nfunction useForceFocusModeForNavigation( navigationBlockClientId ) {\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! navigationBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( navigationBlockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( navigationBlockClientId );\n\t\t};\n\t}, [\n\t\tnavigationBlockClientId,\n\t\tunsetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n}\n\n/**\n * Helper method to extract the post content block types from a template.\n *\n * @param {Array} blocks Template blocks.\n *\n * @return {Array} Flattened object.\n */\nfunction extractPageContentBlockTypesFromTemplateBlocks( blocks ) {\n\tconst result = [];\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\t// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,\n\t\t// we skip it because we only want to render stand-alone page content blocks in the block list.\n\t\tif ( blocks[ i ].name === 'core/query' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {\n\t\t\tresult.push( createBlock( blocks[ i ].name ) );\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tresult.push(\n\t\t\t\t...extractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\tconst maybePostOnlyBlocks = useMemo( () => {\n\t\tif ( mode === 'post-only' ) {\n\t\t\tconst postContentBlocks =\n\t\t\t\textractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\ttemplateBlocks\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\ttop: '4em', // Mimics the post editor.\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\tpostContentBlocks.length\n\t\t\t\t\t\t? postContentBlocks\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-title' ),\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-content' ),\n\t\t\t\t\t\t ]\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t}, [ templateBlocks, mode ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( maybePostOnlyBlocks ) {\n\t\t\treturn maybePostOnlyBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [\n\t\tmaybeNavigationBlocks,\n\t\tmaybePostOnlyBlocks,\n\t\trootLevelPost,\n\t\ttemplateBlocks,\n\t\tpostBlocks,\n\t] );\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation' ||\n\t\tmode === 'post-only';\n\tconst navigationBlockClientId =\n\t\tpost.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;\n\tuseForceFocusModeForNavigation( navigationBlockClientId );\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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);\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ [ 'post-only', 'template-locked' ].includes(\n\t\t\t\t\t\t\t\tmode\n\t\t\t\t\t\t\t) && <DisableNonPageContentBlocks /> }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,eAAe,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC3E,SACCC,mBAAmB,EACnBC,oBAAoB,EACpBC,WAAW,IAAIC,sBAAsB,EACrCC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASJ,WAAW,IAAIK,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,MAAM;EAAEC;AAAgC,CAAC,GAAGH,MAAM,CAAET,sBAAuB,CAAC;AAC5E,MAAM;EAAEa;AAAkB,CAAC,GAAGJ,MAAM,CAAEL,uBAAwB,CAAC;AAE/D,MAAMU,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,8BAA8BA,CAAEC,uBAAuB,EAAG;EAClE,MAAM;IAAEC,mBAAmB;IAAEC;EAAsB,CAAC,GACnD1B,WAAW,CAAEU,gBAAiB,CAAC;EAEhCb,SAAS,CAAE,MAAM;IAChB,IAAK,CAAE2B,uB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AAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnBqC,SAAS,EAAGA,SAAW;IACvBjB,QAAQ,EAAGsB,mBAAqB;IAChCe,cAAc,EAAG;EAAO,GAEtBlC,QAAQ,EACV+B,aAAA,CAAC3E,iBAAiB,MAAE,CAAC,EACnB,CAAE,WAAW,EAAE,iBAAiB,CAAE,CAACY,QAAQ,CAC5CM,IACD,CAAC,IAAIyD,aAAA,CAAC9E,2BAA2B,MAAE,CACN,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASkF,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACnC,0BAA0B;IAAA,GACrBwC,KAAK;IACVnC,4BAA4B,EAAG7D;EAAqB,GAElDgG,KAAK,CAACpC,QACmB,CAAC;AAE/B;AAEA,eAAemC,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "13.24.0",
3
+ "version": "13.24.1",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
77
+ "gitHead": "12b897d7feff1cb00ddbf9016b62c1177d9c0081"
78
78
  }
@@ -111,7 +111,7 @@ function useBlockEditorProps( post, template, mode ) {
111
111
  useEntityBlockEditor( 'postType', template?.type, {
112
112
  id: template?.id,
113
113
  } );
114
- const blocks = useMemo( () => {
114
+ const maybeNavigationBlocks = useMemo( () => {
115
115
  if ( post.type === 'wp_navigation' ) {
116
116
  return [
117
117
  createBlock( 'core/navigation', {
@@ -123,7 +123,9 @@ function useBlockEditorProps( post, template, mode ) {
123
123
  } ),
124
124
  ];
125
125
  }
126
+ }, [ post.type, post.id ] );
126
127
 
128
+ const maybePostOnlyBlocks = useMemo( () => {
127
129
  if ( mode === 'post-only' ) {
128
130
  const postContentBlocks =
129
131
  extractPageContentBlockTypesFromTemplateBlocks(
@@ -151,6 +153,18 @@ function useBlockEditorProps( post, template, mode ) {
151
153
  ),
152
154
  ];
153
155
  }
156
+ }, [ templateBlocks, mode ] );
157
+
158
+ // It is important that we don't create a new instance of blocks on every change
159
+ // We should only create a new instance if the blocks them selves change, not a dependency of them.
160
+ const blocks = useMemo( () => {
161
+ if ( maybeNavigationBlocks ) {
162
+ return maybeNavigationBlocks;
163
+ }
164
+
165
+ if ( maybePostOnlyBlocks ) {
166
+ return maybePostOnlyBlocks;
167
+ }
154
168
 
155
169
  if ( rootLevelPost === 'template' ) {
156
170
  return templateBlocks;
@@ -158,13 +172,16 @@ function useBlockEditorProps( post, template, mode ) {
158
172
 
159
173
  return postBlocks;
160
174
  }, [
175
+ maybeNavigationBlocks,
176
+ maybePostOnlyBlocks,
177
+ rootLevelPost,
161
178
  templateBlocks,
162
179
  postBlocks,
163
- rootLevelPost,
164
- post.type,
165
- post.id,
166
- mode,
167
180
  ] );
181
+
182
+ // Handle fallback to postBlocks outside of the above useMemo, to ensure
183
+ // that constructed block templates that call `createBlock` are not generated
184
+ // too frequently. This ensures that clientIds are stable.
168
185
  const disableRootLevelChanges =
169
186
  ( !! template && mode === 'template-locked' ) ||
170
187
  post.type === 'wp_navigation' ||