@wordpress/editor 13.11.0 → 13.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/autosave-monitor/index.js +1 -2
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/deprecated.js +3 -4
- package/build/components/deprecated.js.map +1 -1
- package/build/components/document-outline/check.js +4 -5
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +12 -16
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js +22 -25
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js +4 -5
- package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build/components/editor-help/help-get-support-button.native.js +4 -5
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build/components/editor-help/help-section-title.native.js +3 -4
- package/build/components/editor-help/help-section-title.native.js.map +1 -1
- package/build/components/editor-help/help-topic-row.native.js +6 -7
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +19 -24
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/view-sections.native.js +16 -20
- package/build/components/editor-help/view-sections.native.js.map +1 -1
- package/build/components/editor-notices/index.js +12 -19
- package/build/components/editor-notices/index.js.map +1 -1
- package/build/components/editor-snackbars/index.js +3 -6
- package/build/components/editor-snackbars/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +7 -10
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +6 -7
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js +84 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -0
- package/build/components/entities-saved-states/index.js +38 -110
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/error-boundary/index.js +4 -5
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/save-shortcut.js +3 -4
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/media-categories/index.js +25 -42
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/page-attributes/check.js +4 -7
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/order.js +5 -8
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/parent.js +5 -12
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-author/check.js +6 -7
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-author/combobox.js +3 -6
- package/build/components/post-author/combobox.js.map +1 -1
- package/build/components/post-author/index.js +1 -1
- package/build/components/post-author/index.js.map +1 -1
- package/build/components/post-comments/index.js +4 -6
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-excerpt/index.js +4 -5
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +56 -69
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-format/check.js +4 -5
- package/build/components/post-format/check.js.map +1 -1
- package/build/components/post-format/index.js +1 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/check.js +5 -7
- package/build/components/post-last-revision/check.js.map +1 -1
- package/build/components/post-last-revision/index.js +4 -5
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-pending-status/check.js +7 -9
- package/build/components/post-pending-status/check.js.map +1 -1
- package/build/components/post-pending-status/index.js +4 -6
- package/build/components/post-pending-status/index.js.map +1 -1
- package/build/components/post-pingbacks/index.js +4 -6
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +8 -12
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +6 -13
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +14 -17
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +6 -7
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +2 -4
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +9 -12
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +4 -7
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js +8 -11
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-publish-panel/prepublish.js +5 -6
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-saved-state/index.js +13 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/check.js +6 -8
- package/build/components/post-schedule/check.js.map +1 -1
- package/build/components/post-schedule/index.js +8 -12
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-schedule/label.js +7 -10
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-slug/check.js +3 -4
- package/build/components/post-slug/check.js.map +1 -1
- package/build/components/post-slug/index.js +5 -6
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-sticky/check.js +7 -9
- package/build/components/post-sticky/check.js.map +1 -1
- package/build/components/post-sticky/index.js +4 -5
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +6 -7
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js +6 -7
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +12 -13
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +13 -14
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +6 -11
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +5 -6
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-template/index.js +6 -9
- package/build/components/post-template/index.js.map +1 -1
- package/build/components/post-title/index.js +2 -6
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/index.native.js +8 -11
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-trash/check.js +7 -9
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-type-support-check/index.js +5 -6
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/post-url/check.js +4 -5
- package/build/components/post-url/check.js.map +1 -1
- package/build/components/post-url/index.js +8 -9
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/post-visibility/check.js +6 -7
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/post-visibility/index.js +10 -12
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js +1 -3
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/provider/index.js +9 -10
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +14 -20
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +5 -9
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.native.js +1 -3
- package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build/components/table-of-contents/index.js +26 -33
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/table-of-contents/panel.js +4 -5
- package/build/components/table-of-contents/panel.js.map +1 -1
- package/build/components/template-validation-notice/index.js +4 -6
- package/build/components/template-validation-notice/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +7 -8
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/hooks/custom-sources-backwards-compatibility.js +16 -35
- package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build/hooks/default-autocompleters.js +1 -2
- package/build/hooks/default-autocompleters.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +147 -179
- package/build/store/actions.js.map +1 -1
- package/build/store/actions.native.js +1 -2
- package/build/store/actions.native.js.map +1 -1
- package/build/store/reducer.js +14 -44
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +3 -12
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +23 -54
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +3 -3
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build/utils/media-upload/index.js +11 -15
- package/build/utils/media-upload/index.js.map +1 -1
- package/build/utils/terms.js +3 -6
- package/build/utils/terms.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +1 -2
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/deprecated.js +3 -4
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/document-outline/check.js +4 -5
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js +12 -16
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +22 -25
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js +4 -5
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build-module/components/editor-help/help-get-support-button.native.js +4 -5
- package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build-module/components/editor-help/help-section-title.native.js +3 -4
- package/build-module/components/editor-help/help-section-title.native.js.map +1 -1
- package/build-module/components/editor-help/help-topic-row.native.js +6 -7
- package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +19 -23
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-help/view-sections.native.js +16 -20
- package/build-module/components/editor-help/view-sections.native.js.map +1 -1
- package/build-module/components/editor-notices/index.js +12 -19
- package/build-module/components/editor-notices/index.js.map +1 -1
- package/build-module/components/editor-snackbars/index.js +3 -6
- package/build-module/components/editor-snackbars/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +7 -10
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +6 -7
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +70 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -0
- package/build-module/components/entities-saved-states/index.js +39 -113
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +4 -5
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js +3 -4
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +25 -42
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/page-attributes/check.js +4 -7
- package/build-module/components/page-attributes/check.js.map +1 -1
- package/build-module/components/page-attributes/order.js +5 -8
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +5 -12
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-author/check.js +6 -7
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-author/combobox.js +3 -6
- package/build-module/components/post-author/combobox.js.map +1 -1
- package/build-module/components/post-author/index.js +1 -1
- package/build-module/components/post-author/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +4 -6
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +4 -5
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +56 -69
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-format/check.js +4 -5
- package/build-module/components/post-format/check.js.map +1 -1
- package/build-module/components/post-format/index.js +1 -1
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-revision/check.js +5 -7
- package/build-module/components/post-last-revision/check.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +4 -5
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-pending-status/check.js +7 -9
- package/build-module/components/post-pending-status/check.js.map +1 -1
- package/build-module/components/post-pending-status/index.js +4 -6
- package/build-module/components/post-pending-status/index.js.map +1 -1
- package/build-module/components/post-pingbacks/index.js +4 -6
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +8 -12
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +6 -13
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +14 -17
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +6 -7
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +2 -4
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +9 -12
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +4 -7
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js +8 -11
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-publish-panel/prepublish.js +5 -6
- package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +13 -8
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/check.js +6 -8
- package/build-module/components/post-schedule/check.js.map +1 -1
- package/build-module/components/post-schedule/index.js +8 -12
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +7 -10
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-slug/check.js +3 -4
- package/build-module/components/post-slug/check.js.map +1 -1
- package/build-module/components/post-slug/index.js +5 -6
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-sticky/check.js +7 -9
- package/build-module/components/post-sticky/check.js.map +1 -1
- package/build-module/components/post-sticky/index.js +4 -5
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +6 -7
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js +6 -7
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +12 -13
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +13 -14
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +6 -11
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +5 -6
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-template/index.js +6 -9
- package/build-module/components/post-template/index.js.map +1 -1
- package/build-module/components/post-title/index.js +2 -6
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/index.native.js +8 -11
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-trash/check.js +7 -9
- package/build-module/components/post-trash/check.js.map +1 -1
- package/build-module/components/post-type-support-check/index.js +5 -6
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/post-url/check.js +4 -5
- package/build-module/components/post-url/check.js.map +1 -1
- package/build-module/components/post-url/index.js +8 -9
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/post-visibility/check.js +6 -7
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/post-visibility/index.js +10 -12
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js +1 -3
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/provider/index.js +9 -10
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +14 -20
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +5 -9
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.native.js +1 -3
- package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +26 -33
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/table-of-contents/panel.js +4 -5
- package/build-module/components/table-of-contents/panel.js.map +1 -1
- package/build-module/components/template-validation-notice/index.js +4 -6
- package/build-module/components/template-validation-notice/index.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +7 -8
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/hooks/custom-sources-backwards-compatibility.js +16 -35
- package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build-module/hooks/default-autocompleters.js +1 -2
- package/build-module/hooks/default-autocompleters.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +147 -179
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/actions.native.js +1 -2
- package/build-module/store/actions.native.js.map +1 -1
- package/build-module/store/reducer.js +14 -44
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +3 -12
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +21 -54
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +3 -3
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-module/utils/media-upload/index.js +11 -15
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-module/utils/terms.js +3 -6
- package/build-module/utils/terms.js.map +1 -1
- package/package.json +30 -30
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +85 -0
- package/src/components/entities-saved-states/index.js +25 -106
- package/src/components/entities-saved-states/test/use-is-dirty.js +94 -0
- package/src/components/index.js +1 -0
- package/src/components/post-saved-state/index.js +6 -0
- package/src/components/post-title/index.js +2 -1
- package/src/private-apis.js +2 -0
|
@@ -18,10 +18,9 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { store as editorStore } from '../../store';
|
|
21
|
-
export default function PostSchedule(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _ref;
|
|
21
|
+
export default function PostSchedule({
|
|
22
|
+
onClose
|
|
23
|
+
}) {
|
|
25
24
|
const {
|
|
26
25
|
postDate,
|
|
27
26
|
postType
|
|
@@ -47,14 +46,11 @@ export default function PostSchedule(_ref) {
|
|
|
47
46
|
per_page: 100,
|
|
48
47
|
_fields: 'id,date'
|
|
49
48
|
}), [previewedMonth, postType]);
|
|
50
|
-
const events = useMemo(() => (eventsByPostType || []).map(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
date: new Date(eventDate)
|
|
56
|
-
};
|
|
57
|
-
}), [eventsByPostType]);
|
|
49
|
+
const events = useMemo(() => (eventsByPostType || []).map(({
|
|
50
|
+
date: eventDate
|
|
51
|
+
}) => ({
|
|
52
|
+
date: new Date(eventDate)
|
|
53
|
+
})), [eventsByPostType]);
|
|
58
54
|
const settings = getSettings(); // To know if the current timezone is a 12 hour time with look for "a" in the time format
|
|
59
55
|
// We also make sure this a is not escaped by a "/"
|
|
60
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["parseISO","endOfMonth","startOfMonth","getSettings","useDispatch","useSelect","__experimentalPublishDateTimePicker","PublishDateTimePicker","useState","useMemo","store","coreStore","editorStore","PostSchedule","onClose","postDate","postType","select","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","date","previewedMonth","setPreviewedMonth","Date","eventsByPostType","getEntityRecords","status","after","toISOString","before","exclude","getCurrentPostId","per_page","_fields","events","map","eventDate","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,YAA/B,QAAmD,UAAnD;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,mCAAmC,IAAIC,qBAAhD,QAA6E,yBAA7E;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;AAEA,eAAe,SAASC,YAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["parseISO","endOfMonth","startOfMonth","getSettings","useDispatch","useSelect","__experimentalPublishDateTimePicker","PublishDateTimePicker","useState","useMemo","store","coreStore","editorStore","PostSchedule","onClose","postDate","postType","select","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","date","previewedMonth","setPreviewedMonth","Date","eventsByPostType","getEntityRecords","status","after","toISOString","before","exclude","getCurrentPostId","per_page","_fields","events","map","eventDate","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,YAA/B,QAAmD,UAAnD;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iB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AM,CAAEL,WAAF,CAAN,CAAsBqB,gBAAtB,EAAF,CAJkD;AAK3DC,IAAAA,QAAQ,EAAE,GALiD;AAM3DC,IAAAA,OAAO,EAAE;AANkD,GAA5D,CAFgC,EAUjC,CAAEZ,cAAF,EAAkBP,QAAlB,CAViC,CAAlC;AAaA,QAAMoB,MAAM,GAAG3B,OAAO,CACrB,MACC,CAAEiB,gBAAgB,IAAI,EAAtB,EAA2BW,GAA3B,CAAgC,CAAE;AAAEf,IAAAA,IAAI,EAAEgB;AAAR,GAAF,MAA6B;AAC5DhB,IAAAA,IAAI,EAAE,IAAIG,IAAJ,CAAUa,SAAV;AADsD,GAA7B,CAAhC,CAFoB,EAKrB,CAAEZ,gBAAF,CALqB,CAAtB;AAQA,QAAMa,QAAQ,GAAGpC,WAAW,EAA5B,CAtCmD,CAwCnD;AACA;;AACA,QAAMqC,YAAY,GAAG,WAAWC,IAAX,CACpBF,QAAQ,CAACG,OAAT,CAAiBC,IAAjB,CACEC,WADF,GACgB;AADhB,GAEEC,OAFF,CAEW,OAFX,EAEoB,EAFpB,EAEyB;AAFzB,GAGEC,KAHF,CAGS,EAHT,EAIEC,OAJF,GAKEC,IALF,CAKQ,EALR,CADoB,CAMP;AANO,GAArB;AASA,SACC,cAAC,qBAAD;AACC,IAAA,WAAW,EAAGjC,QADf;AAEC,IAAA,QAAQ,EAAGM,YAFZ;AAGC,IAAA,QAAQ,EAAGmB,YAHZ;AAIC,IAAA,MAAM,EAAGJ,MAJV;AAKC,IAAA,gBAAgB,EAAKd,IAAF,IAClBE,iBAAiB,CAAExB,QAAQ,CAAEsB,IAAF,CAAV,CANnB;AAQC,IAAA,OAAO,EAAGR;AARX,IADD;AAYA","sourcesContent":["/**\n * External dependencies\n */\nimport { parseISO, endOfMonth, startOfMonth } from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport { getSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostSchedule( { onClose } ) {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tstartOfMonth( new Date( postDate ) )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: startOfMonth( previewedMonth ).toISOString(),\n\t\t\t\tbefore: endOfMonth( previewedMonth ).toISOString(),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t\tper_page: 100,\n\t\t\t\t_fields: 'id,date',\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map( ( { date: eventDate } ) => ( {\n\t\t\t\tdate: new Date( eventDate ),\n\t\t\t} ) ),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst settings = getSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\treturn (\n\t\t<PublishDateTimePicker\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onUpdateDate }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ ( date ) =>\n\t\t\t\tsetPreviewedMonth( parseISO( date ) )\n\t\t\t}\n\t\t\tonClose={ onClose }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -12,10 +12,9 @@ import { store as editorStore } from '../../store';
|
|
|
12
12
|
export default function PostScheduleLabel(props) {
|
|
13
13
|
return usePostScheduleLabel(props);
|
|
14
14
|
}
|
|
15
|
-
export function usePostScheduleLabel(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
|
+
export function usePostScheduleLabel({
|
|
16
|
+
full = false
|
|
17
|
+
} = {}) {
|
|
19
18
|
const {
|
|
20
19
|
date,
|
|
21
20
|
isFloating
|
|
@@ -34,12 +33,10 @@ export function getFullPostScheduleLabel(dateAttribute) {
|
|
|
34
33
|
_x('F j, Y g:i\xa0a', 'post schedule full date format'), date);
|
|
35
34
|
return isRTL() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
|
|
36
35
|
}
|
|
37
|
-
export function getPostScheduleLabel(dateAttribute
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
42
|
-
|
|
36
|
+
export function getPostScheduleLabel(dateAttribute, {
|
|
37
|
+
isFloating = false,
|
|
38
|
+
now = new Date()
|
|
39
|
+
} = {}) {
|
|
43
40
|
if (!dateAttribute || isFloating) {
|
|
44
41
|
return __('Immediately');
|
|
45
42
|
} // If the user timezone does not equal the site timezone then using words
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/label.js"],"names":["__","_x","sprintf","isRTL","getSettings","getDate","dateI18n","useSelect","store","editorStore","PostScheduleLabel","props","usePostScheduleLabel","full","date","isFloating","select","getEditedPostAttribute","isEditedPostDateFloating","getFullPostScheduleLabel","getPostScheduleLabel","dateAttribute","timezoneAbbreviation","getTimezoneAbbreviation","formattedDate","now","Date","isTimezoneSameAsSiteTimezone","isSameDay","tomorrow","setDate","getFullYear","timezone","abbr","isNaN","Number","symbol","offset","siteOffset","dateOffset","getTimezoneOffset","left","right","getMonth"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,QAA/B,QAA+C,iBAA/C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,eAAe,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAClD,SAAOC,oBAAoB,CAAED,KAAF,CAA3B;AACA;AAED,OAAO,SAASC,oBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/label.js"],"names":["__","_x","sprintf","isRTL","getSettings","getDate","dateI18n","useSelect","store","editorStore","PostScheduleLabel","props","usePostScheduleLabel","full","date","isFloating","select","getEditedPostAttribute","isEditedPostDateFloating","getFullPostScheduleLabel","getPostScheduleLabel","dateAttribute","timezoneAbbreviation","getTimezoneAbbreviation","formattedDate","now","Date","isTimezoneSameAsSiteTimezone","isSameDay","tomorrow","setDate","getFullYear","timezone","abbr","isNaN","Number","symbol","offset","siteOffset","dateOffset","getTimezoneOffset","left","right","getMonth"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,QAA/B,QAA+C,iBAA/C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AAC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,IAAX,CAAR,CAA3B,EAAyD;AACxD,WAAOD,QAAQ,CAACC,IAAhB;AACA;;AAED,QAAMG,MAAM,GAAGJ,QAAQ,CAACK,MAAT,GAAkB,CAAlB,GAAsB,EAAtB,GAA2B,GAA1C;AACA,SAAQ,MAAMD,MAAQ,GAAGJ,QAAQ,CAACK,MAAQ,EAA1C;AACA;;AAED,SAASV,4BAAT,CAAuCb,IAAvC,EAA8C;AAC7C,QAAM;AAAEkB,IAAAA;AAAF,MAAe5B,WAAW,EAAhC;AAEA,QAAMkC,UAAU,GAAGH,MAAM,CAAEH,QAAQ,CAACK,MAAX,CAAzB;AACA,QAAME,UAAU,GAAG,CAAC,CAAD,IAAOzB,IAAI,CAAC0B,iBAAL,KAA2B,EAAlC,CAAnB;AACA,SAAOF,UAAU,KAAKC,UAAtB;AACA;;AAED,SAASX,SAAT,CAAoBa,IAApB,EAA0BC,KAA1B,EAAkC;AACjC,SACCD,IAAI,CAACpC,OAAL,OAAmBqC,KAAK,CAACrC,OAAN,EAAnB,IACAoC,IAAI,CAACE,QAAL,OAAoBD,KAAK,CAACC,QAAN,EADpB,IAEAF,IAAI,CAACV,WAAL,OAAuBW,KAAK,CAACX,WAAN,EAHxB;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getSettings, getDate, dateI18n } from '@wordpress/date';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostScheduleLabel( props ) {\n\treturn usePostScheduleLabel( props );\n}\n\nexport function usePostScheduleLabel( { full = false } = {} ) {\n\tconst { date, isFloating } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tisFloating: select( editorStore ).isEditedPostDateFloating(),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn full\n\t\t? getFullPostScheduleLabel( date )\n\t\t: getPostScheduleLabel( date, { isFloating } );\n}\n\nexport function getFullPostScheduleLabel( dateAttribute ) {\n\tconst date = getDate( dateAttribute );\n\n\tconst timezoneAbbreviation = getTimezoneAbbreviation();\n\tconst formattedDate = dateI18n(\n\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n\treturn isRTL()\n\t\t? `${ timezoneAbbreviation } ${ formattedDate }`\n\t\t: `${ formattedDate } ${ timezoneAbbreviation }`;\n}\n\nexport function getPostScheduleLabel(\n\tdateAttribute,\n\t{ isFloating = false, now = new Date() } = {}\n) {\n\tif ( ! dateAttribute || isFloating ) {\n\t\treturn __( 'Immediately' );\n\t}\n\n\t// If the user timezone does not equal the site timezone then using words\n\t// like 'tomorrow' is confusing, so show the full date.\n\tif ( ! isTimezoneSameAsSiteTimezone( now ) ) {\n\t\treturn getFullPostScheduleLabel( dateAttribute );\n\t}\n\n\tconst date = getDate( dateAttribute );\n\n\tif ( isSameDay( date, now ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Today at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tconst tomorrow = new Date( now );\n\ttomorrow.setDate( tomorrow.getDate() + 1 );\n\n\tif ( isSameDay( date, tomorrow ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Tomorrow at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tif ( date.getFullYear() === now.getFullYear() ) {\n\t\treturn dateI18n(\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t\t_x( 'F j g:i\\xa0a', 'post schedule date format without year' ),\n\t\t\tdate\n\t\t);\n\t}\n\n\treturn dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n}\n\nfunction getTimezoneAbbreviation() {\n\tconst { timezone } = getSettings();\n\n\tif ( timezone.abbr && isNaN( Number( timezone.abbr ) ) ) {\n\t\treturn timezone.abbr;\n\t}\n\n\tconst symbol = timezone.offset < 0 ? '' : '+';\n\treturn `UTC${ symbol }${ timezone.offset }`;\n}\n\nfunction isTimezoneSameAsSiteTimezone( date ) {\n\tconst { timezone } = getSettings();\n\n\tconst siteOffset = Number( timezone.offset );\n\tconst dateOffset = -1 * ( date.getTimezoneOffset() / 60 );\n\treturn siteOffset === dateOffset;\n}\n\nfunction isSameDay( left, right ) {\n\treturn (\n\t\tleft.getDate() === right.getDate() &&\n\t\tleft.getMonth() === right.getMonth() &&\n\t\tleft.getFullYear() === right.getFullYear()\n\t);\n}\n"]}
|
|
@@ -4,10 +4,9 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* Internal dependencies
|
|
5
5
|
*/
|
|
6
6
|
import PostTypeSupportCheck from '../post-type-support-check';
|
|
7
|
-
export default function PostSlugCheck(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
7
|
+
export default function PostSlugCheck({
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
11
10
|
return createElement(PostTypeSupportCheck, {
|
|
12
11
|
supportKeys: "slug"
|
|
13
12
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-slug/check.js"],"names":["PostTypeSupportCheck","PostSlugCheck","children"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,oBAAP,MAAiC,4BAAjC;AAEA,eAAe,SAASC,aAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-slug/check.js"],"names":["PostTypeSupportCheck","PostSlugCheck","children"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,oBAAP,MAAiC,4BAAjC;AAEA,eAAe,SAASC,aAAT,CAAwB;AAAEC,EAAAA;AAAF,CAAxB,EAAuC;AACrD,SACC,cAAC,oBAAD;AAAsB,IAAA,WAAW,EAAC;AAAlC,KACGA,QADH,CADD;AAKA","sourcesContent":["/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nexport default function PostSlugCheck( { children } ) {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"slug\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"]}
|
|
@@ -16,12 +16,11 @@ import { TextControl } from '@wordpress/components';
|
|
|
16
16
|
import PostSlugCheck from './check';
|
|
17
17
|
import { store as editorStore } from '../../store';
|
|
18
18
|
export class PostSlug extends Component {
|
|
19
|
-
constructor(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _ref;
|
|
19
|
+
constructor({
|
|
20
|
+
postSlug,
|
|
21
|
+
postTitle,
|
|
22
|
+
postID
|
|
23
|
+
}) {
|
|
25
24
|
super(...arguments);
|
|
26
25
|
this.state = {
|
|
27
26
|
editedSlug: safeDecodeURIComponent(postSlug) || cleanForSlug(postTitle) || postID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-slug/index.js"],"names":["withDispatch","withSelect","Component","__","compose","safeDecodeURIComponent","cleanForSlug","TextControl","PostSlugCheck","store","editorStore","PostSlug","constructor","postSlug","postTitle","postID","arguments","state","editedSlug","setSlug","bind","event","onUpdateSlug","props","value","target","render","slug","setState","select","getCurrentPost","getEditedPostAttribute","id","dispatch","editPost"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,sBAAT,EAAiCC,YAAjC,QAAqD,gBAArD;AACA,SAASC,WAAT,QAA4B,uBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,MAAMC,QAAN,SAAuBT,SAAvB,CAAiC;AACvCU,EAAAA,WAAW,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-slug/index.js"],"names":["withDispatch","withSelect","Component","__","compose","safeDecodeURIComponent","cleanForSlug","TextControl","PostSlugCheck","store","editorStore","PostSlug","constructor","postSlug","postTitle","postID","arguments","state","editedSlug","setSlug","bind","event","onUpdateSlug","props","value","target","render","slug","setState","select","getCurrentPost","getEditedPostAttribute","id","dispatch","editPost"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,sBAAT,EAAiCC,YAAjC,QAAqD,gBAArD;AACA,SAASC,WAAT,QAA4B,uBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,MAAMC,QAAN,SAAuBT,SAAvB,CAAiC;AACvCU,EAAAA,WAAW,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA;AAAvB,GAAF,EAAoC;AAC9C,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,UAAU,EACTb,sBAAsB,CAAEQ,QAAF,CAAtB,IACAP,YAAY,CAAEQ,SAAF,CADZ,IAEAC;AAJW,KAAb;AAOA,SAAKI,OAAL,GAAe,KAAKA,OA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,EAYvBhC,YAAY,CAAIiC,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAeD,QAAQ,CAAEvB,WAAF,CAA7B;AACA,SAAO;AACNY,IAAAA,YAAY,CAAEK,IAAF,EAAS;AACpBO,MAAAA,QAAQ,CAAE;AAAEP,QAAAA;AAAF,OAAF,CAAR;AACA;;AAHK,GAAP;AAKA,CAPW,CAZW,CAAF,CAAP,CAoBVhB,QApBU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { compose } from '@wordpress/compose';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\nimport { TextControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport PostSlugCheck from './check';\nimport { store as editorStore } from '../../store';\n\nexport class PostSlug extends Component {\n\tconstructor( { postSlug, postTitle, postID } ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\teditedSlug:\n\t\t\t\tsafeDecodeURIComponent( postSlug ) ||\n\t\t\t\tcleanForSlug( postTitle ) ||\n\t\t\t\tpostID,\n\t\t};\n\n\t\tthis.setSlug = this.setSlug.bind( this );\n\t}\n\n\tsetSlug( event ) {\n\t\tconst { postSlug, onUpdateSlug } = this.props;\n\t\tconst { value } = event.target;\n\n\t\tconst editedSlug = cleanForSlug( value );\n\n\t\tif ( editedSlug === postSlug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonUpdateSlug( editedSlug );\n\t}\n\n\trender() {\n\t\tconst { editedSlug } = this.state;\n\t\treturn (\n\t\t\t<PostSlugCheck>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Slug' ) }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\tvalue={ editedSlug }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\tthis.setState( { editedSlug: slug } )\n\t\t\t\t\t}\n\t\t\t\t\tonBlur={ this.setSlug }\n\t\t\t\t\tclassName=\"editor-post-slug\"\n\t\t\t\t/>\n\t\t\t</PostSlugCheck>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\tselect( editorStore );\n\n\t\tconst { id } = getCurrentPost();\n\t\treturn {\n\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\tpostTitle: getEditedPostAttribute( 'title' ),\n\t\t\tpostID: id,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateSlug( slug ) {\n\t\t\t\teditPost( { slug } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSlug );\n"]}
|
|
@@ -8,13 +8,11 @@ import { withSelect } from '@wordpress/data';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { store as editorStore } from '../../store';
|
|
11
|
-
export function PostStickyCheck(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref;
|
|
17
|
-
|
|
11
|
+
export function PostStickyCheck({
|
|
12
|
+
hasStickyAction,
|
|
13
|
+
postType,
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
18
16
|
if (postType !== 'post' || !hasStickyAction) {
|
|
19
17
|
return null;
|
|
20
18
|
}
|
|
@@ -22,11 +20,11 @@ export function PostStickyCheck(_ref) {
|
|
|
22
20
|
return children;
|
|
23
21
|
}
|
|
24
22
|
export default compose([withSelect(select => {
|
|
25
|
-
var _post$_links$wpActio
|
|
23
|
+
var _post$_links$wpActio;
|
|
26
24
|
|
|
27
25
|
const post = select(editorStore).getCurrentPost();
|
|
28
26
|
return {
|
|
29
|
-
hasStickyAction: (_post$_links$wpActio =
|
|
27
|
+
hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
|
|
30
28
|
postType: select(editorStore).getCurrentPostType()
|
|
31
29
|
};
|
|
32
30
|
})])(PostStickyCheck);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/check.js"],"names":["compose","withSelect","store","editorStore","PostStickyCheck","hasStickyAction","postType","children","select","post","getCurrentPost","_links","getCurrentPostType"],"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,eAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/check.js"],"names":["compose","withSelect","store","editorStore","PostStickyCheck","hasStickyAction","postType","children","select","post","getCurrentPost","_links","getCurrentPostType"],"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,eAAT,CAA0B;AAAEC,EAAAA,eAAF;AAAmBC,EAAAA,QAAnB;AAA6BC,EAAAA;AAA7B,CAA1B,EAAoE;AAC1E,MAAKD,QAAQ,KAAK,MAAb,IAAuB,CAAED,eAA9B,EAAgD;AAC/C,WAAO,IAAP;AACA;;AAED,SAAOE,QAAP;AACA;AAED,eAAeP,OAAO,CAAE,CACvBC,UAAU,CAAIO,MAAF,IAAc;AAAA;;AACzB,QAAMC,IAAI,GAAGD,MAAM,CAAEL,WAAF,CAAN,CAAsBO,cAAtB,EAAb;AACA,SAAO;AACNL,IAAAA,eAAe,0BAAEI,IAAI,CAACE,MAAL,GAAe,kBAAf,CAAF,uEAAyC,KADlD;AAENL,IAAAA,QAAQ,EAAEE,MAAM,CAAEL,WAAF,CAAN,CAAsBS,kBAAtB;AAFJ,GAAP;AAIA,CANS,CADa,CAAF,CAAP,CAQVR,eARU,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 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"]}
|
|
@@ -13,11 +13,10 @@ import { compose } from '@wordpress/compose';
|
|
|
13
13
|
|
|
14
14
|
import PostStickyCheck from './check';
|
|
15
15
|
import { store as editorStore } from '../../store';
|
|
16
|
-
export function PostSticky(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = _ref;
|
|
16
|
+
export function PostSticky({
|
|
17
|
+
onUpdateSticky,
|
|
18
|
+
postSticky = false
|
|
19
|
+
}) {
|
|
21
20
|
return createElement(PostStickyCheck, null, createElement(CheckboxControl, {
|
|
22
21
|
__nextHasNoMarginBottom: true,
|
|
23
22
|
label: __('Stick to the top of the blog'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"names":["__","CheckboxControl","withSelect","withDispatch","compose","PostStickyCheck","store","editorStore","PostSticky","onUpdateSticky","postSticky","select","getEditedPostAttribute","dispatch","editPost","sticky"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,uBAAhC;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,SAA5B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,UAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"names":["__","CheckboxControl","withSelect","withDispatch","compose","PostStickyCheck","store","editorStore","PostSticky","onUpdateSticky","postSticky","select","getEditedPostAttribute","dispatch","editPost","sticky"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,uBAAhC;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,SAA5B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,UAAT,CAAqB;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA,UAAU,GAAG;AAA/B,CAArB,EAA8D;AACpE,SACC,cAAC,eAAD,QACC,cAAC,eAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAGV,EAAE,CAAE,8BAAF,CAFX;AAGC,IAAA,OAAO,EAAGU,UAHX;AAIC,IAAA,QAAQ,EAAG,MAAMD,cAAc,CAAE,CAAEC,UAAJ;AAJhC,IADD,CADD;AAUA;AAED,eAAeN,OAAO,CAAE,CACvBF,UAAU,CAAIS,MAAF,IAAc;AACzB,SAAO;AACND,IAAAA,UAAU,EACTC,MAAM,CAAEJ,WAAF,CAAN,CAAsBK,sBAAtB,CAA8C,QAA9C;AAFK,GAAP;AAIA,CALS,CADa,EAOvBT,YAAY,CAAIU,QAAF,IAAgB;AAC7B,SAAO;AACNJ,IAAAA,cAAc,CAAEC,UAAF,EAAe;AAC5BG,MAAAA,QAAQ,CAAEN,WAAF,CAAR,CAAwBO,QAAxB,CAAkC;AAAEC,QAAAA,MAAM,EAAEL;AAAV,OAAlC;AACA;;AAHK,GAAP;AAKA,CANW,CAPW,CAAF,CAAP,CAcVF,UAdU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\nexport function PostSticky( { onUpdateSticky, postSticky = false } ) {\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Stick to the top of the blog' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => onUpdateSticky( ! postSticky ) }\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostSticky:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\treturn {\n\t\t\tonUpdateSticky( postSticky ) {\n\t\t\t\tdispatch( editorStore ).editPost( { sticky: postSticky } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSticky );\n"]}
|
|
@@ -14,13 +14,12 @@ import { useState } from '@wordpress/element';
|
|
|
14
14
|
|
|
15
15
|
import { store as editorStore } from '../../store';
|
|
16
16
|
|
|
17
|
-
function PostSwitchToDraftButton(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = _ref;
|
|
17
|
+
function PostSwitchToDraftButton({
|
|
18
|
+
isSaving,
|
|
19
|
+
isPublished,
|
|
20
|
+
isScheduled,
|
|
21
|
+
onClick
|
|
22
|
+
}) {
|
|
24
23
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
25
24
|
|
|
26
25
|
if (!isPublished && !isScheduled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"names":["Button","FlexItem","__experimentalConfirmDialog","ConfirmDialog","__","withSelect","withDispatch","compose","useState","store","editorStore","PostSwitchToDraftButton","isSaving","isPublished","isScheduled","onClick","showConfirmDialog","setShowConfirmDialog","alertMessage","handleConfirm","width","display","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","dispatch","editPost","savePost","status"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,QAFD,EAGCC,2BAA2B,IAAIC,aAHhC,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,uBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"names":["Button","FlexItem","__experimentalConfirmDialog","ConfirmDialog","__","withSelect","withDispatch","compose","useState","store","editorStore","PostSwitchToDraftButton","isSaving","isPublished","isScheduled","onClick","showConfirmDialog","setShowConfirmDialog","alertMessage","handleConfirm","width","display","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","dispatch","editPost","savePost","status"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,QAFD,EAGCC,2BAA2B,IAAIC,aAHhC,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAAS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AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,sBAAhB;AAAwCC,IAAAA;AAAxC,MACLH,MAAM,CAAEZ,WAAF,CADP;AAEA,SAAO;AACNE,IAAAA,QAAQ,EAAEW,YAAY,EADhB;AAENV,IAAAA,WAAW,EAAEW,sBAAsB,EAF7B;AAGNV,IAAAA,WAAW,EAAEW,sBAAsB;AAH7B,GAAP;AAKA,CARS,CADa,EAUvBnB,YAAY,CAAIoB,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,QAAQ,CAAEhB,WAAF,CAAvC;AACA,SAAO;AACNK,IAAAA,OAAO,EAAE,MAAM;AACdY,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,MAAM,EAAE;AAAV,OAAF,CAAR;AACAD,MAAAA,QAAQ;AACR;AAJK,GAAP;AAMA,CARW,CAVW,CAAF,CAAP,CAmBVjB,uBAnBU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFlexItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction PostSwitchToDraftButton( {\n\tisSaving,\n\tisPublished,\n\tisScheduled,\n\tonClick,\n} ) {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! isPublished && ! isScheduled ) {\n\t\treturn null;\n\t}\n\n\tlet alertMessage;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\tonClick();\n\t};\n\n\treturn (\n\t\t<FlexItem isBlock>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t} }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tstyle={ { width: '100%', display: 'block' } }\n\t\t\t>\n\t\t\t\t{ __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</FlexItem>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, savePost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonClick: () => {\n\t\t\t\teditPost( { status: 'draft' } );\n\t\t\t\tsavePost();\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSwitchToDraftButton );\n"]}
|
|
@@ -9,13 +9,12 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { store as editorStore } from '../../store';
|
|
12
|
-
export function PostTaxonomiesCheck(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const hasTaxonomies = taxonomies === null || taxonomies === void 0 ? void 0 : taxonomies.some(taxonomy => taxonomy.types.includes(postType));
|
|
12
|
+
export function PostTaxonomiesCheck({
|
|
13
|
+
postType,
|
|
14
|
+
taxonomies,
|
|
15
|
+
children
|
|
16
|
+
}) {
|
|
17
|
+
const hasTaxonomies = taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
|
|
19
18
|
|
|
20
19
|
if (!hasTaxonomies) {
|
|
21
20
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/check.js"],"names":["compose","withSelect","store","coreStore","editorStore","PostTaxonomiesCheck","postType","taxonomies","children","hasTaxonomies","some","taxonomy","types","includes","select","getCurrentPostType","getTaxonomies","per_page"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,UAAT,QAA2B,iBAA3B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,mBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/check.js"],"names":["compose","withSelect","store","coreStore","editorStore","PostTaxonomiesCheck","postType","taxonomies","children","hasTaxonomies","some","taxonomy","types","includes","select","getCurrentPostType","getTaxonomies","per_page"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,UAAT,QAA2B,iBAA3B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,mBAAT,CAA8B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,UAAZ;AAAwBC,EAAAA;AAAxB,CAA9B,EAAmE;AACzE,QAAMC,aAAa,GAAGF,UAAU,EAAEG,IAAZ,CAAoBC,QAAF,IACvCA,QAAQ,CAACC,KAAT,CAAeC,QAAf,CAAyBP,QAAzB,CADqB,CAAtB;;AAGA,MAAK,CAAEG,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAOD,QAAP;AACA;AAED,eAAeR,OAAO,CAAE,CACvBC,UAAU,CAAIa,MAAF,IAAc;AACzB,SAAO;AACNR,IAAAA,QAAQ,EAAEQ,MAAM,CAAEV,WAAF,CAAN,CAAsBW,kBAAtB,EADJ;AAENR,IAAAA,UAAU,EAAEO,MAAM,CAAEX,SAAF,CAAN,CAAoBa,aAApB,CAAmC;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAnC;AAFN,GAAP;AAIA,CALS,CADa,CAAF,CAAP,CAOVZ,mBAPU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PostTaxonomiesCheck( { postType, taxonomies, children } ) {\n\tconst hasTaxonomies = taxonomies?.some( ( taxonomy ) =>\n\t\ttaxonomy.types.includes( postType )\n\t);\n\tif ( ! hasTaxonomies ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomiesCheck );\n"]}
|
|
@@ -69,12 +69,11 @@ function findOrCreateTerm(termName, restBase, namespace) {
|
|
|
69
69
|
}).then(unescapeTerm);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function FlatTermSelector(
|
|
73
|
-
|
|
72
|
+
export function FlatTermSelector({
|
|
73
|
+
slug
|
|
74
|
+
}) {
|
|
75
|
+
var _taxonomy$labels$add_, _taxonomy$labels$sing2;
|
|
74
76
|
|
|
75
|
-
let {
|
|
76
|
-
slug
|
|
77
|
-
} = _ref;
|
|
78
77
|
const [values, setValues] = useState([]);
|
|
79
78
|
const [search, setSearch] = useState('');
|
|
80
79
|
const debouncedSearch = useDebounce(setSearch, 500);
|
|
@@ -86,7 +85,7 @@ export function FlatTermSelector(_ref) {
|
|
|
86
85
|
hasCreateAction,
|
|
87
86
|
hasResolvedTerms
|
|
88
87
|
} = useSelect(select => {
|
|
89
|
-
var _post$_links, _post$_links2
|
|
88
|
+
var _post$_links, _post$_links2;
|
|
90
89
|
|
|
91
90
|
const {
|
|
92
91
|
getCurrentPost,
|
|
@@ -108,8 +107,8 @@ export function FlatTermSelector(_ref) {
|
|
|
108
107
|
per_page: -1
|
|
109
108
|
};
|
|
110
109
|
return {
|
|
111
|
-
hasCreateAction: _taxonomy ? (_post$_links =
|
|
112
|
-
hasAssignAction: _taxonomy ? (_post$
|
|
110
|
+
hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
|
|
111
|
+
hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
|
|
113
112
|
taxonomy: _taxonomy,
|
|
114
113
|
termIds: _termIds,
|
|
115
114
|
terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY,
|
|
@@ -178,7 +177,7 @@ export function FlatTermSelector(_ref) {
|
|
|
178
177
|
return;
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
const namespace = (_taxonomy$rest_namesp = taxonomy
|
|
180
|
+
const namespace = (_taxonomy$rest_namesp = taxonomy?.rest_namespace) !== null && _taxonomy$rest_namesp !== void 0 ? _taxonomy$rest_namesp : 'wp/v2';
|
|
182
181
|
Promise.all(newTermNames.map(termName => findOrCreateTerm(termName, taxonomy.rest_base, namespace))).then(newTerms => {
|
|
183
182
|
const newAvailableTerms = availableTerms.concat(newTerms);
|
|
184
183
|
return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
|
|
@@ -186,7 +185,7 @@ export function FlatTermSelector(_ref) {
|
|
|
186
185
|
}
|
|
187
186
|
|
|
188
187
|
function appendTerm(newTerm) {
|
|
189
|
-
var _taxonomy$labels$sing
|
|
188
|
+
var _taxonomy$labels$sing;
|
|
190
189
|
|
|
191
190
|
if (termIds.includes(newTerm.id)) {
|
|
192
191
|
return;
|
|
@@ -196,13 +195,13 @@ export function FlatTermSelector(_ref) {
|
|
|
196
195
|
const defaultName = slug === 'post_tag' ? __('Tag') : __('Term');
|
|
197
196
|
const termAddedMessage = sprintf(
|
|
198
197
|
/* translators: %s: term name. */
|
|
199
|
-
_x('%s added', 'term'), (_taxonomy$labels$sing = taxonomy
|
|
198
|
+
_x('%s added', 'term'), (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : defaultName);
|
|
200
199
|
speak(termAddedMessage, 'assertive');
|
|
201
200
|
onUpdateTerms(newTermIds);
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
const newTermLabel = (_taxonomy$labels$add_ = taxonomy
|
|
205
|
-
const singularName = (_taxonomy$labels$sing2 = taxonomy
|
|
203
|
+
const newTermLabel = (_taxonomy$labels$add_ = taxonomy?.labels?.add_new_item) !== null && _taxonomy$labels$add_ !== void 0 ? _taxonomy$labels$add_ : slug === 'post_tag' ? __('Add new tag') : __('Add new Term');
|
|
204
|
+
const singularName = (_taxonomy$labels$sing2 = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing2 !== void 0 ? _taxonomy$labels$sing2 : slug === 'post_tag' ? __('Tag') : __('Term');
|
|
206
205
|
const termAddedLabel = sprintf(
|
|
207
206
|
/* translators: %s: term name. */
|
|
208
207
|
_x('%s added', 'term'), singularName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["escapeHtml","__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","withFilters","useSelect","useDispatch","store","coreStore","useDebounce","apiFetch","speak","editorStore","unescapeString","unescapeTerm","MostUsedTerms","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","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","getEntityRecords","getTaxonomy","hasFinishedResolution","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":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,aAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,OAApB,EAA6BC,QAA7B,QAA6C,oBAA7C;AACA,SAASC,cAAT,EAAyBC,WAAzB,QAA4C,uBAA5C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASJ,KAAK,IAAIK,WAAlB,QAAqC,aAArC;AACA,SAASC,cAAT,EAAyBC,YAAzB,QAA6C,mBAA7C;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA;AACA;AACA;AACA;AACA;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AqC,IAAA,QAAQ,EAAGyC;AAAhD,IAdD,CADD;AAkBA;AAED,eAAe/F,WAAW,CAAE,yBAAF,CAAX,CAA0C8C,gBAA1C,CAAf","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, slug ]\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["escapeHtml","__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","withFilters","useSelect","useDispatch","store","coreStore","useDebounce","apiFetch","speak","editorStore","unescapeString","unescapeTerm","MostUsedTerms","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","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","getEntityRecords","getTaxonomy","hasFinishedResolution","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":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,aAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,OAApB,EAA6BC,QAA7B,QAA6C,oBAA7C;AACA,SAASC,cAAT,EAAyBC,WAAzB,QAA4C,uBAA5C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASJ,KAAK,IAAIK,WAAlB,QAAqC,aAArC;AACA,SAASC,cAAT,EAAyBC,YAAzB,QAA6C,mBAA7C;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,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,KACtBX,cAAc,CAAEU,KAAF,CAAd,CAAwBE,WAAxB,OACAZ,cAAc,CAAEW,KAAF,CAAd,CAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG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EAG7B8G,YAH6B,CAA9B;AAKA,QAAME,gBAAgB,GAAG/G,OAAO;AAC/B;AACAD,EAAAA,EAAE,CAAE,YAAF,EAAgB,MAAhB,CAF6B,EAG/B8G,YAH+B,CAAhC;AAKA,QAAMG,eAAe,GAAGhH,OAAO;AAC9B;AACAD,EAAAA,EAAE,CAAE,WAAF,EAAe,MAAf,CAF4B,EAG9B8G,YAH8B,CAA/B;AAMA,SACC,8BACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGxD,MADT;AAEC,IAAA,WAAW,EAAG2B,WAFf;AAGC,IAAA,QAAQ,EAAGI,QAHZ;AAIC,IAAA,aAAa,EAAG3B,eAJjB;AAKC,IAAA,cAAc,EAAGvC,qBALlB;AAMC,IAAA,KAAK,EAAGyF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVM,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGrD,QAA1B;AAAqC,IAAA,QAAQ,EAAGyC;AAAhD,IAdD,CADD;AAkBA;AAED,eAAe/F,WAAW,CAAE,yBAAF,CAAX,CAA0C8C,gBAA1C,CAAf","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, slug ]\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"]}
|
|
@@ -133,12 +133,11 @@ export function getFilterMatcher(filterValue) {
|
|
|
133
133
|
* @return {WPElement} Hierarchical term selector component.
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
|
-
export function HierarchicalTermSelector(
|
|
137
|
-
|
|
136
|
+
export function HierarchicalTermSelector({
|
|
137
|
+
slug
|
|
138
|
+
}) {
|
|
139
|
+
var _taxonomy$labels$sear, _taxonomy$name;
|
|
138
140
|
|
|
139
|
-
let {
|
|
140
|
-
slug
|
|
141
|
-
} = _ref;
|
|
142
141
|
const [adding, setAdding] = useState(false);
|
|
143
142
|
const [formName, setFormName] = useState('');
|
|
144
143
|
/**
|
|
@@ -158,7 +157,7 @@ export function HierarchicalTermSelector(_ref) {
|
|
|
158
157
|
availableTerms,
|
|
159
158
|
taxonomy
|
|
160
159
|
} = useSelect(select => {
|
|
161
|
-
var _post$_links, _post$_links2
|
|
160
|
+
var _post$_links, _post$_links2;
|
|
162
161
|
|
|
163
162
|
const {
|
|
164
163
|
getCurrentPost,
|
|
@@ -174,8 +173,8 @@ export function HierarchicalTermSelector(_ref) {
|
|
|
174
173
|
|
|
175
174
|
const post = getCurrentPost();
|
|
176
175
|
return {
|
|
177
|
-
hasCreateAction: _taxonomy ? (_post$_links =
|
|
178
|
-
hasAssignAction: _taxonomy ? (_post$
|
|
176
|
+
hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
|
|
177
|
+
hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
|
|
179
178
|
terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : EMPTY_ARRAY,
|
|
180
179
|
loading: isResolving('getEntityRecords', ['taxonomy', slug, DEFAULT_QUERY]),
|
|
181
180
|
availableTerms: getEntityRecords('taxonomy', slug, DEFAULT_QUERY) || EMPTY_ARRAY,
|
|
@@ -250,7 +249,7 @@ export function HierarchicalTermSelector(_ref) {
|
|
|
250
249
|
};
|
|
251
250
|
|
|
252
251
|
const onAddTerm = async event => {
|
|
253
|
-
var _taxonomy$labels$sing
|
|
252
|
+
var _taxonomy$labels$sing;
|
|
254
253
|
|
|
255
254
|
event.preventDefault();
|
|
256
255
|
|
|
@@ -280,7 +279,7 @@ export function HierarchicalTermSelector(_ref) {
|
|
|
280
279
|
const defaultName = slug === 'category' ? __('Category') : __('Term');
|
|
281
280
|
const termAddedMessage = sprintf(
|
|
282
281
|
/* translators: %s: taxonomy name */
|
|
283
|
-
_x('%s added', 'term'), (_taxonomy$labels$sing = taxonomy
|
|
282
|
+
_x('%s added', 'term'), (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : defaultName);
|
|
284
283
|
speak(termAddedMessage, 'assertive');
|
|
285
284
|
setAdding(false);
|
|
286
285
|
setFormName('');
|
|
@@ -334,9 +333,9 @@ export function HierarchicalTermSelector(_ref) {
|
|
|
334
333
|
};
|
|
335
334
|
|
|
336
335
|
const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => {
|
|
337
|
-
var _taxonomy$labels$labe
|
|
336
|
+
var _taxonomy$labels$labe;
|
|
338
337
|
|
|
339
|
-
return (_taxonomy$labels$labe = taxonomy
|
|
338
|
+
return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory;
|
|
340
339
|
};
|
|
341
340
|
|
|
342
341
|
const newTermButtonLabel = labelWithFallback('add_new_item', __('Add new category'), __('Add new term'));
|
|
@@ -344,8 +343,8 @@ export function HierarchicalTermSelector(_ref) {
|
|
|
344
343
|
const parentSelectLabel = labelWithFallback('parent_item', __('Parent Category'), __('Parent Term'));
|
|
345
344
|
const noParentOption = `— ${parentSelectLabel} —`;
|
|
346
345
|
const newTermSubmitLabel = newTermButtonLabel;
|
|
347
|
-
const filterLabel = (_taxonomy$labels$sear = taxonomy
|
|
348
|
-
const groupLabel = (_taxonomy$name = taxonomy
|
|
346
|
+
const filterLabel = (_taxonomy$labels$sear = taxonomy?.labels?.search_items) !== null && _taxonomy$labels$sear !== void 0 ? _taxonomy$labels$sear : __('Search Terms');
|
|
347
|
+
const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : __('Terms');
|
|
349
348
|
const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
|
|
350
349
|
return createElement(Flex, {
|
|
351
350
|
direction: "column",
|