@wordpress/edit-site 6.0.3 → 6.0.5
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-page/index.js +7 -1
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +30 -16
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/editor/index.js +2 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/layout/index.js +5 -5
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +15 -10
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +38 -6
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +8 -2
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +10 -3
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/revisions/index.js +10 -7
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -4
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/store/private-actions.js +7 -2
- package/build/store/private-actions.js.map +1 -1
- package/build-module/components/add-new-page/index.js +8 -2
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +30 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/editor/index.js +2 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/layout/index.js +5 -5
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +15 -10
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +38 -6
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +8 -2
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +10 -3
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/revisions/index.js +10 -7
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +5 -5
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/store/private-actions.js +7 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +17 -25
- package/build-style/style.css +17 -25
- package/package.json +17 -17
- package/src/components/add-new-page/index.js +14 -1
- package/src/components/add-new-pattern/index.js +37 -23
- package/src/components/block-editor/style.scss +0 -11
- package/src/components/editor/index.js +2 -0
- package/src/components/layout/index.js +2 -3
- package/src/components/layout/router.js +23 -15
- package/src/components/page-pages/index.js +45 -11
- package/src/components/page-pages/style.scss +1 -1
- package/src/components/page-patterns/index.js +8 -2
- package/src/components/page-patterns/style.scss +1 -8
- package/src/components/page-templates/index.js +9 -2
- package/src/components/page-templates/style.scss +1 -6
- package/src/components/revisions/index.js +9 -1
- package/src/components/sidebar-dataviews/default-views.js +13 -5
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
- package/src/store/private-actions.js +7 -3
- package/src/style.scss +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_coreData","_htmlEntities","_blocks","_blockEditor","_dataviews","_router","_editor","_async","_page","_link","_interopRequireWildcard","_addNewTemplate","_hooks","_constants","_usePatternSettings","_lockUnlock","_dataviewsActions","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","usePostActions","unlock","editorPrivateApis","ExperimentalBlockEditorProvider","useGlobalStyle","blockEditorPrivateApis","useHistory","useLocation","routerPrivateApis","EMPTY_ARRAY","defaultConfigPerViewType","LAYOUT_TABLE","primaryField","LAYOUT_GRID","mediaField","columnFields","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","hiddenFields","layout","filters","Title","item","viewType","decodeEntities","title","rendered","__","linkProps","params","postId","id","postType","canvas","jsx","children","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","withIcon","jsxs","__experimentalHStack","alignment","spacing","className","clsx","onLoad","alt","src","Icon","Preview","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","onClick","useLink","isEmpty","length","style","Async","BlockPreview","PageTemplates","activeView","defaultView","usedType","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","records","isResolving","isLoadingData","useEntityRecords","TEMPLATE_POST_TYPE","per_page","history","onSelectionChange","useCallback","items","push","undefined","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","label","fields","header","render","minWidth","maxWidth","enableSorting","getValue","enableHiding","enableGlobalSearch","description","Fragment","__experimentalText","variant","VisuallyHidden","elements","width","data","paginationInfo","filterSortAndPaginate","postTypeActions","editAction","useEditPostAction","actions","onChangeView","newView","DataViews","isLoading"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { Async } from '../async';\nimport Page from '../page';\nimport { default as Link, useLink } from '../routes/link';\nimport AddNewTemplate from '../add-new-template';\nimport { useAddedBy } from './hooks';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\n\nconst { usePostActions } = unlock( editorPrivateApis );\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultConfigPerViewType = {\n\t[ LAYOUT_TABLE ]: {\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tmediaField: 'preview',\n\t\tprimaryField: 'title',\n\t\tcolumnFields: [ 'description' ],\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tprimaryField: 'title',\n\t\tmediaField: 'preview',\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\t// All fields are visible by default, so it's\n\t// better to keep track of the hidden ones.\n\thiddenFields: [ 'preview' ],\n\tlayout: defaultConfigPerViewType[ LAYOUT_GRID ],\n\tfilters: [],\n};\n\nfunction Title( { item, viewType } ) {\n\tif ( viewType === LAYOUT_LIST ) {\n\t\treturn decodeEntities( item.title?.rendered ) || __( '(no title)' );\n\t}\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\nfunction AuthorField( { item, viewType } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\tconst withIcon = viewType !== LAYOUT_LIST;\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 1 }>\n\t\t\t{ withIcon && 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{ withIcon && ! 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\nfunction Preview( { item, viewType } ) {\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<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName={ `page-templates-preview-field is-viewtype-${ viewType }` }\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ viewType === LAYOUT_LIST && ! isEmpty && (\n\t\t\t\t\t<Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</Async>\n\t\t\t\t) }\n\t\t\t\t{ viewType !== LAYOUT_LIST && (\n\t\t\t\t\t<button\n\t\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t\t\t<Async>\n\t\t\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t\t\t</Async>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nexport default function PageTemplates() {\n\tconst { params } = useLocation();\n\tconst { activeView = 'all', layout } = params;\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tlayout: defaultConfigPerViewType[ usedType ],\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ activeView ] );\n\n\tconst { records, isResolving: isLoadingData } = useEntityRecords(\n\t\t'postType',\n\t\tTEMPLATE_POST_TYPE,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst history = useHistory();\n\tconst onSelectionChange = useCallback(\n\t\t( items ) => {\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ].id : undefined,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history, params, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\theader: __( 'Preview' ),\n\t\t\t\tid: 'preview',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <Preview item={ item } viewType={ view.type } />;\n\t\t\t\t},\n\t\t\t\tminWidth: 120,\n\t\t\t\tmaxWidth: 120,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Template' ),\n\t\t\t\tid: 'title',\n\t\t\t\tgetValue: ( { item } ) => item.title?.rendered,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<Title item={ item } viewType={ view.type } />\n\t\t\t\t),\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tenableHiding: false,\n\t\t\t\tenableGlobalSearch: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Description' ),\n\t\t\t\tid: 'description',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn item.description ? (\n\t\t\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tview.type === LAYOUT_TABLE && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Text variant=\"muted\" aria-hidden=\"true\">\n\t\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'No description.' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tminWidth: 320,\n\t\t\t\tenableSorting: false,\n\t\t\t\tenableGlobalSearch: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\tgetValue: ( { item } ) => item.author_text,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <AuthorField viewType={ view.type } item={ item } />;\n\t\t\t\t},\n\t\t\t\telements: authors,\n\t\t\t\twidth: '1%',\n\t\t\t},\n\t\t],\n\t\t[ authors, view.type ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( TEMPLATE_POST_TYPE );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useCallback(\n\t\t( newView ) => {\n\t\t\tif ( newView.type !== view.type ) {\n\t\t\t\tnewView = {\n\t\t\t\t\t...newView,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...defaultConfigPerViewType[ newView.type ],\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\t\t},\n\t\t[ view.type, setView, history, params ]\n\t);\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t/>\n\t\t</Page>\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,SAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAIA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAA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OAAO,EAAE3D,MAAM,CACtC,CAAC;EAED,oBACC,IAAAzD,WAAA,CAAA8D,GAAA,EAACvE,KAAA,CAAAgB,OAAI;IACJsE,SAAS,EAAC,0BAA0B;IACpCxB,KAAK,EAAG,IAAAE,QAAE,EAAE,WAAY,CAAG;IAC3BqG,OAAO,eAAG,IAAA5J,WAAA,CAAA8D,GAAA,EAACpE,eAAA,CAAAa,OAAc,IAAE,CAAG;IAAAwD,QAAA,eAE9B,IAAA/D,WAAA,CAAA8D,GAAA,EAAC3E,UAAA,CAAA4K,SAAS;MACTR,cAAc,EAAGA,cAAgB;MACjCjB,MAAM,EAAGA,MAAQ;MACjBsB,OAAO,EAAGA,OAAS;MACnBN,IAAI,EAAGA,IAAM;MACbU,SAAS,EAAGhD,aAAe;MAC3BP,IAAI,EAAGA,IAAM;MACboD,YAAY,EAAGA,YAAc;MAC7BxC,iBAAiB,EAAGA;IAAmB,CACvC;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_coreData","_htmlEntities","_blocks","_blockEditor","_dataviews","_router","_editor","_async","_page","_link","_interopRequireWildcard","_addNewTemplate","_hooks","_constants","_usePatternSettings","_lockUnlock","_dataviewsActions","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","usePostActions","unlock","editorPrivateApis","ExperimentalBlockEditorProvider","useGlobalStyle","blockEditorPrivateApis","useHistory","useLocation","routerPrivateApis","EMPTY_ARRAY","defaultConfigPerViewType","LAYOUT_TABLE","primaryField","LAYOUT_GRID","mediaField","columnFields","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","hiddenFields","layout","filters","Title","item","viewType","decodeEntities","title","rendered","__","linkProps","params","postId","id","postType","canvas","jsx","children","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","withIcon","jsxs","__experimentalHStack","alignment","spacing","className","clsx","onLoad","alt","src","Icon","Preview","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","onClick","useLink","isEmpty","length","style","Async","BlockPreview","PageTemplates","activeView","selection","setSelection","defaultView","usedType","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","records","isResolving","isLoadingData","useEntityRecords","TEMPLATE_POST_TYPE","per_page","history","onSelectionChange","useCallback","items","push","undefined","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","label","fields","header","render","minWidth","maxWidth","enableSorting","getValue","enableHiding","enableGlobalSearch","description","Fragment","__experimentalText","variant","VisuallyHidden","elements","width","data","paginationInfo","filterSortAndPaginate","postTypeActions","context","editAction","useEditPostAction","actions","onChangeView","newView","DataViews","isLoading"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { Async } from '../async';\nimport Page from '../page';\nimport { default as Link, useLink } from '../routes/link';\nimport AddNewTemplate from '../add-new-template';\nimport { useAddedBy } from './hooks';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\n\nconst { usePostActions } = unlock( editorPrivateApis );\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultConfigPerViewType = {\n\t[ LAYOUT_TABLE ]: {\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tmediaField: 'preview',\n\t\tprimaryField: 'title',\n\t\tcolumnFields: [ 'description' ],\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tprimaryField: 'title',\n\t\tmediaField: 'preview',\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\t// All fields are visible by default, so it's\n\t// better to keep track of the hidden ones.\n\thiddenFields: [ 'preview' ],\n\tlayout: defaultConfigPerViewType[ LAYOUT_GRID ],\n\tfilters: [],\n};\n\nfunction Title( { item, viewType } ) {\n\tif ( viewType === LAYOUT_LIST ) {\n\t\treturn decodeEntities( item.title?.rendered ) || __( '(no title)' );\n\t}\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\nfunction AuthorField( { item, viewType } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\tconst withIcon = viewType !== LAYOUT_LIST;\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 1 }>\n\t\t\t{ withIcon && 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{ withIcon && ! 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\nfunction Preview( { item, viewType } ) {\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<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName={ `page-templates-preview-field is-viewtype-${ viewType }` }\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ viewType === LAYOUT_LIST && ! isEmpty && (\n\t\t\t\t\t<Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</Async>\n\t\t\t\t) }\n\t\t\t\t{ viewType !== LAYOUT_LIST && (\n\t\t\t\t\t<button\n\t\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t\t\t<Async>\n\t\t\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t\t\t</Async>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nexport default function PageTemplates() {\n\tconst { params } = useLocation();\n\tconst { activeView = 'all', layout, postId } = params;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tlayout: defaultConfigPerViewType[ usedType ],\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ activeView ] );\n\n\tconst { records, isResolving: isLoadingData } = useEntityRecords(\n\t\t'postType',\n\t\tTEMPLATE_POST_TYPE,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst history = useHistory();\n\tconst onSelectionChange = useCallback(\n\t\t( items ) => {\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ].id : undefined,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history, params, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\theader: __( 'Preview' ),\n\t\t\t\tid: 'preview',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <Preview item={ item } viewType={ view.type } />;\n\t\t\t\t},\n\t\t\t\tminWidth: 120,\n\t\t\t\tmaxWidth: 120,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Template' ),\n\t\t\t\tid: 'title',\n\t\t\t\tgetValue: ( { item } ) => item.title?.rendered,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<Title item={ item } viewType={ view.type } />\n\t\t\t\t),\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tenableHiding: false,\n\t\t\t\tenableGlobalSearch: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Description' ),\n\t\t\t\tid: 'description',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn item.description ? (\n\t\t\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tview.type === LAYOUT_TABLE && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Text variant=\"muted\" aria-hidden=\"true\">\n\t\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'No description.' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tminWidth: 320,\n\t\t\t\tenableSorting: false,\n\t\t\t\tenableGlobalSearch: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\tgetValue: ( { item } ) => item.author_text,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <AuthorField viewType={ view.type } item={ item } />;\n\t\t\t\t},\n\t\t\t\telements: authors,\n\t\t\t\twidth: '1%',\n\t\t\t},\n\t\t],\n\t\t[ authors, view.type ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useCallback(\n\t\t( newView ) => {\n\t\t\tif ( newView.type !== view.type ) {\n\t\t\t\tnewView = {\n\t\t\t\t\t...newView,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...defaultConfigPerViewType[ newView.type ],\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\t\t},\n\t\t[ view.type, setView, history, params ]\n\t);\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\tselection={ selection }\n\t\t\t\tsetSelection={ setSelection }\n\t\t\t/>\n\t\t</Page>\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,SAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAIA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,KAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,KAAA,GAAAC,uBAAA,CAAAd,OAAA;AACA,IA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AAO,EAAEU,OAAO,EAAE7D,MAAM,CACtC,CAAC;EAED,oBACC,IAAAzD,WAAA,CAAA8D,GAAA,EAACvE,KAAA,CAAAgB,OAAI;IACJsE,SAAS,EAAC,0BAA0B;IACpCxB,KAAK,EAAG,IAAAE,QAAE,EAAE,WAAY,CAAG;IAC3BwG,OAAO,eAAG,IAAA/J,WAAA,CAAA8D,GAAA,EAACpE,eAAA,CAAAa,OAAc,IAAE,CAAG;IAAAwD,QAAA,eAE9B,IAAA/D,WAAA,CAAA8D,GAAA,EAAC3E,UAAA,CAAA+K,SAAS;MACTT,cAAc,EAAGA,cAAgB;MACjCjB,MAAM,EAAGA,MAAQ;MACjBuB,OAAO,EAAGA,OAAS;MACnBP,IAAI,EAAGA,IAAM;MACbW,SAAS,EAAGjD,aAAe;MAC3BP,IAAI,EAAGA,IAAM;MACbqD,YAAY,EAAGA,YAAc;MAC7BzC,iBAAiB,EAAGA,iBAAmB;MACvClB,SAAS,EAAGA,SAAW;MACvBC,YAAY,EAAGA;IAAc,CAC7B;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
@@ -25,7 +25,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
25
|
const {
|
|
26
26
|
ExperimentalBlockEditorProvider,
|
|
27
27
|
GlobalStylesContext,
|
|
28
|
-
useGlobalStylesOutputWithConfig
|
|
28
|
+
useGlobalStylesOutputWithConfig,
|
|
29
|
+
__unstableBlockStyleVariationOverridesWithConfig
|
|
29
30
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
30
31
|
const {
|
|
31
32
|
mergeBaseAndUserConfigs
|
|
@@ -62,21 +63,23 @@ function Revisions({
|
|
|
62
63
|
className: "edit-site-revisions__iframe",
|
|
63
64
|
name: "revisions",
|
|
64
65
|
tabIndex: 0,
|
|
65
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
66
|
-
styles: editorStyles
|
|
67
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("style", {
|
|
66
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("style", {
|
|
68
67
|
children:
|
|
69
68
|
// Forming a "block formatting context" to prevent margin collapsing.
|
|
70
69
|
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
71
70
|
`.is-root-container { display: flow-root; }`
|
|
72
71
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Disabled, {
|
|
73
72
|
className: "edit-site-revisions__example-preview__content",
|
|
74
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ExperimentalBlockEditorProvider, {
|
|
75
74
|
value: renderedBlocksArray,
|
|
76
75
|
settings: settings,
|
|
77
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockList, {
|
|
76
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockList, {
|
|
78
77
|
renderAppender: false
|
|
79
|
-
})
|
|
78
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.__unstableEditorStyles, {
|
|
79
|
+
styles: editorStyles
|
|
80
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(__unstableBlockStyleVariationOverridesWithConfig, {
|
|
81
|
+
config: mergedConfig
|
|
82
|
+
})]
|
|
80
83
|
})
|
|
81
84
|
})]
|
|
82
85
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_blockEditor","_editor","_data","_element","_lockUnlock","_editorCanvasContainer","_interopRequireDefault","_jsxRuntime","ExperimentalBlockEditorProvider","GlobalStylesContext","useGlobalStylesOutputWithConfig","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","isObjectEmpty","object","Object","keys","length","Revisions","userConfig","blocks","base","baseConfig","useContext","mergedConfig","useMemo","renderedBlocksArray","Array","isArray","originalSettings","useSelect","select","blockEditorStore","getSettings","settings","__unstableIsPreviewMode","globalStyles","editorStyles","styles","jsx","default","title","__","closeButtonLabel","enableResizing","children","jsxs","__unstableIframe","className","name","tabIndex","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_blockEditor","_editor","_data","_element","_lockUnlock","_editorCanvasContainer","_interopRequireDefault","_jsxRuntime","ExperimentalBlockEditorProvider","GlobalStylesContext","useGlobalStylesOutputWithConfig","__unstableBlockStyleVariationOverridesWithConfig","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","isObjectEmpty","object","Object","keys","length","Revisions","userConfig","blocks","base","baseConfig","useContext","mergedConfig","useMemo","renderedBlocksArray","Array","isArray","originalSettings","useSelect","select","blockEditorStore","getSettings","settings","__unstableIsPreviewMode","globalStyles","editorStyles","styles","jsx","default","title","__","closeButtonLabel","enableResizing","children","jsxs","__unstableIframe","className","name","tabIndex","Disabled","value","BlockList","renderAppender","__unstableEditorStyles","config","_default","exports"],"sources":["@wordpress/edit-site/src/components/revisions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { unlock } from '../../lock-unlock';\nimport EditorCanvasContainer from '../editor-canvas-container';\n\nconst {\n\tExperimentalBlockEditorProvider,\n\tGlobalStylesContext,\n\tuseGlobalStylesOutputWithConfig,\n\t__unstableBlockStyleVariationOverridesWithConfig,\n} = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\nfunction Revisions( { userConfig, blocks } ) {\n\tconst { base: baseConfig } = useContext( GlobalStylesContext );\n\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! isObjectEmpty( userConfig ) && ! isObjectEmpty( baseConfig ) ) {\n\t\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t\t}\n\t\treturn {};\n\t}, [ baseConfig, userConfig ] );\n\n\tconst renderedBlocksArray = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\tconst [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );\n\n\tconst editorStyles =\n\t\t! isObjectEmpty( globalStyles ) && ! isObjectEmpty( userConfig )\n\t\t\t? globalStyles\n\t\t\t: settings.styles;\n\n\treturn (\n\t\t<EditorCanvasContainer\n\t\t\ttitle={ __( 'Revisions' ) }\n\t\t\tcloseButtonLabel={ __( 'Close revisions' ) }\n\t\t\tenableResizing\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tclassName=\"edit-site-revisions__iframe\"\n\t\t\t\tname=\"revisions\"\n\t\t\t\ttabIndex={ 0 }\n\t\t\t>\n\t\t\t\t<style>\n\t\t\t\t\t{\n\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t`.is-root-container { display: flow-root; }`\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t\t<Disabled className=\"edit-site-revisions__example-preview__content\">\n\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\tvalue={ renderedBlocksArray }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * Styles are printed inside the block editor provider,\n\t\t\t\t\t\t * so they can access any registered style overrides.\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t<EditorStyles styles={ editorStyles } />\n\t\t\t\t\t\t<__unstableBlockStyleVariationOverridesWithConfig\n\t\t\t\t\t\t\tconfig={ mergedConfig }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t</Disabled>\n\t\t\t</Iframe>\n\t\t</EditorCanvasContainer>\n\t);\n}\n\nexport default Revisions;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAOA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAMA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAC,sBAAA,CAAAR,OAAA;AAA+D,IAAAS,WAAA,GAAAT,OAAA;AArB/D;AACA;AACA;;AAcA;AACA;AACA;;AAKA,MAAM;EACLU,+BAA+B;EAC/BC,mBAAmB;EACnBC,+BAA+B;EAC/BC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AACpC,MAAM;EAAEC;AAAwB,CAAC,GAAG,IAAAF,kBAAM,EAAEG,mBAAkB,CAAC;AAE/D,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;AAEA,SAASC,SAASA,CAAE;EAAEC,UAAU;EAAEC;AAAO,CAAC,EAAG;EAC5C,MAAM;IAAEC,IAAI,EAAEC;EAAW,CAAC,GAAG,IAAAC,mBAAU,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,EAAC,6BAA6B;MACvCC,IAAI,EAAC,WAAW;MAChBC,QAAQ,EAAG,CAAG;MAAAL,QAAA,gBAEd,IAAAzC,WAAA,CAAAmC,GAAA;QAAAM,QAAA;QAEE;QACA;QACC;MAA2C,CAEvC,CAAC,eACR,IAAAzC,WAAA,CAAAmC,GAAA,EAAC7C,WAAA,CAAAyD,QAAQ;QAACH,SAAS,EAAC,+CAA+C;QAAAH,QAAA,eAClE,IAAAzC,WAAA,CAAA0C,IAAA,EAACzC,+BAA+B;UAC/B+C,KAAK,EAAG1B,mBAAqB;UAC7BQ,QAAQ,EAAGA,QAAU;UAAAW,QAAA,gBAErB,IAAAzC,WAAA,CAAAmC,GAAA,EAAC1C,YAAA,CAAAwD,SAAS;YAACC,cAAc,EAAG;UAAO,CAAE,CAAC,eAKtC,IAAAlD,WAAA,CAAAmC,GAAA,EAAC1C,YAAA,CAAA0D,sBAAY;YAACjB,MAAM,EAAGD;UAAc,CAAE,CAAC,eACxC,IAAAjC,WAAA,CAAAmC,GAAA,EAAC/B,gDAAgD;YAChDgD,MAAM,EAAGhC;UAAc,CACvB,CAAC;QAAA,CAC8B;MAAC,CACzB,CAAC;IAAA,CACJ;EAAC,CACa,CAAC;AAE1B;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAEctB,SAAS","ignoreList":[]}
|
|
@@ -54,7 +54,7 @@ const DEFAULT_VIEWS = exports.DEFAULT_VIEWS = {
|
|
|
54
54
|
}, {
|
|
55
55
|
title: (0, _i18n.__)('Published'),
|
|
56
56
|
slug: 'published',
|
|
57
|
-
icon: _icons.
|
|
57
|
+
icon: _icons.published,
|
|
58
58
|
view: {
|
|
59
59
|
...DEFAULT_PAGE_BASE,
|
|
60
60
|
filters: [{
|
|
@@ -66,7 +66,7 @@ const DEFAULT_VIEWS = exports.DEFAULT_VIEWS = {
|
|
|
66
66
|
}, {
|
|
67
67
|
title: (0, _i18n.__)('Scheduled'),
|
|
68
68
|
slug: 'future',
|
|
69
|
-
icon: _icons.
|
|
69
|
+
icon: _icons.scheduled,
|
|
70
70
|
view: {
|
|
71
71
|
...DEFAULT_PAGE_BASE,
|
|
72
72
|
filters: [{
|
|
@@ -90,7 +90,7 @@ const DEFAULT_VIEWS = exports.DEFAULT_VIEWS = {
|
|
|
90
90
|
}, {
|
|
91
91
|
title: (0, _i18n.__)('Pending'),
|
|
92
92
|
slug: 'pending',
|
|
93
|
-
icon: _icons.
|
|
93
|
+
icon: _icons.pending,
|
|
94
94
|
view: {
|
|
95
95
|
...DEFAULT_PAGE_BASE,
|
|
96
96
|
filters: [{
|
|
@@ -102,7 +102,7 @@ const DEFAULT_VIEWS = exports.DEFAULT_VIEWS = {
|
|
|
102
102
|
}, {
|
|
103
103
|
title: (0, _i18n.__)('Private'),
|
|
104
104
|
slug: 'private',
|
|
105
|
-
icon: _icons.
|
|
105
|
+
icon: _icons.notAllowed,
|
|
106
106
|
view: {
|
|
107
107
|
...DEFAULT_PAGE_BASE,
|
|
108
108
|
filters: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_constants","DEFAULT_CONFIG_PER_VIEW_TYPE","exports","LAYOUT_TABLE","primaryField","LAYOUT_GRID","mediaField","LAYOUT_LIST","DEFAULT_PAGE_BASE","type","search","filters","page","perPage","sort","field","direction","hiddenFields","layout","DEFAULT_VIEWS","title","__","slug","icon","pages","view","operator","OPERATOR_IS_ANY","value","drafts","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_constants","DEFAULT_CONFIG_PER_VIEW_TYPE","exports","LAYOUT_TABLE","primaryField","LAYOUT_GRID","mediaField","LAYOUT_LIST","DEFAULT_PAGE_BASE","type","search","filters","page","perPage","sort","field","direction","hiddenFields","layout","DEFAULT_VIEWS","title","__","slug","icon","pages","view","published","operator","OPERATOR_IS_ANY","value","scheduled","drafts","pending","notAllowed","trash"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/default-views.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\ttrash,\n\tpages,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_LIST,\n\tLAYOUT_TABLE,\n\tLAYOUT_GRID,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\n\nexport const DEFAULT_CONFIG_PER_VIEW_TYPE = {\n\t[ LAYOUT_TABLE ]: {\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tmediaField: 'featured-image',\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tprimaryField: 'title',\n\t\tmediaField: 'featured-image',\n\t},\n};\n\nconst DEFAULT_PAGE_BASE = {\n\ttype: LAYOUT_LIST,\n\tsearch: '',\n\tfilters: [],\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'date',\n\t\tdirection: 'desc',\n\t},\n\t// All fields are visible by default, so it's\n\t// better to keep track of the hidden ones.\n\thiddenFields: [ 'date', 'featured-image' ],\n\tlayout: {\n\t\t...DEFAULT_CONFIG_PER_VIEW_TYPE[ LAYOUT_LIST ],\n\t},\n};\n\nexport const DEFAULT_VIEWS = {\n\tpage: [\n\t\t{\n\t\t\ttitle: __( 'All pages' ),\n\t\t\tslug: 'all',\n\t\t\ticon: pages,\n\t\t\tview: DEFAULT_PAGE_BASE,\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Published' ),\n\t\t\tslug: 'published',\n\t\t\ticon: published,\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\tvalue: 'publish',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Scheduled' ),\n\t\t\tslug: 'future',\n\t\t\ticon: scheduled,\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\tvalue: 'future',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Drafts' ),\n\t\t\tslug: 'drafts',\n\t\t\ticon: drafts,\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\tvalue: 'draft',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Pending' ),\n\t\t\tslug: 'pending',\n\t\t\ticon: pending,\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\tvalue: 'pending',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Private' ),\n\t\t\tslug: 'private',\n\t\t\ticon: notAllowed,\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\tvalue: 'private',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Trash' ),\n\t\t\tslug: 'trash',\n\t\t\ticon: trash,\n\t\t\tview: {\n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ACCI,KAAK,EAAE,QAAQ;QACfY,QAAQ,EAAEC,0BAAe;QACzBC,KAAK,EAAE;MACR,CAAC;IAEH;EACD,CAAC,EACD;IACCT,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;IACpBC,IAAI,EAAE,OAAO;IACbC,IAAI,EAAEW,YAAK;IACXT,IAAI,EAAE;MACL,GAAGjB,iBAAiB;MACpBG,OAAO,EAAE,CACR;QACCI,KAAK,EAAE,QAAQ;QACfY,QAAQ,EAAEC,0BAAe;QACzBC,KAAK,EAAE;MACR,CAAC;IAEH;EACD,CAAC;AAEH,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = useThemeStyleVariationsByProperty;
|
|
8
7
|
exports.filterObjectByProperty = void 0;
|
|
9
8
|
exports.isVariationWithSingleProperty = isVariationWithSingleProperty;
|
|
10
9
|
exports.removePropertyFromObject = removePropertyFromObject;
|
|
@@ -57,17 +56,15 @@ function removePropertyFromObject(object, property) {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
61
|
-
* and
|
|
59
|
+
* Fetches the current theme style variations that contain only the specified property
|
|
60
|
+
* and merges them with the user config.
|
|
62
61
|
*
|
|
63
|
-
* @param {Object}
|
|
64
|
-
* @param {string}
|
|
65
|
-
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
62
|
+
* @param {Object} props Object of hook args.
|
|
63
|
+
* @param {string} props.property The property to filter by.
|
|
66
64
|
* @return {Object[]|*} The merged object.
|
|
67
65
|
*/
|
|
68
66
|
function useCurrentMergeThemeStyleVariationsWithUserConfig({
|
|
69
|
-
property
|
|
70
|
-
filter
|
|
67
|
+
property
|
|
71
68
|
}) {
|
|
72
69
|
const {
|
|
73
70
|
variationsFromTheme
|
|
@@ -78,21 +75,21 @@ function useCurrentMergeThemeStyleVariationsWithUserConfig({
|
|
|
78
75
|
};
|
|
79
76
|
}, []);
|
|
80
77
|
const {
|
|
81
|
-
user:
|
|
78
|
+
user: userVariation
|
|
82
79
|
} = (0, _element.useContext)(GlobalStylesContext);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
80
|
+
return (0, _element.useMemo)(() => {
|
|
81
|
+
const clonedUserVariation = (0, _cloneDeep.default)(userVariation);
|
|
82
|
+
|
|
83
|
+
// Get user variation and remove the settings for the given property.
|
|
84
|
+
const userVariationWithoutProperty = removePropertyFromObject(clonedUserVariation, property);
|
|
85
|
+
userVariationWithoutProperty.title = (0, _i18n.__)('Default');
|
|
86
|
+
const variationsWithSinglePropertyAndBase = variationsFromTheme.filter(variation => {
|
|
87
|
+
return isVariationWithSingleProperty(variation, property);
|
|
88
|
+
}).map(variation => {
|
|
89
|
+
return mergeBaseAndUserConfigs(userVariationWithoutProperty, variation);
|
|
90
|
+
});
|
|
91
|
+
return [userVariationWithoutProperty, ...variationsWithSinglePropertyAndBase];
|
|
92
|
+
}, [property, userVariation, variationsFromTheme]);
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
/**
|
|
@@ -123,72 +120,6 @@ const filterObjectByProperty = (object, property) => {
|
|
|
123
120
|
return newObject;
|
|
124
121
|
};
|
|
125
122
|
|
|
126
|
-
/**
|
|
127
|
-
* Returns a new object with only the properties specified in `property`.
|
|
128
|
-
* Optional merges the baseVariation object with the variation object.
|
|
129
|
-
* Note: this function will only overwrite the specified property in baseVariation if it exists.
|
|
130
|
-
* The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.
|
|
131
|
-
* See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.
|
|
132
|
-
*
|
|
133
|
-
* @param {Object} props Object of hook args.
|
|
134
|
-
* @param {Object[]} props.variations The theme style variations to filter.
|
|
135
|
-
* @param {string} props.property The property to filter by.
|
|
136
|
-
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
137
|
-
* @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.
|
|
138
|
-
* @return {Object[]|*} The merged object.
|
|
139
|
-
*/
|
|
140
|
-
exports.filterObjectByProperty = filterObjectByProperty;
|
|
141
|
-
function useThemeStyleVariationsByProperty({
|
|
142
|
-
variations,
|
|
143
|
-
property,
|
|
144
|
-
filter,
|
|
145
|
-
baseVariation
|
|
146
|
-
}) {
|
|
147
|
-
return (0, _element.useMemo)(() => {
|
|
148
|
-
if (!property || !variations || variations?.length === 0) {
|
|
149
|
-
return variations;
|
|
150
|
-
}
|
|
151
|
-
const clonedBaseVariation = typeof baseVariation === 'object' && Object.keys(baseVariation).length > 0 ? (0, _cloneDeep.default)(baseVariation) : null;
|
|
152
|
-
let processedStyleVariations = variations.reduce((accumulator, variation) => {
|
|
153
|
-
const variationFilteredByProperty = filterObjectByProperty((0, _cloneDeep.default)(variation), property);
|
|
154
|
-
|
|
155
|
-
// Remove variations that are empty once the property is filtered out.
|
|
156
|
-
if (variation.title !== (0, _i18n.__)('Default') && Object.keys(variationFilteredByProperty).length === 0) {
|
|
157
|
-
return accumulator;
|
|
158
|
-
}
|
|
159
|
-
let result = {
|
|
160
|
-
...variationFilteredByProperty,
|
|
161
|
-
title: variation?.title,
|
|
162
|
-
description: variation?.description
|
|
163
|
-
};
|
|
164
|
-
if (clonedBaseVariation) {
|
|
165
|
-
/*
|
|
166
|
-
* Overwrites all baseVariation object `styleProperty` properties
|
|
167
|
-
* with the theme variation `styleProperty` properties.
|
|
168
|
-
*/
|
|
169
|
-
result = mergeBaseAndUserConfigs(clonedBaseVariation, result);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Detect if this is a duplicate variation.
|
|
173
|
-
const isDuplicate = accumulator.some(item => {
|
|
174
|
-
return JSON.stringify(item.styles) === JSON.stringify(result?.styles) && JSON.stringify(item.settings) === JSON.stringify(result?.settings);
|
|
175
|
-
});
|
|
176
|
-
if (isDuplicate) {
|
|
177
|
-
return accumulator;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// If the variation is not a duplicate, add it to the accumulator.
|
|
181
|
-
accumulator.push(result);
|
|
182
|
-
return accumulator;
|
|
183
|
-
}, [] // Initial accumulator value.
|
|
184
|
-
);
|
|
185
|
-
if ('function' === typeof filter) {
|
|
186
|
-
processedStyleVariations = processedStyleVariations.filter(filter);
|
|
187
|
-
}
|
|
188
|
-
return processedStyleVariations;
|
|
189
|
-
}, [variations, property, baseVariation, filter]);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
123
|
/**
|
|
193
124
|
* Compares a style variation to the same variation filtered by a single property.
|
|
194
125
|
* Returns true if the variation contains only the property specified.
|
|
@@ -197,6 +128,7 @@ function useThemeStyleVariationsByProperty({
|
|
|
197
128
|
* @param {string} property The property to compare.
|
|
198
129
|
* @return {boolean} Whether the variation contains only a single property.
|
|
199
130
|
*/
|
|
131
|
+
exports.filterObjectByProperty = filterObjectByProperty;
|
|
200
132
|
function isVariationWithSingleProperty(variation, property) {
|
|
201
133
|
const variationWithProperty = filterObjectByProperty((0, _cloneDeep.default)(variation), property);
|
|
202
134
|
return JSON.stringify(variationWithProperty?.styles) === JSON.stringify(variation?.styles) && JSON.stringify(variationWithProperty?.settings) === JSON.stringify(variation?.settings);
|
package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_element","_blockEditor","_editor","_i18n","_cloneDeep","_interopRequireDefault","_lockUnlock","GlobalStylesContext","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","filter","variationsFromTheme","useSelect","select","_variationsFromTheme","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","baseVariation","useContext","variations","useMemo","title","__","settings","styles","useThemeStyleVariationsByProperty","cloneDeep","filterObjectByProperty","newObject","forEach","newFilter","exports","clonedBaseVariation","processedStyleVariations","reduce","accumulator","variation","variationFilteredByProperty","result","description","isDuplicate","some","item","JSON","stringify","push","isVariationWithSingleProperty","variationWithProperty"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,\n * and user-defined global style/settings object.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n\tfilter,\n} ) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: baseVariation } = useContext( GlobalStylesContext );\n\n\tconst variations = useMemo( () => {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: __( 'Default' ),\n\t\t\t\tsettings: {},\n\t\t\t\tstyles: {},\n\t\t\t},\n\t\t\t...variationsFromTheme,\n\t\t];\n\t}, [ variationsFromTheme ] );\n\n\treturn useThemeStyleVariationsByProperty( {\n\t\tvariations,\n\t\tproperty,\n\t\tfilter,\n\t\tbaseVariation: removePropertyFromObject(\n\t\t\tcloneDeep( baseVariation ),\n\t\t\tproperty\n\t\t),\n\t} );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Returns a new object with only the properties specified in `property`.\n * Optional merges the baseVariation object with the variation object.\n * Note: this function will only overwrite the specified property in baseVariation if it exists.\n * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.\n * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.\n *\n * @param {Object} props Object of hook args.\n * @param {Object[]} props.variations The theme style variations to filter.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.\n * @return {Object[]|*} The merged object.\n */\nexport default function useThemeStyleVariationsByProperty( {\n\tvariations,\n\tproperty,\n\tfilter,\n\tbaseVariation,\n} ) {\n\treturn useMemo( () => {\n\t\tif ( ! property || ! variations || variations?.length === 0 ) {\n\t\t\treturn variations;\n\t\t}\n\n\t\tconst clonedBaseVariation =\n\t\t\ttypeof baseVariation === 'object' &&\n\t\t\tObject.keys( baseVariation ).length > 0\n\t\t\t\t? cloneDeep( baseVariation )\n\t\t\t\t: null;\n\n\t\tlet processedStyleVariations = variations.reduce(\n\t\t\t( accumulator, variation ) => {\n\t\t\t\tconst variationFilteredByProperty = filterObjectByProperty(\n\t\t\t\t\tcloneDeep( variation ),\n\t\t\t\t\tproperty\n\t\t\t\t);\n\n\t\t\t\t// Remove variations that are empty once the property is filtered out.\n\t\t\t\tif (\n\t\t\t\t\tvariation.title !== __( 'Default' ) &&\n\t\t\t\t\tObject.keys( variationFilteredByProperty ).length === 0\n\t\t\t\t) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tlet result = {\n\t\t\t\t\t...variationFilteredByProperty,\n\t\t\t\t\ttitle: variation?.title,\n\t\t\t\t\tdescription: variation?.description,\n\t\t\t\t};\n\n\t\t\t\tif ( clonedBaseVariation ) {\n\t\t\t\t\t/*\n\t\t\t\t\t * Overwrites all baseVariation object `styleProperty` properties\n\t\t\t\t\t * with the theme variation `styleProperty` properties.\n\t\t\t\t\t */\n\t\t\t\t\tresult = mergeBaseAndUserConfigs(\n\t\t\t\t\t\tclonedBaseVariation,\n\t\t\t\t\t\tresult\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Detect if this is a duplicate variation.\n\t\t\t\tconst isDuplicate = accumulator.some( ( item ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tJSON.stringify( item.styles ) ===\n\t\t\t\t\t\t\tJSON.stringify( result?.styles ) &&\n\t\t\t\t\t\tJSON.stringify( item.settings ) ===\n\t\t\t\t\t\t\tJSON.stringify( result?.settings )\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t\tif ( isDuplicate ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// If the variation is not a duplicate, add it to the accumulator.\n\t\t\t\taccumulator.push( result );\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[] // Initial accumulator value.\n\t\t);\n\n\t\tif ( 'function' === typeof filter ) {\n\t\t\tprocessedStyleVariations =\n\t\t\t\tprocessedStyleVariations.filter( filter );\n\t\t}\n\n\t\treturn processedStyleVariations;\n\t}, [ variations, property, baseVariation, filter ] );\n}\n\n/**\n * Compares a style variation to the same variation filtered by a single property.\n * Returns true if the variation contains only the property specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string} property The property to compare.\n * @return {boolean} Whether the variation contains only a single property.\n */\nexport function isVariationWithSingleProperty( variation, property ) {\n\tconst variationWithProperty = filterObjectByProperty(\n\t\tcloneDeep( variation ),\n\t\tproperty\n\t);\n\n\treturn (\n\t\tJSON.stringify( variationWithProperty?.styles ) ===\n\t\t\tJSON.stringify( variation?.styles ) &&\n\t\tJSON.stringify( variationWithProperty?.settings ) ===\n\t\t\tJSON.stringify( variation?.settings )\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAA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version":3,"names":["_data","require","_coreData","_element","_blockEditor","_editor","_i18n","_cloneDeep","_interopRequireDefault","_lockUnlock","GlobalStylesContext","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","variationsFromTheme","useSelect","select","_variationsFromTheme","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","userVariation","useContext","useMemo","clonedUserVariation","cloneDeep","userVariationWithoutProperty","title","__","variationsWithSinglePropertyAndBase","filter","variation","isVariationWithSingleProperty","map","filterObjectByProperty","newObject","forEach","newFilter","exports","variationWithProperty","JSON","stringify","styles","settings"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * Fetches the current theme style variations that contain only the specified property\n * and merges them with the user config.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n} ) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: userVariation } = useContext( GlobalStylesContext );\n\n\treturn useMemo( () => {\n\t\tconst clonedUserVariation = cloneDeep( userVariation );\n\n\t\t// Get user variation and remove the settings for the given property.\n\t\tconst userVariationWithoutProperty = removePropertyFromObject(\n\t\t\tclonedUserVariation,\n\t\t\tproperty\n\t\t);\n\t\tuserVariationWithoutProperty.title = __( 'Default' );\n\n\t\tconst variationsWithSinglePropertyAndBase = variationsFromTheme\n\t\t\t.filter( ( variation ) => {\n\t\t\t\treturn isVariationWithSingleProperty( variation, property );\n\t\t\t} )\n\t\t\t.map( ( variation ) => {\n\t\t\t\treturn mergeBaseAndUserConfigs(\n\t\t\t\t\tuserVariationWithoutProperty,\n\t\t\t\t\tvariation\n\t\t\t\t);\n\t\t\t} );\n\n\t\treturn [\n\t\t\tuserVariationWithoutProperty,\n\t\t\t...variationsWithSinglePropertyAndBase,\n\t\t];\n\t}, [ property, userVariation, variationsFromTheme ] );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Compares a style variation to the same variation filtered by a single property.\n * Returns true if the variation contains only the property specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string} property The property to compare.\n * @return {boolean} Whether the variation contains only a single property.\n */\nexport function isVariationWithSingleProperty( variation, property ) {\n\tconst variationWithProperty = filterObjectByProperty(\n\t\tcloneDeep( variation ),\n\t\tproperty\n\t);\n\n\treturn (\n\t\tJSON.stringify( variationWithProperty?.styles ) ===\n\t\t\tJSON.stringify( variation?.styles ) &&\n\t\tJSON.stringify( variationWithProperty?.settings ) ===\n\t\t\tJSON.stringify( variation?.settings )\n\t);\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIA,MAAM;EAAES;AAAoB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAChE,MAAM;EAAEC;AAAwB,CAAC,GAAG,IAAAF,kBAAM,EAAEG,mBAAkB,CAAC;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC5D,IA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vB,QAAQ,EAAG;EACpE,MAAM+B,qBAAqB,GAAGL,sBAAsB,CACnD,IAAAT,kBAAS,EAAEM,SAAU,CAAC,EACtBvB,QACD,CAAC;EAED,OACCgC,IAAI,CAACC,SAAS,CAAEF,qBAAqB,EAAEG,MAAO,CAAC,KAC9CF,IAAI,CAACC,SAAS,CAAEV,SAAS,EAAEW,MAAO,CAAC,IACpCF,IAAI,CAACC,SAAS,CAAEF,qBAAqB,EAAEI,QAAS,CAAC,KAChDH,IAAI,CAACC,SAAS,CAAEV,SAAS,EAAEY,QAAS,CAAC;AAExC","ignoreList":[]}
|
|
@@ -20,9 +20,9 @@ const setCanvasMode = mode => ({
|
|
|
20
20
|
registry,
|
|
21
21
|
dispatch
|
|
22
22
|
}) => {
|
|
23
|
+
const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
|
|
23
24
|
const switchCanvasMode = () => {
|
|
24
25
|
registry.batch(() => {
|
|
25
|
-
const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
|
|
26
26
|
registry.dispatch(_blockEditor.store).clearSelectedBlock();
|
|
27
27
|
registry.dispatch(_editor.store).setDeviceType('Desktop');
|
|
28
28
|
registry.dispatch(_blockEditor.store).__unstableSetEditorMode('edit');
|
|
@@ -47,7 +47,12 @@ const setCanvasMode = mode => ({
|
|
|
47
47
|
registry.dispatch(_editor.store).setIsInserterOpened(false);
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Skip transition in mobile, otherwise it crashes the browser.
|
|
53
|
+
* See: https://github.com/WordPress/gutenberg/pull/63002.
|
|
54
|
+
*/
|
|
55
|
+
if (!isMediumOrBigger || !document.startViewTransition) {
|
|
51
56
|
switchCanvasMode();
|
|
52
57
|
} else {
|
|
53
58
|
document.documentElement.classList.add(`canvas-mode-${mode}-transition`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","_preferences","_editor","setCanvasMode","mode","registry","dispatch","
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_preferences","_editor","setCanvasMode","mode","registry","dispatch","isMediumOrBigger","window","matchMedia","matches","switchCanvasMode","batch","blockEditorStore","clearSelectedBlock","editorStore","setDeviceType","__unstableSetEditorMode","isPublishSidebarOpened","select","type","isEditMode","closePublishSidebar","preferencesStore","get","setIsListViewOpened","setIsInserterOpened","document","startViewTransition","documentElement","classList","add","transition","finished","finally","remove","exports","setEditorCanvasContainerView","view"],"sources":["@wordpress/edit-site/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch } ) => {\n\t\tconst isMediumOrBigger =\n\t\t\twindow.matchMedia( '(min-width: 782px)' ).matches;\n\t\tconst switchCanvasMode = () => {\n\t\t\tregistry.batch( () => {\n\t\t\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t\t\t\tregistry.dispatch( editorStore ).setDeviceType( 'Desktop' );\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t\t.__unstableSetEditorMode( 'edit' );\n\t\t\t\tconst isPublishSidebarOpened = registry\n\t\t\t\t\t.select( editorStore )\n\t\t\t\t\t.isPublishSidebarOpened();\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\t\t\tmode,\n\t\t\t\t} );\n\t\t\t\tconst isEditMode = mode === 'edit';\n\t\t\t\tif ( isPublishSidebarOpened && ! isEditMode ) {\n\t\t\t\t\tregistry.dispatch( editorStore ).closePublishSidebar();\n\t\t\t\t}\n\n\t\t\t\t// Check if the block list view should be open by default.\n\t\t\t\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t\t\t\t// This behavior is disabled for small viewports.\n\t\t\t\tif (\n\t\t\t\t\tisMediumOrBigger &&\n\t\t\t\t\tisEditMode &&\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.select( preferencesStore )\n\t\t\t\t\t\t.get( 'core', 'showListViewByDefault' ) &&\n\t\t\t\t\t! registry\n\t\t\t\t\t\t.select( preferencesStore )\n\t\t\t\t\t\t.get( 'core', 'distractionFree' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( editorStore )\n\t\t\t\t\t\t.setIsListViewOpened( true );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( editorStore )\n\t\t\t\t\t\t.setIsListViewOpened( false );\n\t\t\t\t}\n\t\t\t\tregistry.dispatch( editorStore ).setIsInserterOpened( false );\n\t\t\t} );\n\t\t};\n\n\t\t/*\n\t\t * Skip transition in mobile, otherwise it crashes the browser.\n\t\t * See: https://github.com/WordPress/gutenberg/pull/63002.\n\t\t */\n\t\tif ( ! isMediumOrBigger || ! document.startViewTransition ) {\n\t\t\tswitchCanvasMode();\n\t\t} else {\n\t\t\tdocument.documentElement.classList.add(\n\t\t\t\t`canvas-mode-${ mode }-transition`\n\t\t\t);\n\t\t\tconst transition = document.startViewTransition( () =>\n\t\t\t\tswitchCanvasMode()\n\t\t\t);\n\t\t\ttransition.finished.finally( () => {\n\t\t\t\tdocument.documentElement.classList.remove(\n\t\t\t\t\t`canvas-mode-${ mode }-transition`\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\t};\n\n/**\n * Action that switches the editor canvas container view.\n *\n * @param {?string} view Editor canvas container view.\n */\nexport const setEditorCanvasContainerView =\n\t( view ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',\n\t\t\tview,\n\t\t} );\n\t};\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC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,CAAE,IAAK,CAAC;MAC9B,CAAC,MAAM;QACNpB,QAAQ,CACNC,QAAQ,CAAES,aAAY,CAAC,CACvBU,mBAAmB,CAAE,KAAM,CAAC;MAC/B;MACApB,QAAQ,CAACC,QAAQ,CAAES,aAAY,CAAC,CAACW,mBAAmB,CAAE,KAAM,CAAC;IAC9D,CAAE,CAAC;EACJ,CAAC;;EAED;AACF;AACA;AACA;EACE,IAAK,CAAEnB,gBAAgB,IAAI,CAAEoB,QAAQ,CAACC,mBAAmB,EAAG;IAC3DjB,gBAAgB,CAAC,CAAC;EACnB,CAAC,MAAM;IACNgB,QAAQ,CAACE,eAAe,CAACC,SAAS,CAACC,GAAG,CACpC,eAAe3B,IAAM,aACvB,CAAC;IACD,MAAM4B,UAAU,GAAGL,QAAQ,CAACC,mBAAmB,CAAE,MAChDjB,gBAAgB,CAAC,CAClB,CAAC;IACDqB,UAAU,CAACC,QAAQ,CAACC,OAAO,CAAE,MAAM;MAClCP,QAAQ,CAACE,eAAe,CAACC,SAAS,CAACK,MAAM,CACvC,eAAe/B,IAAM,aACvB,CAAC;IACF,CAAE,CAAC;EACJ;AACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AAJAgC,OAAA,CAAAjC,aAAA,GAAAA,aAAA;AAKO,MAAMkC,4BAA4B,GACtCC,IAAI,IACN,CAAE;EAAEhC;AAAS,CAAC,KAAM;EACnBA,QAAQ,CAAE;IACTc,IAAI,EAAE,kCAAkC;IACxCkB;EACD,CAAE,CAAC;AACJ,CAAC;AAACF,OAAA,CAAAC,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Button, Modal, __experimentalHStack as HStack, __experimentalVStack as VStack, TextControl } from '@wordpress/components';
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
-
import { useDispatch } from '@wordpress/data';
|
|
6
|
+
import { useDispatch, useRegistry } from '@wordpress/data';
|
|
7
7
|
import { useState } from '@wordpress/element';
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
9
|
import { store as noticesStore } from '@wordpress/notices';
|
|
10
10
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
|
+
import { serialize, synchronizeBlocksWithTemplate } from '@wordpress/blocks';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
export default function AddNewPageModal({
|
|
@@ -23,6 +24,9 @@ export default function AddNewPageModal({
|
|
|
23
24
|
createErrorNotice,
|
|
24
25
|
createSuccessNotice
|
|
25
26
|
} = useDispatch(noticesStore);
|
|
27
|
+
const {
|
|
28
|
+
resolveSelect
|
|
29
|
+
} = useRegistry();
|
|
26
30
|
async function createPage(event) {
|
|
27
31
|
event.preventDefault();
|
|
28
32
|
if (isCreatingPage) {
|
|
@@ -30,10 +34,12 @@ export default function AddNewPageModal({
|
|
|
30
34
|
}
|
|
31
35
|
setIsCreatingPage(true);
|
|
32
36
|
try {
|
|
37
|
+
const pagePostType = await resolveSelect(coreStore).getPostType('page');
|
|
33
38
|
const newPage = await saveEntityRecord('postType', 'page', {
|
|
34
39
|
status: 'draft',
|
|
35
40
|
title,
|
|
36
|
-
slug: title || __('No title')
|
|
41
|
+
slug: title || __('No title'),
|
|
42
|
+
content: !!pagePostType.template && pagePostType.template.length ? serialize(synchronizeBlocksWithTemplate([], pagePostType.template)) : undefined
|
|
37
43
|
}, {
|
|
38
44
|
throwOnError: true
|
|
39
45
|
});
|