@wordpress/editor 13.4.0 → 13.6.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/editor-help/index.native.js +13 -10
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/media-categories/index.js +1 -1
- package/build/components/media-categories/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/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 -7
- 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 +1 -8
- package/build/components/post-taxonomies/most-used-terms.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/provider/use-block-editor-settings.js +1 -1
- package/build/components/provider/use-block-editor-settings.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/editor-help/index.native.js +13 -9
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -1
- package/build-module/components/media-categories/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/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 -6
- 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 +1 -7
- package/build-module/components/post-taxonomies/most-used-terms.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/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.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 -1
- package/build-style/style.css +1 -1
- package/package.json +30 -30
- package/src/components/autosave-monitor/test/index.js +4 -4
- package/src/components/document-outline/index.js +6 -3
- package/src/components/editor-help/index.native.js +21 -14
- package/src/components/media-categories/index.js +1 -1
- package/src/components/page-attributes/check.js +3 -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 -32
- package/src/components/post-taxonomies/hierarchical-term-selector.js +15 -37
- package/src/components/post-taxonomies/most-used-terms.js +1 -7
- package/src/components/post-text-editor/test/index.js +0 -2
- package/src/components/post-visibility/check.js +2 -10
- package/src/components/provider/use-block-editor-settings.js +1 -0
- package/src/components/theme-support-check/index.js +1 -6
- package/src/store/test/actions.js +0 -2
- package/src/store/utils/notice-builder.js +2 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/index.js"],"names":["PostPublishPanel","Component","constructor","arguments","onSubmit","bind","componentDidUpdate","prevProps","isPublished","props","isSaving","isDirty","onClose","hasPublishAction","isPostTypeViewable","render","forceIsDirty","forceIsSaving","isBeingScheduled","isPublishSidebarEnabled","isScheduled","isSavingNonPostEntityChanges","onTogglePublishSidebar","PostPublishExtension","PrePublishExtension","additionalProps","propsForPanel","isPublishedOrScheduled","isPrePublish","isPostPublish","closeSmall","select","getPostType","coreStore","getCurrentPost","getEditedPostAttribute","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostBeingScheduled","isEditedPostDirty","isSavingPost","editorStore","postType","dispatch","disablePublishSidebar","enablePublishSidebar","withFocusReturn","withConstrainedTabbing"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAMO,MAAMA,gBAAN,SAA+BC,kBAA/B,CAAyC;AAC/CC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,gBA/CU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport {\n\tButton,\n\tSpinner,\n\tCheckboxControl,\n\twithFocusReturn,\n\twithConstrainedTabbing,\n} from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { closeSmall } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostPublishButton from '../post-publish-button';\nimport PostPublishPanelPrepublish from './prepublish';\nimport PostPublishPanelPostpublish from './postpublish';\nimport { store as editorStore } from '../../store';\n\nexport class PostPublishPanel extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.onSubmit = this.onSubmit.bind( this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Automatically collapse the publish sidebar when a post\n\t\t// is published and the user makes an edit.\n\t\tif (\n\t\t\tprevProps.isPublished &&\n\t\t\t! this.props.isSaving &&\n\t\t\tthis.props.isDirty\n\t\t) {\n\t\t\tthis.props.onClose();\n\t\t}\n\t}\n\n\tonSubmit() {\n\t\tconst { onClose, hasPublishAction, isPostTypeViewable } = this.props;\n\t\tif ( ! hasPublishAction || ! isPostTypeViewable ) {\n\t\t\tonClose();\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tforceIsDirty,\n\t\t\tforceIsSaving,\n\t\t\tisBeingScheduled,\n\t\t\tisPublished,\n\t\t\tisPublishSidebarEnabled,\n\t\t\tisScheduled,\n\t\t\tisSaving,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t\tonClose,\n\t\t\tonTogglePublishSidebar,\n\t\t\tPostPublishExtension,\n\t\t\tPrePublishExtension,\n\t\t\t...additionalProps\n\t\t} = this.props;\n\t\tconst {\n\t\t\thasPublishAction,\n\t\t\tisDirty,\n\t\t\tisPostTypeViewable,\n\t\t\t...propsForPanel\n\t\t} = additionalProps;\n\t\tconst isPublishedOrScheduled =\n\t\t\tisPublished || ( isScheduled && isBeingScheduled );\n\t\tconst isPrePublish = ! isPublishedOrScheduled && ! isSaving;\n\t\tconst isPostPublish = isPublishedOrScheduled && ! isSaving;\n\t\treturn (\n\t\t\t<div className=\"editor-post-publish-panel\" { ...propsForPanel }>\n\t\t\t\t<div className=\"editor-post-publish-panel__header\">\n\t\t\t\t\t{ isPostPublish ? (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\tlabel={ __( 'Close panel' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<div className=\"editor-post-publish-panel__header-publish-button\">\n\t\t\t\t\t\t\t\t<PostPublishButton\n\t\t\t\t\t\t\t\t\tfocusOnMount={ true }\n\t\t\t\t\t\t\t\t\tonSubmit={ this.onSubmit }\n\t\t\t\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\t\t\t\tforceIsSaving={ forceIsSaving }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"editor-post-publish-panel__header-cancel-button\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdisabled={ isSavingNonPostEntityChanges }\n\t\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-post-publish-panel__content\">\n\t\t\t\t\t{ isPrePublish && (\n\t\t\t\t\t\t<PostPublishPanelPrepublish>\n\t\t\t\t\t\t\t{ PrePublishExtension && <PrePublishExtension /> }\n\t\t\t\t\t\t</PostPublishPanelPrepublish>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isPostPublish && (\n\t\t\t\t\t\t<PostPublishPanelPostpublish focusOnMount={ true }>\n\t\t\t\t\t\t\t{ PostPublishExtension && <PostPublishExtension /> }\n\t\t\t\t\t\t</PostPublishPanelPostpublish>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isSaving && <Spinner /> }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-post-publish-panel__footer\">\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Always show pre-publish checks.' ) }\n\t\t\t\t\t\tchecked={ isPublishSidebarEnabled }\n\t\t\t\t\t\tonChange={ onTogglePublishSidebar }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst {\n\t\t\tgetCurrentPost,\n\t\t\tgetEditedPostAttribute,\n\t\t\tisCurrentPostPublished,\n\t\t\tisCurrentPostScheduled,\n\t\t\tisEditedPostBeingScheduled,\n\t\t\tisEditedPostDirty,\n\t\t\tisSavingPost,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst { isPublishSidebarEnabled } = select( editorStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\thasPublishAction: get(\n\t\t\t\tgetCurrentPost(),\n\t\t\t\t[ '_links', 'wp:action-publish' ],\n\t\t\t\tfalse\n\t\t\t),\n\t\t\tisPostTypeViewable: get( postType, [ 'viewable' ], false ),\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisDirty: isEditedPostDirty(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisPublishSidebarEnabled: isPublishSidebarEnabled(),\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { isPublishSidebarEnabled } ) => {\n\t\tconst { disablePublishSidebar, enablePublishSidebar } =\n\t\t\tdispatch( editorStore );\n\t\treturn {\n\t\t\tonTogglePublishSidebar: () => {\n\t\t\t\tif ( isPublishSidebarEnabled ) {\n\t\t\t\t\tdisablePublishSidebar();\n\t\t\t\t} else {\n\t\t\t\t\tenablePublishSidebar();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t} ),\n\twithFocusReturn,\n\twithConstrainedTabbing,\n] )( PostPublishPanel );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/index.js"],"names":["PostPublishPanel","Component","constructor","arguments","onSubmit","bind","componentDidUpdate","prevProps","isPublished","props","isSaving","isDirty","onClose","hasPublishAction","isPostTypeViewable","render","forceIsDirty","forceIsSaving","isBeingScheduled","isPublishSidebarEnabled","isScheduled","isSavingNonPostEntityChanges","onTogglePublishSidebar","PostPublishExtension","PrePublishExtension","additionalProps","propsForPanel","isPublishedOrScheduled","isPrePublish","isPostPublish","closeSmall","select","getPostType","coreStore","getCurrentPost","getEditedPostAttribute","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostBeingScheduled","isEditedPostDirty","isSavingPost","editorStore","postType","_links","viewable","dispatch","disablePublishSidebar","enablePublishSidebar","withFocusReturn","withConstrainedTabbing"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAeA;AACA;AACA;AAMO,MAAMA,gBAAN,SAA+BC,kBAA/B,CAAyC;AAC/CC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,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YAPK;AAQLnB,IAAAA;AARK,MASFU,MAAM,CAAEU,YAAF,CATV;AAUA,QAAM;AAAEtB,IAAAA;AAAF,MAA8BY,MAAM,CAAEU,YAAF,CAA1C;AACA,QAAMC,QAAQ,GAAGV,WAAW,CAAEG,sBAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,SAAO;AACNtB,IAAAA,gBAAgB,qDACfqB,cAAc,GAAGS,MADF,2DACf,uBAA2B,mBAA3B,CADe,yEACqC,KAF/C;AAGN7B,IAAAA,kBAAkB,EAAE4B,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEE,QAHxB;AAIN1B,IAAAA,gBAAgB,EAAEoB,0BAA0B,EAJtC;AAKN3B,IAAAA,OAAO,EAAE4B,iBAAiB,EALpB;AAMN/B,IAAAA,WAAW,EAAE4B,sBAAsB,EAN7B;AAONjB,IAAAA,uBAAuB,EAAEA,uBAAuB,EAP1C;AAQNT,IAAAA,QAAQ,EAAE8B,YAAY,EARhB;AASNnB,IAAAA,4BAA4B,EAAEA,4BAA4B,EATpD;AAUND,IAAAA,WAAW,EAAEiB,sBAAsB;AAV7B,GAAP;AAYA,CA3BD,CADuB,EA6BvB,wBAAc,CAAEQ,QAAF,WAA6C;AAAA,MAAjC;AAAE1B,IAAAA;AAAF,GAAiC;AAC1D,QAAM;AAAE2B,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MACLF,QAAQ,CAAEJ,YAAF,CADT;AAEA,SAAO;AACNnB,IAAAA,sBAAsB,EAAE,MAAM;AAC7B,UAAKH,uBAAL,EAA+B;AAC9B2B,QAAAA,qBAAqB;AACrB,OAFD,MAEO;AACNC,QAAAA,oBAAoB;AACpB;AACD;AAPK,GAAP;AASA,CAZD,CA7BuB,EA0CvBC,2BA1CuB,EA2CvBC,kCA3CuB,CAAT,EA4CVjD,gBA5CU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport {\n\tButton,\n\tSpinner,\n\tCheckboxControl,\n\twithFocusReturn,\n\twithConstrainedTabbing,\n} from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { closeSmall } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostPublishButton from '../post-publish-button';\nimport PostPublishPanelPrepublish from './prepublish';\nimport PostPublishPanelPostpublish from './postpublish';\nimport { store as editorStore } from '../../store';\n\nexport class PostPublishPanel extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.onSubmit = this.onSubmit.bind( this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Automatically collapse the publish sidebar when a post\n\t\t// is published and the user makes an edit.\n\t\tif (\n\t\t\tprevProps.isPublished &&\n\t\t\t! this.props.isSaving &&\n\t\t\tthis.props.isDirty\n\t\t) {\n\t\t\tthis.props.onClose();\n\t\t}\n\t}\n\n\tonSubmit() {\n\t\tconst { onClose, hasPublishAction, isPostTypeViewable } = this.props;\n\t\tif ( ! hasPublishAction || ! isPostTypeViewable ) {\n\t\t\tonClose();\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tforceIsDirty,\n\t\t\tforceIsSaving,\n\t\t\tisBeingScheduled,\n\t\t\tisPublished,\n\t\t\tisPublishSidebarEnabled,\n\t\t\tisScheduled,\n\t\t\tisSaving,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t\tonClose,\n\t\t\tonTogglePublishSidebar,\n\t\t\tPostPublishExtension,\n\t\t\tPrePublishExtension,\n\t\t\t...additionalProps\n\t\t} = this.props;\n\t\tconst {\n\t\t\thasPublishAction,\n\t\t\tisDirty,\n\t\t\tisPostTypeViewable,\n\t\t\t...propsForPanel\n\t\t} = additionalProps;\n\t\tconst isPublishedOrScheduled =\n\t\t\tisPublished || ( isScheduled && isBeingScheduled );\n\t\tconst isPrePublish = ! isPublishedOrScheduled && ! isSaving;\n\t\tconst isPostPublish = isPublishedOrScheduled && ! isSaving;\n\t\treturn (\n\t\t\t<div className=\"editor-post-publish-panel\" { ...propsForPanel }>\n\t\t\t\t<div className=\"editor-post-publish-panel__header\">\n\t\t\t\t\t{ isPostPublish ? (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\tlabel={ __( 'Close panel' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<div className=\"editor-post-publish-panel__header-publish-button\">\n\t\t\t\t\t\t\t\t<PostPublishButton\n\t\t\t\t\t\t\t\t\tfocusOnMount={ true }\n\t\t\t\t\t\t\t\t\tonSubmit={ this.onSubmit }\n\t\t\t\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\t\t\t\tforceIsSaving={ forceIsSaving }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"editor-post-publish-panel__header-cancel-button\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdisabled={ isSavingNonPostEntityChanges }\n\t\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-post-publish-panel__content\">\n\t\t\t\t\t{ isPrePublish && (\n\t\t\t\t\t\t<PostPublishPanelPrepublish>\n\t\t\t\t\t\t\t{ PrePublishExtension && <PrePublishExtension /> }\n\t\t\t\t\t\t</PostPublishPanelPrepublish>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isPostPublish && (\n\t\t\t\t\t\t<PostPublishPanelPostpublish focusOnMount={ true }>\n\t\t\t\t\t\t\t{ PostPublishExtension && <PostPublishExtension /> }\n\t\t\t\t\t\t</PostPublishPanelPostpublish>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isSaving && <Spinner /> }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-post-publish-panel__footer\">\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Always show pre-publish checks.' ) }\n\t\t\t\t\t\tchecked={ isPublishSidebarEnabled }\n\t\t\t\t\t\tonChange={ onTogglePublishSidebar }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst {\n\t\t\tgetCurrentPost,\n\t\t\tgetEditedPostAttribute,\n\t\t\tisCurrentPostPublished,\n\t\t\tisCurrentPostScheduled,\n\t\t\tisEditedPostBeingScheduled,\n\t\t\tisEditedPostDirty,\n\t\t\tisSavingPost,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst { isPublishSidebarEnabled } = select( editorStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tisPostTypeViewable: postType?.viewable,\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisDirty: isEditedPostDirty(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisPublishSidebarEnabled: isPublishSidebarEnabled(),\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { isPublishSidebarEnabled } ) => {\n\t\tconst { disablePublishSidebar, enablePublishSidebar } =\n\t\t\tdispatch( editorStore );\n\t\treturn {\n\t\t\tonTogglePublishSidebar: () => {\n\t\t\t\tif ( isPublishSidebarEnabled ) {\n\t\t\t\t\tdisablePublishSidebar();\n\t\t\t\t} else {\n\t\t\t\t\tenablePublishSidebar();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t} ),\n\twithFocusReturn,\n\twithConstrainedTabbing,\n] )( PostPublishPanel );\n"]}
|
|
@@ -7,8 +7,6 @@ exports.default = PostFormatPanel;
|
|
|
7
7
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
10
|
var _components = require("@wordpress/components");
|
|
13
11
|
|
|
14
12
|
var _data = require("@wordpress/data");
|
|
@@ -21,10 +19,6 @@ var _postFormat = require("../post-format");
|
|
|
21
19
|
|
|
22
20
|
var _store = require("../../store");
|
|
23
21
|
|
|
24
|
-
/**
|
|
25
|
-
* External dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
22
|
/**
|
|
29
23
|
* WordPress dependencies
|
|
30
24
|
*/
|
|
@@ -55,11 +49,13 @@ function PostFormatPanel() {
|
|
|
55
49
|
currentPostFormat,
|
|
56
50
|
suggestion
|
|
57
51
|
} = (0, _data.useSelect)(select => {
|
|
52
|
+
var _select$getThemeSuppo;
|
|
53
|
+
|
|
58
54
|
const {
|
|
59
55
|
getEditedPostAttribute,
|
|
60
56
|
getSuggestedPostFormat
|
|
61
57
|
} = select(_store.store);
|
|
62
|
-
const supportedFormats = (
|
|
58
|
+
const supportedFormats = (_select$getThemeSuppo = select(_coreData.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : [];
|
|
63
59
|
return {
|
|
64
60
|
currentPostFormat: getEditedPostAttribute('format'),
|
|
65
61
|
suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-post-format-panel.js"],"names":["getSuggestion","supportedFormats","suggestedPostFormat","formats","POST_FORMATS","filter","format","includes","id","find","PostFormatSuggestion","suggestionText","onUpdatePostFormat","PostFormatPanel","currentPostFormat","suggestion","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","coreStore","getThemeSupports","editPost","panelBodyTitle","caption"],"mappings":";;;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-post-format-panel.js"],"names":["getSuggestion","supportedFormats","suggestedPostFormat","formats","POST_FORMATS","filter","format","includes","id","find","PostFormatSuggestion","suggestionText","onUpdatePostFormat","PostFormatPanel","currentPostFormat","suggestion","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","coreStore","getThemeSupports","editPost","panelBodyTitle","caption"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG,CAAEC,gBAAF,EAAoBC,mBAApB,KAA6C;AAClE,QAAMC,OAAO,GAAGC,yBAAaC,MAAb,CAAuBC,MAAF,IACpCL,gBADoC,aACpCA,gBADoC,uBACpCA,gBAAgB,CAAEM,QAAlB,CAA4BD,MAAM,CAACE,EAAnC,CADe,CAAhB;;AAGA,SAAOL,OAAO,CAACM,IAAR,CAAgBH,MAAF,IAAcA,MAAM,CAACE,EAAP,KAAcN,mBAA1C,CAAP;AACA,CALD;;AAOA,MAAMQ,oBAAoB,GAAG;AAAA,MAAE;AAC9BR,IAAAA,mBAD8B;AAE9BS,IAAAA,cAF8B;AAG9BC,IAAAA;AAH8B,GAAF;AAAA,SAK5B,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMA,kBAAkB,CAAEV,mBAAF;AAFnC,KAIGS,cAJH,CAL4B;AAAA,CAA7B;;AAae,SAASE,eAAT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esContent":["/**\n * WordPress dependencies\n */\nimport { Button, PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { POST_FORMATS } from '../post-format';\nimport { store as editorStore } from '../../store';\n\nconst getSuggestion = ( supportedFormats, suggestedPostFormat ) => {\n\tconst formats = POST_FORMATS.filter( ( format ) =>\n\t\tsupportedFormats?.includes( format.id )\n\t);\n\treturn formats.find( ( format ) => format.id === suggestedPostFormat );\n};\n\nconst PostFormatSuggestion = ( {\n\tsuggestedPostFormat,\n\tsuggestionText,\n\tonUpdatePostFormat,\n} ) => (\n\t<Button\n\t\tvariant=\"link\"\n\t\tonClick={ () => onUpdatePostFormat( suggestedPostFormat ) }\n\t>\n\t\t{ suggestionText }\n\t</Button>\n);\n\nexport default function PostFormatPanel() {\n\tconst { currentPostFormat, suggestion } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\tselect( editorStore );\n\t\tconst supportedFormats =\n\t\t\tselect( coreStore ).getThemeSupports().formats ?? [];\n\t\treturn {\n\t\t\tcurrentPostFormat: getEditedPostAttribute( 'format' ),\n\t\t\tsuggestion: getSuggestion(\n\t\t\t\tsupportedFormats,\n\t\t\t\tgetSuggestedPostFormat()\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Use a post format' ) }\n\t\t</span>,\n\t];\n\n\tif ( ! suggestion || suggestion.id === currentPostFormat ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t<PostFormatSuggestion\n\t\t\t\t\tonUpdatePostFormat={ onUpdatePostFormat }\n\t\t\t\t\tsuggestedPostFormat={ suggestion.id }\n\t\t\t\t\tsuggestionText={ sprintf(\n\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t__( 'Apply the \"%1$s\" format.' ),\n\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</p>\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _components = require("@wordpress/components");
|
|
15
13
|
|
|
16
14
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -29,10 +27,6 @@ var _label = _interopRequireDefault(require("../post-schedule/label"));
|
|
|
29
27
|
|
|
30
28
|
var _store = require("../../store");
|
|
31
29
|
|
|
32
|
-
/**
|
|
33
|
-
* External dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
30
|
/**
|
|
37
31
|
* WordPress dependencies
|
|
38
32
|
*/
|
|
@@ -112,15 +106,17 @@ class PostPublishPanelPostpublish extends _element.Component {
|
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
render() {
|
|
109
|
+
var _postType$labels, _postType$labels2, _postType$labels3;
|
|
110
|
+
|
|
115
111
|
const {
|
|
116
112
|
children,
|
|
117
113
|
isScheduled,
|
|
118
114
|
post,
|
|
119
115
|
postType
|
|
120
116
|
} = this.props;
|
|
121
|
-
const postLabel =
|
|
122
|
-
const viewPostLabel =
|
|
123
|
-
const addNewPostLabel =
|
|
117
|
+
const postLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.singular_name;
|
|
118
|
+
const viewPostLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels2 = postType.labels) === null || _postType$labels2 === void 0 ? void 0 : _postType$labels2.view_item;
|
|
119
|
+
const addNewPostLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels3 = postType.labels) === null || _postType$labels3 === void 0 ? void 0 : _postType$labels3.add_new_item;
|
|
124
120
|
const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
|
|
125
121
|
const addLink = (0, _url.addQueryArgs)('post-new.php', {
|
|
126
122
|
post_type: post.type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/postpublish.js"],"names":["POSTNAME","getFuturePostUrl","post","slug","permalink_template","includes","replace","CopyButton","text","onCopy","children","ref","PostPublishPanelPostpublish","Component","constructor","arguments","state","showCopyConfirmation","bind","onSelectInput","postLink","componentDidMount","props","focusOnMount","current","focus","componentWillUnmount","clearTimeout","dismissCopyConfirmation","setState","setTimeout","event","target","select","render","isScheduled","postType","postLabel","viewPostLabel","addNewPostLabel","link","status","addLink","post_type","type","postPublishNonLinkHeader","title","getEditedPostAttribute","getCurrentPost","isCurrentPostScheduled","editorStore","getPostType","coreStore"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/postpublish.js"],"names":["POSTNAME","getFuturePostUrl","post","slug","permalink_template","includes","replace","CopyButton","text","onCopy","children","ref","PostPublishPanelPostpublish","Component","constructor","arguments","state","showCopyConfirmation","bind","onSelectInput","postLink","componentDidMount","props","focusOnMount","current","focus","componentWillUnmount","clearTimeout","dismissCopyConfirmation","setState","setTimeout","event","target","select","render","isScheduled","postType","postLabel","labels","singular_name","viewPostLabel","view_item","addNewPostLabel","add_new_item","link","status","addLink","post_type","type","postPublishNonLinkHeader","title","getEditedPostAttribute","getCurrentPost","isCurrentPostScheduled","editorStore","getPostType","coreStore"],"mapp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AIGJ,eAJH,CAND,CA3BD,CAPD,EAgDGhC,QAhDH,CADD;AAoDA;;AA9GkD;;eAiHrC,sBAAcuB,MAAF,IAAc;AACxC,QAAM;AAAEkB,IAAAA,sBAAF;AAA0BC,IAAAA,cAA1B;AAA0CC,IAAAA;AAA1C,MACLpB,MAAM,CAAEqB,YAAF,CADP;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAkBtB,MAAM,CAAEuB,eAAF,CAA9B;AAEA,SAAO;AACNtD,IAAAA,IAAI,EAAEkD,cAAc,EADd;AAENhB,IAAAA,QAAQ,EAAEmB,WAAW,CAAEJ,sBAAsB,CAAE,MAAF,CAAxB,CAFf;AAGNhB,IAAAA,WAAW,EAAEkB,sBAAsB;AAH7B,GAAP;AAKA,CAVc,EAUVzC,2BAVU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody, Button, TextControl } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { addQueryArgs, safeDecodeURIComponent } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostScheduleLabel from '../post-schedule/label';\nimport { store as editorStore } from '../../store';\n\nconst POSTNAME = '%postname%';\n\n/**\n * Returns URL for a future post.\n *\n * @param {Object} post Post object.\n *\n * @return {string} PostPublish URL.\n */\n\nconst getFuturePostUrl = ( post ) => {\n\tconst { slug } = post;\n\n\tif ( post.permalink_template.includes( POSTNAME ) ) {\n\t\treturn post.permalink_template.replace( POSTNAME, slug );\n\t}\n\n\treturn post.permalink_template;\n};\n\nfunction CopyButton( { text, onCopy, children } ) {\n\tconst ref = useCopyToClipboard( text, onCopy );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass PostPublishPanelPostpublish extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.state = {\n\t\t\tshowCopyConfirmation: false,\n\t\t};\n\t\tthis.onCopy = this.onCopy.bind( this );\n\t\tthis.onSelectInput = this.onSelectInput.bind( this );\n\t\tthis.postLink = createRef();\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.focusOnMount ) {\n\t\t\tthis.postLink.current.focus();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.dismissCopyConfirmation );\n\t}\n\n\tonCopy() {\n\t\tthis.setState( {\n\t\t\tshowCopyConfirmation: true,\n\t\t} );\n\n\t\tclearTimeout( this.dismissCopyConfirmation );\n\t\tthis.dismissCopyConfirmation = setTimeout( () => {\n\t\t\tthis.setState( {\n\t\t\t\tshowCopyConfirmation: false,\n\t\t\t} );\n\t\t}, 4000 );\n\t}\n\n\tonSelectInput( event ) {\n\t\tevent.target.select();\n\t}\n\n\trender() {\n\t\tconst { children, isScheduled, post, postType } = this.props;\n\t\tconst postLabel = postType?.labels?.singular_name;\n\t\tconst viewPostLabel = postType?.labels?.view_item;\n\t\tconst addNewPostLabel = postType?.labels?.add_new_item;\n\t\tconst link =\n\t\t\tpost.status === 'future' ? getFuturePostUrl( post ) : post.link;\n\t\tconst addLink = addQueryArgs( 'post-new.php', {\n\t\t\tpost_type: post.type,\n\t\t} );\n\n\t\tconst postPublishNonLinkHeader = isScheduled ? (\n\t\t\t<>\n\t\t\t\t{ __( 'is now scheduled. It will go live on' ) }{ ' ' }\n\t\t\t\t<PostScheduleLabel />.\n\t\t\t</>\n\t\t) : (\n\t\t\t__( 'is now live.' )\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"post-publish-panel__postpublish\">\n\t\t\t\t<PanelBody className=\"post-publish-panel__postpublish-header\">\n\t\t\t\t\t<a ref={ this.postLink } href={ link }>\n\t\t\t\t\t\t{ decodeEntities( post.title ) || __( '(no title)' ) }\n\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t{ postPublishNonLinkHeader }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<p className=\"post-publish-panel__postpublish-subheader\">\n\t\t\t\t\t\t<strong>{ __( 'What’s next?' ) }</strong>\n\t\t\t\t\t</p>\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address-container\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"post-publish-panel__postpublish-post-address\"\n\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post type singular name */\n\t\t\t\t\t\t\t\t__( '%s address' ),\n\t\t\t\t\t\t\t\tpostLabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ safeDecodeURIComponent( link ) }\n\t\t\t\t\t\t\tonFocus={ this.onSelectInput }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address__copy-button-wrap\">\n\t\t\t\t\t\t\t<CopyButton text={ link } onCopy={ this.onCopy }>\n\t\t\t\t\t\t\t\t{ this.state.showCopyConfirmation\n\t\t\t\t\t\t\t\t\t? __( 'Copied!' )\n\t\t\t\t\t\t\t\t\t: __( 'Copy' ) }\n\t\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-buttons\">\n\t\t\t\t\t\t{ ! isScheduled && (\n\t\t\t\t\t\t\t<Button variant=\"primary\" href={ link }>\n\t\t\t\t\t\t\t\t{ viewPostLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant={ isScheduled ? 'primary' : 'secondary' }\n\t\t\t\t\t\t\thref={ addLink }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ addNewPostLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</PanelBody>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getEditedPostAttribute, getCurrentPost, isCurrentPostScheduled } =\n\t\tselect( editorStore );\n\tconst { getPostType } = select( coreStore );\n\n\treturn {\n\t\tpost: getCurrentPost(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tisScheduled: isCurrentPostScheduled(),\n\t};\n} )( PostPublishPanelPostpublish );\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _i18n = require("@wordpress/i18n");
|
|
15
13
|
|
|
16
14
|
var _components = require("@wordpress/components");
|
|
@@ -41,10 +39,6 @@ var _store = require("../../store");
|
|
|
41
39
|
|
|
42
40
|
var _maybeCategoryPanel = _interopRequireDefault(require("./maybe-category-panel"));
|
|
43
41
|
|
|
44
|
-
/**
|
|
45
|
-
* External dependencies
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
42
|
/**
|
|
49
43
|
* WordPress dependencies
|
|
50
44
|
*/
|
|
@@ -64,6 +58,8 @@ function PostPublishPanelPrepublish(_ref) {
|
|
|
64
58
|
siteTitle,
|
|
65
59
|
siteHome
|
|
66
60
|
} = (0, _data.useSelect)(select => {
|
|
61
|
+
var _getCurrentPost$_link, _getCurrentPost$_link2;
|
|
62
|
+
|
|
67
63
|
const {
|
|
68
64
|
getCurrentPost,
|
|
69
65
|
isEditedPostBeingScheduled
|
|
@@ -74,7 +70,7 @@ function PostPublishPanelPrepublish(_ref) {
|
|
|
74
70
|
} = select(_coreData.store);
|
|
75
71
|
const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
|
|
76
72
|
return {
|
|
77
|
-
hasPublishAction: (
|
|
73
|
+
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,
|
|
78
74
|
isBeingScheduled: isEditedPostBeingScheduled(),
|
|
79
75
|
isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
|
|
80
76
|
siteIconUrl: siteData.site_icon_url,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/prepublish.js"],"names":["PostPublishPanelPrepublish","children","isBeingScheduled","isRequestingSiteIcon","hasPublishAction","siteIconUrl","siteTitle","siteHome","select","getCurrentPost","isEditedPostBeingScheduled","editorStore","getEntityRecord","isResolving","coreStore","siteData","undefined","site_icon_url","name","home","siteIcon","wordpress","prePublishTitle","prePublishBodyText"],"mappings":";;;;;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/prepublish.js"],"names":["PostPublishPanelPrepublish","children","isBeingScheduled","isRequestingSiteIcon","hasPublishAction","siteIconUrl","siteTitle","siteHome","select","getCurrentPost","isEditedPostBeingScheduled","editorStore","getEntityRecord","isResolving","coreStore","siteData","undefined","_links","site_icon_url","name","home","siteIcon","wordpress","prePublishTitle","prePublishBodyText"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AASA;AACA;AACA;AAUA,SAASA,0BAAT,OAAoD;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,gBAHK;AAILC,IAAAA,WAJK;AAKLC,IAAAA,SALK;AAMLC,IAAAA;AANK,MAOF,qB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uBAAD,OA/CD,EAgDC,4BAAC,2BAAD,OAhDD,EAiDGH,QAjDH,CADD;AAqDA;;eAEcD,0B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, PanelBody } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { wordpress } from '@wordpress/icons';\nimport { filterURLForDisplay } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostVisibility from '../post-visibility';\nimport PostVisibilityLabel from '../post-visibility/label';\nimport PostSchedule from '../post-schedule';\nimport PostScheduleLabel from '../post-schedule/label';\nimport MaybeTagsPanel from './maybe-tags-panel';\nimport MaybePostFormatPanel from './maybe-post-format-panel';\nimport { store as editorStore } from '../../store';\nimport MaybeCategoryPanel from './maybe-category-panel';\n\nfunction PostPublishPanelPrepublish( { children } ) {\n\tconst {\n\t\tisBeingScheduled,\n\t\tisRequestingSiteIcon,\n\t\thasPublishAction,\n\t\tsiteIconUrl,\n\t\tsiteTitle,\n\t\tsiteHome,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentPost, isEditedPostBeingScheduled } =\n\t\t\tselect( editorStore );\n\t\tconst { getEntityRecord, isResolving } = select( coreStore );\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisRequestingSiteIcon: isResolving( 'getEntityRecord', [\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase',\n\t\t\t\tundefined,\n\t\t\t] ),\n\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t\tsiteTitle: siteData.name,\n\t\t\tsiteHome: siteData.home && filterURLForDisplay( siteData.home ),\n\t\t};\n\t}, [] );\n\n\tlet siteIcon = (\n\t\t<Icon className=\"components-site-icon\" size=\"36px\" icon={ wordpress } />\n\t);\n\n\tif ( siteIconUrl ) {\n\t\tsiteIcon = (\n\t\t\t<img\n\t\t\t\talt={ __( 'Site Icon' ) }\n\t\t\t\tclassName=\"components-site-icon\"\n\t\t\t\tsrc={ siteIconUrl }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isRequestingSiteIcon ) {\n\t\tsiteIcon = null;\n\t}\n\n\tlet prePublishTitle, prePublishBodyText;\n\n\tif ( ! hasPublishAction ) {\n\t\tprePublishTitle = __( 'Are you ready to submit for review?' );\n\t\tprePublishBodyText = __(\n\t\t\t'When you’re ready, submit your work for review, and an Editor will be able to approve it for you.'\n\t\t);\n\t} else if ( isBeingScheduled ) {\n\t\tprePublishTitle = __( 'Are you ready to schedule?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Your work will be published at the specified date and time.'\n\t\t);\n\t} else {\n\t\tprePublishTitle = __( 'Are you ready to publish?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Double-check your settings before publishing.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"editor-post-publish-panel__prepublish\">\n\t\t\t<div>\n\t\t\t\t<strong>{ prePublishTitle }</strong>\n\t\t\t</div>\n\t\t\t<p>{ prePublishBodyText }</p>\n\t\t\t<div className=\"components-site-card\">\n\t\t\t\t{ siteIcon }\n\t\t\t\t<div className=\"components-site-info\">\n\t\t\t\t\t<span className=\"components-site-name\">\n\t\t\t\t\t\t{ decodeEntities( siteTitle ) || __( '(Untitled)' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"components-site-home\">{ siteHome }</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ hasPublishAction && (\n\t\t\t\t<>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Visibility:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostVisibility />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Publish:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostScheduleLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostSchedule />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<MaybePostFormatPanel />\n\t\t\t<MaybeTagsPanel />\n\t\t\t<MaybeCategoryPanel />\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default PostPublishPanelPrepublish;\n"]}
|
|
@@ -6,18 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.PostScheduleCheck = PostScheduleCheck;
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
|
|
9
|
-
var _lodash = require("lodash");
|
|
10
|
-
|
|
11
9
|
var _compose = require("@wordpress/compose");
|
|
12
10
|
|
|
13
11
|
var _data = require("@wordpress/data");
|
|
14
12
|
|
|
15
13
|
var _store = require("../../store");
|
|
16
14
|
|
|
17
|
-
/**
|
|
18
|
-
* External dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
15
|
/**
|
|
22
16
|
* WordPress dependencies
|
|
23
17
|
*/
|
|
@@ -39,12 +33,14 @@ function PostScheduleCheck(_ref) {
|
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
36
|
+
var _getCurrentPost$_link, _getCurrentPost$_link2;
|
|
37
|
+
|
|
42
38
|
const {
|
|
43
39
|
getCurrentPost,
|
|
44
40
|
getCurrentPostType
|
|
45
41
|
} = select(_store.store);
|
|
46
42
|
return {
|
|
47
|
-
hasPublishAction: (
|
|
43
|
+
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,
|
|
48
44
|
postType: getCurrentPostType()
|
|
49
45
|
};
|
|
50
46
|
})])(PostScheduleCheck);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/check.js"],"names":["PostScheduleCheck","hasPublishAction","children","select","getCurrentPost","getCurrentPostType","editorStore","postType"],"mappings":";;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/check.js"],"names":["PostScheduleCheck","hasPublishAction","children","select","getCurrentPost","getCurrentPostType","editorStore","_links","postType"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAA6D;AAAA,MAAjC;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAiC;;AACnE,MAAK,CAAED,gBAAP,EAA0B;AACzB,WAAO,IAAP;AACA;;AAED,SAAOC,QAAP;AACA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AAAA;;AACzB,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,SAAO;AACNL,IAAAA,gBAAgB,qDACfG,cAAc,GAAGG,MADF,2DACf,uBAA2B,mBAA3B,CADe,yEACqC,KAF/C;AAGNC,IAAAA,QAAQ,EAAEH,kBAAkB;AAHtB,GAAP;AAKA,CAPD,CADuB,CAAT,EASVL,iBATU,C","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 PostScheduleCheck( { hasPublishAction, children } ) {\n\tif ( ! hasPublishAction ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t} ),\n] )( PostScheduleCheck );\n"]}
|
|
@@ -6,18 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.PostStickyCheck = PostStickyCheck;
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
|
|
9
|
-
var _lodash = require("lodash");
|
|
10
|
-
|
|
11
9
|
var _compose = require("@wordpress/compose");
|
|
12
10
|
|
|
13
11
|
var _data = require("@wordpress/data");
|
|
14
12
|
|
|
15
13
|
var _store = require("../../store");
|
|
16
14
|
|
|
17
|
-
/**
|
|
18
|
-
* External dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
15
|
/**
|
|
22
16
|
* WordPress dependencies
|
|
23
17
|
*/
|
|
@@ -40,9 +34,11 @@ function PostStickyCheck(_ref) {
|
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
37
|
+
var _post$_links$wpActio, _post$_links;
|
|
38
|
+
|
|
43
39
|
const post = select(_store.store).getCurrentPost();
|
|
44
40
|
return {
|
|
45
|
-
hasStickyAction: (
|
|
41
|
+
hasStickyAction: (_post$_links$wpActio = (_post$_links = post._links) === null || _post$_links === void 0 ? void 0 : _post$_links['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
|
|
46
42
|
postType: select(_store.store).getCurrentPostType()
|
|
47
43
|
};
|
|
48
44
|
})])(PostStickyCheck);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/check.js"],"names":["PostStickyCheck","hasStickyAction","postType","children","select","post","editorStore","getCurrentPost","getCurrentPostType"],"mappings":";;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/check.js"],"names":["PostStickyCheck","hasStickyAction","postType","children","select","post","editorStore","getCurrentPost","_links","getCurrentPostType"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,eAAT,OAAoE;AAAA,MAA1C;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAA0C;;AAC1E,MAAKD,QAAQ,KAAK,MAAb,IAAuB,CAAED,eAA9B,EAAgD;AAC/C,WAAO,IAAP;AACA;;AAED,SAAOE,QAAP;AACA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AAAA;;AACzB,QAAMC,IAAI,GAAGD,MAAM,CAAEE,YAAF,CAAN,CAAsBC,cAAtB,EAAb;AACA,SAAO;AACNN,IAAAA,eAAe,0CAAEI,IAAI,CAACG,MAAP,iDAAE,aAAe,kBAAf,CAAF,uEAAyC,KADlD;AAENN,IAAAA,QAAQ,EAAEE,MAAM,CAAEE,YAAF,CAAN,CAAsBG,kBAAtB;AAFJ,GAAP;AAIA,CAND,CADuB,CAAT,EAQVT,eARU,C","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 PostStickyCheck( { hasStickyAction, postType, children } ) {\n\tif ( postType !== 'post' || ! hasStickyAction ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\treturn {\n\t\t\thasStickyAction: post._links?.[ 'wp:action-sticky' ] ?? false,\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t};\n\t} ),\n] )( PostStickyCheck );\n"]}
|
|
@@ -10,8 +10,6 @@ exports.default = void 0;
|
|
|
10
10
|
|
|
11
11
|
var _element = require("@wordpress/element");
|
|
12
12
|
|
|
13
|
-
var _lodash = require("lodash");
|
|
14
|
-
|
|
15
13
|
var _escapeHtml = _interopRequireDefault(require("escape-html"));
|
|
16
14
|
|
|
17
15
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -92,6 +90,8 @@ function findOrCreateTerm(termName, restBase, namespace) {
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
function FlatTermSelector(_ref) {
|
|
93
|
+
var _taxonomy$labels$add_, _taxonomy$labels2, _taxonomy$labels$sing2, _taxonomy$labels3;
|
|
94
|
+
|
|
95
95
|
let {
|
|
96
96
|
slug
|
|
97
97
|
} = _ref;
|
|
@@ -106,6 +106,8 @@ function FlatTermSelector(_ref) {
|
|
|
106
106
|
hasCreateAction,
|
|
107
107
|
hasResolvedTerms
|
|
108
108
|
} = (0, _data.useSelect)(select => {
|
|
109
|
+
var _post$_links, _post$_links2, _post$_links3, _post$_links4;
|
|
110
|
+
|
|
109
111
|
const {
|
|
110
112
|
getCurrentPost,
|
|
111
113
|
getEditedPostAttribute
|
|
@@ -126,8 +128,8 @@ function FlatTermSelector(_ref) {
|
|
|
126
128
|
per_page: -1
|
|
127
129
|
};
|
|
128
130
|
return {
|
|
129
|
-
hasCreateAction: _taxonomy ? (
|
|
130
|
-
hasAssignAction: _taxonomy ? (
|
|
131
|
+
hasCreateAction: _taxonomy ? (_post$_links = (_post$_links2 = post._links) === null || _post$_links2 === void 0 ? void 0 : _post$_links2['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
|
|
132
|
+
hasAssignAction: _taxonomy ? (_post$_links3 = (_post$_links4 = post._links) === null || _post$_links4 === void 0 ? void 0 : _post$_links4['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links3 !== void 0 ? _post$_links3 : false : false,
|
|
131
133
|
taxonomy: _taxonomy,
|
|
132
134
|
termIds: _termIds,
|
|
133
135
|
terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY,
|
|
@@ -204,20 +206,23 @@ function FlatTermSelector(_ref) {
|
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
function appendTerm(newTerm) {
|
|
209
|
+
var _taxonomy$labels$sing, _taxonomy$labels;
|
|
210
|
+
|
|
207
211
|
if (termIds.includes(newTerm.id)) {
|
|
208
212
|
return;
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
const newTermIds = [...termIds, newTerm.id];
|
|
216
|
+
const defaultName = slug === 'post_tag' ? (0, _i18n.__)('Tag') : (0, _i18n.__)('Term');
|
|
212
217
|
const termAddedMessage = (0, _i18n.sprintf)(
|
|
213
218
|
/* translators: %s: term name. */
|
|
214
|
-
(0, _i18n._x)('%s added', 'term'), (0
|
|
219
|
+
(0, _i18n._x)('%s added', 'term'), (_taxonomy$labels$sing = taxonomy === null || taxonomy === void 0 ? void 0 : (_taxonomy$labels = taxonomy.labels) === null || _taxonomy$labels === void 0 ? void 0 : _taxonomy$labels.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : defaultName);
|
|
215
220
|
(0, _a11y.speak)(termAddedMessage, 'assertive');
|
|
216
221
|
onUpdateTerms(newTermIds);
|
|
217
222
|
}
|
|
218
223
|
|
|
219
|
-
const newTermLabel = (0
|
|
220
|
-
const singularName = (0
|
|
224
|
+
const newTermLabel = (_taxonomy$labels$add_ = taxonomy === null || taxonomy === void 0 ? void 0 : (_taxonomy$labels2 = taxonomy.labels) === null || _taxonomy$labels2 === void 0 ? void 0 : _taxonomy$labels2.add_new_item) !== null && _taxonomy$labels$add_ !== void 0 ? _taxonomy$labels$add_ : slug === 'post_tag' ? (0, _i18n.__)('Add new tag') : (0, _i18n.__)('Add new Term');
|
|
225
|
+
const singularName = (_taxonomy$labels$sing2 = taxonomy === null || taxonomy === void 0 ? void 0 : (_taxonomy$labels3 = taxonomy.labels) === null || _taxonomy$labels3 === void 0 ? void 0 : _taxonomy$labels3.singular_name) !== null && _taxonomy$labels$sing2 !== void 0 ? _taxonomy$labels$sing2 : slug === 'post_tag' ? (0, _i18n.__)('Tag') : (0, _i18n.__)('Term');
|
|
221
226
|
const termAddedLabel = (0, _i18n.sprintf)(
|
|
222
227
|
/* translators: %s: term name. */
|
|
223
228
|
(0, _i18n._x)('%s added', 'term'), singularName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","unescapeTerm","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings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QADoB,EAEpB,CAAE,QAAF,EAAY,cAAZ,CAFoB,EAGpBP,IAAI,KAAK,UAAT,GAAsB,cAAI,aAAJ,CAAtB,GAA4C,cAAI,cAAJ,CAHxB,CAArB;AAKA,QAAMsD,YAAY,GAAG,iBACpB/C,QADoB,EAEpB,CAAE,QAAF,EAAY,eAAZ,CAFoB,EAGpBP,IAAI,KAAK,UAAT,GAAsB,cAAI,KAAJ,CAAtB,GAAoC,cAAI,MAAJ,CAHhB,CAArB;AAKA,QAAMuD,cAAc,GAAG;AACtB;AACA,gBAAI,UAAJ,EAAgB,MAAhB,CAFsB,EAGtBD,YAHsB,CAAvB;AAKA,QAAME,gBAAgB,GAAG;AACxB;AACA,gBAAI,YAAJ,EAAkB,MAAlB,CAFwB,EAGxBF,YAHwB,CAAzB;AAKA,QAAMG,eAAe,GAAG;AACvB;AACA,gBAAI,WAAJ,EAAiB,MAAjB,CAFuB,EAGvBH,YAHuB,CAAxB;AAMA,SACC,qDACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGrD,MADT;AAEC,IAAA,WAAW,EAAG4B,WAFf;AAGC,IAAA,QAAQ,EAAGI,QAHZ;AAIC,IAAA,aAAa,EAAG5B,eAJjB;AAKC,IAAA,cAAc,EAAGxC,qBALlB;AAMC,IAAA,KAAK,EAAGwF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVK,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,4BAAC,sBAAD;AAAe,IAAA,QAAQ,EAAGlD,QAA1B;AAAqC,IAAA,QAAQ,EAAG0C;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0ClD,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","unescapeTerm","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","_links","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","defaultName","termAddedMessage","labels","singular_name","newTermLabel","add_new_item","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,SAFY;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAtB;;AAMA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KACtB,2BAAgBD,KAAhB,EAAwBE,WAAxB,OACA,2BAAgBD,KAAhB,EAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAC1C,SAAOD,KAAK,CAACE,GAAN,CACJC,QAAF,IACCF,KAAK,CAACG,IAAN,CAAcC,IAAF,IAAYV,cAAc,CAAEU,IAAI,CAACC,IAAP,EAAaH,QAAb,CAAtC,EAAgEI,EAF3D,CAAP;AAIA,CALD,C,CAOA;;;AACA,SAASC,gBAAT,CAA2BL,QAA3B,EAAqCM,QAArC,EAA+CC,SAA/C,EAA2D;AAC1D,QAAMC,eAAe,GAAG,yBAAYR,QAAZ,CAAxB;AAEA,SAAO,uBAAU;AAChBS,IAAAA,IAAI,EAAG,IAAIF,SAAW,IAAID,QAAU,EADpB;AAEhBI,IAAAA,MAAM,EAAE,MAFQ;AAGhBC,IAAAA,IAAI,EAAE;AAAER,MAAAA,IAAI,EAAEK;A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AC,sBAAD;AAAe,IAAA,QAAQ,EAAGvD,QAA1B;AAAqC,IAAA,QAAQ,EAAG2C;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0CnD,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
|