@wordpress/editor 13.3.6 → 13.5.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 +4 -0
- package/build/components/document-outline/index.js +7 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/page-attributes/check.js +6 -10
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/order.js +3 -5
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/parent.js +9 -6
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-author/check.js +3 -7
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-featured-image/index.js +7 -12
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -7
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-pending-status/check.js +3 -7
- package/build/components/post-pending-status/check.js.map +1 -1
- package/build/components/post-preview-button/index.js +3 -3
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -4
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +3 -7
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +4 -8
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +3 -7
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js +5 -9
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-publish-panel/prepublish.js +3 -7
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-schedule/check.js +3 -7
- package/build/components/post-schedule/check.js.map +1 -1
- package/build/components/post-sticky/check.js +3 -7
- package/build/components/post-sticky/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +12 -9
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +18 -12
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +2 -9
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -0
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-visibility/check.js +3 -7
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/theme-support-check/index.js +3 -7
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/store/utils/notice-builder.js +4 -8
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/document-outline/index.js +8 -2
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/page-attributes/check.js +6 -9
- package/build-module/components/page-attributes/check.js.map +1 -1
- package/build-module/components/page-attributes/order.js +4 -6
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +9 -5
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-author/check.js +3 -6
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +7 -11
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -6
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-pending-status/check.js +3 -6
- package/build-module/components/post-pending-status/check.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +3 -2
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -3
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +3 -6
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +4 -7
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +3 -6
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js +5 -8
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-publish-panel/prepublish.js +3 -6
- package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
- package/build-module/components/post-schedule/check.js +3 -6
- package/build-module/components/post-schedule/check.js.map +1 -1
- package/build-module/components/post-sticky/check.js +3 -6
- package/build-module/components/post-sticky/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +12 -8
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +18 -11
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +2 -8
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-title/index.native.js +1 -0
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-visibility/check.js +3 -6
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +3 -6
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +4 -7
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-style/style-rtl.css +1 -13
- package/build-style/style.css +1 -13
- package/package.json +30 -30
- package/src/components/document-outline/index.js +6 -3
- package/src/components/page-attributes/check.js +3 -12
- package/src/components/page-attributes/order.js +18 -12
- package/src/components/page-attributes/parent.js +41 -41
- package/src/components/post-author/check.js +2 -10
- package/src/components/post-featured-image/index.js +5 -10
- package/src/components/post-locked-modal/index.js +1 -6
- package/src/components/post-pending-status/check.js +2 -10
- package/src/components/post-preview-button/index.js +1 -2
- package/src/components/post-publish-button/index.js +3 -7
- package/src/components/post-publish-button/label.js +2 -10
- package/src/components/post-publish-panel/index.js +3 -11
- package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -10
- package/src/components/post-publish-panel/postpublish.js +3 -8
- package/src/components/post-publish-panel/prepublish.js +2 -10
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-schedule/check.js +2 -10
- package/src/components/post-sticky/check.js +1 -10
- package/src/components/post-taxonomies/flat-term-selector.js +14 -34
- package/src/components/post-taxonomies/hierarchical-term-selector.js +15 -37
- package/src/components/post-taxonomies/most-used-terms.js +15 -18
- package/src/components/post-title/index.native.js +1 -0
- package/src/components/post-visibility/check.js +2 -10
- package/src/components/theme-support-check/index.js +1 -6
- package/src/store/utils/notice-builder.js +2 -7
- package/src/style.scss +0 -1
- package/src/components/page-attributes/style.scss +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"names":["get","removeAccents","__","ComboboxControl","debounce","useState","useMemo","useSelect","useDispatch","decodeEntities","store","coreStore","buildTermsTree","editorStore","getTitle","post","title","rendered","id","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","length","Infinity","PageAttributesParent","editPost","fieldValue","setFieldValue","parentPost","parentPostId","items","postType","select","getPostType","getEntityRecords","getEntityRecord","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","isHierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPageLabel","pageItems","parentOptions","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AACA,OAAOC,aAAP,MAA0B,gBAA1B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,uBAAhC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,KAAK,IAAIC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AQ,EAAGE;AAPZ,IADD;AAWA;AAED,eAAexD,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { parentPost, parentPostId, items, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst isHierarchical = get( pType, [ 'hierarchical' ], false );\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPost: pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null,\n\t\t\t\titems: isHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: [],\n\t\t\t\tpostType: pType,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst isHierarchical = get( postType, [ 'hierarchical' ], false );\n\tconst parentPageLabel = get( postType, [ 'labels', 'parent_item_colon' ] );\n\tconst pageItems = items || [];\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPost && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: getTitle( parentPost ),\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue ] );\n\n\tif ( ! isHierarchical || ! parentPageLabel ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ parentPageLabel }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"names":["removeAccents","__","ComboboxControl","debounce","useState","useMemo","useSelect","useDispatch","decodeEntities","store","coreStore","buildTermsTree","editorStore","getTitle","post","title","rendered","id","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","length","Infinity","PageAttributesParent","editPost","fieldValue","setFieldValue","isHierarchical","parentPost","parentPostId","items","postType","select","getPostType","getEntityRecords","getEntityRecord","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","postIsHierarchical","hierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPageLabel","labels","parent_item_colon","pageItems","parentOptions","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,gBAA1B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,uBAAhC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASF,KAAK,IAAIG,WAAlB,QAAqC,aAArC;;AAEA,SAASC,QAAT,CAAmBC,IAAnB,EAA0B;AAAA;;AACzB,SAAOA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,mBAAAA,IAAI,CAAEC,KAAN,oDAAaC,QAAb,GACJR,cAAc,CAAEM,IAAI,CAACC,KAAL,CAAWC,QAAb,CADV,GAEH,IAAIF,IAAI,CAACG,EAAI,KAAKhB,EAAE,CAAE,UAAF,CAAgB,GAFxC;AAGA;;AAED,OAAO,MAAMiB,eAAe,GAAG,CAAEC,IAAF,EAAQC,WAAR,KAAyB;AACvD,QAAMC,cAAc,GAAGrB,aAAa,CAAEmB,IAAI,IAAI,EAAV,CAAb,CAA4BG,WAA5B,EAAvB;AACA,QAAMC,gBAAgB,GAAGvB,aAAa,CAAEoB,WAAW,IAAI,EAAjB,CAAb,CAAmCE,WAAnC,EAAzB;;AACA,MAAKD,cAAc,K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A;AACD;AACD;AACA;AACA;AACA;;;AACC,QAAM6B,aAAa,GAAKC,UAAF,IAAkB;AACvCxD,IAAAA,aAAa,CAAEwD,UAAF,CAAb;AACA,GAFD;AAIA;AACD;AACA;AACA;AACA;;;AACC,QAAMC,YAAY,GAAKC,cAAF,IAAsB;AAC1C5D,IAAAA,QAAQ,CAAE;AAAEoD,MAAAA,MAAM,EAAEQ;AAAV,KAAF,CAAR;AACA,GAFD;;AAIA,SACC,cAAC,eAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,gCAFX;AAGC,IAAA,KAAK,EAAGhC,eAHT;AAIC,IAAA,KAAK,EAAGvB,YAJT;AAKC,IAAA,OAAO,EAAG2B,aALX;AAMC,IAAA,mBAAmB,EAAGzD,QAAQ,CAAEkF,aAAF,EAAiB,GAAjB,CAN/B;AAOC,IAAA,QAAQ,EAAGE;AAPZ,IADD;AAWA;AAED,eAAe5D,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { isHierarchical, parentPost, parentPostId, items, postType } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\t\tselect( editorStore );\n\t\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\t\tconst query = {\n\t\t\t\t\tper_page: 100,\n\t\t\t\t\texclude: postId,\n\t\t\t\t\tparent_exclude: postId,\n\t\t\t\t\torderby: 'menu_order',\n\t\t\t\t\torder: 'asc',\n\t\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t};\n\n\t\t\t\t// Perform a search when the field is changed.\n\t\t\t\tif ( !! fieldValue ) {\n\t\t\t\t\tquery.search = fieldValue;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\t\tparentPostId: pageId,\n\t\t\t\t\tparentPost: pageId\n\t\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t\t: null,\n\t\t\t\t\titems: postIsHierarchical\n\t\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t\t: [],\n\t\t\t\t\tpostType: pType,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ fieldValue ]\n\t\t);\n\n\tconst parentPageLabel = postType?.labels?.parent_item_colon;\n\tconst pageItems = items || [];\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPost && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: getTitle( parentPost ),\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue ] );\n\n\tif ( ! isHierarchical || ! parentPageLabel ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ parentPageLabel }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { get } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { useSelect } from '@wordpress/data';
|
|
12
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
8
|
/**
|
|
@@ -25,10 +20,12 @@ export default function PostAuthorCheck(_ref) {
|
|
|
25
20
|
hasAssignAuthorAction,
|
|
26
21
|
hasAuthors
|
|
27
22
|
} = useSelect(select => {
|
|
23
|
+
var _post$_links$wpActio, _post$_links;
|
|
24
|
+
|
|
28
25
|
const post = select(editorStore).getCurrentPost();
|
|
29
26
|
const authors = select(coreStore).getUsers(AUTHORS_QUERY);
|
|
30
27
|
return {
|
|
31
|
-
hasAssignAuthorAction:
|
|
28
|
+
hasAssignAuthorAction: (_post$_links$wpActio = (_post$_links = post._links) === null || _post$_links === void 0 ? void 0 : _post$_links['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
|
|
32
29
|
hasAuthors: (authors === null || authors === void 0 ? void 0 : authors.length) >= 1
|
|
33
30
|
};
|
|
34
31
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-author/check.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-author/check.js"],"names":["useSelect","store","coreStore","PostTypeSupportCheck","editorStore","AUTHORS_QUERY","PostAuthorCheck","children","hasAssignAuthorAction","hasAuthors","select","post","getCurrentPost","authors","getUsers","_links","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASF,KAAK,IAAIG,WAAlB,QAAqC,aAArC;AACA,SAASC,aAAT,QAA8B,aAA9B;AAEA,eAAe,SAASC,eAAT,OAAyC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACvD,QAAM;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MAAwCT,SAAS,CAAIU,MAAF,IAAc;AAAA;;AACtE,UAAMC,IAAI,GAAGD,MAAM,CAAEN,WAAF,CAAN,CAAsBQ,cAAtB,EAAb;AACA,UAAMC,OAAO,GAAGH,MAAM,CAAER,SAAF,CAAN,CAAoBY,QAApB,CAA8BT,aAA9B,CAAhB;AACA,WAAO;AACNG,MAAAA,qBAAqB,0CACpBG,IAAI,CAACI,MADe,iDACpB,aAAe,yBAAf,CADoB,uEAC0B,KAFzC;AAGNN,MAAAA,UAAU,EAAE,CAAAI,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEG,MAAT,KAAmB;AAHzB,KAAP;AAKA,GARsD,EAQpD,EARoD,CAAvD;;AAUA,MAAK,CAAER,qBAAF,IAA2B,CAAEC,UAAlC,EAA+C;AAC9C,WAAO,IAAP;AACA;;AAED,SACC,cAAC,oBAAD;AAAsB,IAAA,WAAW,EAAC;AAAlC,KACGF,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nexport default function PostAuthorCheck( { children } ) {\n\tconst { hasAssignAuthorAction, hasAuthors } = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\t\treturn {\n\t\t\thasAssignAuthorAction:\n\t\t\t\tpost._links?.[ 'wp:action-assign-author' ] ?? false,\n\t\t\thasAuthors: authors?.length >= 1,\n\t\t};\n\t}, [] );\n\n\tif ( ! hasAssignAuthorAction || ! hasAuthors ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"author\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { get } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
7
|
import { applyFilters } from '@wordpress/hooks';
|
|
13
8
|
import { DropZone, Button, Spinner, ResponsiveWrapper, withNotices, withFilters } from '@wordpress/components';
|
|
@@ -70,7 +65,7 @@ function getMediaDetails(media, postId) {
|
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
function PostFeaturedImage(_ref) {
|
|
73
|
-
var _media$media_details$3, _media$media_details$4;
|
|
68
|
+
var _media$media_details$3, _media$media_details$4, _postType$labels, _postType$labels3, _postType$labels4;
|
|
74
69
|
|
|
75
70
|
let {
|
|
76
71
|
currentPostId,
|
|
@@ -86,7 +81,6 @@ function PostFeaturedImage(_ref) {
|
|
|
86
81
|
const mediaUpload = useSelect(select => {
|
|
87
82
|
return select(blockEditorStore).getSettings().mediaUpload;
|
|
88
83
|
}, []);
|
|
89
|
-
const postLabel = get(postType, ['labels'], {});
|
|
90
84
|
const {
|
|
91
85
|
mediaWidth,
|
|
92
86
|
mediaHeight,
|
|
@@ -128,12 +122,14 @@ function PostFeaturedImage(_ref) {
|
|
|
128
122
|
__('The current image has no alternative text. The file name is: %s'), ((_media$media_details$3 = media.media_details.sizes) === null || _media$media_details$3 === void 0 ? void 0 : (_media$media_details$4 = _media$media_details$3.full) === null || _media$media_details$4 === void 0 ? void 0 : _media$media_details$4.file) || media.slug)), createElement(MediaUploadCheck, {
|
|
129
123
|
fallback: instructions
|
|
130
124
|
}, createElement(MediaUpload, {
|
|
131
|
-
title:
|
|
125
|
+
title: (postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.featured_image) || DEFAULT_FEATURE_IMAGE_LABEL,
|
|
132
126
|
onSelect: onUpdateImage,
|
|
133
127
|
unstableFeaturedImageFlow: true,
|
|
134
128
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
135
129
|
modalClass: "editor-post-featured-image__media-modal",
|
|
136
130
|
render: _ref3 => {
|
|
131
|
+
var _postType$labels2;
|
|
132
|
+
|
|
137
133
|
let {
|
|
138
134
|
open
|
|
139
135
|
} = _ref3;
|
|
@@ -151,13 +147,13 @@ function PostFeaturedImage(_ref) {
|
|
|
151
147
|
}, createElement("img", {
|
|
152
148
|
src: mediaSourceUrl,
|
|
153
149
|
alt: ""
|
|
154
|
-
})), isLoading && createElement(Spinner, null), !featuredImageId && !isLoading && (
|
|
150
|
+
})), isLoading && createElement(Spinner, null), !featuredImageId && !isLoading && ((postType === null || postType === void 0 ? void 0 : (_postType$labels2 = postType.labels) === null || _postType$labels2 === void 0 ? void 0 : _postType$labels2.set_featured_image) || DEFAULT_SET_FEATURE_IMAGE_LABEL)), createElement(DropZone, {
|
|
155
151
|
onFilesDrop: onDropFiles
|
|
156
152
|
}));
|
|
157
153
|
},
|
|
158
154
|
value: featuredImageId
|
|
159
155
|
})), !!featuredImageId && createElement(MediaUploadCheck, null, media && createElement(MediaUpload, {
|
|
160
|
-
title:
|
|
156
|
+
title: (postType === null || postType === void 0 ? void 0 : (_postType$labels3 = postType.labels) === null || _postType$labels3 === void 0 ? void 0 : _postType$labels3.featured_image) || DEFAULT_FEATURE_IMAGE_LABEL,
|
|
161
157
|
onSelect: onUpdateImage,
|
|
162
158
|
unstableFeaturedImageFlow: true,
|
|
163
159
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
@@ -175,7 +171,7 @@ function PostFeaturedImage(_ref) {
|
|
|
175
171
|
onClick: onRemoveImage,
|
|
176
172
|
variant: "link",
|
|
177
173
|
isDestructive: true
|
|
178
|
-
},
|
|
174
|
+
}, (postType === null || postType === void 0 ? void 0 : (_postType$labels4 = postType.labels) === null || _postType$labels4 === void 0 ? void 0 : _postType$labels4.remove_featured_image) || DEFAULT_REMOVE_FEATURE_IMAGE_LABEL))));
|
|
179
175
|
}
|
|
180
176
|
|
|
181
177
|
const applyWithSelect = withSelect(select => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"names":["get","__","sprintf","applyFilters","DropZone","Button","Spinner","ResponsiveWrapper","withNotices","withFilters","isBlobURL","useState","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","DEFAULT_REMOVE_FEATURE_IMAGE_LABEL","instructions","getMediaDetails","media","postId","defaultSize","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isLoading","setIsLoading","mediaUpload","select","getSettings","postLabel","onDropFiles","filesList","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","alt_text","full","file","slug","featured_image","open","set_featured_image","remove_featured_image","applyWithSelect","getMedia","getPostType","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,OAHD,EAICC,iBAJD,EAKCC,WALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,UAAlC,QAAoD,iBAApD;AACA,SACCC,WADD,EAECC,gBAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,SAAnC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,aAArC;AAEA,MAAMC,mBAAmB,GAAG,CAAE,OAAF,CAA5B,C,CAEA;;AACA,MAAMC,2BAA2B,GAAGvB,EAAE,CAAE,gBAAF,CAAtC;;AACA,MAAMwB,+BAA+B,GAAGxB,EAAE,CAAE,oBAAF,CAA1C;;AACA,MAAMyB,kCAAkC,GAAGzB,EAAE,CAAE,cAAF,CAA7C;;AAEA,MAAM0B,YAAY,GACjB,yBACG1B,EAAE,CACH,kEADG,CADL,CADD;;AAQA,SAAS2B,eAAT,CAA0BC,KAA1B,EAAiCC,MAAjC,EAA0C;AAAA;;AACzC,MAAK,CAAED,KAAP,EAAe;AACd,WAAO,EAAP;AACA;;AAED,QAAME,WAAW,GAAG5B,YAAY,CAC/B,oCAD+B,EAE/B,OAF+B,EAG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OAApC;AACA;;AATY,OAFf;AAaA,KAlBK;;AAmBNjB,IAAAA,aAAa,GAAG;AACfoC,MAAAA,QAAQ,CAAE;AAAEC,QAAAA,cAAc,EAAE;AAAlB,OAAF,CAAR;AACA;;AArBK,GAAP;AAuBA,CA1BoC,CAAtC;AA6BA,eAAevE,OAAO,CACrBJ,WADqB,EAErBkE,eAFqB,EAGrBM,iBAHqB,EAIrBvE,WAAW,CAAE,0BAAF,CAJU,CAAP,CAKZiC,iBALY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\tResponsiveWrapper,\n\twithNotices,\n\twithFilters,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );\nconst DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n} ) {\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst postLabel = get( postType, [ 'labels' ], {} );\n\tconst { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(\n\t\tmedia,\n\t\tcurrentPostId\n\t);\n\n\tfunction onDropFiles( filesList ) {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonUpdateImage( image );\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image filename.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmedia.media_details.sizes?.full?.file ||\n\t\t\t\t\t\t\t\t\tmedia.slug\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostLabel.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Edit or update the image' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t<ResponsiveWrapper\n\t\t\t\t\t\t\t\t\t\t\tnaturalWidth={ mediaWidth }\n\t\t\t\t\t\t\t\t\t\t\tnaturalHeight={ mediaHeight }\n\t\t\t\t\t\t\t\t\t\t\tisInline\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ResponsiveWrapper>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isLoading && <Spinner /> }\n\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t( postLabel.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t{ media && (\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\tpostLabel.featured_image ||\n\t\t\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Replace Image' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onRemoveImage }\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postLabel.remove_featured_image ||\n\t\t\t\t\t\t\t\tDEFAULT_REMOVE_FEATURE_IMAGE_LABEL }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType } = select( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"names":["__","sprintf","applyFilters","DropZone","Button","Spinner","ResponsiveWrapper","withNotices","withFilters","isBlobURL","useState","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","DEFAULT_REMOVE_FEATURE_IMAGE_LABEL","instructions","getMediaDetails","media","postId","defaultSize","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isLoading","setIsLoading","mediaUpload","select","getSettings","onDropFiles","filesList","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","alt_text","full","file","slug","labels","featured_image","open","set_featured_image","remove_featured_image","applyWithSelect","getMedia","getPostType","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,OAHD,EAICC,iBAJD,EAKCC,WALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,UAAlC,QAAoD,iBAApD;AACA,SACCC,WADD,EAECC,gBAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OA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AAAA,MAAhB;AAAEI,IAAAA;AAAF,GAAgB;AACjD,QAAM;AAAE6B,IAAAA;AAAF,MAAeD,QAAQ,CAAE3D,WAAF,CAA7B;AACA,SAAO;AACNuB,IAAAA,aAAa,CAAEc,KAAF,EAAU;AACtBuB,MAAAA,QAAQ,CAAE;AAAEC,QAAAA,cAAc,EAAExB,KAAK,CAAC3B;AAAxB,OAAF,CAAR;AACA,KAHK;;AAINoD,IAAAA,WAAW,CAAE5B,SAAF,EAAc;AACxBH,MAAAA,MAAM,CAAElC,gBAAF,CAAN,CACEmC,WADF,GAEEF,WAFF,CAEe;AACbK,QAAAA,YAAY,EAAE,CAAE,OAAF,CADD;AAEbD,QAAAA,SAFa;;AAGbE,QAAAA,YAAY,QAAc;AAAA,cAAZ,CAAEC,KAAF,CAAY;AACzBuB,UAAAA,QAAQ,CAAE;AAAEC,YAAAA,cAAc,EAAExB,KAAK,CAAC3B;AAAxB,WAAF,CAAR;AACA,SALY;;AAMb6B,QAAAA,OAAO,CAAEC,OAAF,EAAY;AAClBb,UAAAA,gBAAgB,CAACc,gBAAjB;AACAd,UAAAA,gBAAgB,CAACe,iBAAjB,CAAoCF,OAApC;AACA;;AATY,OAFf;AAaA,KAlBK;;AAmBNhB,IAAAA,aAAa,GAAG;AACfoC,MAAAA,QAAQ,CAAE;AAAEC,QAAAA,cAAc,EAAE;AAAlB,OAAF,CAAR;AACA;;AArBK,GAAP;AAuBA,CA1BoC,CAAtC;AA6BA,eAAevE,OAAO,CACrBJ,WADqB,EAErBkE,eAFqB,EAGrBM,iBAHqB,EAIrBvE,WAAW,CAAE,0BAAF,CAJU,CAAP,CAKZiC,iBALY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\tResponsiveWrapper,\n\twithNotices,\n\twithFilters,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );\nconst DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n} ) {\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(\n\t\tmedia,\n\t\tcurrentPostId\n\t);\n\n\tfunction onDropFiles( filesList ) {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonUpdateImage( image );\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image filename.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmedia.media_details.sizes?.full?.file ||\n\t\t\t\t\t\t\t\t\tmedia.slug\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Edit or update the image' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t<ResponsiveWrapper\n\t\t\t\t\t\t\t\t\t\t\tnaturalWidth={ mediaWidth }\n\t\t\t\t\t\t\t\t\t\t\tnaturalHeight={ mediaHeight }\n\t\t\t\t\t\t\t\t\t\t\tisInline\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ResponsiveWrapper>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isLoading && <Spinner /> }\n\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t{ media && (\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Replace Image' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onRemoveImage }\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postType?.labels?.remove_featured_image ||\n\t\t\t\t\t\t\t\tDEFAULT_REMOVE_FEATURE_IMAGE_LABEL }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType } = select( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { get } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
7
|
import { Modal, Button, ExternalLink, Flex, FlexItem } from '@wordpress/components';
|
|
13
8
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -164,7 +159,7 @@ export default function PostLockedModal() {
|
|
|
164
159
|
_wpnonce: postLockUtils.nonce
|
|
165
160
|
});
|
|
166
161
|
const allPostsUrl = addQueryArgs('edit.php', {
|
|
167
|
-
post_type:
|
|
162
|
+
post_type: postType === null || postType === void 0 ? void 0 : postType.slug
|
|
168
163
|
});
|
|
169
164
|
|
|
170
165
|
const allPostsLabel = __('Exit editor');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["get","__","sprintf","Modal","Button","ExternalLink","Flex","FlexItem","useSelect","useDispatch","addQueryArgs","useEffect","createInterpolateElement","addAction","removeAction","useInstanceId","store","coreStore","editorStore","PostLockedModal","instanceId","hookName","autosave","updatePostLock","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","previewLink","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditedPostPreviewLink","getEditorSettings","getPostType","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","name","avatar","avatar_src_2x","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel","strong","PreviewLink"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,KADD,EAECC,MAFD,EAGCC,YAHD,EAICC,IAJD,EAKCC,QALD,QAMO,uBANP;AAOA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,SAAT,EAAoBC,wBAApB,QAAoD,oBAApD;AACA,SAASC,SAAT,EAAoBC,YAApB,QAAwC,kBAAxC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;AAEA,e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CAToB,EAYzB;AACC6E,IAAAA,MAAM,EAAE,6BADT;AAECC,IAAAA,WAAW,EACV,cAAC,YAAD;AAAc,MAAA,IAAI,EAAGhD;AAArB,OACG9B,EAAE,CAAE,SAAF,CADL;AAHF,GAZyB,CAD3B,CADD,EAwBC,yBACGA,EAAE,CACH,0GADG,CADL,CAxBD,CA3BF,EA2DC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKG,CAAEwB,UAAF,IACD,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,IAAI,EAAG4C;AAAlC,KACGpE,EAAE,CAAE,WAAF,CADL,CADD,CANF,EAYC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAG0E;AAAjC,KACGE,aADH,CADD,CAZD,CA3DD,CArBD,CADD;AAsGA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = addQueryArgs( 'edit.php', {\n\t\tpost_type: get( postType, [ 'slug' ] ),\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount={ true }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t>\n\t\t\t{ !! userAvatar && (\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\twidth={ 64 }\n\t\t\t\t\theight={ 64 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div>\n\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button variant=\"tertiary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["__","sprintf","Modal","Button","ExternalLink","Flex","FlexItem","useSelect","useDispatch","addQueryArgs","useEffect","createInterpolateElement","addAction","removeAction","useInstanceId","store","coreStore","editorStore","PostLockedModal","instanceId","hookName","autosave","updatePostLock","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","previewLink","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditedPostPreviewLink","getEditorSettings","getPostType","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","name","avatar","avatar_src_2x","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","slug","allPostsLabel","strong","PreviewLink"],"mappings":";;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ACGb,wBAAwB,CACzBuD,eAAe,GACZjE,OAAO;AACP;AACAD,EAAAA,EAAE,CACD,0IADC,CAFK,EAKPkE,eALO,CADK,GAQZlE,EAAE,CACF,mIADE,CAToB,EAYzB;AACC8E,IAAAA,MAAM,EAAE,6BADT;AAECC,IAAAA,WAAW,EACV,cAAC,YAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG9B,EAAE,CAAE,SAAF,CADL;AAHF,GAZyB,CAD3B,CAFF,EA0BG,CAAEwB,UAAF,IACD,8BACC,yBACGb,wBAAwB,CACzBuD,eAAe,GACZjE,OAAO;AACP;AACAD,EAAAA,EAAE,CACD,qIADC,CAFK,EAKPkE,eALO,CADK,GAQZlE,EAAE,CACF,8HADE,CAToB,EAYzB;AACC8E,IAAAA,MAAM,EAAE,6BADT;AAECC,IAAAA,WAAW,EACV,cAAC,YAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG9B,EAAE,CAAE,SAAF,CADL;AAHF,GAZyB,CAD3B,CADD,EAwBC,yBACGA,EAAE,CACH,0GADG,CADL,CAxBD,CA3BF,EA2DC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKG,CAAEwB,UAAF,IACD,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,IAAI,EAAG4C;AAAlC,KACGpE,EAAE,CAAE,WAAF,CADL,CADD,CANF,EAYC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAG0E;AAAjC,KACGG,aADH,CADD,CAZD,CA3DD,CArBD,CADD;AAsGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = addQueryArgs( 'edit.php', {\n\t\tpost_type: postType?.slug,\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount={ true }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t>\n\t\t\t{ !! userAvatar && (\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\twidth={ 64 }\n\t\t\t\t\theight={ 64 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div>\n\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button variant=\"tertiary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
1
|
/**
|
|
6
2
|
* WordPress dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
4
|
import { compose } from '@wordpress/compose';
|
|
10
5
|
import { withSelect } from '@wordpress/data';
|
|
11
6
|
/**
|
|
@@ -27,13 +22,15 @@ export function PostPendingStatusCheck(_ref) {
|
|
|
27
22
|
return children;
|
|
28
23
|
}
|
|
29
24
|
export default compose(withSelect(select => {
|
|
25
|
+
var _getCurrentPost$_link, _getCurrentPost$_link2;
|
|
26
|
+
|
|
30
27
|
const {
|
|
31
28
|
isCurrentPostPublished,
|
|
32
29
|
getCurrentPostType,
|
|
33
30
|
getCurrentPost
|
|
34
31
|
} = select(editorStore);
|
|
35
32
|
return {
|
|
36
|
-
hasPublishAction:
|
|
33
|
+
hasPublishAction: (_getCurrentPost$_link = (_getCurrentPost$_link2 = getCurrentPost()._links) === null || _getCurrentPost$_link2 === void 0 ? void 0 : _getCurrentPost$_link2['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
|
|
37
34
|
isPublished: isCurrentPostPublished(),
|
|
38
35
|
postType: getCurrentPostType()
|
|
39
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-pending-status/check.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-pending-status/check.js"],"names":["compose","withSelect","store","editorStore","PostPendingStatusCheck","hasPublishAction","isPublished","children","select","isCurrentPostPublished","getCurrentPostType","getCurrentPost","_links","postType"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,UAAT,QAA2B,iBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,sBAAT,OAIH;AAAA,MAJoC;AACvCC,IAAAA,gBADuC;AAEvCC,IAAAA,WAFuC;AAGvCC,IAAAA;AAHuC,GAIpC;;AACH,MAAKD,WAAW,IAAI,CAAED,gBAAtB,EAAyC;AACxC,WAAO,IAAP;AACA;;AAED,SAAOE,QAAP;AACA;AAED,eAAeP,OAAO,CACrBC,UAAU,CAAIO,MAAF,IAAc;AAAA;;AACzB,QAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA,kBAA1B;AAA8CC,IAAAA;AAA9C,MACLH,MAAM,CAAEL,WAAF,CADP;AAEA,SAAO;AACNE,IAAAA,gBAAgB,qDACfM,cAAc,GAAGC,MADF,2DACf,uBAA2B,mBAA3B,CADe,yEACqC,KAF/C;AAGNN,IAAAA,WAAW,EAAEG,sBAAsB,EAH7B;AAINI,IAAAA,QAAQ,EAAEH,kBAAkB;AAJtB,GAAP;AAMA,CATS,CADW,CAAP,CAWZN,sBAXY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PostPendingStatusCheck( {\n\thasPublishAction,\n\tisPublished,\n\tchildren,\n} ) {\n\tif ( isPublished || ! hasPublishAction ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isCurrentPostPublished, getCurrentPostType, getCurrentPost } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t} )\n)( PostPendingStatusCheck );\n"]}
|
|
@@ -3,7 +3,6 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { get } from 'lodash';
|
|
7
6
|
import classnames from 'classnames';
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
@@ -224,6 +223,8 @@ export class PostPreviewButton extends Component {
|
|
|
224
223
|
|
|
225
224
|
}
|
|
226
225
|
export default compose([withSelect((select, _ref) => {
|
|
226
|
+
var _postType$viewable;
|
|
227
|
+
|
|
227
228
|
let {
|
|
228
229
|
forcePreviewLink,
|
|
229
230
|
forceIsAutosaveable
|
|
@@ -248,7 +249,7 @@ export default compose([withSelect((select, _ref) => {
|
|
|
248
249
|
previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
|
|
249
250
|
isSaveable: isEditedPostSaveable(),
|
|
250
251
|
isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),
|
|
251
|
-
isViewable:
|
|
252
|
+
isViewable: (_postType$viewable = postType === null || postType === void 0 ? void 0 : postType.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false,
|
|
252
253
|
isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1,
|
|
253
254
|
isPostLocked: isPostLocked()
|
|
254
255
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-preview-button/index.js"],"names":["get","classnames","Component","createRef","renderToString","Button","Path","SVG","VisuallyHidden","__","_x","withSelect","withDispatch","ifCondition","compose","applyFilters","store","coreStore","editorStore","writeInterstitialMessage","targetDocument","markup","write","title","close","PostPreviewButton","constructor","arguments","buttonRef","openPreviewWindow","bind","componentDidUpdate","prevProps","previewLink","props","setPreviewWindowLink","url","previewWindow","closed","location","current","focus","getWindowTarget","postId","event","preventDefault","window","open","isAutosaveable","isPostLocked","target","href","isDraft","savePost","isPreview","autosave","document","render","currentPostLink","isSaveable","role","classNames","className","undefined","textContent","select","forcePreviewLink","forceIsAutosaveable","getCurrentPostId","getCurrentPostAttribute","getEditedPostAttribute","isEditedPostSaveable","isEditedPostAutosaveable","getEditedPostPreviewLink","getPostType","postType","isViewable","indexOf","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,SAApB,EAA+BC,cAA/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AAmB,IAAIK,wBAAwB,EANzD;AAONI,IAAAA,UAAU,EAAE5E,GAAG,CAAE2E,QAAF,EAAY,CAAE,UAAF,CAAZ,EAA4B,KAA5B,CAPT;AAQNvB,IAAAA,OAAO,EACN,CAAE,OAAF,EAAW,YAAX,EAA0ByB,OAA1B,CACCP,sBAAsB,CAAE,QAAF,CADvB,MAEM,CAAC,CAXF;AAYNrB,IAAAA,YAAY,EAAEA,YAAY;AAZpB,GAAP;AAcA,CA7BS,CADa,EA+BvBrC,YAAY,CAAIkE,QAAF,KAAkB;AAC/BvB,EAAAA,QAAQ,EAAEuB,QAAQ,CAAE5D,WAAF,CAAR,CAAwBqC,QADH;AAE/BF,EAAAA,QAAQ,EAAEyB,QAAQ,CAAE5D,WAAF,CAAR,CAAwBmC;AAFH,CAAlB,CAAF,CA/BW,EAmCvBxC,WAAW,CAAE;AAAA,MAAE;AAAE+D,IAAAA;AAAF,GAAF;AAAA,SAAsBA,UAAtB;AAAA,CAAF,CAnCY,CAAF,CAAP,CAoCVnD,iBApCU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Component, createRef, renderToString } from '@wordpress/element';\nimport { Button, Path, SVG, VisuallyHidden } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { ifCondition, compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction writeInterstitialMessage( targetDocument ) {\n\tlet markup = renderToString(\n\t\t<div className=\"editor-post-preview-button__interstitial-message\">\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\">\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"outer\"\n\t\t\t\t\td=\"M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"inner\"\n\t\t\t\t\td=\"M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t</SVG>\n\t\t\t<p>{ __( 'Generating preview…' ) }</p>\n\t\t</div>\n\t);\n\n\tmarkup += `\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t`;\n\n\t/**\n\t * Filters the interstitial message shown when generating previews.\n\t *\n\t * @param {string} markup The preview interstitial markup.\n\t */\n\tmarkup = applyFilters( 'editor.PostPreview.interstitialMarkup', markup );\n\n\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\n}\n\nexport class PostPreviewButton extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.buttonRef = createRef();\n\n\t\tthis.openPreviewWindow = this.openPreviewWindow.bind( this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { previewLink } = this.props;\n\t\t// This relies on the window being responsible to unset itself when\n\t\t// navigation occurs or a new preview window is opened, to avoid\n\t\t// unintentional forceful redirects.\n\t\tif ( previewLink && ! prevProps.previewLink ) {\n\t\t\tthis.setPreviewWindowLink( previewLink );\n\t\t}\n\t}\n\n\t/**\n\t * Sets the preview window's location to the given URL, if a preview window\n\t * exists and is not closed.\n\t *\n\t * @param {string} url URL to assign as preview window location.\n\t */\n\tsetPreviewWindowLink( url ) {\n\t\tconst { previewWindow } = this;\n\n\t\tif ( previewWindow && ! previewWindow.closed ) {\n\t\t\tpreviewWindow.location = url;\n\t\t\tif ( this.buttonRef.current ) {\n\t\t\t\tthis.buttonRef.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tgetWindowTarget() {\n\t\tconst { postId } = this.props;\n\t\treturn `wp-preview-${ postId }`;\n\t}\n\n\topenPreviewWindow( event ) {\n\t\t// Our Preview button has its 'href' and 'target' set correctly for a11y\n\t\t// purposes. Unfortunately, though, we can't rely on the default 'click'\n\t\t// handler since sometimes it incorrectly opens a new tab instead of reusing\n\t\t// the existing one.\n\t\t// https://github.com/WordPress/gutenberg/pull/8330\n\t\tevent.preventDefault();\n\n\t\t// Open up a Preview tab if needed. This is where we'll show the preview.\n\t\tif ( ! this.previewWindow || this.previewWindow.closed ) {\n\t\t\tthis.previewWindow = window.open( '', this.getWindowTarget() );\n\t\t}\n\n\t\t// Focus the Preview tab. This might not do anything, depending on the browser's\n\t\t// and user's preferences.\n\t\t// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus\n\t\tthis.previewWindow.focus();\n\n\t\tif (\n\t\t\t// If we don't need to autosave the post before previewing, then we simply\n\t\t\t// load the Preview URL in the Preview tab.\n\t\t\t! this.props.isAutosaveable ||\n\t\t\t// Do not save or overwrite the post, if the post is already locked.\n\t\t\tthis.props.isPostLocked\n\t\t) {\n\t\t\tthis.setPreviewWindowLink( event.target.href );\n\t\t\treturn;\n\t\t}\n\n\t\t// Request an autosave. This happens asynchronously and causes the component\n\t\t// to update when finished.\n\t\tif ( this.props.isDraft ) {\n\t\t\tthis.props.savePost( { isPreview: true } );\n\t\t} else {\n\t\t\tthis.props.autosave( { isPreview: true } );\n\t\t}\n\n\t\t// Display a 'Generating preview' message in the Preview tab while we wait for the\n\t\t// autosave to finish.\n\t\twriteInterstitialMessage( this.previewWindow.document );\n\t}\n\n\trender() {\n\t\tconst { previewLink, currentPostLink, isSaveable, role } = this.props;\n\n\t\t// Link to the `?preview=true` URL if we have it, since this lets us see\n\t\t// changes that were autosaved since the post was last published. Otherwise,\n\t\t// just link to the post's URL.\n\t\tconst href = previewLink || currentPostLink;\n\n\t\tconst classNames = classnames(\n\t\t\t{\n\t\t\t\t'editor-post-preview': ! this.props.className,\n\t\t\t},\n\t\t\tthis.props.className\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tvariant={ ! this.props.className ? 'tertiary' : undefined }\n\t\t\t\tclassName={ classNames }\n\t\t\t\thref={ href }\n\t\t\t\ttarget={ this.getWindowTarget() }\n\t\t\t\tdisabled={ ! isSaveable }\n\t\t\t\tonClick={ this.openPreviewWindow }\n\t\t\t\tref={ this.buttonRef }\n\t\t\t\trole={ role }\n\t\t\t>\n\t\t\t\t{ this.props.textContent ? (\n\t\t\t\t\tthis.props.textContent\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ _x( 'Preview', 'imperative verb' ) }\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { forcePreviewLink, forceIsAutosaveable } ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostAttribute,\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditedPostSaveable,\n\t\t\tisEditedPostAutosaveable,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tisPostLocked,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\tconst previewLink = getEditedPostPreviewLink();\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tcurrentPostLink: getCurrentPostAttribute( 'link' ),\n\t\t\tpreviewLink:\n\t\t\t\tforcePreviewLink !== undefined ? forcePreviewLink : previewLink,\n\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\tisAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),\n\t\t\tisViewable: get( postType, [ 'viewable' ], false ),\n\t\t\tisDraft:\n\t\t\t\t[ 'draft', 'auto-draft' ].indexOf(\n\t\t\t\t\tgetEditedPostAttribute( 'status' )\n\t\t\t\t) !== -1,\n\t\t\tisPostLocked: isPostLocked(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tautosave: dispatch( editorStore ).autosave,\n\t\tsavePost: dispatch( editorStore ).savePost,\n\t} ) ),\n\tifCondition( ( { isViewable } ) => isViewable ),\n] )( PostPreviewButton );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-preview-button/index.js"],"names":["classnames","Component","createRef","renderToString","Button","Path","SVG","VisuallyHidden","__","_x","withSelect","withDispatch","ifCondition","compose","applyFilters","store","coreStore","editorStore","writeInterstitialMessage","targetDocument","markup","write","title","close","PostPreviewButton","constructor","arguments","buttonRef","openPreviewWindow","bind","componentDidUpdate","prevProps","previewLink","props","setPreviewWindowLink","url","previewWindow","closed","location","current","focus","getWindowTarget","postId","event","preventDefault","window","open","isAutosaveable","isPostLocked","target","href","isDraft","savePost","isPreview","autosave","document","render","currentPostLink","isSaveable","role","classNames","className","undefined","textContent","select","forcePreviewLink","forceIsAutosaveable","getCurrentPostId","getCurrentPostAttribute","getEditedPostAttribute","isEditedPostSaveable","isEditedPostAutosaveable","getEditedPostPreviewLink","getPostType","postType","isViewable","viewable","indexOf","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,SAApB,EAA+BC,cAA/B,QAAqD,oBAArD;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,GAAvB,EAA4BC,cAA5B,QAAkD,uBAAlD;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;;AAEA,SAASC,wBAAT,CAAmCC,cAAnC,EAAoD;AACnD,MAAIC,MAAM,GAAGjB,cAAc,CAC1B;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,GAAD;AAAK,IAAA,KAAK,EAAC,4BAAX;AAAwC,IAAA,OAAO,EAAC;AAAhD,KACC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,OADX;AAEC,IAAA,CAAC,EAAC,uEAFH;AAGC,IAAA,IAAI,EAAC;AAHN,IADD,EAMC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,OADX;AAEC,IAAA,CAAC,EAAC,0nBAFH;AAGC,IAAA,IAAI,EAAC;AAHN,IAND,CADD,EAaC,yBAAKK,EAAE,CAAE,qBAAF,CAAP,CAbD,CAD0B,CAA3B;AAkBAY,EAAAA,MAAM,IAAK;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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BAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,SAAO;AACN3B,IAAAA,MAAM,EAAEyB,gBAAgB,EADlB;AAENV,IAAAA,eAAe,EAAEW,uBAAuB,CAAE,MAAF,CAFlC;AAGNpC,IAAAA,WAAW,EACViC,gBAAgB,KAAKH,SAArB,GAAiCG,gBAAjC,GAAoDjC,WAJ/C;AAKN0B,IAAAA,UAAU,EAAEY,oBAAoB,EAL1B;AAMNvB,IAAAA,cAAc,EAAEmB,mBAAmB,IAAIK,wBAAwB,EANzD;AAONI,IAAAA,UAAU,wBAAED,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEE,QAAZ,mEAAwB,KAP5B;AAQNzB,IAAAA,OAAO,EACN,CAAE,OAAF,EAAW,YAAX,EAA0B0B,OAA1B,CACCR,sBAAsB,CAAE,QAAF,CADvB,MAEM,CAAC,CAXF;AAYNrB,IAAAA,YAAY,EAAEA,YAAY;AAZpB,GAAP;AAcA,CA7BS,CADa,EA+BvBrC,YAAY,CAAImE,QAAF,KAAkB;AAC/BxB,EAAAA,QAAQ,EAAEwB,QAAQ,CAAE7D,WAAF,CAAR,CAAwBqC,QADH;AAE/BF,EAAAA,QAAQ,EAAE0B,QAAQ,CAAE7D,WAAF,CAAR,CAAwBmC;AAFH,CAAlB,CAAF,CA/BW,EAmCvBxC,WAAW,CAAE;AAAA,MAAE;AAAE+D,IAAAA;AAAF,GAAF;AAAA,SAAsBA,UAAtB;AAAA,CAAF,CAnCY,CAAF,CAAP,CAoCVnD,iBApCU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Component, createRef, renderToString } from '@wordpress/element';\nimport { Button, Path, SVG, VisuallyHidden } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { ifCondition, compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction writeInterstitialMessage( targetDocument ) {\n\tlet markup = renderToString(\n\t\t<div className=\"editor-post-preview-button__interstitial-message\">\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\">\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"outer\"\n\t\t\t\t\td=\"M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"inner\"\n\t\t\t\t\td=\"M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t</SVG>\n\t\t\t<p>{ __( 'Generating preview…' ) }</p>\n\t\t</div>\n\t);\n\n\tmarkup += `\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t`;\n\n\t/**\n\t * Filters the interstitial message shown when generating previews.\n\t *\n\t * @param {string} markup The preview interstitial markup.\n\t */\n\tmarkup = applyFilters( 'editor.PostPreview.interstitialMarkup', markup );\n\n\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\n}\n\nexport class PostPreviewButton extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.buttonRef = createRef();\n\n\t\tthis.openPreviewWindow = this.openPreviewWindow.bind( this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { previewLink } = this.props;\n\t\t// This relies on the window being responsible to unset itself when\n\t\t// navigation occurs or a new preview window is opened, to avoid\n\t\t// unintentional forceful redirects.\n\t\tif ( previewLink && ! prevProps.previewLink ) {\n\t\t\tthis.setPreviewWindowLink( previewLink );\n\t\t}\n\t}\n\n\t/**\n\t * Sets the preview window's location to the given URL, if a preview window\n\t * exists and is not closed.\n\t *\n\t * @param {string} url URL to assign as preview window location.\n\t */\n\tsetPreviewWindowLink( url ) {\n\t\tconst { previewWindow } = this;\n\n\t\tif ( previewWindow && ! previewWindow.closed ) {\n\t\t\tpreviewWindow.location = url;\n\t\t\tif ( this.buttonRef.current ) {\n\t\t\t\tthis.buttonRef.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tgetWindowTarget() {\n\t\tconst { postId } = this.props;\n\t\treturn `wp-preview-${ postId }`;\n\t}\n\n\topenPreviewWindow( event ) {\n\t\t// Our Preview button has its 'href' and 'target' set correctly for a11y\n\t\t// purposes. Unfortunately, though, we can't rely on the default 'click'\n\t\t// handler since sometimes it incorrectly opens a new tab instead of reusing\n\t\t// the existing one.\n\t\t// https://github.com/WordPress/gutenberg/pull/8330\n\t\tevent.preventDefault();\n\n\t\t// Open up a Preview tab if needed. This is where we'll show the preview.\n\t\tif ( ! this.previewWindow || this.previewWindow.closed ) {\n\t\t\tthis.previewWindow = window.open( '', this.getWindowTarget() );\n\t\t}\n\n\t\t// Focus the Preview tab. This might not do anything, depending on the browser's\n\t\t// and user's preferences.\n\t\t// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus\n\t\tthis.previewWindow.focus();\n\n\t\tif (\n\t\t\t// If we don't need to autosave the post before previewing, then we simply\n\t\t\t// load the Preview URL in the Preview tab.\n\t\t\t! this.props.isAutosaveable ||\n\t\t\t// Do not save or overwrite the post, if the post is already locked.\n\t\t\tthis.props.isPostLocked\n\t\t) {\n\t\t\tthis.setPreviewWindowLink( event.target.href );\n\t\t\treturn;\n\t\t}\n\n\t\t// Request an autosave. This happens asynchronously and causes the component\n\t\t// to update when finished.\n\t\tif ( this.props.isDraft ) {\n\t\t\tthis.props.savePost( { isPreview: true } );\n\t\t} else {\n\t\t\tthis.props.autosave( { isPreview: true } );\n\t\t}\n\n\t\t// Display a 'Generating preview' message in the Preview tab while we wait for the\n\t\t// autosave to finish.\n\t\twriteInterstitialMessage( this.previewWindow.document );\n\t}\n\n\trender() {\n\t\tconst { previewLink, currentPostLink, isSaveable, role } = this.props;\n\n\t\t// Link to the `?preview=true` URL if we have it, since this lets us see\n\t\t// changes that were autosaved since the post was last published. Otherwise,\n\t\t// just link to the post's URL.\n\t\tconst href = previewLink || currentPostLink;\n\n\t\tconst classNames = classnames(\n\t\t\t{\n\t\t\t\t'editor-post-preview': ! this.props.className,\n\t\t\t},\n\t\t\tthis.props.className\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tvariant={ ! this.props.className ? 'tertiary' : undefined }\n\t\t\t\tclassName={ classNames }\n\t\t\t\thref={ href }\n\t\t\t\ttarget={ this.getWindowTarget() }\n\t\t\t\tdisabled={ ! isSaveable }\n\t\t\t\tonClick={ this.openPreviewWindow }\n\t\t\t\tref={ this.buttonRef }\n\t\t\t\trole={ role }\n\t\t\t>\n\t\t\t\t{ this.props.textContent ? (\n\t\t\t\t\tthis.props.textContent\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ _x( 'Preview', 'imperative verb' ) }\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { forcePreviewLink, forceIsAutosaveable } ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostAttribute,\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditedPostSaveable,\n\t\t\tisEditedPostAutosaveable,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tisPostLocked,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\tconst previewLink = getEditedPostPreviewLink();\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tcurrentPostLink: getCurrentPostAttribute( 'link' ),\n\t\t\tpreviewLink:\n\t\t\t\tforcePreviewLink !== undefined ? forcePreviewLink : previewLink,\n\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\tisAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),\n\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\tisDraft:\n\t\t\t\t[ 'draft', 'auto-draft' ].indexOf(\n\t\t\t\t\tgetEditedPostAttribute( 'status' )\n\t\t\t\t) !== -1,\n\t\t\tisPostLocked: isPostLocked(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tautosave: dispatch( editorStore ).autosave,\n\t\tsavePost: dispatch( editorStore ).savePost,\n\t} ) ),\n\tifCondition( ( { isViewable } ) => isViewable ),\n] )( PostPreviewButton );\n"]}
|
|
@@ -4,7 +4,6 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* External dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { get } from 'lodash';
|
|
8
7
|
import classnames from 'classnames';
|
|
9
8
|
/**
|
|
10
9
|
* WordPress dependencies
|
|
@@ -162,7 +161,7 @@ export class PostPublishButton extends Component {
|
|
|
162
161
|
const buttonProps = {
|
|
163
162
|
'aria-disabled': isButtonDisabled,
|
|
164
163
|
className: 'editor-post-publish-button',
|
|
165
|
-
isBusy: !isAutoSaving && isSaving
|
|
164
|
+
isBusy: !isAutoSaving && isSaving,
|
|
166
165
|
variant: 'primary',
|
|
167
166
|
onClick: this.createOnClick(onClickButton)
|
|
168
167
|
};
|
|
@@ -192,6 +191,8 @@ export class PostPublishButton extends Component {
|
|
|
192
191
|
|
|
193
192
|
}
|
|
194
193
|
export default compose([withSelect(select => {
|
|
194
|
+
var _getCurrentPost$_link, _getCurrentPost$_link2;
|
|
195
|
+
|
|
195
196
|
const {
|
|
196
197
|
isSavingPost,
|
|
197
198
|
isAutosavingPost,
|
|
@@ -219,7 +220,7 @@ export default compose([withSelect(select => {
|
|
|
219
220
|
isPostSavingLocked: isPostSavingLocked(),
|
|
220
221
|
isPublishable: isEditedPostPublishable(),
|
|
221
222
|
isPublished: isCurrentPostPublished(),
|
|
222
|
-
hasPublishAction:
|
|
223
|
+
hasPublishAction: (_getCurrentPost$_link = (_getCurrentPost$_link2 = getCurrentPost()._links) === null || _getCurrentPost$_link2 === void 0 ? void 0 : _getCurrentPost$_link2['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
|
|
223
224
|
postType: getCurrentPostType(),
|
|
224
225
|
postId: getCurrentPostId(),
|
|
225
226
|
hasNonPostEntityChanges: hasNonPostEntityChanges(),
|