@wordpress/editor 14.15.1 → 14.16.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 +1 -1
- package/build/bindings/pattern-overrides.js +1 -1
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/components/collab-sidebar/index.js +1 -4
- package/build/components/collab-sidebar/index.js.map +1 -1
- package/build/components/document-outline/index.js +2 -2
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/header/index.js +3 -2
- package/build/components/header/index.js.map +1 -1
- package/build/components/post-excerpt/index.js +1 -1
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +7 -1
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +2 -2
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/post-publish-button-or-toggle.js +1 -1
- package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/post-schedule/index.js +1 -1
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +1 -1
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/provider/index.js +25 -17
- package/build/components/provider/index.js.map +1 -1
- package/build/components/sidebar/post-summary.js +1 -1
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/components/visual-editor/index.js +2 -2
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/dataviews/fields/content-preview/content-preview-view.js +101 -0
- package/build/dataviews/fields/content-preview/content-preview-view.js.map +1 -0
- package/build/dataviews/fields/content-preview/index.js +26 -0
- package/build/dataviews/fields/content-preview/index.js.map +1 -0
- package/build/dataviews/store/private-actions.js +3 -1
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/store/private-actions.js +1 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +7 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +1 -1
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/components/collab-sidebar/index.js +1 -4
- package/build-module/components/collab-sidebar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +2 -2
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/header/index.js +3 -2
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +1 -1
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +7 -1
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +2 -2
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +1 -1
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/post-schedule/index.js +1 -1
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +1 -1
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/provider/index.js +25 -17
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +1 -1
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/visual-editor/index.js +2 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/dataviews/fields/content-preview/content-preview-view.js +95 -0
- package/build-module/dataviews/fields/content-preview/content-preview-view.js.map +1 -0
- package/build-module/dataviews/fields/content-preview/index.js +19 -0
- package/build-module/dataviews/fields/content-preview/index.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js +2 -1
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +7 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +24 -8
- package/build-style/style.css +24 -8
- package/build-types/components/autocompleters/user.d.ts +5 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/post-author/hook.d.ts +1 -1
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/index.d.ts +1 -1
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts +9 -9
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
- package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts +5 -0
- package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts.map +1 -0
- package/build-types/dataviews/fields/content-preview/index.d.ts +8 -0
- package/build-types/dataviews/fields/content-preview/index.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +1 -1
- package/package.json +37 -37
- package/src/bindings/pattern-overrides.js +1 -1
- package/src/components/autocompleters/style.scss +1 -1
- package/src/components/collab-sidebar/index.js +1 -4
- package/src/components/document-outline/index.js +2 -2
- package/src/components/header/index.js +8 -2
- package/src/components/post-excerpt/index.js +1 -1
- package/src/components/post-preview-button/index.js +5 -1
- package/src/components/post-publish-button/index.js +2 -2
- package/src/components/post-publish-button/post-publish-button-or-toggle.js +1 -1
- package/src/components/post-schedule/index.js +1 -1
- package/src/components/post-template/swap-template-button.js +1 -1
- package/src/components/provider/index.js +32 -20
- package/src/components/sidebar/post-summary.js +1 -1
- package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/src/components/visual-editor/index.js +2 -2
- package/src/dataviews/fields/content-preview/content-preview-view.tsx +108 -0
- package/src/dataviews/fields/content-preview/index.tsx +21 -0
- package/src/dataviews/fields/content-preview/style.scss +21 -0
- package/src/dataviews/store/private-actions.ts +4 -0
- package/src/store/private-actions.js +1 -1
- package/src/store/private-selectors.js +15 -8
- package/src/style.scss +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fastDeepEqual","_interopRequireDefault","require","_blockEditor","_data","_icons","_coreData","_selectors","_privateSelectors","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","filterValue","getInserter","exports","createRegistrySelector","select","createSelector","state","blockInserterPanel","getRenderingMode","postContentClientId","blockEditorStore","getBlocksByName","getListViewToggleRef","listViewToggleRef","getInserterSidebarToggleRef","inserterSidebarToggleRef","CARD_ICONS","wp_block","symbol","wp_navigation","navigation","page","pageIcon","post","verse","getPostIcon","postType","options","coreStore","getEntityRecord","default_template_part_areas","find","item","area","icon","layout","postTypeEntity","getPostType","startsWith","slice","hasPostMetaChanges","postId","type","currentPostType","id","currentPostId","getCurrentPost","edits","getEntityRecordNonTransientEdits","meta","originalPostMeta","fastDeepEqual","footnotes","getEntityActions","args","_getEntityActions","dataviews","isEntityReady","_isEntityReady","getEntityFields","_getEntityFields","getPostBlocksByName","blockNames","Array","isArray","getBlockParents","getBlockName","filter","clientId","every","parentClientId","parentBlockName","includes","getBlocks"],"sources":["@wordpress/editor/src/store/private-selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * Get the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t\t'core/post-content'\n\t\t\t\t\t);\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\treturn (\n\t\t\t\t\t(\n\t\t\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t\t)?.default_template_part_areas || []\n\t\t\t\t\t).find( ( item ) => options.area === item.area )?.icon ||\n\t\t\t\t\tlayout\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t() => [ select( blockEditorStore ).getBlocks() ]\n\t)\n);\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAA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A,GAAG,IAAA1D,4BAAsB,EAAIC,MAAM,IAClE,IAAAC,oBAAc,EACb,CAAEC,KAAK,EAAEwD,UAAU,KAAM;EACxBA,UAAU,GAAGC,KAAK,CAACC,OAAO,CAAEF,UAAW,CAAC,GACrCA,UAAU,GACV,CAAEA,UAAU,CAAE;EACjB,MAAM;IAAEnD,eAAe;IAAEsD,eAAe;IAAEC;EAAa,CAAC,GACvD9D,MAAM,CAAEM,kBAAiB,CAAC;EAC3B,OAAOC,eAAe,CAAEmD,UAAW,CAAC,CAACK,MAAM,CAAIC,QAAQ,IACtDH,eAAe,CAAEG,QAAS,CAAC,CAACC,KAAK,CAAIC,cAAc,IAAM;IACxD,MAAMC,eAAe,GAAGL,YAAY,CAAEI,cAAe,CAAC;IACtD;MACC;MACAC,eAAe,KAAK,YAAY;MAChC;MACA,CAAET,UAAU,CAACU,QAAQ,CAAED,eAAgB;IAAC;EAE1C,CAAE,CACH,CAAC;AACF,CAAC,EACD,MAAM,CAAEnE,MAAM,CAAEM,kBAAiB,CAAC,CAAC+D,SAAS,CAAC,CAAC,CAC/C,CACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_fastDeepEqual","_interopRequireDefault","require","_blockEditor","_data","_icons","_coreData","_selectors","_privateSelectors","_utils","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","filterValue","getInserter","exports","createRegistrySelector","select","createSelector","state","blockInserterPanel","getRenderingMode","postContentClientId","blockEditorStore","getBlocksByName","getListViewToggleRef","listViewToggleRef","getInserterSidebarToggleRef","inserterSidebarToggleRef","CARD_ICONS","wp_block","symbol","wp_navigation","navigation","page","pageIcon","post","verse","getPostIcon","postType","options","templateAreas","coreStore","getEntityRecord","default_template_part_areas","areaData","find","item","area","icon","getTemplatePartIcon","layout","postTypeEntity","getPostType","startsWith","slice","hasPostMetaChanges","postId","type","currentPostType","id","currentPostId","getCurrentPost","edits","getEntityRecordNonTransientEdits","meta","originalPostMeta","fastDeepEqual","footnotes","getEntityActions","args","_getEntityActions","dataviews","isEntityReady","_isEntityReady","getEntityFields","_getEntityFields","getPostBlocksByName","blockNames","Array","isArray","getBlockParents","getBlockName","filter","clientId","every","parentClientId","parentBlockName","includes","getBlocks"],"sources":["@wordpress/editor/src/store/private-selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * Get the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t\t'core/post-content'\n\t\t\t\t\t);\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t)?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t() => [ select( blockEditorStore ).getBlocks() ]\n\t)\n);\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAOA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AASA,MAAMQ,qBAAqB,GAAG;EAC7BC,YAAY,EAAEC,SAAS;EACvBC,cAAc,EAAED,SAAS;EACzBE,WAAW,EAAEF;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,IAAAE,4BAAsB,EAAIC,MAAM,IAC1D,IAAAC,oBAAc,EACXC,KAAK,IAAM;EACZ,IAAK,OAAOA,KAAK,CAACC,kBAAkB,KAAK,QAAQ,EAAG;IACnD,OAAOD,KAAK,CAACC,kBAAkB;EAChC;EAEA,IAAK,IAAAC,2BAAgB,EAAEF,K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I,cAAe,CAAC;IACtD;MACC;MACAC,eAAe,KAAK,YAAY;MAChC;MACA,CAAET,UAAU,CAACU,QAAQ,CAAED,eAAgB;IAAC;EAE1C,CAAE,CACH,CAAC;AACF,CAAC,EACD,MAAM,CAAEtE,MAAM,CAAEM,kBAAiB,CAAC,CAACkE,SAAS,CAAC,CAAC,CAC/C,CACD,CAAC","ignoreList":[]}
|
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
for (const attributeName of Object.keys(bindings)) {
|
|
22
22
|
const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
|
|
23
23
|
|
|
24
|
-
// If it has not been
|
|
24
|
+
// If it has not been overridden, return the original value.
|
|
25
25
|
// Check undefined because empty string is a valid value.
|
|
26
26
|
if (overridableValue === undefined) {
|
|
27
27
|
overridesValues[attributeName] = currentBlockAttributes[attributeName];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blockEditorStore","CONTENT","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been
|
|
1
|
+
{"version":3,"names":["store","blockEditorStore","CONTENT","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overridden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { select, dispatch, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tdispatch( blockEditorStore ).updateBlockAttributes(\n\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\n\t\tdispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: {\n\t\t\t\t...currentBindingValue,\n\t\t\t\t[ blockName ]: {\n\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t},\n\tcanUserEditValue: () => true,\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,MAAMC,OAAO,GAAG,SAAS;AAEzB,eAAe;EACdC,IAAI,EAAE,wBAAwB;EAC9BC,SAASA,CAAE;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IACpD,MAAMC,uBAAuB,GAAGF,OAAO,CAAE,mBAAmB,CAAE;IAC9D,MAAM;MAAEG;IAAmB,CAAC,GAAGL,MAAM,CAAEJ,gBAAiB,CAAC;IACzD,MAAMU,sBAAsB,GAAGD,kBAAkB,CAAEJ,QAAS,CAAC;IAE7D,MAAMM,eAAe,GAAG,CAAC,CAAC;IAC1B,KAAM,MAAMC,aAAa,IAAIC,MAAM,CAACC,IAAI,CAAEP,QAAS,CAAC,EAAG;MACtD,MAAMQ,gBAAgB,GACrBP,uBAAuB,GACtBE,sBAAsB,EAAEM,QAAQ,EAAEd,IAAI,CACtC,GAAIU,aAAa,CAAE;;MAErB;MACA;MACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;QACrCN,eAAe,CAAEC,aAAa,CAAE,GAC/BF,sBAAsB,CAAEE,aAAa,CAAE;QACxC;MACD,CAAC,MAAM;QACND,eAAe,CAAEC,aAAa,CAAE,GAC/BG,gBAAgB,KAAK,EAAE,GAAGE,SAAS,GAAGF,gBAAgB;MACxD;IACD;IACA,OAAOJ,eAAe;EACvB,CAAC;EACDO,SAASA,CAAE;IAAEd,MAAM;IAAEe,QAAQ;IAAEd,QAAQ;IAAEE;EAAS,CAAC,EAAG;IACrD,MAA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B;QACtB,CAAEb,SAAS,GAAI;UACd,GAAGa,mBAAmB,GAAIb,SAAS,CAAE;UACrC,GAAGT,MAAM,CAACY,OAAO,CAAED,UAAW,CAAC,CAACE,MAAM,CACrC,CAAEU,GAAG,EAAE,CAAER,GAAG,EAAES,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAER,GAAG,CAAE,GAAGS,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACJ,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
|
|
@@ -25,7 +25,6 @@ import AddCommentToolbarButton from './comment-button-toolbar';
|
|
|
25
25
|
import { useGlobalStylesContext } from '../global-styles-provider';
|
|
26
26
|
import { getCommentIdsFromBlocks } from './utils';
|
|
27
27
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
|
-
const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
|
|
29
28
|
const modifyBlockCommentAttributes = settings => {
|
|
30
29
|
if (!settings.attributes.blockCommentId) {
|
|
31
30
|
settings.attributes = {
|
|
@@ -298,9 +297,7 @@ export default function CollabSidebar() {
|
|
|
298
297
|
}
|
|
299
298
|
});
|
|
300
299
|
}
|
|
301
|
-
|
|
302
|
-
// Check if the experimental flag is enabled.
|
|
303
|
-
if (!isBlockCommentExperimentEnabled || postStatus === 'publish') {
|
|
300
|
+
if (postStatus === 'publish') {
|
|
304
301
|
return null; // or maybe return some message indicating no threads are available.
|
|
305
302
|
}
|
|
306
303
|
const AddCommentComponent = blockCommentId ? AddCommentToolbarButton : AddCommentButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useSelect","useDispatch","resolveSelect","subscribe","useState","useMemo","comment","commentIcon","addFilter","store","noticesStore","coreStore","useEntityBlockEditor","blockEditorStore","interfaceStore","PluginSidebar","collabHistorySidebarName","collabSidebarName","Comments","AddComment","editorStore","AddCommentButton","AddCommentToolbarButton","useGlobalStylesContext","getCommentIdsFromBlocks","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","saveEntityRecord","deleteEntityRecord","getEntityRecord","postId","select","getCurrentPostId","_postId","getSelectedBlockClientId","updateBlockAttributes","addNewComment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","className","style","children","onSubmit","threads","onAddReply","CollabSidebar","enableComplementaryArea","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","resultComments","sortedThreads","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","threadIdMap","Map","thread","sortedComments","get","merged","GlobalStyles","backgroundColor","color","background","unsubscribe","activeSidebar","AddCommentComponent","onClick","identifier","title","icon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], sortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: updatedResult, sortedThreads: sortedComments };\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Check if the experimental flag is enabled.\n\tif ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ sortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,SAAS,QACH,iBAAiB;AACxB,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AACzD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC/E,SAASH,KAAK,IAAII,gBAAgB,QAAQ,yBAAyB;AACnE,SAASJ,KAAK,IAAIK,cAAc,QAAQ,sBAAsB;;AAE9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D,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChBf,IAAA,CAACX,aAAa;MACb+G,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBJ,UAAU,EAAG1G,iBAAmB;MAChCyD,SAAS,EAAC,uBAAuB;MACjCsD,eAAe,EAAC,+BAA+B;MAAApD,QAAA,eAE/ClD,IAAA,CAACa,oBAAoB;QACpBI,QAAQ,EAAGoD,aAAe;QAC1BvD,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR0E;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","useSelect","useDispatch","resolveSelect","subscribe","useState","useMemo","comment","commentIcon","addFilter","store","noticesStore","coreStore","useEntityBlockEditor","blockEditorStore","interfaceStore","PluginSidebar","collabHistorySidebarName","collabSidebarName","Comments","AddComment","editorStore","AddCommentButton","AddCommentToolbarButton","useGlobalStylesContext","getCommentIdsFromBlocks","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","saveEntityRecord","deleteEntityRecord","getEntityRecord","postId","select","getCurrentPostId","_postId","getSelectedBlockClientId","updateBlockAttributes","addNewComment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","className","style","children","onSubmit","threads","onAddReply","CollabSidebar","enableComplementaryArea","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","resultComments","sortedThreads","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","threadIdMap","Map","thread","sortedComments","get","merged","GlobalStyles","backgroundColor","color","background","unsubscribe","activeSidebar","AddCommentComponent","onClick","identifier","title","icon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], sortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: updatedResult, sortedThreads: sortedComments };\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tif ( postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ sortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA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,GACvCZ,uBAAuB,GACvBD,gBAAgB;EAEnB,oBACCO,KAAA,CAAAE,SAAA;IAAA2C,QAAA,gBACC/C,IAAA,CAAC4F,mBAAmB;MAACC,OAAO,EAAG9B;IAAiB,CAAE,CAAC,eACnD/D,IAAA,CAACX,aAAa;MACbyG,UAAU,EAAGxG;MACb;MAAA;MACAyG,KAAK,EAAG1H,EAAE,CAAE,UAAW,CAAG;MAC1B2H,IAAI,EAAGnH,WAAa;MAAAkE,QAAA,eAEpB/C,IAAA,CAACU,oBAAoB;QACpBI,QAAQ,EAAGmD,cAAgB;QAC3BtD,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChBZ,IAAA,CAACX,aAAa;MACb4G,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBJ,UAAU,EAAGvG,iBAAmB;MAChCsD,SAAS,EAAC,uBAAuB;MACjCsD,eAAe,EAAC,+BAA+B;MAAApD,QAAA,eAE/C/C,IAAA,CAACU,oBAAoB;QACpBI,QAAQ,EAAGoD,aAAe;QAC1BvD,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR0E;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
|
|
@@ -202,7 +202,7 @@ export default function DocumentOutline({
|
|
|
202
202
|
href: `#${titleNode.id}`,
|
|
203
203
|
isDisabled: hasOutlineItemsDisabled,
|
|
204
204
|
children: title
|
|
205
|
-
}), headings.map(
|
|
205
|
+
}), headings.map(item => {
|
|
206
206
|
// Headings remain the same, go up by one, or down by any amount.
|
|
207
207
|
// Otherwise there are missing levels.
|
|
208
208
|
const isIncorrectLevel = item.level > prevHeadingLevelRef.current + 1;
|
|
@@ -220,7 +220,7 @@ export default function DocumentOutline({
|
|
|
220
220
|
children: [item.isEmpty ? emptyHeadingContent : getTextContent(create({
|
|
221
221
|
html: item.attributes.content
|
|
222
222
|
})), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
|
|
223
|
-
},
|
|
223
|
+
}, item.clientId);
|
|
224
224
|
})]
|
|
225
225
|
})
|
|
226
226
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useDispatch","useSelect","useRef","create","getTextContent","store","blockEditorStore","coreStore","Path","SVG","Line","Rect","DocumentOutlineItem","editorStore","jsx","_jsx","jsxs","_jsxs","emptyHeadingContent","children","incorrectLevelContent","singleH1Headings","multipleH1Headings","EmptyOutlineIllustration","width","height","viewBox","fill","xmlns","rx","x1","y1","x2","y2","stroke","x","y","d","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","trim","length","DocumentOutline","onSelect","hasOutlineItemsDisabled","selectBlock","title","isTitleSupported","select","_postType$supports$ti","getBlocks","getEditedPostAttribute","getPostType","postType","supports","prevHeadingLevelRef","headings","className","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","isValid","href","id","isDisabled","map","item","index","isIncorrectLevel","current","clientId","html"],"sources":["@wordpress/editor/src/components/document-outline/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { Path, SVG, Line, Rect } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\nfunction EmptyOutlineIllustration() {\n\treturn (\n\t\t<SVG\n\t\t\twidth=\"138\"\n\t\t\theight=\"148\"\n\t\t\tviewBox=\"0 0 138 148\"\n\t\t\tfill=\"none\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t>\n\t\t\t<Rect width=\"138\" height=\"148\" rx=\"4\" fill=\"#F0F6FC\" />\n\t\t\t<Line x1=\"44\" y1=\"28\" x2=\"24\" y2=\"28\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"48\" y=\"16\" width=\"27\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"55\" y1=\"59\" x2=\"24\" y2=\"59\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"59\" y=\"47\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"80\" y1=\"90\" x2=\"24\" y2=\"90\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"84\" y=\"78\" width=\"30\" height=\"23\" rx=\"4\" fill=\"#F0B849\" />\n\t\t\t<Path\n\t\t\t\td=\"M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"66\" y1=\"121\" x2=\"24\" y2=\"121\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"70\" y=\"109\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t</SVG>\n\t);\n}\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content ||\n\theading.attributes.content.trim().length === 0;\n\n/**\n * Renders a document outline component.\n *\n * @param {Object} props Props.\n * @param {Function} props.onSelect Function to be called when an outline item is selected\n * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function DocumentOutline( {\n\tonSelect,\n\thasOutlineItemsDisabled,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { blocks, title, isTitleSupported } = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} );\n\n\tconst prevHeadingLevelRef = useRef( 1 );\n\n\tconst headings = computeOutlineHeadings( blocks );\n\tif ( headings.length < 1 ) {\n\t\treturn (\n\t\t\t<div className=\"editor-document-outline has-no-headings\">\n\t\t\t\t<EmptyOutlineIllustration />\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Navigate the structure of your document and address issues like empty or incorrect heading levels.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item, index ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel =\n\t\t\t\t\t\titem.level > prevHeadingLevelRef.current + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevelRef.current = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\tselectBlock( item.clientId );\n\t\t\t\t\t\t\t\tonSelect?.();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\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{ isIncorrectLevel && incorrectLevelContent }\n\t\t\t\t\t\t\t{ item.level === 1 &&\n\t\t\t\t\t\t\t\thasMultipleH1 &&\n\t\t\t\t\t\t\t\tmultipleH1Headings }\n\t\t\t\t\t\t\t{ hasTitle &&\n\t\t\t\t\t\t\t\titem.level === 1 &&\n\t\t\t\t\t\t\t\t! hasMultipleH1 &&\n\t\t\t\t\t\t\t\tsingleH1Headings }\n\t\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,MAAM,EAAEC,cAAc,QAAQ,sBAAsB;AAC7D,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAEC,IAAI,QAAQ,uBAAuB;;AAE7D;AACA;AACA;AACA,OAAOC,mB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AACpC,OAAO,GACX3B,mBAAmB,GACnBd,cAAc,CACdD,MAAM,CAAE;YACPmF,IAAI,EAAEL,IAAI,CAACrC,UAAU,CAACK;UACvB,CAAE,CACF,CAAC,EACFkC,gBAAgB,IAAI/D,qBAAqB,EACzC6D,IAAI,CAACtC,KAAK,KAAK,CAAC,IACjBgC,aAAa,IACbrD,kBAAkB,EACjBiD,QAAQ,IACTU,IAAI,CAACtC,KAAK,KAAK,CAAC,IAChB,CAAEgC,aAAa,IACftD,gBAAgB;QAAA,GAxBX6D,KAyBc,CAAC;MAExB,CAAE,CAAC;IAAA,CACA;EAAC,CACD,CAAC;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","useDispatch","useSelect","useRef","create","getTextContent","store","blockEditorStore","coreStore","Path","SVG","Line","Rect","DocumentOutlineItem","editorStore","jsx","_jsx","jsxs","_jsxs","emptyHeadingContent","children","incorrectLevelContent","singleH1Headings","multipleH1Headings","EmptyOutlineIllustration","width","height","viewBox","fill","xmlns","rx","x1","y1","x2","y2","stroke","x","y","d","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","trim","length","DocumentOutline","onSelect","hasOutlineItemsDisabled","selectBlock","title","isTitleSupported","select","_postType$supports$ti","getBlocks","getEditedPostAttribute","getPostType","postType","supports","prevHeadingLevelRef","headings","className","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","isValid","href","id","isDisabled","map","item","isIncorrectLevel","current","clientId","html"],"sources":["@wordpress/editor/src/components/document-outline/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { Path, SVG, Line, Rect } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\nfunction EmptyOutlineIllustration() {\n\treturn (\n\t\t<SVG\n\t\t\twidth=\"138\"\n\t\t\theight=\"148\"\n\t\t\tviewBox=\"0 0 138 148\"\n\t\t\tfill=\"none\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t>\n\t\t\t<Rect width=\"138\" height=\"148\" rx=\"4\" fill=\"#F0F6FC\" />\n\t\t\t<Line x1=\"44\" y1=\"28\" x2=\"24\" y2=\"28\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"48\" y=\"16\" width=\"27\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"55\" y1=\"59\" x2=\"24\" y2=\"59\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"59\" y=\"47\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"80\" y1=\"90\" x2=\"24\" y2=\"90\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"84\" y=\"78\" width=\"30\" height=\"23\" rx=\"4\" fill=\"#F0B849\" />\n\t\t\t<Path\n\t\t\t\td=\"M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"66\" y1=\"121\" x2=\"24\" y2=\"121\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"70\" y=\"109\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t</SVG>\n\t);\n}\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content ||\n\theading.attributes.content.trim().length === 0;\n\n/**\n * Renders a document outline component.\n *\n * @param {Object} props Props.\n * @param {Function} props.onSelect Function to be called when an outline item is selected\n * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function DocumentOutline( {\n\tonSelect,\n\thasOutlineItemsDisabled,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { blocks, title, isTitleSupported } = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} );\n\n\tconst prevHeadingLevelRef = useRef( 1 );\n\n\tconst headings = computeOutlineHeadings( blocks );\n\tif ( headings.length < 1 ) {\n\t\treturn (\n\t\t\t<div className=\"editor-document-outline has-no-headings\">\n\t\t\t\t<EmptyOutlineIllustration />\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Navigate the structure of your document and address issues like empty or incorrect heading levels.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel =\n\t\t\t\t\t\titem.level > prevHeadingLevelRef.current + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevelRef.current = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ item.clientId }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\tselectBlock( item.clientId );\n\t\t\t\t\t\t\t\tonSelect?.();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\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{ isIncorrectLevel && incorrectLevelContent }\n\t\t\t\t\t\t\t{ item.level === 1 &&\n\t\t\t\t\t\t\t\thasMultipleH1 &&\n\t\t\t\t\t\t\t\tmultipleH1Headings }\n\t\t\t\t\t\t\t{ hasTitle &&\n\t\t\t\t\t\t\t\titem.level === 1 &&\n\t\t\t\t\t\t\t\t! hasMultipleH1 &&\n\t\t\t\t\t\t\t\tsingleH1Headings }\n\t\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,MAAM,EAAEC,cAAc,QAAQ,sBAAsB;AAC7D,SAASC,KAAK,IAAIC,gBAA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AAK;UACpC/B,QAAQ,EAAGA,CAAA,KAAM;YAChBE,WAAW,CAAE0B,IAAI,CAACG,QAAS,CAAC;YAC5B/B,QAAQ,GAAG,CAAC;UACb,CAAG;UAAAlC,QAAA,GAED8D,IAAI,CAACpC,OAAO,GACX3B,mBAAmB,GACnBd,cAAc,CACdD,MAAM,CAAE;YACPkF,IAAI,EAAEJ,IAAI,CAACrC,UAAU,CAACK;UACvB,CAAE,CACF,CAAC,EACFiC,gBAAgB,IAAI9D,qBAAqB,EACzC6D,IAAI,CAACtC,KAAK,KAAK,CAAC,IACjBgC,aAAa,IACbrD,kBAAkB,EACjBiD,QAAQ,IACTU,IAAI,CAACtC,KAAK,KAAK,CAAC,IAChB,CAAEgC,aAAa,IACftD,gBAAgB;QAAA,GAxBX4D,IAAI,CAACG,QAyBS,CAAC;MAExB,CAAE,CAAC;IAAA,CACA;EAAC,CACD,CAAC;AAER","ignoreList":[]}
|
|
@@ -28,6 +28,7 @@ import { store as editorStore } from '../../store';
|
|
|
28
28
|
import { TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE } from '../../store/constants';
|
|
29
29
|
import { unlock } from '../../lock-unlock';
|
|
30
30
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
|
+
const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
|
|
31
32
|
const toolbarVariations = {
|
|
32
33
|
distractionFreeDisabled: {
|
|
33
34
|
y: '-50px'
|
|
@@ -105,7 +106,7 @@ function Header({
|
|
|
105
106
|
const hasSectionRootClientId = useSelect(select => !!unlock(select(blockEditorStore)).getSectionRootClientId(), []);
|
|
106
107
|
|
|
107
108
|
/*
|
|
108
|
-
* The edit-post-header classname is only kept for backward
|
|
109
|
+
* The edit-post-header classname is only kept for backward compatibility
|
|
109
110
|
* as some plugins might be relying on its presence.
|
|
110
111
|
*/
|
|
111
112
|
return /*#__PURE__*/_jsxs("div", {
|
|
@@ -168,7 +169,7 @@ function Header({
|
|
|
168
169
|
}), !customSaveButton && /*#__PURE__*/_jsx(PostPublishButtonOrToggle, {
|
|
169
170
|
forceIsDirty: forceIsDirty,
|
|
170
171
|
setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
|
|
171
|
-
}), /*#__PURE__*/_jsx(CollabSidebar, {}), customSaveButton, /*#__PURE__*/_jsx(MoreMenu, {})]
|
|
172
|
+
}), isBlockCommentExperimentEnabled ? /*#__PURE__*/_jsx(CollabSidebar, {}) : undefined, customSaveButton, /*#__PURE__*/_jsx(MoreMenu, {})]
|
|
172
173
|
})]
|
|
173
174
|
});
|
|
174
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blockEditorStore","useSelect","useMediaQuery","useViewportMatch","__unstableMotion","motion","preferencesStore","useState","PinnedItems","CollabSidebar","BackButton","useHasBackButton","CollapsibleBlockToolbar","DocumentBar","DocumentTools","MoreMenu","PostPreviewButton","PostPublishButtonOrToggle","PostSavedState","PostViewLink","PreviewDropdown","ZoomOutToggle","editorStore","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","unlock","jsx","_jsx","jsxs","_jsxs","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isWideViewport","isLargeViewport","isTooNarrowForDocumentBar","postType","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","hasBlockSelection","select","get","getPreference","getEditorMode","getCurrentPostType","_isPublishSidebarOpened","getBlockSelectionStart","canBeZoomedOut","includes","disablePreviewOption","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasCenter","hasBackButton","hasSectionRootClientId","getSectionRootClientId","className","children","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","scope"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport CollabSidebar from '../collab-sidebar';\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tpostType,\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\thasBlockSelection,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetCurrentPostType,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\n\tconst canBeZoomedOut = [ 'post', 'page', 'wp_template' ].includes(\n\t\tpostType\n\t);\n\n\tconst disablePreviewOption = [\n\t\tNAVIGATION_POST_TYPE,\n\t\tTEMPLATE_PART_POST_TYPE,\n\t\tPATTERN_POST_TYPE,\n\t].includes( postType );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter =\n\t\t! isTooNarrowForDocumentBar &&\n\t\t( ! hasFixedToolbar ||\n\t\t\t( hasFixedToolbar &&\n\t\t\t\t( ! hasBlockSelection || isBlockToolsCollapsed ) ) );\n\tconst hasBackButton = useHasBackButton();\n\n\tconst hasSectionRootClientId = useSelect(\n\t\t( select ) =>\n\t\t\t!! unlock( select( blockEditorStore ) ).getSectionRootClientId(),\n\t\t[]\n\t);\n\n\t/*\n\t * The edit-post-header classname is only kept for backward compatability\n\t * as some plugins might be relying on its presence.\n\t */\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t/*\n\t\t\t\t\t * This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t * We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t * We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t * when the publish sidebar has been closed.\n\t\t\t\t\t */\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ disablePreviewOption }\n\t\t\t\t/>\n\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\n\t\t\t\t{ canBeZoomedOut &&\n\t\t\t\t\tisWideViewport &&\n\t\t\t\t\thasSectionRootClientId && (\n\t\t\t\t\t\t<ZoomOutToggle disabled={ forceDisableBlockTools } />\n\t\t\t\t\t) }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<CollabSidebar />\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,gBAAgB,IAAIC,MAAM,QAAQ,uBAAuB;AAClE,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,WAAW,QAAQ,sBAAsB;;AAElD;AACA;AACA;AACA,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,UAAU,IAAIC,gBAAgB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eAEhC5C,IAAA,CAACf,WAAW;QAACgC,KAAK,EAAGA;MAAO,CAAE;IAAC,CACpB,CACZ,eACDf,KAAA,CAACzB,MAAM,CAACoE,GAAG;MACVC,QAAQ,EAAG3C,iBAAmB;MAC9B4C,UAAU,EAAG;QAAEC,IAAI,EAAE;MAAQ,CAAG;MAChCL,SAAS,EAAC,yBAAyB;MAAAC,QAAA,GAEjC,CAAE/B,gBAAgB,IAAI,CAAEU,sBAAsB;MAAA;MAC/C;AACL;AACA;AACA;AACA;AACA;AACA;MACKvB,IAAA,CAACV,cAAc;QAACwB,YAAY,EAAGA;MAAc,CAAE,CAC/C,eAEDd,IAAA,CAACT,YAAY,IAAE,CAAC,eAEhBS,IAAA,CAACR,eAAe;QACf6D,mBAAmB,EAAGvC,YAAc;QACpCwC,QAAQ,EAAGlB;MAAsB,CACjC,CAAC,eAEFpC,IAAA,CAACZ,iBAAiB;QACjBuD,SAAS,EAAC,oCAAoC;QAC9CU,mBAAmB,EAAGvC;MAAc,CACpC,CAAC,EAEAoB,cAAc,IACfhB,cAAc,IACduB,sBAAsB,iBACrBzC,IAAA,CAACP,aAAa;QAAC6D,QAAQ,EAAGvC;MAAwB,CAAE,CACpD,EAEA,CAAEG,cAAc,IAAI,CAAEM,cAAc,kBACrCxB,IAAA,CAACpB,WAAW,CAACqE,IAAI;QAACM,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAE1C,gBAAgB,iBACnBb,IAAA,CAACX,yBAAyB;QACzByB,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,eACDhB,IAAA,CAACnB,aAAa,IAAE,CAAC,EAEfgC,gBAAgB,eAClBb,IAAA,CAACb,QAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAEA,eAAeyB,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["store","blockEditorStore","useSelect","useMediaQuery","useViewportMatch","__unstableMotion","motion","preferencesStore","useState","PinnedItems","CollabSidebar","BackButton","useHasBackButton","CollapsibleBlockToolbar","DocumentBar","DocumentTools","MoreMenu","PostPreviewButton","PostPublishButtonOrToggle","PostSavedState","PostViewLink","PreviewDropdown","ZoomOutToggle","editorStore","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","unlock","jsx","_jsx","jsxs","_jsxs","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isWideViewport","isLargeViewport","isTooNarrowForDocumentBar","postType","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","hasBlockSelection","select","get","getPreference","getEditorMode","getCurrentPostType","_isPublishSidebarOpened","getBlockSelectionStart","canBeZoomedOut","includes","disablePreviewOption","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasCenter","hasBackButton","hasSectionRootClientId","getSectionRootClientId","className","children","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","scope","undefined"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport CollabSidebar from '../collab-sidebar';\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tpostType,\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\thasBlockSelection,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetCurrentPostType,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\n\tconst canBeZoomedOut = [ 'post', 'page', 'wp_template' ].includes(\n\t\tpostType\n\t);\n\n\tconst disablePreviewOption = [\n\t\tNAVIGATION_POST_TYPE,\n\t\tTEMPLATE_PART_POST_TYPE,\n\t\tPATTERN_POST_TYPE,\n\t].includes( postType );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter =\n\t\t! isTooNarrowForDocumentBar &&\n\t\t( ! hasFixedToolbar ||\n\t\t\t( hasFixedToolbar &&\n\t\t\t\t( ! hasBlockSelection || isBlockToolsCollapsed ) ) );\n\tconst hasBackButton = useHasBackButton();\n\n\tconst hasSectionRootClientId = useSelect(\n\t\t( select ) =>\n\t\t\t!! unlock( select( blockEditorStore ) ).getSectionRootClientId(),\n\t\t[]\n\t);\n\n\t/*\n\t * The edit-post-header classname is only kept for backward compatibility\n\t * as some plugins might be relying on its presence.\n\t */\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t/*\n\t\t\t\t\t * This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t * We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t * We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t * when the publish sidebar has been closed.\n\t\t\t\t\t */\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ disablePreviewOption }\n\t\t\t\t/>\n\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\n\t\t\t\t{ canBeZoomedOut &&\n\t\t\t\t\tisWideViewport &&\n\t\t\t\t\thasSectionRootClientId && (\n\t\t\t\t\t\t<ZoomOutToggle disabled={ forceDisableBlockTools } />\n\t\t\t\t\t) }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ isBlockCommentExperimentEnabled ? (\n\t\t\t\t\t<CollabSidebar />\n\t\t\t\t) : undefined }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,gBAAgB,IAAIC,MAAM,QAAQ,uBAAuB;AAClE,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,WAAW,QAAQ,sBAAsB;;AAElD;AACA;AACA;AACA,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,UAAU,IAAIC,gBAAgB,QAAQ,eAAe;AAC5D,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,QAAQ,MAAM,cAAc;AACnC,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,yBAAyB,MAAM,sDAAsD;AAC5F,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,aAAa,M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C/C;AACL;AACA;AACA;AACA;AACA;AACA;MACK1B,IAAA,CAACV,cAAc;QAAC2B,YAAY,EAAGA;MAAc,CAAE,CAC/C,eAEDjB,IAAA,CAACT,YAAY,IAAE,CAAC,eAEhBS,IAAA,CAACR,eAAe;QACfgE,mBAAmB,EAAGvC,YAAc;QACpCwC,QAAQ,EAAGlB;MAAsB,CACjC,CAAC,eAEFvC,IAAA,CAACZ,iBAAiB;QACjB0D,SAAS,EAAC,oCAAoC;QAC9CU,mBAAmB,EAAGvC;MAAc,CACpC,CAAC,EAEAoB,cAAc,IACfhB,cAAc,IACduB,sBAAsB,iBACrB5C,IAAA,CAACP,aAAa;QAACgE,QAAQ,EAAGvC;MAAwB,CAAE,CACpD,EAEA,CAAEG,cAAc,IAAI,CAAEM,cAAc,kBACrC3B,IAAA,CAACpB,WAAW,CAACwE,IAAI;QAACM,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAE1C,gBAAgB,iBACnBhB,IAAA,CAACX,yBAAyB;QACzB4B,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,EAEChB,+BAA+B,gBAChCH,IAAA,CAACnB,aAAa,IAAE,CAAC,GACd8E,SAAS,EAEX3C,gBAAgB,eAClBhB,IAAA,CAACb,QAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAEA,eAAe4B,MAAM","ignoreList":[]}
|
|
@@ -38,7 +38,7 @@ export default function PostExcerpt({
|
|
|
38
38
|
} = select(editorStore);
|
|
39
39
|
const postType = getCurrentPostType();
|
|
40
40
|
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
41
|
-
// support the excerpt field
|
|
41
|
+
// support the excerpt field through the "description" field rather than "excerpt".
|
|
42
42
|
const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
|
|
43
43
|
return {
|
|
44
44
|
excerpt: getEditedPostAttribute(_usedAttribute),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","ExternalLink","TextareaControl","useDispatch","useSelect","useState","decodeEntities","store","editorStore","jsx","_jsx","PostExcerpt","hideLabelFromVision","updateOnBlur","excerpt","shouldUseDescriptionLabel","usedAttribute","select","getCurrentPostType","getEditedPostAttribute","postType","_usedAttribute","includes","editPost","localExcerpt","setLocalExcerpt","updatePost","value","label","className","children","__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';\nimport { decodeEntities } from '@wordpress/html-entities';\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
|
|
1
|
+
{"version":3,"names":["__","ExternalLink","TextareaControl","useDispatch","useSelect","useState","decodeEntities","store","editorStore","jsx","_jsx","PostExcerpt","hideLabelFromVision","updateOnBlur","excerpt","shouldUseDescriptionLabel","usedAttribute","select","getCurrentPostType","getEditedPostAttribute","postType","_usedAttribute","includes","editPost","localExcerpt","setLocalExcerpt","updatePost","value","label","className","children","__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';\nimport { decodeEntities } from '@wordpress/html-entities';\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 through 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(\n\t\tdecodeEntities( excerpt )\n\t);\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\t\t\t__( 'Write a description' )\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,EAAEC,eAAe,QAAQ,uBAAuB;AACrE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,S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A;IAAKmB,SAAS,EAAC,qBAAqB;IAAAC,QAAA,eACnCpB,IAAA,CAACR,eAAe;MACf6B,uBAAuB;MACvBH,KAAK,EAAGA,KAAO;MACfhB,mBAAmB,EAAGA,mBAAqB;MAC3CiB,SAAS,EAAC,+BAA+B;MACzCG,QAAQ,EAAGnB,YAAY,GAAGY,eAAe,GAAGC,UAAY;MACxDO,MAAM,EACLpB,YAAY,GAAG,MAAMa,UAAU,CAAEF,YAAa,CAAC,GAAGU,SAClD;MACDP,KAAK,EAAGd,YAAY,GAAGW,YAAY,GAAGV,OAAS;MAC/CqB,IAAI,EACH,CAAEpB,yBAAyB,gBAC1BL,IAAA,CAACT,YAAY;QACZmC,IAAI,EAAGpC,EAAE,CACR,iFACD,CAAG;QAAA8B,QAAA,EAED9B,EAAE,CAAE,kCAAmC;MAAC,CAC7B,CAAC,GAEfA,EAAE,CAAE,qBAAsB;IAE3B,CACD;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
@@ -131,12 +131,18 @@ export default function PostPreviewButton({
|
|
|
131
131
|
const editor = select(editorStore);
|
|
132
132
|
const core = select(coreStore);
|
|
133
133
|
const postType = core.getPostType(editor.getCurrentPostType('type'));
|
|
134
|
+
const canView = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
|
|
135
|
+
if (!canView) {
|
|
136
|
+
return {
|
|
137
|
+
isViewable: canView
|
|
138
|
+
};
|
|
139
|
+
}
|
|
134
140
|
return {
|
|
135
141
|
postId: editor.getCurrentPostId(),
|
|
136
142
|
currentPostLink: editor.getCurrentPostAttribute('link'),
|
|
137
143
|
previewLink: editor.getEditedPostPreviewLink(),
|
|
138
144
|
isSaveable: editor.isEditedPostSaveable(),
|
|
139
|
-
isViewable:
|
|
145
|
+
isViewable: canView
|
|
140
146
|
};
|
|
141
147
|
}, []);
|
|
142
148
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderToString","Button","Path","SVG","VisuallyHidden","__","_x","useSelect","useDispatch","applyFilters","store","coreStore","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","writeInterstitialMessage","targetDocument","markup","className","children","xmlns","viewBox","d","fill","write","title","close","PostPreviewButton","textContent","forceIsAutosaveable","role","onPreview","postId","currentPostLink","previewLink","isSaveable","isViewable","select","_postType$viewable","editor","core","postType","getPostType","getCurrentPostType","getCurrentPostId","getCurrentPostAttribute","getEditedPostPreviewLink","isEditedPostSaveable","viewable","__unstableSaveForPreview","targetId","openPreviewWindow","event","preventDefault","previewWindow","window","open","focus","document","link","location","href","variant","undefined","target","accessibleWhenDisabled","disabled","onClick","size","as"],"sources":["@wordpress/editor/src/components/post-preview-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport { Button, Path, SVG, VisuallyHidden } 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';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction writeInterstitialMessage( targetDocument ) {\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\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\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\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: postType?.viewable ?? false,\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\twriteInterstitialMessage( previewWindow.document );\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 as=\"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAEC,cAAc,QAAQ,uBAAuB;AACzE,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAEnD,SAASC,wBAAwBA,CAAEC,cAAc,EAAG;EACnD,IAAIC,MAAM,GAAGrB,cAAc,cAC1BgB,KAAA;IAAKM,SAAS,EAAC,kDAAkD;IAAAC,QAAA,gBAChEP,KAAA,CAACb,GAAG;MAACqB,KAAK,EAAC,4BAA4B;MAACC,OAAO,EAAC,WAAW;MAAAF,QAAA,gBAC1DT,IAAA,CAACZ,IAAI;QACJoB,SAAS,EAAC,OAAO;QACjBI,CAAC,EAAC,uEAAuE;QACzEC,IAAI,EAAC;MAAM,CACX,CAAC,eACFb,IAAA,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GA,IAAM;IACbG,MAAM,EAAGd,QAAU;IACnBe,sBAAsB;IACtBC,QAAQ,EAAG,CAAE/B,UAAY;IACzBgC,OAAO,EAAGhB,iBAAmB;IAC7BrB,IAAI,EAAGA,IAAM;IACbsC,IAAI,EAAC,SAAS;IAAAjD,QAAA,EAEZS,WAAW,iBACZhB,KAAA,CAAAE,SAAA;MAAAK,QAAA,GACGjB,EAAE,CAAE,SAAS,EAAE,iBAAkB,CAAC,eACpCQ,IAAA,CAACV,cAAc;QAACqE,EAAE,EAAC,MAAM;QAAAlD,QAAA,EAEvB;QACAlB,EAAE,CAAE,sBAAuB;MAAC,CAEd,CAAC;IAAA,CAChB;EACF,CACM,CAAC;AAEX","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["renderToString","Button","Path","SVG","VisuallyHidden","__","_x","useSelect","useDispatch","applyFilters","store","coreStore","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","writeInterstitialMessage","targetDocument","markup","className","children","xmlns","viewBox","d","fill","write","title","close","PostPreviewButton","textContent","forceIsAutosaveable","role","onPreview","postId","currentPostLink","previewLink","isSaveable","isViewable","select","_postType$viewable","editor","core","postType","getPostType","getCurrentPostType","canView","viewable","getCurrentPostId","getCurrentPostAttribute","getEditedPostPreviewLink","isEditedPostSaveable","__unstableSaveForPreview","targetId","openPreviewWindow","event","preventDefault","previewWindow","window","open","focus","document","link","location","href","variant","undefined","target","accessibleWhenDisabled","disabled","onClick","size","as"],"sources":["@wordpress/editor/src/components/post-preview-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport { Button, Path, SVG, VisuallyHidden } 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';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction writeInterstitialMessage( targetDocument ) {\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\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\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\twriteInterstitialMessage( previewWindow.document );\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 as=\"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAEC,cAAc,QAAQ,uBAAuB;AACzE,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACx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AQ,GAAG,cAAenB,MAAM,EAAG;EAEzC,MAAMoB,iBAAiB,GAAG,MAAQC,KAAK,IAAM;IAC5C;IACA;IACA;IACA;IACA;IACAA,KAAK,CAACC,cAAc,CAAC,CAAC;;IAEtB;IACA,MAAMC,aAAa,GAAGC,MAAM,CAACC,IAAI,CAAE,EAAE,EAAEN,QAAS,CAAC;;IAEjD;IACA;IACA;IACAI,aAAa,CAACG,KAAK,CAAC,CAAC;IAErB3C,wBAAwB,CAAEwC,aAAa,CAACI,QAAS,CAAC;IAElD,MAAMC,IAAI,GAAG,MAAMV,wBAAwB,CAAE;MAAErB;IAAoB,CAAE,CAAC;IAEtE0B,aAAa,CAACM,QAAQ,GAAGD,IAAI;IAE7B7B,SAAS,GAAG,CAAC;EACd,CAAC;;EAED;EACA;EACA;EACA,MAAM+B,IAAI,GAAG5B,WAAW,IAAID,eAAe;EAE3C,oBACCvB,IAAA,CAACb,MAAM;IACNkE,OAAO,EAAG,CAAE7C,SAAS,GAAG,UAAU,GAAG8C,SAAW;IAChD9C,SAAS,EAAGA,SAAS,IAAI,qBAAuB;IAChD4C,IAAI,EAAGA,IAAM;IACbG,MAAM,EAAGd,QAAU;IACnBe,sBAAsB;IACtBC,QAAQ,EAAG,CAAEhC,UAAY;IACzBiC,OAAO,EAAGhB,iBAAmB;IAC7BtB,IAAI,EAAGA,IAAM;IACbuC,IAAI,EAAC,SAAS;IAAAlD,QAAA,EAEZS,WAAW,iBACZhB,KAAA,CAAAE,SAAA;MAAAK,QAAA,GACGjB,EAAE,CAAE,SAAS,EAAE,iBAAkB,CAAC,eACpCQ,IAAA,CAACV,cAAc;QAACsE,EAAE,EAAC,MAAM;QAAAnD,QAAA,EAEvB;QACAlB,EAAE,CAAE,sBAAuB;MAAC,CAEd,CAAC;IAAA,CAChB;EACF,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -94,10 +94,10 @@ export class PostPublishButton extends Component {
|
|
|
94
94
|
const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
|
|
95
95
|
const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
|
|
96
96
|
|
|
97
|
-
// If the new status has not changed
|
|
97
|
+
// If the new status has not changed explicitly, we derive it from
|
|
98
98
|
// other factors, like having a publish action, etc.. We need to preserve
|
|
99
99
|
// this because it affects when to show the pre and post publish panels.
|
|
100
|
-
// If it has changed though
|
|
100
|
+
// If it has changed though explicitly, we need to respect that.
|
|
101
101
|
let publishStatus = 'publish';
|
|
102
102
|
if (postStatusHasChanged) {
|
|
103
103
|
publishStatus = postStatus;
|