@wordpress/block-library 8.19.7 → 8.19.9
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/image/image.js +8 -2
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +47 -34
- package/build/image/view.js.map +1 -1
- package/build/navigation/view.js +20 -5
- package/build/navigation/view.js.map +1 -1
- package/build-module/image/image.js +8 -2
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +47 -34
- package/build-module/image/view.js.map +1 -1
- package/build-module/navigation/view.js +20 -5
- package/build-module/navigation/view.js.map +1 -1
- package/build-style/image/style-rtl.css +23 -4
- package/build-style/image/style.css +23 -4
- package/build-style/style-rtl.css +23 -4
- package/build-style/style.css +23 -4
- package/package.json +32 -32
- package/src/image/image.js +13 -2
- package/src/image/index.php +16 -7
- package/src/image/style.scss +27 -4
- package/src/image/view.js +69 -48
- package/src/navigation/index.php +7 -0
- package/src/navigation/view.js +18 -6
package/build/navigation/view.js
CHANGED
|
@@ -6,14 +6,17 @@ var _interactivity = require("@wordpress/interactivity");
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const focusableSelectors = ['a[href]', 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', 'select:not([disabled]):not([aria-hidden])', 'textarea:not([disabled]):not([aria-hidden])', 'button:not([disabled]):not([aria-hidden])', '[contenteditable]', '[tabindex]:not([tabindex^="-"])'];
|
|
9
|
+
|
|
10
|
+
// This is a fix for Safari in iOS/iPadOS. Without it, Safari doesn't focus out
|
|
11
|
+
// when the user taps in the body. It can be removed once we add an overlay to
|
|
12
|
+
// capture the clicks, instead of relying on the focusout event.
|
|
13
|
+
document.addEventListener('click', () => {});
|
|
9
14
|
const openMenu = (store, menuOpenedOn) => {
|
|
10
15
|
const {
|
|
11
16
|
context,
|
|
12
|
-
ref,
|
|
13
17
|
selectors
|
|
14
18
|
} = store;
|
|
15
19
|
selectors.core.navigation.menuOpenedBy(store)[menuOpenedOn] = true;
|
|
16
|
-
context.core.navigation.previousFocus = ref;
|
|
17
20
|
if (context.core.navigation.type === 'overlay') {
|
|
18
21
|
// Add a `has-modal-open` class to the <html> root.
|
|
19
22
|
document.documentElement.classList.add('has-modal-open');
|
|
@@ -28,7 +31,7 @@ const closeMenu = (store, menuClosedOn) => {
|
|
|
28
31
|
// Check if the menu is still open or not.
|
|
29
32
|
if (!selectors.core.navigation.isMenuOpen(store)) {
|
|
30
33
|
if (context.core.navigation.modal?.contains(window.document.activeElement)) {
|
|
31
|
-
context.core.navigation.previousFocus
|
|
34
|
+
context.core.navigation.previousFocus?.focus();
|
|
32
35
|
}
|
|
33
36
|
context.core.navigation.modal = null;
|
|
34
37
|
context.core.navigation.previousFocus = null;
|
|
@@ -116,6 +119,11 @@ const closeMenu = (store, menuClosedOn) => {
|
|
|
116
119
|
closeMenu(store, 'hover');
|
|
117
120
|
},
|
|
118
121
|
openMenuOnClick(store) {
|
|
122
|
+
const {
|
|
123
|
+
context,
|
|
124
|
+
ref
|
|
125
|
+
} = store;
|
|
126
|
+
context.core.navigation.previousFocus = ref;
|
|
119
127
|
openMenu(store, 'click');
|
|
120
128
|
},
|
|
121
129
|
closeMenuOnClick(store) {
|
|
@@ -127,13 +135,18 @@ const closeMenu = (store, menuClosedOn) => {
|
|
|
127
135
|
},
|
|
128
136
|
toggleMenuOnClick: store => {
|
|
129
137
|
const {
|
|
130
|
-
selectors
|
|
138
|
+
selectors,
|
|
139
|
+
context,
|
|
140
|
+
ref
|
|
131
141
|
} = store;
|
|
142
|
+
// Safari won't send focus to the clicked element, so we need to manually place it: https://bugs.webkit.org/show_bug.cgi?id=22261
|
|
143
|
+
if (window.document.activeElement !== ref) ref.focus();
|
|
132
144
|
const menuOpenedBy = selectors.core.navigation.menuOpenedBy(store);
|
|
133
145
|
if (menuOpenedBy.click || menuOpenedBy.focus) {
|
|
134
146
|
closeMenu(store, 'click');
|
|
135
147
|
closeMenu(store, 'focus');
|
|
136
148
|
} else {
|
|
149
|
+
context.core.navigation.previousFocus = ref;
|
|
137
150
|
openMenu(store, 'click');
|
|
138
151
|
}
|
|
139
152
|
},
|
|
@@ -174,7 +187,9 @@ const closeMenu = (store, menuClosedOn) => {
|
|
|
174
187
|
// event.relatedTarget === The element receiving focus (if any)
|
|
175
188
|
// When focusout is outsite the document,
|
|
176
189
|
// `window.document.activeElement` doesn't change.
|
|
177
|
-
|
|
190
|
+
|
|
191
|
+
// The event.relatedTarget is null when something outside the navigation menu is clicked. This is only necessary for Safari.
|
|
192
|
+
if (event.relatedTarget === null || !context.core.navigation.modal?.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
|
|
178
193
|
closeMenu(store, 'click');
|
|
179
194
|
closeMenu(store, 'focus');
|
|
180
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_interactivity","require","focusableSelectors","openMenu","store","menuOpenedOn","context","ref","selectors","core","navigation","menuOpenedBy","previousFocus","type","document","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","focus","remove","wpStore","effects","initMenu","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","ariaModal","ariaLabel","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, ref, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tcontext.core.navigation.previousFocus = ref;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaModal: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaLabel: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? context.core.navigation.ariaLabel\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors } = store;\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outsite the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tevent.target !== window.document.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UACD;QACD,CAAC;QACDiC,kBAAkB,EAAItD,KAAK,IAAM;UAChC,MAAM;YAAEE,OAAO;YAAEgD;UAAM,CAAC,GAAGlD,KAAK;UAChC;UACA;UACA;UACA;UACA;UACA,IACC,CAAEE,OAAO,CAACG,IAAI,CAACC,UAAU,CAACW,KAAK,EAAEC,QAAQ,CACxCgC,KAAK,CAACK,aACP,CAAC,IACDL,KAAK,CAACM,MAAM,KAAKrC,MAAM,CAACT,QAAQ,CAACU,aAAa,EAC7C;YACDN,SAAS,CAAEd,KAAK,EAAE,OAAQ,CAAC;YAC3Bc,SAAS,CAAEd,KAAK,EAAE,OAAQ,CAAC;UAC5B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
|
|
1
|
+
{"version":3,"names":["_interactivity","require","focusableSelectors","document","addEventListener","openMenu","store","menuOpenedOn","context","selectors","core","navigation","menuOpenedBy","type","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","previousFocus","focus","remove","wpStore","effects","initMenu","ref","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","ariaModal","ariaLabel","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n// This is a fix for Safari in iOS/iPadOS. Without it, Safari doesn't focus out\n// when the user taps in the body. It can be removed once we add an overlay to\n// capture the clicks, instead of relying on the focusout event.\ndocument.addEventListener( 'click', () => {} );\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus?.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaModal: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaLabel: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? context.core.navigation.ariaLabel\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\tconst { context, ref } = store;\n\t\t\t\t\tcontext.core.navigation.previousFocus = ref;\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors, context, ref } = store;\n\t\t\t\t\t// Safari won't send focus to the clicked element, so we need to manually place it: https://bugs.webkit.org/show_bug.cgi?id=22261\n\t\t\t\t\tif ( window.document.activeElement !== ref ) ref.focus();\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontext.core.navigation.previousFocus = ref;\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outsite the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\n\t\t\t\t\t// The event.relatedTarget is null when something outside the navigation menu is clicked. This is only necessary for Safari.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.relatedTarget === null ||\n\t\t\t\t\t\t( ! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\tevent.target !== window.document.activeElement )\n\t\t\t\t\t) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,mBAAmB,EACnB,iCAAiC,CACjC;;AAED;AACA;AACA;AACAC,QAAQ,CAACC,gBAAgB,CAAE,OAAO,EAAE,MAAM,CAAC,CAAE,CAAC;AAE9C,MAAMC,QAAQ,GAAGA,CAAEC,KAAK,EAAEC,YAAY,KAAM;EAC3C,MAAM;IAAEC,OAAO;IAAEC;EAAU,CAAC,GAAGH,KAAK;EACpCG,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEN,KAAM,CAAC,CAAEC,YAAY,CAAE,GAAG,IAAI;EACtE,IAAKC,OAAO,CAACE,IAAI,CAACC,UAAU,CAACE,IAAI,KAAK,SAAS,EAAG;IACjD;IACAV,QAAQ,CAACW,eAAe,CAACC,SAAS,CAACC,GAAG,CAAE,gBAAiB,CAAC;EAC3D;AACD,CAAC;AAED,MAAMC,SAAS,G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|
|
@@ -41,6 +41,10 @@ const scaleOptions = [{
|
|
|
41
41
|
label: _x('Contain', 'Scale option for dimensions control'),
|
|
42
42
|
help: __('Image is contained without distortion.')
|
|
43
43
|
}];
|
|
44
|
+
const disabledClickProps = {
|
|
45
|
+
onClick: event => event.preventDefault(),
|
|
46
|
+
'aria-disabled': true
|
|
47
|
+
};
|
|
44
48
|
export default function Image({
|
|
45
49
|
temporaryURL,
|
|
46
50
|
attributes,
|
|
@@ -561,7 +565,6 @@ export default function Image({
|
|
|
561
565
|
}
|
|
562
566
|
}
|
|
563
567
|
/* eslint-enable no-lonely-if */
|
|
564
|
-
|
|
565
568
|
img = createElement(ResizableBox, {
|
|
566
569
|
style: {
|
|
567
570
|
display: 'block',
|
|
@@ -603,7 +606,10 @@ export default function Image({
|
|
|
603
606
|
if (!url && !temporaryURL) {
|
|
604
607
|
return sizeControls;
|
|
605
608
|
}
|
|
606
|
-
return createElement(Fragment, null, !temporaryURL && controls,
|
|
609
|
+
return createElement(Fragment, null, !temporaryURL && controls, !!href ? createElement("a", {
|
|
610
|
+
href: href,
|
|
611
|
+
...disabledClickProps
|
|
612
|
+
}, img) : img, showCaption && (!RichText.isEmpty(caption) || isSelected) && createElement(RichText, {
|
|
607
613
|
identifier: "caption",
|
|
608
614
|
className: __experimentalGetElementClassName('caption'),
|
|
609
615
|
ref: captionRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isBlobURL","ExternalLink","ResizableBox","Spinner","TextareaControl","ToggleControl","TextControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUseCustomUnits","useCustomUnits","useViewportMatch","usePrevious","useSelect","useDispatch","BlockControls","InspectorControls","RichText","__experimentalImageURLInputUI","ImageURLInputUI","MediaReplaceFlow","store","blockEditorStore","useSetting","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","lightbox","numericWidth","parseInt","undefined","numericHeight","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","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","lightboxSetting","showLightboxToggle","allowEditing","lightboxChecked","enabled","lightboxToggleDisabled","dimensionsControl","createElement","onChange","newWidth","newHeight","newScale","newAspectRatio","defaultScale","defaultAspectRatio","unitsOptions","resetAll","sizeControls","controls","Fragment","group","onClick","icon","isPressed","onChangeUrl","mediaUrl","mediaLink","link","mediaId","mediaURL","accept","onSelect","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","options","checked","newValue","disabled","filename","defaultedAlt","borderProps","isRounded","className","src","onLoad","event","target","ref","style","objectFit","fallbackClientWidth","onSaveImage","imageAttributes","onFinishEditing","numericRatio","customRatio","naturalRatio","ratio","currentWidth","currentHeight","minWidth","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","offsetWidth","String","resizeRatio","isEmpty","identifier","tagName","placeholder","inlineToolbar","__unstableOnSplitAtEnd"],"sources":["@wordpress/block-library/src/image/image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tToggleControl,\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\tuseSetting,\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\tlightbox,\n\t} = attributes;\n\n\t// The only supported unit is px, so we can parseInt to strip the px here.\n\tconst numericWidth = width ? parseInt( width, 10 ) : undefined;\n\tconst numericHeight = height ? parseInt( height, 10 ) : undefined;\n\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\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? {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\tscale: undefined,\n\t\t\t }\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 lightboxSetting = useSetting( 'lightbox' );\n\n\tconst showLightboxToggle =\n\t\t!! lightbox || lightboxSetting?.allowEditing === true;\n\n\tconst lightboxChecked =\n\t\t!! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );\n\n\tconst lightboxToggleDisabled = linkDestination !== 'none';\n\n\tconst dimensionsControl = (\n\t\t<DimensionsTool\n\t\t\tvalue={ { width, height, scale, aspectRatio } }\n\t\t\tonChange={ ( {\n\t\t\t\twidth: newWidth,\n\t\t\t\theight: newHeight,\n\t\t\t\tscale: newScale,\n\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t} ) => {\n\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\tsetAttributes( {\n\t\t\t\t\t// CSS includes `height: auto`, but we need\n\t\t\t\t\t// `width: auto` to fix the aspect ratio when\n\t\t\t\t\t// only height is set due to the width and\n\t\t\t\t\t// height attributes set via the server.\n\t\t\t\t\twidth: ! newWidth && newHeight ? 'auto' : newWidth,\n\t\t\t\t\theight: newHeight,\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdefaultScale=\"cover\"\n\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\tscaleOptions={ scaleOptions }\n\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t/>\n\t);\n\n\tconst resetAll = () => {\n\t\tsetAttributes( {\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\tscale: undefined,\n\t\t\taspectRatio: undefined,\n\t\t\tlightbox: undefined,\n\t\t} );\n\t};\n\n\tconst sizeControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>\n\t\t\t\t{ isResizable && dimensionsControl }\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\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 label={ __( 'Settings' ) } resetAll={ resetAll }>\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{ isResizable && dimensionsControl }\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\t{ showLightboxToggle && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! lightbox }\n\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { lightbox: undefined } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\t\tchecked={ lightboxChecked }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlightbox: { enabled: newValue },\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\tdisabled={ lightboxToggleDisabled }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlightboxToggleDisabled\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'“Expand on click” scales the image up, and can’t be combined with a link.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\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/>\n\t\t\t\t\t\t</ToolsPanelItem>\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={ numericWidth }\n\t\t\t\theight={ numericHeight }\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 numericRatio = aspectRatio && evalAspectRatio( aspectRatio );\n\t\tconst customRatio = numericWidth / numericHeight;\n\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\tconst ratio = numericRatio || customRatio || naturalRatio || 1;\n\t\tconst currentWidth =\n\t\t\t! numericWidth && numericHeight\n\t\t\t\t? numericHeight * ratio\n\t\t\t\t: numericWidth;\n\t\tconst currentHeight =\n\t\t\t! numericHeight && numericWidth\n\t\t\t\t? numericWidth / ratio\n\t\t\t\t: numericHeight;\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\t// Since the aspect ratio is locked when resizing, we can\n\t\t\t\t\t// use the width of the resized element to calculate the\n\t\t\t\t\t// height in CSS to prevent stretching when the max-width\n\t\t\t\t\t// is reached.\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: `${ elt.offsetWidth }px`,\n\t\t\t\t\t\theight: 'auto',\n\t\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t\tratio === naturalRatio\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: String( ratio ),\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\tif ( ! url && ! temporaryURL ) {\n\t\treturn sizeControls;\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\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,CAAE,CAAC;MACJ,CAAG;MACHsB,WAAW,EAAGhM,KAAK,KAAK,QAAQ,GAAG,CAAC,GAAG;IAAG,GAExCkG,GACW,CACd;EACF;EAEA,IAAK,CAAEpG,GAAG,IAAI,CAAEb,YAAY,EAAG;IAC9B,OAAO+I,YAAY;EACpB;EAEA,OACCV,aAAA,CAAAY,QAAA,QAGG,CAAEjJ,YAAY,IAAIgJ,QAAQ,EAC1B/B,GAAG,EACH9E,WAAW,KACV,CAAEpF,QAAQ,CAACiQ,OAAO,CAAElO,OAAQ,CAAC,IAAIqB,UAAU,CAAE,IAC9CkI,aAAA,CAACtL,QAAQ;IACRkQ,UAAU,EAAC,SAAS;IACpBvC,SAAS,EAAGjN,iCAAiC,CAC5C,SACD,CAAG;IACHsN,GAAG,EAAGpF,UAAY;IAClBuH,OAAO,EAAC,YAAY;IACpB,cAAa/O,EAAE,CAAE,oBAAqB,CAAG;IACzCgP,WAAW,EAAGhP,EAAE,CAAE,aAAc,CAAG;IACnCyB,KAAK,EAAGd,OAAS;IACjBwJ,QAAQ,EAAK1I,KAAK,IACjBM,aAAa,CAAE;MAAEpB,OAAO,EAAEc;IAAM,CAAE,CAClC;IACDwN,aAAa;IACbC,sBAAsB,EAAGA,CAAA,KACxBjN,iBAAiB,CAChB5B,WAAW,CAAEC,mBAAmB,CAAC,CAAE,CACpC;EACA,CACD,CAEF,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["isBlobURL","ExternalLink","ResizableBox","Spinner","TextareaControl","ToggleControl","TextControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUseCustomUnits","useCustomUnits","useViewportMatch","usePrevious","useSelect","useDispatch","BlockControls","InspectorControls","RichText","__experimentalImageURLInputUI","ImageURLInputUI","MediaReplaceFlow","store","blockEditorStore","useSetting","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","disabledClickProps","onClick","event","preventDefault","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","lightbox","numericWidth","parseInt","undefined","numericHeight","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","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","lightboxSetting","showLightboxToggle","allowEditing","lightboxChecked","enabled","lightboxToggleDisabled","dimensionsControl","createElement","onChange","newWidth","newHeight","newScale","newAspectRatio","defaultScale","defaultAspectRatio","unitsOptions","resetAll","sizeControls","controls","Fragment","group","icon","isPressed","onChangeUrl","mediaUrl","mediaLink","link","mediaId","mediaURL","accept","onSelect","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","options","checked","newValue","disabled","filename","defaultedAlt","borderProps","isRounded","className","src","onLoad","target","ref","style","objectFit","fallbackClientWidth","onSaveImage","imageAttributes","onFinishEditing","numericRatio","customRatio","naturalRatio","ratio","currentWidth","currentHeight","minWidth","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","offsetWidth","String","resizeRatio","isEmpty","identifier","tagName","placeholder","inlineToolbar","__unstableOnSplitAtEnd"],"sources":["@wordpress/block-library/src/image/image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tToggleControl,\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\tuseSetting,\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\nconst disabledClickProps = {\n\tonClick: ( event ) => event.preventDefault(),\n\t'aria-disabled': true,\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\tlightbox,\n\t} = attributes;\n\n\t// The only supported unit is px, so we can parseInt to strip the px here.\n\tconst numericWidth = width ? parseInt( width, 10 ) : undefined;\n\tconst numericHeight = height ? parseInt( height, 10 ) : undefined;\n\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\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? {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\tscale: undefined,\n\t\t\t }\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 lightboxSetting = useSetting( 'lightbox' );\n\n\tconst showLightboxToggle =\n\t\t!! lightbox || lightboxSetting?.allowEditing === true;\n\n\tconst lightboxChecked =\n\t\t!! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );\n\n\tconst lightboxToggleDisabled = linkDestination !== 'none';\n\n\tconst dimensionsControl = (\n\t\t<DimensionsTool\n\t\t\tvalue={ { width, height, scale, aspectRatio } }\n\t\t\tonChange={ ( {\n\t\t\t\twidth: newWidth,\n\t\t\t\theight: newHeight,\n\t\t\t\tscale: newScale,\n\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t} ) => {\n\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\tsetAttributes( {\n\t\t\t\t\t// CSS includes `height: auto`, but we need\n\t\t\t\t\t// `width: auto` to fix the aspect ratio when\n\t\t\t\t\t// only height is set due to the width and\n\t\t\t\t\t// height attributes set via the server.\n\t\t\t\t\twidth: ! newWidth && newHeight ? 'auto' : newWidth,\n\t\t\t\t\theight: newHeight,\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdefaultScale=\"cover\"\n\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\tscaleOptions={ scaleOptions }\n\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t/>\n\t);\n\n\tconst resetAll = () => {\n\t\tsetAttributes( {\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\tscale: undefined,\n\t\t\taspectRatio: undefined,\n\t\t\tlightbox: undefined,\n\t\t} );\n\t};\n\n\tconst sizeControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>\n\t\t\t\t{ isResizable && dimensionsControl }\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\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 label={ __( 'Settings' ) } resetAll={ resetAll }>\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{ isResizable && dimensionsControl }\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\t{ showLightboxToggle && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! lightbox }\n\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { lightbox: undefined } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\t\tchecked={ lightboxChecked }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlightbox: { enabled: newValue },\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\tdisabled={ lightboxToggleDisabled }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlightboxToggleDisabled\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'“Expand on click” scales the image up, and can’t be combined with a link.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\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/>\n\t\t\t\t\t\t</ToolsPanelItem>\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={ numericWidth }\n\t\t\t\theight={ numericHeight }\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 numericRatio = aspectRatio && evalAspectRatio( aspectRatio );\n\t\tconst customRatio = numericWidth / numericHeight;\n\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\tconst ratio = numericRatio || customRatio || naturalRatio || 1;\n\t\tconst currentWidth =\n\t\t\t! numericWidth && numericHeight\n\t\t\t\t? numericHeight * ratio\n\t\t\t\t: numericWidth;\n\t\tconst currentHeight =\n\t\t\t! numericHeight && numericWidth\n\t\t\t\t? numericWidth / ratio\n\t\t\t\t: numericHeight;\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\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\t// Since the aspect ratio is locked when resizing, we can\n\t\t\t\t\t// use the width of the resized element to calculate the\n\t\t\t\t\t// height in CSS to prevent stretching when the max-width\n\t\t\t\t\t// is reached.\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: `${ elt.offsetWidth }px`,\n\t\t\t\t\t\theight: 'auto',\n\t\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t\tratio === naturalRatio\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: String( ratio ),\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\tif ( ! url && ! temporaryURL ) {\n\t\treturn sizeControls;\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{ /* If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles */ }\n\t\t\t{ !! href ? (\n\t\t\t\t<a href={ href } { ...disabledClickProps }>\n\t\t\t\t\t{ img }\n\t\t\t\t</a>\n\t\t\t) : (\n\t\t\t\timg\n\t\t\t) }\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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,YAAY,EACZC,YAAY,EACZC,OAAO,EACPC,eAAe,EACfC,aAAa,EACbC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,EAC9CC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,oBAAoB;AAClE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,6BAA6B,IAAIC,eAAe,EAChDC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,UAAU,EACVC,qBAAqB,EACrBC,yBAAyB,IAAIC,WAAW,EACxCC,iCAAiC,EACjCC,4BAA4B,IAAIC,cAAc,EAC9CC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SACCC,SAAS,EACTC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,WAAW,QACL,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,EAAEC,KAAK,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SACCC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,QACX,mBAAmB;AAC1B,SACCC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,OAAO,IAAIC,WAAW,QAChB,kBAAkB;AACzB,SAAS5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D0N,aAAa;IACbC,sBAAsB,EAAGA,CAAA,KACxB/M,iBAAiB,CAChBhC,WAAW,CAAEC,mBAAmB,CAAC,CAAE,CACpC;EACA,CACD,CAEF,CAAC;AAEL"}
|
|
@@ -87,8 +87,9 @@ store({
|
|
|
87
87
|
context.core.image.initialized = true;
|
|
88
88
|
context.core.image.lastFocusedElement = window.document.activeElement;
|
|
89
89
|
context.core.image.scrollDelta = 0;
|
|
90
|
+
context.core.image.pointerType = event.pointerType;
|
|
90
91
|
context.core.image.lightboxEnabled = true;
|
|
91
|
-
setStyles(context,
|
|
92
|
+
setStyles(context, context.core.image.imageRef);
|
|
92
93
|
context.core.image.scrollTopReset = window.pageYOffset || document.documentElement.scrollTop;
|
|
93
94
|
|
|
94
95
|
// In most cases, this value will be 0, but this is included
|
|
@@ -121,11 +122,14 @@ store({
|
|
|
121
122
|
// may scroll too soon and cause the animation to look sloppy.
|
|
122
123
|
setTimeout(function () {
|
|
123
124
|
window.removeEventListener('scroll', scrollCallback);
|
|
125
|
+
// If we don't delay before changing the focus,
|
|
126
|
+
// the focus ring will appear on Firefox before
|
|
127
|
+
// the image has finished animating, which looks broken.
|
|
128
|
+
context.core.image.lightboxTriggerRef.focus({
|
|
129
|
+
preventScroll: true
|
|
130
|
+
});
|
|
124
131
|
}, 450);
|
|
125
132
|
context.core.image.lightboxEnabled = false;
|
|
126
|
-
context.core.image.lastFocusedElement.focus({
|
|
127
|
-
preventScroll: true
|
|
128
|
-
});
|
|
129
133
|
}
|
|
130
134
|
},
|
|
131
135
|
handleKeydown: ({
|
|
@@ -152,8 +156,9 @@ store({
|
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
},
|
|
159
|
+
// This is fired just by lazily loaded
|
|
160
|
+
// images on the page, not all images.
|
|
155
161
|
handleLoad: ({
|
|
156
|
-
state,
|
|
157
162
|
context,
|
|
158
163
|
effects,
|
|
159
164
|
ref
|
|
@@ -161,7 +166,6 @@ store({
|
|
|
161
166
|
context.core.image.imageLoaded = true;
|
|
162
167
|
context.core.image.imageCurrentSrc = ref.currentSrc;
|
|
163
168
|
effects.core.image.setButtonStyles({
|
|
164
|
-
state,
|
|
165
169
|
context,
|
|
166
170
|
ref
|
|
167
171
|
});
|
|
@@ -229,10 +233,12 @@ store({
|
|
|
229
233
|
effects: {
|
|
230
234
|
core: {
|
|
231
235
|
image: {
|
|
232
|
-
|
|
236
|
+
initOriginImage: ({
|
|
233
237
|
context,
|
|
234
238
|
ref
|
|
235
239
|
}) => {
|
|
240
|
+
context.core.image.imageRef = ref;
|
|
241
|
+
context.core.image.lightboxTriggerRef = ref.parentElement.querySelector('.lightbox-trigger');
|
|
236
242
|
if (ref.complete) {
|
|
237
243
|
context.core.image.imageLoaded = true;
|
|
238
244
|
context.core.image.imageCurrentSrc = ref.currentSrc;
|
|
@@ -242,17 +248,16 @@ store({
|
|
|
242
248
|
context,
|
|
243
249
|
ref
|
|
244
250
|
}) => {
|
|
245
|
-
context.core.image.figureRef = ref.querySelector('figure');
|
|
246
|
-
context.core.image.imageRef = ref.querySelector('img');
|
|
247
251
|
if (context.core.image.lightboxEnabled) {
|
|
248
252
|
const focusableElements = ref.querySelectorAll(focusableSelectors);
|
|
249
253
|
context.core.image.firstFocusableElement = focusableElements[0];
|
|
250
254
|
context.core.image.lastFocusableElement = focusableElements[focusableElements.length - 1];
|
|
251
|
-
|
|
255
|
+
|
|
256
|
+
// Move focus to the dialog when opening it.
|
|
257
|
+
ref.focus();
|
|
252
258
|
}
|
|
253
259
|
},
|
|
254
260
|
setButtonStyles: ({
|
|
255
|
-
state,
|
|
256
261
|
context,
|
|
257
262
|
ref
|
|
258
263
|
}) => {
|
|
@@ -264,43 +269,51 @@ store({
|
|
|
264
269
|
} = ref;
|
|
265
270
|
|
|
266
271
|
// If the image isn't loaded yet, we can't
|
|
267
|
-
// calculate
|
|
272
|
+
// calculate where the button should be.
|
|
268
273
|
if (naturalWidth === 0 || naturalHeight === 0) {
|
|
269
274
|
return;
|
|
270
275
|
}
|
|
276
|
+
const figure = ref.parentElement;
|
|
277
|
+
const figureWidth = ref.parentElement.clientWidth;
|
|
271
278
|
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
279
|
+
// We need special handling for the height because
|
|
280
|
+
// a caption will cause the figure to be taller than
|
|
281
|
+
// the image, which means we need to account for that
|
|
282
|
+
// when calculating the placement of the button in the
|
|
283
|
+
// top right corner of the image.
|
|
284
|
+
let figureHeight = ref.parentElement.clientHeight;
|
|
285
|
+
const caption = figure.querySelector('figcaption');
|
|
286
|
+
if (caption) {
|
|
287
|
+
const captionComputedStyle = window.getComputedStyle(caption);
|
|
288
|
+
figureHeight = figureHeight - caption.offsetHeight - parseFloat(captionComputedStyle.marginTop) - parseFloat(captionComputedStyle.marginBottom);
|
|
289
|
+
}
|
|
290
|
+
const buttonOffsetTop = figureHeight - offsetHeight;
|
|
291
|
+
const buttonOffsetRight = figureWidth - offsetWidth;
|
|
278
292
|
|
|
293
|
+
// In the case of an image with object-fit: contain, the
|
|
294
|
+
// size of the <img> element can be larger than the image itself,
|
|
295
|
+
// so we need to calculate where to place the button.
|
|
296
|
+
if (context.core.image.scaleAttr === 'contain') {
|
|
279
297
|
// Natural ratio of the image.
|
|
280
298
|
const naturalRatio = naturalWidth / naturalHeight;
|
|
281
299
|
// Offset ratio of the image.
|
|
282
300
|
const offsetRatio = offsetWidth / offsetHeight;
|
|
283
|
-
if (naturalRatio
|
|
301
|
+
if (naturalRatio >= offsetRatio) {
|
|
284
302
|
// If it reaches the width first, keep
|
|
285
|
-
// the width and
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
context.core.image.
|
|
289
|
-
context.core.image.imageButtonTop = (offsetHeight - buttonHeight) / 2;
|
|
303
|
+
// the width and compute the height.
|
|
304
|
+
const referenceHeight = offsetWidth / naturalRatio;
|
|
305
|
+
context.core.image.imageButtonTop = (offsetHeight - referenceHeight) / 2 + buttonOffsetTop + 10;
|
|
306
|
+
context.core.image.imageButtonRight = buttonOffsetRight + 10;
|
|
290
307
|
} else {
|
|
291
308
|
// If it reaches the height first, keep
|
|
292
|
-
// the height and
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
context.core.image.
|
|
296
|
-
context.core.image.imageButtonLeft = (offsetWidth - buttonWidth) / 2;
|
|
309
|
+
// the height and compute the width.
|
|
310
|
+
const referenceWidth = offsetHeight * naturalRatio;
|
|
311
|
+
context.core.image.imageButtonTop = buttonOffsetTop + 10;
|
|
312
|
+
context.core.image.imageButtonRight = (offsetWidth - referenceWidth) / 2 + buttonOffsetRight + 10;
|
|
297
313
|
}
|
|
298
314
|
} else {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
context.core.image.imageButtonWidth = offsetWidth;
|
|
303
|
-
context.core.image.imageButtonHeight = offsetHeight;
|
|
315
|
+
context.core.image.imageButtonTop = buttonOffsetTop + 10;
|
|
316
|
+
context.core.image.imageButtonRight = buttonOffsetRight + 10;
|
|
304
317
|
}
|
|
305
318
|
},
|
|
306
319
|
setStylesOnResize: ({
|