@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":["_element","require","_data","_i18n","_coreData","_blockEditor","_notices","_patterns","_blocks","_withRegistryProvider","_interopRequireDefault","_store","_useBlockEditorSettings","_lockUnlock","_disableNonPageContentBlocks","_navigationBlockEditingMode","_useHideBlocksFromInserter","_commands","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","noop","NON_CONTEXTUAL_POST_TYPES","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","useEntityBlockEditor","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","useMemo","createBlock","ref","templateLock","blocks","disableRootLevelChanges","ExperimentalEditorProvider","exports","withRegistryProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","useSelect","select","editorStore","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","includes","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","useBlockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","setCurrentTemplateId","setEditedPost","setRenderingMode","useDispatch","createWarningNotice","noticesStore","useLayoutEffect","postLock","autosave","__","actions","label","url","editLink","useEffect","_settings$defaultRend","defaultRenderingMode","useHideBlocksFromInserter","useCommands","_react","createElement","EntityProvider","kind","BlockContextProvider","value","useSubRegistry","default","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} 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":";;;;;;;;;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;AAKA,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,2BAAA,GAAAL,sBAAA,CAAAT,OAAA;AACA,IAAAe,0BAAA,GAAAf,OAAA;AACA,IAAAgB,SAAA,GAAAP,sBAAA,CAAAT,OAAA;AA1BA;AACA;AACA;;AAcA;AACA;AACA;;AAUA,MAAM;EAAEiB;AAAgC,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAC5E,MAAM;EAAEC;AAAkB,CAAC,GAAG,IAAAF,kBAAM,EAAEG,qBAAwB,CAAC;AAE/D,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,CACjC,UAAU,EACV,aAAa,EACb,eA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AC,aAAA,EAAC/F,SAAA,CAAAgG,cAAc;IAACC,IAAI,EAAC,MAAM;IAACnE,IAAI,EAAC;EAAM,GACtC,IAAAgE,MAAA,CAAAC,aAAA,EAAC/F,SAAA,CAAAgG,cAAc;IACdC,IAAI,EAAC,UAAU;IACfnE,IAAI,EAAGR,IAAI,CAACQ,IAAM;IAClBC,EAAE,EAAGT,IAAI,CAACS;EAAI,GAEd,IAAA+D,MAAA,CAAAC,aAAA,EAAC9F,YAAA,CAAAiG,oBAAoB;IAACC,KAAK,EAAG3C;EAAqB,GAClD,IAAAsC,MAAA,CAAAC,aAAA,EAAC9C,4BAA4B;IAC5BkD,KAAK,EAAG3D,MAAQ;IAChBZ,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnBsC,SAAS,EAAGA,SAAW;IACvBpB,QAAQ,EAAGyB,mBAAqB;IAChC8B,cAAc,EAAG;EAAO,GAEtBpD,QAAQ,EACV,IAAA8C,MAAA,CAAAC,aAAA,EAAC9E,iBAAiB,MAAE,CAAC,EACnBO,IAAI,KAAK,iBAAiB,IAC3B,IAAAsE,MAAA,CAAAC,aAAA,EAACrF,4BAAA,CAAA2F,OAA2B,MAAE,CAC9B,EACCvE,IAAI,KAAK,eAAe,IACzB,IAAAgE,MAAA,CAAAC,aAAA,EAACpF,2BAAA,CAAA0F,OAA0B,MAAE,CAED,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAEM,SAASC,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACC,IAAAT,MAAA,CAAAC,aAAA,EAACrD,0BAA0B;IAAA,GACrB6D,KAAK;IACVtD,4BAA4B,EAAGuD;EAAqB,GAElDD,KAAK,CAACvD,QACmB,CAAC;AAE/B;AAAC,IAAAyD,QAAA,GAAA9D,OAAA,CAAA0D,OAAA,GAEcC,cAAc"}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_i18n","_coreData","_blockEditor","_notices","_patterns","_blocks","_withRegistryProvider","_interopRequireDefault","_store","_useBlockEditorSettings","_lockUnlock","_disableNonPageContentBlocks","_navigationBlockEditingMode","_useHideBlocksFromInserter","_commands","_blockRemovalWarnings","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","noop","NON_CONTEXTUAL_POST_TYPES","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","useEntityBlockEditor","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","useMemo","createBlock","ref","templateLock","blocks","disableRootLevelChanges","ExperimentalEditorProvider","exports","withRegistryProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","useSelect","select","editorStore","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","includes","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","useBlockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","setCurrentTemplateId","setEditedPost","setRenderingMode","useDispatch","createWarningNotice","noticesStore","useLayoutEffect","postLock","autosave","__","actions","label","url","editLink","useEffect","_settings$defaultRend","defaultRenderingMode","useHideBlocksFromInserter","useCommands","_react","createElement","EntityProvider","kind","BlockContextProvider","value","useSubRegistry","default","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} 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":";;;;;;;;;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;AAKA,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,2BAAA,GAAAL,sBAAA,CAAAT,O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AI,KAAK,eAAe,IACzB,IAAAgE,MAAA,CAAAC,aAAA,EAACrF,2BAAA,CAAA2F,OAA0B,MAAE,CAC7B,EACD,IAAAP,MAAA,CAAAC,aAAA,EAAClF,qBAAA,CAAAwF,OAAoB,MAAE,CACM,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAEM,SAASC,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACC,IAAAT,MAAA,CAAAC,aAAA,EAACrD,0BAA0B;IAAA,GACrB6D,KAAK;IACVtD,4BAA4B,EAAGuD;EAAqB,GAElDD,KAAK,CAACvD,QACmB,CAAC;AAE/B;AAAC,IAAAyD,QAAA,GAAA9D,OAAA,CAAA0D,OAAA,GAEcC,cAAc"}
|
|
@@ -20,14 +20,15 @@ const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template
|
|
|
20
20
|
* the template part and post content blocks need to be hidden.
|
|
21
21
|
*
|
|
22
22
|
* @param {string} postType Post Type
|
|
23
|
+
* @param {string} mode Rendering mode
|
|
23
24
|
*/
|
|
24
|
-
function useHideBlocksFromInserter(postType) {
|
|
25
|
+
function useHideBlocksFromInserter(postType, mode) {
|
|
25
26
|
(0, _element.useEffect)(() => {
|
|
26
27
|
/*
|
|
27
28
|
* Prevent adding template part in the editor.
|
|
28
29
|
*/
|
|
29
30
|
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
|
|
30
|
-
if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part') {
|
|
31
|
+
if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
|
|
31
32
|
return false;
|
|
32
33
|
}
|
|
33
34
|
return canInsert;
|
|
@@ -48,6 +49,6 @@ function useHideBlocksFromInserter(postType) {
|
|
|
48
49
|
(0, _hooks.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
|
|
49
50
|
(0, _hooks.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
|
|
50
51
|
};
|
|
51
|
-
}, [postType]);
|
|
52
|
+
}, [postType, mode]);
|
|
52
53
|
}
|
|
53
54
|
//# sourceMappingURL=use-hide-blocks-from-inserter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_hooks","POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART","useHideBlocksFromInserter","postType","useEffect","addFilter","canInsert","blockType","includes","name","rootClientId","getBlockParentsByBlockName","length","removeFilter"],"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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAME,8CAA8C,GAAG,CACtD,UAAU,EACV,aAAa,EACb,kBAAkB,CAClB;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CAAEC,QAAQ,EAAG;
|
|
1
|
+
{"version":3,"names":["_element","require","_hooks","POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART","useHideBlocksFromInserter","postType","mode","useEffect","addFilter","canInsert","blockType","includes","name","rootClientId","getBlockParentsByBlockName","length","removeFilter"],"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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAME,8CAA8C,GAAG,CACtD,UAAU,EACV,aAAa,EACb,kBAAkB,CAClB;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CAAEC,QAAQ,EAAEC,IAAI,EAAG;EAC3D,IAAAC,kBAAS,EAAE,MAAM;IAChB;AACF;AACA;IACE,IAAAC,gBAAS,EACR,0CAA0C,EAC1C,iCAAiC,EACjC,CAAEC,SAAS,EAAEC,SAAS,KAAM;MAC3B,IACC,CAAEP,8CAA8C,CAACQ,QAAQ,CACxDN,QACD,CAAC,IACDK,SAAS,CAACE,IAAI,KAAK,oBAAoB,IACvCN,IAAI,KAAK,WAAW,EACnB;QACD,OAAO,KAAK;MACb;MACA,OAAOG,SAAS;IACjB,CACD,CAAC;;IAED;AACF;AACA;IACE,IAAAD,gBAAS,EACR,0CAA0C,EAC1C,+BAA+B,EAC/B,CACCC,SAAS,EACTC,SAAS,EACTG,YAAY,EACZ;MAAEC;IAA2B,CAAC,KAC1B;MACJ,IACC,CAAEX,8CAA8C,CAACQ,QAAQ,CACxDN,QACD,CAAC,IACDK,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;MACZ,IAAAO,mBAAY,EACX,0CAA0C,EAC1C,iCACD,CAAC;MACD,IAAAA,mBAAY,EACX,0CAA0C,EAC1C,+BACD,CAAC;IACF,CAAC;EACF,CAAC,EAAE,CAAEX,QAAQ,EAAEC,IAAI,CAAG,CAAC;AACxB"}
|
package/build/hooks/index.js
CHANGED
package/build/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require"],"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":["require"],"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":";;AAGAA,OAAA;AACAA,OAAA;AACAA,OAAA"}
|
|
@@ -17,7 +17,7 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
const {
|
|
20
|
-
|
|
20
|
+
useSetPatternBindings,
|
|
21
21
|
ResetOverridesControl,
|
|
22
22
|
PATTERN_TYPES,
|
|
23
23
|
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
@@ -32,14 +32,21 @@ const {
|
|
|
32
32
|
*
|
|
33
33
|
* @return {Component} Wrapped component.
|
|
34
34
|
*/
|
|
35
|
-
const
|
|
35
|
+
const withPatternOverrideControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
|
|
36
36
|
const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
|
|
37
37
|
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(BlockEdit, {
|
|
38
38
|
...props
|
|
39
|
+
}), isSupportedBlock && (0, _react.createElement)(BindingUpdater, {
|
|
40
|
+
...props
|
|
39
41
|
}), props.isSelected && isSupportedBlock && (0, _react.createElement)(ControlsWithStoreSubscription, {
|
|
40
42
|
...props
|
|
41
43
|
}));
|
|
42
44
|
});
|
|
45
|
+
function BindingUpdater(props) {
|
|
46
|
+
const postType = (0, _data.useSelect)(select => select(_store.store).getCurrentPostType(), []);
|
|
47
|
+
useSetPatternBindings(props, postType);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
43
50
|
|
|
44
51
|
// Split into a separate component to avoid a store subscription
|
|
45
52
|
// on every block.
|
|
@@ -48,13 +55,10 @@ function ControlsWithStoreSubscription(props) {
|
|
|
48
55
|
const isEditingPattern = (0, _data.useSelect)(select => select(_store.store).getCurrentPostType() === PATTERN_TYPES.user, []);
|
|
49
56
|
const bindings = props.attributes.metadata?.bindings;
|
|
50
57
|
const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
return (0, _react.createElement)(_react.Fragment, null, shouldShowPartialSyncingControls && (0, _react.createElement)(PartialSyncingControls, {
|
|
54
|
-
...props
|
|
55
|
-
}), shouldShowResetOverridesControl && (0, _react.createElement)(ResetOverridesControl, {
|
|
58
|
+
const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
|
|
59
|
+
return (0, _react.createElement)(_react.Fragment, null, shouldShowResetOverridesControl && (0, _react.createElement)(ResetOverridesControl, {
|
|
56
60
|
...props
|
|
57
61
|
}));
|
|
58
62
|
}
|
|
59
|
-
(0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/with-
|
|
60
|
-
//# sourceMappingURL=pattern-
|
|
63
|
+
(0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
|
|
64
|
+
//# sourceMappingURL=pattern-overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_hooks","require","_patterns","_compose","_blockEditor","_data","_store","_lockUnlock","useSetPatternBindings","ResetOverridesControl","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","unlock","patternsPrivateApis","withPatternOverrideControls","createHigherOrderComponent","BlockEdit","props","isSupportedBlock","Object","keys","includes","name","_react","createElement","Fragment","BindingUpdater","isSelected","ControlsWithStoreSubscription","postType","useSelect","select","editorStore","getCurrentPostType","blockEditingMode","useBlockEditingMode","isEditingPattern","user","bindings","attributes","metadata","hasPatternBindings","values","some","binding","source","shouldShowResetOverridesControl","addFilter"],"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":";;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EACLO,qBAAqB;EACrBC,qBAAqB;EACrBC,aAAa;EACbC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC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IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,+BAA+B,GACpC,CAAEV,gBAAgB,IAClB,CAAC,CAAEnB,KAAK,CAACsB,UAAU,CAACC,QAAQ,EAAElB,IAAI,IAClCY,gBAAgB,KAAK,UAAU,IAC/BO,kBAAkB;EAEnB,OACC,IAAAlB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACGqB,+BAA+B,IAChC,IAAAvB,MAAA,CAAAC,aAAA,EAACf,qBAAqB;IAAA,GAAMQ;EAAK,CAAI,CAErC,CAAC;AAEL;AAEA,IAAA8B,gBAAS,EACR,kBAAkB,EAClB,4CAA4C,EAC5CjC,2BACD,CAAC"}
|
package/build/private-apis.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.privateApis = void 0;
|
|
|
8
8
|
var _editorCanvas = _interopRequireDefault(require("./components/editor-canvas"));
|
|
9
9
|
var _provider = require("./components/provider");
|
|
10
10
|
var _lockUnlock = require("./lock-unlock");
|
|
11
|
-
var _enablePluginDocumentSettingPanel = _interopRequireDefault(require("./components/preferences-modal/enable-plugin-document-setting-panel"));
|
|
12
11
|
var _entitiesSavedStates = require("./components/entities-saved-states");
|
|
13
12
|
var _useBlockEditorSettings = _interopRequireDefault(require("./components/provider/use-block-editor-settings"));
|
|
14
13
|
var _documentTools = _interopRequireDefault(require("./components/document-tools"));
|
|
@@ -29,7 +28,6 @@ const privateApis = exports.privateApis = {};
|
|
|
29
28
|
DocumentTools: _documentTools.default,
|
|
30
29
|
EditorCanvas: _editorCanvas.default,
|
|
31
30
|
ExperimentalEditorProvider: _provider.ExperimentalEditorProvider,
|
|
32
|
-
EnablePluginDocumentSettingPanelOption: _enablePluginDocumentSettingPanel.default,
|
|
33
31
|
EntitiesSavedStatesExtensible: _entitiesSavedStates.EntitiesSavedStatesExtensible,
|
|
34
32
|
InserterSidebar: _inserterSidebar.default,
|
|
35
33
|
ListViewSidebar: _listViewSidebar.default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_editorCanvas","_interopRequireDefault","require","_provider","_lockUnlock","
|
|
1
|
+
{"version":3,"names":["_editorCanvas","_interopRequireDefault","require","_provider","_lockUnlock","_entitiesSavedStates","_useBlockEditorSettings","_documentTools","_inserterSidebar","_listViewSidebar","_modeSwitcher","_plugin","_postPanelRow","_postViewLink","_previewDropdown","_preferencesModal","privateApis","exports","lock","DocumentTools","EditorCanvas","ExperimentalEditorProvider","EntitiesSavedStatesExtensible","InserterSidebar","ListViewSidebar","ModeSwitcher","PluginPostExcerpt","PostPanelRow","PostViewLink","PreviewDropdown","PreferencesModal","useBlockEditorSettings"],"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":";;;;;;;AAGA,IAAAA,aAAA,GAAAC,sBAAA,CA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5
5
|
import { dispatch } from '@wordpress/data';
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -11,7 +11,9 @@ import patternOverrides from './pattern-overrides';
|
|
|
11
11
|
import postMeta from './post-meta';
|
|
12
12
|
const {
|
|
13
13
|
registerBlockBindingsSource
|
|
14
|
-
} = unlock(dispatch(
|
|
15
|
-
registerBlockBindingsSource(patternOverrides);
|
|
14
|
+
} = unlock(dispatch(blocksStore));
|
|
16
15
|
registerBlockBindingsSource(postMeta);
|
|
16
|
+
if (process.env.IS_GUTENBERG_PLUGIN) {
|
|
17
|
+
registerBlockBindingsSource(patternOverrides);
|
|
18
|
+
}
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","
|
|
1
|
+
{"version":3,"names":["store","blocksStore","dispatch","unlock","patternOverrides","postMeta","registerBlockBindingsSource","process","env","IS_GUTENBERG_PLUGIN"],"sources":["@wordpress/editor/src/bindings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\n\nconst { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );\nregisterBlockBindingsSource( postMeta );\n\nif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\tregisterBlockBindingsSource( patternOverrides );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAM;EAAEC;AAA4B,CAAC,GAAGH,MAAM,CAAED,QAAQ,CAAED,WAAY,CAAE,CAAC;AACzEK,2BAA2B,CAAED,QAAS,CAAC;AAEvC,IAAKE,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;EACtCH,2BAA2B,CAAEF,gBAAiB,CAAC;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEntityProp","useSelect","_x","store","editorStore","name","label","useSource","props","sourceAttributes","getCurrentPostType","context","key","metaKey","postType","meta","setMeta","postId","placeholder","metaValue","updateMetaValue","newValue","
|
|
1
|
+
{"version":3,"names":["useEntityProp","useSelect","_x","store","editorStore","name","label","useSource","props","sourceAttributes","getCurrentPostType","context","key","metaKey","postType","meta","setMeta","postId","placeholder","metaValue","updateMetaValue","newValue","value","updateValue"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tlabel: _x( 'Post Meta', 'block bindings source' ),\n\tuseSource( props, sourceAttributes ) {\n\t\tconst { getCurrentPostType } = useSelect( editorStore );\n\t\tconst { context } = props;\n\t\tconst { key: metaKey } = sourceAttributes;\n\t\tconst postType = context.postType\n\t\t\t? context.postType\n\t\t\t: getCurrentPostType();\n\n\t\tconst [ meta, setMeta ] = useEntityProp(\n\t\t\t'postType',\n\t\t\tcontext.postType,\n\t\t\t'meta',\n\t\t\tcontext.postId\n\t\t);\n\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn { placeholder: metaKey };\n\t\t}\n\t\tconst metaValue = meta[ metaKey ];\n\t\tconst updateMetaValue = ( newValue ) => {\n\t\t\tsetMeta( { ...meta, [ metaKey ]: newValue } );\n\t\t};\n\n\t\treturn {\n\t\t\tplaceholder: metaKey,\n\t\t\tvalue: metaValue,\n\t\t\tupdateValue: updateMetaValue,\n\t\t};\n\t},\n};\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
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { _n } from '@wordpress/i18n';
|
|
7
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
8
|
+
import { useSelect } from '@wordpress/data';
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { unlock } from '../../lock-unlock';
|
|
15
|
+
import { store as editorStore } from '../../store';
|
|
16
|
+
const {
|
|
17
|
+
BlockRemovalWarningModal
|
|
18
|
+
} = unlock(blockEditorPrivateApis);
|
|
19
|
+
|
|
20
|
+
// Prevent accidental removal of certain blocks, asking the user for confirmation first.
|
|
21
|
+
const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
|
|
22
|
+
const BLOCK_REMOVAL_RULES = [{
|
|
23
|
+
// Template blocks.
|
|
24
|
+
// The warning is only shown when a user manipulates templates or template parts.
|
|
25
|
+
postTypes: ['wp_template', 'wp_template_part'],
|
|
26
|
+
callback(removedBlocks) {
|
|
27
|
+
const removedTemplateBlocks = removedBlocks.filter(({
|
|
28
|
+
name
|
|
29
|
+
}) => TEMPLATE_BLOCKS.includes(name));
|
|
30
|
+
if (removedTemplateBlocks.length) {
|
|
31
|
+
return _n('Deleting this block will stop your post or page content from displaying on this template. It is not recommended.', 'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.', removedBlocks.length);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
// Pattern overrides.
|
|
36
|
+
// The warning is only shown when the user edits a pattern.
|
|
37
|
+
postTypes: ['wp_block'],
|
|
38
|
+
callback(removedBlocks) {
|
|
39
|
+
const removedBlocksWithOverrides = removedBlocks.filter(({
|
|
40
|
+
attributes
|
|
41
|
+
}) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
|
|
42
|
+
if (removedBlocksWithOverrides.length) {
|
|
43
|
+
return _n('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?', '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?', removedBlocks.length);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}];
|
|
47
|
+
export default function BlockRemovalWarnings() {
|
|
48
|
+
const currentPostType = useSelect(select => select(editorStore).getCurrentPostType(), []);
|
|
49
|
+
const removalRulesForPostType = useMemo(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
|
|
50
|
+
|
|
51
|
+
// `BlockRemovalWarnings` is rendered in the editor provider, a shared component
|
|
52
|
+
// across react native and web. However, `BlockRemovalWarningModal` is web only.
|
|
53
|
+
// Check it exists before trying to render it.
|
|
54
|
+
if (!BlockRemovalWarningModal) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (!removalRulesForPostType) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return createElement(BlockRemovalWarningModal, {
|
|
61
|
+
rules: removalRulesForPostType
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_n","privateApis","blockEditorPrivateApis","useSelect","useMemo","unlock","store","editorStore","BlockRemovalWarningModal","TEMPLATE_BLOCKS","BLOCK_REMOVAL_RULES","postTypes","callback","removedBlocks","removedTemplateBlocks","filter","name","includes","length","removedBlocksWithOverrides","attributes","metadata","bindings","Object","values","some","binding","source","BlockRemovalWarnings","currentPostType","select","getCurrentPostType","removalRulesForPostType","rule","createElement","rules"],"sources":["@wordpress/editor/src/components/block-removal-warnings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { _n } from '@wordpress/i18n';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\n\n// Prevent accidental removal of certain blocks, asking the user for confirmation first.\nconst TEMPLATE_BLOCKS = [\n\t'core/post-content',\n\t'core/post-template',\n\t'core/query',\n];\nconst BLOCK_REMOVAL_RULES = [\n\t{\n\t\t// Template blocks.\n\t\t// The warning is only shown when a user manipulates templates or template parts.\n\t\tpostTypes: [ 'wp_template', 'wp_template_part' ],\n\t\tcallback( removedBlocks ) {\n\t\t\tconst removedTemplateBlocks = removedBlocks.filter( ( { name } ) =>\n\t\t\t\tTEMPLATE_BLOCKS.includes( name )\n\t\t\t);\n\t\t\tif ( removedTemplateBlocks.length ) {\n\t\t\t\treturn _n(\n\t\t\t\t\t'Deleting this block will stop your post or page content from displaying on this template. It is not recommended.',\n\t\t\t\t\t'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.',\n\t\t\t\t\tremovedBlocks.length\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n\t{\n\t\t// Pattern overrides.\n\t\t// The warning is only shown when the user edits a pattern.\n\t\tpostTypes: [ 'wp_block' ],\n\t\tcallback( removedBlocks ) {\n\t\t\tconst removedBlocksWithOverrides = removedBlocks.filter(\n\t\t\t\t( { attributes } ) =>\n\t\t\t\t\tattributes?.metadata?.bindings &&\n\t\t\t\t\tObject.values( attributes.metadata.bindings ).some(\n\t\t\t\t\t\t( binding ) =>\n\t\t\t\t\t\t\tbinding.source === 'core/pattern-overrides'\n\t\t\t\t\t)\n\t\t\t);\n\t\t\tif ( removedBlocksWithOverrides.length ) {\n\t\t\t\treturn _n(\n\t\t\t\t\t'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?',\n\t\t\t\t\t'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?',\n\t\t\t\t\tremovedBlocks.length\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n];\n\nexport default function BlockRemovalWarnings() {\n\tconst currentPostType = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentPostType(),\n\t\t[]\n\t);\n\n\tconst removalRulesForPostType = useMemo(\n\t\t() =>\n\t\t\tBLOCK_REMOVAL_RULES.filter( ( rule ) =>\n\t\t\t\trule.postTypes.includes( currentPostType )\n\t\t\t),\n\t\t[ currentPostType ]\n\t);\n\n\t// `BlockRemovalWarnings` is rendered in the editor provider, a shared component\n\t// across react native and web. However, `BlockRemovalWarningModal` is web only.\n\t// Check it exists before trying to render it.\n\tif ( ! BlockRemovalWarningModal ) {\n\t\treturn null;\n\t}\n\n\tif ( ! removalRulesForPostType ) {\n\t\treturn null;\n\t}\n\n\treturn <BlockRemovalWarningModal rules={ removalRulesForPostType } />;\n}\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,MAAM;EAAEC;AAAyB,CAAC,GAAGH,MAAM,CAAEH,sBAAuB,CAAC;;AAErE;AACA,MAAMO,eAAe,GAAG,CACvB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,CACZ;AACD,MAAMC,mBAAmB,GAAG,CAC3B;EACC;EACA;EACAC,SAAS,EAAE,CAAE,aAAa,EAAE,kBAAkB,CAAE;EAChDC,QAAQA,CAAEC,aAAa,EAAG;IACzB,MAAMC,qBAAqB,GAAGD,aAAa,CAACE,MAAM,CAAE,CAAE;MAAEC;IAAK,CAAC,KAC7DP,eAAe,CAACQ,QAAQ,CAAED,IAAK,CAChC,CAA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ader() {
|
|
|
23
23
|
isTopToolbar,
|
|
24
24
|
isFocusMode,
|
|
25
25
|
isPreviewMode,
|
|
26
|
-
isViewable
|
|
26
|
+
isViewable,
|
|
27
|
+
isCodeEditingEnabled,
|
|
28
|
+
isRichEditingEnabled
|
|
27
29
|
} = useSelect(select => {
|
|
28
30
|
var _get, _getPostType$viewable;
|
|
29
31
|
const {
|
|
@@ -31,7 +33,8 @@ function useEditorCommandLoader() {
|
|
|
31
33
|
} = select(preferencesStore);
|
|
32
34
|
const {
|
|
33
35
|
isListViewOpened,
|
|
34
|
-
getCurrentPostType
|
|
36
|
+
getCurrentPostType,
|
|
37
|
+
getEditorSettings
|
|
35
38
|
} = select(editorStore);
|
|
36
39
|
const {
|
|
37
40
|
getSettings
|
|
@@ -47,7 +50,9 @@ function useEditorCommandLoader() {
|
|
|
47
50
|
isFocusMode: get('core', 'focusMode'),
|
|
48
51
|
isTopToolbar: get('core', 'fixedToolbar'),
|
|
49
52
|
isPreviewMode: getSettings().__unstableIsPreviewMode,
|
|
50
|
-
isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false
|
|
53
|
+
isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
|
|
54
|
+
isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
|
|
55
|
+
isRichEditingEnabled: getEditorSettings().richEditingEnabled
|
|
51
56
|
};
|
|
52
57
|
}, []);
|
|
53
58
|
const {
|
|
@@ -65,6 +70,7 @@ function useEditorCommandLoader() {
|
|
|
65
70
|
const {
|
|
66
71
|
getCurrentPostId
|
|
67
72
|
} = useSelect(editorStore);
|
|
73
|
+
const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
|
|
68
74
|
if (isPreviewMode) {
|
|
69
75
|
return {
|
|
70
76
|
commands: [],
|
|
@@ -140,17 +146,19 @@ function useEditorCommandLoader() {
|
|
|
140
146
|
});
|
|
141
147
|
}
|
|
142
148
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
if (allowSwitchEditorMode) {
|
|
150
|
+
commands.push({
|
|
151
|
+
name: 'core/toggle-code-editor',
|
|
152
|
+
label: editorMode === 'visual' ? __('Open code editor') : __('Exit code editor'),
|
|
153
|
+
icon: code,
|
|
154
|
+
callback: ({
|
|
155
|
+
close
|
|
156
|
+
}) => {
|
|
157
|
+
switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
|
|
158
|
+
close();
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
154
162
|
commands.push({
|
|
155
163
|
name: 'core/toggle-breadcrumbs',
|
|
156
164
|
label: showBlockBreadcrumbs ? __('Hide block breadcrumbs') : __('Show block breadcrumbs'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","code","listView","external","useCommandLoader","store","preferencesStore","noticesStore","blockEditorStore","coreStore","editorStore","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","select","_get","_getPostType$viewable","get","isListViewOpened","getCurrentPostType","getSettings","getPostType","__unstableIsPreviewMode","viewable","toggle","createInfoNotice","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","getCurrentPostId","commands","isLoading","push","name","label","callback","close","id","type","actions","onClick","icon","postId","link","window","open","useCommands","hook"],"sources":["@wordpress/editor/src/components/commands/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { code, listView, external } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction useEditorCommandLoader() {\n\tconst {\n\t\teditorMode,\n\t\tisListViewOpen,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t\tisPreviewMode,\n\t\tisViewable,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getCurrentPostType } = select( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\teditorMode: get( 'core', 'editorMode' ) ?? 'visual',\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisPreviewMode: getSettings().__unstableIsPreviewMode,\n\t\t\tisViewable: getPostType( getCurrentPostType() )?.viewable ?? false,\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst {\n\t\t__unstableSaveForPreview,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\n\tif ( isPreviewMode ) {\n\t\treturn { commands: [], isLoading: false };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction Free' )\n\t\t\t: __( 'Enter Distraction Free ' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\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\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\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\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-code-editor',\n\t\tlabel:\n\t\t\teditorMode === 'visual'\n\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t: __( 'Exit code editor' ),\n\t\ticon: code,\n\t\tcallback: ( { close } ) => {\n\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( isViewable ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/preview-link',\n\t\t\tlabel: __( 'Preview in a new tab' ),\n\t\t\ticon: external,\n\t\t\tcallback: async ( { close } ) => {\n\t\t\t\tclose();\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport default function useCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/editor/edit-ui',\n\t\thook: useEditorCommandLoader,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,yBAAyB;AACnE,SAASH,KAAK,IAAII,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;AAElD,SAASC,sBAAsBA,CAAA,EAAG;EACjC,MAAM;IACLC,UAAU;IACVC,cAAc;IACdC,oBAAoB;IACpBC,iBAAiB;IACjBC,YAAY;IACZC,WAAW;IACXC,aAAa;IACbC;EACD,CAAC,GAAGrB,SAAS,CAAIsB,MAAM,IAAM;IAAA,IAAAC,IAAA,EAAAC,qBAAA;IAC5B,MAAM;MAAEC;IAAI,CAAC,GAAGH,MAAM,CAAEd,gBAAiB,CAAC;IAC1C,MAAM;MAAEkB,gBAAgB;MAAEC;IAAmB,CAAC,GAAGL,MAAM,CAAEV,WAAY,CAAC;IACtE,MAAM;MAAEgB;IAAY,CAAC,GAAGN,MAAM,CAAEZ,gBAAiB,CAAC;IAClD,MAAM;MAAEmB;IAAY,CAAC,GAAGP,MAAM,CAAEX,SAAU,CAAC;I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bb,MAAM,CAAE,MAAM,EAAE,sBAAuB,CAAC;MACxCa,KAAK,CAAC,CAAC;MACPZ,gBAAgB,CACfjB,oBAAoB,GACjBd,EAAE,CAAE,qBAAsB,CAAC,GAC3BA,EAAE,CAAE,sBAAuB,CAAC,EAC/B;QACC4C,EAAE,EAAE,uCAAuC;QAC3CC,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEH,IAAK1B,UAAU,EAAG;IACjBkB,QAAQ,CAACE,IAAI,CAAE;MACdC,IAAI,EAAE,mBAAmB;MACzBC,KAAK,EAAEzC,EAAE,CAAE,sBAAuB,CAAC;MACnCgD,IAAI,EAAE7C,QAAQ;MACduC,QAAQ,EAAE,MAAAA,CAAQ;QAAEC;MAAM,CAAC,KAAM;QAChCA,KAAK,CAAC,CAAC;QACP,MAAMM,MAAM,GAAGb,gBAAgB,CAAC,CAAC;QACjC,MAAMc,IAAI,GAAG,MAAMlB,wBAAwB,CAAC,CAAC;QAC7CmB,MAAM,CAACC,IAAI,CAAEF,IAAI,EAAG,cAAcD,MAAQ,EAAE,CAAC;MAC9C;IACD,CAAE,CAAC;EACJ;EAEA,OAAO;IACNZ,QAAQ;IACRC,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,eAAe,SAASe,WAAWA,CAAA,EAAG;EACrCjD,gBAAgB,CAAE;IACjBoC,IAAI,EAAE,qBAAqB;IAC3Bc,IAAI,EAAE3C;EACP,CAAE,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","__","code","listView","external","useCommandLoader","store","preferencesStore","noticesStore","blockEditorStore","coreStore","editorStore","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","isCodeEditingEnabled","isRichEditingEnabled","select","_get","_getPostType$viewable","get","isListViewOpened","getCurrentPostType","getEditorSettings","getSettings","getPostType","__unstableIsPreviewMode","viewable","codeEditingEnabled","richEditingEnabled","toggle","createInfoNotice","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","getCurrentPostId","allowSwitchEditorMode","commands","isLoading","push","name","label","callback","close","id","type","actions","onClick","icon","postId","link","window","open","useCommands","hook"],"sources":["@wordpress/editor/src/components/commands/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { code, listView, external } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction useEditorCommandLoader() {\n\tconst {\n\t\teditorMode,\n\t\tisListViewOpen,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t\tisPreviewMode,\n\t\tisViewable,\n\t\tisCodeEditingEnabled,\n\t\tisRichEditingEnabled,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\teditorMode: get( 'core', 'editorMode' ) ?? 'visual',\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisPreviewMode: getSettings().__unstableIsPreviewMode,\n\t\t\tisViewable: getPostType( getCurrentPostType() )?.viewable ?? false,\n\t\t\tisCodeEditingEnabled: getEditorSettings().codeEditingEnabled,\n\t\t\tisRichEditingEnabled: getEditorSettings().richEditingEnabled,\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst {\n\t\t__unstableSaveForPreview,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;\n\n\tif ( isPreviewMode ) {\n\t\treturn { commands: [], isLoading: false };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction Free' )\n\t\t\t: __( 'Enter Distraction Free ' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\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\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\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\t} );\n\n\tif ( allowSwitchEditorMode ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/toggle-code-editor',\n\t\t\tlabel:\n\t\t\t\teditorMode === 'visual'\n\t\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t\t: __( 'Exit code editor' ),\n\t\t\ticon: code,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tcommands.push( {\n\t\tname: 'core/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( isViewable ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/preview-link',\n\t\t\tlabel: __( 'Preview in a new tab' ),\n\t\t\ticon: external,\n\t\t\tcallback: async ( { close } ) => {\n\t\t\t\tclose();\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport default function useCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/editor/edit-ui',\n\t\thook: useEditorCommandLoader,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,yBAAyB;AACnE,SAAS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,sBAAuB,CAAC;MACnCsD,IAAI,EAAEnD,QAAQ;MACd6C,QAAQ,EAAE,MAAAA,CAAQ;QAAEC;MAAM,CAAC,KAAM;QAChCA,KAAK,CAAC,CAAC;QACP,MAAMM,MAAM,GAAGd,gBAAgB,CAAC,CAAC;QACjC,MAAMe,IAAI,GAAG,MAAMnB,wBAAwB,CAAC,CAAC;QAC7CoB,MAAM,CAACC,IAAI,CAAEF,IAAI,EAAG,cAAcD,MAAQ,EAAE,CAAC;MAC9C;IACD,CAAE,CAAC;EACJ;EAEA,OAAO;IACNZ,QAAQ;IACRC,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,eAAe,SAASe,WAAWA,CAAA,EAAG;EACrCvD,gBAAgB,CAAE;IACjB0C,IAAI,EAAE,qBAAqB;IAC3Bc,IAAI,EAAEjD;EACP,CAAE,CAAC;AACJ"}
|
|
@@ -57,7 +57,7 @@ export default function DocumentBar() {
|
|
|
57
57
|
} = select(editorStore);
|
|
58
58
|
const {
|
|
59
59
|
getEditedEntityRecord,
|
|
60
|
-
|
|
60
|
+
isResolving: isResolvingSelector
|
|
61
61
|
} = select(coreStore);
|
|
62
62
|
const _postType = getCurrentPostType();
|
|
63
63
|
const _postId = getCurrentPostId();
|
|
@@ -66,7 +66,7 @@ export default function DocumentBar() {
|
|
|
66
66
|
return {
|
|
67
67
|
postType: _postType,
|
|
68
68
|
document: _document,
|
|
69
|
-
isResolving:
|
|
69
|
+
isResolving: isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
|
|
70
70
|
templateIcon: _templateInfo.icon,
|
|
71
71
|
templateTitle: _templateInfo.title,
|
|
72
72
|
onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
|