@wordpress/editor 13.27.1 → 13.27.2
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/build/bindings/post-meta.js +2 -2
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/document-bar/index.js +4 -19
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +22 -6
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-canvas/index.js +3 -3
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +24 -12
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +15 -10
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +21 -5
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/provider/index.js +3 -3
- package/build/components/provider/index.js.map +1 -1
- package/build/store/actions.js +7 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +1 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +10 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/bindings/post-meta.js +2 -2
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/document-bar/index.js +4 -19
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +22 -6
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +3 -3
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +24 -12
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +15 -10
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +21 -5
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/provider/index.js +3 -3
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/store/actions.js +7 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +10 -0
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +6 -6
- package/src/bindings/post-meta.js +2 -2
- package/src/components/document-bar/index.js +4 -23
- package/src/components/editor-canvas/edit-template-blocks-notification.js +21 -5
- package/src/components/editor-canvas/index.js +3 -3
- package/src/components/post-template/block-theme.js +32 -20
- package/src/components/post-template/classic-theme.js +19 -9
- package/src/components/post-template/create-new-template-modal.js +19 -9
- package/src/components/provider/index.js +3 -11
- package/src/store/actions.js +8 -3
- package/src/store/private-actions.js +1 -0
- package/src/store/selectors.js +12 -0
|
@@ -30,7 +30,26 @@ import { store as editorStore } from '../../store';
|
|
|
30
30
|
export default function EditTemplateBlocksNotification({
|
|
31
31
|
contentRef
|
|
32
32
|
}) {
|
|
33
|
-
const
|
|
33
|
+
const {
|
|
34
|
+
renderingMode,
|
|
35
|
+
getPostLinkProps,
|
|
36
|
+
templateId
|
|
37
|
+
} = useSelect(select => {
|
|
38
|
+
const {
|
|
39
|
+
getRenderingMode,
|
|
40
|
+
getEditorSettings,
|
|
41
|
+
getCurrentTemplateId
|
|
42
|
+
} = select(editorStore);
|
|
43
|
+
return {
|
|
44
|
+
renderingMode: getRenderingMode(),
|
|
45
|
+
getPostLinkProps: getEditorSettings().getPostLinkProps,
|
|
46
|
+
templateId: getCurrentTemplateId()
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
const editTemplate = getPostLinkProps ? getPostLinkProps({
|
|
50
|
+
postId: templateId,
|
|
51
|
+
postType: 'wp_template'
|
|
52
|
+
}) : {};
|
|
34
53
|
const {
|
|
35
54
|
getNotices
|
|
36
55
|
} = useSelect(noticesStore);
|
|
@@ -38,9 +57,6 @@ export default function EditTemplateBlocksNotification({
|
|
|
38
57
|
createInfoNotice,
|
|
39
58
|
removeNotice
|
|
40
59
|
} = useDispatch(noticesStore);
|
|
41
|
-
const {
|
|
42
|
-
setRenderingMode
|
|
43
|
-
} = useDispatch(editorStore);
|
|
44
60
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
45
61
|
const lastNoticeId = useRef(0);
|
|
46
62
|
useEffect(() => {
|
|
@@ -62,7 +78,7 @@ export default function EditTemplateBlocksNotification({
|
|
|
62
78
|
type: 'snackbar',
|
|
63
79
|
actions: [{
|
|
64
80
|
label: __('Edit template'),
|
|
65
|
-
onClick: () =>
|
|
81
|
+
onClick: () => editTemplate.onClick()
|
|
66
82
|
}]
|
|
67
83
|
});
|
|
68
84
|
lastNoticeId.current = notice.id;
|
|
@@ -92,7 +108,7 @@ export default function EditTemplateBlocksNotification({
|
|
|
92
108
|
confirmButtonText: __('Edit template'),
|
|
93
109
|
onConfirm: () => {
|
|
94
110
|
setIsDialogOpen(false);
|
|
95
|
-
|
|
111
|
+
editTemplate.onClick();
|
|
96
112
|
},
|
|
97
113
|
onCancel: () => setIsDialogOpen(false)
|
|
98
114
|
}, __('Edit your template to edit this block.'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useEffect","useState","useRef","store","noticesStore","__","__experimentalConfirmDialog","ConfirmDialog","editorStore","EditTemplateBlocksNotification","contentRef","renderingMode","select","getRenderingMode","getNotices","createInfoNotice","removeNotice","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useEffect","useState","useRef","store","noticesStore","__","__experimentalConfirmDialog","ConfirmDialog","editorStore","EditTemplateBlocksNotification","contentRef","renderingMode","getPostLinkProps","templateId","select","getRenderingMode","getEditorSettings","getCurrentTemplateId","editTemplate","postId","postType","getNotices","createInfoNotice","removeNotice","isDialogOpen","setIsDialogOpen","lastNoticeId","handleClick","event","target","classList","contains","isNoticeAlreadyShowing","some","notice","id","current","isDismissible","type","actions","label","onClick","handleDblClick","canvas","addEventListener","removeEventListener","createElement","isOpen","confirmButtonText","onConfirm","onCancel"],"sources":["@wordpress/editor/src/components/editor-canvas/edit-template-blocks-notification.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page conetnt and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateBlocksNotification( { contentRef } ) {\n\tconst { renderingMode, getPostLinkProps, templateId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetRenderingMode,\n\t\t\t\tgetEditorSettings,\n\t\t\t\tgetCurrentTemplateId,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\trenderingMode: getRenderingMode(),\n\t\t\t\tgetPostLinkProps: getEditorSettings().getPostLinkProps,\n\t\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst editTemplate = getPostLinkProps\n\t\t? getPostLinkProps( {\n\t\t\t\tpostId: templateId,\n\t\t\t\tpostType: 'wp_template',\n\t\t } )\n\t\t: {};\n\tconst { getNotices } = useSelect( noticesStore );\n\n\tconst { createInfoNotice, removeNotice } = useDispatch( noticesStore );\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tconst lastNoticeId = useRef( 0 );\n\n\tuseEffect( () => {\n\t\tconst handleClick = async ( event ) => {\n\t\t\tif ( renderingMode !== 'template-locked' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( ! event.target.classList.contains( 'is-root-container' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst isNoticeAlreadyShowing = getNotices().some(\n\t\t\t\t( notice ) => notice.id === lastNoticeId.current\n\t\t\t);\n\t\t\tif ( isNoticeAlreadyShowing ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { notice } = await createInfoNotice(\n\t\t\t\t__( 'Edit your template to edit this block.' ),\n\t\t\t\t{\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Edit template' ),\n\t\t\t\t\t\t\tonClick: () => editTemplate.onClick(),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t\tlastNoticeId.current = notice.id;\n\t\t};\n\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( renderingMode !== 'template-locked' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( ! event.target.classList.contains( 'is-root-container' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( lastNoticeId.current ) {\n\t\t\t\tremoveNotice( lastNoticeId.current );\n\t\t\t}\n\t\t\tsetIsDialogOpen( true );\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'click', handleClick );\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'click', handleClick );\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ lastNoticeId, renderingMode, contentRef.current ] );\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\teditTemplate.onClick();\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t>\n\t\t\t{ __( 'Edit your template to edit this block.' ) }\n\t\t</ConfirmDialog>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AAChE,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;;AAEpF;AACA;AACA;AACA,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,8BAA8BA,CAAE;EAAEC;AAAW,CAAC,EAAG;EACxE,MAAM;IAAEC,aAAa;IAAEC,gBAAgB;IAAEC;EAAW,CAAC,GAAGf,SAAS,CAC9DgB,MAAM,IAAM;IACb,MAAM;MACLC,gBAAgB;MAChBC,iBAAiB;MACjBC;IACD,CAAC,GAAGH,MAAM,CAAEN,WAAY,CAAC;IACzB,OAAO;MACNG,aAAa,EAAEI,gBAAgB,CAAC,CAAC;MACjCH,gBAAgB,EAAEI,iBAAiB,CAAC,CAAC,CAACJ,gBAAgB;MACtDC,UAAU,EAAEI,oBAAoB,CAAC;IAClC,CAAC;EACF,CAAC,EACD,EACD,CAAC;EACD,MAAMC,YAAY,GAAGN,gBAAgB,GAClCA,gBAAgB,CAAE;IAClBO,MAAM,EAAEN,UAAU;IAClBO,QAAQ,EAAE;EACV,CAAE,CAAC,GACH,CAAC,CAAC;EACL,MAAM;IAAEC;EAAW,CAAC,GAAGvB,SAAS,CAAEM,YAAa,CAAC;EAEhD,MAAM;IAAEkB,gBAAgB;IAAEC;EAAa,CAAC,GAAGxB,WAAW,CAAEK,YAAa,CAAC;EAEtE,MAAM,CAAEoB,YAAY,E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0B,OAAO;IACjCO,MAAM,EAAEC,gBAAgB,CAAE,OAAO,EAAEjB,WAAY,CAAC;IAChDgB,MAAM,EAAEC,gBAAgB,CAAE,UAAU,EAAEF,cAAe,CAAC;IACtD,OAAO,MAAM;MACZC,MAAM,EAAEE,mBAAmB,CAAE,OAAO,EAAElB,WAAY,CAAC;MACnDgB,MAAM,EAAEE,mBAAmB,CAAE,UAAU,EAAEH,cAAe,CAAC;IAC1D,CAAC;EACF,CAAC,EAAE,CAAEhB,YAAY,EAAEf,aAAa,EAAED,UAAU,CAAC0B,OAAO,CAAG,CAAC;EAExD,OACCU,aAAA,CAACvC,aAAa;IACbwC,MAAM,EAAGvB,YAAc;IACvBwB,iBAAiB,EAAG3C,EAAE,CAAE,eAAgB,CAAG;IAC3C4C,SAAS,EAAGA,CAAA,KAAM;MACjBxB,eAAe,CAAE,KAAM,CAAC;MACxBP,YAAY,CAACuB,OAAO,CAAC,CAAC;IACvB,CAAG;IACHS,QAAQ,EAAGA,CAAA,KAAMzB,eAAe,CAAE,KAAM;EAAG,GAEzCpB,EAAE,CAAE,wCAAyC,CACjC,CAAC;AAElB"}
|
|
@@ -76,7 +76,7 @@ function EditorCanvas({
|
|
|
76
76
|
wrapperBlockName,
|
|
77
77
|
wrapperUniqueId,
|
|
78
78
|
deviceType,
|
|
79
|
-
|
|
79
|
+
showEditorPadding
|
|
80
80
|
} = useSelect(select => {
|
|
81
81
|
const {
|
|
82
82
|
getCurrentPostId,
|
|
@@ -114,7 +114,7 @@ function EditorCanvas({
|
|
|
114
114
|
wrapperBlockName: _wrapperBlockName,
|
|
115
115
|
wrapperUniqueId: getCurrentPostId(),
|
|
116
116
|
deviceType: getDeviceType(),
|
|
117
|
-
|
|
117
|
+
showEditorPadding: !!editorSettings.goBack
|
|
118
118
|
};
|
|
119
119
|
}, []);
|
|
120
120
|
const {
|
|
@@ -233,7 +233,7 @@ function EditorCanvas({
|
|
|
233
233
|
height: "100%",
|
|
234
234
|
iframeProps: {
|
|
235
235
|
className: classnames('editor-canvas__iframe', {
|
|
236
|
-
'has-
|
|
236
|
+
'has-editor-padding': showEditorPadding
|
|
237
237
|
}),
|
|
238
238
|
...iframeProps,
|
|
239
239
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","BlockList","store","blockEditorStore","__unstableUseTypewriter","useTypewriter","__unstableUseTypingObserver","useTypingObserver","useSettings","RecursionProvider","privateApis","blockEditorPrivateApis","__experimentalUseResizeCanvas","useResizeCanvas","useEffect","useRef","useMemo","useSelect","parse","coreStore","useMergeRefs","PostTitle","editorStore","unlock","EditTemplateBlocksNotification","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","noop","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","EditorCanvas","autoFocus","className","renderAppender","styles","disableIframe","iframeProps","children","renderingMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","deviceType","hasHistory","select","getCurrentPostId","getCurrentPostType","getCurrentTemplateId","getEditorSettings","getRenderingMode","getDeviceType","getPostType","canUser","getEditedEntityRecord","postTypeSlug","_renderingMode","_wrapperBlockName","editorSettings","supportsTemplateMode","postType","canEditTemplate","currentTemplateId","template","undefined","viewable","goBack","isCleanNewPost","hasRootPaddingAwareAlignments","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","getSettings","disableLayoutStyles","supportsLayout","__experimentalFeatures","useRootPaddingAwareAlignments","deviceStyles","globalLayoutSettings","fallbackLayout","type","newestPostContentAttributes","content","parseableContent","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","titleRef","current","focus","alignCSS","localRef","typewriterRef","contentRef","createElement","shouldIframe","includes","height","style","Fragment","selector","css","contentEditable","ref","marginTop","blockName","uniqueId","toLowerCase","dropZoneElement","parentNode"],"sources":["@wordpress/editor/src/components/editor-canvas/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tuseSettings,\n\tRecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTitle from '../post-title';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport EditTemplateBlocksNotification from './edit-template-blocks-notification';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n} = unlock( blockEditorPrivateApis );\n\nconst noop = () => {};\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction EditorCanvas( {\n\t// Ideally as we unify post and site editors, we won't need these props.\n\tautoFocus,\n\tclassName,\n\trenderAppender,\n\tstyles,\n\tdisableIframe = false,\n\tiframeProps,\n\tchildren,\n} ) {\n\tconst {\n\t\trenderingMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tdeviceType,\n\t\thasHistory,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentTemplateId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t\tgetDeviceType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, canUser, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst _renderingMode = getRenderingMode();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _renderingMode === 'post-only' ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postType = getPostType( postTypeSlug );\n\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\tconst currentTemplateId = getCurrentTemplateId();\n\t\tconst template = currentTemplateId\n\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tcurrentTemplateId\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\trenderingMode: _renderingMode,\n\t\t\tpostContentAttributes: editorSettings.postContentAttributes,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostType?.viewable && supportsTemplateMode && canEditTemplate\n\t\t\t\t\t? template\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tdeviceType: getDeviceType(),\n\t\t\thasHistory: !! editorSettings.goBack,\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( renderingMode !== 'post-only' ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ renderingMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif (\n\t\t\t! editedPostTemplate?.content &&\n\t\t\t! editedPostTemplate?.blocks &&\n\t\t\tpostContentAttributes\n\t\t) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( ! autoFocus || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ autoFocus, isCleanNewPost ] );\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst localRef = useRef();\n\tconst typewriterRef = useTypewriter();\n\tconst contentRef = useMergeRefs( [\n\t\tlocalRef,\n\t\trenderingMode === 'post-only' ? typewriterRef : noop,\n\t] );\n\n\treturn (\n\t\t<BlockCanvas\n\t\t\tshouldIframe={\n\t\t\t\t! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType )\n\t\t\t}\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyles={ styles }\n\t\t\theight=\"100%\"\n\t\t\tiframeProps={ {\n\t\t\t\tclassName: classnames( 'editor-canvas__iframe', {\n\t\t\t\t\t'has-history': hasHistory,\n\t\t\t\t} ),\n\t\t\t\t...iframeProps,\n\t\t\t\tstyle: {\n\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t\t...deviceStyles,\n\t\t\t\t},\n\t\t\t} }\n\t\t>\n\t\t\t{ themeSupportsLayout &&\n\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\trenderingMode === 'post-only' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector=\".editor-editor-canvas__post-title-wrapper\"\n\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ align && <LayoutStyle css={ alignCSS } /> }\n\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\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{ renderingMode === 'post-only' && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'editor-editor-canvas__post-title-wrapper',\n\t\t\t\t\t\t// The following class is only here for backward comapatibility\n\t\t\t\t\t\t// some themes might be using it to style the post title.\n\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-global-padding': hasRootPaddingAwareAlignments,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t// This is using inline styles\n\t\t\t\t\t\t// so it's applied for both iframed and non iframed editors.\n\t\t\t\t\t\tmarginTop: '4rem',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<RecursionProvider\n\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t>\n\t\t\t\t<BlockList\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'is-' + deviceType.toLowerCase() + '-preview',\n\t\t\t\t\t\trenderingMode !== 'post-only'\n\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\trenderingMode !== 'all' && 'is-' + renderingMode\n\t\t\t\t\t) }\n\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\tdisableIframe\n\t\t\t\t\t\t\t? localRef.current\n\t\t\t\t\t\t\t: localRef.current?.parentNode\n\t\t\t\t\t}\n\t\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t/>\n\t\t\t\t<EditTemplateBlocksNotification contentRef={ localRef } />\n\t\t\t</RecursionProvider>\n\t\t\t{ children }\n\t\t</BlockCanvas>\n\t);\n}\n\nexport default EditorCanvas;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,SAAS,EACTC,KAAK,IAAIC,gBAAgB,EACzBC,uBAAuB,IAAIC,aAAa,EACxCC,2BAA2B,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ACH,OAAO,EAAEqB,UACrB;IACDtF,cAAc,EAAGA;EAAgB,CACjC,CAAC,EACFuE,aAAA,CAAC1F,8BAA8B;IAACyF,UAAU,EAAGF;EAAU,CAAE,CACvC,CAAC,EAClBhE,QACU,CAAC;AAEhB;AAEA,eAAeP,YAAY"}
|
|
1
|
+
{"version":3,"names":["classnames","BlockList","store","blockEditorStore","__unstableUseTypewriter","useTypewriter","__unstableUseTypingObserver","useTypingObserver","useSettings","RecursionProvider","privateApis","blockEditorPrivateApis","__experimentalUseResizeCanvas","useResizeCanvas","useEffect","useRef","useMemo","useSelect","parse","coreStore","useMergeRefs","PostTitle","editorStore","unlock","EditTemplateBlocksNotification","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","noop","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","EditorCanvas","autoFocus","className","renderAppender","styles","disableIframe","iframeProps","children","renderingMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","deviceType","showEditorPadding","select","getCurrentPostId","getCurrentPostType","getCurrentTemplateId","getEditorSettings","getRenderingMode","getDeviceType","getPostType","canUser","getEditedEntityRecord","postTypeSlug","_renderingMode","_wrapperBlockName","editorSettings","supportsTemplateMode","postType","canEditTemplate","currentTemplateId","template","undefined","viewable","goBack","isCleanNewPost","hasRootPaddingAwareAlignments","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","getSettings","disableLayoutStyles","supportsLayout","__experimentalFeatures","useRootPaddingAwareAlignments","deviceStyles","globalLayoutSettings","fallbackLayout","type","newestPostContentAttributes","content","parseableContent","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","titleRef","current","focus","alignCSS","localRef","typewriterRef","contentRef","createElement","shouldIframe","includes","height","style","Fragment","selector","css","contentEditable","ref","marginTop","blockName","uniqueId","toLowerCase","dropZoneElement","parentNode"],"sources":["@wordpress/editor/src/components/editor-canvas/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tuseSettings,\n\tRecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTitle from '../post-title';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport EditTemplateBlocksNotification from './edit-template-blocks-notification';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n} = unlock( blockEditorPrivateApis );\n\nconst noop = () => {};\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction EditorCanvas( {\n\t// Ideally as we unify post and site editors, we won't need these props.\n\tautoFocus,\n\tclassName,\n\trenderAppender,\n\tstyles,\n\tdisableIframe = false,\n\tiframeProps,\n\tchildren,\n} ) {\n\tconst {\n\t\trenderingMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tdeviceType,\n\t\tshowEditorPadding,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentTemplateId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t\tgetDeviceType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, canUser, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst _renderingMode = getRenderingMode();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _renderingMode === 'post-only' ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postType = getPostType( postTypeSlug );\n\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\tconst currentTemplateId = getCurrentTemplateId();\n\t\tconst template = currentTemplateId\n\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tcurrentTemplateId\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\trenderingMode: _renderingMode,\n\t\t\tpostContentAttributes: editorSettings.postContentAttributes,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostType?.viewable && supportsTemplateMode && canEditTemplate\n\t\t\t\t\t? template\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tdeviceType: getDeviceType(),\n\t\t\tshowEditorPadding: !! editorSettings.goBack,\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( renderingMode !== 'post-only' ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ renderingMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif (\n\t\t\t! editedPostTemplate?.content &&\n\t\t\t! editedPostTemplate?.blocks &&\n\t\t\tpostContentAttributes\n\t\t) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( ! autoFocus || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ autoFocus, isCleanNewPost ] );\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst localRef = useRef();\n\tconst typewriterRef = useTypewriter();\n\tconst contentRef = useMergeRefs( [\n\t\tlocalRef,\n\t\trenderingMode === 'post-only' ? typewriterRef : noop,\n\t] );\n\n\treturn (\n\t\t<BlockCanvas\n\t\t\tshouldIframe={\n\t\t\t\t! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType )\n\t\t\t}\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyles={ styles }\n\t\t\theight=\"100%\"\n\t\t\tiframeProps={ {\n\t\t\t\tclassName: classnames( 'editor-canvas__iframe', {\n\t\t\t\t\t'has-editor-padding': showEditorPadding,\n\t\t\t\t} ),\n\t\t\t\t...iframeProps,\n\t\t\t\tstyle: {\n\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t\t...deviceStyles,\n\t\t\t\t},\n\t\t\t} }\n\t\t>\n\t\t\t{ themeSupportsLayout &&\n\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\trenderingMode === 'post-only' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector=\".editor-editor-canvas__post-title-wrapper\"\n\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ align && <LayoutStyle css={ alignCSS } /> }\n\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\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{ renderingMode === 'post-only' && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'editor-editor-canvas__post-title-wrapper',\n\t\t\t\t\t\t// The following class is only here for backward comapatibility\n\t\t\t\t\t\t// some themes might be using it to style the post title.\n\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-global-padding': hasRootPaddingAwareAlignments,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t// This is using inline styles\n\t\t\t\t\t\t// so it's applied for both iframed and non iframed editors.\n\t\t\t\t\t\tmarginTop: '4rem',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<RecursionProvider\n\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t>\n\t\t\t\t<BlockList\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'is-' + deviceType.toLowerCase() + '-preview',\n\t\t\t\t\t\trenderingMode !== 'post-only'\n\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\trenderingMode !== 'all' && 'is-' + renderingMode\n\t\t\t\t\t) }\n\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\tdisableIframe\n\t\t\t\t\t\t\t? localRef.current\n\t\t\t\t\t\t\t: localRef.current?.parentNode\n\t\t\t\t\t}\n\t\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t/>\n\t\t\t\t<EditTemplateBlocksNotification contentRef={ localRef } />\n\t\t\t</RecursionProvider>\n\t\t\t{ children }\n\t\t</BlockCanvas>\n\t);\n}\n\nexport default EditorCanvas;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,SAAS,EACTC,KAAK,IAAIC,gB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AnF,aAAa,GACVkE,QAAQ,CAACH,OAAO,GAChBG,QAAQ,CAACH,OAAO,EAAEqB,UACrB;IACDtF,cAAc,EAAGA;EAAgB,CACjC,CAAC,EACFuE,aAAA,CAAC1F,8BAA8B;IAACyF,UAAU,EAAGF;EAAU,CAAE,CACvC,CAAC,EAClBhE,QACU,CAAC;AAEhB;AAEA,eAAeP,YAAY"}
|
|
@@ -26,31 +26,46 @@ export default function BlockThemeControl({
|
|
|
26
26
|
id
|
|
27
27
|
}) {
|
|
28
28
|
const {
|
|
29
|
-
isTemplateHidden
|
|
29
|
+
isTemplateHidden,
|
|
30
|
+
getPostLinkProps,
|
|
31
|
+
getEditorSettings,
|
|
32
|
+
hasGoBack
|
|
30
33
|
} = useSelect(select => {
|
|
31
34
|
const {
|
|
32
|
-
getRenderingMode
|
|
35
|
+
getRenderingMode,
|
|
36
|
+
getEditorSettings: _getEditorSettings
|
|
33
37
|
} = unlock(select(editorStore));
|
|
38
|
+
const editorSettings = _getEditorSettings();
|
|
34
39
|
return {
|
|
35
|
-
isTemplateHidden: getRenderingMode() === 'post-only'
|
|
40
|
+
isTemplateHidden: getRenderingMode() === 'post-only',
|
|
41
|
+
getPostLinkProps: editorSettings.getPostLinkProps,
|
|
42
|
+
getEditorSettings: _getEditorSettings,
|
|
43
|
+
hasGoBack: editorSettings.hasOwnProperty('goBack')
|
|
36
44
|
};
|
|
37
45
|
}, []);
|
|
38
46
|
const {
|
|
39
47
|
editedRecord: template,
|
|
40
48
|
hasResolved
|
|
41
49
|
} = useEntityRecord('postType', 'wp_template', id);
|
|
42
|
-
const {
|
|
43
|
-
getEditorSettings
|
|
44
|
-
} = useSelect(editorStore);
|
|
45
50
|
const {
|
|
46
51
|
createSuccessNotice
|
|
47
52
|
} = useDispatch(noticesStore);
|
|
48
53
|
const {
|
|
49
54
|
setRenderingMode
|
|
50
55
|
} = useDispatch(editorStore);
|
|
56
|
+
const editTemplate = getPostLinkProps ? getPostLinkProps({
|
|
57
|
+
postId: template.id,
|
|
58
|
+
postType: 'wp_template'
|
|
59
|
+
}) : {};
|
|
51
60
|
if (!hasResolved) {
|
|
52
61
|
return null;
|
|
53
62
|
}
|
|
63
|
+
// The site editor does not have a `goBack` setting as it uses its own routing
|
|
64
|
+
// and assigns its own backlink to focusMode pages.
|
|
65
|
+
const notificationAction = hasGoBack ? [{
|
|
66
|
+
label: __('Go back'),
|
|
67
|
+
onClick: () => getEditorSettings().goBack()
|
|
68
|
+
}] : undefined;
|
|
54
69
|
return createElement(DropdownMenu, {
|
|
55
70
|
popoverProps: POPOVER_PROPS,
|
|
56
71
|
focusOnMount: true,
|
|
@@ -63,15 +78,12 @@ export default function BlockThemeControl({
|
|
|
63
78
|
}, ({
|
|
64
79
|
onClose
|
|
65
80
|
}) => createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
|
|
66
|
-
onClick:
|
|
67
|
-
|
|
81
|
+
onClick: event => {
|
|
82
|
+
editTemplate.onClick(event);
|
|
68
83
|
onClose();
|
|
69
84
|
createSuccessNotice(__('Editing template. Changes made here affect all posts and pages that use the template.'), {
|
|
70
85
|
type: 'snackbar',
|
|
71
|
-
actions:
|
|
72
|
-
label: __('Go back'),
|
|
73
|
-
onClick: () => setRenderingMode(getEditorSettings().defaultRenderingMode)
|
|
74
|
-
}]
|
|
86
|
+
actions: notificationAction
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
}, __('Edit template')), createElement(SwapTemplateButton, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","useEntityRecord","check","store","noticesStore","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","select","getRenderingMode","editedRecord","template","hasResolved","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","useEntityRecord","check","store","noticesStore","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","getPostLinkProps","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","editTemplate","postId","postType","notificationAction","label","onClick","goBack","undefined","createElement","popoverProps","focusOnMount","toggleProps","variant","text","title","icon","onClose","Fragment","event","type","actions","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst { isTemplateHidden, getPostLinkProps, getEditorSettings, hasGoBack } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst editorSettings = _getEditorSettings();\n\t\t\treturn {\n\t\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\t\tgetPostLinkProps: editorSettings.getPostLinkProps,\n\t\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\t\thasGoBack: editorSettings.hasOwnProperty( 'goBack' ),\n\t\t\t};\n\t\t}, [] );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst editTemplate = getPostLinkProps\n\t\t? getPostLinkProps( {\n\t\t\t\tpostId: template.id,\n\t\t\t\tpostType: 'wp_template',\n\t\t } )\n\t\t: {};\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\t// The site editor does not have a `goBack` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () => getEditorSettings().goBack(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\teditTemplate.onClick( event );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tactions: notificationAction,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Template preview' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASC,MAAM,QAAQ,mBAAmB;AAC1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ACJ,CAAC;IACF;EAAG,GAEDf,EAAE,CAAE,kBAAmB,CAChB,CACA,CACV,CAEU,CAAC;AAEjB"}
|
|
@@ -55,7 +55,10 @@ function PostTemplateDropdownContent({
|
|
|
55
55
|
fetchedTemplates,
|
|
56
56
|
selectedTemplateSlug,
|
|
57
57
|
canCreate,
|
|
58
|
-
canEdit
|
|
58
|
+
canEdit,
|
|
59
|
+
currentTemplateId,
|
|
60
|
+
getPostLinkProps,
|
|
61
|
+
getEditorSettings
|
|
59
62
|
} = useSelect(select => {
|
|
60
63
|
const {
|
|
61
64
|
canUser,
|
|
@@ -63,6 +66,7 @@ function PostTemplateDropdownContent({
|
|
|
63
66
|
} = select(coreStore);
|
|
64
67
|
const editorSettings = select(editorStore).getEditorSettings();
|
|
65
68
|
const canCreateTemplates = canUser('create', 'templates');
|
|
69
|
+
const _currentTemplateId = select(editorStore).getCurrentTemplateId();
|
|
66
70
|
return {
|
|
67
71
|
availableTemplates: editorSettings.availableTemplates,
|
|
68
72
|
fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
|
|
@@ -71,9 +75,16 @@ function PostTemplateDropdownContent({
|
|
|
71
75
|
}) : undefined,
|
|
72
76
|
selectedTemplateSlug: select(editorStore).getEditedPostAttribute('template'),
|
|
73
77
|
canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
|
|
74
|
-
canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!
|
|
78
|
+
canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
|
|
79
|
+
currentTemplateId: _currentTemplateId,
|
|
80
|
+
getPostLinkProps: editorSettings.getPostLinkProps,
|
|
81
|
+
getEditorSettings: select(editorStore).getEditorSettings
|
|
75
82
|
};
|
|
76
83
|
}, [allowSwitchingTemplate]);
|
|
84
|
+
const editTemplate = getPostLinkProps && currentTemplateId ? getPostLinkProps({
|
|
85
|
+
postId: currentTemplateId,
|
|
86
|
+
postType: 'wp_template'
|
|
87
|
+
}) : {};
|
|
77
88
|
const options = useMemo(() => Object.entries({
|
|
78
89
|
...availableTemplates,
|
|
79
90
|
...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
|
|
@@ -89,15 +100,9 @@ function PostTemplateDropdownContent({
|
|
|
89
100
|
const {
|
|
90
101
|
editPost
|
|
91
102
|
} = useDispatch(editorStore);
|
|
92
|
-
const {
|
|
93
|
-
getEditorSettings
|
|
94
|
-
} = useSelect(editorStore);
|
|
95
103
|
const {
|
|
96
104
|
createSuccessNotice
|
|
97
105
|
} = useDispatch(noticesStore);
|
|
98
|
-
const {
|
|
99
|
-
setRenderingMode
|
|
100
|
-
} = useDispatch(editorStore);
|
|
101
106
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
|
102
107
|
return createElement("div", {
|
|
103
108
|
className: "editor-post-template__classic-theme-dropdown"
|
|
@@ -126,13 +131,13 @@ function PostTemplateDropdownContent({
|
|
|
126
131
|
}), canEdit && createElement("p", null, createElement(Button, {
|
|
127
132
|
variant: "link",
|
|
128
133
|
onClick: () => {
|
|
129
|
-
|
|
134
|
+
editTemplate.onClick();
|
|
130
135
|
onClose();
|
|
131
136
|
createSuccessNotice(__('Editing template. Changes made here affect all posts and pages that use the template.'), {
|
|
132
137
|
type: 'snackbar',
|
|
133
138
|
actions: [{
|
|
134
139
|
label: __('Go back'),
|
|
135
|
-
onClick: () =>
|
|
140
|
+
onClick: () => getEditorSettings().goBack()
|
|
136
141
|
}]
|
|
137
142
|
});
|
|
138
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","getCurrentTemplateId","title","slug","createElement","variant","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","getEntityRecords","editorSettings","canCreateTemplates","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","setRenderingMode","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__next40pxDefaultSize","__nextHasNoMarginBottom","hideLabelFromVision","onChange","type","defaultRenderingMode","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! select( editorStore ).getCurrentTemplateId(),\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ClassicThemeControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;AAC/E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASN,KAAK,IAAIO,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAEpD,MAAMC,aAAa,GAAG;EACrBC,SAAS,EAAE,gCAAgC;EAC3CC,SAAS,EAAE;AACZ,CAAC;AAED,SAASC,kBAAkBA,CAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAG;EAClD,MAA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E/C;IAAQ,CAAC,KAC5BH,aAAA,CAACE,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;AAEA,eAAe0C,mBAAmB"}
|
|
1
|
+
{"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","getCurrentTemplateId","title","slug","createElement","variant","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","getPostLinkProps","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","editTemplate","postId","postType","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__next40pxDefaultSize","__nextHasNoMarginBottom","hideLabelFromVision","onChange","type","goBack","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tgetPostLinkProps,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tgetPostLinkProps: editorSettings.getPostLinkProps,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst editTemplate =\n\t\tgetPostLinkProps && currentTemplateId\n\t\t\t? getPostLinkProps( {\n\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t } )\n\t\t\t: {};\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\teditTemplate.onClick();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().goBack(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ClassicThemeControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;AAC/E,SAASC,SAAS,EAAEC,WAAW,QA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C,YAAY,CAAClC,OAAO,CAAC,CAAC;MACtBgB,OAAO,CAAC,CAAC;MACTiC,mBAAmB,CAClBxE,EAAE,CACD,uFACD,CAAC,EACD;QACCoF,IAAI,EAAE,UAAU;QAChBR,OAAO,EAAE,CACR;UACCT,KAAK,EAAEnE,EAAE,CAAE,SAAU,CAAC;UACtBuB,OAAO,EAAEA,CAAA,KACRO,iBAAiB,CAAC,CAAC,CAACuD,MAAM,CAAC;QAC7B,CAAC;MAEH,CACD,CAAC;IACF;EAAG,GAEDrF,EAAE,CAAE,eAAgB,CACf,CACN,CACH,EACCyE,iBAAiB,IAClBrC,aAAA,CAACpB,sBAAsB;IACtBuB,OAAO,EAAGA,CAAA,KAAMmC,oBAAoB,CAAE,KAAM;EAAG,CAC/C,CAEE,CAAC;AAER;AAEA,SAASY,mBAAmBA,CAAA,EAAG;EAC9B,OACClD,aAAA,CAAClC,QAAQ;IACRqF,YAAY,EAAGrE,aAAe;IAC9BsE,YAAY;IACZC,YAAY,EAAGA,CAAE;MAAEnE,MAAM;MAAEoE;IAAS,CAAC,KACpCtD,aAAA,CAACf,kBAAkB;MAACC,MAAM,EAAGA,MAAQ;MAACC,OAAO,EAAGmE;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAEpD;IAAQ,CAAC,KAC5BH,aAAA,CAACE,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;AAEA,eAAe+C,mBAAmB"}
|
|
@@ -18,10 +18,22 @@ const DEFAULT_TITLE = __('Custom Template');
|
|
|
18
18
|
export default function CreateNewTemplateModal({
|
|
19
19
|
onClose
|
|
20
20
|
}) {
|
|
21
|
-
const defaultBlockTemplate = useSelect(select => select(editorStore).getEditorSettings().defaultBlockTemplate, []);
|
|
22
21
|
const {
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
defaultBlockTemplate,
|
|
23
|
+
getPostLinkProps
|
|
24
|
+
} = useSelect(select => {
|
|
25
|
+
const {
|
|
26
|
+
getEditorSettings,
|
|
27
|
+
getCurrentTemplateId
|
|
28
|
+
} = select(editorStore);
|
|
29
|
+
return {
|
|
30
|
+
defaultBlockTemplate: getEditorSettings().defaultBlockTemplate,
|
|
31
|
+
getPostLinkProps: getEditorSettings().getPostLinkProps,
|
|
32
|
+
getTemplateId: getCurrentTemplateId
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const {
|
|
36
|
+
createTemplate
|
|
25
37
|
} = unlock(useDispatch(editorStore));
|
|
26
38
|
const [title, setTitle] = useState('');
|
|
27
39
|
const [isBusy, setIsBusy] = useState(false);
|
|
@@ -51,14 +63,18 @@ export default function CreateNewTemplateModal({
|
|
|
51
63
|
inherit: true
|
|
52
64
|
}
|
|
53
65
|
})])]);
|
|
54
|
-
await createTemplate({
|
|
66
|
+
const newTemplate = await createTemplate({
|
|
55
67
|
slug: cleanForSlug(title || DEFAULT_TITLE),
|
|
56
68
|
content: newTemplateContent,
|
|
57
69
|
title: title || DEFAULT_TITLE
|
|
58
70
|
});
|
|
59
71
|
setIsBusy(false);
|
|
72
|
+
const editTemplate = getPostLinkProps ? getPostLinkProps({
|
|
73
|
+
postId: newTemplate.id,
|
|
74
|
+
postType: 'wp_template'
|
|
75
|
+
}) : {};
|
|
76
|
+
editTemplate.onClick();
|
|
60
77
|
cancel();
|
|
61
|
-
setRenderingMode('template-only');
|
|
62
78
|
};
|
|
63
79
|
return createElement(Modal, {
|
|
64
80
|
title: __('Create custom template'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","select","getEditorSettings","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","getPostLinkProps","select","getEditorSettings","getCurrentTemplateId","getTemplateId","createTemplate","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","newTemplate","slug","content","editTemplate","postId","id","postType","onClick","createElement","onRequestClose","className","onSubmit","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, getPostLinkProps } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tgetPostLinkProps: getEditorSettings().getPostLinkProps,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\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\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tconst editTemplate = getPostLinkProps\n\t\t\t? getPostLinkProps( {\n\t\t\t\t\tpostId: newTemplate.id,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t } )\n\t\t\t: {};\n\t\teditTemplate.onClick();\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ cancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AAC1D,SACCC,KAAK,EACLC,WAAW,EACXC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;A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KAAO;IACf4B,QAAQ,EAAG3B,QAAU;IACrB4B,WAAW,EAAGvC,aAAe;IAC7BwC,QAAQ,EAAG5B,MAAQ;IACnB6B,IAAI,EAAG9C,EAAE,CACR,iHACD;EAAG,CACH,CAAC,EACFmC,aAAA,CAACtC,MAAM;IAACkD,OAAO,EAAC;EAAO,GACtBZ,aAAA,CAACxC,MAAM;IAACqD,OAAO,EAAC,UAAU;IAACd,OAAO,EAAGf;EAAQ,GAC1CnB,EAAE,CAAE,QAAS,CACR,CAAC,EAETmC,aAAA,CAACxC,MAAM;IACNqD,OAAO,EAAC,SAAS;IACjBC,IAAI,EAAC,QAAQ;IACbhC,MAAM,EAAGA,MAAQ;IACjB,iBAAgBA;EAAQ,GAEtBjB,EAAE,CAAE,QAAS,CACR,CACD,CACD,CACH,CACA,CAAC;AAEV"}
|
|
@@ -91,7 +91,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
91
91
|
const shouldRenderTemplate = !!template && mode !== 'post-only';
|
|
92
92
|
const rootLevelPost = shouldRenderTemplate ? template : post;
|
|
93
93
|
const defaultBlockContext = useMemo(() => {
|
|
94
|
-
const postContext = rootLevelPost.type !== 'wp_template' || shouldRenderTemplate
|
|
94
|
+
const postContext = rootLevelPost.type !== 'wp_template' || shouldRenderTemplate ? {
|
|
95
95
|
postId: post.id,
|
|
96
96
|
postType: post.type
|
|
97
97
|
} : {};
|
|
@@ -99,7 +99,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
99
99
|
...postContext,
|
|
100
100
|
templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
|
|
101
101
|
};
|
|
102
|
-
}, [
|
|
102
|
+
}, [post.id, post.type, rootLevelPost.type, rootLevelPost.slug]);
|
|
103
103
|
const {
|
|
104
104
|
editorSettings,
|
|
105
105
|
selection,
|
|
@@ -156,7 +156,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
156
156
|
// Synchronizes the active post with the state
|
|
157
157
|
useEffect(() => {
|
|
158
158
|
setEditedPost(post.type, post.id);
|
|
159
|
-
}, [post.type, post.id]);
|
|
159
|
+
}, [post.type, post.id, setEditedPost]);
|
|
160
160
|
|
|
161
161
|
// Synchronize the editor settings as they change.
|
|
162
162
|
useEffect(() => {
|