@wordpress/edit-site 6.33.4 → 6.33.6
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/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +2 -2
- package/build/components/add-new-template/index.js +6 -4
- package/build/components/add-new-template/index.js.map +2 -2
- package/build/components/add-new-template/utils.js +84 -9
- package/build/components/add-new-template/utils.js.map +2 -2
- package/build/components/dataviews-actions/index.js +2 -55
- package/build/components/dataviews-actions/index.js.map +3 -3
- package/build/components/editor/index.js +0 -1
- package/build/components/editor/index.js.map +2 -2
- package/build/components/editor/use-resolve-edited-entity.js +5 -11
- package/build/components/editor/use-resolve-edited-entity.js.map +2 -2
- package/build/components/page-templates/fields.js +5 -80
- package/build/components/page-templates/fields.js.map +3 -3
- package/build/components/page-templates/hooks.js +1 -1
- package/build/components/page-templates/hooks.js.map +2 -2
- package/build/components/page-templates/index.js +46 -217
- package/build/components/page-templates/index.js.map +3 -3
- package/build/components/page-templates/view-utils.js +1 -5
- package/build/components/page-templates/view-utils.js.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +6 -21
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
- package/build/components/site-editor-routes/template-item.js +14 -15
- package/build/components/site-editor-routes/template-item.js.map +2 -2
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +2 -2
- package/build-module/components/add-new-template/index.js +7 -4
- package/build-module/components/add-new-template/index.js.map +2 -2
- package/build-module/components/add-new-template/utils.js +84 -9
- package/build-module/components/add-new-template/utils.js.map +2 -2
- package/build-module/components/dataviews-actions/index.js +1 -53
- package/build-module/components/dataviews-actions/index.js.map +2 -2
- package/build-module/components/editor/index.js +0 -1
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/editor/use-resolve-edited-entity.js +5 -11
- package/build-module/components/editor/use-resolve-edited-entity.js.map +2 -2
- package/build-module/components/page-templates/fields.js +6 -85
- package/build-module/components/page-templates/fields.js.map +3 -3
- package/build-module/components/page-templates/hooks.js +1 -1
- package/build-module/components/page-templates/hooks.js.map +2 -2
- package/build-module/components/page-templates/index.js +51 -235
- package/build-module/components/page-templates/index.js.map +2 -2
- package/build-module/components/page-templates/view-utils.js +1 -5
- package/build-module/components/page-templates/view-utils.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +7 -22
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
- package/build-module/components/site-editor-routes/template-item.js +14 -15
- package/build-module/components/site-editor-routes/template-item.js.map +2 -2
- package/package.json +17 -17
- package/src/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/src/components/add-new-template/index.js +9 -4
- package/src/components/add-new-template/utils.js +118 -9
- package/src/components/dataviews-actions/index.js +0 -61
- package/src/components/editor/index.js +0 -1
- package/src/components/editor/use-resolve-edited-entity.js +5 -20
- package/src/components/page-templates/fields.js +5 -95
- package/src/components/page-templates/hooks.js +1 -1
- package/src/components/page-templates/index.js +35 -244
- package/src/components/page-templates/view-utils.js +1 -8
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +7 -22
- package/src/components/site-editor-routes/template-item.js +26 -28
|
@@ -18,68 +18,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var dataviews_actions_exports = {};
|
|
20
20
|
__export(dataviews_actions_exports, {
|
|
21
|
-
useEditPostAction: () => useEditPostAction
|
|
22
|
-
useSetActiveTemplateAction: () => useSetActiveTemplateAction
|
|
21
|
+
useEditPostAction: () => useEditPostAction
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(dataviews_actions_exports);
|
|
25
24
|
var import_i18n = require("@wordpress/i18n");
|
|
26
25
|
var import_icons = require("@wordpress/icons");
|
|
27
26
|
var import_element = require("@wordpress/element");
|
|
28
27
|
var import_router = require("@wordpress/router");
|
|
29
|
-
var import_data = require("@wordpress/data");
|
|
30
|
-
var import_core_data = require("@wordpress/core-data");
|
|
31
28
|
var import_constants = require("../../utils/constants");
|
|
32
29
|
var import_lock_unlock = require("../../lock-unlock");
|
|
33
30
|
const { useHistory } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
34
|
-
const useSetActiveTemplateAction = () => {
|
|
35
|
-
const activeTheme = (0, import_data.useSelect)(
|
|
36
|
-
(select) => select(import_core_data.store).getCurrentTheme()
|
|
37
|
-
);
|
|
38
|
-
const { getEntityRecord } = (0, import_data.useSelect)(import_core_data.store);
|
|
39
|
-
const { editEntityRecord, saveEditedEntityRecord } = (0, import_data.useDispatch)(import_core_data.store);
|
|
40
|
-
return (0, import_element.useMemo)(
|
|
41
|
-
() => ({
|
|
42
|
-
id: "set-active-template",
|
|
43
|
-
label(items) {
|
|
44
|
-
return items.some((item) => item._isActive) ? (0, import_i18n.__)("Deactivate") : (0, import_i18n.__)("Activate");
|
|
45
|
-
},
|
|
46
|
-
isPrimary: true,
|
|
47
|
-
icon: import_icons.pencil,
|
|
48
|
-
isEligible(item) {
|
|
49
|
-
if (item.theme !== activeTheme.stylesheet) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
if (typeof item.id !== "number") {
|
|
53
|
-
return item._isActive === false;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
},
|
|
57
|
-
async callback(items) {
|
|
58
|
-
const deactivate = items.some((item) => item._isActive);
|
|
59
|
-
const activeTemplates = {
|
|
60
|
-
...await getEntityRecord("root", "site").active_templates ?? {}
|
|
61
|
-
};
|
|
62
|
-
for (const item of items) {
|
|
63
|
-
if (deactivate) {
|
|
64
|
-
delete activeTemplates[item.slug];
|
|
65
|
-
} else {
|
|
66
|
-
activeTemplates[item.slug] = item.id;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
await editEntityRecord("root", "site", void 0, {
|
|
70
|
-
active_templates: activeTemplates
|
|
71
|
-
});
|
|
72
|
-
await saveEditedEntityRecord("root", "site");
|
|
73
|
-
}
|
|
74
|
-
}),
|
|
75
|
-
[
|
|
76
|
-
editEntityRecord,
|
|
77
|
-
saveEditedEntityRecord,
|
|
78
|
-
getEntityRecord,
|
|
79
|
-
activeTheme
|
|
80
|
-
]
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
31
|
const useEditPostAction = () => {
|
|
84
32
|
const history = useHistory();
|
|
85
33
|
return (0, import_element.useMemo)(
|
|
@@ -104,7 +52,6 @@ const useEditPostAction = () => {
|
|
|
104
52
|
};
|
|
105
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
106
54
|
0 && (module.exports = {
|
|
107
|
-
useEditPostAction
|
|
108
|
-
useSetActiveTemplateAction
|
|
55
|
+
useEditPostAction
|
|
109
56
|
});
|
|
110
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-actions/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { pencil } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["routerPrivateApis"
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { pencil } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { PATTERN_TYPES } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport const useEditPostAction = () => {\n\tconst history = useHistory();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'edit-post',\n\t\t\tlabel: __( 'Edit' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: pencil,\n\t\t\tisEligible( post ) {\n\t\t\t\tif ( post.status === 'trash' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t// It's eligible for all post types except theme patterns.\n\t\t\t\treturn post.type !== PATTERN_TYPES.theme;\n\t\t\t},\n\t\t\tcallback( items ) {\n\t\t\t\tconst post = items[ 0 ];\n\t\t\t\thistory.navigate( `/${ post.type }/${ post.id }?canvas=edit` );\n\t\t\t},\n\t\t} ),\n\t\t[ history ]\n\t);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAAuB;AACvB,qBAAwB;AACxB,oBAAiD;AAKjD,uBAA8B;AAC9B,yBAAuB;AAEvB,MAAM,EAAE,WAAW,QAAI,2BAAQ,cAAAA,WAAkB;AAE1C,MAAM,oBAAoB,MAAM;AACtC,QAAM,UAAU,WAAW;AAC3B,aAAO;AAAA,IACN,OAAQ;AAAA,MACP,IAAI;AAAA,MACJ,WAAO,gBAAI,MAAO;AAAA,MAClB,WAAW;AAAA,MACX,MAAM;AAAA,MACN,WAAY,MAAO;AAClB,YAAK,KAAK,WAAW,SAAU;AAC9B,iBAAO;AAAA,QACR;AAEA,eAAO,KAAK,SAAS,+BAAc;AAAA,MACpC;AAAA,MACA,SAAU,OAAQ;AACjB,cAAM,OAAO,MAAO,CAAE;AACtB,gBAAQ,SAAU,IAAK,KAAK,IAAK,IAAK,KAAK,EAAG,cAAe;AAAA,MAC9D;AAAA,IACD;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACD;",
|
|
6
|
+
"names": ["routerPrivateApis"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/editor/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Button, __unstableMotion as motion } from '@wordpress/components';\nimport { useInstanceId, useReducedMotion } from '@wordpress/compose';\nimport {\n\tEditorKeyboardShortcutsRegister,\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { Icon, arrowUpLeft } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport CanvasLoader from '../canvas-loader';\nimport { unlock } from '../../lock-unlock';\nimport { useSpecificEditorSettings } from '../block-editor/use-site-editor-settings';\nimport PluginTemplateSettingPanel from '../plugin-template-setting-panel';\nimport GlobalStylesSidebar from '../global-styles-sidebar';\nimport { isPreviewingTheme } from '../../utils/is-previewing-theme';\nimport {\n\tgetEditorCanvasContainerTitle,\n\tuseHasEditorCanvasContainer,\n} from '../editor-canvas-container';\nimport SaveButton from '../save-button';\nimport SavePanel from '../save-panel';\nimport SiteEditorMoreMenu from '../more-menu';\nimport SiteIcon from '../site-icon';\nimport useEditorIframeProps from '../block-editor/use-editor-iframe-props';\nimport useEditorTitle from './use-editor-title';\nimport { useIsSiteEditorLoading } from '../layout/hooks';\nimport { useAdaptEditorToCanvas } from './use-adapt-editor-to-canvas';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport {\n\tuseResolveEditedEntity,\n\tuseSyncDeprecatedEntityIntoState,\n} from './use-resolve-edited-entity';\nimport SitePreview from './site-preview';\n\nconst { Editor, BackButton } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nconst toggleHomeIconVariants = {\n\tedit: {\n\t\topacity: 0,\n\t\tscale: 0.2,\n\t},\n\thover: {\n\t\topacity: 1,\n\t\tscale: 1,\n\t\tclipPath: 'inset( 22% round 2px )',\n\t},\n};\n\nconst siteIconVariants = {\n\tedit: {\n\t\tclipPath: 'inset(0% round 0px)',\n\t},\n\thover: {\n\t\tclipPath: 'inset( 22% round 2px )',\n\t},\n\ttap: {\n\t\tclipPath: 'inset(0% round 0px)',\n\t},\n};\n\nfunction getListPathForPostType( postType ) {\n\tswitch ( postType ) {\n\t\tcase 'navigation':\n\t\t\treturn '/navigation';\n\t\tcase 'wp_block':\n\t\t\treturn '/pattern?postType=wp_block';\n\t\tcase 'wp_template_part':\n\t\t\treturn '/pattern?postType=wp_template_part';\n\t\tcase 'wp_template':\n\t\t\treturn '/template';\n\t\tcase 'page':\n\t\t\treturn '/page';\n\t\tcase 'post':\n\t\t\treturn '/';\n\t}\n\tthrow 'Unknown post type';\n}\n\nfunction getNavigationPath( location, postType ) {\n\tconst { path, name } = location;\n\tif (\n\t\t[\n\t\t\t'pattern-item',\n\t\t\t'template-part-item',\n\t\t\t'page-item',\n\t\t\t'template-item',\n\t\t\t'static-template-item',\n\t\t\t'post-item',\n\t\t].includes( name )\n\t) {\n\t\treturn getListPathForPostType( postType );\n\t}\n\treturn addQueryArgs( path, { canvas: undefined } );\n}\n\nexport default function EditSiteEditor( {\n\tisHomeRoute = false,\n\tisPostsList = false,\n} ) {\n\tconst disableMotion = useReducedMotion();\n\tconst location = useLocation();\n\tconst { canvas = 'view' } = location.query;\n\tconst isLoading = useIsSiteEditorLoading();\n\tuseAdaptEditorToCanvas( canvas );\n\tconst entity = useResolveEditedEntity();\n\t// deprecated sync state with url\n\tuseSyncDeprecatedEntityIntoState( entity );\n\tconst { postType, postId, context } = entity;\n\tconst {\n\t\tisBlockBasedTheme,\n\t\teditorCanvasView,\n\t\tcurrentPostIsTrashed,\n\t\thasSiteIcon,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditorCanvasContainerView } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\t\tconst { getCurrentTheme, getEntityRecord } = select( coreDataStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase', undefined );\n\n\t\treturn {\n\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\teditorCanvasView: getEditorCanvasContainerView(),\n\t\t\tcurrentPostIsTrashed:\n\t\t\t\tselect( editorStore ).getCurrentPostAttribute( 'status' ) ===\n\t\t\t\t'trash',\n\t\t\thasSiteIcon: !! siteData?.site_icon_url,\n\t\t};\n\t}, [] );\n\tconst postWithTemplate = !! context?.postId;\n\tuseEditorTitle(\n\t\tpostWithTemplate ? context.postType : postType,\n\t\tpostWithTemplate ? context.postId : postId\n\t);\n\tconst _isPreviewingTheme = isPreviewingTheme();\n\tconst hasDefaultEditorCanvasView = ! useHasEditorCanvasContainer();\n\tconst iframeProps = useEditorIframeProps();\n\tconst isEditMode = canvas === 'edit';\n\tconst loadingProgressId = useInstanceId(\n\t\tCanvasLoader,\n\t\t'edit-site-editor__loading-progress'\n\t);\n\n\tconst settings = useSpecificEditorSettings();\n\tconst styles = useMemo(\n\t\t() => [\n\t\t\t...settings.styles,\n\t\t\t{\n\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\tcss:\n\t\t\t\t\tcanvas === 'view'\n\t\t\t\t\t\t? `body{min-height: 100vh; ${\n\t\t\t\t\t\t\t\tcurrentPostIsTrashed ? '' : 'cursor: pointer;'\n\t\t\t\t\t\t }}`\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t],\n\t\t[ settings.styles, canvas, currentPostIsTrashed ]\n\t);\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst history = useHistory();\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\tcase 'delete-post':\n\t\t\t\t\t{\n\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\tgetListPathForPostType(\n\t\t\t\t\t\t\t\tpostWithTemplate ? context.postType : postType\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\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst _title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( _title ) || __( '(no title)' )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\t`/${ newItem.type }/${ newItem.id }?canvas=edit`\n\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\tbreak;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tpostType,\n\t\t\tcontext?.postType,\n\t\t\tpostWithTemplate,\n\t\t\thistory,\n\t\t\tcreateSuccessNotice,\n\t\t]\n\t);\n\n\t// Replace the title and icon displayed in the DocumentBar when there's an overlay visible.\n\tconst title = getEditorCanvasContainerTitle( editorCanvasView );\n\n\tconst isReady = ! isLoading;\n\tconst transition = {\n\t\tduration: disableMotion ? 0 : 0.2,\n\t};\n\n\treturn ! isBlockBasedTheme && isHomeRoute ? (\n\t\t<SitePreview />\n\t) : (\n\t\t<>\n\t\t\t<GlobalStylesRenderer\n\t\t\t\tdisableRootPadding={ postType !== TEMPLATE_POST_TYPE }\n\t\t\t/>\n\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t{ isEditMode && <BlockKeyboardShortcuts /> }\n\t\t\t{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }\n\t\t\t{ isEditMode && (\n\t\t\t\t<WelcomeGuide\n\t\t\t\t\tpostType={ postWithTemplate ? context.postType : postType }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isReady && (\n\t\t\t\t<Editor\n\t\t\t\t\tpostType={ postWithTemplate ? context.postType : postType }\n\t\t\t\t\tpostId={ postWithTemplate ? context.postId : postId }\n\t\t\t\t\ttemplateId={ postWithTemplate ? postId : undefined }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tclassName=\"edit-site-editor__editor-interface\"\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tcustomSaveButton={\n\t\t\t\t\t\t_isPreviewingTheme && <SaveButton size=\"compact\" />\n\t\t\t\t\t}\n\t\t\t\t\tcustomSavePanel={ _isPreviewingTheme && <SavePanel /> }\n\t\t\t\t\tforceDisableBlockTools={ ! hasDefaultEditorCanvasView }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tiframeProps={ iframeProps }\n\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t! postWithTemplate && (\n\t\t\t\t\t\t\t<PluginTemplateSettingPanel.Slot />\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t<BackButton>\n\t\t\t\t\t\t\t{ ( { length } ) =>\n\t\t\t\t\t\t\t\tlength <= 1 && (\n\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-editor__view-mode-toggle\"\n\t\t\t\t\t\t\t\t\t\ttransition={ transition }\n\t\t\t\t\t\t\t\t\t\tanimate=\"edit\"\n\t\t\t\t\t\t\t\t\t\tinitial=\"edit\"\n\t\t\t\t\t\t\t\t\t\twhileHover=\"hover\"\n\t\t\t\t\t\t\t\t\t\twhileTap=\"tap\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Open Navigation' ) }\n\t\t\t\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"middle right\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tresetZoomLevel();\n\n\t\t\t\t\t\t\t\t\t\t\t\t// TODO: this is a temporary solution to navigate to the posts list if we are\n\t\t\t\t\t\t\t\t\t\t\t\t// come here through `posts list` and are in focus mode editing a template, template part etc..\n\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\tisPostsList &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tlocation.query?.focusMode\n\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\thistory.navigate( '/', {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'canvas-mode-view-transition',\n\t\t\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetNavigationPath(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpostWithTemplate\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? context.postType\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: postType\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'canvas-mode-view-transition',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\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\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\t\t\tvariants={ siteIconVariants }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-editor__view-mode-toggle-icon\" />\n\t\t\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t\t'edit-site-editor__back-icon',\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t'has-site-icon':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thasSiteIcon,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tvariants={ toggleHomeIconVariants }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ arrowUpLeft } />\n\t\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</BackButton>\n\t\t\t\t\t) }\n\t\t\t\t\t<SiteEditorMoreMenu />\n\t\t\t\t\t{ isBlockBasedTheme && <GlobalStylesSidebar /> }\n\t\t\t\t</Editor>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Button, __unstableMotion as motion } from '@wordpress/components';\nimport { useInstanceId, useReducedMotion } from '@wordpress/compose';\nimport {\n\tEditorKeyboardShortcutsRegister,\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { Icon, arrowUpLeft } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport CanvasLoader from '../canvas-loader';\nimport { unlock } from '../../lock-unlock';\nimport { useSpecificEditorSettings } from '../block-editor/use-site-editor-settings';\nimport PluginTemplateSettingPanel from '../plugin-template-setting-panel';\nimport GlobalStylesSidebar from '../global-styles-sidebar';\nimport { isPreviewingTheme } from '../../utils/is-previewing-theme';\nimport {\n\tgetEditorCanvasContainerTitle,\n\tuseHasEditorCanvasContainer,\n} from '../editor-canvas-container';\nimport SaveButton from '../save-button';\nimport SavePanel from '../save-panel';\nimport SiteEditorMoreMenu from '../more-menu';\nimport SiteIcon from '../site-icon';\nimport useEditorIframeProps from '../block-editor/use-editor-iframe-props';\nimport useEditorTitle from './use-editor-title';\nimport { useIsSiteEditorLoading } from '../layout/hooks';\nimport { useAdaptEditorToCanvas } from './use-adapt-editor-to-canvas';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport {\n\tuseResolveEditedEntity,\n\tuseSyncDeprecatedEntityIntoState,\n} from './use-resolve-edited-entity';\nimport SitePreview from './site-preview';\n\nconst { Editor, BackButton } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nconst toggleHomeIconVariants = {\n\tedit: {\n\t\topacity: 0,\n\t\tscale: 0.2,\n\t},\n\thover: {\n\t\topacity: 1,\n\t\tscale: 1,\n\t\tclipPath: 'inset( 22% round 2px )',\n\t},\n};\n\nconst siteIconVariants = {\n\tedit: {\n\t\tclipPath: 'inset(0% round 0px)',\n\t},\n\thover: {\n\t\tclipPath: 'inset( 22% round 2px )',\n\t},\n\ttap: {\n\t\tclipPath: 'inset(0% round 0px)',\n\t},\n};\n\nfunction getListPathForPostType( postType ) {\n\tswitch ( postType ) {\n\t\tcase 'navigation':\n\t\t\treturn '/navigation';\n\t\tcase 'wp_block':\n\t\t\treturn '/pattern?postType=wp_block';\n\t\tcase 'wp_template_part':\n\t\t\treturn '/pattern?postType=wp_template_part';\n\t\tcase 'wp_template':\n\t\t\treturn '/template';\n\t\tcase 'page':\n\t\t\treturn '/page';\n\t\tcase 'post':\n\t\t\treturn '/';\n\t}\n\tthrow 'Unknown post type';\n}\n\nfunction getNavigationPath( location, postType ) {\n\tconst { path, name } = location;\n\tif (\n\t\t[\n\t\t\t'pattern-item',\n\t\t\t'template-part-item',\n\t\t\t'page-item',\n\t\t\t'template-item',\n\t\t\t'post-item',\n\t\t].includes( name )\n\t) {\n\t\treturn getListPathForPostType( postType );\n\t}\n\treturn addQueryArgs( path, { canvas: undefined } );\n}\n\nexport default function EditSiteEditor( {\n\tisHomeRoute = false,\n\tisPostsList = false,\n} ) {\n\tconst disableMotion = useReducedMotion();\n\tconst location = useLocation();\n\tconst { canvas = 'view' } = location.query;\n\tconst isLoading = useIsSiteEditorLoading();\n\tuseAdaptEditorToCanvas( canvas );\n\tconst entity = useResolveEditedEntity();\n\t// deprecated sync state with url\n\tuseSyncDeprecatedEntityIntoState( entity );\n\tconst { postType, postId, context } = entity;\n\tconst {\n\t\tisBlockBasedTheme,\n\t\teditorCanvasView,\n\t\tcurrentPostIsTrashed,\n\t\thasSiteIcon,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditorCanvasContainerView } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\t\tconst { getCurrentTheme, getEntityRecord } = select( coreDataStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase', undefined );\n\n\t\treturn {\n\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\teditorCanvasView: getEditorCanvasContainerView(),\n\t\t\tcurrentPostIsTrashed:\n\t\t\t\tselect( editorStore ).getCurrentPostAttribute( 'status' ) ===\n\t\t\t\t'trash',\n\t\t\thasSiteIcon: !! siteData?.site_icon_url,\n\t\t};\n\t}, [] );\n\tconst postWithTemplate = !! context?.postId;\n\tuseEditorTitle(\n\t\tpostWithTemplate ? context.postType : postType,\n\t\tpostWithTemplate ? context.postId : postId\n\t);\n\tconst _isPreviewingTheme = isPreviewingTheme();\n\tconst hasDefaultEditorCanvasView = ! useHasEditorCanvasContainer();\n\tconst iframeProps = useEditorIframeProps();\n\tconst isEditMode = canvas === 'edit';\n\tconst loadingProgressId = useInstanceId(\n\t\tCanvasLoader,\n\t\t'edit-site-editor__loading-progress'\n\t);\n\n\tconst settings = useSpecificEditorSettings();\n\tconst styles = useMemo(\n\t\t() => [\n\t\t\t...settings.styles,\n\t\t\t{\n\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\tcss:\n\t\t\t\t\tcanvas === 'view'\n\t\t\t\t\t\t? `body{min-height: 100vh; ${\n\t\t\t\t\t\t\t\tcurrentPostIsTrashed ? '' : 'cursor: pointer;'\n\t\t\t\t\t\t }}`\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t],\n\t\t[ settings.styles, canvas, currentPostIsTrashed ]\n\t);\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst history = useHistory();\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\tcase 'delete-post':\n\t\t\t\t\t{\n\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\tgetListPathForPostType(\n\t\t\t\t\t\t\t\tpostWithTemplate ? context.postType : postType\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\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst _title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( _title ) || __( '(no title)' )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\t`/${ newItem.type }/${ newItem.id }?canvas=edit`\n\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\tbreak;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tpostType,\n\t\t\tcontext?.postType,\n\t\t\tpostWithTemplate,\n\t\t\thistory,\n\t\t\tcreateSuccessNotice,\n\t\t]\n\t);\n\n\t// Replace the title and icon displayed in the DocumentBar when there's an overlay visible.\n\tconst title = getEditorCanvasContainerTitle( editorCanvasView );\n\n\tconst isReady = ! isLoading;\n\tconst transition = {\n\t\tduration: disableMotion ? 0 : 0.2,\n\t};\n\n\treturn ! isBlockBasedTheme && isHomeRoute ? (\n\t\t<SitePreview />\n\t) : (\n\t\t<>\n\t\t\t<GlobalStylesRenderer\n\t\t\t\tdisableRootPadding={ postType !== TEMPLATE_POST_TYPE }\n\t\t\t/>\n\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t{ isEditMode && <BlockKeyboardShortcuts /> }\n\t\t\t{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }\n\t\t\t{ isEditMode && (\n\t\t\t\t<WelcomeGuide\n\t\t\t\t\tpostType={ postWithTemplate ? context.postType : postType }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isReady && (\n\t\t\t\t<Editor\n\t\t\t\t\tpostType={ postWithTemplate ? context.postType : postType }\n\t\t\t\t\tpostId={ postWithTemplate ? context.postId : postId }\n\t\t\t\t\ttemplateId={ postWithTemplate ? postId : undefined }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tclassName=\"edit-site-editor__editor-interface\"\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tcustomSaveButton={\n\t\t\t\t\t\t_isPreviewingTheme && <SaveButton size=\"compact\" />\n\t\t\t\t\t}\n\t\t\t\t\tcustomSavePanel={ _isPreviewingTheme && <SavePanel /> }\n\t\t\t\t\tforceDisableBlockTools={ ! hasDefaultEditorCanvasView }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tiframeProps={ iframeProps }\n\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t! postWithTemplate && (\n\t\t\t\t\t\t\t<PluginTemplateSettingPanel.Slot />\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t<BackButton>\n\t\t\t\t\t\t\t{ ( { length } ) =>\n\t\t\t\t\t\t\t\tlength <= 1 && (\n\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-editor__view-mode-toggle\"\n\t\t\t\t\t\t\t\t\t\ttransition={ transition }\n\t\t\t\t\t\t\t\t\t\tanimate=\"edit\"\n\t\t\t\t\t\t\t\t\t\tinitial=\"edit\"\n\t\t\t\t\t\t\t\t\t\twhileHover=\"hover\"\n\t\t\t\t\t\t\t\t\t\twhileTap=\"tap\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Open Navigation' ) }\n\t\t\t\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"middle right\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tresetZoomLevel();\n\n\t\t\t\t\t\t\t\t\t\t\t\t// TODO: this is a temporary solution to navigate to the posts list if we are\n\t\t\t\t\t\t\t\t\t\t\t\t// come here through `posts list` and are in focus mode editing a template, template part etc..\n\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\tisPostsList &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tlocation.query?.focusMode\n\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\thistory.navigate( '/', {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'canvas-mode-view-transition',\n\t\t\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetNavigationPath(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpostWithTemplate\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? context.postType\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: postType\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'canvas-mode-view-transition',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\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\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\t\t\tvariants={ siteIconVariants }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-editor__view-mode-toggle-icon\" />\n\t\t\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t\t'edit-site-editor__back-icon',\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t'has-site-icon':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thasSiteIcon,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tvariants={ toggleHomeIconVariants }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ arrowUpLeft } />\n\t\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</BackButton>\n\t\t\t\t\t) }\n\t\t\t\t\t<SiteEditorMoreMenu />\n\t\t\t\t\t{ isBlockB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B;AAAA;AAAA;AAAA,IAC7C;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": ["editorPrivateApis", "routerPrivateApis", "blockLibraryPrivateApis", "editSiteStore", "coreDataStore", "editorStore", "useEditorTitle", "useEditorIframeProps", "CanvasLoader", "blockEditorStore", "noticesStore", "SitePreview", "WelcomeGuide", "SaveButton", "SavePanel", "PluginTemplateSettingPanel", "motion", "SiteIcon", "clsx", "SiteEditorMoreMenu", "GlobalStylesSidebar"]
|
|
7
7
|
}
|
|
@@ -37,7 +37,9 @@ const postTypesWithoutParentTemplate = [
|
|
|
37
37
|
import_constants.PATTERN_TYPES.user
|
|
38
38
|
];
|
|
39
39
|
const authorizedPostTypes = ["page", "post"];
|
|
40
|
-
function
|
|
40
|
+
function useResolveEditedEntity() {
|
|
41
|
+
const { name, params = {}, query } = useLocation();
|
|
42
|
+
const { postId = query?.postId } = params;
|
|
41
43
|
let postType;
|
|
42
44
|
if (name === "navigation-item") {
|
|
43
45
|
postType = import_constants.NAVIGATION_POST_TYPE;
|
|
@@ -45,21 +47,13 @@ function getPostType(name) {
|
|
|
45
47
|
postType = import_constants.PATTERN_TYPES.user;
|
|
46
48
|
} else if (name === "template-part-item") {
|
|
47
49
|
postType = import_constants.TEMPLATE_PART_POST_TYPE;
|
|
48
|
-
} else if (name === "templates") {
|
|
49
|
-
postType = import_constants.TEMPLATE_POST_TYPE;
|
|
50
|
-
} else if (name === "template-item") {
|
|
50
|
+
} else if (name === "template-item" || name === "templates") {
|
|
51
51
|
postType = import_constants.TEMPLATE_POST_TYPE;
|
|
52
52
|
} else if (name === "page-item" || name === "pages") {
|
|
53
53
|
postType = "page";
|
|
54
54
|
} else if (name === "post-item" || name === "posts") {
|
|
55
55
|
postType = "post";
|
|
56
56
|
}
|
|
57
|
-
return postType;
|
|
58
|
-
}
|
|
59
|
-
function useResolveEditedEntity() {
|
|
60
|
-
const { name, params = {}, query } = useLocation();
|
|
61
|
-
const { postId = query?.postId } = params;
|
|
62
|
-
const postType = getPostType(name, postId) ?? query?.postType;
|
|
63
57
|
const homePage = (0, import_data.useSelect)((select) => {
|
|
64
58
|
const { getHomePage } = (0, import_lock_unlock.unlock)(select(import_core_data.store));
|
|
65
59
|
return getHomePage();
|
|
@@ -119,7 +113,7 @@ function useSyncDeprecatedEntityIntoState({
|
|
|
119
113
|
const { setEditedEntity } = (0, import_data.useDispatch)(import_store.store);
|
|
120
114
|
(0, import_element.useEffect)(() => {
|
|
121
115
|
if (isReady) {
|
|
122
|
-
setEditedEntity(postType,
|
|
116
|
+
setEditedEntity(postType, postId, context);
|
|
123
117
|
}
|
|
124
118
|
}, [isReady, postType, postId, context, setEditedEntity]);
|
|
125
119
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/editor/use-resolve-edited-entity.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nconst authorizedPostTypes = [ 'page', 'post' ];\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,kBAAuC;AACvC,uBAAuC;AACvC,oBAAiD;AAKjD,mBAAuC;AACvC,yBAAuB;AACvB,uBAKO;AAEP,MAAM,EAAE,YAAY,QAAI,2BAAQ,cAAAA,WAAkB;AAElD,MAAM,iCAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAAc;AACf;AAEA,MAAM,sBAAsB,CAAE,QAAQ,MAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nconst authorizedPostTypes = [ 'page', 'post' ];\n\nexport function useResolveEditedEntity() {\n\tconst { name, params = {}, query } = useLocation();\n\tconst { postId = query?.postId } = params; // Fallback to query param for postId for list view routes.\n\tlet postType;\n\tif ( name === 'navigation-item' ) {\n\t\tpostType = NAVIGATION_POST_TYPE;\n\t} else if ( name === 'pattern-item' ) {\n\t\tpostType = PATTERN_TYPES.user;\n\t} else if ( name === 'template-part-item' ) {\n\t\tpostType = TEMPLATE_PART_POST_TYPE;\n\t} else if ( name === 'template-item' || name === 'templates' ) {\n\t\tpostType = TEMPLATE_POST_TYPE;\n\t} else if ( name === 'page-item' || name === 'pages' ) {\n\t\tpostType = 'page';\n\t} else if ( name === 'post-item' || name === 'posts' ) {\n\t\tpostType = 'post';\n\t}\n\n\tconst homePage = useSelect( ( select ) => {\n\t\tconst { getHomePage } = unlock( select( coreDataStore ) );\n\t\treturn getHomePage();\n\t}, [] );\n\n\t/**\n\t * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId\n\t * in order to match the frontend as closely as possible in the site editor.\n\t *\n\t * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.\n\t */\n\tconst resolvedTemplateId = useSelect(\n\t\t( select ) => {\n\t\t\t// If we're rendering a post type that doesn't have a template\n\t\t\t// no need to resolve its template.\n\t\t\tif (\n\t\t\t\tpostTypesWithoutParentTemplate.includes( postType ) &&\n\t\t\t\tpostId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't trigger resolution for multi-selected posts.\n\t\t\tif ( postId && postId.includes( ',' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getTemplateId } = unlock( select( coreDataStore ) );\n\n\t\t\t// If we're rendering a specific page, we need to resolve its template.\n\t\t\t// The site editor only supports pages for now, not other CPTs.\n\t\t\tif (\n\t\t\t\tpostType &&\n\t\t\t\tpostId &&\n\t\t\t\tauthorizedPostTypes.includes( postType )\n\t\t\t) {\n\t\t\t\treturn getTemplateId( postType, postId );\n\t\t\t}\n\n\t\t\t// If we're rendering the home page, and we have a static home page, resolve its template.\n\t\t\tif ( homePage?.postType === 'page' ) {\n\t\t\t\treturn getTemplateId( 'page', homePage?.postId );\n\t\t\t}\n\n\t\t\tif ( homePage?.postType === 'wp_template' ) {\n\t\t\t\treturn homePage?.postId;\n\t\t\t}\n\t\t},\n\t\t[ homePage, postId, postType ]\n\t);\n\n\tconst context = useMemo( () => {\n\t\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif ( postType && postId && authorizedPostTypes.includes( postType ) ) {\n\t\t\treturn { postType, postId };\n\t\t}\n\t\t// TODO: for post types lists we should probably not render the front page, but maybe a placeholder\n\t\t// with a message like \"Select a page\" or something similar.\n\t\tif ( homePage?.postType === 'page' ) {\n\t\t\treturn { postType: 'page', postId: homePage?.postId };\n\t\t}\n\n\t\treturn {};\n\t}, [ homePage, postType, postId ] );\n\n\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\treturn { isReady: true, postType, postId, context };\n\t}\n\n\tif ( !! homePage ) {\n\t\treturn {\n\t\t\tisReady: resolvedTemplateId !== undefined,\n\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\tpostId: resolvedTemplateId,\n\t\t\tcontext,\n\t\t};\n\t}\n\n\treturn { isReady: false };\n}\n\nexport function useSyncDeprecatedEntityIntoState( {\n\tpostType,\n\tpostId,\n\tcontext,\n\tisReady,\n} ) {\n\tconst { setEditedEntity } = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( isReady ) {\n\t\t\tsetEditedEntity( postType, postId, context );\n\t\t}\n\t}, [ isReady, postType, postId, context, setEditedEntity ] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,kBAAuC;AACvC,uBAAuC;AACvC,oBAAiD;AAKjD,mBAAuC;AACvC,yBAAuB;AACvB,uBAKO;AAEP,MAAM,EAAE,YAAY,QAAI,2BAAQ,cAAAA,WAAkB;AAElD,MAAM,iCAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAAc;AACf;AAEA,MAAM,sBAAsB,CAAE,QAAQ,MAAO;AAEtC,SAAS,yBAAyB;AACxC,QAAM,EAAE,MAAM,SAAS,CAAC,GAAG,MAAM,IAAI,YAAY;AACjD,QAAM,EAAE,SAAS,OAAO,OAAO,IAAI;AACnC,MAAI;AACJ,MAAK,SAAS,mBAAoB;AACjC,eAAW;AAAA,EACZ,WAAY,SAAS,gBAAiB;AACrC,eAAW,+BAAc;AAAA,EAC1B,WAAY,SAAS,sBAAuB;AAC3C,eAAW;AAAA,EACZ,WAAY,SAAS,mBA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AO,EAAE,SAAS,MAAM,UAAU,QAAQ,QAAQ;AAAA,EACnD;AAEA,MAAK,CAAC,CAAE,UAAW;AAClB,WAAO;AAAA,MACN,SAAS,uBAAuB;AAAA,MAChC,UAAU;AAAA,MACV,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,SAAO,EAAE,SAAS,MAAM;AACzB;AAEO,SAAS,iCAAkC;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,gBAAgB,QAAI,yBAAa,aAAAC,KAAc;AAEvD,gCAAW,MAAM;AAChB,QAAK,SAAU;AACd,sBAAiB,UAAU,QAAQ,OAAQ;AAAA,IAC5C;AAAA,EACD,GAAG,CAAE,SAAS,UAAU,QAAQ,SAAS,eAAgB,CAAE;AAC5D;",
|
|
6
6
|
"names": ["routerPrivateApis", "coreDataStore", "editSiteStore"]
|
|
7
7
|
}
|
|
@@ -28,12 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var fields_exports = {};
|
|
30
30
|
__export(fields_exports, {
|
|
31
|
-
activeField: () => activeField,
|
|
32
31
|
authorField: () => authorField,
|
|
33
32
|
descriptionField: () => descriptionField,
|
|
34
|
-
previewField: () => previewField
|
|
35
|
-
slugField: () => slugField,
|
|
36
|
-
useThemeField: () => useThemeField
|
|
33
|
+
previewField: () => previewField
|
|
37
34
|
});
|
|
38
35
|
module.exports = __toCommonJS(fields_exports);
|
|
39
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -45,32 +42,10 @@ var import_html_entities = require("@wordpress/html-entities");
|
|
|
45
42
|
var import_blocks = require("@wordpress/blocks");
|
|
46
43
|
var import_block_editor = require("@wordpress/block-editor");
|
|
47
44
|
var import_editor = require("@wordpress/editor");
|
|
48
|
-
var import_core_data = require("@wordpress/core-data");
|
|
49
|
-
var import_data = require("@wordpress/data");
|
|
50
45
|
var import_hooks = require("./hooks");
|
|
51
|
-
var import_utils = require("../add-new-template/utils");
|
|
52
46
|
var import_use_pattern_settings = __toESM(require("../page-patterns/use-pattern-settings"));
|
|
53
47
|
var import_lock_unlock = require("../../lock-unlock");
|
|
54
48
|
const { useGlobalStyle } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
55
|
-
const { Badge } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
56
|
-
const { useEntityRecordsWithPermissions } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
|
|
57
|
-
function useAllDefaultTemplateTypes() {
|
|
58
|
-
const defaultTemplateTypes = (0, import_utils.useDefaultTemplateTypes)();
|
|
59
|
-
const { records: staticRecords } = useEntityRecordsWithPermissions(
|
|
60
|
-
"root",
|
|
61
|
-
"registeredTemplate"
|
|
62
|
-
);
|
|
63
|
-
return [
|
|
64
|
-
...defaultTemplateTypes,
|
|
65
|
-
...staticRecords?.filter((record) => !record.is_custom).map((record) => {
|
|
66
|
-
return {
|
|
67
|
-
slug: record.slug,
|
|
68
|
-
title: record.title.rendered,
|
|
69
|
-
description: record.description
|
|
70
|
-
};
|
|
71
|
-
})
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
49
|
function PreviewField({ item }) {
|
|
75
50
|
const settings = (0, import_use_pattern_settings.default)();
|
|
76
51
|
const [backgroundColor = "white"] = useGlobalStyle("color.background");
|
|
@@ -99,12 +74,8 @@ const previewField = {
|
|
|
99
74
|
const descriptionField = {
|
|
100
75
|
label: (0, import_i18n.__)("Description"),
|
|
101
76
|
id: "description",
|
|
102
|
-
render:
|
|
103
|
-
|
|
104
|
-
const defaultTemplateType = defaultTemplateTypes.find(
|
|
105
|
-
(type) => type.slug === item.slug
|
|
106
|
-
);
|
|
107
|
-
return item.description ? (0, import_html_entities.decodeEntities)(item.description) : defaultTemplateType?.description;
|
|
77
|
+
render: ({ item }) => {
|
|
78
|
+
return item.description && (0, import_html_entities.decodeEntities)(item.description);
|
|
108
79
|
},
|
|
109
80
|
enableSorting: false,
|
|
110
81
|
enableGlobalSearch: true
|
|
@@ -136,59 +107,13 @@ function AuthorField({ item }) {
|
|
|
136
107
|
const authorField = {
|
|
137
108
|
label: (0, import_i18n.__)("Author"),
|
|
138
109
|
id: "author",
|
|
139
|
-
getValue: ({ item }) => item.author_text
|
|
110
|
+
getValue: ({ item }) => item.author_text,
|
|
140
111
|
render: AuthorField
|
|
141
112
|
};
|
|
142
|
-
const activeField = {
|
|
143
|
-
label: (0, import_i18n.__)("Status"),
|
|
144
|
-
id: "active",
|
|
145
|
-
type: "boolean",
|
|
146
|
-
getValue: ({ item }) => item._isActive,
|
|
147
|
-
render: function Render({ item }) {
|
|
148
|
-
const activeLabel = item._isCustom ? (0, import_i18n.__)("Active when used") : (0, import_i18n.__)("Active");
|
|
149
|
-
const activeIntent = item._isCustom ? "info" : "success";
|
|
150
|
-
const isActive = item._isActive;
|
|
151
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { intent: isActive ? activeIntent : "default", children: isActive ? activeLabel : (0, import_i18n.__)("Inactive") });
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const useThemeField = () => {
|
|
155
|
-
const activeTheme = (0, import_data.useSelect)(
|
|
156
|
-
(select) => select(import_core_data.store).getCurrentTheme()
|
|
157
|
-
);
|
|
158
|
-
return (0, import_element.useMemo)(
|
|
159
|
-
() => ({
|
|
160
|
-
label: (0, import_i18n.__)("Compatible Theme"),
|
|
161
|
-
id: "theme",
|
|
162
|
-
getValue: ({ item }) => item.theme,
|
|
163
|
-
render: function Render3({ item }) {
|
|
164
|
-
if (item.theme === activeTheme.stylesheet) {
|
|
165
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { intent: "success", children: item.theme });
|
|
166
|
-
}
|
|
167
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { intent: "error", children: item.theme });
|
|
168
|
-
}
|
|
169
|
-
}),
|
|
170
|
-
[activeTheme]
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
const slugField = {
|
|
174
|
-
label: (0, import_i18n.__)("Template Type"),
|
|
175
|
-
id: "slug",
|
|
176
|
-
getValue: ({ item }) => item.slug,
|
|
177
|
-
render: function Render2({ item }) {
|
|
178
|
-
const defaultTemplateTypes = useAllDefaultTemplateTypes();
|
|
179
|
-
const defaultTemplateType = defaultTemplateTypes.find(
|
|
180
|
-
(type) => type.slug === item.slug
|
|
181
|
-
);
|
|
182
|
-
return defaultTemplateType?.title || (0, import_i18n._x)("Custom", "template type");
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
113
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
114
|
0 && (module.exports = {
|
|
187
|
-
activeField,
|
|
188
115
|
authorField,
|
|
189
116
|
descriptionField,
|
|
190
|
-
previewField
|
|
191
|
-
slugField,
|
|
192
|
-
useThemeField
|
|
117
|
+
previewField
|
|
193
118
|
});
|
|
194
119
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-templates/fields.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["blockEditorPrivateApis", "
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { EditorProvider } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from './hooks';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: ( { item } ) => {\n\t\treturn item.description && decodeEntities( item.description );\n\t},\n\tenableSorting: false,\n\tenableGlobalSearch: true,\n};\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport const authorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text,\n\trender: AuthorField,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6CG;AA1CH,kBAAiB;AAKjB,wBAAqD;AACrD,kBAAmB;AACnB,qBAAkC;AAClC,2BAA+B;AAC/B,oBAAsB;AACtB,0BAGO;AACP,oBAA+B;AAK/B,mBAA2B;AAC3B,kCAA+B;AAC/B,yBAAuB;AAEvB,MAAM,EAAE,eAAe,QAAI,2BAAQ,oBAAAA,WAAuB;AAE1D,SAAS,aAAc,EAAE,KAAK,GAAI;AACjC,QAAM,eAAW,4BAAAC,SAAmB;AACpC,QAAM,CAAE,kBAAkB,OAAQ,IAAI,eAAgB,kBAAmB;AACzE,QAAM,aAAS,wBAAS,MAAM;AAC7B,eAAO,qBAAO,KAAK,QAAQ,GAAI;AAAA,EAChC,GAAG,CAAE,KAAK,QAAQ,GAAI,CAA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;AAEO,MAAM,cAAc;AAAA,EAC1B,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,QAAQ;AACT;",
|
|
6
|
+
"names": ["blockEditorPrivateApis", "usePatternSettings", "HStack", "clsx"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-templates/hooks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from '../../utils/constants';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getUser, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst originalSource = template?.original_source;\n\t\t\tconst authorText = template?.author_text;\n\n\t\t\tswitch ( originalSource ) {\n\t\t\t\tcase 'theme': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'plugin': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'site': {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\t\tsiteData.site_logo\n\t\t\t\t\t\t\t )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tconst user = getUser( template.author );\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'user',\n\t\t\t\t\t\ticon: authorIcon,\n\t\t\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\t\t\ttext: authorText
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AACnC,kBAA0B;AAC1B,mBAKO;AAKP,uBAAiC;AAmB1B,SAAS,WAAY,UAAU,QAAS;AAC9C,aAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,EAAE,iBAAiB,SAAS,sBAAsB,IACvD,OAAQ,iBAAAA,KAAU;AACnB,YAAM,WAAW;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,YAAM,iBAAiB,UAAU;AACjC,YAAM,aAAa,UAAU;AAE7B,cAAS,gBAAiB;AAAA,QACzB,KAAK,SAAS;AACb,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,aAAAC;AAAA,YACN,MAAM;AAAA,YACN,cACC,SAAS,WAAW,kCAAiB;AAAA,UACvC;AAAA,QACD;AAAA,QACA,KAAK,UAAU;AACd,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,aAAAC;AAAA,YACN,MAAM;AAAA,YACN,cACC,SAAS,WAAW,kCAAiB;AAAA,UACvC;AAAA,QACD;AAAA,QACA,KAAK,QAAQ;AACZ,gBAAM,WAAW;AAAA,YAChB;AAAA,YACA;AAAA,UACD;AACA,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,aAAAC;AAAA,YACN,UAAU,UAAU,YACjB;AAAA,cACA;AAAA,cACA;AAAA,cACA,SAAS;AAAA,YACT,GAAG,aACH;AAAA,YACH,MAAM;AAAA,YACN,cAAc;AAAA,UACf;AAAA,QACD;AAAA,QACA,SAAS;AACR,gBAAM,OAAO,QAAS,SAAS,MAAO;AACtC,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,aAAAC;AAAA,YACN,UAAU,MAAM,cAAe,EAAG;AAAA,YAClC,MAAM
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from '../../utils/constants';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getUser, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst originalSource = template?.original_source;\n\t\t\tconst authorText = template?.author_text;\n\n\t\t\tswitch ( originalSource ) {\n\t\t\t\tcase 'theme': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'plugin': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'site': {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\t\tsiteData.site_logo\n\t\t\t\t\t\t\t )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tconst user = getUser( template.author );\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'user',\n\t\t\t\t\t\ticon: authorIcon,\n\t\t\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ postType, postId ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AACnC,kBAA0B;AAC1B,mBAKO;AAKP,uBAAiC;AAmB1B,SAAS,WAAY,UAAU,QAAS;AAC9C,aAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,EAAE,iBAAiB,SAAS,sBAAsB,IACvD,OAAQ,iBAAAA,KAAU;AACnB,YAAM,WAAW;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,YAAM,iBAAiB,UAAU;AACjC,YAAM,aAAa,UAAU;AAE7B,cAAS,gBAAiB;AAAA,QACzB,KAAK,SAAS;AACb,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,aAAAC;AAAA,YACN,MAAM;AAAA,YACN,cACC,SAAS,WAAW,kCAAiB;AAAA,UACvC;AAAA,QACD;AAAA,QACA,KAAK,UAAU;AACd,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,aAAAC;AAAA,YACN,MAAM;AAAA,YACN,cACC,SAAS,WAAW,kCA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