@wordpress/editor 14.38.0 → 14.39.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 +2 -0
- package/build/components/document-bar/useEditedSectionDetails.cjs +0 -3
- package/build/components/document-bar/useEditedSectionDetails.cjs.map +2 -2
- package/build/components/editor-interface/index.cjs +33 -9
- package/build/components/editor-interface/index.cjs.map +2 -2
- package/build/components/header/header-skeleton.cjs +100 -0
- package/build/components/header/header-skeleton.cjs.map +7 -0
- package/build/components/header/index.cjs +63 -106
- package/build/components/header/index.cjs.map +3 -3
- package/build/components/media/index.cjs +44 -0
- package/build/components/media/index.cjs.map +7 -0
- package/build/components/media/metadata-panel.cjs +96 -0
- package/build/components/media/metadata-panel.cjs.map +7 -0
- package/build/components/media/preview.cjs +39 -0
- package/build/components/media/preview.cjs.map +7 -0
- package/build/components/more-menu/index.cjs +3 -2
- package/build/components/more-menu/index.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +33 -4
- package/build/components/post-card-panel/index.cjs.map +3 -3
- package/build/components/post-content-information/index.cjs +9 -0
- package/build/components/post-content-information/index.cjs.map +2 -2
- package/build/components/post-last-edited-panel/index.cjs +5 -6
- package/build/components/post-last-edited-panel/index.cjs.map +2 -2
- package/build/components/post-last-revision/index.cjs +5 -7
- package/build/components/post-last-revision/index.cjs.map +2 -2
- package/build/components/post-publish-button/label.cjs +6 -1
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-button/post-publish-button-or-toggle.cjs +8 -3
- package/build/components/post-publish-button/post-publish-button-or-toggle.cjs.map +2 -2
- package/build/components/post-revisions-preview/index.cjs +44 -0
- package/build/components/post-revisions-preview/index.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-canvas.cjs +82 -0
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-header.cjs +119 -0
- package/build/components/post-revisions-preview/revisions-header.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs +110 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +7 -0
- package/build/components/post-saved-state/index.cjs +8 -2
- package/build/components/post-saved-state/index.cjs.map +2 -2
- package/build/components/post-title/index.cjs +5 -4
- package/build/components/post-title/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +19 -0
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +2 -1
- package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
- package/build/components/revision-author-panel/index.cjs +59 -0
- package/build/components/revision-author-panel/index.cjs.map +7 -0
- package/build/components/revision-created-panel/index.cjs +47 -0
- package/build/components/revision-created-panel/index.cjs.map +7 -0
- package/build/components/sidebar/header.cjs +27 -12
- package/build/components/sidebar/header.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +36 -15
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +44 -19
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/start-page-options/index.cjs +1 -1
- package/build/components/start-page-options/index.cjs.map +2 -2
- package/build/dataviews/store/private-actions.cjs +47 -26
- package/build/dataviews/store/private-actions.cjs.map +3 -3
- package/build/store/constants.cjs +3 -0
- package/build/store/constants.cjs.map +2 -2
- package/build/store/private-actions.cjs +40 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +33 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +10 -0
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +3 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/store/utils/notice-builder.cjs +4 -0
- package/build/store/utils/notice-builder.cjs.map +2 -2
- package/build-module/components/document-bar/useEditedSectionDetails.mjs +0 -3
- package/build-module/components/document-bar/useEditedSectionDetails.mjs.map +2 -2
- package/build-module/components/editor-interface/index.mjs +33 -9
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/header/header-skeleton.mjs +69 -0
- package/build-module/components/header/header-skeleton.mjs.map +7 -0
- package/build-module/components/header/index.mjs +65 -107
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media/index.mjs +8 -0
- package/build-module/components/media/index.mjs.map +7 -0
- package/build-module/components/media/metadata-panel.mjs +65 -0
- package/build-module/components/media/metadata-panel.mjs.map +7 -0
- package/build-module/components/media/preview.mjs +21 -0
- package/build-module/components/media/preview.mjs.map +7 -0
- package/build-module/components/more-menu/index.mjs +3 -2
- package/build-module/components/more-menu/index.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +35 -5
- package/build-module/components/post-card-panel/index.mjs.map +3 -3
- package/build-module/components/post-content-information/index.mjs +9 -0
- package/build-module/components/post-content-information/index.mjs.map +2 -2
- package/build-module/components/post-last-edited-panel/index.mjs +5 -6
- package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
- package/build-module/components/post-last-revision/index.mjs +6 -8
- package/build-module/components/post-last-revision/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +6 -1
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.mjs +8 -3
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/index.mjs +8 -0
- package/build-module/components/post-revisions-preview/index.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs +54 -0
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-header.mjs +92 -0
- package/build-module/components/post-revisions-preview/revisions-header.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +89 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +7 -0
- package/build-module/components/post-saved-state/index.mjs +8 -2
- package/build-module/components/post-saved-state/index.mjs.map +2 -2
- package/build-module/components/post-title/index.mjs +5 -4
- package/build-module/components/post-title/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +19 -0
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +2 -1
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/revision-author-panel/index.mjs +28 -0
- package/build-module/components/revision-author-panel/index.mjs.map +7 -0
- package/build-module/components/revision-created-panel/index.mjs +26 -0
- package/build-module/components/revision-created-panel/index.mjs.map +7 -0
- package/build-module/components/sidebar/header.mjs +22 -7
- package/build-module/components/sidebar/header.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +38 -16
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +48 -20
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/start-page-options/index.mjs +2 -1
- package/build-module/components/start-page-options/index.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +59 -27
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/constants.mjs +2 -0
- package/build-module/store/constants.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +38 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +29 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +9 -0
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +4 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/store/utils/notice-builder.mjs +4 -0
- package/build-module/store/utils/notice-builder.mjs.map +2 -2
- package/build-style/style-rtl.css +182 -16
- package/build-style/style.css +182 -16
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/header/header-skeleton.d.ts +17 -0
- package/build-types/components/header/header-skeleton.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/media/index.d.ts +3 -0
- package/build-types/components/media/index.d.ts.map +1 -0
- package/build-types/components/media/metadata-panel.d.ts +12 -0
- package/build-types/components/media/metadata-panel.d.ts.map +1 -0
- package/build-types/components/media/preview.d.ts +9 -0
- package/build-types/components/media/preview.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts +3 -1
- package/build-types/components/more-menu/index.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-content-information/index.d.ts.map +1 -1
- package/build-types/components/post-last-edited-panel/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/index.d.ts +3 -0
- package/build-types/components/post-revisions-preview/index.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +7 -0
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-header.d.ts +8 -0
- package/build-types/components/post-revisions-preview/revisions-header.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts +8 -0
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -0
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/revision-author-panel/index.d.ts +2 -0
- package/build-types/components/revision-author-panel/index.d.ts.map +1 -0
- package/build-types/components/revision-created-panel/index.d.ts +2 -0
- package/build-types/components/revision-created-panel/index.d.ts.map +1 -0
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts +1 -0
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +13 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +25 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +11 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/utils/notice-builder.d.ts.map +1 -1
- package/package.json +42 -40
- package/src/components/document-bar/useEditedSectionDetails.js +0 -5
- package/src/components/editor-interface/index.js +39 -9
- package/src/components/header/header-skeleton.js +90 -0
- package/src/components/header/index.js +69 -102
- package/src/components/header/style.scss +4 -0
- package/src/components/media/index.js +2 -0
- package/src/components/media/metadata-panel.js +77 -0
- package/src/components/media/preview.js +35 -0
- package/src/components/more-menu/index.js +2 -1
- package/src/components/post-card-panel/index.js +43 -7
- package/src/components/post-content-information/index.js +11 -0
- package/src/components/post-last-edited-panel/index.js +8 -9
- package/src/components/post-last-revision/index.js +7 -8
- package/src/components/post-publish-button/label.js +9 -0
- package/src/components/post-publish-button/post-publish-button-or-toggle.js +13 -5
- package/src/components/post-revisions-preview/index.js +2 -0
- package/src/components/post-revisions-preview/revisions-canvas.js +73 -0
- package/src/components/post-revisions-preview/revisions-header.js +108 -0
- package/src/components/post-revisions-preview/revisions-slider.js +123 -0
- package/src/components/post-revisions-preview/style.scss +22 -0
- package/src/components/post-saved-state/index.js +8 -0
- package/src/components/post-title/index.js +4 -3
- package/src/components/provider/index.js +26 -0
- package/src/components/provider/use-block-editor-settings.js +2 -3
- package/src/components/revision-author-panel/index.js +36 -0
- package/src/components/revision-created-panel/index.js +36 -0
- package/src/components/sidebar/header.js +35 -14
- package/src/components/sidebar/index.js +40 -13
- package/src/components/sidebar/post-summary.js +45 -11
- package/src/components/sidebar/style.scss +7 -0
- package/src/components/start-page-options/index.js +2 -0
- package/src/dataviews/store/private-actions.ts +79 -33
- package/src/store/constants.ts +1 -0
- package/src/store/private-actions.js +70 -0
- package/src/store/private-selectors.js +54 -0
- package/src/store/reducer.js +17 -0
- package/src/store/selectors.js +6 -0
- package/src/store/test/selectors.js +7 -0
- package/src/store/utils/notice-builder.js +9 -0
- package/src/style.scss +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-title/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nimport { unlock } from '../../lock-unlock';\n\nconst PostTitle = forwardRef( ( _, forwardedRef ) => {\n\tconst { placeholder, isEditingContentOnlySection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedContentOnlySection } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { titlePlaceholder } = getSettings();\n\n\t\t\treturn {\n\t\t\t\tplaceholder: titlePlaceholder,\n\t\t\t\tisEditingContentOnlySection: !! getEditedContentOnlySection(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: title,\n\t\tonChange( newValue ) {\n\t\t\tonUpdate( newValue.replace( REGEXP_NEWLINES, ' ' ) );\n\t\t},\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error ) {\n\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t// behaviour.\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\t\t\tonChange( insert( value, create( { html: contentNoHTML } ) ) );\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\t// Because the title is within the editor iframe, we can't use scss styles.\n\t// Instead use an inline style to dim the block when it's disabled.\n\tconst style = isEditingContentOnlySection ? { opacity: 0.2 } : undefined;\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<h1\n\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\tcontentEditable={ ! isEditingContentOnlySection }\n\t\t\tclassName={ className }\n\t\t\taria-label={ decodedPlaceholder }\n\t\t\trole=\"textbox\"\n\t\t\taria-multiline=\"true\"\n\t\t\tonFocus={ onSelect }\n\t\t\tonBlur={ onUnselect }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonPaste={ onPaste }\n\t\t\tstyle={ style }\n\t\t/>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n} );\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {React.ReactNode} The rendered PostTitle component.\n */\nexport default forwardRef( ( _, forwardedRef ) => (\n\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t<PostTitle ref={ forwardedRef } />\n\t</PostTypeSupportCheck>\n) );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,kBAAmB;AACnB,qBAAqC;AACrC,2BAA+B;AAC/B,kBAAuC;AACvC,0BAA0C;AAC1C,sBAAsB;AACtB,oBAA6B;AAC7B,uBAIO;AACP,qBAA6B;AAC7B,iBAAiD;AAKjD,uBAAoD;AACpD,kCAA8B;AAC9B,4BAAyB;AACzB,qCAAiC;AAEjC,yBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nimport { unlock } from '../../lock-unlock';\n\nconst PostTitle = forwardRef( ( _, forwardedRef ) => {\n\tconst { placeholder, isEditingContentOnlySection, isPreview } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedContentOnlySection } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { titlePlaceholder, isPreviewMode } = getSettings();\n\n\t\t\treturn {\n\t\t\t\tplaceholder: titlePlaceholder,\n\t\t\t\tisEditingContentOnlySection: !! getEditedContentOnlySection(),\n\t\t\t\tisPreview: isPreviewMode,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: title,\n\t\tonChange( newValue ) {\n\t\t\tonUpdate( newValue.replace( REGEXP_NEWLINES, ' ' ) );\n\t\t},\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error ) {\n\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t// behaviour.\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\t\t\tonChange( insert( value, create( { html: contentNoHTML } ) ) );\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\t// Because the title is within the editor iframe, we can't use scss styles.\n\t// Instead use an inline style to dim the block when it's disabled.\n\tconst style = isEditingContentOnlySection ? { opacity: 0.2 } : undefined;\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<h1\n\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\tcontentEditable={ ! isEditingContentOnlySection && ! isPreview }\n\t\t\tclassName={ className }\n\t\t\taria-label={ decodedPlaceholder }\n\t\t\trole=\"textbox\"\n\t\t\taria-multiline=\"true\"\n\t\t\tonFocus={ onSelect }\n\t\t\tonBlur={ onUnselect }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonPaste={ onPaste }\n\t\t\tstyle={ style }\n\t\t/>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n} );\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {React.ReactNode} The rendered PostTitle component.\n */\nexport default forwardRef( ( _, forwardedRef ) => (\n\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t<PostTitle ref={ forwardedRef } />\n\t</PostTypeSupportCheck>\n) );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,kBAAmB;AACnB,qBAAqC;AACrC,2BAA+B;AAC/B,kBAAuC;AACvC,0BAA0C;AAC1C,sBAAsB;AACtB,oBAA6B;AAC7B,uBAIO;AACP,qBAA6B;AAC7B,iBAAiD;AAKjD,uBAAoD;AACpD,kCAA8B;AAC9B,4BAAyB;AACzB,qCAAiC;AAEjC,yBAAuB;AA4JrB;AAAA;AAAA;AAAA;AA1JF,IAAM,gBAAY,2BAAY,CAAE,GAAG,iBAAkB;AACpD,QAAM,EAAE,aAAa,6BAA6B,UAAU,QAAI;AAAA,IAC/D,CAAE,WAAY;AACb,YAAM,EAAE,aAAa,4BAA4B,QAAI;AAAA,QACpD,OAAQ,oBAAAA,KAAiB;AAAA,MAC1B;AACA,YAAM,EAAE,kBAAkB,cAAc,IAAI,YAAY;AAExD,aAAO;AAAA,QACN,aAAa;AAAA,QACb,6BAA6B,CAAC,CAAE,4BAA4B;AAAA,QAC5D,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAU,KAAM;AAEtD,QAAM,EAAE,KAAK,SAAS,QAAI,4BAAAC,SAAmB,YAAa;AAE1D,QAAM,EAAE,OAAO,UAAU,SAAS,QAAI,sBAAAC,SAAa;AAEnD,QAAM,CAAE,WAAW,YAAa,QAAI,yBAAU,CAAC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names": ["blockEditorStore", "usePostTitleFocus", "usePostTitle", "useRichText", "stripHTML", "clsx", "PostTypeSupportCheck"]
|
|
7
7
|
}
|
|
@@ -45,6 +45,7 @@ var import_patterns = require("@wordpress/patterns");
|
|
|
45
45
|
var import_blocks = require("@wordpress/blocks");
|
|
46
46
|
var import_with_registry_provider = __toESM(require("./with-registry-provider.cjs"));
|
|
47
47
|
var import_store = require("../../store/index.cjs");
|
|
48
|
+
var import_constants = require("../../store/constants.cjs");
|
|
48
49
|
var import_use_block_editor_settings = __toESM(require("./use-block-editor-settings.cjs"));
|
|
49
50
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
50
51
|
var import_disable_non_page_content_blocks = __toESM(require("./disable-non-page-content-blocks.cjs"));
|
|
@@ -256,6 +257,24 @@ var ExperimentalEditorProvider = (0, import_with_registry_provider.default)(
|
|
|
256
257
|
if (!isReady || !mode) {
|
|
257
258
|
return null;
|
|
258
259
|
}
|
|
260
|
+
const isAttachment = post.type === import_constants.ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor;
|
|
261
|
+
if (isAttachment) {
|
|
262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core_data.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
263
|
+
import_core_data.EntityProvider,
|
|
264
|
+
{
|
|
265
|
+
kind: "postType",
|
|
266
|
+
type: post.type,
|
|
267
|
+
id: post.id,
|
|
268
|
+
children: [
|
|
269
|
+
children,
|
|
270
|
+
!settings.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_global_keyboard_shortcuts.default, {}),
|
|
272
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_keyboard_shortcut_help_modal.default, {})
|
|
273
|
+
] })
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
) });
|
|
277
|
+
}
|
|
259
278
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core_data.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
260
279
|
import_core_data.EntityProvider,
|
|
261
280
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/provider/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tEntityProvider,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} 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';\nimport StartPageOptions from '../start-page-options';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport StartTemplateOptions from '../start-template-options';\nimport EditorKeyboardShortcuts from '../global-keyboard-shortcuts';\nimport PatternRenameModal from '../pattern-rename-modal';\nimport PatternDuplicateModal from '../pattern-duplicate-modal';\nimport TemplatePartMenuItems from '../template-part-menu-items';\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_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 *\n * @example\n * ```jsx\n * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );\n * ```\n *\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost = mode === 'template-locked' ? 'template' : 'post';\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\n/**\n * This component provides the editor context and manages the state of the block editor.\n *\n * @param {Object} props The component props.\n * @param {Object} props.post The post object.\n * @param {Object} props.settings The editor settings.\n * @param {boolean} props.recovery Indicates if the editor is in recovery mode.\n * @param {Array} props.initialEdits The initial edits for the editor.\n * @param {Object} props.children The child components.\n * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.\n * @param {Object} [props.__unstableTemplate] The template object.\n *\n * @example\n * ```jsx\n * <ExperimentalEditorProvider\n * post={ post }\n * settings={ settings }\n * recovery={ recovery }\n * initialEdits={ initialEdits }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </ExperimentalEditorProvider>\n *\n * @return {Object} The rendered ExperimentalEditorProvider component.\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 hasTemplate = !! template;\n\t\tconst {\n\t\t\teditorSettings,\n\t\t\tselection,\n\t\t\tisReady,\n\t\t\tmode,\n\t\t\tdefaultMode,\n\t\t\tpostTypeEntities,\n\t\t} = 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\tgetRenderingMode,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t\tgetDefaultRenderingMode,\n\t\t\t\t} = unlock( select( editorStore ) );\n\t\t\t\tconst { getEntitiesConfig } = select( coreStore );\n\n\t\t\t\tconst _mode = getRenderingMode();\n\t\t\t\tconst _defaultMode = getDefaultRenderingMode( post.type );\n\t\t\t\t/**\n\t\t\t\t * To avoid content \"flash\", wait until rendering mode has been resolved.\n\t\t\t\t * This is important for the initial render of the editor.\n\t\t\t\t *\n\t\t\t\t * - Wait for template to be resolved if the default mode is 'template-locked'.\n\t\t\t\t * - Wait for default mode to be resolved otherwise.\n\t\t\t\t */\n\t\t\t\tconst hasResolvedDefaultMode =\n\t\t\t\t\t_defaultMode === 'template-locked'\n\t\t\t\t\t\t? hasTemplate\n\t\t\t\t\t\t: _defaultMode !== undefined;\n\t\t\t\t// Wait until the default mode is retrieved and start rendering canvas.\n\t\t\t\tconst isRenderingModeReady = _defaultMode !== undefined;\n\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tmode: isRenderingModeReady ? _mode : undefined,\n\t\t\t\t\tdefaultMode: hasResolvedDefaultMode\n\t\t\t\t\t\t? _defaultMode\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t\tpostTypeEntities:\n\t\t\t\t\t\tpost.type === 'wp_template'\n\t\t\t\t\t\t\t? getEntitiesConfig( 'postType' )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ post.type, hasTemplate ]\n\t\t);\n\n\t\tconst shouldRenderTemplate = hasTemplate && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext = {};\n\t\t\t// If it is a template, try to inherit the post type from the name.\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\tif ( post.slug === 'page' ) {\n\t\t\t\t\tpostContext.postType = 'page';\n\t\t\t\t} else if ( post.slug === 'single' ) {\n\t\t\t\t\tpostContext.postType = 'post';\n\t\t\t\t} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {\n\t\t\t\t\t// If the slug is single-{postType}, infer the post type from the name.\n\t\t\t\t\tconst postTypeNames =\n\t\t\t\t\t\tpostTypeEntities?.map( ( entity ) => entity.name ) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst match = post.slug.match(\n\t\t\t\t\t\t`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`\n\t\t\t\t\t);\n\t\t\t\t\tif ( match ) {\n\t\t\t\t\t\tpostContext.postType = match[ 1 ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\n\t\t\t) {\n\t\t\t\tpostContext.postId = post.id;\n\t\t\t\tpostContext.postType = post.type;\n\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\tpost.slug,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\n\t\t\tpostTypeEntities,\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\tmode\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, removeNotice } =\n\t\t\tuseDispatch( 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\n\t\t\t// The dependencies of the hook are omitted deliberately\n\t\t\t// We only want to run setupEditor (with initialEdits) only once per post.\n\t\t\t// A better solution in the future would be to split this effect into multiple ones.\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\tif (\n\t\t\t\ttypeof window !== 'undefined' &&\n\t\t\t\twindow.__experimentalTemplateActivate\n\t\t\t) {\n\t\t\t\t// Clear any notices dependent on the post context.\n\t\t\t\tremoveNotice( 'template-activate-notice' );\n\t\t\t}\n\n\t\t\treturn () => setEditedPost( null, null );\n\t\t}, [ post.type, post.id, setEditedPost, removeNotice ] );\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\tif ( defaultMode ) {\n\t\t\t\tsetRenderingMode( defaultMode );\n\t\t\t}\n\t\t}, [ defaultMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\n\n\t\tif ( ! isReady || ! mode ) {\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{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t\t\t<TemplatePartMenuItems />\n\t\t\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t\t\t<BlockRemovalWarnings />\n\t\t\t\t\t\t\t\t\t<StartPageOptions />\n\t\t\t\t\t\t\t\t\t<StartTemplateOptions />\n\t\t\t\t\t\t\t\t\t<PatternRenameModal />\n\t\t\t\t\t\t\t\t\t<PatternDuplicateModal />\n\t\t\t\t\t\t\t\t</>\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\n/**\n * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).\n *\n * It supports a large number of post types, including post, page, templates,\n * custom post types, patterns, template parts.\n *\n * All modification and changes are performed to the `@wordpress/core-data` store.\n *\n * @param {Object} props The component props.\n * @param {Object} [props.post] The post object to edit. This is required.\n * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.\n * This is optional and can only be used when the post type supports templates (like posts and pages).\n * @param {Object} [props.settings] The settings object to use for the editor.\n * This is optional and can be used to override the default settings.\n * @param {React.ReactNode} [props.children] Children elements for which the BlockEditorProvider context should apply.\n * This is optional.\n *\n * @example\n * ```jsx\n * <EditorProvider\n * post={ post }\n * settings={ settings }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </EditorProvider>\n * ```\n *\n * @return {React.ReactNode} The rendered EditorProvider component.\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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoD;AACpD,kBAAuC;AACvC,kBAAmB;AACnB,uBAIO;AACP,0BAIO;AACP,qBAAsC;AACtC,sBAAuD;AACvD,oBAA4B;AAK5B,oCAAiC;AACjC,mBAAqC;AACrC,uCAAmC;AACnC,yBAAuB;AACvB,6CAAwC;AACxC,2CAAuC;AACvC,2CAA0C;AAC1C,sBAAwB;AACxB,oCAAiC;AACjC,gCAA6B;AAC7B,0CAAsC;AACtC,oCAAiC;AACjC,uCAAoC;AACpC,kCAA+B;AAC/B,qCAAkC;AAClC,sCAAkC;
|
|
6
|
-
"names": ["blockEditorPrivateApis", "editPatternsPrivateApis", "withRegistryProvider", "editorStore", "coreStore", "useBlockEditorSettings", "noticesStore", "useCommands", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tEntityProvider,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} 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 { ATTACHMENT_POST_TYPE } from '../../store/constants';\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';\nimport StartPageOptions from '../start-page-options';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport StartTemplateOptions from '../start-template-options';\nimport EditorKeyboardShortcuts from '../global-keyboard-shortcuts';\nimport PatternRenameModal from '../pattern-rename-modal';\nimport PatternDuplicateModal from '../pattern-duplicate-modal';\nimport TemplatePartMenuItems from '../template-part-menu-items';\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_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 *\n * @example\n * ```jsx\n * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );\n * ```\n *\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost = mode === 'template-locked' ? 'template' : 'post';\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\n/**\n * This component provides the editor context and manages the state of the block editor.\n *\n * @param {Object} props The component props.\n * @param {Object} props.post The post object.\n * @param {Object} props.settings The editor settings.\n * @param {boolean} props.recovery Indicates if the editor is in recovery mode.\n * @param {Array} props.initialEdits The initial edits for the editor.\n * @param {Object} props.children The child components.\n * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.\n * @param {Object} [props.__unstableTemplate] The template object.\n *\n * @example\n * ```jsx\n * <ExperimentalEditorProvider\n * post={ post }\n * settings={ settings }\n * recovery={ recovery }\n * initialEdits={ initialEdits }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </ExperimentalEditorProvider>\n *\n * @return {Object} The rendered ExperimentalEditorProvider component.\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 hasTemplate = !! template;\n\t\tconst {\n\t\t\teditorSettings,\n\t\t\tselection,\n\t\t\tisReady,\n\t\t\tmode,\n\t\t\tdefaultMode,\n\t\t\tpostTypeEntities,\n\t\t} = 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\tgetRenderingMode,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t\tgetDefaultRenderingMode,\n\t\t\t\t} = unlock( select( editorStore ) );\n\t\t\t\tconst { getEntitiesConfig } = select( coreStore );\n\n\t\t\t\tconst _mode = getRenderingMode();\n\t\t\t\tconst _defaultMode = getDefaultRenderingMode( post.type );\n\t\t\t\t/**\n\t\t\t\t * To avoid content \"flash\", wait until rendering mode has been resolved.\n\t\t\t\t * This is important for the initial render of the editor.\n\t\t\t\t *\n\t\t\t\t * - Wait for template to be resolved if the default mode is 'template-locked'.\n\t\t\t\t * - Wait for default mode to be resolved otherwise.\n\t\t\t\t */\n\t\t\t\tconst hasResolvedDefaultMode =\n\t\t\t\t\t_defaultMode === 'template-locked'\n\t\t\t\t\t\t? hasTemplate\n\t\t\t\t\t\t: _defaultMode !== undefined;\n\t\t\t\t// Wait until the default mode is retrieved and start rendering canvas.\n\t\t\t\tconst isRenderingModeReady = _defaultMode !== undefined;\n\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tmode: isRenderingModeReady ? _mode : undefined,\n\t\t\t\t\tdefaultMode: hasResolvedDefaultMode\n\t\t\t\t\t\t? _defaultMode\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t\tpostTypeEntities:\n\t\t\t\t\t\tpost.type === 'wp_template'\n\t\t\t\t\t\t\t? getEntitiesConfig( 'postType' )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ post.type, hasTemplate ]\n\t\t);\n\n\t\tconst shouldRenderTemplate = hasTemplate && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext = {};\n\t\t\t// If it is a template, try to inherit the post type from the name.\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\tif ( post.slug === 'page' ) {\n\t\t\t\t\tpostContext.postType = 'page';\n\t\t\t\t} else if ( post.slug === 'single' ) {\n\t\t\t\t\tpostContext.postType = 'post';\n\t\t\t\t} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {\n\t\t\t\t\t// If the slug is single-{postType}, infer the post type from the name.\n\t\t\t\t\tconst postTypeNames =\n\t\t\t\t\t\tpostTypeEntities?.map( ( entity ) => entity.name ) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst match = post.slug.match(\n\t\t\t\t\t\t`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`\n\t\t\t\t\t);\n\t\t\t\t\tif ( match ) {\n\t\t\t\t\t\tpostContext.postType = match[ 1 ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\n\t\t\t) {\n\t\t\t\tpostContext.postId = post.id;\n\t\t\t\tpostContext.postType = post.type;\n\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\tpost.slug,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\n\t\t\tpostTypeEntities,\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\tmode\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, removeNotice } =\n\t\t\tuseDispatch( 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\n\t\t\t// The dependencies of the hook are omitted deliberately\n\t\t\t// We only want to run setupEditor (with initialEdits) only once per post.\n\t\t\t// A better solution in the future would be to split this effect into multiple ones.\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\tif (\n\t\t\t\ttypeof window !== 'undefined' &&\n\t\t\t\twindow.__experimentalTemplateActivate\n\t\t\t) {\n\t\t\t\t// Clear any notices dependent on the post context.\n\t\t\t\tremoveNotice( 'template-activate-notice' );\n\t\t\t}\n\n\t\t\treturn () => setEditedPost( null, null );\n\t\t}, [ post.type, post.id, setEditedPost, removeNotice ] );\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\tif ( defaultMode ) {\n\t\t\t\tsetRenderingMode( defaultMode );\n\t\t\t}\n\t\t}, [ defaultMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\n\n\t\tif ( ! isReady || ! mode ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst isAttachment =\n\t\t\tpost.type === ATTACHMENT_POST_TYPE &&\n\t\t\twindow?.__experimentalMediaEditor;\n\n\t\t// Early return for attachments - no block editor needed\n\t\tif ( isAttachment ) {\n\t\t\treturn (\n\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\ttype={ post.type }\n\t\t\t\t\t\tid={ post.id }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</EntityProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t);\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{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t\t\t<TemplatePartMenuItems />\n\t\t\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t\t\t<BlockRemovalWarnings />\n\t\t\t\t\t\t\t\t\t<StartPageOptions />\n\t\t\t\t\t\t\t\t\t<StartTemplateOptions />\n\t\t\t\t\t\t\t\t\t<PatternRenameModal />\n\t\t\t\t\t\t\t\t\t<PatternDuplicateModal />\n\t\t\t\t\t\t\t\t</>\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\n/**\n * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).\n *\n * It supports a large number of post types, including post, page, templates,\n * custom post types, patterns, template parts.\n *\n * All modification and changes are performed to the `@wordpress/core-data` store.\n *\n * @param {Object} props The component props.\n * @param {Object} [props.post] The post object to edit. This is required.\n * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.\n * This is optional and can only be used when the post type supports templates (like posts and pages).\n * @param {Object} [props.settings] The settings object to use for the editor.\n * This is optional and can be used to override the default settings.\n * @param {React.ReactNode} [props.children] Children elements for which the BlockEditorProvider context should apply.\n * This is optional.\n *\n * @example\n * ```jsx\n * <EditorProvider\n * post={ post }\n * settings={ settings }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </EditorProvider>\n * ```\n *\n * @return {React.ReactNode} The rendered EditorProvider component.\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoD;AACpD,kBAAuC;AACvC,kBAAmB;AACnB,uBAIO;AACP,0BAIO;AACP,qBAAsC;AACtC,sBAAuD;AACvD,oBAA4B;AAK5B,oCAAiC;AACjC,mBAAqC;AACrC,uBAAqC;AACrC,uCAAmC;AACnC,yBAAuB;AACvB,6CAAwC;AACxC,2CAAuC;AACvC,2CAA0C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eAC5B;AAAA;AAAA;AAAA,MAEF,GACD;AAAA,IAEF;AAEA,WACC,4CAAC,mCAAe,MAAK,QAAO,MAAK,QAChC;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO,KAAK;AAAA,QACZ,IAAK,KAAK;AAAA,QAEV,sDAAC,4CAAqB,OAAQ,qBAC7B;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ;AAAA,YACR;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAW;AAAA,YACX,gBAAiB;AAAA,YAEf;AAAA;AAAA,cACA,CAAE,SAAS,iBACZ,4EACC;AAAA,4DAAC,qBAAkB;AAAA,gBACnB,4CAAC,gCAAAC,SAAA,EAAsB;AAAA,gBACrB,SAAS,qBACV,4CAAC,uCAAAC,SAAA,EAA4B;AAAA,gBAE5B,SAAS,mBACV,4CAAC,qCAAAC,SAAA,EAA2B;AAAA,gBAE7B,4CAAC,iCAAAJ,SAAA,EAAwB;AAAA,gBACzB,4CAAC,oCAAAC,SAAA,EAA0B;AAAA,gBAC3B,4CAAC,8BAAAI,SAAA,EAAqB;AAAA,gBACtB,4CAAC,0BAAAC,SAAA,EAAiB;AAAA,gBAClB,4CAAC,8BAAAC,SAAA,EAAqB;AAAA,gBACtB,4CAAC,4BAAAC,SAAA,EAAmB;AAAA,gBACpB,4CAAC,+BAAAC,SAAA,EAAsB;AAAA,iBACxB;AAAA;AAAA;AAAA,QAEF,GACD;AAAA;AAAA,IACD,GACD;AAAA,EAEF;AACD;AAgCO,SAAS,eAAgB,OAAQ;AACvC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,8BAA+B;AAAA,MAE7B,gBAAM;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,mBAAQ;",
|
|
6
|
+
"names": ["blockEditorPrivateApis", "editPatternsPrivateApis", "withRegistryProvider", "editorStore", "coreStore", "useBlockEditorSettings", "noticesStore", "useCommands", "EditorKeyboardShortcuts", "KeyboardShortcutHelpModal", "TemplatePartMenuItems", "DisableNonPageContentBlocks", "NavigationBlockEditingMode", "BlockRemovalWarnings", "StartPageOptions", "StartTemplateOptions", "PatternRenameModal", "PatternDuplicateModal"]
|
|
7
7
|
}
|
|
@@ -67,6 +67,7 @@ var BLOCK_EDITOR_SETTINGS = [
|
|
|
67
67
|
"maxUploadFileSize",
|
|
68
68
|
"allowedMimeTypes",
|
|
69
69
|
"bodyPlaceholder",
|
|
70
|
+
"canEditCSS",
|
|
70
71
|
"canLockBlocks",
|
|
71
72
|
"canUpdateBlockBindings",
|
|
72
73
|
"capabilities",
|
|
@@ -322,7 +323,7 @@ function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
|
322
323
|
"wp_block",
|
|
323
324
|
"wp_navigation"
|
|
324
325
|
].includes(postType),
|
|
325
|
-
...
|
|
326
|
+
...deviceType ? { [deviceTypeKey]: deviceType } : {}
|
|
326
327
|
};
|
|
327
328
|
return blockEditorSettings;
|
|
328
329
|
}, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/provider/use-block-editor-settings.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { default as mediaSideload } from '../../utils/media-sideload';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useGlobalStylesContext } from '../global-styles-provider';\n\nconst EMPTY_OBJECT = {};\n\nfunction __experimentalReusableBlocksSelect( select ) {\n\tconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\tconst { getEntityRecords } = select( coreStore );\n\treturn getEntityRecords( 'postType', 'wp_block', {\n\t\tper_page: -1,\n\t\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n\t} );\n}\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockBindingsSupportedAttributes',\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'alignWide',\n\t'blockInspectorTabs',\n\t'maxUploadFileSize',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'canUpdateBlockBindings',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'onNavigateToEntityRecord',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isPreviewMode',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\nconst {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n\tmediaEditKey,\n\tgetMediaSelectKey,\n\tisIsolatedEditorKey,\n\tdeviceTypeKey,\n} = unlock( privateApis );\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n * @param {string} renderingMode Editor rendering mode.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId, renderingMode ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallowRightClickOverrides,\n\t\tblockTypes,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\thiddenBlockTypes,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t\trestBlockPatternCategories,\n\t\tsectionRootClientId,\n\t\tdeviceType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst { getDeviceType } = unlock( select( editorStore ) );\n\t\t\tconst { getBlocksByName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tfunction getSectionRootBlock() {\n\t\t\t\tif ( renderingMode === 'template-locked' ) {\n\t\t\t\t\treturn getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlocksByName( 'core/group' ).find(\n\t\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )?.tagName === 'main'\n\t\t\t\t\t) ?? ''\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\thiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\thasUploadPermissions:\n\t\t\t\t\tcanUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'attachment',\n\t\t\t\t\t} ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'page',\n\t\t\t\t} ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t\tsectionRootClientId: getSectionRootBlock(),\n\t\t\t\tdeviceType: getDeviceType(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport, renderingMode ]\n\t);\n\n\tconst { merged: mergedGlobalStyles } = useGlobalStylesContext();\n\tconst globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT;\n\tconst globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT;\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[ ...( settingsBlockPatterns || [] ) ].filter(\n\t\t\t\t( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t),\n\t\t[ settingsBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\tconst { editMediaEntity } = unlock( useDispatch( coreStore ) );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\n\t/**\n\t * Wraps onNavigateToEntityRecord to automatically include the currently selected block.\n\t * This ensures that navigation can restore the selection when returning to the previous entity.\n\t */\n\tconst wrappedOnNavigateToEntityRecord = useCallback(\n\t\t( params ) => {\n\t\t\tif ( ! settings.onNavigateToEntityRecord ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn settings.onNavigateToEntityRecord( {\n\t\t\t\t...params,\n\t\t\t\tselectedBlockClientId,\n\t\t\t} );\n\t\t},\n\t\t[ settings, getSelectedBlockClientId ]\n\t);\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\treturn defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings.allowedBlockTypes;\n\t}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo( () => {\n\t\tconst blockEditorSettings = {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings )\n\t\t\t\t\t.filter( ( [ key ] ) =>\n\t\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t\t)\n\t\t\t\t\t// Exclude onNavigateToEntityRecord since we're wrapping it\n\t\t\t\t\t.filter( ( [ key ] ) => key !== 'onNavigateToEntityRecord' )\n\t\t\t),\n\t\t\t[ globalStylesDataKey ]: globalStylesData,\n\t\t\t[ globalStylesLinksDataKey ]: globalStylesLinksData,\n\t\t\tallowedBlockTypes,\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tonNavigateToEntityRecord: settings.onNavigateToEntityRecord\n\t\t\t\t? wrappedOnNavigateToEntityRecord\n\t\t\t\t: undefined,\n\t\t\t[ getMediaSelectKey ]: ( select, attachmentId ) => {\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ mediaEditKey ]: hasUploadPermissions\n\t\t\t\t? editMediaEntity\n\t\t\t\t: undefined,\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\tmediaSideload: hasUploadPermissions ? mediaSideload : undefined,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t[ selectBlockPatternsKey ]: ( select ) => {\n\t\t\t\tconst { hasFinishedResolution, getBlockPatternsForPostType } =\n\t\t\t\t\tunlock( select( coreStore ) );\n\t\t\t\tconst patterns = getBlockPatternsForPostType( postType );\n\t\t\t\treturn hasFinishedResolution( 'getBlockPatterns' )\n\t\t\t\t\t? patterns\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\t[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: ! isDistractionFree && postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\t[ sectionRootClientIdKey ]: sectionRootClientId,\n\t\t\teditorTool:\n\t\t\t\trenderingMode === 'post-only' && postType !== 'wp_template'\n\t\t\t\t\t? 'edit'\n\t\t\t\t\t: undefined,\n\t\t\t// When editing template parts, patterns, or navigation directly,\n\t\t\t// we're in an isolated editing context (focused on that entity alone).\n\t\t\t[ isIsolatedEditorKey ]: [\n\t\t\t\t'wp_template_part',\n\t\t\t\t'wp_block',\n\t\t\t\t'wp_navigation',\n\t\t\t].includes( postType ),\n\t\t\t...( window.__experimentalHideBlocksBasedOnScreenSize && deviceType\n\t\t\t\t? { [ deviceTypeKey ]: deviceType }\n\t\t\t\t: {} ),\n\t\t};\n\n\t\treturn blockEditorSettings;\n\t}, [\n\t\tallowedBlockTypes,\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\tforceDisableFocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\tsettings,\n\t\thasUploadPermissions,\n\t\tuserPatternCategories,\n\t\tblockPatterns,\n\t\tblockPatternCategories,\n\t\tcanUseUnfilteredHTML,\n\t\tundo,\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tsetIsInserterOpened,\n\t\tsectionRootClientId,\n\t\tglobalStylesData,\n\t\tglobalStylesLinksData,\n\t\trenderingMode,\n\t\teditMediaEntity,\n\t\twrappedOnNavigateToEntityRecord,\n\t\tdeviceType,\n\t] );\n}\n\nexport default useBlockEditorSettings;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAqC;AACrC,kBAAuC;AACvC,uBAKO;AACP,kBAAmB;AACnB,yBAA0C;AAC1C,qBAAiC;AACjC,oBAAqC;AACrC,0BAGO;AAKP,8BAAoC;AACpC,mBAA4B;AAC5B,4BAAyC;AACzC,mBAAqC;AACrC,yBAAuB;AACvB,oCAAuC;AAEvC,IAAM,eAAe,CAAC;AAEtB,SAAS,mCAAoC,QAAS;AACrD,QAAM,EAAE,6BAA6B,QAAI,2BAAQ,iBAAAA,WAAoB;AACrE,QAAM,EAAE,iBAAiB,IAAI,OAAQ,iBAAAC,KAAU;AAC/C,SAAO,iBAAkB,YAAY,YAAY;AAAA,IAChD,UAAU;AAAA,IACV,CAAE,4BAA6B,GAAG;AAAA,EACnC,CAAE;AACH;AAEA,IAAM,wBAAwB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;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,uBAAuB,sBAAAK,UAAgB;AAAA,MACtD,6BAA6B;AAAA,MAC7B,CAAE,sBAAuB,GAAG,CAAE,WAAY;AACzC,cAAM,EAAE,uBAAuB,4BAA4B,QAC1D,2BAAQ,OAAQ,iBAAAL,KAAU,CAAE;AAC7B,cAAM,WAAW,4BAA6B,QAAS;AACvD,eAAO,sBAAuB,kBAAmB,IAC9C,WACA;AAAA,MACJ;AAAA,MACA,CAAE,uBAAwB,GAAG;AAAA,MAC7B,sCAAsC;AAAA,MACtC,qCAAqC;AAAA,MACrC,oCAAoC,CAAE,QAAQ,sBAC7C,iBAAAM,oCAAsB,QAAQ,eAAe,QAAS;AAAA,MACvD,iDAAAC;AAAA,MACA,gCAAgC,iBAAAC;AAAA;AAAA;AAAA,MAGhC,wCAAwC;AAAA;AAAA,MAExC,oBAAoB;AAAA;AAAA;AAAA,MAGpB,aAAa,CAAE,qBAAqB,aAAa;AAAA;AAAA,MAEjD,gCAAgC;AAAA,MAChC,kCAAkC;AAAA,MAClC;AAAA,MACA;AAAA,MACA,oCAAoC,aAAa;AAAA,MACjD,cACC,aAAa,kBAAkB,WAAW,SAAS;AAAA,MACpD,UACC,aAAa,kBACV,CAAE,CAAE,mBAAmB,CAAC,GAAG,CAAC,CAAE,CAAE,IAChC,SAAS;AAAA,MACb,mCAAmC;AAAA,MACnC,CAAE,sBAAuB,GAAG;AAAA,MAC5B,YACC,kBAAkB,eAAe,aAAa,gBAC3C,SACA;AAAA;AAAA;AAAA,MAGJ,CAAE,mBAAoB,GAAG;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,MACD,EAAE,SAAU,QAAS;AAAA,MACrB,GAAK,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { default as mediaSideload } from '../../utils/media-sideload';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useGlobalStylesContext } from '../global-styles-provider';\n\nconst EMPTY_OBJECT = {};\n\nfunction __experimentalReusableBlocksSelect( select ) {\n\tconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\tconst { getEntityRecords } = select( coreStore );\n\treturn getEntityRecords( 'postType', 'wp_block', {\n\t\tper_page: -1,\n\t\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n\t} );\n}\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockBindingsSupportedAttributes',\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'alignWide',\n\t'blockInspectorTabs',\n\t'maxUploadFileSize',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canEditCSS',\n\t'canLockBlocks',\n\t'canUpdateBlockBindings',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'onNavigateToEntityRecord',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isPreviewMode',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\nconst {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n\tmediaEditKey,\n\tgetMediaSelectKey,\n\tisIsolatedEditorKey,\n\tdeviceTypeKey,\n} = unlock( privateApis );\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n * @param {string} renderingMode Editor rendering mode.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId, renderingMode ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallowRightClickOverrides,\n\t\tblockTypes,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\thiddenBlockTypes,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t\trestBlockPatternCategories,\n\t\tsectionRootClientId,\n\t\tdeviceType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst { getDeviceType } = unlock( select( editorStore ) );\n\t\t\tconst { getBlocksByName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tfunction getSectionRootBlock() {\n\t\t\t\tif ( renderingMode === 'template-locked' ) {\n\t\t\t\t\treturn getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlocksByName( 'core/group' ).find(\n\t\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )?.tagName === 'main'\n\t\t\t\t\t) ?? ''\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\thiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\thasUploadPermissions:\n\t\t\t\t\tcanUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'attachment',\n\t\t\t\t\t} ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'page',\n\t\t\t\t} ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t\tsectionRootClientId: getSectionRootBlock(),\n\t\t\t\tdeviceType: getDeviceType(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport, renderingMode ]\n\t);\n\n\tconst { merged: mergedGlobalStyles } = useGlobalStylesContext();\n\tconst globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT;\n\tconst globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT;\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[ ...( settingsBlockPatterns || [] ) ].filter(\n\t\t\t\t( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t),\n\t\t[ settingsBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\tconst { editMediaEntity } = unlock( useDispatch( coreStore ) );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\n\t/**\n\t * Wraps onNavigateToEntityRecord to automatically include the currently selected block.\n\t * This ensures that navigation can restore the selection when returning to the previous entity.\n\t */\n\tconst wrappedOnNavigateToEntityRecord = useCallback(\n\t\t( params ) => {\n\t\t\tif ( ! settings.onNavigateToEntityRecord ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn settings.onNavigateToEntityRecord( {\n\t\t\t\t...params,\n\t\t\t\tselectedBlockClientId,\n\t\t\t} );\n\t\t},\n\t\t[ settings, getSelectedBlockClientId ]\n\t);\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\treturn defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings.allowedBlockTypes;\n\t}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo( () => {\n\t\tconst blockEditorSettings = {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings )\n\t\t\t\t\t.filter( ( [ key ] ) =>\n\t\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t\t)\n\t\t\t\t\t// Exclude onNavigateToEntityRecord since we're wrapping it\n\t\t\t\t\t.filter( ( [ key ] ) => key !== 'onNavigateToEntityRecord' )\n\t\t\t),\n\t\t\t[ globalStylesDataKey ]: globalStylesData,\n\t\t\t[ globalStylesLinksDataKey ]: globalStylesLinksData,\n\t\t\tallowedBlockTypes,\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tonNavigateToEntityRecord: settings.onNavigateToEntityRecord\n\t\t\t\t? wrappedOnNavigateToEntityRecord\n\t\t\t\t: undefined,\n\t\t\t[ getMediaSelectKey ]: ( select, attachmentId ) => {\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ mediaEditKey ]: hasUploadPermissions\n\t\t\t\t? editMediaEntity\n\t\t\t\t: undefined,\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\tmediaSideload: hasUploadPermissions ? mediaSideload : undefined,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t[ selectBlockPatternsKey ]: ( select ) => {\n\t\t\t\tconst { hasFinishedResolution, getBlockPatternsForPostType } =\n\t\t\t\t\tunlock( select( coreStore ) );\n\t\t\t\tconst patterns = getBlockPatternsForPostType( postType );\n\t\t\t\treturn hasFinishedResolution( 'getBlockPatterns' )\n\t\t\t\t\t? patterns\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\t[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: ! isDistractionFree && postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\t[ sectionRootClientIdKey ]: sectionRootClientId,\n\t\t\teditorTool:\n\t\t\t\trenderingMode === 'post-only' && postType !== 'wp_template'\n\t\t\t\t\t? 'edit'\n\t\t\t\t\t: undefined,\n\t\t\t// When editing template parts, patterns, or navigation directly,\n\t\t\t// we're in an isolated editing context (focused on that entity alone).\n\t\t\t[ isIsolatedEditorKey ]: [\n\t\t\t\t'wp_template_part',\n\t\t\t\t'wp_block',\n\t\t\t\t'wp_navigation',\n\t\t\t].includes( postType ),\n\t\t\t...( deviceType ? { [ deviceTypeKey ]: deviceType } : {} ),\n\t\t};\n\n\t\treturn blockEditorSettings;\n\t}, [\n\t\tallowedBlockTypes,\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\tforceDisableFocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\tsettings,\n\t\thasUploadPermissions,\n\t\tuserPatternCategories,\n\t\tblockPatterns,\n\t\tblockPatternCategories,\n\t\tcanUseUnfilteredHTML,\n\t\tundo,\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tsetIsInserterOpened,\n\t\tsectionRootClientId,\n\t\tglobalStylesData,\n\t\tglobalStylesLinksData,\n\t\trenderingMode,\n\t\teditMediaEntity,\n\t\twrappedOnNavigateToEntityRecord,\n\t\tdeviceType,\n\t] );\n}\n\nexport default useBlockEditorSettings;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAqC;AACrC,kBAAuC;AACvC,uBAKO;AACP,kBAAmB;AACnB,yBAA0C;AAC1C,qBAAiC;AACjC,oBAAqC;AACrC,0BAGO;AAKP,8BAAoC;AACpC,mBAA4B;AAC5B,4BAAyC;AACzC,mBAAqC;AACrC,yBAAuB;AACvB,oCAAuC;AAEvC,IAAM,eAAe,CAAC;AAEtB,SAAS,mCAAoC,QAAS;AACrD,Q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G;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,MACD,EAAE,SAAU,QAAS;AAAA,MACrB,GAAK,aAAa,EAAE,CAAE,aAAc,GAAG,WAAW,IAAI,CAAC;AAAA,IACxD;AAEA,WAAO;AAAA,EACR,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAEA,IAAO,oCAAQ;",
|
|
6
6
|
"names": ["coreDataPrivateApis", "coreStore", "preferencesStore", "blocksStore", "editorStore", "blockEditorStore", "mediaSideload", "fetchLinkSuggestions", "inserterMediaCategories", "fetchUrlData"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/editor/src/components/revision-author-panel/index.js
|
|
31
|
+
var revision_author_panel_exports = {};
|
|
32
|
+
__export(revision_author_panel_exports, {
|
|
33
|
+
default: () => RevisionAuthorPanel
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(revision_author_panel_exports);
|
|
36
|
+
var import_data = require("@wordpress/data");
|
|
37
|
+
var import_core_data = require("@wordpress/core-data");
|
|
38
|
+
var import_html_entities = require("@wordpress/html-entities");
|
|
39
|
+
var import_i18n = require("@wordpress/i18n");
|
|
40
|
+
var import_post_panel_row = __toESM(require("../post-panel-row/index.cjs"));
|
|
41
|
+
var import_store = require("../../store/index.cjs");
|
|
42
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
function RevisionAuthorPanel() {
|
|
45
|
+
const authorName = (0, import_data.useSelect)((select) => {
|
|
46
|
+
const { getCurrentRevision } = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
47
|
+
const revision = getCurrentRevision();
|
|
48
|
+
if (!revision?.author) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const author = select(import_core_data.store).getUser(revision.author);
|
|
52
|
+
return author?.name;
|
|
53
|
+
}, []);
|
|
54
|
+
if (!authorName) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_post_panel_row.default, { label: (0, import_i18n.__)("Author"), children: (0, import_html_entities.decodeEntities)(authorName) });
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/revision-author-panel/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport default function RevisionAuthorPanel() {\n\tconst authorName = useSelect( ( select ) => {\n\t\tconst { getCurrentRevision } = unlock( select( editorStore ) );\n\t\tconst revision = getCurrentRevision();\n\t\tif ( ! revision?.author ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst author = select( coreStore ).getUser( revision.author );\n\t\treturn author?.name;\n\t}, [] );\n\n\tif ( ! authorName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Author' ) }>\n\t\t\t{ decodeEntities( authorName ) }\n\t\t</PostPanelRow>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,uBAAmC;AACnC,2BAA+B;AAC/B,kBAAmB;AAKnB,4BAAyB;AACzB,mBAAqC;AACrC,yBAAuB;AAkBrB;AAhBa,SAAR,sBAAuC;AAC7C,QAAM,iBAAa,uBAAW,CAAE,WAAY;AAC3C,UAAM,EAAE,mBAAmB,QAAI,2BAAQ,OAAQ,aAAAA,KAAY,CAAE;AAC7D,UAAM,WAAW,mBAAmB;AACpC,QAAK,CAAE,UAAU,QAAS;AACzB,aAAO;AAAA,IACR;AACA,UAAM,SAAS,OAAQ,iBAAAC,KAAU,EAAE,QAAS,SAAS,MAAO;AAC5D,WAAO,QAAQ;AAAA,EAChB,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,YAAa;AACnB,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,sBAAAC,SAAA,EAAa,WAAQ,gBAAI,QAAS,GAChC,mDAAgB,UAAW,GAC9B;AAEF;",
|
|
6
|
+
"names": ["editorStore", "coreStore", "PostPanelRow"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/editor/src/components/revision-created-panel/index.js
|
|
21
|
+
var revision_created_panel_exports = {};
|
|
22
|
+
__export(revision_created_panel_exports, {
|
|
23
|
+
default: () => RevisionCreatedPanel
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(revision_created_panel_exports);
|
|
26
|
+
var import_components = require("@wordpress/components");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_i18n = require("@wordpress/i18n");
|
|
29
|
+
var import_date = require("@wordpress/date");
|
|
30
|
+
var import_store = require("../../store/index.cjs");
|
|
31
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
function RevisionCreatedPanel() {
|
|
34
|
+
const date = (0, import_data.useSelect)((select) => {
|
|
35
|
+
const { getCurrentRevision } = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
36
|
+
return getCurrentRevision()?.date;
|
|
37
|
+
}, []);
|
|
38
|
+
if (!date) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-post-last-edited-panel", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { children: (0, import_i18n.sprintf)(
|
|
42
|
+
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
43
|
+
(0, import_i18n.__)("Created %s."),
|
|
44
|
+
(0, import_date.humanTimeDiff)(date)
|
|
45
|
+
) }) });
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/revision-created-panel/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalText as Text } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { humanTimeDiff } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport default function RevisionCreatedPanel() {\n\tconst date = useSelect( ( select ) => {\n\t\tconst { getCurrentRevision } = unlock( select( editorStore ) );\n\t\treturn getCurrentRevision()?.date;\n\t}, [] );\n\n\tif ( ! date ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"editor-post-last-edited-panel\">\n\t\t\t<Text>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t\t\t__( 'Created %s.' ),\n\t\t\t\t\thumanTimeDiff( date )\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA2C;AAC3C,kBAA0B;AAC1B,kBAA4B;AAC5B,kBAA8B;AAK9B,mBAAqC;AACrC,yBAAuB;AAcpB;AAZY,SAAR,uBAAwC;AAC9C,QAAM,WAAO,uBAAW,CAAE,WAAY;AACrC,UAAM,EAAE,mBAAmB,QAAI,2BAAQ,OAAQ,aAAAA,KAAY,CAAE;AAC7D,WAAO,mBAAmB,GAAG;AAAA,EAC9B,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,SAAI,WAAU,iCACd,sDAAC,kBAAAC,oBAAA,EACE;AAAA;AAAA,QAED,gBAAI,aAAc;AAAA,QAClB,2BAAe,IAAK;AAAA,EACrB,GACD,GACD;AAEF;",
|
|
6
|
+
"names": ["editorStore", "Text"]
|
|
7
|
+
}
|
|
@@ -29,33 +29,48 @@ var import_data = require("@wordpress/data");
|
|
|
29
29
|
var import_element = require("@wordpress/element");
|
|
30
30
|
var import_html_entities = require("@wordpress/html-entities");
|
|
31
31
|
var import_store = require("../../store/index.cjs");
|
|
32
|
+
var import_constants = require("../../store/constants.cjs");
|
|
32
33
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
33
|
-
var
|
|
34
|
+
var import_constants2 = require("./constants.cjs");
|
|
34
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
36
|
var { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
36
37
|
var SidebarHeader = (_, ref) => {
|
|
37
|
-
const postTypeLabel = (0, import_data.useSelect)(
|
|
38
|
-
(select) =>
|
|
38
|
+
const { postTypeLabel, isAttachment, isRevisionsMode } = (0, import_data.useSelect)(
|
|
39
|
+
(select) => {
|
|
40
|
+
const { getPostTypeLabel, getCurrentPostType } = select(import_store.store);
|
|
41
|
+
const { isRevisionsMode: _isRevisionsMode } = (0, import_lock_unlock.unlock)(
|
|
42
|
+
select(import_store.store)
|
|
43
|
+
);
|
|
44
|
+
return {
|
|
45
|
+
postTypeLabel: getPostTypeLabel(),
|
|
46
|
+
isAttachment: getCurrentPostType() === import_constants.ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor,
|
|
47
|
+
isRevisionsMode: _isRevisionsMode()
|
|
48
|
+
};
|
|
49
|
+
},
|
|
39
50
|
[]
|
|
40
51
|
);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(0, import_i18n.
|
|
44
|
-
)
|
|
52
|
+
let documentLabel;
|
|
53
|
+
if (isRevisionsMode) {
|
|
54
|
+
documentLabel = (0, import_i18n.__)("Revision");
|
|
55
|
+
} else if (postTypeLabel) {
|
|
56
|
+
documentLabel = (0, import_html_entities.decodeEntities)(postTypeLabel);
|
|
57
|
+
} else {
|
|
58
|
+
documentLabel = (0, import_i18n._x)("Document", "noun, panel");
|
|
59
|
+
}
|
|
45
60
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs.TabList, { ref, children: [
|
|
46
61
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
47
62
|
Tabs.Tab,
|
|
48
63
|
{
|
|
49
|
-
tabId:
|
|
50
|
-
"data-tab-id":
|
|
64
|
+
tabId: import_constants2.sidebars.document,
|
|
65
|
+
"data-tab-id": import_constants2.sidebars.document,
|
|
51
66
|
children: documentLabel
|
|
52
67
|
}
|
|
53
68
|
),
|
|
54
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
!isAttachment && !isRevisionsMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
70
|
Tabs.Tab,
|
|
56
71
|
{
|
|
57
|
-
tabId:
|
|
58
|
-
"data-tab-id":
|
|
72
|
+
tabId: import_constants2.sidebars.block,
|
|
73
|
+
"data-tab-id": import_constants2.sidebars.block,
|
|
59
74
|
children: (0, import_i18n.__)("Block")
|
|
60
75
|
}
|
|
61
76
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar/header.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { sidebars } from './constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SidebarHeader = ( _, ref ) => {\n\tconst postTypeLabel = useSelect(\n\t\t( select ) =>
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAqD;AACrD,kBAAuB;AACvB,kBAA0B;AAC1B,qBAA2B;AAC3B,2BAA+B;AAK/B,mBAAqC;AACrC,yBAAuB;AACvB,
|
|
6
|
-
"names": ["componentsPrivateApis", "editorStore"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE } from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport { sidebars } from './constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SidebarHeader = ( _, ref ) => {\n\tconst { postTypeLabel, isAttachment, isRevisionsMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostTypeLabel, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { isRevisionsMode: _isRevisionsMode } = unlock(\n\t\t\t\tselect( editorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tpostTypeLabel: getPostTypeLabel(),\n\t\t\t\tisAttachment:\n\t\t\t\t\tgetCurrentPostType() === ATTACHMENT_POST_TYPE &&\n\t\t\t\t\twindow?.__experimentalMediaEditor,\n\t\t\t\tisRevisionsMode: _isRevisionsMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tlet documentLabel;\n\tif ( isRevisionsMode ) {\n\t\tdocumentLabel = __( 'Revision' );\n\t} else if ( postTypeLabel ) {\n\t\tdocumentLabel = decodeEntities( postTypeLabel );\n\t} else {\n\t\t// translators: Default label for the Document sidebar tab, not selected.\n\t\tdocumentLabel = _x( 'Document', 'noun, panel' );\n\t}\n\n\treturn (\n\t\t<Tabs.TabList ref={ ref }>\n\t\t\t<Tabs.Tab\n\t\t\t\ttabId={ sidebars.document }\n\t\t\t\t// Used for focus management in the SettingsSidebar component.\n\t\t\t\tdata-tab-id={ sidebars.document }\n\t\t\t>\n\t\t\t\t{ documentLabel }\n\t\t\t</Tabs.Tab>\n\t\t\t{ ! isAttachment && ! isRevisionsMode && (\n\t\t\t\t<Tabs.Tab\n\t\t\t\t\ttabId={ sidebars.block }\n\t\t\t\t\t// Used for focus management in the SettingsSidebar component.\n\t\t\t\t\tdata-tab-id={ sidebars.block }\n\t\t\t\t>\n\t\t\t\t\t{ /* translators: Text label for the Block Settings Sidebar tab. */ }\n\t\t\t\t\t{ __( 'Block' ) }\n\t\t\t\t</Tabs.Tab>\n\t\t\t) }\n\t\t</Tabs.TabList>\n\t);\n};\n\nexport default forwardRef( SidebarHeader );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAqD;AACrD,kBAAuB;AACvB,kBAA0B;AAC1B,qBAA2B;AAC3B,2BAA+B;AAK/B,mBAAqC;AACrC,uBAAqC;AACrC,yBAAuB;AACvB,IAAAA,oBAAyB;AAkCvB;AAhCF,IAAM,EAAE,KAAK,QAAI,2BAAQ,kBAAAC,WAAsB;AAE/C,IAAM,gBAAgB,CAAE,GAAG,QAAS;AACnC,QAAM,EAAE,eAAe,cAAc,gBAAgB,QAAI;AAAA,IACxD,CAAE,WAAY;AACb,YAAM,EAAE,kBAAkB,mBAAmB,IAC5C,OAAQ,aAAAC,KAAY;AACrB,YAAM,EAAE,iBAAiB,iBAAiB,QAAI;AAAA,QAC7C,OAAQ,aAAAA,KAAY;AAAA,MACrB;AACA,aAAO;AAAA,QACN,eAAe,iBAAiB;AAAA,QAChC,cACC,mBAAmB,MAAM,yCACzB,QAAQ;AAAA,QACT,iBAAiB,iBAAiB;AAAA,MACnC;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,MAAI;AACJ,MAAK,iBAAkB;AACtB,wBAAgB,gBAAI,UAAW;AAAA,EAChC,WAAY,eAAgB;AAC3B,wBAAgB,qCAAgB,aAAc;AAAA,EAC/C,OAAO;AAEN,wBAAgB,gBAAI,YAAY,aAAc;AAAA,EAC/C;AAEA,SACC,6CAAC,KAAK,SAAL,EAAa,KACb;AAAA;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QACA,OAAQ,2BAAS;AAAA,QAEjB,eAAc,2BAAS;AAAA,QAErB;AAAA;AAAA,IACH;AAAA,IACE,CAAE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