@wordpress/block-editor 15.0.0 → 15.0.1-next.46f643fa0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-list/zoom-out-separator.js +0 -1
- package/build/components/block-list/zoom-out-separator.js.map +1 -1
- package/build/components/block-toolbar/index.js +6 -3
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/iframe/index.js +20 -15
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +49 -30
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/inserter-button/index.native.js +54 -64
- package/build/components/inserter-button/index.native.js.map +1 -1
- package/build/components/list-view/block.js +2 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +2 -1
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +3 -1
- package/build/components/writing-flow/use-click-selection.js.map +1 -1
- package/build/private-apis.js +2 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +5 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/utils/block-bindings.js +2 -1
- package/build/utils/block-bindings.js.map +1 -1
- package/build-module/components/block-list/zoom-out-separator.js +0 -1
- package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -3
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/iframe/index.js +20 -15
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +50 -30
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +55 -65
- package/build-module/components/inserter-button/index.native.js.map +1 -1
- package/build-module/components/list-view/block.js +2 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +2 -1
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +3 -1
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
- package/build-module/private-apis.js +3 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +5 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/utils/block-bindings.js +2 -1
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-style/style-rtl.css +4 -18
- package/build-style/style.css +4 -18
- package/package.json +34 -34
- package/src/components/block-list/zoom-out-separator.js +0 -1
- package/src/components/block-toolbar/index.js +8 -2
- package/src/components/grid/style.scss +3 -2
- package/src/components/iframe/index.js +25 -16
- package/src/components/image-editor/use-save-image.js +58 -31
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter-button/index.native.js +69 -80
- package/src/components/list-view/block.js +1 -0
- package/src/components/list-view/style.scss +2 -20
- package/src/components/publish-date-time-picker/README.md +9 -0
- package/src/components/publish-date-time-picker/index.js +2 -1
- package/src/components/writing-flow/use-click-selection.js +3 -1
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +8 -1
- package/src/store/private-keys.js +1 -0
- package/src/store/test/actions.js +15 -2
- package/src/utils/block-bindings.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useRegistry","store","blockEditorStore","useBlockEditContext","DEFAULT_ATTRIBUTE","PATTERN_OVERRIDES_SOURCE","BLOCK_BINDINGS_ALLOWED_BLOCKS","isObjectEmpty","object","Object","keys","length","canBindBlock","blockName","canBindAttribute","attributeName","includes","getBindableAttributes","hasPatternOverridesDefaultBinding","bindings","source","replacePatternOverridesDefaultBinding","supportedAttributes","bindingsWithDefaults","bindingSource","useBlockBindingsUtils","clientId","contextClientId","blockClientId","updateBlockAttributes","getBlockAttributes","select","updateBlockBindings","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\nconst DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\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\n/**\n * Checks if the given object is empty.\n *\n * @param {?Object} object The object to check.\n *\n * @return {boolean} Whether the object is empty.\n */\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Based on the given block name, checks if it is possible to bind the block.\n *\n * @param {string} blockName The name of the block.\n *\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, checks if it is possible to bind the block attribute.\n *\n * @param {string} blockName The name of the block.\n * @param {string} attributeName The name of attribute.\n *\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\n/**\n * Gets the bindable attributes for a given block.\n *\n * @param {string} blockName The name of the block.\n *\n * @return {string[]} The bindable attributes for the block.\n */\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\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 {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\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: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\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 * @since 6.7.0 Introduced in WordPress core.\n *\n * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.\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( clientId ) {\n\tconst { clientId: contextClientId } = useBlockEditContext();\n\tconst blockClientId = clientId || contextClientId;\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( blockClientId );\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( blockClientId, {\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( blockClientId );\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,MAAMC,iBAAiB,GAAG,WAAW;AACrC,MAAMC,wBAAwB,GAAG,wBAAwB;AACzD,MAAMC,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EAC7C,aAAa,EAAE,CAA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C,SAAS,EAAEC,OAAO,CAAE,KAAM;MACjE,IAAK,CAAEA,OAAO,IAAIJ,WAAW,CAAEG,SAAS,CAAE,EAAG;QAC5C,OAAOH,WAAW,CAAEG,SAAS,CAAE;QAC/B;MACD;MACAH,WAAW,CAAEG,SAAS,CAAE,GAAGC,OAAO;IACnC,CAAE,CAAC;IAEH,MAAMC,WAAW,GAAG;MACnB,GAAGP,QAAQ;MACXd,QAAQ,EAAEgB;IACX,CAAC;IAED,IAAK5B,aAAa,CAAEiC,WAAW,CAACrB,QAAS,CAAC,EAAG;MAC5C,OAAOqB,WAAW,CAACrB,QAAQ;IAC5B;IAEAU,qBAAqB,CAAED,aAAa,EAAE;MACrCK,QAAQ,EAAE1B,aAAa,CAAEiC,WAAY,CAAC,GAAGC,SAAS,GAAGD;IACtD,CAAE,CAAC;EACJ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAME,sBAAsB,GAAGA,CAAA,KAAM;IACpC,MAAM;MAAET,QAAQ,EAAE;QAAEd,QAAQ;QAAE,GAAGc;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GACjDH,kBAAkB,CAAEF,aAAc,CAAC;IACpCC,qBAAqB,CAAED,aAAa,EAAE;MACrCK,QAAQ,EAAE1B,aAAa,CAAE0B,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAED,mBAAmB;IAAEU;EAAuB,CAAC;AACvD","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useDispatch","useRegistry","store","blockEditorStore","useBlockEditContext","DEFAULT_ATTRIBUTE","PATTERN_OVERRIDES_SOURCE","BLOCK_BINDINGS_ALLOWED_BLOCKS","isObjectEmpty","object","Object","keys","length","canBindBlock","blockName","canBindAttribute","attributeName","includes","getBindableAttributes","hasPatternOverridesDefaultBinding","bindings","source","replacePatternOverridesDefaultBinding","supportedAttributes","bindingsWithDefaults","bindingSource","useBlockBindingsUtils","clientId","contextClientId","blockClientId","updateBlockAttributes","getBlockAttributes","select","updateBlockBindings","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\nconst DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\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\t'core/post-date': [ 'datetime' ],\n};\n\n/**\n * Checks if the given object is empty.\n *\n * @param {?Object} object The object to check.\n *\n * @return {boolean} Whether the object is empty.\n */\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Based on the given block name, checks if it is possible to bind the block.\n *\n * @param {string} blockName The name of the block.\n *\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, checks if it is possible to bind the block attribute.\n *\n * @param {string} blockName The name of the block.\n * @param {string} attributeName The name of attribute.\n *\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\n/**\n * Gets the bindable attributes for a given block.\n *\n * @param {string} blockName The name of the block.\n *\n * @return {string[]} The bindable attributes for the block.\n */\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\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 {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\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: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\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 * @since 6.7.0 Introduced in WordPress core.\n *\n * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.\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( clientId ) {\n\tconst { clientId: contextClientId } = useBlockEditContext();\n\tconst blockClientId = clientId || contextClientId;\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( blockClientId );\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( blockClientId, {\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( blockClientId );\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,MAAMC,iBAAiB,GAAG,WAAW;AACrC,MAAMC,wBAAwB,GAAG,wBAAwB;AACzD,MAAMC,6BAA6B,GAAG;EACrC,gBAAgB,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|
|
1538
1538
|
.block-editor-block-pattern-setup .block-editor-block-pattern-setup__toolbar {
|
|
1539
|
-
height:
|
|
1539
|
+
height: 64px;
|
|
1540
1540
|
box-sizing: border-box;
|
|
1541
1541
|
padding: 16px;
|
|
1542
1542
|
width: 100%;
|
|
@@ -2110,7 +2110,7 @@ iframe[name=editor-canvas] {
|
|
|
2110
2110
|
.editor-collapsible-block-toolbar .block-editor-grid-item-mover__move-vertical-button-container {
|
|
2111
2111
|
height: 40px;
|
|
2112
2112
|
position: relative;
|
|
2113
|
-
top: -
|
|
2113
|
+
top: -4px;
|
|
2114
2114
|
}
|
|
2115
2115
|
}
|
|
2116
2116
|
|
|
@@ -2718,7 +2718,7 @@ iframe[name=editor-canvas] {
|
|
|
2718
2718
|
color: var(--wp-block-synced-color);
|
|
2719
2719
|
}
|
|
2720
2720
|
.block-editor-list-view-leaf.is-synced:not(.is-selected) .block-editor-list-view-block-contents:focus::after {
|
|
2721
|
-
box-shadow: inset 0 0 0
|
|
2721
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-block-synced-color);
|
|
2722
2722
|
}
|
|
2723
2723
|
.block-editor-list-view-leaf.is-selected .block-editor-list-view-block-contents, .block-editor-list-view-leaf.is-selected .components-button.has-icon {
|
|
2724
2724
|
color: #fff;
|
|
@@ -2906,7 +2906,7 @@ iframe[name=editor-canvas] {
|
|
|
2906
2906
|
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell,
|
|
2907
2907
|
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell {
|
|
2908
2908
|
line-height: 0;
|
|
2909
|
-
width:
|
|
2909
|
+
width: 28px;
|
|
2910
2910
|
vertical-align: middle;
|
|
2911
2911
|
}
|
|
2912
2912
|
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell > *,
|
|
@@ -2919,20 +2919,6 @@ iframe[name=editor-canvas] {
|
|
|
2919
2919
|
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell.is-visible > * {
|
|
2920
2920
|
opacity: 1;
|
|
2921
2921
|
}
|
|
2922
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell,
|
|
2923
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell .components-button.has-icon,
|
|
2924
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell,
|
|
2925
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell .components-button.has-icon {
|
|
2926
|
-
width: 24px;
|
|
2927
|
-
min-width: 24px;
|
|
2928
|
-
padding: 0;
|
|
2929
|
-
}
|
|
2930
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell {
|
|
2931
|
-
padding-left: 4px;
|
|
2932
|
-
}
|
|
2933
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell .components-button.has-icon {
|
|
2934
|
-
height: 24px;
|
|
2935
|
-
}
|
|
2936
2922
|
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell-alignment-wrapper {
|
|
2937
2923
|
display: flex;
|
|
2938
2924
|
height: 100%;
|
package/build-style/style.css
CHANGED
|
@@ -1536,7 +1536,7 @@ iframe[name=editor-canvas] {
|
|
|
1536
1536
|
width: 100%;
|
|
1537
1537
|
}
|
|
1538
1538
|
.block-editor-block-pattern-setup .block-editor-block-pattern-setup__toolbar {
|
|
1539
|
-
height:
|
|
1539
|
+
height: 64px;
|
|
1540
1540
|
box-sizing: border-box;
|
|
1541
1541
|
padding: 16px;
|
|
1542
1542
|
width: 100%;
|
|
@@ -2111,7 +2111,7 @@ iframe[name=editor-canvas] {
|
|
|
2111
2111
|
.editor-collapsible-block-toolbar .block-editor-grid-item-mover__move-vertical-button-container {
|
|
2112
2112
|
height: 40px;
|
|
2113
2113
|
position: relative;
|
|
2114
|
-
top: -
|
|
2114
|
+
top: -4px;
|
|
2115
2115
|
}
|
|
2116
2116
|
}
|
|
2117
2117
|
|
|
@@ -2719,7 +2719,7 @@ iframe[name=editor-canvas] {
|
|
|
2719
2719
|
color: var(--wp-block-synced-color);
|
|
2720
2720
|
}
|
|
2721
2721
|
.block-editor-list-view-leaf.is-synced:not(.is-selected) .block-editor-list-view-block-contents:focus::after {
|
|
2722
|
-
box-shadow: inset 0 0 0
|
|
2722
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-block-synced-color);
|
|
2723
2723
|
}
|
|
2724
2724
|
.block-editor-list-view-leaf.is-selected .block-editor-list-view-block-contents, .block-editor-list-view-leaf.is-selected .components-button.has-icon {
|
|
2725
2725
|
color: #fff;
|
|
@@ -2907,7 +2907,7 @@ iframe[name=editor-canvas] {
|
|
|
2907
2907
|
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell,
|
|
2908
2908
|
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell {
|
|
2909
2909
|
line-height: 0;
|
|
2910
|
-
width:
|
|
2910
|
+
width: 28px;
|
|
2911
2911
|
vertical-align: middle;
|
|
2912
2912
|
}
|
|
2913
2913
|
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell > *,
|
|
@@ -2920,20 +2920,6 @@ iframe[name=editor-canvas] {
|
|
|
2920
2920
|
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell.is-visible > * {
|
|
2921
2921
|
opacity: 1;
|
|
2922
2922
|
}
|
|
2923
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell,
|
|
2924
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell .components-button.has-icon,
|
|
2925
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell,
|
|
2926
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell .components-button.has-icon {
|
|
2927
|
-
width: 24px;
|
|
2928
|
-
min-width: 24px;
|
|
2929
|
-
padding: 0;
|
|
2930
|
-
}
|
|
2931
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell {
|
|
2932
|
-
padding-right: 4px;
|
|
2933
|
-
}
|
|
2934
|
-
.block-editor-list-view-leaf .block-editor-list-view-block__menu-cell .components-button.has-icon {
|
|
2935
|
-
height: 24px;
|
|
2936
|
-
}
|
|
2937
2923
|
.block-editor-list-view-leaf .block-editor-list-view-block__mover-cell-alignment-wrapper {
|
|
2938
2924
|
display: flex;
|
|
2939
2925
|
height: 100%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.0.0",
|
|
3
|
+
"version": "15.0.1-next.46f643fa0.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,38 +37,38 @@
|
|
|
37
37
|
"@emotion/react": "^11.7.1",
|
|
38
38
|
"@emotion/styled": "^11.6.0",
|
|
39
39
|
"@react-spring/web": "^9.4.5",
|
|
40
|
-
"@wordpress/a11y": "^4.27.0",
|
|
41
|
-
"@wordpress/api-fetch": "^7.27.0",
|
|
42
|
-
"@wordpress/blob": "^4.27.0",
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.27.0",
|
|
44
|
-
"@wordpress/blocks": "^15.0.0",
|
|
45
|
-
"@wordpress/commands": "^1.27.0",
|
|
46
|
-
"@wordpress/components": "^30.
|
|
47
|
-
"@wordpress/compose": "^7.27.0",
|
|
48
|
-
"@wordpress/data": "^10.27.0",
|
|
49
|
-
"@wordpress/date": "^5.27.0",
|
|
50
|
-
"@wordpress/deprecated": "^4.27.0",
|
|
51
|
-
"@wordpress/dom": "^4.27.0",
|
|
52
|
-
"@wordpress/element": "^6.27.0",
|
|
53
|
-
"@wordpress/escape-html": "^3.27.0",
|
|
54
|
-
"@wordpress/hooks": "^4.27.0",
|
|
55
|
-
"@wordpress/html-entities": "^4.27.0",
|
|
56
|
-
"@wordpress/i18n": "^6.0.0",
|
|
57
|
-
"@wordpress/icons": "^10.27.0",
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.27.0",
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.27.0",
|
|
60
|
-
"@wordpress/keycodes": "^4.27.0",
|
|
61
|
-
"@wordpress/notices": "^5.27.0",
|
|
62
|
-
"@wordpress/preferences": "^4.27.0",
|
|
63
|
-
"@wordpress/priority-queue": "^3.27.0",
|
|
64
|
-
"@wordpress/private-apis": "^1.27.0",
|
|
65
|
-
"@wordpress/rich-text": "^7.27.0",
|
|
66
|
-
"@wordpress/style-engine": "^2.27.0",
|
|
67
|
-
"@wordpress/token-list": "^3.27.0",
|
|
68
|
-
"@wordpress/upload-media": "^0.12.0",
|
|
69
|
-
"@wordpress/url": "^4.27.0",
|
|
70
|
-
"@wordpress/warning": "^3.27.0",
|
|
71
|
-
"@wordpress/wordcount": "^4.27.0",
|
|
40
|
+
"@wordpress/a11y": "^4.27.1-next.46f643fa0.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.27.1-next.46f643fa0.0",
|
|
42
|
+
"@wordpress/blob": "^4.27.1-next.46f643fa0.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.27.1-next.46f643fa0.0",
|
|
44
|
+
"@wordpress/blocks": "^15.0.1-next.46f643fa0.0",
|
|
45
|
+
"@wordpress/commands": "^1.27.1-next.46f643fa0.0",
|
|
46
|
+
"@wordpress/components": "^30.1.1-next.46f643fa0.0",
|
|
47
|
+
"@wordpress/compose": "^7.27.1-next.46f643fa0.0",
|
|
48
|
+
"@wordpress/data": "^10.27.1-next.46f643fa0.0",
|
|
49
|
+
"@wordpress/date": "^5.27.1-next.46f643fa0.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.27.1-next.46f643fa0.0",
|
|
51
|
+
"@wordpress/dom": "^4.27.1-next.46f643fa0.0",
|
|
52
|
+
"@wordpress/element": "^6.27.1-next.46f643fa0.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.27.1-next.46f643fa0.0",
|
|
54
|
+
"@wordpress/hooks": "^4.27.1-next.46f643fa0.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.27.1-next.46f643fa0.0",
|
|
56
|
+
"@wordpress/i18n": "^6.0.1-next.46f643fa0.0",
|
|
57
|
+
"@wordpress/icons": "^10.27.2-next.46f643fa0.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.27.1-next.46f643fa0.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.27.1-next.46f643fa0.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.27.1-next.46f643fa0.0",
|
|
61
|
+
"@wordpress/notices": "^5.27.1-next.46f643fa0.0",
|
|
62
|
+
"@wordpress/preferences": "^4.27.1-next.46f643fa0.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.27.1-next.46f643fa0.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.27.1-next.46f643fa0.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.27.1-next.46f643fa0.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.27.1-next.46f643fa0.0",
|
|
67
|
+
"@wordpress/token-list": "^3.27.1-next.46f643fa0.0",
|
|
68
|
+
"@wordpress/upload-media": "^0.12.1-next.46f643fa0.0",
|
|
69
|
+
"@wordpress/url": "^4.27.1-next.46f643fa0.0",
|
|
70
|
+
"@wordpress/warning": "^3.27.1-next.46f643fa0.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.27.1-next.46f643fa0.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"clsx": "^2.1.1",
|
|
74
74
|
"colord": "^2.7.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "17e600e091675c5e3d809adfea23ac456bbeae19"
|
|
95
95
|
}
|
|
@@ -49,7 +49,6 @@ export function ZoomOutSeparator( {
|
|
|
49
49
|
return {
|
|
50
50
|
sectionRootClientId: root,
|
|
51
51
|
sectionClientIds: sectionRootClientIds,
|
|
52
|
-
blockOrder: getBlockOrder( root ),
|
|
53
52
|
insertionPoint: getInsertionPoint(),
|
|
54
53
|
blockInsertionPoint: getBlockInsertionPoint(),
|
|
55
54
|
blockInsertionPointVisible: isBlockInsertionPointVisible(),
|
|
@@ -91,6 +91,7 @@ export function PrivateBlockToolbar( {
|
|
|
91
91
|
getParentSectionBlock,
|
|
92
92
|
isZoomOut,
|
|
93
93
|
isNavigationMode: _isNavigationMode,
|
|
94
|
+
isSectionBlock,
|
|
94
95
|
} = unlock( select( blockEditorStore ) );
|
|
95
96
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
96
97
|
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
@@ -100,6 +101,7 @@ export function PrivateBlockToolbar( {
|
|
|
100
101
|
const parentBlockName = getBlockName( parentClientId );
|
|
101
102
|
const parentBlockType = getBlockType( parentBlockName );
|
|
102
103
|
const editingMode = getBlockEditingMode( selectedBlockClientId );
|
|
104
|
+
const isNavigationModeEnabled = _isNavigationMode();
|
|
103
105
|
const _isDefaultEditingMode = editingMode === 'default';
|
|
104
106
|
const _blockName = getBlockName( selectedBlockClientId );
|
|
105
107
|
const isValid = selectedBlockClientIds.every( ( id ) =>
|
|
@@ -151,9 +153,13 @@ export function PrivateBlockToolbar( {
|
|
|
151
153
|
showSlots: ! _isZoomOut,
|
|
152
154
|
showGroupButtons: ! _isZoomOut,
|
|
153
155
|
showLockButtons: ! _isZoomOut,
|
|
154
|
-
showSwitchSectionStyleButton:
|
|
156
|
+
showSwitchSectionStyleButton:
|
|
157
|
+
_isZoomOut ||
|
|
158
|
+
( isNavigationModeEnabled &&
|
|
159
|
+
editingMode === 'contentOnly' &&
|
|
160
|
+
isSectionBlock( selectedBlockClientId ) ), // Zoom out or Write Mode Section Blocks
|
|
155
161
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
156
|
-
isNavigationMode:
|
|
162
|
+
isNavigationMode: isNavigationModeEnabled,
|
|
157
163
|
};
|
|
158
164
|
}, [] );
|
|
159
165
|
|
|
@@ -176,11 +176,12 @@
|
|
|
176
176
|
|
|
177
177
|
.editor-collapsible-block-toolbar {
|
|
178
178
|
.block-editor-grid-item-mover__move-vertical-button-container {
|
|
179
|
-
//
|
|
179
|
+
// Reduce height and move up a little to prevent the toolbar
|
|
180
|
+
// shift when focus is on the vertical movers.
|
|
180
181
|
@include break-small() {
|
|
181
182
|
height: $grid-unit-50;
|
|
182
183
|
position: relative;
|
|
183
|
-
top: -
|
|
184
|
+
top: #{$grid-unit-05 * -1};
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
}
|
|
@@ -131,6 +131,29 @@ function Iframe( {
|
|
|
131
131
|
function preventFileDropDefault( event ) {
|
|
132
132
|
event.preventDefault();
|
|
133
133
|
}
|
|
134
|
+
// Prevent clicks on link fragments from navigating away. Note that links
|
|
135
|
+
// inside `contenteditable` are already disabled by the browser, so
|
|
136
|
+
// this is for links in blocks outside of `contenteditable`.
|
|
137
|
+
function interceptLinkClicks( event ) {
|
|
138
|
+
if (
|
|
139
|
+
event.target.tagName === 'A' &&
|
|
140
|
+
event.target.getAttribute( 'href' )?.startsWith( '#' )
|
|
141
|
+
) {
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
// Manually handle link fragment navigation within the iframe. The iframe's
|
|
144
|
+
// location is a blob URL, which can't be used to resolve relative links like
|
|
145
|
+
// `#hash`. The relative link would be resolved against the iframe's base URL
|
|
146
|
+
// or the parent frame's URL, causing the iframe to navigate to a completely
|
|
147
|
+
// different page. Setting the `location.hash` works because it really sets the
|
|
148
|
+
// blob URL's hash.
|
|
149
|
+
//
|
|
150
|
+
// Links with fragments are used for example with footnotes. Clicking on these
|
|
151
|
+
// links will scroll smoothly to the anchors in the editor canvas.
|
|
152
|
+
iFrameDocument.defaultView.location.hash = event.target
|
|
153
|
+
.getAttribute( 'href' )
|
|
154
|
+
.slice( 1 );
|
|
155
|
+
}
|
|
156
|
+
}
|
|
134
157
|
|
|
135
158
|
const { ownerDocument } = node;
|
|
136
159
|
|
|
@@ -185,22 +208,7 @@ function Iframe( {
|
|
|
185
208
|
preventFileDropDefault,
|
|
186
209
|
false
|
|
187
210
|
);
|
|
188
|
-
|
|
189
|
-
// inside `contenteditable` are already disabled by the browser, so
|
|
190
|
-
// this is for links in blocks outside of `contenteditable`.
|
|
191
|
-
iFrameDocument.addEventListener( 'click', ( event ) => {
|
|
192
|
-
if ( event.target.tagName === 'A' ) {
|
|
193
|
-
event.preventDefault();
|
|
194
|
-
|
|
195
|
-
// Appending a hash to the current URL will not reload the
|
|
196
|
-
// page. This is useful for e.g. footnotes.
|
|
197
|
-
const href = event.target.getAttribute( 'href' );
|
|
198
|
-
if ( href?.startsWith( '#' ) ) {
|
|
199
|
-
iFrameDocument.defaultView.location.hash =
|
|
200
|
-
href.slice( 1 );
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
} );
|
|
211
|
+
iFrameDocument.addEventListener( 'click', interceptLinkClicks );
|
|
204
212
|
}
|
|
205
213
|
|
|
206
214
|
node.addEventListener( 'load', onLoad );
|
|
@@ -216,6 +224,7 @@ function Iframe( {
|
|
|
216
224
|
'drop',
|
|
217
225
|
preventFileDropDefault
|
|
218
226
|
);
|
|
227
|
+
iFrameDocument?.removeEventListener( 'click', interceptLinkClicks );
|
|
219
228
|
};
|
|
220
229
|
}, [] );
|
|
221
230
|
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports
|
|
6
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
5
|
import { useCallback, useMemo, useState } from '@wordpress/element';
|
|
9
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
7
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
8
|
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
12
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import { mediaEditKey } from '../../store/private-keys';
|
|
15
|
+
|
|
13
16
|
const messages = {
|
|
14
17
|
crop: __( 'Image cropped.' ),
|
|
15
18
|
rotate: __( 'Image rotated.' ),
|
|
@@ -27,13 +30,31 @@ export default function useSaveImage( {
|
|
|
27
30
|
const { createErrorNotice, createSuccessNotice } =
|
|
28
31
|
useDispatch( noticesStore );
|
|
29
32
|
const [ isInProgress, setIsInProgress ] = useState( false );
|
|
33
|
+
const { editMediaEntity } = useSelect( ( select ) => {
|
|
34
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
35
|
+
return {
|
|
36
|
+
editMediaEntity: settings?.[ mediaEditKey ],
|
|
37
|
+
};
|
|
38
|
+
}, [] );
|
|
30
39
|
|
|
31
40
|
const cancel = useCallback( () => {
|
|
32
41
|
setIsInProgress( false );
|
|
33
42
|
onFinishEditing();
|
|
34
43
|
}, [ onFinishEditing ] );
|
|
35
44
|
|
|
36
|
-
const apply = useCallback( () => {
|
|
45
|
+
const apply = useCallback( async () => {
|
|
46
|
+
if ( ! editMediaEntity ) {
|
|
47
|
+
onFinishEditing();
|
|
48
|
+
createErrorNotice(
|
|
49
|
+
__( 'Sorry, you are not allowed to edit images on this site.' ),
|
|
50
|
+
{
|
|
51
|
+
id: 'image-editing-error',
|
|
52
|
+
type: 'snackbar',
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
setIsInProgress( true );
|
|
38
59
|
|
|
39
60
|
const modifiers = [];
|
|
@@ -71,16 +92,22 @@ export default function useSaveImage( {
|
|
|
71
92
|
const modifierType =
|
|
72
93
|
modifiers.length === 1 ? modifiers[ 0 ].type : 'cropAndRotate';
|
|
73
94
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
try {
|
|
96
|
+
const savedImage = await editMediaEntity(
|
|
97
|
+
id,
|
|
98
|
+
{
|
|
99
|
+
src: url,
|
|
100
|
+
modifiers,
|
|
101
|
+
},
|
|
102
|
+
{ throwOnError: true }
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
if ( savedImage ) {
|
|
80
106
|
onSaveImage( {
|
|
81
|
-
id:
|
|
82
|
-
url:
|
|
107
|
+
id: savedImage.id,
|
|
108
|
+
url: savedImage.source_url,
|
|
83
109
|
} );
|
|
110
|
+
|
|
84
111
|
createSuccessNotice( messages[ modifierType ], {
|
|
85
112
|
type: 'snackbar',
|
|
86
113
|
actions: [
|
|
@@ -95,24 +122,23 @@ export default function useSaveImage( {
|
|
|
95
122
|
},
|
|
96
123
|
],
|
|
97
124
|
} );
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} );
|
|
125
|
+
}
|
|
126
|
+
} catch ( error ) {
|
|
127
|
+
createErrorNotice(
|
|
128
|
+
sprintf(
|
|
129
|
+
/* translators: %s: Error message. */
|
|
130
|
+
__( 'Could not edit image. %s' ),
|
|
131
|
+
stripHTML( error.message )
|
|
132
|
+
),
|
|
133
|
+
{
|
|
134
|
+
id: 'image-editing-error',
|
|
135
|
+
type: 'snackbar',
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
} finally {
|
|
139
|
+
setIsInProgress( false );
|
|
140
|
+
onFinishEditing();
|
|
141
|
+
}
|
|
116
142
|
}, [
|
|
117
143
|
crop,
|
|
118
144
|
rotation,
|
|
@@ -122,6 +148,7 @@ export default function useSaveImage( {
|
|
|
122
148
|
createErrorNotice,
|
|
123
149
|
createSuccessNotice,
|
|
124
150
|
onFinishEditing,
|
|
151
|
+
editMediaEntity,
|
|
125
152
|
] );
|
|
126
153
|
|
|
127
154
|
return useMemo(
|
|
@@ -373,7 +373,7 @@ $block-inserter-tabs-height: 44px;
|
|
|
373
373
|
.block-editor-block-patterns-explorer {
|
|
374
374
|
&__sidebar {
|
|
375
375
|
position: absolute;
|
|
376
|
-
top: $header-height + $grid-unit-
|
|
376
|
+
top: $header-height + $grid-unit-10;
|
|
377
377
|
left: 0;
|
|
378
378
|
bottom: 0;
|
|
379
379
|
width: $sidebar-width;
|