@wordpress/editor 13.29.0 → 13.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/bindings/index.js +5 -3
- package/build/bindings/index.js.map +1 -1
- package/build/bindings/post-meta.js +2 -1
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-removal-warnings/index.js +70 -0
- package/build/components/block-removal-warnings/index.js.map +1 -0
- package/build/components/commands/index.js +22 -14
- package/build/components/commands/index.js.map +1 -1
- package/build/components/document-bar/index.js +2 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/check.js +8 -7
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +27 -28
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +5 -3
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build/components/entities-saved-states/index.js +17 -3
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/error-boundary/index.native.js +133 -0
- package/build/components/error-boundary/index.native.js.map +1 -0
- package/build/components/index.js +9 -8
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +1 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/plugin-document-setting-panel/index.js +123 -0
- package/build/components/plugin-document-setting-panel/index.js.map +1 -0
- package/build/components/post-featured-image/index.js +3 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +7 -3
- package/build/components/post-featured-image/panel.js.map +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +2 -1
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +2 -1
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-sync-status/index.js +0 -72
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +7 -3
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -0
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-view-link/index.js +2 -1
- package/build/components/post-view-link/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +23 -30
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/index.js +3 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-hide-blocks-from-inserter.js +4 -3
- package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/{pattern-partial-syncing.js → pattern-overrides.js} +13 -9
- package/build/hooks/pattern-overrides.js.map +1 -0
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build-module/bindings/index.js +5 -3
- package/build-module/bindings/index.js.map +1 -1
- package/build-module/bindings/post-meta.js +2 -1
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-removal-warnings/index.js +64 -0
- package/build-module/components/block-removal-warnings/index.js.map +1 -0
- package/build-module/components/commands/index.js +22 -14
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +2 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/check.js +9 -8
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js +27 -27
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +5 -3
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +18 -4
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/error-boundary/index.native.js +125 -0
- package/build-module/components/error-boundary/index.native.js.map +1 -0
- package/build-module/components/index.js +2 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +1 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/plugin-document-setting-panel/index.js +115 -0
- package/build-module/components/plugin-document-setting-panel/index.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +4 -9
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +6 -2
- package/build-module/components/post-featured-image/panel.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +2 -1
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +2 -1
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +2 -73
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +7 -3
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -0
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-view-link/index.js +2 -1
- package/build-module/components/post-view-link/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +24 -31
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/index.js +3 -2
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-hide-blocks-from-inserter.js +4 -3
- package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build-module/hooks/index.js +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/{pattern-partial-syncing.js → pattern-overrides.js} +13 -9
- package/build-module/hooks/pattern-overrides.js.map +1 -0
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-style/style-rtl.css +9 -8
- package/build-style/style.css +9 -8
- package/package.json +34 -32
- package/src/bindings/index.js +6 -3
- package/src/bindings/post-meta.js +4 -1
- package/src/components/block-removal-warnings/index.js +92 -0
- package/src/components/commands/index.js +21 -13
- package/src/components/document-bar/index.js +3 -2
- package/src/components/document-outline/check.js +8 -10
- package/src/components/document-outline/index.js +20 -24
- package/src/components/document-outline/test/index.js +26 -7
- package/src/components/document-tools/index.js +3 -3
- package/src/components/editor-help/intro-to-blocks.native.js +1 -1
- package/src/components/entities-saved-states/entity-type-list.js +1 -1
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +18 -22
- package/src/components/entities-saved-states/index.js +33 -8
- package/src/components/entities-saved-states/test/use-is-dirty.js +3 -0
- package/src/components/error-boundary/index.native.js +192 -0
- package/src/components/error-boundary/style.native.scss +116 -0
- package/src/components/index.js +2 -4
- package/src/components/index.native.js +1 -0
- package/src/components/list-view-sidebar/index.js +1 -1
- package/src/components/plugin-document-setting-panel/index.js +121 -0
- package/src/components/post-featured-image/index.js +6 -15
- package/src/components/post-featured-image/panel.js +9 -3
- package/src/components/post-featured-image/style.scss +8 -13
- package/src/components/post-locked-modal/index.js +1 -1
- package/src/components/post-preview-button/index.js +1 -0
- package/src/components/post-publish-button/index.js +1 -0
- package/src/components/post-publish-panel/index.js +1 -1
- package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +3 -3
- package/src/components/post-sync-status/index.js +1 -94
- package/src/components/post-taxonomies/flat-term-selector.js +13 -8
- package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -0
- package/src/components/post-title/index.native.js +2 -2
- package/src/components/post-title/post-title-raw.js +1 -1
- package/src/components/post-view-link/index.js +1 -0
- package/src/components/provider/disable-non-page-content-blocks.js +34 -36
- package/src/components/provider/index.js +3 -1
- package/src/components/provider/test/disable-non-page-content-blocks.js +90 -0
- package/src/components/provider/use-hide-blocks-from-inserter.js +5 -3
- package/src/hooks/index.js +1 -1
- package/src/hooks/{pattern-partial-syncing.js → pattern-overrides.js} +16 -10
- package/src/private-apis.js +0 -2
- package/build/components/provider/constants.js +0 -8
- package/build/components/provider/constants.js.map +0 -1
- package/build/hooks/pattern-partial-syncing.js.map +0 -1
- package/build-module/components/provider/constants.js +0 -2
- package/build-module/components/provider/constants.js.map +0 -1
- package/build-module/hooks/pattern-partial-syncing.js.map +0 -1
- package/src/components/provider/constants.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","NavigationBlockEditingMode","useHideBlocksFromInserter","useCommands","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","NON_CONTEXTUAL_POST_TYPES","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","ref","templateLock","blocks","disableRootLevelChanges","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","includes","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","setCurrentTemplateId","setEditedPost","setRenderingMode","createWarningNotice","postLock","autosave","actions","label","url","editLink","_settings$defaultRend","defaultRenderingMode","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} 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 NavigationBlockEditingMode from './navigation-block-editing-mode';\nimport { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';\nimport useCommands from '../commands';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * These are global entities that are only there to split blocks into logical units\n * They don't provide a \"context\" for the current post/page being rendered.\n * So we should not use their ids as post context. This is important to allow post blocks\n * (post content, post title) to be used within them without issues.\n */\nconst NON_CONTEXTUAL_POST_TYPES = [\n\t'wp_block',\n\t'wp_template',\n\t'wp_navigation',\n\t'wp_template_part',\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\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 ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\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\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\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\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\tshouldRenderTemplate,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\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\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\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\t\t}, [] );\n\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t}, [ post.type, post.id, setEditedPost ] );\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\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tsetRenderingMode( settings.defaultRenderingMode ?? 'post-only' );\n\t\t}, [ settings.defaultRenderingMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\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{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t) }\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,QAC/B,yBAAyB;AAChC,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASH,WAAW,IAAII,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,0BAA0B,MAAM,iCAAiC;AACxE,SAASC,yBAAyB,QAAQ,iCAAiC;AAC3E,OAAOC,WAAW,MAAM,aAAa;AAErC,MAAM;EAAEC;AAAgC,CAAC,GAAGL,MAAM,CAAER,sBAAuB,CAAC;AAC5E,MAAM;EAAEc;AAAkB,CAAC,GAAGN,MAAM,CAAEL,uBAAwB,CAAC;AAE/D,MAAMY,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,CACjC,UAAU,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,CAClB;;AAED;AACA;AACA;AACA;A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AACQ;EAAI,GAEdiD,aAAA,CAAC7E,oBAAoB;IAAC+E,KAAK,EAAGhC;EAAqB,GAClD8B,aAAA,CAACnC,4BAA4B;IAC5BqC,KAAK,EAAG5C,MAAQ;IAChBT,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnB+B,SAAS,EAAGA,SAAW;IACvBlB,QAAQ,EAAGuB,mBAAqB;IAChCmB,cAAc,EAAG;EAAO,GAEtBvC,QAAQ,EACVoC,aAAA,CAAC7D,iBAAiB,MAAE,CAAC,EACnBM,IAAI,KAAK,iBAAiB,IAC3BuD,aAAA,CAAClE,2BAA2B,MAAE,CAC9B,EACCgB,IAAI,KAAK,eAAe,IACzBkD,aAAA,CAACjE,0BAA0B,MAAE,CAED,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASqE,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACxC,0BAA0B;IAAA,GACrB6C,KAAK;IACVxC,4BAA4B,EAAG3C;EAAqB,GAElDmF,KAAK,CAACzC,QACmB,CAAC;AAE/B;AAEA,eAAewC,cAAc"}
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","NavigationBlockEditingMode","useHideBlocksFromInserter","useCommands","BlockRemovalWarnings","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","NON_CONTEXTUAL_POST_TYPES","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","ref","templateLock","blocks","disableRootLevelChanges","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","includes","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","setCurrentTemplateId","setEditedPost","setRenderingMode","createWarningNotice","postLock","autosave","actions","label","url","editLink","_settings$defaultRend","defaultRenderingMode","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} 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 NavigationBlockEditingMode from './navigation-block-editing-mode';\nimport { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';\nimport useCommands from '../commands';\nimport BlockRemovalWarnings from '../block-removal-warnings';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * These are global entities that are only there to split blocks into logical units\n * They don't provide a \"context\" for the current post/page being rendered.\n * So we should not use their ids as post context. This is important to allow post blocks\n * (post content, post title) to be used within them without issues.\n */\nconst NON_CONTEXTUAL_POST_TYPES = [\n\t'wp_block',\n\t'wp_template',\n\t'wp_navigation',\n\t'wp_template_part',\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\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 ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\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\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\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\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\tshouldRenderTemplate,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\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\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\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\t\t}, [] );\n\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t}, [ post.type, post.id, setEditedPost ] );\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\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tsetRenderingMode( settings.defaultRenderingMode ?? 'post-only' );\n\t\t}, [ settings.defaultRenderingMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\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{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockRemovalWarnings />\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,QAC/B,yBAAyB;AAChC,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASH,WAAW,IAAII,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,0BAA0B,MAAM,iCAAiC;AACxE,SAASC,yBAAyB,QAAQ,iCAAiC;AAC3E,OAAOC,WAAW,MAAM,aAAa;AACrC,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,MAAM;EAAEC;AAAgC,CAAC,GAAGN,MAAM,CAAER,sBAAuB,CAAC;AAC5E,MAAM;EAAEe;AAAkB,CAAC,GAAGP,MAAM,CAAEL,uBAAwB,CAAC;AAE/D,MAAMa,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,CACjC,UAAU,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,CAClB;;AAED;AACA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BC,EAAE,EAAGR,IAAI,CAACQ;EAAI,GAEdiD,aAAA,CAAC9E,oBAAoB;IAACgF,KAAK,EAAGhC;EAAqB,GAClD8B,aAAA,CAACnC,4BAA4B;IAC5BqC,KAAK,EAAG5C,MAAQ;IAChBT,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnB+B,SAAS,EAAGA,SAAW;IACvBlB,QAAQ,EAAGuB,mBAAqB;IAChCmB,cAAc,EAAG;EAAO,GAEtBvC,QAAQ,EACVoC,aAAA,CAAC7D,iBAAiB,MAAE,CAAC,EACnBM,IAAI,KAAK,iBAAiB,IAC3BuD,aAAA,CAACnE,2BAA2B,MAAE,CAC9B,EACCiB,IAAI,KAAK,eAAe,IACzBkD,aAAA,CAAClE,0BAA0B,MAAE,CAC7B,EACDkE,aAAA,CAAC/D,oBAAoB,MAAE,CACM,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASmE,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACxC,0BAA0B;IAAA,GACrB6C,KAAK;IACVxC,4BAA4B,EAAG5C;EAAqB,GAElDoF,KAAK,CAACzC,QACmB,CAAC;AAE/B;AAEA,eAAewC,cAAc"}
|
|
@@ -14,14 +14,15 @@ const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template
|
|
|
14
14
|
* the template part and post content blocks need to be hidden.
|
|
15
15
|
*
|
|
16
16
|
* @param {string} postType Post Type
|
|
17
|
+
* @param {string} mode Rendering mode
|
|
17
18
|
*/
|
|
18
|
-
export function useHideBlocksFromInserter(postType) {
|
|
19
|
+
export function useHideBlocksFromInserter(postType, mode) {
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
/*
|
|
21
22
|
* Prevent adding template part in the editor.
|
|
22
23
|
*/
|
|
23
24
|
addFilter('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
|
|
24
|
-
if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part') {
|
|
25
|
+
if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
|
|
25
26
|
return false;
|
|
26
27
|
}
|
|
27
28
|
return canInsert;
|
|
@@ -42,6 +43,6 @@ export function useHideBlocksFromInserter(postType) {
|
|
|
42
43
|
removeFilter('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
|
|
43
44
|
removeFilter('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
|
|
44
45
|
};
|
|
45
|
-
}, [postType]);
|
|
46
|
+
}, [postType, mode]);
|
|
46
47
|
}
|
|
47
48
|
//# sourceMappingURL=use-hide-blocks-from-inserter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","addFilter","removeFilter","POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART","useHideBlocksFromInserter","postType","canInsert","blockType","includes","name","rootClientId","getBlockParentsByBlockName","length"],"sources":["@wordpress/editor/src/components/provider/use-hide-blocks-from-inserter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { addFilter, removeFilter } from '@wordpress/hooks';\n\n// These post types are \"structural\" block lists.\n// We should be allowed to use\n// the post content and template parts blocks within them.\nconst POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [\n\t'wp_block',\n\t'wp_template',\n\t'wp_template_part',\n];\n\n/**\n * In some specific contexts,\n * the template part and post content blocks need to be hidden.\n *\n * @param {string} postType Post Type\n */\nexport function useHideBlocksFromInserter( postType ) {\n\tuseEffect( () => {\n\t\t/*\n\t\t * Prevent adding template part in the editor.\n\t\t */\n\t\taddFilter(\n\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t'removeTemplatePartsFromInserter',\n\t\t\t( canInsert, blockType ) => {\n\t\t\t\tif (\n\t\t\t\t\t! POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(\n\t\t\t\t\t\tpostType\n\t\t\t\t\t) &&\n\t\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn canInsert;\n\t\t\t}\n\t\t);\n\n\t\t/*\n\t\t * Prevent adding post content block (except in query block) in the editor.\n\t\t */\n\t\taddFilter(\n\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t'removePostContentFromInserter',\n\t\t\t(\n\t\t\t\tcanInsert,\n\t\t\t\tblockType,\n\t\t\t\trootClientId,\n\t\t\t\t{ getBlockParentsByBlockName }\n\t\t\t) => {\n\t\t\t\tif (\n\t\t\t\t\t! POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(\n\t\t\t\t\t\tpostType\n\t\t\t\t\t) &&\n\t\t\t\t\tblockType.name === 'core/post-content'\n\t\t\t\t) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tgetBlockParentsByBlockName( rootClientId, 'core/query' )\n\t\t\t\t\t\t\t.length > 0\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn canInsert;\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tremoveFilter(\n\t\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t\t'removeTemplatePartsFromInserter'\n\t\t\t);\n\t\t\tremoveFilter(\n\t\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t\t'removePostContentFromInserter'\n\t\t\t);\n\t\t};\n\t}, [ postType ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,MAAMC,8CAA8C,GAAG,CACtD,UAAU,EACV,aAAa,EACb,kBAAkB,CAClB;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAEC,QAAQ,EAAG;
|
|
1
|
+
{"version":3,"names":["useEffect","addFilter","removeFilter","POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART","useHideBlocksFromInserter","postType","mode","canInsert","blockType","includes","name","rootClientId","getBlockParentsByBlockName","length"],"sources":["@wordpress/editor/src/components/provider/use-hide-blocks-from-inserter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { addFilter, removeFilter } from '@wordpress/hooks';\n\n// These post types are \"structural\" block lists.\n// We should be allowed to use\n// the post content and template parts blocks within them.\nconst POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [\n\t'wp_block',\n\t'wp_template',\n\t'wp_template_part',\n];\n\n/**\n * In some specific contexts,\n * the template part and post content blocks need to be hidden.\n *\n * @param {string} postType Post Type\n * @param {string} mode Rendering mode\n */\nexport function useHideBlocksFromInserter( postType, mode ) {\n\tuseEffect( () => {\n\t\t/*\n\t\t * Prevent adding template part in the editor.\n\t\t */\n\t\taddFilter(\n\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t'removeTemplatePartsFromInserter',\n\t\t\t( canInsert, blockType ) => {\n\t\t\t\tif (\n\t\t\t\t\t! POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(\n\t\t\t\t\t\tpostType\n\t\t\t\t\t) &&\n\t\t\t\t\tblockType.name === 'core/template-part' &&\n\t\t\t\t\tmode === 'post-only'\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn canInsert;\n\t\t\t}\n\t\t);\n\n\t\t/*\n\t\t * Prevent adding post content block (except in query block) in the editor.\n\t\t */\n\t\taddFilter(\n\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t'removePostContentFromInserter',\n\t\t\t(\n\t\t\t\tcanInsert,\n\t\t\t\tblockType,\n\t\t\t\trootClientId,\n\t\t\t\t{ getBlockParentsByBlockName }\n\t\t\t) => {\n\t\t\t\tif (\n\t\t\t\t\t! POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(\n\t\t\t\t\t\tpostType\n\t\t\t\t\t) &&\n\t\t\t\t\tblockType.name === 'core/post-content'\n\t\t\t\t) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tgetBlockParentsByBlockName( rootClientId, 'core/query' )\n\t\t\t\t\t\t\t.length > 0\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn canInsert;\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tremoveFilter(\n\t\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t\t'removeTemplatePartsFromInserter'\n\t\t\t);\n\t\t\tremoveFilter(\n\t\t\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t\t\t'removePostContentFromInserter'\n\t\t\t);\n\t\t};\n\t}, [ postType, mode ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,MAAMC,8CAA8C,GAAG,CACtD,UAAU,EACV,aAAa,EACb,kBAAkB,CAClB;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAEC,QAAQ,EAAEC,IAAI,EAAG;EAC3DN,SAAS,CAAE,MAAM;IAChB;AACF;AACA;IACEC,SAAS,CACR,0CAA0C,EAC1C,iCAAiC,EACjC,CAAEM,SAAS,EAAEC,SAAS,KAAM;MAC3B,IACC,CAAEL,8CAA8C,CAACM,QAAQ,CACxDJ,QACD,CAAC,IACDG,SAAS,CAACE,IAAI,KAAK,oBAAoB,IACvCJ,IAAI,KAAK,WAAW,EACnB;QACD,OAAO,KAAK;MACb;MACA,OAAOC,SAAS;IACjB,CACD,CAAC;;IAED;AACF;AACA;IACEN,SAAS,CACR,0CAA0C,EAC1C,+BAA+B,EAC/B,CACCM,SAAS,EACTC,SAAS,EACTG,YAAY,EACZ;MAAEC;IAA2B,CAAC,KAC1B;MACJ,IACC,CAAET,8CAA8C,CAACM,QAAQ,CACxDJ,QACD,CAAC,IACDG,SAAS,CAACE,IAAI,KAAK,mBAAmB,EACrC;QACD,OACCE,0BAA0B,CAAED,YAAY,EAAE,YAAa,CAAC,CACtDE,MAAM,GAAG,CAAC;MAEd;MACA,OAAON,SAAS;IACjB,CACD,CAAC;IAED,OAAO,MAAM;MACZL,YAAY,CACX,0CAA0C,EAC1C,iCACD,CAAC;MACDA,YAAY,CACX,0CAA0C,EAC1C,+BACD,CAAC;IACF,CAAC;EACF,CAAC,EAAE,CAAEG,QAAQ,EAAEC,IAAI,CAAG,CAAC;AACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-overrides';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,0CAA0C;AACjD,OAAO,0BAA0B;AACjC,OAAO,qBAAqB"}
|
|
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
14
14
|
import { store as editorStore } from '../store';
|
|
15
15
|
import { unlock } from '../lock-unlock';
|
|
16
16
|
const {
|
|
17
|
-
|
|
17
|
+
useSetPatternBindings,
|
|
18
18
|
ResetOverridesControl,
|
|
19
19
|
PATTERN_TYPES,
|
|
20
20
|
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
@@ -29,14 +29,21 @@ const {
|
|
|
29
29
|
*
|
|
30
30
|
* @return {Component} Wrapped component.
|
|
31
31
|
*/
|
|
32
|
-
const
|
|
32
|
+
const withPatternOverrideControls = createHigherOrderComponent(BlockEdit => props => {
|
|
33
33
|
const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
|
|
34
34
|
return createElement(Fragment, null, createElement(BlockEdit, {
|
|
35
35
|
...props
|
|
36
|
+
}), isSupportedBlock && createElement(BindingUpdater, {
|
|
37
|
+
...props
|
|
36
38
|
}), props.isSelected && isSupportedBlock && createElement(ControlsWithStoreSubscription, {
|
|
37
39
|
...props
|
|
38
40
|
}));
|
|
39
41
|
});
|
|
42
|
+
function BindingUpdater(props) {
|
|
43
|
+
const postType = useSelect(select => select(editorStore).getCurrentPostType(), []);
|
|
44
|
+
useSetPatternBindings(props, postType);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
40
47
|
|
|
41
48
|
// Split into a separate component to avoid a store subscription
|
|
42
49
|
// on every block.
|
|
@@ -45,13 +52,10 @@ function ControlsWithStoreSubscription(props) {
|
|
|
45
52
|
const isEditingPattern = useSelect(select => select(editorStore).getCurrentPostType() === PATTERN_TYPES.user, []);
|
|
46
53
|
const bindings = props.attributes.metadata?.bindings;
|
|
47
54
|
const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
return createElement(Fragment, null, shouldShowPartialSyncingControls && createElement(PartialSyncingControls, {
|
|
51
|
-
...props
|
|
52
|
-
}), shouldShowResetOverridesControl && createElement(ResetOverridesControl, {
|
|
55
|
+
const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
|
|
56
|
+
return createElement(Fragment, null, shouldShowResetOverridesControl && createElement(ResetOverridesControl, {
|
|
53
57
|
...props
|
|
54
58
|
}));
|
|
55
59
|
}
|
|
56
|
-
addFilter('editor.BlockEdit', 'core/editor/with-
|
|
57
|
-
//# sourceMappingURL=pattern-
|
|
60
|
+
addFilter('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
|
|
61
|
+
//# sourceMappingURL=pattern-overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","editorStore","unlock","useSetPatternBindings","ResetOverridesControl","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","Object","keys","includes","name","createElement","Fragment","BindingUpdater","isSelected","ControlsWithStoreSubscription","postType","select","getCurrentPostType","blockEditingMode","isEditingPattern","user","bindings","attributes","metadata","hasPatternBindings","values","some","binding","source","shouldShowResetOverridesControl"],"sources":["@wordpress/editor/src/hooks/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useBlockEditingMode } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst {\n\tuseSetPatternBindings,\n\tResetOverridesControl,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} = unlock( patternsPrivateApis );\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning a partial syncing controls to supported blocks in the pattern editor.\n * Currently, only the `core/paragraph` block is supported.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withPatternOverrideControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock = Object.keys(\n\t\t\tPARTIAL_SYNCING_SUPPORTED_BLOCKS\n\t\t).includes( props.name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ isSupportedBlock && <BindingUpdater { ...props } /> }\n\t\t\t\t{ props.isSelected && isSupportedBlock && (\n\t\t\t\t\t<ControlsWithStoreSubscription { ...props } />\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\nfunction BindingUpdater( props ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentPostType(),\n\t\t[]\n\t);\n\tuseSetPatternBindings( props, postType );\n\treturn null;\n}\n\n// Split into a separate component to avoid a store subscription\n// on every block.\nfunction ControlsWithStoreSubscription( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isEditingPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,\n\t\t[]\n\t);\n\n\tconst bindings = props.attributes.metadata?.bindings;\n\tconst hasPatternBindings =\n\t\t!! bindings &&\n\t\tObject.values( bindings ).some(\n\t\t\t( binding ) => binding.source === 'core/pattern-overrides'\n\t\t);\n\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowResetOverridesControl && (\n\t\t\t\t<ResetOverridesControl { ...props } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/with-pattern-override-controls',\n\twithPatternOverrideControls\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,IAAIC,mBAAmB,QAAQ,qBAAqB;AACxE,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAM;EACLC,qBAA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CAACmB,MAAM,CAAEJ,QAAS,CAAC,CAACK,IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,+BAA+B,GACpC,CAAEV,gBAAgB,IAClB,CAAC,CAAEf,KAAK,CAACkB,UAAU,CAACC,QAAQ,EAAEd,IAAI,IAClCS,gBAAgB,KAAK,UAAU,IAC/BM,kBAAkB;EAEnB,OACCd,aAAA,CAAAC,QAAA,QACGkB,+BAA+B,IAChCnB,aAAA,CAACX,qBAAqB;IAAA,GAAMK;EAAK,CAAI,CAErC,CAAC;AAEL;AAEAf,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5Ca,2BACD,CAAC"}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import EditorCanvas from './components/editor-canvas';
|
|
5
5
|
import { ExperimentalEditorProvider } from './components/provider';
|
|
6
6
|
import { lock } from './lock-unlock';
|
|
7
|
-
import EnablePluginDocumentSettingPanelOption from './components/preferences-modal/enable-plugin-document-setting-panel';
|
|
8
7
|
import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
|
|
9
8
|
import useBlockEditorSettings from './components/provider/use-block-editor-settings';
|
|
10
9
|
import DocumentTools from './components/document-tools';
|
|
@@ -21,7 +20,6 @@ lock(privateApis, {
|
|
|
21
20
|
DocumentTools,
|
|
22
21
|
EditorCanvas,
|
|
23
22
|
ExperimentalEditorProvider,
|
|
24
|
-
EnablePluginDocumentSettingPanelOption,
|
|
25
23
|
EntitiesSavedStatesExtensible,
|
|
26
24
|
InserterSidebar,
|
|
27
25
|
ListViewSidebar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EditorCanvas","ExperimentalEditorProvider","lock","
|
|
1
|
+
{"version":3,"names":["EditorCanvas","ExperimentalEditorProvider","lock","EntitiesSavedStatesExtensible","useBlockEditorSettings","DocumentTools","InserterSidebar","ListViewSidebar","ModeSwitcher","PluginPostExcerpt","PostPanelRow","PostViewLink","PreviewDropdown","PreferencesModal","privateApis"],"sources":["@wordpress/editor/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport EditorCanvas from './components/editor-canvas';\nimport { ExperimentalEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport useBlockEditorSettings from './components/provider/use-block-editor-settings';\nimport DocumentTools from './components/document-tools';\nimport InserterSidebar from './components/inserter-sidebar';\nimport ListViewSidebar from './components/list-view-sidebar';\nimport ModeSwitcher from './components/mode-switcher';\nimport PluginPostExcerpt from './components/post-excerpt/plugin';\nimport PostPanelRow from './components/post-panel-row';\nimport PostViewLink from './components/post-view-link';\nimport PreviewDropdown from './components/preview-dropdown';\nimport PreferencesModal from './components/preferences-modal';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tDocumentTools,\n\tEditorCanvas,\n\tExperimentalEditorProvider,\n\tEntitiesSavedStatesExtensible,\n\tInserterSidebar,\n\tListViewSidebar,\n\tModeSwitcher,\n\tPluginPostExcerpt,\n\tPostPanelRow,\n\tPostViewLink,\n\tPreviewDropdown,\n\tPreferencesModal,\n\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tuseBlockEditorSettings,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,YAAY,MAAM,4BAA4B;AACrD,SAASC,0BAA0B,QAAQ,uBAAuB;AAClE,SAASC,IAAI,QAAQ,eAAe;AACpC,SAASC,6BAA6B,QAAQ,oCAAoC;AAClF,OAAOC,sBAAsB,MAAM,iDAAiD;AACpF,OAAOC,aAAa,MAAM,6BAA6B;AACvD,OAAOC,eAAe,MAAM,+BAA+B;AAC3D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,YAAY,MAAM,4BAA4B;AACrD,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,YAAY,MAAM,6BAA6B;AACtD,OAAOC,YAAY,MAAM,6BAA6B;AACtD,OAAOC,eAAe,MAAM,+BAA+B;AAC3D,OAAOC,gBAAgB,MAAM,gCAAgC;AAE7D,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7BZ,IAAI,CAAEY,WAAW,EAAE;EAClBT,aAAa;EACbL,YAAY;EACZC,0BAA0B;EAC1BE,6BAA6B;EAC7BG,eAAe;EACfC,eAAe;EACfC,YAAY;EACZC,iBAAiB;EACjBC,YAAY;EACZC,YAAY;EACZC,eAAe;EACfC,gBAAgB;EAEhB;EACAT;AACD,CAAE,CAAC"}
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
--wp-admin-border-width-focus: 2px;
|
|
98
98
|
--wp-block-synced-color: #7a00df;
|
|
99
99
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
100
|
+
--wp-bound-block-color: #9747ff;
|
|
100
101
|
}
|
|
101
102
|
@media (min-resolution: 192dpi) {
|
|
102
103
|
:root {
|
|
@@ -696,13 +697,10 @@
|
|
|
696
697
|
margin-top: -9px;
|
|
697
698
|
margin-right: -9px;
|
|
698
699
|
}
|
|
699
|
-
.editor-post-featured-image .components-responsive-wrapper__content {
|
|
700
|
-
max-width: 100%;
|
|
701
|
-
width: auto;
|
|
702
|
-
}
|
|
703
700
|
|
|
704
701
|
.editor-post-featured-image__container {
|
|
705
702
|
position: relative;
|
|
703
|
+
aspect-ratio: 2/1;
|
|
706
704
|
}
|
|
707
705
|
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
708
706
|
opacity: 1;
|
|
@@ -715,9 +713,10 @@
|
|
|
715
713
|
transition: all 0.1s ease-out;
|
|
716
714
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
717
715
|
overflow: hidden;
|
|
716
|
+
outline: 1px solid rgba(0, 0, 0, 0.1);
|
|
717
|
+
outline-offset: -1px;
|
|
718
718
|
display: flex;
|
|
719
719
|
justify-content: center;
|
|
720
|
-
max-height: 150px;
|
|
721
720
|
}
|
|
722
721
|
@media (prefers-reduced-motion: reduce) {
|
|
723
722
|
.editor-post-featured-image__toggle,
|
|
@@ -730,15 +729,17 @@
|
|
|
730
729
|
.editor-post-featured-image__preview {
|
|
731
730
|
height: auto;
|
|
732
731
|
}
|
|
733
|
-
.editor-post-featured-image__preview .
|
|
732
|
+
.editor-post-featured-image__preview .editor-post-featured-image__preview-image {
|
|
733
|
+
object-fit: cover;
|
|
734
734
|
width: 100%;
|
|
735
|
-
|
|
735
|
+
object-position: 50% 50%;
|
|
736
|
+
aspect-ratio: 2/1;
|
|
736
737
|
}
|
|
737
738
|
|
|
738
739
|
.editor-post-featured-image__toggle {
|
|
739
740
|
border-radius: 2px;
|
|
740
741
|
background-color: #f0f0f0;
|
|
741
|
-
|
|
742
|
+
height: 100%;
|
|
742
743
|
line-height: 20px;
|
|
743
744
|
padding: 8px 0;
|
|
744
745
|
text-align: center;
|
package/build-style/style.css
CHANGED
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
--wp-admin-border-width-focus: 2px;
|
|
98
98
|
--wp-block-synced-color: #7a00df;
|
|
99
99
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
100
|
+
--wp-bound-block-color: #9747ff;
|
|
100
101
|
}
|
|
101
102
|
@media (min-resolution: 192dpi) {
|
|
102
103
|
:root {
|
|
@@ -696,13 +697,10 @@
|
|
|
696
697
|
margin-top: -9px;
|
|
697
698
|
margin-left: -9px;
|
|
698
699
|
}
|
|
699
|
-
.editor-post-featured-image .components-responsive-wrapper__content {
|
|
700
|
-
max-width: 100%;
|
|
701
|
-
width: auto;
|
|
702
|
-
}
|
|
703
700
|
|
|
704
701
|
.editor-post-featured-image__container {
|
|
705
702
|
position: relative;
|
|
703
|
+
aspect-ratio: 2/1;
|
|
706
704
|
}
|
|
707
705
|
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
708
706
|
opacity: 1;
|
|
@@ -715,9 +713,10 @@
|
|
|
715
713
|
transition: all 0.1s ease-out;
|
|
716
714
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
717
715
|
overflow: hidden;
|
|
716
|
+
outline: 1px solid rgba(0, 0, 0, 0.1);
|
|
717
|
+
outline-offset: -1px;
|
|
718
718
|
display: flex;
|
|
719
719
|
justify-content: center;
|
|
720
|
-
max-height: 150px;
|
|
721
720
|
}
|
|
722
721
|
@media (prefers-reduced-motion: reduce) {
|
|
723
722
|
.editor-post-featured-image__toggle,
|
|
@@ -730,15 +729,17 @@
|
|
|
730
729
|
.editor-post-featured-image__preview {
|
|
731
730
|
height: auto;
|
|
732
731
|
}
|
|
733
|
-
.editor-post-featured-image__preview .
|
|
732
|
+
.editor-post-featured-image__preview .editor-post-featured-image__preview-image {
|
|
733
|
+
object-fit: cover;
|
|
734
734
|
width: 100%;
|
|
735
|
-
|
|
735
|
+
object-position: 50% 50%;
|
|
736
|
+
aspect-ratio: 2/1;
|
|
736
737
|
}
|
|
737
738
|
|
|
738
739
|
.editor-post-featured-image__toggle {
|
|
739
740
|
border-radius: 2px;
|
|
740
741
|
background-color: #f0f0f0;
|
|
741
|
-
|
|
742
|
+
height: 100%;
|
|
742
743
|
line-height: 20px;
|
|
743
744
|
padding: 8px 0;
|
|
744
745
|
text-align: center;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.31.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,36 +31,38 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^6.
|
|
36
|
-
"@wordpress/blob": "^3.
|
|
37
|
-
"@wordpress/block-editor": "^12.
|
|
38
|
-
"@wordpress/blocks": "^12.
|
|
39
|
-
"@wordpress/commands": "^0.
|
|
40
|
-
"@wordpress/components": "^27.
|
|
41
|
-
"@wordpress/compose": "^6.
|
|
42
|
-
"@wordpress/core-data": "^6.
|
|
43
|
-
"@wordpress/data": "^9.
|
|
44
|
-
"@wordpress/date": "^4.
|
|
45
|
-
"@wordpress/deprecated": "^3.
|
|
46
|
-
"@wordpress/dom": "^3.
|
|
47
|
-
"@wordpress/element": "^5.
|
|
48
|
-
"@wordpress/hooks": "^3.
|
|
49
|
-
"@wordpress/html-entities": "^3.
|
|
50
|
-
"@wordpress/i18n": "^4.
|
|
51
|
-
"@wordpress/icons": "^9.
|
|
52
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
53
|
-
"@wordpress/keycodes": "^3.
|
|
54
|
-
"@wordpress/media-utils": "^4.
|
|
55
|
-
"@wordpress/notices": "^4.
|
|
56
|
-
"@wordpress/patterns": "^1.
|
|
57
|
-
"@wordpress/
|
|
58
|
-
"@wordpress/
|
|
59
|
-
"@wordpress/
|
|
60
|
-
"@wordpress/
|
|
61
|
-
"@wordpress/
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
34
|
+
"@wordpress/a11y": "^3.54.0",
|
|
35
|
+
"@wordpress/api-fetch": "^6.51.0",
|
|
36
|
+
"@wordpress/blob": "^3.54.0",
|
|
37
|
+
"@wordpress/block-editor": "^12.22.0",
|
|
38
|
+
"@wordpress/blocks": "^12.31.0",
|
|
39
|
+
"@wordpress/commands": "^0.25.0",
|
|
40
|
+
"@wordpress/components": "^27.2.0",
|
|
41
|
+
"@wordpress/compose": "^6.31.0",
|
|
42
|
+
"@wordpress/core-data": "^6.31.0",
|
|
43
|
+
"@wordpress/data": "^9.24.0",
|
|
44
|
+
"@wordpress/date": "^4.54.0",
|
|
45
|
+
"@wordpress/deprecated": "^3.54.0",
|
|
46
|
+
"@wordpress/dom": "^3.54.0",
|
|
47
|
+
"@wordpress/element": "^5.31.0",
|
|
48
|
+
"@wordpress/hooks": "^3.54.0",
|
|
49
|
+
"@wordpress/html-entities": "^3.54.0",
|
|
50
|
+
"@wordpress/i18n": "^4.54.0",
|
|
51
|
+
"@wordpress/icons": "^9.45.0",
|
|
52
|
+
"@wordpress/keyboard-shortcuts": "^4.31.0",
|
|
53
|
+
"@wordpress/keycodes": "^3.54.0",
|
|
54
|
+
"@wordpress/media-utils": "^4.45.0",
|
|
55
|
+
"@wordpress/notices": "^4.22.0",
|
|
56
|
+
"@wordpress/patterns": "^1.15.0",
|
|
57
|
+
"@wordpress/plugins": "^6.22.0",
|
|
58
|
+
"@wordpress/preferences": "^3.31.0",
|
|
59
|
+
"@wordpress/private-apis": "^0.36.0",
|
|
60
|
+
"@wordpress/reusable-blocks": "^4.31.0",
|
|
61
|
+
"@wordpress/rich-text": "^6.31.0",
|
|
62
|
+
"@wordpress/server-side-render": "^4.31.0",
|
|
63
|
+
"@wordpress/url": "^3.55.0",
|
|
64
|
+
"@wordpress/warning": "^2.54.0",
|
|
65
|
+
"@wordpress/wordcount": "^3.54.0",
|
|
64
66
|
"classnames": "^2.3.1",
|
|
65
67
|
"date-fns": "^2.28.0",
|
|
66
68
|
"memize": "^2.1.0",
|
|
@@ -75,5 +77,5 @@
|
|
|
75
77
|
"publishConfig": {
|
|
76
78
|
"access": "public"
|
|
77
79
|
},
|
|
78
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "ffc07735d0abfb3f69e91d48f25b7fe8d1ef92d2"
|
|
79
81
|
}
|
package/src/bindings/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { store as
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import { dispatch } from '@wordpress/data';
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -10,6 +10,9 @@ import { unlock } from '../lock-unlock';
|
|
|
10
10
|
import patternOverrides from './pattern-overrides';
|
|
11
11
|
import postMeta from './post-meta';
|
|
12
12
|
|
|
13
|
-
const { registerBlockBindingsSource } = unlock( dispatch(
|
|
14
|
-
registerBlockBindingsSource( patternOverrides );
|
|
13
|
+
const { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );
|
|
15
14
|
registerBlockBindingsSource( postMeta );
|
|
15
|
+
|
|
16
|
+
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
17
|
+
registerBlockBindingsSource( patternOverrides );
|
|
18
|
+
}
|
|
@@ -19,6 +19,7 @@ export default {
|
|
|
19
19
|
const postType = context.postType
|
|
20
20
|
? context.postType
|
|
21
21
|
: getCurrentPostType();
|
|
22
|
+
|
|
22
23
|
const [ meta, setMeta ] = useEntityProp(
|
|
23
24
|
'postType',
|
|
24
25
|
context.postType,
|
|
@@ -33,9 +34,11 @@ export default {
|
|
|
33
34
|
const updateMetaValue = ( newValue ) => {
|
|
34
35
|
setMeta( { ...meta, [ metaKey ]: newValue } );
|
|
35
36
|
};
|
|
37
|
+
|
|
36
38
|
return {
|
|
37
39
|
placeholder: metaKey,
|
|
38
|
-
|
|
40
|
+
value: metaValue,
|
|
41
|
+
updateValue: updateMetaValue,
|
|
39
42
|
};
|
|
40
43
|
},
|
|
41
44
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { _n } from '@wordpress/i18n';
|
|
6
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { useMemo } from '@wordpress/element';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
import { store as editorStore } from '../../store';
|
|
15
|
+
|
|
16
|
+
const { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );
|
|
17
|
+
|
|
18
|
+
// Prevent accidental removal of certain blocks, asking the user for confirmation first.
|
|
19
|
+
const TEMPLATE_BLOCKS = [
|
|
20
|
+
'core/post-content',
|
|
21
|
+
'core/post-template',
|
|
22
|
+
'core/query',
|
|
23
|
+
];
|
|
24
|
+
const BLOCK_REMOVAL_RULES = [
|
|
25
|
+
{
|
|
26
|
+
// Template blocks.
|
|
27
|
+
// The warning is only shown when a user manipulates templates or template parts.
|
|
28
|
+
postTypes: [ 'wp_template', 'wp_template_part' ],
|
|
29
|
+
callback( removedBlocks ) {
|
|
30
|
+
const removedTemplateBlocks = removedBlocks.filter( ( { name } ) =>
|
|
31
|
+
TEMPLATE_BLOCKS.includes( name )
|
|
32
|
+
);
|
|
33
|
+
if ( removedTemplateBlocks.length ) {
|
|
34
|
+
return _n(
|
|
35
|
+
'Deleting this block will stop your post or page content from displaying on this template. It is not recommended.',
|
|
36
|
+
'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.',
|
|
37
|
+
removedBlocks.length
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
// Pattern overrides.
|
|
44
|
+
// The warning is only shown when the user edits a pattern.
|
|
45
|
+
postTypes: [ 'wp_block' ],
|
|
46
|
+
callback( removedBlocks ) {
|
|
47
|
+
const removedBlocksWithOverrides = removedBlocks.filter(
|
|
48
|
+
( { attributes } ) =>
|
|
49
|
+
attributes?.metadata?.bindings &&
|
|
50
|
+
Object.values( attributes.metadata.bindings ).some(
|
|
51
|
+
( binding ) =>
|
|
52
|
+
binding.source === 'core/pattern-overrides'
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
if ( removedBlocksWithOverrides.length ) {
|
|
56
|
+
return _n(
|
|
57
|
+
'The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?',
|
|
58
|
+
'Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?',
|
|
59
|
+
removedBlocks.length
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export default function BlockRemovalWarnings() {
|
|
67
|
+
const currentPostType = useSelect(
|
|
68
|
+
( select ) => select( editorStore ).getCurrentPostType(),
|
|
69
|
+
[]
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const removalRulesForPostType = useMemo(
|
|
73
|
+
() =>
|
|
74
|
+
BLOCK_REMOVAL_RULES.filter( ( rule ) =>
|
|
75
|
+
rule.postTypes.includes( currentPostType )
|
|
76
|
+
),
|
|
77
|
+
[ currentPostType ]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// `BlockRemovalWarnings` is rendered in the editor provider, a shared component
|
|
81
|
+
// across react native and web. However, `BlockRemovalWarningModal` is web only.
|
|
82
|
+
// Check it exists before trying to render it.
|
|
83
|
+
if ( ! BlockRemovalWarningModal ) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if ( ! removalRulesForPostType ) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return <BlockRemovalWarningModal rules={ removalRulesForPostType } />;
|
|
92
|
+
}
|