@wordpress/editor 14.45.2-next.v.202605131032.0 → 14.47.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 +12 -1
- package/build/components/collab-sidebar/add-note.cjs +6 -0
- package/build/components/collab-sidebar/add-note.cjs.map +2 -2
- package/build/components/collab-sidebar/hooks.cjs +36 -24
- package/build/components/collab-sidebar/hooks.cjs.map +2 -2
- package/build/components/collab-sidebar/index.cjs +19 -10
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-byline.cjs +16 -9
- package/build/components/collab-sidebar/note-byline.cjs.map +2 -2
- package/build/components/collab-sidebar/notes.cjs +20 -11
- package/build/components/collab-sidebar/notes.cjs.map +2 -2
- package/build/components/collab-sidebar/utils.cjs +42 -2
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-overlay/compute-selection.cjs +39 -15
- package/build/components/collaborators-overlay/compute-selection.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-block-highlighting.cjs +10 -2
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-render-cursors.cjs +15 -7
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/collaborators-presence/avatar/component.cjs +5 -1
- package/build/components/collaborators-presence/avatar/component.cjs.map +3 -3
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +6 -3
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
- package/build/components/editor-interface/index.cjs +17 -16
- package/build/components/editor-interface/index.cjs.map +3 -3
- package/build/components/editor-notices/index.cjs +6 -1
- package/build/components/editor-notices/index.cjs.map +3 -3
- package/build/components/global-styles/hooks.cjs +12 -1
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/header/index.cjs +11 -6
- package/build/components/header/index.cjs.map +2 -2
- package/build/components/media/media-editor-modal.cjs +14 -1
- package/build/components/media/media-editor-modal.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +7 -1
- package/build/components/post-card-panel/index.cjs.map +3 -3
- package/build/components/post-last-revision/index.cjs +28 -8
- package/build/components/post-last-revision/index.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +9 -6
- package/build/components/post-locked-modal/index.cjs.map +2 -2
- package/build/components/post-publish-button/label.cjs +0 -7
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-panel/prepublish.cjs +8 -1
- package/build/components/post-publish-panel/prepublish.cjs.map +3 -3
- package/build/components/post-revisions-panel/index.cjs +7 -0
- package/build/components/post-revisions-panel/index.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +21 -13
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-canvas.cjs +7 -1
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
- package/build/components/post-taxonomies/check.cjs +1 -2
- package/build/components/post-taxonomies/check.cjs.map +2 -2
- package/build/components/post-taxonomies/index.cjs +1 -2
- package/build/components/post-taxonomies/index.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +1 -1
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs.map +3 -3
- package/build/components/provider/index.cjs +5 -21
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +16 -9
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/resizable-editor/resize-handle.cjs +24 -16
- package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
- package/build/components/sidebar/header.cjs +16 -21
- package/build/components/sidebar/header.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +2 -6
- package/build/components/sidebar/index.cjs.map +2 -2
- package/build/components/start-page-options/index.cjs +14 -4
- package/build/components/start-page-options/index.cjs.map +2 -2
- package/build/components/start-template-options/index.cjs +8 -6
- package/build/components/start-template-options/index.cjs.map +2 -2
- package/build/components/styles-canvas/style-book.cjs +59 -2
- package/build/components/styles-canvas/style-book.cjs.map +2 -2
- package/build/components/sync-connection-error-modal/index.cjs +10 -7
- package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
- package/build/components/template-actions-panel/block-theme-content.cjs +21 -12
- package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +17 -1
- package/build/store/private-actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs +18 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +0 -17
- package/build/store/selectors.cjs.map +2 -2
- package/build/{components/media → utils/media-delete}/index.cjs +12 -13
- package/build/utils/media-delete/index.cjs.map +7 -0
- package/build/utils/media-finalize/index.cjs +3 -1
- package/build/utils/media-finalize/index.cjs.map +2 -2
- package/build/utils/sync-error-messages.cjs +9 -0
- package/build/utils/sync-error-messages.cjs.map +2 -2
- package/build-module/components/collab-sidebar/add-note.mjs +6 -0
- package/build-module/components/collab-sidebar/add-note.mjs.map +2 -2
- package/build-module/components/collab-sidebar/hooks.mjs +42 -25
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +19 -10
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-byline.mjs +17 -10
- package/build-module/components/collab-sidebar/note-byline.mjs.map +2 -2
- package/build-module/components/collab-sidebar/notes.mjs +26 -13
- package/build-module/components/collab-sidebar/notes.mjs.map +2 -2
- package/build-module/components/collab-sidebar/utils.mjs +38 -2
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/compute-selection.mjs +36 -12
- package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +10 -3
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +11 -6
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/avatar/component.mjs +7 -3
- package/build-module/components/collaborators-presence/avatar/component.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +6 -3
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/editor-interface/index.mjs +22 -17
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/editor-notices/index.mjs +6 -1
- package/build-module/components/editor-notices/index.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +12 -1
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/header/index.mjs +11 -6
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media/media-editor-modal.mjs +14 -1
- package/build-module/components/media/media-editor-modal.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +8 -2
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-last-revision/index.mjs +29 -9
- package/build-module/components/post-last-revision/index.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +9 -6
- package/build-module/components/post-locked-modal/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +0 -7
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-panel/prepublish.mjs +9 -2
- package/build-module/components/post-publish-panel/prepublish.mjs.map +2 -2
- package/build-module/components/post-revisions-panel/index.mjs +7 -0
- package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +22 -14
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs +7 -1
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
- package/build-module/components/post-taxonomies/check.mjs +1 -2
- package/build-module/components/post-taxonomies/check.mjs.map +2 -2
- package/build-module/components/post-taxonomies/index.mjs +1 -2
- package/build-module/components/post-taxonomies/index.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +1 -1
- package/build-module/components/preferences-modal/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 +6 -22
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +16 -9
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/resizable-editor/resize-handle.mjs +26 -18
- package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
- package/build-module/components/sidebar/header.mjs +11 -16
- package/build-module/components/sidebar/header.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +2 -7
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/start-page-options/index.mjs +14 -4
- package/build-module/components/start-page-options/index.mjs.map +2 -2
- package/build-module/components/start-template-options/index.mjs +8 -6
- package/build-module/components/start-template-options/index.mjs.map +2 -2
- package/build-module/components/styles-canvas/style-book.mjs +60 -3
- package/build-module/components/styles-canvas/style-book.mjs.map +2 -2
- package/build-module/components/sync-connection-error-modal/index.mjs +14 -8
- package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
- package/build-module/components/template-actions-panel/block-theme-content.mjs +21 -13
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +16 -1
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +18 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +0 -16
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/media-delete/index.mjs +12 -0
- package/build-module/utils/media-delete/index.mjs.map +7 -0
- package/build-module/utils/media-finalize/index.mjs +3 -1
- package/build-module/utils/media-finalize/index.mjs.map +2 -2
- package/build-module/utils/sync-error-messages.mjs +8 -0
- package/build-module/utils/sync-error-messages.mjs.map +2 -2
- package/build-style/style-rtl.css +462 -408
- package/build-style/style.css +462 -408
- package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -1
- 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 +3 -0
- package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/notes.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +33 -0
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +3 -0
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/editor-notices/index.d.ts.map +1 -1
- package/build-types/components/global-styles/hooks.d.ts.map +1 -1
- package/build-types/components/media/media-editor-modal.d.ts +6 -2
- package/build-types/components/media/media-editor-modal.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts +1 -6
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/prepublish.d.ts.map +1 -1
- package/build-types/components/post-revisions-panel/index.d.ts +1 -1
- package/build-types/components/post-revisions-panel/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +1 -6
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -6
- package/build-types/components/post-taxonomies/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/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/styles-canvas/style-book.d.ts.map +1 -1
- package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts +0 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +15 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +10 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +0 -10
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-delete/index.d.ts +2 -0
- package/build-types/utils/media-delete/index.d.ts.map +1 -0
- 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/sync-error-messages.d.ts +1 -0
- package/build-types/utils/sync-error-messages.d.ts.map +1 -1
- package/package.json +48 -48
- package/src/components/collab-sidebar/add-note.js +9 -0
- package/src/components/collab-sidebar/hooks.js +53 -29
- package/src/components/collab-sidebar/index.js +28 -14
- package/src/components/collab-sidebar/note-byline.js +15 -10
- package/src/components/collab-sidebar/notes.js +36 -14
- package/src/components/collab-sidebar/test/utils.js +375 -1
- package/src/components/collab-sidebar/utils.js +70 -1
- package/src/components/collaborators-overlay/compute-selection.ts +67 -19
- package/src/components/collaborators-overlay/use-block-highlighting.ts +14 -1
- package/src/components/collaborators-overlay/use-render-cursors.ts +15 -4
- package/src/components/collaborators-presence/avatar/component.tsx +10 -3
- package/src/components/collaborators-presence/avatar/test/index.tsx +50 -18
- package/src/components/collaborators-presence/styles/collaborators-presence.scss +4 -1
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +2 -1
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +6 -4
- package/src/components/editor-help/help-topic-row.native.js +2 -2
- package/src/components/editor-interface/index.js +22 -23
- package/src/components/editor-interface/style.scss +4 -0
- package/src/components/editor-notices/index.js +7 -1
- package/src/components/error-boundary/index.native.js +2 -2
- package/src/components/global-styles/hooks.js +26 -0
- package/src/components/global-styles-sidebar/style.scss +0 -9
- package/src/components/header/index.js +12 -12
- package/src/components/media/media-editor-modal.js +20 -2
- package/src/components/offline-status/index.native.js +2 -2
- package/src/components/post-card-panel/index.js +5 -2
- package/src/components/post-last-revision/index.js +37 -9
- package/src/components/post-last-revision/style.scss +0 -3
- package/src/components/post-locked-modal/index.js +8 -5
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-publish-button/label.js +0 -11
- package/src/components/post-publish-panel/prepublish.js +6 -2
- package/src/components/post-revisions-panel/index.js +8 -0
- package/src/components/post-revisions-preview/diff-markers.js +17 -11
- package/src/components/post-revisions-preview/revisions-canvas.js +7 -1
- package/src/components/post-revisions-preview/style.scss +4 -4
- package/src/components/post-taxonomies/check.js +1 -2
- package/src/components/post-taxonomies/index.js +1 -2
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/preview-dropdown/index.js +2 -2
- package/src/components/provider/index.js +10 -31
- package/src/components/provider/use-block-editor-settings.js +19 -12
- package/src/components/resizable-editor/resize-handle.js +22 -16
- package/src/components/sidebar/header.js +18 -28
- package/src/components/sidebar/index.js +5 -14
- package/src/components/start-page-options/index.js +19 -4
- package/src/components/start-template-options/index.js +13 -6
- package/src/components/styles-canvas/style-book.js +75 -13
- package/src/components/sync-connection-error-modal/index.tsx +25 -11
- package/src/components/template-actions-panel/block-theme-content.js +19 -13
- package/src/components/text-editor/style.scss +2 -2
- package/src/dataviews/store/private-actions.ts +0 -1
- package/src/store/private-actions.js +27 -0
- package/src/store/private-selectors.js +26 -0
- package/src/store/selectors.js +0 -24
- package/src/store/test/actions.js +34 -0
- package/src/utils/media-delete/index.js +11 -0
- package/src/utils/media-finalize/index.js +6 -1
- package/src/utils/media-finalize/test/index.js +32 -2
- package/src/utils/sync-error-messages.ts +8 -0
- package/src/utils/test/sync-error-messages.js +1 -0
- package/build/components/global-styles-provider/index.cjs +0 -181
- package/build/components/global-styles-provider/index.cjs.map +0 -7
- package/build/components/media/index.cjs.map +0 -7
- package/build/components/media/metadata-panel.cjs +0 -96
- package/build/components/media/metadata-panel.cjs.map +0 -7
- package/build/components/media/preview.cjs +0 -39
- package/build/components/media/preview.cjs.map +0 -7
- package/build-module/components/global-styles-provider/index.mjs +0 -156
- package/build-module/components/global-styles-provider/index.mjs.map +0 -7
- package/build-module/components/media/index.mjs +0 -8
- package/build-module/components/media/index.mjs.map +0 -7
- package/build-module/components/media/metadata-panel.mjs +0 -65
- package/build-module/components/media/metadata-panel.mjs.map +0 -7
- package/build-module/components/media/preview.mjs +0 -21
- package/build-module/components/media/preview.mjs.map +0 -7
- package/build-types/components/global-styles-provider/index.d.ts +0 -16
- package/build-types/components/global-styles-provider/index.d.ts.map +0 -1
- package/build-types/components/media/index.d.ts +0 -3
- package/build-types/components/media/index.d.ts.map +0 -1
- package/build-types/components/media/metadata-panel.d.ts +0 -12
- package/build-types/components/media/metadata-panel.d.ts.map +0 -1
- package/build-types/components/media/preview.d.ts +0 -9
- package/build-types/components/media/preview.d.ts.map +0 -1
- package/src/components/global-styles-provider/index.js +0 -207
- package/src/components/media/index.js +0 -2
- package/src/components/media/metadata-panel.js +0 -77
- package/src/components/media/preview.js +0 -35
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/provider/use-block-editor-settings.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { privateApis as mediaEditorPrivateApis } from '@wordpress/media-editor';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport mediaUploadOnSuccess from '../../utils/media-upload/on-success';\nimport { default as mediaSideload } from '../../utils/media-sideload';\nimport { default as mediaFinalize } from '../../utils/media-finalize';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useGlobalStylesContext } from '../global-styles-provider';\n\nconst { store: mediaEditorStore } = unlock( mediaEditorPrivateApis );\n\nconst EMPTY_OBJECT = {};\n\nfunction __experimentalReusableBlocksSelect( select ) {\n\tconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\tconst { getEntityRecords } = select( coreStore );\n\treturn getEntityRecords( 'postType', 'wp_block', {\n\t\tper_page: -1,\n\t\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n\t} );\n}\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockBindingsSupportedAttributes',\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'allImageSizes',\n\t'alignWide',\n\t'blockInspectorTabs',\n\t'maxUploadFileSize',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canEditCSS',\n\t'canLockBlocks',\n\t'canUpdateBlockBindings',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableContentOnlyForUnsyncedPatterns',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'onNavigateToEntityRecord',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isPreviewMode',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\nconst {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n\tmediaEditKey,\n\tgetMediaSelectKey,\n\tisIsolatedEditorKey,\n\tdeviceTypeKey,\n\tisNavigationOverlayContextKey,\n\tisNavigationPostEditorKey,\n\tmediaUploadOnSuccessKey,\n\topenMediaEditorModalKey,\n} = unlock( privateApis );\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n * @param {string} renderingMode Editor rendering mode.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId, renderingMode ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallImageSizes,\n\t\tbigImageSizeThreshold,\n\t\tallowRightClickOverrides,\n\t\tblockTypes,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\thiddenBlockTypes,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t\trestBlockPatternCategories,\n\t\tsectionRootClientId,\n\t\tdeviceType,\n\t\tisNavigationOverlayContext,\n\t\tisRevisionsMode,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst { getDeviceType, isRevisionsMode: _isRevisionsMode } = unlock(\n\t\t\t\tselect( editorStore )\n\t\t\t);\n\t\t\tconst { getBlocksByName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\t// Fetch image sizes from REST API index for client-side media processing.\n\t\t\tconst baseData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\t\tfunction getSectionRootBlock() {\n\t\t\t\tif ( renderingMode === 'template-locked' ) {\n\t\t\t\t\treturn getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlocksByName( 'core/group' ).find(\n\t\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )?.tagName === 'main'\n\t\t\t\t\t) ?? ''\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tallImageSizes: baseData?.image_sizes,\n\t\t\t\tbigImageSizeThreshold: baseData?.image_size_threshold,\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\thiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\thasUploadPermissions:\n\t\t\t\t\tcanUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'attachment',\n\t\t\t\t\t} ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'page',\n\t\t\t\t} ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t\tsectionRootClientId: getSectionRootBlock(),\n\t\t\t\tdeviceType: getDeviceType(),\n\t\t\t\tisNavigationOverlayContext:\n\t\t\t\t\tpostType === 'wp_template_part' && postId\n\t\t\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t\t\t\tpostId\n\t\t\t\t\t\t )?.area === 'navigation-overlay'\n\t\t\t\t\t\t: false,\n\t\t\t\tisRevisionsMode: _isRevisionsMode(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport, renderingMode ]\n\t);\n\n\tconst { merged: mergedGlobalStyles } = useGlobalStylesContext();\n\tconst globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT;\n\tconst globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT;\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[ ...( settingsBlockPatterns || [] ) ].filter(\n\t\t\t\t( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t),\n\t\t[ settingsBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\tconst { editMediaEntity } = unlock( useDispatch( coreStore ) );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { openMediaEditorModal } = useDispatch( mediaEditorStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\treturn defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings.allowedBlockTypes;\n\t}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo( () => {\n\t\tconst blockEditorSettings = {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\t[ globalStylesDataKey ]: globalStylesData,\n\t\t\t[ globalStylesLinksDataKey ]: globalStylesLinksData,\n\t\t\tallImageSizes,\n\t\t\tbigImageSizeThreshold,\n\t\t\tallowedBlockTypes,\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t[ getMediaSelectKey ]: ( select, attachmentId ) => {\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ mediaEditKey ]: hasUploadPermissions\n\t\t\t\t? editMediaEntity\n\t\t\t\t: undefined,\n\t\t\t[ openMediaEditorModalKey ]: window?.__experimentalMediaEditorModal\n\t\t\t\t? ( { id, onUpdate } ) =>\n\t\t\t\t\t\topenMediaEditorModal( { id, onUpdate } )\n\t\t\t\t: undefined,\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t[ mediaUploadOnSuccessKey ]: hasUploadPermissions\n\t\t\t\t? mediaUploadOnSuccess\n\t\t\t\t: undefined,\n\t\t\tmediaSideload: hasUploadPermissions ? mediaSideload : undefined,\n\t\t\tmediaFinalize: hasUploadPermissions ? mediaFinalize : undefined,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t[ selectBlockPatternsKey ]: ( select ) => {\n\t\t\t\tconst { hasFinishedResolution, getBlockPatternsForPostType } =\n\t\t\t\t\tunlock( select( coreStore ) );\n\t\t\t\tconst patterns = getBlockPatternsForPostType( postType );\n\t\t\t\treturn hasFinishedResolution( 'getBlockPatterns' )\n\t\t\t\t\t? patterns\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\t[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: ! isDistractionFree && postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\t[ sectionRootClientIdKey ]: sectionRootClientId,\n\t\t\teditorTool:\n\t\t\t\trenderingMode === 'post-only' && postType !== 'wp_template'\n\t\t\t\t\t? 'edit'\n\t\t\t\t\t: undefined,\n\t\t\t// When editing template parts, patterns, or navigation directly,\n\t\t\t// we're in an isolated editing context (focused on that entity alone).\n\t\t\t[ isIsolatedEditorKey ]: [\n\t\t\t\t'wp_template_part',\n\t\t\t\t'wp_block',\n\t\t\t\t'wp_navigation',\n\t\t\t].includes( postType ),\n\t\t\t[ isNavigationPostEditorKey ]: postType === 'wp_navigation',\n\t\t\t// When in template-locked mode (e.g., \"Show Template\" in the post editor),\n\t\t\t// don't treat template parts as contentOnly sections.\n\t\t\tdisableContentOnlyForTemplateParts:\n\t\t\t\trenderingMode === 'template-locked',\n\t\t\t...( deviceType ? { [ deviceTypeKey ]: deviceType } : {} ),\n\t\t\t[ isNavigationOverlayContextKey ]: isNavigationOverlayContext,\n\t\t};\n\n\t\tif ( isRevisionsMode ) {\n\t\t\tblockEditorSettings.isPreviewMode = true;\n\t\t}\n\n\t\treturn blockEditorSettings;\n\t}, [\n\t\tisRevisionsMode,\n\t\tallowedBlockTypes,\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\tforceDisableFocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\tsettings,\n\t\thasUploadPermissions,\n\t\tuserPatternCategories,\n\t\tblockPatterns,\n\t\tblockPatternCategories,\n\t\tcanUseUnfilteredHTML,\n\t\tundo,\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tsetIsInserterOpened,\n\t\tsectionRootClientId,\n\t\tglobalStylesData,\n\t\tglobalStylesLinksData,\n\t\trenderingMode,\n\t\teditMediaEntity,\n\t\topenMediaEditorModal,\n\t\tsettings.onNavigateToEntityRecord,\n\t\tdeviceType,\n\t\tallImageSizes,\n\t\tbigImageSizeThreshold,\n\t\tisNavigationOverlayContext,\n\t] );\n}\n\nexport default useBlockEditorSettings;\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC,SAAS;AAAA,EACT,sCAAsC;AAAA,EACtC,8BAA8B;AAAA,EAC9B,eAAe;AAAA,OACT;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AACjC,SAAS,SAAS,mBAAmB;AACrC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,eAAe,8BAA8B;AAKtD,OAAO,6BAA6B;AACpC,SAAS,mBAAmB;AAC5B,OAAO,0BAA0B;AACjC,SAAS,WAAW,qBAAqB;AACzC,SAAS,WAAW,qBAAqB;AACzC,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AACvB,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { privateApis as mediaEditorPrivateApis } from '@wordpress/media-editor';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport mediaUploadOnSuccess from '../../utils/media-upload/on-success';\nimport { default as mediaSideload } from '../../utils/media-sideload';\nimport { default as mediaFinalize } from '../../utils/media-finalize';\nimport { default as mediaDelete } from '../../utils/media-delete';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useGlobalStyles } from '../global-styles';\n\nconst { store: mediaEditorStore } = unlock( mediaEditorPrivateApis );\n\nconst EMPTY_OBJECT = {};\n\nfunction __experimentalReusableBlocksSelect( select ) {\n\tconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\tconst { getEntityRecords } = select( coreStore );\n\treturn getEntityRecords( 'postType', 'wp_block', {\n\t\tper_page: -1,\n\t\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n\t} );\n}\n\nfunction __experimentalUserPatternCategoriesSelect( select ) {\n\treturn select( coreStore ).getUserPatternCategories();\n}\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockBindingsSupportedAttributes',\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'allImageSizes',\n\t'alignWide',\n\t'blockInspectorTabs',\n\t'maxUploadFileSize',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canEditCSS',\n\t'canLockBlocks',\n\t'canUpdateBlockBindings',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableContentOnlyForUnsyncedPatterns',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'onNavigateToEntityRecord',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isPreviewMode',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\nconst {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tuserPatternCategoriesSelectKey,\n\tsectionRootClientIdKey,\n\tmediaEditKey,\n\tgetMediaSelectKey,\n\tisIsolatedEditorKey,\n\tdeviceTypeKey,\n\tonViewportStateChangeKey,\n\tisNavigationOverlayContextKey,\n\tisNavigationPostEditorKey,\n\tmediaUploadOnSuccessKey,\n\topenMediaEditorModalKey,\n} = unlock( privateApis );\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n * @param {string} renderingMode Editor rendering mode.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId, renderingMode ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallImageSizes,\n\t\tbigImageSizeThreshold,\n\t\tallowRightClickOverrides,\n\t\tblockTypes,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\thiddenBlockTypes,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\trestBlockPatternCategories,\n\t\tsectionRootClientId,\n\t\tdeviceType,\n\t\tisNavigationOverlayContext,\n\t\tisRevisionsMode,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst { getDeviceType, isRevisionsMode: _isRevisionsMode } = unlock(\n\t\t\t\tselect( editorStore )\n\t\t\t);\n\t\t\tconst { getBlocksByName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\t// Fetch image sizes from REST API index for client-side media processing.\n\t\t\tconst baseData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\t\tfunction getSectionRootBlock() {\n\t\t\t\tif ( renderingMode === 'template-locked' ) {\n\t\t\t\t\treturn getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlocksByName( 'core/group' ).find(\n\t\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )?.tagName === 'main'\n\t\t\t\t\t) ?? ''\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tallImageSizes: baseData?.image_sizes,\n\t\t\t\tbigImageSizeThreshold: baseData?.image_size_threshold,\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\thiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\thasUploadPermissions:\n\t\t\t\t\tcanUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'attachment',\n\t\t\t\t\t} ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'page',\n\t\t\t\t} ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t\tsectionRootClientId: getSectionRootBlock(),\n\t\t\t\tdeviceType: getDeviceType(),\n\t\t\t\tisNavigationOverlayContext:\n\t\t\t\t\tpostType === 'wp_template_part' && postId\n\t\t\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t\t\t\tpostId\n\t\t\t\t\t\t )?.area === 'navigation-overlay'\n\t\t\t\t\t\t: false,\n\t\t\t\tisRevisionsMode: _isRevisionsMode(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport, renderingMode ]\n\t);\n\n\tconst { merged: mergedGlobalStyles } = useGlobalStyles();\n\tconst globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT;\n\tconst globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT;\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[ ...( settingsBlockPatterns || [] ) ].filter(\n\t\t\t\t( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t),\n\t\t[ settingsBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\tconst { updateDeviceTypeForViewportState } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\tconst { editMediaEntity } = unlock( useDispatch( coreStore ) );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { openMediaEditorModal } = useDispatch( mediaEditorStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\treturn defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings.allowedBlockTypes;\n\t}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo( () => {\n\t\tconst blockEditorSettings = {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\t[ globalStylesDataKey ]: globalStylesData,\n\t\t\t[ globalStylesLinksDataKey ]: globalStylesLinksData,\n\t\t\tallImageSizes,\n\t\t\tbigImageSizeThreshold,\n\t\t\tallowedBlockTypes,\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t[ getMediaSelectKey ]: ( select, attachmentId ) => {\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ mediaEditKey ]: hasUploadPermissions\n\t\t\t\t? editMediaEntity\n\t\t\t\t: undefined,\n\t\t\t[ openMediaEditorModalKey ]: ( { id, onUpdate } ) =>\n\t\t\t\topenMediaEditorModal( { id, onUpdate } ),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t[ mediaUploadOnSuccessKey ]: hasUploadPermissions\n\t\t\t\t? mediaUploadOnSuccess\n\t\t\t\t: undefined,\n\t\t\tmediaSideload: hasUploadPermissions ? mediaSideload : undefined,\n\t\t\tmediaFinalize: hasUploadPermissions ? mediaFinalize : undefined,\n\t\t\tmediaDelete: hasUploadPermissions ? mediaDelete : undefined,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t[ selectBlockPatternsKey ]: ( select ) => {\n\t\t\t\tconst { hasFinishedResolution, getBlockPatternsForPostType } =\n\t\t\t\t\tunlock( select( coreStore ) );\n\t\t\t\tconst patterns = getBlockPatternsForPostType( postType );\n\t\t\t\treturn hasFinishedResolution( 'getBlockPatterns' )\n\t\t\t\t\t? patterns\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\t[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,\n\t\t\t[ userPatternCategoriesSelectKey ]:\n\t\t\t\t__experimentalUserPatternCategoriesSelect,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: ! isDistractionFree && postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\t[ sectionRootClientIdKey ]: sectionRootClientId,\n\t\t\teditorTool:\n\t\t\t\trenderingMode === 'post-only' && postType !== 'wp_template'\n\t\t\t\t\t? 'edit'\n\t\t\t\t\t: undefined,\n\t\t\t// When editing template parts, patterns, or navigation directly,\n\t\t\t// we're in an isolated editing context (focused on that entity alone).\n\t\t\t[ isIsolatedEditorKey ]: [\n\t\t\t\t'wp_template_part',\n\t\t\t\t'wp_block',\n\t\t\t\t'wp_navigation',\n\t\t\t].includes( postType ),\n\t\t\t[ isNavigationPostEditorKey ]: postType === 'wp_navigation',\n\t\t\t// When in template-locked mode (e.g., \"Show Template\" in the post editor),\n\t\t\t// don't treat template parts as contentOnly sections.\n\t\t\tdisableContentOnlyForTemplateParts:\n\t\t\t\trenderingMode === 'template-locked',\n\t\t\t...( deviceType ? { [ deviceTypeKey ]: deviceType } : {} ),\n\t\t\t[ onViewportStateChangeKey ]: updateDeviceTypeForViewportState,\n\t\t\t[ isNavigationOverlayContextKey ]: isNavigationOverlayContext,\n\t\t};\n\n\t\tif ( isRevisionsMode ) {\n\t\t\tblockEditorSettings.isPreviewMode = true;\n\t\t}\n\n\t\treturn blockEditorSettings;\n\t}, [\n\t\tisRevisionsMode,\n\t\tallowedBlockTypes,\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\tforceDisableFocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\tsettings,\n\t\thasUploadPermissions,\n\t\tblockPatterns,\n\t\tblockPatternCategories,\n\t\tcanUseUnfilteredHTML,\n\t\tundo,\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tsetIsInserterOpened,\n\t\tsectionRootClientId,\n\t\tglobalStylesData,\n\t\tglobalStylesLinksData,\n\t\trenderingMode,\n\t\teditMediaEntity,\n\t\topenMediaEditorModal,\n\t\tupdateDeviceTypeForViewportState,\n\t\tdeviceType,\n\t\tallImageSizes,\n\t\tbigImageSizeThreshold,\n\t\tisNavigationOverlayContext,\n\t] );\n}\n\nexport default useBlockEditorSettings;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC,SAAS,aAAa,iBAAiB;AACvC;AAAA,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ACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAEA,IAAO,oCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// packages/editor/src/components/resizable-editor/resize-handle.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { LEFT, RIGHT } from "@wordpress/keycodes";
|
|
4
|
-
import {
|
|
5
|
-
import { VisuallyHidden } from "@wordpress/ui";
|
|
4
|
+
import { __unstableMotion as motion } from "@wordpress/components";
|
|
5
|
+
import { Tooltip, VisuallyHidden } from "@wordpress/ui";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
var DELTA_DISTANCE = 20;
|
|
8
8
|
function ResizeHandle({ direction, resizeWidthBy }) {
|
|
@@ -26,22 +26,30 @@ function ResizeHandle({ direction, resizeWidthBy }) {
|
|
|
26
26
|
};
|
|
27
27
|
const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
|
|
28
28
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
/* @__PURE__ */ jsxs(Tooltip.Root, { children: [
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
Tooltip.Trigger,
|
|
32
|
+
{
|
|
33
|
+
render: /* @__PURE__ */ jsx(
|
|
34
|
+
motion.button,
|
|
35
|
+
{
|
|
36
|
+
className: `editor-resizable-editor__resize-handle is-${direction}`,
|
|
37
|
+
"aria-label": __("Drag to resize"),
|
|
38
|
+
"aria-describedby": resizableHandleHelpId,
|
|
39
|
+
onKeyDown: handleKeyDown,
|
|
40
|
+
variants: resizeHandleVariants,
|
|
41
|
+
whileFocus: "active",
|
|
42
|
+
whileHover: "active",
|
|
43
|
+
whileTap: "active",
|
|
44
|
+
role: "separator",
|
|
45
|
+
"aria-orientation": "vertical"
|
|
46
|
+
},
|
|
47
|
+
"handle"
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx(Tooltip.Popup, { children: __("Drag to resize") })
|
|
52
|
+
] }),
|
|
45
53
|
/* @__PURE__ */ jsx(VisuallyHidden, { id: resizableHandleHelpId, children: __("Use left and right arrow keys to resize the canvas.") })
|
|
46
54
|
] });
|
|
47
55
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/resizable-editor/resize-handle.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { LEFT, RIGHT } from '@wordpress/keycodes';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,MAAM,aAAa;AAC5B,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { LEFT, RIGHT } from '@wordpress/keycodes';\nimport { __unstableMotion as motion } from '@wordpress/components';\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip, VisuallyHidden } from '@wordpress/ui';\n\nconst DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.\n\nexport default function ResizeHandle( { direction, resizeWidthBy } ) {\n\tfunction handleKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( keyCode !== LEFT && keyCode !== RIGHT ) {\n\t\t\treturn;\n\t\t}\n\t\tevent.preventDefault();\n\n\t\tif (\n\t\t\t( direction === 'left' && keyCode === LEFT ) ||\n\t\t\t( direction === 'right' && keyCode === RIGHT )\n\t\t) {\n\t\t\tresizeWidthBy( DELTA_DISTANCE );\n\t\t} else if (\n\t\t\t( direction === 'left' && keyCode === RIGHT ) ||\n\t\t\t( direction === 'right' && keyCode === LEFT )\n\t\t) {\n\t\t\tresizeWidthBy( -DELTA_DISTANCE );\n\t\t}\n\t}\n\n\tconst resizeHandleVariants = {\n\t\tactive: {\n\t\t\topacity: 1,\n\t\t\tscaleY: 1.3,\n\t\t},\n\t};\n\n\tconst resizableHandleHelpId = `resizable-editor__resize-help-${ direction }`;\n\n\treturn (\n\t\t<>\n\t\t\t<Tooltip.Root>\n\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\trender={\n\t\t\t\t\t\t<motion.button\n\t\t\t\t\t\t\tclassName={ `editor-resizable-editor__resize-handle is-${ direction }` }\n\t\t\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\t\t\taria-describedby={ resizableHandleHelpId }\n\t\t\t\t\t\t\tonKeyDown={ handleKeyDown }\n\t\t\t\t\t\t\tvariants={ resizeHandleVariants }\n\t\t\t\t\t\t\twhileFocus=\"active\"\n\t\t\t\t\t\t\twhileHover=\"active\"\n\t\t\t\t\t\t\twhileTap=\"active\"\n\t\t\t\t\t\t\tkey=\"handle\"\n\t\t\t\t\t\t\trole=\"separator\"\n\t\t\t\t\t\t\taria-orientation=\"vertical\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Tooltip.Popup>{ __( 'Drag to resize' ) }</Tooltip.Popup>\n\t\t\t</Tooltip.Root>\n\t\t\t<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A,OAC1C;AAAA,IACA,oBAAC,kBAAe,IAAK,uBAClB,aAAI,qDAAsD,GAC7D;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,26 +5,21 @@ import { useSelect } from "@wordpress/data";
|
|
|
5
5
|
import { forwardRef } from "@wordpress/element";
|
|
6
6
|
import { decodeEntities } from "@wordpress/html-entities";
|
|
7
7
|
import { store as editorStore } from "../../store/index.mjs";
|
|
8
|
-
import { ATTACHMENT_POST_TYPE } from "../../store/constants.mjs";
|
|
9
8
|
import { unlock } from "../../lock-unlock.mjs";
|
|
10
9
|
import { sidebars } from "./constants.mjs";
|
|
11
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
11
|
var { Tabs } = unlock(componentsPrivateApis);
|
|
13
12
|
var SidebarHeader = (_, ref) => {
|
|
14
|
-
const { postTypeLabel,
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
[]
|
|
27
|
-
);
|
|
13
|
+
const { postTypeLabel, isRevisionsMode } = useSelect((select) => {
|
|
14
|
+
const { getPostTypeLabel } = select(editorStore);
|
|
15
|
+
const { isRevisionsMode: _isRevisionsMode } = unlock(
|
|
16
|
+
select(editorStore)
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
postTypeLabel: getPostTypeLabel(),
|
|
20
|
+
isRevisionsMode: _isRevisionsMode()
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
28
23
|
let documentLabel;
|
|
29
24
|
if (isRevisionsMode) {
|
|
30
25
|
documentLabel = __("Revision");
|
|
@@ -42,7 +37,7 @@ var SidebarHeader = (_, ref) => {
|
|
|
42
37
|
children: documentLabel
|
|
43
38
|
}
|
|
44
39
|
),
|
|
45
|
-
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
46
41
|
Tabs.Tab,
|
|
47
42
|
{
|
|
48
43
|
tabId: sidebars.block,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar/header.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,eAAe,6BAA6B;AACrD,SAAS,IAAI,UAAU;AACvB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAK/B,SAAS,SAAS,mBAAmB;AACrC,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { sidebars } from './constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SidebarHeader = ( _, ref ) => {\n\tconst { postTypeLabel, isRevisionsMode } = useSelect( ( select ) => {\n\t\tconst { getPostTypeLabel } = select( editorStore );\n\t\tconst { isRevisionsMode: _isRevisionsMode } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\treturn {\n\t\t\tpostTypeLabel: getPostTypeLabel(),\n\t\t\tisRevisionsMode: _isRevisionsMode(),\n\t\t};\n\t}, [] );\n\n\tlet documentLabel;\n\tif ( isRevisionsMode ) {\n\t\tdocumentLabel = __( 'Revision' );\n\t} else if ( postTypeLabel ) {\n\t\tdocumentLabel = decodeEntities( postTypeLabel );\n\t} else {\n\t\t// translators: Default label for the Document sidebar tab, not selected.\n\t\tdocumentLabel = _x( 'Document', 'noun, panel' );\n\t}\n\n\treturn (\n\t\t<Tabs.TabList ref={ ref }>\n\t\t\t<Tabs.Tab\n\t\t\t\ttabId={ sidebars.document }\n\t\t\t\t// Used for focus management in the SettingsSidebar component.\n\t\t\t\tdata-tab-id={ sidebars.document }\n\t\t\t>\n\t\t\t\t{ documentLabel }\n\t\t\t</Tabs.Tab>\n\t\t\t<Tabs.Tab\n\t\t\t\ttabId={ sidebars.block }\n\t\t\t\t// Used for focus management in the SettingsSidebar component.\n\t\t\t\tdata-tab-id={ sidebars.block }\n\t\t\t>\n\t\t\t\t{ /* translators: Text label for the Block Settings Sidebar tab. */ }\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</Tabs.Tab>\n\t\t</Tabs.TabList>\n\t);\n};\n\nexport default forwardRef( SidebarHeader );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,eAAe,6BAA6B;AACrD,SAAS,IAAI,UAAU;AACvB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAK/B,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AACvB,SAAS,gBAAgB;AA2BvB,SACC,KADD;AAzBF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAE/C,IAAM,gBAAgB,CAAE,GAAG,QAAS;AACnC,QAAM,EAAE,eAAe,gBAAgB,IAAI,UAAW,CAAE,WAAY;AACnE,UAAM,EAAE,iBAAiB,IAAI,OAAQ,WAAY;AACjD,UAAM,EAAE,iBAAiB,iBAAiB,IAAI;AAAA,MAC7C,OAAQ,WAAY;AAAA,IACrB;AACA,WAAO;AAAA,MACN,eAAe,iBAAiB;AAAA,MAChC,iBAAiB,iBAAiB;AAAA,IACnC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAI;AACJ,MAAK,iBAAkB;AACtB,oBAAgB,GAAI,UAAW;AAAA,EAChC,WAAY,eAAgB;AAC3B,oBAAgB,eAAgB,aAAc;AAAA,EAC/C,OAAO;AAEN,oBAAgB,GAAI,YAAY,aAAc;AAAA,EAC/C;AAEA,SACC,qBAAC,KAAK,SAAL,EAAa,KACb;AAAA;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QACA,OAAQ,SAAS;AAAA,QAEjB,eAAc,SAAS;AAAA,QAErB;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QACA,OAAQ,SAAS;AAAA,QAEjB,eAAc,SAAS;AAAA,QAGrB,aAAI,OAAQ;AAAA;AAAA,IACf;AAAA,KACD;AAEF;AAEA,IAAO,iBAAQ,WAAY,aAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,6 @@ import SidebarHeader from "./header.mjs";
|
|
|
27
27
|
import TemplateActionsPanel from "../template-actions-panel/index.mjs";
|
|
28
28
|
import TemplateContentPanel from "../template-content-panel/index.mjs";
|
|
29
29
|
import TemplatePartContentPanel from "../template-part-content-panel/index.mjs";
|
|
30
|
-
import { MediaMetadataPanel } from "../media/index.mjs";
|
|
31
30
|
import PostRevisionsPanel from "../post-revisions-panel/index.mjs";
|
|
32
31
|
import RevisionBlockDiffPanel from "../revision-block-diff/index.mjs";
|
|
33
32
|
import useAutoSwitchEditorSidebars from "../provider/use-auto-switch-editor-sidebars.mjs";
|
|
@@ -35,7 +34,6 @@ import { sidebars } from "./constants.mjs";
|
|
|
35
34
|
import { unlock } from "../../lock-unlock.mjs";
|
|
36
35
|
import { store as editorStore } from "../../store/index.mjs";
|
|
37
36
|
import {
|
|
38
|
-
ATTACHMENT_POST_TYPE,
|
|
39
37
|
NAVIGATION_POST_TYPE,
|
|
40
38
|
TEMPLATE_PART_POST_TYPE,
|
|
41
39
|
TEMPLATE_POST_TYPE
|
|
@@ -55,7 +53,6 @@ var SidebarContent = ({
|
|
|
55
53
|
}) => {
|
|
56
54
|
const tabListRef = useRef(null);
|
|
57
55
|
const tabsContextValue = useContext(Tabs.Context);
|
|
58
|
-
const isAttachment = postType === ATTACHMENT_POST_TYPE;
|
|
59
56
|
const isRevisionsMode = useSelect((select) => {
|
|
60
57
|
return unlock(select(editorStore)).isRevisionsMode();
|
|
61
58
|
});
|
|
@@ -78,9 +75,7 @@ var SidebarContent = ({
|
|
|
78
75
|
}
|
|
79
76
|
}, [tabName]);
|
|
80
77
|
let tabContent;
|
|
81
|
-
if (
|
|
82
|
-
tabContent = /* @__PURE__ */ jsx(MediaMetadataPanel, { onActionPerformed });
|
|
83
|
-
} else if (isRevisionsMode) {
|
|
78
|
+
if (isRevisionsMode) {
|
|
84
79
|
tabContent = /* @__PURE__ */ jsx(PostRevisionSummary, {});
|
|
85
80
|
} else {
|
|
86
81
|
tabContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -121,7 +116,7 @@ var SidebarContent = ({
|
|
|
121
116
|
isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
|
|
122
117
|
children: /* @__PURE__ */ jsxs(Tabs.Context.Provider, { value: tabsContextValue, children: [
|
|
123
118
|
/* @__PURE__ */ jsx(Tabs.TabPanel, { tabId: sidebars.document, focusable: false, children: tabContent }),
|
|
124
|
-
|
|
119
|
+
/* @__PURE__ */ jsxs(Tabs.TabPanel, { tabId: sidebars.block, focusable: false, children: [
|
|
125
120
|
/* @__PURE__ */ jsx(BlockInspector, {}),
|
|
126
121
|
isRevisionsMode && /* @__PURE__ */ jsx(RevisionBlockDiffPanel, {})
|
|
127
122
|
] })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPlatform,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { isRTL, __, _x } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PatternOverridesPanel from '../pattern-overrides-panel';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebar from '../plugin-sidebar';\nimport PostSummary from './post-summary';\nimport PostRevisionSummary from './post-revision-summary';\nimport PostTaxonomiesPanel from '../post-taxonomies/panel';\nimport PostTransformPanel from '../post-transform-panel';\nimport SidebarHeader from './header';\nimport TemplateActionsPanel from '../template-actions-panel';\nimport TemplateContentPanel from '../template-content-panel';\nimport TemplatePartContentPanel from '../template-part-content-panel';\nimport
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,IAAI,UAAU;AAC9B,SAAS,YAAY,mBAAmB;AACxC,SAAS,SAAS,8BAA8B;AAChD,SAAS,eAAe,6BAA6B;AACrD,SAAS,SAAS,sBAAsB;AAKxC,OAAO,2BAA2B;AAClC,OAAO,gCAAgC;AACvC,OAAO,mBAAmB;AAC1B,OAAO,iBAAiB;AACxB,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAChC,OAAO,wBAAwB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AACjC,OAAO,8BAA8B;AACrC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPlatform,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { isRTL, __, _x } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PatternOverridesPanel from '../pattern-overrides-panel';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebar from '../plugin-sidebar';\nimport PostSummary from './post-summary';\nimport PostRevisionSummary from './post-revision-summary';\nimport PostTaxonomiesPanel from '../post-taxonomies/panel';\nimport PostTransformPanel from '../post-transform-panel';\nimport SidebarHeader from './header';\nimport TemplateActionsPanel from '../template-actions-panel';\nimport TemplateContentPanel from '../template-content-panel';\nimport TemplatePartContentPanel from '../template-part-content-panel';\nimport PostRevisionsPanel from '../post-revisions-panel';\nimport RevisionBlockDiffPanel from '../revision-block-diff';\nimport useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-sidebars';\nimport { sidebars } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst SidebarContent = ( {\n\ttabName,\n\tkeyboardShortcut,\n\tonActionPerformed,\n\textraPanels,\n\tpostType,\n} ) => {\n\tconst tabListRef = useRef( null );\n\t// Because `PluginSidebar` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\tconst isRevisionsMode = useSelect( ( select ) => {\n\t\treturn unlock( select( editorStore ) ).isRevisionsMode();\n\t} );\n\n\t// This effect addresses a race condition caused by tabbing from the last\n\t// block in the editor into the settings sidebar. Without this effect, the\n\t// selected tab and browser focus can become separated in an unexpected way\n\t// (e.g the \"block\" tab is focused, but the \"post\" tab is selected).\n\tuseEffect( () => {\n\t\tconst tabsElements = Array.from(\n\t\t\ttabListRef.current?.querySelectorAll( '[role=\"tab\"]' ) || []\n\t\t);\n\t\tconst selectedTabElement = tabsElements.find(\n\t\t\t// We are purposefully using a custom `data-tab-id` attribute here\n\t\t\t// because we don't want rely on any assumptions about `Tabs`\n\t\t\t// component internals.\n\t\t\t( element ) => element.getAttribute( 'data-tab-id' ) === tabName\n\t\t);\n\t\tconst activeElement = selectedTabElement?.ownerDocument.activeElement;\n\t\tconst tabsHasFocus = tabsElements.some( ( element ) => {\n\t\t\treturn activeElement && activeElement.id === element.id;\n\t\t} );\n\t\tif (\n\t\t\ttabsHasFocus &&\n\t\t\tselectedTabElement &&\n\t\t\tselectedTabElement.id !== activeElement?.id\n\t\t) {\n\t\t\tselectedTabElement?.focus();\n\t\t}\n\t}, [ tabName ] );\n\n\tlet tabContent;\n\tif ( isRevisionsMode ) {\n\t\ttabContent = <PostRevisionSummary />;\n\t} else {\n\t\ttabContent = (\n\t\t\t<>\n\t\t\t\t<PostSummary onActionPerformed={ onActionPerformed } />\n\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t<TemplateContentPanel />\n\t\t\t\t{ window?.__experimentalDataFormInspector &&\n\t\t\t\t\t[\n\t\t\t\t\t\t'post',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t].includes( postType ) && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TemplateActionsPanel />\n\t\t\t\t\t\t\t<PostRevisionsPanel />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t<TemplatePartContentPanel />\n\t\t\t\t<PostTransformPanel />\n\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t<PatternOverridesPanel />\n\t\t\t\t{ extraPanels }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PluginSidebar\n\t\t\tidentifier={ tabName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader ref={ tabListRef } />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"editor-sidebar__panel\"\n\t\t\theaderClassName=\"editor-sidebar__panel-tabs\"\n\t\t\ttitle={\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t_x( 'Settings', 'panel button label' )\n\t\t\t}\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t{ tabContent }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t{ isRevisionsMode && <RevisionBlockDiffPanel /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebar>\n\t);\n};\n\nconst Sidebar = ( { extraPanels, onActionPerformed } ) => {\n\tuseAutoSwitchEditorSidebars();\n\tconst { tabName, keyboardShortcut, showSummary, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' );\n\n\t\t\tconst sidebar =\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tsidebars.block,\n\t\t\t\tsidebars.document,\n\t\t\t].includes( sidebar );\n\t\t\tlet _tabName = sidebar;\n\t\t\tif ( ! _isEditorSidebarOpened ) {\n\t\t\t\t_tabName = !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart()\n\t\t\t\t\t? sidebars.block\n\t\t\t\t\t: sidebars.document;\n\t\t\t}\n\n\t\t\tconst _postType = select( editorStore ).getCurrentPostType();\n\n\t\t\treturn {\n\t\t\t\ttabName: _tabName,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tshowSummary: ! [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t\tNAVIGATION_POST_TYPE,\n\t\t\t\t].includes( _postType ),\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea( 'core', newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\tselectedTabId={ tabName }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\ttabName={ tabName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tshowSummary={ showSummary }\n\t\t\t\tonActionPerformed={ onActionPerformed }\n\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B;AACvB,UAAK,CAAC,CAAE,kBAAmB;AAC1B,gCAAyB,QAAQ,gBAAiB;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAE,uBAAwB;AAAA,EAC3B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX,cAAe;AAAA,MAEf;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -119,9 +119,10 @@ function StartPageOptionsModal({ onClose }) {
|
|
|
119
119
|
}
|
|
120
120
|
function StartPageOptions() {
|
|
121
121
|
const [isOpen, setIsOpen] = useState(false);
|
|
122
|
-
const {
|
|
122
|
+
const { isEditedPostEmpty } = useSelect(editorStore);
|
|
123
|
+
const { getEntityRecordNonTransientEdits } = useSelect(coreStore);
|
|
123
124
|
const { isModalActive } = useSelect(interfaceStore);
|
|
124
|
-
const { enabled, postId } = useSelect((select) => {
|
|
125
|
+
const { enabled, postType, postId } = useSelect((select) => {
|
|
125
126
|
const { getCurrentPostId, getCurrentPostType } = select(editorStore);
|
|
126
127
|
const choosePatternModalEnabled = select(preferencesStore).get(
|
|
127
128
|
"core",
|
|
@@ -129,12 +130,20 @@ function StartPageOptions() {
|
|
|
129
130
|
);
|
|
130
131
|
const currentPostType = getCurrentPostType();
|
|
131
132
|
return {
|
|
133
|
+
postType: currentPostType,
|
|
132
134
|
postId: getCurrentPostId(),
|
|
133
135
|
enabled: choosePatternModalEnabled && ATTACHMENT_POST_TYPE !== currentPostType && TEMPLATE_POST_TYPE !== currentPostType && TEMPLATE_PART_POST_TYPE !== currentPostType
|
|
134
136
|
};
|
|
135
137
|
}, []);
|
|
136
138
|
useEffect(() => {
|
|
137
|
-
const
|
|
139
|
+
const hasEdits = Object.keys(
|
|
140
|
+
getEntityRecordNonTransientEdits(
|
|
141
|
+
"postType",
|
|
142
|
+
postType,
|
|
143
|
+
postId
|
|
144
|
+
) ?? {}
|
|
145
|
+
).length > 0;
|
|
146
|
+
const isFreshPage = !hasEdits && isEditedPostEmpty();
|
|
138
147
|
const isPreferencesModalActive = isModalActive("editor/preferences");
|
|
139
148
|
if (!enabled || !isFreshPage || isPreferencesModalActive) {
|
|
140
149
|
return;
|
|
@@ -142,8 +151,9 @@ function StartPageOptions() {
|
|
|
142
151
|
setIsOpen(true);
|
|
143
152
|
}, [
|
|
144
153
|
enabled,
|
|
154
|
+
postType,
|
|
145
155
|
postId,
|
|
146
|
-
|
|
156
|
+
getEntityRecordNonTransientEdits,
|
|
147
157
|
isEditedPostEmpty,
|
|
148
158
|
isModalActive
|
|
149
159
|
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/start-page-options/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport {\n\tATTACHMENT_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t'Always show starter patterns for new pages'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false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CAAE,aAAc;AAC1B,uCAAsB,QAAS;AAAA,gBAChC;AAAA;AAAA,YACD,GACD;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;AAEe,SAAR,mBAAoC;AAC1C,QAAM,CAAE,QAAQ,SAAU,IAAI,SAAU,KAAM;AAC9C,QAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport {\n\tATTACHMENT_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t'Always show starter patterns for new pages'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst { isEditedPostEmpty } = useSelect( editorStore );\n\tconst { getEntityRecordNonTransientEdits } = useSelect( coreStore );\n\tconst { isModalActive } = useSelect( interfaceStore );\n\tconst { enabled, postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\tconst currentPostType = getCurrentPostType();\n\t\treturn {\n\t\t\tpostType: currentPostType,\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled &&\n\t\t\t\tATTACHMENT_POST_TYPE !== currentPostType &&\n\t\t\t\tTEMPLATE_POST_TYPE !== currentPostType &&\n\t\t\t\tTEMPLATE_PART_POST_TYPE !== currentPostType,\n\t\t};\n\t}, [] );\n\n\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\tuseEffect( () => {\n\t\t// Read non-transient edits directly. `isEditedPostDirty` /\n\t\t// `hasEditsForEntityRecord` also return true while the CRDT\n\t\t// sync manager's phantom save (fired off `receiveEntityRecords`\n\t\t// at boot) is in flight, which would suppress the modal.\n\t\tconst hasEdits =\n\t\t\tObject.keys(\n\t\t\t\tgetEntityRecordNonTransientEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t) ?? {}\n\t\t\t).length > 0;\n\t\tconst isFreshPage = ! hasEdits && isEditedPostEmpty();\n\t\t// Prevents immediately opening when features is enabled via preferences modal.\n\t\tconst isPreferencesModalActive = isModalActive( 'editor/preferences' );\n\t\tif ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the modal after the initial render for a new page.\n\t\tsetIsOpen( true );\n\t}, [\n\t\tenabled,\n\t\tpostType,\n\t\tpostId,\n\t\tgetEntityRecordNonTransientEdits,\n\t\tisEditedPostEmpty,\n\t\tisModalActive,\n\t] );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsOpen( false ) } />;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,MAAM,UAAU,OAAO,uBAAuB;AACvD,SAAS,UAAU;AACnB,SAAS,UAAU,SAAS,iBAAiB;AAC7C;AAAA,EACC,SAAS;AAAA,EACT,mCAAmC;AAAA,OAC7B;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,mCAAmC;AAC5C,SAAS,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,UAAW,SAAU;AAClE,QAAM,EAAE,cAAc,IAAI,UAAW,cAAe;AACpD,QAAM,EAAE,SAAS,UAAU,OAAO,IAAI,UAAW,CAAE,WAAY;AAC9D,UAAM,EAAE,kBAAkB,mBAAmB,IAAI,OAAQ,WAAY;AACrE,UAAM,4BAA4B,OAAQ,gBAAiB,EAAE;AAAA,MAC5D;AAAA,MACA;AAAA,IACD;AACA,UAAM,kBAAkB,mBAAmB;AAC3C,WAAO;AAAA,MACN,UAAU;AAAA,MACV,QAAQ,iBAAiB;AAAA,MACzB,SACC,6BACA,yBAAyB,mBACzB,uBAAuB,mBACvB,4BAA4B;AAAA,IAC9B;AAAA,EACD,GAAG,CAAC,CAAE;AAIN,YAAW,MAAM;AAKhB,UAAM,WACL,OAAO;AAAA,MACN;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,MACD,KAAK,CAAC;AAAA,IACP,EAAE,SAAS;AACZ,UAAM,cAAc,CAAE,YAAY,kBAAkB;AAEpD,UAAM,2BAA2B,cAAe,oBAAqB;AACrE,QAAK,CAAE,WAAW,CAAE,eAAe,0BAA2B;AAC7D;AAAA,IACD;AAGA,cAAW,IAAK;AAAA,EACjB,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AAEA,SAAO,oBAAC,yBAAsB,SAAU,MAAM,UAAW,KAAM,GAAI;AACpE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -145,17 +145,19 @@ function StartTemplateOptions() {
|
|
|
145
145
|
const { getCurrentPostType, getCurrentPostId } = select(editorStore);
|
|
146
146
|
const _postType = getCurrentPostType();
|
|
147
147
|
const _postId = getCurrentPostId();
|
|
148
|
-
const { getEditedEntityRecord,
|
|
148
|
+
const { getEditedEntityRecord, getEntityRecordNonTransientEdits } = select(coreStore);
|
|
149
149
|
const templateRecord = getEditedEntityRecord(
|
|
150
150
|
"postType",
|
|
151
151
|
_postType,
|
|
152
152
|
_postId
|
|
153
153
|
);
|
|
154
|
-
const hasEdits =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
const hasEdits = Object.keys(
|
|
155
|
+
getEntityRecordNonTransientEdits(
|
|
156
|
+
"postType",
|
|
157
|
+
_postType,
|
|
158
|
+
_postId
|
|
159
|
+
) ?? {}
|
|
160
|
+
).length > 0;
|
|
159
161
|
return {
|
|
160
162
|
shouldOpenModal: !hasEdits && "" === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
|
|
161
163
|
slug: templateRecord.slug,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/start-template-options/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal, Flex, FlexItem, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getDefaultTemplateId } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateId = getDefaultTemplateId( {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} );\n\t\t\treturn templateId\n\t\t\t\t? getEntityRecord( 'postType', TEMPLATE_POST_TYPE, templateId )\n\t\t\t\t\t\t?.content?.raw\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ slug, isCustom ]\n\t);\n}\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\t\tconst { getEntityRecord, getBlockPatterns } = select( coreStore );\n\t\tconst postId = getCurrentPostId();\n\t\tconst postType = getCurrentPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getBlockPatterns(),\n\t\t};\n\t}, [] );\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\t// Duplicated from packages/block-library/src/pattern/edit.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pattern,\n\t\t\t\t\t\tblocks: parse( pattern.content ).map( ( block ) =>\n\t\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\tonChange( blocks, { selection: undefined } );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<div className=\"editor-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-template-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Skip' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartTemplateOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst { shouldOpenModal, slug, isCustom, postType, postId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getCurrentPostId } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst _postType = getCurrentPostType();\n\t\t\tconst _postId = getCurrentPostId();\n\t\t\tconst { getEditedEntityRecord,
|
|
5
|
-
"mappings": ";AAGA,SAAS,OAAO,MAAM,UAAU,cAAc;AAC9C,SAAS,UAAU;AACnB,SAAS,UAAU,SAAS,iBAAiB;AAC7C,SAAS,mCAAmC,yBAAyB;AACrE,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,SAAS,WAAW,4BAA4B;AAKzD,SAAS,SAAS,mBAAmB;AACrC,SAAS,0BAA0B;AAkGjC,cAgBA,YAhBA;AAhGF,SAAS,2BAA4B,MAAM,WAAW,OAAQ;AAC7D,SAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,EAAE,iBAAiB,qBAAqB,IAC7C,OAAQ,SAAU;AACnB,YAAM,aAAa,qBAAsB;AAAA,QACxC;AAAA,QACA,WAAW;AAAA,QACX,cAAc;AAAA,MACf,CAAE;AACF,aAAO,aACJ,gBAAiB,YAAY,oBAAoB,UAAW,GAC1D,SAAS,MACX;AAAA,IACJ;AAAA,IACA,CAAE,MAAM,QAAS;AAAA,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AI,MAAO;AAAA;AAAA,YACd,GACD;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;AAEe,SAAR,uBAAwC;AAC9C,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,KAAM;AAClD,QAAM,EAAE,iBAAiB,MAAM,UAAU,UAAU,OAAO,IAAI;AAAA,IAC7D,CAAE,WAAY;AACb,YAAM,EAAE,oBAAoB,iBAAiB,IAC5C,OAAQ,WAAY;AACrB,YAAM,YAAY,mBAAmB;AACrC,YAAM,UAAU,iBAAiB;AACjC,YAAM,EAAE,uBAAuB,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal, Flex, FlexItem, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getDefaultTemplateId } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateId = getDefaultTemplateId( {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} );\n\t\t\treturn templateId\n\t\t\t\t? getEntityRecord( 'postType', TEMPLATE_POST_TYPE, templateId )\n\t\t\t\t\t\t?.content?.raw\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ slug, isCustom ]\n\t);\n}\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\t\tconst { getEntityRecord, getBlockPatterns } = select( coreStore );\n\t\tconst postId = getCurrentPostId();\n\t\tconst postType = getCurrentPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getBlockPatterns(),\n\t\t};\n\t}, [] );\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\t// Duplicated from packages/block-library/src/pattern/edit.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pattern,\n\t\t\t\t\t\tblocks: parse( pattern.content ).map( ( block ) =>\n\t\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\tonChange( blocks, { selection: undefined } );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<div className=\"editor-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-template-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Skip' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartTemplateOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst { shouldOpenModal, slug, isCustom, postType, postId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getCurrentPostId } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst _postType = getCurrentPostType();\n\t\t\tconst _postId = getCurrentPostId();\n\t\t\tconst { getEditedEntityRecord, getEntityRecordNonTransientEdits } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\t_postId\n\t\t\t);\n\t\t\t// Read non-transient edits directly. `isEditedPostDirty` /\n\t\t\t// `hasEditsForEntityRecord` also return true while the CRDT\n\t\t\t// sync manager's phantom save (fired off `receiveEntityRecords`\n\t\t\t// at boot) is in flight, which would suppress the modal.\n\t\t\tconst hasEdits =\n\t\t\t\tObject.keys(\n\t\t\t\t\tgetEntityRecordNonTransientEdits(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t_postType,\n\t\t\t\t\t\t_postId\n\t\t\t\t\t) ?? {}\n\t\t\t\t).length > 0;\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModal:\n\t\t\t\t\t! hasEdits &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\tTEMPLATE_POST_TYPE === _postType,\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t\tpostId: _postId,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\t// Should reset the modal state when navigating to a new page/post.\n\t\tsetIsClosed( false );\n\t}, [ postType, postId ] );\n\n\tif ( ! shouldOpenModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug }\n\t\t\tisCustom={ isCustom }\n\t\t\tpostType={ postType }\n\t\t\tonClose={ () => setIsClosed( true ) }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,OAAO,MAAM,UAAU,cAAc;AAC9C,SAAS,UAAU;AACnB,SAAS,UAAU,SAAS,iBAAiB;AAC7C,SAAS,mCAAmC,yBAAyB;AACrE,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,SAAS,WAAW,4BAA4B;AAKzD,SAAS,SAAS,mBAAmB;AACrC,SAAS,0BAA0B;AAkGjC,cAgBA,YAhBA;AAhGF,SAAS,2BAA4B,MAAM,WAAW,OAAQ;AAC7D,SAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,EAAE,iBAAiB,qBAAqB,IAC7C,OAAQ,SAAU;AACnB,YAAM,aAAa,qBAAsB;AAAA,QACxC;AAAA,QACA,WAAW;AAAA,QACX,cAAc;AAAA,MACf,CAAE;AACF,aAAO,aACJ,gBAAiB,YAAY,oBAAoB,UAAW,GAC1D,SAAS,MACX;AAAA,IACJ;AAAA,IACA,CAAE,MAAM,QAAS;AAAA,EAClB;AACD;AAEA,SAAS,iBAAkB,iBAAkB;AAC5C,QAAM,EAAE,MAAM,SAAS,IAAI,UAAW,CAAE,WAAY;AACnD,UAAM,EAAE,oBAAoB,iBAAiB,IAAI,OAAQ,WAAY;AACrE,UAAM,EAAE,iBAAiB,iBAAiB,IAAI,OAAQ,SAAU;AAChE,UAAM,SAAS,iBAAiB;AAChC,UAAM,WAAW,mBAAmB;AACpC,UAAM,SAAS,gBAAiB,YAAY,UAAU,MAAO;AAC7D,WAAO;AAAA,MACN,MAAM,OAAO;AAAA,MACb,UAAU,iBAAiB;AAAA,IAC5B;AA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