@wordpress/editor 14.49.1 → 14.51.1-next.v.202607070741.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 -0
- package/build/components/collab-sidebar/format.cjs +83 -0
- package/build/components/collab-sidebar/format.cjs.map +7 -0
- package/build/components/collab-sidebar/hooks.cjs +117 -16
- package/build/components/collab-sidebar/hooks.cjs.map +2 -2
- package/build/components/collab-sidebar/index.cjs +18 -2
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-highlight-styles.cjs +67 -0
- package/build/components/collab-sidebar/note-highlight-styles.cjs.map +7 -0
- package/build/components/collab-sidebar/utils.cjs +139 -0
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +55 -30
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
- package/build/components/commands/index.cjs +99 -3
- package/build/components/commands/index.cjs.map +2 -2
- package/build/components/document-bar/index.cjs +28 -34
- package/build/components/document-bar/index.cjs.map +2 -2
- package/build/components/entities-saved-states/index.cjs +1 -4
- package/build/components/entities-saved-states/index.cjs.map +2 -2
- package/build/components/header/index.cjs +1 -8
- package/build/components/header/index.cjs.map +2 -2
- package/build/components/media-categories/index.cjs +92 -6
- package/build/components/media-categories/index.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +0 -1
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-author/combobox.cjs +0 -1
- package/build/components/post-author/combobox.cjs.map +2 -2
- package/build/components/post-author/select.cjs +0 -1
- package/build/components/post-author/select.cjs.map +2 -2
- package/build/components/post-preview-button/index.cjs +29 -2
- package/build/components/post-preview-button/index.cjs.map +2 -2
- package/build/components/post-publish-panel/maybe-upload-media.cjs +15 -26
- package/build/components/post-publish-panel/maybe-upload-media.cjs.map +3 -3
- package/build/components/post-revisions-preview/revisions-slider.cjs +3 -1
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-taxonomies/flat-term-selector.cjs +0 -1
- package/build/components/post-taxonomies/flat-term-selector.cjs.map +2 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
- package/build/components/post-template/classic-theme.cjs +0 -1
- package/build/components/post-template/classic-theme.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +54 -28
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs +38 -9
- package/build/components/preview-dropdown/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +23 -9
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/resizable-editor/index.cjs +54 -9
- package/build/components/resizable-editor/index.cjs.map +3 -3
- package/build/components/sidebar/dataform-post-summary.cjs +5 -1
- package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +29 -38
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +0 -13
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +15 -11
- package/build/components/visual-editor/index.cjs.map +3 -3
- package/build/dataviews/store/private-actions.cjs +24 -19
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/actions.cjs +5 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/constants.cjs +26 -0
- package/build/store/constants.cjs.map +2 -2
- package/build/store/private-actions.cjs +25 -18
- package/build/store/private-actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs +5 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +3 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/device-type.cjs +52 -0
- package/build/utils/device-type.cjs.map +7 -0
- package/build/utils/media-sideload-from-url/index.cjs +63 -0
- package/build/utils/media-sideload-from-url/index.cjs.map +7 -0
- package/build-module/components/collab-sidebar/format.mjs +57 -0
- package/build-module/components/collab-sidebar/format.mjs.map +7 -0
- package/build-module/components/collab-sidebar/hooks.mjs +121 -16
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +21 -5
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-highlight-styles.mjs +41 -0
- package/build-module/components/collab-sidebar/note-highlight-styles.mjs.map +7 -0
- package/build-module/components/collab-sidebar/utils.mjs +133 -0
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +55 -30
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/commands/index.mjs +99 -3
- package/build-module/components/commands/index.mjs.map +2 -2
- package/build-module/components/document-bar/index.mjs +28 -34
- package/build-module/components/document-bar/index.mjs.map +2 -2
- package/build-module/components/entities-saved-states/index.mjs +1 -4
- package/build-module/components/entities-saved-states/index.mjs.map +2 -2
- package/build-module/components/header/index.mjs +1 -13
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media-categories/index.mjs +93 -7
- package/build-module/components/media-categories/index.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +0 -1
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-author/combobox.mjs +0 -1
- package/build-module/components/post-author/combobox.mjs.map +2 -2
- package/build-module/components/post-author/select.mjs +0 -1
- package/build-module/components/post-author/select.mjs.map +2 -2
- package/build-module/components/post-preview-button/index.mjs +29 -2
- package/build-module/components/post-preview-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs +19 -27
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +3 -1
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-taxonomies/flat-term-selector.mjs +0 -1
- package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
- package/build-module/components/post-template/classic-theme.mjs +0 -1
- package/build-module/components/post-template/classic-theme.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +54 -28
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/preview-dropdown/index.mjs +38 -9
- package/build-module/components/preview-dropdown/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +23 -9
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/resizable-editor/index.mjs +55 -10
- package/build-module/components/resizable-editor/index.mjs.map +2 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs +6 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +29 -42
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +0 -13
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +16 -13
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +26 -19
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/actions.mjs +5 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/constants.mjs +25 -0
- package/build-module/store/constants.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +27 -17
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +4 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +5 -5
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +3 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/device-type.mjs +25 -0
- package/build-module/utils/device-type.mjs.map +7 -0
- package/build-module/utils/media-sideload-from-url/index.mjs +32 -0
- package/build-module/utils/media-sideload-from-url/index.mjs.map +7 -0
- package/build-style/style-rtl.css +84 -39
- package/build-style/style.css +84 -39
- package/build-types/components/collab-sidebar/format.d.ts +17 -0
- package/build-types/components/collab-sidebar/format.d.ts.map +1 -0
- 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-highlight-styles.d.ts +31 -0
- package/build-types/components/collab-sidebar/note-highlight-styles.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/utils.d.ts +82 -2
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
- package/build-types/components/commands/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/media-categories/index.d.ts +12 -3
- package/build-types/components/media-categories/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-author/combobox.d.ts.map +1 -1
- package/build-types/components/post-author/select.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/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/index.d.ts.map +1 -1
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts +6 -0
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/index.d.ts +2 -2
- package/build-types/store/private-actions.d.ts +9 -15
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +6 -7
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/device-type.d.ts +23 -0
- package/build-types/utils/device-type.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-sideload-from-url/index.d.ts +18 -0
- package/build-types/utils/media-sideload-from-url/index.d.ts.map +1 -0
- package/package.json +48 -46
- package/src/components/collab-sidebar/format.js +72 -0
- package/src/components/collab-sidebar/hooks.js +203 -22
- package/src/components/collab-sidebar/index.js +19 -5
- package/src/components/collab-sidebar/note-highlight-styles.js +83 -0
- package/src/components/collab-sidebar/style.scss +9 -0
- package/src/components/collab-sidebar/test/note-highlight-styles.js +106 -0
- package/src/components/collab-sidebar/test/utils.js +471 -0
- package/src/components/collab-sidebar/utils.js +225 -2
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +265 -262
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +70 -34
- package/src/components/commands/index.js +142 -0
- package/src/components/document-bar/index.js +0 -9
- package/src/components/document-bar/style.scss +0 -17
- package/src/components/entities-saved-states/index.js +1 -5
- package/src/components/header/index.js +1 -15
- package/src/components/header/style.scss +7 -3
- package/src/components/media-categories/index.js +160 -6
- package/src/components/media-categories/test/index.js +202 -0
- package/src/components/page-attributes/parent.js +0 -1
- package/src/components/post-author/combobox.js +0 -1
- package/src/components/post-author/select.js +0 -1
- package/src/components/post-preview-button/index.js +68 -2
- package/src/components/post-publish-panel/maybe-upload-media.js +25 -30
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -127
- package/src/components/post-revisions-preview/revisions-slider.js +4 -1
- package/src/components/post-revisions-preview/test/block-diff.js +2 -2
- package/src/components/post-taxonomies/flat-term-selector.js +0 -1
- package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -2
- package/src/components/post-template/classic-theme.js +0 -1
- package/src/components/preferences-modal/index.js +40 -22
- package/src/components/preferences-modal/test/index.js +83 -0
- package/src/components/preview-dropdown/index.js +42 -3
- package/src/components/provider/use-block-editor-settings.js +42 -7
- package/src/components/resizable-editor/index.js +71 -9
- package/src/components/resizable-editor/style.scss +7 -0
- package/src/components/sidebar/dataform-post-summary.js +13 -1
- package/src/components/sidebar/index.js +32 -47
- package/src/components/sidebar/post-summary.js +0 -17
- package/src/components/styles-canvas/style.scss +1 -2
- package/src/components/visual-editor/index.js +19 -15
- package/src/components/visual-editor/style.scss +11 -4
- package/src/dataviews/store/private-actions.ts +30 -26
- package/src/store/actions.js +6 -3
- package/src/store/constants.ts +45 -0
- package/src/store/private-actions.js +38 -28
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +7 -9
- package/src/store/selectors.js +3 -1
- package/src/store/test/actions.js +31 -22
- package/src/utils/device-type.js +46 -0
- package/src/utils/media-sideload-from-url/index.js +54 -0
- package/src/utils/media-sideload-from-url/test/index.js +162 -0
- package/build/components/post-publish-panel/media-util.cjs +0 -72
- package/build/components/post-publish-panel/media-util.cjs.map +0 -7
- package/build-module/components/post-publish-panel/media-util.mjs +0 -46
- package/build-module/components/post-publish-panel/media-util.mjs.map +0 -7
- package/build-types/components/post-publish-panel/media-util.d.ts +0 -20
- package/build-types/components/post-publish-panel/media-util.d.ts.map +0 -1
- package/src/components/post-publish-panel/media-util.js +0 -87
- package/src/components/post-publish-panel/test/media-util.js +0 -118
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-categories/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.\n * See `packages/editor/src/components/media-categories/index.js`.\n *\n * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.\n * The rest of the settings would still need to be in sync though.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */\n/** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */\n\nconst getExternalLink = ( url, text ) =>\n\t`<a ${ getExternalLinkAttributes( url ) }>${ text }</a>`;\n\nconst getExternalLinkAttributes = ( url ) =>\n\t`href=\"${ url }\" target=\"_blank\" rel=\"noopener\"`;\n\nconst getOpenverseLicense = ( license, licenseVersion ) => {\n\tlet licenseName = license.trim();\n\t// PDM has no abbreviation\n\tif ( license !== 'pdm' ) {\n\t\tlicenseName = license.toUpperCase().replace( 'SAMPLING', 'Sampling' );\n\t}\n\t// If version is known, append version to the name.\n\t// The license has to have a version to be valid. Only\n\t// PDM (public domain mark) doesn't have a version.\n\tif ( licenseVersion ) {\n\t\tlicenseName += ` ${ licenseVersion }`;\n\t}\n\t// For licenses other than public-domain marks, prepend 'CC' to the name.\n\tif ( ! [ 'pdm', 'cc0' ].includes( license ) ) {\n\t\tlicenseName = `CC ${ licenseName }`;\n\t}\n\treturn licenseName;\n};\n\nconst getOpenverseCaption = ( item ) => {\n\tconst {\n\t\ttitle,\n\t\tforeign_landing_url: foreignLandingUrl,\n\t\tcreator,\n\t\tcreator_url: creatorUrl,\n\t\tlicense,\n\t\tlicense_version: licenseVersion,\n\t\tlicense_url: licenseUrl,\n\t} = item;\n\tconst fullLicense = getOpenverseLicense( license, licenseVersion );\n\tconst _creator = decodeEntities( creator );\n\tlet _caption;\n\tif ( _creator ) {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2$s: Name of the work's creator; %3s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\" by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a> by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t} else {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\"/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a>/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t}\n\treturn _caption.replace( /\\s{2}/g, ' ' );\n};\n\nconst coreMediaFetch = async ( query = {} ) => {\n\tconst mediaItems = await resolveSelect( coreStore ).getEntityRecords(\n\t\t'postType',\n\t\t'attachment',\n\t\t{\n\t\t\t...query,\n\t\t\torderBy: !! query?.search ? 'relevance' : 'date',\n\t\t}\n\t);\n\treturn mediaItems.map( ( mediaItem ) => ( {\n\t\t...mediaItem,\n\t\talt: mediaItem.alt_text,\n\t\turl: mediaItem.source_url,\n\t\tpreviewUrl: mediaItem.media_details?.sizes?.medium?.source_url,\n\t\tcaption: mediaItem.caption?.raw,\n\t} ) );\n};\n\n/** @type {InserterMediaCategory[]} */\nconst inserterMediaCategories = [\n\t{\n\t\tname: 'images',\n\t\tlabels: {\n\t\t\tname: __( 'Images' ),\n\t\t\tsearch_items: __( 'Search images' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'image' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'videos',\n\t\tlabels: {\n\t\t\tname: __( 'Videos' ),\n\t\t\tsearch_items: __( 'Search videos' ),\n\t\t},\n\t\tmediaType: 'video',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'video' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'audio',\n\t\tlabels: {\n\t\t\tname: __( 'Audio' ),\n\t\t\tsearch_items: __( 'Search audio' ),\n\t\t},\n\t\tmediaType: 'audio',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'audio' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'openverse',\n\t\tlabels: {\n\t\t\tname: __( 'Openverse' ),\n\t\t\tsearch_items: __( 'Search Openverse' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\tconst defaultArgs = {\n\t\t\t\tmature: false,\n\t\t\t\texcluded_source: 'flickr,inaturalist,wikimedia',\n\t\t\t\tlicense: 'pdm,cc0',\n\t\t\t};\n\t\t\tconst finalQuery = { ...query, ...defaultArgs };\n\t\t\tconst mapFromInserterMediaRequest = {\n\t\t\t\tper_page: 'page_size',\n\t\t\t\tsearch: 'q',\n\t\t\t};\n\t\t\tconst url = new URL( 'https://api.openverse.org/v1/images/' );\n\t\t\tObject.entries( finalQuery ).forEach( ( [ key, value ] ) => {\n\t\t\t\tconst queryKey = mapFromInserterMediaRequest[ key ] || key;\n\t\t\t\turl.searchParams.set( queryKey, value );\n\t\t\t} );\n\t\t\tconst response = await window.fetch( url, {\n\t\t\t\theaders: {\n\t\t\t\t\t'User-Agent': 'WordPress/inserter-media-fetch',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst jsonResponse = await response.json();\n\t\t\tconst results = jsonResponse.results;\n\t\t\treturn results.map( ( result ) => ( {\n\t\t\t\t...result,\n\t\t\t\t// This is a temp solution for better titles, until Openverse API\n\t\t\t\t// completes the cleaning up of some titles of their upstream data.\n\t\t\t\ttitle: result.title?.toLowerCase().startsWith( 'file:' )\n\t\t\t\t\t? result.title.slice( 5 )\n\t\t\t\t\t: result.title,\n\t\t\t\tsourceId: result.id,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: getOpenverseCaption( result ),\n\t\t\t\tpreviewUrl: result.thumbnail,\n\t\t\t} ) );\n\t\t},\n\t\tgetReportUrl: ( { sourceId } ) =>\n\t\t\t`https://wordpress.org/openverse/image/${ sourceId }/report/`,\n\t\tisExternalResource: true,\n\t},\n];\n\nexport default inserterMediaCategories;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,kBAAgC;AAChC,
|
|
4
|
+
"sourcesContent": ["/**\n * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.\n * See `packages/editor/src/components/media-categories/index.js`.\n *\n * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.\n * The rest of the settings would still need to be in sync though.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { dispatch, resolveSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */\n/** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */\n\nconst getExternalLink = ( url, text ) =>\n\t`<a ${ getExternalLinkAttributes( url ) }>${ text }</a>`;\n\nconst getExternalLinkAttributes = ( url ) =>\n\t`href=\"${ url }\" target=\"_blank\" rel=\"noopener\"`;\n\nconst getOpenverseLicense = ( license, licenseVersion ) => {\n\tlet licenseName = license.trim();\n\t// PDM has no abbreviation\n\tif ( license !== 'pdm' ) {\n\t\tlicenseName = license.toUpperCase().replace( 'SAMPLING', 'Sampling' );\n\t}\n\t// If version is known, append version to the name.\n\t// The license has to have a version to be valid. Only\n\t// PDM (public domain mark) doesn't have a version.\n\tif ( licenseVersion ) {\n\t\tlicenseName += ` ${ licenseVersion }`;\n\t}\n\t// For licenses other than public-domain marks, prepend 'CC' to the name.\n\tif ( ! [ 'pdm', 'cc0' ].includes( license ) ) {\n\t\tlicenseName = `CC ${ licenseName }`;\n\t}\n\treturn licenseName;\n};\n\nconst getOpenverseCaption = ( item ) => {\n\tconst {\n\t\ttitle,\n\t\tforeign_landing_url: foreignLandingUrl,\n\t\tcreator,\n\t\tcreator_url: creatorUrl,\n\t\tlicense,\n\t\tlicense_version: licenseVersion,\n\t\tlicense_url: licenseUrl,\n\t} = item;\n\tconst fullLicense = getOpenverseLicense( license, licenseVersion );\n\tconst _creator = decodeEntities( creator );\n\tlet _caption;\n\tif ( _creator ) {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2$s: Name of the work's creator; %3s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\" by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a> by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t} else {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\"/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a>/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t}\n\treturn _caption.replace( /\\s{2}/g, ' ' );\n};\n\nconst getCoreMediaQuery = ( query = {} ) => ( {\n\t...query,\n\torderBy: !! query?.search ? 'relevance' : 'date',\n} );\n\nconst coreMediaFetch = async ( query = {} ) => {\n\tconst mediaItems = await resolveSelect( coreStore ).getEntityRecords(\n\t\t'postType',\n\t\t'attachment',\n\t\tgetCoreMediaQuery( query )\n\t);\n\treturn mediaItems.map( ( mediaItem ) => ( {\n\t\t...mediaItem,\n\t\talt: mediaItem.alt_text,\n\t\turl: mediaItem.source_url,\n\t\tpreviewUrl: mediaItem.media_details?.sizes?.medium?.source_url,\n\t\tcaption: mediaItem.caption?.raw,\n\t} ) );\n};\n\nconst getAttachedImagesQuery = ( postId, query = {} ) => ( {\n\t...query,\n\tmedia_type: 'image',\n\tparent: postId,\n} );\n\nconst normalizePostId = ( postId ) => {\n\tconst parsedPostId = typeof postId === 'number' ? postId : Number( postId );\n\n\treturn Number.isInteger( parsedPostId ) && parsedPostId > 0\n\t\t? parsedPostId\n\t\t: undefined;\n};\n\nconst saveAttachmentParent = ( attachmentId, postId ) =>\n\t// `throwOnError` so a failed REST write rejects (rather than being silently\n\t// swallowed), letting the attach/detach handlers surface an error notice\n\t// instead of a false success.\n\tdispatch( coreStore ).saveEntityRecord(\n\t\t'postType',\n\t\t'attachment',\n\t\t{\n\t\t\tid: attachmentId,\n\t\t\tpost: postId,\n\t\t},\n\t\t{ throwOnError: true }\n\t);\n\n// A selected media item's coarse type is exposed differently by each picker.\n// The classic media modal puts the media type directly on `type` (e.g. 'image').\n// The DataViews-driven modal passes REST attachment records, where `type` is the\n// *post* type ('attachment') and the media type lives in `media_type`\n// ('image'|'file') / `mime_type`. So the REST fields must be read first, with\n// `type` as the classic-modal fallback — otherwise a REST image reads as\n// 'attachment' and gets gated out.\nconst getMediaItemType = ( mediaItem ) =>\n\tmediaItem?.media_type ||\n\tmediaItem?.mime_type?.split( '/' )[ 0 ] ||\n\tmediaItem?.type;\n\n// The picker's \"Upload files\" tab accepts any file type, so the selection can\n// include non-images. Gate to images only: a non-image would be reparented to\n// the post but never appear in the image-filtered grid, and would wrongly count\n// toward the \"images attached\" notice.\nconst getImageAttachmentIds = ( mediaItems ) => [\n\t...new Set(\n\t\t( Array.isArray( mediaItems ) ? mediaItems : [ mediaItems ] )\n\t\t\t.filter(\n\t\t\t\t( mediaItem ) => getMediaItemType( mediaItem ) === 'image'\n\t\t\t)\n\t\t\t.map( ( mediaItem ) => mediaItem?.id )\n\t\t\t.filter( Boolean )\n\t),\n];\n\nconst invalidateAttachedImagesQueries = ( postId, query = {} ) => {\n\tconst { invalidateResolution } = dispatch( coreStore );\n\t// Invalidate the resolution backing the visible grid so it refetches after\n\t// an attach/detach and reflects the updated set of attached images. The tab\n\t// is always shown (via `emptyMessage`), so there's no separate visibility\n\t// probe to invalidate.\n\tinvalidateResolution( 'getEntityRecords', [\n\t\t'postType',\n\t\t'attachment',\n\t\tgetCoreMediaQuery( getAttachedImagesQuery( postId, query ) ),\n\t] );\n};\n\n/**\n * Builds the \"Attachments\" media category for a given post. It behaves like\n * any other inserter media source (e.g. Openverse): it appears in the tab list\n * and renders through the shared media panel. In addition to `fetch`, it exposes\n * optional `attach`/`detach`/`invalidate` capabilities that the shared panel\n * picks up to offer an \"Attach images\" button and a per-item \"Detach from post\"\n * action in the same dropdown Openverse uses for \"Report image\".\n *\n * @param {number} postId The current post id.\n * @param {string|null} [typeLabel] The post type's singular label to use in copy (e.g. \"Page\"),\n * or null to fall back to the generic \"post\".\n * @return {InserterMediaCategory} The Attachments media category.\n */\nconst getAttachedImagesCategory = ( postId, typeLabel ) => ( {\n\tname: 'attached-images',\n\tlabels: {\n\t\tname: __( 'Attached images' ),\n\t\tsearch_items: __( 'Search attachments' ),\n\t},\n\tmediaType: 'image',\n\t// The post type's singular label (e.g. \"Page\"), threaded through so the\n\t// shared panel can word its attach/detach copy for the current post type.\n\tpostTypeLabel: typeLabel,\n\t// Empty-state message. Providing this also keeps the source in the tab list\n\t// when it has no items, so it stays discoverable and the first image can be\n\t// attached even with none yet.\n\temptyMessage: typeLabel\n\t\t? sprintf(\n\t\t\t\t// translators: %s: Name of the post type e.g: \"Page\".\n\t\t\t\t__( 'No images attached to this %s.' ),\n\t\t\t\ttypeLabel\n\t\t )\n\t\t: __( 'No images attached to this post.' ),\n\tasync fetch( query = {} ) {\n\t\treturn coreMediaFetch( getAttachedImagesQuery( postId, query ) );\n\t},\n\tasync attach( mediaItems ) {\n\t\tconst attachmentIds = getImageAttachmentIds( mediaItems );\n\n\t\tawait Promise.all(\n\t\t\tattachmentIds.map( ( attachmentId ) =>\n\t\t\t\tsaveAttachmentParent( attachmentId, postId )\n\t\t\t)\n\t\t);\n\n\t\treturn attachmentIds.length;\n\t},\n\tasync detach( mediaItem ) {\n\t\tawait saveAttachmentParent( mediaItem.id, 0 );\n\t},\n\tinvalidate( query = {} ) {\n\t\tinvalidateAttachedImagesQueries( postId, query );\n\t},\n} );\n\n/** @type {InserterMediaCategory[]} */\nconst inserterMediaCategories = [\n\t{\n\t\tname: 'images',\n\t\tlabels: {\n\t\t\tname: __( 'Images' ),\n\t\t\tsearch_items: __( 'Search images' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'image' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'videos',\n\t\tlabels: {\n\t\t\tname: __( 'Videos' ),\n\t\t\tsearch_items: __( 'Search videos' ),\n\t\t},\n\t\tmediaType: 'video',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'video' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'audio',\n\t\tlabels: {\n\t\t\tname: __( 'Audio' ),\n\t\t\tsearch_items: __( 'Search audio' ),\n\t\t},\n\t\tmediaType: 'audio',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'audio' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'openverse',\n\t\tlabels: {\n\t\t\tname: __( 'Openverse' ),\n\t\t\tsearch_items: __( 'Search Openverse' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\tconst defaultArgs = {\n\t\t\t\tmature: false,\n\t\t\t\texcluded_source: 'flickr,inaturalist,wikimedia',\n\t\t\t\tlicense: 'pdm,cc0',\n\t\t\t};\n\t\t\tconst finalQuery = { ...query, ...defaultArgs };\n\t\t\tconst mapFromInserterMediaRequest = {\n\t\t\t\tper_page: 'page_size',\n\t\t\t\tsearch: 'q',\n\t\t\t};\n\t\t\tconst url = new URL( 'https://api.openverse.org/v1/images/' );\n\t\t\tObject.entries( finalQuery ).forEach( ( [ key, value ] ) => {\n\t\t\t\tconst queryKey = mapFromInserterMediaRequest[ key ] || key;\n\t\t\t\turl.searchParams.set( queryKey, value );\n\t\t\t} );\n\t\t\tconst response = await window.fetch( url, {\n\t\t\t\theaders: {\n\t\t\t\t\t'User-Agent': 'WordPress/inserter-media-fetch',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst jsonResponse = await response.json();\n\t\t\tconst results = jsonResponse.results;\n\t\t\treturn results.map( ( result ) => ( {\n\t\t\t\t...result,\n\t\t\t\t// This is a temp solution for better titles, until Openverse API\n\t\t\t\t// completes the cleaning up of some titles of their upstream data.\n\t\t\t\ttitle: result.title?.toLowerCase().startsWith( 'file:' )\n\t\t\t\t\t? result.title.slice( 5 )\n\t\t\t\t\t: result.title,\n\t\t\t\tsourceId: result.id,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: getOpenverseCaption( result ),\n\t\t\t\tpreviewUrl: result.thumbnail,\n\t\t\t} ) );\n\t\t},\n\t\tgetReportUrl: ( { sourceId } ) =>\n\t\t\t`https://wordpress.org/openverse/image/${ sourceId }/report/`,\n\t\tisExternalResource: true,\n\t},\n];\n\n/**\n * Returns the inserter media categories for a given post. The \"Attachments\"\n * category is prepended only when editing real, front-end-rendered content\n * (posts, pages, public custom post types). It is omitted for synced patterns,\n * navigation menus and templates, which aren't the entity that actually gets\n * rendered, so attaching media to them is meaningless.\n *\n * @param {number|string} postId The current post id.\n * @param {string} [viewablePostTypeLabel] Singular label of the post type, set only when it is front-end viewable (post, page, public CPT).\n * @return {InserterMediaCategory[]} The inserter media categories.\n */\nexport default function getInserterMediaCategories(\n\tpostId,\n\tviewablePostTypeLabel\n) {\n\tconst currentPostId = normalizePostId( postId );\n\n\t// A falsy label means either a non-viewable post type (synced pattern,\n\t// navigation, template) or that the record hasn't resolved yet — in both\n\t// cases the category is omitted. A numeric id is also required since it\n\t// backs the attachment `parent` query.\n\tif ( ! currentPostId || ! viewablePostTypeLabel ) {\n\t\treturn inserterMediaCategories;\n\t}\n\n\treturn [\n\t\tgetAttachedImagesCategory( currentPostId, viewablePostTypeLabel ),\n\t\t...inserterMediaCategories,\n\t];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,kBAAgC;AAChC,kBAAwC;AACxC,2BAA+B;AAK/B,uBAAmC;AAMnC,IAAM,kBAAkB,CAAE,KAAK,SAC9B,MAAO,0BAA2B,GAAI,CAAE,IAAK,IAAK;AAEnD,IAAM,4BAA4B,CAAE,QACnC,SAAU,GAAI;AAEf,IAAM,sBAAsB,CAAE,SAAS,mBAAoB;AAC1D,MAAI,cAAc,QAAQ,KAAK;AAE/B,MAAK,YAAY,OAAQ;AACxB,kBAAc,QAAQ,YAAY,EAAE,QAAS,YAAY,UAAW;AAAA,EACrE;AAIA,MAAK,gBAAiB;AACrB,mBAAe,IAAK,cAAe;AAAA,EACpC;AAEA,MAAK,CAAE,CAAE,OAAO,KAAM,EAAE,SAAU,OAAQ,GAAI;AAC7C,kBAAc,MAAO,WAAY;AAAA,EAClC;AACA,SAAO;AACR;AAEA,IAAM,sBAAsB,CAAE,SAAU;AACvC,QAAM;AAAA,IACL;AAAA,IACA,qBAAqB;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AAE,YAAc;AAAA,QACnC,GAAG;AAAA;AAAA;AAAA,QAGH,OAAO,OAAO,OAAO,YAAY,EAAE,WAAY,OAAQ,IACpD,OAAO,MAAM,MAAO,CAAE,IACtB,OAAO;AAAA,QACV,UAAU,OAAO;AAAA,QACjB,IAAI;AAAA,QACJ,SAAS,oBAAqB,MAAO;AAAA,QACrC,YAAY,OAAO;AAAA,MACpB,EAAI;AAAA,IACL;AAAA,IACA,cAAc,CAAE,EAAE,SAAS,MAC1B,yCAA0C,QAAS;AAAA,IACpD,oBAAoB;AAAA,EACrB;AACD;AAae,SAAR,2BACN,QACA,uBACC;AACD,QAAM,gBAAgB,gBAAiB,MAAO;AAM9C,MAAK,CAAE,iBAAiB,CAAE,uBAAwB;AACjD,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,0BAA2B,eAAe,qBAAsB;AAAA,IAChE,GAAG;AAAA,EACJ;AACD;",
|
|
6
6
|
"names": ["coreStore"]
|
|
7
7
|
}
|
|
@@ -167,7 +167,6 @@ function PageAttributesParent() {
|
|
|
167
167
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
168
|
import_components.ComboboxControl,
|
|
169
169
|
{
|
|
170
|
-
__next40pxDefaultSize: true,
|
|
171
170
|
className: "editor-page-attributes__parent",
|
|
172
171
|
label: (0, import_i18n.__)("Parent"),
|
|
173
172
|
help: (0, import_i18n.__)("Choose a parent page."),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-attributes/parent.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( '' );\n\tconst {\n\t\tisHierarchical,\n\t\tparentPostId,\n\t\tparentPostTitle,\n\t\tpageItems,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetPostType,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tisResolving,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t\tquery.orderby = 'relevance';\n\t\t\t\tquery.search_columns = [ 'post_title' ];\n\t\t\t}\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: null,\n\t\t\t\tisLoading: postIsHierarchical\n\t\t\t\t\t? isResolving( 'getEntityRecords', [\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t ] )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA0B;AAK1B,kBAA4B;AAC5B,wBAKO;AACP,qBAAyB;AACzB,qBAIO;AACP,kBAAuC;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;AAGJ,QAAK,CAAE,YAAa;AACnB,iBAAO,6BAAgB,IAAK;AAAA,IAC7B;AAEA,UAAM,OAAO,mBAAoB,IAAK;AAGtC,UAAM,gBAAgB,KAAK;AAAA,MAC1B,CAAE,SAAU,KAAK,UAAU;AAAA,IAC5B;AACA,QAAK,mBAAmB,CAAE,eAAgB;AACzC,WAAK,QAAS;AAAA,QACb,OAAO;AAAA,QACP,OAAO;AAAA,MACR,CAAE;AAAA,IACH;AACA,WAAO;AAAA,EACR,GAAG,CAAE,WAAW,YAAY,iBAAiB,YAAa,CAAE;AAE5D,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAMA,QAAM,gBAAgB,CAAE,eAAgB;AACvC,kBAAe,UAAW;AAAA,EAC3B;AAOA,QAAM,eAAe,CAAE,mBAAoB;AAC1C,aAAU,EAAE,QAAQ,eAAe,CAAE;AAAA,EACtC;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( '' );\n\tconst {\n\t\tisHierarchical,\n\t\tparentPostId,\n\t\tparentPostTitle,\n\t\tpageItems,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetPostType,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tisResolving,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t\tquery.orderby = 'relevance';\n\t\t\t\tquery.search_columns = [ 'post_title' ];\n\t\t\t}\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: null,\n\t\t\t\tisLoading: postIsHierarchical\n\t\t\t\t\t? isResolving( 'getEntityRecords', [\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t ] )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-parent__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Current post parent.\n\t\t\t\tsprintf( __( 'Change parent: %s' ), parentTitle )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ parentTitle }\n\t\t</Button>\n\t);\n}\n\nexport function ParentRow() {\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostPanelRow label={ __( 'Parent' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"editor-post-parent__panel-dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-parent__panel-dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostParentToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<div className=\"editor-post-parent\">\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Parent' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t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,eAAgB,CAAE,EAAE,QAAQ,MAC3B,6CAAC,SAAI,WAAU,sBACd;AAAA;AAAA,UAAC,oBAAAC;AAAA,UAAA;AAAA,YACA,WAAQ,gBAAI,QAAS;AAAA,YACrB;AAAA;AAAA,QACD;AAAA,QACA,6CAAC,SACE;AAAA;AAAA,gBACD;AAAA;AAAA,kBAEC;AAAA,gBACC;AAAA,cACD;AAAA,kBACA,gCAAqB,OAAQ,EAAE;AAAA,gBAC9B;AAAA,gBACA;AAAA,cACD;AAAA,YACD;AAAA,YACA;AAAA,cACC,KAAK,4CAAC,SAAI;AAAA,YACX;AAAA,UACD;AAAA,UACA,4CAAC,OACE;AAAA,gBACD;AAAA,cACC;AAAA,YACD;AAAA,YACA;AAAA,cACC,GACC;AAAA,gBAAC;AAAA;AAAA,kBACA,UAAO;AAAA,oBACN;AAAA,kBACD;AAAA;AAAA,cACD;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,4CAAC,wBAAqB;AAAA,SACvB;AAAA;AAAA,EAEF,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": ["removeAccents", "editorStore", "coreStore", "tree", "PostPanelRow", "InspectorPopoverHeader"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-author/combobox.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions, isLoading } =\n\t\tuseAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,qBAAyB;AACzB,kBAA4B;AAC5B,kBAAmB;AACnB,wBAAgC;AAKhC,mBAAqC;AACrC,kBAAgC;AAsB9B;AApBa,SAAR,qBAAsC;AAC5C,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAS;AAE/C,QAAM,EAAE,SAAS,QAAI,yBAAa,aAAAA,KAAY;AAC9C,QAAM,EAAE,UAAU,eAAe,UAAU,QAC1C,6BAAiB,UAAW;AAO7B,QAAM,eAAe,CAAE,iBAAkB;AACxC,QAAK,CAAE,cAAe;AACrB;AAAA,IACD;AACA,aAAU,EAAE,QAAQ,aAAa,CAAE;AAAA,EACpC;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions, isLoading } =\n\t\tuseAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( setFieldValue, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tallowReset={ false }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,qBAAyB;AACzB,kBAA4B;AAC5B,kBAAmB;AACnB,wBAAgC;AAKhC,mBAAqC;AACrC,kBAAgC;AAsB9B;AApBa,SAAR,qBAAsC;AAC5C,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAS;AAE/C,QAAM,EAAE,SAAS,QAAI,yBAAa,aAAAA,KAAY;AAC9C,QAAM,EAAE,UAAU,eAAe,UAAU,QAC1C,6BAAiB,UAAW;AAO7B,QAAM,eAAe,CAAE,iBAAkB;AACxC,QAAK,CAAE,cAAe;AACrB;AAAA,IACD;AACA,aAAU,EAAE,QAAQ,aAAa,CAAE;AAAA,EACpC;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ,gBAAI,QAAS;AAAA,MACrB,SAAU;AAAA,MACV,OAAQ;AAAA,MACR,yBAAsB,yBAAU,eAAe,GAAI;AAAA,MACnD,UAAW;AAAA,MACX,YAAa;AAAA,MACb,qBAAmB;AAAA,MACnB;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["editorStore"]
|
|
7
7
|
}
|
|
@@ -39,7 +39,6 @@ function PostAuthorSelect() {
|
|
|
39
39
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40
40
|
import_components.SelectControl,
|
|
41
41
|
{
|
|
42
|
-
__next40pxDefaultSize: true,
|
|
43
42
|
className: "post-author-selector",
|
|
44
43
|
label: (0, import_i18n.__)("Author"),
|
|
45
44
|
options: authorOptions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-author/select.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { SelectControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery();\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,kBAA4B;AAC5B,wBAA8B;AAK9B,mBAAqC;AACrC,kBAAgC;AAY9B;AAVa,SAAR,mBAAoC;AAC1C,QAAM,EAAE,SAAS,QAAI,yBAAa,aAAAA,KAAY;AAC9C,QAAM,EAAE,UAAU,cAAc,QAAI,6BAAgB;AAEpD,QAAM,cAAc,CAAE,UAAW;AAChC,UAAM,SAAS,OAAQ,KAAM;AAC7B,aAAU,EAAE,OAAO,CAAE;AAAA,EACtB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { SelectControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery();\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ authorId }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,kBAA4B;AAC5B,wBAA8B;AAK9B,mBAAqC;AACrC,kBAAgC;AAY9B;AAVa,SAAR,mBAAoC;AAC1C,QAAM,EAAE,SAAS,QAAI,yBAAa,aAAAA,KAAY;AAC9C,QAAM,EAAE,UAAU,cAAc,QAAI,6BAAgB;AAEpD,QAAM,cAAc,CAAE,UAAW;AAChC,UAAM,SAAS,OAAQ,KAAM;AAC7B,aAAU,EAAE,OAAO,CAAE;AAAA,EACtB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,WAAQ,gBAAI,QAAS;AAAA,MACrB,SAAU;AAAA,MACV,UAAW;AAAA,MACX,OAAQ;AAAA,MACR,qBAAmB;AAAA;AAAA,EACpB;AAEF;",
|
|
6
6
|
"names": ["editorStore"]
|
|
7
7
|
}
|
|
@@ -32,7 +32,7 @@ var import_core_data = require("@wordpress/core-data");
|
|
|
32
32
|
var import_ui = require("@wordpress/ui");
|
|
33
33
|
var import_store = require("../../store/index.cjs");
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
function
|
|
35
|
+
function buildInterstitialMarkup() {
|
|
36
36
|
let markup = (0, import_element.renderToString)(
|
|
37
37
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "editor-post-preview-button__interstitial-message", children: [
|
|
38
38
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 96 96", children: [
|
|
@@ -111,10 +111,37 @@ function writeInterstitialMessage(targetDocument) {
|
|
|
111
111
|
</style>
|
|
112
112
|
`;
|
|
113
113
|
markup = (0, import_hooks.applyFilters)("editor.PostPreview.interstitialMarkup", markup);
|
|
114
|
+
return markup;
|
|
115
|
+
}
|
|
116
|
+
function writeInterstitialMessage(targetDocument, markup) {
|
|
114
117
|
targetDocument.write(markup);
|
|
115
118
|
targetDocument.title = (0, import_i18n.__)("Generating preview…");
|
|
116
119
|
targetDocument.close();
|
|
117
120
|
}
|
|
121
|
+
async function getPreviewDocument(previewWindow) {
|
|
122
|
+
try {
|
|
123
|
+
return previewWindow.document;
|
|
124
|
+
} catch {
|
|
125
|
+
}
|
|
126
|
+
previewWindow.location = "about:blank";
|
|
127
|
+
const timeoutMs = 1e3;
|
|
128
|
+
const intervalMs = 50;
|
|
129
|
+
const deadline = Date.now() + timeoutMs;
|
|
130
|
+
do {
|
|
131
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
132
|
+
try {
|
|
133
|
+
return previewWindow.document;
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
} while (Date.now() < deadline);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
async function writeInterstitialIntoPreviewWindow(previewWindow) {
|
|
140
|
+
const previewDocument = await getPreviewDocument(previewWindow);
|
|
141
|
+
if (previewDocument) {
|
|
142
|
+
writeInterstitialMessage(previewDocument, buildInterstitialMarkup());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
118
145
|
function PostPreviewButton({
|
|
119
146
|
className,
|
|
120
147
|
textContent,
|
|
@@ -149,7 +176,7 @@ function PostPreviewButton({
|
|
|
149
176
|
event.preventDefault();
|
|
150
177
|
const previewWindow = window.open("", targetId);
|
|
151
178
|
previewWindow.focus();
|
|
152
|
-
|
|
179
|
+
await writeInterstitialIntoPreviewWindow(previewWindow);
|
|
153
180
|
const link = await __unstableSaveForPreview({ forceIsAutosaveable });
|
|
154
181
|
previewWindow.location = link;
|
|
155
182
|
onPreview?.();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-preview-button/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport { Button, Path, SVG } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA+B;AAC/B,wBAAkC;AAClC,kBAAuB;AACvB,kBAAuC;AACvC,mBAA6B;AAC7B,uBAAmC;AACnC,gBAA+B;AAK/B,mBAAqC;AAKlC;AAHH,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport { Button, Path, SVG } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction buildInterstitialMarkup() {\n\tlet markup = renderToString(\n\t\t<div className=\"editor-post-preview-button__interstitial-message\">\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\">\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"outer\"\n\t\t\t\t\td=\"M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"inner\"\n\t\t\t\t\td=\"M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t</SVG>\n\t\t\t<p>{ __( 'Generating preview…' ) }</p>\n\t\t</div>\n\t);\n\n\tmarkup += `\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t`;\n\n\t/**\n\t * Filters the interstitial message shown when generating previews.\n\t *\n\t * @param {string} markup The preview interstitial markup.\n\t */\n\tmarkup = applyFilters( 'editor.PostPreview.interstitialMarkup', markup );\n\n\treturn markup;\n}\n\nfunction writeInterstitialMessage( targetDocument, markup ) {\n\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\n}\n\n/**\n * Resolves the preview window's `document`, working around\n * `Document-Isolation-Policy` (DIP) isolation.\n *\n * The editor screen is served with `Document-Isolation-Policy:\n * isolate-and-credentialless` to enable cross-origin isolation. This places the\n * editor tab and an already-open preview tab in separate agent clusters, so\n * synchronous access to a reused preview tab's `document` throws a\n * `SecurityError`. Navigating the reused tab back to `about:blank` returns it to\n * the opener's agent cluster and restores access. That navigation is\n * asynchronous and we can't attach a cross-isolation `load` listener, so poll\n * the `document` access (the operation that throws) until it succeeds, up to a\n * short timeout.\n *\n * @param {Window} previewWindow The preview window/tab.\n *\n * @return {?Document} The reachable preview document, or `null` if it never\n * becomes reachable within the timeout.\n */\nasync function getPreviewDocument( previewWindow ) {\n\t// A freshly opened tab is already on `about:blank` and accessible, so this\n\t// succeeds on the first preview without any reset.\n\ttry {\n\t\treturn previewWindow.document;\n\t} catch {\n\t\t// The reused preview tab is isolated from the editor; reset it below.\n\t}\n\n\tpreviewWindow.location = 'about:blank';\n\n\tconst timeoutMs = 1000;\n\tconst intervalMs = 50;\n\tconst deadline = Date.now() + timeoutMs;\n\tdo {\n\t\tawait new Promise( ( resolve ) => setTimeout( resolve, intervalMs ) );\n\t\ttry {\n\t\t\treturn previewWindow.document;\n\t\t} catch {\n\t\t\t// Navigation to `about:blank` hasn't completed yet; keep polling.\n\t\t}\n\t} while ( Date.now() < deadline );\n\n\treturn null;\n}\n\n/**\n * Writes the preview interstitial into the preview window, working around\n * `Document-Isolation-Policy` (DIP) isolation.\n *\n * The interstitial is a progressive enhancement: if the document never becomes\n * reachable we simply skip it, and the caller still navigates the preview to the\n * real content.\n *\n * @param {Window} previewWindow The preview window/tab.\n */\nasync function writeInterstitialIntoPreviewWindow( previewWindow ) {\n\tconst previewDocument = await getPreviewDocument( previewWindow );\n\tif ( previewDocument ) {\n\t\twriteInterstitialMessage( previewDocument, buildInterstitialMarkup() );\n\t}\n}\n\n/**\n * Renders a button that opens a new window or tab for the preview,\n * writes the interstitial message to this window, and then navigates\n * to the actual preview link. The button is not rendered if the post\n * is not viewable and disabled if the post is not saveable.\n *\n * @param {Object} props The component props.\n * @param {string} props.className The class name for the button.\n * @param {string} props.textContent The text content for the button.\n * @param {boolean} props.forceIsAutosaveable Whether to force autosave.\n * @param {string} props.role The role attribute for the button.\n * @param {Function} props.onPreview The callback function for preview event.\n *\n * @return {React.ReactNode} The rendered button component.\n */\nexport default function PostPreviewButton( {\n\tclassName,\n\ttextContent,\n\tforceIsAutosaveable,\n\trole,\n\tonPreview,\n} ) {\n\tconst { postId, currentPostLink, previewLink, isSaveable, isViewable } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst editor = select( editorStore );\n\t\t\tconst core = select( coreStore );\n\n\t\t\tconst postType = core.getPostType(\n\t\t\t\teditor.getCurrentPostType( 'type' )\n\t\t\t);\n\t\t\tconst canView = postType?.viewable ?? false;\n\t\t\tif ( ! canView ) {\n\t\t\t\treturn { isViewable: canView };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tpostId: editor.getCurrentPostId(),\n\t\t\t\tcurrentPostLink: editor.getCurrentPostAttribute( 'link' ),\n\t\t\t\tpreviewLink: editor.getEditedPostPreviewLink(),\n\t\t\t\tisSaveable: editor.isEditedPostSaveable(),\n\t\t\t\tisViewable: canView,\n\t\t\t};\n\t\t}, [] );\n\n\tconst { __unstableSaveForPreview } = useDispatch( editorStore );\n\n\tif ( ! isViewable ) {\n\t\treturn null;\n\t}\n\n\tconst targetId = `wp-preview-${ postId }`;\n\n\tconst openPreviewWindow = async ( event ) => {\n\t\t// Our Preview button has its 'href' and 'target' set correctly for a11y\n\t\t// purposes. Unfortunately, though, we can't rely on the default 'click'\n\t\t// handler since sometimes it incorrectly opens a new tab instead of reusing\n\t\t// the existing one.\n\t\t// https://github.com/WordPress/gutenberg/pull/8330\n\t\tevent.preventDefault();\n\n\t\t// Open up a Preview tab if needed. This is where we'll show the preview.\n\t\tconst previewWindow = window.open( '', targetId );\n\n\t\t// Focus the Preview tab. This might not do anything, depending on the browser's\n\t\t// and user's preferences.\n\t\t// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus\n\t\tpreviewWindow.focus();\n\n\t\tawait writeInterstitialIntoPreviewWindow( previewWindow );\n\n\t\tconst link = await __unstableSaveForPreview( { forceIsAutosaveable } );\n\n\t\tpreviewWindow.location = link;\n\n\t\tonPreview?.();\n\t};\n\n\t// Link to the `?preview=true` URL if we have it, since this lets us see\n\t// changes that were autosaved since the post was last published. Otherwise,\n\t// just link to the post's URL.\n\tconst href = previewLink || currentPostLink;\n\n\treturn (\n\t\t<Button\n\t\t\tvariant={ ! className ? 'tertiary' : undefined }\n\t\t\tclassName={ className || 'editor-post-preview' }\n\t\t\thref={ href }\n\t\t\ttarget={ targetId }\n\t\t\taccessibleWhenDisabled\n\t\t\tdisabled={ ! isSaveable }\n\t\t\tonClick={ openPreviewWindow }\n\t\t\trole={ role }\n\t\t\tsize=\"compact\"\n\t\t>\n\t\t\t{ textContent || (\n\t\t\t\t<>\n\t\t\t\t\t{ _x( 'Preview', 'imperative verb' ) }\n\t\t\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Button>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA+B;AAC/B,wBAAkC;AAClC,kBAAuB;AACvB,kBAAuC;AACvC,mBAA6B;AAC7B,uBAAmC;AACnC,gBAA+B;AAK/B,mBAAqC;AAKlC;AAHH,SAAS,0BAA0B;AAClC,MAAI,aAAS;AAAA,IACZ,6CAAC,SAAI,WAAU,oDACd;AAAA,mDAAC,yBAAI,OAAM,8BAA6B,SAAQ,aAC/C;AAAA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACN;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA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UAAK;AAAA;AAAA,UAG7B,8BAAI,sBAAuB;AAAA,SAE7B;AAAA,SACD;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": ["editorStore", "coreStore"]
|
|
7
7
|
}
|
|
@@ -28,9 +28,9 @@ var import_data = require("@wordpress/data");
|
|
|
28
28
|
var import_i18n = require("@wordpress/i18n");
|
|
29
29
|
var import_block_editor = require("@wordpress/block-editor");
|
|
30
30
|
var import_element = require("@wordpress/element");
|
|
31
|
-
var
|
|
32
|
-
var import_media_util = require("./media-util.cjs");
|
|
31
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
33
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var { mediaSideloadFromUrlKey } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
34
34
|
function flattenBlocks(blocks) {
|
|
35
35
|
const result = [];
|
|
36
36
|
blocks.forEach((block) => {
|
|
@@ -96,10 +96,10 @@ function MaybeUploadMediaPanel() {
|
|
|
96
96
|
const [isUploading, setIsUploading] = (0, import_element.useState)(false);
|
|
97
97
|
const [isAnimating, setIsAnimating] = (0, import_element.useState)(false);
|
|
98
98
|
const [hadUploadError, setHadUploadError] = (0, import_element.useState)(false);
|
|
99
|
-
const { editorBlocks,
|
|
99
|
+
const { editorBlocks, mediaSideloadFromUrl } = (0, import_data.useSelect)(
|
|
100
100
|
(select) => ({
|
|
101
101
|
editorBlocks: select(import_block_editor.store).getBlocks(),
|
|
102
|
-
|
|
102
|
+
mediaSideloadFromUrl: select(import_block_editor.store).getSettings()[mediaSideloadFromUrlKey]
|
|
103
103
|
}),
|
|
104
104
|
[]
|
|
105
105
|
);
|
|
@@ -107,7 +107,7 @@ function MaybeUploadMediaPanel() {
|
|
|
107
107
|
(block) => hasExternalMedia(block)
|
|
108
108
|
);
|
|
109
109
|
const { updateBlockAttributes } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
110
|
-
if (!
|
|
110
|
+
if (!mediaSideloadFromUrl || !blocksWithExternalMedia.length) {
|
|
111
111
|
return null;
|
|
112
112
|
}
|
|
113
113
|
const panelBodyTitle = [
|
|
@@ -138,27 +138,16 @@ function MaybeUploadMediaPanel() {
|
|
|
138
138
|
})
|
|
139
139
|
);
|
|
140
140
|
const uploadPromises = Object.fromEntries(
|
|
141
|
-
|
|
142
|
-
(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
resolve(media);
|
|
152
|
-
},
|
|
153
|
-
onError() {
|
|
154
|
-
reject();
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
return [url, uploadPromise];
|
|
160
|
-
}
|
|
161
|
-
)
|
|
141
|
+
[...mediaUrls].map((url) => {
|
|
142
|
+
const uploadPromise = new Promise((resolve, reject) => {
|
|
143
|
+
mediaSideloadFromUrl({
|
|
144
|
+
url,
|
|
145
|
+
onSuccess: (media) => resolve(media),
|
|
146
|
+
onError: () => reject()
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
return [url, uploadPromise];
|
|
150
|
+
})
|
|
162
151
|
);
|
|
163
152
|
Promise.allSettled(
|
|
164
153
|
blocksWithExternalMedia.map((block) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-publish-panel/maybe-upload-media.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\tSpinner,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAMO;AACP,kBAAuC;AACvC,kBAAuB;AACvB,
|
|
6
|
-
"names": ["blockEditorStore", "motion", "AnimatePresence"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\tSpinner,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { mediaSideloadFromUrlKey } = unlock( blockEditorPrivateApis );\n\nfunction flattenBlocks( blocks ) {\n\tconst result = [];\n\n\tblocks.forEach( ( block ) => {\n\t\tresult.push( block );\n\t\tresult.push( ...flattenBlocks( block.innerBlocks ) );\n\t} );\n\n\treturn result;\n}\n\n/**\n * Determine whether a block has external media.\n *\n * Different blocks use different attribute names (and potentially\n * different logic as well) in determining whether the media is\n * present, and whether it's external.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {boolean?} Whether the block has external media\n */\nfunction hasExternalMedia( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\treturn block.attributes.url && ! block.attributes.id;\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\treturn block.attributes.mediaUrl && ! block.attributes.mediaId;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Retrieve media info from a block.\n *\n * Different blocks use different attribute names, so we need this\n * function to normalize things into a consistent naming scheme.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.\n */\nfunction getMediaInfo( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\tconst { url, alt, id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\tconst { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\treturn {};\n}\n\n// Image component to represent a single image in the upload dialog.\nfunction Image( { clientId, alt, url } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn (\n\t\t<motion.img\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\taria-label={ __( 'Select image block.' ) }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tkey={ clientId }\n\t\t\talt={ alt }\n\t\t\tsrc={ url }\n\t\t\tanimate={ { opacity: 1 } }\n\t\t\texit={ { opacity: 0, scale: 0 } }\n\t\t\tstyle={ {\n\t\t\t\twidth: '32px',\n\t\t\t\theight: '32px',\n\t\t\t\tobjectFit: 'cover',\n\t\t\t\tborderRadius: '2px',\n\t\t\t\tcursor: 'var(--wpds-cursor-control, pointer)',\n\t\t\t} }\n\t\t\twhileHover={ { scale: 1.08 } }\n\t\t/>\n\t);\n}\n\nexport default function MaybeUploadMediaPanel() {\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst [ isAnimating, setIsAnimating ] = useState( false );\n\tconst [ hadUploadError, setHadUploadError ] = useState( false );\n\tconst { editorBlocks, mediaSideloadFromUrl } = useSelect(\n\t\t( select ) => ( {\n\t\t\teditorBlocks: select( blockEditorStore ).getBlocks(),\n\t\t\tmediaSideloadFromUrl:\n\t\t\t\tselect( blockEditorStore ).getSettings()[\n\t\t\t\t\tmediaSideloadFromUrlKey\n\t\t\t\t],\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Get a list of blocks with external media.\n\tconst blocksWithExternalMedia = flattenBlocks( editorBlocks ).filter(\n\t\t( block ) => hasExternalMedia( block )\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tif ( ! mediaSideloadFromUrl || ! blocksWithExternalMedia.length ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'External media' ) }\n\t\t</span>,\n\t];\n\n\t/**\n\t * Update an individual block to point to newly-added library media.\n\t *\n\t * Different blocks use different attribute names, so we need this\n\t * function to ensure we modify the correct attributes for each type.\n\t *\n\t * @param {{name: string, attributes: Object}} block The block.\n\t * @param {{id: number, url: string}} media Media library file info.\n\t */\n\tfunction updateBlockWithUploadedMedia( block, media ) {\n\t\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tid: media.id,\n\t\t\t\turl: media.url,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block.name === 'core/media-text' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tmediaId: media.id,\n\t\t\t\tmediaUrl: media.url,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle fetching and uploading all external media in the post.\n\tfunction uploadImages() {\n\t\tsetIsUploading( true );\n\t\tsetHadUploadError( false );\n\n\t\t// Multiple blocks can be using the same URL, so we\n\t\t// should ensure we only fetch and upload each of them once.\n\t\tconst mediaUrls = new Set(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\t\t\t\treturn url;\n\t\t\t} )\n\t\t);\n\n\t\t// Create an upload promise for each URL, that we can wait for in all\n\t\t// blocks that make use of that media. The server sideloads each URL,\n\t\t// so this works even when the editor is cross-origin isolated.\n\t\tconst uploadPromises = Object.fromEntries(\n\t\t\t[ ...mediaUrls ].map( ( url ) => {\n\t\t\t\tconst uploadPromise = new Promise( ( resolve, reject ) => {\n\t\t\t\t\tmediaSideloadFromUrl( {\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tonSuccess: ( media ) => resolve( media ),\n\t\t\t\t\t\tonError: () => reject(),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn [ url, uploadPromise ];\n\t\t\t} )\n\t\t);\n\n\t\t// Wait for all blocks to be updated with library media.\n\t\tPromise.allSettled(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\n\t\t\t\treturn uploadPromises[ url ]\n\t\t\t\t\t.then( ( media ) =>\n\t\t\t\t\t\tupdateBlockWithUploadedMedia( block, media )\n\t\t\t\t\t)\n\t\t\t\t\t.then( () => setIsAnimating( true ) )\n\t\t\t\t\t.catch( () => setHadUploadError( true ) );\n\t\t\t} )\n\t\t).finally( () => {\n\t\t\tsetIsUploading( false );\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\tgap: '8px',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<AnimatePresence\n\t\t\t\t\tonExitComplete={ () => setIsAnimating( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ blocksWithExternalMedia.map( ( block ) => {\n\t\t\t\t\t\tconst { url, alt } = getMediaInfo( block );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\tkey={ block.clientId }\n\t\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</AnimatePresence>\n\t\t\t\t{ isUploading || isAnimating ? (\n\t\t\t\t\t<Spinner />\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ uploadImages }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Upload', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ hadUploadError && <p>{ __( 'Upload failed, try again.' ) }</p> }\n\t\t</PanelBody>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAMO;AACP,kBAAuC;AACvC,kBAAuB;AACvB,0BAGO;AACP,qBAAyB;AAKzB,yBAAuB;AAgErB;AA9DF,IAAM,EAAE,wBAAwB,QAAI,2BAAQ,oBAAAA,WAAuB;AAEnE,SAAS,cAAe,QAAS;AAChC,QAAM,SAAS,CAAC;AAEhB,SAAO,QAAS,CAAE,UAAW;AAC5B,WAAO,KAAM,KAAM;AACnB,WAAO,KAAM,GAAG,cAAe,MAAM,WAAY,CAAE;AAAA,EACpD,CAAE;AAEF,SAAO;AACR;AAYA,SAAS,iBAAkB,OAAQ;AAClC,MAAK,MAAM,SAAS,gBAAgB,MAAM,SAAS,cAAe;AACjE,WAAO,MAAM,WAAW,OAAO,CAAE,MAAM,WAAW;AAAA,EACnD;AAEA,MAAK,MAAM,SAAS,mBAAoB;AACvC,WAAO,MAAM,WAAW,YAAY,CAAE,MAAM,WAAW;AAAA,EACxD;AAEA,SAAO;AACR;AAWA,SAAS,aAAc,OAAQ;AAC9B,MAAK,MAAM,SAAS,gBAAgB,MAAM,SAAS,cAAe;AACjE,UAAM,EAAE,KAAK,KAAK,GAAG,IAAI,MAAM;AAC/B,WAAO,EAAE,KAAK,KAAK,GAAG;AAAA,EACvB;AAEA,MAAK,MAAM,SAAS,mBAAoB;AACvC,UA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var import_date = require("@wordpress/date");
|
|
|
31
31
|
var import_element = require("@wordpress/element");
|
|
32
32
|
var import_icons = require("@wordpress/icons");
|
|
33
33
|
var import_ui = require("@wordpress/ui");
|
|
34
|
+
var import_compose = require("@wordpress/compose");
|
|
34
35
|
var import_store = require("../../store/index.cjs");
|
|
35
36
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
36
37
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -71,6 +72,7 @@ function RevisionsSlider() {
|
|
|
71
72
|
const { setCurrentRevisionId, setRevisionPage } = (0, import_lock_unlock.unlock)(
|
|
72
73
|
(0, import_data.useDispatch)(import_store.store)
|
|
73
74
|
);
|
|
75
|
+
const focusOnMountRef = (0, import_compose.useFocusOnMount)(true);
|
|
74
76
|
const isLoading = !rawRevisions;
|
|
75
77
|
const totalPages = Math.ceil(totalRevisions / perPage) || 1;
|
|
76
78
|
const revisions = (0, import_element.useMemo)(
|
|
@@ -117,7 +119,7 @@ function RevisionsSlider() {
|
|
|
117
119
|
const sliderOrSpinner = isLoading || selectedIndex === -1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
120
|
import_components.RangeControl,
|
|
119
121
|
{
|
|
120
|
-
|
|
122
|
+
ref: focusOnMountRef,
|
|
121
123
|
"aria-valuetext": renderTooltipContent(selectedIndex),
|
|
122
124
|
className: "editor-revisions-header__slider",
|
|
123
125
|
hideLabelFromVision: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-preview/revisions-slider.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner, Button } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\nimport { useMemo } from '@wordpress/element';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions with pagination.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst {\n\t\trevisions: rawRevisions,\n\t\tperPage,\n\t\tcurrentRevisionId,\n\t\trevisionKey,\n\t\trevisionPage,\n\t\ttotalRevisions,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentRevisionId,\n\t\t\tgetRevisionPage,\n\t\t\tgetPageRevisions,\n\t\t\tgetRevisionsPerPage,\n\t\t} = unlock( select( editorStore ) );\n\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tif ( ! postType ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\tconst _revisionPage = getRevisionPage();\n\n\t\treturn {\n\t\t\trevisions: getPageRevisions( _revisionPage ),\n\t\t\tperPage: getRevisionsPerPage(),\n\t\t\tcurrentRevisionId: getCurrentRevisionId(),\n\t\t\trevisionKey: _revisionKey,\n\t\t\trevisionPage: _revisionPage,\n\t\t\ttotalRevisions:\n\t\t\t\tselect( editorStore ).getCurrentPostRevisionsCount(),\n\t\t};\n\t}, [] );\n\n\tconst { setCurrentRevisionId, setRevisionPage } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst isLoading = ! rawRevisions;\n\tconst totalPages = Math.ceil( totalRevisions / perPage ) || 1;\n\n\t// Reverse desc→asc so the slider reads oldest (left) → newest (right).\n\tconst revisions = useMemo(\n\t\t() => rawRevisions && [ ...rawRevisions ].reverse(),\n\t\t[ rawRevisions ]\n\t);\n\n\tconst selectedIndex = revisions?.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tconst showPagination = totalPages > 1;\n\n\tif ( isLoading && ! showPagination ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! isLoading && ! revisions?.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( totalRevisions <= 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tconst getPageRangeLabel = ( page ) => {\n\t\tconst end = totalRevisions - ( page - 1 ) * perPage;\n\t\tconst start = Math.max( 1, end - perPage + 1 );\n\t\treturn sprintf(\n\t\t\t/* translators: 1: first revision number, 2: last revision number */\n\t\t\t__( 'Revisions %1$s–%2$s' ),\n\t\t\tstart,\n\t\t\tend\n\t\t);\n\t};\n\n\tconst sliderOrSpinner =\n\t\tisLoading || selectedIndex === -1 ? (\n\t\t\t<Spinner />\n\t\t) : (\n\t\t\t<RangeControl\n\t\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,wBAA8C;AAC9C,uBAAmC;AACnC,kBAA4B;AAC5B,kBAAyD;AACzD,qBAAwB;AACxB,mBAA0C;AAC1C,gBAAsB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner, Button } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\nimport { useMemo } from '@wordpress/element';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { Stack } from '@wordpress/ui';\nimport { useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions with pagination.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst {\n\t\trevisions: rawRevisions,\n\t\tperPage,\n\t\tcurrentRevisionId,\n\t\trevisionKey,\n\t\trevisionPage,\n\t\ttotalRevisions,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentRevisionId,\n\t\t\tgetRevisionPage,\n\t\t\tgetPageRevisions,\n\t\t\tgetRevisionsPerPage,\n\t\t} = unlock( select( editorStore ) );\n\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tif ( ! postType ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\tconst _revisionPage = getRevisionPage();\n\n\t\treturn {\n\t\t\trevisions: getPageRevisions( _revisionPage ),\n\t\t\tperPage: getRevisionsPerPage(),\n\t\t\tcurrentRevisionId: getCurrentRevisionId(),\n\t\t\trevisionKey: _revisionKey,\n\t\t\trevisionPage: _revisionPage,\n\t\t\ttotalRevisions:\n\t\t\t\tselect( editorStore ).getCurrentPostRevisionsCount(),\n\t\t};\n\t}, [] );\n\n\tconst { setCurrentRevisionId, setRevisionPage } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst focusOnMountRef = useFocusOnMount( true );\n\n\tconst isLoading = ! rawRevisions;\n\tconst totalPages = Math.ceil( totalRevisions / perPage ) || 1;\n\n\t// Reverse desc→asc so the slider reads oldest (left) → newest (right).\n\tconst revisions = useMemo(\n\t\t() => rawRevisions && [ ...rawRevisions ].reverse(),\n\t\t[ rawRevisions ]\n\t);\n\n\tconst selectedIndex = revisions?.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tconst showPagination = totalPages > 1;\n\n\tif ( isLoading && ! showPagination ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! isLoading && ! revisions?.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( totalRevisions <= 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tconst getPageRangeLabel = ( page ) => {\n\t\tconst end = totalRevisions - ( page - 1 ) * perPage;\n\t\tconst start = Math.max( 1, end - perPage + 1 );\n\t\treturn sprintf(\n\t\t\t/* translators: 1: first revision number, 2: last revision number */\n\t\t\t__( 'Revisions %1$s–%2$s' ),\n\t\t\tstart,\n\t\t\tend\n\t\t);\n\t};\n\n\tconst sliderOrSpinner =\n\t\tisLoading || selectedIndex === -1 ? (\n\t\t\t<Spinner />\n\t\t) : (\n\t\t\t<RangeControl\n\t\t\t\tref={ focusOnMountRef }\n\t\t\t\taria-valuetext={ renderTooltipContent( selectedIndex ) }\n\t\t\t\tclassName=\"editor-revisions-header__slider\"\n\t\t\t\thideLabelFromVision\n\t\t\t\tlabel={ __( 'Revision' ) }\n\t\t\t\tmax={ revisions?.length - 1 }\n\t\t\t\tmin={ 0 }\n\t\t\t\tmarks\n\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\t\tvalue={ selectedIndex }\n\t\t\t\twithInputField={ false }\n\t\t\t/>\n\t\t);\n\n\tif ( ! showPagination ) {\n\t\treturn sliderOrSpinner;\n\t}\n\n\treturn (\n\t\t<Stack direction=\"row\" gap=\"sm\" align=\"center\" style={ { flex: 1 } }>\n\t\t\t<Button\n\t\t\t\ticon={ chevronLeft }\n\t\t\t\tlabel={\n\t\t\t\t\trevisionPage < totalPages\n\t\t\t\t\t\t? getPageRangeLabel( revisionPage + 1 )\n\t\t\t\t\t\t: __( 'No older revisions' )\n\t\t\t\t}\n\t\t\t\tonClick={ () => setRevisionPage( revisionPage + 1 ) }\n\t\t\t\tdisabled={ isLoading || revisionPage >= totalPages }\n\t\t\t\tsize=\"compact\"\n\t\t\t\taccessibleWhenDisabled\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tflex: 1,\n\t\t\t\t\tminWidth: 0,\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ sliderOrSpinner }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\ticon={ chevronRight }\n\t\t\t\tlabel={\n\t\t\t\t\trevisionPage > 1\n\t\t\t\t\t\t? getPageRangeLabel( revisionPage - 1 )\n\t\t\t\t\t\t: __( 'No newer revisions' )\n\t\t\t\t}\n\t\t\t\tonClick={ () => setRevisionPage( revisionPage - 1 ) }\n\t\t\t\tdisabled={ isLoading || revisionPage <= 1 }\n\t\t\t\tsize=\"compact\"\n\t\t\t\taccessibleWhenDisabled\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n\nexport default RevisionsSlider;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,wBAA8C;AAC9C,uBAAmC;AACnC,kBAA4B;AAC5B,kBAAyD;AACzD,qBAAwB;AACxB,mBAA0C;AAC1C,gBAAsB;AACtB,qBAAgC;AAKhC,mBAAqC;AACrC,yBAAuB;AAqFd;AA9ET,SAAS,kBAAkB;AAC1B,QAAM;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAY,CAAE;AAElC,UAAM,WAAW,OAAQ,aAAAA,KAAY,EAAE,mBAAmB;AAC1D,QAAK,CAAE,UAAW;AACjB,aAAO,CAAC;AAAA,IACT;AAEA,UAAM,eAAe,OAAQ,iBAAAC,KAAU,EAAE;AAAA,MACxC;AAAA,MACA;AAAA,IACD;AACA,UAAM,eAAe,cAAc,eAAe;AAClD,UAAM,gBAAgB,gBAAgB;AAEtC,WAAO;AAAA,MACN,WAAW,iBAAkB,aAAc;AAAA,MAC3C,SAAS,oBAAoB;AAAA,MAC7B,mBAAmB,qBAAqB;AAAA,MACxC,aAAa;AAAA,MACb,cAAc;AAAA,MACd,gBACC,OAAQ,aAAAD,KAAY,EAAE,6BAA6B;AAAA,IACrD;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,sBAAsB,gBAAgB,QAAI;AAAA,QACjD,yBAAa,aAAAA,KAAY;AAAA,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