@wordpress/editor 14.6.0 → 14.7.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 +37 -0
- package/build/bindings/post-meta.js +10 -8
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-manager/index.js +4 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +5 -8
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/document-bar/index.js +4 -4
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/editor-history/redo.js +4 -1
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +4 -1
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-interface/index.js +2 -3
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/error-boundary/index.js +4 -1
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/index.js +8 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +3 -5
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +5 -5
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/page-attributes/parent.js +4 -1
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/plugin-preview-menu-item/index.js +57 -0
- package/build/components/plugin-preview-menu-item/index.js.map +1 -0
- package/build/components/post-actions/index.js +5 -8
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +4 -1
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-featured-image/index.js +12 -3
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-format/index.js +4 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +4 -1
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +12 -3
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +4 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +4 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +14 -8
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-status/index.js +4 -2
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +4 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +4 -1
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-template/block-theme.js +13 -4
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +4 -1
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-title/index.js +32 -46
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-url/index.js +4 -1
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +26 -14
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +5 -6
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/save-publish-panels/index.js +8 -2
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/components/start-template-options/index.js +4 -1
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/table-of-contents/index.js +4 -1
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/text-editor/index.js +4 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/index.js +1 -6
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/dataviews/actions/export-pattern.js +2 -0
- package/build/dataviews/actions/export-pattern.js.map +1 -1
- package/build/dataviews/actions/permanently-delete-post.js +2 -0
- package/build/dataviews/actions/permanently-delete-post.js.map +1 -1
- package/build/dataviews/actions/reset-post.js +8 -2
- package/build/dataviews/actions/reset-post.js.map +1 -1
- package/build/dataviews/actions/trash-post.js +8 -2
- package/build/dataviews/actions/trash-post.js.map +1 -1
- package/build/dataviews/actions/view-post.js +1 -1
- package/build/dataviews/actions/view-post.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +1 -1
- package/build/store/private-actions.js.map +1 -1
- package/build-module/bindings/post-meta.js +10 -8
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-manager/index.js +4 -1
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +6 -9
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/document-bar/index.js +4 -4
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-history/redo.js +4 -1
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +4 -1
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-interface/index.js +2 -3
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +4 -1
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +3 -5
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +5 -5
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +4 -1
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/plugin-preview-menu-item/index.js +52 -0
- package/build-module/components/plugin-preview-menu-item/index.js.map +1 -0
- package/build-module/components/post-actions/index.js +5 -8
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +4 -1
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +12 -3
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-format/index.js +4 -1
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +4 -1
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +12 -3
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +4 -1
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +4 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +14 -8
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-status/index.js +4 -2
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +4 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +4 -1
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +13 -4
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +4 -1
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-title/index.js +33 -47
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-url/index.js +4 -1
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +26 -14
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +6 -7
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +8 -2
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +4 -1
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +4 -1
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +4 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +1 -6
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/dataviews/actions/export-pattern.js +2 -0
- package/build-module/dataviews/actions/export-pattern.js.map +1 -1
- package/build-module/dataviews/actions/permanently-delete-post.js +3 -0
- package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -1
- package/build-module/dataviews/actions/reset-post.js +8 -2
- package/build-module/dataviews/actions/reset-post.js.map +1 -1
- package/build-module/dataviews/actions/trash-post.js +8 -2
- package/build-module/dataviews/actions/trash-post.js.map +1 -1
- package/build-module/dataviews/actions/view-post.js +2 -2
- package/build-module/dataviews/actions/view-post.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +1 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +12 -7
- package/build-style/style.css +12 -7
- package/build-types/bindings/post-meta.d.ts +0 -3
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +1 -1
- package/build-types/components/editor-history/redo.d.ts.map +1 -1
- package/build-types/components/editor-history/undo.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/index.d.ts +1 -0
- package/build-types/components/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/plugin-preview-menu-item/index.d.ts +3 -0
- package/build-types/components/plugin-preview-menu-item/index.d.ts.map +1 -0
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/text-editor/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/actions/export-pattern.d.ts.map +1 -1
- package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/trash-post.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/bindings/post-meta.js +12 -6
- package/src/components/block-manager/index.js +2 -0
- package/src/components/block-settings-menu/content-only-settings-menu.js +5 -9
- package/src/components/create-template-part-modal/style.scss +1 -1
- package/src/components/document-bar/index.js +4 -4
- package/src/components/document-outline/style.scss +1 -1
- package/src/components/editor-history/redo.js +2 -0
- package/src/components/editor-history/undo.js +2 -0
- package/src/components/editor-interface/index.js +2 -4
- package/src/components/error-boundary/index.js +6 -1
- package/src/components/header/style.scss +6 -3
- package/src/components/index.js +1 -0
- package/src/components/inserter-sidebar/index.js +4 -3
- package/src/components/local-autosave-monitor/index.js +6 -6
- package/src/components/page-attributes/parent.js +5 -4
- package/src/components/plugin-preview-menu-item/index.js +52 -0
- package/src/components/post-actions/index.js +8 -14
- package/src/components/post-card-panel/style.scss +1 -1
- package/src/components/post-excerpt/panel.js +2 -0
- package/src/components/post-featured-image/index.js +6 -0
- package/src/components/post-featured-image/style.scss +1 -2
- package/src/components/post-format/index.js +2 -0
- package/src/components/post-last-revision/index.js +2 -0
- package/src/components/post-locked-modal/index.js +14 -2
- package/src/components/post-locked-modal/style.scss +1 -1
- package/src/components/post-publish-panel/index.js +2 -0
- package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +37 -29
- package/src/components/post-publish-panel/style.scss +3 -1
- package/src/components/post-status/index.js +3 -2
- package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -0
- package/src/components/post-taxonomies/most-used-terms.js +2 -0
- package/src/components/post-template/block-theme.js +15 -9
- package/src/components/post-template/classic-theme.js +2 -0
- package/src/components/post-title/index.js +30 -41
- package/src/components/post-url/index.js +2 -0
- package/src/components/preview-dropdown/index.js +28 -20
- package/src/components/provider/use-block-editor-settings.js +5 -5
- package/src/components/resizable-editor/style.scss +2 -2
- package/src/components/save-publish-panels/index.js +4 -0
- package/src/components/start-template-options/index.js +6 -1
- package/src/components/table-of-contents/index.js +2 -0
- package/src/components/text-editor/index.js +2 -0
- package/src/components/visual-editor/index.js +2 -9
- package/src/dataviews/actions/export-pattern.tsx +2 -0
- package/src/dataviews/actions/permanently-delete-post.tsx +2 -0
- package/src/dataviews/actions/reset-post.tsx +4 -0
- package/src/dataviews/actions/trash-post.tsx +4 -0
- package/src/dataviews/actions/view-post.tsx +2 -2
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +3 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","_n","_x","sprintf","useMemo","useState","store","noticesStore","Button","CheckboxControl","TextControl","TreeSelect","withFilters","Flex","FlexItem","SearchControl","useDispatch","useSelect","useDebounce","coreStore","speak","decodeEntities","buildTermsTree","editorStore","jsx","_jsx","jsxs","_jsxs","DEFAULT_QUERY","per_page","orderby","order","_fields","context","MIN_TERMS_COUNT_FOR_FILTER","EMPTY_ARRAY","sortBySelected","termsTree","terms","treeHasSelection","termTree","indexOf","id","undefined","children","map","filter","child","length","termOrChildIsSelected","termA","termB","termASelected","termBSelected","newTermTree","sort","findTerm","parent","name","find","term","parseInt","toLowerCase","getFilterMatcher","filterValue","matchTermsForFilter","originalTerm","HierarchicalTermSelector","slug","_taxonomy$labels$sear","_taxonomy$name","adding","setAdding","formName","setFormName","formParent","setFormParent","showForm","setShowForm","setFilterValue","filteredTermsTree","setFilteredTermsTree","debouncedSpeak","hasCreateAction","hasAssignAction","loading","availableTerms","taxonomy","select","_post$_links","_post$_links2","getCurrentPost","getEditedPostAttribute","getTaxonomy","getEntityRecords","isResolving","_taxonomy","post","_links","rest_base","editPost","saveEntityRecord","availableTermsTree","createErrorNotice","addTerm","throwOnError","onUpdateTerms","termIds","onChange","termId","hasTerm","includes","newTerms","onChangeFormName","value","onChangeFormParent","parentId","onToggleForm","onAddTerm","event","_taxonomy$labels$sing","preventDefault","existingTerm","some","newTerm","error","message","type","defaultName","termAddedMessage","labels","singular_name","setFilter","newFilteredTermsTree","getResultCount","count","i","resultCount","resultsFoundMessage","renderTerms","renderedTerms","className","__nextHasNoMarginBottom","checked","label","labelWithFallback","labelProperty","fallbackIsCategory","fallbackIsNotCategory","_taxonomy$labels$labe","newTermButtonLabel","newTermLabel","parentSelectLabel","noParentOption","newTermSubmitLabel","filterLabel","search_items","groupLabel","showFilter","direction","gap","__next40pxDefaultSize","tabIndex","role","onClick","variant","onSubmit","required","noOptionLabel","selectedId","tree"],"sources":["@wordpress/editor/src/components/post-taxonomies/hierarchical-term-selector.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst DEFAULT_QUERY = {\n\tper_page: -1,\n\torderby: 'name',\n\torder: 'asc',\n\t_fields: 'id,name,parent',\n\tcontext: 'view',\n};\n\nconst MIN_TERMS_COUNT_FOR_FILTER = 8;\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Sort Terms by Selected.\n *\n * @param {Object[]} termsTree Array of terms in tree format.\n * @param {number[]} terms Selected terms.\n *\n * @return {Object[]} Sorted array of terms.\n */\nexport function sortBySelected( termsTree, terms ) {\n\tconst treeHasSelection = ( termTree ) => {\n\t\tif ( terms.indexOf( termTree.id ) !== -1 ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( undefined === termTree.children ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\ttermTree.children\n\t\t\t\t.map( treeHasSelection )\n\t\t\t\t.filter( ( child ) => child ).length > 0\n\t\t);\n\t};\n\tconst termOrChildIsSelected = ( termA, termB ) => {\n\t\tconst termASelected = treeHasSelection( termA );\n\t\tconst termBSelected = treeHasSelection( termB );\n\n\t\tif ( termASelected === termBSelected ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( termASelected && ! termBSelected ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif ( ! termASelected && termBSelected ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn 0;\n\t};\n\tconst newTermTree = [ ...termsTree ];\n\tnewTermTree.sort( termOrChildIsSelected );\n\treturn newTermTree;\n}\n\n/**\n * Find term by parent id or name.\n *\n * @param {Object[]} terms Array of Terms.\n * @param {number|string} parent id.\n * @param {string} name Term name.\n * @return {Object} Term object.\n */\nexport function findTerm( terms, parent, name ) {\n\treturn terms.find( ( term ) => {\n\t\treturn (\n\t\t\t( ( ! term.parent && ! parent ) ||\n\t\t\t\tparseInt( term.parent ) === parseInt( parent ) ) &&\n\t\t\tterm.name.toLowerCase() === name.toLowerCase()\n\t\t);\n\t} );\n}\n\n/**\n * Get filter matcher function.\n *\n * @param {string} filterValue Filter value.\n * @return {(function(Object): (Object|boolean))} Matcher function.\n */\nexport function getFilterMatcher( filterValue ) {\n\tconst matchTermsForFilter = ( originalTerm ) => {\n\t\tif ( '' === filterValue ) {\n\t\t\treturn originalTerm;\n\t\t}\n\n\t\t// Shallow clone, because we'll be filtering the term's children and\n\t\t// don't want to modify the original term.\n\t\tconst term = { ...originalTerm };\n\n\t\t// Map and filter the children, recursive so we deal with grandchildren\n\t\t// and any deeper levels.\n\t\tif ( term.children.length > 0 ) {\n\t\t\tterm.children = term.children\n\t\t\t\t.map( matchTermsForFilter )\n\t\t\t\t.filter( ( child ) => child );\n\t\t}\n\n\t\t// If the term's name contains the filterValue, or it has children\n\t\t// (i.e. some child matched at some point in the tree) then return it.\n\t\tif (\n\t\t\t-1 !==\n\t\t\t\tterm.name.toLowerCase().indexOf( filterValue.toLowerCase() ) ||\n\t\t\tterm.children.length > 0\n\t\t) {\n\t\t\treturn term;\n\t\t}\n\n\t\t// Otherwise, return false. After mapping, the list of terms will need\n\t\t// to have false values filtered out.\n\t\treturn false;\n\t};\n\treturn matchTermsForFilter;\n}\n\n/**\n * Hierarchical term selector.\n *\n * @param {Object} props Component props.\n * @param {string} props.slug Taxonomy slug.\n * @return {Element} Hierarchical term selector component.\n */\nexport function HierarchicalTermSelector( { slug } ) {\n\tconst [ adding, setAdding ] = useState( false );\n\tconst [ formName, setFormName ] = useState( '' );\n\t/**\n\t * @type {[number|'', Function]}\n\t */\n\tconst [ formParent, setFormParent ] = useState( '' );\n\tconst [ showForm, setShowForm ] = useState( false );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ filteredTermsTree, setFilteredTermsTree ] = useState( [] );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst {\n\t\thasCreateAction,\n\t\thasAssignAction,\n\t\tterms,\n\t\tloading,\n\t\tavailableTerms,\n\t\ttaxonomy,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getTaxonomy, getEntityRecords, isResolving } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst post = getCurrentPost();\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\tterms: _taxonomy\n\t\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\tloading: isResolving( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tDEFAULT_QUERY,\n\t\t\t\t] ),\n\t\t\t\tavailableTerms:\n\t\t\t\t\tgetEntityRecords( 'taxonomy', slug, DEFAULT_QUERY ) ||\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst availableTermsTree = useMemo(\n\t\t() => sortBySelected( buildTermsTree( availableTerms ), terms ),\n\t\t// Remove `terms` from the dependency list to avoid reordering every time\n\t\t// checking or unchecking a term.\n\t\t[ availableTerms ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Append new term.\n\t *\n\t * @param {Object} term Term object.\n\t * @return {Promise} A promise that resolves to save term object.\n\t */\n\tconst addTerm = ( term ) => {\n\t\treturn saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\t/**\n\t * Update terms for post.\n\t *\n\t * @param {number[]} termIds Term ids.\n\t */\n\tconst onUpdateTerms = ( termIds ) => {\n\t\teditPost( { [ taxonomy.rest_base ]: termIds } );\n\t};\n\n\t/**\n\t * Handler for checking term.\n\t *\n\t * @param {number} termId\n\t */\n\tconst onChange = ( termId ) => {\n\t\tconst hasTerm = terms.includes( termId );\n\t\tconst newTerms = hasTerm\n\t\t\t? terms.filter( ( id ) => id !== termId )\n\t\t\t: [ ...terms, termId ];\n\t\tonUpdateTerms( newTerms );\n\t};\n\n\tconst onChangeFormName = ( value ) => {\n\t\tsetFormName( value );\n\t};\n\n\t/**\n\t * Handler for changing form parent.\n\t *\n\t * @param {number|''} parentId Parent post id.\n\t */\n\tconst onChangeFormParent = ( parentId ) => {\n\t\tsetFormParent( parentId );\n\t};\n\n\tconst onToggleForm = () => {\n\t\tsetShowForm( ! showForm );\n\t};\n\n\tconst onAddTerm = async ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( formName === '' || adding ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if the term we are adding already exists.\n\t\tconst existingTerm = findTerm( availableTerms, formParent, formName );\n\t\tif ( existingTerm ) {\n\t\t\t// If the term we are adding exists but is not selected select it.\n\t\t\tif ( ! terms.some( ( term ) => term === existingTerm.id ) ) {\n\t\t\t\tonUpdateTerms( [ ...terms, existingTerm.id ] );\n\t\t\t}\n\n\t\t\tsetFormName( '' );\n\t\t\tsetFormParent( '' );\n\n\t\t\treturn;\n\t\t}\n\t\tsetAdding( true );\n\t\tlet newTerm;\n\t\ttry {\n\t\t\tnewTerm = await addTerm( {\n\t\t\t\tname: formName,\n\t\t\t\tparent: formParent ? formParent : undefined,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\tconst defaultName =\n\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: taxonomy name */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tsetAdding( false );\n\t\tsetFormName( '' );\n\t\tsetFormParent( '' );\n\t\tonUpdateTerms( [ ...terms, newTerm.id ] );\n\t};\n\n\tconst setFilter = ( value ) => {\n\t\tconst newFilteredTermsTree = availableTermsTree\n\t\t\t.map( getFilterMatcher( value ) )\n\t\t\t.filter( ( term ) => term );\n\t\tconst getResultCount = ( termsTree ) => {\n\t\t\tlet count = 0;\n\t\t\tfor ( let i = 0; i < termsTree.length; i++ ) {\n\t\t\t\tcount++;\n\t\t\t\tif ( undefined !== termsTree[ i ].children ) {\n\t\t\t\t\tcount += getResultCount( termsTree[ i ].children );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t};\n\n\t\tsetFilterValue( value );\n\t\tsetFilteredTermsTree( newFilteredTermsTree );\n\n\t\tconst resultCount = getResultCount( newFilteredTermsTree );\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results */\n\t\t\t_n( '%d result found.', '%d results found.', resultCount ),\n\t\t\tresultCount\n\t\t);\n\n\t\tdebouncedSpeak( resultsFoundMessage, 'assertive' );\n\t};\n\n\tconst renderTerms = ( renderedTerms ) => {\n\t\treturn renderedTerms.map( ( term ) => {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tkey={ term.id }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-choice\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ terms.indexOf( term.id ) !== -1 }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tconst termId = parseInt( term.id, 10 );\n\t\t\t\t\t\t\tonChange( termId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ decodeEntities( term.name ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! term.children.length && (\n\t\t\t\t\t\t<div className=\"editor-post-taxonomies__hierarchical-terms-subchoices\">\n\t\t\t\t\t\t\t{ renderTerms( term.children ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t} );\n\t};\n\n\tconst labelWithFallback = (\n\t\tlabelProperty,\n\t\tfallbackIsCategory,\n\t\tfallbackIsNotCategory\n\t) =>\n\t\ttaxonomy?.labels?.[ labelProperty ] ??\n\t\t( slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory );\n\n\tconst newTermButtonLabel = labelWithFallback(\n\t\t'add_new_item',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst newTermLabel = labelWithFallback(\n\t\t'new_item_name',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst parentSelectLabel = labelWithFallback(\n\t\t'parent_item',\n\t\t__( 'Parent Category' ),\n\t\t__( 'Parent Term' )\n\t);\n\tconst noParentOption = `— ${ parentSelectLabel } —`;\n\tconst newTermSubmitLabel = newTermButtonLabel;\n\tconst filterLabel = taxonomy?.labels?.search_items ?? __( 'Search Terms' );\n\tconst groupLabel = taxonomy?.name ?? __( 'Terms' );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t{ showFilter && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ filterLabel }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ setFilter }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-list\"\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ groupLabel }\n\t\t\t>\n\t\t\t\t{ renderTerms(\n\t\t\t\t\t'' !== filterValue ? filteredTermsTree : availableTermsTree\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! loading && hasCreateAction && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACrD,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SACCC,MAAM,EACNC,eAAe,EACfC,WAAW,EACXC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,aAAa,QACP,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASZ,KAAK,IAAIa,SAAS,QAAQ,sBAAsB;AACzD,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,cAAc,QAAQ,0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M,iBACzBvB,IAAA,CAACd,UAAU;UACVsJ,qBAAqB;UACrBnB,uBAAuB;UACvBE,KAAK,EAAGQ,iBAAmB;UAC3BgB,aAAa,EAAGf,cAAgB;UAChC7C,QAAQ,EAAGO,kBAAoB;UAC/BsD,UAAU,EAAG9F,UAAY;UACzB+F,IAAI,EAAGpE;QAAoB,CAC3B,CACD,eACD7E,IAAA,CAACX,QAAQ;UAAA8B,QAAA,eACRnB,IAAA,CAACjB,MAAM;YACNyJ,qBAAqB;YACrBI,OAAO,EAAC,WAAW;YACnBtC,IAAI,EAAC,QAAQ;YACbc,SAAS,EAAC,mDAAmD;YAAAjG,QAAA,EAE3D8G;UAAkB,CACb;QAAC,CACA,CAAC;MAAA,CACN;IAAC,CACF,CACN;EAAA,CACI,CAAC;AAET;AAEA,eAAe9I,WAAW,CAAE,yBAA0B,CAAC,CACtDuD,wBACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","_n","_x","sprintf","useMemo","useState","store","noticesStore","Button","CheckboxControl","TextControl","TreeSelect","withFilters","Flex","FlexItem","SearchControl","useDispatch","useSelect","useDebounce","coreStore","speak","decodeEntities","buildTermsTree","editorStore","jsx","_jsx","jsxs","_jsxs","DEFAULT_QUERY","per_page","orderby","order","_fields","context","MIN_TERMS_COUNT_FOR_FILTER","EMPTY_ARRAY","sortBySelected","termsTree","terms","treeHasSelection","termTree","indexOf","id","undefined","children","map","filter","child","length","termOrChildIsSelected","termA","termB","termASelected","termBSelected","newTermTree","sort","findTerm","parent","name","find","term","parseInt","toLowerCase","getFilterMatcher","filterValue","matchTermsForFilter","originalTerm","HierarchicalTermSelector","slug","_taxonomy$labels$sear","_taxonomy$name","adding","setAdding","formName","setFormName","formParent","setFormParent","showForm","setShowForm","setFilterValue","filteredTermsTree","setFilteredTermsTree","debouncedSpeak","hasCreateAction","hasAssignAction","loading","availableTerms","taxonomy","select","_post$_links","_post$_links2","getCurrentPost","getEditedPostAttribute","getTaxonomy","getEntityRecords","isResolving","_taxonomy","post","_links","rest_base","editPost","saveEntityRecord","availableTermsTree","createErrorNotice","addTerm","throwOnError","onUpdateTerms","termIds","onChange","termId","hasTerm","includes","newTerms","onChangeFormName","value","onChangeFormParent","parentId","onToggleForm","onAddTerm","event","_taxonomy$labels$sing","preventDefault","existingTerm","some","newTerm","error","message","type","defaultName","termAddedMessage","labels","singular_name","setFilter","newFilteredTermsTree","getResultCount","count","i","resultCount","resultsFoundMessage","renderTerms","renderedTerms","className","__nextHasNoMarginBottom","checked","label","labelWithFallback","labelProperty","fallbackIsCategory","fallbackIsNotCategory","_taxonomy$labels$labe","newTermButtonLabel","newTermLabel","parentSelectLabel","noParentOption","newTermSubmitLabel","filterLabel","search_items","groupLabel","showFilter","direction","gap","__next40pxDefaultSize","tabIndex","role","onClick","variant","onSubmit","required","noOptionLabel","selectedId","tree"],"sources":["@wordpress/editor/src/components/post-taxonomies/hierarchical-term-selector.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst DEFAULT_QUERY = {\n\tper_page: -1,\n\torderby: 'name',\n\torder: 'asc',\n\t_fields: 'id,name,parent',\n\tcontext: 'view',\n};\n\nconst MIN_TERMS_COUNT_FOR_FILTER = 8;\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Sort Terms by Selected.\n *\n * @param {Object[]} termsTree Array of terms in tree format.\n * @param {number[]} terms Selected terms.\n *\n * @return {Object[]} Sorted array of terms.\n */\nexport function sortBySelected( termsTree, terms ) {\n\tconst treeHasSelection = ( termTree ) => {\n\t\tif ( terms.indexOf( termTree.id ) !== -1 ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( undefined === termTree.children ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\ttermTree.children\n\t\t\t\t.map( treeHasSelection )\n\t\t\t\t.filter( ( child ) => child ).length > 0\n\t\t);\n\t};\n\tconst termOrChildIsSelected = ( termA, termB ) => {\n\t\tconst termASelected = treeHasSelection( termA );\n\t\tconst termBSelected = treeHasSelection( termB );\n\n\t\tif ( termASelected === termBSelected ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( termASelected && ! termBSelected ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif ( ! termASelected && termBSelected ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn 0;\n\t};\n\tconst newTermTree = [ ...termsTree ];\n\tnewTermTree.sort( termOrChildIsSelected );\n\treturn newTermTree;\n}\n\n/**\n * Find term by parent id or name.\n *\n * @param {Object[]} terms Array of Terms.\n * @param {number|string} parent id.\n * @param {string} name Term name.\n * @return {Object} Term object.\n */\nexport function findTerm( terms, parent, name ) {\n\treturn terms.find( ( term ) => {\n\t\treturn (\n\t\t\t( ( ! term.parent && ! parent ) ||\n\t\t\t\tparseInt( term.parent ) === parseInt( parent ) ) &&\n\t\t\tterm.name.toLowerCase() === name.toLowerCase()\n\t\t);\n\t} );\n}\n\n/**\n * Get filter matcher function.\n *\n * @param {string} filterValue Filter value.\n * @return {(function(Object): (Object|boolean))} Matcher function.\n */\nexport function getFilterMatcher( filterValue ) {\n\tconst matchTermsForFilter = ( originalTerm ) => {\n\t\tif ( '' === filterValue ) {\n\t\t\treturn originalTerm;\n\t\t}\n\n\t\t// Shallow clone, because we'll be filtering the term's children and\n\t\t// don't want to modify the original term.\n\t\tconst term = { ...originalTerm };\n\n\t\t// Map and filter the children, recursive so we deal with grandchildren\n\t\t// and any deeper levels.\n\t\tif ( term.children.length > 0 ) {\n\t\t\tterm.children = term.children\n\t\t\t\t.map( matchTermsForFilter )\n\t\t\t\t.filter( ( child ) => child );\n\t\t}\n\n\t\t// If the term's name contains the filterValue, or it has children\n\t\t// (i.e. some child matched at some point in the tree) then return it.\n\t\tif (\n\t\t\t-1 !==\n\t\t\t\tterm.name.toLowerCase().indexOf( filterValue.toLowerCase() ) ||\n\t\t\tterm.children.length > 0\n\t\t) {\n\t\t\treturn term;\n\t\t}\n\n\t\t// Otherwise, return false. After mapping, the list of terms will need\n\t\t// to have false values filtered out.\n\t\treturn false;\n\t};\n\treturn matchTermsForFilter;\n}\n\n/**\n * Hierarchical term selector.\n *\n * @param {Object} props Component props.\n * @param {string} props.slug Taxonomy slug.\n * @return {Element} Hierarchical term selector component.\n */\nexport function HierarchicalTermSelector( { slug } ) {\n\tconst [ adding, setAdding ] = useState( false );\n\tconst [ formName, setFormName ] = useState( '' );\n\t/**\n\t * @type {[number|'', Function]}\n\t */\n\tconst [ formParent, setFormParent ] = useState( '' );\n\tconst [ showForm, setShowForm ] = useState( false );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ filteredTermsTree, setFilteredTermsTree ] = useState( [] );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst {\n\t\thasCreateAction,\n\t\thasAssignAction,\n\t\tterms,\n\t\tloading,\n\t\tavailableTerms,\n\t\ttaxonomy,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getTaxonomy, getEntityRecords, isResolving } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst post = getCurrentPost();\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\tterms: _taxonomy\n\t\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\tloading: isResolving( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tDEFAULT_QUERY,\n\t\t\t\t] ),\n\t\t\t\tavailableTerms:\n\t\t\t\t\tgetEntityRecords( 'taxonomy', slug, DEFAULT_QUERY ) ||\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst availableTermsTree = useMemo(\n\t\t() => sortBySelected( buildTermsTree( availableTerms ), terms ),\n\t\t// Remove `terms` from the dependency list to avoid reordering every time\n\t\t// checking or unchecking a term.\n\t\t[ availableTerms ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Append new term.\n\t *\n\t * @param {Object} term Term object.\n\t * @return {Promise} A promise that resolves to save term object.\n\t */\n\tconst addTerm = ( term ) => {\n\t\treturn saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\t/**\n\t * Update terms for post.\n\t *\n\t * @param {number[]} termIds Term ids.\n\t */\n\tconst onUpdateTerms = ( termIds ) => {\n\t\teditPost( { [ taxonomy.rest_base ]: termIds } );\n\t};\n\n\t/**\n\t * Handler for checking term.\n\t *\n\t * @param {number} termId\n\t */\n\tconst onChange = ( termId ) => {\n\t\tconst hasTerm = terms.includes( termId );\n\t\tconst newTerms = hasTerm\n\t\t\t? terms.filter( ( id ) => id !== termId )\n\t\t\t: [ ...terms, termId ];\n\t\tonUpdateTerms( newTerms );\n\t};\n\n\tconst onChangeFormName = ( value ) => {\n\t\tsetFormName( value );\n\t};\n\n\t/**\n\t * Handler for changing form parent.\n\t *\n\t * @param {number|''} parentId Parent post id.\n\t */\n\tconst onChangeFormParent = ( parentId ) => {\n\t\tsetFormParent( parentId );\n\t};\n\n\tconst onToggleForm = () => {\n\t\tsetShowForm( ! showForm );\n\t};\n\n\tconst onAddTerm = async ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( formName === '' || adding ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if the term we are adding already exists.\n\t\tconst existingTerm = findTerm( availableTerms, formParent, formName );\n\t\tif ( existingTerm ) {\n\t\t\t// If the term we are adding exists but is not selected select it.\n\t\t\tif ( ! terms.some( ( term ) => term === existingTerm.id ) ) {\n\t\t\t\tonUpdateTerms( [ ...terms, existingTerm.id ] );\n\t\t\t}\n\n\t\t\tsetFormName( '' );\n\t\t\tsetFormParent( '' );\n\n\t\t\treturn;\n\t\t}\n\t\tsetAdding( true );\n\t\tlet newTerm;\n\t\ttry {\n\t\t\tnewTerm = await addTerm( {\n\t\t\t\tname: formName,\n\t\t\t\tparent: formParent ? formParent : undefined,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\tconst defaultName =\n\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: taxonomy name */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tsetAdding( false );\n\t\tsetFormName( '' );\n\t\tsetFormParent( '' );\n\t\tonUpdateTerms( [ ...terms, newTerm.id ] );\n\t};\n\n\tconst setFilter = ( value ) => {\n\t\tconst newFilteredTermsTree = availableTermsTree\n\t\t\t.map( getFilterMatcher( value ) )\n\t\t\t.filter( ( term ) => term );\n\t\tconst getResultCount = ( termsTree ) => {\n\t\t\tlet count = 0;\n\t\t\tfor ( let i = 0; i < termsTree.length; i++ ) {\n\t\t\t\tcount++;\n\t\t\t\tif ( undefined !== termsTree[ i ].children ) {\n\t\t\t\t\tcount += getResultCount( termsTree[ i ].children );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t};\n\n\t\tsetFilterValue( value );\n\t\tsetFilteredTermsTree( newFilteredTermsTree );\n\n\t\tconst resultCount = getResultCount( newFilteredTermsTree );\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results */\n\t\t\t_n( '%d result found.', '%d results found.', resultCount ),\n\t\t\tresultCount\n\t\t);\n\n\t\tdebouncedSpeak( resultsFoundMessage, 'assertive' );\n\t};\n\n\tconst renderTerms = ( renderedTerms ) => {\n\t\treturn renderedTerms.map( ( term ) => {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tkey={ term.id }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-choice\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ terms.indexOf( term.id ) !== -1 }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tconst termId = parseInt( term.id, 10 );\n\t\t\t\t\t\t\tonChange( termId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ decodeEntities( term.name ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! term.children.length && (\n\t\t\t\t\t\t<div className=\"editor-post-taxonomies__hierarchical-terms-subchoices\">\n\t\t\t\t\t\t\t{ renderTerms( term.children ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t} );\n\t};\n\n\tconst labelWithFallback = (\n\t\tlabelProperty,\n\t\tfallbackIsCategory,\n\t\tfallbackIsNotCategory\n\t) =>\n\t\ttaxonomy?.labels?.[ labelProperty ] ??\n\t\t( slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory );\n\n\tconst newTermButtonLabel = labelWithFallback(\n\t\t'add_new_item',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst newTermLabel = labelWithFallback(\n\t\t'new_item_name',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst parentSelectLabel = labelWithFallback(\n\t\t'parent_item',\n\t\t__( 'Parent Category' ),\n\t\t__( 'Parent Term' )\n\t);\n\tconst noParentOption = `— ${ parentSelectLabel } —`;\n\tconst newTermSubmitLabel = newTermButtonLabel;\n\tconst filterLabel = taxonomy?.labels?.search_items ?? __( 'Search Terms' );\n\tconst groupLabel = taxonomy?.name ?? __( 'Terms' );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t{ showFilter && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ filterLabel }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ setFilter }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-list\"\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ groupLabel }\n\t\t\t>\n\t\t\t\t{ renderTerms(\n\t\t\t\t\t'' !== filterValue ? filteredTermsTree : availableTermsTree\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! loading && hasCreateAction && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACrD,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SACCC,MAAM,EACNC,eAAe,EACfC,WAAW,EACXC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,aAAa,QACP,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASZ,KAAK,IAAIa,SAAS,QAAQ,sBAAsB;AACzD,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAAShB,KAAK,IAAIiB,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAGA,MAAMC,aAAa,GAAG;EACrBC,QAAQ,EAAE,CAAC,CAAC;EACZC,OAAO,EAAE,MAAM;EACfC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,gBAAgB;EACzBC,OAAO,EAAE;AACV,CAAC;AAED,MAAMC,0BAA0B,GAAG,CAAC;AAEpC,MAAMC,WAAW,GAAG,EAAE;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AC,mDAAmD;YAAAjG,QAAA,EAE3D8G;UAAkB,CACb;QAAC,CACA,CAAC;MAAA,CACN;IAAC,CACF,CACN;EAAA,CACI,CAAC;AAET;AAEA,eAAe9I,WAAW,CAAE,yBAA0B,CAAC,CACtDuD,wBACD,CAAC","ignoreList":[]}
|
|
@@ -48,7 +48,10 @@ export default function MostUsedTerms({
|
|
|
48
48
|
role: "list",
|
|
49
49
|
className: "editor-post-taxonomies__flat-term-most-used-list",
|
|
50
50
|
children: terms.map(term => /*#__PURE__*/_jsx("li", {
|
|
51
|
-
children: /*#__PURE__*/_jsx(Button
|
|
51
|
+
children: /*#__PURE__*/_jsx(Button
|
|
52
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
53
|
+
, {
|
|
54
|
+
__next40pxDefaultSize: false,
|
|
52
55
|
variant: "link",
|
|
53
56
|
onClick: () => onSelect(term),
|
|
54
57
|
children: term.name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseControl","Button","useSelect","store","coreStore","unescapeTerms","jsx","_jsx","jsxs","_jsxs","MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","getEntityRecords","slug","length","terms","className","children","VisualLabel","as","labels","most_used","role","map","term","variant","onClick","name","id"],"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BaseControl, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\tDEFAULT_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t_terms: mostUsedTerms,\n\t\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t\t};\n\t\t},\n\t\t[ taxonomy.slug ]\n\t);\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<BaseControl.VisualLabel\n\t\t\t\tas=\"h3\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-label\"\n\t\t\t>\n\t\t\t\t{ taxonomy.labels.most_used }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,MAAM,QAAQ,uBAAuB;AAC3D,SAASC,SAAS,QAAQ,i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K,CAACQ,GAAG,CAAIC,IAAI,iBAClB9B,IAAA;QAAAuB,QAAA,eACCvB,IAAA,CAACN,
|
|
1
|
+
{"version":3,"names":["BaseControl","Button","useSelect","store","coreStore","unescapeTerms","jsx","_jsx","jsxs","_jsxs","MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","getEntityRecords","slug","length","terms","className","children","VisualLabel","as","labels","most_used","role","map","term","__next40pxDefaultSize","variant","onClick","name","id"],"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BaseControl, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\tDEFAULT_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t_terms: mostUsedTerms,\n\t\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t\t};\n\t\t},\n\t\t[ taxonomy.slug ]\n\t);\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<BaseControl.VisualLabel\n\t\t\t\tas=\"h3\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-label\"\n\t\t\t>\n\t\t\t\t{ taxonomy.labels.most_used }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,MAAM,QAAQ,uBAAuB;AAC3D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAElD,MAAMC,mBAAmB,GAAG,CAAC;AAC7B,MAAMC,aAAa,GAAG;EACrBC,QAAQ,EAAE,EAAE;EACZC,OAAO,EAAE,OAAO;EAChBC,KAAK,EAAE,MAAM;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,eAAe;EACxBC,OAAO,EAAE;AACV,CAAC;AAED,eAAe,SAASC,aAAa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store as coreStore } from '@wordpress/core-data';
|
|
9
9
|
import { check } from '@wordpress/icons';
|
|
10
10
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
@@ -45,6 +46,9 @@ export default function BlockThemeControl({
|
|
|
45
46
|
hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
|
|
46
47
|
};
|
|
47
48
|
}, []);
|
|
49
|
+
const {
|
|
50
|
+
get: getPreference
|
|
51
|
+
} = useSelect(preferencesStore);
|
|
48
52
|
const {
|
|
49
53
|
editedRecord: template,
|
|
50
54
|
hasResolved
|
|
@@ -69,6 +73,14 @@ export default function BlockThemeControl({
|
|
|
69
73
|
label: __('Go back'),
|
|
70
74
|
onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
|
|
71
75
|
}] : undefined;
|
|
76
|
+
const mayShowTemplateEditNotice = () => {
|
|
77
|
+
if (!getPreference('core/edit-site', 'welcomeGuideTemplate')) {
|
|
78
|
+
createSuccessNotice(__('Editing template. Changes made here affect all posts and pages that use the template.'), {
|
|
79
|
+
type: 'snackbar',
|
|
80
|
+
actions: notificationAction
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
72
84
|
return /*#__PURE__*/_jsx(DropdownMenu, {
|
|
73
85
|
popoverProps: POPOVER_PROPS,
|
|
74
86
|
focusOnMount: true,
|
|
@@ -91,10 +103,7 @@ export default function BlockThemeControl({
|
|
|
91
103
|
postType: 'wp_template'
|
|
92
104
|
});
|
|
93
105
|
onClose();
|
|
94
|
-
|
|
95
|
-
type: 'snackbar',
|
|
96
|
-
actions: notificationAction
|
|
97
|
-
});
|
|
106
|
+
mayShowTemplateEditNotice();
|
|
98
107
|
},
|
|
99
108
|
children: __('Edit template')
|
|
100
109
|
}), /*#__PURE__*/_jsx(SwapTemplateButton, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","useEntityRecord","store","coreStore","check","noticesStore","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","canCreateTemplate","canUser","kind","name","notificationAction","label","onClick","onNavigateToPreviousEntityRecord","undefined","popoverProps","focusOnMount","toggleProps","size","variant","tooltipPosition","text","title","icon","children","onClose","postId","postType","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","useEntityRecord","store","coreStore","check","noticesStore","preferencesStore","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","get","getPreference","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","canCreateTemplate","canUser","kind","name","notificationAction","label","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","popoverProps","focusOnMount","toggleProps","size","variant","tooltipPosition","text","title","icon","children","onClose","postId","postType","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tsize: 'compact',\n\t\t\t\tvariant: 'tertiary',\n\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\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\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAC1E,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASF,KAAK,IAAIG,YAAY,QAAQ,oBAAoB;AAC1D,SAASH,KAAK,IAAII,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;AAClD,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,iBAAiB,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BAAyB,CAAC,CAAC;UAC5B,CAAG;UAAAY,QAAA,EAED5D,EAAE,CAAE,eAAgB;QAAC,CACd,CACV,eAEDa,IAAA,CAACL,kBAAkB;UAACqC,OAAO,EAAGgB;QAAS,CAAE,CAAC,eAC1ChD,IAAA,CAACJ,oBAAoB;UAACoC,OAAO,EAAGgB;QAAS,CAAE,CAAC,EAC1CtB,iBAAiB,iBAClB1B,IAAA,CAACF,iBAAiB;UAACkC,OAAO,EAAGgB;QAAS,CAAE,CACxC;MAAA,CACS,CAAC,eACZhD,IAAA,CAACf,SAAS;QAAA8D,QAAA,eACT/C,IAAA,CAACd,QAAQ;UACR4D,IAAI,EAAG,CAAEpC,gBAAgB,GAAGnB,KAAK,GAAG2C,SAAW;UAC/CiB,UAAU,EAAG,CAAEzC,gBAAkB;UACjC0C,IAAI,EAAC,kBAAkB;UACvBpB,OAAO,EAAGA,CAAA,KAAM;YACfP,gBAAgB,CACff,gBAAgB,GACb,iBAAiB,GACjB,WACJ,CAAC;UACF,CAAG;UAAAqC,QAAA,EAED5D,EAAE,CAAE,eAAgB;QAAC,CACd;MAAC,CACD,CAAC;IAAA,CACX;EACF,CACY,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -143,7 +143,10 @@ function PostTemplateDropdownContent({
|
|
|
143
143
|
template: slug || ''
|
|
144
144
|
})
|
|
145
145
|
}), canEdit && onNavigateToEntityRecord && /*#__PURE__*/_jsx("p", {
|
|
146
|
-
children: /*#__PURE__*/_jsx(Button
|
|
146
|
+
children: /*#__PURE__*/_jsx(Button
|
|
147
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
148
|
+
, {
|
|
149
|
+
__next40pxDefaultSize: false,
|
|
147
150
|
variant: "link",
|
|
148
151
|
onClick: () => {
|
|
149
152
|
onNavigateToEntityRecord({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","jsxs","_jsxs","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","kind","name","getCurrentTemplateId","title","slug","__next40pxDefaultSize","variant","children","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) && select( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the dropdown content for selecting a post template.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose The function to close the dropdown.\n *\n * @return {JSX.Element} The rendered dropdown content.\n */\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\n/**\n * Provides a dropdown menu for selecting and managing post templates.\n *\n * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.\n *\n * @return {JSX.Element} The rendered ClassicThemeControl component.\n */\nexport default ClassicThemeControl;\n"],"mappings":"AAAA;AACA;AACA;AAC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;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe6C,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","jsxs","_jsxs","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","kind","name","getCurrentTemplateId","title","slug","__next40pxDefaultSize","variant","children","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) && select( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the dropdown content for selecting a post template.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose The function to close the dropdown.\n *\n * @return {JSX.Element} The rendered dropdown content.\n */\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\n/**\n * Provides a dropdown menu for selecting and managing post templates.\n *\n * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.\n *\n * @return {JSX.Element} The rendered ClassicThemeControl component.\n */\nexport default ClassicThemeControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;AAC/E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASN,KAAK,IAAIO,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAErD,MAAMC,aAAa,GAAG;EACrBC,SAAS,EAAE,gCAAgC;EAC3CC,SAAS,EAAE;AACZ,CAAC;AAED,SAASC,kBAAkBA,CAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAG;EAClD,MAAMC,aAAa,GAAGvB,SAAS,CAAIwB,MAAM,IAAM;IAC9C,MAAMC,YAAY,GACjBD,MAAM,CAAEd,WAAY,CAAC,CAACgB,sBAAsB,CAAE,UAAW,CAAC;IAE3D,MAAM;MAAEC,oBAAoB;MAAEC;IAAmB,CAAC,GACjDJ,MAAM,CAAEd,WAAY,CAA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A,CAACjB,QAAQ;IACR0F,YAAY,EAAGtE,aAAe;IAC9BuE,YAAY;IACZC,YAAY,EAAGA,CAAE;MAAEpE,MAAM;MAAEqE;IAAS,CAAC,kBACpC5E,IAAA,CAACM,kBAAkB;MAACC,MAAM,EAAGA,MAAQ;MAACC,OAAO,EAAGoE;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAElD;IAAQ,CAAC,kBAC5B3B,IAAA,CAAC0B,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe6C,mBAAmB","ignoreList":[]}
|
|
@@ -12,7 +12,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
12
12
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
13
|
import { ENTER } from '@wordpress/keycodes';
|
|
14
14
|
import { pasteHandler } from '@wordpress/blocks';
|
|
15
|
-
import { __unstableUseRichText as useRichText, create,
|
|
15
|
+
import { __unstableUseRichText as useRichText, create, insert } from '@wordpress/rich-text';
|
|
16
16
|
import { useMergeRefs } from '@wordpress/compose';
|
|
17
17
|
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
18
18
|
|
|
@@ -52,9 +52,36 @@ function PostTitle(_, forwardedRef) {
|
|
|
52
52
|
insertBlocks,
|
|
53
53
|
insertDefaultBlock
|
|
54
54
|
} = useDispatch(blockEditorStore);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const decodedPlaceholder = decodeEntities(placeholder) || __('Add title');
|
|
56
|
+
const {
|
|
57
|
+
value,
|
|
58
|
+
onChange,
|
|
59
|
+
ref: richTextRef
|
|
60
|
+
} = useRichText({
|
|
61
|
+
value: title,
|
|
62
|
+
onChange(newValue) {
|
|
63
|
+
onUpdate(newValue.replace(REGEXP_NEWLINES, ' '));
|
|
64
|
+
},
|
|
65
|
+
placeholder: decodedPlaceholder,
|
|
66
|
+
selectionStart: selection.start,
|
|
67
|
+
selectionEnd: selection.end,
|
|
68
|
+
onSelectionChange(newStart, newEnd) {
|
|
69
|
+
setSelection(sel => {
|
|
70
|
+
const {
|
|
71
|
+
start,
|
|
72
|
+
end
|
|
73
|
+
} = sel;
|
|
74
|
+
if (start === newStart && end === newEnd) {
|
|
75
|
+
return sel;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
start: newStart,
|
|
79
|
+
end: newEnd
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
__unstableDisableFormats: false
|
|
84
|
+
});
|
|
58
85
|
function onInsertBlockAfter(blocks) {
|
|
59
86
|
insertBlocks(blocks, 0);
|
|
60
87
|
}
|
|
@@ -113,55 +140,15 @@ function PostTitle(_, forwardedRef) {
|
|
|
113
140
|
onInsertBlockAfter(content);
|
|
114
141
|
}
|
|
115
142
|
} else {
|
|
116
|
-
const value = {
|
|
117
|
-
...create({
|
|
118
|
-
html: title
|
|
119
|
-
}),
|
|
120
|
-
...selection
|
|
121
|
-
};
|
|
122
|
-
|
|
123
143
|
// Strip HTML to avoid unwanted HTML being added to the title.
|
|
124
144
|
// In the majority of cases it is assumed that HTML in the title
|
|
125
145
|
// is undesirable.
|
|
126
146
|
const contentNoHTML = stripHTML(content);
|
|
127
|
-
|
|
147
|
+
onChange(insert(value, create({
|
|
128
148
|
html: contentNoHTML
|
|
129
|
-
}));
|
|
130
|
-
onUpdate(toHTMLString({
|
|
131
|
-
value: newValue
|
|
132
|
-
}));
|
|
133
|
-
setSelection({
|
|
134
|
-
start: newValue.start,
|
|
135
|
-
end: newValue.end
|
|
136
|
-
});
|
|
149
|
+
})));
|
|
137
150
|
}
|
|
138
151
|
}
|
|
139
|
-
const decodedPlaceholder = decodeEntities(placeholder) || __('Add title');
|
|
140
|
-
const {
|
|
141
|
-
ref: richTextRef
|
|
142
|
-
} = useRichText({
|
|
143
|
-
value: title,
|
|
144
|
-
onChange,
|
|
145
|
-
placeholder: decodedPlaceholder,
|
|
146
|
-
selectionStart: selection.start,
|
|
147
|
-
selectionEnd: selection.end,
|
|
148
|
-
onSelectionChange(newStart, newEnd) {
|
|
149
|
-
setSelection(sel => {
|
|
150
|
-
const {
|
|
151
|
-
start,
|
|
152
|
-
end
|
|
153
|
-
} = sel;
|
|
154
|
-
if (start === newStart && end === newEnd) {
|
|
155
|
-
return sel;
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
start: newStart,
|
|
159
|
-
end: newEnd
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
__unstableDisableFormats: false
|
|
164
|
-
});
|
|
165
152
|
|
|
166
153
|
// The wp-block className is important for editor styles.
|
|
167
154
|
// This same block is used in both the visual and the code editor.
|
|
@@ -183,7 +170,6 @@ function PostTitle(_, forwardedRef) {
|
|
|
183
170
|
onFocus: onSelect,
|
|
184
171
|
onBlur: onUnselect,
|
|
185
172
|
onKeyDown: onKeyDown,
|
|
186
|
-
onKeyPress: onUnselect,
|
|
187
173
|
onPaste: onPaste
|
|
188
174
|
})
|
|
189
175
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","forwardRef","useState","decodeEntities","useSelect","useDispatch","store","blockEditorStore","ENTER","pasteHandler","__unstableUseRichText","useRichText","create","toHTMLString","insert","useMergeRefs","__unstableStripHTML","stripHTML","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","PostTypeSupportCheck","jsx","_jsx","PostTitle","_","forwardedRef","placeholder","select","getSettings","titlePlaceholder","isSelected","setIsSelected","ref","focusRef","title","setTitle","onUpdate","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","onChange","value","replace","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","preventDefault","onPaste","clipboardData","plainText","html","getData","error","window","console","log","content","HTML","length","firstBlock","name","contentNoHTML","attributes","slice","newValue","start","end","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","className","supportKeys","children","contentEditable","role","onFocus","onBlur","onKeyPress"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\ttoHTMLString,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst { placeholder } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder } = getSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error ) {\n\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t// behaviour.\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\tconst value = {\n\t\t\t\t...create( { html: title } ),\n\t\t\t\t...selection,\n\t\t\t};\n\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\n\t\t\tconst newValue = insert( value, create( { html: contentNoHTML } ) );\n\t\t\tonUpdate( toHTMLString( { value: newValue } ) );\n\t\t\tsetSelection( {\n\t\t\t\tstart: newValue.start,\n\t\t\t\tend: newValue.end,\n\t\t\t} );\n\t\t}\n\t}\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst { ref: richTextRef } = useRichText( {\n\t\tvalue: title,\n\t\tonChange,\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n}\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {Component} The rendered PostTitle component.\n */\nexport default forwardRef( PostTitle );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;AACvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,MAAM,EACNC,YAAY,EACZC,MAAM,QACA,sBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,aAAa;AACjE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,oBAAoB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9D,SAASC,SAASA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACrC,MAAM;IAAEC;EAA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AE,CAAC;;EAEH;EACA;EACA,MAAMC,SAAS,GAAGvF,IAAI,CAAEmB,kBAAkB,EAAE;IAC3C,aAAa,EAAEc;EAChB,CAAE,CAAC;EAEH;IAAA;IACC;IACAR,IAAA,CAACF,oBAAoB;MAACiE,WAAW,EAAC,OAAO;MAAAC,QAAA,eACxChE,IAAA;QACCU,GAAG,EAAGnB,YAAY,CAAE,CAAE+D,WAAW,EAAE3C,QAAQ,CAAG,CAAG;QACjDsD,eAAe;QACfH,SAAS,EAAGA,SAAW;QACvB,cAAaT,kBAAoB;QACjCa,IAAI,EAAC,SAAS;QACd,kBAAe,MAAM;QACrBC,OAAO,EAAG1C,QAAU;QACpB2C,MAAM,EAAG1C,UAAY;QACrBG,SAAS,EAAGA,SAAW;QACvBwC,UAAU,EAAG3C,UAAY;QACzBO,OAAO,EAAGA;MAAS,CACnB;IAAC,CACmB;IACtB;EAAA;AAEF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAexD,UAAU,CAAEwB,SAAU,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__","forwardRef","useState","decodeEntities","useSelect","useDispatch","store","blockEditorStore","ENTER","pasteHandler","__unstableUseRichText","useRichText","create","insert","useMergeRefs","__unstableStripHTML","stripHTML","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","PostTypeSupportCheck","jsx","_jsx","PostTitle","_","forwardedRef","placeholder","select","getSettings","titlePlaceholder","isSelected","setIsSelected","ref","focusRef","title","setTitle","onUpdate","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","decodedPlaceholder","value","onChange","richTextRef","newValue","replace","selectionStart","start","selectionEnd","end","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","preventDefault","onPaste","clipboardData","plainText","html","getData","error","window","console","log","content","HTML","length","firstBlock","name","contentNoHTML","attributes","slice","className","supportKeys","children","contentEditable","role","onFocus","onBlur"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst { placeholder } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder } = getSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: title,\n\t\tonChange( newValue ) {\n\t\t\tonUpdate( newValue.replace( REGEXP_NEWLINES, ' ' ) );\n\t\t},\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error ) {\n\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t// behaviour.\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\t\t\tonChange( insert( value, create( { html: contentNoHTML } ) ) );\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n}\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {Component} The rendered PostTitle component.\n */\nexport default forwardRef( PostTitle );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;AACvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,MAAM,EACNC,MAAM,QACA,sBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,aAAa;AACjE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,oBAAoB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9D,SAASC,SAASA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACrC,MAAM;IAAEC;EAAY,CAAC,GAAGvB,SAAS,CAAIwB,MAAM,IAAM;IAChD,MAAM;MAAEC;IAAY,CAAC,GAAGD,MAAM,CAAErB,gBAAiB,CAAC;IAClD,MAAM;MAAEuB;IAAiB,CAAC,GAAGD,WAAW,CAAC,CAAC;IAE1C,OAAO;MACNF,WAAW,EAAEG;IACd,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAA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AU,CAAEuB,SAAU,CAAC","ignoreList":[]}
|
|
@@ -90,7 +90,10 @@ export default function PostURL({
|
|
|
90
90
|
prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {
|
|
91
91
|
children: "/"
|
|
92
92
|
}),
|
|
93
|
-
suffix: /*#__PURE__*/_jsx(Button
|
|
93
|
+
suffix: /*#__PURE__*/_jsx(Button
|
|
94
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
95
|
+
, {
|
|
96
|
+
__next40pxDefaultSize: false,
|
|
94
97
|
icon: copySmall,
|
|
95
98
|
ref: copyButtonRef,
|
|
96
99
|
label: __('Copy')
|