@wordpress/block-editor 12.19.0 → 12.19.1

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.
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","useRefEffect","insert","isCollapsed","toHTMLString","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","preventEventDiscovery","retrieveSelectedAttribute","START_OF_SELECTED_AREA","findSelection","blocks","i","length","attributeKey","attributes","toString","replace","clientId","nestedSelection","innerBlocks","replacePrecedingSpaces","value","text","start","lastTwoCharacters","slice","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","inputRule","getValue","onReplace","selectionChange","characterBefore","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { insert, isCollapsed, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { preventEventDiscovery } from './prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../utils/selection';\n\nfunction findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\n/**\n * An input rule that replaces two spaces with an en space, and an en space\n * followed by a space with an em space.\n *\n * @param {Object} value Value to replace spaces in.\n *\n * @return {Object} Value with spaces replaced.\n */\nfunction replacePrecedingSpaces( value ) {\n\tif ( ! isCollapsed( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst { text, start } = value;\n\tconst lastTwoCharacters = text.slice( start - 2, start );\n\n\t// Replace two spaces with an em space.\n\tif ( lastTwoCharacters === ' ' ) {\n\t\treturn insert( value, '\\u2002', start - 2, start );\n\t}\n\t// Replace an en space followed by a space with an em space.\n\telse if ( lastTwoCharacters === '\\u2002 ' ) {\n\t\treturn insert( value, '\\u2003', start - 2, start );\n\t}\n\n\treturn value;\n}\n\nexport function useInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction inputRule() {\n\t\t\tconst { getValue, onReplace, selectionChange } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We must use getValue() here because value may be update\n\t\t\t// asynchronously.\n\t\t\tconst value = getValue();\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\n\t\t\treturn true;\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, type } = event;\n\t\t\tconst {\n\t\t\t\tgetValue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst value = getValue();\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tpreventEventDiscovery( replacePrecedingSpaces( value ) )\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\telement.addEventListener( 'compositionend', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t\telement.removeEventListener( 'compositionend', onInput );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,EAAEC,WAAW,EAAEC,YAAY,QAAQ,sBAAsB;AACxE,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,mBAAmB;AACrE,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,qBAAqB,QAAQ,2BAA2B;AACjE,SACCC,yBAAyB,EACzBC,sBAAsB,QAChB,uBAAuB;AAE9B,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,IAAIC,CAAC,GAAGD,MAAM,CAACE,MAAM;EAErB,OAAQD,CAAC,EAAE,EAAG;IACb,MAAME,YAAY,GAAGN,yBAAyB,CAC7CG,MAAM,CAAEC,CAAC,CAAE,CAACG,UACb,CAAC;IAED,IAAKD,YAAY,EAAG;MACnBH,MAAM,CAAEC,CAAC,CAAE,CAACG,UAAU,CAAED,YAAY,CAAE,GAAGH,MAAM,CAAEC,CAAC,CAAE,CAACG,UAAU,CAC9DD,YAAY;MAEZ;MACA;MACA;MAAA,CACCE,QAAQ,CAAC,CAAC,CACVC,OAAO,CAAER,sBAAsB,EAAE,EAAG,CAAC;MACvC,OAAO,CAAEE,MAAM,CAAEC,CAAC,CAAE,CAACM,QAAQ,EAAEJ,YAAY,EAAE,CAAC,EAAE,CAAC,CAAE;IACpD;IAEA,MAAMK,eAAe,GAAGT,aAAa,CAAEC,MAAM,CAAEC,CAAC,CAAE,CAACQ,WAAY,CA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;MACD;MAEA,IAAKU,oCAAoC,IAAInB,SAAS,CAAC,CAAC,EAAG;QAC1D;MACD;MAEA,MAAMZ,KAAK,GAAGa,QAAQ,CAAC,CAAC;MACxB,MAAMoB,WAAW,GAAGD,WAAW,CAACE,MAAM,CACrC,CAAEC,UAAU,EAAE;QAAEC;MAAoB,CAAC,KAAM;QAC1C,IAAKA,mBAAmB,EAAG;UAC1BD,UAAU,GAAGC,mBAAmB,CAAED,UAAW,CAAC;QAC/C;QAEA,OAAOA,UAAU;MAClB,CAAC,EACDlD,qBAAqB,CAAEc,sBAAsB,CAAEC,KAAM,CAAE,CACxD,CAAC;MAED,IAAKiC,WAAW,KAAKjC,KAAK,EAAG;QAC5BO,oCAAoC,CAAC,CAAC;QACtCuB,QAAQ,CAAE;UACT,GAAGG,WAAW;UACdI,aAAa,EAAErC,KAAK,CAACqC;QACtB,CAAE,CAAC;QACH7B,6BAA6B,CAAC,CAAC;MAChC;IACD;IAEAG,OAAO,CAAC2B,gBAAgB,CAAE,OAAO,EAAEX,OAAQ,CAAC;IAC5ChB,OAAO,CAAC2B,gBAAgB,CAAE,gBAAgB,EAAEX,OAAQ,CAAC;IACrD,OAAO,MAAM;MACZhB,OAAO,CAAC4B,mBAAmB,CAAE,OAAO,EAAEZ,OAAQ,CAAC;MAC/ChB,OAAO,CAAC4B,mBAAmB,CAAE,gBAAgB,EAAEZ,OAAQ,CAAC;IACzD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
1
+ {"version":3,"names":["useRef","useRefEffect","insert","toHTMLString","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","preventEventDiscovery","retrieveSelectedAttribute","START_OF_SELECTED_AREA","findSelection","blocks","i","length","attributeKey","attributes","toString","replace","clientId","nestedSelection","innerBlocks","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","inputRule","getValue","onReplace","selectionChange","value","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { preventEventDiscovery } from './prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../utils/selection';\n\nfunction findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport function useInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction inputRule() {\n\t\t\tconst { getValue, onReplace, selectionChange } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We must use getValue() here because value may be update\n\t\t\t// asynchronously.\n\t\t\tconst value = getValue();\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\n\t\t\treturn true;\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, type } = event;\n\t\t\tconst {\n\t\t\t\tgetValue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst value = getValue();\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tpreventEventDiscovery( value )\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\telement.addEventListener( 'compositionend', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t\telement.removeEventListener( 'compositionend', onInput );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,EAAEC,YAAY,QAAQ,sBAAsB;AAC3D,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,mBAAmB;AACrE,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,qBAAqB,QAAQ,2BAA2B;AACjE,SACCC,yBAAyB,EACzBC,sBAAsB,QAChB,uBAAuB;AAE9B,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,IAAIC,CAAC,GAAGD,MAAM,CAACE,MAAM;EAErB,OAAQD,CAAC,EAAE,EAAG;IACb,MAAME,YAAY,GAAGN,yBAAyB,CAC7CG,MAAM,CAAEC,CAAC,CAAE,CAACG,UACb,CAAC;IAED,IAAKD,YAAY,EAAG;MACnBH,MAAM,CAAEC,CAAC,CAAE,CAACG,UAAU,CAAED,YAAY,CAAE,GAAGH,MAAM,CAAEC,CAAC,CAAE,CAACG,UAAU,CAC9DD,YAAY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,CAAEyB,KAAM,CAC9B,CAAC;MAED,IAAKqB,WAAW,KAAKrB,KAAK,EAAG;QAC5BT,oCAAoC,CAAC,CAAC;QACtC2B,QAAQ,CAAE;UACT,GAAGG,WAAW;UACdI,aAAa,EAAEzB,KAAK,CAACyB;QACtB,CAAE,CAAC;QACHjC,6BAA6B,CAAC,CAAC;MAChC;IACD;IAEAG,OAAO,CAAC+B,gBAAgB,CAAE,OAAO,EAAEX,OAAQ,CAAC;IAC5CpB,OAAO,CAAC+B,gBAAgB,CAAE,gBAAgB,EAAEX,OAAQ,CAAC;IACrD,OAAO,MAAM;MACZpB,OAAO,CAACgC,mBAAmB,CAAE,OAAO,EAAEZ,OAAQ,CAAC;MAC/CpB,OAAO,CAACgC,mBAAmB,CAAE,gBAAgB,EAAEZ,OAAQ,CAAC;IACzD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -44,7 +44,7 @@ const createEditFunctionWithBindingsAttribute = () => createHigherOrderComponent
44
44
  if (updatedAttributes?.metadata?.bindings) {
45
45
  Object.entries(updatedAttributes.metadata.bindings).forEach(([attributeName, settings]) => {
46
46
  const source = getBlockBindingsSource(settings.source);
47
- if (source) {
47
+ if (source && source.useSource) {
48
48
  // Second argument (`updateMetaValue`) will be used to update the value in the future.
49
49
  const {
50
50
  placeholder,
@@ -1 +1 @@
1
- {"version":3,"names":["getBlockType","createHigherOrderComponent","useSelect","addFilter","store","blockEditorStore","useBlockEditContext","unlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","createEditFunctionWithBindingsAttribute","BlockEdit","props","clientId","name","blockName","getBlockBindingsSource","getBlockAttributes","updatedAttributes","metadata","bindings","Object","entries","forEach","attributeName","settings","source","placeholder","useValue","metaValue","useSource","args","htmlAttribute","attributes","attribute","createElement","key","shimAttributeSource","edit","contextItems","usesContextArray","usesContext","oldUsesContextArray","Set","item","has","push"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit/context';\nimport { unlock } from '../lock-unlock';\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\nexport const BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget' ],\n};\n\nconst createEditFunctionWithBindingsAttribute = () =>\n\tcreateHigherOrderComponent(\n\t\t( BlockEdit ) => ( props ) => {\n\t\t\tconst { clientId, name: blockName } = useBlockEditContext();\n\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\tuseSelect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\n\t\t\tconst updatedAttributes = getBlockAttributes( clientId );\n\t\t\tif ( updatedAttributes?.metadata?.bindings ) {\n\t\t\t\tObject.entries( updatedAttributes.metadata.bindings ).forEach(\n\t\t\t\t\t( [ attributeName, settings ] ) => {\n\t\t\t\t\t\tconst source = getBlockBindingsSource(\n\t\t\t\t\t\t\tsettings.source\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( source ) {\n\t\t\t\t\t\t\t// Second argument (`updateMetaValue`) will be used to update the value in the future.\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\tuseValue: [ metaValue = null ] = [],\n\t\t\t\t\t\t\t} = source.useSource( props, settings.args );\n\n\t\t\t\t\t\t\tif ( placeholder && ! metaValue ) {\n\t\t\t\t\t\t\t\t// If the attribute is `src` or `href`, a placeholder can't be used because it is not a valid url.\n\t\t\t\t\t\t\t\t// Adding this workaround until attributes and metadata fields types are improved and include `url`.\n\t\t\t\t\t\t\t\tconst htmlAttribute =\n\t\t\t\t\t\t\t\t\tgetBlockType( blockName ).attributes[\n\t\t\t\t\t\t\t\t\t\tattributeName\n\t\t\t\t\t\t\t\t\t].attribute;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\thtmlAttribute === 'src' ||\n\t\t\t\t\t\t\t\t\thtmlAttribute === 'href'\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] = null;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] =\n\t\t\t\t\t\t\t\t\t\tplaceholder;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( metaValue ) {\n\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] = metaValue;\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\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockEdit\n\t\t\t\t\tkey=\"edit\"\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ updatedAttributes }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t\t'useBoundAttributes'\n\t);\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 *\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings ) {\n\tif ( ! ( settings.name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {\n\t\treturn settings;\n\t}\n\tsettings.edit = createEditFunctionWithBindingsAttribute()( settings.edit );\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n\n// Add the context to all blocks.\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/block-bindings-ui',\n\t( settings, name ) => {\n\t\tif ( ! ( name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {\n\t\t\treturn settings;\n\t\t}\n\t\tconst contextItems = [ 'postId', 'postType', 'queryId' ];\n\t\tconst usesContextArray = settings.usesContext;\n\t\tconst oldUsesContextArray = new Set( usesContextArray );\n\t\tcontextItems.forEach( ( item ) => {\n\t\t\tif ( ! oldUsesContextArray.has( item ) ) {\n\t\t\t\tusesContextArray.push( item );\n\t\t\t}\n\t\t} );\n\t\tsettings.usesContext = usesContextArray;\n\t\treturn settings;\n\t}\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,6BAA6B,GAAG;EAC5C,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EACvC,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY;AAC7C,CAAC;AAED,MAAMC,uCAAuC,GAAGA,CAAA,KAC/CR,0BAA0B,CACvBS,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAM;IAAEC,QAAQ;IAA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B,KAAK;IACVqB,UAAU,EAAGf;EAAmB,CAChC,CAAC;AAEJ,CAAC,EACD,oBACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASmB,mBAAmBA,CAAEZ,QAAQ,EAAG;EACxC,IAAK,EAAIA,QAAQ,CAACX,IAAI,IAAIL,6BAA6B,CAAE,EAAG;IAC3D,OAAOgB,QAAQ;EAChB;EACAA,QAAQ,CAACa,IAAI,GAAG5B,uCAAuC,CAAC,CAAC,CAAEe,QAAQ,CAACa,IAAK,CAAC;EAE1E,OAAOb,QAAQ;AAChB;AAEArB,SAAS,CACR,0BAA0B,EAC1B,0EAA0E,EAC1EiC,mBACD,CAAC;;AAED;AACAjC,SAAS,CACR,0BAA0B,EAC1B,wBAAwB,EACxB,CAAEqB,QAAQ,EAAEX,IAAI,KAAM;EACrB,IAAK,EAAIA,IAAI,IAAIL,6BAA6B,CAAE,EAAG;IAClD,OAAOgB,QAAQ;EAChB;EACA,MAAMc,YAAY,GAAG,CAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAE;EACxD,MAAMC,gBAAgB,GAAGf,QAAQ,CAACgB,WAAW;EAC7C,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAEH,gBAAiB,CAAC;EACvDD,YAAY,CAAChB,OAAO,CAAIqB,IAAI,IAAM;IACjC,IAAK,CAAEF,mBAAmB,CAACG,GAAG,CAAED,IAAK,CAAC,EAAG;MACxCJ,gBAAgB,CAACM,IAAI,CAAEF,IAAK,CAAC;IAC9B;EACD,CAAE,CAAC;EACHnB,QAAQ,CAACgB,WAAW,GAAGD,gBAAgB;EACvC,OAAOf,QAAQ;AAChB,CACD,CAAC"}
1
+ {"version":3,"names":["getBlockType","createHigherOrderComponent","useSelect","addFilter","store","blockEditorStore","useBlockEditContext","unlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","createEditFunctionWithBindingsAttribute","BlockEdit","props","clientId","name","blockName","getBlockBindingsSource","getBlockAttributes","updatedAttributes","metadata","bindings","Object","entries","forEach","attributeName","settings","source","useSource","placeholder","useValue","metaValue","args","htmlAttribute","attributes","attribute","createElement","key","shimAttributeSource","edit","contextItems","usesContextArray","usesContext","oldUsesContextArray","Set","item","has","push"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit/context';\nimport { unlock } from '../lock-unlock';\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\nexport const BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget' ],\n};\n\nconst createEditFunctionWithBindingsAttribute = () =>\n\tcreateHigherOrderComponent(\n\t\t( BlockEdit ) => ( props ) => {\n\t\t\tconst { clientId, name: blockName } = useBlockEditContext();\n\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\tuseSelect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\n\t\t\tconst updatedAttributes = getBlockAttributes( clientId );\n\t\t\tif ( updatedAttributes?.metadata?.bindings ) {\n\t\t\t\tObject.entries( updatedAttributes.metadata.bindings ).forEach(\n\t\t\t\t\t( [ attributeName, settings ] ) => {\n\t\t\t\t\t\tconst source = getBlockBindingsSource(\n\t\t\t\t\t\t\tsettings.source\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( source && source.useSource ) {\n\t\t\t\t\t\t\t// Second argument (`updateMetaValue`) will be used to update the value in the future.\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\tuseValue: [ metaValue = null ] = [],\n\t\t\t\t\t\t\t} = source.useSource( props, settings.args );\n\n\t\t\t\t\t\t\tif ( placeholder && ! metaValue ) {\n\t\t\t\t\t\t\t\t// If the attribute is `src` or `href`, a placeholder can't be used because it is not a valid url.\n\t\t\t\t\t\t\t\t// Adding this workaround until attributes and metadata fields types are improved and include `url`.\n\t\t\t\t\t\t\t\tconst htmlAttribute =\n\t\t\t\t\t\t\t\t\tgetBlockType( blockName ).attributes[\n\t\t\t\t\t\t\t\t\t\tattributeName\n\t\t\t\t\t\t\t\t\t].attribute;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\thtmlAttribute === 'src' ||\n\t\t\t\t\t\t\t\t\thtmlAttribute === 'href'\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] = null;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] =\n\t\t\t\t\t\t\t\t\t\tplaceholder;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( metaValue ) {\n\t\t\t\t\t\t\t\tupdatedAttributes[ attributeName ] = metaValue;\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\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockEdit\n\t\t\t\t\tkey=\"edit\"\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ updatedAttributes }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t\t'useBoundAttributes'\n\t);\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 *\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings ) {\n\tif ( ! ( settings.name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {\n\t\treturn settings;\n\t}\n\tsettings.edit = createEditFunctionWithBindingsAttribute()( settings.edit );\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n\n// Add the context to all blocks.\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/block-bindings-ui',\n\t( settings, name ) => {\n\t\tif ( ! ( name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {\n\t\t\treturn settings;\n\t\t}\n\t\tconst contextItems = [ 'postId', 'postType', 'queryId' ];\n\t\tconst usesContextArray = settings.usesContext;\n\t\tconst oldUsesContextArray = new Set( usesContextArray );\n\t\tcontextItems.forEach( ( item ) => {\n\t\t\tif ( ! oldUsesContextArray.has( item ) ) {\n\t\t\t\tusesContextArray.push( item );\n\t\t\t}\n\t\t} );\n\t\tsettings.usesContext = usesContextArray;\n\t\treturn settings;\n\t}\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,6BAA6B,GAAG;EAC5C,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAA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Q,CAACgB,WAAW,GAAGD,gBAAgB;EACvC,OAAOf,QAAQ;AAChB,CACD,CAAC"}
@@ -1808,12 +1808,13 @@ export function lastFocus(state = false, action) {
1808
1808
  }
1809
1809
  function blockBindingsSources(state = {}, action) {
1810
1810
  if (action.type === 'REGISTER_BLOCK_BINDINGS_SOURCE') {
1811
+ var _action$lockAttribute;
1811
1812
  return {
1812
1813
  ...state,
1813
1814
  [action.sourceName]: {
1814
1815
  label: action.sourceLabel,
1815
1816
  useSource: action.useSource,
1816
- lockAttributesEditing: action.lockAttributesEditing
1817
+ lockAttributesEditing: (_action$lockAttribute = action.lockAttributesEditing) !== null && _action$lockAttribute !== void 0 ? _action$lockAttribute : true
1817
1818
  }
1818
1819
  };
1819
1820
  }