@wordpress/block-editor 12.19.7 → 12.19.8
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/inserter/block-patterns-explorer/index.js +2 -1
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/recursion-provider/index.js +2 -2
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +50 -36
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +2 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +2 -2
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +50 -36
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/package.json +5 -5
- package/src/components/inserter/block-patterns-explorer/index.js +1 -0
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/recursion-provider/index.js +2 -2
- package/src/components/url-popover/image-url-input-ui.js +68 -51
|
@@ -42,7 +42,8 @@ function PatternsExplorer({
|
|
|
42
42
|
searchValue: searchValue,
|
|
43
43
|
selectedCategory: selectedCategory,
|
|
44
44
|
patternCategories: patternCategories,
|
|
45
|
-
patternSourceFilter: patternSourceFilter
|
|
45
|
+
patternSourceFilter: patternSourceFilter,
|
|
46
|
+
rootClientId: rootClientId
|
|
46
47
|
}));
|
|
47
48
|
}
|
|
48
49
|
function PatternsExplorerModal({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","_patternExplorerSidebar","_interopRequireDefault","_patternList","_usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","useState","patternSourceFilter","setPatternSourceFilter","selectedCategory","setSelectedCategory","name","patternCategories","usePatternCategories","_react","createElement","className","default","onClickCategory","PatternsExplorerModal","onModalClose","restProps","Modal","title","__","onRequestClose","isFullScreen","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\tsetPatternSourceFilter={ setPatternSourceFilter }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,uBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA,SAASO,gBAAgBA,CAAE;EAAEC,eAAe;EAAEC;AAAa,CAAC,EAAG;EAC9D,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAG,IAAAC,iBAAQ,EAAE,EAAG,CAAC;EACtD,MAAM,CAAEC,mBAAmB,EAAEC,sBAAsB,CAAE,GAAG,IAAAF,iBAAQ,EAAE,KAAM,CAAC;EAEzE,MAAM,CAAEG,gBAAgB,EAAEC,mBAAmB,CAAE,GAAG,IAAAJ,iBAAQ,EACzDJ,eAAe,EAAES,IAClB,CAAC;EAED,MAAMC,iBAAiB,GAAG,IAAAC,0CAAoB,EAC7CV,YAAY,EACZI,mBACD,CAAC;EAED,OACC,IAAAO,MAAA,CAAAC,aAAA;IAAKC,SAAS,EAAC;EAAsC,GACpD,IAAAF,MAAA,CAAAC,aAAA,EAAClB,uBAAA,CAAAoB,OAAsB;IACtBR,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCM,eAAe,EAAGR,mBAAqB;IACvCN,WAAW,EAAGA,WAAa;IAC3BC,cAAc,EAAGA,cAAgB;IACjCE,mBAAmB,EAAGA,mBAAqB;IAC3CC,sBAAsB,EAAGA;EAAwB,CACjD,CAAC,EACF,IAAAM,MAAA,CAAAC,aAAA,EAAChB,YAAA,CAAAkB,OAAW;IACXb,WAAW,EAAGA,WAAa;IAC3BK,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCL,mBAAmB,EAAGA;
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","_patternExplorerSidebar","_interopRequireDefault","_patternList","_usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","useState","patternSourceFilter","setPatternSourceFilter","selectedCategory","setSelectedCategory","name","patternCategories","usePatternCategories","_react","createElement","className","default","onClickCategory","PatternsExplorerModal","onModalClose","restProps","Modal","title","__","onRequestClose","isFullScreen","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\tsetPatternSourceFilter={ setPatternSourceFilter }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,uBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA,SAASO,gBAAgBA,CAAE;EAAEC,eAAe;EAAEC;AAAa,CAAC,EAAG;EAC9D,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAG,IAAAC,iBAAQ,EAAE,EAAG,CAAC;EACtD,MAAM,CAAEC,mBAAmB,EAAEC,sBAAsB,CAAE,GAAG,IAAAF,iBAAQ,EAAE,KAAM,CAAC;EAEzE,MAAM,CAAEG,gBAAgB,EAAEC,mBAAmB,CAAE,GAAG,IAAAJ,iBAAQ,EACzDJ,eAAe,EAAES,IAClB,CAAC;EAED,MAAMC,iBAAiB,GAAG,IAAAC,0CAAoB,EAC7CV,YAAY,EACZI,mBACD,CAAC;EAED,OACC,IAAAO,MAAA,CAAAC,aAAA;IAAKC,SAAS,EAAC;EAAsC,GACpD,IAAAF,MAAA,CAAAC,aAAA,EAAClB,uBAAA,CAAAoB,OAAsB;IACtBR,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCM,eAAe,EAAGR,mBAAqB;IACvCN,WAAW,EAAGA,WAAa;IAC3BC,cAAc,EAAGA,cAAgB;IACjCE,mBAAmB,EAAGA,mBAAqB;IAC3CC,sBAAsB,EAAGA;EAAwB,CACjD,CAAC,EACF,IAAAM,MAAA,CAAAC,aAAA,EAAChB,YAAA,CAAAkB,OAAW;IACXb,WAAW,EAAGA,WAAa;IAC3BK,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCL,mBAAmB,EAAGA,mBAAqB;IAC3CJ,YAAY,EAAGA;EAAc,CAC7B,CACG,CAAC;AAER;AAEA,SAASgB,qBAAqBA,CAAE;EAAEC,YAAY;EAAE,GAAGC;AAAU,CAAC,EAAG;EAChE,OACC,IAAAP,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAA6B,KAAK;IACLC,KAAK,EAAG,IAAAC,QAAE,EAAE,UAAW,CAAG;IAC1BC,cAAc,EAAGL,YAAc;IAC/BM,YAAY;EAAA,GAEZ,IAAAZ,MAAA,CAAAC,aAAA,EAACd,gBAAgB;IAAA,GAAMoB;EAAS,CAAI,CAC9B,CAAC;AAEV;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEcE,qBAAqB"}
|
|
@@ -44,11 +44,13 @@ function PatternsListHeader({
|
|
|
44
44
|
function PatternList({
|
|
45
45
|
searchValue,
|
|
46
46
|
selectedCategory,
|
|
47
|
-
patternCategories
|
|
47
|
+
patternCategories,
|
|
48
|
+
rootClientId
|
|
48
49
|
}) {
|
|
49
50
|
const container = (0, _element.useRef)();
|
|
50
51
|
const debouncedSpeak = (0, _compose.useDebounce)(_a11y.speak, 500);
|
|
51
52
|
const [destinationRootClientId, onInsertBlocks] = (0, _useInsertionPoint.default)({
|
|
53
|
+
rootClientId,
|
|
52
54
|
shouldFocusBlock: true
|
|
53
55
|
});
|
|
54
56
|
const [patterns,, onClickPattern] = (0, _usePatternsState.default)(onInsertBlocks, destinationRootClientId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","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","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","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( {
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","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","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","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} ) {\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);\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 = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\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\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\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,sBAAA,CAAAN,OAAA;AACA,IAAAY,kBAAA,GAAAN,sBAAA,CAAAN,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AAnBA;AACA;AACA;;AAOA;AACA;AACA;;AAcA,SAASc,kBAAkBA,CAAE;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CAAE3C,WAAY,CAAC;IACrCwC,WAAW,CAACK,UAAU,CAAE,CAAE,CAAC;EAC5B;EAEA,MAAMC,QAAQ,GAAG,CAAC,CAAEzB,qBAAqB,EAAEc,MAAM;EACjD,OACC,IAAA5C,MAAA,CAAAC,aAAA;IACCI,SAAS,EAAC,4CAA4C;IACtDmD,GAAG,EAAG3C;EAAW,GAEjB,IAAAb,MAAA,CAAAC,aAAA,EAACJ,kBAAkB;IAClBC,WAAW,EAAGW,WAAa;IAC3BV,2BAA2B,EAAG+B,qBAAqB,CAACc;EAAQ,CAC5D,CAAC,EAEF,IAAA5C,MAAA,CAAAC,aAAA,EAACT,gBAAA,CAAAiE,OAAe,QACbF,QAAQ,IACT,IAAAvD,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAA0D,QAAA,QACC,IAAA1D,MAAA,CAAAC,aAAA,EAACb,kBAAA,CAAAqE,OAAiB;IACjBE,aAAa,EACZV,WAAW,CAACW,yBACZ;IACDC,aAAa,EAAGZ,WAAW,CAACa,gBAAkB;IAC9CvC,cAAc,EAAGA,cAAgB;IACjCwC,WAAW,EAAG;EAAO,CACrB,CAAC,EACF,IAAA/D,MAAA,CAAAC,aAAA,EAACP,oBAAA,CAAA+D,OAAmB;IAAA,GAAMR;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcjD,WAAW"}
|
|
@@ -100,12 +100,12 @@ const DeprecatedExperimentalRecursionProvider = props => {
|
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
102
|
exports.DeprecatedExperimentalRecursionProvider = DeprecatedExperimentalRecursionProvider;
|
|
103
|
-
const DeprecatedExperimentalUseHasRecursion =
|
|
103
|
+
const DeprecatedExperimentalUseHasRecursion = (...args) => {
|
|
104
104
|
(0, _deprecated.default)('wp.blockEditor.__experimentalUseHasRecursion', {
|
|
105
105
|
since: '6.5',
|
|
106
106
|
alternative: 'wp.blockEditor.useHasRecursion'
|
|
107
107
|
});
|
|
108
|
-
return useHasRecursion(...
|
|
108
|
+
return useHasRecursion(...args);
|
|
109
109
|
};
|
|
110
110
|
exports.DeprecatedExperimentalUseHasRecursion = DeprecatedExperimentalUseHasRecursion;
|
|
111
111
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_context","RenderedRefsContext","createContext","addToBlockType","renderedBlocks","blockName","uniqueId","result","Set","add","RecursionProvider","children","previouslyRenderedBlocks","useContext","name","useBlockEditContext","newRenderedBlocks","useMemo","_react","createElement","Provider","value","useHasRecursion","Boolean","has","DeprecatedExperimentalRecursionProvider","props","deprecated","since","alternative","exports","DeprecatedExperimentalUseHasRecursion"],"sources":["@wordpress/block-editor/src/components/recursion-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\n\nconst RenderedRefsContext = createContext( {} );\n\n/**\n * Immutably adds an unique identifier to a set scoped for a given block type.\n *\n * @param {Object} renderedBlocks Rendered blocks grouped by block name\n * @param {string} blockName Name of the block.\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n *\n * @return {Object} The list of rendered blocks grouped by block name.\n */\nfunction addToBlockType( renderedBlocks, blockName, uniqueId ) {\n\tconst result = {\n\t\t...renderedBlocks,\n\t\t[ blockName ]: renderedBlocks[ blockName ]\n\t\t\t? new Set( renderedBlocks[ blockName ] )\n\t\t\t: new Set(),\n\t};\n\tresult[ blockName ].add( uniqueId );\n\n\treturn result;\n}\n\n/**\n * A React context provider for use with the `useHasRecursion` hook to prevent recursive\n * renders.\n *\n * Wrap block content with this provider and provide the same `uniqueId` prop as used\n * with `useHasRecursion`.\n *\n * @param {Object} props\n * @param {*} props.uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} props.blockName Optional block name.\n * @param {JSX.Element} props.children React children.\n *\n * @return {JSX.Element} A React element.\n */\nexport function RecursionProvider( { children, uniqueId, blockName = '' } ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\n\tblockName = blockName || name;\n\n\tconst newRenderedBlocks = useMemo(\n\t\t() => addToBlockType( previouslyRenderedBlocks, blockName, uniqueId ),\n\t\t[ previouslyRenderedBlocks, blockName, uniqueId ]\n\t);\n\n\treturn (\n\t\t<RenderedRefsContext.Provider value={ newRenderedBlocks }>\n\t\t\t{ children }\n\t\t</RenderedRefsContext.Provider>\n\t);\n}\n\n/**\n * A React hook for keeping track of blocks previously rendered up in the block\n * tree. Blocks susceptible to recursion can use this hook in their `Edit`\n * function to prevent said recursion.\n *\n * Use this with the `RecursionProvider` component, using the same `uniqueId` value\n * for both the hook and the provider.\n *\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} blockName Optional block name.\n *\n * @return {boolean} A boolean describing whether the provided id has already been rendered.\n */\nexport function useHasRecursion( uniqueId, blockName = '' ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\tblockName = blockName || name;\n\treturn Boolean( previouslyRenderedBlocks[ blockName ]?.has( uniqueId ) );\n}\n\nexport const DeprecatedExperimentalRecursionProvider = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalRecursionProvider', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.RecursionProvider',\n\t} );\n\treturn <RecursionProvider { ...props } />;\n};\n\nexport const DeprecatedExperimentalUseHasRecursion = (
|
|
1
|
+
{"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_context","RenderedRefsContext","createContext","addToBlockType","renderedBlocks","blockName","uniqueId","result","Set","add","RecursionProvider","children","previouslyRenderedBlocks","useContext","name","useBlockEditContext","newRenderedBlocks","useMemo","_react","createElement","Provider","value","useHasRecursion","Boolean","has","DeprecatedExperimentalRecursionProvider","props","deprecated","since","alternative","exports","DeprecatedExperimentalUseHasRecursion","args"],"sources":["@wordpress/block-editor/src/components/recursion-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\n\nconst RenderedRefsContext = createContext( {} );\n\n/**\n * Immutably adds an unique identifier to a set scoped for a given block type.\n *\n * @param {Object} renderedBlocks Rendered blocks grouped by block name\n * @param {string} blockName Name of the block.\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n *\n * @return {Object} The list of rendered blocks grouped by block name.\n */\nfunction addToBlockType( renderedBlocks, blockName, uniqueId ) {\n\tconst result = {\n\t\t...renderedBlocks,\n\t\t[ blockName ]: renderedBlocks[ blockName ]\n\t\t\t? new Set( renderedBlocks[ blockName ] )\n\t\t\t: new Set(),\n\t};\n\tresult[ blockName ].add( uniqueId );\n\n\treturn result;\n}\n\n/**\n * A React context provider for use with the `useHasRecursion` hook to prevent recursive\n * renders.\n *\n * Wrap block content with this provider and provide the same `uniqueId` prop as used\n * with `useHasRecursion`.\n *\n * @param {Object} props\n * @param {*} props.uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} props.blockName Optional block name.\n * @param {JSX.Element} props.children React children.\n *\n * @return {JSX.Element} A React element.\n */\nexport function RecursionProvider( { children, uniqueId, blockName = '' } ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\n\tblockName = blockName || name;\n\n\tconst newRenderedBlocks = useMemo(\n\t\t() => addToBlockType( previouslyRenderedBlocks, blockName, uniqueId ),\n\t\t[ previouslyRenderedBlocks, blockName, uniqueId ]\n\t);\n\n\treturn (\n\t\t<RenderedRefsContext.Provider value={ newRenderedBlocks }>\n\t\t\t{ children }\n\t\t</RenderedRefsContext.Provider>\n\t);\n}\n\n/**\n * A React hook for keeping track of blocks previously rendered up in the block\n * tree. Blocks susceptible to recursion can use this hook in their `Edit`\n * function to prevent said recursion.\n *\n * Use this with the `RecursionProvider` component, using the same `uniqueId` value\n * for both the hook and the provider.\n *\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} blockName Optional block name.\n *\n * @return {boolean} A boolean describing whether the provided id has already been rendered.\n */\nexport function useHasRecursion( uniqueId, blockName = '' ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\tblockName = blockName || name;\n\treturn Boolean( previouslyRenderedBlocks[ blockName ]?.has( uniqueId ) );\n}\n\nexport const DeprecatedExperimentalRecursionProvider = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalRecursionProvider', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.RecursionProvider',\n\t} );\n\treturn <RecursionProvider { ...props } />;\n};\n\nexport const DeprecatedExperimentalUseHasRecursion = ( ...args ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalUseHasRecursion', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.useHasRecursion',\n\t} );\n\treturn useHasRecursion( ...args );\n};\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMI,mBAAmB,GAAG,IAAAC,sBAAa,EAAE,CAAC,CAAE,CAAC;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAEC,cAAc,EAAEC,SAAS,EAAEC,QAAQ,EAAG;EAC9D,MAAMC,MAAM,GAAG;IACd,GAAGH,cAAc;IACjB,CAAEC,SAAS,GAAID,cAAc,CAAEC,SAAS,CAAE,GACvC,IAAIG,GAAG,CAAEJ,cAAc,CAAEC,SAAS,CA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gD,EAAE;IAC7DC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAAO,IAAAX,MAAA,CAAAC,aAAA,EAACT,iBAAiB;IAAA,GAAMgB;EAAK,CAAI,CAAC;AAC1C,CAAC;AAACI,OAAA,CAAAL,uCAAA,GAAAA,uCAAA;AAEK,MAAMM,qCAAqC,GAAGA,CAAE,GAAGC,IAAI,KAAM;EACnE,IAAAL,mBAAU,EAAE,8CAA8C,EAAE;IAC3DC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAAOP,eAAe,CAAE,GAAGU,IAAK,CAAC;AAClC,CAAC;AAACF,OAAA,CAAAC,qCAAA,GAAAA,qCAAA"}
|
|
@@ -37,7 +37,8 @@ const ImageURLInputUI = ({
|
|
|
37
37
|
rel,
|
|
38
38
|
showLightboxSetting,
|
|
39
39
|
lightboxEnabled,
|
|
40
|
-
onSetLightbox
|
|
40
|
+
onSetLightbox,
|
|
41
|
+
resetLightbox
|
|
41
42
|
}) => {
|
|
42
43
|
const [isOpen, setIsOpen] = (0, _element.useState)(false);
|
|
43
44
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -198,8 +199,52 @@ const ImageURLInputUI = ({
|
|
|
198
199
|
onChange: onSetLinkClass
|
|
199
200
|
}));
|
|
200
201
|
const linkEditorValue = urlInput !== null ? urlInput : url;
|
|
201
|
-
const
|
|
202
|
+
const hideLightboxPanel = !lightboxEnabled || lightboxEnabled && !showLightboxSetting;
|
|
203
|
+
const showLinkEditor = !linkEditorValue && hideLightboxPanel;
|
|
202
204
|
const urlLabel = (getLinkDestinations().find(destination => destination.linkDestination === linkDestination) || {}).title;
|
|
205
|
+
const PopoverChildren = () => {
|
|
206
|
+
if (lightboxEnabled && showLightboxSetting && !url && !isEditingLink) {
|
|
207
|
+
return (0, _react.createElement)("div", {
|
|
208
|
+
className: "block-editor-url-popover__expand-on-click"
|
|
209
|
+
}, (0, _react.createElement)(_icons.Icon, {
|
|
210
|
+
icon: _icons.fullscreen
|
|
211
|
+
}), (0, _react.createElement)("div", {
|
|
212
|
+
className: "text"
|
|
213
|
+
}, (0, _react.createElement)("p", null, (0, _i18n.__)('Expand on click')), (0, _react.createElement)("p", {
|
|
214
|
+
className: "description"
|
|
215
|
+
}, (0, _i18n.__)('Scales the image with a lightbox effect'))), (0, _react.createElement)(_components.Button, {
|
|
216
|
+
icon: _icons.linkOff,
|
|
217
|
+
label: (0, _i18n.__)('Disable expand on click'),
|
|
218
|
+
onClick: () => {
|
|
219
|
+
onSetLightbox(false);
|
|
220
|
+
},
|
|
221
|
+
size: "compact"
|
|
222
|
+
}));
|
|
223
|
+
} else if (!url || isEditingLink) {
|
|
224
|
+
return (0, _react.createElement)(_index.default.LinkEditor, {
|
|
225
|
+
className: "block-editor-format-toolbar__link-container-content",
|
|
226
|
+
value: linkEditorValue,
|
|
227
|
+
onChangeInputValue: setUrlInput,
|
|
228
|
+
onSubmit: onSubmitLinkChange(),
|
|
229
|
+
autocompleteRef: autocompleteRef
|
|
230
|
+
});
|
|
231
|
+
} else if (url && !isEditingLink) {
|
|
232
|
+
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_index.default.LinkViewer, {
|
|
233
|
+
className: "block-editor-format-toolbar__link-container-content",
|
|
234
|
+
url: url,
|
|
235
|
+
onEditLinkClick: startEditLink,
|
|
236
|
+
urlLabel: urlLabel
|
|
237
|
+
}), (0, _react.createElement)(_components.Button, {
|
|
238
|
+
icon: _icons.linkOff,
|
|
239
|
+
label: (0, _i18n.__)('Remove link'),
|
|
240
|
+
onClick: () => {
|
|
241
|
+
onLinkRemove();
|
|
242
|
+
resetLightbox();
|
|
243
|
+
},
|
|
244
|
+
size: "compact"
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
};
|
|
203
248
|
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.ToolbarButton, {
|
|
204
249
|
icon: _icons.link,
|
|
205
250
|
className: "components-toolbar__control",
|
|
@@ -207,13 +252,13 @@ const ImageURLInputUI = ({
|
|
|
207
252
|
"aria-expanded": isOpen,
|
|
208
253
|
onClick: openLinkUI,
|
|
209
254
|
ref: setPopoverAnchor,
|
|
210
|
-
isActive: !!url || lightboxEnabled
|
|
255
|
+
isActive: !!url || lightboxEnabled && showLightboxSetting
|
|
211
256
|
}), isOpen && (0, _react.createElement)(_index.default, {
|
|
212
257
|
ref: wrapperRef,
|
|
213
258
|
anchor: popoverAnchor,
|
|
214
259
|
onFocusOutside: onFocusOutside(),
|
|
215
260
|
onClose: closeLinkUI,
|
|
216
|
-
renderSettings:
|
|
261
|
+
renderSettings: hideLightboxPanel ? () => advancedOptions : null,
|
|
217
262
|
additionalControls: showLinkEditor && (0, _react.createElement)(_components.NavigableMenu, null, getLinkDestinations().map(link => (0, _react.createElement)(_components.MenuItem, {
|
|
218
263
|
key: link.linkDestination,
|
|
219
264
|
icon: link.icon,
|
|
@@ -240,38 +285,7 @@ const ImageURLInputUI = ({
|
|
|
240
285
|
}
|
|
241
286
|
}, (0, _i18n.__)('Expand on click'))),
|
|
242
287
|
offset: 13
|
|
243
|
-
}, (
|
|
244
|
-
className: "block-editor-format-toolbar__link-container-content",
|
|
245
|
-
value: linkEditorValue,
|
|
246
|
-
onChangeInputValue: setUrlInput,
|
|
247
|
-
onSubmit: onSubmitLinkChange(),
|
|
248
|
-
autocompleteRef: autocompleteRef
|
|
249
|
-
})), url && !isEditingLink && !lightboxEnabled && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_index.default.LinkViewer, {
|
|
250
|
-
className: "block-editor-format-toolbar__link-container-content",
|
|
251
|
-
url: url,
|
|
252
|
-
onEditLinkClick: startEditLink,
|
|
253
|
-
urlLabel: urlLabel
|
|
254
|
-
}), (0, _react.createElement)(_components.Button, {
|
|
255
|
-
icon: _icons.linkOff,
|
|
256
|
-
label: (0, _i18n.__)('Remove link'),
|
|
257
|
-
onClick: onLinkRemove,
|
|
258
|
-
size: "compact"
|
|
259
|
-
})), !url && !isEditingLink && lightboxEnabled && (0, _react.createElement)("div", {
|
|
260
|
-
className: "block-editor-url-popover__expand-on-click"
|
|
261
|
-
}, (0, _react.createElement)(_icons.Icon, {
|
|
262
|
-
icon: _icons.fullscreen
|
|
263
|
-
}), (0, _react.createElement)("div", {
|
|
264
|
-
className: "text"
|
|
265
|
-
}, (0, _react.createElement)("p", null, (0, _i18n.__)('Expand on click')), (0, _react.createElement)("p", {
|
|
266
|
-
className: "description"
|
|
267
|
-
}, (0, _i18n.__)('Scales the image with a lightbox effect'))), (0, _react.createElement)(_components.Button, {
|
|
268
|
-
icon: _icons.linkOff,
|
|
269
|
-
label: (0, _i18n.__)('Disable expand on click'),
|
|
270
|
-
onClick: () => {
|
|
271
|
-
onSetLightbox(false);
|
|
272
|
-
},
|
|
273
|
-
size: "compact"
|
|
274
|
-
}))));
|
|
288
|
+
}, PopoverChildren()));
|
|
275
289
|
};
|
|
276
290
|
exports.__experimentalImageURLInputUI = ImageURLInputUI;
|
|
277
291
|
//# sourceMappingURL=image-url-input-ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_dom","_components","_icons","_index","_interopRequireDefault","LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","showLightboxSetting","lightboxEnabled","onSetLightbox","isOpen","setIsOpen","useState","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","useRef","wrapperRef","useEffect","current","nextFocusTarget","focus","focusable","find","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","destination","href","lightbox","enabled","preventDefault","onLinkRemove","linkDestinations","title","__","icon","image","page","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","_react","createElement","__experimentalVStack","spacing","ToggleControl","__nextHasNoMarginBottom","label","onChange","checked","TextControl","linkEditorValue","showLinkEditor","urlLabel","Fragment","ToolbarButton","linkIcon","className","onClick","ref","isActive","default","anchor","onClose","renderSettings","additionalControls","NavigableMenu","map","link","MenuItem","key","iconPosition","fullscreen","info","offset","LinkEditor","onChangeInputValue","onSubmit","LinkViewer","onEditLinkClick","Button","linkOff","size","Icon","exports","__experimentalImageURLInputUI"],"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst showLinkEditor = ( ! linkEditorValue && ! lightboxEnabled ) === true;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={ !! url || lightboxEnabled }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\t! lightboxEnabled ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Expand on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && ! lightboxEnabled && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && ! lightboxEnabled && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! url && ! isEditingLink && lightboxEnabled && (\n\t\t\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t\t\t<p>{ __( 'Expand on click' ) }</p>\n\t\t\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Scales the image with a lightbox effect'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t\t\tlabel={ __( 'Disable expand on click' ) }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonSetLightbox( false );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,IAAAI,MAAA,GAAAJ,OAAA;AAYA,IAAAK,MAAA,GAAAC,sBAAA,CAAAN,OAAA;AA3BA;AACA;AACA;;AAsBA;AACA;AACA;;AAGA,MAAMO,qBAAqB,GAAG,MAAM;AACpC,MAAMC,uBAAuB,GAAG,QAAQ;AACxC,MAAMC,sBAAsB,GAAG,OAAO;AACtC,MAAMC,2BAA2B,GAAG,YAAY;AAChD,MAAMC,WAAW,GAAG,CAAE,YAAY,EAAE,UAAU,CAAE;AAEhD,MAAMC,eAAe,GAAGA,CAAE;EACzBC,eAAe;EACfC,WAAW;EACXC,GAAG;EACHC,SAAS,GAAG,OAAO;EACnBC,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVC,SAAS;EACTC,GAAG;EACHC,mBAAmB;EACnBC,eAAe;EACfC;AACD,CAAC,KAAM;EACN,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAC/C;EACA;EACA,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAG,IAAAF,iBAAQ,EAAE,IAAK,CAAC;EAC5D,MAAMG,UAAU,GAAGA,CAAA,KAAM;IACxBJ,SAAS,CAA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,QAAE,EAAE,yBAA0B,CAAG;IACzC4B,OAAO,EAAGA,CAAA,KAAM;MACfjF,aAAa,CAAE,KAAM,CAAC;IACvB,CAAG;IACHyG,IAAI,EAAC;EAAS,CACd,CACG,CAEK,CAEZ,CAAC;AAEL,CAAC;AAACE,OAAA,CAAAC,6BAAA,GAAAxH,eAAA"}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_dom","_components","_icons","_index","_interopRequireDefault","LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","showLightboxSetting","lightboxEnabled","onSetLightbox","resetLightbox","isOpen","setIsOpen","useState","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","useRef","wrapperRef","useEffect","current","nextFocusTarget","focus","focusable","find","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","destination","href","lightbox","enabled","preventDefault","onLinkRemove","linkDestinations","title","__","icon","image","page","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","_react","createElement","__experimentalVStack","spacing","ToggleControl","__nextHasNoMarginBottom","label","onChange","checked","TextControl","linkEditorValue","hideLightboxPanel","showLinkEditor","urlLabel","PopoverChildren","className","Icon","fullscreen","Button","linkOff","onClick","size","default","LinkEditor","onChangeInputValue","onSubmit","Fragment","LinkViewer","onEditLinkClick","ToolbarButton","linkIcon","ref","isActive","anchor","onClose","renderSettings","additionalControls","NavigableMenu","map","link","MenuItem","key","iconPosition","info","offset","exports","__experimentalImageURLInputUI"],"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n\tresetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst hideLightboxPanel =\n\t\t! lightboxEnabled || ( lightboxEnabled && ! showLightboxSetting );\n\tconst showLinkEditor = ! linkEditorValue && hideLightboxPanel;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\tconst PopoverChildren = () => {\n\t\tif (\n\t\t\tlightboxEnabled &&\n\t\t\tshowLightboxSetting &&\n\t\t\t! url &&\n\t\t\t! isEditingLink\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t<p>{ __( 'Expand on click' ) }</p>\n\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t{ __( 'Scales the image with a lightbox effect' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Disable expand on click' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonSetLightbox( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ( ! url || isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t/>\n\t\t\t);\n\t\t} else if ( url && ! isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonLinkRemove();\n\t\t\t\t\t\t\tresetLightbox();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={\n\t\t\t\t\t!! url || ( lightboxEnabled && showLightboxSetting )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\thideLightboxPanel ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Expand on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ PopoverChildren() }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,WA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({
|
|
|
34
34
|
searchValue: searchValue,
|
|
35
35
|
selectedCategory: selectedCategory,
|
|
36
36
|
patternCategories: patternCategories,
|
|
37
|
-
patternSourceFilter: patternSourceFilter
|
|
37
|
+
patternSourceFilter: patternSourceFilter,
|
|
38
|
+
rootClientId: rootClientId
|
|
38
39
|
}));
|
|
39
40
|
}
|
|
40
41
|
function PatternsExplorerModal({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","useState","__","PatternExplorerSidebar","PatternList","usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","patternSourceFilter","setPatternSourceFilter","selectedCategory","setSelectedCategory","name","patternCategories","createElement","className","onClickCategory","PatternsExplorerModal","onModalClose","restProps","title","onRequestClose","isFullScreen"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\tsetPatternSourceFilter={ setPatternSourceFilter }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,4BAA4B;AAC/D,OAAOC,WAAW,MAAM,gBAAgB;AACxC,SAASC,oBAAoB,QAAQ,8CAA8C;AAEnF,SAASC,gBAAgBA,CAAE;EAAEC,eAAe;EAAEC;AAAa,CAAC,EAAG;EAC9D,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAGT,QAAQ,CAAE,EAAG,CAAC;EACtD,MAAM,CAAEU,mBAAmB,EAAEC,sBAAsB,CAAE,GAAGX,QAAQ,CAAE,KAAM,CAAC;EAEzE,MAAM,CAAEY,gBAAgB,EAAEC,mBAAmB,CAAE,GAAGb,QAAQ,CACzDM,eAAe,EAAEQ,IAClB,CAAC;EAED,MAAMC,iBAAiB,GAAGX,oBAAoB,CAC7CG,YAAY,EACZG,mBACD,CAAC;EAED,OACCM,aAAA;IAAKC,SAAS,EAAC;EAAsC,GACpDD,aAAA,CAACd,sBAAsB;IACtBU,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCG,eAAe,EAAGL,mBAAqB;IACvCL,WAAW,EAAGA,WAAa;IAC3BC,cAAc,EAAGA,cAAgB;IACjCC,mBAAmB,EAAGA,mBAAqB;IAC3CC,sBAAsB,EAAGA;EAAwB,CACjD,CAAC,EACFK,aAAA,CAACb,WAAW;IACXK,WAAW,EAAGA,WAAa;IAC3BI,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCL,mBAAmB,EAAGA;
|
|
1
|
+
{"version":3,"names":["Modal","useState","__","PatternExplorerSidebar","PatternList","usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","patternSourceFilter","setPatternSourceFilter","selectedCategory","setSelectedCategory","name","patternCategories","createElement","className","onClickCategory","PatternsExplorerModal","onModalClose","restProps","title","onRequestClose","isFullScreen"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\tsetPatternSourceFilter={ setPatternSourceFilter }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,4BAA4B;AAC/D,OAAOC,WAAW,MAAM,gBAAgB;AACxC,SAASC,oBAAoB,QAAQ,8CAA8C;AAEnF,SAASC,gBAAgBA,CAAE;EAAEC,eAAe;EAAEC;AAAa,CAAC,EAAG;EAC9D,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAGT,QAAQ,CAAE,EAAG,CAAC;EACtD,MAAM,CAAEU,mBAAmB,EAAEC,sBAAsB,CAAE,GAAGX,QAAQ,CAAE,KAAM,CAAC;EAEzE,MAAM,CAAEY,gBAAgB,EAAEC,mBAAmB,CAAE,GAAGb,QAAQ,CACzDM,eAAe,EAAEQ,IAClB,CAAC;EAED,MAAMC,iBAAiB,GAAGX,oBAAoB,CAC7CG,YAAY,EACZG,mBACD,CAAC;EAED,OACCM,aAAA;IAAKC,SAAS,EAAC;EAAsC,GACpDD,aAAA,CAACd,sBAAsB;IACtBU,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCG,eAAe,EAAGL,mBAAqB;IACvCL,WAAW,EAAGA,WAAa;IAC3BC,cAAc,EAAGA,cAAgB;IACjCC,mBAAmB,EAAGA,mBAAqB;IAC3CC,sBAAsB,EAAGA;EAAwB,CACjD,CAAC,EACFK,aAAA,CAACb,WAAW;IACXK,WAAW,EAAGA,WAAa;IAC3BI,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCL,mBAAmB,EAAGA,mBAAqB;IAC3CH,YAAY,EAAGA;EAAc,CAC7B,CACG,CAAC;AAER;AAEA,SAASY,qBAAqBA,CAAE;EAAEC,YAAY;EAAE,GAAGC;AAAU,CAAC,EAAG;EAChE,OACCL,aAAA,CAACjB,KAAK;IACLuB,KAAK,EAAGrB,EAAE,CAAE,UAAW,CAAG;IAC1BsB,cAAc,EAAGH,YAAc;IAC/BI,YAAY;EAAA,GAEZR,aAAA,CAACX,gBAAgB;IAAA,GAAMgB;EAAS,CAAI,CAC9B,CAAC;AAEV;AAEA,eAAeF,qBAAqB"}
|
|
@@ -36,11 +36,13 @@ function PatternsListHeader({
|
|
|
36
36
|
function PatternList({
|
|
37
37
|
searchValue,
|
|
38
38
|
selectedCategory,
|
|
39
|
-
patternCategories
|
|
39
|
+
patternCategories,
|
|
40
|
+
rootClientId
|
|
40
41
|
}) {
|
|
41
42
|
const container = useRef();
|
|
42
43
|
const debouncedSpeak = useDebounce(speak, 500);
|
|
43
44
|
const [destinationRootClientId, onInsertBlocks] = useInsertionPoint({
|
|
45
|
+
rootClientId,
|
|
44
46
|
shouldFocusBlock: true
|
|
45
47
|
});
|
|
46
48
|
const [patterns,, onClickPattern] = usePatternsState(onInsertBlocks, destinationRootClientId);
|
|
@@ -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","PatternsListHeader","filterValue","filteredBlockPatternsLength","createElement","level","lineHeight","className","PatternList","searchValue","selectedCategory","patternCategories","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","hasKnownCategory","categories","some","category","includes","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","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} 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( {
|
|
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","PatternsListHeader","filterValue","filteredBlockPatternsLength","createElement","level","lineHeight","className","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","hasKnownCategory","categories","some","category","includes","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","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} 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} ) {\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);\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 = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\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\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\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,mBAAmB,MAAM,6BAA6B;AAC7D,OAAOC,iBAAiB,MAAM,8BAA8B;AAC5D,SACCC,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,QACZ,6BAA6B;AAEpC,SAASC,kBAAkBA,CAAE;EAAEC,WAAW;EAAEC;AAA4B,CAAC,EAAG;EAC3E,IAAK,CAAED,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OACCE,aAAA,CAACf,OAAO;IACPgB,KAAK,EAAG,CAAG;IACXC,UAAU,EAAG,MAAQ;IACrBC,SAAS,EAAC;EAA4D,GAEpErB,OAAO,EACR;EACAD,EAAE,CACD,kBAAkB,EAClB,mBAAmB,EACnBkB,2BACD,CAAC,EACDA,2BACD,CACQ,CAAC;AAEZ;AAEA,SAASK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AAa,EACZP,WAAW,CAACQ,yBACZ;IACDC,aAAa,EAAGT,WAAW,CAACU,gBAAkB;IAC9C7B,cAAc,EAAGA,cAAgB;IACjC8B,WAAW,EAAG;EAAO,CACrB,CAAC,EACF7C,aAAA,CAACR,mBAAmB;IAAA,GAAM0C;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAEA,eAAe9B,WAAW"}
|
|
@@ -89,11 +89,11 @@ export const DeprecatedExperimentalRecursionProvider = props => {
|
|
|
89
89
|
...props
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
|
-
export const DeprecatedExperimentalUseHasRecursion =
|
|
92
|
+
export const DeprecatedExperimentalUseHasRecursion = (...args) => {
|
|
93
93
|
deprecated('wp.blockEditor.__experimentalUseHasRecursion', {
|
|
94
94
|
since: '6.5',
|
|
95
95
|
alternative: 'wp.blockEditor.useHasRecursion'
|
|
96
96
|
});
|
|
97
|
-
return useHasRecursion(...
|
|
97
|
+
return useHasRecursion(...args);
|
|
98
98
|
};
|
|
99
99
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","useMemo","deprecated","useBlockEditContext","RenderedRefsContext","addToBlockType","renderedBlocks","blockName","uniqueId","result","Set","add","RecursionProvider","children","previouslyRenderedBlocks","name","newRenderedBlocks","createElement","Provider","value","useHasRecursion","Boolean","has","DeprecatedExperimentalRecursionProvider","props","since","alternative","DeprecatedExperimentalUseHasRecursion"],"sources":["@wordpress/block-editor/src/components/recursion-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\n\nconst RenderedRefsContext = createContext( {} );\n\n/**\n * Immutably adds an unique identifier to a set scoped for a given block type.\n *\n * @param {Object} renderedBlocks Rendered blocks grouped by block name\n * @param {string} blockName Name of the block.\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n *\n * @return {Object} The list of rendered blocks grouped by block name.\n */\nfunction addToBlockType( renderedBlocks, blockName, uniqueId ) {\n\tconst result = {\n\t\t...renderedBlocks,\n\t\t[ blockName ]: renderedBlocks[ blockName ]\n\t\t\t? new Set( renderedBlocks[ blockName ] )\n\t\t\t: new Set(),\n\t};\n\tresult[ blockName ].add( uniqueId );\n\n\treturn result;\n}\n\n/**\n * A React context provider for use with the `useHasRecursion` hook to prevent recursive\n * renders.\n *\n * Wrap block content with this provider and provide the same `uniqueId` prop as used\n * with `useHasRecursion`.\n *\n * @param {Object} props\n * @param {*} props.uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} props.blockName Optional block name.\n * @param {JSX.Element} props.children React children.\n *\n * @return {JSX.Element} A React element.\n */\nexport function RecursionProvider( { children, uniqueId, blockName = '' } ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\n\tblockName = blockName || name;\n\n\tconst newRenderedBlocks = useMemo(\n\t\t() => addToBlockType( previouslyRenderedBlocks, blockName, uniqueId ),\n\t\t[ previouslyRenderedBlocks, blockName, uniqueId ]\n\t);\n\n\treturn (\n\t\t<RenderedRefsContext.Provider value={ newRenderedBlocks }>\n\t\t\t{ children }\n\t\t</RenderedRefsContext.Provider>\n\t);\n}\n\n/**\n * A React hook for keeping track of blocks previously rendered up in the block\n * tree. Blocks susceptible to recursion can use this hook in their `Edit`\n * function to prevent said recursion.\n *\n * Use this with the `RecursionProvider` component, using the same `uniqueId` value\n * for both the hook and the provider.\n *\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} blockName Optional block name.\n *\n * @return {boolean} A boolean describing whether the provided id has already been rendered.\n */\nexport function useHasRecursion( uniqueId, blockName = '' ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\tblockName = blockName || name;\n\treturn Boolean( previouslyRenderedBlocks[ blockName ]?.has( uniqueId ) );\n}\n\nexport const DeprecatedExperimentalRecursionProvider = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalRecursionProvider', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.RecursionProvider',\n\t} );\n\treturn <RecursionProvider { ...props } />;\n};\n\nexport const DeprecatedExperimentalUseHasRecursion = (
|
|
1
|
+
{"version":3,"names":["createContext","useContext","useMemo","deprecated","useBlockEditContext","RenderedRefsContext","addToBlockType","renderedBlocks","blockName","uniqueId","result","Set","add","RecursionProvider","children","previouslyRenderedBlocks","name","newRenderedBlocks","createElement","Provider","value","useHasRecursion","Boolean","has","DeprecatedExperimentalRecursionProvider","props","since","alternative","DeprecatedExperimentalUseHasRecursion","args"],"sources":["@wordpress/block-editor/src/components/recursion-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\n\nconst RenderedRefsContext = createContext( {} );\n\n/**\n * Immutably adds an unique identifier to a set scoped for a given block type.\n *\n * @param {Object} renderedBlocks Rendered blocks grouped by block name\n * @param {string} blockName Name of the block.\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n *\n * @return {Object} The list of rendered blocks grouped by block name.\n */\nfunction addToBlockType( renderedBlocks, blockName, uniqueId ) {\n\tconst result = {\n\t\t...renderedBlocks,\n\t\t[ blockName ]: renderedBlocks[ blockName ]\n\t\t\t? new Set( renderedBlocks[ blockName ] )\n\t\t\t: new Set(),\n\t};\n\tresult[ blockName ].add( uniqueId );\n\n\treturn result;\n}\n\n/**\n * A React context provider for use with the `useHasRecursion` hook to prevent recursive\n * renders.\n *\n * Wrap block content with this provider and provide the same `uniqueId` prop as used\n * with `useHasRecursion`.\n *\n * @param {Object} props\n * @param {*} props.uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} props.blockName Optional block name.\n * @param {JSX.Element} props.children React children.\n *\n * @return {JSX.Element} A React element.\n */\nexport function RecursionProvider( { children, uniqueId, blockName = '' } ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\n\tblockName = blockName || name;\n\n\tconst newRenderedBlocks = useMemo(\n\t\t() => addToBlockType( previouslyRenderedBlocks, blockName, uniqueId ),\n\t\t[ previouslyRenderedBlocks, blockName, uniqueId ]\n\t);\n\n\treturn (\n\t\t<RenderedRefsContext.Provider value={ newRenderedBlocks }>\n\t\t\t{ children }\n\t\t</RenderedRefsContext.Provider>\n\t);\n}\n\n/**\n * A React hook for keeping track of blocks previously rendered up in the block\n * tree. Blocks susceptible to recursion can use this hook in their `Edit`\n * function to prevent said recursion.\n *\n * Use this with the `RecursionProvider` component, using the same `uniqueId` value\n * for both the hook and the provider.\n *\n * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.\n * @param {string} blockName Optional block name.\n *\n * @return {boolean} A boolean describing whether the provided id has already been rendered.\n */\nexport function useHasRecursion( uniqueId, blockName = '' ) {\n\tconst previouslyRenderedBlocks = useContext( RenderedRefsContext );\n\tconst { name } = useBlockEditContext();\n\tblockName = blockName || name;\n\treturn Boolean( previouslyRenderedBlocks[ blockName ]?.has( uniqueId ) );\n}\n\nexport const DeprecatedExperimentalRecursionProvider = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalRecursionProvider', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.RecursionProvider',\n\t} );\n\treturn <RecursionProvider { ...props } />;\n};\n\nexport const DeprecatedExperimentalUseHasRecursion = ( ...args ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalUseHasRecursion', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.useHasRecursion',\n\t} );\n\treturn useHasRecursion( ...args );\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;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EAAED,SAAS,GAAG,EAAE,EAAG;EAC3D,MAAMO,wBAAwB,GAAGd,UAAU,CAAEI,mBAAoB,CAAC;EAClE,MAAM;IAAEW;EAAK,CAAC,GAAGZ,mBAAmB,CAAC,CAAC;EACtCI,SAAS,GAAGA,SAAS,IAAIQ,IAAI;EAC7B,OAAOM,OAAO,CAAEP,wBAAwB,CAAEP,SAAS,CAAE,EAAEe,GAAG,CAAEd,QAAS,CAAE,CAAC;AACzE;AAEA,OAAO,MAAMe,uCAAuC,GAAKC,KAAK,IAAM;EACnEtB,UAAU,CAAE,gDAAgD,EAAE;IAC7DuB,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAAOT,aAAA,CAACL,iBAAiB;IAAA,GAAMY;EAAK,CAAI,CAAC;AAC1C,CAAC;AAED,OAAO,MAAMG,qCAAqC,GAAGA,CAAE,GAAGC,IAAI,KAAM;EACnE1B,UAAU,CAAE,8CAA8C,EAAE;IAC3DuB,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAAON,eAAe,CAAE,GAAGQ,IAAK,CAAC;AAClC,CAAC"}
|
|
@@ -29,7 +29,8 @@ const ImageURLInputUI = ({
|
|
|
29
29
|
rel,
|
|
30
30
|
showLightboxSetting,
|
|
31
31
|
lightboxEnabled,
|
|
32
|
-
onSetLightbox
|
|
32
|
+
onSetLightbox,
|
|
33
|
+
resetLightbox
|
|
33
34
|
}) => {
|
|
34
35
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
36
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -190,8 +191,52 @@ const ImageURLInputUI = ({
|
|
|
190
191
|
onChange: onSetLinkClass
|
|
191
192
|
}));
|
|
192
193
|
const linkEditorValue = urlInput !== null ? urlInput : url;
|
|
193
|
-
const
|
|
194
|
+
const hideLightboxPanel = !lightboxEnabled || lightboxEnabled && !showLightboxSetting;
|
|
195
|
+
const showLinkEditor = !linkEditorValue && hideLightboxPanel;
|
|
194
196
|
const urlLabel = (getLinkDestinations().find(destination => destination.linkDestination === linkDestination) || {}).title;
|
|
197
|
+
const PopoverChildren = () => {
|
|
198
|
+
if (lightboxEnabled && showLightboxSetting && !url && !isEditingLink) {
|
|
199
|
+
return createElement("div", {
|
|
200
|
+
className: "block-editor-url-popover__expand-on-click"
|
|
201
|
+
}, createElement(Icon, {
|
|
202
|
+
icon: fullscreen
|
|
203
|
+
}), createElement("div", {
|
|
204
|
+
className: "text"
|
|
205
|
+
}, createElement("p", null, __('Expand on click')), createElement("p", {
|
|
206
|
+
className: "description"
|
|
207
|
+
}, __('Scales the image with a lightbox effect'))), createElement(Button, {
|
|
208
|
+
icon: linkOff,
|
|
209
|
+
label: __('Disable expand on click'),
|
|
210
|
+
onClick: () => {
|
|
211
|
+
onSetLightbox(false);
|
|
212
|
+
},
|
|
213
|
+
size: "compact"
|
|
214
|
+
}));
|
|
215
|
+
} else if (!url || isEditingLink) {
|
|
216
|
+
return createElement(URLPopover.LinkEditor, {
|
|
217
|
+
className: "block-editor-format-toolbar__link-container-content",
|
|
218
|
+
value: linkEditorValue,
|
|
219
|
+
onChangeInputValue: setUrlInput,
|
|
220
|
+
onSubmit: onSubmitLinkChange(),
|
|
221
|
+
autocompleteRef: autocompleteRef
|
|
222
|
+
});
|
|
223
|
+
} else if (url && !isEditingLink) {
|
|
224
|
+
return createElement(Fragment, null, createElement(URLPopover.LinkViewer, {
|
|
225
|
+
className: "block-editor-format-toolbar__link-container-content",
|
|
226
|
+
url: url,
|
|
227
|
+
onEditLinkClick: startEditLink,
|
|
228
|
+
urlLabel: urlLabel
|
|
229
|
+
}), createElement(Button, {
|
|
230
|
+
icon: linkOff,
|
|
231
|
+
label: __('Remove link'),
|
|
232
|
+
onClick: () => {
|
|
233
|
+
onLinkRemove();
|
|
234
|
+
resetLightbox();
|
|
235
|
+
},
|
|
236
|
+
size: "compact"
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
};
|
|
195
240
|
return createElement(Fragment, null, createElement(ToolbarButton, {
|
|
196
241
|
icon: linkIcon,
|
|
197
242
|
className: "components-toolbar__control",
|
|
@@ -199,13 +244,13 @@ const ImageURLInputUI = ({
|
|
|
199
244
|
"aria-expanded": isOpen,
|
|
200
245
|
onClick: openLinkUI,
|
|
201
246
|
ref: setPopoverAnchor,
|
|
202
|
-
isActive: !!url || lightboxEnabled
|
|
247
|
+
isActive: !!url || lightboxEnabled && showLightboxSetting
|
|
203
248
|
}), isOpen && createElement(URLPopover, {
|
|
204
249
|
ref: wrapperRef,
|
|
205
250
|
anchor: popoverAnchor,
|
|
206
251
|
onFocusOutside: onFocusOutside(),
|
|
207
252
|
onClose: closeLinkUI,
|
|
208
|
-
renderSettings:
|
|
253
|
+
renderSettings: hideLightboxPanel ? () => advancedOptions : null,
|
|
209
254
|
additionalControls: showLinkEditor && createElement(NavigableMenu, null, getLinkDestinations().map(link => createElement(MenuItem, {
|
|
210
255
|
key: link.linkDestination,
|
|
211
256
|
icon: link.icon,
|
|
@@ -232,38 +277,7 @@ const ImageURLInputUI = ({
|
|
|
232
277
|
}
|
|
233
278
|
}, __('Expand on click'))),
|
|
234
279
|
offset: 13
|
|
235
|
-
}, (
|
|
236
|
-
className: "block-editor-format-toolbar__link-container-content",
|
|
237
|
-
value: linkEditorValue,
|
|
238
|
-
onChangeInputValue: setUrlInput,
|
|
239
|
-
onSubmit: onSubmitLinkChange(),
|
|
240
|
-
autocompleteRef: autocompleteRef
|
|
241
|
-
})), url && !isEditingLink && !lightboxEnabled && createElement(Fragment, null, createElement(URLPopover.LinkViewer, {
|
|
242
|
-
className: "block-editor-format-toolbar__link-container-content",
|
|
243
|
-
url: url,
|
|
244
|
-
onEditLinkClick: startEditLink,
|
|
245
|
-
urlLabel: urlLabel
|
|
246
|
-
}), createElement(Button, {
|
|
247
|
-
icon: linkOff,
|
|
248
|
-
label: __('Remove link'),
|
|
249
|
-
onClick: onLinkRemove,
|
|
250
|
-
size: "compact"
|
|
251
|
-
})), !url && !isEditingLink && lightboxEnabled && createElement("div", {
|
|
252
|
-
className: "block-editor-url-popover__expand-on-click"
|
|
253
|
-
}, createElement(Icon, {
|
|
254
|
-
icon: fullscreen
|
|
255
|
-
}), createElement("div", {
|
|
256
|
-
className: "text"
|
|
257
|
-
}, createElement("p", null, __('Expand on click')), createElement("p", {
|
|
258
|
-
className: "description"
|
|
259
|
-
}, __('Scales the image with a lightbox effect'))), createElement(Button, {
|
|
260
|
-
icon: linkOff,
|
|
261
|
-
label: __('Disable expand on click'),
|
|
262
|
-
onClick: () => {
|
|
263
|
-
onSetLightbox(false);
|
|
264
|
-
},
|
|
265
|
-
size: "compact"
|
|
266
|
-
}))));
|
|
280
|
+
}, PopoverChildren()));
|
|
267
281
|
};
|
|
268
282
|
export { ImageURLInputUI as __experimentalImageURLInputUI };
|
|
269
283
|
//# sourceMappingURL=image-url-input-ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useRef","useEffect","useState","focus","ToolbarButton","NavigableMenu","Button","MenuItem","ToggleControl","TextControl","__experimentalVStack","VStack","Icon","link","linkIcon","image","page","fullscreen","linkOff","URLPopover","LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","showLightboxSetting","lightboxEnabled","onSetLightbox","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","wrapperRef","current","nextFocusTarget","focusable","find","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","destination","href","lightbox","enabled","preventDefault","onLinkRemove","linkDestinations","title","icon","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","createElement","spacing","__nextHasNoMarginBottom","label","onChange","checked","linkEditorValue","showLinkEditor","urlLabel","Fragment","className","onClick","ref","isActive","anchor","onClose","renderSettings","additionalControls","map","key","iconPosition","info","offset","LinkEditor","onChangeInputValue","onSubmit","LinkViewer","onEditLinkClick","size","__experimentalImageURLInputUI"],"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst showLinkEditor = ( ! linkEditorValue && ! lightboxEnabled ) === true;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={ !! url || lightboxEnabled }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\t! lightboxEnabled ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Expand on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && ! lightboxEnabled && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && ! lightboxEnabled && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! url && ! isEditingLink && lightboxEnabled && (\n\t\t\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t\t\t<p>{ __( 'Expand on click' ) }</p>\n\t\t\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Scales the image with a lightbox effect'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t\t\tlabel={ __( 'Disable expand on click' ) }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonSetLightbox( false );\n\t\t\t\t\t\t\t\t} }\n\t\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lG,EAAE,CAAE,aAAc,CAAG;IAC7B0G,OAAO,EAAGtB,YAAc;IACxBuC,IAAI,EAAC;EAAS,CACd,CACA,CACF,EACC,CAAE9F,GAAG,IAAI,CAAEe,aAAa,IAAIP,eAAe,IAC5C0D,aAAA;IAAKU,SAAS,EAAC;EAA2C,GACzDV,aAAA,CAAClF,IAAI;IAAC0E,IAAI,EAAGrE;EAAY,CAAE,CAAC,EAC5B6E,aAAA;IAAKU,SAAS,EAAC;EAAM,GACpBV,aAAA,YAAK/F,EAAE,CAAE,iBAAkB,CAAM,CAAC,EAClC+F,aAAA;IAAGU,SAAS,EAAC;EAAa,GACvBzG,EAAE,CACH,yCACD,CACE,CACC,CAAC,EACN+F,aAAA,CAACxF,MAAM;IACNgF,IAAI,EAAGpE,OAAS;IAChB+E,KAAK,EAAGlG,EAAE,CAAE,yBAA0B,CAAG;IACzC0G,OAAO,EAAGA,CAAA,KAAM;MACfpE,aAAa,CAAE,KAAM,CAAC;IACvB,CAAG;IACHqF,IAAI,EAAC;EAAS,CACd,CACG,CAEK,CAEZ,CAAC;AAEL,CAAC;AAED,SAASjG,eAAe,IAAIkG,6BAA6B"}
|
|
1
|
+
{"version":3,"names":["__","useRef","useEffect","useState","focus","ToolbarButton","NavigableMenu","Button","MenuItem","ToggleControl","TextControl","__experimentalVStack","VStack","Icon","link","linkIcon","image","page","fullscreen","linkOff","URLPopover","LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","showLightboxSetting","lightboxEnabled","onSetLightbox","resetLightbox","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","wrapperRef","current","nextFocusTarget","focusable","find","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","destination","href","lightbox","enabled","preventDefault","onLinkRemove","linkDestinations","title","icon","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","createElement","spacing","__nextHasNoMarginBottom","label","onChange","checked","linkEditorValue","hideLightboxPanel","showLinkEditor","urlLabel","PopoverChildren","className","onClick","size","LinkEditor","onChangeInputValue","onSubmit","Fragment","LinkViewer","onEditLinkClick","ref","isActive","anchor","onClose","renderSettings","additionalControls","map","key","iconPosition","info","offset","__experimentalImageURLInputUI"],"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n\tresetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst hideLightboxPanel =\n\t\t! lightboxEnabled || ( lightboxEnabled && ! showLightboxSetting );\n\tconst showLinkEditor = ! linkEditorValue && hideLightboxPanel;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\tconst PopoverChildren = () => {\n\t\tif (\n\t\t\tlightboxEnabled &&\n\t\t\tshowLightboxSetting &&\n\t\t\t! url &&\n\t\t\t! isEditingLink\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t<p>{ __( 'Expand on click' ) }</p>\n\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t{ __( 'Scales the image with a lightbox effect' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Disable expand on click' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonSetLightbox( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ( ! url || isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t/>\n\t\t\t);\n\t\t} else if ( url && ! isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonLinkRemove();\n\t\t\t\t\t\t\tresetLightbox();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={\n\t\t\t\t\t!! url || ( lightboxEnabled && showLightboxSetting )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\thideLightboxPanel ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Expand on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ PopoverChildren() }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,aAAa,EACbC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,aAAa,EACbC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SACCC,IAAI,EACJC,IAAI,IAAIC,QAAQ,EAChBC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,OAAO,QACD,kBAAkB;;AAEzB;AACA;AACA;AACA,OAAOC,UAAU,MAAM,SAAS;AAEhC,MAAMC,qBAAqB,GAAG,MAAM;AACpC,MAAMC,uBAAuB,GAAG,QAAQ;AACxC,MAAMC,sBAAsB,GAAG,OAAO;AACtC,MAAMC,2BAA2B,GAAG,YAAY;AAChD,MAAMC,WAAW,GAAG,CAAE,YAAY,EAAE,UAAU,CAAE;AAEhD,MAAMC,eAAe,GAAGA,CAAE;EACzBC,eAAe;EACfC,WAAW;EACXC,GAAG;EACHC,SAAS,GAAG,OAAO;EACnBC,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVC,SAAS;EACTC,GAAG;EACHC,mBAAmB;EACnBC,eAAe;EACfC,aAAa;EACbC;AACD,CAAC,KAAM;EACN,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAGt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version": "12.19.
|
|
3
|
+
"version": "12.19.8",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@wordpress/api-fetch": "^6.48.1",
|
|
40
40
|
"@wordpress/blob": "^3.51.1",
|
|
41
41
|
"@wordpress/blocks": "^12.28.6",
|
|
42
|
-
"@wordpress/commands": "^0.22.
|
|
43
|
-
"@wordpress/components": "^26.0.
|
|
42
|
+
"@wordpress/commands": "^0.22.6",
|
|
43
|
+
"@wordpress/components": "^26.0.6",
|
|
44
44
|
"@wordpress/compose": "^6.28.1",
|
|
45
45
|
"@wordpress/data": "^9.21.1",
|
|
46
46
|
"@wordpress/date": "^4.51.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@wordpress/keyboard-shortcuts": "^4.28.1",
|
|
57
57
|
"@wordpress/keycodes": "^3.51.1",
|
|
58
58
|
"@wordpress/notices": "^4.19.1",
|
|
59
|
-
"@wordpress/preferences": "^3.28.
|
|
59
|
+
"@wordpress/preferences": "^3.28.6",
|
|
60
60
|
"@wordpress/private-apis": "^0.33.1",
|
|
61
61
|
"@wordpress/rich-text": "^6.28.4",
|
|
62
62
|
"@wordpress/style-engine": "^1.34.1",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "be077ee679b7b319a1d9eed46a74ffcbc5ad0b93"
|
|
91
91
|
}
|
|
@@ -47,10 +47,16 @@ function PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {
|
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function PatternList( {
|
|
50
|
+
function PatternList( {
|
|
51
|
+
searchValue,
|
|
52
|
+
selectedCategory,
|
|
53
|
+
patternCategories,
|
|
54
|
+
rootClientId,
|
|
55
|
+
} ) {
|
|
51
56
|
const container = useRef();
|
|
52
57
|
const debouncedSpeak = useDebounce( speak, 500 );
|
|
53
58
|
const [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {
|
|
59
|
+
rootClientId,
|
|
54
60
|
shouldFocusBlock: true,
|
|
55
61
|
} );
|
|
56
62
|
const [ patterns, , onClickPattern ] = usePatternsState(
|
|
@@ -92,10 +92,10 @@ export const DeprecatedExperimentalRecursionProvider = ( props ) => {
|
|
|
92
92
|
return <RecursionProvider { ...props } />;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
export const DeprecatedExperimentalUseHasRecursion = (
|
|
95
|
+
export const DeprecatedExperimentalUseHasRecursion = ( ...args ) => {
|
|
96
96
|
deprecated( 'wp.blockEditor.__experimentalUseHasRecursion', {
|
|
97
97
|
since: '6.5',
|
|
98
98
|
alternative: 'wp.blockEditor.useHasRecursion',
|
|
99
99
|
} );
|
|
100
|
-
return useHasRecursion( ...
|
|
100
|
+
return useHasRecursion( ...args );
|
|
101
101
|
};
|
|
@@ -46,6 +46,7 @@ const ImageURLInputUI = ( {
|
|
|
46
46
|
showLightboxSetting,
|
|
47
47
|
lightboxEnabled,
|
|
48
48
|
onSetLightbox,
|
|
49
|
+
resetLightbox,
|
|
49
50
|
} ) => {
|
|
50
51
|
const [ isOpen, setIsOpen ] = useState( false );
|
|
51
52
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -241,7 +242,9 @@ const ImageURLInputUI = ( {
|
|
|
241
242
|
);
|
|
242
243
|
|
|
243
244
|
const linkEditorValue = urlInput !== null ? urlInput : url;
|
|
244
|
-
const
|
|
245
|
+
const hideLightboxPanel =
|
|
246
|
+
! lightboxEnabled || ( lightboxEnabled && ! showLightboxSetting );
|
|
247
|
+
const showLinkEditor = ! linkEditorValue && hideLightboxPanel;
|
|
245
248
|
|
|
246
249
|
const urlLabel = (
|
|
247
250
|
getLinkDestinations().find(
|
|
@@ -249,6 +252,65 @@ const ImageURLInputUI = ( {
|
|
|
249
252
|
) || {}
|
|
250
253
|
).title;
|
|
251
254
|
|
|
255
|
+
const PopoverChildren = () => {
|
|
256
|
+
if (
|
|
257
|
+
lightboxEnabled &&
|
|
258
|
+
showLightboxSetting &&
|
|
259
|
+
! url &&
|
|
260
|
+
! isEditingLink
|
|
261
|
+
) {
|
|
262
|
+
return (
|
|
263
|
+
<div className="block-editor-url-popover__expand-on-click">
|
|
264
|
+
<Icon icon={ fullscreen } />
|
|
265
|
+
<div className="text">
|
|
266
|
+
<p>{ __( 'Expand on click' ) }</p>
|
|
267
|
+
<p className="description">
|
|
268
|
+
{ __( 'Scales the image with a lightbox effect' ) }
|
|
269
|
+
</p>
|
|
270
|
+
</div>
|
|
271
|
+
<Button
|
|
272
|
+
icon={ linkOff }
|
|
273
|
+
label={ __( 'Disable expand on click' ) }
|
|
274
|
+
onClick={ () => {
|
|
275
|
+
onSetLightbox( false );
|
|
276
|
+
} }
|
|
277
|
+
size="compact"
|
|
278
|
+
/>
|
|
279
|
+
</div>
|
|
280
|
+
);
|
|
281
|
+
} else if ( ! url || isEditingLink ) {
|
|
282
|
+
return (
|
|
283
|
+
<URLPopover.LinkEditor
|
|
284
|
+
className="block-editor-format-toolbar__link-container-content"
|
|
285
|
+
value={ linkEditorValue }
|
|
286
|
+
onChangeInputValue={ setUrlInput }
|
|
287
|
+
onSubmit={ onSubmitLinkChange() }
|
|
288
|
+
autocompleteRef={ autocompleteRef }
|
|
289
|
+
/>
|
|
290
|
+
);
|
|
291
|
+
} else if ( url && ! isEditingLink ) {
|
|
292
|
+
return (
|
|
293
|
+
<>
|
|
294
|
+
<URLPopover.LinkViewer
|
|
295
|
+
className="block-editor-format-toolbar__link-container-content"
|
|
296
|
+
url={ url }
|
|
297
|
+
onEditLinkClick={ startEditLink }
|
|
298
|
+
urlLabel={ urlLabel }
|
|
299
|
+
/>
|
|
300
|
+
<Button
|
|
301
|
+
icon={ linkOff }
|
|
302
|
+
label={ __( 'Remove link' ) }
|
|
303
|
+
onClick={ () => {
|
|
304
|
+
onLinkRemove();
|
|
305
|
+
resetLightbox();
|
|
306
|
+
} }
|
|
307
|
+
size="compact"
|
|
308
|
+
/>
|
|
309
|
+
</>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
252
314
|
return (
|
|
253
315
|
<>
|
|
254
316
|
<ToolbarButton
|
|
@@ -258,7 +320,9 @@ const ImageURLInputUI = ( {
|
|
|
258
320
|
aria-expanded={ isOpen }
|
|
259
321
|
onClick={ openLinkUI }
|
|
260
322
|
ref={ setPopoverAnchor }
|
|
261
|
-
isActive={
|
|
323
|
+
isActive={
|
|
324
|
+
!! url || ( lightboxEnabled && showLightboxSetting )
|
|
325
|
+
}
|
|
262
326
|
/>
|
|
263
327
|
{ isOpen && (
|
|
264
328
|
<URLPopover
|
|
@@ -267,7 +331,7 @@ const ImageURLInputUI = ( {
|
|
|
267
331
|
onFocusOutside={ onFocusOutside() }
|
|
268
332
|
onClose={ closeLinkUI }
|
|
269
333
|
renderSettings={
|
|
270
|
-
|
|
334
|
+
hideLightboxPanel ? () => advancedOptions : null
|
|
271
335
|
}
|
|
272
336
|
additionalControls={
|
|
273
337
|
showLinkEditor && (
|
|
@@ -314,54 +378,7 @@ const ImageURLInputUI = ( {
|
|
|
314
378
|
}
|
|
315
379
|
offset={ 13 }
|
|
316
380
|
>
|
|
317
|
-
{ (
|
|
318
|
-
<>
|
|
319
|
-
<URLPopover.LinkEditor
|
|
320
|
-
className="block-editor-format-toolbar__link-container-content"
|
|
321
|
-
value={ linkEditorValue }
|
|
322
|
-
onChangeInputValue={ setUrlInput }
|
|
323
|
-
onSubmit={ onSubmitLinkChange() }
|
|
324
|
-
autocompleteRef={ autocompleteRef }
|
|
325
|
-
/>
|
|
326
|
-
</>
|
|
327
|
-
) }
|
|
328
|
-
{ url && ! isEditingLink && ! lightboxEnabled && (
|
|
329
|
-
<>
|
|
330
|
-
<URLPopover.LinkViewer
|
|
331
|
-
className="block-editor-format-toolbar__link-container-content"
|
|
332
|
-
url={ url }
|
|
333
|
-
onEditLinkClick={ startEditLink }
|
|
334
|
-
urlLabel={ urlLabel }
|
|
335
|
-
/>
|
|
336
|
-
<Button
|
|
337
|
-
icon={ linkOff }
|
|
338
|
-
label={ __( 'Remove link' ) }
|
|
339
|
-
onClick={ onLinkRemove }
|
|
340
|
-
size="compact"
|
|
341
|
-
/>
|
|
342
|
-
</>
|
|
343
|
-
) }
|
|
344
|
-
{ ! url && ! isEditingLink && lightboxEnabled && (
|
|
345
|
-
<div className="block-editor-url-popover__expand-on-click">
|
|
346
|
-
<Icon icon={ fullscreen } />
|
|
347
|
-
<div className="text">
|
|
348
|
-
<p>{ __( 'Expand on click' ) }</p>
|
|
349
|
-
<p className="description">
|
|
350
|
-
{ __(
|
|
351
|
-
'Scales the image with a lightbox effect'
|
|
352
|
-
) }
|
|
353
|
-
</p>
|
|
354
|
-
</div>
|
|
355
|
-
<Button
|
|
356
|
-
icon={ linkOff }
|
|
357
|
-
label={ __( 'Disable expand on click' ) }
|
|
358
|
-
onClick={ () => {
|
|
359
|
-
onSetLightbox( false );
|
|
360
|
-
} }
|
|
361
|
-
size="compact"
|
|
362
|
-
/>
|
|
363
|
-
</div>
|
|
364
|
-
) }
|
|
381
|
+
{ PopoverChildren() }
|
|
365
382
|
</URLPopover>
|
|
366
383
|
) }
|
|
367
384
|
</>
|