mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-09 22:29:05 +02:00
Updates the editor npm packages to latest versions. See https://github.com/WordPress/wordpress-develop/pull/6612. Props ellatrix, mukesh27, youknowriad, mamaduka. Built from https://develop.svn.wordpress.org/trunk@58187 git-svn-id: http://core.svn.wordpress.org/trunk@57650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
35 KiB
JavaScript
2 lines
35 KiB
JavaScript
/*! This file is auto-generated */
|
||
(()=>{"use strict";var e={7734:e=>{e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var i,s,n;if(Array.isArray(t)){if((i=t.length)!=r.length)return!1;for(s=i;0!=s--;)if(!e(t[s],r[s]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(s of t.entries())if(!r.has(s[0]))return!1;for(s of t.entries())if(!e(s[1],r.get(s[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(s of t.entries())if(!r.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if((i=t.length)!=r.length)return!1;for(s=i;0!=s--;)if(t[s]!==r[s])return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((i=(n=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=i;0!=s--;)if(!Object.prototype.hasOwnProperty.call(r,n[s]))return!1;for(s=i;0!=s--;){var o=n[s];if(!e(t[o],r[o]))return!1}return!0}return t!=t&&r!=r}}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{r.r(i),r.d(i,{initialize:()=>Ne,store:()=>P});var e={};r.r(e),r.d(e,{__experimentalGetInsertionPoint:()=>M,isInserterOpened:()=>A});var t={};r.r(t),r.d(t,{setIsInserterOpened:()=>O});const s=window.React,n=window.wp.element,o=window.wp.blockLibrary,a=window.wp.widgets,c=window.wp.blocks,l=window.wp.data,d=window.wp.preferences,u=window.wp.components,m=window.wp.i18n,h=window.wp.blockEditor,p=window.wp.compose,g=window.wp.hooks;function b({text:e,children:t}){const r=(0,p.useCopyToClipboard)(e);return(0,s.createElement)(u.Button,{variant:"secondary",ref:r},t)}class w extends n.Component{constructor(){super(...arguments),this.state={error:null}}componentDidCatch(e){this.setState({error:e}),(0,g.doAction)("editor.ErrorBoundary.errorLogged",e)}render(){const{error:e}=this.state;return e?(0,s.createElement)(h.Warning,{className:"customize-widgets-error-boundary",actions:[(0,s.createElement)(b,{key:"copy-error",text:e.stack},(0,m.__)("Copy Error"))]},(0,m.__)("The editor has encountered an unexpected error.")):this.props.children}}const f=window.wp.coreData,_=window.wp.mediaUtils;const y=function({inspector:e,closeMenu:t,...r}){const i=(0,l.useSelect)((e=>e(h.store).getSelectedBlockClientId()),[]),o=(0,n.useMemo)((()=>document.getElementById(`block-${i}`)),[i]);return(0,s.createElement)(u.MenuItem,{onClick:()=>{e.open({returnFocusWhenClose:o}),t()},...r},(0,m.__)("Show more settings"))};function k(e){var t,r,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=k(e[t]))&&(i&&(i+=" "),i+=r)}else for(r in e)e[r]&&(i&&(i+=" "),i+=r);return i}const E=function(){for(var e,t,r=0,i="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=k(e))&&(i&&(i+=" "),i+=t);return i},v=window.wp.keycodes,C=window.wp.primitives,S=(0,s.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(C.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),x=(0,s.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(C.Path,{d:"M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"})),I=(0,s.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(C.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})),z=(0,s.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(C.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));const W=(0,l.combineReducers)({blockInserterPanel:function(e=!1,t){return"SET_IS_INSERTER_OPENED"===t.type?t.value:e}}),B={rootClientId:void 0,insertionIndex:void 0};function A(e){return!!e.blockInserterPanel}function M(e){return"boolean"==typeof e.blockInserterPanel?B:e.blockInserterPanel}function O(e){return{type:"SET_IS_INSERTER_OPENED",value:e}}const T={reducer:W,selectors:e,actions:t},P=(0,l.createReduxStore)("core/customize-widgets",T);(0,l.register)(P);const N=function e({setIsOpened:t}){const r=(0,p.useInstanceId)(e,"customize-widget-layout__inserter-panel-title"),i=(0,l.useSelect)((e=>e(P).__experimentalGetInsertionPoint()),[]);return(0,s.createElement)("div",{className:"customize-widgets-layout__inserter-panel","aria-labelledby":r},(0,s.createElement)("div",{className:"customize-widgets-layout__inserter-panel-header"},(0,s.createElement)("h2",{id:r,className:"customize-widgets-layout__inserter-panel-header-title"},(0,m.__)("Add a block")),(0,s.createElement)(u.Button,{className:"customize-widgets-layout__inserter-panel-header-close-button",icon:z,onClick:()=>t(!1),"aria-label":(0,m.__)("Close inserter")})),(0,s.createElement)("div",{className:"customize-widgets-layout__inserter-panel-content"},(0,s.createElement)(h.__experimentalLibrary,{rootClientId:i.rootClientId,__experimentalInsertionIndex:i.insertionIndex,showInserterHelpPanel:!0,onSelect:()=>t(!1)})))},F=(0,s.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(C.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})),L=(0,s.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(C.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),D=window.wp.keyboardShortcuts,H=[{keyCombination:{modifier:"primary",character:"b"},description:(0,m.__)("Make the selected text bold.")},{keyCombination:{modifier:"primary",character:"i"},description:(0,m.__)("Make the selected text italic.")},{keyCombination:{modifier:"primary",character:"k"},description:(0,m.__)("Convert the selected text into a link.")},{keyCombination:{modifier:"primaryShift",character:"k"},description:(0,m.__)("Remove a link.")},{keyCombination:{character:"[["},description:(0,m.__)("Insert a link to a post or page.")},{keyCombination:{modifier:"primary",character:"u"},description:(0,m.__)("Underline the selected text.")},{keyCombination:{modifier:"access",character:"d"},description:(0,m.__)("Strikethrough the selected text.")},{keyCombination:{modifier:"access",character:"x"},description:(0,m.__)("Make the selected text inline code.")},{keyCombination:{modifier:"access",character:"0"},aliases:[{modifier:"access",character:"7"}],description:(0,m.__)("Convert the current heading to a paragraph.")},{keyCombination:{modifier:"access",character:"1-6"},description:(0,m.__)("Convert the current paragraph or heading to a heading of level 1 to 6.")},{keyCombination:{modifier:"primaryShift",character:"SPACE"},description:(0,m.__)("Add non breaking space.")}];function R({keyCombination:e,forceAriaLabel:t}){const r=e.modifier?v.displayShortcutList[e.modifier](e.character):e.character,i=e.modifier?v.shortcutAriaLabel[e.modifier](e.character):e.character;return(0,s.createElement)("kbd",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination","aria-label":t||i},(Array.isArray(r)?r:[r]).map(((e,t)=>"+"===e?(0,s.createElement)(n.Fragment,{key:t},e):(0,s.createElement)("kbd",{key:t,className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-key"},e))))}const G=function({description:e,keyCombination:t,aliases:r=[],ariaLabel:i}){return(0,s.createElement)(n.Fragment,null,(0,s.createElement)("div",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-description"},e),(0,s.createElement)("div",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-term"},(0,s.createElement)(R,{keyCombination:t,forceAriaLabel:i}),r.map(((e,t)=>(0,s.createElement)(R,{keyCombination:e,forceAriaLabel:i,key:t})))))};const V=function({name:e}){const{keyCombination:t,description:r,aliases:i}=(0,l.useSelect)((t=>{const{getShortcutKeyCombination:r,getShortcutDescription:i,getShortcutAliases:s}=t(D.store);return{keyCombination:r(e),aliases:s(e),description:i(e)}}),[e]);return t?(0,s.createElement)(G,{keyCombination:t,description:r,aliases:i}):null},U=({shortcuts:e})=>(0,s.createElement)("ul",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-list",role:"list"},e.map(((e,t)=>(0,s.createElement)("li",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut",key:t},"string"==typeof e?(0,s.createElement)(V,{name:e}):(0,s.createElement)(G,{...e}))))),j=({title:e,shortcuts:t,className:r})=>(0,s.createElement)("section",{className:E("customize-widgets-keyboard-shortcut-help-modal__section",r)},!!e&&(0,s.createElement)("h2",{className:"customize-widgets-keyboard-shortcut-help-modal__section-title"},e),(0,s.createElement)(U,{shortcuts:t})),$=({title:e,categoryName:t,additionalShortcuts:r=[]})=>{const i=(0,l.useSelect)((e=>e(D.store).getCategoryShortcuts(t)),[t]);return(0,s.createElement)(j,{title:e,shortcuts:i.concat(r)})};function q({isModalActive:e,toggleModal:t}){const{registerShortcut:r}=(0,l.useDispatch)(D.store);return r({name:"core/customize-widgets/keyboard-shortcuts",category:"main",description:(0,m.__)("Display these keyboard shortcuts."),keyCombination:{modifier:"access",character:"h"}}),(0,D.useShortcut)("core/customize-widgets/keyboard-shortcuts",t),e?(0,s.createElement)(u.Modal,{className:"customize-widgets-keyboard-shortcut-help-modal",title:(0,m.__)("Keyboard shortcuts"),onRequestClose:t},(0,s.createElement)(j,{className:"customize-widgets-keyboard-shortcut-help-modal__main-shortcuts",shortcuts:["core/customize-widgets/keyboard-shortcuts"]}),(0,s.createElement)($,{title:(0,m.__)("Global shortcuts"),categoryName:"global"}),(0,s.createElement)($,{title:(0,m.__)("Selection shortcuts"),categoryName:"selection"}),(0,s.createElement)($,{title:(0,m.__)("Block shortcuts"),categoryName:"block",additionalShortcuts:[{keyCombination:{character:"/"},description:(0,m.__)("Change the block type after adding a new paragraph."),ariaLabel:(0,m.__)("Forward-slash")}]}),(0,s.createElement)(j,{title:(0,m.__)("Text formatting"),shortcuts:H})):null}function K(){const[e,t]=(0,n.useState)(!1),r=()=>t(!e);return(0,D.useShortcut)("core/customize-widgets/keyboard-shortcuts",r),(0,s.createElement)(s.Fragment,null,(0,s.createElement)(u.ToolbarDropdownMenu,{icon:F,label:(0,m.__)("Options"),popoverProps:{placement:"bottom-end",className:"more-menu-dropdown__content"},toggleProps:{tooltipPosition:"bottom",size:"compact"}},(()=>(0,s.createElement)(s.Fragment,null,(0,s.createElement)(u.MenuGroup,{label:(0,m._x)("View","noun")},(0,s.createElement)(d.PreferenceToggleMenuItem,{scope:"core/customize-widgets",name:"fixedToolbar",label:(0,m.__)("Top toolbar"),info:(0,m.__)("Access all block and document tools in a single place"),messageActivated:(0,m.__)("Top toolbar activated"),messageDeactivated:(0,m.__)("Top toolbar deactivated")})),(0,s.createElement)(u.MenuGroup,{label:(0,m.__)("Tools")},(0,s.createElement)(u.MenuItem,{onClick:()=>{t(!0)},shortcut:v.displayShortcut.access("h")},(0,m.__)("Keyboard shortcuts")),(0,s.createElement)(d.PreferenceToggleMenuItem,{scope:"core/customize-widgets",name:"welcomeGuide",label:(0,m.__)("Welcome Guide")}),(0,s.createElement)(u.MenuItem,{role:"menuitem",icon:L,href:(0,m.__)("https://wordpress.org/documentation/article/block-based-widgets-editor/"),target:"_blank",rel:"noopener noreferrer"},(0,m.__)("Help"),(0,s.createElement)(u.VisuallyHidden,{as:"span"},(0,m.__)("(opens in a new tab)")))),(0,s.createElement)(u.MenuGroup,{label:(0,m.__)("Preferences")},(0,s.createElement)(d.PreferenceToggleMenuItem,{scope:"core/customize-widgets",name:"keepCaretInsideBlock",label:(0,m.__)("Contain text cursor inside block"),info:(0,m.__)("Aids screen readers by stopping text caret from leaving blocks."),messageActivated:(0,m.__)("Contain text cursor inside block activated"),messageDeactivated:(0,m.__)("Contain text cursor inside block deactivated")}))))),(0,s.createElement)(q,{isModalActive:e,toggleModal:r}))}const Z=function({sidebar:e,inserter:t,isInserterOpened:r,setIsInserterOpened:i,isFixedToolbarActive:o}){const[[a,c],l]=(0,n.useState)([e.hasUndo(),e.hasRedo()]),d=(0,v.isAppleOS)()?v.displayShortcut.primaryShift("z"):v.displayShortcut.primary("y");return(0,n.useEffect)((()=>e.subscribeHistory((()=>{l([e.hasUndo(),e.hasRedo()])}))),[e]),(0,s.createElement)(s.Fragment,null,(0,s.createElement)("div",{className:E("customize-widgets-header",{"is-fixed-toolbar-active":o})},(0,s.createElement)(h.NavigableToolbar,{className:"customize-widgets-header-toolbar","aria-label":(0,m.__)("Document tools")},(0,s.createElement)(u.ToolbarButton,{icon:(0,m.isRTL)()?x:S,label:(0,m.__)("Undo"),shortcut:v.displayShortcut.primary("z"),"aria-disabled":!a,onClick:e.undo,className:"customize-widgets-editor-history-button undo-button"}),(0,s.createElement)(u.ToolbarButton,{icon:(0,m.isRTL)()?S:x,label:(0,m.__)("Redo"),shortcut:d,"aria-disabled":!c,onClick:e.redo,className:"customize-widgets-editor-history-button redo-button"}),(0,s.createElement)(u.ToolbarButton,{className:"customize-widgets-header-toolbar__inserter-toggle",isPressed:r,variant:"primary",icon:I,label:(0,m._x)("Add block","Generic label for block inserter button"),onClick:()=>{i((e=>!e))}}),(0,s.createElement)(K,null))),(0,n.createPortal)((0,s.createElement)(N,{setIsOpened:i}),t.contentContainer[0]))};var Y=r(7734),J=r.n(Y);const Q=window.wp.isShallowEqual;var X=r.n(Q);function ee(e){const t=e.match(/^widget_(.+)(?:\[(\d+)\])$/);if(t){return`${t[1]}-${parseInt(t[2],10)}`}return e}function te(e,t=null){let r;if("core/legacy-widget"===e.name&&(e.attributes.id||e.attributes.instance))if(e.attributes.id)r={id:e.attributes.id};else{const{encoded:i,hash:s,raw:n,...o}=e.attributes.instance;r={idBase:e.attributes.idBase,instance:{...t?.instance,is_widget_customizer_js_value:!0,encoded_serialized_instance:i,instance_hash_key:s,raw_instance:n,...o}}}else{r={idBase:"block",widgetClass:"WP_Widget_Block",instance:{raw_instance:{content:(0,c.serialize)(e)}}}}const{form:i,rendered:s,...n}=t||{};return{...n,...r}}function re({id:e,idBase:t,number:r,instance:i}){let s;const{encoded_serialized_instance:n,instance_hash_key:o,raw_instance:l,...d}=i;if("block"===t){var u;const e=(0,c.parse)(null!==(u=l.content)&&void 0!==u?u:"",{__unstableSkipAutop:!0});s=e.length?e[0]:(0,c.createBlock)("core/paragraph",{})}else s=r?(0,c.createBlock)("core/legacy-widget",{idBase:t,instance:{encoded:n,hash:o,raw:l,...d}}):(0,c.createBlock)("core/legacy-widget",{id:e});return(0,a.addWidgetIdToBlock)(s,e)}function ie(e){const[t,r]=(0,n.useState)((()=>e.getWidgets().map((e=>re(e)))));(0,n.useEffect)((()=>e.subscribe(((e,t)=>{r((r=>{const i=new Map(e.map((e=>[e.id,e]))),s=new Map(r.map((e=>[(0,a.getWidgetIdFromBlock)(e),e]))),n=t.map((e=>{const t=i.get(e.id);return t&&t===e?s.get(e.id):re(e)}));return X()(r,n)?r:n}))}))),[e]);const i=(0,n.useCallback)((t=>{r((r=>{if(X()(r,t))return r;const i=new Map(r.map((e=>[(0,a.getWidgetIdFromBlock)(e),e]))),s=t.map((t=>{const r=(0,a.getWidgetIdFromBlock)(t);if(r&&i.has(r)){const s=i.get(r),n=e.getWidget(r);return J()(t,s)&&n?n:te(t,n)}return te(t)}));if(X()(e.getWidgets(),s))return r;const n=e.setWidgets(s);return t.reduce(((e,r,i)=>{const s=n[i];return null!==s&&(e===t&&(e=t.slice()),e[i]=(0,a.addWidgetIdToBlock)(r,s)),e}),t)}))}),[e]);return[t,i,i]}const se=(0,n.createContext)();function ne({api:e,sidebarControls:t,children:r}){const[i,o]=(0,n.useState)({current:null}),a=(0,n.useCallback)((e=>{for(const r of t){if(r.setting.get().includes(e)){r.sectionInstance.expand({completeCallback(){o({current:e})}});break}}}),[t]);(0,n.useEffect)((()=>{function t(e){const t=ee(e);a(t)}let r=!1;function i(){e.previewer.preview.bind("focus-control-for-setting",t),r=!0}return e.previewer.bind("ready",i),()=>{e.previewer.unbind("ready",i),r&&e.previewer.preview.unbind("focus-control-for-setting",t)}}),[e,a]);const c=(0,n.useMemo)((()=>[i,a]),[i,a]);return(0,s.createElement)(se.Provider,{value:c},r)}const oe=()=>(0,n.useContext)(se);const ae=window.wp.privateApis,{lock:ce,unlock:le}=(0,ae.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/customize-widgets"),{ExperimentalBlockEditorProvider:de}=le(h.privateApis);function ue({sidebar:e,settings:t,children:r}){const[i,o,c]=ie(e);return function(e){const{selectBlock:t}=(0,l.useDispatch)(h.store),[r]=oe(),i=(0,n.useRef)(e);(0,n.useEffect)((()=>{i.current=e}),[e]),(0,n.useEffect)((()=>{if(r.current){const e=i.current.find((e=>(0,a.getWidgetIdFromBlock)(e)===r.current));if(e){t(e.clientId);const r=document.querySelector(`[data-block="${e.clientId}"]`);r?.focus()}}}),[r,t])}(i),(0,s.createElement)(de,{value:i,onInput:o,onChange:c,settings:t,useSubRegistry:!1},r)}function me({sidebar:e}){const{toggle:t}=(0,l.useDispatch)(d.store),r=e.getWidgets().every((e=>e.id.startsWith("block-")));return(0,s.createElement)("div",{className:"customize-widgets-welcome-guide"},(0,s.createElement)("div",{className:"customize-widgets-welcome-guide__image__wrapper"},(0,s.createElement)("picture",null,(0,s.createElement)("source",{srcSet:"https://s.w.org/images/block-editor/welcome-editor.svg",media:"(prefers-reduced-motion: reduce)"}),(0,s.createElement)("img",{className:"customize-widgets-welcome-guide__image",src:"https://s.w.org/images/block-editor/welcome-editor.gif",width:"312",height:"240",alt:""}))),(0,s.createElement)("h1",{className:"customize-widgets-welcome-guide__heading"},(0,m.__)("Welcome to block Widgets")),(0,s.createElement)("p",{className:"customize-widgets-welcome-guide__text"},r?(0,m.__)("Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site."):(0,m.__)("You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.")),(0,s.createElement)(u.Button,{className:"customize-widgets-welcome-guide__button",variant:"primary",onClick:()=>t("core/customize-widgets","welcomeGuide")},(0,m.__)("Got it")),(0,s.createElement)("hr",{className:"customize-widgets-welcome-guide__separator"}),!r&&(0,s.createElement)("p",{className:"customize-widgets-welcome-guide__more-info"},(0,m.__)("Want to stick with the old widgets?"),(0,s.createElement)("br",null),(0,s.createElement)(u.ExternalLink,{href:(0,m.__)("https://wordpress.org/plugins/classic-widgets/")},(0,m.__)("Get the Classic Widgets plugin."))),(0,s.createElement)("p",{className:"customize-widgets-welcome-guide__more-info"},(0,m.__)("New to the block editor?"),(0,s.createElement)("br",null),(0,s.createElement)(u.ExternalLink,{href:(0,m.__)("https://wordpress.org/documentation/article/wordpress-block-editor/")},(0,m.__)("Here's a detailed guide."))))}function he({undo:e,redo:t,save:r}){return(0,D.useShortcut)("core/customize-widgets/undo",(t=>{e(),t.preventDefault()})),(0,D.useShortcut)("core/customize-widgets/redo",(e=>{t(),e.preventDefault()})),(0,D.useShortcut)("core/customize-widgets/save",(e=>{e.preventDefault(),r()})),null}he.Register=function(){const{registerShortcut:e,unregisterShortcut:t}=(0,l.useDispatch)(D.store);return(0,n.useEffect)((()=>(e({name:"core/customize-widgets/undo",category:"global",description:(0,m.__)("Undo your last changes."),keyCombination:{modifier:"primary",character:"z"}}),e({name:"core/customize-widgets/redo",category:"global",description:(0,m.__)("Redo your last undo."),keyCombination:{modifier:"primaryShift",character:"z"},aliases:(0,v.isAppleOS)()?[]:[{modifier:"primary",character:"y"}]}),e({name:"core/customize-widgets/save",category:"global",description:(0,m.__)("Save your changes."),keyCombination:{modifier:"primary",character:"s"}}),()=>{t("core/customize-widgets/undo"),t("core/customize-widgets/redo"),t("core/customize-widgets/save")})),[e]),null};const pe=he;function ge(e){const t=(0,n.useRef)(),r=(0,l.useSelect)((e=>0===e(h.store).getBlockCount()));return(0,n.useEffect)((()=>{if(r&&t.current){const{ownerDocument:e}=t.current;e.activeElement&&e.activeElement!==e.body||t.current.focus()}}),[r]),(0,s.createElement)(h.ButtonBlockAppender,{...e,ref:t})}const{ExperimentalBlockCanvas:be}=le(h.privateApis),{BlockKeyboardShortcuts:we}=le(o.privateApis);function fe({blockEditorSettings:e,sidebar:t,inserter:r,inspector:i}){const[o,a]=function(e){const t=(0,l.useSelect)((e=>e(P).isInserterOpened()),[]),{setIsInserterOpened:r}=(0,l.useDispatch)(P);return(0,n.useEffect)((()=>{t?e.open():e.close()}),[e,t]),[t,(0,n.useCallback)((e=>{let t=e;"function"==typeof e&&(t=e((0,l.select)(P).isInserterOpened())),r(t)}),[r])]}(r),c=(0,p.useViewportMatch)("small"),{hasUploadPermissions:u,isFixedToolbarActive:m,keepCaretInsideBlock:g,isWelcomeGuideActive:b}=(0,l.useSelect)((e=>{var t;const{get:r}=e(d.store);return{hasUploadPermissions:null===(t=e(f.store).canUser("create","media"))||void 0===t||t,isFixedToolbarActive:!!r("core/customize-widgets","fixedToolbar"),keepCaretInsideBlock:!!r("core/customize-widgets","keepCaretInsideBlock"),isWelcomeGuideActive:!!r("core/customize-widgets","welcomeGuide")}}),[]),w=(0,n.useMemo)((()=>{let t;return u&&(t=({onError:t,...r})=>{(0,_.uploadMedia)({wpAllowedMimeTypes:e.allowedMimeTypes,onError:({message:e})=>t(e),...r})}),{...e,__experimentalSetIsInserterOpened:a,mediaUpload:t,hasFixedToolbar:m||!c,keepCaretInsideBlock:g,__unstableHasCustomAppender:!0}}),[u,e,m,c,g,a]);return b?(0,s.createElement)(me,{sidebar:t}):(0,s.createElement)(s.Fragment,null,(0,s.createElement)(pe.Register,null),(0,s.createElement)(we,null),(0,s.createElement)(ue,{sidebar:t,settings:w},(0,s.createElement)(pe,{undo:t.undo,redo:t.redo,save:t.save}),(0,s.createElement)(Z,{sidebar:t,inserter:r,isInserterOpened:o,setIsInserterOpened:a,isFixedToolbarActive:m||!c}),(m||!c)&&(0,s.createElement)(h.BlockToolbar,{hideDragHandle:!0}),(0,s.createElement)(be,{shouldIframe:!1,styles:w.defaultEditorStyles,height:"100%"},(0,s.createElement)(h.BlockList,{renderAppender:ge})),(0,n.createPortal)((0,s.createElement)("form",{onSubmit:e=>e.preventDefault()},(0,s.createElement)(h.BlockInspector,null)),i.contentContainer[0])),(0,s.createElement)(h.__unstableBlockSettingsMenuFirstItem,null,(({onClose:e})=>(0,s.createElement)(y,{inspector:i,closeMenu:e}))))}const _e=(0,n.createContext)();function ye({sidebarControls:e,activeSidebarControl:t,children:r}){const i=(0,n.useMemo)((()=>({sidebarControls:e,activeSidebarControl:t})),[e,t]);return(0,s.createElement)(_e.Provider,{value:i},r)}function ke({api:e,sidebarControls:t,blockEditorSettings:r}){const[i,o]=(0,n.useState)(null),a=document.getElementById("customize-theme-controls"),c=(0,n.useRef)();!function(e,t){const{hasSelectedBlock:r,hasMultiSelection:i}=(0,l.useSelect)(h.store),{clearSelectedBlock:s}=(0,l.useDispatch)(h.store);(0,n.useEffect)((()=>{if(t.current&&e){const n=e.inspector,o=e.container[0],a=o.ownerDocument,c=a.defaultView;function l(e){!r()&&!i()||!e||!a.contains(e)||o.contains(e)||t.current.contains(e)||e.closest('[role="dialog"]')||n.expanded()||s()}function d(e){l(e.target)}function u(){l(a.activeElement)}return a.addEventListener("mousedown",d),c.addEventListener("blur",u),()=>{a.removeEventListener("mousedown",d),c.removeEventListener("blur",u)}}}),[t,e,r,i,s])}(i,c),(0,n.useEffect)((()=>{const e=t.map((e=>e.subscribe((t=>{t&&o(e)}))));return()=>{e.forEach((e=>e()))}}),[t]);const d=i&&(0,n.createPortal)((0,s.createElement)(w,null,(0,s.createElement)(fe,{key:i.id,blockEditorSettings:r,sidebar:i.sidebarAdapter,inserter:i.inserter,inspector:i.inspector})),i.container[0]),m=a&&(0,n.createPortal)((0,s.createElement)("div",{className:"customize-widgets-popover",ref:c},(0,s.createElement)(u.Popover.Slot,null)),a);return(0,s.createElement)(u.SlotFillProvider,null,(0,s.createElement)(ye,{sidebarControls:t,activeSidebarControl:i},(0,s.createElement)(ne,{api:e,sidebarControls:t},d,m)))}const Ee=e=>`widgets-inspector-${e}`;function ve(){const{wp:{customize:e}}=window,t=window.matchMedia("(prefers-reduced-motion: reduce)");let r=t.matches;return t.addEventListener("change",(e=>{r=e.matches})),class extends e.Section{ready(){const t=function(){const{wp:{customize:e}}=window;return class extends e.Section{constructor(e,t){super(e,t),this.parentSection=t.parentSection,this.returnFocusWhenClose=null,this._isOpen=!1}get isOpen(){return this._isOpen}set isOpen(e){this._isOpen=e,this.triggerActiveCallbacks()}ready(){this.contentContainer[0].classList.add("customize-widgets-layout__inspector")}isContextuallyActive(){return this.isOpen}onChangeExpanded(e,t){super.onChangeExpanded(e,t),this.parentSection&&!t.unchanged&&(e?this.parentSection.collapse({manualTransition:!0}):this.parentSection.expand({manualTransition:!0,completeCallback:()=>{this.returnFocusWhenClose&&!this.contentContainer[0].contains(this.returnFocusWhenClose)&&this.returnFocusWhenClose.focus()}}))}open({returnFocusWhenClose:e}={}){this.isOpen=!0,this.returnFocusWhenClose=e,this.expand({allowMultiple:!0})}close(){this.collapse({allowMultiple:!0})}collapse(e){this.isOpen=!1,super.collapse(e)}triggerActiveCallbacks(){this.active.callbacks.fireWith(this.active,[!1,!0])}}}();this.inspector=new t(Ee(this.id),{title:(0,m.__)("Block Settings"),parentSection:this,customizeAction:[(0,m.__)("Customizing"),(0,m.__)("Widgets"),this.params.title].join(" ▸ ")}),e.section.add(this.inspector),this.contentContainer[0].classList.add("customize-widgets__sidebar-section")}hasSubSectionOpened(){return this.inspector.expanded()}onChangeExpanded(e,t){const i=this.controls(),s={...t,completeCallback(){i.forEach((t=>{t.onChangeSectionExpanded?.(e,s)})),t.completeCallback?.()}};if(s.manualTransition){e?(this.contentContainer.addClass(["busy","open"]),this.contentContainer.removeClass("is-sub-section-open"),this.contentContainer.closest(".wp-full-overlay").addClass("section-open")):(this.contentContainer.addClass(["busy","is-sub-section-open"]),this.contentContainer.closest(".wp-full-overlay").addClass("section-open"),this.contentContainer.removeClass("open"));const t=()=>{this.contentContainer.removeClass("busy"),s.completeCallback()};r?t():this.contentContainer.one("transitionend",t)}else super.onChangeExpanded(e,s)}}}const{wp:Ce}=window;function Se(e){const t=e.match(/^(.+)-(\d+)$/);return t?{idBase:t[1],number:parseInt(t[2],10)}:{idBase:e}}function xe(e){const{idBase:t,number:r}=Se(e);return r?`widget_${t}[${r}]`:`widget_${t}`}class Ie{constructor(e,t){this.setting=e,this.api=t,this.locked=!1,this.widgetsCache=new WeakMap,this.subscribers=new Set,this.history=[this._getWidgetIds().map((e=>this.getWidget(e)))],this.historyIndex=0,this.historySubscribers=new Set,this._debounceSetHistory=function(e,t,r){let i,s=!1;function n(...n){const o=(s?t:e).apply(this,n);return s=!0,clearTimeout(i),i=setTimeout((()=>{s=!1}),r),o}return n.cancel=()=>{s=!1,clearTimeout(i)},n}(this._pushHistory,this._replaceHistory,1e3),this.setting.bind(this._handleSettingChange.bind(this)),this.api.bind("change",this._handleAllSettingsChange.bind(this)),this.undo=this.undo.bind(this),this.redo=this.redo.bind(this),this.save=this.save.bind(this)}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}getWidgets(){return this.history[this.historyIndex]}_emit(...e){for(const t of this.subscribers)t(...e)}_getWidgetIds(){return this.setting.get()}_pushHistory(){this.history=[...this.history.slice(0,this.historyIndex+1),this._getWidgetIds().map((e=>this.getWidget(e)))],this.historyIndex+=1,this.historySubscribers.forEach((e=>e()))}_replaceHistory(){this.history[this.historyIndex]=this._getWidgetIds().map((e=>this.getWidget(e)))}_handleSettingChange(){if(this.locked)return;const e=this.getWidgets();this._pushHistory(),this._emit(e,this.getWidgets())}_handleAllSettingsChange(e){if(this.locked)return;if(!e.id.startsWith("widget_"))return;const t=ee(e.id);if(!this.setting.get().includes(t))return;const r=this.getWidgets();this._pushHistory(),this._emit(r,this.getWidgets())}_createWidget(e){const t=Ce.customize.Widgets.availableWidgets.findWhere({id_base:e.idBase});let r=e.number;t.get("is_multi")&&!r&&(t.set("multi_number",t.get("multi_number")+1),r=t.get("multi_number"));const i=r?`widget_${e.idBase}[${r}]`:`widget_${e.idBase}`,s={transport:Ce.customize.Widgets.data.selectiveRefreshableWidgets[t.get("id_base")]?"postMessage":"refresh",previewer:this.setting.previewer};this.api.create(i,i,"",s).set(e.instance);return ee(i)}_removeWidget(e){const t=xe(e.id),r=this.api(t);if(r){const e=r.get();this.widgetsCache.delete(e)}this.api.remove(t)}_updateWidget(e){const t=this.getWidget(e.id);if(t===e)return e.id;if(t.idBase&&e.idBase&&t.idBase===e.idBase){const t=xe(e.id);return this.api(t).set(e.instance),e.id}return this._removeWidget(e),this._createWidget(e)}getWidget(e){if(!e)return null;const{idBase:t,number:r}=Se(e),i=xe(e),s=this.api(i);if(!s)return null;const n=s.get();if(this.widgetsCache.has(n))return this.widgetsCache.get(n);const o={id:e,idBase:t,number:r,instance:n};return this.widgetsCache.set(n,o),o}_updateWidgets(e){this.locked=!0;const t=[],r=e.map((e=>{if(e.id&&this.getWidget(e.id))return t.push(null),this._updateWidget(e);const r=this._createWidget(e);return t.push(r),r}));return this.getWidgets().filter((e=>!r.includes(e.id))).forEach((e=>this._removeWidget(e))),this.setting.set(r),this.locked=!1,t}setWidgets(e){const t=this._updateWidgets(e);return this._debounceSetHistory(),t}hasUndo(){return this.historyIndex>0}hasRedo(){return this.historyIndex<this.history.length-1}_seek(e){const t=this.getWidgets();this.historyIndex=e;const r=this.history[this.historyIndex];this._updateWidgets(r),this._emit(t,this.getWidgets()),this.historySubscribers.forEach((e=>e())),this._debounceSetHistory.cancel()}undo(){this.hasUndo()&&this._seek(this.historyIndex-1)}redo(){this.hasRedo()&&this._seek(this.historyIndex+1)}subscribeHistory(e){return this.historySubscribers.add(e),()=>{this.historySubscribers.delete(e)}}save(){this.api.previewer.save()}}const ze=window.wp.dom;const We=e=>`widgets-inserter-${e}`;function Be(){const{wp:{customize:e}}=window;return class extends e.Control{constructor(...e){super(...e),this.subscribers=new Set}ready(){const t=function(){const{wp:{customize:e}}=window,t=e.OuterSection;return e.OuterSection=class extends t{onChangeExpanded(t,r){return t&&e.section.each((e=>{"outer"===e.params.type&&e.id!==this.id&&e.expanded()&&e.collapse()})),super.onChangeExpanded(t,r)}},e.sectionConstructor.outer=e.OuterSection,class extends e.OuterSection{constructor(...e){super(...e),this.params.type="outer",this.activeElementBeforeExpanded=null,this.contentContainer[0].ownerDocument.defaultView.addEventListener("keydown",(e=>{!this.expanded()||e.keyCode!==v.ESCAPE&&"Escape"!==e.code||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),(0,l.dispatch)(P).setIsInserterOpened(!1))}),!0),this.contentContainer.addClass("widgets-inserter"),this.isFromInternalAction=!1,this.expanded.bind((()=>{this.isFromInternalAction||(0,l.dispatch)(P).setIsInserterOpened(this.expanded()),this.isFromInternalAction=!1}))}open(){if(!this.expanded()){const e=this.contentContainer[0];this.activeElementBeforeExpanded=e.ownerDocument.activeElement,this.isFromInternalAction=!0,this.expand({completeCallback(){const t=ze.focus.tabbable.find(e)[1];t&&t.focus()}})}}close(){if(this.expanded()){const e=this.contentContainer[0],t=e.ownerDocument.activeElement;this.isFromInternalAction=!0,this.collapse({completeCallback(){e.contains(t)&&this.activeElementBeforeExpanded&&this.activeElementBeforeExpanded.focus()}})}}}}();this.inserter=new t(We(this.id),{}),e.section.add(this.inserter),this.sectionInstance=e.section(this.section()),this.inspector=this.sectionInstance.inspector,this.sidebarAdapter=new Ie(this.setting,e)}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}onChangeSectionExpanded(e,t){t.unchanged||(e||(0,l.dispatch)(P).setIsInserterOpened(!1),this.subscribers.forEach((r=>r(e,t))))}}}const Ae=(0,p.createHigherOrderComponent)((e=>t=>{let r=(0,a.getWidgetIdFromBlock)(t);const i=function(){const{sidebarControls:e}=(0,n.useContext)(_e);return e}(),o=function(){const{activeSidebarControl:e}=(0,n.useContext)(_e);return e}(),c=i?.length>1,d=t.name,u=t.clientId,m=(0,l.useSelect)((e=>e(h.store).canInsertBlockType(d,"")),[d]),p=(0,l.useSelect)((e=>e(h.store).getBlock(u)),[u]),{removeBlock:g}=(0,l.useDispatch)(h.store),[,b]=oe();return(0,s.createElement)(s.Fragment,null,(0,s.createElement)(e,{...t}),c&&m&&(0,s.createElement)(h.BlockControls,null,(0,s.createElement)(a.MoveToWidgetArea,{widgetAreas:i.map((e=>({id:e.id,name:e.params.label,description:e.params.description}))),currentWidgetAreaId:o?.id,onSelect:function(e){const t=i.find((t=>t.id===e));if(r){const e=o.setting,i=t.setting;e(e().filter((e=>e!==r))),i([...i(),r])}else{const e=t.sidebarAdapter;g(u);const i=e.setWidgets([...e.getWidgets(),te(p)]);r=i.reverse().find((e=>!!e))}b(r)}})))}),"withMoveToSidebarToolbarItem");(0,g.addFilter)("editor.BlockEdit","core/customize-widgets/block-edit",Ae);(0,g.addFilter)("editor.MediaUpload","core/edit-widgets/replace-media-upload",(()=>_.MediaUpload));const{wp:Me}=window,Oe=(0,p.createHigherOrderComponent)((e=>t=>{var r;const{idBase:i}=t.attributes,n=null!==(r=Me.customize.Widgets.data.availableWidgets.find((e=>e.id_base===i))?.is_wide)&&void 0!==r&&r;return(0,s.createElement)(e,{...t,isWide:n})}),"withWideWidgetDisplay");(0,g.addFilter)("editor.BlockEdit","core/customize-widgets/wide-widget-display",Oe);const{wp:Te}=window,Pe=["core/more","core/block","core/freeform","core/template-part"];function Ne(e,t){(0,l.dispatch)(d.store).setDefaults("core/customize-widgets",{fixedToolbar:!1,welcomeGuide:!0}),(0,l.dispatch)(c.store).reapplyBlockTypeFilters();const r=(0,o.__experimentalGetCoreBlocks)().filter((e=>!(Pe.includes(e.name)||e.name.startsWith("core/post")||e.name.startsWith("core/query")||e.name.startsWith("core/site")||e.name.startsWith("core/navigation"))));(0,o.registerCoreBlocks)(r),(0,a.registerLegacyWidgetBlock)(),(0,a.registerLegacyWidgetVariations)(t),(0,a.registerWidgetGroupBlock)(),(0,c.setFreeformContentHandlerName)("core/html");const i=Be();Te.customize.sectionConstructor.sidebar=ve(),Te.customize.controlConstructor.sidebar_block_editor=i;const u=document.createElement("div");document.body.appendChild(u),Te.customize.bind("ready",(()=>{const e=[];Te.customize.control.each((t=>{t instanceof i&&e.push(t)})),(0,n.createRoot)(u).render((0,s.createElement)(ke,{api:Te.customize,sidebarControls:e,blockEditorSettings:t}))}))}})(),(window.wp=window.wp||{}).customizeWidgets=i})(); |