@wordpress/editor 14.0.0 → 14.1.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 +164 -20
- package/build/components/block-settings-menu/content-only-settings-menu.js +14 -5
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/document-tools/index.js +12 -3
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor/index.js +77 -0
- package/build/components/editor/index.js.map +1 -0
- package/build/components/editor-interface/index.js +6 -8
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js +9 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build/components/entities-saved-states/index.js +28 -0
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +9 -2
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/back-button.js +4 -1
- package/build/components/header/back-button.js.map +1 -1
- package/build/components/header/index.js +1 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/index.js +7 -0
- package/build/components/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -1
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/post-actions/actions.js +10 -4
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-last-revision/index.js +35 -9
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +1 -0
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -0
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +5 -0
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +5 -0
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-sticky/check.js +8 -0
- package/build/components/post-sticky/check.js.map +1 -1
- package/build/components/post-sticky/index.js +5 -1
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +11 -2
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-sync-status/index.js +6 -2
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js +8 -0
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +14 -2
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +9 -0
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-taxonomies/panel.js +10 -0
- package/build/components/post-taxonomies/panel.js.map +1 -1
- package/build/components/post-title/index.js +4 -8
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/post-title-raw.js +3 -7
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-trash/check.js +8 -0
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-trash/index.js +6 -1
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-url/panel.js +25 -3
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/post-visibility/index.js +1 -0
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +5 -3
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/index.js +18 -15
- package/build/components/provider/index.js.map +1 -1
- package/build/components/sidebar/post-summary.js +3 -2
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/table-of-contents/index.js +11 -0
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/template-part-menu-items/convert-to-regular.js +38 -0
- package/build/components/template-part-menu-items/convert-to-regular.js.map +1 -0
- package/build/components/template-part-menu-items/convert-to-template-part.js +77 -0
- package/build/components/template-part-menu-items/convert-to-template-part.js.map +1 -0
- package/build/components/template-part-menu-items/index.js +67 -0
- package/build/components/template-part-menu-items/index.js.map +1 -0
- package/build/components/template-part-menu-items/index.native.js +10 -0
- package/build/components/template-part-menu-items/index.native.js.map +1 -0
- package/build/components/template-validation-notice/index.js +1 -0
- package/build/components/template-validation-notice/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +9 -0
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/components/time-to-read/index.js +6 -0
- package/build/components/time-to-read/index.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +1 -0
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/components/word-count/index.js +5 -1
- package/build/components/word-count/index.js.map +1 -1
- package/build/dataviews/api.js +61 -0
- package/build/dataviews/api.js.map +1 -0
- package/build/dataviews/store/private-actions.js +28 -0
- package/build/dataviews/store/private-actions.js.map +1 -0
- package/build/dataviews/store/private-selectors.js +20 -0
- package/build/dataviews/store/private-selectors.js.map +1 -0
- package/build/dataviews/store/reducer.js +36 -0
- package/build/dataviews/store/reducer.js.map +1 -0
- package/build/hooks/pattern-overrides.js +2 -1
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +2 -6
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +0 -2
- package/build/private-apis.native.js.map +1 -1
- package/build/store/private-actions.js +21 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +5 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +4 -1
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +14 -5
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/document-tools/index.js +12 -3
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor/index.js +71 -0
- package/build-module/components/editor/index.js.map +1 -0
- package/build-module/components/editor-interface/index.js +6 -8
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +28 -0
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +9 -2
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/back-button.js +4 -1
- package/build-module/components/header/back-button.js.map +1 -1
- package/build-module/components/header/index.js +1 -5
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/index.js +7 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -1
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +10 -4
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +34 -11
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +1 -0
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -0
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +6 -0
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +5 -0
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-sticky/check.js +9 -0
- package/build-module/components/post-sticky/check.js.map +1 -1
- package/build-module/components/post-sticky/index.js +6 -0
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +10 -1
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +7 -1
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js +9 -0
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +14 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +9 -0
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js +10 -0
- package/build-module/components/post-taxonomies/panel.js.map +1 -1
- package/build-module/components/post-title/index.js +4 -8
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js +3 -7
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-trash/check.js +9 -0
- package/build-module/components/post-trash/check.js.map +1 -1
- package/build-module/components/post-trash/index.js +7 -0
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-url/panel.js +26 -3
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/post-visibility/index.js +1 -0
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/index.js +18 -15
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +3 -2
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +11 -0
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/template-part-menu-items/convert-to-regular.js +31 -0
- package/build-module/components/template-part-menu-items/convert-to-regular.js.map +1 -0
- package/build-module/components/template-part-menu-items/convert-to-template-part.js +71 -0
- package/build-module/components/template-part-menu-items/convert-to-template-part.js.map +1 -0
- package/build-module/components/template-part-menu-items/index.js +59 -0
- package/build-module/components/template-part-menu-items/index.js.map +1 -0
- package/build-module/components/template-part-menu-items/index.native.js +4 -0
- package/build-module/components/template-part-menu-items/index.native.js.map +1 -0
- package/build-module/components/template-validation-notice/index.js +1 -0
- package/build-module/components/template-validation-notice/index.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +10 -0
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/components/time-to-read/index.js +6 -0
- package/build-module/components/time-to-read/index.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -0
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/word-count/index.js +6 -0
- package/build-module/components/word-count/index.js.map +1 -1
- package/build-module/dataviews/api.js +54 -0
- package/build-module/dataviews/api.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js +21 -0
- package/build-module/dataviews/store/private-actions.js.map +1 -0
- package/build-module/dataviews/store/private-selectors.js +14 -0
- package/build-module/dataviews/store/private-selectors.js.map +1 -0
- package/build-module/dataviews/store/reducer.js +29 -0
- package/build-module/dataviews/store/reducer.js.map +1 -0
- package/build-module/hooks/pattern-overrides.js +2 -1
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +2 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +0 -2
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/private-actions.js +1 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +3 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +35 -43
- package/build-style/style.css +35 -43
- package/build-types/dataviews/store/private-actions.d.ts +17 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -0
- package/build-types/dataviews/store/private-selectors.d.ts +10 -0
- package/build-types/dataviews/store/private-selectors.d.ts.map +1 -0
- package/build-types/dataviews/store/reducer.d.ts +11 -0
- package/build-types/dataviews/store/reducer.d.ts.map +1 -0
- package/package.json +35 -35
- package/src/components/block-settings-menu/content-only-settings-menu.js +26 -12
- package/src/components/collapsible-block-toolbar/style.scss +3 -1
- package/src/components/document-tools/index.js +13 -4
- package/src/components/editor/index.js +88 -0
- package/src/components/editor-interface/index.js +5 -5
- package/src/components/editor-interface/style.scss +3 -0
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +9 -0
- package/src/components/entities-saved-states/index.js +26 -0
- package/src/components/entities-saved-states/style.scss +0 -7
- package/src/components/global-styles-provider/index.js +12 -2
- package/src/components/header/back-button.js +6 -1
- package/src/components/header/index.js +1 -8
- package/src/components/header/style.scss +1 -1
- package/src/components/index.js +7 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -3
- package/src/components/media-categories/index.js +1 -3
- package/src/components/post-actions/actions.js +9 -3
- package/src/components/post-card-panel/style.scss +4 -0
- package/src/components/post-last-revision/index.js +30 -7
- package/src/components/post-last-revision/style.scss +4 -0
- package/src/components/post-panel-row/style.scss +2 -1
- package/src/components/post-preview-button/index.js +1 -0
- package/src/components/post-preview-button/test/index.js +10 -2
- package/src/components/post-publish-button/index.js +3 -0
- package/src/components/post-publish-button/label.js +5 -0
- package/src/components/post-publish-panel/index.js +4 -0
- package/src/components/post-publish-panel/style.scss +28 -36
- package/src/components/post-status/style.scss +5 -0
- package/src/components/post-sticky/check.js +8 -0
- package/src/components/post-sticky/index.js +5 -0
- package/src/components/post-switch-to-draft-button/index.js +10 -1
- package/src/components/post-sync-status/index.js +7 -8
- package/src/components/post-taxonomies/check.js +8 -0
- package/src/components/post-taxonomies/flat-term-selector.js +13 -2
- package/src/components/post-taxonomies/index.js +8 -0
- package/src/components/post-taxonomies/panel.js +9 -0
- package/src/components/post-title/index.js +2 -5
- package/src/components/post-title/post-title-raw.js +2 -5
- package/src/components/post-trash/check.js +8 -0
- package/src/components/post-trash/index.js +6 -0
- package/src/components/post-url/panel.js +13 -5
- package/src/components/post-visibility/index.js +1 -0
- package/src/components/provider/disable-non-page-content-blocks.js +9 -4
- package/src/components/provider/index.js +17 -17
- package/src/components/save-publish-panels/style.scss +0 -8
- package/src/components/sidebar/post-summary.js +3 -1
- package/src/components/table-of-contents/index.js +10 -0
- package/src/components/template-part-menu-items/convert-to-regular.js +32 -0
- package/src/components/template-part-menu-items/convert-to-template-part.js +75 -0
- package/src/components/template-part-menu-items/index.js +59 -0
- package/src/components/template-part-menu-items/index.native.js +3 -0
- package/src/components/template-validation-notice/index.js +1 -0
- package/src/components/theme-support-check/index.js +9 -0
- package/src/components/time-to-read/index.js +5 -0
- package/src/components/visual-editor/edit-template-blocks-notification.js +1 -0
- package/src/components/word-count/index.js +5 -0
- package/src/dataviews/api.js +55 -0
- package/src/dataviews/store/private-actions.ts +30 -0
- package/src/dataviews/store/private-selectors.ts +15 -0
- package/src/dataviews/store/reducer.ts +44 -0
- package/src/hooks/pattern-overrides.js +2 -0
- package/src/index.js +1 -0
- package/src/private-apis.js +2 -6
- package/src/private-apis.native.js +0 -2
- package/src/store/private-actions.js +1 -0
- package/src/store/private-selectors.js +5 -0
- package/src/store/reducer.js +2 -0
- package/src/style.scss +1 -0
- package/tsconfig.json +36 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_i18n","_notices","_blockEditor","_preferences","_url","_apiFetch","_interopRequireDefault","_blocks","_htmlEntities","_isTemplateRevertable","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","coreStore","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","noticesStore","createSuccessNotice","__","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","exports","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","preferencesStore","get","newBlockNames","filter","Array","isArray","includes","set","hideBlockTypes","_registry$select$get2","mergedBlockNames","Set","saveDirtyEntities","onSave","dirtyEntityRecords","entitiesToSkip","close","PUBLISH_ON_SAVE_ENTITIES","kind","name","saveNoticeId","homeUrl","getUnstableBase","home","removeNotice","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","blockEditorStore","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","isTemplateRevertable","templateEntityConfig","getEntityConfig","fileTemplatePath","addQueryArgs","baseURL","context","source","fileTemplate","apiFetch","path","serializeBlocks","blocks","blocksForSerialization","__unstableSerializeAndClean","edited","getEditedEntityRecord","content","undoIgnore","parse","raw","undoRevert","errorMessage","message","code","removeTemplates","items","promiseResult","allSettled","map","item","deleteEntityRecord","force","throwOnError","every","successMessage","title","rendered","sprintf","decodeEntities","reason","errorMessages","failedPromises","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n */\nexport const saveDirtyEntities =\n\t( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry.select( coreStore ).getUnstableBase()?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: 'theme' }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with sucess.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tconst title =\n\t\t\t\t\ttypeof items[ 0 ].title === 'string'\n\t\t\t\t\t\t? items[ 0 ].title\n\t\t\t\t\t\t: items[ 0 ].title?.rendered;\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while deleting the items: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAKA,IAAAU,qBAAA,GAAAH,sBAAA,CAAAP,OAAA;AAhBA;AACA;AACA;;AAWA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,oBAAoBA,CAAEC,EAAE,EAAG;EAC1C,OAAO;IACNC,IAAI,EAAE,yBAAyB;IAC/BD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAME,cAAc,GACxBC,QAAQ,IACV,OAAQ;EAAEC,MAAM;EAAEC,QAAQ;EAAEC;AAAS,CAAC,KAAM;EAC3C,MAAMC,aAAa,GAAG,MAAMD,QAAQ,CAClCD,QAAQ,CAAEG,eAAU,CAAC,CACrBC,gBAAgB,CAAE,UAAU,EAAE,aAAa,EAAEN,QAAS,CAAC;EACzDG,QAAQ,CACND,QAAQ,CAAEG,eAAU,CAAC,CACrBE,gBAAgB,CAChB,UAAU,EAC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2G,aAAa,CAACI,IAAI,KAAK,CAAC,EAAG;QACtCvB,YAAY,GAAG,IAAAgB,aAAO,GACrB;QACA,IAAAxG,QAAE,EAAE,gDAAiD,CAAC,EACtD,CAAE,GAAG2G,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;MACF,CAAC,MAAM;QACN,IAAAH,aAAO,GACN;QACA,IAAAxG,QAAE,EACD,mDACD,CAAC,EACD,CAAE,GAAG2G,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAChC,CAAC;MACF;IACD;IACA1H,QAAQ,CACND,QAAQ,CAAES,cAAa,CAAC,CACxB6D,iBAAiB,CAAE6B,YAAY,EAAE;MAAEvG,IAAI,EAAE;IAAW,CAAE,CAAC;EAC1D;AACD,CAAC;AAACsB,OAAA,CAAAoF,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_coreData","require","_i18n","_notices","_blockEditor","_preferences","_url","_apiFetch","_interopRequireDefault","_blocks","_htmlEntities","_isTemplateRevertable","_privateActions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","coreStore","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","noticesStore","createSuccessNotice","__","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","preferencesStore","newBlockNames","filter","Array","isArray","includes","set","hideBlockTypes","_registry$select$get2","mergedBlockNames","Set","saveDirtyEntities","onSave","dirtyEntityRecords","entitiesToSkip","close","PUBLISH_ON_SAVE_ENTITIES","kind","name","saveNoticeId","homeUrl","getUnstableBase","home","removeNotice","entitiesToSave","property","some","elt","siteItemsToSave","pendingSavedRecords","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","blockEditorStore","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","isTemplateRevertable","templateEntityConfig","getEntityConfig","fileTemplatePath","addQueryArgs","baseURL","context","source","fileTemplate","apiFetch","path","serializeBlocks","blocks","blocksForSerialization","__unstableSerializeAndClean","edited","getEditedEntityRecord","content","undoIgnore","parse","raw","undoRevert","errorMessage","message","code","removeTemplates","items","promiseResult","allSettled","map","item","deleteEntityRecord","force","throwOnError","every","successMessage","title","rendered","sprintf","decodeEntities","reason","errorMessages","failedPromises","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n */\nexport const saveDirtyEntities =\n\t( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry.select( coreStore ).getUnstableBase()?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: 'theme' }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with sucess.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tconst title =\n\t\t\t\t\ttypeof items[ 0 ].title === 'string'\n\t\t\t\t\t\t? items[ 0 ].title\n\t\t\t\t\t\t: items[ 0 ].title?.rendered;\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while deleting the items: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAKA,IAAAU,qBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAAAY,MAAA,CAAAC,IAAA,CAAAF,eAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,eAAA,CAAAI,GAAA;EAAAH,M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|
|
6
6
|
});
|
|
7
7
|
exports.getCurrentTemplateTemplateParts = void 0;
|
|
8
|
+
exports.getEntityActions = getEntityActions;
|
|
8
9
|
exports.getInserterSidebarToggleRef = getInserterSidebarToggleRef;
|
|
9
10
|
exports.getInsertionPoint = void 0;
|
|
10
11
|
exports.getListViewToggleRef = getListViewToggleRef;
|
|
@@ -17,6 +18,7 @@ var _coreData = require("@wordpress/core-data");
|
|
|
17
18
|
var _selectors = require("./selectors");
|
|
18
19
|
var _constants = require("./constants");
|
|
19
20
|
var _getFilteredTemplateParts = require("./utils/get-filtered-template-parts");
|
|
21
|
+
var _privateSelectors = require("../dataviews/store/private-selectors");
|
|
20
22
|
/**
|
|
21
23
|
* External dependencies
|
|
22
24
|
*/
|
|
@@ -138,4 +140,7 @@ const hasPostMetaChanges = exports.hasPostMetaChanges = (0, _data.createRegistry
|
|
|
138
140
|
footnotes: undefined
|
|
139
141
|
});
|
|
140
142
|
});
|
|
143
|
+
function getEntityActions(state, ...args) {
|
|
144
|
+
return (0, _privateSelectors.getEntityActions)(state.dataviews, ...args);
|
|
145
|
+
}
|
|
141
146
|
//# sourceMappingURL=private-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fastDeepEqual","_interopRequireDefault","require","_blockEditor","_data","_icons","_coreData","_selectors","_constants","_getFilteredTemplateParts","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","filterValue","getInsertionPoint","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","__experimentalGetDefaultTemplatePartAreas","find","item","area","icon","layout","postTypeEntity","coreStore","getPostType","startsWith","slice","getCurrentTemplateTemplateParts","templateParts","getEntityRecords","TEMPLATE_PART_POST_TYPE","per_page","clientIds","blocks","getBlocksByClientId","getFilteredTemplatePartBlocks","hasPostMetaChanges","postId","type","currentPostType","id","currentPostId","getCurrentPost","edits","getEntityRecordNonTransientEdits","meta","originalPostMeta","getEntityRecord","fastDeepEqual","footnotes"],"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 {\n\tgetRenderingMode,\n\tgetCurrentPost,\n\t__experimentalGetDefaultTemplatePartAreas,\n} from './selectors';\nimport { TEMPLATE_PART_POST_TYPE } from './constants';\nimport { getFilteredTemplatePartBlocks } from './utils/get-filtered-template-parts';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * Get the insertion point for 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 getInsertionPoint = 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__experimentalGetDefaultTemplatePartAreas( state ).find(\n\t\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t\t)?.icon || layout\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 ( postTypeEntity?.icon?.startsWith( 'dashicons-' ) ) {\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 the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst templateParts = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\tconst clientIds =\n\t\t\tselect( blockEditorStore ).getBlocksByName( 'core/template-part' );\n\t\tconst blocks =\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds );\n\n\t\treturn getFilteredTemplatePartBlocks( blocks, templateParts );\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"],"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;AAK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ACnE,MAAMkC,MAAM,GACXzC,MAAM,CAAEM,kBAAiB,CAAC,CAACoC,mBAAmB,CAAEF,SAAU,CAAC;EAE5D,OAAO,IAAAG,uDAA6B,EAAEF,MAAM,EAAEL,aAAc,CAAC;AAC9D,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMQ,kBAAkB,GAAA9C,OAAA,CAAA8C,kBAAA,GAAG,IAAA7C,4BAAsB,EACrDC,MAAM,IAAM,CAAEE,KAAK,EAAEoB,QAAQ,EAAEuB,MAAM,KAAM;EAC5C,MAAM;IAAEC,IAAI,EAAEC,eAAe;IAAEC,EAAE,EAAEC;EAAc,CAAC,GACjD,IAAAC,yBAAc,EAAEhD,KAAM,CAAC;EACxB;EACA,MAAMiD,KAAK,GAAGnD,MAAM,CAAE+B,eAAU,CAAC,CAACqB,gCAAgC,CACjE,UAAU,EACV9B,QAAQ,IAAIyB,eAAe,EAC3BF,MAAM,IAAII,aACX,CAAC;EAED,IAAK,CAAEE,KAAK,EAAEE,IAAI,EAAG;IACpB,OAAO,KAAK;EACb;;EAEA;EACA,MAAMC,gBAAgB,GAAGtD,MAAM,CAAE+B,eAAU,CAAC,CAACwB,eAAe,CAC3D,UAAU,EACVjC,QAAQ,IAAIyB,eAAe,EAC3BF,MAAM,IAAII,aACX,CAAC,EAAEI,IAAI;EAEP,OAAO,CAAE,IAAAG,sBAAa,EACrB;IAAE,GAAGF,gBAAgB;IAAEG,SAAS,EAAE/D;EAAU,CAAC,EAC7C;IAAE,GAAGyD,KAAK,CAACE,IAAI;IAAEI,SAAS,EAAE/D;EAAU,CACvC,CAAC;AACF,CACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_fastDeepEqual","_interopRequireDefault","require","_blockEditor","_data","_icons","_coreData","_selectors","_constants","_getFilteredTemplateParts","_privateSelectors","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","filterValue","getInsertionPoint","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","__experimentalGetDefaultTemplatePartAreas","find","item","area","icon","layout","postTypeEntity","coreStore","getPostType","startsWith","slice","getCurrentTemplateTemplateParts","templateParts","getEntityRecords","TEMPLATE_PART_POST_TYPE","per_page","clientIds","blocks","getBlocksByClientId","getFilteredTemplatePartBlocks","hasPostMetaChanges","postId","type","currentPostType","id","currentPostId","getCurrentPost","edits","getEntityRecordNonTransientEdits","meta","originalPostMeta","getEntityRecord","fastDeepEqual","footnotes","getEntityActions","args","_getEntityActions","dataviews"],"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 {\n\tgetRenderingMode,\n\tgetCurrentPost,\n\t__experimentalGetDefaultTemplatePartAreas,\n} from './selectors';\nimport { TEMPLATE_PART_POST_TYPE } from './constants';\nimport { getFilteredTemplatePartBlocks } from './utils/get-filtered-template-parts';\nimport { getEntityActions as _getEntityActions } 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 insertion point for 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 getInsertionPoint = 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__experimentalGetDefaultTemplatePartAreas( state ).find(\n\t\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t\t)?.icon || layout\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 ( postTypeEntity?.icon?.startsWith( 'dashicons-' ) ) {\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 the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst templateParts = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\tconst clientIds =\n\t\t\tselect( blockEditorStore ).getBlocksByName( 'core/template-part' );\n\t\tconst blocks =\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds );\n\n\t\treturn getFilteredTemplatePartBlocks( blocks, templateParts );\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"],"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;AAKA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,yBAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAUA,MAAMS,qBAAqB,GAAG;EAC7BC,YAAY,EAAEC,SAAS;EACvBC,cAAc,EAAED,SAAS;EACzBE,WAAW,EAAEF;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAAE,4BAAsB,EAAIC,MAAM,IAChE,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,KAAM,CAAC,KAAK,iBAAiB,EAAG;IACtD,MAAM,CAAEG,mBAAmB,CAAE,GAC5BL,MAAM,CAAEM,kBAAiB,CAAC,CAACC,eAAe,CACzC,mBACD,CAAC;IACF,IAAKF,mBAAmB,EAAG;MAC1B,OAAO;QACNZ,YAAY,EAAEY,mBAAmB;QACjCV,cAAc,EAAED,SAAS;QACzBE,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C,CAACwB,eAAe,CAC3D,UAAU,EACVjC,QAAQ,IAAIyB,eAAe,EAC3BF,MAAM,IAAII,aACX,CAAC,EAAEI,IAAI;EAEP,OAAO,CAAE,IAAAG,sBAAa,EACrB;IAAE,GAAGF,gBAAgB;IAAEG,SAAS,EAAE/D;EAAU,CAAC,EAC7C;IAAE,GAAGyD,KAAK,CAACE,IAAI;IAAEI,SAAS,EAAE/D;EAAU,CACvC,CAAC;AACF,CACD,CAAC;AAEM,SAASgE,gBAAgBA,CAAExD,KAAK,EAAE,GAAGyD,IAAI,EAAG;EAClD,OAAO,IAAAC,kCAAiB,EAAE1D,KAAK,CAAC2D,SAAS,EAAE,GAAGF,IAAK,CAAC;AACrD","ignoreList":[]}
|
package/build/store/reducer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -28,6 +29,7 @@ exports.template = template;
|
|
|
28
29
|
exports.templateId = templateId;
|
|
29
30
|
var _data = require("@wordpress/data");
|
|
30
31
|
var _defaults = require("./defaults");
|
|
32
|
+
var _reducer = _interopRequireDefault(require("../dataviews/store/reducer"));
|
|
31
33
|
/**
|
|
32
34
|
* WordPress dependencies
|
|
33
35
|
*/
|
|
@@ -421,6 +423,7 @@ var _default = exports.default = (0, _data.combineReducers)({
|
|
|
421
423
|
inserterSidebarToggleRef,
|
|
422
424
|
listViewPanel,
|
|
423
425
|
listViewToggleRef,
|
|
424
|
-
publishSidebarActive
|
|
426
|
+
publishSidebarActive,
|
|
427
|
+
dataviews: _reducer.default
|
|
425
428
|
});
|
|
426
429
|
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_defaults","getPostRawValue","value","raw","hasSameKeys","a","b","keysA","Object","keys","sort","keysB","length","every","key","index","isUpdatingSamePostProperty","action","previousAction","type","edits","shouldOverwriteState","shouldCreateUndoLevel","postId","state","templateId","id","postType","template","isValid","saving","pending","options","deleting","postLock","isLocked","lock","postSavingLock","lockName","removedLockName","restState","postAutosavingLock","editorSettings","EDITOR_SETTINGS_DEFAULTS","settings","renderingMode","mode","deviceType","removedPanels","includes","panelName","blockInserterPanel","isOpen","listViewPanel","listViewToggleRef","current","inserterSidebarToggleRef","publishSidebarActive","_default","exports","default","combineReducers"],"sources":["@wordpress/editor/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { EDITOR_SETTINGS_DEFAULTS } from './defaults';\n\n/**\n * Returns a post attribute value, flattening nested rendered content using its\n * raw value in place of its original object form.\n *\n * @param {*} value Original value.\n *\n * @return {*} Raw value.\n */\nexport function getPostRawValue( value ) {\n\tif ( value && 'object' === typeof value && 'raw' in value ) {\n\t\treturn value.raw;\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns true if the two object arguments have the same keys, or false\n * otherwise.\n *\n * @param {Object} a First object.\n * @param {Object} b Second object.\n *\n * @return {boolean} Whether the two objects have the same keys.\n */\nexport function hasSameKeys( a, b ) {\n\tconst keysA = Object.keys( a ).sort();\n\tconst keysB = Object.keys( b ).sort();\n\treturn (\n\t\tkeysA.length === keysB.length &&\n\t\tkeysA.every( ( key, index ) => keysB[ index ] === key )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are editing the same post property, or\n * false otherwise.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether actions are updating the same post property.\n */\nexport function isUpdatingSamePostProperty( action, previousAction ) {\n\treturn (\n\t\taction.type === 'EDIT_POST' &&\n\t\thasSameKeys( action.edits, previousAction.edits )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are modifying the same property such that\n * undo history should be batched.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether to overwrite present state.\n */\nexport function shouldOverwriteState( action, previousAction ) {\n\tif ( action.type === 'RESET_EDITOR_BLOCKS' ) {\n\t\treturn ! action.shouldCreateUndoLevel;\n\t}\n\n\tif ( ! previousAction || action.type !== previousAction.type ) {\n\t\treturn false;\n\t}\n\n\treturn isUpdatingSamePostProperty( action, previousAction );\n}\n\nexport function postId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postId;\n\t}\n\n\treturn state;\n}\n\nexport function templateId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CURRENT_TEMPLATE_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\nexport function postType( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning whether the post blocks match the defined template or not.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function template( state = { isValid: true }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE_VALIDITY':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisValid: action.isValid,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning current network request state (whether a request to\n * the WP REST API is in progress, successful, or failed).\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function saving( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_UPDATE_START':\n\t\tcase 'REQUEST_POST_UPDATE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_UPDATE_START',\n\t\t\t\toptions: action.options || {},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning deleting post request state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deleting( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_DELETE_START':\n\t\tcase 'REQUEST_POST_DELETE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_DELETE_START',\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Post Lock State.\n *\n * @typedef {Object} PostLockState\n *\n * @property {boolean} isLocked Whether the post is locked.\n * @property {?boolean} isTakeover Whether the post editing has been taken over.\n * @property {?boolean} activePostLock Active post lock value.\n * @property {?Object} user User that took over the post.\n */\n\n/**\n * Reducer returning the post lock status.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postLock( state = { isLocked: false }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_POST_LOCK':\n\t\t\treturn action.lock;\n\t}\n\n\treturn state;\n}\n\n/**\n * Post saving lock.\n *\n * When post saving is locked, the post cannot be published or updated.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postSavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_SAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_SAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Post autosaving lock.\n *\n * When post autosaving is locked, the post will not autosave.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postAutosavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_AUTOSAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_AUTOSAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the post editor setting.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_EDITOR_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function renderingMode( state = 'post-only', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_RENDERING_MODE':\n\t\t\treturn action.mode;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer storing the list of all programmatically removed panels.\n *\n * @param {Array} state Current state.\n * @param {Object} action Action object.\n *\n * @return {Array} Updated state.\n */\nexport function removedPanels( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REMOVE_PANEL':\n\t\t\tif ( ! state.includes( action.panelName ) ) {\n\t\t\t\treturn [ ...state, action.panelName ];\n\t\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the list view toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the list view toggle button.\n */\nexport function listViewToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the inserter sidebar toggle button.\n */\nexport function inserterSidebarToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\nexport function publishSidebarActive( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_PUBLISH_SIDEBAR':\n\t\t\treturn true;\n\t\tcase 'CLOSE_PUBLISH_SIDEBAR':\n\t\t\treturn false;\n\t\tcase 'TOGGLE_PUBLISH_SIDEBAR':\n\t\t\treturn ! state;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpostId,\n\tpostType,\n\ttemplateId,\n\tsaving,\n\tdeleting,\n\tpostLock,\n\ttemplate,\n\tpostSavingLock,\n\teditorSettings,\n\tpostAutosavingLock,\n\trenderingMode,\n\tdeviceType,\n\tremovedPanels,\n\tblockInserterPanel,\n\tinserterSidebarToggleRef,\n\tlistViewPanel,\n\tlistViewToggleRef,\n\tpublishSidebarActive,\n} );\n"],"mappings":";;;;;;;;;;;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AkC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,qBAAe,EAAE;EAC/BtC,MAAM;EACNI,QAAQ;EACRF,UAAU;EACVK,MAAM;EACNG,QAAQ;EACRC,QAAQ;EACRN,QAAQ;EACRS,cAAc;EACdK,cAAc;EACdD,kBAAkB;EAClBI,aAAa;EACbE,UAAU;EACVC,aAAa;EACbG,kBAAkB;EAClBK,wBAAwB;EACxBH,aAAa;EACbC,iBAAiB;EACjBG;AACD,CAAE,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_defaults","_reducer","_interopRequireDefault","getPostRawValue","value","raw","hasSameKeys","a","b","keysA","Object","keys","sort","keysB","length","every","key","index","isUpdatingSamePostProperty","action","previousAction","type","edits","shouldOverwriteState","shouldCreateUndoLevel","postId","state","templateId","id","postType","template","isValid","saving","pending","options","deleting","postLock","isLocked","lock","postSavingLock","lockName","removedLockName","restState","postAutosavingLock","editorSettings","EDITOR_SETTINGS_DEFAULTS","settings","renderingMode","mode","deviceType","removedPanels","includes","panelName","blockInserterPanel","isOpen","listViewPanel","listViewToggleRef","current","inserterSidebarToggleRef","publishSidebarActive","_default","exports","default","combineReducers","dataviews","dataviewsReducer"],"sources":["@wordpress/editor/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { EDITOR_SETTINGS_DEFAULTS } from './defaults';\nimport dataviewsReducer from '../dataviews/store/reducer';\n\n/**\n * Returns a post attribute value, flattening nested rendered content using its\n * raw value in place of its original object form.\n *\n * @param {*} value Original value.\n *\n * @return {*} Raw value.\n */\nexport function getPostRawValue( value ) {\n\tif ( value && 'object' === typeof value && 'raw' in value ) {\n\t\treturn value.raw;\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns true if the two object arguments have the same keys, or false\n * otherwise.\n *\n * @param {Object} a First object.\n * @param {Object} b Second object.\n *\n * @return {boolean} Whether the two objects have the same keys.\n */\nexport function hasSameKeys( a, b ) {\n\tconst keysA = Object.keys( a ).sort();\n\tconst keysB = Object.keys( b ).sort();\n\treturn (\n\t\tkeysA.length === keysB.length &&\n\t\tkeysA.every( ( key, index ) => keysB[ index ] === key )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are editing the same post property, or\n * false otherwise.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether actions are updating the same post property.\n */\nexport function isUpdatingSamePostProperty( action, previousAction ) {\n\treturn (\n\t\taction.type === 'EDIT_POST' &&\n\t\thasSameKeys( action.edits, previousAction.edits )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are modifying the same property such that\n * undo history should be batched.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether to overwrite present state.\n */\nexport function shouldOverwriteState( action, previousAction ) {\n\tif ( action.type === 'RESET_EDITOR_BLOCKS' ) {\n\t\treturn ! action.shouldCreateUndoLevel;\n\t}\n\n\tif ( ! previousAction || action.type !== previousAction.type ) {\n\t\treturn false;\n\t}\n\n\treturn isUpdatingSamePostProperty( action, previousAction );\n}\n\nexport function postId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postId;\n\t}\n\n\treturn state;\n}\n\nexport function templateId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CURRENT_TEMPLATE_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\nexport function postType( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning whether the post blocks match the defined template or not.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function template( state = { isValid: true }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE_VALIDITY':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisValid: action.isValid,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning current network request state (whether a request to\n * the WP REST API is in progress, successful, or failed).\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function saving( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_UPDATE_START':\n\t\tcase 'REQUEST_POST_UPDATE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_UPDATE_START',\n\t\t\t\toptions: action.options || {},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning deleting post request state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deleting( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_DELETE_START':\n\t\tcase 'REQUEST_POST_DELETE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_DELETE_START',\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Post Lock State.\n *\n * @typedef {Object} PostLockState\n *\n * @property {boolean} isLocked Whether the post is locked.\n * @property {?boolean} isTakeover Whether the post editing has been taken over.\n * @property {?boolean} activePostLock Active post lock value.\n * @property {?Object} user User that took over the post.\n */\n\n/**\n * Reducer returning the post lock status.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postLock( state = { isLocked: false }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_POST_LOCK':\n\t\t\treturn action.lock;\n\t}\n\n\treturn state;\n}\n\n/**\n * Post saving lock.\n *\n * When post saving is locked, the post cannot be published or updated.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postSavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_SAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_SAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Post autosaving lock.\n *\n * When post autosaving is locked, the post will not autosave.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postAutosavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_AUTOSAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_AUTOSAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the post editor setting.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_EDITOR_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function renderingMode( state = 'post-only', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_RENDERING_MODE':\n\t\t\treturn action.mode;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer storing the list of all programmatically removed panels.\n *\n * @param {Array} state Current state.\n * @param {Object} action Action object.\n *\n * @return {Array} Updated state.\n */\nexport function removedPanels( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REMOVE_PANEL':\n\t\t\tif ( ! state.includes( action.panelName ) ) {\n\t\t\t\treturn [ ...state, action.panelName ];\n\t\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the list view toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the list view toggle button.\n */\nexport function listViewToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the inserter sidebar toggle button.\n */\nexport function inserterSidebarToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\nexport function publishSidebarActive( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_PUBLISH_SIDEBAR':\n\t\t\treturn true;\n\t\tcase 'CLOSE_PUBLISH_SIDEBAR':\n\t\t\treturn false;\n\t\tcase 'TOGGLE_PUBLISH_SIDEBAR':\n\t\t\treturn ! state;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpostId,\n\tpostType,\n\ttemplateId,\n\tsaving,\n\tdeleting,\n\tpostLock,\n\ttemplate,\n\tpostSavingLock,\n\teditorSettings,\n\tpostAutosavingLock,\n\trenderingMode,\n\tdeviceType,\n\tremovedPanels,\n\tblockInserterPanel,\n\tinserterSidebarToggleRef,\n\tlistViewPanel,\n\tlistViewToggleRef,\n\tpublishSidebarActive,\n\tdataviews: dataviewsReducer,\n} );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,eAAeA,CAAEC,KAAK,EAAG;EACxC,IAAKA,KAAK,IAAI,QAAQ,KAAK,OAAOA,KAAK,IAAI,KAAK,IAAIA,KAAK,EAAG;IAC3D,OAAOA,KAAK,CAACC,GAAG;EACjB;EAEA,OAAOD,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,WAAWA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACnC,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAEJ,CAAE,CAAC,CAACK,IAAI,CAAC,CAAC;EACrC,MAAMC,KAAK,GAAGH,MAAM,CAACC,IAAI,CAAEH,CAAE,CAAC,CAACI,IAAI,CAAC,CAAC;EACrC,OACCH,KAAK,CAACK,MAAM,KAAKD,KAAK,CAACC,MAAM,IAC7BL,KAAK,CAACM,KAAK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AACA;AACA;AACA;AACA;AACA;AACO,SAAS8B,iBAAiBA,CAAE9B,KAAK,GAAG;EAAE+B,OAAO,EAAE;AAAK,CAAC,EAAG;EAC9D,OAAO/B,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASgC,wBAAwBA,CAAEhC,KAAK,GAAG;EAAE+B,OAAO,EAAE;AAAK,CAAC,EAAG;EACrE,OAAO/B,KAAK;AACb;AAEO,SAASiC,oBAAoBA,CAAEjC,KAAK,GAAG,KAAK,EAAEP,MAAM,EAAG;EAC7D,QAASA,MAAM,CAACE,IAAI;IACnB,KAAK,sBAAsB;MAC1B,OAAO,IAAI;IACZ,KAAK,uBAAuB;MAC3B,OAAO,KAAK;IACb,KAAK,wBAAwB;MAC5B,OAAO,CAAEK,KAAK;EAChB;EACA,OAAOA,KAAK;AACb;AAAC,IAAAkC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,qBAAe,EAAE;EAC/BtC,MAAM;EACNI,QAAQ;EACRF,UAAU;EACVK,MAAM;EACNG,QAAQ;EACRC,QAAQ;EACRN,QAAQ;EACRS,cAAc;EACdK,cAAc;EACdD,kBAAkB;EAClBI,aAAa;EACbE,UAAU;EACVC,aAAa;EACbG,kBAAkB;EAClBK,wBAAwB;EACxBH,aAAa;EACbC,iBAAiB;EACjBG,oBAAoB;EACpBK,SAAS,EAAEC;AACZ,CAAE,CAAC","ignoreList":[]}
|
|
@@ -21,7 +21,8 @@ function ContentOnlySettingsMenuItems({
|
|
|
21
21
|
}) {
|
|
22
22
|
const {
|
|
23
23
|
entity,
|
|
24
|
-
onNavigateToEntityRecord
|
|
24
|
+
onNavigateToEntityRecord,
|
|
25
|
+
canEditTemplates
|
|
25
26
|
} = useSelect(select => {
|
|
26
27
|
const {
|
|
27
28
|
getBlockEditingMode,
|
|
@@ -39,16 +40,19 @@ function ContentOnlySettingsMenuItems({
|
|
|
39
40
|
record = select(coreStore).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
|
|
40
41
|
} else {
|
|
41
42
|
const {
|
|
42
|
-
getCurrentPostType,
|
|
43
43
|
getCurrentTemplateId
|
|
44
44
|
} = select(editorStore);
|
|
45
|
-
const currentPostType = getCurrentPostType();
|
|
46
45
|
const templateId = getCurrentTemplateId();
|
|
47
|
-
|
|
46
|
+
const {
|
|
47
|
+
getContentLockingParent
|
|
48
|
+
} = unlock(select(blockEditorStore));
|
|
49
|
+
if (!getContentLockingParent(clientId) && templateId) {
|
|
48
50
|
record = select(coreStore).getEntityRecord('postType', 'wp_template', templateId);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
const _canEditTemplates = select(coreStore).canUser('create', 'templates');
|
|
51
54
|
return {
|
|
55
|
+
canEditTemplates: _canEditTemplates,
|
|
52
56
|
entity: record,
|
|
53
57
|
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
|
|
54
58
|
};
|
|
@@ -60,6 +64,10 @@ function ContentOnlySettingsMenuItems({
|
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
const isPattern = entity.type === 'wp_block';
|
|
67
|
+
let helpText = isPattern ? __('Edit the pattern to move, delete, or make further changes to this block.') : __('Edit the template to move, delete, or make further changes to this block.');
|
|
68
|
+
if (!canEditTemplates) {
|
|
69
|
+
helpText = __('Only users with permissions to edit the template can move or delete this block');
|
|
70
|
+
}
|
|
63
71
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
64
72
|
children: [/*#__PURE__*/_jsx(BlockSettingsMenuFirstItem, {
|
|
65
73
|
children: /*#__PURE__*/_jsx(MenuItem, {
|
|
@@ -69,13 +77,14 @@ function ContentOnlySettingsMenuItems({
|
|
|
69
77
|
postType: entity.type
|
|
70
78
|
});
|
|
71
79
|
},
|
|
80
|
+
disabled: !canEditTemplates,
|
|
72
81
|
children: isPattern ? __('Edit pattern') : __('Edit template')
|
|
73
82
|
})
|
|
74
83
|
}), /*#__PURE__*/_jsx(Text, {
|
|
75
84
|
variant: "muted",
|
|
76
85
|
as: "p",
|
|
77
86
|
className: "editor-content-only-settings-menu__description",
|
|
78
|
-
children:
|
|
87
|
+
children: helpText
|
|
79
88
|
})]
|
|
80
89
|
});
|
|
81
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockSettingsMenuControls","__unstableBlockSettingsMenuFirstItem","BlockSettingsMenuFirstItem","store","blockEditorStore","useBlockDisplayInformation","coreStore","__experimentalText","Text","MenuItem","useSelect","useDispatch","__","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ContentOnlySettingsMenuItems","clientId","onClose","entity","onNavigateToEntityRecord","select","getBlockEditingMode","getBlockParentsByBlockName","getSettings","getBlockAttributes","contentOnly","patternParent","record","getEntityRecord","ref","getCurrentPostType","getCurrentTemplateId","currentPostType","templateId","TemplateLockContentOnlyMenuItems","isPattern","type","children","onClick","postId","id","postType","variant","as","className","contentLockingParent","getContentLockingParent","blockDisplayInformation","modifyContentLockBlock","selectBlock","title","ContentOnlySettingsMenu","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst { entity, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst contentOnly =\n\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly';\n\t\t\tif ( ! contentOnly ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { getCurrentPostType, getCurrentTemplateId } =\n\t\t\t\t\tselect( editorStore );\n\t\t\t\tconst currentPostType = getCurrentPostType();\n\t\t\t\tconst templateId = getCurrentTemplateId();\n\t\t\t\tif ( currentPostType === 'page' && templateId ) {\n\t\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\ttemplateId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ isPattern\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t\t\t\t ) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\t// Disable reason: We're using a hook here so it has to be on top-level.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { modifyContentLockBlock, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tselectBlock( contentLockingParent );\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Unlock' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,yBAAyB,EACzBC,oCAAoC,IAAIC,0BAA0B,EAClEC,KAAK,IAAIC,gBAAgB,EACzBC,0BAA0B,QACpB,yBAAyB;AAChC,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;AACzD,SAASC,kBAAkB,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC5E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAAST,KAAK,IAAIU,WAAW,QAAQ,aAAa;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3C,SAASC,4BAA4BA,CAAE;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAG;EAC9D,MAAM;IAAEC,MAAM;IAAEC;EAAyB,CAAC,GAAGf,SAAS,CACnDg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B,QAAA,gBACC3B,IAAA,CAACd,0BAA0B;MAAAyC,QAAA,eAC1B3B,IAAA,CAACP,QAAQ;QACRmC,OAAO,EAAGA,CAAA,KAAM;UACfW,WAAW,CAAEJ,oBAAqB,CAAC;UACnCG,sBAAsB,CAAEH,oBAAqB,CAAC;UAC9C5B,OAAO,CAAC,CAAC;QACV,CAAG;QAAAoB,QAAA,EAED/B,EAAE,CAAE,QAAS;MAAC,CACP;IAAC,CACgB,CAAC,eAC7BI,IAAA,CAACR,IAAI;MACJwC,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,SAAS,EAAC,gDAAgD;MAAAP,QAAA,EAExD/B,EAAE,CACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEA,eAAe,SAAS6C,uBAAuBA,CAAA,EAAG;EACjD,oBACCzC,IAAA,CAAChB,yBAAyB;IAAA2C,QAAA,EACvBA,CAAE;MAAEe,iBAAiB;MAAEnC;IAAQ,CAAC,KACjCmC,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7B3C,IAAA,CAACK,4BAA4B;MAC5BC,QAAQ,EAAGoC,iBAAiB,CAAE,CAAC,CAAI;MACnCnC,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BlockSettingsMenuControls","__unstableBlockSettingsMenuFirstItem","BlockSettingsMenuFirstItem","store","blockEditorStore","useBlockDisplayInformation","coreStore","__experimentalText","Text","MenuItem","useSelect","useDispatch","__","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ContentOnlySettingsMenuItems","clientId","onClose","entity","onNavigateToEntityRecord","canEditTemplates","select","getBlockEditingMode","getBlockParentsByBlockName","getSettings","getBlockAttributes","contentOnly","patternParent","record","getEntityRecord","ref","getCurrentTemplateId","templateId","getContentLockingParent","_canEditTemplates","canUser","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","children","onClick","postId","id","postType","disabled","variant","as","className","contentLockingParent","blockDisplayInformation","modifyContentLockBlock","selectBlock","title","ContentOnlySettingsMenu","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst contentOnly =\n\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly';\n\t\t\tif ( ! contentOnly ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { getCurrentTemplateId } = select( editorStore );\n\t\t\t\tconst templateId = getCurrentTemplateId();\n\t\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tif ( ! getContentLockingParent( clientId ) && templateId ) {\n\t\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\ttemplateId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser(\n\t\t\t\t'create',\n\t\t\t\t'templates'\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\t// Disable reason: We're using a hook here so it has to be on top-level.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { modifyContentLockBlock, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tselectBlock( contentLockingParent );\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Unlock' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,yBAAyB,EACzBC,oCAAoC,IAAIC,0BAA0B,EAClEC,KAAK,IAAIC,gBAAgB,EACzBC,0BAA0B,QACpB,yBAAyB;AAChC,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;AACzD,SAASC,kBAAkB,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC5E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAAST,KAAK,IAAIU,WAAW,QAAQ,aAAa;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3C,SAASC,4BAA4BA,CAAE;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAG;EAC9D,MAAM;IAAEC,MAAM;IAAEC,wBAAwB;IAAEC;EAAiB,CAAC,GAAGhB,SAAS,CACrEiB,MAAM,IAAM;IACb,MAAM;MACLC,mBAAmB;MACnBC,0BAA0B;MAC1BC,WAAW;MACXC;IACD,CAAC,GAAGJ,MAAM,CAAEvB,gBAAiB,CAAC;IAC9B,MAAM4B,WAAW,GAChBJ,mBAAmB,CAAEN,QAAS,CAAC,KAAK,aAAa;IAClD,IAAK,CAAEU,WAAW,EAAG;MACpB,OAAO,CAAC,CAAC;IACV;IACA,MAAMC,aAAa,GAAGJ,0BAA0B,CAC/CP,QAAQ,EACR,YA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A,CAAAF,SAAA;IAAA4B,QAAA,gBACC9B,IAAA,CAACd,0BAA0B;MAAA4C,QAAA,eAC1B9B,IAAA,CAACP,QAAQ;QACRsC,OAAO,EAAGA,CAAA,KAAM;UACfW,WAAW,CAAEH,oBAAqB,CAAC;UACnCE,sBAAsB,CAAEF,oBAAqB,CAAC;UAC9ChC,OAAO,CAAC,CAAC;QACV,CAAG;QAAAuB,QAAA,EAEDlC,EAAE,CAAE,QAAS;MAAC,CACP;IAAC,CACgB,CAAC,eAC7BI,IAAA,CAACR,IAAI;MACJ4C,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,SAAS,EAAC,gDAAgD;MAAAR,QAAA,EAExDlC,EAAE,CACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEA,eAAe,SAASgD,uBAAuBA,CAAA,EAAG;EACjD,oBACC5C,IAAA,CAAChB,yBAAyB;IAAA8C,QAAA,EACvBA,CAAE;MAAEe,iBAAiB;MAAEtC;IAAQ,CAAC,KACjCsC,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7B9C,IAAA,CAACK,4BAA4B;MAC5BC,QAAQ,EAAGuC,iBAAiB,CAAE,CAAC,CAAI;MACnCtC,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
|
|
@@ -26,9 +26,6 @@ import EditorHistoryUndo from '../editor-history/undo';
|
|
|
26
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
27
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
-
const preventDefault = event => {
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
};
|
|
32
29
|
function DocumentTools({
|
|
33
30
|
className,
|
|
34
31
|
disableBlockTools = false
|
|
@@ -78,6 +75,18 @@ function DocumentTools({
|
|
|
78
75
|
isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
|
|
79
76
|
};
|
|
80
77
|
}, []);
|
|
78
|
+
const preventDefault = event => {
|
|
79
|
+
// Because the inserter behaves like a dialog,
|
|
80
|
+
// if the inserter is opened already then when we click on the toggle button
|
|
81
|
+
// then the initial click event will close the inserter and then be propagated
|
|
82
|
+
// to the inserter toggle and it will open it again.
|
|
83
|
+
// To prevent this we need to stop the propagation of the event.
|
|
84
|
+
// This won't be necessary when the inserter no longer behaves like a dialog.
|
|
85
|
+
|
|
86
|
+
if (isInserterOpened) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
81
90
|
const isLargeViewport = useViewportMatch('medium');
|
|
82
91
|
const isWideViewport = useViewportMatch('wide');
|
|
83
92
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","Button","ToolbarItem","listView","plus","useCallback","keyboardShortcutsStore","preferencesStore","unlock","editorStore","EditorHistoryRedo","EditorHistoryUndo","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","preventDefault","event","DocumentTools","className","disableBlockTools","setIsInserterOpened","setIsListViewOpened","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","inserterSidebarToggleRef","listViewToggleRef","hasFixedToolbar","showIconLabels","select","getSettings","get","isListViewOpened","getEditorMode","getInserterSidebarToggleRef","getListViewToggleRef","getShortcutRepresentation","__unstableGetEditorMode","isVisualMode","isZoomedOutView","isLargeViewport","isWideViewport","toolbarAriaLabel","toggleListView","toggleInserter","longLabel","shortLabel","variant","children","ref","as","isPressed","onMouseDown","onClick","disabled","icon","label","showTooltip","undefined","size","shortcut"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction DocumentTools( { className, disableBlockTools = false } ) {\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t\thasFixedToolbar,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpened ),\n\t\t[ isInserterOpened, setIsInserterOpened ]\n\t);\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SACCC,gBAAgB,EAChBC,YAAY,EACZC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AAC3D,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASN,KAAK,IAAIO,sBAAsB,QAAQ,+BAA+B;AAC/E,SAASP,KAAK,IAAIQ,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAAST,KAAK,IAAIU,WAAW,QAAQ,aAAa;AAClD,OAAOC,iBAAiB,MA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,QAAQ,EAAGpC,iBAAmB;YAC9BiC,SAAS,EAAG5B;YACZ;YACAiC,KAAK,EAAGjE,EAAE,CAAE,mBAAoB,CAAG;YACnC8D,OAAO,EAAGV,cAAgB;YAC1BiB,QAAQ,EAAGpC,gBAAkB;YAC7BiC,WAAW,EAAG,CAAE7B,cAAgB;YAChCmB,OAAO,EACNnB,cAAc,GAAG,UAAU,GAAG8B,SAC9B;YACD,iBAAgBnC,cAAgB;YAChC0B,GAAG,EAAGvB,iBAAmB;YACzBiC,IAAI,EAAC;UAAS,CACd,CACD;QAAA,CACA,CACF;MAAA,CACG;IAAC,CACW;EAAC;AAErB;AAEA,eAAe3C,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","Button","ToolbarItem","listView","plus","useCallback","keyboardShortcutsStore","preferencesStore","unlock","editorStore","EditorHistoryRedo","EditorHistoryUndo","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DocumentTools","className","disableBlockTools","setIsInserterOpened","setIsListViewOpened","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","inserterSidebarToggleRef","listViewToggleRef","hasFixedToolbar","showIconLabels","select","getSettings","get","isListViewOpened","getEditorMode","getInserterSidebarToggleRef","getListViewToggleRef","getShortcutRepresentation","__unstableGetEditorMode","isVisualMode","isZoomedOutView","preventDefault","event","isLargeViewport","isWideViewport","toolbarAriaLabel","toggleListView","toggleInserter","longLabel","shortLabel","variant","children","ref","as","isPressed","onMouseDown","onClick","disabled","icon","label","showTooltip","undefined","size","shortcut"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nfunction DocumentTools( { className, disableBlockTools = false } ) {\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t\thasFixedToolbar,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst preventDefault = ( event ) => {\n\t\t// Because the inserter behaves like a dialog,\n\t\t// if the inserter is opened already then when we click on the toggle button\n\t\t// then the initial click event will close the inserter and then be propagated\n\t\t// to the inserter toggle and it will open it again.\n\t\t// To prevent this we need to stop the propagation of the event.\n\t\t// This won't be necessary when the inserter no longer behaves like a dialog.\n\n\t\tif ( isInserterOpened ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpened ),\n\t\t[ isInserterOpened, setIsInserterOpened ]\n\t);\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SACCC,gBAAgB,EAChBC,YAAY,EACZC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AAC3D,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASN,KAAK,IAAIO,sBAA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AAG,CAAE/B,cAAgB;YAChCqB,OAAO,EAAGrB,cAAc,GAAG,UAAU,GAAGgC,SAAW;YACnDC,IAAI,EAAC;UAAS,CACd,CAAC,EACA,CAAExC,iBAAiB,iBACpBV,IAAA,CAACX,WAAW;YACXoD,EAAE,EAAGrD,MAAQ;YACbkB,SAAS,EAAC,iDAAiD;YAC3DwC,IAAI,EAAGxD,QAAU;YACjBuD,QAAQ,EAAGtC,iBAAmB;YAC9BmC,SAAS,EAAG9B;YACZ;YACAmC,KAAK,EAAGjE,EAAE,CAAE,mBAAoB,CAAG;YACnC8D,OAAO,EAAGV,cAAgB;YAC1BiB,QAAQ,EAAGtC,gBAAkB;YAC7BmC,WAAW,EAAG,CAAE/B,cAAgB;YAChCqB,OAAO,EACNrB,cAAc,GAAG,UAAU,GAAGgC,SAC9B;YACD,iBAAgBrC,cAAgB;YAChC4B,GAAG,EAAGzB,iBAAmB;YACzBmC,IAAI,EAAC;UAAS,CACd,CACD;QAAA,CACA,CACF;MAAA,CACG;IAAC,CACW;EAAC;AAErB;AAEA,eAAe7C,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { Notice } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
13
|
+
import EditorInterface from '../editor-interface';
|
|
14
|
+
import { ExperimentalEditorProvider } from '../provider';
|
|
15
|
+
import Sidebar from '../sidebar';
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
function Editor({
|
|
20
|
+
postType,
|
|
21
|
+
postId,
|
|
22
|
+
templateId,
|
|
23
|
+
settings,
|
|
24
|
+
children,
|
|
25
|
+
initialEdits,
|
|
26
|
+
// This could be part of the settings.
|
|
27
|
+
onActionPerformed,
|
|
28
|
+
// The following abstractions are not ideal but necessary
|
|
29
|
+
// to account for site editor and post editor differences for now.
|
|
30
|
+
extraContent,
|
|
31
|
+
extraSidebarPanels,
|
|
32
|
+
...props
|
|
33
|
+
}) {
|
|
34
|
+
const {
|
|
35
|
+
post,
|
|
36
|
+
template,
|
|
37
|
+
hasLoadedPost
|
|
38
|
+
} = useSelect(select => {
|
|
39
|
+
const {
|
|
40
|
+
getEntityRecord,
|
|
41
|
+
hasFinishedResolution
|
|
42
|
+
} = select(coreStore);
|
|
43
|
+
return {
|
|
44
|
+
post: getEntityRecord('postType', postType, postId),
|
|
45
|
+
template: templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId) : undefined,
|
|
46
|
+
hasLoadedPost: hasFinishedResolution('getEntityRecord', ['postType', postType, postId])
|
|
47
|
+
};
|
|
48
|
+
}, [postType, postId, templateId]);
|
|
49
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
50
|
+
children: [hasLoadedPost && !post && /*#__PURE__*/_jsx(Notice, {
|
|
51
|
+
status: "warning",
|
|
52
|
+
isDismissible: false,
|
|
53
|
+
children: __("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")
|
|
54
|
+
}), !!post && /*#__PURE__*/_jsxs(ExperimentalEditorProvider, {
|
|
55
|
+
post: post,
|
|
56
|
+
__unstableTemplate: template,
|
|
57
|
+
settings: settings,
|
|
58
|
+
initialEdits: initialEdits,
|
|
59
|
+
useSubRegistry: false,
|
|
60
|
+
children: [/*#__PURE__*/_jsx(EditorInterface, {
|
|
61
|
+
...props,
|
|
62
|
+
children: extraContent
|
|
63
|
+
}), /*#__PURE__*/_jsx(Sidebar, {
|
|
64
|
+
onActionPerformed: onActionPerformed,
|
|
65
|
+
extraPanels: extraSidebarPanels
|
|
66
|
+
}), children]
|
|
67
|
+
})]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
export default Editor;
|
|
71
|
+
//# sourceMappingURL=index.js.map
|