@wordpress/block-library 8.12.13 → 8.12.15
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/footnotes/format.js +38 -6
- package/build/footnotes/format.js.map +1 -1
- package/build/image/image.js +2 -2
- package/build/image/image.js.map +1 -1
- package/build/pattern/edit.js +28 -4
- package/build/pattern/edit.js.map +1 -1
- package/build-module/footnotes/format.js +38 -6
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/image/image.js +2 -2
- package/build-module/image/image.js.map +1 -1
- package/build-module/pattern/edit.js +27 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/package.json +7 -7
- package/src/footnotes/format.js +47 -5
- package/src/footnotes/index.php +80 -8
- package/src/image/image.js +2 -2
- package/src/pattern/edit.js +21 -0
|
@@ -58,6 +58,8 @@ const {
|
|
|
58
58
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
59
59
|
const formatName = 'core/footnote';
|
|
60
60
|
exports.formatName = formatName;
|
|
61
|
+
const POST_CONTENT_BLOCK_NAME = 'core/post-content';
|
|
62
|
+
const SYNCED_PATTERN_BLOCK_NAME = 'core/block';
|
|
61
63
|
const format = {
|
|
62
64
|
title: (0, _i18n.__)('Footnote'),
|
|
63
65
|
tagName: 'sup',
|
|
@@ -78,11 +80,27 @@ const format = {
|
|
|
78
80
|
const registry = (0, _data.useRegistry)();
|
|
79
81
|
const {
|
|
80
82
|
getSelectedBlockClientId,
|
|
83
|
+
getBlocks,
|
|
81
84
|
getBlockRootClientId,
|
|
82
85
|
getBlockName,
|
|
83
|
-
|
|
86
|
+
getBlockParentsByBlockName
|
|
84
87
|
} = (0, _data.useSelect)(_blockEditor.store);
|
|
85
88
|
const footnotesBlockType = (0, _data.useSelect)(select => select(_blocks.store).getBlockType(name));
|
|
89
|
+
/*
|
|
90
|
+
* This useSelect exists because we need to use its return value
|
|
91
|
+
* outside the event callback.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
const isBlockWithinPattern = (0, _data.useSelect)(select => {
|
|
95
|
+
const {
|
|
96
|
+
getBlockParentsByBlockName: _getBlockParentsByBlockName,
|
|
97
|
+
getSelectedBlockClientId: _getSelectedBlockClientId
|
|
98
|
+
} = select(_blockEditor.store);
|
|
99
|
+
|
|
100
|
+
const parentCoreBlocks = _getBlockParentsByBlockName(_getSelectedBlockClientId(), SYNCED_PATTERN_BLOCK_NAME);
|
|
101
|
+
|
|
102
|
+
return parentCoreBlocks && parentCoreBlocks.length > 0;
|
|
103
|
+
}, []);
|
|
86
104
|
const {
|
|
87
105
|
selectionChange,
|
|
88
106
|
insertBlock
|
|
@@ -94,6 +112,11 @@ const format = {
|
|
|
94
112
|
|
|
95
113
|
if (postType !== 'post' && postType !== 'page') {
|
|
96
114
|
return null;
|
|
115
|
+
} // Checks if the selected block lives within a pattern.
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if (isBlockWithinPattern) {
|
|
119
|
+
return null;
|
|
97
120
|
}
|
|
98
121
|
|
|
99
122
|
function onClick() {
|
|
@@ -114,12 +137,22 @@ const format = {
|
|
|
114
137
|
}, value.end, value.end);
|
|
115
138
|
newValue.start = newValue.end - 1;
|
|
116
139
|
onChange(newValue);
|
|
117
|
-
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const selectedClientId = getSelectedBlockClientId();
|
|
143
|
+
/*
|
|
144
|
+
* Attempts to find a common parent post content block.
|
|
145
|
+
* This allows for locating blocks within a page edited in the site editor.
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
const parentPostContent = getBlockParentsByBlockName(selectedClientId, POST_CONTENT_BLOCK_NAME); // When called with a post content block, getBlocks will return
|
|
149
|
+
// the block with controlled inner blocks included.
|
|
118
150
|
|
|
151
|
+
const blocks = parentPostContent.length ? getBlocks(parentPostContent[0]) : getBlocks(); // BFS search to find the first footnote block.
|
|
119
152
|
|
|
120
153
|
let fnBlock = null;
|
|
121
154
|
{
|
|
122
|
-
const queue = [...
|
|
155
|
+
const queue = [...blocks];
|
|
123
156
|
|
|
124
157
|
while (queue.length) {
|
|
125
158
|
const block = queue.shift();
|
|
@@ -136,10 +169,9 @@ const format = {
|
|
|
136
169
|
// insert it at the bottom.
|
|
137
170
|
|
|
138
171
|
if (!fnBlock) {
|
|
139
|
-
|
|
140
|
-
let rootClientId = getBlockRootClientId(clientId);
|
|
172
|
+
let rootClientId = getBlockRootClientId(selectedClientId);
|
|
141
173
|
|
|
142
|
-
while (rootClientId && getBlockName(rootClientId) !==
|
|
174
|
+
while (rootClientId && getBlockName(rootClientId) !== POST_CONTENT_BLOCK_NAME) {
|
|
143
175
|
rootClientId = getBlockRootClientId(rootClientId);
|
|
144
176
|
}
|
|
145
177
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["usesContextKey","privateApis","formatName","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlockRootClientId","getBlockName","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["usesContextKey","privateApis","formatName","POST_CONTENT_BLOCK_NAME","SYNCED_PATTERN_BLOCK_NAME","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlocks","getBlockRootClientId","getBlockName","getBlockParentsByBlockName","blockEditorStore","footnotesBlockType","select","blocksStore","getBlockType","name","isBlockWithinPattern","_getBlockParentsByBlockName","_getSelectedBlockClientId","parentCoreBlocks","length","selectionChange","insertBlock","onClick","batch","id","object","replacements","start","newValue","type","innerHTML","end","selectedClientId","parentPostContent","blocks","fnBlock","queue","block","shift","push","innerBlocks","rootClientId","undefined","clientId","icon"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAMA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;;;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from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { formatListNumbered as icon } from '@wordpress/icons';\nimport { insertObject } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tstore as blockEditorStore,\n\tprivateApis,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\nimport { unlock } from '../lock-unlock';\n\nconst { usesContextKey } = unlock( privateApis );\n\nexport const formatName = 'core/footnote';\n\nconst POST_CONTENT_BLOCK_NAME = 'core/post-content';\nconst SYNCED_PATTERN_BLOCK_NAME = 'core/block';\n\nexport const format = {\n\ttitle: __( 'Footnote' ),\n\ttagName: 'sup',\n\tclassName: 'fn',\n\tattributes: {\n\t\t'data-fn': 'data-fn',\n\t},\n\tcontentEditable: false,\n\t[ usesContextKey ]: [ 'postType' ],\n\tedit: function Edit( {\n\t\tvalue,\n\t\tonChange,\n\t\tisObjectActive,\n\t\tcontext: { postType },\n\t} ) {\n\t\tconst registry = useRegistry();\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlocks,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockName,\n\t\t\tgetBlockParentsByBlockName,\n\t\t} = useSelect( blockEditorStore );\n\t\tconst footnotesBlockType = useSelect( ( select ) =>\n\t\t\tselect( blocksStore ).getBlockType( name )\n\t\t);\n\t\t/*\n\t\t * This useSelect exists because we need to use its return value\n\t\t * outside the event callback.\n\t\t */\n\t\tconst isBlockWithinPattern = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName: _getBlockParentsByBlockName,\n\t\t\t\tgetSelectedBlockClientId: _getSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst parentCoreBlocks = _getBlockParentsByBlockName(\n\t\t\t\t_getSelectedBlockClientId(),\n\t\t\t\tSYNCED_PATTERN_BLOCK_NAME\n\t\t\t);\n\t\t\treturn parentCoreBlocks && parentCoreBlocks.length > 0;\n\t\t}, [] );\n\n\t\tconst { selectionChange, insertBlock } =\n\t\t\tuseDispatch( blockEditorStore );\n\n\t\tif ( ! footnotesBlockType ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( postType !== 'post' && postType !== 'page' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Checks if the selected block lives within a pattern.\n\t\tif ( isBlockWithinPattern ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tregistry.batch( () => {\n\t\t\t\tlet id;\n\t\t\t\tif ( isObjectActive ) {\n\t\t\t\t\tconst object = value.replacements[ value.start ];\n\t\t\t\t\tid = object?.attributes?.[ 'data-fn' ];\n\t\t\t\t} else {\n\t\t\t\t\tid = createId();\n\t\t\t\t\tconst newValue = insertObject(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: formatName,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t'data-fn': id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinnerHTML: `<a href=\"#${ id }\" id=\"${ id }-link\">*</a>`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalue.end,\n\t\t\t\t\t\tvalue.end\n\t\t\t\t\t);\n\t\t\t\t\tnewValue.start = newValue.end - 1;\n\t\t\t\t\tonChange( newValue );\n\t\t\t\t}\n\n\t\t\t\tconst selectedClientId = getSelectedBlockClientId();\n\n\t\t\t\t/*\n\t\t\t\t * Attempts to find a common parent post content block.\n\t\t\t\t * This allows for locating blocks within a page edited in the site editor.\n\t\t\t\t */\n\t\t\t\tconst parentPostContent = getBlockParentsByBlockName(\n\t\t\t\t\tselectedClientId,\n\t\t\t\t\tPOST_CONTENT_BLOCK_NAME\n\t\t\t\t);\n\n\t\t\t\t// When called with a post content block, getBlocks will return\n\t\t\t\t// the block with controlled inner blocks included.\n\t\t\t\tconst blocks = parentPostContent.length\n\t\t\t\t\t? getBlocks( parentPostContent[ 0 ] )\n\t\t\t\t\t: getBlocks();\n\n\t\t\t\t// BFS search to find the first footnote block.\n\t\t\t\tlet fnBlock = null;\n\t\t\t\t{\n\t\t\t\t\tconst queue = [ ...blocks ];\n\t\t\t\t\twhile ( queue.length ) {\n\t\t\t\t\t\tconst block = queue.shift();\n\t\t\t\t\t\tif ( block.name === name ) {\n\t\t\t\t\t\t\tfnBlock = block;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqueue.push( ...block.innerBlocks );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Maybe this should all also be moved to the entity provider.\n\t\t\t\t// When there is no footnotes block in the post, create one and\n\t\t\t\t// insert it at the bottom.\n\t\t\t\tif ( ! fnBlock ) {\n\t\t\t\t\tlet rootClientId = getBlockRootClientId( selectedClientId );\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\trootClientId &&\n\t\t\t\t\t\tgetBlockName( rootClientId ) !== POST_CONTENT_BLOCK_NAME\n\t\t\t\t\t) {\n\t\t\t\t\t\trootClientId = getBlockRootClientId( rootClientId );\n\t\t\t\t\t}\n\n\t\t\t\t\tfnBlock = createBlock( name );\n\n\t\t\t\t\tinsertBlock( fnBlock, undefined, rootClientId );\n\t\t\t\t}\n\n\t\t\t\tselectionChange( fnBlock.clientId, id, 0, 0 );\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ icon }\n\t\t\t\ttitle={ __( 'Footnote' ) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isObjectActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
|
package/build/image/image.js
CHANGED
|
@@ -475,8 +475,8 @@ function Image({
|
|
|
475
475
|
ref: imageRef,
|
|
476
476
|
className: borderProps.className,
|
|
477
477
|
style: {
|
|
478
|
-
width: width && height || aspectRatio ? '100%' :
|
|
479
|
-
height: width && height || aspectRatio ? '100%' :
|
|
478
|
+
width: width && height || aspectRatio ? '100%' : undefined,
|
|
479
|
+
height: width && height || aspectRatio ? '100%' : undefined,
|
|
480
480
|
objectFit: scale,
|
|
481
481
|
...borderProps.style
|
|
482
482
|
}
|
package/build/image/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/image/image.js"],"names":["DimensionsTool","ResolutionTool","blockEditorPrivateApis","scaleOptions","value","label","help","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","caption","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","imageRef","prevCaption","showCaption","setShowCaption","allowResize","getBlock","blockEditorStore","image","multiImageSelection","select","getMedia","coreStore","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","createErrorNotice","createSuccessNotice","noticesStore","isLargeViewport","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","window","fetch","then","response","blob","catch","captionRef","node","focus","naturalWidth","naturalHeight","current","undefined","complete","onResizeStart","onResizeStop","onImageError","embedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","type","allowedTypes","ALLOWED_MEDIA_TYPES","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","dimensionsUnitsOptions","availableUnits","controls","captionIcon","link","crop","overlayText","upload","newValue","parseInt","filename","defaultedAlt","borderProps","isRounded","className","event","target","objectFit","style","fallbackClientWidth","imageAttributes","ratio","currentWidth","currentHeight","minWidth","MIN_SIZE","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","top","right","bottom","left","direction","elt","offsetWidth","offsetHeight","RichText","isEmpty"],"mappings":";;;;;;;;;AA+BA;;AA5BA;;AACA;;AAYA;;AACA;;AACA;;AAoBA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlEA;AACA;AACA;;AAoDA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,IAAqC,wBAAQC,wBAAR,CAA3C;AAEA,MAAMC,YAAY,GAAG,CACpB;AACCC,EAAAA,KAAK,EAAE,OADR;AAECC,EAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,qCAAb,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,gCAAJ;AAHP,CADoB,EAMpB;AACCF,EAAAA,KAAK,EAAE,SADR;AAECC,EAAAA,KAAK,EAAE,cAAI,SAAJ,EAAe,qCAAf,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,wCAAJ;AAHP,CANoB,CAArB;;AAae,SAASC,KAAT,CAAgB;AAC9BC,EAAAA,YAD8B;AAE9BC,EAAAA,UAF8B;AAG9BC,EAAAA,aAH8B;AAI9BC,EAAAA,UAJ8B;AAK9BC,EAAAA,iBAL8B;AAM9BC,EAAAA,SAN8B;AAO9BC,EAAAA,aAP8B;AAQ9BC,EAAAA,WAR8B;AAS9BC,EAAAA,aAT8B;AAU9BC,EAAAA,YAV8B;AAW9BC,EAAAA,OAX8B;AAY9BC,EAAAA,QAZ8B;AAa9BC,EAAAA;AAb8B,CAAhB,EAcX;AACH,QAAM;AACLC,IAAAA,GAAG,GAAG,EADD;AAELC,IAAAA,GAFK;AAGLC,IAAAA,OAHK;AAILC,IAAAA,KAJK;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AAX,KAAF,CAXf;AAaC,IAAA,aAAa,MAbd;AAcC,IAAA,sBAAsB,EAAG,MACxBQ,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAfnB,IAPH,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tTextControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tBlockAlignmentControl,\n\t__experimentalImageEditor as ImageEditor,\n\t__experimentalGetElementClassName,\n\t__experimentalUseBorderProps as useBorderProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tcrop,\n\toverlayText,\n\tupload,\n\tcaption as captionIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport useClientWidth from './use-client-width';\nimport { isExternalImage } from './edit';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';\nimport { evalAspectRatio } from './utils';\n\nconst { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nexport default function Image( {\n\ttemporaryURL,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontainerRef,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t} = attributes;\n\tconst imageRef = useRef();\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst { allowResize = true } = context;\n\tconst { getBlock } = useSelect( blockEditorStore );\n\n\tconst { image, multiImageSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia } = select( coreStore );\n\t\t\tconst { getMultiSelectedBlockClientIds, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst multiSelectedClientIds = getMultiSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tid && isSelected\n\t\t\t\t\t\t? getMedia( id, { context: 'view' } )\n\t\t\t\t\t\t: null,\n\t\t\t\tmultiImageSelection:\n\t\t\t\t\tmultiSelectedClientIds.length &&\n\t\t\t\t\tmultiSelectedClientIds.every(\n\t\t\t\t\t\t( _clientId ) =>\n\t\t\t\t\t\t\tgetBlockName( _clientId ) === 'core/image'\n\t\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id, isSelected ]\n\t);\n\tconst { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetSettings,\n\t\t\t\t\tcanInsertBlockType,\n\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst settings = getSettings();\n\n\t\t\t\treturn {\n\t\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t\t'core/cover',\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst [ externalBlob, setExternalBlob ] = useState();\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! ( isWideAligned && isLargeViewport );\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\tconst canUploadMedia = !! mediaUpload;\n\n\t// If an image is externally hosted, try to fetch the image data. This may\n\t// fail if the image host doesn't allow CORS with the domain. If it works,\n\t// we can enable a button in the toolbar to upload the image.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isExternalImage( id, url ) ||\n\t\t\t! isSelected ||\n\t\t\t! canUploadMedia\n\t\t) {\n\t\t\tsetExternalBlob();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( externalBlob ) return;\n\n\t\twindow\n\t\t\t// Avoid cache, which seems to help avoid CORS problems.\n\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t.then( ( response ) => response.blob() )\n\t\t\t.then( ( blob ) => setExternalBlob( blob ) )\n\t\t\t// Do nothing, cannot upload.\n\t\t\t.catch( () => {} );\n\t}, [ id, url, isSelected, externalBlob, canUploadMedia ] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\t// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageRef.current?.naturalWidth ||\n\t\t\t\tloadedNaturalWidth ||\n\t\t\t\tundefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageRef.current?.naturalHeight ||\n\t\t\t\tloadedNaturalHeight ||\n\t\t\t\tundefined,\n\t\t};\n\t}, [\n\t\tloadedNaturalWidth,\n\t\tloadedNaturalHeight,\n\t\timageRef.current?.complete,\n\t] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tfunction onImageError() {\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\n\t\tif ( undefined !== embedBlock ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tmediaUpload( {\n\t\t\tfilesList: [ externalBlob ],\n\t\t\tonFileChange( [ img ] ) {\n\t\t\t\tonSelectImage( img );\n\n\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetExternalBlob();\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? { width: undefined, height: undefined }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t\tif ( ! caption ) {\n\t\t\t\tsetShowCaption( false );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tconst canEditImage = id && naturalWidth && naturalHeight && imageEditing;\n\tconst allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox and ImageEditor components. Calculations later on\n\t// for those components are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowCrop && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => setIsEditingImage( true ) }\n\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\tlabel={ __( 'Crop' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && canInsertCover && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ ! multiImageSelection && externalBlob && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload external image' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t\tscale: undefined,\n\t\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ! multiImageSelection && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t\thasValue={ () => alt !== '' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tvalue={ alt }\n\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/WAI/tutorials/images/decision-tree\">\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<DimensionsTool\n\t\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t\twidth: width && `${ width }px`,\n\t\t\t\t\t\t\theight: height && `${ height }px`,\n\t\t\t\t\t\t\tscale,\n\t\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\tnewValue.width &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.width, 10 ),\n\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\tnewValue.height &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.height, 10 ),\n\t\t\t\t\t\t\t\tscale: newValue.scale,\n\t\t\t\t\t\t\t\taspectRatio: newValue.aspectRatio,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdefaultScale=\"cover\"\n\t\t\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\t\t\tscaleOptions={ scaleOptions }\n\t\t\t\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t\t\t\t/>\n\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\thelp={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Describe the role of this image on the page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'(Note: many devices and browsers do not display this text.)'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst isRounded = attributes.className?.includes( 'is-style-rounded' );\n\n\tlet img = (\n\t\t// Disable reason: Image itself is not meant to be interactive, but\n\t\t// should direct focus to block.\n\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\talt={ defaultedAlt }\n\t\t\t\tonError={ () => onImageError() }\n\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\tsetLoadedNaturalSize( {\n\t\t\t\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\t\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tref={ imageRef }\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : 'inherit',\n\t\t\t\t\theight:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : 'inherit',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ temporaryURL && <Spinner /> }\n\t\t</>\n\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t);\n\n\t// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0\n\t// So we try using the imageRef width first and fallback to clientWidth.\n\tconst fallbackClientWidth = imageRef.current?.width || clientWidth;\n\n\tif ( canEditImage && isEditingImage ) {\n\t\timg = (\n\t\t\t<ImageEditor\n\t\t\t\tid={ id }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ width }\n\t\t\t\theight={ height }\n\t\t\t\tclientWidth={ fallbackClientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) =>\n\t\t\t\t\tsetAttributes( imageAttributes )\n\t\t\t\t}\n\t\t\t\tonFinishEditing={ () => {\n\t\t\t\t\tsetIsEditingImage( false );\n\t\t\t\t} }\n\t\t\t\tborderProps={ isRounded ? undefined : borderProps }\n\t\t\t/>\n\t\t);\n\t} else if ( ! isResizable ) {\n\t\timg = <div style={ { width, height, aspectRatio } }>{ img }</div>;\n\t} else {\n\t\tconst ratio =\n\t\t\t( aspectRatio && evalAspectRatio( aspectRatio ) ) ||\n\t\t\t( width && height && width / height ) ||\n\t\t\tnaturalWidth / naturalHeight ||\n\t\t\t1;\n\n\t\tconst currentWidth = ! width && height ? height * ratio : width;\n\t\tconst currentHeight = ! height && width ? width / ratio : height;\n\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\n\t\timg = (\n\t\t\t<ResizableBox\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! width && ! height && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} }\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth ?? 'auto',\n\t\t\t\t\theight: currentHeight ?? 'auto',\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxWidthBuffer }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxWidthBuffer / ratio }\n\t\t\t\tlockAspectRatio={ ratio }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResizeStop={ ( event, direction, elt ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: elt.offsetWidth,\n\t\t\t\t\t\theight: elt.offsetHeight,\n\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</ResizableBox>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Hide controls during upload to avoid component remount,\n\t\t\t\twhich causes duplicated image upload. */ }\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ img }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Image caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/image/image.js"],"names":["DimensionsTool","ResolutionTool","blockEditorPrivateApis","scaleOptions","value","label","help","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","caption","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","imageRef","prevCaption","showCaption","setShowCaption","allowResize","getBlock","blockEditorStore","image","multiImageSelection","select","getMedia","coreStore","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","createErrorNotice","createSuccessNotice","noticesStore","isLargeViewport","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","window","fetch","then","response","blob","catch","captionRef","node","focus","naturalWidth","naturalHeight","current","undefined","complete","onResizeStart","onResizeStop","onImageError","embedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","type","allowedTypes","ALLOWED_MEDIA_TYPES","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","dimensionsUnitsOptions","availableUnits","controls","captionIcon","link","crop","overlayText","upload","newValue","parseInt","filename","defaultedAlt","borderProps","isRounded","className","event","target","objectFit","style","fallbackClientWidth","imageAttributes","ratio","currentWidth","currentHeight","minWidth","MIN_SIZE","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","top","right","bottom","left","direction","elt","offsetWidth","offsetHeight","RichText","isEmpty"],"mappings":";;;;;;;;;AA+BA;;AA5BA;;AACA;;AAYA;;AACA;;AACA;;AAoBA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlEA;AACA;AACA;;AAoDA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,IAAqC,wBAAQC,wBAAR,CAA3C;AAEA,MAAMC,YAAY,GAAG,CACpB;AACCC,EAAAA,KAAK,EAAE,OADR;AAECC,EAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,qCAAb,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,gCAAJ;AAHP,CADoB,EAMpB;AACCF,EAAAA,KAAK,EAAE,SADR;AAECC,EAAAA,KAAK,EAAE,cAAI,SAAJ,EAAe,qCAAf,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,wCAAJ;AAHP,CANoB,CAArB;;AAae,SAASC,KAAT,CAAgB;AAC9BC,EAAAA,YAD8B;AAE9BC,EAAAA,UAF8B;AAG9BC,EAAAA,aAH8B;AAI9BC,EAAAA,UAJ8B;AAK9BC,EAAAA,iBAL8B;AAM9BC,EAAAA,SAN8B;AAO9BC,EAAAA,aAP8B;AAQ9BC,EAAAA,WAR8B;AAS9BC,EAAAA,aAT8B;AAU9BC,EAAAA,YAV8B;AA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AOC,kBAAa,cAAI,oBAAJ,CAPd;AAQC,IAAA,WAAW,EAAG,cAAI,aAAJ,CARf;AASC,IAAA,KAAK,EAAG3E,OATT;AAUC,IAAA,QAAQ,EAAKnB,KAAF,IACVM,aAAa,CAAE;AAAEa,MAAAA,OAAO,EAAEnB;AAAX,KAAF,CAXf;AAaC,IAAA,aAAa,MAbd;AAcC,IAAA,sBAAsB,EAAG,MACxBQ,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAfnB,IAPH,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tTextControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tBlockAlignmentControl,\n\t__experimentalImageEditor as ImageEditor,\n\t__experimentalGetElementClassName,\n\t__experimentalUseBorderProps as useBorderProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tcrop,\n\toverlayText,\n\tupload,\n\tcaption as captionIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport useClientWidth from './use-client-width';\nimport { isExternalImage } from './edit';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';\nimport { evalAspectRatio } from './utils';\n\nconst { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nexport default function Image( {\n\ttemporaryURL,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontainerRef,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t} = attributes;\n\tconst imageRef = useRef();\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst { allowResize = true } = context;\n\tconst { getBlock } = useSelect( blockEditorStore );\n\n\tconst { image, multiImageSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia } = select( coreStore );\n\t\t\tconst { getMultiSelectedBlockClientIds, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst multiSelectedClientIds = getMultiSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tid && isSelected\n\t\t\t\t\t\t? getMedia( id, { context: 'view' } )\n\t\t\t\t\t\t: null,\n\t\t\t\tmultiImageSelection:\n\t\t\t\t\tmultiSelectedClientIds.length &&\n\t\t\t\t\tmultiSelectedClientIds.every(\n\t\t\t\t\t\t( _clientId ) =>\n\t\t\t\t\t\t\tgetBlockName( _clientId ) === 'core/image'\n\t\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id, isSelected ]\n\t);\n\tconst { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetSettings,\n\t\t\t\t\tcanInsertBlockType,\n\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst settings = getSettings();\n\n\t\t\t\treturn {\n\t\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t\t'core/cover',\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst [ externalBlob, setExternalBlob ] = useState();\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! ( isWideAligned && isLargeViewport );\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\tconst canUploadMedia = !! mediaUpload;\n\n\t// If an image is externally hosted, try to fetch the image data. This may\n\t// fail if the image host doesn't allow CORS with the domain. If it works,\n\t// we can enable a button in the toolbar to upload the image.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isExternalImage( id, url ) ||\n\t\t\t! isSelected ||\n\t\t\t! canUploadMedia\n\t\t) {\n\t\t\tsetExternalBlob();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( externalBlob ) return;\n\n\t\twindow\n\t\t\t// Avoid cache, which seems to help avoid CORS problems.\n\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t.then( ( response ) => response.blob() )\n\t\t\t.then( ( blob ) => setExternalBlob( blob ) )\n\t\t\t// Do nothing, cannot upload.\n\t\t\t.catch( () => {} );\n\t}, [ id, url, isSelected, externalBlob, canUploadMedia ] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\t// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageRef.current?.naturalWidth ||\n\t\t\t\tloadedNaturalWidth ||\n\t\t\t\tundefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageRef.current?.naturalHeight ||\n\t\t\t\tloadedNaturalHeight ||\n\t\t\t\tundefined,\n\t\t};\n\t}, [\n\t\tloadedNaturalWidth,\n\t\tloadedNaturalHeight,\n\t\timageRef.current?.complete,\n\t] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tfunction onImageError() {\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\n\t\tif ( undefined !== embedBlock ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tmediaUpload( {\n\t\t\tfilesList: [ externalBlob ],\n\t\t\tonFileChange( [ img ] ) {\n\t\t\t\tonSelectImage( img );\n\n\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetExternalBlob();\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? { width: undefined, height: undefined }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t\tif ( ! caption ) {\n\t\t\t\tsetShowCaption( false );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tconst canEditImage = id && naturalWidth && naturalHeight && imageEditing;\n\tconst allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox and ImageEditor components. Calculations later on\n\t// for those components are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowCrop && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => setIsEditingImage( true ) }\n\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\tlabel={ __( 'Crop' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && canInsertCover && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ ! multiImageSelection && externalBlob && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload external image' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t\tscale: undefined,\n\t\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ! multiImageSelection && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t\thasValue={ () => alt !== '' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tvalue={ alt }\n\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/WAI/tutorials/images/decision-tree\">\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<DimensionsTool\n\t\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t\twidth: width && `${ width }px`,\n\t\t\t\t\t\t\theight: height && `${ height }px`,\n\t\t\t\t\t\t\tscale,\n\t\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\tnewValue.width &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.width, 10 ),\n\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\tnewValue.height &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.height, 10 ),\n\t\t\t\t\t\t\t\tscale: newValue.scale,\n\t\t\t\t\t\t\t\taspectRatio: newValue.aspectRatio,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdefaultScale=\"cover\"\n\t\t\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\t\t\tscaleOptions={ scaleOptions }\n\t\t\t\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t\t\t\t/>\n\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\thelp={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Describe the role of this image on the page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'(Note: many devices and browsers do not display this text.)'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst isRounded = attributes.className?.includes( 'is-style-rounded' );\n\n\tlet img = (\n\t\t// Disable reason: Image itself is not meant to be interactive, but\n\t\t// should direct focus to block.\n\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\talt={ defaultedAlt }\n\t\t\t\tonError={ () => onImageError() }\n\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\tsetLoadedNaturalSize( {\n\t\t\t\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\t\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tref={ imageRef }\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\theight:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ temporaryURL && <Spinner /> }\n\t\t</>\n\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t);\n\n\t// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0\n\t// So we try using the imageRef width first and fallback to clientWidth.\n\tconst fallbackClientWidth = imageRef.current?.width || clientWidth;\n\n\tif ( canEditImage && isEditingImage ) {\n\t\timg = (\n\t\t\t<ImageEditor\n\t\t\t\tid={ id }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ width }\n\t\t\t\theight={ height }\n\t\t\t\tclientWidth={ fallbackClientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) =>\n\t\t\t\t\tsetAttributes( imageAttributes )\n\t\t\t\t}\n\t\t\t\tonFinishEditing={ () => {\n\t\t\t\t\tsetIsEditingImage( false );\n\t\t\t\t} }\n\t\t\t\tborderProps={ isRounded ? undefined : borderProps }\n\t\t\t/>\n\t\t);\n\t} else if ( ! isResizable ) {\n\t\timg = <div style={ { width, height, aspectRatio } }>{ img }</div>;\n\t} else {\n\t\tconst ratio =\n\t\t\t( aspectRatio && evalAspectRatio( aspectRatio ) ) ||\n\t\t\t( width && height && width / height ) ||\n\t\t\tnaturalWidth / naturalHeight ||\n\t\t\t1;\n\n\t\tconst currentWidth = ! width && height ? height * ratio : width;\n\t\tconst currentHeight = ! height && width ? width / ratio : height;\n\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\n\t\timg = (\n\t\t\t<ResizableBox\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! width && ! height && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} }\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth ?? 'auto',\n\t\t\t\t\theight: currentHeight ?? 'auto',\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxWidthBuffer }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxWidthBuffer / ratio }\n\t\t\t\tlockAspectRatio={ ratio }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResizeStop={ ( event, direction, elt ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: elt.offsetWidth,\n\t\t\t\t\t\theight: elt.offsetHeight,\n\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</ResizableBox>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Hide controls during upload to avoid component remount,\n\t\t\t\twhich causes duplicated image upload. */ }\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ img }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Image caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</>\n\t);\n}\n"]}
|
package/build/pattern/edit.js
CHANGED
|
@@ -13,9 +13,15 @@ var _data = require("@wordpress/data");
|
|
|
13
13
|
|
|
14
14
|
var _blockEditor = require("@wordpress/block-editor");
|
|
15
15
|
|
|
16
|
+
var _lockUnlock = require("../lock-unlock");
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* WordPress dependencies
|
|
18
20
|
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
19
25
|
const PatternEdit = ({
|
|
20
26
|
attributes,
|
|
21
27
|
clientId
|
|
@@ -24,7 +30,14 @@ const PatternEdit = ({
|
|
|
24
30
|
const {
|
|
25
31
|
replaceBlocks,
|
|
26
32
|
__unstableMarkNextChangeAsNotPersistent
|
|
27
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
33
|
+
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
34
|
+
const {
|
|
35
|
+
setBlockEditingMode
|
|
36
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_blockEditor.store));
|
|
37
|
+
const {
|
|
38
|
+
getBlockRootClientId,
|
|
39
|
+
getBlockEditingMode
|
|
40
|
+
} = (0, _lockUnlock.unlock)((0, _data.useSelect)(_blockEditor.store)); // Run this effect when the component loads.
|
|
28
41
|
// This adds the Pattern's contents to the post.
|
|
29
42
|
// This change won't be saved.
|
|
30
43
|
// It will continue to pull from the pattern file unless changes are made to its respective template part.
|
|
@@ -37,16 +50,27 @@ const PatternEdit = ({
|
|
|
37
50
|
// because nested pattern blocks cannot be inserted if the parent block supports
|
|
38
51
|
// inner blocks but doesn't have blockSettings in the state.
|
|
39
52
|
window.queueMicrotask(() => {
|
|
40
|
-
// Clone blocks from the pattern before insertion to ensure they receive
|
|
53
|
+
const rootClientId = getBlockRootClientId(clientId); // Clone blocks from the pattern before insertion to ensure they receive
|
|
41
54
|
// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.
|
|
55
|
+
|
|
42
56
|
const clonedBlocks = selectedPattern.blocks.map(block => (0, _blocks.cloneBlock)(block));
|
|
57
|
+
const rootEditingMode = getBlockEditingMode(rootClientId); // Temporarily set the root block to default mode to allow replacing the pattern.
|
|
58
|
+
// This could happen when the page is disabling edits of non-content blocks.
|
|
59
|
+
|
|
60
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
61
|
+
|
|
62
|
+
setBlockEditingMode(rootClientId, 'default');
|
|
63
|
+
|
|
64
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
65
|
+
|
|
66
|
+
replaceBlocks(clientId, clonedBlocks); // Restore the root block's original mode.
|
|
43
67
|
|
|
44
68
|
__unstableMarkNextChangeAsNotPersistent();
|
|
45
69
|
|
|
46
|
-
|
|
70
|
+
setBlockEditingMode(rootClientId, rootEditingMode);
|
|
47
71
|
});
|
|
48
72
|
}
|
|
49
|
-
}, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks]);
|
|
73
|
+
}, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks, getBlockEditingMode, setBlockEditingMode, getBlockRootClientId]);
|
|
50
74
|
const props = (0, _blockEditor.useBlockProps)();
|
|
51
75
|
return (0, _element.createElement)("div", { ...props
|
|
52
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/pattern/edit.js"],"names":["PatternEdit","attributes","clientId","selectedPattern","select","blockEditorStore","__experimentalGetParsedPattern","slug","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","blocks","window","queueMicrotask","clonedBlocks","map","block","props"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/pattern/edit.js"],"names":["PatternEdit","attributes","clientId","selectedPattern","select","blockEditorStore","__experimentalGetParsedPattern","slug","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","blocks","window","queueMicrotask","rootClientId","clonedBlocks","map","block","rootEditingMode","props"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAQA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,CAAE;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,CAAF,KAAgC;AACnD,QAAMC,eAAe,GAAG,qBACrBC,MAAF,IACCA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,8BAA3B,CACCL,UAAU,CAACM,IADZ,CAFsB,EAKvB,CAAEN,UAAU,CAACM,IAAb,CALuB,CAAxB;AAQA,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MACL,uBAAaJ,kBAAb,CADD;AAEA,QAAM;AAAEK,IAAAA;AAAF,MAA0B,wBAAQ,uBAAaL,kBAAb,CAAR,CAAhC;AACA,QAAM;AAAEM,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MAAgD,wBACrD,qBAAWP,kBAAX,CADqD,CAAtD,CAZmD,CAgBnD;AACA;AACA;AACA;;AACA,0BAAW,MAAM;AAChB,QAAKF,eAAe,EAAEU,MAAtB,EAA+B;AAC9B;AACA;AACA;AACA;AACA;AACAC,MAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5B,cAAMC,YAAY,GAAGL,oBAAoB,CAAET,QAAF,CAAzC,CAD4B,CAE5B;AACA;;AACA,cAAMe,YAAY,GAAGd,eAAe,CAACU,MAAhB,CAAuBK,GAAvB,CAA8BC,KAAF,IAChD,wBAAYA,KAAZ,CADoB,CAArB;AAGA,cAAMC,eAAe,GAAGR,mBAAmB,CAAEI,YAAF,CAA3C,CAP4B,CAQ5B;AACA;;AACAP,QAAAA,uCAAuC;;AACvCC,QAAAA,mBAAmB,CAAEM,YAAF,EAAgB,SAAhB,CAAnB;;AACAP,QAAAA,uCAAuC;;AACvCD,QAAAA,aAAa,CAAEN,QAAF,EAAYe,YAAZ,CAAb,CAb4B,CAc5B;;AACAR,QAAAA,uCAAuC;;AACvCC,QAAAA,mBAAmB,CAAEM,YAAF,EAAgBI,eAAhB,CAAnB;AACA,OAjBD;AAkBA;AACD,GA1BD,EA0BG,CACFlB,QADE,EAEFC,eAAe,EAAEU,MAFf,EAGFJ,uCAHE,EAIFD,aAJE,EAKFI,mBALE,EAMFF,mBANE,EAOFC,oBAPE,CA1BH;AAoCA,QAAMU,KAAK,GAAG,iCAAd;AAEA,SAAO,wCAAUA;AAAV,IAAP;AACA,CA3DD;;eA6DerB,W","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = unlock( useDispatch( blockEditorStore ) );\n\tconst { getBlockRootClientId, getBlockEditingMode } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"]}
|
|
@@ -42,6 +42,8 @@ const {
|
|
|
42
42
|
usesContextKey
|
|
43
43
|
} = unlock(privateApis);
|
|
44
44
|
export const formatName = 'core/footnote';
|
|
45
|
+
const POST_CONTENT_BLOCK_NAME = 'core/post-content';
|
|
46
|
+
const SYNCED_PATTERN_BLOCK_NAME = 'core/block';
|
|
45
47
|
export const format = {
|
|
46
48
|
title: __('Footnote'),
|
|
47
49
|
tagName: 'sup',
|
|
@@ -62,11 +64,27 @@ export const format = {
|
|
|
62
64
|
const registry = useRegistry();
|
|
63
65
|
const {
|
|
64
66
|
getSelectedBlockClientId,
|
|
67
|
+
getBlocks,
|
|
65
68
|
getBlockRootClientId,
|
|
66
69
|
getBlockName,
|
|
67
|
-
|
|
70
|
+
getBlockParentsByBlockName
|
|
68
71
|
} = useSelect(blockEditorStore);
|
|
69
72
|
const footnotesBlockType = useSelect(select => select(blocksStore).getBlockType(name));
|
|
73
|
+
/*
|
|
74
|
+
* This useSelect exists because we need to use its return value
|
|
75
|
+
* outside the event callback.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
const isBlockWithinPattern = useSelect(select => {
|
|
79
|
+
const {
|
|
80
|
+
getBlockParentsByBlockName: _getBlockParentsByBlockName,
|
|
81
|
+
getSelectedBlockClientId: _getSelectedBlockClientId
|
|
82
|
+
} = select(blockEditorStore);
|
|
83
|
+
|
|
84
|
+
const parentCoreBlocks = _getBlockParentsByBlockName(_getSelectedBlockClientId(), SYNCED_PATTERN_BLOCK_NAME);
|
|
85
|
+
|
|
86
|
+
return parentCoreBlocks && parentCoreBlocks.length > 0;
|
|
87
|
+
}, []);
|
|
70
88
|
const {
|
|
71
89
|
selectionChange,
|
|
72
90
|
insertBlock
|
|
@@ -78,6 +96,11 @@ export const format = {
|
|
|
78
96
|
|
|
79
97
|
if (postType !== 'post' && postType !== 'page') {
|
|
80
98
|
return null;
|
|
99
|
+
} // Checks if the selected block lives within a pattern.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if (isBlockWithinPattern) {
|
|
103
|
+
return null;
|
|
81
104
|
}
|
|
82
105
|
|
|
83
106
|
function onClick() {
|
|
@@ -98,12 +121,22 @@ export const format = {
|
|
|
98
121
|
}, value.end, value.end);
|
|
99
122
|
newValue.start = newValue.end - 1;
|
|
100
123
|
onChange(newValue);
|
|
101
|
-
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const selectedClientId = getSelectedBlockClientId();
|
|
127
|
+
/*
|
|
128
|
+
* Attempts to find a common parent post content block.
|
|
129
|
+
* This allows for locating blocks within a page edited in the site editor.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
const parentPostContent = getBlockParentsByBlockName(selectedClientId, POST_CONTENT_BLOCK_NAME); // When called with a post content block, getBlocks will return
|
|
133
|
+
// the block with controlled inner blocks included.
|
|
102
134
|
|
|
135
|
+
const blocks = parentPostContent.length ? getBlocks(parentPostContent[0]) : getBlocks(); // BFS search to find the first footnote block.
|
|
103
136
|
|
|
104
137
|
let fnBlock = null;
|
|
105
138
|
{
|
|
106
|
-
const queue = [...
|
|
139
|
+
const queue = [...blocks];
|
|
107
140
|
|
|
108
141
|
while (queue.length) {
|
|
109
142
|
const block = queue.shift();
|
|
@@ -120,10 +153,9 @@ export const format = {
|
|
|
120
153
|
// insert it at the bottom.
|
|
121
154
|
|
|
122
155
|
if (!fnBlock) {
|
|
123
|
-
|
|
124
|
-
let rootClientId = getBlockRootClientId(clientId);
|
|
156
|
+
let rootClientId = getBlockRootClientId(selectedClientId);
|
|
125
157
|
|
|
126
|
-
while (rootClientId && getBlockName(rootClientId) !==
|
|
158
|
+
while (rootClientId && getBlockName(rootClientId) !== POST_CONTENT_BLOCK_NAME) {
|
|
127
159
|
rootClientId = getBlockRootClientId(rootClientId);
|
|
128
160
|
}
|
|
129
161
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","privateApis","useSelect","useDispatch","useRegistry","createBlock","blocksStore","unlock","usesContextKey","formatName","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlockRootClientId","getBlockName","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","privateApis","useSelect","useDispatch","useRegistry","createBlock","blocksStore","unlock","usesContextKey","formatName","POST_CONTENT_BLOCK_NAME","SYNCED_PATTERN_BLOCK_NAME","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlocks","getBlockRootClientId","getBlockName","getBlockParentsByBlockName","footnotesBlockType","select","getBlockType","name","isBlockWithinPattern","_getBlockParentsByBlockName","_getSelectedBlockClientId","parentCoreBlocks","length","selectionChange","insertBlock","onClick","batch","id","object","replacements","start","newValue","type","innerHTML","end","selectedClientId","parentPostContent","blocks","fnBlock","queue","block","shift","push","innerBlocks","rootClientId","undefined","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,QAAf,QAA+B,MAA/B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SACCC,qBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAHD,QAIO,yBAJP;AAKA,SAASC,SAAT,EAAoBC,WAApB,E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zED;AA0EA;;AAED,WACC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAGhD,IADR;AAEC,MAAA,KAAK,EAAGF,EAAE,CAAE,UAAF,CAFX;AAGC,MAAA,OAAO,EAAGgD,OAHX;AAIC,MAAA,QAAQ,EAAGpB;AAJZ,MADD;AAQA;AA/IoB,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as createId } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { formatListNumbered as icon } from '@wordpress/icons';\nimport { insertObject } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tstore as blockEditorStore,\n\tprivateApis,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\nimport { unlock } from '../lock-unlock';\n\nconst { usesContextKey } = unlock( privateApis );\n\nexport const formatName = 'core/footnote';\n\nconst POST_CONTENT_BLOCK_NAME = 'core/post-content';\nconst SYNCED_PATTERN_BLOCK_NAME = 'core/block';\n\nexport const format = {\n\ttitle: __( 'Footnote' ),\n\ttagName: 'sup',\n\tclassName: 'fn',\n\tattributes: {\n\t\t'data-fn': 'data-fn',\n\t},\n\tcontentEditable: false,\n\t[ usesContextKey ]: [ 'postType' ],\n\tedit: function Edit( {\n\t\tvalue,\n\t\tonChange,\n\t\tisObjectActive,\n\t\tcontext: { postType },\n\t} ) {\n\t\tconst registry = useRegistry();\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlocks,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockName,\n\t\t\tgetBlockParentsByBlockName,\n\t\t} = useSelect( blockEditorStore );\n\t\tconst footnotesBlockType = useSelect( ( select ) =>\n\t\t\tselect( blocksStore ).getBlockType( name )\n\t\t);\n\t\t/*\n\t\t * This useSelect exists because we need to use its return value\n\t\t * outside the event callback.\n\t\t */\n\t\tconst isBlockWithinPattern = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName: _getBlockParentsByBlockName,\n\t\t\t\tgetSelectedBlockClientId: _getSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst parentCoreBlocks = _getBlockParentsByBlockName(\n\t\t\t\t_getSelectedBlockClientId(),\n\t\t\t\tSYNCED_PATTERN_BLOCK_NAME\n\t\t\t);\n\t\t\treturn parentCoreBlocks && parentCoreBlocks.length > 0;\n\t\t}, [] );\n\n\t\tconst { selectionChange, insertBlock } =\n\t\t\tuseDispatch( blockEditorStore );\n\n\t\tif ( ! footnotesBlockType ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( postType !== 'post' && postType !== 'page' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Checks if the selected block lives within a pattern.\n\t\tif ( isBlockWithinPattern ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tregistry.batch( () => {\n\t\t\t\tlet id;\n\t\t\t\tif ( isObjectActive ) {\n\t\t\t\t\tconst object = value.replacements[ value.start ];\n\t\t\t\t\tid = object?.attributes?.[ 'data-fn' ];\n\t\t\t\t} else {\n\t\t\t\t\tid = createId();\n\t\t\t\t\tconst newValue = insertObject(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: formatName,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t'data-fn': id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinnerHTML: `<a href=\"#${ id }\" id=\"${ id }-link\">*</a>`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalue.end,\n\t\t\t\t\t\tvalue.end\n\t\t\t\t\t);\n\t\t\t\t\tnewValue.start = newValue.end - 1;\n\t\t\t\t\tonChange( newValue );\n\t\t\t\t}\n\n\t\t\t\tconst selectedClientId = getSelectedBlockClientId();\n\n\t\t\t\t/*\n\t\t\t\t * Attempts to find a common parent post content block.\n\t\t\t\t * This allows for locating blocks within a page edited in the site editor.\n\t\t\t\t */\n\t\t\t\tconst parentPostContent = getBlockParentsByBlockName(\n\t\t\t\t\tselectedClientId,\n\t\t\t\t\tPOST_CONTENT_BLOCK_NAME\n\t\t\t\t);\n\n\t\t\t\t// When called with a post content block, getBlocks will return\n\t\t\t\t// the block with controlled inner blocks included.\n\t\t\t\tconst blocks = parentPostContent.length\n\t\t\t\t\t? getBlocks( parentPostContent[ 0 ] )\n\t\t\t\t\t: getBlocks();\n\n\t\t\t\t// BFS search to find the first footnote block.\n\t\t\t\tlet fnBlock = null;\n\t\t\t\t{\n\t\t\t\t\tconst queue = [ ...blocks ];\n\t\t\t\t\twhile ( queue.length ) {\n\t\t\t\t\t\tconst block = queue.shift();\n\t\t\t\t\t\tif ( block.name === name ) {\n\t\t\t\t\t\t\tfnBlock = block;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqueue.push( ...block.innerBlocks );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Maybe this should all also be moved to the entity provider.\n\t\t\t\t// When there is no footnotes block in the post, create one and\n\t\t\t\t// insert it at the bottom.\n\t\t\t\tif ( ! fnBlock ) {\n\t\t\t\t\tlet rootClientId = getBlockRootClientId( selectedClientId );\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\trootClientId &&\n\t\t\t\t\t\tgetBlockName( rootClientId ) !== POST_CONTENT_BLOCK_NAME\n\t\t\t\t\t) {\n\t\t\t\t\t\trootClientId = getBlockRootClientId( rootClientId );\n\t\t\t\t\t}\n\n\t\t\t\t\tfnBlock = createBlock( name );\n\n\t\t\t\t\tinsertBlock( fnBlock, undefined, rootClientId );\n\t\t\t\t}\n\n\t\t\t\tselectionChange( fnBlock.clientId, id, 0, 0 );\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ icon }\n\t\t\t\ttitle={ __( 'Footnote' ) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isObjectActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
|
|
@@ -449,8 +449,8 @@ export default function Image({
|
|
|
449
449
|
ref: imageRef,
|
|
450
450
|
className: borderProps.className,
|
|
451
451
|
style: {
|
|
452
|
-
width: width && height || aspectRatio ? '100%' :
|
|
453
|
-
height: width && height || aspectRatio ? '100%' :
|
|
452
|
+
width: width && height || aspectRatio ? '100%' : undefined,
|
|
453
|
+
height: width && height || aspectRatio ? '100%' : undefined,
|
|
454
454
|
objectFit: scale,
|
|
455
455
|
...borderProps.style
|
|
456
456
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/image/image.js"],"names":["isBlobURL","ExternalLink","ResizableBox","Spinner","TextareaControl","TextControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUseCustomUnits","useCustomUnits","useViewportMatch","usePrevious","useSelect","useDispatch","BlockControls","InspectorControls","RichText","__experimentalImageURLInputUI","ImageURLInputUI","MediaReplaceFlow","store","blockEditorStore","BlockAlignmentControl","__experimentalImageEditor","ImageEditor","__experimentalGetElementClassName","__experimentalUseBorderProps","useBorderProps","privateApis","blockEditorPrivateApis","useEffect","useMemo","useState","useRef","useCallback","__","_x","sprintf","isRTL","getFilename","createBlock","getDefaultBlockName","switchToBlockType","crop","overlayText","upload","caption","captionIcon","noticesStore","coreStore","unlock","createUpgradedEmbedBlock","useClientWidth","isExternalImage","MIN_SIZE","ALLOWED_MEDIA_TYPES","evalAspectRatio","DimensionsTool","ResolutionTool","scaleOptions","value","label","help","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","imageRef","prevCaption","showCaption","setShowCaption","allowResize","getBlock","image","multiImageSelection","select","getMedia","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","createErrorNotice","createSuccessNotice","isLargeViewport","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","window","fetch","then","response","blob","catch","captionRef","node","focus","naturalWidth","naturalHeight","current","undefined","complete","onResizeStart","onResizeStop","onImageError","embedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","type","allowedTypes","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","dimensionsUnitsOptions","availableUnits","controls","link","newValue","parseInt","filename","defaultedAlt","borderProps","isRounded","className","event","target","objectFit","style","fallbackClientWidth","imageAttributes","ratio","currentWidth","currentHeight","minWidth","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","top","right","bottom","left","direction","elt","offsetWidth","offsetHeight","isEmpty"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SACCC,YADD,EAECC,YAFD,EAGCC,OAHD,EAICC,eAJD,EAKCC,WALD,EAMCC,aAND,EAOCC,YAPD,EAQCC,wBAAwB,IAAIC,UAR7B,EASCC,4BAA4B,IAAIC,cATjC,EAUCC,4BAA4B,IAAIC,cAVjC,QAWO,uBAXP;AAYA,SAASC,gBAAT,EAA2BC,WAA3B,QAA8C,oBAA9C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,aADD,EAECC,iBAFD,EAGCC,QAHD,EA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AAa,EAAGlD,aAzBjB;AA0BC,MAAA,YAAY,EAAG,CAAEqC,KAAF,EAASmB,SAAT,EAAoBC,GAApB,KAA6B;AAC3CxD,QAAAA,YAAY;AACZ7F,QAAAA,aAAa,CAAE;AACdoB,UAAAA,KAAK,EAAEiI,GAAG,CAACC,WADG;AAEdjI,UAAAA,MAAM,EAAEgI,GAAG,CAACE,YAFE;AAGdjI,UAAAA,WAAW,EAAEoE;AAHC,SAAF,CAAb;AAKA,OAjCF;AAkCC,MAAA,WAAW,EAAG7E,KAAK,KAAK,QAAV,GAAqB,CAArB,GAAyB;AAlCxC,OAoCG8F,GApCH,CADD;AAwCA;;AAED,SACC,8BAGG,CAAE7G,YAAF,IAAkB0H,QAHrB,EAIGb,GAJH,EAKG/E,WAAW,KACV,CAAE9E,QAAQ,CAAC0M,OAAT,CAAkB5K,OAAlB,CAAF,IAAiCqB,UADvB,CAAX,IAEA,cAAC,QAAD;AACC,IAAA,UAAU,EAAC,SADZ;AAEC,IAAA,SAAS,EAAG1C,iCAAiC,CAC5C,SAD4C,CAF9C;AAKC,IAAA,GAAG,EAAG6H,UALP;AAMC,IAAA,OAAO,EAAC,YANT;AAOC,kBAAanH,EAAE,CAAE,oBAAF,CAPhB;AAQC,IAAA,WAAW,EAAGA,EAAE,CAAE,aAAF,CARjB;AASC,IAAA,KAAK,EAAGW,OATT;AAUC,IAAA,QAAQ,EAAKc,KAAF,IACVM,aAAa,CAAE;AAAEpB,MAAAA,OAAO,EAAEc;AAAX,KAAF,CAXf;AAaC,IAAA,aAAa,MAbd;AAcC,IAAA,sBAAsB,EAAG,MACxBQ,iBAAiB,CAChB5B,WAAW,CAAEC,mBAAmB,EAArB,CADK;AAfnB,IAPH,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tTextControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tBlockAlignmentControl,\n\t__experimentalImageEditor as ImageEditor,\n\t__experimentalGetElementClassName,\n\t__experimentalUseBorderProps as useBorderProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tcrop,\n\toverlayText,\n\tupload,\n\tcaption as captionIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport useClientWidth from './use-client-width';\nimport { isExternalImage } from './edit';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';\nimport { evalAspectRatio } from './utils';\n\nconst { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nexport default function Image( {\n\ttemporaryURL,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontainerRef,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t} = attributes;\n\tconst imageRef = useRef();\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst { allowResize = true } = context;\n\tconst { getBlock } = useSelect( blockEditorStore );\n\n\tconst { image, multiImageSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia } = select( coreStore );\n\t\t\tconst { getMultiSelectedBlockClientIds, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst multiSelectedClientIds = getMultiSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tid && isSelected\n\t\t\t\t\t\t? getMedia( id, { context: 'view' } )\n\t\t\t\t\t\t: null,\n\t\t\t\tmultiImageSelection:\n\t\t\t\t\tmultiSelectedClientIds.length &&\n\t\t\t\t\tmultiSelectedClientIds.every(\n\t\t\t\t\t\t( _clientId ) =>\n\t\t\t\t\t\t\tgetBlockName( _clientId ) === 'core/image'\n\t\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id, isSelected ]\n\t);\n\tconst { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetSettings,\n\t\t\t\t\tcanInsertBlockType,\n\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst settings = getSettings();\n\n\t\t\t\treturn {\n\t\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t\t'core/cover',\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst [ externalBlob, setExternalBlob ] = useState();\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! ( isWideAligned && isLargeViewport );\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\tconst canUploadMedia = !! mediaUpload;\n\n\t// If an image is externally hosted, try to fetch the image data. This may\n\t// fail if the image host doesn't allow CORS with the domain. If it works,\n\t// we can enable a button in the toolbar to upload the image.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isExternalImage( id, url ) ||\n\t\t\t! isSelected ||\n\t\t\t! canUploadMedia\n\t\t) {\n\t\t\tsetExternalBlob();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( externalBlob ) return;\n\n\t\twindow\n\t\t\t// Avoid cache, which seems to help avoid CORS problems.\n\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t.then( ( response ) => response.blob() )\n\t\t\t.then( ( blob ) => setExternalBlob( blob ) )\n\t\t\t// Do nothing, cannot upload.\n\t\t\t.catch( () => {} );\n\t}, [ id, url, isSelected, externalBlob, canUploadMedia ] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\t// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageRef.current?.naturalWidth ||\n\t\t\t\tloadedNaturalWidth ||\n\t\t\t\tundefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageRef.current?.naturalHeight ||\n\t\t\t\tloadedNaturalHeight ||\n\t\t\t\tundefined,\n\t\t};\n\t}, [\n\t\tloadedNaturalWidth,\n\t\tloadedNaturalHeight,\n\t\timageRef.current?.complete,\n\t] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tfunction onImageError() {\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\n\t\tif ( undefined !== embedBlock ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tmediaUpload( {\n\t\t\tfilesList: [ externalBlob ],\n\t\t\tonFileChange( [ img ] ) {\n\t\t\t\tonSelectImage( img );\n\n\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetExternalBlob();\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? { width: undefined, height: undefined }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t\tif ( ! caption ) {\n\t\t\t\tsetShowCaption( false );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tconst canEditImage = id && naturalWidth && naturalHeight && imageEditing;\n\tconst allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox and ImageEditor components. Calculations later on\n\t// for those components are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowCrop && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => setIsEditingImage( true ) }\n\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\tlabel={ __( 'Crop' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && canInsertCover && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ ! multiImageSelection && externalBlob && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload external image' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t\tscale: undefined,\n\t\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ! multiImageSelection && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t\thasValue={ () => alt !== '' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tvalue={ alt }\n\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/WAI/tutorials/images/decision-tree\">\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<DimensionsTool\n\t\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t\twidth: width && `${ width }px`,\n\t\t\t\t\t\t\theight: height && `${ height }px`,\n\t\t\t\t\t\t\tscale,\n\t\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\tnewValue.width &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.width, 10 ),\n\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\tnewValue.height &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.height, 10 ),\n\t\t\t\t\t\t\t\tscale: newValue.scale,\n\t\t\t\t\t\t\t\taspectRatio: newValue.aspectRatio,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdefaultScale=\"cover\"\n\t\t\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\t\t\tscaleOptions={ scaleOptions }\n\t\t\t\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t\t\t\t/>\n\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\thelp={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Describe the role of this image on the page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'(Note: many devices and browsers do not display this text.)'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst isRounded = attributes.className?.includes( 'is-style-rounded' );\n\n\tlet img = (\n\t\t// Disable reason: Image itself is not meant to be interactive, but\n\t\t// should direct focus to block.\n\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\talt={ defaultedAlt }\n\t\t\t\tonError={ () => onImageError() }\n\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\tsetLoadedNaturalSize( {\n\t\t\t\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\t\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tref={ imageRef }\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : 'inherit',\n\t\t\t\t\theight:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : 'inherit',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ temporaryURL && <Spinner /> }\n\t\t</>\n\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t);\n\n\t// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0\n\t// So we try using the imageRef width first and fallback to clientWidth.\n\tconst fallbackClientWidth = imageRef.current?.width || clientWidth;\n\n\tif ( canEditImage && isEditingImage ) {\n\t\timg = (\n\t\t\t<ImageEditor\n\t\t\t\tid={ id }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ width }\n\t\t\t\theight={ height }\n\t\t\t\tclientWidth={ fallbackClientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) =>\n\t\t\t\t\tsetAttributes( imageAttributes )\n\t\t\t\t}\n\t\t\t\tonFinishEditing={ () => {\n\t\t\t\t\tsetIsEditingImage( false );\n\t\t\t\t} }\n\t\t\t\tborderProps={ isRounded ? undefined : borderProps }\n\t\t\t/>\n\t\t);\n\t} else if ( ! isResizable ) {\n\t\timg = <div style={ { width, height, aspectRatio } }>{ img }</div>;\n\t} else {\n\t\tconst ratio =\n\t\t\t( aspectRatio && evalAspectRatio( aspectRatio ) ) ||\n\t\t\t( width && height && width / height ) ||\n\t\t\tnaturalWidth / naturalHeight ||\n\t\t\t1;\n\n\t\tconst currentWidth = ! width && height ? height * ratio : width;\n\t\tconst currentHeight = ! height && width ? width / ratio : height;\n\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\n\t\timg = (\n\t\t\t<ResizableBox\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! width && ! height && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} }\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth ?? 'auto',\n\t\t\t\t\theight: currentHeight ?? 'auto',\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxWidthBuffer }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxWidthBuffer / ratio }\n\t\t\t\tlockAspectRatio={ ratio }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResizeStop={ ( event, direction, elt ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: elt.offsetWidth,\n\t\t\t\t\t\theight: elt.offsetHeight,\n\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</ResizableBox>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Hide controls during upload to avoid component remount,\n\t\t\t\twhich causes duplicated image upload. */ }\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ img }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Image caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/image/image.js"],"names":["isBlobURL","ExternalLink","ResizableBox","Spinner","TextareaControl","TextControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUseCustomUnits","useCustomUnits","useViewportMatch","usePrevious","useSelect","useDispatch","BlockControls","InspectorControls","RichText","__experimentalImageURLInputUI","ImageURLInputUI","MediaReplaceFlow","store","blockEditorStore","BlockAlignmentControl","__experimentalImageEditor","ImageEditor","__experimentalGetElementClassName","__experimentalUseBorderProps","useBorderProps","privateApis","blockEditorPrivateApis","useEffect","useMemo","useState","useRef","useCallback","__","_x","sprintf","isRTL","getFilename","createBlock","getDefaultBlockName","switchToBlockType","crop","overlayText","upload","caption","captionIcon","noticesStore","coreStore","unlock","createUpgradedEmbedBlock","useClientWidth","isExternalImage","MIN_SIZE","ALLOWED_MEDIA_TYPES","evalAspectRatio","DimensionsTool","ResolutionTool","scaleOptions","value","label","help","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","imageRef","prevCaption","showCaption","setShowCaption","allowResize","getBlock","image","multiImageSelection","select","getMedia","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","createErrorNotice","createSuccessNotice","isLargeViewport","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","window","fetch","then","response","blob","catch","captionRef","node","focus","naturalWidth","naturalHeight","current","undefined","complete","onResizeStart","onResizeStop","onImageError","embedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","type","allowedTypes","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","dimensionsUnitsOptions","availableUnits","controls","link","newValue","parseInt","filename","defaultedAlt","borderProps","isRounded","className","event","target","objectFit","style","fallbackClientWidth","imageAttributes","ratio","currentWidth","currentHeight","minWidth","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","top","right","bottom","left","direction","elt","offsetWidth","offsetHeight","isEmpty"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SACCC,YADD,EAECC,YAFD,EAGCC,OAHD,EAICC,eAJD,EAKCC,WALD,EAMCC,aAND,EAOCC,YAPD,EAQCC,wBAAwB,IAAIC,UAR7B,EASCC,4BAA4B,IAAIC,cATjC,EAUCC,4BAA4B,IAAIC,cAVjC,QAWO,uBAXP;AAYA,SAASC,gBAAT,EAA2BC,WAA3B,QAA8C,oBAA9C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,aADD,EAECC,iBAFD,EAGCC,QAHD,EAICC,6BAA6B,IAAIC,eAJlC,EAKCC,gBALD,EAMCC,KAAK,IAAIC,gBANV,EAOCC,qBAPD,EAQCC,yBAAyB,IAAIC,WAR9B,EASCC,iCATD,EAUCC,4BAA4B,IAAIC,cAVjC,EAWCC,WAAW,IAAIC,sBAXhB,QAYO,yBAZP;AAaA,SACCC,SADD,EAECC,OAFD,EAGCC,QAHD,EAICC,MAJD,EAKCC,WALD,QAMO,oBANP;AAOA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,E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WAAW,EAAG7E,KAAK,KAAK,QAAV,GAAqB,CAArB,GAAyB;AAlCxC,OAoCG8F,GApCH,CADD;AAwCA;;AAED,SACC,8BAGG,CAAE7G,YAAF,IAAkB0H,QAHrB,EAIGb,GAJH,EAKG/E,WAAW,KACV,CAAE9E,QAAQ,CAAC0M,OAAT,CAAkB5K,OAAlB,CAAF,IAAiCqB,UADvB,CAAX,IAEA,cAAC,QAAD;AACC,IAAA,UAAU,EAAC,SADZ;AAEC,IAAA,SAAS,EAAG1C,iCAAiC,CAC5C,SAD4C,CAF9C;AAKC,IAAA,GAAG,EAAG6H,UALP;AAMC,IAAA,OAAO,EAAC,YANT;AAOC,kBAAanH,EAAE,CAAE,oBAAF,CAPhB;AAQC,IAAA,WAAW,EAAGA,EAAE,CAAE,aAAF,CARjB;AASC,IAAA,KAAK,EAAGW,OATT;AAUC,IAAA,QAAQ,EAAKc,KAAF,IACVM,aAAa,CAAE;AAAEpB,MAAAA,OAAO,EAAEc;AAAX,KAAF,CAXf;AAaC,IAAA,aAAa,MAbd;AAcC,IAAA,sBAAsB,EAAG,MACxBQ,iBAAiB,CAChB5B,WAAW,CAAEC,mBAAmB,EAArB,CADK;AAfnB,IAPH,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tTextControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tBlockAlignmentControl,\n\t__experimentalImageEditor as ImageEditor,\n\t__experimentalGetElementClassName,\n\t__experimentalUseBorderProps as useBorderProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tcrop,\n\toverlayText,\n\tupload,\n\tcaption as captionIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport useClientWidth from './use-client-width';\nimport { isExternalImage } from './edit';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';\nimport { evalAspectRatio } from './utils';\n\nconst { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nexport default function Image( {\n\ttemporaryURL,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontainerRef,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t} = attributes;\n\tconst imageRef = useRef();\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst { allowResize = true } = context;\n\tconst { getBlock } = useSelect( blockEditorStore );\n\n\tconst { image, multiImageSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia } = select( coreStore );\n\t\t\tconst { getMultiSelectedBlockClientIds, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst multiSelectedClientIds = getMultiSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tid && isSelected\n\t\t\t\t\t\t? getMedia( id, { context: 'view' } )\n\t\t\t\t\t\t: null,\n\t\t\t\tmultiImageSelection:\n\t\t\t\t\tmultiSelectedClientIds.length &&\n\t\t\t\t\tmultiSelectedClientIds.every(\n\t\t\t\t\t\t( _clientId ) =>\n\t\t\t\t\t\t\tgetBlockName( _clientId ) === 'core/image'\n\t\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id, isSelected ]\n\t);\n\tconst { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetSettings,\n\t\t\t\t\tcanInsertBlockType,\n\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst settings = getSettings();\n\n\t\t\t\treturn {\n\t\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t\t'core/cover',\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst [ externalBlob, setExternalBlob ] = useState();\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! ( isWideAligned && isLargeViewport );\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\tconst canUploadMedia = !! mediaUpload;\n\n\t// If an image is externally hosted, try to fetch the image data. This may\n\t// fail if the image host doesn't allow CORS with the domain. If it works,\n\t// we can enable a button in the toolbar to upload the image.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isExternalImage( id, url ) ||\n\t\t\t! isSelected ||\n\t\t\t! canUploadMedia\n\t\t) {\n\t\t\tsetExternalBlob();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( externalBlob ) return;\n\n\t\twindow\n\t\t\t// Avoid cache, which seems to help avoid CORS problems.\n\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t.then( ( response ) => response.blob() )\n\t\t\t.then( ( blob ) => setExternalBlob( blob ) )\n\t\t\t// Do nothing, cannot upload.\n\t\t\t.catch( () => {} );\n\t}, [ id, url, isSelected, externalBlob, canUploadMedia ] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\t// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageRef.current?.naturalWidth ||\n\t\t\t\tloadedNaturalWidth ||\n\t\t\t\tundefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageRef.current?.naturalHeight ||\n\t\t\t\tloadedNaturalHeight ||\n\t\t\t\tundefined,\n\t\t};\n\t}, [\n\t\tloadedNaturalWidth,\n\t\tloadedNaturalHeight,\n\t\timageRef.current?.complete,\n\t] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tfunction onImageError() {\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\n\t\tif ( undefined !== embedBlock ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tmediaUpload( {\n\t\t\tfilesList: [ externalBlob ],\n\t\t\tonFileChange( [ img ] ) {\n\t\t\t\tonSelectImage( img );\n\n\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetExternalBlob();\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? { width: undefined, height: undefined }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t\tif ( ! caption ) {\n\t\t\t\tsetShowCaption( false );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tconst canEditImage = id && naturalWidth && naturalHeight && imageEditing;\n\tconst allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox and ImageEditor components. Calculations later on\n\t// for those components are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowCrop && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => setIsEditingImage( true ) }\n\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\tlabel={ __( 'Crop' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && canInsertCover && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ ! multiImageSelection && externalBlob && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload external image' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t\tscale: undefined,\n\t\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ! multiImageSelection && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t\thasValue={ () => alt !== '' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tvalue={ alt }\n\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/WAI/tutorials/images/decision-tree\">\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<DimensionsTool\n\t\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t\twidth: width && `${ width }px`,\n\t\t\t\t\t\t\theight: height && `${ height }px`,\n\t\t\t\t\t\t\tscale,\n\t\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\tnewValue.width &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.width, 10 ),\n\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\tnewValue.height &&\n\t\t\t\t\t\t\t\t\tparseInt( newValue.height, 10 ),\n\t\t\t\t\t\t\t\tscale: newValue.scale,\n\t\t\t\t\t\t\t\taspectRatio: newValue.aspectRatio,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdefaultScale=\"cover\"\n\t\t\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\t\t\tscaleOptions={ scaleOptions }\n\t\t\t\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t\t\t\t/>\n\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\thelp={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Describe the role of this image on the page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'(Note: many devices and browsers do not display this text.)'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst isRounded = attributes.className?.includes( 'is-style-rounded' );\n\n\tlet img = (\n\t\t// Disable reason: Image itself is not meant to be interactive, but\n\t\t// should direct focus to block.\n\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\talt={ defaultedAlt }\n\t\t\t\tonError={ () => onImageError() }\n\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\tsetLoadedNaturalSize( {\n\t\t\t\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\t\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tref={ imageRef }\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\theight:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ temporaryURL && <Spinner /> }\n\t\t</>\n\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t);\n\n\t// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0\n\t// So we try using the imageRef width first and fallback to clientWidth.\n\tconst fallbackClientWidth = imageRef.current?.width || clientWidth;\n\n\tif ( canEditImage && isEditingImage ) {\n\t\timg = (\n\t\t\t<ImageEditor\n\t\t\t\tid={ id }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ width }\n\t\t\t\theight={ height }\n\t\t\t\tclientWidth={ fallbackClientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) =>\n\t\t\t\t\tsetAttributes( imageAttributes )\n\t\t\t\t}\n\t\t\t\tonFinishEditing={ () => {\n\t\t\t\t\tsetIsEditingImage( false );\n\t\t\t\t} }\n\t\t\t\tborderProps={ isRounded ? undefined : borderProps }\n\t\t\t/>\n\t\t);\n\t} else if ( ! isResizable ) {\n\t\timg = <div style={ { width, height, aspectRatio } }>{ img }</div>;\n\t} else {\n\t\tconst ratio =\n\t\t\t( aspectRatio && evalAspectRatio( aspectRatio ) ) ||\n\t\t\t( width && height && width / height ) ||\n\t\t\tnaturalWidth / naturalHeight ||\n\t\t\t1;\n\n\t\tconst currentWidth = ! width && height ? height * ratio : width;\n\t\tconst currentHeight = ! height && width ? width / ratio : height;\n\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\n\t\timg = (\n\t\t\t<ResizableBox\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! width && ! height && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} }\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth ?? 'auto',\n\t\t\t\t\theight: currentHeight ?? 'auto',\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxWidthBuffer }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxWidthBuffer / ratio }\n\t\t\t\tlockAspectRatio={ ratio }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResizeStop={ ( event, direction, elt ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: elt.offsetWidth,\n\t\t\t\t\t\theight: elt.offsetHeight,\n\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</ResizableBox>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Hide controls during upload to avoid component remount,\n\t\t\t\twhich causes duplicated image upload. */ }\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ img }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Image caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</>\n\t);\n}\n"]}
|
|
@@ -7,6 +7,11 @@ import { cloneBlock } from '@wordpress/blocks';
|
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
8
|
import { useEffect } from '@wordpress/element';
|
|
9
9
|
import { store as blockEditorStore, useBlockProps } from '@wordpress/block-editor';
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { unlock } from '../lock-unlock';
|
|
10
15
|
|
|
11
16
|
const PatternEdit = ({
|
|
12
17
|
attributes,
|
|
@@ -16,7 +21,14 @@ const PatternEdit = ({
|
|
|
16
21
|
const {
|
|
17
22
|
replaceBlocks,
|
|
18
23
|
__unstableMarkNextChangeAsNotPersistent
|
|
19
|
-
} = useDispatch(blockEditorStore);
|
|
24
|
+
} = useDispatch(blockEditorStore);
|
|
25
|
+
const {
|
|
26
|
+
setBlockEditingMode
|
|
27
|
+
} = unlock(useDispatch(blockEditorStore));
|
|
28
|
+
const {
|
|
29
|
+
getBlockRootClientId,
|
|
30
|
+
getBlockEditingMode
|
|
31
|
+
} = unlock(useSelect(blockEditorStore)); // Run this effect when the component loads.
|
|
20
32
|
// This adds the Pattern's contents to the post.
|
|
21
33
|
// This change won't be saved.
|
|
22
34
|
// It will continue to pull from the pattern file unless changes are made to its respective template part.
|
|
@@ -29,16 +41,27 @@ const PatternEdit = ({
|
|
|
29
41
|
// because nested pattern blocks cannot be inserted if the parent block supports
|
|
30
42
|
// inner blocks but doesn't have blockSettings in the state.
|
|
31
43
|
window.queueMicrotask(() => {
|
|
32
|
-
// Clone blocks from the pattern before insertion to ensure they receive
|
|
44
|
+
const rootClientId = getBlockRootClientId(clientId); // Clone blocks from the pattern before insertion to ensure they receive
|
|
33
45
|
// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.
|
|
46
|
+
|
|
34
47
|
const clonedBlocks = selectedPattern.blocks.map(block => cloneBlock(block));
|
|
48
|
+
const rootEditingMode = getBlockEditingMode(rootClientId); // Temporarily set the root block to default mode to allow replacing the pattern.
|
|
49
|
+
// This could happen when the page is disabling edits of non-content blocks.
|
|
50
|
+
|
|
51
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
52
|
+
|
|
53
|
+
setBlockEditingMode(rootClientId, 'default');
|
|
54
|
+
|
|
55
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
56
|
+
|
|
57
|
+
replaceBlocks(clientId, clonedBlocks); // Restore the root block's original mode.
|
|
35
58
|
|
|
36
59
|
__unstableMarkNextChangeAsNotPersistent();
|
|
37
60
|
|
|
38
|
-
|
|
61
|
+
setBlockEditingMode(rootClientId, rootEditingMode);
|
|
39
62
|
});
|
|
40
63
|
}
|
|
41
|
-
}, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks]);
|
|
64
|
+
}, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks, getBlockEditingMode, setBlockEditingMode, getBlockRootClientId]);
|
|
42
65
|
const props = useBlockProps();
|
|
43
66
|
return createElement("div", { ...props
|
|
44
67
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/pattern/edit.js"],"names":["cloneBlock","useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockProps","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","blocks","window","queueMicrotask","clonedBlocks","map","block","props"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,mBAA3B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SACCC,KAAK,IAAIC,gBADV,EAECC,aAFD,QAGO,yBAHP;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/pattern/edit.js"],"names":["cloneBlock","useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockProps","unlock","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","blocks","window","queueMicrotask","rootClientId","clonedBlocks","map","block","rootEditingMode","props"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAA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mBAAmB,CAAEM,YAAF,EAAgB,SAAhB,CAAnB;;AACAP,QAAAA,uCAAuC;;AACvCD,QAAAA,aAAa,CAAEL,QAAF,EAAYc,YAAZ,CAAb,CAb4B,CAc5B;;AACAR,QAAAA,uCAAuC;;AACvCC,QAAAA,mBAAmB,CAAEM,YAAF,EAAgBI,eAAhB,CAAnB;AACA,OAjBD;AAkBA;AACD,GA1BQ,EA0BN,CACFjB,QADE,EAEFC,eAAe,EAAES,MAFf,EAGFJ,uCAHE,EAIFD,aAJE,EAKFI,mBALE,EAMFF,mBANE,EAOFC,oBAPE,CA1BM,CAAT;AAoCA,QAAMU,KAAK,GAAGtB,aAAa,EAA3B;AAEA,SAAO,0BAAUsB;AAAV,IAAP;AACA,CA3DD;;AA6DA,eAAepB,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = unlock( useDispatch( blockEditorStore ) );\n\tconst { getBlockRootClientId, getBlockEditingMode } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "8.12.
|
|
3
|
+
"version": "8.12.15",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"@wordpress/api-fetch": "^6.32.1",
|
|
38
38
|
"@wordpress/autop": "^3.35.1",
|
|
39
39
|
"@wordpress/blob": "^3.35.1",
|
|
40
|
-
"@wordpress/block-editor": "^12.3.
|
|
41
|
-
"@wordpress/blocks": "^12.12.
|
|
40
|
+
"@wordpress/block-editor": "^12.3.12",
|
|
41
|
+
"@wordpress/blocks": "^12.12.7",
|
|
42
42
|
"@wordpress/components": "^25.1.10",
|
|
43
43
|
"@wordpress/compose": "^6.12.2",
|
|
44
|
-
"@wordpress/core-data": "^6.12.
|
|
44
|
+
"@wordpress/core-data": "^6.12.13",
|
|
45
45
|
"@wordpress/data": "^9.5.5",
|
|
46
46
|
"@wordpress/date": "^4.35.1",
|
|
47
47
|
"@wordpress/deprecated": "^3.35.1",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@wordpress/notices": "^4.3.5",
|
|
57
57
|
"@wordpress/primitives": "^3.33.1",
|
|
58
58
|
"@wordpress/private-apis": "^0.17.2",
|
|
59
|
-
"@wordpress/reusable-blocks": "^4.12.
|
|
59
|
+
"@wordpress/reusable-blocks": "^4.12.13",
|
|
60
60
|
"@wordpress/rich-text": "^6.12.7",
|
|
61
|
-
"@wordpress/server-side-render": "^4.12.
|
|
61
|
+
"@wordpress/server-side-render": "^4.12.12",
|
|
62
62
|
"@wordpress/url": "^3.36.1",
|
|
63
63
|
"@wordpress/viewport": "^5.12.5",
|
|
64
64
|
"@wordpress/wordcount": "^3.35.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "cfdd2a100c5301e4b37123b21e3499f48a6fcbaf"
|
|
87
87
|
}
|
package/src/footnotes/format.js
CHANGED
|
@@ -26,6 +26,10 @@ import { unlock } from '../lock-unlock';
|
|
|
26
26
|
const { usesContextKey } = unlock( privateApis );
|
|
27
27
|
|
|
28
28
|
export const formatName = 'core/footnote';
|
|
29
|
+
|
|
30
|
+
const POST_CONTENT_BLOCK_NAME = 'core/post-content';
|
|
31
|
+
const SYNCED_PATTERN_BLOCK_NAME = 'core/block';
|
|
32
|
+
|
|
29
33
|
export const format = {
|
|
30
34
|
title: __( 'Footnote' ),
|
|
31
35
|
tagName: 'sup',
|
|
@@ -44,13 +48,30 @@ export const format = {
|
|
|
44
48
|
const registry = useRegistry();
|
|
45
49
|
const {
|
|
46
50
|
getSelectedBlockClientId,
|
|
51
|
+
getBlocks,
|
|
47
52
|
getBlockRootClientId,
|
|
48
53
|
getBlockName,
|
|
49
|
-
|
|
54
|
+
getBlockParentsByBlockName,
|
|
50
55
|
} = useSelect( blockEditorStore );
|
|
51
56
|
const footnotesBlockType = useSelect( ( select ) =>
|
|
52
57
|
select( blocksStore ).getBlockType( name )
|
|
53
58
|
);
|
|
59
|
+
/*
|
|
60
|
+
* This useSelect exists because we need to use its return value
|
|
61
|
+
* outside the event callback.
|
|
62
|
+
*/
|
|
63
|
+
const isBlockWithinPattern = useSelect( ( select ) => {
|
|
64
|
+
const {
|
|
65
|
+
getBlockParentsByBlockName: _getBlockParentsByBlockName,
|
|
66
|
+
getSelectedBlockClientId: _getSelectedBlockClientId,
|
|
67
|
+
} = select( blockEditorStore );
|
|
68
|
+
const parentCoreBlocks = _getBlockParentsByBlockName(
|
|
69
|
+
_getSelectedBlockClientId(),
|
|
70
|
+
SYNCED_PATTERN_BLOCK_NAME
|
|
71
|
+
);
|
|
72
|
+
return parentCoreBlocks && parentCoreBlocks.length > 0;
|
|
73
|
+
}, [] );
|
|
74
|
+
|
|
54
75
|
const { selectionChange, insertBlock } =
|
|
55
76
|
useDispatch( blockEditorStore );
|
|
56
77
|
|
|
@@ -62,6 +83,11 @@ export const format = {
|
|
|
62
83
|
return null;
|
|
63
84
|
}
|
|
64
85
|
|
|
86
|
+
// Checks if the selected block lives within a pattern.
|
|
87
|
+
if ( isBlockWithinPattern ) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
65
91
|
function onClick() {
|
|
66
92
|
registry.batch( () => {
|
|
67
93
|
let id;
|
|
@@ -86,10 +112,27 @@ export const format = {
|
|
|
86
112
|
onChange( newValue );
|
|
87
113
|
}
|
|
88
114
|
|
|
115
|
+
const selectedClientId = getSelectedBlockClientId();
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Attempts to find a common parent post content block.
|
|
119
|
+
* This allows for locating blocks within a page edited in the site editor.
|
|
120
|
+
*/
|
|
121
|
+
const parentPostContent = getBlockParentsByBlockName(
|
|
122
|
+
selectedClientId,
|
|
123
|
+
POST_CONTENT_BLOCK_NAME
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// When called with a post content block, getBlocks will return
|
|
127
|
+
// the block with controlled inner blocks included.
|
|
128
|
+
const blocks = parentPostContent.length
|
|
129
|
+
? getBlocks( parentPostContent[ 0 ] )
|
|
130
|
+
: getBlocks();
|
|
131
|
+
|
|
89
132
|
// BFS search to find the first footnote block.
|
|
90
133
|
let fnBlock = null;
|
|
91
134
|
{
|
|
92
|
-
const queue = [ ...
|
|
135
|
+
const queue = [ ...blocks ];
|
|
93
136
|
while ( queue.length ) {
|
|
94
137
|
const block = queue.shift();
|
|
95
138
|
if ( block.name === name ) {
|
|
@@ -104,12 +147,11 @@ export const format = {
|
|
|
104
147
|
// When there is no footnotes block in the post, create one and
|
|
105
148
|
// insert it at the bottom.
|
|
106
149
|
if ( ! fnBlock ) {
|
|
107
|
-
|
|
108
|
-
let rootClientId = getBlockRootClientId( clientId );
|
|
150
|
+
let rootClientId = getBlockRootClientId( selectedClientId );
|
|
109
151
|
|
|
110
152
|
while (
|
|
111
153
|
rootClientId &&
|
|
112
|
-
getBlockName( rootClientId ) !==
|
|
154
|
+
getBlockName( rootClientId ) !== POST_CONTENT_BLOCK_NAME
|
|
113
155
|
) {
|
|
114
156
|
rootClientId = getBlockRootClientId( rootClientId );
|
|
115
157
|
}
|
package/src/footnotes/index.php
CHANGED
|
@@ -34,7 +34,7 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
|
|
|
34
34
|
|
|
35
35
|
$footnotes = json_decode( $footnotes, true );
|
|
36
36
|
|
|
37
|
-
if ( count( $footnotes ) === 0 ) {
|
|
37
|
+
if ( ! is_array( $footnotes ) || count( $footnotes ) === 0 ) {
|
|
38
38
|
return '';
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -98,7 +98,7 @@ function wp_save_footnotes_meta( $revision_id ) {
|
|
|
98
98
|
|
|
99
99
|
if ( $footnotes ) {
|
|
100
100
|
// Can't use update_post_meta() because it doesn't allow revisions.
|
|
101
|
-
update_metadata( 'post', $revision_id, 'footnotes', $footnotes );
|
|
101
|
+
update_metadata( 'post', $revision_id, 'footnotes', wp_slash( $footnotes ) );
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -154,15 +154,14 @@ function wp_add_footnotes_revisions_to_post_meta( $post ) {
|
|
|
154
154
|
|
|
155
155
|
if ( $footnotes ) {
|
|
156
156
|
// Can't use update_post_meta() because it doesn't allow revisions.
|
|
157
|
-
update_metadata( 'post', $wp_temporary_footnote_revision_id, 'footnotes', $footnotes );
|
|
157
|
+
update_metadata( 'post', $wp_temporary_footnote_revision_id, 'footnotes', wp_slash( $footnotes ) );
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
163
|
+
add_action( 'rest_after_insert_post', 'wp_add_footnotes_revisions_to_post_meta' );
|
|
164
|
+
add_action( 'rest_after_insert_page', 'wp_add_footnotes_revisions_to_post_meta' );
|
|
166
165
|
|
|
167
166
|
/**
|
|
168
167
|
* Restores the footnotes meta value from the revision.
|
|
@@ -176,7 +175,7 @@ function wp_restore_footnotes_from_revision( $post_id, $revision_id ) {
|
|
|
176
175
|
$footnotes = get_post_meta( $revision_id, 'footnotes', true );
|
|
177
176
|
|
|
178
177
|
if ( $footnotes ) {
|
|
179
|
-
update_post_meta( $post_id, 'footnotes', $footnotes );
|
|
178
|
+
update_post_meta( $post_id, 'footnotes', wp_slash( $footnotes ) );
|
|
180
179
|
} else {
|
|
181
180
|
delete_post_meta( $post_id, 'footnotes' );
|
|
182
181
|
}
|
|
@@ -211,4 +210,77 @@ add_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' );
|
|
|
211
210
|
function wp_get_footnotes_from_revision( $revision_field, $field, $revision ) {
|
|
212
211
|
return get_metadata( 'post', $revision->ID, $field, true );
|
|
213
212
|
}
|
|
214
|
-
add_filter( '
|
|
213
|
+
add_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision', 10, 3 );
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The REST API autosave endpoint doesn't save meta, so we can use the
|
|
217
|
+
* `wp_creating_autosave` when it updates an exiting autosave, and
|
|
218
|
+
* `_wp_put_post_revision` when it creates a new autosave.
|
|
219
|
+
*
|
|
220
|
+
* @since 6.3.0
|
|
221
|
+
*
|
|
222
|
+
* @param int|array $autosave The autosave ID or array.
|
|
223
|
+
*/
|
|
224
|
+
function _wp_rest_api_autosave_meta( $autosave ) {
|
|
225
|
+
// Ensure it's a REST API request.
|
|
226
|
+
if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
$body = rest_get_server()->get_raw_data();
|
|
231
|
+
$body = json_decode( $body, true );
|
|
232
|
+
|
|
233
|
+
if ( ! isset( $body['meta']['footnotes'] ) ) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// `wp_creating_autosave` passes the array,
|
|
238
|
+
// `_wp_put_post_revision` passes the ID.
|
|
239
|
+
$id = is_int( $autosave ) ? $autosave : $autosave['ID'];
|
|
240
|
+
|
|
241
|
+
if ( ! $id ) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
update_post_meta( $id, 'footnotes', wp_slash( $body['meta']['footnotes'] ) );
|
|
246
|
+
}
|
|
247
|
+
// See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L391C1-L391C1.
|
|
248
|
+
add_action( 'wp_creating_autosave', '_wp_rest_api_autosave_meta' );
|
|
249
|
+
// See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L398.
|
|
250
|
+
// Then https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/revision.php#L367.
|
|
251
|
+
add_action( '_wp_put_post_revision', '_wp_rest_api_autosave_meta' );
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* This is a workaround for the autosave endpoint returning early if the
|
|
255
|
+
* revision field are equal. The problem is that "footnotes" is not real
|
|
256
|
+
* revision post field, so there's nothing to compare against.
|
|
257
|
+
*
|
|
258
|
+
* This trick sets the "footnotes" field (value doesn't matter), which will
|
|
259
|
+
* cause the autosave endpoint to always update the latest revision. That should
|
|
260
|
+
* be fine, it should be ok to update the revision even if nothing changed. Of
|
|
261
|
+
* course, this is temporary fix.
|
|
262
|
+
*
|
|
263
|
+
* @since 6.3.0
|
|
264
|
+
*
|
|
265
|
+
* @param WP_Post $prepared_post The prepared post object.
|
|
266
|
+
* @param WP_REST_Request $request The request object.
|
|
267
|
+
*
|
|
268
|
+
* See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L365-L384.
|
|
269
|
+
* See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L219.
|
|
270
|
+
*/
|
|
271
|
+
function _wp_rest_api_force_autosave_difference( $prepared_post, $request ) {
|
|
272
|
+
// We only want to be altering POST requests.
|
|
273
|
+
if ( $request->get_method() !== 'POST' ) {
|
|
274
|
+
return $prepared_post;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Only alter requests for the '/autosaves' route.
|
|
278
|
+
if ( substr( $request->get_route(), -strlen( '/autosaves' ) ) !== '/autosaves' ) {
|
|
279
|
+
return $prepared_post;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
$prepared_post->footnotes = '[]';
|
|
283
|
+
return $prepared_post;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
add_filter( 'rest_pre_insert_post', '_wp_rest_api_force_autosave_difference', 10, 2 );
|
package/src/image/image.js
CHANGED
|
@@ -566,9 +566,9 @@ export default function Image( {
|
|
|
566
566
|
className={ borderProps.className }
|
|
567
567
|
style={ {
|
|
568
568
|
width:
|
|
569
|
-
( width && height ) || aspectRatio ? '100%' :
|
|
569
|
+
( width && height ) || aspectRatio ? '100%' : undefined,
|
|
570
570
|
height:
|
|
571
|
-
( width && height ) || aspectRatio ? '100%' :
|
|
571
|
+
( width && height ) || aspectRatio ? '100%' : undefined,
|
|
572
572
|
objectFit: scale,
|
|
573
573
|
...borderProps.style,
|
|
574
574
|
} }
|
package/src/pattern/edit.js
CHANGED
|
@@ -9,6 +9,11 @@ import {
|
|
|
9
9
|
useBlockProps,
|
|
10
10
|
} from '@wordpress/block-editor';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { unlock } from '../lock-unlock';
|
|
16
|
+
|
|
12
17
|
const PatternEdit = ( { attributes, clientId } ) => {
|
|
13
18
|
const selectedPattern = useSelect(
|
|
14
19
|
( select ) =>
|
|
@@ -20,6 +25,10 @@ const PatternEdit = ( { attributes, clientId } ) => {
|
|
|
20
25
|
|
|
21
26
|
const { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =
|
|
22
27
|
useDispatch( blockEditorStore );
|
|
28
|
+
const { setBlockEditingMode } = unlock( useDispatch( blockEditorStore ) );
|
|
29
|
+
const { getBlockRootClientId, getBlockEditingMode } = unlock(
|
|
30
|
+
useSelect( blockEditorStore )
|
|
31
|
+
);
|
|
23
32
|
|
|
24
33
|
// Run this effect when the component loads.
|
|
25
34
|
// This adds the Pattern's contents to the post.
|
|
@@ -33,13 +42,22 @@ const PatternEdit = ( { attributes, clientId } ) => {
|
|
|
33
42
|
// because nested pattern blocks cannot be inserted if the parent block supports
|
|
34
43
|
// inner blocks but doesn't have blockSettings in the state.
|
|
35
44
|
window.queueMicrotask( () => {
|
|
45
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
36
46
|
// Clone blocks from the pattern before insertion to ensure they receive
|
|
37
47
|
// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.
|
|
38
48
|
const clonedBlocks = selectedPattern.blocks.map( ( block ) =>
|
|
39
49
|
cloneBlock( block )
|
|
40
50
|
);
|
|
51
|
+
const rootEditingMode = getBlockEditingMode( rootClientId );
|
|
52
|
+
// Temporarily set the root block to default mode to allow replacing the pattern.
|
|
53
|
+
// This could happen when the page is disabling edits of non-content blocks.
|
|
54
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
55
|
+
setBlockEditingMode( rootClientId, 'default' );
|
|
41
56
|
__unstableMarkNextChangeAsNotPersistent();
|
|
42
57
|
replaceBlocks( clientId, clonedBlocks );
|
|
58
|
+
// Restore the root block's original mode.
|
|
59
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
60
|
+
setBlockEditingMode( rootClientId, rootEditingMode );
|
|
43
61
|
} );
|
|
44
62
|
}
|
|
45
63
|
}, [
|
|
@@ -47,6 +65,9 @@ const PatternEdit = ( { attributes, clientId } ) => {
|
|
|
47
65
|
selectedPattern?.blocks,
|
|
48
66
|
__unstableMarkNextChangeAsNotPersistent,
|
|
49
67
|
replaceBlocks,
|
|
68
|
+
getBlockEditingMode,
|
|
69
|
+
setBlockEditingMode,
|
|
70
|
+
getBlockRootClientId,
|
|
50
71
|
] );
|
|
51
72
|
|
|
52
73
|
const props = useBlockProps();
|