@wordpress/editor 12.19.0 → 12.21.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/entities-saved-states/entity-record-item.js +1 -0
  3. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  4. package/build/components/entities-saved-states/entity-type-list.js +1 -7
  5. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  6. package/build/components/entities-saved-states/index.js +1 -1
  7. package/build/components/entities-saved-states/index.js.map +1 -1
  8. package/build/components/index.js +18 -0
  9. package/build/components/index.js.map +1 -1
  10. package/build/components/post-comments/index.js +1 -0
  11. package/build/components/post-comments/index.js.map +1 -1
  12. package/build/components/post-format/index.js +1 -1
  13. package/build/components/post-format/index.js.map +1 -1
  14. package/build/components/post-pending-status/index.js +1 -0
  15. package/build/components/post-pending-status/index.js.map +1 -1
  16. package/build/components/post-pingbacks/index.js +1 -0
  17. package/build/components/post-pingbacks/index.js.map +1 -1
  18. package/build/components/post-publish-button/index.js +11 -2
  19. package/build/components/post-publish-button/index.js.map +1 -1
  20. package/build/components/post-publish-panel/index.js +1 -0
  21. package/build/components/post-publish-panel/index.js.map +1 -1
  22. package/build/components/post-publish-panel/maybe-category-panel.js +1 -7
  23. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  24. package/build/components/post-publish-panel/maybe-post-format-panel.js +1 -1
  25. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  26. package/build/components/post-publish-panel/maybe-tags-panel.js +1 -7
  27. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  28. package/build/components/post-saved-state/index.js +19 -5
  29. package/build/components/post-saved-state/index.js.map +1 -1
  30. package/build/components/post-schedule/index.js +13 -16
  31. package/build/components/post-schedule/index.js.map +1 -1
  32. package/build/components/post-sticky/index.js +1 -0
  33. package/build/components/post-sticky/index.js.map +1 -1
  34. package/build/components/post-taxonomies/check.js +1 -7
  35. package/build/components/post-taxonomies/check.js.map +1 -1
  36. package/build/components/post-taxonomies/flat-term-selector.js +3 -1
  37. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  38. package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -2
  39. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  40. package/build/components/post-taxonomies/index.js +1 -1
  41. package/build/components/post-taxonomies/index.js.map +1 -1
  42. package/build/components/post-title/index.js +4 -2
  43. package/build/components/post-title/index.js.map +1 -1
  44. package/build/components/post-type-support-check/index.js +1 -7
  45. package/build/components/post-type-support-check/index.js.map +1 -1
  46. package/build/components/theme-support-check/index.js +2 -2
  47. package/build/components/theme-support-check/index.js.map +1 -1
  48. package/build/components/time-to-read/index.js +2 -6
  49. package/build/components/time-to-read/index.js.map +1 -1
  50. package/build/store/selectors.js +1 -6
  51. package/build/store/selectors.js.map +1 -1
  52. package/build/store/utils/notice-builder.js +2 -2
  53. package/build/store/utils/notice-builder.js.map +1 -1
  54. package/build-module/components/entities-saved-states/entity-record-item.js +1 -0
  55. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  56. package/build-module/components/entities-saved-states/entity-type-list.js +1 -6
  57. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  58. package/build-module/components/entities-saved-states/index.js +2 -2
  59. package/build-module/components/entities-saved-states/index.js.map +1 -1
  60. package/build-module/components/index.js +3 -1
  61. package/build-module/components/index.js.map +1 -1
  62. package/build-module/components/post-comments/index.js +1 -0
  63. package/build-module/components/post-comments/index.js.map +1 -1
  64. package/build-module/components/post-format/index.js +2 -2
  65. package/build-module/components/post-format/index.js.map +1 -1
  66. package/build-module/components/post-pending-status/index.js +1 -0
  67. package/build-module/components/post-pending-status/index.js.map +1 -1
  68. package/build-module/components/post-pingbacks/index.js +1 -0
  69. package/build-module/components/post-pingbacks/index.js.map +1 -1
  70. package/build-module/components/post-publish-button/index.js +12 -3
  71. package/build-module/components/post-publish-button/index.js.map +1 -1
  72. package/build-module/components/post-publish-panel/index.js +1 -0
  73. package/build-module/components/post-publish-panel/index.js.map +1 -1
  74. package/build-module/components/post-publish-panel/maybe-category-panel.js +1 -6
  75. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  76. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -2
  77. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  78. package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -6
  79. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  80. package/build-module/components/post-saved-state/index.js +19 -5
  81. package/build-module/components/post-saved-state/index.js.map +1 -1
  82. package/build-module/components/post-schedule/index.js +12 -17
  83. package/build-module/components/post-schedule/index.js.map +1 -1
  84. package/build-module/components/post-sticky/index.js +1 -0
  85. package/build-module/components/post-sticky/index.js.map +1 -1
  86. package/build-module/components/post-taxonomies/check.js +1 -6
  87. package/build-module/components/post-taxonomies/check.js.map +1 -1
  88. package/build-module/components/post-taxonomies/flat-term-selector.js +3 -2
  89. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  90. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +4 -3
  91. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  92. package/build-module/components/post-taxonomies/index.js +2 -2
  93. package/build-module/components/post-taxonomies/index.js.map +1 -1
  94. package/build-module/components/post-title/index.js +3 -2
  95. package/build-module/components/post-title/index.js.map +1 -1
  96. package/build-module/components/post-type-support-check/index.js +1 -6
  97. package/build-module/components/post-type-support-check/index.js.map +1 -1
  98. package/build-module/components/theme-support-check/index.js +3 -3
  99. package/build-module/components/theme-support-check/index.js.map +1 -1
  100. package/build-module/components/time-to-read/index.js +2 -6
  101. package/build-module/components/time-to-read/index.js.map +1 -1
  102. package/build-module/store/selectors.js +1 -6
  103. package/build-module/store/selectors.js.map +1 -1
  104. package/build-module/store/utils/notice-builder.js +3 -3
  105. package/build-module/store/utils/notice-builder.js.map +1 -1
  106. package/build-style/style-rtl.css +0 -4
  107. package/build-style/style.css +0 -4
  108. package/package.json +31 -28
  109. package/src/components/editor-help/test/index.native.js +2 -2
  110. package/src/components/entities-saved-states/entity-record-item.js +1 -0
  111. package/src/components/entities-saved-states/entity-type-list.js +1 -7
  112. package/src/components/entities-saved-states/index.js +2 -3
  113. package/src/components/index.js +2 -0
  114. package/src/components/post-comments/index.js +1 -0
  115. package/src/components/post-format/index.js +2 -2
  116. package/src/components/post-pending-status/index.js +1 -0
  117. package/src/components/post-pingbacks/index.js +1 -0
  118. package/src/components/post-publish-button/index.js +13 -4
  119. package/src/components/post-publish-panel/index.js +1 -0
  120. package/src/components/post-publish-panel/maybe-category-panel.js +1 -6
  121. package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -2
  122. package/src/components/post-publish-panel/maybe-tags-panel.js +1 -6
  123. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -15
  124. package/src/components/post-saved-state/index.js +15 -3
  125. package/src/components/post-saved-state/style.scss +0 -4
  126. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +1 -1
  127. package/src/components/post-schedule/index.js +16 -20
  128. package/src/components/post-sticky/index.js +1 -0
  129. package/src/components/post-taxonomies/check.js +2 -7
  130. package/src/components/post-taxonomies/flat-term-selector.js +3 -2
  131. package/src/components/post-taxonomies/hierarchical-term-selector.js +4 -3
  132. package/src/components/post-taxonomies/index.js +2 -2
  133. package/src/components/post-text-editor/test/index.js +7 -3
  134. package/src/components/post-title/index.js +6 -2
  135. package/src/components/post-type-support-check/index.js +3 -9
  136. package/src/components/theme-support-check/index.js +5 -3
  137. package/src/components/time-to-read/index.js +2 -2
  138. package/src/store/selectors.js +1 -10
  139. package/src/store/test/selectors.js +2 -56
  140. package/src/store/utils/notice-builder.js +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/hierarchical-term-selector.js"],"names":["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","term","parseInt","toLowerCase","getFilterMatcher","filterValue","matchTermsForFilter","originalTerm","HierarchicalTermSelector","slug","adding","setAdding","formName","setFormName","formParent","setFormParent","showForm","setShowForm","setFilterValue","filteredTermsTree","setFilteredTermsTree","debouncedSpeak","speak","hasCreateAction","hasAssignAction","loading","availableTerms","taxonomy","select","getCurrentPost","getEditedPostAttribute","editorStore","getTaxonomy","getEntityRecords","isResolving","coreStore","_taxonomy","rest_base","editPost","saveEntityRecord","availableTermsTree","addTerm","onUpdateTerms","termIds","onChange","termId","hasTerm","includes","newTerms","onChangeFormName","value","onChangeFormParent","parentId","onToggleForm","onAddTerm","event","preventDefault","existingTerm","newTerm","termAddedMessage","setFilter","newFilteredTermsTree","getResultCount","count","i","resultCount","resultsFoundMessage","renderTerms","renderedTerms","labelWithFallback","labelProperty","fallbackIsCategory","fallbackIsNotCategory","newTermButtonLabel","newTermLabel","parentSelectLabel","noParentOption","newTermSubmitLabel","filterLabel","groupLabel","showFilter"],"mappings":";;;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,CAAC,CADU;AAErBC,EAAAA,OAAO,EAAE,MAFY;AAGrBC,EAAAA,KAAK,EAAE,KAHc;AAIrBC,EAAAA,OAAO,EAAE,gBAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;AAQA,MAAMC,0BAA0B,GAAG,CAAnC;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A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AAA,IAAI,EAAG0B;AALR,IATF,EAiBC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,SAAS,EAAC;AAHX,KAKGqC,kBALH,CAjBD,CA9BF,CADD;AA2DA;;eAEc,6BAAa,yBAAb,EACdrE,wBADc,C","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get, some, unescape as unescapeString, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\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';\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 find( terms, ( 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 {WPElement} 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\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\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\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};\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? without( terms, 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 ( ! some( terms, ( 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\n\t\tconst newTerm = await addTerm( {\n\t\t\tname: formName,\n\t\t\tparent: formParent ? formParent : undefined,\n\t\t} );\n\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: taxonomy name */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' )\n\t\t\t)\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\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={ unescapeString( 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\tget(\n\t\t\ttaxonomy,\n\t\t\t[ 'labels', labelProperty ],\n\t\t\tslug === 'category' ? fallbackIsCategory : fallbackIsNotCategory\n\t\t);\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 = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'search_items' ],\n\t\t__( 'Search Terms' )\n\t);\n\tconst groupLabel = get( taxonomy, [ 'name' ], __( 'Terms' ) );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<>\n\t\t\t{ showFilter && (\n\t\t\t\t<TextControl\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-filter\"\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<Button\n\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t>\n\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/hierarchical-term-selector.js"],"names":["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","term","parseInt","toLowerCase","getFilterMatcher","filterValue","matchTermsForFilter","originalTerm","HierarchicalTermSelector","slug","adding","setAdding","formName","setFormName","formParent","setFormParent","showForm","setShowForm","setFilterValue","filteredTermsTree","setFilteredTermsTree","debouncedSpeak","speak","hasCreateAction","hasAssignAction","loading","availableTerms","taxonomy","select","getCurrentPost","getEditedPostAttribute","editorStore","getTaxonomy","getEntityRecords","isResolving","coreStore","_taxonomy","rest_base","editPost","saveEntityRecord","availableTermsTree","addTerm","onUpdateTerms","termIds","onChange","termId","hasTerm","includes","newTerms","onChangeFormName","value","onChangeFormParent","parentId","onToggleForm","onAddTerm","event","preventDefault","existingTerm","some","newTerm","termAddedMessage","setFilter","newFilteredTermsTree","getResultCount","count","i","resultCount","resultsFoundMessage","renderTerms","renderedTerms","labelWithFallback","labelProperty","fallbackIsCategory","fallbackIsNotCategory","newTermButtonLabel","newTermLabel","parentSelectLabel","noParentOption","newTermSubmitLabel","filterLabel","groupLabel","showFilter"],"mappings":";;;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,CAAC,CADU;AAErBC,EAAAA,OAAO,EAAE,MAFY;AAGrBC,EAAAA,KAAK,EAAE,KAHc;AAIrBC,EAAAA,OAAO,EAAE,gBAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;AAQA,MAAMC,0BAA0B,GAAG,CAAnC;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,cAAT,CAAyBC,SAAzB,EAAoCC,KAApC,EAA4C;AAClD,QAAMC,gBAAgB,GAAKC,QAAF,IAAgB;AACxC,QAAKF,KAAK,CAACG,OAAN,CAAeD,QAAQ,CAACE,EAAxB,MAAiC,CAAC,CAAvC,EAA2C;AAC1C,aAAO,IAAP;AACA;;AACD,QAAKC,SAAS,KAAKH,QAAQ,CAACI,QAA5B,EAAuC;AACtC,aAAO,KAAP;AACA;;AACD,WACCJ,QAAQ,CAACI,QAAT,CACEC,GADF,CACON,gBADP,EAEEO,MAFF,CAEYC,KAAF,IAAaA,KAFvB,EAE+BC,MAF/B,GAEwC,CAHzC;AAKA,GAZD;;AAaA,QAAMC,qBAAqB,GAAG,C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IC,IAAA,QAAQ,EAAGwD;AAJZ,IAFF,EASC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,QAAQ,EAAC,GAFV;AAGC,IAAA,IAAI,EAAC,OAHN;AAIC,kBAAamB;AAJd,KAMGZ,WAAW,CACZ,OAAO/D,WAAP,GAAqBc,iBAArB,GAAyCqB,kBAD7B,CANd,CATD,EAmBG,CAAEf,OAAF,IAAaF,eAAb,IACD,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAG8B,YADX;AAEC,IAAA,SAAS,EAAC,gDAFX;AAGC,qBAAgBrC,QAHjB;AAIC,IAAA,OAAO,EAAC;AAJT,KAMG0D,kBANH,CApBF,EA6BG1D,QAAQ,IACT;AAAM,IAAA,QAAQ,EAAGsC;AAAjB,KACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,kDADX;AAEC,IAAA,KAAK,EAAGqB,YAFT;AAGC,IAAA,KAAK,EAAG/D,QAHT;AAIC,IAAA,QAAQ,EAAGqC,gBAJZ;AAKC,IAAA,QAAQ;AALT,IADD,EAQG,CAAC,CAAEvB,cAAc,CAACpC,MAAlB,IACD,4BAAC,sBAAD;AACC,IAAA,KAAK,EAAGsF,iBADT;AAEC,IAAA,aAAa,EAAGC,cAFjB;AAGC,IAAA,QAAQ,EAAG1B,kBAHZ;AAIC,IAAA,UAAU,EAAGrC,UAJd;AAKC,IAAA,IAAI,EAAG0B;AALR,IATF,EAiBC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,SAAS,EAAC;AAHX,KAKGsC,kBALH,CAjBD,CA9BF,CADD;AA2DA;;eAEc,6BAAa,yBAAb,EACdtE,wBADc,C","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get, unescape as unescapeString } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\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';\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 find( terms, ( 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 {WPElement} 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\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\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\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};\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\n\t\tconst newTerm = await addTerm( {\n\t\t\tname: formName,\n\t\t\tparent: formParent ? formParent : undefined,\n\t\t} );\n\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: taxonomy name */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' )\n\t\t\t)\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={ unescapeString( 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\tget(\n\t\t\ttaxonomy,\n\t\t\t[ 'labels', labelProperty ],\n\t\t\tslug === 'category' ? fallbackIsCategory : fallbackIsNotCategory\n\t\t);\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 = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'search_items' ],\n\t\t__( 'Search Terms' )\n\t);\n\tconst groupLabel = get( taxonomy, [ 'name' ], __( 'Terms' ) );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<>\n\t\t\t{ showFilter && (\n\t\t\t\t<TextControl\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-filter\"\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<Button\n\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t>\n\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"]}
@@ -43,7 +43,7 @@ function PostTaxonomies(_ref) {
43
43
  taxonomies,
44
44
  taxonomyWrapper = identity
45
45
  } = _ref;
46
- const availableTaxonomies = (0, _lodash.filter)(taxonomies, taxonomy => (0, _lodash.includes)(taxonomy.types, postType));
46
+ const availableTaxonomies = (0, _lodash.filter)(taxonomies, taxonomy => taxonomy.types.includes(postType));
47
47
  const visibleTaxonomies = (0, _lodash.filter)(availableTaxonomies, // In some circumstances .visibility can end up as undefined so optional chaining operator required.
48
48
  // https://github.com/WordPress/gutenberg/issues/40326
49
49
  taxonomy => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"names":["identity","x","PostTaxonomies","postType","taxonomies","taxonomyWrapper","availableTaxonomies","taxonomy","types","visibleTaxonomies","visibility","show_ui","map","TaxonomyComponent","hierarchical","HierarchicalTermSelector","FlatTermSelector","slug","select","editorStore","getCurrentPostType","coreStore","getTaxonomies","per_page"],"mappings":";;;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,QAAQ,GAAKC,CAAF,IAASA,CAA1B;;AAEO,SAASC,cAAT,OAIH;AAAA,MAJ4B;AAC/BC,IAAAA,QAD+B;AAE/BC,IAAAA,UAF+B;AAG/BC,IAAAA,eAAe,GAAGL;AAHa,GAI5B;AACH,QAAMM,mBAAmB,GAAG,oBAAQF,UAAR,EAAsBG,QAAF,IAC/C,sBAAUA,QAAQ,CAACC,KAAnB,EAA0BL,QAA1B,CAD2B,CAA5B;AAGA,QAAMM,iBAAiB,GAAG,oBACzBH,mBADyB,EAEzB;AACA;AACEC,EAAAA,QAAF;AAAA;;AAAA,mCAAgBA,QAAQ,CAACG,UAAzB,yDAAgB,qBAAqBC,OAArC;AAAA,GAJyB,CAA1B;AAMA,SAAOF,iBAAiB,CAACG,GAAlB,CAAyBL,QAAF,IAAgB;AAC7C,UAAMM,iBAAiB,GAAGN,QAAQ,CAACO,YAAT,GACvBC,iCADuB,GAEvBC,yBAFH;AAGA,WACC,4BAAC,iBAAD;AAAU,MAAA,GAAG,EAAI,YAAYT,QAAQ,CAACU,IAAM;AAA5C,OACGZ,eAAe,CAChB,4BAAC,iBAAD;AAAmB,MAAA,IAAI,EAAGE,QAAQ,CAACU;AAAnC,MADgB,EAEhBV,QAFgB,CADlB,CADD;AAQA,GAZM,CAAP;AAaA;;eAEc,sBAAS,CACvB,sBAAcW,MAAF,IAAc;AACzB,SAAO;AACNf,IAAAA,QAAQ,EAAEe,MAAM,CAAEC,YAAF,CAAN,CAAsBC,kBAAtB,EADJ;AAENhB,IAAAA,UAAU,EAAEc,MAAM,CAAEG,eAAF,CAAN,CAAoBC,aAApB,CAAmC;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAnC;AAFN,GAAP;AAIA,CALD,CADuB,CAAT,EAOVrB,cAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, includes } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( {\n\tpostType,\n\ttaxonomies,\n\ttaxonomyWrapper = identity,\n} ) {\n\tconst availableTaxonomies = filter( taxonomies, ( taxonomy ) =>\n\t\tincludes( taxonomy.types, postType )\n\t);\n\tconst visibleTaxonomies = filter(\n\t\tavailableTaxonomies,\n\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t( taxonomy ) => taxonomy.visibility?.show_ui\n\t);\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomies );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"names":["identity","x","PostTaxonomies","postType","taxonomies","taxonomyWrapper","availableTaxonomies","taxonomy","types","includes","visibleTaxonomies","visibility","show_ui","map","TaxonomyComponent","hierarchical","HierarchicalTermSelector","FlatTermSelector","slug","select","editorStore","getCurrentPostType","coreStore","getTaxonomies","per_page"],"mappings":";;;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,QAAQ,GAAKC,CAAF,IAASA,CAA1B;;AAEO,SAASC,cAAT,OAIH;AAAA,MAJ4B;AAC/BC,IAAAA,QAD+B;AAE/BC,IAAAA,UAF+B;AAG/BC,IAAAA,eAAe,GAAGL;AAHa,GAI5B;AACH,QAAMM,mBAAmB,GAAG,oBAAQF,UAAR,EAAsBG,QAAF,IAC/CA,QAAQ,CAACC,KAAT,CAAeC,QAAf,CAAyBN,QAAzB,CAD2B,CAA5B;AAGA,QAAMO,iBAAiB,GAAG,oBACzBJ,mBADyB,EAEzB;AACA;AACEC,EAAAA,QAAF;AAAA;;AAAA,mCAAgBA,QAAQ,CAACI,UAAzB,yDAAgB,qBAAqBC,OAArC;AAAA,GAJyB,CAA1B;AAMA,SAAOF,iBAAiB,CAACG,GAAlB,CAAyBN,QAAF,IAAgB;AAC7C,UAAMO,iBAAiB,GAAGP,QAAQ,CAACQ,YAAT,GACvBC,iCADuB,GAEvBC,yBAFH;AAGA,WACC,4BAAC,iBAAD;AAAU,MAAA,GAAG,EAAI,YAAYV,QAAQ,CAACW,IAAM;AAA5C,OACGb,eAAe,CAChB,4BAAC,iBAAD;AAAmB,MAAA,IAAI,EAAGE,QAAQ,CAACW;AAAnC,MADgB,EAEhBX,QAFgB,CADlB,CADD;AAQA,GAZM,CAAP;AAaA;;eAEc,sBAAS,CACvB,sBAAcY,MAAF,IAAc;AACzB,SAAO;AACNhB,IAAAA,QAAQ,EAAEgB,MAAM,CAAEC,YAAF,CAAN,CAAsBC,kBAAtB,EADJ;AAENjB,IAAAA,UAAU,EAAEe,MAAM,CAAEG,eAAF,CAAN,CAAoBC,aAApB,CAAmC;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAnC;AAFN,GAAP;AAIA,CALD,CADuB,CAAT,EAOVtB,cAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { filter } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( {\n\tpostType,\n\ttaxonomies,\n\ttaxonomyWrapper = identity,\n} ) {\n\tconst availableTaxonomies = filter( taxonomies, ( taxonomy ) =>\n\t\ttaxonomy.types.includes( postType )\n\t);\n\tconst visibleTaxonomies = filter(\n\t\tavailableTaxonomies,\n\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t( taxonomy ) => taxonomy.visibility?.show_ui\n\t);\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomies );\n"]}
@@ -27,6 +27,8 @@ var _richText = require("@wordpress/rich-text");
27
27
 
28
28
  var _compose = require("@wordpress/compose");
29
29
 
30
+ var _dom = require("@wordpress/dom");
31
+
30
32
  var _postTypeSupportCheck = _interopRequireDefault(require("../post-type-support-check"));
31
33
 
32
34
  var _store = require("../../store");
@@ -186,7 +188,7 @@ function PostTitle(_, forwardedRef) {
186
188
  const [firstBlock] = content;
187
189
 
188
190
  if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
189
- onUpdate(firstBlock.attributes.content);
191
+ onUpdate((0, _dom.__unstableStripHTML)(firstBlock.attributes.content));
190
192
  onInsertBlockAfter(content.slice(1));
191
193
  } else {
192
194
  onInsertBlockAfter(content);
@@ -198,7 +200,7 @@ function PostTitle(_, forwardedRef) {
198
200
  ...selection
199
201
  };
200
202
  const newValue = (0, _richText.insert)(value, (0, _richText.create)({
201
- html: content
203
+ html: (0, _dom.__unstableStripHTML)(content)
202
204
  }));
203
205
  onUpdate((0, _richText.toHTMLString)({
204
206
  value: newValue
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-title/index.js"],"names":["REGEXP_NEWLINES","PostTitle","_","forwardedRef","ref","isSelected","setIsSelected","editPost","editorStore","insertDefaultBlock","clearSelectedBlock","insertBlocks","blockEditorStore","isCleanNewPost","title","placeholder","hasFixedToolbar","select","getEditedPostAttribute","_isCleanNewPost","getSettings","titlePlaceholder","_hasFixedToolbar","focus","current","ownerDocument","activeElement","body","onEnterPress","undefined","onInsertBlockAfter","blocks","onUpdate","newTitle","selection","setSelection","onSelect","onUnselect","onChange","value","replace","onKeyDown","event","keyCode","ENTER","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","attributes","slice","newValue","start","end","className","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","preserveWhiteSpace"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,UAAxB;;AAEA,SAASC,SAAT,CAAoBC,CAApB,EAAuBC,YAAvB,EAAsC;AACrC,QAAMC,GAAG,GAAG,sBAAZ;AACA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,KAAV,CAAtC;AACA,QAAM;A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AA7B;AAsBA;;AACA,SACC,4BAAC,6BAAD;AAAsB,IAAA,WAAW,EAAC;AAAlC,KACC;AACC,IAAA,GAAG,EAAG,2BAAc,CAAER,WAAF,EAAehE,GAAf,CAAd,CADP;AAEC,IAAA,eAAe,MAFhB;AAGC,IAAA,SAAS,EAAG8D,SAHb;AAIC,kBAAaC,kBAJd;AAKC,IAAA,IAAI,EAAC,SALN;AAMC,sBAAe,MANhB;AAOC,IAAA,OAAO,EAAG/B,QAPX;AAQC,IAAA,MAAM,EAAGC,UARV;AASC,IAAA,SAAS,EAAGI,SATb;AAUC,IAAA,UAAU,EAAGJ,UAVd;AAWC,IAAA,OAAO,EAAGS;AAXX,IADD,CADD;AAiBA;AACA;;eAEc,yBAAY7C,SAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\ttoHTMLString,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Constants\n */\nconst REGEXP_NEWLINES = /[\\r\\n]+/g;\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst ref = useRef();\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { insertDefaultBlock, clearSelectedBlock, insertBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { isCleanNewPost, title, placeholder, hasFixedToolbar } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, isCleanNewPost: _isCleanNewPost } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\t\tgetSettings();\n\n\t\t\treturn {\n\t\t\t\tisCleanNewPost: _isCleanNewPost(),\n\t\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\t\tplaceholder: titlePlaceholder,\n\t\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tuseImperativeHandle( forwardedRef, () => ( {\n\t\tfocus: () => {\n\t\t\tref?.current?.focus();\n\t\t},\n\t} ) );\n\n\tuseEffect( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\t// Only autofocus the title when the post is entirely empty. This should\n\t\t// only happen for a new post, which means we focus the title on new\n\t\t// post so the author can start typing right away, without needing to\n\t\t// click anything.\n\t\tif ( isCleanNewPost && ( ! activeElement || body === activeElement ) ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [ isCleanNewPost ] );\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onUpdate( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\tconst [ selection, setSelection ] = useState( {} );\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 onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\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\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\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\tonUpdate( firstBlock.attributes.content );\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\t\t\tconst newValue = insert( value, create( { html: content } ) );\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\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 = classnames(\n\t\t'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text',\n\t\t{\n\t\t\t'is-selected': isSelected,\n\t\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t}\n\t);\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\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: true,\n\t\tpreserveWhiteSpace: true,\n\t} );\n\n\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, ref ] ) }\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);\n\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\nexport default forwardRef( PostTitle );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-title/index.js"],"names":["REGEXP_NEWLINES","PostTitle","_","forwardedRef","ref","isSelected","setIsSelected","editPost","editorStore","insertDefaultBlock","clearSelectedBlock","insertBlocks","blockEditorStore","isCleanNewPost","title","placeholder","hasFixedToolbar","select","getEditedPostAttribute","_isCleanNewPost","getSettings","titlePlaceholder","_hasFixedToolbar","focus","current","ownerDocument","activeElement","body","onEnterPress","undefined","onInsertBlockAfter","blocks","onUpdate","newTitle","selection","setSelection","onSelect","onUnselect","onChange","value","replace","onKeyDown","event","keyCode","ENTER","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","attributes","slice","newValue","start","end","className","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","preserveWhiteSpace"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,UAAxB;;AAEA,SAASC,SAAT,CAAoBC,CAApB,EAAuBC,YAAvB,EAAsC;AACrC,QAAMC,GAAG,GAAG,sBAAZ;AACA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,KAAV,CAAtC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaC,YAAb,CAArB;AACA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,kBAAtB;AAA0CC,IAAAA;AAA1C,MACL,uBAAaC,kBAAb,CADD;AAEA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,KAAlB;AAAyBC,IAAAA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D,SAHb;AAIC,kBAAaC,kBAJd;AAKC,IAAA,IAAI,EAAC,SALN;AAMC,sBAAe,MANhB;AAOC,IAAA,OAAO,EAAG/B,QAPX;AAQC,IAAA,MAAM,EAAGC,UARV;AASC,IAAA,SAAS,EAAGI,SATb;AAUC,IAAA,UAAU,EAAGJ,UAVd;AAWC,IAAA,OAAO,EAAGS;AAXX,IADD,CADD;AAiBA;AACA;;eAEc,yBAAY7C,SAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\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 PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Constants\n */\nconst REGEXP_NEWLINES = /[\\r\\n]+/g;\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst ref = useRef();\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { insertDefaultBlock, clearSelectedBlock, insertBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { isCleanNewPost, title, placeholder, hasFixedToolbar } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, isCleanNewPost: _isCleanNewPost } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\t\tgetSettings();\n\n\t\t\treturn {\n\t\t\t\tisCleanNewPost: _isCleanNewPost(),\n\t\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\t\tplaceholder: titlePlaceholder,\n\t\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tuseImperativeHandle( forwardedRef, () => ( {\n\t\tfocus: () => {\n\t\t\tref?.current?.focus();\n\t\t},\n\t} ) );\n\n\tuseEffect( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\t// Only autofocus the title when the post is entirely empty. This should\n\t\t// only happen for a new post, which means we focus the title on new\n\t\t// post so the author can start typing right away, without needing to\n\t\t// click anything.\n\t\tif ( isCleanNewPost && ( ! activeElement || body === activeElement ) ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [ isCleanNewPost ] );\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onUpdate( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\tconst [ selection, setSelection ] = useState( {} );\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 onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\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\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\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\tonUpdate( stripHTML( firstBlock.attributes.content ) );\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\t\t\tconst newValue = insert(\n\t\t\t\tvalue,\n\t\t\t\tcreate( { html: stripHTML( content ) } )\n\t\t\t);\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\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 = classnames(\n\t\t'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text',\n\t\t{\n\t\t\t'is-selected': isSelected,\n\t\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t}\n\t);\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\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: true,\n\t\tpreserveWhiteSpace: true,\n\t} );\n\n\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, ref ] ) }\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);\n\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\nexport default forwardRef( PostTitle );\n"]}
@@ -6,18 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PostTypeSupportCheck = PostTypeSupportCheck;
7
7
  exports.default = void 0;
8
8
 
9
- var _lodash = require("lodash");
10
-
11
9
  var _data = require("@wordpress/data");
12
10
 
13
11
  var _coreData = require("@wordpress/core-data");
14
12
 
15
13
  var _store = require("../../store");
16
14
 
17
- /**
18
- * External dependencies
19
- */
20
-
21
15
  /**
22
16
  * WordPress dependencies
23
17
  */
@@ -48,7 +42,7 @@ function PostTypeSupportCheck(_ref) {
48
42
  let isSupported = true;
49
43
 
50
44
  if (postType) {
51
- isSupported = (0, _lodash.some)((0, _lodash.castArray)(supportKeys), key => !!postType.supports[key]);
45
+ isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]);
52
46
  }
53
47
 
54
48
  if (!isSupported) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-type-support-check/index.js"],"names":["PostTypeSupportCheck","postType","children","supportKeys","isSupported","key","supports","select","getEditedPostAttribute","editorStore","getPostType","coreStore"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,OAAqE;AAAA,MAAtC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,GAAsC;AAC3E,MAAIC,WAAW,GAAG,IAAlB;;AACA,MAAKH,QAAL,EAAgB;AACfG,IAAAA,WAAW,GAAG,kBACb,uBAAWD,WAAX,CADa,EAEXE,GAAF,IAAW,CAAC,CAAEJ,QAAQ,CAACK,QAAT,CAAmBD,GAAnB,CAFD,CAAd;AAIA;;AAED,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SAAOF,QAAP;AACA;;eAEc,sBAAcK,MAAF,IAAc;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAA6BD,MAAM,CAAEE,YAAF,CAAzC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAkBH,MAAM,CAAEI,eAAF,CAA9B;AACA,SAAO;AACNV,IAAAA,QAAQ,EAAES,WAAW,CAAEF,sBAAsB,CAAE,MAAF,CAAxB;AADf,GAAP;AAGA,CANc,EAMVR,oBANU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { some, castArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * A component which renders its own children only if the current editor post\n * type supports one of the given `supportKeys` prop.\n *\n * @param {Object} props Props.\n * @param {string} [props.postType] Current post type.\n * @param {WPElement} props.children Children to be rendered if post\n * type supports.\n * @param {(string|string[])} props.supportKeys String or string array of keys\n * to test.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport function PostTypeSupportCheck( { postType, children, supportKeys } ) {\n\tlet isSupported = true;\n\tif ( postType ) {\n\t\tisSupported = some(\n\t\t\tcastArray( supportKeys ),\n\t\t\t( key ) => !! postType.supports[ key ]\n\t\t);\n\t}\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getEditedPostAttribute } = select( editorStore );\n\tconst { getPostType } = select( coreStore );\n\treturn {\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t};\n} )( PostTypeSupportCheck );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-type-support-check/index.js"],"names":["PostTypeSupportCheck","postType","children","supportKeys","isSupported","Array","isArray","some","key","supports","select","getEditedPostAttribute","editorStore","getPostType","coreStore"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,OAAqE;AAAA,MAAtC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,GAAsC;AAC3E,MAAIC,WAAW,GAAG,IAAlB;;AACA,MAAKH,QAAL,EAAgB;AACfG,IAAAA,WAAW,GAAG,CACbC,KAAK,CAACC,OAAN,CAAeH,WAAf,IAA+BA,WAA/B,GAA6C,CAAEA,WAAF,CADhC,EAEXI,IAFW,CAEHC,GAAF,IAAW,CAAC,CAAEP,QAAQ,CAACQ,QAAT,CAAmBD,GAAnB,CAFT,CAAd;AAGA;;AAED,MAAK,CAAEJ,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SAAOF,QAAP;AACA;;eAEc,sBAAcQ,MAAF,IAAc;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAA6BD,MAAM,CAAEE,YAAF,CAAzC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAkBH,MAAM,CAAEI,eAAF,CAA9B;AACA,SAAO;AACNb,IAAAA,QAAQ,EAAEY,WAAW,CAAEF,sBAAsB,CAAE,MAAF,CAAxB;AADf,GAAP;AAGA,CANc,EAMVX,oBANU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * A component which renders its own children only if the current editor post\n * type supports one of the given `supportKeys` prop.\n *\n * @param {Object} props Props.\n * @param {string} [props.postType] Current post type.\n * @param {WPElement} props.children Children to be rendered if post\n * type supports.\n * @param {(string|string[])} props.supportKeys String or string array of keys\n * to test.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport function PostTypeSupportCheck( { postType, children, supportKeys } ) {\n\tlet isSupported = true;\n\tif ( postType ) {\n\t\tisSupported = (\n\t\t\tArray.isArray( supportKeys ) ? supportKeys : [ supportKeys ]\n\t\t ).some( ( key ) => !! postType.supports[ key ] );\n\t}\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getEditedPostAttribute } = select( editorStore );\n\tconst { getPostType } = select( coreStore );\n\treturn {\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t};\n} )( PostTypeSupportCheck );\n"]}
@@ -32,14 +32,14 @@ function ThemeSupportCheck(_ref) {
32
32
  postType,
33
33
  supportKeys
34
34
  } = _ref;
35
- const isSupported = (0, _lodash.some)((0, _lodash.castArray)(supportKeys), key => {
35
+ const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
36
36
  const supported = (0, _lodash.get)(themeSupports, [key], false); // 'post-thumbnails' can be boolean or an array of post types.
37
37
  // In the latter case, we need to verify `postType` exists
38
38
  // within `supported`. If `postType` isn't passed, then the check
39
39
  // should fail.
40
40
 
41
41
  if ('post-thumbnails' === key && Array.isArray(supported)) {
42
- return (0, _lodash.includes)(supported, postType);
42
+ return supported.includes(postType);
43
43
  }
44
44
 
45
45
  return supported;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/theme-support-check/index.js"],"names":["ThemeSupportCheck","themeSupports","children","postType","supportKeys","isSupported","key","supported","Array","isArray","select","getThemeSupports","coreStore","getEditedPostAttribute","editorStore"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAKH;AAAA,MAL+B;AAClCC,IAAAA,aADkC;AAElCC,IAAAA,QAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC,IAAAA;AAJkC,GAK/B;AACH,QAAMC,WAAW,GAAG,kBAAM,uBAAWD,WAAX,CAAN,EAAkCE,GAAF,IAAW;AAC9D,UAAMC,SAAS,GAAG,iBAAKN,aAAL,EAAoB,CAAEK,GAAF,CAApB,EAA6B,KAA7B,CAAlB,CAD8D,CAE9D;AACA;AACA;AACA;;AACA,QAAK,sBAAsBA,GAAtB,IAA6BE,KAAK,CAACC,OAAN,CAAeF,SAAf,CAAlC,EAA+D;AAC9D,aAAO,sBAAUA,SAAV,EAAqBJ,QAArB,CAAP;AACA;;AACD,WAAOI,SAAP;AACA,GAVmB,CAApB;;AAYA,MAAK,CAAEF,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SAAOH,QAAP;AACA;;eAEc,sBAAcQ,MAAF,IAAc;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6BH,MAAM,CAAEI,YAAF,CAAzC;AACA,SAAO;AACNX,IAAAA,QAAQ,EAAEU,sBAAsB,CAAE,MAAF,CAD1B;AAENZ,IAAAA,aAAa,EAAEU,gBAAgB;AAFzB,GAAP;AAIA,CAPc,EAOVX,iBAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, includes, get, some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function ThemeSupportCheck( {\n\tthemeSupports,\n\tchildren,\n\tpostType,\n\tsupportKeys,\n} ) {\n\tconst isSupported = some( castArray( supportKeys ), ( key ) => {\n\t\tconst supported = get( themeSupports, [ key ], false );\n\t\t// 'post-thumbnails' can be boolean or an array of post types.\n\t\t// In the latter case, we need to verify `postType` exists\n\t\t// within `supported`. If `postType` isn't passed, then the check\n\t\t// should fail.\n\t\tif ( 'post-thumbnails' === key && Array.isArray( supported ) ) {\n\t\t\treturn includes( supported, postType );\n\t\t}\n\t\treturn supported;\n\t} );\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getThemeSupports } = select( coreStore );\n\tconst { getEditedPostAttribute } = select( editorStore );\n\treturn {\n\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\tthemeSupports: getThemeSupports(),\n\t};\n} )( ThemeSupportCheck );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/theme-support-check/index.js"],"names":["ThemeSupportCheck","themeSupports","children","postType","supportKeys","isSupported","Array","isArray","some","key","supported","includes","select","getThemeSupports","coreStore","getEditedPostAttribute","editorStore"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAKH;AAAA,MAL+B;AAClCC,IAAAA,aADkC;AAElCC,IAAAA,QAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC,IAAAA;AAJkC,GAK/B;AACH,QAAMC,WAAW,GAAG,CACnBC,KAAK,CAACC,OAAN,CAAeH,WAAf,IAA+BA,WAA/B,GAA6C,CAAEA,WAAF,CAD1B,EAEjBI,IAFiB,CAETC,GAAF,IAAW;AACnB,UAAMC,SAAS,GAAG,iBAAKT,aAAL,EAAoB,CAAEQ,GAAF,CAApB,EAA6B,KAA7B,CAAlB,CADmB,CAEnB;AACA;AACA;AACA;;AACA,QAAK,sBAAsBA,GAAtB,IAA6BH,KAAK,CAACC,OAAN,CAAeG,SAAf,CAAlC,EAA+D;AAC9D,aAAOA,SAAS,CAACC,QAAV,CAAoBR,QAApB,CAAP;AACA;;AACD,WAAOO,SAAP;AACA,GAZmB,CAApB;;AAcA,MAAK,CAAEL,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SAAOH,QAAP;AACA;;eAEc,sBAAcU,MAAF,IAAc;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6BH,MAAM,CAAEI,YAAF,CAAzC;AACA,SAAO;AACNb,IAAAA,QAAQ,EAAEY,sBAAsB,CAAE,MAAF,CAD1B;AAENd,IAAAA,aAAa,EAAEY,gBAAgB;AAFzB,GAAP;AAIA,CAPc,EAOVb,iBAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function ThemeSupportCheck( {\n\tthemeSupports,\n\tchildren,\n\tpostType,\n\tsupportKeys,\n} ) {\n\tconst isSupported = (\n\t\tArray.isArray( supportKeys ) ? supportKeys : [ supportKeys ]\n\t ).some( ( key ) => {\n\t\tconst supported = get( themeSupports, [ key ], false );\n\t\t// 'post-thumbnails' can be boolean or an array of post types.\n\t\t// In the latter case, we need to verify `postType` exists\n\t\t// within `supported`. If `postType` isn't passed, then the check\n\t\t// should fail.\n\t\tif ( 'post-thumbnails' === key && Array.isArray( supported ) ) {\n\t\t\treturn supported.includes( postType );\n\t\t}\n\t\treturn supported;\n\t} );\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getThemeSupports } = select( coreStore );\n\tconst { getEditedPostAttribute } = select( editorStore );\n\treturn {\n\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\tthemeSupports: getThemeSupports(),\n\t};\n} )( ThemeSupportCheck );\n"]}
@@ -43,15 +43,11 @@ function TimeToRead() {
43
43
  const wordCountType = (0, _i18n._x)('words', 'Word count type. Do not translate!');
44
44
  const minutesToRead = Math.round((0, _wordcount.count)(content, wordCountType) / AVERAGE_READING_RATE);
45
45
  const minutesToReadString = minutesToRead === 0 ? (0, _element.createInterpolateElement)((0, _i18n.__)('<span>< 1</span> minute'), {
46
- span: (0, _element.createElement)("span", {
47
- className: "table-of-contents__number"
48
- })
46
+ span: (0, _element.createElement)("span", null)
49
47
  }) : (0, _element.createInterpolateElement)((0, _i18n.sprintf)(
50
48
  /* translators: %s is the number of minutes the post will take to read. */
51
49
  (0, _i18n._n)('<span>%d</span> minute', '<span>%d</span> minutes', minutesToRead), minutesToRead), {
52
- span: (0, _element.createElement)("span", {
53
- className: "table-of-contents__number"
54
- })
50
+ span: (0, _element.createElement)("span", null)
55
51
  });
56
52
  return (0, _element.createElement)("span", {
57
53
  className: "time-to-read"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/time-to-read/index.js"],"names":["AVERAGE_READING_RATE","TimeToRead","content","select","editorStore","getEditedPostAttribute","wordCountType","minutesToRead","Math","round","minutesToReadString","span"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,GAAG,GAA7B;;AAEe,SAASC,UAAT,GAAsB;AACpC,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,SAA9C,CADC,EAEf,EAFe,CAAhB;AAKA;AACD;AACA;AACA;AACA;;AACC,QAAMC,aAAa,GAAG,cAAI,OAAJ,EAAa,oCAAb,CAAtB;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,KAAL,CACrB,sBAAWP,OAAX,EAAoBI,aAApB,IAAsCN,oBADjB,CAAtB;AAGA,QAAMU,mBAAmB,GACxBH,aAAa,KAAK,CAAlB,GACG,uCAA0B,cAAI,yBAAJ,CAA1B,EAA2D;AAC3DI,IAAAA,IAAI,EAAE;AAAM,MAAA,SAAS,EAAC;AAAhB;AADqD,GAA3D,CADH,GAIG,uCACA;AACC;AACA,gBACC,wBADD,EAEC,yBAFD,EAGCJ,aAHD,CAFD,EAOCA,aAPD,CADA,EAUA;AACCI,IAAAA,IAAI,EAAE;AAAM,MAAA,SAAS,EAAC;AAAhB;AADP,GAVA,CALJ;AAoBA,SAAO;AAAM,IAAA,SAAS,EAAC;AAAhB,KAAiCD,mBAAjC,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { _x, _n, __, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Average reading rate - based on average taken from\n * https://irisreading.com/average-reading-speed-in-various-languages/\n * (Characters/minute used for Chinese rather than words).\n *\n * @type {number} A rough estimate of the average reading rate across multiple languages.\n */\nconst AVERAGE_READING_RATE = 189;\n\nexport default function TimeToRead() {\n\tconst content = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),\n\t\t[]\n\t);\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\tconst minutesToRead = Math.round(\n\t\twordCount( content, wordCountType ) / AVERAGE_READING_RATE\n\t);\n\tconst minutesToReadString =\n\t\tminutesToRead === 0\n\t\t\t? createInterpolateElement( __( '<span>< 1</span> minute' ), {\n\t\t\t\t\tspan: <span className=\"table-of-contents__number\" />,\n\t\t\t } )\n\t\t\t: createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s is the number of minutes the post will take to read. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'<span>%d</span> minute',\n\t\t\t\t\t\t\t'<span>%d</span> minutes',\n\t\t\t\t\t\t\tminutesToRead\n\t\t\t\t\t\t),\n\t\t\t\t\t\tminutesToRead\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tspan: <span className=\"table-of-contents__number\" />,\n\t\t\t\t\t}\n\t\t\t );\n\n\treturn <span className=\"time-to-read\">{ minutesToReadString }</span>;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/time-to-read/index.js"],"names":["AVERAGE_READING_RATE","TimeToRead","content","select","editorStore","getEditedPostAttribute","wordCountType","minutesToRead","Math","round","minutesToReadString","span"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,GAAG,GAA7B;;AAEe,SAASC,UAAT,GAAsB;AACpC,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,SAA9C,CADC,EAEf,EAFe,CAAhB;AAKA;AACD;AACA;AACA;AACA;;AACC,QAAMC,aAAa,GAAG,cAAI,OAAJ,EAAa,oCAAb,CAAtB;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,KAAL,CACrB,sBAAWP,OAAX,EAAoBI,aAApB,IAAsCN,oBADjB,CAAtB;AAGA,QAAMU,mBAAmB,GACxBH,aAAa,KAAK,CAAlB,GACG,uCAA0B,cAAI,yBAAJ,CAA1B,EAA2D;AAC3DI,IAAAA,IAAI,EAAE;AADqD,GAA3D,CADH,GAIG,uCACA;AACC;AACA,gBACC,wBADD,EAEC,yBAFD,EAGCJ,aAHD,CAFD,EAOCA,aAPD,CADA,EAUA;AACCI,IAAAA,IAAI,EAAE;AADP,GAVA,CALJ;AAoBA,SAAO;AAAM,IAAA,SAAS,EAAC;AAAhB,KAAiCD,mBAAjC,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { _x, _n, __, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Average reading rate - based on average taken from\n * https://irisreading.com/average-reading-speed-in-various-languages/\n * (Characters/minute used for Chinese rather than words).\n *\n * @type {number} A rough estimate of the average reading rate across multiple languages.\n */\nconst AVERAGE_READING_RATE = 189;\n\nexport default function TimeToRead() {\n\tconst content = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),\n\t\t[]\n\t);\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\tconst minutesToRead = Math.round(\n\t\twordCount( content, wordCountType ) / AVERAGE_READING_RATE\n\t);\n\tconst minutesToReadString =\n\t\tminutesToRead === 0\n\t\t\t? createInterpolateElement( __( '<span>< 1</span> minute' ), {\n\t\t\t\t\tspan: <span />,\n\t\t\t } )\n\t\t\t: createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s is the number of minutes the post will take to read. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'<span>%d</span> minute',\n\t\t\t\t\t\t\t'<span>%d</span> minutes',\n\t\t\t\t\t\t\tminutesToRead\n\t\t\t\t\t\t),\n\t\t\t\t\t\tminutesToRead\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t}\n\t\t\t );\n\n\treturn <span className=\"time-to-read\">{ minutesToReadString }</span>;\n}\n"]}
@@ -175,12 +175,7 @@ function isEditedPostNew(state) {
175
175
 
176
176
  function hasChangedContent(state) {
177
177
  const edits = getPostEdits(state);
178
- return 'blocks' in edits || // `edits` is intended to contain only values which are different from
179
- // the saved post, so the mere presence of a property is an indicator
180
- // that the value is different than what is known to be saved. While
181
- // content in Visual mode is represented by the blocks state, in Text
182
- // mode it is tracked by `edits.content`.
183
- 'content' in edits;
178
+ return 'content' in edits;
184
179
  }
185
180
  /**
186
181
  * Returns true if there are unsaved values for the current edit session, or