@wordpress/editor 13.10.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 +4 -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 +42 -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 +13 -14
- 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 +6 -10
- 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 +43 -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 +13 -14
- 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 +6 -10
- 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/build-style/style-rtl.css +1 -1
- package/build-style/style.css +1 -1
- package/package.json +31 -31
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +85 -0
- package/src/components/entities-saved-states/index.js +29 -107
- 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-taxonomies/flat-term-selector.js +1 -1
- package/src/components/post-title/index.js +2 -1
- package/src/components/provider/use-block-editor-settings.js +1 -0
- package/src/private-apis.js +2 -0
|
@@ -5,27 +5,19 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
7
|
import { Button, Flex, FlexItem } from '@wordpress/components';
|
|
8
|
-
import { __
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { useDispatch } from '@wordpress/data';
|
|
10
|
+
import { useCallback, useRef } from '@wordpress/element';
|
|
11
11
|
import { store as coreStore } from '@wordpress/core-data';
|
|
12
12
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
13
|
import { __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
14
14
|
import { store as noticesStore } from '@wordpress/notices';
|
|
15
|
-
import { getQueryArg } from '@wordpress/url';
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
19
|
import EntityTypeList from './entity-type-list';
|
|
21
|
-
|
|
22
|
-
title: __('Title'),
|
|
23
|
-
description: __('Tagline'),
|
|
24
|
-
site_logo: __('Logo'),
|
|
25
|
-
site_icon: __('Icon'),
|
|
26
|
-
show_on_front: __('Show on front'),
|
|
27
|
-
page_on_front: __('Page on front')
|
|
28
|
-
};
|
|
20
|
+
import { useIsDirty } from './hooks/use-is-dirty';
|
|
29
21
|
const PUBLISH_ON_SAVE_ENTITIES = [{
|
|
30
22
|
kind: 'postType',
|
|
31
23
|
name: 'wp_navigation'
|
|
@@ -35,56 +27,26 @@ function identity(values) {
|
|
|
35
27
|
return values;
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (isPreviewingTheme()) {
|
|
46
|
-
return getQueryArg(window.location.href, 'theme_preview');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return null;
|
|
30
|
+
export default function EntitiesSavedStates({
|
|
31
|
+
close
|
|
32
|
+
}) {
|
|
33
|
+
const isDirtyProps = useIsDirty();
|
|
34
|
+
return createElement(EntitiesSavedStatesExtensible, _extends({
|
|
35
|
+
close: close
|
|
36
|
+
}, isDirtyProps));
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
38
|
+
export function EntitiesSavedStatesExtensible({
|
|
39
|
+
additionalPrompt = undefined,
|
|
40
|
+
close,
|
|
41
|
+
onSave = identity,
|
|
42
|
+
saveEnabled: saveEnabledProp = undefined,
|
|
43
|
+
saveLabel = __('Save'),
|
|
44
|
+
dirtyEntityRecords,
|
|
45
|
+
isDirty,
|
|
46
|
+
setUnselectedEntities,
|
|
47
|
+
unselectedEntities
|
|
48
|
+
}) {
|
|
59
49
|
const saveButtonRef = useRef();
|
|
60
|
-
const {
|
|
61
|
-
getTheme
|
|
62
|
-
} = useSelect(coreStore);
|
|
63
|
-
const theme = getTheme(currentlyPreviewingTheme());
|
|
64
|
-
const {
|
|
65
|
-
dirtyEntityRecords
|
|
66
|
-
} = useSelect(select => {
|
|
67
|
-
const dirtyRecords = select(coreStore).__experimentalGetDirtyEntityRecords(); // Remove site object and decouple into its edited pieces.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const dirtyRecordsWithoutSite = dirtyRecords.filter(record => !(record.kind === 'root' && record.name === 'site'));
|
|
71
|
-
const siteEdits = select(coreStore).getEntityRecordEdits('root', 'site');
|
|
72
|
-
const siteEditsAsEntities = [];
|
|
73
|
-
|
|
74
|
-
for (const property in siteEdits) {
|
|
75
|
-
siteEditsAsEntities.push({
|
|
76
|
-
kind: 'root',
|
|
77
|
-
name: 'site',
|
|
78
|
-
title: TRANSLATED_SITE_PROPERTIES[property] || property,
|
|
79
|
-
property
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const dirtyRecordsWithSiteItems = [...dirtyRecordsWithoutSite, ...siteEditsAsEntities];
|
|
84
|
-
return {
|
|
85
|
-
dirtyEntityRecords: dirtyRecordsWithSiteItems
|
|
86
|
-
};
|
|
87
|
-
}, []);
|
|
88
50
|
const {
|
|
89
51
|
editEntityRecord,
|
|
90
52
|
saveEditedEntityRecord,
|
|
@@ -95,7 +57,8 @@ export default function EntitiesSavedStates(_ref) {
|
|
|
95
57
|
} = useDispatch(blockEditorStore);
|
|
96
58
|
const {
|
|
97
59
|
createSuccessNotice,
|
|
98
|
-
createErrorNotice
|
|
60
|
+
createErrorNotice,
|
|
61
|
+
removeNotice
|
|
99
62
|
} = useDispatch(noticesStore); // To group entities by type.
|
|
100
63
|
|
|
101
64
|
const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
|
|
@@ -117,51 +80,29 @@ export default function EntitiesSavedStates(_ref) {
|
|
|
117
80
|
wp_template_part: templatePartSavables,
|
|
118
81
|
...contentSavables
|
|
119
82
|
} = partitionedSavables;
|
|
120
|
-
const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
|
|
121
|
-
|
|
122
|
-
const [unselectedEntities, _setUnselectedEntities] = useState([]);
|
|
83
|
+
const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
|
|
84
|
+
const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
|
|
123
85
|
|
|
124
|
-
const
|
|
125
|
-
|
|
86
|
+
const saveCheckedEntities = () => {
|
|
87
|
+
const saveNoticeId = 'site-editor-save-success';
|
|
88
|
+
removeNotice(saveNoticeId);
|
|
89
|
+
const entitiesToSave = dirtyEntityRecords.filter(({
|
|
126
90
|
kind,
|
|
127
91
|
name,
|
|
128
92
|
key,
|
|
129
93
|
property
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (checked) {
|
|
133
|
-
_setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
|
|
134
|
-
} else {
|
|
135
|
-
_setUnselectedEntities([...unselectedEntities, {
|
|
136
|
-
kind,
|
|
137
|
-
name,
|
|
138
|
-
key,
|
|
139
|
-
property
|
|
140
|
-
}]);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const saveCheckedEntitiesAndActivate = () => {
|
|
145
|
-
const entitiesToSave = dirtyEntityRecords.filter(_ref3 => {
|
|
146
|
-
let {
|
|
147
|
-
kind,
|
|
148
|
-
name,
|
|
149
|
-
key,
|
|
150
|
-
property
|
|
151
|
-
} = _ref3;
|
|
94
|
+
}) => {
|
|
152
95
|
return !unselectedEntities.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
|
|
153
96
|
});
|
|
154
97
|
close(entitiesToSave);
|
|
155
98
|
const siteItemsToSave = [];
|
|
156
99
|
const pendingSavedRecords = [];
|
|
157
|
-
entitiesToSave.forEach(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
} = _ref4;
|
|
164
|
-
|
|
100
|
+
entitiesToSave.forEach(({
|
|
101
|
+
kind,
|
|
102
|
+
name,
|
|
103
|
+
key,
|
|
104
|
+
property
|
|
105
|
+
}) => {
|
|
165
106
|
if ('root' === kind && 'site' === name) {
|
|
166
107
|
siteItemsToSave.push(property);
|
|
167
108
|
} else {
|
|
@@ -188,7 +129,8 @@ export default function EntitiesSavedStates(_ref) {
|
|
|
188
129
|
createErrorNotice(__('Saving failed.'));
|
|
189
130
|
} else {
|
|
190
131
|
createSuccessNotice(__('Site updated.'), {
|
|
191
|
-
type: 'snackbar'
|
|
132
|
+
type: 'snackbar',
|
|
133
|
+
id: saveNoticeId
|
|
192
134
|
});
|
|
193
135
|
}
|
|
194
136
|
}).catch(error => createErrorNotice(`${__('Saving failed.')} ${error}`));
|
|
@@ -200,18 +142,6 @@ export default function EntitiesSavedStates(_ref) {
|
|
|
200
142
|
const [saveDialogRef, saveDialogProps] = useDialog({
|
|
201
143
|
onClose: () => dismissPanel()
|
|
202
144
|
});
|
|
203
|
-
const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
|
|
204
|
-
const activateSaveEnabled = isPreviewingTheme() || isDirty;
|
|
205
|
-
let activateSaveLabel;
|
|
206
|
-
|
|
207
|
-
if (isPreviewingTheme() && isDirty) {
|
|
208
|
-
activateSaveLabel = __('Activate & Save');
|
|
209
|
-
} else if (isPreviewingTheme()) {
|
|
210
|
-
activateSaveLabel = __('Activate');
|
|
211
|
-
} else {
|
|
212
|
-
activateSaveLabel = __('Save');
|
|
213
|
-
}
|
|
214
|
-
|
|
215
145
|
return createElement("div", _extends({
|
|
216
146
|
ref: saveDialogRef
|
|
217
147
|
}, saveDialogProps, {
|
|
@@ -224,17 +154,17 @@ export default function EntitiesSavedStates(_ref) {
|
|
|
224
154
|
as: Button,
|
|
225
155
|
ref: saveButtonRef,
|
|
226
156
|
variant: "primary",
|
|
227
|
-
disabled: !
|
|
228
|
-
onClick:
|
|
157
|
+
disabled: !saveEnabled,
|
|
158
|
+
onClick: saveCheckedEntities,
|
|
229
159
|
className: "editor-entities-saved-states__save-button"
|
|
230
|
-
},
|
|
160
|
+
}, saveLabel), createElement(FlexItem, {
|
|
231
161
|
isBlock: true,
|
|
232
162
|
as: Button,
|
|
233
163
|
variant: "secondary",
|
|
234
164
|
onClick: dismissPanel
|
|
235
165
|
}, __('Cancel'))), createElement("div", {
|
|
236
166
|
className: "entities-saved-states__text-prompt"
|
|
237
|
-
}, createElement("strong", null, __('Are you ready to save?')),
|
|
167
|
+
}, createElement("strong", null, __('Are you ready to save?')), additionalPrompt, isDirty && createElement("p", null, __('The following changes have been made to your site, templates, and content.'))), sortedPartitionedSavables.map(list => {
|
|
238
168
|
return createElement(EntityTypeList, {
|
|
239
169
|
key: list[0].name,
|
|
240
170
|
list: list,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"names":["Button","Flex","FlexItem","__","sprintf","useSelect","useDispatch","useState","useCallback","useRef","store","coreStore","blockEditorStore","__experimentalUseDialog","useDialog","noticesStore","getQueryArg","EntityTypeList","TRANSLATED_SITE_PROPERTIES","title","description","site_logo","site_icon","show_on_front","page_on_front","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","isPreviewingTheme","window","__experimentalEnableThemePreviews","location","href","undefined","currentlyPreviewingTheme","EntitiesSavedStates","close","onSave","saveButtonRef","getTheme","theme","dirtyEntityRecords","select","dirtyRecords","__experimentalGetDirtyEntityRecords","dirtyRecordsWithoutSite","filter","record","siteEdits","getEntityRecordEdits","siteEditsAsEntities","property","push","dirtyRecordsWithSiteItems","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","__unstableMarkLastChangeAsPersistent","createSuccessNotice","createErrorNotice","partitionedSavables","reduce","acc","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","Array","isArray","unselectedEntities","_setUnselectedEntities","setUnselectedEntities","checked","key","elt","saveCheckedEntitiesAndActivate","entitiesToSave","some","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","catch","error","dismissPanel","saveDialogRef","saveDialogProps","onClose","isDirty","activateSaveEnabled","activateSaveLabel","rendered","map","list"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,IAAjB,EAAuBC,QAAvB,QAAuC,uBAAvC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,MAAhC,QAA8C,oBAA9C;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,uBAAuB,IAAIC,SAApC,QAAqD,oBAArD;AACA,SAASJ,KAAK,IAAIK,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAT,QAA4B,gBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,MAAMC,0BAA0B,GAAG;AAClCC,EAAAA,KAAK,EAAEhB,EAAE,CAAE,OAAF,CADyB;AAElCiB,EAAAA,WAAW,EAAEjB,EAAE,CAAE,SAAF,CAFmB;AAGlCkB,EAAAA,SAAS,EAAElB,EAAE,CAAE,MAAF,CAHqB;AAIlCmB,EAAAA,SAAS,EAAEnB,EAAE,CAAE,MAAF,CAJqB;AAKlCoB,EAAAA,aAAa,EAAEpB,EAAE,CAAE,eAAF,CALiB;AAMlCqB,EAAAA,aAAa,EAAErB,EAAE,CAAE,eAAF;AANiB,CAAnC;AASA,MAAMsB,wBAAwB,GAAG,CAChC;AACCC,EAAAA,IAAI,EAAE,UADP;AAECC,EAAAA,IAAI,EAAE;AAFP,CADgC,CAAjC;;AAOA,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,SAAOA,MAAP;AACA;;AAED,SAASC,iBAAT,GAA6B;AAAA;;AAC5B,SACC,YAAAC,MAAM,UAAN,0CAAQC,iCAAR,KACA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AA,GAAG,EAAGwC,aAHP;AAIC,IAAA,OAAO,EAAC,SAJT;AAKC,IAAA,QAAQ,EAAG,CAAEgE,mBALd;AAMC,IAAA,OAAO,EAAGrB,8BANX;AAOC,IAAA,SAAS,EAAC;AAPX,KASGsB,iBATH,CADD,EAYC,cAAC,QAAD;AACC,IAAA,OAAO,MADR;AAEC,IAAA,EAAE,EAAGzG,MAFN;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,IAAA,OAAO,EAAGmG;AAJX,KAMGhG,EAAE,CAAE,QAAF,CANL,CAZD,CALD,EA2BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,8BAAUA,EAAE,CAAE,wBAAF,CAAZ,CADD,EAEG2B,iBAAiB,MAClB,yBACG1B,OAAO,CACR,6DADQ,EAERsC,KAFQ,aAERA,KAFQ,sCAERA,KAAK,CAAEf,IAFC,gDAER,YAAa+E,QAFL,CADV,CAHF,EAUGH,OAAO,IACR,yBACGpG,EAAE,CACH,4EADG,CADL,CAXF,CA3BD,EA8CGsE,yBAAyB,CAACkC,GAA1B,CAAiCC,IAAF,IAAY;AAC5C,WACC,cAAC,cAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAAE,CAAF,CAAJ,CAAUjF,IADjB;AAEC,MAAA,IAAI,EAAGiF,IAFR;AAGC,MAAA,UAAU,EAAGT,YAHd;AAIC,MAAA,kBAAkB,EAAGtB,kBAJtB;AAKC,MAAA,qBAAqB,EAAGE;AALzB,MADD;AASA,GAVC,CA9CH,CADD;AA4DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getQueryArg } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\n\nconst TRANSLATED_SITE_PROPERTIES = {\n\ttitle: __( 'Title' ),\n\tdescription: __( 'Tagline' ),\n\tsite_logo: __( 'Logo' ),\n\tsite_icon: __( 'Icon' ),\n\tshow_on_front: __( 'Show on front' ),\n\tpage_on_front: __( 'Page on front' ),\n};\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nfunction isPreviewingTheme() {\n\treturn (\n\t\twindow?.__experimentalEnableThemePreviews &&\n\t\tgetQueryArg( window.location.href, 'theme_preview' ) !== undefined\n\t);\n}\n\nfunction currentlyPreviewingTheme() {\n\tif ( isPreviewingTheme() ) {\n\t\treturn getQueryArg( window.location.href, 'theme_preview' );\n\t}\n\treturn null;\n}\n\nexport default function EntitiesSavedStates( { close, onSave = identity } ) {\n\tconst saveButtonRef = useRef();\n\tconst { getTheme } = useSelect( coreStore );\n\tconst theme = getTheme( currentlyPreviewingTheme() );\n\tconst { dirtyEntityRecords } = useSelect( ( select ) => {\n\t\tconst dirtyRecords =\n\t\t\tselect( coreStore ).__experimentalGetDirtyEntityRecords();\n\n\t\t// Remove site object and decouple into its edited pieces.\n\t\tconst dirtyRecordsWithoutSite = dirtyRecords.filter(\n\t\t\t( record ) => ! ( record.kind === 'root' && record.name === 'site' )\n\t\t);\n\n\t\tconst siteEdits = select( coreStore ).getEntityRecordEdits(\n\t\t\t'root',\n\t\t\t'site'\n\t\t);\n\n\t\tconst siteEditsAsEntities = [];\n\t\tfor ( const property in siteEdits ) {\n\t\t\tsiteEditsAsEntities.push( {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t\ttitle: TRANSLATED_SITE_PROPERTIES[ property ] || property,\n\t\t\t\tproperty,\n\t\t\t} );\n\t\t}\n\t\tconst dirtyRecordsWithSiteItems = [\n\t\t\t...dirtyRecordsWithoutSite,\n\t\t\t...siteEditsAsEntities,\n\t\t];\n\n\t\treturn {\n\t\t\tdirtyEntityRecords: dirtyRecordsWithSiteItems,\n\t\t};\n\t}, [] );\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\t// Unchecked entities to be ignored by save function.\n\tconst [ unselectedEntities, _setUnselectedEntities ] = useState( [] );\n\n\tconst setUnselectedEntities = (\n\t\t{ kind, name, key, property },\n\t\tchecked\n\t) => {\n\t\tif ( checked ) {\n\t\t\t_setUnselectedEntities(\n\t\t\t\tunselectedEntities.filter(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind !== kind ||\n\t\t\t\t\t\telt.name !== name ||\n\t\t\t\t\t\telt.key !== key ||\n\t\t\t\t\t\telt.property !== property\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\t_setUnselectedEntities( [\n\t\t\t\t...unselectedEntities,\n\t\t\t\t{ kind, name, key, property },\n\t\t\t] );\n\t\t}\n\t};\n\n\tconst saveCheckedEntitiesAndActivate = () => {\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\tconst isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;\n\tconst activateSaveEnabled = isPreviewingTheme() || isDirty;\n\n\tlet activateSaveLabel;\n\tif ( isPreviewingTheme() && isDirty ) {\n\t\tactivateSaveLabel = __( 'Activate & Save' );\n\t} else if ( isPreviewingTheme() ) {\n\t\tactivateSaveLabel = __( 'Activate' );\n\t} else {\n\t\tactivateSaveLabel = __( 'Save' );\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! activateSaveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntitiesAndActivate }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ activateSaveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong>{ __( 'Are you ready to save?' ) }</strong>\n\t\t\t\t{ isPreviewingTheme() && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t'Saving your changes will change your active theme to %1$s.',\n\t\t\t\t\t\t\ttheme?.name?.rendered\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ isDirty && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tclosePanel={ dismissPanel }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"names":["Button","Flex","FlexItem","__","useDispatch","useCallback","useRef","store","coreStore","blockEditorStore","__experimentalUseDialog","useDialog","noticesStore","EntityTypeList","useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","__unstableMarkLastChangeAsPersistent","createSuccessNotice","createErrorNotice","removeNotice","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","catch","error","dismissPanel","saveDialogRef","saveDialogProps","onClose","map","list"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,IAAjB,EAAuBC,QAAvB,QAAuC,uBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,uBAAuB,IAAIC,SAApC,QAAqD,oBAArD;AACA,SAASJ,KAAK,IAAIK,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,SAASC,UAAT,QAA2B,sBAA3B;AAEA,MAAMC,wBAAwB,GAAG,CAChC;AACCC,EAAAA,IAAI,EAAE,UADP;AAECC,EAAAA,IAAI,EAAE;AAFP,CADgC,CAAjC;;AAOA,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,SAAOA,MAAP;AACA;;AAED,eAAe,SAASC,mBAAT,CAA8B;AAAEC,EAAAA;AAAF,CAA9B,EAA0C;AACxD,QAAMC,YAAY,GAAGR,UAAU,EAA/B;AACA,SACC,cAAC,6BAAD;AAA+B,IAAA,KAAK,EAAGO;AAAvC,KAAoDC,YAApD,EADD;AAGA;AAED,OAAO,SAASC,6BAA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press/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong>{ __( 'Are you ready to save?' ) }</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t{ isDirty && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tclosePanel={ dismissPanel }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -28,11 +28,10 @@ function getContent() {
|
|
|
28
28
|
} catch (error) {}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function CopyButton(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = _ref;
|
|
31
|
+
function CopyButton({
|
|
32
|
+
text,
|
|
33
|
+
children
|
|
34
|
+
}) {
|
|
36
35
|
const ref = useCopyToClipboard(text);
|
|
37
36
|
return createElement(Button, {
|
|
38
37
|
variant: "secondary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["Component","__","Button","select","Warning","useCopyToClipboard","doAction","store","editorStore","getContent","getEditedPostContent","error","CopyButton","text","children","ref","ErrorBoundary","constructor","arguments","state","componentDidCatch","getDerivedStateFromError","render","props","actions","stack"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,QAAT,QAAyB,kBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,UAAT,GAAsB;AACrB,MAAI;AACH;AACA;AACA;AACA;AACA;AACA;AACA,WAAON,MAAM,CAAEK,WAAF,CAAN,CAAsBE,oBAAtB,EAAP;AACA,GARD,CAQE,OAAQC,KAAR,EAAgB,CAAE;AACpB;;AAED,SAASC,UAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["Component","__","Button","select","Warning","useCopyToClipboard","doAction","store","editorStore","getContent","getEditedPostContent","error","CopyButton","text","children","ref","ErrorBoundary","constructor","arguments","state","componentDidCatch","getDerivedStateFromError","render","props","actions","stack"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,QAAT,QAAyB,kBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,UAAT,GAAsB;AACrB,MAAI;AACH;AACA;AACA;AACA;AACA;AACA;AACA,WAAON,MAAM,CAAEK,WAAF,CAAN,CAAsBE,oBAAtB,EAAP;AACA,GARD,CAQE,OAAQC,KAAR,EAAgB,CAAE;AACpB;;AAED,SAASC,UAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAA0C;AACzC,QAAMC,GAAG,GAAGV,kBAAkB,CAAEQ,IAAF,CAA9B;AACA,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,MAAME,aAAN,SAA4BhB,SAA5B,CAAsC;AACrCiB,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZR,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDS,EAAAA,iBAAiB,CAAET,KAAF,EAAU;AAC1BL,IAAAA,QAAQ,CAAE,kCAAF,EAAsCK,KAAtC,CAAR;AACA;;AAE8B,SAAxBU,wBAAwB,CAAEV,KAAF,EAAU;AACxC,WAAO;AAAEA,MAAAA;AAAF,KAAP;AACA;;AAEDW,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEX,MAAAA;AAAF,QAAY,KAAKQ,KAAvB;;AACA,QAAK,CAAER,KAAP,EAAe;AACd,aAAO,KAAKY,KAAL,CAAWT,QAAlB;AACA;;AAED,UAAMU,OAAO,GAAG,CACf,cAAC,UAAD;AAAY,MAAA,GAAG,EAAC,WAAhB;AAA4B,MAAA,IAAI,EAAGf;AAAnC,OACGR,EAAE,CAAE,gBAAF,CADL,CADe,EAIf,cAAC,UAAD;AAAY,MAAA,GAAG,EAAC,YAAhB;AAA6B,MAAA,IAAI,EAAGU,KAAK,CAACc;AAA1C,OACGxB,EAAE,CAAE,YAAF,CADL,CAJe,CAAhB;AASA,WACC,cAAC,OAAD;AAAS,MAAA,SAAS,EAAC,uBAAnB;AAA2C,MAAA,OAAO,EAAGuB;AAArD,OACGvB,EAAE,CAAE,iDAAF,CADL,CADD;AAKA;;AArCoC;;AAwCtC,eAAee,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { select } from '@wordpress/data';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getContent() {\n\ttry {\n\t\t// While `select` in a component is generally discouraged, it is\n\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t// case of additional errors by performing a direct retrieval and\n\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t// application.\n\t\treturn select( editorStore ).getEditedPostContent();\n\t} catch ( error ) {}\n}\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst actions = [\n\t\t\t<CopyButton key=\"copy-post\" text={ getContent }>\n\t\t\t\t{ __( 'Copy Post Text' ) }\n\t\t\t</CopyButton>,\n\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t</CopyButton>,\n\t\t];\n\n\t\treturn (\n\t\t\t<Warning className=\"editor-error-boundary\" actions={ actions }>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n\nexport default ErrorBoundary;\n"]}
|
|
@@ -10,10 +10,9 @@ import { parse } from '@wordpress/blocks';
|
|
|
10
10
|
|
|
11
11
|
import { store as editorStore } from '../../store';
|
|
12
12
|
|
|
13
|
-
function SaveShortcut(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref;
|
|
13
|
+
function SaveShortcut({
|
|
14
|
+
resetBlocksOnSave
|
|
15
|
+
}) {
|
|
17
16
|
const {
|
|
18
17
|
resetEditorBlocks,
|
|
19
18
|
savePost
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/save-shortcut.js"],"names":["useShortcut","useDispatch","useSelect","parse","store","editorStore","SaveShortcut","resetBlocksOnSave","resetEditorBlocks","savePost","isEditedPostDirty","getPostEdits","isPostSavingLocked","event","preventDefault","postEdits","content","blocks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,+BAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,YAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/save-shortcut.js"],"names":["useShortcut","useDispatch","useSelect","parse","store","editorStore","SaveShortcut","resetBlocksOnSave","resetEditorBlocks","savePost","isEditedPostDirty","getPostEdits","isPostSavingLocked","event","preventDefault","postEdits","content","blocks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,+BAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,YAAT,CAAuB;AAAEC,EAAAA;AAAF,CAAvB,EAA+C;AAC9C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAkCR,WAAW,CAAEI,WAAF,CAAnD;AACA,QAAM;AAAEK,IAAAA,iBAAF;AAAqBC,IAAAA,YAArB;AAAmCC,IAAAA;AAAnC,MACLV,SAAS,CAAEG,WAAF,CADV;AAGAL,EAAAA,WAAW,CAAE,kBAAF,EAAwBa,KAAF,IAAa;AAC7CA,IAAAA,KAAK,CAACC,cAAN;AAEA;AACF;AACA;;AACE,QAAKF,kBAAkB,EAAvB,EAA4B;AAC3B;AACA,KAR4C,CAU7C;AACA;AACA;AACA;AACA;;;AACA,QAAK,CAAEF,iBAAiB,EAAxB,EAA6B;AAC5B;AACA,KAjB4C,CAmB7C;AACA;AACA;AACA;;;AACA,QAAKH,iBAAL,EAAyB;AACxB,YAAMQ,SAAS,GAAGJ,YAAY,EAA9B;;AACA,UAAKI,SAAS,CAACC,OAAV,IAAqB,OAAOD,SAAS,CAACC,OAAjB,KAA6B,QAAvD,EAAkE;AACjE,cAAMC,MAAM,GAAGd,KAAK,CAAEY,SAAS,CAACC,OAAZ,CAApB;AACAR,QAAAA,iBAAiB,CAAES,MAAF,CAAjB;AACA;AACD;;AAEDR,IAAAA,QAAQ;AACR,GAhCU,CAAX;AAkCA,SAAO,IAAP;AACA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction SaveShortcut( { resetBlocksOnSave } ) {\n\tconst { resetEditorBlocks, savePost } = useDispatch( editorStore );\n\tconst { isEditedPostDirty, getPostEdits, isPostSavingLocked } =\n\t\tuseSelect( editorStore );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The text editor requires that editor blocks are updated for a\n\t\t// save to work correctly. Usually this happens when the textarea\n\t\t// for the code editors blurs, but the shortcut can be used without\n\t\t// blurring the textarea.\n\t\tif ( resetBlocksOnSave ) {\n\t\t\tconst postEdits = getPostEdits();\n\t\t\tif ( postEdits.content && typeof postEdits.content === 'string' ) {\n\t\t\t\tconst blocks = parse( postEdits.content );\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t}\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\treturn null;\n}\n\nexport default SaveShortcut;\n"]}
|
|
@@ -12,6 +12,7 @@ export { default as EditorHistoryUndo } from './editor-history/undo';
|
|
|
12
12
|
export { default as EditorNotices } from './editor-notices';
|
|
13
13
|
export { default as EditorSnackbars } from './editor-snackbars';
|
|
14
14
|
export { default as EntitiesSavedStates } from './entities-saved-states';
|
|
15
|
+
export { useIsDirty as useEntitiesSavedStatesIsDirty } from './entities-saved-states/hooks/use-is-dirty';
|
|
15
16
|
export { default as ErrorBoundary } from './error-boundary';
|
|
16
17
|
export { default as LocalAutosaveMonitor } from './local-autosave-monitor';
|
|
17
18
|
export { default as PageAttributesCheck } from './page-attributes/check';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":["default","AutosaveMonitor","DocumentOutline","DocumentOutlineCheck","VisualEditorGlobalKeyboardShortcuts","TextEditorGlobalKeyboardShortcuts","EditorKeyboardShortcutsRegister","EditorHistoryRedo","EditorHistoryUndo","EditorNotices","EditorSnackbars","EntitiesSavedStates","ErrorBoundary","LocalAutosaveMonitor","PageAttributesCheck","PageAttributesOrder","PageAttributesParent","PageTemplate","PostAuthor","PostAuthorCheck","PostComments","PostExcerpt","PostExcerptCheck","PostFeaturedImage","PostFeaturedImageCheck","PostFormat","PostFormatCheck","PostLastRevision","PostLastRevisionCheck","PostLockedModal","PostPendingStatus","PostPendingStatusCheck","PostPingbacks","PostPreviewButton","PostPublishButton","PostPublishButtonLabel","PostPublishPanel","PostSavedState","PostSchedule","PostScheduleCheck","PostScheduleLabel","usePostScheduleLabel","PostSlug","PostSlugCheck","PostSticky","PostStickyCheck","PostSwitchToDraftButton","PostTaxonomies","FlatTermSelector","PostTaxonomiesFlatTermSelector","HierarchicalTermSelector","PostTaxonomiesHierarchicalTermSelector","PostTaxonomiesCheck","PostTextEditor","PostTitle","PostTrash","PostTrashCheck","PostTypeSupportCheck","PostURL","PostURLCheck","PostURLLabel","usePostURLLabel","PostVisibility","PostVisibilityLabel","usePostVisibilityLabel","PostVisibilityCheck","TableOfContents","ThemeSupportCheck","UnsavedChangesWarning","WordCount","TimeToRead","CharacterCount","EditorProvider"],"mappings":"AAAA;AACA,cAAc,kBAAd,C,CAEA;;AACA,SAASA,OAAO,IAAIC,eAApB,QAA2C,oBAA3C;AACA,SAASD,OAAO,IAAIE,eAApB,QAA2C,oBAA3C;AACA,SAASF,OAAO,IAAIG,oBAApB,QAAgD,0BAAhD;AACA,SAASH,OAAO,IAAII,mCAApB,QAA+D,qDAA/D;AACA,SAASJ,OAAO,IAAIK,iCAApB,QAA6D,mDAA7D;AACA,SAASL,OAAO,IAAIM,+BAApB,QAA2D,gDAA3D;AACA,SAASN,OAAO,IAAIO,iBAApB,QAA6C,uBAA7C;AACA,SAASP,OAAO,IAAIQ,iBAApB,QAA6C,uBAA7C;AACA,SAASR,OAAO,IAAIS,aAApB,QAAyC,kBAAzC;AACA,SAAST,OAAO,IAAIU,eAApB,QAA2C,oBAA3C;AACA,SAASV,OAAO,IAAIW,mBAApB,QAA+C,yBAA/C;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":["default","AutosaveMonitor","DocumentOutline","DocumentOutlineCheck","VisualEditorGlobalKeyboardShortcuts","TextEditorGlobalKeyboardShortcuts","EditorKeyboardShortcutsRegister","EditorHistoryRedo","EditorHistoryUndo","EditorNotices","EditorSnackbars","EntitiesSavedStates","useIsDirty","useEntitiesSavedStatesIsDirty","ErrorBoundary","LocalAutosaveMonitor","PageAttributesCheck","PageAttributesOrder","PageAttributesParent","PageTemplate","PostAuthor","PostAuthorCheck","PostComments","PostExcerpt","PostExcerptCheck","PostFeaturedImage","PostFeaturedImageCheck","PostFormat","PostFormatCheck","PostLastRevision","PostLastRevisionCheck","PostLockedModal","PostPendingStatus","PostPendingStatusCheck","PostPingbacks","PostPreviewButton","PostPublishButton","PostPublishButtonLabel","PostPublishPanel","PostSavedState","PostSchedule","PostScheduleCheck","PostScheduleLabel","usePostScheduleLabel","PostSlug","PostSlugCheck","PostSticky","PostStickyCheck","PostSwitchToDraftButton","PostTaxonomies","FlatTermSelector","PostTaxonomiesFlatTermSelector","HierarchicalTermSelector","PostTaxonomiesHierarchicalTermSelector","PostTaxonomiesCheck","PostTextEditor","PostTitle","PostTrash","PostTrashCheck","PostTypeSupportCheck","PostURL","PostURLCheck","PostURLLabel","usePostURLLabel","PostVisibility","PostVisibilityLabel","usePostVisibilityLabel","PostVisibilityCheck","TableOfContents","ThemeSupportCheck","UnsavedChangesWarning","WordCount","TimeToRead","CharacterCount","EditorProvider"],"mappings":"AAAA;AACA,cAAc,kBAAd,C,CAEA;;AACA,SAASA,OAAO,IAAIC,eAApB,QAA2C,oBAA3C;AACA,SAASD,OAAO,IAAIE,eAApB,QAA2C,oBAA3C;AACA,SAASF,OAAO,IAAIG,oBAApB,QAAgD,0BAAhD;AACA,SAASH,OAAO,IAAII,mCAApB,QAA+D,qDAA/D;AACA,SAASJ,OAAO,IAAIK,iCAApB,QAA6D,mDAA7D;AACA,SAASL,OAAO,IAAIM,+BAApB,QAA2D,gDAA3D;AACA,SAASN,OAAO,IAAIO,iBAApB,QAA6C,uBAA7C;AACA,SAASP,OAAO,IAAIQ,iBAApB,QA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D;AACA,SAAS/D,OAAO,IAAIgE,cAApB,QAA0C,mBAA1C;AACA,SACChE,OAAO,IAAIiE,mBADZ,EAECC,sBAFD,QAGO,yBAHP;AAIA,SAASlE,OAAO,IAAImE,mBAApB,QAA+C,yBAA/C;AACA,SAASnE,OAAO,IAAIoE,eAApB,QAA2C,qBAA3C;AACA,SAASpE,OAAO,IAAIqE,iBAApB,QAA6C,uBAA7C;AACA,SAASrE,OAAO,IAAIsE,qBAApB,QAAiD,2BAAjD;AACA,SAAStE,OAAO,IAAIuE,SAApB,QAAqC,cAArC;AACA,SAASvE,OAAO,IAAIwE,UAApB,QAAsC,gBAAtC;AACA,SAASxE,OAAO,IAAIyE,cAApB,QAA0C,mBAA1C,C,CAEA;;AACA,SAASzE,OAAO,IAAI0E,cAApB,QAA0C,YAA1C;AAEA,cAAc,cAAd","sourcesContent":["// Block Creation Components.\nexport * from './autocompleters';\n\n// Post Related Components.\nexport { default as AutosaveMonitor } from './autosave-monitor';\nexport { default as DocumentOutline } from './document-outline';\nexport { default as DocumentOutlineCheck } from './document-outline/check';\nexport { default as VisualEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/visual-editor-shortcuts';\nexport { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts';\nexport { default as EditorKeyboardShortcutsRegister } from './global-keyboard-shortcuts/register-shortcuts';\nexport { default as EditorHistoryRedo } from './editor-history/redo';\nexport { default as EditorHistoryUndo } from './editor-history/undo';\nexport { default as EditorNotices } from './editor-notices';\nexport { default as EditorSnackbars } from './editor-snackbars';\nexport { default as EntitiesSavedStates } from './entities-saved-states';\nexport { useIsDirty as useEntitiesSavedStatesIsDirty } from './entities-saved-states/hooks/use-is-dirty';\nexport { default as ErrorBoundary } from './error-boundary';\nexport { default as LocalAutosaveMonitor } from './local-autosave-monitor';\nexport { default as PageAttributesCheck } from './page-attributes/check';\nexport { default as PageAttributesOrder } from './page-attributes/order';\nexport { default as PageAttributesParent } from './page-attributes/parent';\nexport { default as PageTemplate } from './post-template';\nexport { default as PostAuthor } from './post-author';\nexport { default as PostAuthorCheck } from './post-author/check';\nexport { default as PostComments } from './post-comments';\nexport { default as PostExcerpt } from './post-excerpt';\nexport { default as PostExcerptCheck } from './post-excerpt/check';\nexport { default as PostFeaturedImage } from './post-featured-image';\nexport { default as PostFeaturedImageCheck } from './post-featured-image/check';\nexport { default as PostFormat } from './post-format';\nexport { default as PostFormatCheck } from './post-format/check';\nexport { default as PostLastRevision } from './post-last-revision';\nexport { default as PostLastRevisionCheck } from './post-last-revision/check';\nexport { default as PostLockedModal } from './post-locked-modal';\nexport { default as PostPendingStatus } from './post-pending-status';\nexport { default as PostPendingStatusCheck } from './post-pending-status/check';\nexport { default as PostPingbacks } from './post-pingbacks';\nexport { default as PostPreviewButton } from './post-preview-button';\nexport { default as PostPublishButton } from './post-publish-button';\nexport { default as PostPublishButtonLabel } from './post-publish-button/label';\nexport { default as PostPublishPanel } from './post-publish-panel';\nexport { default as PostSavedState } from './post-saved-state';\nexport { default as PostSchedule } from './post-schedule';\nexport { default as PostScheduleCheck } from './post-schedule/check';\nexport {\n\tdefault as PostScheduleLabel,\n\tusePostScheduleLabel,\n} from './post-schedule/label';\nexport { default as PostSlug } from './post-slug';\nexport { default as PostSlugCheck } from './post-slug/check';\nexport { default as PostSticky } from './post-sticky';\nexport { default as PostStickyCheck } from './post-sticky/check';\nexport { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';\nexport { default as PostTaxonomies } from './post-taxonomies';\nexport { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';\nexport { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';\nexport { default as PostTaxonomiesCheck } from './post-taxonomies/check';\nexport { default as PostTextEditor } from './post-text-editor';\nexport { default as PostTitle } from './post-title';\nexport { default as PostTrash } from './post-trash';\nexport { default as PostTrashCheck } from './post-trash/check';\nexport { default as PostTypeSupportCheck } from './post-type-support-check';\nexport { default as PostURL } from './post-url';\nexport { default as PostURLCheck } from './post-url/check';\nexport { default as PostURLLabel, usePostURLLabel } from './post-url/label';\nexport { default as PostVisibility } from './post-visibility';\nexport {\n\tdefault as PostVisibilityLabel,\n\tusePostVisibilityLabel,\n} from './post-visibility/label';\nexport { default as PostVisibilityCheck } from './post-visibility/check';\nexport { default as TableOfContents } from './table-of-contents';\nexport { default as ThemeSupportCheck } from './theme-support-check';\nexport { default as UnsavedChangesWarning } from './unsaved-changes-warning';\nexport { default as WordCount } from './word-count';\nexport { default as TimeToRead } from './time-to-read';\nexport { default as CharacterCount } from './character-count';\n\n// State Related Components.\nexport { default as EditorProvider } from './provider';\n\nexport * from './deprecated';\n"]}
|
|
@@ -99,21 +99,16 @@ const getOpenverseCaption = item => {
|
|
|
99
99
|
return _caption.replace(/\s{2}/g, ' ');
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const coreMediaFetch = async
|
|
103
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
102
|
+
const coreMediaFetch = async (query = {}) => {
|
|
104
103
|
const mediaItems = await resolveSelect(coreStore).getMediaItems({ ...query,
|
|
105
|
-
orderBy: !!
|
|
106
|
-
});
|
|
107
|
-
return mediaItems.map(mediaItem => {
|
|
108
|
-
var _mediaItem$media_deta, _mediaItem$media_deta2, _mediaItem$media_deta3, _mediaItem$caption;
|
|
109
|
-
|
|
110
|
-
return { ...mediaItem,
|
|
111
|
-
alt: mediaItem.alt_text,
|
|
112
|
-
url: mediaItem.source_url,
|
|
113
|
-
previewUrl: (_mediaItem$media_deta = mediaItem.media_details) === null || _mediaItem$media_deta === void 0 ? void 0 : (_mediaItem$media_deta2 = _mediaItem$media_deta.sizes) === null || _mediaItem$media_deta2 === void 0 ? void 0 : (_mediaItem$media_deta3 = _mediaItem$media_deta2.medium) === null || _mediaItem$media_deta3 === void 0 ? void 0 : _mediaItem$media_deta3.source_url,
|
|
114
|
-
caption: (_mediaItem$caption = mediaItem.caption) === null || _mediaItem$caption === void 0 ? void 0 : _mediaItem$caption.raw
|
|
115
|
-
};
|
|
104
|
+
orderBy: !!query?.search ? 'relevance' : 'date'
|
|
116
105
|
});
|
|
106
|
+
return mediaItems.map(mediaItem => ({ ...mediaItem,
|
|
107
|
+
alt: mediaItem.alt_text,
|
|
108
|
+
url: mediaItem.source_url,
|
|
109
|
+
previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
|
|
110
|
+
caption: mediaItem.caption?.raw
|
|
111
|
+
}));
|
|
117
112
|
};
|
|
118
113
|
/** @type {InserterMediaCategory[]} */
|
|
119
114
|
|
|
@@ -126,8 +121,7 @@ const inserterMediaCategories = [{
|
|
|
126
121
|
},
|
|
127
122
|
mediaType: 'image',
|
|
128
123
|
|
|
129
|
-
async fetch() {
|
|
130
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
124
|
+
async fetch(query = {}) {
|
|
131
125
|
return coreMediaFetch({ ...query,
|
|
132
126
|
media_type: 'image'
|
|
133
127
|
});
|
|
@@ -141,8 +135,7 @@ const inserterMediaCategories = [{
|
|
|
141
135
|
},
|
|
142
136
|
mediaType: 'video',
|
|
143
137
|
|
|
144
|
-
async fetch() {
|
|
145
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
138
|
+
async fetch(query = {}) {
|
|
146
139
|
return coreMediaFetch({ ...query,
|
|
147
140
|
media_type: 'video'
|
|
148
141
|
});
|
|
@@ -156,8 +149,7 @@ const inserterMediaCategories = [{
|
|
|
156
149
|
},
|
|
157
150
|
mediaType: 'audio',
|
|
158
151
|
|
|
159
|
-
async fetch() {
|
|
160
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
152
|
+
async fetch(query = {}) {
|
|
161
153
|
return coreMediaFetch({ ...query,
|
|
162
154
|
media_type: 'audio'
|
|
163
155
|
});
|
|
@@ -171,8 +163,7 @@ const inserterMediaCategories = [{
|
|
|
171
163
|
},
|
|
172
164
|
mediaType: 'image',
|
|
173
165
|
|
|
174
|
-
async fetch() {
|
|
175
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
166
|
+
async fetch(query = {}) {
|
|
176
167
|
const defaultArgs = {
|
|
177
168
|
mature: false,
|
|
178
169
|
excluded_source: 'flickr,inaturalist,wikimedia',
|
|
@@ -186,8 +177,7 @@ const inserterMediaCategories = [{
|
|
|
186
177
|
search: 'q'
|
|
187
178
|
};
|
|
188
179
|
const url = new URL('https://api.openverse.engineering/v1/images/');
|
|
189
|
-
Object.entries(finalQuery).forEach(
|
|
190
|
-
let [key, value] = _ref;
|
|
180
|
+
Object.entries(finalQuery).forEach(([key, value]) => {
|
|
191
181
|
const queryKey = mapFromInserterMediaRequest[key] || key;
|
|
192
182
|
url.searchParams.set(queryKey, value);
|
|
193
183
|
});
|
|
@@ -198,27 +188,20 @@ const inserterMediaCategories = [{
|
|
|
198
188
|
});
|
|
199
189
|
const jsonResponse = await response.json();
|
|
200
190
|
const results = jsonResponse.results;
|
|
201
|
-
return results.map(result => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
caption: getOpenverseCaption(result),
|
|
211
|
-
previewUrl: result.thumbnail
|
|
212
|
-
};
|
|
213
|
-
});
|
|
191
|
+
return results.map(result => ({ ...result,
|
|
192
|
+
// This is a temp solution for better titles, until Openverse API
|
|
193
|
+
// completes the cleaning up of some titles of their upstream data.
|
|
194
|
+
title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
|
|
195
|
+
sourceId: result.id,
|
|
196
|
+
id: undefined,
|
|
197
|
+
caption: getOpenverseCaption(result),
|
|
198
|
+
previewUrl: result.thumbnail
|
|
199
|
+
}));
|
|
214
200
|
},
|
|
215
201
|
|
|
216
|
-
getReportUrl:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} = _ref2;
|
|
220
|
-
return `https://wordpress.org/openverse/image/${sourceId}/report/`;
|
|
221
|
-
},
|
|
202
|
+
getReportUrl: ({
|
|
203
|
+
sourceId
|
|
204
|
+
}) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
|
|
222
205
|
isExternalResource: true
|
|
223
206
|
}];
|
|
224
207
|
export default inserterMediaCategories;
|