@wordpress/block-editor 14.14.0 → 14.14.2
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/build/components/block-popover/use-popover-scroll.js +2 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -0
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/link-control/search-input.js +2 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +21 -14
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/block-popover/use-popover-scroll.js +2 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +4 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/link-control/search-input.js +2 -3
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +21 -14
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/package.json +34 -34
- package/src/components/block-popover/use-popover-scroll.js +2 -1
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -0
- package/src/components/link-control/search-input.js +2 -4
- package/src/components/link-control/test/index.js +46 -46
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/writing-flow/use-tab-nav.js +22 -17
|
@@ -20,7 +20,7 @@ const scrollContainerCache = new WeakMap();
|
|
|
20
20
|
* @param {Object} contentRef
|
|
21
21
|
*/
|
|
22
22
|
function usePopoverScroll(contentRef) {
|
|
23
|
-
|
|
23
|
+
const effect = (0, _compose.useRefEffect)(node => {
|
|
24
24
|
function onWheel(event) {
|
|
25
25
|
const {
|
|
26
26
|
deltaX,
|
|
@@ -44,6 +44,7 @@ function usePopoverScroll(contentRef) {
|
|
|
44
44
|
node.removeEventListener('wheel', onWheel, options);
|
|
45
45
|
};
|
|
46
46
|
}, [contentRef]);
|
|
47
|
+
return contentRef ? effect : null;
|
|
47
48
|
}
|
|
48
49
|
var _default = exports.default = usePopoverScroll;
|
|
49
50
|
//# sourceMappingURL=use-popover-scroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_dom","scrollContainerCache","WeakMap","usePopoverScroll","contentRef","useRefEffect","node","onWheel","event","deltaX","deltaY","contentEl","current","scrollContainer","get","getScrollContainer","set","scrollBy","options","passive","addEventListener","removeEventListener","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/block-popover/use-popover-scroll.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\nconst scrollContainerCache = new WeakMap();\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} contentRef\n */\nfunction usePopoverScroll( contentRef ) {\n\
|
|
1
|
+
{"version":3,"names":["_compose","require","_dom","scrollContainerCache","WeakMap","usePopoverScroll","contentRef","effect","useRefEffect","node","onWheel","event","deltaX","deltaY","contentEl","current","scrollContainer","get","getScrollContainer","set","scrollBy","options","passive","addEventListener","removeEventListener","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/block-popover/use-popover-scroll.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\nconst scrollContainerCache = new WeakMap();\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} contentRef\n */\nfunction usePopoverScroll( contentRef ) {\n\tconst effect = useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onWheel( event ) {\n\t\t\t\tconst { deltaX, deltaY } = event;\n\t\t\t\tconst contentEl = contentRef.current;\n\t\t\t\tlet scrollContainer = scrollContainerCache.get( contentEl );\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\tscrollContainer = getScrollContainer( contentEl );\n\t\t\t\t\tscrollContainerCache.set( contentEl, scrollContainer );\n\t\t\t\t}\n\t\t\t\tscrollContainer.scrollBy( deltaX, deltaY );\n\t\t\t}\n\t\t\t// Tell the browser that we do not call event.preventDefault\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners\n\t\t\tconst options = { passive: true };\n\t\t\tnode.addEventListener( 'wheel', onWheel, options );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'wheel', onWheel, options );\n\t\t\t};\n\t\t},\n\t\t[ contentRef ]\n\t);\n\treturn contentRef ? effect : null;\n}\n\nexport default usePopoverScroll;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,MAAME,oBAAoB,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAEC,UAAU,EAAG;EACvC,MAAMC,MAAM,GAAG,IAAAC,qBAAY,EACxBC,IAAI,IAAM;IACX,SAASC,OAAOA,CAAEC,KAAK,EAAG;MACzB,MAAM;QAAEC,MAAM;QAAEC;MAAO,CAAC,GAAGF,KAAK;MAChC,MAAMG,SAAS,GAAGR,UAAU,CAACS,OAAO;MACpC,IAAIC,eAAe,GAAGb,oBAAoB,CAACc,GAAG,CAAEH,SAAU,CAAC;MAC3D,IAAK,CAAEE,eAAe,EAAG;QACxBA,eAAe,GAAG,IAAAE,uBAAkB,EAAEJ,SAAU,CAAC;QACjDX,oBAAoB,CAACgB,GAAG,CAAEL,SAAS,EAAEE,eAAgB,CAAC;MACvD;MACAA,eAAe,CAACI,QAAQ,CAAER,MAAM,EAAEC,MAAO,CAAC;IAC3C;IACA;IACA;IACA,MAAMQ,OAAO,GAAG;MAAEC,OAAO,EAAE;IAAK,CAAC;IACjCb,IAAI,CAACc,gBAAgB,CAAE,OAAO,EAAEb,OAAO,EAAEW,OAAQ,CAAC;IAClD,OAAO,MAAM;MACZZ,IAAI,CAACe,mBAAmB,CAAE,OAAO,EAAEd,OAAO,EAAEW,OAAQ,CAAC;IACtD,CAAC;EACF,CAAC,EACD,CAAEf,UAAU,CACb,CAAC;EACD,OAAOA,UAAU,GAAGC,MAAM,GAAG,IAAI;AAClC;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEctB,gBAAgB","ignoreList":[]}
|
|
@@ -65,6 +65,9 @@ function PatternList({
|
|
|
65
65
|
if (selectedCategory === _utils.myPatternsCategory.name && pattern.type === _utils.INSERTER_PATTERN_TYPES.user) {
|
|
66
66
|
return true;
|
|
67
67
|
}
|
|
68
|
+
if (selectedCategory === _utils.starterPatternsCategory.name && pattern.blockTypes?.includes('core/post-content')) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
68
71
|
if (selectedCategory === 'uncategorized') {
|
|
69
72
|
var _pattern$categories$s;
|
|
70
73
|
const hasKnownCategory = (_pattern$categories$s = pattern.categories?.some(category => registeredPatternCategories.includes(category))) !== null && _pattern$categories$s !== void 0 ? _pattern$categories$s : false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","_jsxRuntime","PatternsListHeader","filterValue","filteredBlockPatternsLength","jsx","__experimentalHeading","level","lineHeight","className","children","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","onModalClose","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","type","INSERTER_PATTERN_TYPES","user","_pattern$categories$s","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","jsxs","ref","default","Fragment","blockPatterns","categoryPatterns","blocks","isDraggable","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight=\"48px\"\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( {\n\tsearchValue,\n\tselectedCategory,\n\tpatternCategories,\n\trootClientId,\n\tonModalClose,\n} ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\trootClientId,\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tselectedCategory\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory =\n\t\t\t\t\tpattern.categories?.some( ( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t\t) ?? false;\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\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.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\t\t\t\tonClickPattern( pattern, blocks );\n\t\t\t\t\t\t\t\tonModalClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GA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,gBAAkB;UAC9CvC,cAAc,EAAGA,CAAEU,OAAO,EAAE8B,MAAM,KAAM;YACvCxC,cAAc,CAAEU,OAAO,EAAE8B,MAAO,CAAC;YACjCnD,YAAY,CAAC,CAAC;UACf,CAAG;UACHoD,WAAW,EAAG;QAAO,CACrB,CAAC,eACF,IAAArE,WAAA,CAAAI,GAAA,EAACP,oBAAA,CAAAmE,OAAmB;UAAA,GAAMT;QAAW,CAAI,CAAC;MAAA,CACzC;IACF,CACe,CAAC;EAAA,CACd,CAAC;AAER;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAP,OAAA,GAEcpD,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","_jsxRuntime","PatternsListHeader","filterValue","filteredBlockPatternsLength","jsx","__experimentalHeading","level","lineHeight","className","children","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","onModalClose","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","type","INSERTER_PATTERN_TYPES","user","starterPatternsCategory","blockTypes","includes","_pattern$categories$s","hasKnownCategory","categories","some","category","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","jsxs","ref","default","Fragment","blockPatterns","categoryPatterns","blocks","isDraggable","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tstarterPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight=\"48px\"\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( {\n\tsearchValue,\n\tselectedCategory,\n\tpatternCategories,\n\trootClientId,\n\tonModalClose,\n} ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\trootClientId,\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tselectedCategory\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === starterPatternsCategory.name &&\n\t\t\t\tpattern.blockTypes?.includes( 'core/post-content' )\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory =\n\t\t\t\t\tpattern.categories?.some( ( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t\t) ?? false;\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\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.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\t\t\t\tonClickPattern( pattern, blocks );\n\t\t\t\t\t\t\t\tonModalClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,kBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,iBAAA,GAAAF,sBAAA,CAAAN,OAAA;AACA,IAAAS,gBAAA,GAAAH,sBAAA,CAAAN,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAL,sBAA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,YAAY,CAAC,CAAC;UACf,CAAG;UACHsD,WAAW,EAAG;QAAO,CACrB,CAAC,eACF,IAAAvE,WAAA,CAAAI,GAAA,EAACP,oBAAA,CAAAqE,OAAmB;UAAA,GAAMT;QAAW,CAAI,CAAC;MAAA,CACzC;IACF,CACe,CAAC;EAAA,CACd,CAAC;AAER;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAP,OAAA,GAEctD,WAAW","ignoreList":[]}
|
|
@@ -102,17 +102,16 @@ const LinkControlSearchInput = (0, _element.forwardRef)(({
|
|
|
102
102
|
}, suggestion);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
const inputLabel = placeholder !== null && placeholder !== void 0 ? placeholder : (0, _i18n.__)('Search or type URL');
|
|
106
105
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
107
106
|
className: "block-editor-link-control__search-input-container",
|
|
108
107
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.URLInput, {
|
|
109
108
|
disableSuggestions: currentLink?.url === value,
|
|
110
|
-
label:
|
|
109
|
+
label: (0, _i18n.__)('Link'),
|
|
111
110
|
hideLabelFromVision: hideLabelFromVision,
|
|
112
111
|
className: className,
|
|
113
112
|
value: value,
|
|
114
113
|
onChange: onInputChange,
|
|
115
|
-
placeholder:
|
|
114
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : (0, _i18n.__)('Search or type URL'),
|
|
116
115
|
__experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
|
|
117
116
|
__experimentalFetchLinkSuggestions: searchHandler,
|
|
118
117
|
__experimentalHandleURLSuggestions: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_","_searchResults","_interopRequireDefault","_constants","_useSearchHandler","_deprecated","_jsxRuntime","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","forwardRef","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","jsx","default","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","suffix","ref","genericSearchHandler","useSearchHandler","searchHandler","focusedSuggestion","setFocusedSuggestion","useState","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","CREATE_TYPE","type","title","url","e","Object","keys","length","id","restLinkProps","inputLabel","__","jsxs","URLInput","disableSuggestions","label","__experimentalRenderSuggestions","__experimentalFetchLinkSuggestions","__experimentalHandleURLSuggestions","__experimentalShowInitialSuggestions","onSubmit","event","hasSuggestion","trim","preventDefault","_default","exports","__experimentalLinkControlSearchInput","deprecated","since"],"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\nimport deprecated from '@wordpress/deprecated';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t\tsuffix,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst inputLabel = placeholder ?? __( 'Search or type URL' );\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\tlabel={ inputLabel }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ inputLabel }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\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\tref={ ref }\n\t\t\t\t\tsuffix={ suffix }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n\nexport const __experimentalLinkControlSearchInput = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', {\n\t\tsince: '6.8',\n\t} );\n\n\treturn <LinkControlSearchInput { ...props } />;\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,CAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,WAAA,GAAAH,sBAAA,CAAAJ,OAAA;AAA+C,IAAAQ,WAAA,GAAAR,OAAA;AAb/C;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AACA,MAAMS,iBAAiB,GAAGA,CAAA,KAAMC,OAAO,CAACC,OAAO,CAAE,EAAG,CAAC;AAErD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,MAAMC,sBAAsB,GAAG,IAAAC,mBAAU,EACxC,CACC;EACCC,KAAK;EACLC,QAAQ;EACRC,WAAW,GAAG,CAAC,CAAC;EAChBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,IAAI;EAClBC,oBAAoB,GAAG,KAAK;EAC5BC,kBAAkB,GAAGT,IAAI;EACzBU,QAAQ,GAAGV,IAAI;EACfW,QAAQ,GAAGX,IAAI;EACfY,eAAe,GAAG,IAAI;EACtBC,iBAAiB,GAAKC,KAAK,iBAC1B,IAAAlB,WAAA,CAAAmB,GAAA,EAACxB,cAAA,CAAAyB,OAAw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,IAAK,CAAEgC,aAAa,IAAI,CAAE1D,KAAK,EAAE2D,IAAI,CAAC,CAAC,EAAEhB,MAAM,EAAG;UACjDc,KAAK,CAACG,cAAc,CAAC,CAAC;QACvB,CAAC,MAAM;UACN1B,oBAAoB,CACnBwB,aAAa,IAAI;YAAEnB,GAAG,EAAEvC;UAAM,CAC/B,CAAC;QACF;MACD,CAAG;MACHsB,GAAG,EAAGA,GAAK;MACXD,MAAM,EAAGA;IAAQ,CACjB,CAAC,EACApB,QAAQ;EAAA,CACN,CAAC;AAER,CACD,CAAC;AAAC,IAAA4D,QAAA,GAAAC,OAAA,CAAAjD,OAAA,GAEaf,sBAAsB;AAE9B,MAAMiE,oCAAoC,GAAKpD,KAAK,IAAM;EAChE,IAAAqD,mBAAU,EAAE,qDAAqD,EAAE;IAClEC,KAAK,EAAE;EACR,CAAE,CAAC;EAEH,oBAAO,IAAAxE,WAAA,CAAAmB,GAAA,EAACd,sBAAsB;IAAA,GAAMa;EAAK,CAAI,CAAC;AAC/C,CAAC;AAACmD,OAAA,CAAAC,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_","_searchResults","_interopRequireDefault","_constants","_useSearchHandler","_deprecated","_jsxRuntime","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","forwardRef","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","jsx","default","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","suffix","ref","genericSearchHandler","useSearchHandler","searchHandler","focusedSuggestion","setFocusedSuggestion","useState","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","CREATE_TYPE","type","title","url","e","Object","keys","length","id","restLinkProps","jsxs","URLInput","disableSuggestions","label","__","__experimentalRenderSuggestions","__experimentalFetchLinkSuggestions","__experimentalHandleURLSuggestions","__experimentalShowInitialSuggestions","onSubmit","event","hasSuggestion","trim","preventDefault","_default","exports","__experimentalLinkControlSearchInput","deprecated","since"],"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\nimport deprecated from '@wordpress/deprecated';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t\tsuffix,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type URL' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\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\tref={ ref }\n\t\t\t\t\tsuffix={ suffix }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n\nexport const __experimentalLinkControlSearchInput = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', {\n\t\tsince: '6.8',\n\t} );\n\n\treturn <LinkControlSearchInput { ...props } />;\n};\n"],"mappings":";;;;;;;AAGA,IAA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D,OAAA,GAEaf,sBAAsB;AAE9B,MAAMgE,oCAAoC,GAAKnD,KAAK,IAAM;EAChE,IAAAoD,mBAAU,EAAE,qDAAqD,EAAE;IAClEC,KAAK,EAAE;EACR,CAAE,CAAC;EAEH,oBAAO,IAAAvE,WAAA,CAAAmB,GAAA,EAACd,sBAAsB;IAAA,GAAMa;EAAK,CAAI,CAAC;AAC/C,CAAC;AAACkD,OAAA,CAAAC,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
@@ -22,7 +22,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
function useTabNav() {
|
|
25
|
-
const
|
|
25
|
+
const containerRef = /** @type {typeof useRef<HTMLElement>} */(0, _element.useRef)();
|
|
26
26
|
const focusCaptureBeforeRef = (0, _element.useRef)();
|
|
27
27
|
const focusCaptureAfterRef = (0, _element.useRef)();
|
|
28
28
|
const {
|
|
@@ -42,19 +42,19 @@ function useTabNav() {
|
|
|
42
42
|
// capturing on the focus capture elements.
|
|
43
43
|
const noCaptureRef = (0, _element.useRef)();
|
|
44
44
|
function onFocusCapture(event) {
|
|
45
|
-
const canvasElement =
|
|
45
|
+
const canvasElement = containerRef.current.ownerDocument === event.target.ownerDocument ? containerRef.current : containerRef.current.ownerDocument.defaultView.frameElement;
|
|
46
46
|
|
|
47
47
|
// Do not capture incoming focus if set by us in WritingFlow.
|
|
48
48
|
if (noCaptureRef.current) {
|
|
49
49
|
noCaptureRef.current = null;
|
|
50
50
|
} else if (hasMultiSelection()) {
|
|
51
|
-
|
|
51
|
+
containerRef.current.focus();
|
|
52
52
|
} else if (getSelectedBlockClientId()) {
|
|
53
53
|
if (getLastFocus()?.current) {
|
|
54
54
|
getLastFocus().current.focus();
|
|
55
55
|
} else {
|
|
56
56
|
// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.
|
|
57
|
-
|
|
57
|
+
containerRef.current.querySelector(`[data-block="${getSelectedBlockClientId()}"]`).focus();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
// In "compose" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.
|
|
@@ -64,11 +64,11 @@ function useTabNav() {
|
|
|
64
64
|
|
|
65
65
|
// If we have section within the section root, focus the first one.
|
|
66
66
|
if (sectionBlocks.length) {
|
|
67
|
-
|
|
67
|
+
containerRef.current.querySelector(`[data-block="${sectionBlocks[0]}"]`).focus();
|
|
68
68
|
}
|
|
69
69
|
// If we don't have any section blocks, focus the section root.
|
|
70
70
|
else if (sectionRootClientId) {
|
|
71
|
-
|
|
71
|
+
containerRef.current.querySelector(`[data-block="${sectionRootClientId}"]`).focus();
|
|
72
72
|
} else {
|
|
73
73
|
// If we don't have any section root, focus the canvas.
|
|
74
74
|
canvasElement.focus();
|
|
@@ -77,7 +77,7 @@ function useTabNav() {
|
|
|
77
77
|
const isBefore =
|
|
78
78
|
// eslint-disable-next-line no-bitwise
|
|
79
79
|
event.target.compareDocumentPosition(canvasElement) & event.target.DOCUMENT_POSITION_FOLLOWING;
|
|
80
|
-
const tabbables = _dom.focus.tabbable.find(
|
|
80
|
+
const tabbables = _dom.focus.tabbable.find(containerRef.current);
|
|
81
81
|
if (tabbables.length) {
|
|
82
82
|
const next = isBefore ? tabbables[0] : tabbables[tabbables.length - 1];
|
|
83
83
|
next.focus();
|
|
@@ -109,19 +109,26 @@ function useTabNav() {
|
|
|
109
109
|
if (event.keyCode !== _keycodes.TAB) {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
|
-
if (
|
|
112
|
+
if (
|
|
113
|
+
// Bails in case the focus capture elements aren’t present. They
|
|
114
|
+
// may be omitted to avoid silent tab stops in preview mode.
|
|
115
|
+
// See: https://github.com/WordPress/gutenberg/pull/59317
|
|
116
|
+
!focusCaptureAfterRef.current || !focusCaptureBeforeRef.current) {
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
|
-
const
|
|
119
|
+
const {
|
|
120
|
+
target,
|
|
121
|
+
shiftKey: isShift
|
|
122
|
+
} = event;
|
|
116
123
|
const direction = isShift ? 'findPrevious' : 'findNext';
|
|
117
|
-
const nextTabbable = _dom.focus.tabbable[direction](
|
|
124
|
+
const nextTabbable = _dom.focus.tabbable[direction](target);
|
|
118
125
|
|
|
119
126
|
// We want to constrain the tabbing to the block and its child blocks.
|
|
120
127
|
// If the preceding form element is within a different block,
|
|
121
128
|
// such as two sibling image blocks in the placeholder state,
|
|
122
129
|
// we want shift + tab from the first form element to move to the image
|
|
123
130
|
// block toolbar and not the previous image block's form element.
|
|
124
|
-
const currentBlock =
|
|
131
|
+
const currentBlock = target.closest('[data-block]');
|
|
125
132
|
const isElementPartOfSelectedBlock = currentBlock && nextTabbable && ((0, _dom2.isInSameBlock)(currentBlock, nextTabbable) || (0, _dom2.isInsideRootBlock)(currentBlock, nextTabbable));
|
|
126
133
|
|
|
127
134
|
// Allow tabbing from the block wrapper to a form element,
|
|
@@ -158,7 +165,7 @@ function useTabNav() {
|
|
|
158
165
|
|
|
159
166
|
// If focus disappears due to there being no blocks, move focus to
|
|
160
167
|
// the writing flow wrapper.
|
|
161
|
-
if (!event.relatedTarget && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
|
|
168
|
+
if (!event.relatedTarget && event.target.hasAttribute('data-block') && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
|
|
162
169
|
node.focus();
|
|
163
170
|
}
|
|
164
171
|
}
|
|
@@ -178,7 +185,7 @@ function useTabNav() {
|
|
|
178
185
|
if (event.target?.getAttribute('role') === 'region') {
|
|
179
186
|
return;
|
|
180
187
|
}
|
|
181
|
-
if (
|
|
188
|
+
if (containerRef.current === event.target) {
|
|
182
189
|
return;
|
|
183
190
|
}
|
|
184
191
|
const isShift = event.shiftKey;
|
|
@@ -207,7 +214,7 @@ function useTabNav() {
|
|
|
207
214
|
node.removeEventListener('focusout', onFocusOut);
|
|
208
215
|
};
|
|
209
216
|
}, []);
|
|
210
|
-
const mergedRefs = (0, _compose.useMergeRefs)([
|
|
217
|
+
const mergedRefs = (0, _compose.useMergeRefs)([containerRef, ref]);
|
|
211
218
|
return [before, mergedRefs, after];
|
|
212
219
|
}
|
|
213
220
|
//# sourceMappingURL=use-tab-nav.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dom","require","_keycodes","_data","_compose","_element","_store","_dom2","_lockUnlock","_jsxRuntime","useTabNav","container","useRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","getBlockOrder","getLastFocus","getSectionRootClientId","isZoomOut","unlock","useSelect","blockEditorStore","setLastFocus","useDispatch","noCaptureRef","onFocusCapture","event","canvasElement","current","ownerDocument","target","defaultView","frameElement","focus","querySelector","sectionRootClientId","sectionBlocks","length","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","next","before","jsx","ref","tabIndex","onFocus","after","useRefEffect","node","onKeyDown","defaultPrevented","keyCode","TAB","isShift","shiftKey","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","isInSameBlock","isInsideRootBlock","isFormElement","preventScroll","onFocusOut","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","preventDefault","addEventListener","removeEventListener","mergedRefs","useMergeRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t\tgetBlockOrder,\n\t\tgetLastFocus,\n\t\tgetSectionRootClientId,\n\t\tisZoomOut,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { setLastFocus } = unlock( useDispatch( blockEditorStore ) );\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\tconst canvasElement =\n\t\t\tcontainer.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t? container.current\n\t\t\t\t: container.current.ownerDocument.defaultView.frameElement;\n\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t}\n\t\t// In \"compose\" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.\n\t\telse if ( isZoomOut() ) {\n\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\tconst sectionBlocks = getBlockOrder( sectionRootClientId );\n\n\t\t\t// If we have section within the section root, focus the first one.\n\t\t\tif ( sectionBlocks.length ) {\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionBlocks[ 0 ] }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t\t// If we don't have any section blocks, focus the section root.\n\t\t\telse if ( sectionRootClientId ) {\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionRootClientId }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t} else {\n\t\t\t\t// If we don't have any section root, focus the canvas.\n\t\t\t\tcanvasElement.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( container.current );\n\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n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MAAM,GAAGG,UAAK,CAACS,QAAQ,CAAEiB,SAAS,CAAE,CAAEjC,KAAK,CAACI,MAAO,CAAC;MAC1D;MACA,IACCA,MAAM,KAAKpB,qBAAqB,CAACkB,OAAO,IACxCE,MAAM,KAAKnB,oBAAoB,CAACiB,OAAO,EACtC;QACDF,KAAK,CAACgD,cAAc,CAAC,CAAC;QACtB5C,MAAM,CAACG,KAAK,CAAE;UAAEkC,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAEtC;IAAc,CAAC,GAAGuB,IAAI;IAC9B,MAAM;MAAErB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAAC4C,gBAAgB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;IAC7DpB,IAAI,CAACuB,gBAAgB,CAAE,SAAS,EAAEtB,SAAU,CAAC;IAC7CD,IAAI,CAACuB,gBAAgB,CAAE,UAAU,EAAEP,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZrC,WAAW,CAAC6C,mBAAmB,CAAE,SAAS,EAAEJ,kBAAmB,CAAC;MAChEpB,IAAI,CAACwB,mBAAmB,CAAE,SAAS,EAAEvB,SAAU,CAAC;MAChDD,IAAI,CAACwB,mBAAmB,CAAE,UAAU,EAAER,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMS,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEtE,SAAS,EAAEuC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAEF,MAAM,EAAEgC,UAAU,EAAE3B,KAAK,CAAE;AACrC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_dom","require","_keycodes","_data","_compose","_element","_store","_dom2","_lockUnlock","_jsxRuntime","useTabNav","containerRef","useRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","getBlockOrder","getLastFocus","getSectionRootClientId","isZoomOut","unlock","useSelect","blockEditorStore","setLastFocus","useDispatch","noCaptureRef","onFocusCapture","event","canvasElement","current","ownerDocument","target","defaultView","frameElement","focus","querySelector","sectionRootClientId","sectionBlocks","length","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","next","before","jsx","ref","tabIndex","onFocus","after","useRefEffect","node","onKeyDown","defaultPrevented","keyCode","TAB","shiftKey","isShift","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","isInSameBlock","isInsideRootBlock","isFormElement","preventScroll","onFocusOut","relatedTarget","hasAttribute","activeElement","body","preventScrollOnTab","getAttribute","preventDefault","addEventListener","removeEventListener","mergedRefs","useMergeRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t\tgetBlockOrder,\n\t\tgetLastFocus,\n\t\tgetSectionRootClientId,\n\t\tisZoomOut,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { setLastFocus } = unlock( useDispatch( blockEditorStore ) );\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\tconst canvasElement =\n\t\t\tcontainerRef.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t? containerRef.current\n\t\t\t\t: containerRef.current.ownerDocument.defaultView.frameElement;\n\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainerRef.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t}\n\t\t// In \"compose\" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.\n\t\telse if ( isZoomOut() ) {\n\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\tconst sectionBlocks = getBlockOrder( sectionRootClientId );\n\n\t\t\t// If we have section within the section root, focus the first one.\n\t\t\tif ( sectionBlocks.length ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionBlocks[ 0 ] }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t\t// If we don't have any section blocks, focus the section root.\n\t\t\telse if ( sectionRootClientId ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionRootClientId }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t} else {\n\t\t\t\t// If we don't have any section root, focus the canvas.\n\t\t\t\tcanvasElement.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( containerRef.current );\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t// Bails in case the focus capture elements aren’t present. They\n\t\t\t\t// may be omitted to avoid silent tab stops in preview mode.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/59317\n\t\t\t\t! focusCaptureAfterRef.current ||\n\t\t\t\t! focusCaptureBeforeRef.current\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { target, shiftKey: isShift } = event;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\tevent.target.hasAttribute( 'data-block' ) &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( containerRef.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ containerRef, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAA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,CAAEjC,KAAK,CAACI,MAAO,CAAC;MAC1D;MACA,IACCA,MAAM,KAAKpB,qBAAqB,CAACkB,OAAO,IACxCE,MAAM,KAAKnB,oBAAoB,CAACiB,OAAO,EACtC;QACDF,KAAK,CAACiD,cAAc,CAAC,CAAC;QACtB7C,MAAM,CAACG,KAAK,CAAE;UAAEkC,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAEtC;IAAc,CAAC,GAAGuB,IAAI;IAC9B,MAAM;MAAErB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAAC6C,gBAAgB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;IAC7DrB,IAAI,CAACwB,gBAAgB,CAAE,SAAS,EAAEvB,SAAU,CAAC;IAC7CD,IAAI,CAACwB,gBAAgB,CAAE,UAAU,EAAER,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZrC,WAAW,CAAC8C,mBAAmB,CAAE,SAAS,EAAEJ,kBAAmB,CAAC;MAChErB,IAAI,CAACyB,mBAAmB,CAAE,SAAS,EAAExB,SAAU,CAAC;MAChDD,IAAI,CAACyB,mBAAmB,CAAE,UAAU,EAAET,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMU,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEvE,YAAY,EAAEuC,GAAG,CAAG,CAAC;EAExD,OAAO,CAAEF,MAAM,EAAEiC,UAAU,EAAE5B,KAAK,CAAE;AACrC","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ const scrollContainerCache = new WeakMap();
|
|
|
13
13
|
* @param {Object} contentRef
|
|
14
14
|
*/
|
|
15
15
|
function usePopoverScroll(contentRef) {
|
|
16
|
-
|
|
16
|
+
const effect = useRefEffect(node => {
|
|
17
17
|
function onWheel(event) {
|
|
18
18
|
const {
|
|
19
19
|
deltaX,
|
|
@@ -37,6 +37,7 @@ function usePopoverScroll(contentRef) {
|
|
|
37
37
|
node.removeEventListener('wheel', onWheel, options);
|
|
38
38
|
};
|
|
39
39
|
}, [contentRef]);
|
|
40
|
+
return contentRef ? effect : null;
|
|
40
41
|
}
|
|
41
42
|
export default usePopoverScroll;
|
|
42
43
|
//# sourceMappingURL=use-popover-scroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRefEffect","getScrollContainer","scrollContainerCache","WeakMap","usePopoverScroll","contentRef","node","onWheel","event","deltaX","deltaY","contentEl","current","scrollContainer","get","set","scrollBy","options","passive","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-popover/use-popover-scroll.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\nconst scrollContainerCache = new WeakMap();\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} contentRef\n */\nfunction usePopoverScroll( contentRef ) {\n\
|
|
1
|
+
{"version":3,"names":["useRefEffect","getScrollContainer","scrollContainerCache","WeakMap","usePopoverScroll","contentRef","effect","node","onWheel","event","deltaX","deltaY","contentEl","current","scrollContainer","get","set","scrollBy","options","passive","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-popover/use-popover-scroll.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\nconst scrollContainerCache = new WeakMap();\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} contentRef\n */\nfunction usePopoverScroll( contentRef ) {\n\tconst effect = useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onWheel( event ) {\n\t\t\t\tconst { deltaX, deltaY } = event;\n\t\t\t\tconst contentEl = contentRef.current;\n\t\t\t\tlet scrollContainer = scrollContainerCache.get( contentEl );\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\tscrollContainer = getScrollContainer( contentEl );\n\t\t\t\t\tscrollContainerCache.set( contentEl, scrollContainer );\n\t\t\t\t}\n\t\t\t\tscrollContainer.scrollBy( deltaX, deltaY );\n\t\t\t}\n\t\t\t// Tell the browser that we do not call event.preventDefault\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners\n\t\t\tconst options = { passive: true };\n\t\t\tnode.addEventListener( 'wheel', onWheel, options );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'wheel', onWheel, options );\n\t\t\t};\n\t\t},\n\t\t[ contentRef ]\n\t);\n\treturn contentRef ? effect : null;\n}\n\nexport default usePopoverScroll;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,kBAAkB,QAAQ,gBAAgB;AAEnD,MAAMC,oBAAoB,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAEC,UAAU,EAAG;EACvC,MAAMC,MAAM,GAAGN,YAAY,CACxBO,IAAI,IAAM;IACX,SAASC,OAAOA,CAAEC,KAAK,EAAG;MACzB,MAAM;QAAEC,MAAM;QAAEC;MAAO,CAAC,GAAGF,KAAK;MAChC,MAAMG,SAAS,GAAGP,UAAU,CAACQ,OAAO;MACpC,IAAIC,eAAe,GAAGZ,oBAAoB,CAACa,GAAG,CAAEH,SAAU,CAAC;MAC3D,IAAK,CAAEE,eAAe,EAAG;QACxBA,eAAe,GAAGb,kBAAkB,CAAEW,SAAU,CAAC;QACjDV,oBAAoB,CAACc,GAAG,CAAEJ,SAAS,EAAEE,eAAgB,CAAC;MACvD;MACAA,eAAe,CAACG,QAAQ,CAAEP,MAAM,EAAEC,MAAO,CAAC;IAC3C;IACA;IACA;IACA,MAAMO,OAAO,GAAG;MAAEC,OAAO,EAAE;IAAK,CAAC;IACjCZ,IAAI,CAACa,gBAAgB,CAAE,OAAO,EAAEZ,OAAO,EAAEU,OAAQ,CAAC;IAClD,OAAO,MAAM;MACZX,IAAI,CAACc,mBAAmB,CAAE,OAAO,EAAEb,OAAO,EAAEU,OAAQ,CAAC;IACtD,CAAC;EACF,CAAC,EACD,CAAEb,UAAU,CACb,CAAC;EACD,OAAOA,UAAU,GAAGC,MAAM,GAAG,IAAI;AAClC;AAEA,eAAeF,gBAAgB","ignoreList":[]}
|
|
@@ -17,7 +17,7 @@ import InserterListbox from '../../inserter-listbox';
|
|
|
17
17
|
import { searchItems } from '../search-items';
|
|
18
18
|
import BlockPatternsPaging from '../../block-patterns-paging';
|
|
19
19
|
import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
20
|
-
import { INSERTER_PATTERN_TYPES, allPatternsCategory, myPatternsCategory } from '../block-patterns-tab/utils';
|
|
20
|
+
import { INSERTER_PATTERN_TYPES, allPatternsCategory, myPatternsCategory, starterPatternsCategory } from '../block-patterns-tab/utils';
|
|
21
21
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
22
|
function PatternsListHeader({
|
|
23
23
|
filterValue,
|
|
@@ -57,6 +57,9 @@ function PatternList({
|
|
|
57
57
|
if (selectedCategory === myPatternsCategory.name && pattern.type === INSERTER_PATTERN_TYPES.user) {
|
|
58
58
|
return true;
|
|
59
59
|
}
|
|
60
|
+
if (selectedCategory === starterPatternsCategory.name && pattern.blockTypes?.includes('core/post-content')) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
60
63
|
if (selectedCategory === 'uncategorized') {
|
|
61
64
|
var _pattern$categories$s;
|
|
62
65
|
const hasKnownCategory = (_pattern$categories$s = pattern.categories?.some(category => registeredPatternCategories.includes(category))) !== null && _pattern$categories$s !== void 0 ? _pattern$categories$s : false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useEffect","useRef","useState","_n","sprintf","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","INSERTER_PATTERN_TYPES","allPatternsCategory","myPatternsCategory","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternsListHeader","filterValue","filteredBlockPatternsLength","level","lineHeight","className","children","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","onModalClose","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","_pattern$categories$s","hasKnownCategory","categories","some","category","
|
|
1
|
+
{"version":3,"names":["useMemo","useEffect","useRef","useState","_n","sprintf","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","INSERTER_PATTERN_TYPES","allPatternsCategory","myPatternsCategory","starterPatternsCategory","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternsListHeader","filterValue","filteredBlockPatternsLength","level","lineHeight","className","children","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","onModalClose","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","blockTypes","includes","_pattern$categories$s","hasKnownCategory","categories","some","category","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","blockPatterns","categoryPatterns","blocks","isDraggable"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tstarterPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight=\"48px\"\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( {\n\tsearchValue,\n\tselectedCategory,\n\tpatternCategories,\n\trootClientId,\n\tonModalClose,\n} ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\trootClientId,\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tselectedCategory\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === starterPatternsCategory.name &&\n\t\t\t\tpattern.blockTypes?.includes( 'core/post-content' )\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory =\n\t\t\t\t\tpattern.categories?.some( ( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t\t) ?? false;\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\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.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\t\t\t\tonClickPattern( pattern, blocks );\n\t\t\t\t\t\t\t\tonModalClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AACzE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,qBAAqB,IAAIC,OAAO,QAAQ,uBAAuB;AACxE,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,OAAOC,iBAAiB,MAAM,8BAA8B;AAC5D,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,eAAe,MAAM,wBAAwB;AACpD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,mBA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","ignoreList":[]}
|
|
@@ -95,17 +95,16 @@ const LinkControlSearchInput = forwardRef(({
|
|
|
95
95
|
}, suggestion);
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
const inputLabel = placeholder !== null && placeholder !== void 0 ? placeholder : __('Search or type URL');
|
|
99
98
|
return /*#__PURE__*/_jsxs("div", {
|
|
100
99
|
className: "block-editor-link-control__search-input-container",
|
|
101
100
|
children: [/*#__PURE__*/_jsx(URLInput, {
|
|
102
101
|
disableSuggestions: currentLink?.url === value,
|
|
103
|
-
label:
|
|
102
|
+
label: __('Link'),
|
|
104
103
|
hideLabelFromVision: hideLabelFromVision,
|
|
105
104
|
className: className,
|
|
106
105
|
value: value,
|
|
107
106
|
onChange: onInputChange,
|
|
108
|
-
placeholder:
|
|
107
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : __('Search or type URL'),
|
|
109
108
|
__experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
|
|
110
109
|
__experimentalFetchLinkSuggestions: searchHandler,
|
|
111
110
|
__experimentalHandleURLSuggestions: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","deprecated","jsx","_jsx","jsxs","_jsxs","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","suffix","ref","genericSearchHandler","searchHandler","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","
|
|
1
|
+
{"version":3,"names":["forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","deprecated","jsx","_jsx","jsxs","_jsxs","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","suffix","ref","genericSearchHandler","searchHandler","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","disableSuggestions","label","__experimentalRenderSuggestions","__experimentalFetchLinkSuggestions","__experimentalHandleURLSuggestions","__experimentalShowInitialSuggestions","onSubmit","event","hasSuggestion","trim","preventDefault","__experimentalLinkControlSearchInput","since"],"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\nimport deprecated from '@wordpress/deprecated';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t\tsuffix,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type URL' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\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\tref={ ref }\n\t\t\t\t\tsuffix={ suffix }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n\nexport const __experimentalLinkControlSearchInput = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', {\n\t\tsince: '6.8',\n\t} );\n\n\treturn <LinkControlSearchInput { ...props } />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,KAAK;AAC9B,OAAOC,wBAAwB,MAAM,kBAAkB;AACvD,SAASC,WAAW,QAAQ,aAAa;AACzC,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AACA,MAAMC,iBAAiB,GAAGA,CAAA,KAAMC,OAAO,CAACC,OAAO,CAAE,EAAG,CAAC;AAErD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,MAAMC,sBAAsB,GAAGhB,UAAU,CACxC,CACC;EACCiB,KAAK;EACLC,QAAQ;EACRC,WAAW,GAAG,CAAC,CAAC;EAChBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,IAAI;EAClBC,oBAAoB,GAAG,KAAK;EAC5BC,kBAAkB,GAAGR,IAAI;EACzBS,QAAQ,GAAGT,IAAI;EACfU,QAAQ,GAAGV,IAAI;EACfW,eAAe,GAAG,IAAI;EACtBC,iBAAiB,GAAKC,KAAK,iBAC1BnB,IAAA,CAACL,wBAAwB;IAAA,G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