@wordpress/editor 13.33.0 → 13.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +132 -20
- package/build/components/autosave-monitor/index.js +15 -12
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/character-count/index.js +5 -0
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/collapsible-block-toolbar/index.js +73 -0
- package/build/components/collapsible-block-toolbar/index.js.map +1 -0
- package/build/components/document-outline/check.js +8 -0
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +11 -0
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +0 -7
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-history/redo.js +11 -0
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +11 -0
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-snackbars/index.js +6 -0
- package/build/components/editor-snackbars/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +7 -0
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +34 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +1 -4
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +1 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/more-menu/copy-content-menu-item.js +59 -0
- package/build/components/more-menu/copy-content-menu-item.js.map +1 -0
- package/build/components/more-menu/index.js +119 -0
- package/build/components/more-menu/index.js.map +1 -0
- package/build/components/more-menu/tools-more-menu-group.js +23 -0
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -0
- package/build/components/more-menu/view-more-menu-group.js +24 -0
- package/build/components/more-menu/view-more-menu-group.js.map +1 -0
- package/build/components/page-attributes/check.js +8 -0
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/order.js +7 -0
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/panel.js +14 -8
- package/build/components/page-attributes/panel.js.map +1 -1
- package/build/components/page-attributes/parent.js +7 -0
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/plugin-post-publish-panel/index.js +1 -1
- package/build/components/plugin-post-publish-panel/index.js.map +1 -1
- package/build/components/plugin-pre-publish-panel/index.js +1 -1
- package/build/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build/components/plugin-sidebar/index.js +1 -1
- package/build/components/plugin-sidebar/index.js.map +1 -1
- package/build/components/post-actions/actions.js +100 -5
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +30 -7
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-author/check.js +9 -0
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-author/index.js +6 -0
- package/build/components/post-author/index.js.map +1 -1
- package/build/components/post-author/panel.js +5 -0
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-card-panel/index.js +14 -49
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-content-information/index.js +72 -0
- package/build/components/post-content-information/index.js.map +1 -0
- package/build/components/post-discussion/panel.js +9 -7
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/check.js +0 -19
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/index.js +52 -12
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +118 -7
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-excerpt/plugin.js +2 -2
- package/build/components/post-excerpt/plugin.js.map +1 -1
- package/build/components/post-featured-image/index.js +1 -1
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-last-edited-panel/index.js +33 -0
- package/build/components/post-last-edited-panel/index.js.map +1 -0
- package/build/components/post-publish-button/post-publish-button-or-toggle.js +100 -0
- package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
- package/build/components/post-schedule/panel.js +1 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-status/index.js +9 -9
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +2 -2
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +0 -1
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +2 -5
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-url/index.js +2 -1
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/post-url/panel.js +1 -1
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/preferences-modal/enable-publish-sidebar.js +34 -0
- package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
- package/build/components/preferences-modal/index.js +8 -2
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +3 -1
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +23 -16
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/save-publish-panels/index.js +89 -0
- package/build/components/save-publish-panels/index.js.map +1 -0
- package/build/components/start-page-options/index.js +5 -1
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/private-apis.js +18 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +15 -13
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/character-count/index.js +6 -0
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/collapsible-block-toolbar/index.js +65 -0
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -0
- package/build-module/components/document-outline/check.js +9 -0
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js +11 -0
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +1 -8
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-history/redo.js +11 -0
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +11 -0
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-snackbars/index.js +6 -0
- package/build-module/components/editor-snackbars/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +8 -0
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +35 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +2 -5
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +1 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/more-menu/copy-content-menu-item.js +52 -0
- package/build-module/components/more-menu/copy-content-menu-item.js.map +1 -0
- package/build-module/components/more-menu/index.js +111 -0
- package/build-module/components/more-menu/index.js.map +1 -0
- package/build-module/components/more-menu/tools-more-menu-group.js +16 -0
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -0
- package/build-module/components/more-menu/view-more-menu-group.js +17 -0
- package/build-module/components/more-menu/view-more-menu-group.js.map +1 -0
- package/build-module/components/page-attributes/check.js +9 -0
- package/build-module/components/page-attributes/check.js.map +1 -1
- package/build-module/components/page-attributes/order.js +7 -0
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/panel.js +13 -6
- package/build-module/components/page-attributes/panel.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +7 -0
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/plugin-post-publish-panel/index.js +1 -1
- package/build-module/components/plugin-post-publish-panel/index.js.map +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build-module/components/plugin-sidebar/index.js +1 -1
- package/build-module/components/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +100 -6
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +31 -8
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-author/check.js +10 -0
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-author/index.js +6 -0
- package/build-module/components/post-author/index.js.map +1 -1
- package/build-module/components/post-author/panel.js +6 -0
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +16 -51
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-content-information/index.js +66 -0
- package/build-module/components/post-content-information/index.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +8 -6
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/check.js +0 -19
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +52 -11
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +118 -8
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-excerpt/plugin.js +2 -2
- package/build-module/components/post-excerpt/plugin.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +1 -1
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-last-edited-panel/index.js +26 -0
- package/build-module/components/post-last-edited-panel/index.js.map +1 -0
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +91 -0
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
- package/build-module/components/post-schedule/panel.js +1 -1
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-status/index.js +9 -9
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +2 -2
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +0 -1
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +3 -6
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-url/index.js +2 -1
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/post-url/panel.js +1 -1
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/preferences-modal/enable-publish-sidebar.js +27 -0
- package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +8 -2
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +3 -1
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +24 -17
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +80 -0
- package/build-module/components/save-publish-panels/index.js.map +1 -0
- package/build-module/components/start-page-options/index.js +5 -1
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/private-apis.js +18 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +207 -30
- package/build-style/style.css +207 -30
- package/package.json +35 -35
- package/src/components/autosave-monitor/index.js +15 -12
- package/src/components/character-count/index.js +5 -0
- package/src/components/collapsible-block-toolbar/index.js +77 -0
- package/src/components/collapsible-block-toolbar/style.scss +80 -0
- package/src/components/document-outline/check.js +8 -0
- package/src/components/document-outline/index.js +10 -0
- package/src/components/document-tools/index.js +0 -5
- package/src/components/editor-canvas/edit-template-blocks-notification.js +1 -1
- package/src/components/editor-history/redo.js +10 -0
- package/src/components/editor-history/undo.js +10 -0
- package/src/components/editor-snackbars/index.js +5 -0
- package/src/components/entities-saved-states/style.scss +7 -0
- package/src/components/global-keyboard-shortcuts/index.js +7 -0
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +41 -0
- package/src/components/inserter-sidebar/index.js +2 -5
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -1
- package/src/components/list-view-sidebar/index.js +1 -1
- package/src/components/list-view-sidebar/style.scss +2 -2
- package/src/components/more-menu/copy-content-menu-item.js +51 -0
- package/src/components/more-menu/index.js +158 -0
- package/src/components/more-menu/tools-more-menu-group.js +11 -0
- package/src/components/more-menu/view-more-menu-group.js +13 -0
- package/src/components/page-attributes/check.js +8 -0
- package/src/components/page-attributes/order.js +6 -0
- package/src/components/page-attributes/panel.js +21 -17
- package/src/components/page-attributes/parent.js +6 -0
- package/src/components/plugin-post-publish-panel/index.js +1 -1
- package/src/components/plugin-pre-publish-panel/index.js +1 -1
- package/src/components/plugin-sidebar/index.js +1 -1
- package/src/components/post-actions/actions.js +120 -5
- package/src/components/post-actions/index.js +41 -7
- package/src/components/post-author/check.js +9 -0
- package/src/components/post-author/index.js +5 -0
- package/src/components/post-author/panel.js +5 -0
- package/src/components/post-card-panel/index.js +27 -82
- package/src/components/post-card-panel/style.scss +2 -6
- package/src/components/post-content-information/index.js +83 -0
- package/src/components/post-content-information/style.scss +6 -0
- package/src/components/post-discussion/panel.js +24 -20
- package/src/components/post-excerpt/check.js +0 -18
- package/src/components/post-excerpt/index.js +66 -15
- package/src/components/post-excerpt/panel.js +196 -19
- package/src/components/post-excerpt/plugin.js +2 -2
- package/src/components/post-excerpt/style.scss +24 -0
- package/src/components/post-featured-image/index.js +1 -1
- package/src/components/post-featured-image/style.scss +2 -8
- package/src/components/post-last-edited-panel/index.js +35 -0
- package/src/components/post-last-edited-panel/style.scss +6 -0
- package/src/components/post-panel-row/style.scss +3 -3
- package/src/components/post-publish-button/post-publish-button-or-toggle.js +102 -0
- package/src/components/post-publish-button/test/post-publish-button-or-toggle.js +63 -0
- package/src/components/post-publish-panel/style.scss +43 -0
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +225 -75
- package/src/components/post-schedule/panel.js +1 -1
- package/src/components/post-schedule/style.scss +2 -4
- package/src/components/post-status/index.js +84 -76
- package/src/components/post-status/style.scss +0 -1
- package/src/components/post-template/block-theme.js +2 -2
- package/src/components/post-template/classic-theme.js +0 -1
- package/src/components/post-template/swap-template-button.js +3 -6
- package/src/components/post-text-editor/style.scss +1 -1
- package/src/components/post-title/style.scss +1 -1
- package/src/components/post-url/index.js +1 -0
- package/src/components/post-url/panel.js +1 -1
- package/src/components/preferences-modal/enable-publish-sidebar.js +28 -0
- package/src/components/preferences-modal/index.js +14 -0
- package/src/components/preview-dropdown/index.js +3 -1
- package/src/components/provider/disable-non-page-content-blocks.js +23 -21
- package/src/components/save-publish-panels/index.js +96 -0
- package/src/components/save-publish-panels/style.scss +36 -0
- package/src/components/start-page-options/index.js +6 -1
- package/src/private-apis.js +18 -2
- package/src/store/selectors.js +3 -1
- package/src/style.scss +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","store","coreStore","PostTypeSupportCheck","editorStore","AUTHORS_QUERY","PostAuthorCheck","children","hasAssignAuthorAction","hasAuthors","select","_post$_links$wpActio","post","getCurrentPost","authors","getUsers","_links","length","createElement","supportKeys"],"sources":["@wordpress/editor/src/components/post-author/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nexport default function PostAuthorCheck( { children } ) {\n\tconst { hasAssignAuthorAction, hasAuthors } = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\t\treturn {\n\t\t\thasAssignAuthorAction:\n\t\t\t\tpost._links?.[ 'wp:action-assign-author' ] ?? false,\n\t\t\thasAuthors: authors?.length >= 1,\n\t\t};\n\t}, [] );\n\n\tif ( ! hasAssignAuthorAction || ! hasAuthors ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"author\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,SAASF,KAAK,IAAIG,WAAW,QAAQ,aAAa;AAClD,SAASC,aAAa,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"names":["useSelect","store","coreStore","PostTypeSupportCheck","editorStore","AUTHORS_QUERY","PostAuthorCheck","children","hasAssignAuthorAction","hasAuthors","select","_post$_links$wpActio","post","getCurrentPost","authors","getUsers","_links","length","createElement","supportKeys"],"sources":["@wordpress/editor/src/components/post-author/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\n/**\n * Wrapper component that renders its children only if the post type supports the author.\n *\n * @param {Object} props The component props.\n * @param {Element} props.children Children to be rendered.\n *\n * @return {Component|null} The component to be rendered. Return `null` if the post type doesn't\n * supports the author or if there are no authors available.\n */\nexport default function PostAuthorCheck( { children } ) {\n\tconst { hasAssignAuthorAction, hasAuthors } = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\t\treturn {\n\t\t\thasAssignAuthorAction:\n\t\t\t\tpost._links?.[ 'wp:action-assign-author' ] ?? false,\n\t\t\thasAuthors: authors?.length >= 1,\n\t\t};\n\t}, [] );\n\n\tif ( ! hasAssignAuthorAction || ! hasAuthors ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"author\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,SAASF,KAAK,IAAIG,WAAW,QAAQ,aAAa;AAClD,SAASC,aAAa,QAAQ,aAAa;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACvD,MAAM;IAAEC,qBAAqB;IAAEC;EAAW,CAAC,GAAGT,SAAS,CAAIU,MAAM,IAAM;IAAA,IAAAC,oBAAA;IACtE,MAAMC,IAAI,GAAGF,MAAM,CAAEN,WAAY,CAAC,CAACS,cAAc,CAAC,CAAC;IACnD,MAAMC,OAAO,GAAGJ,MAAM,CAAER,SAAU,CAAC,CAACa,QAAQ,CAAEV,aAAc,CAAC;IAC7D,OAAO;MACNG,qBAAqB,GAAAG,oBAAA,GACpBC,IAAI,CAACI,MAAM,GAAI,yBAAyB,CAAE,cAAAL,oBAAA,cAAAA,oBAAA,GAAI,KAAK;MACpDF,UAAU,EAAEK,OAAO,EAAEG,MAAM,IAAI;IAChC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAET,qBAAqB,IAAI,CAAEC,UAAU,EAAG;IAC9C,OAAO,IAAI;EACZ;EAEA,OACCS,aAAA,CAACf,oBAAoB;IAACgB,WAAW,EAAC;EAAQ,GACvCZ,QACmB,CAAC;AAEzB","ignoreList":[]}
|
|
@@ -12,6 +12,12 @@ import PostAuthorCombobox from './combobox';
|
|
|
12
12
|
import PostAuthorSelect from './select';
|
|
13
13
|
import { AUTHORS_QUERY } from './constants';
|
|
14
14
|
const minimumUsersForCombobox = 25;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Renders the component for selecting the post author.
|
|
18
|
+
*
|
|
19
|
+
* @return {Component} The component to be rendered.
|
|
20
|
+
*/
|
|
15
21
|
function PostAuthor() {
|
|
16
22
|
const showCombobox = useSelect(select => {
|
|
17
23
|
const authors = select(coreStore).getUsers(AUTHORS_QUERY);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","store","coreStore","PostAuthorCombobox","PostAuthorSelect","AUTHORS_QUERY","minimumUsersForCombobox","PostAuthor","showCombobox","select","authors","getUsers","length","createElement"],"sources":["@wordpress/editor/src/components/post-author/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\nimport { AUTHORS_QUERY } from './constants';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,YAAY;AAC3C,OAAOC,gBAAgB,MAAM,UAAU;AACvC,SAASC,aAAa,QAAQ,aAAa;AAE3C,MAAMC,uBAAuB,GAAG,EAAE;
|
|
1
|
+
{"version":3,"names":["useSelect","store","coreStore","PostAuthorCombobox","PostAuthorSelect","AUTHORS_QUERY","minimumUsersForCombobox","PostAuthor","showCombobox","select","authors","getUsers","length","createElement"],"sources":["@wordpress/editor/src/components/post-author/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\nimport { AUTHORS_QUERY } from './constants';\n\nconst minimumUsersForCombobox = 25;\n\n/**\n * Renders the component for selecting the post author.\n *\n * @return {Component} The component to be rendered.\n */\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,YAAY;AAC3C,OAAOC,gBAAgB,MAAM,UAAU;AACvC,SAASC,aAAa,QAAQ,aAAa;AAE3C,MAAMC,uBAAuB,GAAG,EAAE;;AAElC;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAA,EAAG;EACrB,MAAMC,YAAY,GAAGR,SAAS,CAAIS,MAAM,IAAM;IAC7C,MAAMC,OAAO,GAAGD,MAAM,CAAEP,SAAU,CAAC,CAACS,QAAQ,CAAEN,aAAc,CAAC;IAE7D,OAAOK,OAAO,EAAEE,MAAM,IAAIN,uBAAuB;EAClD,CAAC,EAAE,EAAG,CAAC;EAEP,IAAKE,YAAY,EAAG;IACnB,OAAOK,aAAA,CAACV,kBAAkB,MAAE,CAAC;EAC9B;EACA,OAAOU,aAAA,CAACT,gBAAgB,MAAE,CAAC;AAC5B;AAEA,eAAeG,UAAU","ignoreList":[]}
|
|
@@ -5,6 +5,12 @@ import { createElement } from "react";
|
|
|
5
5
|
import PostAuthorCheck from './check';
|
|
6
6
|
import PostAuthorForm from './index';
|
|
7
7
|
import PostPanelRow from '../post-panel-row';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders the Post Author Panel component.
|
|
11
|
+
*
|
|
12
|
+
* @return {Component} The component to be rendered.
|
|
13
|
+
*/
|
|
8
14
|
export function PostAuthor() {
|
|
9
15
|
return createElement(PostAuthorCheck, null, createElement(PostPanelRow, {
|
|
10
16
|
className: "editor-post-author__panel"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PostAuthorCheck","PostAuthorForm","PostPanelRow","PostAuthor","createElement","className"],"sources":["@wordpress/editor/src/components/post-author/panel.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport PostAuthorCheck from './check';\nimport PostAuthorForm from './index';\nimport PostPanelRow from '../post-panel-row';\n\nexport function PostAuthor() {\n\treturn (\n\t\t<PostAuthorCheck>\n\t\t\t<PostPanelRow className=\"editor-post-author__panel\">\n\t\t\t\t<PostAuthorForm />\n\t\t\t</PostPanelRow>\n\t\t</PostAuthorCheck>\n\t);\n}\n\nexport default PostAuthor;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,eAAe,MAAM,SAAS;AACrC,OAAOC,cAAc,MAAM,SAAS;AACpC,OAAOC,YAAY,MAAM,mBAAmB;
|
|
1
|
+
{"version":3,"names":["PostAuthorCheck","PostAuthorForm","PostPanelRow","PostAuthor","createElement","className"],"sources":["@wordpress/editor/src/components/post-author/panel.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport PostAuthorCheck from './check';\nimport PostAuthorForm from './index';\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Renders the Post Author Panel component.\n *\n * @return {Component} The component to be rendered.\n */\nexport function PostAuthor() {\n\treturn (\n\t\t<PostAuthorCheck>\n\t\t\t<PostPanelRow className=\"editor-post-author__panel\">\n\t\t\t\t<PostAuthorForm />\n\t\t\t</PostPanelRow>\n\t\t</PostAuthorCheck>\n\t);\n}\n\nexport default PostAuthor;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,eAAe,MAAM,SAAS;AACrC,OAAOC,cAAc,MAAM,SAAS;AACpC,OAAOC,YAAY,MAAM,mBAAmB;;AAE5C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC5B,OACCC,aAAA,CAACJ,eAAe,QACfI,aAAA,CAACF,YAAY;IAACG,SAAS,EAAC;EAA2B,GAClDD,aAAA,CAACH,cAAc,MAAE,CACJ,CACE,CAAC;AAEpB;AAEA,eAAeE,UAAU","ignoreList":[]}
|
|
@@ -10,17 +10,16 @@ import classnames from 'classnames';
|
|
|
10
10
|
import { Icon, __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalText as Text, PanelBody } from '@wordpress/components';
|
|
11
11
|
import { store as coreStore } from '@wordpress/core-data';
|
|
12
12
|
import { useSelect } from '@wordpress/data';
|
|
13
|
-
import { __
|
|
14
|
-
import { humanTimeDiff } from '@wordpress/date';
|
|
13
|
+
import { __ } from '@wordpress/i18n';
|
|
15
14
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
16
|
-
import { count as wordCount } from '@wordpress/wordcount';
|
|
17
|
-
import { useMemo } from '@wordpress/element';
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* Internal dependencies
|
|
21
18
|
*/
|
|
22
19
|
import { store as editorStore } from '../../store';
|
|
23
|
-
import { TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE } from '../../store/constants';
|
|
20
|
+
import { TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE } from '../../store/constants';
|
|
21
|
+
import { PrivatePostExcerptPanel } from '../post-excerpt/panel';
|
|
22
|
+
import PostLastEditedPanel from '../post-last-edited-panel';
|
|
24
23
|
import { unlock } from '../../lock-unlock';
|
|
25
24
|
import TemplateAreas from '../template-areas';
|
|
26
25
|
export default function PostCardPanel({
|
|
@@ -28,12 +27,10 @@ export default function PostCardPanel({
|
|
|
28
27
|
actions
|
|
29
28
|
}) {
|
|
30
29
|
const {
|
|
31
|
-
modified,
|
|
32
30
|
title,
|
|
33
|
-
|
|
31
|
+
showPostContentPanels,
|
|
34
32
|
icon,
|
|
35
|
-
postType
|
|
36
|
-
isPostsPage
|
|
33
|
+
postType
|
|
37
34
|
} = useSelect(select => {
|
|
38
35
|
const {
|
|
39
36
|
getEditedPostAttribute,
|
|
@@ -42,33 +39,28 @@ export default function PostCardPanel({
|
|
|
42
39
|
__experimentalGetTemplateInfo
|
|
43
40
|
} = select(editorStore);
|
|
44
41
|
const {
|
|
45
|
-
getEditedEntityRecord
|
|
46
|
-
getEntityRecord
|
|
42
|
+
getEditedEntityRecord
|
|
47
43
|
} = select(coreStore);
|
|
48
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
49
44
|
const _type = getCurrentPostType();
|
|
50
45
|
const _id = getCurrentPostId();
|
|
51
46
|
const _record = getEditedEntityRecord('postType', _type, _id);
|
|
52
|
-
const _templateInfo = __experimentalGetTemplateInfo(_record);
|
|
47
|
+
const _templateInfo = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(_type) && __experimentalGetTemplateInfo(_record);
|
|
53
48
|
return {
|
|
54
49
|
title: _templateInfo?.title || getEditedPostAttribute('title'),
|
|
55
|
-
modified: getEditedPostAttribute('modified'),
|
|
56
50
|
id: _id,
|
|
57
51
|
postType: _type,
|
|
58
|
-
templateInfo: _templateInfo,
|
|
59
52
|
icon: unlock(select(editorStore)).getPostIcon(_type, {
|
|
60
53
|
area: _record?.area
|
|
61
54
|
}),
|
|
62
|
-
|
|
55
|
+
// Post excerpt panel and Last Edited info are rendered in different place depending on the post type.
|
|
56
|
+
// So we cannot make this check inside the PostExcerpt or PostLastEditedPanel component based on the current edited entity.
|
|
57
|
+
showPostContentPanels: [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(_type)
|
|
63
58
|
};
|
|
64
59
|
}, []);
|
|
65
|
-
const description = templateInfo?.description;
|
|
66
|
-
const lastEditedText = modified && sprintf(
|
|
67
|
-
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
68
|
-
__('Last edited %s.'), humanTimeDiff(modified));
|
|
69
|
-
const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
|
|
70
60
|
return createElement(PanelBody, null, createElement("div", {
|
|
71
|
-
className: classnames('editor-post-card-panel', className
|
|
61
|
+
className: classnames('editor-post-card-panel', className, {
|
|
62
|
+
'has-description': showPostContentPanels
|
|
63
|
+
})
|
|
72
64
|
}, createElement(HStack, {
|
|
73
65
|
spacing: 2,
|
|
74
66
|
className: "editor-post-card-panel__header",
|
|
@@ -84,36 +76,9 @@ export default function PostCardPanel({
|
|
|
84
76
|
as: "h2"
|
|
85
77
|
}, title ? decodeEntities(title) : __('No Title')), actions), createElement(VStack, {
|
|
86
78
|
className: "editor-post-card-panel__content"
|
|
87
|
-
},
|
|
79
|
+
}, showPostContentPanels && createElement(VStack, {
|
|
88
80
|
className: "editor-post-card-panel__description",
|
|
89
81
|
spacing: 2
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Taken from packages/editor/src/components/time-to-read/index.js.
|
|
94
|
-
const AVERAGE_READING_RATE = 189;
|
|
95
|
-
|
|
96
|
-
// This component renders the wordcount and reading time for the post.
|
|
97
|
-
function PostContentInfo() {
|
|
98
|
-
const postContent = useSelect(select => select(editorStore).getEditedPostAttribute('content'), []);
|
|
99
|
-
/*
|
|
100
|
-
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
|
101
|
-
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
|
102
|
-
* Do not translate into your own language.
|
|
103
|
-
*/
|
|
104
|
-
const wordCountType = _x('words', 'Word count type. Do not translate!');
|
|
105
|
-
const wordsCounted = useMemo(() => postContent ? wordCount(postContent, wordCountType) : 0, [postContent, wordCountType]);
|
|
106
|
-
if (!wordsCounted) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE);
|
|
110
|
-
const wordsCountText = sprintf(
|
|
111
|
-
// translators: %s: the number of words in the post.
|
|
112
|
-
_n('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
|
|
113
|
-
const minutesText = readingTime <= 1 ? __('1 minute') : sprintf(
|
|
114
|
-
// translators: %s: the number of minutes to read the post.
|
|
115
|
-
_n('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
|
|
116
|
-
return createElement(Text, null, sprintf( /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
|
|
117
|
-
__('%1$s, %2$s read time.'), wordsCountText, minutesText));
|
|
82
|
+
}, createElement(PrivatePostExcerptPanel, null), createElement(PostLastEditedPanel, null)), postType === TEMPLATE_POST_TYPE && createElement(TemplateAreas, null))));
|
|
118
83
|
}
|
|
119
84
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","Icon","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalText","Text","PanelBody","store","coreStore","useSelect","__","_x","_n","sprintf","humanTimeDiff","decodeEntities","count","wordCount","useMemo","editorStore","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","unlock","TemplateAreas","PostCardPanel","className","actions","modified","title","templateInfo","icon","postType","isPostsPage","select","getEditedPostAttribute","getCurrentPostType","getCurrentPostId","__experimentalGetTemplateInfo","getEditedEntityRecord","getEntityRecord","siteSettings","_type","_id","_record","_templateInfo","id","getPostIcon","area","page_for_posts","description","lastEditedText","showPostContentInfo","includes","createElement","spacing","align","numberOfLines","truncate","weight","as","PostContentInfo","AVERAGE_READING_RATE","postContent","wordCountType","wordsCounted","readingTime","Math","round","wordsCountText","toLocaleString","minutesText"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tPanelBody,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { humanTimeDiff } from '@wordpress/date';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport TemplateAreas from '../template-areas';\n\nexport default function PostCardPanel( { className, actions } ) {\n\tconst { modified, title, templateInfo, icon, postType, isPostsPage } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\t__experimentalGetTemplateInfo,\n\t\t\t} = select( editorStore );\n\t\t\tconst { getEditedEntityRecord, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst _type = getCurrentPostType();\n\t\t\tconst _id = getCurrentPostId();\n\t\t\tconst _record = getEditedEntityRecord( 'postType', _type, _id );\n\t\t\tconst _templateInfo = __experimentalGetTemplateInfo( _record );\n\t\t\treturn {\n\t\t\t\ttitle:\n\t\t\t\t\t_templateInfo?.title || getEditedPostAttribute( 'title' ),\n\t\t\t\tmodified: getEditedPostAttribute( 'modified' ),\n\t\t\t\tid: _id,\n\t\t\t\tpostType: _type,\n\t\t\t\ttemplateInfo: _templateInfo,\n\t\t\t\ticon: unlock( select( editorStore ) ).getPostIcon( _type, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\tisPostsPage: +_id === siteSettings?.page_for_posts,\n\t\t\t};\n\t\t}, [] );\n\tconst description = templateInfo?.description;\n\tconst lastEditedText =\n\t\tmodified &&\n\t\tsprintf(\n\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t__( 'Last edited %s.' ),\n\t\t\thumanTimeDiff( modified )\n\t\t);\n\tconst showPostContentInfo =\n\t\t! isPostsPage &&\n\t\t! [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes( postType );\n\treturn (\n\t\t<PanelBody>\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'editor-post-card-panel', className ) }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__icon\"\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t/>\n\t\t\t\t\t<Text\n\t\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\t\ttruncate\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\tas=\"h2\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title ? decodeEntities( title ) : __( 'No Title' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ actions }\n\t\t\t\t</HStack>\n\t\t\t\t<VStack className=\"editor-post-card-panel__content\">\n\t\t\t\t\t{ ( description ||\n\t\t\t\t\t\tlastEditedText ||\n\t\t\t\t\t\tshowPostContentInfo ) && (\n\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\tclassName=\"editor-post-card-panel__description\"\n\t\t\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ description && <Text>{ description }</Text> }\n\t\t\t\t\t\t\t{ showPostContentInfo && <PostContentInfo /> }\n\t\t\t\t\t\t\t{ lastEditedText && (\n\t\t\t\t\t\t\t\t<Text>{ lastEditedText }</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t) }\n\t\t\t\t\t{ postType === TEMPLATE_POST_TYPE && <TemplateAreas /> }\n\t\t\t\t</VStack>\n\t\t\t</div>\n\t\t</PanelBody>\n\t);\n}\n\n// Taken from packages/editor/src/components/time-to-read/index.js.\nconst AVERAGE_READING_RATE = 189;\n\n// This component renders the wordcount and reading time for the post.\nfunction PostContentInfo() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),\n\t\t[]\n\t);\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\tconst wordsCounted = useMemo(\n\t\t() => ( postContent ? wordCount( postContent, wordCountType ) : 0 ),\n\t\t[ postContent, wordCountType ]\n\t);\n\tif ( ! wordsCounted ) {\n\t\treturn null;\n\t}\n\tconst readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );\n\tconst wordsCountText = sprintf(\n\t\t// translators: %s: the number of words in the post.\n\t\t_n( '%s word', '%s words', wordsCounted ),\n\t\twordsCounted.toLocaleString()\n\t);\n\tconst minutesText =\n\t\treadingTime <= 1\n\t\t\t? __( '1 minute' )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: the number of minutes to read the post.\n\t\t\t\t\t_n( '%s minute', '%s minutes', readingTime ),\n\t\t\t\t\treadingTime.toLocaleString()\n\t\t\t );\n\treturn (\n\t\t<Text>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */\n\t\t\t\t__( '%1$s, %2$s read time.' ),\n\t\t\t\twordsCountText,\n\t\t\t\tminutesText\n\t\t\t) }\n\t\t</Text>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,IAAI,EACJC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,SAAS,QACH,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACrD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASX,KAAK,IAAIY,WAAW,QAAQ,aAAa;AAClD,SACCC,kBAAkB,EAClBC,uBAAuB,QACjB,uBAAuB;AAC9B,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,aAAa,MAAM,mBAAmB;AAE7C,eAAe,SAASC,aAAaA,CAAE;EAAEC,SAAS;EAAEC;AAAQ,CAAC,EAAG;EAC/D,MAAM;IAAEC,QAAQ;IAAEC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,GAAGrD,SAAS,CAC1BwB,MAAM,IAAMA,MAAM,CAAEd,WAAY,CAAC,CAACe,sBAAsB,CAAE,SAAU,CAAC,EACvE,EACD,CAAC;EACD;AACD;AACA;AACA;AACA;EACC,MAAM6B,aAAa,GAAGpD,EAAE,CAAE,OAAO,EAAE,oCAAqC,CAAC;EACzE,MAAMqD,YAAY,GAAG9C,OAAO,CAC3B,MAAQ4C,WAAW,GAAG7C,SAAS,CAAE6C,WAAW,EAAEC,aAAc,CAAC,GAAG,CAAG,EACnE,CAAED,WAAW,EAAEC,aAAa,CAC7B,CAAC;EACD,IAAK,CAAEC,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EACA,MAAMC,WAAW,GAAGC,IAAI,CAACC,KAAK,CAAEH,YAAY,GAAGH,oBAAqB,CAAC;EACrE,MAAMO,cAAc,GAAGvD,OAAO;EAC7B;EACAD,EAAE,CAAE,SAAS,EAAE,UAAU,EAAEoD,YAAa,CAAC,EACzCA,YAAY,CAACK,cAAc,CAAC,CAC7B,CAAC;EACD,MAAMC,WAAW,GAChBL,WAAW,IAAI,CAAC,GACbvD,EAAE,CAAE,UAAW,CAAC,GAChBG,OAAO;EACP;EACAD,EAAE,CAAE,WAAW,EAAE,YAAY,EAAEqD,WAAY,CAAC,EAC5CA,WAAW,CAACI,cAAc,CAAC,CAC3B,CAAC;EACL,OACChB,aAAA,CAAChD,IAAI,QACFQ,OAAO,EACR;EACAH,EAAE,CAAE,uBAAwB,CAAC,EAC7B0D,cAAc,EACdE,WACD,CACK,CAAC;AAET","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["classnames","Icon","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalText","Text","PanelBody","store","coreStore","useSelect","__","decodeEntities","editorStore","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","PrivatePostExcerptPanel","PostLastEditedPanel","unlock","TemplateAreas","PostCardPanel","className","actions","title","showPostContentPanels","icon","postType","select","getEditedPostAttribute","getCurrentPostType","getCurrentPostId","__experimentalGetTemplateInfo","getEditedEntityRecord","_type","_id","_record","_templateInfo","includes","id","getPostIcon","area","createElement","spacing","align","numberOfLines","truncate","weight","as"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tPanelBody,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n} from '../../store/constants';\nimport { PrivatePostExcerptPanel } from '../post-excerpt/panel';\nimport PostLastEditedPanel from '../post-last-edited-panel';\nimport { unlock } from '../../lock-unlock';\nimport TemplateAreas from '../template-areas';\n\nexport default function PostCardPanel( { className, actions } ) {\n\tconst { title, showPostContentPanels, icon, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\t__experimentalGetTemplateInfo,\n\t\t\t} = select( editorStore );\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\tconst _type = getCurrentPostType();\n\t\t\tconst _id = getCurrentPostId();\n\t\t\tconst _record = getEditedEntityRecord( 'postType', _type, _id );\n\t\t\tconst _templateInfo =\n\t\t\t\t[ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(\n\t\t\t\t\t_type\n\t\t\t\t) && __experimentalGetTemplateInfo( _record );\n\t\t\treturn {\n\t\t\t\ttitle:\n\t\t\t\t\t_templateInfo?.title || getEditedPostAttribute( 'title' ),\n\t\t\t\tid: _id,\n\t\t\t\tpostType: _type,\n\t\t\t\ticon: unlock( select( editorStore ) ).getPostIcon( _type, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\t// Post excerpt panel and Last Edited info are rendered in different place depending on the post type.\n\t\t\t\t// So we cannot make this check inside the PostExcerpt or PostLastEditedPanel component based on the current edited entity.\n\t\t\t\tshowPostContentPanels: [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t\tPATTERN_POST_TYPE,\n\t\t\t\t].includes( _type ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\treturn (\n\t\t<PanelBody>\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'editor-post-card-panel', className, {\n\t\t\t\t\t'has-description': showPostContentPanels,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__icon\"\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t/>\n\t\t\t\t\t<Text\n\t\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\t\ttruncate\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\tas=\"h2\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title ? decodeEntities( title ) : __( 'No Title' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ actions }\n\t\t\t\t</HStack>\n\t\t\t\t<VStack className=\"editor-post-card-panel__content\">\n\t\t\t\t\t{ showPostContentPanels && (\n\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\tclassName=\"editor-post-card-panel__description\"\n\t\t\t\t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K;IACdC,EAAE,EAAC;EAAI,GAELxB,KAAK,GAAGZ,cAAc,CAAEY,KAAM,CAAC,GAAGb,EAAE,CAAE,UAAW,CAC9C,CAAC,EACLY,OACK,CAAC,EACTmB,aAAA,CAACtC,MAAM;IAACkB,SAAS,EAAC;EAAiC,GAChDG,qBAAqB,IACtBiB,aAAA,CAACtC,MAAM;IACNkB,SAAS,EAAC,qCAAqC;IAC/CqB,OAAO,EAAG;EAAG,GAEbD,aAAA,CAACzB,uBAAuB,MAAE,CAAC,EAC3ByB,aAAA,CAACxB,mBAAmB,MAAE,CACf,CACR,EACCS,QAAQ,KAAKb,kBAAkB,IAAI4B,aAAA,CAACtB,aAAa,MAAE,CAC9C,CACJ,CACK,CAAC;AAEd","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { __experimentalText as Text } from '@wordpress/components';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { __, _x, _n, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { count as wordCount } from '@wordpress/wordcount';
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { store as editorStore } from '../../store';
|
|
16
|
+
import { TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE } from '../../store/constants';
|
|
17
|
+
|
|
18
|
+
// Taken from packages/editor/src/components/time-to-read/index.js.
|
|
19
|
+
const AVERAGE_READING_RATE = 189;
|
|
20
|
+
|
|
21
|
+
// This component renders the wordcount and reading time for the post.
|
|
22
|
+
export default function PostContentInformation() {
|
|
23
|
+
const {
|
|
24
|
+
postContent
|
|
25
|
+
} = useSelect(select => {
|
|
26
|
+
const {
|
|
27
|
+
getEditedPostAttribute,
|
|
28
|
+
getCurrentPostType,
|
|
29
|
+
getCurrentPostId
|
|
30
|
+
} = select(editorStore);
|
|
31
|
+
const {
|
|
32
|
+
getEntityRecord
|
|
33
|
+
} = select(coreStore);
|
|
34
|
+
const siteSettings = getEntityRecord('root', 'site');
|
|
35
|
+
const postType = getCurrentPostType();
|
|
36
|
+
const _id = getCurrentPostId();
|
|
37
|
+
const isPostsPage = +_id === siteSettings?.page_for_posts;
|
|
38
|
+
const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
|
|
39
|
+
return {
|
|
40
|
+
postContent: showPostContentInfo && getEditedPostAttribute('content')
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
|
46
|
+
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
|
47
|
+
* Do not translate into your own language.
|
|
48
|
+
*/
|
|
49
|
+
const wordCountType = _x('words', 'Word count type. Do not translate!');
|
|
50
|
+
const wordsCounted = useMemo(() => postContent ? wordCount(postContent, wordCountType) : 0, [postContent, wordCountType]);
|
|
51
|
+
if (!wordsCounted) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE);
|
|
55
|
+
const wordsCountText = sprintf(
|
|
56
|
+
// translators: %s: the number of words in the post.
|
|
57
|
+
_n('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
|
|
58
|
+
const minutesText = readingTime <= 1 ? __('1 minute') : sprintf(
|
|
59
|
+
// translators: %s: the number of minutes to read the post.
|
|
60
|
+
_n('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
|
|
61
|
+
return createElement("div", {
|
|
62
|
+
className: "editor-post-content-information"
|
|
63
|
+
}, createElement(Text, null, sprintf( /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
|
|
64
|
+
__('%1$s, %2$s read time.'), wordsCountText, minutesText)));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__experimentalText","Text","useSelect","__","_x","_n","sprintf","count","wordCount","useMemo","store","coreStore","editorStore","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","AVERAGE_READING_RATE","PostContentInformation","postContent","select","getEditedPostAttribute","getCurrentPostType","getCurrentPostId","getEntityRecord","siteSettings","postType","_id","isPostsPage","page_for_posts","showPostContentInfo","includes","wordCountType","wordsCounted","readingTime","Math","round","wordsCountText","toLocaleString","minutesText","createElement","className"],"sources":["@wordpress/editor/src/components/post-content-information/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalText as Text } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\n\n// Taken from packages/editor/src/components/time-to-read/index.js.\nconst AVERAGE_READING_RATE = 189;\n\n// This component renders the wordcount and reading time for the post.\nexport default function PostContentInformation() {\n\tconst { postContent } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getCurrentPostType, getCurrentPostId } =\n\t\t\tselect( editorStore );\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\tconst postType = getCurrentPostType();\n\t\tconst _id = getCurrentPostId();\n\t\tconst isPostsPage = +_id === siteSettings?.page_for_posts;\n\t\tconst showPostContentInfo =\n\t\t\t! isPostsPage &&\n\t\t\t! [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\treturn {\n\t\t\tpostContent:\n\t\t\t\tshowPostContentInfo && getEditedPostAttribute( 'content' ),\n\t\t};\n\t}, [] );\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\tconst wordsCounted = useMemo(\n\t\t() => ( postContent ? wordCount( postContent, wordCountType ) : 0 ),\n\t\t[ postContent, wordCountType ]\n\t);\n\tif ( ! wordsCounted ) {\n\t\treturn null;\n\t}\n\tconst readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );\n\tconst wordsCountText = sprintf(\n\t\t// translators: %s: the number of words in the post.\n\t\t_n( '%s word', '%s words', wordsCounted ),\n\t\twordsCounted.toLocaleString()\n\t);\n\tconst minutesText =\n\t\treadingTime <= 1\n\t\t\t? __( '1 minute' )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: the number of minutes to read the post.\n\t\t\t\t\t_n( '%s minute', '%s minutes', readingTime ),\n\t\t\t\t\treadingTime.toLocaleString()\n\t\t\t );\n\treturn (\n\t\t<div className=\"editor-post-content-information\">\n\t\t\t<Text>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */\n\t\t\t\t\t__( '%1$s, %2$s read time.' ),\n\t\t\t\t\twordsCountText,\n\t\t\t\t\tminutesText\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAClE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,Q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,CAAEb,WAAW,EAAEa,aAAa,CAC7B,CAAC;EACD,IAAK,CAAEC,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EACA,MAAMC,WAAW,GAAGC,IAAI,CAACC,KAAK,CAAEH,YAAY,GAAGhB,oBAAqB,CAAC;EACrE,MAAMoB,cAAc,GAAG7B,OAAO;EAC7B;EACAD,EAAE,CAAE,SAAS,EAAE,UAAU,EAAE0B,YAAa,CAAC,EACzCA,YAAY,CAACK,cAAc,CAAC,CAC7B,CAAC;EACD,MAAMC,WAAW,GAChBL,WAAW,IAAI,CAAC,GACb7B,EAAE,CAAE,UAAW,CAAC,GAChBG,OAAO;EACP;EACAD,EAAE,CAAE,WAAW,EAAE,YAAY,EAAE2B,WAAY,CAAC,EAC5CA,WAAW,CAACI,cAAc,CAAC,CAC3B,CAAC;EACL,OACCE,aAAA;IAAKC,SAAS,EAAC;EAAiC,GAC/CD,aAAA,CAACrC,IAAI,QACFK,OAAO,EACR;EACAH,EAAE,CAAE,uBAAwB,CAAC,EAC7BgC,cAAc,EACdE,WACD,CACK,CACF,CAAC;AAER","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ import PostTypeSupportCheck from '../post-type-support-check';
|
|
|
14
14
|
import PostComments from '../post-comments';
|
|
15
15
|
import PostPingbacks from '../post-pingbacks';
|
|
16
16
|
const PANEL_NAME = 'discussion-panel';
|
|
17
|
-
function
|
|
17
|
+
function DiscussionPanel() {
|
|
18
18
|
const {
|
|
19
19
|
isEnabled,
|
|
20
20
|
isOpened
|
|
@@ -34,9 +34,7 @@ function PostDiscussionPanel() {
|
|
|
34
34
|
if (!isEnabled) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
|
-
return createElement(
|
|
38
|
-
supportKeys: ['comments', 'trackbacks']
|
|
39
|
-
}, createElement(PanelBody, {
|
|
37
|
+
return createElement(PanelBody, {
|
|
40
38
|
title: __('Discussion'),
|
|
41
39
|
opened: isOpened,
|
|
42
40
|
onToggle: () => toggleEditorPanelOpened(PANEL_NAME)
|
|
@@ -44,7 +42,11 @@ function PostDiscussionPanel() {
|
|
|
44
42
|
supportKeys: "comments"
|
|
45
43
|
}, createElement(PanelRow, null, createElement(PostComments, null))), createElement(PostTypeSupportCheck, {
|
|
46
44
|
supportKeys: "trackbacks"
|
|
47
|
-
}, createElement(PanelRow, null, createElement(PostPingbacks, null))))
|
|
45
|
+
}, createElement(PanelRow, null, createElement(PostPingbacks, null))));
|
|
46
|
+
}
|
|
47
|
+
export default function PostDiscussionPanel() {
|
|
48
|
+
return createElement(PostTypeSupportCheck, {
|
|
49
|
+
supportKeys: ['comments', 'trackbacks']
|
|
50
|
+
}, createElement(DiscussionPanel, null));
|
|
48
51
|
}
|
|
49
|
-
export default PostDiscussionPanel;
|
|
50
52
|
//# sourceMappingURL=panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","PanelBody","PanelRow","useDispatch","useSelect","store","editorStore","PostTypeSupportCheck","PostComments","PostPingbacks","PANEL_NAME","
|
|
1
|
+
{"version":3,"names":["__","PanelBody","PanelRow","useDispatch","useSelect","store","editorStore","PostTypeSupportCheck","PostComments","PostPingbacks","PANEL_NAME","DiscussionPanel","isEnabled","isOpened","select","isEditorPanelEnabled","isEditorPanelOpened","toggleEditorPanelOpened","createElement","title","opened","onToggle","supportKeys","PostDiscussionPanel"],"sources":["@wordpress/editor/src/components/post-discussion/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport PostComments from '../post-comments';\nimport PostPingbacks from '../post-pingbacks';\n\nconst PANEL_NAME = 'discussion-panel';\n\nfunction DiscussionPanel() {\n\tconst { isEnabled, isOpened } = useSelect( ( select ) => {\n\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ __( 'Discussion' ) }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }\n\t\t>\n\t\t\t<PostTypeSupportCheck supportKeys=\"comments\">\n\t\t\t\t<PanelRow>\n\t\t\t\t\t<PostComments />\n\t\t\t\t</PanelRow>\n\t\t\t</PostTypeSupportCheck>\n\n\t\t\t<PostTypeSupportCheck supportKeys=\"trackbacks\">\n\t\t\t\t<PanelRow>\n\t\t\t\t\t<PostPingbacks />\n\t\t\t\t</PanelRow>\n\t\t\t</PostTypeSupportCheck>\n\t\t</PanelBody>\n\t);\n}\n\nexport default function PostDiscussionPanel() {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>\n\t\t\t<DiscussionPanel />\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AAC3D,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,aAAa,MAAM,mBAAmB;AAE7C,MAAMC,UAAU,GAAG,kBAAkB;AAErC,SAASC,eAAeA,CAAA,EAAG;EAC1B,MAAM;IAAEC,SAAS;IAAEC;EAAS,CAAC,GAAGT,SAAS,CAAIU,MAAM,IAAM;IACxD,MAAM;MAAEC,oBAAoB;MAAEC;IAAoB,CAAC,GAClDF,MAAM,CAAER,WAAY,CAAC;IACtB,OAAO;MACNM,SAAS,EAAEG,oBAAoB,CAAEL,UAAW,CAAC;MAC7CG,QAAQ,EAAEG,mBAAmB,CAAEN,UAAW;IAC3C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAEO;EAAwB,CAAC,GAAGd,WAAW,CAAEG,WAAY,CAAC;EAE9D,IAAK,CAAEM,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OACCM,aAAA,CAACjB,SAAS;IACTkB,KAAK,EAAGnB,EAAE,CAAE,YAAa,CAAG;IAC5BoB,MAAM,EAAGP,QAAU;IACnBQ,QAAQ,EAAGA,CAAA,KAAMJ,uBAAuB,CAAEP,UAAW;EAAG,GAExDQ,aAAA,CAACX,oBAAoB;IAACe,WAAW,EAAC;EAAU,GAC3CJ,aAAA,CAAChB,QAAQ,QACRgB,aAAA,CAACV,YAAY,MAAE,CACN,CACW,CAAC,EAEvBU,aAAA,CAACX,oBAAoB;IAACe,WAAW,EAAC;EAAY,GAC7CJ,aAAA,CAAChB,QAAQ,QACRgB,aAAA,CAACT,aAAa,MAAE,CACP,CACW,CACZ,CAAC;AAEd;AAEA,eAAe,SAASc,mBAAmBA,CAAA,EAAG;EAC7C,OACCL,aAAA,CAACX,oBAAoB;IAACe,WAAW,EAAG,CAAE,UAAU,EAAE,YAAY;EAAI,GACjEJ,aAAA,CAACP,eAAe,MAAE,CACG,CAAC;AAEzB","ignoreList":[]}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useSelect } from '@wordpress/data';
|
|
6
|
-
|
|
7
2
|
/**
|
|
8
3
|
* Internal dependencies
|
|
9
4
|
*/
|
|
10
5
|
import PostTypeSupportCheck from '../post-type-support-check';
|
|
11
|
-
import { store as editorStore } from '../../store';
|
|
12
6
|
|
|
13
7
|
/**
|
|
14
8
|
* Component for checking if the post type supports the excerpt field.
|
|
@@ -21,19 +15,6 @@ import { store as editorStore } from '../../store';
|
|
|
21
15
|
function PostExcerptCheck({
|
|
22
16
|
children
|
|
23
17
|
}) {
|
|
24
|
-
const postType = useSelect(select => {
|
|
25
|
-
const {
|
|
26
|
-
getEditedPostAttribute
|
|
27
|
-
} = select(editorStore);
|
|
28
|
-
return getEditedPostAttribute('type');
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
32
|
-
// support the excerpt field throught the "description" field rather than "excerpt" which means
|
|
33
|
-
// the default ExcerptPanel won't work for these.
|
|
34
|
-
if (['wp_template', 'wp_template_part'].includes(postType)) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
18
|
return createElement(PostTypeSupportCheck, {
|
|
38
19
|
supportKeys: "excerpt"
|
|
39
20
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["PostTypeSupportCheck","PostExcerptCheck","children","createElement","supportKeys"],"sources":["@wordpress/editor/src/components/post-excerpt/check.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\n\n/**\n * Component for checking if the post type supports the excerpt field.\n *\n * @param {Object} props Props.\n * @param {Element} props.children Children to be rendered.\n *\n * @return {Component} The component to be rendered.\n */\nfunction PostExcerptCheck( { children } ) {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"excerpt\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nexport default PostExcerptCheck;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,oBAAoB,MAAM,4BAA4B;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACzC,OACCC,aAAA,CAACH,oBAAoB;IAACI,WAAW,EAAC;EAAS,GACxCF,QACmB,CAAC;AAEzB;AAEA,eAAeD,gBAAgB","ignoreList":[]}
|
|
@@ -5,29 +5,70 @@ import { createElement } from "react";
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { ExternalLink, TextareaControl } from '@wordpress/components';
|
|
7
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
+
import { useState } from '@wordpress/element';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
import { store as editorStore } from '../../store';
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Renders an editable textarea for the post excerpt.
|
|
17
|
+
* Templates, template parts and patterns use the `excerpt` field as a description semantically.
|
|
18
|
+
* Additionally templates and template parts override the `excerpt` field as `description` in
|
|
19
|
+
* REST API. So this component handles proper labeling and updating the edited entity.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} props - Component props.
|
|
22
|
+
* @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
|
|
23
|
+
* @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
|
|
24
|
+
*/
|
|
25
|
+
export default function PostExcerpt({
|
|
26
|
+
hideLabelFromVision = false,
|
|
27
|
+
updateOnBlur = false
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
excerpt,
|
|
31
|
+
shouldUseDescriptionLabel,
|
|
32
|
+
usedAttribute
|
|
33
|
+
} = useSelect(select => {
|
|
34
|
+
const {
|
|
35
|
+
getCurrentPostType,
|
|
36
|
+
getEditedPostAttribute
|
|
37
|
+
} = select(editorStore);
|
|
38
|
+
const postType = getCurrentPostType();
|
|
39
|
+
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
40
|
+
// support the excerpt field throught the "description" field rather than "excerpt".
|
|
41
|
+
const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
|
|
42
|
+
return {
|
|
43
|
+
excerpt: getEditedPostAttribute(_usedAttribute),
|
|
44
|
+
// There are special cases where we want to label the excerpt as a description.
|
|
45
|
+
shouldUseDescriptionLabel: ['wp_template', 'wp_template_part', 'wp_block'].includes(postType),
|
|
46
|
+
usedAttribute: _usedAttribute
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
15
49
|
const {
|
|
16
50
|
editPost
|
|
17
51
|
} = useDispatch(editorStore);
|
|
52
|
+
const [localExcerpt, setLocalExcerpt] = useState(excerpt);
|
|
53
|
+
const updatePost = value => {
|
|
54
|
+
editPost({
|
|
55
|
+
[usedAttribute]: value
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const label = shouldUseDescriptionLabel ? __('Write a description (optional)') : __('Write an excerpt (optional)');
|
|
18
59
|
return createElement("div", {
|
|
19
60
|
className: "editor-post-excerpt"
|
|
20
61
|
}, createElement(TextareaControl, {
|
|
21
62
|
__nextHasNoMarginBottom: true,
|
|
22
|
-
label:
|
|
63
|
+
label: label,
|
|
64
|
+
hideLabelFromVision: hideLabelFromVision,
|
|
23
65
|
className: "editor-post-excerpt__textarea",
|
|
24
|
-
onChange:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
66
|
+
onChange: updateOnBlur ? setLocalExcerpt : updatePost,
|
|
67
|
+
onBlur: updateOnBlur ? () => updatePost(localExcerpt) : undefined,
|
|
68
|
+
value: updateOnBlur ? localExcerpt : excerpt,
|
|
69
|
+
help: !shouldUseDescriptionLabel ? createElement(ExternalLink, {
|
|
70
|
+
href: __('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt')
|
|
71
|
+
}, __('Learn more about manual excerpts')) : __('Write a description')
|
|
72
|
+
}));
|
|
31
73
|
}
|
|
32
|
-
export default PostExcerpt;
|
|
33
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","ExternalLink","TextareaControl","useDispatch","useSelect","store","editorStore","PostExcerpt","excerpt","select","getEditedPostAttribute","editPost","createElement","className","__nextHasNoMarginBottom","
|
|
1
|
+
{"version":3,"names":["__","ExternalLink","TextareaControl","useDispatch","useSelect","useState","store","editorStore","PostExcerpt","hideLabelFromVision","updateOnBlur","excerpt","shouldUseDescriptionLabel","usedAttribute","select","getCurrentPostType","getEditedPostAttribute","postType","_usedAttribute","includes","editPost","localExcerpt","setLocalExcerpt","updatePost","value","label","createElement","className","__nextHasNoMarginBottom","onChange","onBlur","undefined","help","href"],"sources":["@wordpress/editor/src/components/post-excerpt/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ExternalLink, TextareaControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders an editable textarea for the post excerpt.\n * Templates, template parts and patterns use the `excerpt` field as a description semantically.\n * Additionally templates and template parts override the `excerpt` field as `description` in\n * REST API. So this component handles proper labeling and updating the edited entity.\n *\n * @param {Object} props - Component props.\n * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.\n * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.\n */\nexport default function PostExcerpt( {\n\thideLabelFromVision = false,\n\tupdateOnBlur = false,\n} ) {\n\tconst { excerpt, shouldUseDescriptionLabel, usedAttribute } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postType = getCurrentPostType();\n\t\t\t// This special case is unfortunate, but the REST API of wp_template and wp_template_part\n\t\t\t// support the excerpt field throught the \"description\" field rather than \"excerpt\".\n\t\t\tconst _usedAttribute = [\n\t\t\t\t'wp_template',\n\t\t\t\t'wp_template_part',\n\t\t\t].includes( postType )\n\t\t\t\t? 'description'\n\t\t\t\t: 'excerpt';\n\t\t\treturn {\n\t\t\t\texcerpt: getEditedPostAttribute( _usedAttribute ),\n\t\t\t\t// There are special cases where we want to label the excerpt as a description.\n\t\t\t\tshouldUseDescriptionLabel: [\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t'wp_block',\n\t\t\t\t].includes( postType ),\n\t\t\t\tusedAttribute: _usedAttribute,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ localExcerpt, setLocalExcerpt ] = useState( excerpt );\n\tconst updatePost = ( value ) => {\n\t\teditPost( { [ usedAttribute ]: value } );\n\t};\n\tconst label = shouldUseDescriptionLabel\n\t\t? __( 'Write a description (optional)' )\n\t\t: __( 'Write an excerpt (optional)' );\n\n\treturn (\n\t\t<div className=\"editor-post-excerpt\">\n\t\t\t<TextareaControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ label }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\tclassName=\"editor-post-excerpt__textarea\"\n\t\t\t\tonChange={ updateOnBlur ? setLocalExcerpt : updatePost }\n\t\t\t\tonBlur={\n\t\t\t\t\tupdateOnBlur ? () => updatePost( localExcerpt ) : undefined\n\t\t\t\t}\n\t\t\t\tvalue={ updateOnBlur ? localExcerpt : excerpt }\n\t\t\t\thelp={\n\t\t\t\t\t! shouldUseDescriptionLabel ? (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about manual excerpts' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) : (\n\t\t\t\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