@wordpress/edit-site 6.11.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/app/index.js +0 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build/components/editor/index.js +9 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-editor-title.js +29 -12
- package/build/components/editor/use-editor-title.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +2 -3
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +42 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +6 -8
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/layout/hooks.js +1 -10
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +1 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +3 -7
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/page-templates/fields.js +1 -2
- package/build/components/page-templates/fields.js.map +1 -1
- package/build/components/post-edit/index.js +14 -8
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +3 -197
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +11 -1
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar/index.js +11 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
- package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +14 -72
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +43 -42
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/site-editor-routes/styles-edit.js +6 -1
- package/build/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build/components/site-editor-routes/styles-view.js +8 -2
- package/build/components/site-editor-routes/styles-view.js.map +1 -1
- package/build/components/site-hub/index.js +19 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/constants.js +10 -3
- package/build/components/style-book/constants.js.map +1 -1
- package/build/components/style-book/examples.js +71 -1
- package/build/components/style-book/examples.js.map +1 -1
- package/build/components/style-book/index.js +70 -11
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/welcome-guide/index.js +4 -2
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +1 -9
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -12
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +15 -15
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/posts.js +1 -0
- package/build/posts.js.map +1 -1
- package/build-module/components/app/index.js +0 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build-module/components/editor/index.js +9 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +29 -12
- package/build-module/components/editor/use-editor-title.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +43 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +6 -8
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +1 -9
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +1 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +4 -8
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/page-templates/fields.js +1 -2
- package/build-module/components/page-templates/fields.js.map +1 -1
- package/build-module/components/post-edit/index.js +14 -8
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +7 -202
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +11 -1
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +11 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +15 -73
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-edit.js +6 -1
- package/build-module/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-view.js +8 -2
- package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -6
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/constants.js +10 -3
- package/build-module/components/style-book/constants.js.map +1 -1
- package/build-module/components/style-book/examples.js +71 -1
- package/build-module/components/style-book/examples.js.map +1 -1
- package/build-module/components/style-book/index.js +71 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +4 -2
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +1 -9
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -11
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +15 -15
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +1 -0
- package/build-module/posts.js.map +1 -1
- package/build-style/posts-rtl.css +54 -5
- package/build-style/posts.css +54 -5
- package/build-style/style-rtl.css +109 -28
- package/build-style/style.css +109 -28
- package/package.json +3 -4
- package/src/components/app/index.js +0 -2
- package/src/components/block-editor/use-editor-iframe-props.js +2 -3
- package/src/components/editor/index.js +16 -4
- package/src/components/editor/use-editor-title.js +37 -13
- package/src/components/editor-canvas-container/style.scss +0 -1
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
- package/src/components/global-styles/screen-revisions/style.scss +11 -17
- package/src/components/global-styles/shadows-edit-panel.js +4 -2
- package/src/components/global-styles/ui.js +42 -2
- package/src/components/global-styles-renderer/index.js +4 -10
- package/src/components/layout/hooks.js +1 -7
- package/src/components/layout/index.js +6 -1
- package/src/components/page-patterns/fields.js +6 -12
- package/src/components/page-patterns/style.scss +0 -5
- package/src/components/page-templates/fields.js +2 -3
- package/src/components/post-edit/index.js +38 -30
- package/src/components/post-edit/style.scss +7 -0
- package/src/components/post-fields/index.js +19 -273
- package/src/components/post-list/index.js +9 -3
- package/src/components/post-list/style.scss +29 -3
- package/src/components/sidebar/index.js +23 -7
- package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
- package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
- package/src/components/sidebar-navigation-item/style.scss +2 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +13 -88
- package/src/components/sidebar-navigation-screen-main/index.js +46 -45
- package/src/components/site-editor-routes/styles-edit.js +10 -1
- package/src/components/site-editor-routes/styles-view.js +11 -1
- package/src/components/site-hub/index.js +33 -16
- package/src/components/site-icon/style.scss +16 -0
- package/src/components/style-book/constants.ts +11 -3
- package/src/components/style-book/examples.tsx +105 -1
- package/src/components/style-book/index.js +86 -8
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +54 -64
- package/src/components/welcome-guide/index.js +3 -3
- package/src/components/welcome-guide/page.js +1 -7
- package/src/components/welcome-guide/template.js +1 -8
- package/src/hooks/commands/use-common-commands.js +253 -246
- package/src/index.js +1 -0
- package/src/posts.js +1 -0
- package/src/style.scss +2 -3
- package/build/components/async/index.js +0 -51
- package/build/components/async/index.js.map +0 -1
- package/build/components/use-edited-entity-record/index.js +0 -60
- package/build/components/use-edited-entity-record/index.js.map +0 -1
- package/build/hooks/commands/use-edit-mode-commands.js +0 -179
- package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/build-module/components/async/index.js +0 -44
- package/build-module/components/async/index.js.map +0 -1
- package/build-module/components/use-edited-entity-record/index.js +0 -53
- package/build-module/components/use-edited-entity-record/index.js.map +0 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/src/components/async/index.js +0 -43
- package/src/components/use-edited-entity-record/index.js +0 -58
- package/src/hooks/commands/use-edit-mode-commands.js +0 -168
|
@@ -13,7 +13,6 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
13
13
|
var _icons = require("@wordpress/icons");
|
|
14
14
|
var _blocks = require("@wordpress/blocks");
|
|
15
15
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
16
|
-
var _async = require("../async");
|
|
17
16
|
var _constants = require("../../utils/constants");
|
|
18
17
|
var _lockUnlock = require("../../lock-unlock");
|
|
19
18
|
var _link = require("../routes/link");
|
|
@@ -45,7 +44,7 @@ function PreviewWrapper({
|
|
|
45
44
|
className: "page-patterns-preview-field__button",
|
|
46
45
|
type: "button",
|
|
47
46
|
onClick: item.type !== _constants.PATTERN_TYPES.theme ? onClick : undefined,
|
|
48
|
-
"aria-label": item
|
|
47
|
+
"aria-label": (0, _searchItems.defaultGetTitle)(item),
|
|
49
48
|
"aria-describedby": ariaDescribedBy,
|
|
50
49
|
"aria-disabled": item.type === _constants.PATTERN_TYPES.theme,
|
|
51
50
|
children: children
|
|
@@ -82,7 +81,7 @@ function PreviewField({
|
|
|
82
81
|
item: item,
|
|
83
82
|
onClick: onClick,
|
|
84
83
|
ariaDescribedBy: !!description ? descriptionId : undefined,
|
|
85
|
-
children: [isEmpty && isTemplatePart && (0, _i18n.__)('Empty template part'), isEmpty && !isTemplatePart && (0, _i18n.__)('Empty pattern'), !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
84
|
+
children: [isEmpty && isTemplatePart && (0, _i18n.__)('Empty template part'), isEmpty && !isTemplatePart && (0, _i18n.__)('Empty pattern'), !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview.Async, {
|
|
86
85
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview, {
|
|
87
86
|
blocks: blocks,
|
|
88
87
|
viewportWidth: item.viewportWidth
|
|
@@ -118,10 +117,7 @@ function TitleField({
|
|
|
118
117
|
alignment: "center",
|
|
119
118
|
justify: "flex-start",
|
|
120
119
|
spacing: 2,
|
|
121
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
122
|
-
as: "div",
|
|
123
|
-
gap: 0,
|
|
124
|
-
justify: "flex-start",
|
|
120
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexBlock, {
|
|
125
121
|
className: "edit-site-patterns__pattern-title",
|
|
126
122
|
children: item.type === _constants.PATTERN_TYPES.theme ? title : /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
127
123
|
__next40pxDefaultSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_blockEditor","_icons","_blocks","_htmlEntities","_async","_constants","_lockUnlock","_link","_hooks","_searchItems","_jsxRuntime","useGlobalStyle","unlock","blockEditorPrivateApis","PreviewWrapper","item","onClick","ariaDescribedBy","children","jsx","className","type","PATTERN_TYPES","theme","undefined","title","PreviewField","descriptionId","useId","description","excerpt","raw","isUserPattern","user","isTemplatePart","TEMPLATE_PART_POST_TYPE","backgroundColor","useLink","postType","postId","id","name","canvas","blocks","useMemo","_item$blocks","parse","content","__unstableSkipMigrationLogs","isEmpty","length","jsxs","style","__","Async","BlockPreview","viewportWidth","hidden","previewField","exports","label","render","enableSorting","TitleField","decodeEntities","defaultGetTitle","__experimentalHStack","alignment","justify","spacing","Flex","as","gap","Button","__next40pxDefaultSize","variant","tabIndex","Tooltip","placement","text","Icon","icon","lockSmall","size","titleField","getValue","enableHiding","SYNC_FILTERS","value","PATTERN_SYNC_TYPES","full","_x","unsynced","patternStatusField","syncStatus","wp_pattern_sync_status","find","elements","filterBy","operators","OPERATOR_IS","isPrimary","AuthorField","isImageLoaded","setIsImageLoaded","useState","imageUrl","useAddedBy","clsx","onLoad","alt","src","templatePartAuthorField","author_text"],"sources":["@wordpress/edit-site/src/components/page-patterns/fields.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tButton,\n\tTooltip,\n\tFlex,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useMemo, useId } from '@wordpress/element';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { Icon, lockSmall } from '@wordpress/icons';\nimport { parse } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { Async } from '../async';\nimport {\n\tPATTERN_TYPES,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_SYNC_TYPES,\n\tOPERATOR_IS,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useLink } from '../routes/link';\nimport { useAddedBy } from '../page-templates/hooks';\nimport { defaultGetTitle } from './search-items';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nfunction PreviewWrapper( { item, onClick, ariaDescribedBy, children } ) {\n\treturn (\n\t\t<button\n\t\t\tclassName=\"page-patterns-preview-field__button\"\n\t\t\ttype=\"button\"\n\t\t\tonClick={ item.type !== PATTERN_TYPES.theme ? onClick : undefined }\n\t\t\taria-label={ item.title }\n\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\taria-disabled={ item.type === PATTERN_TYPES.theme }\n\t\t>\n\t\t\t{ children }\n\t\t</button>\n\t);\n}\n\nfunction PreviewField( { item } ) {\n\tconst descriptionId = useId();\n\tconst description = item.description || item?.excerpt?.raw;\n\tconst isUserPattern = item.type === PATTERN_TYPES.user;\n\tconst isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: isUserPattern || isTemplatePart ? item.id : item.name,\n\t\tcanvas: 'edit',\n\t} );\n\tconst blocks = useMemo( () => {\n\t\treturn (\n\t\t\titem.blocks ??\n\t\t\tparse( item.content.raw, {\n\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t} )\n\t\t);\n\t}, [ item?.content?.raw, item.blocks ] );\n\tconst isEmpty = ! blocks?.length;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"page-patterns-preview-field\"\n\t\t\tstyle={ { backgroundColor } }\n\t\t>\n\t\t\t<PreviewWrapper\n\t\t\t\titem={ item }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tariaDescribedBy={ !! description ? descriptionId : undefined }\n\t\t\t>\n\t\t\t\t{ isEmpty && isTemplatePart && __( 'Empty template part' ) }\n\t\t\t\t{ isEmpty && ! isTemplatePart && __( 'Empty pattern' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<Async>\n\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tviewportWidth={ item.viewportWidth }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Async>\n\t\t\t\t) }\n\t\t\t</PreviewWrapper>\n\t\t\t{ !! description && (\n\t\t\t\t<div hidden id={ descriptionId }>\n\t\t\t\t\t{ description }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nfunction TitleField( { item } ) {\n\tconst isUserPattern = item.type === PATTERN_TYPES.user;\n\tconst isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: isUserPattern || isTemplatePart ? item.id : item.name,\n\t\tcanvas: 'edit',\n\t} );\n\tconst title = decodeEntities( defaultGetTitle( item ) );\n\treturn (\n\t\t<HStack alignment=\"center\" justify=\"flex-start\" spacing={ 2 }>\n\t\t\t<Flex\n\t\t\t\tas=\"div\"\n\t\t\t\tgap={ 0 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-patterns__pattern-title\"\n\t\t\t>\n\t\t\t\t{ item.type === PATTERN_TYPES.theme ? (\n\t\t\t\t\ttitle\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\t// Required for the grid's roving tab index system.\n\t\t\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t\t{ item.type === PATTERN_TYPES.theme && (\n\t\t\t\t<Tooltip\n\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\ttext={ __( 'This pattern cannot be edited.' ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"edit-site-patterns__pattern-lock-icon\"\n\t\t\t\t\t\ticon={ lockSmall }\n\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t</Tooltip>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n\nexport const titleField = {\n\tlabel: __( 'Title' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => item.title?.raw || item.title,\n\trender: TitleField,\n\tenableHiding: false,\n};\n\nconst SYNC_FILTERS = [\n\t{\n\t\tvalue: PATTERN_SYNC_TYPES.full,\n\t\tlabel: _x( 'Synced', 'pattern (singular)' ),\n\t\tdescription: __( 'Patterns that are kept in sync across the site.' ),\n\t},\n\t{\n\t\tvalue: PATTERN_SYNC_TYPES.unsynced,\n\t\tlabel: _x( 'Not synced', 'pattern (singular)' ),\n\t\tdescription: __(\n\t\t\t'Patterns that can be changed freely without affecting the site.'\n\t\t),\n\t},\n];\n\nexport const patternStatusField = {\n\tlabel: __( 'Sync status' ),\n\tid: 'sync-status',\n\trender: ( { item } ) => {\n\t\tconst syncStatus =\n\t\t\t'wp_pattern_sync_status' in item\n\t\t\t\t? item.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full\n\t\t\t\t: PATTERN_SYNC_TYPES.unsynced;\n\t\t// User patterns can have their sync statuses checked directly.\n\t\t// Non-user patterns are all unsynced for the time being.\n\t\treturn (\n\t\t\t<span\n\t\t\t\tclassName={ `edit-site-patterns__field-sync-status-${ syncStatus }` }\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\tSYNC_FILTERS.find( ( { value } ) => value === syncStatus )\n\t\t\t\t\t\t.label\n\t\t\t\t}\n\t\t\t</span>\n\t\t);\n\t},\n\telements: SYNC_FILTERS,\n\tfilterBy: {\n\t\toperators: [ OPERATOR_IS ],\n\t\tisPrimary: true,\n\t},\n\tenableSorting: false,\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 templatePartAuthorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text,\n\trender: AuthorField,\n\tfilterBy: {\n\t\tisPrimary: true,\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAIA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,aAA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,EAAC,MAAM;IAACE,OAAO,EAAG,CAAG;IAAAnD,QAAA,GACnCwF,QAAQ,iBACT,IAAAhG,WAAA,CAAAS,GAAA;MACCC,SAAS,EAAG,IAAAwF,aAAI,EAAE,qCAAqC,EAAE;QACxD,WAAW,EAAEL;MACd,CAAE,CAAG;MAAArF,QAAA,eAEL,IAAAR,WAAA,CAAAS,GAAA;QACC0F,MAAM,EAAGA,CAAA,KAAML,gBAAgB,CAAE,IAAK,CAAG;QACzCM,GAAG,EAAC,EAAE;QACNC,GAAG,EAAGL;MAAU,CAChB;IAAC,CACE,CACL,EACC,CAAEA,QAAQ,iBACX,IAAAhG,WAAA,CAAAS,GAAA;MAAKC,SAAS,EAAC,mCAAmC;MAAAF,QAAA,eACjD,IAAAR,WAAA,CAAAS,GAAA,EAAClB,MAAA,CAAA+E,IAAI;QAACC,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACD,IAAAvE,WAAA,CAAAS,GAAA;MAAMC,SAAS,EAAC,mCAAmC;MAAAF,QAAA,EAAG6D;IAAI,CAAQ,CAAC;EAAA,CAC5D,CAAC;AAEX;AAEO,MAAMiC,uBAAuB,GAAArD,OAAA,CAAAqD,uBAAA,GAAG;EACtCpD,KAAK,EAAE,IAAAP,QAAE,EAAE,QAAS,CAAC;EACrBb,EAAE,EAAE,QAAQ;EACZ6C,QAAQ,EAAEA,CAAE;IAAEtE;EAAK,CAAC,KAAMA,IAAI,CAACkG,WAAW;EAC1CpD,MAAM,EAAEyC,WAAW;EACnBJ,QAAQ,EAAE;IACTG,SAAS,EAAE;EACZ;AACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_blockEditor","_icons","_blocks","_htmlEntities","_constants","_lockUnlock","_link","_hooks","_searchItems","_jsxRuntime","useGlobalStyle","unlock","blockEditorPrivateApis","PreviewWrapper","item","onClick","ariaDescribedBy","children","jsx","className","type","PATTERN_TYPES","theme","undefined","defaultGetTitle","PreviewField","descriptionId","useId","description","excerpt","raw","isUserPattern","user","isTemplatePart","TEMPLATE_PART_POST_TYPE","backgroundColor","useLink","postType","postId","id","name","canvas","blocks","useMemo","_item$blocks","parse","content","__unstableSkipMigrationLogs","isEmpty","length","jsxs","style","__","BlockPreview","Async","viewportWidth","hidden","previewField","exports","label","render","enableSorting","TitleField","title","decodeEntities","__experimentalHStack","alignment","justify","spacing","FlexBlock","Button","__next40pxDefaultSize","variant","tabIndex","Tooltip","placement","text","Icon","icon","lockSmall","size","titleField","getValue","enableHiding","SYNC_FILTERS","value","PATTERN_SYNC_TYPES","full","_x","unsynced","patternStatusField","syncStatus","wp_pattern_sync_status","find","elements","filterBy","operators","OPERATOR_IS","isPrimary","AuthorField","isImageLoaded","setIsImageLoaded","useState","imageUrl","useAddedBy","clsx","onLoad","alt","src","templatePartAuthorField","author_text"],"sources":["@wordpress/edit-site/src/components/page-patterns/fields.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tButton,\n\tTooltip,\n\tFlexBlock,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useMemo, useId } from '@wordpress/element';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { Icon, lockSmall } from '@wordpress/icons';\nimport { parse } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tPATTERN_TYPES,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_SYNC_TYPES,\n\tOPERATOR_IS,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useLink } from '../routes/link';\nimport { useAddedBy } from '../page-templates/hooks';\nimport { defaultGetTitle } from './search-items';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nfunction PreviewWrapper( { item, onClick, ariaDescribedBy, children } ) {\n\treturn (\n\t\t<button\n\t\t\tclassName=\"page-patterns-preview-field__button\"\n\t\t\ttype=\"button\"\n\t\t\tonClick={ item.type !== PATTERN_TYPES.theme ? onClick : undefined }\n\t\t\taria-label={ defaultGetTitle( item ) }\n\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\taria-disabled={ item.type === PATTERN_TYPES.theme }\n\t\t>\n\t\t\t{ children }\n\t\t</button>\n\t);\n}\n\nfunction PreviewField( { item } ) {\n\tconst descriptionId = useId();\n\tconst description = item.description || item?.excerpt?.raw;\n\tconst isUserPattern = item.type === PATTERN_TYPES.user;\n\tconst isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: isUserPattern || isTemplatePart ? item.id : item.name,\n\t\tcanvas: 'edit',\n\t} );\n\tconst blocks = useMemo( () => {\n\t\treturn (\n\t\t\titem.blocks ??\n\t\t\tparse( item.content.raw, {\n\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t} )\n\t\t);\n\t}, [ item?.content?.raw, item.blocks ] );\n\tconst isEmpty = ! blocks?.length;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"page-patterns-preview-field\"\n\t\t\tstyle={ { backgroundColor } }\n\t\t>\n\t\t\t<PreviewWrapper\n\t\t\t\titem={ item }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tariaDescribedBy={ !! description ? descriptionId : undefined }\n\t\t\t>\n\t\t\t\t{ isEmpty && isTemplatePart && __( 'Empty template part' ) }\n\t\t\t\t{ isEmpty && ! isTemplatePart && __( 'Empty pattern' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tviewportWidth={ item.viewportWidth }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</PreviewWrapper>\n\t\t\t{ !! description && (\n\t\t\t\t<div hidden id={ descriptionId }>\n\t\t\t\t\t{ description }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nfunction TitleField( { item } ) {\n\tconst isUserPattern = item.type === PATTERN_TYPES.user;\n\tconst isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: isUserPattern || isTemplatePart ? item.id : item.name,\n\t\tcanvas: 'edit',\n\t} );\n\tconst title = decodeEntities( defaultGetTitle( item ) );\n\treturn (\n\t\t<HStack alignment=\"center\" justify=\"flex-start\" spacing={ 2 }>\n\t\t\t<FlexBlock className=\"edit-site-patterns__pattern-title\">\n\t\t\t\t{ item.type === PATTERN_TYPES.theme ? (\n\t\t\t\t\ttitle\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\t// Required for the grid's roving tab index system.\n\t\t\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</FlexBlock>\n\t\t\t{ item.type === PATTERN_TYPES.theme && (\n\t\t\t\t<Tooltip\n\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\ttext={ __( 'This pattern cannot be edited.' ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"edit-site-patterns__pattern-lock-icon\"\n\t\t\t\t\t\ticon={ lockSmall }\n\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t</Tooltip>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n\nexport const titleField = {\n\tlabel: __( 'Title' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => item.title?.raw || item.title,\n\trender: TitleField,\n\tenableHiding: false,\n};\n\nconst SYNC_FILTERS = [\n\t{\n\t\tvalue: PATTERN_SYNC_TYPES.full,\n\t\tlabel: _x( 'Synced', 'pattern (singular)' ),\n\t\tdescription: __( 'Patterns that are kept in sync across the site.' ),\n\t},\n\t{\n\t\tvalue: PATTERN_SYNC_TYPES.unsynced,\n\t\tlabel: _x( 'Not synced', 'pattern (singular)' ),\n\t\tdescription: __(\n\t\t\t'Patterns that can be changed freely without affecting the site.'\n\t\t),\n\t},\n];\n\nexport const patternStatusField = {\n\tlabel: __( 'Sync status' ),\n\tid: 'sync-status',\n\trender: ( { item } ) => {\n\t\tconst syncStatus =\n\t\t\t'wp_pattern_sync_status' in item\n\t\t\t\t? item.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full\n\t\t\t\t: PATTERN_SYNC_TYPES.unsynced;\n\t\t// User patterns can have their sync statuses checked directly.\n\t\t// Non-user patterns are all unsynced for the time being.\n\t\treturn (\n\t\t\t<span\n\t\t\t\tclassName={ `edit-site-patterns__field-sync-status-${ syncStatus }` }\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\tSYNC_FILTERS.find( ( { value } ) => value === syncStatus )\n\t\t\t\t\t\t.label\n\t\t\t\t}\n\t\t\t</span>\n\t\t);\n\t},\n\telements: SYNC_FILTERS,\n\tfilterBy: {\n\t\toperators: [ OPERATOR_IS ],\n\t\tisPrimary: true,\n\t},\n\tenableSorting: false,\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 templatePartAuthorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text,\n\trender: AuthorField,\n\tfilterBy: {\n\t\tisPrimary: true,\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAIA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAKA,IAAAQ,UAAA,GAAAR,OAAA;AAMA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,YAAA,GAAAZ,OAAA;AAAiD,IAAAa,WAAA,GAAAb,OAAA;AApCjD;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAYA,MAAM;EAAEc;AAAe,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAE3D,SAASC,cAAcA,CAAE;EAA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AAC,mCAAmC;MAAAF,QAAA,eACjD,IAAAR,WAAA,CAAAS,GAAA,EAACjB,MAAA,CAAA4E,IAAI;QAACC,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACD,IAAArE,WAAA,CAAAS,GAAA;MAAMC,SAAS,EAAC,mCAAmC;MAAAF,QAAA,EAAG2D;IAAI,CAAQ,CAAC;EAAA,CAC5D,CAAC;AAEX;AAEO,MAAMiC,uBAAuB,GAAAnD,OAAA,CAAAmD,uBAAA,GAAG;EACtClD,KAAK,EAAE,IAAAP,QAAE,EAAE,QAAS,CAAC;EACrBb,EAAE,EAAE,QAAQ;EACZ2C,QAAQ,EAAEA,CAAE;IAAEpE;EAAK,CAAC,KAAMA,IAAI,CAACgG,WAAW;EAC1ClD,MAAM,EAAEuC,WAAW;EACnBJ,QAAQ,EAAE;IACTG,SAAS,EAAE;EACZ;AACD,CAAC","ignoreList":[]}
|
|
@@ -13,7 +13,6 @@ var _htmlEntities = require("@wordpress/html-entities");
|
|
|
13
13
|
var _blocks = require("@wordpress/blocks");
|
|
14
14
|
var _blockEditor = require("@wordpress/block-editor");
|
|
15
15
|
var _editor = require("@wordpress/editor");
|
|
16
|
-
var _async = require("../async");
|
|
17
16
|
var _link = _interopRequireWildcard(require("../routes/link"));
|
|
18
17
|
var _hooks = require("./hooks");
|
|
19
18
|
var _usePatternSettings = _interopRequireDefault(require("../page-patterns/use-pattern-settings"));
|
|
@@ -72,7 +71,7 @@ function PreviewField({
|
|
|
72
71
|
type: "button",
|
|
73
72
|
onClick: onClick,
|
|
74
73
|
"aria-label": item.title?.rendered || item.title,
|
|
75
|
-
children: [isEmpty && (0, _i18n.__)('Empty template'), !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
74
|
+
children: [isEmpty && (0, _i18n.__)('Empty template'), !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview.Async, {
|
|
76
75
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview, {
|
|
77
76
|
blocks: blocks
|
|
78
77
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_htmlEntities","_blocks","_blockEditor","_editor","_async","_link","_interopRequireWildcard","_hooks","_usePatternSettings","_lockUnlock","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useGlobalStyle","unlock","blockEditorPrivateApis","PreviewField","item","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","onClick","useLink","postId","id","postType","type","canvas","isEmpty","length","jsx","EditorProvider","post","children","className","style","jsxs","title","rendered","__","Async","BlockPreview","previewField","exports","label","render","enableSorting","TitleField","linkProps","params","decodeEntities","titleField","getValue","enableHiding","enableGlobalSearch","descriptionField","description","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","__experimentalHStack","alignment","spacing","clsx","onLoad","alt","src","Icon","authorField","author_text"],"sources":["@wordpress/edit-site/src/components/page-templates/fields.js"],"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 { Async } from '../async';\nimport { default as Link, useLink } from '../routes/link';\nimport { useAddedBy } from './hooks';\n\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\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\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<button\n\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t\t<Async>\n\t\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t\t</Async>\n\t\t\t\t\t) }\n\t\t\t\t</button>\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\nfunction TitleField( { item } ) {\n\tconst linkProps = {\n\t\tparams: {\n\t\t\tpostId: item.id,\n\t\t\tpostType: item.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t};\n\treturn (\n\t\t<Link { ...linkProps }>\n\t\t\t{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) }\n\t\t</Link>\n\t);\n}\n\nexport const titleField = {\n\tlabel: __( 'Template' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => item.title?.rendered,\n\trender: TitleField,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: ( { item } ) => {\n\t\treturn (\n\t\t\titem.description && (\n\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t</span>\n\t\t\t)\n\t\t);\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"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA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9C,WAAA,CAAA2C,GAAA;QACCuC,MAAM,EAAGA,CAAA,KAAMV,gBAAgB,CAAE,IAAK,CAAG;QACzCW,GAAG,EAAC,EAAE;QACNC,GAAG,EAAGR;MAAU,CAChB;IAAC,CACE,CACL,EACC,CAAEA,QAAQ,iBACX,IAAA5E,WAAA,CAAA2C,GAAA;MAAKI,SAAS,EAAC,mCAAmC;MAAAD,QAAA,eACjD,IAAA9C,WAAA,CAAA2C,GAAA,EAACxD,WAAA,CAAAkG,IAAI;QAACV,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACD,IAAA3E,WAAA,CAAA2C,GAAA;MAAMI,SAAS,EAAC,mCAAmC;MAAAD,QAAA,EAAG4B;IAAI,CAAQ,CAAC;EAAA,CAC5D,CAAC;AAEX;AAEO,MAAMY,WAAW,GAAA9B,OAAA,CAAA8B,WAAA,GAAG;EAC1B7B,KAAK,EAAE,IAAAL,QAAE,EAAE,QAAS,CAAC;EACrBf,EAAE,EAAE,QAAQ;EACZ4B,QAAQ,EAAEA,CAAE;IAAExC;EAAK,CAAC,KAAMA,IAAI,CAAC8D,WAAW;EAC1C7B,MAAM,EAAEY;AACT,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_htmlEntities","_blocks","_blockEditor","_editor","_link","_interopRequireWildcard","_hooks","_usePatternSettings","_lockUnlock","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useGlobalStyle","unlock","blockEditorPrivateApis","PreviewField","item","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","onClick","useLink","postId","id","postType","type","canvas","isEmpty","length","jsx","EditorProvider","post","children","className","style","jsxs","title","rendered","__","BlockPreview","Async","previewField","exports","label","render","enableSorting","TitleField","linkProps","params","decodeEntities","titleField","getValue","enableHiding","enableGlobalSearch","descriptionField","description","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","__experimentalHStack","alignment","spacing","clsx","onLoad","alt","src","Icon","authorField","author_text"],"sources":["@wordpress/edit-site/src/components/page-templates/fields.js"],"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 { default as Link, useLink } from '../routes/link';\nimport { useAddedBy } from './hooks';\n\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\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\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<button\n\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t\t) }\n\t\t\t\t</button>\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\nfunction TitleField( { item } ) {\n\tconst linkProps = {\n\t\tparams: {\n\t\t\tpostId: item.id,\n\t\t\tpostType: item.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t};\n\treturn (\n\t\t<Link { ...linkProps }>\n\t\t\t{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) }\n\t\t</Link>\n\t);\n}\n\nexport const titleField = {\n\tlabel: __( 'Template' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => item.title?.rendered,\n\trender: TitleField,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: ( { item } ) => {\n\t\treturn (\n\t\t\titem.description && (\n\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t</span>\n\t\t\t)\n\t\t);\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"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAIA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,KAAA,GAAAC,uBAAA,CAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAEA,IAAAW,mBAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAA2C,IAAAa,WAAA,GAAAb,OAAA;AAAA,SAAAc,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,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CAAC;EACrBf,EAAE,EAAE,QAAQ;EACZ4B,QAAQ,EAAEA,CAAE;IAAExC;EAAK,CAAC,KAAMA,IAAI,CAAC8D,WAAW;EAC1C7B,MAAM,EAAEY;AACT,CAAC","ignoreList":[]}
|
|
@@ -32,6 +32,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
32
32
|
const {
|
|
33
33
|
PostCardPanel
|
|
34
34
|
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
35
|
+
const fieldsWithBulkEditSupport = ['title', 'status', 'date', 'author', 'comment_status'];
|
|
35
36
|
function PostEditForm({
|
|
36
37
|
postType,
|
|
37
38
|
postId
|
|
@@ -60,11 +61,19 @@ function PostEditForm({
|
|
|
60
61
|
}
|
|
61
62
|
return field;
|
|
62
63
|
}), [_fields]);
|
|
63
|
-
const form = {
|
|
64
|
+
const form = (0, _element.useMemo)(() => ({
|
|
64
65
|
type: 'panel',
|
|
65
|
-
fields: ['featured_media', 'title', 'author', 'date', 'slug', 'parent', 'comment_status']
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
fields: ['featured_media', 'title', 'status_and_visibility', 'author', 'date', 'slug', 'parent', 'comment_status'].filter(field => ids.length === 1 || fieldsWithBulkEditSupport.includes(field)),
|
|
67
|
+
combinedFields: [{
|
|
68
|
+
id: 'status_and_visibility',
|
|
69
|
+
label: (0, _i18n.__)('Status & Visibility'),
|
|
70
|
+
children: ['status', 'password'],
|
|
71
|
+
direction: 'vertical',
|
|
72
|
+
render: ({
|
|
73
|
+
item
|
|
74
|
+
}) => item.status
|
|
75
|
+
}]
|
|
76
|
+
}), [ids]);
|
|
68
77
|
const onChange = edits => {
|
|
69
78
|
for (const id of ids) {
|
|
70
79
|
if (edits.status && edits.status !== 'future' && record?.status === 'future' && new Date(record.date) > new Date()) {
|
|
@@ -93,10 +102,7 @@ function PostEditForm({
|
|
|
93
102
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviews.DataForm, {
|
|
94
103
|
data: ids.length === 1 ? record : multiEdits,
|
|
95
104
|
fields: fields,
|
|
96
|
-
form:
|
|
97
|
-
...form,
|
|
98
|
-
fields: form.fields.filter(field => fieldsWithBulkEditSupport.includes(field))
|
|
99
|
-
},
|
|
105
|
+
form: form,
|
|
100
106
|
onChange: onChange
|
|
101
107
|
})]
|
|
102
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_dataviews","_data","_coreData","_components","_element","_editor","_page","_postFields","_lockUnlock","_jsxRuntime","PostCardPanel","unlock","editorPrivateApis","PostEditForm","postType","postId","ids","useMemo","split","record","useSelect","select","length","coreDataStore","getEditedEntityRecord","multiEdits","setMultiEdits","useState","editEntityRecord","useDispatch","fields","_fields","usePostFields","map","field","id","elements","filter","element","value","form","type","
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_dataviews","_data","_coreData","_components","_element","_editor","_page","_postFields","_lockUnlock","_jsxRuntime","PostCardPanel","unlock","editorPrivateApis","fieldsWithBulkEditSupport","PostEditForm","postType","postId","ids","useMemo","split","record","useSelect","select","length","coreDataStore","getEditedEntityRecord","multiEdits","setMultiEdits","useState","editEntityRecord","useDispatch","fields","_fields","usePostFields","map","field","id","elements","filter","element","value","form","type","includes","combinedFields","label","__","children","direction","render","item","status","onChange","edits","Date","date","password","prev","useEffect","jsxs","__experimentalVStack","spacing","jsx","DataForm","data","PostEdit","default","className","clsx"],"sources":["@wordpress/edit-site/src/components/post-edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport usePostFields from '../post-fields';\nimport { unlock } from '../../lock-unlock';\n\nconst { PostCardPanel } = unlock( editorPrivateApis );\n\nconst fieldsWithBulkEditSupport = [\n\t'title',\n\t'status',\n\t'date',\n\t'author',\n\t'comment_status',\n];\n\nfunction PostEditForm( { postType, postId } ) {\n\tconst ids = useMemo( () => postId.split( ',' ), [ postId ] );\n\tconst { record } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\trecord:\n\t\t\t\t\tids.length === 1\n\t\t\t\t\t\t? select( coreDataStore ).getEditedEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tids[ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, ids ]\n\t);\n\tconst [ multiEdits, setMultiEdits ] = useState( {} );\n\tconst { editEntityRecord } = useDispatch( coreDataStore );\n\tconst { fields: _fields } = usePostFields();\n\tconst fields = useMemo(\n\t\t() =>\n\t\t\t_fields?.map( ( field ) => {\n\t\t\t\tif ( field.id === 'status' ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...field,\n\t\t\t\t\t\telements: field.elements.filter(\n\t\t\t\t\t\t\t( element ) => element.value !== 'trash'\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn field;\n\t\t\t} ),\n\t\t[ _fields ]\n\t);\n\n\tconst form = useMemo(\n\t\t() => ( {\n\t\t\ttype: 'panel',\n\t\t\tfields: [\n\t\t\t\t'featured_media',\n\t\t\t\t'title',\n\t\t\t\t'status_and_visibility',\n\t\t\t\t'author',\n\t\t\t\t'date',\n\t\t\t\t'slug',\n\t\t\t\t'parent',\n\t\t\t\t'comment_status',\n\t\t\t].filter(\n\t\t\t\t( field ) =>\n\t\t\t\t\tids.length === 1 ||\n\t\t\t\t\tfieldsWithBulkEditSupport.includes( field )\n\t\t\t),\n\t\t\tcombinedFields: [\n\t\t\t\t{\n\t\t\t\t\tid: 'status_and_visibility',\n\t\t\t\t\tlabel: __( 'Status & Visibility' ),\n\t\t\t\t\tchildren: [ 'status', 'password' ],\n\t\t\t\t\tdirection: 'vertical',\n\t\t\t\t\trender: ( { item } ) => item.status,\n\t\t\t\t},\n\t\t\t],\n\t\t} ),\n\t\t[ ids ]\n\t);\n\tconst onChange = ( edits ) => {\n\t\tfor ( const id of ids ) {\n\t\t\tif (\n\t\t\t\tedits.status &&\n\t\t\t\tedits.status !== 'future' &&\n\t\t\t\trecord?.status === 'future' &&\n\t\t\t\tnew Date( record.date ) > new Date()\n\t\t\t) {\n\t\t\t\tedits.date = null;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tedits.status &&\n\t\t\t\tedits.status === 'private' &&\n\t\t\t\trecord.password\n\t\t\t) {\n\t\t\t\tedits.password = '';\n\t\t\t}\n\t\t\teditEntityRecord( 'postType', postType, id, edits );\n\t\t\tif ( ids.length > 1 ) {\n\t\t\t\tsetMultiEdits( ( prev ) => ( {\n\t\t\t\t\t...prev,\n\t\t\t\t\t...edits,\n\t\t\t\t} ) );\n\t\t\t}\n\t\t}\n\t};\n\tuseEffect( () => {\n\t\tsetMultiEdits( {} );\n\t}, [ ids ] );\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t{ ids.length === 1 && (\n\t\t\t\t<PostCardPanel postType={ postType } postId={ ids[ 0 ] } />\n\t\t\t) }\n\t\t\t<DataForm\n\t\t\t\tdata={ ids.length === 1 ? record : multiEdits }\n\t\t\t\tfields={ fields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n\nexport function PostEdit( { postType, postId } ) {\n\treturn (\n\t\t<Page\n\t\t\tclassName={ clsx( 'edit-site-post-edit', {\n\t\t\t\t'is-empty': ! postId,\n\t\t\t} ) }\n\t\t\tlabel={ __( 'Post Edit' ) }\n\t\t>\n\t\t\t{ postId && (\n\t\t\t\t<PostEditForm postType={ postType } postId={ postId } />\n\t\t\t) }\n\t\t\t{ ! postId && <p>{ __( 'Select a page to edit' ) }</p> }\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,KAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,WAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAA2C,IAAAW,WAAA,GAAAX,OAAA;AArB3C;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAKA,MAAM;EAAEY;AAAc,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAErD,MAAMC,yBAAyB,GAAG,CACjC,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,gBAAgB,CAChB;AAED,SAASC,YAAYA,CAAE;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC7C,MAAMC,GAAG,GAAG,IAAAC,gBAAO,EAAE,MAAMF,MAAM,CAACG,KAAK,CAAE,GAAI,CAAC,EAAE,CAAEH,MAAM,CAAG,CAAC;EAC5D,MAAM;IAAEI;EAAO,CAAC,GAAG,IAAAC,eAAS,EACzBC,MAAM,IAAM;IACb,OAAO;MACNF,MAAM,EACLH,GAAG,CAACM,MAAM,KAAK,CAAC,GACbD,MAAM,CAAEE,eAAc,CAAC,CAACC,qBAAqB,CAC7C,UAAU,EACVV,QAAQ,EACRE,GAAG,CAAE,CAAC,CACN,CAAC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IAAI,EAAG/C,GAAG,CAACM,MAAM,KAAK,CAAC,GAAGH,MAAM,GAAGM,UAAY;MAC/CK,MAAM,EAAGA,MAAQ;MACjBU,IAAI,EAAGA,IAAM;MACbW,QAAQ,EAAGA;IAAU,CACrB,CAAC;EAAA,CACK,CAAC;AAEX;AAEO,SAASa,QAAQA,CAAE;EAAElD,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAChD,oBACC,IAAAP,WAAA,CAAAkD,IAAA,EAACrD,KAAA,CAAA4D,OAAI;IACJC,SAAS,EAAG,IAAAC,aAAI,EAAE,qBAAqB,EAAE;MACxC,UAAU,EAAE,CAAEpD;IACf,CAAE,CAAG;IACL6B,KAAK,EAAG,IAAAC,QAAE,EAAE,WAAY,CAAG;IAAAC,QAAA,GAEzB/B,MAAM,iBACP,IAAAP,WAAA,CAAAqD,GAAA,EAAChD,YAAY;MAACC,QAAQ,EAAGA,QAAU;MAACC,MAAM,EAAGA;IAAQ,CAAE,CACvD,EACC,CAAEA,MAAM,iBAAI,IAAAP,WAAA,CAAAqD,GAAA;MAAAf,QAAA,EAAK,IAAAD,QAAE,EAAE,uBAAwB;IAAC,CAAK,CAAC;EAAA,CACjD,CAAC;AAET","ignoreList":[]}
|
|
@@ -7,16 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
11
10
|
var _fields = require("@wordpress/fields");
|
|
12
11
|
var _element = require("@wordpress/element");
|
|
13
|
-
var _date = require("@wordpress/date");
|
|
14
12
|
var _icons = require("@wordpress/icons");
|
|
15
13
|
var _components = require("@wordpress/components");
|
|
16
14
|
var _data = require("@wordpress/data");
|
|
17
15
|
var _coreData = require("@wordpress/core-data");
|
|
18
|
-
var _constants = require("../../utils/constants");
|
|
19
|
-
var _link = _interopRequireDefault(require("../routes/link"));
|
|
20
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
17
|
/**
|
|
22
18
|
* External dependencies
|
|
@@ -26,64 +22,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
26
22
|
* WordPress dependencies
|
|
27
23
|
*/
|
|
28
24
|
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
// See https://github.com/WordPress/gutenberg/issues/55886
|
|
34
|
-
// We do not support custom statutes at the moment.
|
|
35
|
-
const STATUSES = [{
|
|
36
|
-
value: 'draft',
|
|
37
|
-
label: (0, _i18n.__)('Draft'),
|
|
38
|
-
icon: _icons.drafts,
|
|
39
|
-
description: (0, _i18n.__)('Not ready to publish.')
|
|
40
|
-
}, {
|
|
41
|
-
value: 'future',
|
|
42
|
-
label: (0, _i18n.__)('Scheduled'),
|
|
43
|
-
icon: _icons.scheduled,
|
|
44
|
-
description: (0, _i18n.__)('Publish automatically on a chosen date.')
|
|
45
|
-
}, {
|
|
46
|
-
value: 'pending',
|
|
47
|
-
label: (0, _i18n.__)('Pending Review'),
|
|
48
|
-
icon: _icons.pending,
|
|
49
|
-
description: (0, _i18n.__)('Waiting for review before publishing.')
|
|
50
|
-
}, {
|
|
51
|
-
value: 'private',
|
|
52
|
-
label: (0, _i18n.__)('Private'),
|
|
53
|
-
icon: _icons.notAllowed,
|
|
54
|
-
description: (0, _i18n.__)('Only visible to site admins and editors.')
|
|
55
|
-
}, {
|
|
56
|
-
value: 'publish',
|
|
57
|
-
label: (0, _i18n.__)('Published'),
|
|
58
|
-
icon: _icons.published,
|
|
59
|
-
description: (0, _i18n.__)('Visible to everyone.')
|
|
60
|
-
}, {
|
|
61
|
-
value: 'trash',
|
|
62
|
-
label: (0, _i18n.__)('Trash'),
|
|
63
|
-
icon: _icons.trash
|
|
64
|
-
}];
|
|
65
|
-
const getFormattedDate = dateToDisplay => (0, _date.dateI18n)((0, _date.getSettings)().formats.datetimeAbbreviated, (0, _date.getDate)(dateToDisplay));
|
|
66
|
-
function PostStatusField({
|
|
67
|
-
item
|
|
68
|
-
}) {
|
|
69
|
-
const status = STATUSES.find(({
|
|
70
|
-
value
|
|
71
|
-
}) => value === item.status);
|
|
72
|
-
const label = status?.label || item.status;
|
|
73
|
-
const icon = status?.icon;
|
|
74
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
75
|
-
alignment: "left",
|
|
76
|
-
spacing: 0,
|
|
77
|
-
children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
78
|
-
className: "edit-site-post-list__status-icon",
|
|
79
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
80
|
-
icon: icon
|
|
81
|
-
})
|
|
82
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
83
|
-
children: label
|
|
84
|
-
})]
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
25
|
function PostAuthorField({
|
|
88
26
|
item
|
|
89
27
|
}) {
|
|
@@ -124,69 +62,14 @@ function PostAuthorField({
|
|
|
124
62
|
})]
|
|
125
63
|
});
|
|
126
64
|
}
|
|
127
|
-
function usePostFields(
|
|
65
|
+
function usePostFields() {
|
|
128
66
|
const {
|
|
129
67
|
records: authors,
|
|
130
68
|
isResolving: isLoadingAuthors
|
|
131
69
|
} = (0, _coreData.useEntityRecords)('root', 'user', {
|
|
132
70
|
per_page: -1
|
|
133
71
|
});
|
|
134
|
-
const {
|
|
135
|
-
frontPageId,
|
|
136
|
-
postsPageId
|
|
137
|
-
} = (0, _data.useSelect)(select => {
|
|
138
|
-
const {
|
|
139
|
-
getEntityRecord
|
|
140
|
-
} = select(_coreData.store);
|
|
141
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
142
|
-
return {
|
|
143
|
-
frontPageId: siteSettings?.page_on_front,
|
|
144
|
-
postsPageId: siteSettings?.page_for_posts
|
|
145
|
-
};
|
|
146
|
-
}, []);
|
|
147
|
-
const fields = (0, _element.useMemo)(() => [_fields.featuredImageField, {
|
|
148
|
-
label: (0, _i18n.__)('Title'),
|
|
149
|
-
id: 'title',
|
|
150
|
-
type: 'text',
|
|
151
|
-
getValue: ({
|
|
152
|
-
item
|
|
153
|
-
}) => typeof item.title === 'string' ? item.title : item.title?.raw,
|
|
154
|
-
render: ({
|
|
155
|
-
item
|
|
156
|
-
}) => {
|
|
157
|
-
const addLink = [_constants.LAYOUT_TABLE, _constants.LAYOUT_GRID].includes(viewType) && item.status !== 'trash';
|
|
158
|
-
const renderedTitle = typeof item.title === 'string' ? item.title : item.title?.rendered;
|
|
159
|
-
const title = addLink ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_link.default, {
|
|
160
|
-
params: {
|
|
161
|
-
postId: item.id,
|
|
162
|
-
postType: item.type,
|
|
163
|
-
canvas: 'edit'
|
|
164
|
-
},
|
|
165
|
-
children: (0, _htmlEntities.decodeEntities)(renderedTitle) || (0, _i18n.__)('(no title)')
|
|
166
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
167
|
-
children: (0, _htmlEntities.decodeEntities)(renderedTitle) || (0, _i18n.__)('(no title)')
|
|
168
|
-
});
|
|
169
|
-
let suffix = '';
|
|
170
|
-
if (item.id === frontPageId) {
|
|
171
|
-
suffix = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
172
|
-
className: "edit-site-post-list__title-badge",
|
|
173
|
-
children: (0, _i18n.__)('Homepage')
|
|
174
|
-
});
|
|
175
|
-
} else if (item.id === postsPageId) {
|
|
176
|
-
suffix = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
177
|
-
className: "edit-site-post-list__title-badge",
|
|
178
|
-
children: (0, _i18n.__)('Posts Page')
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
182
|
-
className: "edit-site-post-list__title",
|
|
183
|
-
alignment: "center",
|
|
184
|
-
justify: "flex-start",
|
|
185
|
-
children: [title, suffix]
|
|
186
|
-
});
|
|
187
|
-
},
|
|
188
|
-
enableHiding: false
|
|
189
|
-
}, {
|
|
72
|
+
const fields = (0, _element.useMemo)(() => [_fields.featuredImageField, _fields.titleField, {
|
|
190
73
|
label: (0, _i18n.__)('Author'),
|
|
191
74
|
id: 'author',
|
|
192
75
|
type: 'integer',
|
|
@@ -203,84 +86,7 @@ function usePostFields(viewType) {
|
|
|
203
86
|
const nameB = b._embedded?.author?.[0]?.name || '';
|
|
204
87
|
return direction === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
|
|
205
88
|
}
|
|
206
|
-
},
|
|
207
|
-
label: (0, _i18n.__)('Status'),
|
|
208
|
-
id: 'status',
|
|
209
|
-
type: 'text',
|
|
210
|
-
elements: STATUSES,
|
|
211
|
-
render: PostStatusField,
|
|
212
|
-
Edit: 'radio',
|
|
213
|
-
enableSorting: false,
|
|
214
|
-
filterBy: {
|
|
215
|
-
operators: [_constants.OPERATOR_IS_ANY]
|
|
216
|
-
}
|
|
217
|
-
}, {
|
|
218
|
-
label: (0, _i18n.__)('Date'),
|
|
219
|
-
id: 'date',
|
|
220
|
-
type: 'datetime',
|
|
221
|
-
render: ({
|
|
222
|
-
item
|
|
223
|
-
}) => {
|
|
224
|
-
const isDraftOrPrivate = ['draft', 'private'].includes(item.status);
|
|
225
|
-
if (isDraftOrPrivate) {
|
|
226
|
-
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation or modification date. */
|
|
227
|
-
(0, _i18n.__)('<span>Modified: <time>%s</time></span>'), getFormattedDate(item.date)), {
|
|
228
|
-
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
229
|
-
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
const isScheduled = item.status === 'future';
|
|
233
|
-
if (isScheduled) {
|
|
234
|
-
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation date */
|
|
235
|
-
(0, _i18n.__)('<span>Scheduled: <time>%s</time></span>'), getFormattedDate(item.date)), {
|
|
236
|
-
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
237
|
-
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
const isPublished = item.status === 'publish';
|
|
241
|
-
if (isPublished) {
|
|
242
|
-
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation time */
|
|
243
|
-
(0, _i18n.__)('<span>Published: <time>%s</time></span>'), getFormattedDate(item.date)), {
|
|
244
|
-
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
245
|
-
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Pending posts show the modified date if it's newer.
|
|
250
|
-
const dateToDisplay = (0, _date.getDate)(item.modified) > (0, _date.getDate)(item.date) ? item.modified : item.date;
|
|
251
|
-
const isPending = item.status === 'pending';
|
|
252
|
-
if (isPending) {
|
|
253
|
-
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation or modification date. */
|
|
254
|
-
(0, _i18n.__)('<span>Modified: <time>%s</time></span>'), getFormattedDate(dateToDisplay)), {
|
|
255
|
-
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
256
|
-
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Unknow status.
|
|
261
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {
|
|
262
|
-
children: getFormattedDate(item.date)
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}, _fields.slugField, _fields.parentField, {
|
|
266
|
-
id: 'comment_status',
|
|
267
|
-
label: (0, _i18n.__)('Discussion'),
|
|
268
|
-
type: 'text',
|
|
269
|
-
Edit: 'radio',
|
|
270
|
-
enableSorting: false,
|
|
271
|
-
filterBy: {
|
|
272
|
-
operators: []
|
|
273
|
-
},
|
|
274
|
-
elements: [{
|
|
275
|
-
value: 'open',
|
|
276
|
-
label: (0, _i18n.__)('Open'),
|
|
277
|
-
description: (0, _i18n.__)('Visitors can add new comments and replies.')
|
|
278
|
-
}, {
|
|
279
|
-
value: 'closed',
|
|
280
|
-
label: (0, _i18n.__)('Closed'),
|
|
281
|
-
description: (0, _i18n.__)('Visitors cannot add new comments or replies. Existing comments remain visible.')
|
|
282
|
-
}]
|
|
283
|
-
}], [authors, viewType, frontPageId, postsPageId]);
|
|
89
|
+
}, _fields.statusField, _fields.dateField, _fields.slugField, _fields.parentField, _fields.commentStatusField, _fields.passwordField], [authors]);
|
|
284
90
|
return {
|
|
285
91
|
isLoading: isLoadingAuthors,
|
|
286
92
|
fields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_htmlEntities","_fields","_element","_date","_icons","_components","_data","_coreData","_constants","_link","_jsxRuntime","STATUSES","value","label","__","icon","drafts","description","scheduled","pending","notAllowed","published","trash","getFormattedDate","dateToDisplay","dateI18n","getSettings","formats","datetimeAbbreviated","getDate","PostStatusField","item","status","find","jsxs","__experimentalHStack","alignment","spacing","children","jsx","className","Icon","PostAuthorField","text","imageUrl","useSelect","select","getUser","coreStore","user","author","avatar_urls","name","isImageLoaded","setIsImageLoaded","useState","clsx","onLoad","alt","src","authorIcon","usePostFields","viewType","records","authors","isResolving","isLoadingAuthors","useEntityRecords","per_page","frontPageId","postsPageId","getEntityRecord","siteSettings","page_on_front","page_for_posts","fields","useMemo","featuredImageField","id","type","getValue","title","raw","render","addLink","LAYOUT_TABLE","LAYOUT_GRID","includes","renderedTitle","rendered","default","params","postId","postType","canvas","decodeEntities","suffix","justify","enableHiding","elements","map","sort","a","b","direction","nameA","_embedded","nameB","localeCompare","Edit","enableSorting","filterBy","operators","OPERATOR_IS_ANY","isDraftOrPrivate","createInterpolateElement","sprintf","date","span","time","isScheduled","isPublished","modified","isPending","slugField","parentField","isLoading","_default","exports"],"sources":["@wordpress/edit-site/src/components/post-fields/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { featuredImageField, slugField, parentField } from '@wordpress/fields';\nimport {\n\tcreateInterpolateElement,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport {\n\ttrash,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n\tcommentAuthorAvatar as authorIcon,\n} from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\nimport { default as Link } from '../routes/link';\n\n// See https://github.com/WordPress/gutenberg/issues/55886\n// We do not support custom statutes at the moment.\nconst STATUSES = [\n\t{\n\t\tvalue: 'draft',\n\t\tlabel: __( 'Draft' ),\n\t\ticon: drafts,\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tvalue: 'future',\n\t\tlabel: __( 'Scheduled' ),\n\t\ticon: scheduled,\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tvalue: 'pending',\n\t\tlabel: __( 'Pending Review' ),\n\t\ticon: pending,\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tvalue: 'private',\n\t\tlabel: __( 'Private' ),\n\t\ticon: notAllowed,\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tvalue: 'publish',\n\t\tlabel: __( 'Published' ),\n\t\ticon: published,\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n\t{ value: 'trash', label: __( 'Trash' ), icon: trash },\n];\n\nconst getFormattedDate = ( dateToDisplay ) =>\n\tdateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( dateToDisplay )\n\t);\n\nfunction PostStatusField( { item } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-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>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction PostAuthorField( { item } ) {\n\tconst { text, imageUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\tconst user = getUser( item.author );\n\t\t\treturn {\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.name,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\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={ __( 'Author avatar' ) }\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={ authorIcon } />\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\nfunction usePostFields( viewType ) {\n\tconst { records: authors, isResolving: isLoadingAuthors } =\n\t\tuseEntityRecords( 'root', 'user', { per_page: -1 } );\n\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tfeaturedImageField,\n\t\t\t{\n\t\t\t\tlabel: __( 'Title' ),\n\t\t\t\tid: 'title',\n\t\t\t\ttype: 'text',\n\t\t\t\tgetValue: ( { item } ) =>\n\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t: item.title?.raw,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst addLink =\n\t\t\t\t\t\t[ LAYOUT_TABLE, LAYOUT_GRID ].includes( viewType ) &&\n\t\t\t\t\t\titem.status !== 'trash';\n\t\t\t\t\tconst renderedTitle =\n\t\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t\t: item.title?.rendered;\n\t\t\t\t\tconst title = addLink ? (\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( renderedTitle ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ decodeEntities( renderedTitle ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t);\n\n\t\t\t\t\tlet suffix = '';\n\t\t\t\t\tif ( item.id === frontPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Homepage' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( item.id === postsPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Posts Page' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tclassName=\"edit-site-post-list__title\"\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t{ suffix }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\ttype: 'integer',\n\t\t\t\telements:\n\t\t\t\t\tauthors?.map( ( { id, name } ) => ( {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t} ) ) || [],\n\t\t\t\trender: PostAuthorField,\n\t\t\t\tsort: ( a, b, direction ) => {\n\t\t\t\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\t\t\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\t\t\t\treturn direction === 'asc'\n\t\t\t\t\t\t? nameA.localeCompare( nameB )\n\t\t\t\t\t\t: nameB.localeCompare( nameA );\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Status' ),\n\t\t\t\tid: 'status',\n\t\t\t\ttype: 'text',\n\t\t\t\telements: STATUSES,\n\t\t\t\trender: PostStatusField,\n\t\t\t\tEdit: 'radio',\n\t\t\t\tenableSorting: false,\n\t\t\t\tfilterBy: {\n\t\t\t\t\toperators: [ OPERATOR_IS_ANY ],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Date' ),\n\t\t\t\tid: 'date',\n\t\t\t\ttype: 'datetime',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst isDraftOrPrivate = [ 'draft', 'private' ].includes(\n\t\t\t\t\t\titem.status\n\t\t\t\t\t);\n\t\t\t\t\tif ( isDraftOrPrivate ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isScheduled = item.status === 'future';\n\t\t\t\t\tif ( isScheduled ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t\t\t\t\t__( '<span>Scheduled: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isPublished = item.status === 'publish';\n\t\t\t\t\tif ( isPublished ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation time */\n\t\t\t\t\t\t\t\t__( '<span>Published: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Pending posts show the modified date if it's newer.\n\t\t\t\t\tconst dateToDisplay =\n\t\t\t\t\t\tgetDate( item.modified ) > getDate( item.date )\n\t\t\t\t\t\t\t? item.modified\n\t\t\t\t\t\t\t: item.date;\n\n\t\t\t\t\tconst isPending = item.status === 'pending';\n\t\t\t\t\tif ( isPending ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( dateToDisplay )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Unknow status.\n\t\t\t\t\treturn <time>{ getFormattedDate( item.date ) }</time>;\n\t\t\t\t},\n\t\t\t},\n\t\t\tslugField,\n\t\t\tparentField,\n\t\t\t{\n\t\t\t\tid: 'comment_status',\n\t\t\t\tlabel: __( 'Discussion' ),\n\t\t\t\ttype: 'text',\n\t\t\t\tEdit: 'radio',\n\t\t\t\tenableSorting: false,\n\t\t\t\tfilterBy: {\n\t\t\t\t\toperators: [],\n\t\t\t\t},\n\t\t\t\telements: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'open',\n\t\t\t\t\t\tlabel: __( 'Open' ),\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Visitors can add new comments and replies.'\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'closed',\n\t\t\t\t\t\tlabel: __( 'Closed' ),\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Visitors cannot add new comments or replies. Existing comments remain visible.'\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\t[ authors, viewType, frontPageId, postsPageId ]\n\t);\n\n\treturn {\n\t\tisLoading: isLoadingAuthors,\n\t\tfields,\n\t};\n}\n\nexport default usePostFields;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AASA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAKA,IAAAU,UAAA,GAAAV,OAAA;AAKA,IAAAW,KAAA,GAAAZ,sBAAA,CAAAC,OAAA;AAAiD,IAAAY,WAAA,GAAAZ,OAAA;AAtCjD;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAQA;AACA;AACA,MAAMa,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EACX;IACC/C,EAAE,EAAE,gBAAgB;IACpBjE,KAAK,EAAE,IAAAC,QAAE,EAAE,YAAa,CAAC;IACzBiE,IAAI,EAAE,MAAM;IACZ8B,IAAI,EAAE,OAAO;IACbC,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE;MACTC,SAAS,EAAE;IACZ,CAAC;IACDb,QAAQ,EAAE,CACT;MACCvF,KAAK,EAAE,MAAM;MACbC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;MACnBG,WAAW,EAAE,IAAAH,QAAE,EACd,4CACD;IACD,CAAC,EACD;MACCF,KAAK,EAAE,QAAQ;MACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;MACrBG,WAAW,EAAE,IAAAH,QAAE,EACd,gFACD;IACD,CAAC;EAEH,CAAC,CACD,EACD,CAAEkD,OAAO,EAAEF,QAAQ,EAAEO,WAAW,EAAEC,WAAW,CAC9C,CAAC;EAED,OAAO;IACNwD,SAAS,EAAE5D,gBAAgB;IAC3BS;EACD,CAAC;AACF;AAAC,IAAAoD,QAAA,GAAAC,OAAA,CAAAtC,OAAA,GAEc7B,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_fields","_element","_icons","_components","_data","_coreData","_jsxRuntime","PostAuthorField","item","text","imageUrl","useSelect","select","getUser","coreStore","user","author","avatar_urls","name","isImageLoaded","setIsImageLoaded","useState","jsxs","__experimentalHStack","alignment","spacing","children","jsx","className","clsx","onLoad","alt","__","src","Icon","icon","authorIcon","usePostFields","records","authors","isResolving","isLoadingAuthors","useEntityRecords","per_page","fields","useMemo","featuredImageField","titleField","label","id","type","elements","map","value","render","sort","a","b","direction","nameA","_embedded","nameB","localeCompare","statusField","dateField","slugField","parentField","commentStatusField","passwordField","isLoading","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/post-fields/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tfeaturedImageField,\n\tslugField,\n\tparentField,\n\tpasswordField,\n\tstatusField,\n\tcommentStatusField,\n\ttitleField,\n\tdateField,\n} from '@wordpress/fields';\nimport { useMemo, useState } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\n\nfunction PostAuthorField( { item } ) {\n\tconst { text, imageUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\tconst user = getUser( item.author );\n\t\t\treturn {\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.name,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\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={ __( 'Author avatar' ) }\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={ authorIcon } />\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\nfunction usePostFields() {\n\tconst { records: authors, isResolving: isLoadingAuthors } =\n\t\tuseEntityRecords( 'root', 'user', { per_page: -1 } );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tfeaturedImageField,\n\t\t\ttitleField,\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\ttype: 'integer',\n\t\t\t\telements:\n\t\t\t\t\tauthors?.map( ( { id, name } ) => ( {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t} ) ) || [],\n\t\t\t\trender: PostAuthorField,\n\t\t\t\tsort: ( a, b, direction ) => {\n\t\t\t\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\t\t\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\t\t\t\treturn direction === 'asc'\n\t\t\t\t\t\t? nameA.localeCompare( nameB )\n\t\t\t\t\t\t: nameB.localeCompare( nameA );\n\t\t\t\t},\n\t\t\t},\n\t\t\tstatusField,\n\t\t\tdateField,\n\t\t\tslugField,\n\t\t\tparentField,\n\t\t\tcommentStatusField,\n\t\t\tpasswordField,\n\t\t],\n\t\t[ authors ]\n\t);\n\n\treturn {\n\t\tisLoading: isLoadingAuthors,\n\t\tfields,\n\t};\n}\n\nexport default usePostFields;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAUA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAA4E,IAAAQ,WAAA,GAAAR,OAAA;AAvB5E;AACA;AACA;;AAGA;AACA;AACA;;AAkBA,SAASS,eAAeA,CAAE;EAAEC;AAAK,CAAC,EAAG;EACpC,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EACjCC,MAAM,IAAM;IACb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7 +207,7 @@ function PostList({
|
|
|
207
207
|
const {
|
|
208
208
|
isLoading: isLoadingFields,
|
|
209
209
|
fields: _fields
|
|
210
|
-
} = (0, _postFields.default)(
|
|
210
|
+
} = (0, _postFields.default)();
|
|
211
211
|
const fields = (0, _element.useMemo)(() => {
|
|
212
212
|
const activeViewFilters = getActiveViewFilters(defaultViews, activeView).map(({
|
|
213
213
|
field
|
|
@@ -352,6 +352,16 @@ function PostList({
|
|
|
352
352
|
onChangeView: setView,
|
|
353
353
|
selection: selection,
|
|
354
354
|
onChangeSelection: onChangeSelection,
|
|
355
|
+
isItemClickable: item => item.status !== 'trash',
|
|
356
|
+
onClickItem: ({
|
|
357
|
+
id
|
|
358
|
+
}) => {
|
|
359
|
+
history.push({
|
|
360
|
+
postId: id,
|
|
361
|
+
postType,
|
|
362
|
+
canvas: 'edit'
|
|
363
|
+
});
|
|
364
|
+
},
|
|
355
365
|
getItemId: getItemId,
|
|
356
366
|
defaultLayouts: _defaultViews.defaultLayouts,
|
|
357
367
|
header: window.__experimentalQuickEditDataViews && view.type !== _constants.LAYOUT_LIST && postType === 'page' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|