@wordpress/block-editor 14.3.3 → 14.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +42 -0
  2. package/build/components/media-placeholder/index.js +17 -19
  3. package/build/components/media-placeholder/index.js.map +1 -1
  4. package/build/components/rich-text/index.js +4 -8
  5. package/build/components/rich-text/index.js.map +1 -1
  6. package/build/hooks/block-bindings.js +6 -13
  7. package/build/hooks/block-bindings.js.map +1 -1
  8. package/build/hooks/use-bindings-attributes.js +5 -4
  9. package/build/hooks/use-bindings-attributes.js.map +1 -1
  10. package/build/private-apis.js +0 -2
  11. package/build/private-apis.js.map +1 -1
  12. package/build/utils/block-bindings.js +48 -0
  13. package/build/utils/block-bindings.js.map +1 -1
  14. package/build/utils/index.js +7 -0
  15. package/build/utils/index.js.map +1 -1
  16. package/build-module/components/media-placeholder/index.js +18 -20
  17. package/build-module/components/media-placeholder/index.js.map +1 -1
  18. package/build-module/components/rich-text/index.js +4 -8
  19. package/build-module/components/rich-text/index.js.map +1 -1
  20. package/build-module/hooks/block-bindings.js +6 -13
  21. package/build-module/hooks/block-bindings.js.map +1 -1
  22. package/build-module/hooks/use-bindings-attributes.js +5 -4
  23. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  24. package/build-module/private-apis.js +0 -2
  25. package/build-module/private-apis.js.map +1 -1
  26. package/build-module/utils/block-bindings.js +48 -0
  27. package/build-module/utils/block-bindings.js.map +1 -1
  28. package/build-module/utils/index.js +1 -0
  29. package/build-module/utils/index.js.map +1 -1
  30. package/build-style/content-rtl.css +2 -14
  31. package/build-style/content.css +2 -14
  32. package/package.json +6 -6
  33. package/src/components/media-placeholder/content.scss +3 -19
  34. package/src/components/media-placeholder/index.js +17 -17
  35. package/src/components/rich-text/index.js +4 -13
  36. package/src/hooks/block-bindings.js +9 -10
  37. package/src/hooks/use-bindings-attributes.js +66 -63
  38. package/src/private-apis.js +0 -2
  39. package/src/utils/block-bindings.js +47 -0
  40. package/src/utils/index.js +1 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_blocks","_components","_data","_element","_compose","_useBindingsAttributes","_lockUnlock","_inspectorControls","_interopRequireDefault","_blockContext","_blockBindings","_store","_jsxRuntime","DropdownMenuV2","unlock","componentsPrivateApis","EMPTY_OBJECT","useToolsPanelDropdownMenuProps","isMobile","useViewportMatch","popoverProps","placement","offset","BlockBindingsPanelDropdown","fieldsList","attribute","binding","getBlockBindingsSources","blocksPrivateApis","registeredSources","updateBlockBindings","useBlockBindingsUtils","currentKey","args","key","jsx","Fragment","children","Object","entries","map","name","fields","i","jsxs","Group","keys","length","GroupLabel","label","RadioItem","onChange","source","value","checked","ItemLabel","ItemHelpText","Separator","BlockBindingsAttribute","sourceName","sourceProps","getBlockBindingsSource","isSourceInvalid","__experimentalVStack","className","spacing","__experimentalText","truncate","variant","isDestructive","__","ReadOnlyBlockBindingsPanelItems","bindings","__experimentalItem","EditableBlockBindingsPanelItems","attributes","__experimentalToolsPanelItem","hasValue","onDeselect","undefined","gutter","trigger","BlockBindingsPanel","blockName","metadata","registry","useRegistry","blockContext","useContext","BlockContext","removeAllBlockBindings","bindableAttributes","getBindableAttributes","dropdownMenuProps","_fieldsList","canUpdateBlockBindings","useSelect","select","forEach","getFieldsList","usesContext","context","sourceList","values","blockEditorStore","getSettings","filteredBindings","canBindAttribute","readOnly","default","group","__experimentalToolsPanel","resetAll","__experimentalItemGroup","isBordered","isSeparated","exports","_default","edit","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalText as Text,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useContext, Fragment } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcanBindAttribute,\n\tgetBindableAttributes,\n} from '../hooks/use-bindings-attributes';\nimport { unlock } from '../lock-unlock';\nimport InspectorControls from '../components/inspector-controls';\nimport BlockContext from '../components/block-context';\nimport { useBlockBindingsUtils } from '../utils/block-bindings';\nimport { store as blockEditorStore } from '../store';\n\nconst { DropdownMenuV2 } = unlock( componentsPrivateApis );\n\nconst EMPTY_OBJECT = {};\n\nconst useToolsPanelDropdownMenuProps = () => {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n};\n\nfunction BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {\n\tconst { getBlockBindingsSources } = unlock( blocksPrivateApis );\n\tconst registeredSources = getBlockBindingsSources();\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst currentKey = binding?.args?.key;\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( fieldsList ).map( ( [ name, fields ], i ) => (\n\t\t\t\t<Fragment key={ name }>\n\t\t\t\t\t<DropdownMenuV2.Group>\n\t\t\t\t\t\t{ Object.keys( fieldsList ).length > 1 && (\n\t\t\t\t\t\t\t<DropdownMenuV2.GroupLabel>\n\t\t\t\t\t\t\t\t{ registeredSources[ name ].label }\n\t\t\t\t\t\t\t</DropdownMenuV2.GroupLabel>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ Object.entries( fields ).map( ( [ key, args ] ) => (\n\t\t\t\t\t\t\t<DropdownMenuV2.RadioItem\n\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t[ attribute ]: {\n\t\t\t\t\t\t\t\t\t\t\tsource: name,\n\t\t\t\t\t\t\t\t\t\t\targs: { key },\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tname={ attribute + '-binding' }\n\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\tchecked={ key === currentKey }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<DropdownMenuV2.ItemLabel>\n\t\t\t\t\t\t\t\t\t{ args?.label }\n\t\t\t\t\t\t\t\t</DropdownMenuV2.ItemLabel>\n\t\t\t\t\t\t\t\t<DropdownMenuV2.ItemHelpText>\n\t\t\t\t\t\t\t\t\t{ args?.value }\n\t\t\t\t\t\t\t\t</DropdownMenuV2.ItemHelpText>\n\t\t\t\t\t\t\t</DropdownMenuV2.RadioItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</DropdownMenuV2.Group>\n\t\t\t\t\t{ i !== Object.keys( fieldsList ).length - 1 && (\n\t\t\t\t\t\t<DropdownMenuV2.Separator />\n\t\t\t\t\t) }\n\t\t\t\t</Fragment>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction BlockBindingsAttribute( { attribute, binding, fieldsList } ) {\n\tconst { source: sourceName, args } = binding || {};\n\tconst sourceProps =\n\t\tunlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );\n\tconst isSourceInvalid = ! sourceProps;\n\treturn (\n\t\t<VStack className=\"block-editor-bindings__item\" spacing={ 0 }>\n\t\t\t<Text truncate>{ attribute }</Text>\n\t\t\t{ !! binding && (\n\t\t\t\t<Text\n\t\t\t\t\ttruncate\n\t\t\t\t\tvariant={ ! isSourceInvalid && 'muted' }\n\t\t\t\t\tisDestructive={ isSourceInvalid }\n\t\t\t\t>\n\t\t\t\t\t{ isSourceInvalid\n\t\t\t\t\t\t? __( 'Invalid source' )\n\t\t\t\t\t\t: fieldsList?.[ sourceName ]?.[ args?.key ]?.label ||\n\t\t\t\t\t\t sourceProps?.label ||\n\t\t\t\t\t\t sourceName }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nfunction ReadOnlyBlockBindingsPanelItems( { bindings, fieldsList } ) {\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( bindings ).map( ( [ attribute, binding ] ) => (\n\t\t\t\t<Item key={ attribute }>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t/>\n\t\t\t\t</Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction EditableBlockBindingsPanelItems( {\n\tattributes,\n\tbindings,\n\tfieldsList,\n} ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ attributes.map( ( attribute ) => {\n\t\t\t\tconst binding = bindings[ attribute ];\n\t\t\t\treturn (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\thasValue={ () => !! binding }\n\t\t\t\t\t\tlabel={ attribute }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DropdownMenuV2\n\t\t\t\t\t\t\tplacement={\n\t\t\t\t\t\t\t\tisMobile ? 'bottom-start' : 'left-start'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgutter={ isMobile ? 8 : 36 }\n\t\t\t\t\t\t\ttrigger={\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockBindingsPanelDropdown\n\t\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</DropdownMenuV2>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport const BlockBindingsPanel = ( { name: blockName, metadata } ) => {\n\tconst registry = useRegistry();\n\tconst blockContext = useContext( BlockContext );\n\tconst { removeAllBlockBindings } = useBlockBindingsUtils();\n\tconst bindableAttributes = getBindableAttributes( blockName );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// `useSelect` is used purposely here to ensure `getFieldsList`\n\t// is updated whenever there are updates in block context.\n\t// `source.getFieldsList` may also call a selector via `registry.select`.\n\tconst _fieldsList = {};\n\tconst { fieldsList, canUpdateBlockBindings } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\t\t\tconst { getBlockBindingsSources } = unlock( blocksPrivateApis );\n\t\t\tconst registeredSources = getBlockBindingsSources();\n\t\t\tObject.entries( registeredSources ).forEach(\n\t\t\t\t( [ sourceName, { getFieldsList, usesContext } ] ) => {\n\t\t\t\t\tif ( getFieldsList ) {\n\t\t\t\t\t\t// Populate context.\n\t\t\t\t\t\tconst context = {};\n\t\t\t\t\t\tif ( usesContext?.length ) {\n\t\t\t\t\t\t\tfor ( const key of usesContext ) {\n\t\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst sourceList = getFieldsList( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\t// Only add source if the list is not empty.\n\t\t\t\t\t\tif ( Object.keys( sourceList || {} ).length ) {\n\t\t\t\t\t\t\t_fieldsList[ sourceName ] = { ...sourceList };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tfieldsList:\n\t\t\t\t\tObject.values( _fieldsList ).length > 0\n\t\t\t\t\t\t? _fieldsList\n\t\t\t\t\t\t: EMPTY_OBJECT,\n\t\t\t\tcanUpdateBlockBindings:\n\t\t\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t\t\t.canUpdateBlockBindings,\n\t\t\t};\n\t\t},\n\t\t[ blockContext, bindableAttributes, registry ]\n\t);\n\t// Return early if there are no bindable attributes.\n\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\treturn null;\n\t}\n\t// Filter bindings to only show bindable attributes and remove pattern overrides.\n\tconst { bindings } = metadata || {};\n\tconst filteredBindings = { ...bindings };\n\tObject.keys( filteredBindings ).forEach( ( key ) => {\n\t\tif (\n\t\t\t! canBindAttribute( blockName, key ) ||\n\t\t\tfilteredBindings[ key ].source === 'core/pattern-overrides'\n\t\t) {\n\t\t\tdelete filteredBindings[ key ];\n\t\t}\n\t} );\n\n\t// Lock the UI when the user can't update bindings or there are no fields to connect to.\n\tconst readOnly =\n\t\t! canUpdateBlockBindings || ! Object.keys( fieldsList ).length;\n\n\tif ( readOnly && Object.keys( filteredBindings ).length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"bindings\">\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Attributes' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tremoveAllBlockBindings();\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\tclassName=\"block-editor-bindings__panel\"\n\t\t\t>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t{ readOnly ? (\n\t\t\t\t\t\t<ReadOnlyBlockBindingsPanelItems\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<EditableBlockBindingsPanelItems\n\t\t\t\t\t\t\tattributes={ bindableAttributes }\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ItemGroup>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Attributes connected to custom fields or other dynamic data.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t</ItemGroup>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default {\n\tedit: BlockBindingsPanel,\n\tattributeKeys: [ 'metadata' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AAIA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,G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AAC,CACI;MAAC,CACG,CAAC;IAAA,CACD;EAAC,CACK,CAAC;AAEtB,CAAC;AAAC8C,OAAA,CAAAlC,kBAAA,GAAAA,kBAAA;AAAA,IAAAmC,QAAA,GAAAD,OAAA,CAAAP,OAAA,GAEa;EACdS,IAAI,EAAEpC,kBAAkB;EACxBqC,aAAa,EAAE,CAAE,UAAU,CAAE;EAC7BC,UAAUA,CAAA,EAAG;IACZ,OAAO,IAAI;EACZ;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_blocks","_components","_data","_element","_compose","_useBindingsAttributes","_lockUnlock","_inspectorControls","_interopRequireDefault","_blockContext","_blockBindings","_store","_jsxRuntime","DropdownMenuV2","unlock","componentsPrivateApis","EMPTY_OBJECT","useToolsPanelDropdownMenuProps","isMobile","useViewportMatch","popoverProps","placement","offset","BlockBindingsPanelDropdown","fieldsList","attribute","binding","registeredSources","getBlockBindingsSources","updateBlockBindings","useBlockBindingsUtils","currentKey","args","key","jsx","Fragment","children","Object","entries","map","name","fields","i","jsxs","Group","keys","length","GroupLabel","label","RadioItem","onChange","source","value","checked","ItemLabel","ItemHelpText","Separator","BlockBindingsAttribute","sourceName","sourceProps","getBlockBindingsSource","isSourceInvalid","__experimentalVStack","className","spacing","__experimentalText","truncate","variant","isDestructive","__","ReadOnlyBlockBindingsPanelItems","bindings","__experimentalItem","EditableBlockBindingsPanelItems","attributes","__experimentalToolsPanelItem","hasValue","onDeselect","undefined","gutter","trigger","BlockBindingsPanel","blockName","metadata","blockContext","useContext","BlockContext","removeAllBlockBindings","bindableAttributes","getBindableAttributes","dropdownMenuProps","_fieldsList","canUpdateBlockBindings","useSelect","select","forEach","getFieldsList","usesContext","context","sourceList","values","blockEditorStore","getSettings","filteredBindings","canBindAttribute","readOnly","default","group","__experimentalToolsPanel","resetAll","__experimentalItemGroup","isBordered","isSeparated","exports","_default","edit","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tgetBlockBindingsSource,\n\tgetBlockBindingsSources,\n} from '@wordpress/blocks';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalText as Text,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, Fragment } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcanBindAttribute,\n\tgetBindableAttributes,\n} from '../hooks/use-bindings-attributes';\nimport { unlock } from '../lock-unlock';\nimport InspectorControls from '../components/inspector-controls';\nimport BlockContext from '../components/block-context';\nimport { useBlockBindingsUtils } from '../utils/block-bindings';\nimport { store as blockEditorStore } from '../store';\n\nconst { DropdownMenuV2 } = unlock( componentsPrivateApis );\n\nconst EMPTY_OBJECT = {};\n\nconst useToolsPanelDropdownMenuProps = () => {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n};\n\nfunction BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {\n\tconst registeredSources = getBlockBindingsSources();\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst currentKey = binding?.args?.key;\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( fieldsList ).map( ( [ name, fields ], i ) => (\n\t\t\t\t<Fragment key={ name }>\n\t\t\t\t\t<DropdownMenuV2.Group>\n\t\t\t\t\t\t{ Object.keys( fieldsList ).length > 1 && (\n\t\t\t\t\t\t\t<DropdownMenuV2.GroupLabel>\n\t\t\t\t\t\t\t\t{ registeredSources[ name ].label }\n\t\t\t\t\t\t\t</DropdownMenuV2.GroupLabel>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ Object.entries( fields ).map( ( [ key, args ] ) => (\n\t\t\t\t\t\t\t<DropdownMenuV2.RadioItem\n\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t[ attribute ]: {\n\t\t\t\t\t\t\t\t\t\t\tsource: name,\n\t\t\t\t\t\t\t\t\t\t\targs: { key },\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tname={ attribute + '-binding' }\n\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\tchecked={ key === currentKey }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<DropdownMenuV2.ItemLabel>\n\t\t\t\t\t\t\t\t\t{ args?.label }\n\t\t\t\t\t\t\t\t</DropdownMenuV2.ItemLabel>\n\t\t\t\t\t\t\t\t<DropdownMenuV2.ItemHelpText>\n\t\t\t\t\t\t\t\t\t{ args?.value }\n\t\t\t\t\t\t\t\t</DropdownMenuV2.ItemHelpText>\n\t\t\t\t\t\t\t</DropdownMenuV2.RadioItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</DropdownMenuV2.Group>\n\t\t\t\t\t{ i !== Object.keys( fieldsList ).length - 1 && (\n\t\t\t\t\t\t<DropdownMenuV2.Separator />\n\t\t\t\t\t) }\n\t\t\t\t</Fragment>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction BlockBindingsAttribute( { attribute, binding, fieldsList } ) {\n\tconst { source: sourceName, args } = binding || {};\n\tconst sourceProps = getBlockBindingsSource( sourceName );\n\tconst isSourceInvalid = ! sourceProps;\n\treturn (\n\t\t<VStack className=\"block-editor-bindings__item\" spacing={ 0 }>\n\t\t\t<Text truncate>{ attribute }</Text>\n\t\t\t{ !! binding && (\n\t\t\t\t<Text\n\t\t\t\t\ttruncate\n\t\t\t\t\tvariant={ ! isSourceInvalid && 'muted' }\n\t\t\t\t\tisDestructive={ isSourceInvalid }\n\t\t\t\t>\n\t\t\t\t\t{ isSourceInvalid\n\t\t\t\t\t\t? __( 'Invalid source' )\n\t\t\t\t\t\t: fieldsList?.[ sourceName ]?.[ args?.key ]?.label ||\n\t\t\t\t\t\t sourceProps?.label ||\n\t\t\t\t\t\t sourceName }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nfunction ReadOnlyBlockBindingsPanelItems( { bindings, fieldsList } ) {\n\treturn (\n\t\t<>\n\t\t\t{ Object.entries( bindings ).map( ( [ attribute, binding ] ) => (\n\t\t\t\t<Item key={ attribute }>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t/>\n\t\t\t\t</Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction EditableBlockBindingsPanelItems( {\n\tattributes,\n\tbindings,\n\tfieldsList,\n} ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ attributes.map( ( attribute ) => {\n\t\t\t\tconst binding = bindings[ attribute ];\n\t\t\t\treturn (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\thasValue={ () => !! binding }\n\t\t\t\t\t\tlabel={ attribute }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DropdownMenuV2\n\t\t\t\t\t\t\tplacement={\n\t\t\t\t\t\t\t\tisMobile ? 'bottom-start' : 'left-start'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgutter={ isMobile ? 8 : 36 }\n\t\t\t\t\t\t\ttrigger={\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockBindingsPanelDropdown\n\t\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</DropdownMenuV2>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport const BlockBindingsPanel = ( { name: blockName, metadata } ) => {\n\tconst blockContext = useContext( BlockContext );\n\tconst { removeAllBlockBindings } = useBlockBindingsUtils();\n\tconst bindableAttributes = getBindableAttributes( blockName );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// `useSelect` is used purposely here to ensure `getFieldsList`\n\t// is updated whenever there are updates in block context.\n\t// `source.getFieldsList` may also call a selector via `select`.\n\tconst _fieldsList = {};\n\tconst { fieldsList, canUpdateBlockBindings } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\t\t\tconst registeredSources = getBlockBindingsSources();\n\t\t\tObject.entries( registeredSources ).forEach(\n\t\t\t\t( [ sourceName, { getFieldsList, usesContext } ] ) => {\n\t\t\t\t\tif ( getFieldsList ) {\n\t\t\t\t\t\t// Populate context.\n\t\t\t\t\t\tconst context = {};\n\t\t\t\t\t\tif ( usesContext?.length ) {\n\t\t\t\t\t\t\tfor ( const key of usesContext ) {\n\t\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst sourceList = getFieldsList( {\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\t// Only add source if the list is not empty.\n\t\t\t\t\t\tif ( Object.keys( sourceList || {} ).length ) {\n\t\t\t\t\t\t\t_fieldsList[ sourceName ] = { ...sourceList };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tfieldsList:\n\t\t\t\t\tObject.values( _fieldsList ).length > 0\n\t\t\t\t\t\t? _fieldsList\n\t\t\t\t\t\t: EMPTY_OBJECT,\n\t\t\t\tcanUpdateBlockBindings:\n\t\t\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t\t\t.canUpdateBlockBindings,\n\t\t\t};\n\t\t},\n\t\t[ blockContext, bindableAttributes ]\n\t);\n\t// Return early if there are no bindable attributes.\n\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\treturn null;\n\t}\n\t// Filter bindings to only show bindable attributes and remove pattern overrides.\n\tconst { bindings } = metadata || {};\n\tconst filteredBindings = { ...bindings };\n\tObject.keys( filteredBindings ).forEach( ( key ) => {\n\t\tif (\n\t\t\t! canBindAttribute( blockName, key ) ||\n\t\t\tfilteredBindings[ key ].source === 'core/pattern-overrides'\n\t\t) {\n\t\t\tdelete filteredBindings[ key ];\n\t\t}\n\t} );\n\n\t// Lock the UI when the user can't update bindings or there are no fields to connect to.\n\tconst readOnly =\n\t\t! canUpdateBlockBindings || ! Object.keys( fieldsList ).length;\n\n\tif ( readOnly && Object.keys( filteredBindings ).length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"bindings\">\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Attributes' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tremoveAllBlockBindings();\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\tclassName=\"block-editor-bindings__panel\"\n\t\t\t>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t{ readOnly ? (\n\t\t\t\t\t\t<ReadOnlyBlockBindingsPanelItems\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<EditableBlockBindingsPanelItems\n\t\t\t\t\t\t\tattributes={ bindableAttributes }\n\t\t\t\t\t\t\tbindings={ filteredBindings }\n\t\t\t\t\t\t\tfieldsList={ fieldsList }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ItemGroup>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Attributes connected to custom fields or other dynamic data.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t</ItemGroup>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default {\n\tedit: BlockBindingsPanel,\n\tattributeKeys: [ 'metadata' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAIA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAA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OAAA,CAAAP,OAAA,GAEa;EACdS,IAAI,EAAElC,kBAAkB;EACxBmC,aAAa,EAAE,CAAE,UAAU,CAAE;EAC7BC,UAAUA,CAAA,EAAG;IACZ,OAAO,IAAI;EACZ;AACD,CAAC","ignoreList":[]}
@@ -112,7 +112,7 @@ const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.c
112
112
  // there are attribute updates.
113
113
  // `source.getValues` may also call a selector via `registry.select`.
114
114
  const updatedContext = {};
115
- const boundAttributes = (0, _data.useSelect)(() => {
115
+ const boundAttributes = (0, _data.useSelect)(select => {
116
116
  if (!blockBindings) {
117
117
  return;
118
118
  }
@@ -150,7 +150,7 @@ const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.c
150
150
  });
151
151
  } else {
152
152
  values = source.getValues({
153
- registry,
153
+ select,
154
154
  context: updatedContext,
155
155
  clientId,
156
156
  bindings
@@ -167,7 +167,7 @@ const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.c
167
167
  }
168
168
  }
169
169
  return attributes;
170
- }, [blockBindings, name, clientId, updatedContext, registry, sources]);
170
+ }, [blockBindings, name, clientId, updatedContext, sources]);
171
171
  const hasParentPattern = !!updatedContext['pattern/overrides'];
172
172
  const hasPatternOverridesDefaultBinding = props.attributes.metadata?.bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides';
173
173
  const _setAttributes = (0, _element.useCallback)(nextAttributes => {
@@ -203,7 +203,8 @@ const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.c
203
203
  if (blockBindingsBySource.size) {
204
204
  for (const [source, bindings] of blockBindingsBySource) {
205
205
  source.setValues({
206
- registry,
206
+ select: registry.select,
207
+ dispatch: registry.dispatch,
207
208
  context: updatedContext,
208
209
  clientId,
209
210
  bindings
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_isUrlLike","_interopRequireDefault","_lockUnlock","_blockContext","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","getBindableAttributes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","blockContext","useContext","BlockContext","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","context","setAttributes","blockBindings","useMemo","attributes","metadata","updatedContext","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","key","usesContext","set","get","size","values","getValues","keys","forEach","attr","label","value","isURLLike","hasParentPattern","hasPatternOverridesDefaultBinding","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","newValue","setValues","length","caption","href","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from '../components/link-control/is-url-like';\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId, context, setAttributes } = props;\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst updatedContext = {};\n\t\tconst boundAttributes = useSelect( () => {\n\t\t\tif ( ! blockBindings ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst attributes = {};\n\n\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\tblockBindings\n\t\t\t) ) {\n\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\tif ( ! source || ! canBindAttribute( name, attributeName ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Populate context.\n\t\t\t\tfor ( const key of source.usesContext || [] ) {\n\t\t\t\t\tupdatedContext[ key ] = blockContext[ key ];\n\t\t\t\t}\n\n\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\tfor ( const [ source, bindings ] of blockBindingsBySource ) {\n\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\tlet values = {};\n\t\t\t\t\tif ( ! source.getValues ) {\n\t\t\t\t\t\tObject.keys( bindings ).forEach( ( attr ) => {\n\t\t\t\t\t\t\t// Default to the the source label when `getValues` doesn't exist.\n\t\t\t\t\t\t\tvalues[ attr ] = source.label;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalues = source.getValues( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\tvalues\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tattributeName === 'url' &&\n\t\t\t\t\t\t\t( ! value || ! isURLLike( value ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Return null if value is not a valid URL.\n\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tattributes[ attributeName ] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn attributes;\n\t\t}, [\n\t\t\tblockBindings,\n\t\t\tname,\n\t\t\tclientId,\n\t\t\tupdatedContext,\n\t\t\tregistry,\n\t\t\tsources,\n\t\t] );\n\n\t\tconst hasParentPattern = !! updatedContext[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tupdatedContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t\tcontext={ { ...context, ...updatedContext } }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim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AA,CAAA2E,QAAA;IAAAC,QAAA,eACC,IAAA5E,WAAA,CAAA0E,GAAA,EAACxD,SAAS;MAAA,GACJC,KAAK;MACVkB,UAAU,EAAG;QAAE,GAAGlB,KAAK,CAACkB,UAAU;QAAE,GAAGG;MAAgB,CAAG;MAC1DN,aAAa,EAAG8B,cAAgB;MAChC/B,OAAO,EAAG;QAAE,GAAGA,OAAO;QAAE,GAAGM;MAAe;IAAG,CAC7C;EAAC,CACD,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASsC,mBAAmBA,CAAEC,QAAQ,EAAE/C,IAAI,EAAG;EAC9C,IAAK,CAAEpB,YAAY,CAAEoB,IAAK,CAAC,EAAG;IAC7B,OAAO+C,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAEhE,uBAAuB,CAAE+D,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEA,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_isUrlLike","_interopRequireDefault","_lockUnlock","_blockContext","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","getBindableAttributes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","blockContext","useContext","BlockContext","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","context","setAttributes","blockBindings","useMemo","attributes","metadata","updatedContext","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","key","usesContext","set","get","size","values","getValues","keys","forEach","attr","label","value","isURLLike","hasParentPattern","hasPatternOverridesDefaultBinding","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","newValue","setValues","dispatch","length","caption","href","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from '../components/link-control/is-url-like';\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId, context, setAttributes } = props;\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst updatedContext = {};\n\t\tconst boundAttributes = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst attributes = {};\n\n\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\t\tblockBindings\n\t\t\t\t) ) {\n\t\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\t\tif (\n\t\t\t\t\t\t! source ||\n\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tfor ( const key of source.usesContext || [] ) {\n\t\t\t\t\t\tupdatedContext[ key ] = blockContext[ key ];\n\t\t\t\t\t}\n\n\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\tfor ( const [\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tbindings,\n\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\t\tlet values = {};\n\t\t\t\t\t\tif ( ! source.getValues ) {\n\t\t\t\t\t\t\tObject.keys( bindings ).forEach( ( attr ) => {\n\t\t\t\t\t\t\t\t// Default to the the source label when `getValues` doesn't exist.\n\t\t\t\t\t\t\t\tvalues[ attr ] = source.label;\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalues = source.getValues( {\n\t\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\t\tvalues\n\t\t\t\t\t\t) ) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tattributeName === 'url' &&\n\t\t\t\t\t\t\t\t( ! value || ! isURLLike( value ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// Return null if value is not a valid URL.\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn attributes;\n\t\t\t},\n\t\t\t[ blockBindings, name, clientId, updatedContext, sources ]\n\t\t);\n\n\t\tconst hasParentPattern = !! updatedContext[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tselect: registry.select,\n\t\t\t\t\t\t\t\tdispatch: registry.dispatch,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tupdatedContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t\tcontext={ { ...context, ...updatedContext } }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,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KAAK,CAACkB,UAAU;QAAE,GAAGG;MAAgB,CAAG;MAC1DN,aAAa,EAAG8B,cAAgB;MAChC/B,OAAO,EAAG;QAAE,GAAGA,OAAO;QAAE,GAAGM;MAAe;IAAG,CAC7C;EAAC,CACD,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASuC,mBAAmBA,CAAEC,QAAQ,EAAEhD,IAAI,EAAG;EAC9C,IAAK,CAAEpB,YAAY,CAAEoB,IAAK,CAAC,EAAG;IAC7B,OAAOgD,QAAQ;EAChB;EAEA,OAAO;IACN,GAAGA,QAAQ;IACXC,IAAI,EAAEjE,uBAAuB,CAAEgE,QAAQ,CAACC,IAAK;EAC9C,CAAC;AACF;AAEA,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EH,mBACD,CAAC","ignoreList":[]}
@@ -36,7 +36,6 @@ var _publishDateTimePicker = require("./components/publish-date-time-picker");
36
36
  var _useSpacingSizes = _interopRequireDefault(require("./components/spacing-sizes-control/hooks/use-spacing-sizes"));
37
37
  var _useBlockDisplayTitle = _interopRequireDefault(require("./components/block-title/use-block-display-title"));
38
38
  var _tabbedSidebar = _interopRequireDefault(require("./components/tabbed-sidebar"));
39
- var _blockBindings = require("./utils/block-bindings");
40
39
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
41
40
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
42
41
  /**
@@ -86,7 +85,6 @@ const privateApis = exports.privateApis = {};
86
85
  useBlockDisplayTitle: _useBlockDisplayTitle.default,
87
86
  __unstableBlockStyleVariationOverridesWithConfig: _hooks.__unstableBlockStyleVariationOverridesWithConfig,
88
87
  setBackgroundStyleDefaults: _hooks.setBackgroundStyleDefaults,
89
- useBlockBindingsUtils: _blockBindings.useBlockBindingsUtils,
90
88
  sectionRootClientIdKey: _privateKeys.sectionRootClientIdKey
91
89
  });
92
90
  //# sourceMappingURL=private-apis.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["globalStyles","_interopRequireWildcard","require","_provider","_lockUnlock","_getRichTextValues","_resizableBoxPopover","_interopRequireDefault","_quickInserter","_searchItems","_listView","_blockInfoSlotFill","_useHasBlockToolbar","_utils","_blockQuickNavigation","_layout","_blockRemovalWarningModal","_hooks","_dimensionsTool","_resolutionTool","_textAlignmentControl","_formatEdit","_blockCanvas","_utils2","_useFlashEditableBlocks","_privateKeys","_utils3","_richText","_blockPopover","_library","_publishDateTimePicker","_useSpacingSizes","_useBlockDisplayTitle","_tabbedSidebar","_blockBindings","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","privateApis","exports","lock","ExperimentalBlockCanvas","ExperimentalBlockEditorProvider","getDuotoneFilter","getRichTextValues","PrivateQuickInserter","extractWords","getNormalizedSearchTerms","normalizeString","PrivateListView","ResizableBoxPopover","BlockInfo","useHasBlockToolbar","cleanEmptyObject","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","TabbedSidebar","TextAlignmentControl","usesContextKey","useFlashEditableBlocks","globalStylesDataKey","globalStylesLinksDataKey","selectBlockPatternsKey","requiresWrapperOnCopy","PrivateRichText","PrivateInserterLibrary","reusableBlocksSelectKey","PrivateBlockPopover","PrivatePublishDateTimePicker","useSpacingSizes","useBlockDisplayTitle","__unstableBlockStyleVariationOverridesWithConfig","setBackgroundStyleDefaults","useBlockBindingsUtils","sectionRootClientIdKey"],"sources":["@wordpress/block-editor/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport * as globalStyles from './components/global-styles';\nimport { ExperimentalBlockEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { getRichTextValues } from './components/rich-text/get-rich-text-values';\nimport ResizableBoxPopover from './components/resizable-box-popover';\nimport { default as PrivateQuickInserter } from './components/inserter/quick-inserter';\nimport {\n\textractWords,\n\tgetNormalizedSearchTerms,\n\tnormalizeString,\n} from './components/inserter/search-items';\nimport { PrivateListView } from './components/list-view';\nimport BlockInfo from './components/block-info-slot-fill';\nimport { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';\nimport { cleanEmptyObject } from './hooks/utils';\nimport BlockQuickNavigation from './components/block-quick-navigation';\nimport { LayoutStyle } from './components/block-list/layout';\nimport { BlockRemovalWarningModal } from './components/block-removal-warning-modal';\nimport {\n\tsetBackgroundStyleDefaults,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\t__unstableBlockStyleVariationOverridesWithConfig,\n} from './hooks';\nimport DimensionsTool from './components/dimensions-tool';\nimport ResolutionTool from './components/resolution-tool';\nimport TextAlignmentControl from './components/text-alignment-control';\nimport { usesContextKey } from './components/rich-text/format-edit';\nimport { ExperimentalBlockCanvas } from './components/block-canvas';\nimport { getDuotoneFilter } from './components/duotone/utils';\nimport { useFlashEditableBlocks } from './components/use-flash-editable-blocks';\nimport {\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tsectionRootClientIdKey,\n} from './store/private-keys';\nimport { requiresWrapperOnCopy } from './components/writing-flow/utils';\nimport { PrivateRichText } from './components/rich-text/';\nimport { PrivateBlockPopover } from './components/block-popover';\nimport { PrivateInserterLibrary } from './components/inserter/library';\nimport { PrivatePublishDateTimePicker } from './components/publish-date-time-picker';\nimport useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';\nimport useBlockDisplayTitle from './components/block-title/use-block-display-title';\nimport TabbedSidebar from './components/tabbed-sidebar';\nimport { useBlockBindingsUtils } from './utils/block-bindings';\n\n/**\n * Private @wordpress/block-editor APIs.\n */\nexport const privateApis = {};\nlock( privateApis, {\n\t...globalStyles,\n\tExperimentalBlockCanvas,\n\tExperimentalBlockEditorProvider,\n\tgetDuotoneFilter,\n\tgetRichTextValues,\n\tPrivateQuickInserter,\n\textractWords,\n\tgetNormalizedSearchTerms,\n\tnormalizeString,\n\tPrivateListView,\n\tResizableBoxPopover,\n\tBlockInfo,\n\tuseHasBlockToolbar,\n\tcleanEmptyObject,\n\tBlockQuickNavigation,\n\tLayoutStyle,\n\tBlockRemovalWarningModal,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tDimensionsTool,\n\tResolutionTool,\n\tTabbedSidebar,\n\tTextAlignmentControl,\n\tusesContextKey,\n\tuseFlashEditableBlocks,\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\trequiresWrapperOnCopy,\n\tPrivateRichText,\n\tPrivateInserterLibrary,\n\treusableBlocksSelectKey,\n\tPrivateBlockPopover,\n\tPrivatePublishDateTimePicker,\n\tuseSpacingSizes,\n\tuseBlockDisplayTitle,\n\t__unstableBlockStyleVariationOverridesWithConfig,\n\tsetBackgroundStyleDefaults,\n\tuseBlockBindingsUtils,\n\tsectionRootClientIdKey,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,cAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IA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ACfC,eAAe,EAAfA,yBAAe;EACfC,mBAAmB,EAAnBA,4BAAmB;EACnBC,SAAS,EAATA,0BAAS;EACTC,kBAAkB,EAAlBA,sCAAkB;EAClBC,gBAAgB,EAAhBA,uBAAgB;EAChBC,oBAAoB,EAApBA,6BAAoB;EACpBC,WAAW,EAAXA,mBAAW;EACXC,wBAAwB,EAAxBA,kDAAwB;EACxBC,gBAAgB,EAAhBA,uBAAgB;EAChBC,eAAe,EAAfA,sBAAe;EACfC,cAAc,EAAdA,uBAAc;EACdC,cAAc,EAAdA,uBAAc;EACdC,aAAa,EAAbA,sBAAa;EACbC,oBAAoB,EAApBA,6BAAoB;EACpBC,cAAc,EAAdA,0BAAc;EACdC,sBAAsB,EAAtBA,8CAAsB;EACtBC,mBAAmB,EAAnBA,gCAAmB;EACnBC,wBAAwB,EAAxBA,qCAAwB;EACxBC,sBAAsB,EAAtBA,mCAAsB;EACtBC,qBAAqB,EAArBA,6BAAqB;EACrBC,eAAe,EAAfA,yBAAe;EACfC,sBAAsB,EAAtBA,+BAAsB;EACtBC,uBAAuB,EAAvBA,oCAAuB;EACvBC,mBAAmB,EAAnBA,iCAAmB;EACnBC,4BAA4B,EAA5BA,mDAA4B;EAC5BC,eAAe,EAAfA,wBAAe;EACfC,oBAAoB,EAApBA,6BAAoB;EACpBC,gDAAgD,EAAhDA,uDAAgD;EAChDC,0BAA0B,EAA1BA,iCAA0B;EAC1BC,qBAAqB,EAArBA,oCAAqB;EACrBC,sBAAsB,EAAtBA;AACD,CAAE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["globalStyles","_interopRequireWildcard","require","_provider","_lockUnlock","_getRichTextValues","_resizableBoxPopover","_interopRequireDefault","_quickInserter","_searchItems","_listView","_blockInfoSlotFill","_useHasBlockToolbar","_utils","_blockQuickNavigation","_layout","_blockRemovalWarningModal","_hooks","_dimensionsTool","_resolutionTool","_textAlignmentControl","_formatEdit","_blockCanvas","_utils2","_useFlashEditableBlocks","_privateKeys","_utils3","_richText","_blockPopover","_library","_publishDateTimePicker","_useSpacingSizes","_useBlockDisplayTitle","_tabbedSidebar","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","privateApis","exports","lock","ExperimentalBlockCanvas","ExperimentalBlockEditorProvider","getDuotoneFilter","getRichTextValues","PrivateQuickInserter","extractWords","getNormalizedSearchTerms","normalizeString","PrivateListView","ResizableBoxPopover","BlockInfo","useHasBlockToolbar","cleanEmptyObject","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","TabbedSidebar","TextAlignmentControl","usesContextKey","useFlashEditableBlocks","globalStylesDataKey","globalStylesLinksDataKey","selectBlockPatternsKey","requiresWrapperOnCopy","PrivateRichText","PrivateInserterLibrary","reusableBlocksSelectKey","PrivateBlockPopover","PrivatePublishDateTimePicker","useSpacingSizes","useBlockDisplayTitle","__unstableBlockStyleVariationOverridesWithConfig","setBackgroundStyleDefaults","sectionRootClientIdKey"],"sources":["@wordpress/block-editor/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport * as globalStyles from './components/global-styles';\nimport { ExperimentalBlockEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { getRichTextValues } from './components/rich-text/get-rich-text-values';\nimport ResizableBoxPopover from './components/resizable-box-popover';\nimport { default as PrivateQuickInserter } from './components/inserter/quick-inserter';\nimport {\n\textractWords,\n\tgetNormalizedSearchTerms,\n\tnormalizeString,\n} from './components/inserter/search-items';\nimport { PrivateListView } from './components/list-view';\nimport BlockInfo from './components/block-info-slot-fill';\nimport { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';\nimport { cleanEmptyObject } from './hooks/utils';\nimport BlockQuickNavigation from './components/block-quick-navigation';\nimport { LayoutStyle } from './components/block-list/layout';\nimport { BlockRemovalWarningModal } from './components/block-removal-warning-modal';\nimport {\n\tsetBackgroundStyleDefaults,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\t__unstableBlockStyleVariationOverridesWithConfig,\n} from './hooks';\nimport DimensionsTool from './components/dimensions-tool';\nimport ResolutionTool from './components/resolution-tool';\nimport TextAlignmentControl from './components/text-alignment-control';\nimport { usesContextKey } from './components/rich-text/format-edit';\nimport { ExperimentalBlockCanvas } from './components/block-canvas';\nimport { getDuotoneFilter } from './components/duotone/utils';\nimport { useFlashEditableBlocks } from './components/use-flash-editable-blocks';\nimport {\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tsectionRootClientIdKey,\n} from './store/private-keys';\nimport { requiresWrapperOnCopy } from './components/writing-flow/utils';\nimport { PrivateRichText } from './components/rich-text/';\nimport { PrivateBlockPopover } from './components/block-popover';\nimport { PrivateInserterLibrary } from './components/inserter/library';\nimport { PrivatePublishDateTimePicker } from './components/publish-date-time-picker';\nimport useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';\nimport useBlockDisplayTitle from './components/block-title/use-block-display-title';\nimport TabbedSidebar from './components/tabbed-sidebar';\n\n/**\n * Private @wordpress/block-editor APIs.\n */\nexport const privateApis = {};\nlock( privateApis, {\n\t...globalStyles,\n\tExperimentalBlockCanvas,\n\tExperimentalBlockEditorProvider,\n\tgetDuotoneFilter,\n\tgetRichTextValues,\n\tPrivateQuickInserter,\n\textractWords,\n\tgetNormalizedSearchTerms,\n\tnormalizeString,\n\tPrivateListView,\n\tResizableBoxPopover,\n\tBlockInfo,\n\tuseHasBlockToolbar,\n\tcleanEmptyObject,\n\tBlockQuickNavigation,\n\tLayoutStyle,\n\tBlockRemovalWarningModal,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tDimensionsTool,\n\tResolutionTool,\n\tTabbedSidebar,\n\tTextAlignmentControl,\n\tusesContextKey,\n\tuseFlashEditableBlocks,\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\trequiresWrapperOnCopy,\n\tPrivateRichText,\n\tPrivateInserterLibrary,\n\treusableBlocksSelectKey,\n\tPrivateBlockPopover,\n\tPrivatePublishDateTimePicker,\n\tuseSpacingSizes,\n\tuseBlockDisplayTitle,\n\t__unstableBlockStyleVariationOverridesWithConfig,\n\tsetBackgroundStyleDefaults,\n\tsectionRootClientIdKey,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,cAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,kBAAA,GAAAJ,sBAAA,CAAAL,OAAA;AACA,IAAAU,mBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,qBAAA,GAAAP,sBAAA,CAAAL,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AACA,IAAAc,yBAAA,GAAAd,OAAA;AACA,IAAAe,MAAA,GAAAf,OAAA;AAMA,IAAAgB,eAAA,GAAAX,sBAAA,CAAAL,OAAA;AACA,IAAAiB,eAAA,GAAAZ,sBAAA,CAAAL,OAAA;AACA,IAAAkB,qBAAA,GAAAb,sBAAA,CAAAL,OAAA;AACA,IAAAmB,WAAA,GAAAnB,OAAA;AACA,IAAAoB,YAAA,GAAApB,OAAA;AACA,IAAAqB,OAAA,GAAArB,OAAA;AACA,IAAAsB,uBAAA,GAAAtB,OAAA;AACA,IAAAuB,YAAA,GAAAvB,OAAA;AAOA,IAAAwB,OAAA,GAAAxB,OAAA;AACA,IAAAyB,SAAA,GAAAzB,OAAA;AACA,IAAA0B,aAAA,GAAA1B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AC5BC,eAAe,EAAfA,wBAAe;EACfC,oBAAoB,EAApBA,6BAAoB;EACpBC,gDAAgD,EAAhDA,uDAAgD;EAChDC,0BAA0B,EAA1BA,iCAA0B;EAC1BC,sBAAsB,EAAtBA;AACD,CAAE,CAAC","ignoreList":[]}
@@ -18,6 +18,54 @@ var _blockEdit = require("../components/block-edit");
18
18
  function isObjectEmpty(object) {
19
19
  return !object || Object.keys(object).length === 0;
20
20
  }
21
+
22
+ /**
23
+ * Contains utils to update the block `bindings` metadata.
24
+ *
25
+ * @typedef {Object} WPBlockBindingsUtils
26
+ *
27
+ * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.
28
+ * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.
29
+ */
30
+
31
+ /**
32
+ * Retrieves the existing utils needed to update the block `bindings` metadata.
33
+ * They can be used to create, modify, or remove connections from the existing block attributes.
34
+ *
35
+ * It contains the following utils:
36
+ * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.
37
+ * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.
38
+ *
39
+ * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.
40
+ *
41
+ * @example
42
+ * ```js
43
+ * import { useBlockBindingsUtils } from '@wordpress/block-editor'
44
+ * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();
45
+ *
46
+ * // Update url and alt attributes.
47
+ * updateBlockBindings( {
48
+ * url: {
49
+ * source: 'core/post-meta',
50
+ * args: {
51
+ * key: 'url_custom_field',
52
+ * },
53
+ * },
54
+ * alt: {
55
+ * source: 'core/post-meta',
56
+ * args: {
57
+ * key: 'text_custom_field',
58
+ * },
59
+ * },
60
+ * } );
61
+ *
62
+ * // Remove binding from url attribute.
63
+ * updateBlockBindings( { url: undefined } );
64
+ *
65
+ * // Remove bindings from all attributes.
66
+ * removeAllBlockBindings();
67
+ * ```
68
+ */
21
69
  function useBlockBindingsUtils() {
22
70
  const {
23
71
  clientId
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_store","_blockEdit","isObjectEmpty","object","Object","keys","length","useBlockBindingsUtils","clientId","useBlockEditContext","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","useRegistry","select","updateBlockBindings","bindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\nexport function useBlockBindingsUtils() {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( clientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( clientId );\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASG,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;AAEO,SAASC,qBAAqBA,CAAA,EAAG;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,8BAAmB,EAAC,CAAC;EAC1C,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACjE,MAAM;I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GAAG,CAAC;IAAE,CAAC,GACjDL,kBAAkB,CAAEL,QAAS,CAAC;IAC/BE,qBAAqB,CAAEF,QAAQ,EAAE;MAChCU,QAAQ,EAAEhB,aAAa,CAAEgB,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAEF,mBAAmB;IAAEW;EAAuB,CAAC;AACvD","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_store","_blockEdit","isObjectEmpty","object","Object","keys","length","useBlockBindingsUtils","clientId","useBlockEditContext","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","useRegistry","select","updateBlockBindings","bindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Contains utils to update the block `bindings` metadata.\n *\n * @typedef {Object} WPBlockBindingsUtils\n *\n * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.\n * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.\n */\n\n/**\n * Retrieves the existing utils needed to update the block `bindings` metadata.\n * They can be used to create, modify, or remove connections from the existing block attributes.\n *\n * It contains the following utils:\n * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.\n * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.\n *\n * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.\n *\n * @example\n * ```js\n * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();\n *\n * // Update url and alt attributes.\n * updateBlockBindings( {\n * url: {\n * source: 'core/post-meta',\n * args: {\n * key: 'url_custom_field',\n * },\n * },\n * alt: {\n * source: 'core/post-meta',\n * args: {\n * key: 'text_custom_field',\n * },\n * },\n * } );\n *\n * // Remove binding from url attribute.\n * updateBlockBindings( { url: undefined } );\n *\n * // Remove bindings from all attributes.\n * removeAllBlockBindings();\n * ```\n */\nexport function useBlockBindingsUtils() {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( clientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( clientId );\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASG,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAA,EAAG;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,8BAAmB,EAAC,CAAC;EAC1C,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACjE,MAAM;IAAEC;EAAmB,CAAC,GA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C,GACjDL,kBAAkB,CAAEL,QAAS,CAAC;IAC/BE,qBAAqB,CAAEF,QAAQ,EAAE;MAChCU,QAAQ,EAAEhB,aAAa,CAAEgB,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAEF,mBAAmB;IAAEW;EAAuB,CAAC;AACvD","ignoreList":[]}
@@ -16,6 +16,13 @@ Object.defineProperty(exports, "transformStyles", {
16
16
  return _transformStyles.default;
17
17
  }
18
18
  });
19
+ Object.defineProperty(exports, "useBlockBindingsUtils", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _blockBindings.useBlockBindingsUtils;
23
+ }
24
+ });
19
25
  var _transformStyles = _interopRequireDefault(require("./transform-styles"));
20
26
  var _getPxFromCssUnit = _interopRequireDefault(require("./get-px-from-css-unit"));
27
+ var _blockBindings = require("./block-bindings");
21
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_transformStyles","_interopRequireDefault","require","_getPxFromCssUnit"],"sources":["@wordpress/block-editor/src/utils/index.js"],"sourcesContent":["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_transformStyles","_interopRequireDefault","require","_getPxFromCssUnit","_blockBindings"],"sources":["@wordpress/block-editor/src/utils/index.js"],"sourcesContent":["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\nexport { useBlockBindingsUtils } from './block-bindings';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA","ignoreList":[]}
@@ -6,7 +6,7 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { Button, FormFileUpload, Placeholder, DropZone, withFilters } from '@wordpress/components';
9
+ import { Button, FormFileUpload, Placeholder, DropZone, __experimentalInputControl as InputControl, __experimentalInputControlSuffixWrapper as InputControlSuffixWrapper, withFilters } from '@wordpress/components';
10
10
  import { __ } from '@wordpress/i18n';
11
11
  import { useState, useEffect } from '@wordpress/element';
12
12
  import { useSelect } from '@wordpress/data';
@@ -34,25 +34,26 @@ const InsertFromURLPopover = ({
34
34
  }) => /*#__PURE__*/_jsx(URLPopover, {
35
35
  anchor: popoverAnchor,
36
36
  onClose: onClose,
37
- children: /*#__PURE__*/_jsxs("form", {
37
+ children: /*#__PURE__*/_jsx("form", {
38
38
  className: "block-editor-media-placeholder__url-input-form",
39
39
  onSubmit: onSubmit,
40
- children: [/*#__PURE__*/_jsx("input", {
41
- className: "block-editor-media-placeholder__url-input-field",
42
- type: "text",
43
- "aria-label": __('URL'),
40
+ children: /*#__PURE__*/_jsx(InputControl, {
41
+ __next40pxDefaultSize: true,
42
+ label: __('URL'),
43
+ hideLabelFromVision: true,
44
44
  placeholder: __('Paste or type URL'),
45
45
  onChange: onChange,
46
- value: src
47
- }), /*#__PURE__*/_jsx(Button
48
- // TODO: Switch to `true` (40px size) if possible
49
- , {
50
- __next40pxDefaultSize: false,
51
- className: "block-editor-media-placeholder__url-input-submit-button",
52
- icon: keyboardReturn,
53
- label: __('Apply'),
54
- type: "submit"
55
- })]
46
+ value: src,
47
+ suffix: /*#__PURE__*/_jsx(InputControlSuffixWrapper, {
48
+ variant: "control",
49
+ children: /*#__PURE__*/_jsx(Button, {
50
+ size: "small",
51
+ icon: keyboardReturn,
52
+ label: __('Apply'),
53
+ type: "submit"
54
+ })
55
+ })
56
+ })
56
57
  })
57
58
  });
58
59
  const URLSelectionUI = ({
@@ -151,9 +152,6 @@ export function MediaPlaceholder({
151
152
  }
152
153
  return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
153
154
  };
154
- const onChangeSrc = event => {
155
- setSrc(event.target.value);
156
- };
157
155
  const onFilesUpload = files => {
158
156
  if (!handleUpload || typeof handleUpload === 'function' && !handleUpload(files)) {
159
157
  return onSelect(files);
@@ -332,7 +330,7 @@ export function MediaPlaceholder({
332
330
  const renderUrlSelectionUI = () => {
333
331
  return onSelectURL && /*#__PURE__*/_jsx(URLSelectionUI, {
334
332
  src: src,
335
- onChangeSrc: onChangeSrc,
333
+ onChangeSrc: setSrc,
336
334
  onSelectURL: onSelectURL
337
335
  });
338
336
  };