@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.
@@ -39,35 +39,6 @@ function findSelection(blocks) {
39
39
  }
40
40
  return [];
41
41
  }
42
-
43
- /**
44
- * An input rule that replaces two spaces with an en space, and an en space
45
- * followed by a space with an em space.
46
- *
47
- * @param {Object} value Value to replace spaces in.
48
- *
49
- * @return {Object} Value with spaces replaced.
50
- */
51
- function replacePrecedingSpaces(value) {
52
- if (!(0, _richText.isCollapsed)(value)) {
53
- return value;
54
- }
55
- const {
56
- text,
57
- start
58
- } = value;
59
- const lastTwoCharacters = text.slice(start - 2, start);
60
-
61
- // Replace two spaces with an em space.
62
- if (lastTwoCharacters === ' ') {
63
- return (0, _richText.insert)(value, '\u2002', start - 2, start);
64
- }
65
- // Replace an en space followed by a space with an em space.
66
- else if (lastTwoCharacters === '\u2002 ') {
67
- return (0, _richText.insert)(value, '\u2003', start - 2, start);
68
- }
69
- return value;
70
- }
71
42
  function useInputRules(props) {
72
43
  const {
73
44
  __unstableMarkLastChangeAsPersistent,
@@ -147,7 +118,7 @@ function useInputRules(props) {
147
118
  accumlator = __unstableInputRule(accumlator);
148
119
  }
149
120
  return accumlator;
150
- }, (0, _preventEventDiscovery.preventEventDiscovery)(replacePrecedingSpaces(value)));
121
+ }, (0, _preventEventDiscovery.preventEventDiscovery)(value));
151
122
  if (transformed !== value) {
152
123
  __unstableMarkLastChangeAsPersistent();
153
124
  onChange({
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_compose","_richText","_blocks","_data","_store","_preventEventDiscovery","_selection","findSelection","blocks","i","length","attributeKey","retrieveSelectedAttribute","attributes","toString","replace","START_OF_SELECTED_AREA","clientId","nestedSelection","innerBlocks","replacePrecedingSpaces","value","isCollapsed","text","start","lastTwoCharacters","slice","insert","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","useDispatch","blockEditorStore","propsRef","useRef","current","useRefEffect","element","inputRule","getValue","onReplace","selectionChange","characterBefore","trimmedTextBefore","trim","prefixTransforms","getBlockTransforms","filter","type","transformation","findTransform","prefix","content","toHTMLString","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","preventEventDiscovery","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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAA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AEC,KAAM,CAAE,CACxD,CAAC;MAED,IAAK0C,WAAW,KAAK1C,KAAK,EAAG;QAC5BS,oCAAoC,CAAC,CAAC;QACtC8B,QAAQ,CAAE;UACT,GAAGG,WAAW;UACdK,aAAa,EAAE/C,KAAK,CAAC+C;QACtB,CAAE,CAAC;QACHrC,6BAA6B,CAAC,CAAC;MAChC;IACD;IAEAO,OAAO,CAAC+B,gBAAgB,CAAE,OAAO,EAAEZ,OAAQ,CAAC;IAC5CnB,OAAO,CAAC+B,gBAAgB,CAAE,gBAAgB,EAAEZ,OAAQ,CAAC;IACrD,OAAO,MAAM;MACZnB,OAAO,CAACgC,mBAAmB,CAAE,OAAO,EAAEb,OAAQ,CAAC;MAC/CnB,OAAO,CAACgC,mBAAmB,CAAE,gBAAgB,EAAEb,OAAQ,CAAC;IACzD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
1
+ {"version":3,"names":["_element","require","_compose","_richText","_blocks","_data","_store","_preventEventDiscovery","_selection","findSelection","blocks","i","length","attributeKey","retrieveSelectedAttribute","attributes","toString","replace","START_OF_SELECTED_AREA","clientId","nestedSelection","innerBlocks","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","useDispatch","blockEditorStore","propsRef","useRef","current","useRefEffect","element","inputRule","getValue","onReplace","selectionChange","value","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","getBlockTransforms","filter","type","transformation","findTransform","prefix","content","toHTMLString","insert","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","preventEventDiscovery","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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAQA,SAASQ,aAAaA,CAAEC,MAAM,EAAG;EAChC,IAAIC,CAAC,GAAGD,MAAM,CAACE,MAAM;EAErB,OAAQD,CAAC,EAAE,EAAG;IACb,MAAME,YAAY,GAAG,IAAAC,oCAAyB,EAC7CJ,MAAM,CAAEC,CAAC,CAAE,CAACI,UACb,CAAC;IAED,IAAKF,YAAY,EAAG;MACnBH,MAAM,CAAEC,CAAC,CAAE,CAACI,UAAU,CAAEF,YAAY,CAAE,GAAGH,MAAM,CAAEC,CAAC,CAAE,CAACI,UAAU,CAC9DF,YAAY;MAEZ;MACA;MACA;MAAA,CACCG,QAAQ,CAAC,CAAC,CACVC,OAAO,CAAEC,iCAAsB,EAAE,EAAG,CAAC;MACvC,OAAO,CAAER,MAAM,CAAEC,CAAC,CAAE,CAACQ,QAAQ,EAAEN,YAAY,EAAE,CAAC,EAAE,CAAC,CAAE;IACpD;IAEA,MAAMO,eAAe,GAAGX,aAAa,CAAEC,MAAM,CAAEC,CAAC,CAAE,CAACU,WAAY,CAAC;IAEhE,IAAKD,eAAe,EAAG;MACtB,OAAOA,eAAe;IACvB;EACD;EAEA,OAAO,EAAE;AACV;AAEO,SAASE,aAAa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EAAEZ,OAAQ,CAAC;IACrD,OAAO,MAAM;MACZxB,OAAO,CAACqC,mBAAmB,CAAE,OAAO,EAAEb,OAAQ,CAAC;MAC/CxB,OAAO,CAACqC,mBAAmB,CAAE,gBAAgB,EAAEb,OAAQ,CAAC;IACzD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -51,7 +51,7 @@ const createEditFunctionWithBindingsAttribute = () => (0, _compose.createHigherO
51
51
  if (updatedAttributes?.metadata?.bindings) {
52
52
  Object.entries(updatedAttributes.metadata.bindings).forEach(([attributeName, settings]) => {
53
53
  const source = getBlockBindingsSource(settings.source);
54
- if (source) {
54
+ if (source && source.useSource) {
55
55
  // Second argument (`updateMetaValue`) will be used to update the value in the future.
56
56
  const {
57
57
  placeholder,
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_compose","_data","_hooks","_store","_context","_lockUnlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","exports","createEditFunctionWithBindingsAttribute","createHigherOrderComponent","BlockEdit","props","clientId","name","blockName","useBlockEditContext","getBlockBindingsSource","unlock","useSelect","blockEditorStore","getBlockAttributes","updatedAttributes","metadata","bindings","Object","entries","forEach","attributeName","settings","source","placeholder","useValue","metaValue","useSource","args","htmlAttribute","getBlockType","attributes","attribute","_react","createElement","key","shimAttributeSource","edit","addFilter","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":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMO,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,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,MAAME,uCAAuC,GAAGA,CAAA,KAC/C,IAAAC,mCAA0B,EACvBC,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAM;IAAEC,QAAQ;IAAEC,IAAI,EAAEC;EAAU,CAAC,GAAG,IAAAC,4BAAmB,EAAC,CAAC;EAC3D,MAAM;IAAEC;EAAuB,CAAC,GAAG,IAAAC,kBAAM,EACxC,IAAAC,eAAS,EAAEC,YAAiB,CAC7B,CAAC;EACD,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAF,eAAS,EAAEC,YAAiB,CAAC;EAE5D,MAAME,iBAAiB,GAAGD,kBAAkB,CAAER,QAAS,CAAC;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OsB,QAAQ;EAChB;EACAA,QAAQ,CAACe,IAAI,GAAGnC,uCAAuC,CAAC,CAAC,CAAEoB,QAAQ,CAACe,IAAK,CAAC;EAE1E,OAAOf,QAAQ;AAChB;AAEA,IAAAgB,gBAAS,EACR,0BAA0B,EAC1B,0EAA0E,EAC1EF,mBACD,CAAC;;AAED;AACA,IAAAE,gBAAS,EACR,0BAA0B,EAC1B,wBAAwB,EACxB,CAAEhB,QAAQ,EAAEf,IAAI,KAAM;EACrB,IAAK,EAAIA,IAAI,IAAIP,6BAA6B,CAAE,EAAG;IAClD,OAAOsB,QAAQ;EAChB;EACA,MAAMiB,YAAY,GAAG,CAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAE;EACxD,MAAMC,gBAAgB,GAAGlB,QAAQ,CAACmB,WAAW;EAC7C,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAEH,gBAAiB,CAAC;EACvDD,YAAY,CAACnB,OAAO,CAAIwB,IAAI,IAAM;IACjC,IAAK,CAAEF,mBAAmB,CAACG,GAAG,CAAED,IAAK,CAAC,EAAG;MACxCJ,gBAAgB,CAACM,IAAI,CAAEF,IAAK,CAAC;IAC9B;EACD,CAAE,CAAC;EACHtB,QAAQ,CAACmB,WAAW,GAAGD,gBAAgB;EACvC,OAAOlB,QAAQ;AAChB,CACD,CAAC"}
1
+ {"version":3,"names":["_blocks","require","_compose","_data","_hooks","_store","_context","_lockUnlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","exports","createEditFunctionWithBindingsAttribute","createHigherOrderComponent","BlockEdit","props","clientId","name","blockName","useBlockEditContext","getBlockBindingsSource","unlock","useSelect","blockEditorStore","getBlockAttributes","updatedAttributes","metadata","bindings","Object","entries","forEach","attributeName","settings","source","useSource","placeholder","useValue","metaValue","args","htmlAttribute","getBlockType","attributes","attribute","_react","createElement","key","shimAttributeSource","edit","addFilter","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":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMO,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,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,MAAME,uCAAuC,GAAGA,CAAA,KAC/C,IAAAC,mCAA0B,EACvBC,SAAS,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action) {
1848
1848
  }
1849
1849
  function blockBindingsSources(state = {}, action) {
1850
1850
  if (action.type === 'REGISTER_BLOCK_BINDINGS_SOURCE') {
1851
+ var _action$lockAttribute;
1851
1852
  return {
1852
1853
  ...state,
1853
1854
  [action.sourceName]: {
1854
1855
  label: action.sourceLabel,
1855
1856
  useSource: action.useSource,
1856
- lockAttributesEditing: action.lockAttributesEditing
1857
+ lockAttributesEditing: (_action$lockAttribute = action.lockAttributesEditing) !== null && _action$lockAttribute !== void 0 ? _action$lockAttribute : true
1857
1858
  }
1858
1859
  };
1859
1860
  }