@wordpress/editor 14.44.0 → 14.45.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/collab-sidebar/{comment-menu-item.cjs → add-note-menu-item.cjs} +17 -14
- package/build/components/collab-sidebar/add-note-menu-item.cjs.map +7 -0
- package/build/components/collab-sidebar/add-note.cjs +100 -0
- package/build/components/collab-sidebar/add-note.cjs.map +7 -0
- package/build/components/collab-sidebar/board-store.cjs +106 -0
- package/build/components/collab-sidebar/board-store.cjs.map +7 -0
- package/build/components/collab-sidebar/floating-container.cjs +63 -0
- package/build/components/collab-sidebar/floating-container.cjs.map +7 -0
- package/build/components/collab-sidebar/hooks.cjs +105 -140
- package/build/components/collab-sidebar/hooks.cjs.map +3 -3
- package/build/components/collab-sidebar/index.cjs +28 -90
- package/build/components/collab-sidebar/index.cjs.map +3 -3
- package/build/components/collab-sidebar/{comment-author-info.cjs → note-byline.cjs} +13 -9
- package/build/components/collab-sidebar/note-byline.cjs.map +7 -0
- package/build/components/collab-sidebar/note-card.cjs +58 -0
- package/build/components/collab-sidebar/note-card.cjs.map +7 -0
- package/build/components/collab-sidebar/{comment-form.cjs → note-form.cjs} +46 -45
- package/build/components/collab-sidebar/note-form.cjs.map +7 -0
- package/build/components/collab-sidebar/{comment-indicator-toolbar.cjs → note-indicator-toolbar.cjs} +31 -27
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +7 -0
- package/build/components/collab-sidebar/note-thread.cjs +321 -0
- package/build/components/collab-sidebar/note-thread.cjs.map +7 -0
- package/build/components/collab-sidebar/note.cjs +207 -0
- package/build/components/collab-sidebar/note.cjs.map +7 -0
- package/build/components/collab-sidebar/notes.cjs +237 -0
- package/build/components/collab-sidebar/notes.cjs.map +7 -0
- package/build/components/collab-sidebar/utils.cjs +80 -14
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-presence/avatar/component.cjs.map +1 -1
- package/build/components/collaborators-presence/index.cjs +3 -3
- package/build/components/collaborators-presence/index.cjs.map +2 -2
- package/build/components/collaborators-presence/list.cjs +3 -3
- package/build/components/collaborators-presence/list.cjs.map +2 -2
- package/build/components/document-bar/index.cjs.map +3 -3
- package/build/components/error-boundary/index.cjs.map +3 -3
- package/build/components/list-view-sidebar/list-view-outline.cjs.map +3 -3
- package/build/components/media/media-editor-modal.cjs +93 -0
- package/build/components/media/media-editor-modal.cjs.map +7 -0
- package/build/components/media-categories/index.cjs +1 -1
- package/build/components/media-categories/index.cjs.map +1 -1
- package/build/components/more-menu/index.cjs +4 -3
- package/build/components/more-menu/index.cjs.map +2 -2
- package/build/components/post-actions/set-as-homepage.cjs.map +3 -3
- package/build/components/post-actions/set-as-posts-page.cjs.map +3 -3
- package/build/components/post-card-panel/index.cjs +2 -2
- package/build/components/post-card-panel/index.cjs.map +3 -3
- package/build/components/post-content-information/index.cjs.map +3 -3
- package/build/components/post-excerpt/panel.cjs.map +3 -3
- package/build/components/post-last-edited-panel/index.cjs.map +3 -3
- package/build/components/post-preview-button/index.cjs +3 -2
- package/build/components/post-preview-button/index.cjs.map +2 -2
- package/build/components/post-publish-button/index.cjs +2 -2
- package/build/components/post-publish-button/index.cjs.map +2 -2
- package/build/components/post-publish-button/label.cjs +4 -2
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-panel/maybe-upload-media.cjs +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.cjs.map +1 -1
- package/build/components/post-publish-panel/postpublish.cjs +3 -2
- package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
- package/build/components/post-revisions-panel/index.cjs +2 -2
- package/build/components/post-revisions-panel/index.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +1 -1
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-slider.cjs +1 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-saved-state/index.cjs +4 -1
- package/build/components/post-saved-state/index.cjs.map +2 -2
- package/build/components/post-text-editor/index.cjs +3 -4
- package/build/components/post-text-editor/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs +3 -2
- package/build/components/preview-dropdown/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +3 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +7 -1
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/provider/use-upload-save-lock.cjs +2 -12
- package/build/components/provider/use-upload-save-lock.cjs.map +2 -2
- package/build/components/resizable-editor/resize-handle.cjs +2 -1
- package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
- package/build/components/revision-created-panel/index.cjs.map +3 -3
- package/build/components/site-discussion/index.cjs.map +2 -2
- package/build/components/style-book/constants.cjs +1 -1
- package/build/components/style-book/constants.cjs.map +1 -1
- package/build/components/style-book/index.cjs +1 -1
- package/build/components/style-book/index.cjs.map +1 -1
- package/build/components/template-actions-panel/classic-theme-content.cjs.map +2 -2
- package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
- package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +5 -22
- package/build/components/visual-editor/index.cjs.map +2 -2
- package/build/store/private-actions.cjs +0 -8
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +0 -5
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +0 -10
- package/build/store/reducer.cjs.map +2 -2
- package/build/utils/media-finalize/index.cjs +3 -2
- package/build/utils/media-finalize/index.cjs.map +2 -2
- package/build/utils/media-upload/index.cjs +14 -25
- package/build/utils/media-upload/index.cjs.map +2 -2
- package/build-module/components/collab-sidebar/{comment-menu-item.mjs → add-note-menu-item.mjs} +10 -11
- package/build-module/components/collab-sidebar/add-note-menu-item.mjs.map +7 -0
- package/build-module/components/collab-sidebar/add-note.mjs +78 -0
- package/build-module/components/collab-sidebar/add-note.mjs.map +7 -0
- package/build-module/components/collab-sidebar/board-store.mjs +81 -0
- package/build-module/components/collab-sidebar/board-store.mjs.map +7 -0
- package/build-module/components/collab-sidebar/floating-container.mjs +28 -0
- package/build-module/components/collab-sidebar/floating-container.mjs.map +7 -0
- package/build-module/components/collab-sidebar/hooks.mjs +105 -144
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +29 -95
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/{comment-author-info.mjs → note-byline.mjs} +7 -7
- package/build-module/components/collab-sidebar/note-byline.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note-card.mjs +33 -0
- package/build-module/components/collab-sidebar/note-card.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note-form.mjs +84 -0
- package/build-module/components/collab-sidebar/note-form.mjs.map +7 -0
- package/build-module/components/collab-sidebar/{comment-indicator-toolbar.mjs → note-indicator-toolbar.mjs} +25 -29
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note-thread.mjs +289 -0
- package/build-module/components/collab-sidebar/note-thread.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note.mjs +176 -0
- package/build-module/components/collab-sidebar/note.mjs.map +7 -0
- package/build-module/components/collab-sidebar/notes.mjs +215 -0
- package/build-module/components/collab-sidebar/notes.mjs.map +7 -0
- package/build-module/components/collab-sidebar/utils.mjs +76 -10
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-presence/avatar/component.mjs.map +1 -1
- package/build-module/components/collaborators-presence/index.mjs +3 -3
- package/build-module/components/collaborators-presence/index.mjs.map +2 -2
- package/build-module/components/collaborators-presence/list.mjs +3 -3
- package/build-module/components/collaborators-presence/list.mjs.map +2 -2
- package/build-module/components/document-bar/index.mjs +3 -3
- package/build-module/components/document-bar/index.mjs.map +2 -2
- package/build-module/components/error-boundary/index.mjs +2 -2
- package/build-module/components/error-boundary/index.mjs.map +2 -2
- package/build-module/components/list-view-sidebar/list-view-outline.mjs +5 -5
- package/build-module/components/list-view-sidebar/list-view-outline.mjs.map +2 -2
- package/build-module/components/media/media-editor-modal.mjs +62 -0
- package/build-module/components/media/media-editor-modal.mjs.map +7 -0
- package/build-module/components/media-categories/index.mjs +1 -1
- package/build-module/components/media-categories/index.mjs.map +1 -1
- package/build-module/components/more-menu/index.mjs +4 -8
- package/build-module/components/more-menu/index.mjs.map +2 -2
- package/build-module/components/post-actions/set-as-homepage.mjs +2 -2
- package/build-module/components/post-actions/set-as-homepage.mjs.map +2 -2
- package/build-module/components/post-actions/set-as-posts-page.mjs +2 -2
- package/build-module/components/post-actions/set-as-posts-page.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +5 -5
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-content-information/index.mjs +2 -2
- package/build-module/components/post-content-information/index.mjs.map +2 -2
- package/build-module/components/post-excerpt/panel.mjs +2 -2
- package/build-module/components/post-excerpt/panel.mjs.map +2 -2
- package/build-module/components/post-last-edited-panel/index.mjs +2 -2
- package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
- package/build-module/components/post-preview-button/index.mjs +3 -2
- package/build-module/components/post-preview-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/index.mjs +2 -2
- package/build-module/components/post-publish-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +4 -2
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.mjs +3 -3
- package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
- package/build-module/components/post-revisions-panel/index.mjs +2 -2
- package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +1 -1
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-saved-state/index.mjs +4 -1
- package/build-module/components/post-saved-state/index.mjs.map +2 -2
- package/build-module/components/post-text-editor/index.mjs +2 -3
- package/build-module/components/post-text-editor/index.mjs.map +2 -2
- package/build-module/components/preview-dropdown/index.mjs +2 -2
- package/build-module/components/preview-dropdown/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +3 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +7 -1
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/provider/use-upload-save-lock.mjs +2 -12
- package/build-module/components/provider/use-upload-save-lock.mjs.map +2 -2
- package/build-module/components/resizable-editor/resize-handle.mjs +2 -5
- package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
- package/build-module/components/revision-created-panel/index.mjs +2 -2
- package/build-module/components/revision-created-panel/index.mjs.map +2 -2
- package/build-module/components/site-discussion/index.mjs +2 -2
- package/build-module/components/site-discussion/index.mjs.map +2 -2
- package/build-module/components/style-book/constants.mjs +1 -1
- package/build-module/components/style-book/constants.mjs.map +1 -1
- package/build-module/components/style-book/index.mjs +1 -1
- package/build-module/components/style-book/index.mjs.map +1 -1
- package/build-module/components/template-actions-panel/classic-theme-content.mjs +2 -2
- package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +2 -2
- package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
- package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +5 -22
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +0 -7
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +0 -4
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +0 -9
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/utils/media-finalize/index.mjs +3 -2
- package/build-module/utils/media-finalize/index.mjs.map +2 -2
- package/build-module/utils/media-upload/index.mjs +14 -25
- package/build-module/utils/media-upload/index.mjs.map +2 -2
- package/build-style/style-rtl.css +397 -171
- package/build-style/style.css +397 -171
- package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
- package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
- package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/board-store.d.ts +9 -0
- package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/floating-container.d.ts +8 -0
- package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/hooks.d.ts +13 -22
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-byline.d.ts +7 -0
- package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
- package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
- package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
- package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note.d.ts +9 -0
- package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/notes.d.ts +7 -0
- package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/utils.d.ts +41 -17
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/media/media-editor-modal.d.ts +11 -0
- package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/provider/use-upload-save-lock.d.ts +0 -2
- package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/components/style-book/constants.d.ts +1 -1
- package/build-types/components/style-book/constants.d.ts.map +1 -1
- package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +0 -7
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +0 -7
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +0 -10
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/utils/media-finalize/index.d.ts +1 -1
- package/build-types/utils/media-finalize/index.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +46 -46
- package/src/components/collab-sidebar/README.md +117 -0
- package/src/components/collab-sidebar/{comment-menu-item.js → add-note-menu-item.js} +8 -10
- package/src/components/collab-sidebar/{add-comment.js → add-note.js} +26 -49
- package/src/components/collab-sidebar/board-store.js +85 -0
- package/src/components/collab-sidebar/floating-container.js +30 -0
- package/src/components/collab-sidebar/hooks.js +130 -178
- package/src/components/collab-sidebar/index.js +35 -106
- package/src/components/collab-sidebar/{comment-author-info.js → note-byline.js} +5 -6
- package/src/components/collab-sidebar/note-card.js +36 -0
- package/src/components/collab-sidebar/{comment-form.js → note-form.js} +29 -40
- package/src/components/collab-sidebar/{comment-indicator-toolbar.js → note-indicator-toolbar.js} +29 -32
- package/src/components/collab-sidebar/note-thread.js +331 -0
- package/src/components/collab-sidebar/note.js +209 -0
- package/src/components/collab-sidebar/notes.js +276 -0
- package/src/components/collab-sidebar/style.scss +21 -11
- package/src/components/collab-sidebar/test/utils.js +155 -0
- package/src/components/collab-sidebar/utils.js +125 -19
- package/src/components/collaborators-presence/avatar/component.tsx +1 -1
- package/src/components/collaborators-presence/styles/collaborators-list.scss +1 -1
- package/src/components/collaborators-presence/styles/collaborators-presence.scss +1 -1
- package/src/components/document-bar/index.js +4 -4
- package/src/components/document-outline/style.scss +1 -1
- package/src/components/error-boundary/index.js +3 -3
- package/src/components/list-view-sidebar/list-view-outline.js +6 -6
- package/src/components/media/media-editor-modal.js +95 -0
- package/src/components/media-categories/index.js +1 -1
- package/src/components/more-menu/index.js +4 -8
- package/src/components/post-actions/set-as-homepage.js +2 -2
- package/src/components/post-actions/set-as-posts-page.js +2 -2
- package/src/components/post-card-panel/index.js +7 -7
- package/src/components/post-content-information/index.js +3 -3
- package/src/components/post-excerpt/panel.js +3 -3
- package/src/components/post-last-edited-panel/index.js +3 -3
- package/src/components/post-preview-button/index.js +3 -2
- package/src/components/post-publish-button/index.js +6 -5
- package/src/components/post-publish-button/label.js +3 -1
- package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
- package/src/components/post-publish-panel/postpublish.js +2 -2
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +10 -16
- package/src/components/post-revisions-panel/index.js +3 -3
- package/src/components/post-revisions-preview/diff-markers.js +1 -1
- package/src/components/post-revisions-preview/revisions-slider.js +1 -0
- package/src/components/post-revisions-preview/style.scss +1 -1
- package/src/components/post-saved-state/index.js +4 -1
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -1
- package/src/components/post-text-editor/index.js +3 -3
- package/src/components/preview-dropdown/index.js +2 -2
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/use-block-editor-settings.js +10 -0
- package/src/components/provider/use-upload-save-lock.js +2 -17
- package/src/components/resizable-editor/resize-handle.js +2 -5
- package/src/components/revision-created-panel/index.js +3 -3
- package/src/components/site-discussion/index.js +3 -3
- package/src/components/style-book/constants.ts +1 -1
- package/src/components/style-book/index.js +1 -1
- package/src/components/template-actions-panel/classic-theme-content.js +3 -3
- package/src/components/template-actions-panel/style.scss +1 -1
- package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
- package/src/components/visual-editor/index.js +2 -29
- package/src/store/private-actions.js +0 -13
- package/src/store/private-selectors.js +0 -10
- package/src/store/reducer.js +0 -16
- package/src/utils/media-finalize/index.js +2 -1
- package/src/utils/media-finalize/test/index.js +25 -1
- package/src/utils/media-upload/index.js +26 -29
- package/build/components/collab-sidebar/add-comment.cjs +0 -129
- package/build/components/collab-sidebar/add-comment.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-author-info.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-form.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-indicator-toolbar.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-menu-item.cjs.map +0 -7
- package/build/components/collab-sidebar/comments.cjs +0 -816
- package/build/components/collab-sidebar/comments.cjs.map +0 -7
- package/build-module/components/collab-sidebar/add-comment.mjs +0 -100
- package/build-module/components/collab-sidebar/add-comment.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-author-info.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-form.mjs +0 -90
- package/build-module/components/collab-sidebar/comment-form.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-menu-item.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comments.mjs +0 -799
- package/build-module/components/collab-sidebar/comments.mjs.map +0 -7
- package/build-types/components/collab-sidebar/add-comment.d.ts +0 -10
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +0 -8
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-form.d.ts +0 -11
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +0 -6
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts +0 -6
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comments.d.ts +0 -12
- package/build-types/components/collab-sidebar/comments.d.ts.map +0 -1
- package/src/components/collab-sidebar/comments.js +0 -985
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-panel/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { DataViews } from '@wordpress/dataviews';\nimport { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { authorField } from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevisionCheck from '../post-last-revision/check';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\nconst DAY_IN_MILLISECONDS = 86400000;\nconst EMPTY_ARRAY = [];\nconst defaultLayouts = { activity: true };\nconst noop = () => {};\nconst paginationInfo = {};\nconst view = {\n\ttype: 'activity',\n\ttitleField: 'date',\n\tfields: [ 'author' ],\n\tlayout: { density: 'compact' },\n};\nconst fields = [\n\t{\n\t\tid: 'date',\n\t\tlabel: __( 'Date' ),\n\t\trender: ( { item, field } ) => {\n\t\t\tconst dateNowInMs = getDate( null ).getTime();\n\t\t\tconst _value = field.getValue( { item } );\n\t\t\tconst date = getDate( _value ?? null );\n\t\t\tconst displayDate =\n\t\t\t\tdateNowInMs - date.getTime() > DAY_IN_MILLISECONDS\n\t\t\t\t\t? dateI18n(\n\t\t\t\t\t\t\tgetSettings().formats.datetimeAbbreviated,\n\t\t\t\t\t\t\tdate\n\t\t\t\t\t )\n\t\t\t\t\t: humanTimeDiff( date );\n\t\t\treturn (\n\t\t\t\t<time\n\t\t\t\t\tclassName=\"editor-post-revisions-panel__revision-date\"\n\t\t\t\t\tdateTime={ _value }\n\t\t\t\t>\n\t\t\t\t\t{ displayDate }\n\t\t\t\t</time>\n\t\t\t);\n\t\t},\n\t\tenableSorting: false,\n\t\tenableHiding: false,\n\t},\n\tauthorField,\n];\n\nfunction PostRevisionsPanelContent() {\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\tconst {\n\t\trevisionsCount,\n\t\trevisions,\n\t\trevisionKey,\n\t\tisLoading,\n\t\tlastRevisionId,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst { getCurrentPostRevisionsCount, getCurrentPostLastRevisionId } =\n\t\t\tselect( editorStore );\n\t\tconst { getRevisions, getEntityConfig, isResolving } =\n\t\t\tselect( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst entityConfig = getEntityConfig( 'postType', _postType );\n\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\tconst revisionsQuery = {\n\t\t\tper_page: 3,\n\t\t\torderby: 'date',\n\t\t\torder: 'desc',\n\t\t\t_fields: `${ _revisionKey },date,author`,\n\t\t};\n\t\tconst query = [\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\tgetCurrentPostId(),\n\t\t\trevisionsQuery,\n\t\t];\n\t\tconst _revisions = getRevisions( ...query );\n\t\treturn {\n\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\trevisions: _revisions,\n\t\t\trevisionKey: _revisionKey,\n\t\t\tisLoading: isResolving( 'getRevisions', query ),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\t<HStack justify=\"space-between\" align=\"center\" as=\"span\">\n\t\t\t\t\t<span>{ __( 'Revisions' ) }</span>\n\t\t\t\t\t<
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,UAAU,SAAS,eAAe,mBAAmB;AAC9D,SAAS,WAAW,mBAAmB;AACvC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAK5B,OAAO,2BAA2B;AAClC,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AA8BnB,cAuDA,YAvDA;AA5BJ,IAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { DataViews } from '@wordpress/dataviews';\nimport { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { authorField } from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevisionCheck from '../post-last-revision/check';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge: WCBadge } = unlock( componentsPrivateApis );\nconst DAY_IN_MILLISECONDS = 86400000;\nconst EMPTY_ARRAY = [];\nconst defaultLayouts = { activity: true };\nconst noop = () => {};\nconst paginationInfo = {};\nconst view = {\n\ttype: 'activity',\n\ttitleField: 'date',\n\tfields: [ 'author' ],\n\tlayout: { density: 'compact' },\n};\nconst fields = [\n\t{\n\t\tid: 'date',\n\t\tlabel: __( 'Date' ),\n\t\trender: ( { item, field } ) => {\n\t\t\tconst dateNowInMs = getDate( null ).getTime();\n\t\t\tconst _value = field.getValue( { item } );\n\t\t\tconst date = getDate( _value ?? null );\n\t\t\tconst displayDate =\n\t\t\t\tdateNowInMs - date.getTime() > DAY_IN_MILLISECONDS\n\t\t\t\t\t? dateI18n(\n\t\t\t\t\t\t\tgetSettings().formats.datetimeAbbreviated,\n\t\t\t\t\t\t\tdate\n\t\t\t\t\t )\n\t\t\t\t\t: humanTimeDiff( date );\n\t\t\treturn (\n\t\t\t\t<time\n\t\t\t\t\tclassName=\"editor-post-revisions-panel__revision-date\"\n\t\t\t\t\tdateTime={ _value }\n\t\t\t\t>\n\t\t\t\t\t{ displayDate }\n\t\t\t\t</time>\n\t\t\t);\n\t\t},\n\t\tenableSorting: false,\n\t\tenableHiding: false,\n\t},\n\tauthorField,\n];\n\nfunction PostRevisionsPanelContent() {\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\tconst {\n\t\trevisionsCount,\n\t\trevisions,\n\t\trevisionKey,\n\t\tisLoading,\n\t\tlastRevisionId,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst { getCurrentPostRevisionsCount, getCurrentPostLastRevisionId } =\n\t\t\tselect( editorStore );\n\t\tconst { getRevisions, getEntityConfig, isResolving } =\n\t\t\tselect( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst entityConfig = getEntityConfig( 'postType', _postType );\n\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\tconst revisionsQuery = {\n\t\t\tper_page: 3,\n\t\t\torderby: 'date',\n\t\t\torder: 'desc',\n\t\t\t_fields: `${ _revisionKey },date,author`,\n\t\t};\n\t\tconst query = [\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\tgetCurrentPostId(),\n\t\t\trevisionsQuery,\n\t\t];\n\t\tconst _revisions = getRevisions( ...query );\n\t\treturn {\n\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\trevisions: _revisions,\n\t\t\trevisionKey: _revisionKey,\n\t\t\tisLoading: isResolving( 'getRevisions', query ),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\t<HStack justify=\"space-between\" align=\"center\" as=\"span\">\n\t\t\t\t\t<span>{ __( 'Revisions' ) }</span>\n\t\t\t\t\t<WCBadge className=\"editor-post-revisions-panel__revisions-count\">\n\t\t\t\t\t\t{ revisionsCount }\n\t\t\t\t\t</WCBadge>\n\t\t\t\t</HStack>\n\t\t\t}\n\t\t\tinitialOpen={ false }\n\t\t>\n\t\t\t<VStack className=\"editor-post-revisions-panel\">\n\t\t\t\t<DataViews\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ noop }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tdata={ revisions || EMPTY_ARRAY }\n\t\t\t\t\tisLoading={ isLoading }\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\t\tgetItemId={ ( item ) => item[ revisionKey ] }\n\t\t\t\t\tisItemClickable={ () => true }\n\t\t\t\t\tonClickItem={ ( item ) => {\n\t\t\t\t\t\tsetCurrentRevisionId( item[ revisionKey ] );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<DataViews.Layout />\n\t\t\t\t</DataViews>\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-post-revisions-panel__view-all\"\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => setCurrentRevisionId( lastRevisionId ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'View all revisions' ) }\n\t\t\t\t</Button>\n\t\t\t</VStack>\n\t\t</PanelBody>\n\t);\n}\n\nexport default function PostRevisionsPanel() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PostRevisionsPanelContent />\n\t\t</PostLastRevisionCheck>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,UAAU,SAAS,eAAe,mBAAmB;AAC9D,SAAS,WAAW,mBAAmB;AACvC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAK5B,OAAO,2BAA2B;AAClC,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AA8BnB,cAuDA,YAvDA;AA5BJ,IAAM,EAAE,OAAO,QAAQ,IAAI,OAAQ,qBAAsB;AACzD,IAAM,sBAAsB;AAC5B,IAAM,cAAc,CAAC;AACrB,IAAM,iBAAiB,EAAE,UAAU,KAAK;AACxC,IAAM,OAAO,MAAM;AAAC;AACpB,IAAM,iBAAiB,CAAC;AACxB,IAAM,OAAO;AAAA,EACZ,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,QAAQ,CAAE,QAAS;AAAA,EACnB,QAAQ,EAAE,SAAS,UAAU;AAC9B;AACA,IAAM,SAAS;AAAA,EACd;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,MAAO;AAAA,IAClB,QAAQ,CAAE,EAAE,MAAM,MAAM,MAAO;AAC9B,YAAM,cAAc,QAAS,IAAK,EAAE,QAAQ;AAC5C,YA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A,IAAC;AAAA;AAAA,MACA,OACC,qBAAC,UAAO,SAAQ,iBAAgB,OAAM,UAAS,IAAG,QACjD;AAAA,4BAAC,UAAO,aAAI,WAAY,GAAG;AAAA,QAC3B,oBAAC,WAAQ,WAAU,gDAChB,0BACH;AAAA,SACD;AAAA,MAED,aAAc;AAAA,MAEd,+BAAC,UAAO,WAAU,+BACjB;AAAA;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,cAAe;AAAA,YACf;AAAA,YACA,MAAO,aAAa;AAAA,YACpB;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAY,CAAE,SAAU,KAAM,WAAY;AAAA,YAC1C,iBAAkB,MAAM;AAAA,YACxB,aAAc,CAAE,SAAU;AACzB,mCAAsB,KAAM,WAAY,CAAE;AAAA,YAC3C;AAAA,YAEA,8BAAC,UAAU,QAAV,EAAiB;AAAA;AAAA,QACnB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,uBAAqB;AAAA,YACrB,SAAQ;AAAA,YACR,SAAU,MAAM,qBAAsB,cAAe;AAAA,YAEnD,aAAI,oBAAqB;AAAA;AAAA,QAC5B;AAAA,SACD;AAAA;AAAA,EACD;AAEF;AAEe,SAAR,qBAAsC;AAC5C,SACC,oBAAC,yBACA,8BAAC,6BAA0B,GAC5B;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -110,7 +110,7 @@ function useDiffMarkers() {
|
|
|
110
110
|
{
|
|
111
111
|
className: "revision-diff-markers",
|
|
112
112
|
role: "navigation",
|
|
113
|
-
"aria-label": __("
|
|
113
|
+
"aria-label": __("Document changes"),
|
|
114
114
|
children: isMounted && diffBlocks.map(({ clientId, status }) => /* @__PURE__ */ jsx(
|
|
115
115
|
DiffMarkerButton,
|
|
116
116
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-preview/diff-markers.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElementRef } = unlock( blockEditorPrivateApis );\n\n/**\n * Recursively collect blocks with diff status.\n *\n * @param {Array} blocks The blocks to search.\n * @return {Array} Blocks with __revisionDiffStatus.\n */\nfunction collectDiffBlocks( blocks ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( block.__revisionDiffStatus?.status ) {\n\t\t\tresult.push( {\n\t\t\t\tclientId: block.clientId,\n\t\t\t\tstatus: block.__revisionDiffStatus.status,\n\t\t\t} );\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tresult.push( ...collectDiffBlocks( block.innerBlocks ) );\n\t\t}\n\t}\n\treturn result;\n}\n\nconst STATUS_LABELS = {\n\tadded: __( 'Go to added block' ),\n\tremoved: __( 'Go to removed block' ),\n\tmodified: __( 'Go to modified block' ),\n};\n\nfunction calculatePosition( el ) {\n\tif ( ! el ) {\n\t\treturn null;\n\t}\n\tconst doc = el.ownerDocument;\n\tconst scrollHeight = doc.documentElement.scrollHeight;\n\tconst rect = el.getBoundingClientRect();\n\tconst scrollTop = doc.documentElement.scrollTop;\n\tconst top = rect.top + scrollTop;\n\treturn {\n\t\ttop: ( top / scrollHeight ) * 100,\n\t\theight: ( rect.height / scrollHeight ) * 100,\n\t};\n}\n\n/**\n * Button component for a single diff marker.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId The block client ID.\n * @param {string} props.status The diff status (added/removed/modified).\n * @param {Function} props.subscribe Function to subscribe to position updates.\n * @return {React.JSX.Element} The diff marker button or null if position not calculated.\n */\nfunction DiffMarkerButton( { clientId, status, subscribe } ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\tconst [ position, setPosition ] = useState( () =>\n\t\tcalculatePosition( blockRef.current )\n\t);\n\n\tuseEffect( () => {\n\t\treturn subscribe( () => {\n\t\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t\t} );\n\t}, [ subscribe ] );\n\n\tuseEffect( () => {\n\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t}, [ status ] );\n\n\tif ( ! position ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<button\n\t\t\tclassName={ `revision-diff-marker is-${ status }` }\n\t\t\tstyle={ {\n\t\t\t\ttop: `${ position.top }%`,\n\t\t\t\theight: `${ Math.max( position.height, 0.5 ) }%`,\n\t\t\t} }\n\t\t\tonClick={ () => blockRef.current?.focus() }\n\t\t\taria-label={ STATUS_LABELS[ status ] }\n\t\t/>\n\t);\n}\n\n/**\n * Hook that provides diff markers functionality.\n * Returns a ref callback for the content element and a DiffMarkers component.\n * Must be used inside a BlockEditorProvider context.\n *\n * @return {Array} Tuple of [contentRef, DiffMarkersComponent].\n */\nexport function useDiffMarkers() {\n\tconst [ isMounted, setIsMounted ] = useState( false );\n\tconst subscribersRef = useRef( new Set() );\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks(),\n\t\t[]\n\t);\n\tconst diffBlocks = useMemo( () => collectDiffBlocks( blocks ), [ blocks ] );\n\tconst subscribe = useCallback( ( callback ) => {\n\t\tsubscribersRef.current.add( callback );\n\t\treturn () => subscribersRef.current.delete( callback );\n\t}, [] );\n\tconst contentRef = useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst resizeObserver = new defaultView.ResizeObserver( () => {\n\t\t\tsubscribersRef.current.forEach( ( cb ) => cb() );\n\t\t} );\n\t\tresizeObserver.observe( ownerDocument.body );\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [] );\n\treturn [\n\t\tuseMergeRefs( [ contentRef, setIsMounted ] ),\n\t\t<div\n\t\t\tkey=\"diff-markers\"\n\t\t\tclassName=\"revision-diff-markers\"\n\t\t\trole=\"navigation\"\n\t\t\taria-label={ __( '
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc,oBAAoB;AAC3C,SAAS,iBAAiB;AAC1B;AAAA,EACC,eAAe;AAAA,EACf,SAAS;AAAA,OACH;AACP,SAAS,UAAU;AAKnB,SAAS,cAAc;AA8ErB;AA5EF,IAAM,EAAE,mBAAmB,IAAI,OAAQ,sBAAuB;AAQ9D,SAAS,kBAAmB,QAAS;AACpC,QAAM,SAAS,CAAC;AAChB,aAAY,SAAS,QAAS;AAC7B,QAAK,MAAM,sBAAsB,QAAS;AACzC,aAAO,KAAM;AAAA,QACZ,UAAU,MAAM;AAAA,QAChB,QAAQ,MAAM,qBAAqB;AAAA,MACpC,CAAE;AAAA,IACH;AACA,QAAK,MAAM,aAAa,QAAS;AAChC,aAAO,KAAM,GAAG,kBAAmB,MAAM,WAAY,CAAE;AAAA,IACxD;AAAA,EACD;AACA,SAAO;AACR;AAEA,IAAM,gBAAgB;AAAA,EACrB,OAAO,GAAI,mBAAoB;AAAA,EAC/B,SAAS,GAAI,qBAAsB;AAAA,EACnC,UAAU,GAAI,sBAAuB;AACtC;AAEA,SAAS,kBAAmB,IAAK;AAChC,MAAK,CAAE,IAAK;AACX,WAAO;AAAA,EACR;AACA,QAAM,MAAM,GAAG;AACf,QAAM,eAAe,IAAI,gBAAgB;AACzC,QAAM,OAAO,GAAG,sBAAsB;AACtC,QAAM,YAAY,IAAI,gBAAgB;AACtC,QAAM,MAAM,KAAK,MAAM;AACvB,SAAO;AAAA,IACN,KAAO,MAAM,eAAiB;AA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AAE;AACN,QAAM,aAAa,aAAc,CAAE,YAAa;AAC/C,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,UAAM,iBAAiB,IAAI,YAAY,eAAgB,MAAM;AAC5D,qBAAe,QAAQ,QAAS,CAAE,OAAQ,GAAG,CAAE;AAAA,IAChD,CAAE;AACF,mBAAe,QAAS,cAAc,IAAK;AAC3C,WAAO,MAAM;AACZ,qBAAe,WAAW;AAAA,IAC3B;AAAA,EACD,GAAG,CAAC,CAAE;AACN,SAAO;AAAA,IACN,aAAc,CAAE,YAAY,YAAa,CAAE;AAAA,IAC3C;AAAA,MAAC;AAAA;AAAA,QAEA,WAAU;AAAA,QACV,MAAK;AAAA,QACL,cAAa,GAAI,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElementRef } = unlock( blockEditorPrivateApis );\n\n/**\n * Recursively collect blocks with diff status.\n *\n * @param {Array} blocks The blocks to search.\n * @return {Array} Blocks with __revisionDiffStatus.\n */\nfunction collectDiffBlocks( blocks ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( block.__revisionDiffStatus?.status ) {\n\t\t\tresult.push( {\n\t\t\t\tclientId: block.clientId,\n\t\t\t\tstatus: block.__revisionDiffStatus.status,\n\t\t\t} );\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tresult.push( ...collectDiffBlocks( block.innerBlocks ) );\n\t\t}\n\t}\n\treturn result;\n}\n\nconst STATUS_LABELS = {\n\tadded: __( 'Go to added block' ),\n\tremoved: __( 'Go to removed block' ),\n\tmodified: __( 'Go to modified block' ),\n};\n\nfunction calculatePosition( el ) {\n\tif ( ! el ) {\n\t\treturn null;\n\t}\n\tconst doc = el.ownerDocument;\n\tconst scrollHeight = doc.documentElement.scrollHeight;\n\tconst rect = el.getBoundingClientRect();\n\tconst scrollTop = doc.documentElement.scrollTop;\n\tconst top = rect.top + scrollTop;\n\treturn {\n\t\ttop: ( top / scrollHeight ) * 100,\n\t\theight: ( rect.height / scrollHeight ) * 100,\n\t};\n}\n\n/**\n * Button component for a single diff marker.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId The block client ID.\n * @param {string} props.status The diff status (added/removed/modified).\n * @param {Function} props.subscribe Function to subscribe to position updates.\n * @return {React.JSX.Element} The diff marker button or null if position not calculated.\n */\nfunction DiffMarkerButton( { clientId, status, subscribe } ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\tconst [ position, setPosition ] = useState( () =>\n\t\tcalculatePosition( blockRef.current )\n\t);\n\n\tuseEffect( () => {\n\t\treturn subscribe( () => {\n\t\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t\t} );\n\t}, [ subscribe ] );\n\n\tuseEffect( () => {\n\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t}, [ status ] );\n\n\tif ( ! position ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<button\n\t\t\tclassName={ `revision-diff-marker is-${ status }` }\n\t\t\tstyle={ {\n\t\t\t\ttop: `${ position.top }%`,\n\t\t\t\theight: `${ Math.max( position.height, 0.5 ) }%`,\n\t\t\t} }\n\t\t\tonClick={ () => blockRef.current?.focus() }\n\t\t\taria-label={ STATUS_LABELS[ status ] }\n\t\t/>\n\t);\n}\n\n/**\n * Hook that provides diff markers functionality.\n * Returns a ref callback for the content element and a DiffMarkers component.\n * Must be used inside a BlockEditorProvider context.\n *\n * @return {Array} Tuple of [contentRef, DiffMarkersComponent].\n */\nexport function useDiffMarkers() {\n\tconst [ isMounted, setIsMounted ] = useState( false );\n\tconst subscribersRef = useRef( new Set() );\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks(),\n\t\t[]\n\t);\n\tconst diffBlocks = useMemo( () => collectDiffBlocks( blocks ), [ blocks ] );\n\tconst subscribe = useCallback( ( callback ) => {\n\t\tsubscribersRef.current.add( callback );\n\t\treturn () => subscribersRef.current.delete( callback );\n\t}, [] );\n\tconst contentRef = useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst resizeObserver = new defaultView.ResizeObserver( () => {\n\t\t\tsubscribersRef.current.forEach( ( cb ) => cb() );\n\t\t} );\n\t\tresizeObserver.observe( ownerDocument.body );\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [] );\n\treturn [\n\t\tuseMergeRefs( [ contentRef, setIsMounted ] ),\n\t\t<div\n\t\t\tkey=\"diff-markers\"\n\t\t\tclassName=\"revision-diff-markers\"\n\t\t\trole=\"navigation\"\n\t\t\taria-label={ __( 'Document changes' ) }\n\t\t>\n\t\t\t{ isMounted &&\n\t\t\t\tdiffBlocks.map( ( { clientId, status } ) => (\n\t\t\t\t\t<DiffMarkerButton\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tstatus={ status }\n\t\t\t\t\t\tsubscribe={ subscribe }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t</div>,\n\t];\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc,oBAAoB;AAC3C,SAAS,iBAAiB;AAC1B;AAAA,EACC,eAAe;AAAA,EACf,SAAS;AAAA,OACH;AACP,SAAS,UAAU;AAKnB,SAAS,cAAc;AA8ErB;AA5EF,IAAM,EAAE,mBAAmB,IAA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,uBACD,WAAW,IAAK,CAAE,EAAE,UAAU,OAAO,MACpC;AAAA,UAAC;AAAA;AAAA,YAEA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,UAHM;AAAA,QAIP,CACC;AAAA;AAAA,MAbC;AAAA,IAcL;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-preview/revisions-slider.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst { revisions, isLoading, currentRevisionId, revisionKey } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostId, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getRevisions, isResolving, getEntityConfig } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postType = getCurrentPostType();\n\n\t\t\tif ( ! postId || ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst entityConfig = getEntityConfig( 'postType', postType );\n\t\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\t\tconst query = {\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\torderby: 'date',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\t_revisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trevisions: getRevisions( 'postType', postType, postId, query ),\n\t\t\t\tisLoading: isResolving( 'getRevisions', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t\tcurrentRevisionId: unlock(\n\t\t\t\t\tselect( editorStore )\n\t\t\t\t).getCurrentRevisionId(),\n\t\t\t\trevisionKey: _revisionKey,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\n\tconst selectedIndex = revisions?.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! revisions?.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( revisions?.length === 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RangeControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-revisions-header__slider\"\n\t\t\thideLabelFromVision\n\t\t\tlabel={ __( 'Revision' ) }\n\t\t\tmax={ revisions?.length - 1 }\n\t\t\tmin={ 0 }\n\t\t\tmarks\n\t\t\tonChange={ handleSliderChange }\n\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\tvalue={ selectedIndex }\n\t\t\twithInputField={ false }\n\t\t/>\n\t);\n}\n\nexport default RevisionsSlider;\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,cAAc,eAAe;AACtC,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB,SAAS,UAAU,eAAe,uBAAuB;AAKzD,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAoFd;AA7ET,SAAS,kBAAkB;AAC1B,QAAM,EAAE,WAAW,WAAW,mBAAmB,YAAY,IAAI;AAAA,IAChE,CAAE,WAAY;AACb,YAAM,EAAE,kBAAkB,mBAAmB,IAC5C,OAAQ,WAAY;AACrB,YAAM,EAAE,cAAc,aAAa,gBAAgB,IAClD,OAAQ,SAAU;AAEnB,YAAM,SAAS,iBAAiB;AAChC,YAAM,WAAW,mBAAmB;AAEpC,UAAK,CAAE,UAAU,CAAE,UAAW;AAC7B,eAAO,CAAC;AAAA,MACT;AAEA,YAAM,eAAe,gBAAiB,YAAY,QAAS;AAC3D,YAAM,eAAe,cAAc,eAAe;AAClD,YAAM,QAAQ;AAAA,QACb,UAAU;AAAA,QACV,SAAS;AAAA,QACT,SAAS;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,UACR,GAAG,oBAAI,IAAK;AAAA,YACX;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACD,CAAE;AAAA,QACH,EAAE,KAAK;AAA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AAA,MACX;AAAA,MACA,OAAQ;AAAA,MACR,gBAAiB;AAAA;AAAA,EAClB;AAEF;AAEA,IAAO,2BAAQ;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst { revisions, isLoading, currentRevisionId, revisionKey } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostId, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getRevisions, isResolving, getEntityConfig } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postType = getCurrentPostType();\n\n\t\t\tif ( ! postId || ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst entityConfig = getEntityConfig( 'postType', postType );\n\t\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\t\tconst query = {\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\torderby: 'date',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\t_revisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trevisions: getRevisions( 'postType', postType, postId, query ),\n\t\t\t\tisLoading: isResolving( 'getRevisions', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t\tcurrentRevisionId: unlock(\n\t\t\t\t\tselect( editorStore )\n\t\t\t\t).getCurrentRevisionId(),\n\t\t\t\trevisionKey: _revisionKey,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\n\tconst selectedIndex = revisions?.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! revisions?.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( revisions?.length === 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RangeControl\n\t\t\t__next40pxDefaultSize\n\t\t\taria-valuetext={ renderTooltipContent( selectedIndex ) }\n\t\t\tclassName=\"editor-revisions-header__slider\"\n\t\t\thideLabelFromVision\n\t\t\tlabel={ __( 'Revision' ) }\n\t\t\tmax={ revisions?.length - 1 }\n\t\t\tmin={ 0 }\n\t\t\tmarks\n\t\t\tonChange={ handleSliderChange }\n\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\tvalue={ selectedIndex }\n\t\t\twithInputField={ false }\n\t\t/>\n\t);\n}\n\nexport default RevisionsSlider;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,cAAc,eAAe;AACtC,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB,SAAS,UAAU,eAAe,uBAAuB;AAKzD,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAoFd;AA7ET,SAAS,kBAAkB;AAC1B,QAAM,EAAE,WAAW,WAAW,mBAAmB,YAAY,IAAI;AAAA,IAChE,CAAE,WAAY;AACb,YAAM,EAAE,kBAAkB,mBAAmB,IAC5C,OAAQ,WAAY;AACrB,YAAM,EAAE,cAAc,aAAa,gBAAgB,IAClD,OAAQ,SAAU;AAEnB,YAAM,SAAS,iBAAiB;AAChC,YAAM,WAAW,mBAAmB;AAEpC,UAAK,CAAE,UAAU,CAAE,UAAW;AAC7B,eAAO,CAAC;AAAA,MACT;AAEA,YAAM,eAAe,gBAAiB,YAAY,QAAS;AAC3D,YAAM,eAAe,cAAc,eAAe;AAClD,YAAM,QAAQ;AAAA,QACb,UAAU;AAAA,QACV,SAAS;AAAA,QACT,SAAS;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,UACR,GAAG,oBAAI,IAAK;AAAA,YACX;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACD,CAAE;AAAA,QACH,EAAE,KAAK;AAAA,MACR;AACA,aAAO;AAAA,QACN,WAAW,aAAc,YAAY,UAAU,QAAQ,KAAM;AAAA,QAC7D,WAAW,YAAa,gBAAgB;AAAA,UACvC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD,CAAE;AAAA,QACF,mBAAmB;AAAA,UAClB,OA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 forceIsDirty }) {
|
|
|
25
25
|
isPublished,
|
|
26
26
|
isSaveable,
|
|
27
27
|
isSaving,
|
|
28
|
+
isSavingLocked,
|
|
28
29
|
isScheduled,
|
|
29
30
|
hasPublishAction,
|
|
30
31
|
showIconLabels,
|
|
@@ -40,6 +41,7 @@ function PostSavedState({ forceIsDirty }) {
|
|
|
40
41
|
isEditedPostDirty,
|
|
41
42
|
isSavingPost,
|
|
42
43
|
isEditedPostSaveable,
|
|
44
|
+
isPostSavingLocked,
|
|
43
45
|
getCurrentPost,
|
|
44
46
|
isAutosavingPost,
|
|
45
47
|
getEditedPostAttribute,
|
|
@@ -53,6 +55,7 @@ function PostSavedState({ forceIsDirty }) {
|
|
|
53
55
|
isPublished: isCurrentPostPublished(),
|
|
54
56
|
isSaving: isSavingPost(),
|
|
55
57
|
isSaveable: isEditedPostSaveable(),
|
|
58
|
+
isSavingLocked: isPostSavingLocked(),
|
|
56
59
|
isScheduled: isCurrentPostScheduled(),
|
|
57
60
|
hasPublishAction: getCurrentPost()?._links?.["wp:action-publish"] ?? false,
|
|
58
61
|
showIconLabels: get("core", "showIconLabels"),
|
|
@@ -90,7 +93,7 @@ function PostSavedState({ forceIsDirty }) {
|
|
|
90
93
|
const shortLabel = __("Save");
|
|
91
94
|
const isSaved = forceSavedMessage || !isNew && !isDirty;
|
|
92
95
|
const isSavedState = isSaving || isSaved;
|
|
93
|
-
const isDisabled = isSaving || isSaved || !isSaveable;
|
|
96
|
+
const isDisabled = isSaving || isSaved || !isSaveable || isSavingLocked;
|
|
94
97
|
let text;
|
|
95
98
|
if (isSaving) {
|
|
96
99
|
text = isAutosaving ? __("Autosaving") : __("Saving");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-saved-state/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { STATUS_OPTIONS } from '../../components/post-status';\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE } from '../../store/constants';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @return {React.ComponentType} The component.\n */\nexport default function PostSavedState( { forceIsDirty } ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t\tshowIconLabels,\n\t\tpostStatus,\n\t\tpostStatusHasChanged,\n\t\tpostType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetPostEdits,\n\t\t\t} = select( editorStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tpostStatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tpostStatusHasChanged: !! getPostEdits()?.status,\n\t\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty ]\n\t);\n\tconst isPending = postStatus === 'pending';\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Attachments don't support draft mode, so hide this button.\n\tif ( postType === ATTACHMENT_POST_TYPE ) {\n\t\treturn null;\n\t}\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\t// We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.\n\t// The reason for this is that this button handles the `save as pending` and `save draft` actions.\n\t// An exception for this is when the post has a custom status and there should be a way to save changes without\n\t// having to publish. This should be handled better in the future when custom statuses have better support.\n\t// @see https://github.com/WordPress/gutenberg/issues/3144.\n\tconst isIneligibleStatus =\n\t\t! [ 'pending', 'draft', 'auto-draft' ].includes( postStatus ) &&\n\t\tSTATUS_OPTIONS.map( ( { value } ) => value ).includes( postStatus );\n\n\tif (\n\t\tisPublished ||\n\t\tisScheduled ||\n\t\tisIneligibleStatus ||\n\t\t( postStatusHasChanged &&\n\t\t\t[ 'pending', 'draft' ].includes( postStatus ) )\n\t) {\n\t\treturn null;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? clsx( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\tvariant=\"tertiary\"\n\t\t\tsize=\"compact\"\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\tlabel={ text || label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC,iCAAiC;AAAA,EACjC;AAAA,OACM;AACP,SAAS,aAAa,wBAAwB;AAC9C,SAAS,aAAa,iBAAiB;AACvC,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU;AACnB,SAAS,MAAM,OAAO,OAAO,mBAAmB;AAChD,SAAS,uBAAuB;AAChC,SAAS,SAAS,wBAAwB;AAK1C,SAAS,sBAAsB;AAC/B,SAAS,SAAS,mBAAmB;AACrC,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { STATUS_OPTIONS } from '../../components/post-status';\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE } from '../../store/constants';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @return {React.ComponentType} The component.\n */\nexport default function PostSavedState( { forceIsDirty } ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisSavingLocked,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t\tshowIconLabels,\n\t\tpostStatus,\n\t\tpostStatusHasChanged,\n\t\tpostType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tisPostSavingLocked,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetPostEdits,\n\t\t\t} = select( editorStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisSavingLocked: isPostSavingLocked(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tpostStatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tpostStatusHasChanged: !! getPostEdits()?.status,\n\t\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty ]\n\t);\n\tconst isPending = postStatus === 'pending';\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Attachments don't support draft mode, so hide this button.\n\tif ( postType === ATTACHMENT_POST_TYPE ) {\n\t\treturn null;\n\t}\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\t// We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.\n\t// The reason for this is that this button handles the `save as pending` and `save draft` actions.\n\t// An exception for this is when the post has a custom status and there should be a way to save changes without\n\t// having to publish. This should be handled better in the future when custom statuses have better support.\n\t// @see https://github.com/WordPress/gutenberg/issues/3144.\n\tconst isIneligibleStatus =\n\t\t! [ 'pending', 'draft', 'auto-draft' ].includes( postStatus ) &&\n\t\tSTATUS_OPTIONS.map( ( { value } ) => value ).includes( postStatus );\n\n\tif (\n\t\tisPublished ||\n\t\tisScheduled ||\n\t\tisIneligibleStatus ||\n\t\t( postStatusHasChanged &&\n\t\t\t[ 'pending', 'draft' ].includes( postStatus ) )\n\t) {\n\t\treturn null;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable || isSavingLocked;\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? clsx( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\tvariant=\"tertiary\"\n\t\t\tsize=\"compact\"\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\tlabel={ text || label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC,iCAAiC;AAAA,EACjC;AAAA,OACM;AACP,SAAS,aAAa,wBAAwB;AAC9C,SAAS,aAAa,iBAAiB;AACvC,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU;AACnB,SAAS,MAAM,OAAO,OAAO,mBAAmB;AAChD,SAAS,uBAAuB;AAChC,SAAS,SAAS,wBAAwB;AAK1C,SAAS,sBAAsB;AAC/B,SAAS,SAAS,mBAAmB;AACrC,SAAS,4BAA4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lD,UAAW,aAAa,SAAY,gBAAgB,QAAS,GAAI;AAAA,MACjE,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,MAAO,kBAAkB,SAAY;AAAA,MACrC,OAAQ,QAAQ;AAAA,MAChB,iBAAgB;AAAA,MAEd;AAAA,wBAAgB,oBAAC,QAAK,MAAO,UAAU,QAAQ,OAAQ;AAAA,QACvD;AAAA;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import { __ } from "@wordpress/i18n";
|
|
|
4
4
|
import { store as coreStore } from "@wordpress/core-data";
|
|
5
5
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
6
6
|
import { useInstanceId } from "@wordpress/compose";
|
|
7
|
-
import { VisuallyHidden } from "@wordpress/
|
|
7
|
+
import { VisuallyHidden } from "@wordpress/ui";
|
|
8
8
|
import { store as editorStore } from "../../store/index.mjs";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
function PostTextEditor() {
|
|
@@ -22,8 +22,7 @@ function PostTextEditor() {
|
|
|
22
22
|
/* @__PURE__ */ jsx(
|
|
23
23
|
VisuallyHidden,
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
htmlFor: `post-content-${instanceId}`,
|
|
25
|
+
render: /* @__PURE__ */ jsx("label", { htmlFor: `post-content-${instanceId}` }),
|
|
27
26
|
children: __("Type text or HTML")
|
|
28
27
|
}
|
|
29
28
|
),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-text-editor/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/
|
|
5
|
-
"mappings": ";AAGA,OAAO,cAAc;AAKrB,SAAS,UAAU;AACnB,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa,iBAAiB;AACvC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAK/B,SAAS,SAAS,mBAAmB;AAqBnC,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Displays the Post Text Editor along with content in Visual and Text mode.\n *\n * @return {React.ReactNode} The rendered PostTextEditor component.\n */\nexport default function PostTextEditor() {\n\tconst instanceId = useInstanceId( PostTextEditor );\n\tconst { value, type, id } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId, getEditedPostContent } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tvalue: getEditedPostContent(),\n\t\t\ttype: getCurrentPostType(),\n\t\t\tid: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\t// eslint-disable-next-line jsx-a11y/label-has-associated-control\n\t\t\t\trender={ <label htmlFor={ `post-content-${ instanceId }` } /> }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\teditEntityRecord( 'postType', type, id, {\n\t\t\t\t\t\tcontent: event.target.value,\n\t\t\t\t\t\tblocks: undefined,\n\t\t\t\t\t\tselection: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,cAAc;AAKrB,SAAS,UAAU;AACnB,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa,iBAAiB;AACvC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAK/B,SAAS,SAAS,mBAAmB;AAqBnC,mBAGW,KAHX;AAda,SAAR,iBAAkC;AACxC,QAAM,aAAa,cAAe,cAAe;AACjD,QAAM,EAAE,OAAO,MAAM,GAAG,IAAI,UAAW,CAAE,WAAY;AACpD,UAAM,EAAE,oBAAoB,kBAAkB,qBAAqB,IAClE,OAAQ,WAAY;AACrB,WAAO;AAAA,MACN,OAAO,qBAAqB;AAAA,MAC5B,MAAM,mBAAmB;AAAA,MACzB,IAAI,iBAAiB;AAAA,IACtB;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,iBAAiB,IAAI,YAAa,SAAU;AAEpD,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QAEA,QAAS,oBAAC,WAAM,SAAU,gBAAiB,UAAW,IAAK;AAAA,QAEzD,aAAI,mBAAoB;AAAA;AAAA,IAC3B;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,cAAa;AAAA,QACb,KAAI;AAAA,QACJ;AAAA,QACA,UAAW,CAAE,UAAW;AACvB,2BAAkB,YAAY,MAAM,IAAI;AAAA,YACvC,SAAS,MAAM,OAAO;AAAA,YACtB,QAAQ;AAAA,YACR,WAAW;AAAA,UACZ,CAAE;AAAA,QACH;AAAA,QACA,WAAU;AAAA,QACV,IAAK,gBAAiB,UAAW;AAAA,QACjC,aAAc,GAAI,iCAAkC;AAAA;AAAA,IACrD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
MenuGroup,
|
|
7
7
|
MenuItem,
|
|
8
8
|
MenuItemsChoice,
|
|
9
|
-
VisuallyHidden,
|
|
10
9
|
Icon
|
|
11
10
|
} from "@wordpress/components";
|
|
12
11
|
import { __ } from "@wordpress/i18n";
|
|
@@ -16,6 +15,7 @@ import { store as coreStore } from "@wordpress/core-data";
|
|
|
16
15
|
import { store as preferencesStore } from "@wordpress/preferences";
|
|
17
16
|
import { ActionItem } from "@wordpress/interface";
|
|
18
17
|
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
18
|
+
import { VisuallyHidden } from "@wordpress/ui";
|
|
19
19
|
import { store as editorStore } from "../../store/index.mjs";
|
|
20
20
|
import PostPreviewButton from "../post-preview-button/index.mjs";
|
|
21
21
|
import { unlock } from "../../lock-unlock.mjs";
|
|
@@ -129,7 +129,7 @@ function PreviewDropdown({ forceIsAutosaveable, disabled }) {
|
|
|
129
129
|
children: [
|
|
130
130
|
__("View site"),
|
|
131
131
|
/* @__PURE__ */ jsx(VisuallyHidden, {
|
|
132
|
-
|
|
132
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
133
133
|
/* translators: accessibility text */
|
|
134
134
|
children: __("(opens in a new tab)")
|
|
135
135
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preview-dropdown/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tMenuItemsChoice,\n\
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tMenuItemsChoice,\n\tIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { desktop, mobile, tablet, external, check } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { ActionItem } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostPreviewButton from '../post-preview-button';\nimport { unlock } from '../../lock-unlock';\n\nexport default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {\n\tconst {\n\t\tdeviceType,\n\t\thomeUrl,\n\t\tisTemplate,\n\t\tisViewable,\n\t\tshowIconLabels,\n\t\tisTemplateHidden,\n\t\ttemplateId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetDeviceType,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentTemplateId,\n\t\t\tgetRenderingMode,\n\t\t} = select( editorStore );\n\t\tconst { getEntityRecord, getPostType } = select( coreStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst _currentPostType = getCurrentPostType();\n\t\treturn {\n\t\t\tdeviceType: getDeviceType(),\n\t\t\thomeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,\n\t\t\tisTemplate: _currentPostType === 'wp_template',\n\t\t\tisViewable: getPostType( _currentPostType )?.viewable ?? false,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t};\n\t}, [] );\n\tconst { setDeviceType, setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\n\tconst handleDevicePreviewChange = ( newDeviceType ) => {\n\t\tsetDeviceType( newDeviceType );\n\t\tresetZoomLevel();\n\t};\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tif ( isMobile ) {\n\t\treturn null;\n\t}\n\n\tconst popoverProps = {\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'editor-preview-dropdown__toggle',\n\t\ticonPosition: 'right',\n\t\tsize: 'compact',\n\t\tshowTooltip: ! showIconLabels,\n\t\tdisabled,\n\t\taccessibleWhenDisabled: disabled,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tdesktop,\n\t\tmobile,\n\t\ttablet,\n\t};\n\n\t/**\n\t * The choices for the device type.\n\t * Duplicated in block-editor block-visibility constants and edit-site\n\t * use-viewport-sync. Update all three when adding new viewport types.\n\t *\n\t * @type {Array}\n\t */\n\tconst choices = [\n\t\t{\n\t\t\tvalue: 'Desktop',\n\t\t\tlabel: __( 'Desktop' ),\n\t\t\ticon: desktop,\n\t\t},\n\t\t{\n\t\t\tvalue: 'Tablet',\n\t\t\tlabel: __( 'Tablet' ),\n\t\t\ticon: tablet,\n\t\t},\n\t\t{\n\t\t\tvalue: 'Mobile',\n\t\t\tlabel: __( 'Mobile' ),\n\t\t\ticon: mobile,\n\t\t},\n\t];\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-preview-dropdown',\n\t\t\t\t`editor-preview-dropdown--${ deviceType.toLowerCase() }`\n\t\t\t) }\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ __( 'View' ) }\n\t\t\tdisableOpenOnArrowDown={ disabled }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tchoices={ choices }\n\t\t\t\t\t\t\tvalue={ deviceType }\n\t\t\t\t\t\t\tonSelect={ handleDevicePreviewChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ isTemplate && (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'View site' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isTemplate && !! templateId && (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tresetZoomLevel();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isViewable && (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<PostPreviewButton\n\t\t\t\t\t\t\t\tclassName=\"editor-preview-dropdown__button-external\"\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\tforceIsAutosaveable={ forceIsAutosaveable }\n\t\t\t\t\t\t\t\taria-label={ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\ttextContent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ external } />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonPreview={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t<ActionItem.Slot\n\t\t\t\t\t\tname=\"core/plugin-preview-menu\"\n\t\t\t\t\t\tfillProps={ { onClick: onClose } }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,QAAQ,QAAQ,UAAU,aAAa;AACzD,SAAS,WAAW,mBAAmB;AACvC,S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Ac,CAAC,CAAE,cACpB,oBAAC,aACA;AAAA,UAAC;AAAA;AAAA,YACA,MAAO,CAAE,mBAAmB,QAAQ;AAAA,YACpC,YAAa,CAAE;AAAA,YACf,MAAK;AAAA,YACL,SAAU,MAAM;AACf,oBAAM,mBAAmB,mBACtB,oBACA;AACH,+BAAkB,gBAAiB;AACnC,sCAAyB,gBAAiB;AAC1C,6BAAe;AAAA,YAChB;AAAA,YAEE,aAAI,eAAgB;AAAA;AAAA,QACvB,GACD;AAAA,QAEC,cACD,oBAAC,aACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAK;AAAA,YACL;AAAA,YACA,cAAa,GAAI,oBAAqB;AAAA,YACtC,aACC,iCACG;AAAA,iBAAI,oBAAqB;AAAA,cAC3B,oBAAC,QAAK,MAAO,UAAW;AAAA,eACzB;AAAA,YAED,WAAY;AAAA;AAAA,QACb,GACD;AAAA,QAED;AAAA,UAAC,WAAW;AAAA,UAAX;AAAA,YACA,MAAK;AAAA,YACL,WAAY,EAAE,SAAS,QAAQ;AAAA;AAAA,QAChC;AAAA,SACD;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -39,6 +39,7 @@ import EditorKeyboardShortcuts from "../global-keyboard-shortcuts/index.mjs";
|
|
|
39
39
|
import PatternRenameModal from "../pattern-rename-modal/index.mjs";
|
|
40
40
|
import PatternDuplicateModal from "../pattern-duplicate-modal/index.mjs";
|
|
41
41
|
import TemplatePartMenuItems from "../template-part-menu-items/index.mjs";
|
|
42
|
+
import MediaEditorModalMount from "../media/media-editor-modal.mjs";
|
|
42
43
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
43
44
|
var { ExperimentalBlockEditorProvider } = unlock(blockEditorPrivateApis);
|
|
44
45
|
var { PatternsMenuItems } = unlock(editPatternsPrivateApis);
|
|
@@ -312,7 +313,8 @@ var ExperimentalEditorProvider = withRegistryProvider(
|
|
|
312
313
|
/* @__PURE__ */ jsx(StartPageOptions, {}),
|
|
313
314
|
/* @__PURE__ */ jsx(StartTemplateOptions, {}),
|
|
314
315
|
/* @__PURE__ */ jsx(PatternRenameModal, {}),
|
|
315
|
-
/* @__PURE__ */ jsx(PatternDuplicateModal, {})
|
|
316
|
+
/* @__PURE__ */ jsx(PatternDuplicateModal, {}),
|
|
317
|
+
window?.__experimentalMediaEditorModal && /* @__PURE__ */ jsx(MediaEditorModalMount, {})
|
|
316
318
|
] })
|
|
317
319
|
]
|
|
318
320
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/provider/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tEntityProvider,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE } from '../../store/constants';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport NavigationBlockEditingMode from './navigation-block-editing-mode';\nimport { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';\nimport { useRevisionBlocks } from './use-revision-blocks';\nimport useCommands from '../commands';\nimport useUploadSaveLock from './use-upload-save-lock';\nimport BlockRemovalWarnings from '../block-removal-warnings';\nimport StartPageOptions from '../start-page-options';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport StartTemplateOptions from '../start-template-options';\nimport EditorKeyboardShortcuts from '../global-keyboard-shortcuts';\nimport PatternRenameModal from '../pattern-rename-modal';\nimport PatternDuplicateModal from '../pattern-duplicate-modal';\nimport TemplatePartMenuItems from '../template-part-menu-items';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * These are global entities that are only there to split blocks into logical units\n * They don't provide a \"context\" for the current post/page being rendered.\n * So we should not use their ids as post context. This is important to allow post blocks\n * (post content, post title) to be used within them without issues.\n */\nconst NON_CONTEXTUAL_POST_TYPES = [\n\t'wp_block',\n\t'wp_navigation',\n\t'wp_template_part',\n];\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n *\n * @example\n * ```jsx\n * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );\n * ```\n *\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst revisionBlocks = useRevisionBlocks();\n\tconst rootLevelPost = mode === 'template-locked' ? 'template' : 'post';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\n\n\t// In revisions mode, use the revision blocks and disable editing.\n\tif ( revisionBlocks !== null ) {\n\t\treturn [ revisionBlocks, noop, noop ];\n\t}\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation';\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\n/**\n * This component provides the editor context and manages the state of the block editor.\n *\n * @param {Object} props The component props.\n * @param {Object} props.post The post object.\n * @param {Object} props.settings The editor settings.\n * @param {boolean} props.recovery Indicates if the editor is in recovery mode.\n * @param {Array} props.initialEdits The initial edits for the editor.\n * @param {Object} props.children The child components.\n * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.\n * @param {Object} [props.__unstableTemplate] The template object.\n *\n * @example\n * ```jsx\n * <ExperimentalEditorProvider\n * post={ post }\n * settings={ settings }\n * recovery={ recovery }\n * initialEdits={ initialEdits }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </ExperimentalEditorProvider>\n *\n * @return {Object} The rendered ExperimentalEditorProvider component.\n */\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst hasTemplate = !! template;\n\t\tconst {\n\t\t\teditorSettings,\n\t\t\tselection,\n\t\t\tisReady,\n\t\t\tmode,\n\t\t\tdefaultMode,\n\t\t\tpostTypeEntities,\n\t\t\tisInRevisionsMode,\n\t\t\tcurrentRevisionId,\n\t\t} = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetRenderingMode,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t\tgetDefaultRenderingMode,\n\t\t\t\t\tisRevisionsMode: _isRevisionsMode,\n\t\t\t\t\tgetCurrentRevisionId: _getCurrentRevisionId,\n\t\t\t\t} = unlock( select( editorStore ) );\n\t\t\t\tconst { getEntitiesConfig, getEntityRecordEdits } =\n\t\t\t\t\tselect( coreStore );\n\n\t\t\t\tconst _mode = getRenderingMode();\n\t\t\t\tconst _defaultMode = getDefaultRenderingMode( post.type );\n\t\t\t\t/**\n\t\t\t\t * To avoid content \"flash\", wait until rendering mode has been resolved.\n\t\t\t\t * This is important for the initial render of the editor.\n\t\t\t\t *\n\t\t\t\t * - Wait for template to be resolved if the default mode is 'template-locked'.\n\t\t\t\t * - Wait for default mode to be resolved otherwise.\n\t\t\t\t */\n\t\t\t\tconst hasResolvedDefaultMode =\n\t\t\t\t\t_defaultMode === 'template-locked'\n\t\t\t\t\t\t? hasTemplate\n\t\t\t\t\t\t: _defaultMode !== undefined;\n\t\t\t\t// Wait until the default mode is retrieved and start rendering canvas.\n\t\t\t\tconst isRenderingModeReady = _defaultMode !== undefined;\n\n\t\t\t\t// Read selection directly from entity edits using the post prop,\n\t\t\t\t// bypassing getCurrentPostId() which lags behind in useEffect.\n\t\t\t\tconst entityEdits = getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tmode: isRenderingModeReady ? _mode : undefined,\n\t\t\t\t\tdefaultMode: hasResolvedDefaultMode\n\t\t\t\t\t\t? _defaultMode\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselection: entityEdits?.selection,\n\t\t\t\t\tpostTypeEntities:\n\t\t\t\t\t\tpost.type === 'wp_template'\n\t\t\t\t\t\t\t? getEntitiesConfig( 'postType' )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tisInRevisionsMode: _isRevisionsMode(),\n\t\t\t\t\tcurrentRevisionId: _getCurrentRevisionId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ post.type, post.id, hasTemplate ]\n\t\t);\n\n\t\tconst shouldRenderTemplate = hasTemplate && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext = {};\n\t\t\t// If it is a template, try to inherit the post type from the name.\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\tif ( post.slug === 'page' ) {\n\t\t\t\t\tpostContext.postType = 'page';\n\t\t\t\t} else if ( post.slug === 'single' ) {\n\t\t\t\t\tpostContext.postType = 'post';\n\t\t\t\t} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {\n\t\t\t\t\t// If the slug is single-{postType}, infer the post type from the name.\n\t\t\t\t\tconst postTypeNames =\n\t\t\t\t\t\tpostTypeEntities?.map( ( entity ) => entity.name ) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst match = post.slug.match(\n\t\t\t\t\t\t`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`\n\t\t\t\t\t);\n\t\t\t\t\tif ( match ) {\n\t\t\t\t\t\tpostContext.postType = match[ 1 ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\n\t\t\t) {\n\t\t\t\tpostContext.postId = post.id;\n\t\t\t\tpostContext.postType = post.type;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tshouldRenderTemplate,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\tpost.slug,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\n\t\t\tpostTypeEntities,\n\t\t] );\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid,\n\t\t\tmode\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\t\tconst onChangeSelection = useCallback(\n\t\t\t( newSelection ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ selection: newSelection },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ editEntityRecord, post.type, post.id ]\n\t\t);\n\t\tconst { createWarningNotice, removeNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The dependencies of the hook are omitted deliberately\n\t\t\t// We only want to run setupEditor (with initialEdits) only once per post.\n\t\t\t// A better solution in the future would be to split this effect into multiple ones.\n\t\t}, [] );\n\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t\tif (\n\t\t\t\ttypeof window !== 'undefined' &&\n\t\t\t\twindow.__experimentalTemplateActivate\n\t\t\t) {\n\t\t\t\t// Clear any notices dependent on the post context.\n\t\t\t\tremoveNotice( 'template-activate-notice' );\n\t\t\t}\n\n\t\t\treturn () => setEditedPost( null, null );\n\t\t}, [ post.type, post.id, setEditedPost, removeNotice ] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tif ( defaultMode ) {\n\t\t\t\tsetRenderingMode( defaultMode );\n\t\t\t}\n\t\t}, [ defaultMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\n\n\t\t// Lock post saving when media uploads are in progress (experimental feature).\n\t\tuseUploadSaveLock();\n\n\t\tif ( ! isReady || ! mode ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst isAttachment =\n\t\t\tpost.type === ATTACHMENT_POST_TYPE &&\n\t\t\twindow?.__experimentalMediaEditor;\n\n\t\t// Early return for attachments - no block editor needed\n\t\tif ( isAttachment ) {\n\t\t\treturn (\n\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\ttype={ post.type }\n\t\t\t\t\t\tid={ post.id }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</EntityProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t\trevisionId={ currentRevisionId ?? undefined }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? undefined : selection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChangeSelection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? noop : onChangeSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t\t\t<TemplatePartMenuItems />\n\t\t\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t\t\t<BlockRemovalWarnings />\n\t\t\t\t\t\t\t\t\t<StartPageOptions />\n\t\t\t\t\t\t\t\t\t<StartTemplateOptions />\n\t\t\t\t\t\t\t\t\t<PatternRenameModal />\n\t\t\t\t\t\t\t\t\t<PatternDuplicateModal />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\n/**\n * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).\n *\n * It supports a large number of post types, including post, page, templates,\n * custom post types, patterns, template parts.\n *\n * All modification and changes are performed to the `@wordpress/core-data` store.\n *\n * @param {Object} props The component props.\n * @param {Object} [props.post] The post object to edit. This is required.\n * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.\n * This is optional and can only be used when the post type supports templates (like posts and pages).\n * @param {Object} [props.settings] The settings object to use for the editor.\n * This is optional and can be used to override the default settings.\n * @param {React.ReactNode} [props.children] Children elements for which the BlockEditorProvider context should apply.\n * This is optional.\n *\n * @example\n * ```jsx\n * <EditorProvider\n * post={ post }\n * settings={ settings }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </EditorProvider>\n * ```\n *\n * @return {React.ReactNode} The rendered EditorProvider component.\n */\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,eAAe,+BAA+B;AACvD,SAAS,mBAAmB;AAK5B,OAAO,0BAA0B;AACjC,SAAS,SAAS,mBAAmB;AACrC,SAAS,4BAA4B;AACrC,OAAO,4BAA4B;AACnC,SAAS,cAAc;AACvB,OAAO,iCAAiC;AACxC,OAAO,gCAAgC;AACvC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;AACxB,OAAO,uBAAuB;AA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ACtB,oBAAC,oBAAiB;AAAA,gBAClB,oBAAC,wBAAqB;AAAA,gBACtB,oBAAC,sBAAmB;AAAA,gBACpB,oBAAC,yBAAsB;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tEntityProvider,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE } from '../../store/constants';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport NavigationBlockEditingMode from './navigation-block-editing-mode';\nimport { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';\nimport { useRevisionBlocks } from './use-revision-blocks';\nimport useCommands from '../commands';\nimport useUploadSaveLock from './use-upload-save-lock';\nimport BlockRemovalWarnings from '../block-removal-warnings';\nimport StartPageOptions from '../start-page-options';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport StartTemplateOptions from '../start-template-options';\nimport EditorKeyboardShortcuts from '../global-keyboard-shortcuts';\nimport PatternRenameModal from '../pattern-rename-modal';\nimport PatternDuplicateModal from '../pattern-duplicate-modal';\nimport TemplatePartMenuItems from '../template-part-menu-items';\nimport MediaEditorModalMount from '../media/media-editor-modal';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * These are global entities that are only there to split blocks into logical units\n * They don't provide a \"context\" for the current post/page being rendered.\n * So we should not use their ids as post context. This is important to allow post blocks\n * (post content, post title) to be used within them without issues.\n */\nconst NON_CONTEXTUAL_POST_TYPES = [\n\t'wp_block',\n\t'wp_navigation',\n\t'wp_template_part',\n];\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n *\n * @example\n * ```jsx\n * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );\n * ```\n *\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst revisionBlocks = useRevisionBlocks();\n\tconst rootLevelPost = mode === 'template-locked' ? 'template' : 'post';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\n\n\t// In revisions mode, use the revision blocks and disable editing.\n\tif ( revisionBlocks !== null ) {\n\t\treturn [ revisionBlocks, noop, noop ];\n\t}\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation';\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\n/**\n * This component provides the editor context and manages the state of the block editor.\n *\n * @param {Object} props The component props.\n * @param {Object} props.post The post object.\n * @param {Object} props.settings The editor settings.\n * @param {boolean} props.recovery Indicates if the editor is in recovery mode.\n * @param {Array} props.initialEdits The initial edits for the editor.\n * @param {Object} props.children The child components.\n * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.\n * @param {Object} [props.__unstableTemplate] The template object.\n *\n * @example\n * ```jsx\n * <ExperimentalEditorProvider\n * post={ post }\n * settings={ settings }\n * recovery={ recovery }\n * initialEdits={ initialEdits }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </ExperimentalEditorProvider>\n *\n * @return {Object} The rendered ExperimentalEditorProvider component.\n */\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst hasTemplate = !! template;\n\t\tconst {\n\t\t\teditorSettings,\n\t\t\tselection,\n\t\t\tisReady,\n\t\t\tmode,\n\t\t\tdefaultMode,\n\t\t\tpostTypeEntities,\n\t\t\tisInRevisionsMode,\n\t\t\tcurrentRevisionId,\n\t\t} = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetRenderingMode,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t\tgetDefaultRenderingMode,\n\t\t\t\t\tisRevisionsMode: _isRevisionsMode,\n\t\t\t\t\tgetCurrentRevisionId: _getCurrentRevisionId,\n\t\t\t\t} = unlock( select( editorStore ) );\n\t\t\t\tconst { getEntitiesConfig, getEntityRecordEdits } =\n\t\t\t\t\tselect( coreStore );\n\n\t\t\t\tconst _mode = getRenderingMode();\n\t\t\t\tconst _defaultMode = getDefaultRenderingMode( post.type );\n\t\t\t\t/**\n\t\t\t\t * To avoid content \"flash\", wait until rendering mode has been resolved.\n\t\t\t\t * This is important for the initial render of the editor.\n\t\t\t\t *\n\t\t\t\t * - Wait for template to be resolved if the default mode is 'template-locked'.\n\t\t\t\t * - Wait for default mode to be resolved otherwise.\n\t\t\t\t */\n\t\t\t\tconst hasResolvedDefaultMode =\n\t\t\t\t\t_defaultMode === 'template-locked'\n\t\t\t\t\t\t? hasTemplate\n\t\t\t\t\t\t: _defaultMode !== undefined;\n\t\t\t\t// Wait until the default mode is retrieved and start rendering canvas.\n\t\t\t\tconst isRenderingModeReady = _defaultMode !== undefined;\n\n\t\t\t\t// Read selection directly from entity edits using the post prop,\n\t\t\t\t// bypassing getCurrentPostId() which lags behind in useEffect.\n\t\t\t\tconst entityEdits = getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tmode: isRenderingModeReady ? _mode : undefined,\n\t\t\t\t\tdefaultMode: hasResolvedDefaultMode\n\t\t\t\t\t\t? _defaultMode\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselection: entityEdits?.selection,\n\t\t\t\t\tpostTypeEntities:\n\t\t\t\t\t\tpost.type === 'wp_template'\n\t\t\t\t\t\t\t? getEntitiesConfig( 'postType' )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tisInRevisionsMode: _isRevisionsMode(),\n\t\t\t\t\tcurrentRevisionId: _getCurrentRevisionId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ post.type, post.id, hasTemplate ]\n\t\t);\n\n\t\tconst shouldRenderTemplate = hasTemplate && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext = {};\n\t\t\t// If it is a template, try to inherit the post type from the name.\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\tif ( post.slug === 'page' ) {\n\t\t\t\t\tpostContext.postType = 'page';\n\t\t\t\t} else if ( post.slug === 'single' ) {\n\t\t\t\t\tpostContext.postType = 'post';\n\t\t\t\t} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {\n\t\t\t\t\t// If the slug is single-{postType}, infer the post type from the name.\n\t\t\t\t\tconst postTypeNames =\n\t\t\t\t\t\tpostTypeEntities?.map( ( entity ) => entity.name ) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst match = post.slug.match(\n\t\t\t\t\t\t`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`\n\t\t\t\t\t);\n\t\t\t\t\tif ( match ) {\n\t\t\t\t\t\tpostContext.postType = match[ 1 ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\n\t\t\t) {\n\t\t\t\tpostContext.postId = post.id;\n\t\t\t\tpostContext.postType = post.type;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tshouldRenderTemplate,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\tpost.slug,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\n\t\t\tpostTypeEntities,\n\t\t] );\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid,\n\t\t\tmode\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\t\tconst onChangeSelection = useCallback(\n\t\t\t( newSelection ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ selection: newSelection },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ editEntityRecord, post.type, post.id ]\n\t\t);\n\t\tconst { createWarningNotice, removeNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The dependencies of the hook are omitted deliberately\n\t\t\t// We only want to run setupEditor (with initialEdits) only once per post.\n\t\t\t// A better solution in the future would be to split this effect into multiple ones.\n\t\t}, [] );\n\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t\tif (\n\t\t\t\ttypeof window !== 'undefined' &&\n\t\t\t\twindow.__experimentalTemplateActivate\n\t\t\t) {\n\t\t\t\t// Clear any notices dependent on the post context.\n\t\t\t\tremoveNotice( 'template-activate-notice' );\n\t\t\t}\n\n\t\t\treturn () => setEditedPost( null, null );\n\t\t}, [ post.type, post.id, setEditedPost, removeNotice ] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tif ( defaultMode ) {\n\t\t\t\tsetRenderingMode( defaultMode );\n\t\t\t}\n\t\t}, [ defaultMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\n\n\t\t// Lock post saving when media uploads are in progress (experimental feature).\n\t\tuseUploadSaveLock();\n\n\t\tif ( ! isReady || ! mode ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst isAttachment =\n\t\t\tpost.type === ATTACHMENT_POST_TYPE &&\n\t\t\twindow?.__experimentalMediaEditor;\n\n\t\t// Early return for attachments - no block editor needed\n\t\tif ( isAttachment ) {\n\t\t\treturn (\n\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\ttype={ post.type }\n\t\t\t\t\t\tid={ post.id }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</EntityProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t\trevisionId={ currentRevisionId ?? undefined }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? undefined : selection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChangeSelection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? noop : onChangeSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t\t\t<TemplatePartMenuItems />\n\t\t\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t\t\t<BlockRemovalWarnings />\n\t\t\t\t\t\t\t\t\t<StartPageOptions />\n\t\t\t\t\t\t\t\t\t<StartTemplateOptions />\n\t\t\t\t\t\t\t\t\t<PatternRenameModal />\n\t\t\t\t\t\t\t\t\t<PatternDuplicateModal />\n\t\t\t\t\t\t\t\t\t{ window?.__experimentalMediaEditorModal && (\n\t\t\t\t\t\t\t\t\t\t<MediaEditorModalMount />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\n/**\n * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).\n *\n * It supports a large number of post types, including post, page, templates,\n * custom post types, patterns, template parts.\n *\n * All modification and changes are performed to the `@wordpress/core-data` store.\n *\n * @param {Object} props The component props.\n * @param {Object} [props.post] The post object to edit. This is required.\n * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.\n * This is optional and can only be used when the post type supports templates (like posts and pages).\n * @param {Object} [props.settings] The settings object to use for the editor.\n * This is optional and can be used to override the default settings.\n * @param {React.ReactNode} [props.children] Children elements for which the BlockEditorProvider context should apply.\n * This is optional.\n *\n * @example\n * ```jsx\n * <EditorProvider\n * post={ post }\n * settings={ settings }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </EditorProvider>\n * ```\n *\n * @return {React.ReactNode} The rendered EditorProvider component.\n */\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,eAAe,+BAA+B;AACvD,SAAS,mBAAmB;AAK5B,OAAO,0BAA0B;AACjC,SAAS,SAAS,mBAAmB;AACrC,SAAS,4BAA4B;AACrC,OAAO,4BAA4B;AACnC,SAAS,cAAc;AACvB,OAAO,iCAAiC;AACxC,OAAO,gCAAgC;AACvC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;AACxB,OAAO,uBAAuB;AAC9B,OAAO,0BAA0B;AACjC,OAAO,sBAAsB;AAC7B,OAAO,+BAA+B;AACtC,OAAO,0BAA0B;AACjC,OAAO,6BAA6B;AACpC,OAAO,wBAAwB;AAC/B,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;A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sB;AAAA,iBAEzB;AAAA;AAAA;AAAA,QAEF,GACD;AAAA;AAAA,IACD,GACD;AAAA,EAEF;AACD;AAgCO,SAAS,eAAgB,OAAQ;AACvC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,8BAA+B;AAAA,MAE7B,gBAAM;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
privateApis,
|
|
16
16
|
store as blockEditorStore
|
|
17
17
|
} from "@wordpress/block-editor";
|
|
18
|
+
import { privateApis as mediaEditorPrivateApis } from "@wordpress/media-editor";
|
|
18
19
|
import inserterMediaCategories from "../media-categories/index.mjs";
|
|
19
20
|
import { mediaUpload } from "../../utils/index.mjs";
|
|
20
21
|
import mediaUploadOnSuccess from "../../utils/media-upload/on-success.mjs";
|
|
@@ -23,6 +24,7 @@ import { default as mediaFinalize } from "../../utils/media-finalize/index.mjs";
|
|
|
23
24
|
import { store as editorStore } from "../../store/index.mjs";
|
|
24
25
|
import { unlock } from "../../lock-unlock.mjs";
|
|
25
26
|
import { useGlobalStylesContext } from "../global-styles-provider/index.mjs";
|
|
27
|
+
var { store: mediaEditorStore } = unlock(mediaEditorPrivateApis);
|
|
26
28
|
var EMPTY_OBJECT = {};
|
|
27
29
|
function __experimentalReusableBlocksSelect(select) {
|
|
28
30
|
const { RECEIVE_INTERMEDIATE_RESULTS } = unlock(coreDataPrivateApis);
|
|
@@ -96,7 +98,8 @@ var {
|
|
|
96
98
|
deviceTypeKey,
|
|
97
99
|
isNavigationOverlayContextKey,
|
|
98
100
|
isNavigationPostEditorKey,
|
|
99
|
-
mediaUploadOnSuccessKey
|
|
101
|
+
mediaUploadOnSuccessKey,
|
|
102
|
+
openMediaEditorModalKey
|
|
100
103
|
} = unlock(privateApis);
|
|
101
104
|
function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
102
105
|
const isLargeViewport = useViewportMatch("medium");
|
|
@@ -218,6 +221,7 @@ function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
|
218
221
|
const { undo, setIsInserterOpened } = useDispatch(editorStore);
|
|
219
222
|
const { editMediaEntity } = unlock(useDispatch(coreStore));
|
|
220
223
|
const { saveEntityRecord } = useDispatch(coreStore);
|
|
224
|
+
const { openMediaEditorModal } = useDispatch(mediaEditorStore);
|
|
221
225
|
const createPageEntity = useCallback(
|
|
222
226
|
(options) => {
|
|
223
227
|
if (!userCanCreatePages) {
|
|
@@ -266,6 +270,7 @@ function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
|
266
270
|
);
|
|
267
271
|
},
|
|
268
272
|
[mediaEditKey]: hasUploadPermissions ? editMediaEntity : void 0,
|
|
273
|
+
[openMediaEditorModalKey]: window?.__experimentalMediaEditorModal ? ({ id, onUpdate }) => openMediaEditorModal({ id, onUpdate }) : void 0,
|
|
269
274
|
mediaUpload: hasUploadPermissions ? mediaUpload : void 0,
|
|
270
275
|
[mediaUploadOnSuccessKey]: hasUploadPermissions ? mediaUploadOnSuccess : void 0,
|
|
271
276
|
mediaSideload: hasUploadPermissions ? mediaSideload : void 0,
|
|
@@ -346,6 +351,7 @@ function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
|
346
351
|
globalStylesLinksData,
|
|
347
352
|
renderingMode,
|
|
348
353
|
editMediaEntity,
|
|
354
|
+
openMediaEditorModal,
|
|
349
355
|
settings.onNavigateToEntityRecord,
|
|
350
356
|
deviceType,
|
|
351
357
|
allImageSizes,
|