PluginProbe
Gutenberg / 22.4.3
Gutenberg v22.4.3
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / modules / block-editor / utils / fit-text-frontend.min.js

fit-text-frontend.min.js in Gutenberg 22.4.3, at build/modules/block-editor/utils/fit-text-frontend.min.js

3 lines 925 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{store as S,getElement as u,getContext as w}from"@wordpress/interactivity";function z(t,e){let o=t.scrollHeight>t.clientHeight,i=0,s=2400,d=i,l=window.getComputedStyle(t),a=parseFloat(l.paddingLeft)||0,f=parseFloat(l.paddingRight)||0,c=document.createRange();for(c.selectNodeContents(t);i<=s;){let n=Math.floor((i+s)/2);e(n);let g=c.getBoundingClientRect().width,h=t.scrollWidth<=t.clientWidth&&g<=t.clientWidth-a-f,p=o||t.scrollHeight<=t.clientHeight;h&&p?(d=n,i=n+1):s=n-1}return c.detach(),d}function r(t,e){if(!t)return;e(0);let o=z(t,e);return e(o),o}S("core/fit-text",{callbacks:{init(){let t=w(),{ref:e}=u(),o=i=>{i===0?e.style.fontSize="":e.style.fontSize=`${i}px`};if(t.fontSize=r(e,o),window.ResizeObserver&&e.parentElement){let i=new window.ResizeObserver(()=>{t.fontSize=r(e,o)});return i.observe(e.parentElement),i.observe(e),()=>{i&&i.disconnect()}}}}});
2 //# sourceMappingURL=fit-text-frontend.min.js.map
3