@wordpress/block-editor 12.10.0 → 12.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-patterns-list/index.js +10 -5
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +4 -2
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +21 -32
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +0 -15
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-filter.js +137 -0
- package/build/components/inserter/block-patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +77 -37
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +4 -0
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build/components/inserter/search-results.js +1 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/hooks/background.js +28 -23
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-rename-ui.js +2 -1
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/store/private-selectors.js +2 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +11 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +4 -2
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +23 -34
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +0 -14
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-filter.js +128 -0
- package/build-module/components/inserter/block-patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -35
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +5 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build-module/components/inserter/search-results.js +1 -1
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/hooks/background.js +30 -25
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +2 -1
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +54 -26
- package/build-style/style.css +54 -26
- package/package.json +32 -32
- package/src/components/block-patterns-list/index.js +19 -12
- package/src/components/block-patterns-paging/index.js +58 -55
- package/src/components/block-patterns-paging/style.scss +16 -13
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +34 -76
- package/src/components/inserter/block-patterns-explorer/sidebar.js +0 -15
- package/src/components/inserter/block-patterns-filter.js +183 -0
- package/src/components/inserter/block-patterns-tab.js +106 -58
- package/src/components/inserter/hooks/use-patterns-paging.js +12 -1
- package/src/components/inserter/search-results.js +1 -1
- package/src/components/inserter/style.scss +14 -5
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/src/hooks/background.js +57 -46
- package/src/hooks/background.scss +36 -18
- package/src/hooks/block-rename-ui.js +1 -0
- package/src/store/private-selectors.js +7 -3
- package/build/components/inserter/block-patterns-source-filter.js +0 -54
- package/build/components/inserter/block-patterns-source-filter.js.map +0 -1
- package/build/components/inserter/block-patterns-sync-filter.js +0 -46
- package/build/components/inserter/block-patterns-sync-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-source-filter.js +0 -44
- package/build-module/components/inserter/block-patterns-source-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-sync-filter.js +0 -38
- package/build-module/components/inserter/block-patterns-sync-filter.js.map +0 -1
- package/src/components/inserter/block-patterns-source-filter.js +0 -40
- package/src/components/inserter/block-patterns-sync-filter.js +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useEffect","__","_n","sprintf","VisuallyHidden","useDebounce","useAsyncList","speak","useSelect","BlockTypesList","BlockPatternsList","__unstableInserterMenuExtension","InserterPanel","InserterNoResults","useInsertionPoint","usePatternsState","useBlockTypesState","searchBlockItems","searchItems","InserterListbox","orderBy","orderInserterBlockItems","store","blockEditorStore","INITIAL_INSERTER_RESULTS","EMPTY_ARRAY","InserterSearchResults","filterValue","onSelect","onHover","onHoverPattern","rootClientId","clientId","isAppender","__experimentalInsertionIndex","maxBlockPatterns","maxBlockTypes","showBlockDirectory","isDraggable","shouldFocusBlock","prioritizePatterns","selectBlockOnInsert","debouncedSpeak","prioritizedBlocks","select","blockListSettings","getBlockListSettings","prioritizedInserterBlocks","destinationRootClientId","onInsertBlocks","insertionIndex","blockTypes","blockTypeCategories","blockTypeCollections","onSelectBlockType","patterns","onClickPattern","filteredBlockPatterns","results","undefined","slice","maxBlockTypesToShow","length","filteredBlockTypes","nonPatternBlockTypes","filter","blockType","name","orderedItems","count","resultsFoundMessage","currentShownBlockTypes","step","currentShownPatterns","hasItems","blocksUI","createElement","title","items","label","patternsUI","className","shownPatterns","blockPatterns","Slot","fillProps","fills"],"sources":["@wordpress/block-editor/src/components/inserter/search-results.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\nimport { orderInserterBlockItems } from '../../utils/order-inserter-block-items';\nimport { store as blockEditorStore } from '../../store';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\tonHoverPattern,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n\tprioritizePatterns,\n\tselectBlockOnInsert,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst { prioritizedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst blockListSettings =\n\t\t\t\tselect( blockEditorStore ).getBlockListSettings( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tprioritizedBlocks:\n\t\t\t\t\tblockListSettings?.prioritizedInserterBlocks || EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t\tselectBlockOnInsert,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( maxBlockPatterns === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\tlet maxBlockTypesToShow = maxBlockTypes;\n\tif ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {\n\t\tmaxBlockTypesToShow = 0;\n\t}\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( maxBlockTypesToShow === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst nonPatternBlockTypes = blockTypes.filter(\n\t\t\t( blockType ) => blockType.name !== 'core/block'\n\t\t);\n\t\tlet orderedItems = orderBy( nonPatternBlockTypes, 'frecency', 'desc' );\n\n\t\tif ( ! filterValue && prioritizedBlocks.length ) {\n\t\t\torderedItems = orderInserterBlockItems(\n\t\t\t\torderedItems,\n\t\t\t\tprioritizedBlocks\n\t\t\t);\n\t\t}\n\n\t\tconst results = searchBlockItems(\n\t\t\torderedItems,\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypesToShow !== undefined\n\t\t\t? results.slice( 0, maxBlockTypesToShow )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypesToShow,\n\t\tprioritizedBlocks,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + 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}, [\n\t\tfilterValue,\n\t\tdebouncedSpeak,\n\t\tfilteredBlockTypes,\n\t\tfilteredBlockPatterns,\n\t] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\tconst currentShownPatterns = useAsyncList(\n\t\tcurrentShownBlockTypes.length === filteredBlockTypes.length\n\t\t\t? filteredBlockPatterns\n\t\t\t: EMPTY_ARRAY\n\t);\n\n\tconst hasItems =\n\t\tfilteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0;\n\n\tconst blocksUI = !! filteredBlockTypes.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\tisDraggable={ isDraggable }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n\n\tconst patternsUI = !! filteredBlockPatterns.length && (\n\t\t<InserterPanel\n\t\t\ttitle={\n\t\t\t\t<VisuallyHidden>{ __( 'Block Patterns' ) }</VisuallyHidden>\n\t\t\t}\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-patterns\">\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHoverPattern }\n\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</InserterPanel>\n\t);\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }\n\n\t\t\t{ prioritizePatterns ? patternsUI : blocksUI }\n\n\t\t\t{ !! filteredBlockTypes.length &&\n\t\t\t\t!! filteredBlockPatterns.length && (\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t) }\n\n\t\t\t{ prioritizePatterns ? blocksUI : patternsUI }\n\n\t\t\t{ showBlockDirectory && (\n\t\t\t\t<__unstableInserterMenuExtension.Slot\n\t\t\t\t\tfillProps={ {\n\t\t\t\t\t\tonSelect: onSelectBlockType,\n\t\t\t\t\t\tonHover,\n\t\t\t\t\t\tfilterValue,\n\t\t\t\t\t\thasItems,\n\t\t\t\t\t\trootClientId: destinationRootClientId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( fills ) => {\n\t\t\t\t\t\tif ( fills.length ) {\n\t\t\t\t\t\t\treturn fills;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! hasItems ) {\n\t\t\t\t\t\t\treturn <InserterNoResults />;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} }\n\t\t\t\t</__unstableInserterMenuExtension.Slot>\n\t\t\t) }\n\t\t</InserterListbox>\n\t);\n}\n\nexport default InserterSearchResults;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,WAAW,EAAEC,YAAY,QAAQ,oBAAoB;AAC9D,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,+BA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AEZ,QAAQ,EAAG;MACjB,OAAOE,aAAA,CAAC/D,iBAAiB,MAAE,CAAC;IAC7B;IACA,OAAO,IAAI;EACZ,CACqC,CAEvB,CAAC;AAEpB;AAEA,eAAea,qBAAqB"}
|
|
1
|
+
{"version":3,"names":["useMemo","useEffect","__","_n","sprintf","VisuallyHidden","useDebounce","useAsyncList","speak","useSelect","BlockTypesList","BlockPatternsList","__unstableInserterMenuExtension","InserterPanel","InserterNoResults","useInsertionPoint","usePatternsState","useBlockTypesState","searchBlockItems","searchItems","InserterListbox","orderBy","orderInserterBlockItems","store","blockEditorStore","INITIAL_INSERTER_RESULTS","EMPTY_ARRAY","InserterSearchResults","filterValue","onSelect","onHover","onHoverPattern","rootClientId","clientId","isAppender","__experimentalInsertionIndex","maxBlockPatterns","maxBlockTypes","showBlockDirectory","isDraggable","shouldFocusBlock","prioritizePatterns","selectBlockOnInsert","debouncedSpeak","prioritizedBlocks","select","blockListSettings","getBlockListSettings","prioritizedInserterBlocks","destinationRootClientId","onInsertBlocks","insertionIndex","blockTypes","blockTypeCategories","blockTypeCollections","onSelectBlockType","patterns","onClickPattern","filteredBlockPatterns","results","undefined","slice","maxBlockTypesToShow","length","filteredBlockTypes","nonPatternBlockTypes","filter","blockType","name","orderedItems","count","resultsFoundMessage","currentShownBlockTypes","step","currentShownPatterns","hasItems","blocksUI","createElement","title","items","label","patternsUI","className","shownPatterns","blockPatterns","Slot","fillProps","fills"],"sources":["@wordpress/block-editor/src/components/inserter/search-results.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\nimport { orderInserterBlockItems } from '../../utils/order-inserter-block-items';\nimport { store as blockEditorStore } from '../../store';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\tonHoverPattern,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n\tprioritizePatterns,\n\tselectBlockOnInsert,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst { prioritizedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst blockListSettings =\n\t\t\t\tselect( blockEditorStore ).getBlockListSettings( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tprioritizedBlocks:\n\t\t\t\t\tblockListSettings?.prioritizedInserterBlocks || EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t\tselectBlockOnInsert,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( maxBlockPatterns === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\tlet maxBlockTypesToShow = maxBlockTypes;\n\tif ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {\n\t\tmaxBlockTypesToShow = 0;\n\t}\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( maxBlockTypesToShow === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst nonPatternBlockTypes = blockTypes.filter(\n\t\t\t( blockType ) => blockType.name !== 'core/block'\n\t\t);\n\t\tlet orderedItems = orderBy( nonPatternBlockTypes, 'frecency', 'desc' );\n\n\t\tif ( ! filterValue && prioritizedBlocks.length ) {\n\t\t\torderedItems = orderInserterBlockItems(\n\t\t\t\torderedItems,\n\t\t\t\tprioritizedBlocks\n\t\t\t);\n\t\t}\n\n\t\tconst results = searchBlockItems(\n\t\t\torderedItems,\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypesToShow !== undefined\n\t\t\t? results.slice( 0, maxBlockTypesToShow )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypesToShow,\n\t\tprioritizedBlocks,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + 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}, [\n\t\tfilterValue,\n\t\tdebouncedSpeak,\n\t\tfilteredBlockTypes,\n\t\tfilteredBlockPatterns,\n\t] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\tconst currentShownPatterns = useAsyncList(\n\t\tcurrentShownBlockTypes.length === filteredBlockTypes.length\n\t\t\t? filteredBlockPatterns\n\t\t\t: EMPTY_ARRAY\n\t);\n\n\tconst hasItems =\n\t\tfilteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0;\n\n\tconst blocksUI = !! filteredBlockTypes.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\tisDraggable={ isDraggable }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n\n\tconst patternsUI = !! filteredBlockPatterns.length && (\n\t\t<InserterPanel\n\t\t\ttitle={\n\t\t\t\t<VisuallyHidden>{ __( 'Block patterns' ) }</VisuallyHidden>\n\t\t\t}\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-patterns\">\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHoverPattern }\n\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</InserterPanel>\n\t);\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }\n\n\t\t\t{ prioritizePatterns ? patternsUI : blocksUI }\n\n\t\t\t{ !! filteredBlockTypes.length &&\n\t\t\t\t!! filteredBlockPatterns.length && (\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t) }\n\n\t\t\t{ prioritizePatterns ? blocksUI : patternsUI }\n\n\t\t\t{ showBlockDirectory && (\n\t\t\t\t<__unstableInserterMenuExtension.Slot\n\t\t\t\t\tfillProps={ {\n\t\t\t\t\t\tonSelect: onSelectBlockType,\n\t\t\t\t\t\tonHover,\n\t\t\t\t\t\tfilterValue,\n\t\t\t\t\t\thasItems,\n\t\t\t\t\t\trootClientId: destinationRootClientId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( fills ) => {\n\t\t\t\t\t\tif ( fills.length ) {\n\t\t\t\t\t\t\treturn fills;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! hasItems ) {\n\t\t\t\t\t\t\treturn <InserterNoResults />;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} }\n\t\t\t\t</__unstableInserterMenuExtension.Slot>\n\t\t\t) }\n\t\t</InserterListbox>\n\t);\n}\n\nexport default InserterSearchResults;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,WAAW,EAAEC,YAAY,QAAQ,oBAAoB;AAC9D,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,+BAA+B,MAAM,4BAA4B;AACxE,OAAOC,aAAa,MAAM,SAAS;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AiB,MAAE,CAAC;IAC7B;IACA,OAAO,IAAI;EACZ,CACqC,CAEvB,CAAC;AAEpB;AAEA,eAAea,qBAAqB"}
|
|
@@ -29,7 +29,7 @@ const StylesTab = ({
|
|
|
29
29
|
className: "color-block-support-panel__inner-wrapper"
|
|
30
30
|
}), createElement(InspectorControls.Slot, {
|
|
31
31
|
group: "background",
|
|
32
|
-
label: __('Background
|
|
32
|
+
label: __('Background')
|
|
33
33
|
}), createElement(InspectorControls.Slot, {
|
|
34
34
|
group: "filter"
|
|
35
35
|
}), createElement(InspectorControls.Slot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hasBlockSupport","PanelBody","__","BlockStyles","DefaultStylePicker","InspectorControls","StylesTab","blockName","clientId","hasBlockStyles","createElement","Fragment","title","Slot","group","label","className"],"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/styles-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockStyles from '../block-styles';\nimport DefaultStylePicker from '../default-style-picker';\nimport InspectorControls from '../inspector-controls';\n\nconst StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {\n\treturn (\n\t\t<>\n\t\t\t{ hasBlockStyles && (\n\t\t\t\t<div>\n\t\t\t\t\t<PanelBody title={ __( 'Styles' ) }>\n\t\t\t\t\t\t<BlockStyles clientId={ clientId } />\n\t\t\t\t\t\t{ hasBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'defaultStylePicker',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) && <DefaultStylePicker blockName={ blockName } /> }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"background\"\n\t\t\t\tlabel={ __( 'Background
|
|
1
|
+
{"version":3,"names":["hasBlockSupport","PanelBody","__","BlockStyles","DefaultStylePicker","InspectorControls","StylesTab","blockName","clientId","hasBlockStyles","createElement","Fragment","title","Slot","group","label","className"],"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/styles-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockStyles from '../block-styles';\nimport DefaultStylePicker from '../default-style-picker';\nimport InspectorControls from '../inspector-controls';\n\nconst StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {\n\treturn (\n\t\t<>\n\t\t\t{ hasBlockStyles && (\n\t\t\t\t<div>\n\t\t\t\t\t<PanelBody title={ __( 'Styles' ) }>\n\t\t\t\t\t\t<BlockStyles clientId={ clientId } />\n\t\t\t\t\t\t{ hasBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'defaultStylePicker',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) && <DefaultStylePicker blockName={ blockName } /> }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"background\"\n\t\t\t\tlabel={ __( 'Background' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot group=\"filter\" />\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot group=\"border\" label={ __( 'Border' ) } />\n\t\t\t<InspectorControls.Slot group=\"styles\" />\n\t\t</>\n\t);\n};\n\nexport default StylesTab;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,iBAAiB,MAAM,uBAAuB;AAErD,MAAMC,SAAS,GAAGA,CAAE;EAAEC,SAAS;EAAEC,QAAQ;EAAEC;AAAe,CAAC,KAAM;EAChE,OACCC,aAAA,CAAAC,QAAA,QACGF,cAAc,IACfC,aAAA,cACCA,aAAA,CAACT,SAAS;IAACW,KAAK,EAAGV,EAAE,CAAE,QAAS;EAAG,GAClCQ,aAAA,CAACP,WAAW;IAACK,QAAQ,EAAGA;EAAU,CAAE,CAAC,EACnCR,eAAe,CAChBO,SAAS,EACT,oBAAoB,EACpB,IACD,CAAC,IAAIG,aAAA,CAACN,kBAAkB;IAACG,SAAS,EAAGA;EAAW,CAAE,CACxC,CACP,CACL,EACDG,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IACtBC,KAAK,EAAC,OAAO;IACbC,KAAK,EAAGb,EAAE,CAAE,OAAQ,CAAG;IACvBc,SAAS,EAAC;EAA0C,CACpD,CAAC,EACFN,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IACtBC,KAAK,EAAC,YAAY;IAClBC,KAAK,EAAGb,EAAE,CAAE,YAAa;EAAG,CAC5B,CAAC,EACFQ,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IAACC,KAAK,EAAC;EAAQ,CAAE,CAAC,EACzCJ,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IACtBC,KAAK,EAAC,YAAY;IAClBC,KAAK,EAAGb,EAAE,CAAE,YAAa;EAAG,CAC5B,CAAC,EACFQ,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IACtBC,KAAK,EAAC,YAAY;IAClBC,KAAK,EAAGb,EAAE,CAAE,YAAa;EAAG,CAC5B,CAAC,EACFQ,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IAACC,KAAK,EAAC,QAAQ;IAACC,KAAK,EAAGb,EAAE,CAAE,QAAS;EAAG,CAAE,CAAC,EAClEQ,aAAA,CAACL,iBAAiB,CAACQ,IAAI;IAACC,KAAK,EAAC;EAAQ,CAAE,CACvC,CAAC;AAEL,CAAC;AAED,eAAeR,SAAS"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* WordPress dependencies
|
|
4
9
|
*/
|
|
5
10
|
import { isBlobURL } from '@wordpress/blob';
|
|
6
11
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
|
-
import { __experimentalToolsPanelItem as ToolsPanelItem,
|
|
12
|
+
import { __experimentalToolsPanelItem as ToolsPanelItem, DropZone, FlexItem, MenuItem, VisuallyHidden, __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack, __experimentalTruncate as Truncate } from '@wordpress/components';
|
|
8
13
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
14
|
import { Platform, useCallback } from '@wordpress/element';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
15
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
11
16
|
import { store as noticesStore } from '@wordpress/notices';
|
|
12
17
|
import { getFilename } from '@wordpress/url';
|
|
13
18
|
|
|
@@ -16,8 +21,6 @@ import { getFilename } from '@wordpress/url';
|
|
|
16
21
|
*/
|
|
17
22
|
import InspectorControls from '../components/inspector-controls';
|
|
18
23
|
import MediaReplaceFlow from '../components/media-replace-flow';
|
|
19
|
-
import MediaUpload from '../components/media-upload';
|
|
20
|
-
import MediaUploadCheck from '../components/media-upload/check';
|
|
21
24
|
import useSetting from '../components/use-setting';
|
|
22
25
|
import { cleanEmptyObject } from './utils';
|
|
23
26
|
import { store as blockEditorStore } from '../store';
|
|
@@ -85,6 +88,7 @@ export function resetBackgroundImage({
|
|
|
85
88
|
}
|
|
86
89
|
function InspectorImagePreview({
|
|
87
90
|
label,
|
|
91
|
+
filename,
|
|
88
92
|
url: imgUrl
|
|
89
93
|
}) {
|
|
90
94
|
const imgLabel = label || getFilename(imgUrl);
|
|
@@ -93,15 +97,25 @@ function InspectorImagePreview({
|
|
|
93
97
|
}, createElement(HStack, {
|
|
94
98
|
justify: "flex-start",
|
|
95
99
|
as: "span"
|
|
96
|
-
}, createElement("
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
}, createElement("span", {
|
|
101
|
+
className: classnames('block-editor-hooks__background__inspector-image-indicator-wrapper', {
|
|
102
|
+
'has-image': imgUrl
|
|
103
|
+
}),
|
|
104
|
+
"aria-hidden": true
|
|
105
|
+
}, imgUrl && createElement("span", {
|
|
106
|
+
className: "block-editor-hooks__background__inspector-image-indicator",
|
|
107
|
+
style: {
|
|
108
|
+
backgroundImage: `url(${imgUrl})`
|
|
109
|
+
}
|
|
110
|
+
})), createElement(FlexItem, {
|
|
100
111
|
as: "span"
|
|
101
112
|
}, createElement(Truncate, {
|
|
102
113
|
numberOfLines: 1,
|
|
103
114
|
className: "block-editor-hooks__background__inspector-media-replace-title"
|
|
104
|
-
}, imgLabel)
|
|
115
|
+
}, imgLabel), createElement(VisuallyHidden, {
|
|
116
|
+
as: "span"
|
|
117
|
+
}, filename ? sprintf( /* translators: %s: file name */
|
|
118
|
+
__('Selected image: %s'), filename) : __('No image selected')))));
|
|
105
119
|
}
|
|
106
120
|
function BackgroundImagePanelItem(props) {
|
|
107
121
|
const {
|
|
@@ -202,33 +216,24 @@ function BackgroundImagePanelItem(props) {
|
|
|
202
216
|
panelId: clientId
|
|
203
217
|
}, createElement("div", {
|
|
204
218
|
className: "block-editor-hooks__background__inspector-media-replace-container"
|
|
205
|
-
},
|
|
219
|
+
}, createElement(MediaReplaceFlow, {
|
|
206
220
|
mediaId: id,
|
|
207
221
|
mediaURL: url,
|
|
208
222
|
allowedTypes: [IMAGE_BACKGROUND_TYPE],
|
|
209
223
|
accept: "image/*",
|
|
210
224
|
onSelect: onSelectMedia,
|
|
211
225
|
name: createElement(InspectorImagePreview, {
|
|
212
|
-
label:
|
|
226
|
+
label: __('Background image'),
|
|
227
|
+
filename: title,
|
|
213
228
|
url: url
|
|
214
229
|
}),
|
|
215
230
|
variant: "secondary"
|
|
216
231
|
}, createElement(MenuItem, {
|
|
217
232
|
onClick: () => resetBackgroundImage(props)
|
|
218
|
-
}, __('Reset '))),
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
open
|
|
223
|
-
}) => createElement("div", {
|
|
224
|
-
className: "block-editor-hooks__background__inspector-upload-container"
|
|
225
|
-
}, createElement(Button, {
|
|
226
|
-
onClick: open,
|
|
227
|
-
variant: "secondary"
|
|
228
|
-
}, __('Add background image')), createElement(DropZone, {
|
|
229
|
-
onFilesDrop: onFilesDrop
|
|
230
|
-
}))
|
|
231
|
-
}))));
|
|
233
|
+
}, __('Reset '))), createElement(DropZone, {
|
|
234
|
+
onFilesDrop: onFilesDrop,
|
|
235
|
+
label: __('Drop to upload')
|
|
236
|
+
})));
|
|
232
237
|
}
|
|
233
238
|
export function BackgroundImagePanel(props) {
|
|
234
239
|
const isBackgroundImageSupported = useSetting('background.backgroundImage') && hasBackgroundSupport(props.name, 'backgroundImage');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isBlobURL","getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","Button","DropZone","FlexItem","MenuItem","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","__","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","MediaUpload","MediaUploadCheck","useSetting","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","props","hasValue","attributes","style","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","OS","support","resetBackgroundImage","setAttributes","undefined","InspectorImagePreview","label","imgUrl","imgLabel","createElement","as","justify","src","alt","numberOfLines","className","BackgroundImagePanelItem","clientId","title","mediaUpload","select","getSettings","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","isShownByDefault","panelId","mediaId","mediaURL","accept","onSelect","name","variant","onClick","render","open","BackgroundImagePanel","isBackgroundImageSupported","group"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tButton,\n\tDropZone,\n\tFlexItem,\n\tMenuItem,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport MediaUpload from '../components/media-upload';\nimport MediaUploadCheck from '../components/media-upload/check';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( props ) {\n\tconst hasValue =\n\t\t!! props.attributes.style?.background?.backgroundImage?.id ||\n\t\t!! props.attributes.style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! support?.backgroundImage;\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\nfunction InspectorImagePreview( { label, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<img src={ imgUrl } alt=\"\" />\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\n\tconst { id, title, url } =\n\t\tattributes.style?.background?.backgroundImage || {};\n\n\tconst { mediaUpload } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t};\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...attributes.style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...attributes.style,\n\t\t\tbackground: {\n\t\t\t\t...attributes.style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasBackgroundImageValue( props ) }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( props ) }\n\t\t\tisShownByDefault={ true }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div className=\"block-editor-hooks__background__inspector-media-replace-container\">\n\t\t\t\t{ !! url && (\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => resetBackgroundImage( props ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t) }\n\t\t\t\t{ ! url && (\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-hooks__background__inspector-upload-container\">\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Add background image' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onFilesDrop } />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst isBackgroundImageSupported =\n\t\tuseSetting( 'background.backgroundImage' ) &&\n\t\thasBackgroundSupport( props.name, 'backgroundImage' );\n\n\tif ( ! isBackgroundImageSupported ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t{ isBackgroundImageSupported && (\n\t\t\t\t<BackgroundImagePanelItem { ...props } />\n\t\t\t) }\n\t\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,CAAC;AAEnB;AAEA,OAAO,SAASoB,oBAAoBA,CAAE/D,KAAK,EAAG;EAC7C,MAAMgE,0BAA0B,GAC/BtE,UAAU,CAAE,4BAA6B,CAAC,IAC1Cc,oBAAoB,CAAER,KAAK,CAAC0D,IAAI,EAAE,iBAAkB,CAAC;EAEtD,IAAK,CAAEM,0BAA0B,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,OACC5C,aAAA,CAAC9B,iBAAiB;IAAC2E,KAAK,EAAC;EAAY,GAClCD,0BAA0B,IAC3B5C,aAAA,CAACO,wBAAwB;IAAA,GAAM3B;EAAK,CAAI,CAEvB,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","DropZone","FlexItem","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","__","sprintf","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","useSetting","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","props","hasValue","attributes","style","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","OS","support","resetBackgroundImage","setAttributes","undefined","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","title","mediaUpload","select","getSettings","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","isShownByDefault","panelId","mediaId","mediaURL","accept","onSelect","name","variant","onClick","BackgroundImagePanel","isBackgroundImageSupported","group"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tDropZone,\n\tFlexItem,\n\tMenuItem,\n\tVisuallyHidden,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( props ) {\n\tconst hasValue =\n\t\t!! props.attributes.style?.background?.backgroundImage?.id ||\n\t\t!! props.attributes.style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! support?.backgroundImage;\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\nfunction InspectorImagePreview( { label, filename, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-hooks__background__inspector-image-indicator-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-image': imgUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\taria-hidden\n\t\t\t\t>\n\t\t\t\t\t{ imgUrl && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-image-indicator\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackgroundImage: `url(${ imgUrl })`,\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</span>\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ filename\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t\t\t\t\t__( 'Selected image: %s' ),\n\t\t\t\t\t\t\t\t\tfilename\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'No image selected' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\n\tconst { id, title, url } =\n\t\tattributes.style?.background?.backgroundImage || {};\n\n\tconst { mediaUpload } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t};\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...attributes.style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...attributes.style,\n\t\t\tbackground: {\n\t\t\t\t...attributes.style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasBackgroundImageValue( props ) }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( props ) }\n\t\t\tisShownByDefault={ true }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div className=\"block-editor-hooks__background__inspector-media-replace-container\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tname={\n\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t\t\t\t\tfilename={ title }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t>\n\t\t\t\t\t<MenuItem onClick={ () => resetBackgroundImage( props ) }>\n\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tlabel={ __( 'Drop to upload' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst isBackgroundImageSupported =\n\t\tuseSetting( 'background.backgroundImage' ) &&\n\t\thasBackgroundSupport( props.name, 'backgroundImage' );\n\n\tif ( ! isBackgroundImageSupported ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t{ isBackgroundImageSupported && (\n\t\t\t\t<BackgroundImagePanelItem { ...props } />\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,4BAA4B,IAAIC,cAAc,EAC9CC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,uBAAuB,IAAIC,SAAS,EACpCC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,QAAQ,gBAAgB;;AAE5C;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,kCAAkC;AA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mE,GACjFH,aAAA,CAAC5B,gBAAgB;IAChB4D,OAAO,EAAG/C,EAAI;IACdgD,QAAQ,EAAG/C,GAAK;IAChBqC,YAAY,EAAG,CAAE9C,qBAAqB,CAAI;IAC1CyD,MAAM,EAAC,SAAS;IAChBC,QAAQ,EAAGpB,aAAe;IAC1BqB,IAAI,EACHpC,aAAA,CAACL,qBAAqB;MACrBC,KAAK,EAAG9B,EAAE,CAAE,kBAAmB,CAAG;MAClC+B,QAAQ,EAAGU,KAAO;MAClBrB,GAAG,EAAGA;IAAK,CACX,CACD;IACDmD,OAAO,EAAC;EAAW,GAEnBrC,aAAA,CAAC9C,QAAQ;IAACoF,OAAO,EAAGA,CAAA,KAAM9C,oBAAoB,CAAEb,KAAM;EAAG,GACtDb,EAAE,CAAE,QAAS,CACN,CACO,CAAC,EACnBkC,aAAA,CAAChD,QAAQ;IACRqE,WAAW,EAAGA,WAAa;IAC3BzB,KAAK,EAAG9B,EAAE,CAAE,gBAAiB;EAAG,CAChC,CACG,CACU,CAAC;AAEnB;AAEA,OAAO,SAASyE,oBAAoBA,CAAE5D,KAAK,EAAG;EAC7C,MAAM6D,0BAA0B,GAC/BnE,UAAU,CAAE,4BAA6B,CAAC,IAC1Cc,oBAAoB,CAAER,KAAK,CAACyD,IAAI,EAAE,iBAAkB,CAAC;EAEtD,IAAK,CAAEI,0BAA0B,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,OACCxC,aAAA,CAAC7B,iBAAiB;IAACsE,KAAK,EAAC;EAAY,GAClCD,0BAA0B,IAC3BxC,aAAA,CAACK,wBAAwB;IAAA,GAAM1B;EAAK,CAAI,CAEvB,CAAC;AAEtB"}
|
|
@@ -43,7 +43,8 @@ function RenameModal({
|
|
|
43
43
|
overlayClassName: "block-editor-block-rename-modal",
|
|
44
44
|
aria: {
|
|
45
45
|
describedby: dialogDescription
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
|
+
focusOnMount: "firstContentElement"
|
|
47
48
|
}, createElement("p", {
|
|
48
49
|
id: dialogDescription
|
|
49
50
|
}, __('Enter a custom name for this block.')), createElement("form", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","getBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","createElement","title","onRequestClose","overlayClassName","aria","describedby","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControl","BlockEdit","name","attributes","setAttributes","metaDataSupport","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %1$s: type of update (either reset of changed). %2$s: new name/label for the block */\n\t\t\t\t__( 'Block name %1$s to: \"%2$s\".' ),\n\t\t\t\tnameIsOriginal || nameIsEmpty ? __( 'reset' ) : __( 'changed' ),\n\t\t\t\teditedBlockName\n\t\t\t),\n\t\t\t'assertive'\n\t\t);\n\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes } = props;\n\n\t\tconst metaDataSupport = getBlockSupport(\n\t\t\tname,\n\t\t\t'__experimentalMetadata',\n\t\t\tfalse\n\t\t);\n\n\t\tconst supportsBlockNaming = !! (\n\t\t\ttrue === metaDataSupport || metaDataSupport?.name\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...( attributes?.metadata &&\n\t\t\t\t\t\t\t\t\t\t\tattributes?.metadata ),\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,EACNC,WAAW,EACXC,KAAK,QACC,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SACCC,yBAAyB,EACzBC,0BAA0B,EAC1BC,iBAAiB,QACX,eAAe;AAEtB,MAAMC,WAAW,GAAKC,UAAU,IAAMA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AAEtE,SAASC,WAAWA,CAAE;EAAEC,SAAS;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC;AAAO,CAAC,EAAG;EACzE,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAGf,QA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,EAAEI,QAAQ,EAAEL,IAAM;IACzCrB,QAAQ,EAAKiB,OAAO,IAAM;MACzBM,aAAa,CAAE;QACdG,QAAQ,EAAE;UACT,IAAKJ,UAAU,EAAEI,QAAQ,IACxBJ,UAAU,EAAEI,QAAQ,CAAE;UACvBL,IAAI,EAAEJ;QACP;MACD,CAAE,CAAC;IACJ;EAAG,CACH,CACA,CACF,EAEDjC,aAAA,CAACoC,SAAS;IAACO,GAAG,EAAC,MAAM;IAAA,GAAMpB;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAED7D,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChDyE,sBACD,CAAC"}
|
|
1
|
+
{"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","getBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","createElement","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControl","BlockEdit","name","attributes","setAttributes","metaDataSupport","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %1$s: type of update (either reset of changed). %2$s: new name/label for the block */\n\t\t\t\t__( 'Block name %1$s to: \"%2$s\".' ),\n\t\t\t\tnameIsOriginal || nameIsEmpty ? __( 'reset' ) : __( 'changed' ),\n\t\t\t\teditedBlockName\n\t\t\t),\n\t\t\t'assertive'\n\t\t);\n\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes } = props;\n\n\t\tconst metaDataSupport = getBlockSupport(\n\t\t\tname,\n\t\t\t'__experimentalMetadata',\n\t\t\tfalse\n\t\t);\n\n\t\tconst supportsBlockNaming = !! (\n\t\t\ttrue === metaDataSupport || metaDataSupport?.name\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...( attributes?.metadata &&\n\t\t\t\t\t\t\t\t\t\t\tattributes?.metadata ),\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,EACNC,WAAW,EACXC,KAAK,QACC,uBAAuB;AAC9B,SAASC,QAAQ,QAA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IAAEG,QAAQ;IAAEW,IAAI;IAAEC,UAAU;IAAEC;EAAc,CAAC,GAAGhB,KAAK;EAE3D,MAAMiB,eAAe,GAAG5E,eAAe,CACtCyE,IAAI,EACJ,wBAAwB,EACxB,KACD,CAAC;EAED,MAAMI,mBAAmB,GAAG,CAAC,EAC5B,IAAI,KAAKD,eAAe,IAAIA,eAAe,EAAEH,IAAI,CACjD;EAED,OACCtC,aAAA,CAAA8B,QAAA,QACGY,mBAAmB,IACpB1C,aAAA,CAAA8B,QAAA,QACC9B,aAAA,CAACuB,kBAAkB;IAClBI,QAAQ,EAAGA,QAAU;IACrBC,UAAU,EAAGW,UAAU,EAAEI,QAAQ,EAAEL,IAAM;IACzCrB,QAAQ,EAAKiB,OAAO,IAAM;MACzBM,aAAa,CAAE;QACdG,QAAQ,EAAE;UACT,IAAKJ,UAAU,EAAEI,QAAQ,IACxBJ,UAAU,EAAEI,QAAQ,CAAE;UACvBL,IAAI,EAAEJ;QACP;MACD,CAAE,CAAC;IACJ;EAAG,CACH,CACA,CACF,EAEDlC,aAAA,CAACqC,SAAS;IAACO,GAAG,EAAC,MAAM;IAAA,GAAMpB;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAED9D,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChD0E,sBACD,CAAC"}
|
|
@@ -40,11 +40,10 @@ export function getLastInsertedBlocksClientIds(state) {
|
|
|
40
40
|
*/
|
|
41
41
|
export const isBlockSubtreeDisabled = createSelector((state, clientId) => {
|
|
42
42
|
const isChildSubtreeDisabled = childClientId => {
|
|
43
|
-
|
|
44
|
-
return (mode === undefined || mode === 'disabled') && getBlockOrder(state, childClientId).every(isChildSubtreeDisabled);
|
|
43
|
+
return getBlockEditingMode(state, childClientId) === 'disabled' && getBlockOrder(state, childClientId).every(isChildSubtreeDisabled);
|
|
45
44
|
};
|
|
46
45
|
return getBlockEditingMode(state, clientId) === 'disabled' && getBlockOrder(state, clientId).every(isChildSubtreeDisabled);
|
|
47
|
-
}, state => [state.
|
|
46
|
+
}, state => [state.blocks.parents, state.blocks.order, state.blockEditingModes, state.blockListSettings]);
|
|
48
47
|
|
|
49
48
|
/**
|
|
50
49
|
* Returns a tree of block objects with only clientID and innerBlocks set.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSelector","getBlockOrder","getBlockParents","getBlockEditingMode","isBlockInterfaceHidden","state","getLastInsertedBlocksClientIds","lastBlockInserted","clientIds","isBlockSubtreeDisabled","clientId","isChildSubtreeDisabled","childClientId","
|
|
1
|
+
{"version":3,"names":["createSelector","getBlockOrder","getBlockParents","getBlockEditingMode","isBlockInterfaceHidden","state","getLastInsertedBlocksClientIds","lastBlockInserted","clientIds","isBlockSubtreeDisabled","clientId","isChildSubtreeDisabled","childClientId","every","blocks","parents","order","blockEditingModes","blockListSettings","getEnabledClientIdsTree","rootClientId","flatMap","innerBlocks","settings","templateLock","getEnabledBlockParents","ascending","filter","parent","getRemovalPromptData","removalPromptData","getBlockRemovalRules","blockRemovalRules","getOpenedBlockSettingsMenu","openedBlockSettingsMenu","getStyleOverrides","styleOverrides"],"sources":["@wordpress/block-editor/src/store/private-selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockOrder,\n\tgetBlockParents,\n\tgetBlockEditingMode,\n} from './selectors';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\n/**\n * Returns true if the block with the given client ID and all of its descendants\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block and its descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = createSelector(\n\t( state, clientId ) => {\n\t\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\t\treturn (\n\t\t\t\tgetBlockEditingMode( state, childClientId ) === 'disabled' &&\n\t\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\t\tisChildSubtreeDisabled\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, clientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, clientId ).every( isChildSubtreeDisabled )\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blocks.order,\n\t\tstate.blockEditingModes,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getEnabledClientIdsTree = createSelector(\n\t( state, rootClientId = '' ) => {\n\t\treturn getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {\n\t\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tinnerBlocks: getEnabledClientIdsTree( state, clientId ),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn getEnabledClientIdsTree( state, clientId );\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function getBlockRemovalRules( state ) {\n\treturn state.blockRemovalRules;\n}\n\n/**\n * Returns the client ID of the block settings menu that is currently open.\n *\n * @param {Object} state Global application state.\n * @return {string|null} The client ID of the block menu that is currently open.\n */\nexport function getOpenedBlockSettingsMenu( state ) {\n\treturn state.openedBlockSettingsMenu;\n}\n\n/**\n * Returns all style overrides, intended to be merged with global editor styles.\n *\n * @param {Object} state Global application state.\n *\n * @return {Map} A map of style IDs to style overrides.\n */\nexport function getStyleOverrides( state ) {\n\treturn state.styleOverrides;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,QAAQ;;AAEnC;AACA;AACA;AACA,SACCC,aAAa,EACbC,eAAe,EACfC,mBAAmB,QACb,aAAa;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAEC,KAAK,EAAG;EAC/C,OAAOA,KAAK,CAACD,sBAAsB;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,8BAA8BA,CAAED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M,CAACE,KAAK,EAClBX,KAAK,CAACY,iBAAiB,EACvBZ,KAAK,CAACkB,QAAQ,CAACC,YAAY,EAC3BnB,KAAK,CAACa,iBAAiB,CAEzB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,sBAAsB,GAAGzB,cAAc,CACnD,CAAEK,KAAK,EAAEK,QAAQ,EAAEgB,SAAS,GAAG,KAAK,KAAM;EACzC,OAAOxB,eAAe,CAAEG,KAAK,EAAEK,QAAQ,EAAEgB,SAAU,CAAC,CAACC,MAAM,CACxDC,MAAM,IAAMzB,mBAAmB,CAAEE,KAAK,EAAEuB,MAAO,CAAC,KAAK,UACxD,CAAC;AACF,CAAC,EACCvB,KAAK,IAAM,CACZA,KAAK,CAACS,MAAM,CAACC,OAAO,EACpBV,KAAK,CAACY,iBAAiB,EACvBZ,KAAK,CAACkB,QAAQ,CAACC,YAAY,EAC3BnB,KAAK,CAACa,iBAAiB,CAEzB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,oBAAoBA,CAAExB,KAAK,EAAG;EAC7C,OAAOA,KAAK,CAACyB,iBAAiB;AAC/B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAE1B,KAAK,EAAG;EAC7C,OAAOA,KAAK,CAAC2B,iBAAiB;AAC/B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CAAE5B,KAAK,EAAG;EACnD,OAAOA,KAAK,CAAC6B,uBAAuB;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAE9B,KAAK,EAAG;EAC1C,OAAOA,KAAK,CAAC+B,cAAc;AAC5B"}
|
|
@@ -903,20 +903,21 @@
|
|
|
903
903
|
fill: var(--wp-block-synced-color);
|
|
904
904
|
}
|
|
905
905
|
|
|
906
|
-
.block-editor-patterns__grid-pagination {
|
|
906
|
+
.block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination {
|
|
907
907
|
border-top: 1px solid #2f2f2f;
|
|
908
908
|
padding: 4px;
|
|
909
|
+
justify-content: center;
|
|
909
910
|
}
|
|
910
|
-
.block-editor-patterns__grid-pagination .components-button.is-tertiary {
|
|
911
|
+
.block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination .components-button.is-tertiary {
|
|
911
912
|
width: auto;
|
|
912
913
|
height: 32px;
|
|
913
914
|
justify-content: center;
|
|
914
915
|
}
|
|
915
|
-
.block-editor-patterns__grid-pagination .components-button.is-tertiary:disabled {
|
|
916
|
+
.block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination .components-button.is-tertiary:disabled {
|
|
916
917
|
color: #949494;
|
|
917
918
|
background: none;
|
|
918
919
|
}
|
|
919
|
-
.block-editor-patterns__grid-pagination .components-button.is-tertiary:hover:not(:disabled) {
|
|
920
|
+
.block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination .components-button.is-tertiary:hover:not(:disabled) {
|
|
920
921
|
color: #fff;
|
|
921
922
|
background-color: #757575;
|
|
922
923
|
}
|
|
@@ -3199,51 +3200,68 @@
|
|
|
3199
3200
|
flex-direction: row;
|
|
3200
3201
|
}
|
|
3201
3202
|
|
|
3202
|
-
.block-editor-hooks__background__inspector-
|
|
3203
|
+
.block-editor-hooks__background__inspector-media-replace-container {
|
|
3203
3204
|
position: relative;
|
|
3204
3205
|
}
|
|
3205
|
-
.block-editor-hooks__background__inspector-
|
|
3206
|
+
.block-editor-hooks__background__inspector-media-replace-container .components-drop-zone__content-icon {
|
|
3206
3207
|
display: none;
|
|
3207
3208
|
}
|
|
3208
|
-
|
|
3209
|
-
.block-editor-hooks__background__inspector-upload-container button.components-button,
|
|
3210
3209
|
.block-editor-hooks__background__inspector-media-replace-container button.components-button {
|
|
3211
3210
|
color: #1e1e1e;
|
|
3212
|
-
box-shadow: inset 0 0 0 1px #
|
|
3211
|
+
box-shadow: inset 0 0 0 1px #ddd;
|
|
3213
3212
|
width: 100%;
|
|
3214
3213
|
display: block;
|
|
3215
3214
|
height: 40px;
|
|
3216
3215
|
}
|
|
3217
|
-
.block-editor-hooks__background__inspector-upload-container button.components-button:hover,
|
|
3218
3216
|
.block-editor-hooks__background__inspector-media-replace-container button.components-button:hover {
|
|
3219
3217
|
color: var(--wp-admin-theme-color);
|
|
3220
3218
|
}
|
|
3221
|
-
.block-editor-hooks__background__inspector-upload-container button.components-button:focus,
|
|
3222
3219
|
.block-editor-hooks__background__inspector-media-replace-container button.components-button:focus {
|
|
3223
3220
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
3224
3221
|
}
|
|
3225
|
-
.block-editor-hooks__background__inspector-upload-container .block-editor-hooks__background__inspector-media-replace-title,
|
|
3226
3222
|
.block-editor-hooks__background__inspector-media-replace-container .block-editor-hooks__background__inspector-media-replace-title {
|
|
3227
3223
|
word-break: break-all;
|
|
3228
3224
|
white-space: normal;
|
|
3229
3225
|
text-align: start;
|
|
3230
3226
|
text-align-last: center;
|
|
3231
3227
|
}
|
|
3232
|
-
|
|
3233
3228
|
.block-editor-hooks__background__inspector-media-replace-container .components-dropdown {
|
|
3234
3229
|
display: block;
|
|
3235
3230
|
}
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
aspect-ratio: 1;
|
|
3240
|
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
3231
|
+
|
|
3232
|
+
.block-editor-hooks__background__inspector-image-indicator-wrapper {
|
|
3233
|
+
background: #fff linear-gradient(45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
|
|
3241
3234
|
border-radius: 50% !important;
|
|
3235
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
3236
|
+
display: block;
|
|
3237
|
+
width: 20px;
|
|
3238
|
+
height: 20px;
|
|
3239
|
+
flex: none;
|
|
3242
3240
|
}
|
|
3243
|
-
.block-editor-hooks__background__inspector-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3241
|
+
.block-editor-hooks__background__inspector-image-indicator-wrapper.has-image {
|
|
3242
|
+
background: #fff;
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
.block-editor-hooks__background__inspector-image-indicator {
|
|
3246
|
+
background-size: cover;
|
|
3247
|
+
border-radius: 50%;
|
|
3248
|
+
width: 20px;
|
|
3249
|
+
height: 20px;
|
|
3250
|
+
display: block;
|
|
3251
|
+
position: relative;
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
.block-editor-hooks__background__inspector-image-indicator::after {
|
|
3255
|
+
content: "";
|
|
3256
|
+
position: absolute;
|
|
3257
|
+
top: -1px;
|
|
3258
|
+
right: -1px;
|
|
3259
|
+
bottom: -1px;
|
|
3260
|
+
left: -1px;
|
|
3261
|
+
border-radius: 50%;
|
|
3262
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
3263
|
+
border: 1px solid transparent;
|
|
3264
|
+
box-sizing: inherit;
|
|
3247
3265
|
}
|
|
3248
3266
|
|
|
3249
3267
|
.border-block-support-panel .single-column {
|
|
@@ -3833,13 +3851,10 @@
|
|
|
3833
3851
|
border-right: 1px solid #e0e0e0;
|
|
3834
3852
|
border-left: 1px solid #e0e0e0;
|
|
3835
3853
|
position: absolute;
|
|
3836
|
-
padding: 32px 24px;
|
|
3837
3854
|
top: 0;
|
|
3838
3855
|
right: 0;
|
|
3839
3856
|
height: 100%;
|
|
3840
3857
|
width: 100%;
|
|
3841
|
-
overflow-y: auto;
|
|
3842
|
-
scrollbar-gutter: stable both-edges;
|
|
3843
3858
|
}
|
|
3844
3859
|
@media (min-width: 782px) {
|
|
3845
3860
|
.block-editor-inserter__patterns-category-dialog {
|
|
@@ -3849,7 +3864,10 @@
|
|
|
3849
3864
|
}
|
|
3850
3865
|
}
|
|
3851
3866
|
.block-editor-inserter__patterns-category-dialog .block-editor-block-patterns-list {
|
|
3852
|
-
|
|
3867
|
+
overflow-y: auto;
|
|
3868
|
+
flex-grow: 1;
|
|
3869
|
+
height: 100%;
|
|
3870
|
+
padding: 32px 24px;
|
|
3853
3871
|
}
|
|
3854
3872
|
|
|
3855
3873
|
.block-editor-block-patterns-list__list-item .block-editor-block-preview__container {
|
|
@@ -3861,12 +3879,21 @@
|
|
|
3861
3879
|
|
|
3862
3880
|
.block-editor-inserter__patterns-category-panel {
|
|
3863
3881
|
padding: 0 16px;
|
|
3882
|
+
display: flex;
|
|
3883
|
+
flex-direction: column;
|
|
3884
|
+
height: 100%;
|
|
3864
3885
|
}
|
|
3865
3886
|
@media (min-width: 782px) {
|
|
3866
3887
|
.block-editor-inserter__patterns-category-panel {
|
|
3867
3888
|
padding: 0;
|
|
3868
3889
|
}
|
|
3869
3890
|
}
|
|
3891
|
+
.block-editor-inserter__patterns-category-panel .block-editor-inserter__patterns-category-panel-header {
|
|
3892
|
+
padding: 16px 24px;
|
|
3893
|
+
}
|
|
3894
|
+
.block-editor-inserter__patterns-category-panel .block-editor-inserter__patterns-category-no-results {
|
|
3895
|
+
margin-top: 24px;
|
|
3896
|
+
}
|
|
3870
3897
|
|
|
3871
3898
|
.block-editor-inserter__preview-content {
|
|
3872
3899
|
min-height: 144px;
|
|
@@ -3987,6 +4014,7 @@
|
|
|
3987
4014
|
display: grid;
|
|
3988
4015
|
grid-gap: 32px;
|
|
3989
4016
|
grid-template-columns: repeat(1, 1fr);
|
|
4017
|
+
margin-bottom: 16px;
|
|
3990
4018
|
}
|
|
3991
4019
|
@media (min-width: 1080px) {
|
|
3992
4020
|
.block-editor-block-patterns-explorer .block-editor-block-patterns-list {
|