WordPress/wp-includes/js/dist/patterns.min.js

2 lines
8.6 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
Editor: Update npm packages ahead of 6.4 RC1. Updates the npm packages and code for: * [https://github.com/WordPress/gutenberg/pull/55121 List: fix forward merging of nested list] * [https://github.com/WordPress/gutenberg/pull/55182 Update consent string for using private APIs.] * [https://github.com/WordPress/gutenberg/pull/55204 useBlockSettings: add missing useMemo dependencies] * [https://github.com/WordPress/gutenberg/pull/55120 Remove the lightbox filter and view file when the lightbox setting is disabled.] * [https://github.com/WordPress/gutenberg/pull/55245 Patterns: Remove the version enforcement for npm in engines field] * [https://github.com/WordPress/gutenberg/pull/55237 Remove `@return void` from PHP function docs] * [https://github.com/WordPress/gutenberg/pull/55141 Image: Disable lightbox editor UI for linked images] * [https://github.com/WordPress/gutenberg/pull/55269 Image: Stop crashing with Lightbox on image blocks without an image] * [https://github.com/WordPress/gutenberg/pull/55021 Update fullscreen icon] * [https://github.com/WordPress/gutenberg/pull/55217 Template Part block: Fall back to current theme if no theme attribute is given.] This change is part of fix for a performance regression re-introduced by [56818]. References: * [https://github.com/WordPress/gutenberg/pull/55298 Gutenberg PR 55298] Cherry-pick commits Follow-up to [56818], [56816]. Props ellatrix, peterwilsoncc, jsnajdr, afercia, gziolo, isabel_brison, artemiosans, richtabor, bernhard-reiter, flixos90, mikachan, spacedmonkey, hellofromTonya. See #59583, #59411. Built from https://develop.svn.wordpress.org/trunk@56849 git-svn-id: http://core.svn.wordpress.org/trunk@56361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-12 09:58:15 -04:00
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{privateApis:function(){return D},store:function(){return h}});var n={};e.r(n),e.d(n,{convertSyncedPatternToStatic:function(){return m},createPattern:function(){return p},createPatternFromFile:function(){return d},setEditingPattern:function(){return _}});var r={};e.r(r),e.d(r,{isEditingPattern:function(){return w}});var a=window.wp.data;var o=(0,a.combineReducers)({isEditingPattern:function(e={},t){return"SET_EDITING_PATTERN"===t?.type?{...e,[t.clientId]:t.isEditing}:e}}),s=window.wp.blocks,c=window.wp.coreData,i=window.wp.blockEditor;const l="all-patterns",u={full:"fully",unsynced:"unsynced"},p=(e,t,n,r)=>async({registry:a})=>{const o=t===u.unsynced?{wp_pattern_sync_status:t}:void 0,s={title:e,content:n,status:"publish",meta:o,wp_pattern_category:r};return await a.dispatch(c.store).saveEntityRecord("postType","wp_block",s)},d=(e,t)=>async({dispatch:n})=>{const r=await e.text();let a;try{a=JSON.parse(r)}catch(e){throw new Error("Invalid JSON file")}if("wp_block"!==a.__file||!a.title||!a.content||"string"!=typeof a.title||"string"!=typeof a.content||a.syncStatus&&"string"!=typeof a.syncStatus)throw new Error("Invalid pattern JSON file");return await n.createPattern(a.title,a.syncStatus,a.content,t)},m=e=>({registry:t})=>{const n=t.select(i.store).getBlock(e),r=t.select("core").getEditedEntityRecord("postType","wp_block",n.attributes.ref),a=(0,s.parse)("function"==typeof r.content?r.content(r):r.content);t.dispatch(i.store).replaceBlocks(n.clientId,a)};function _(e,t){return{type:"SET_EDITING_PATTERN",clientId:e,isEditing:t}}function w(e,t){return e.isEditingPattern[t]}var y=window.wp.privateApis;const{lock:g,unlock:f}=(0,y.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/patterns"),E={reducer:o},h=(0,a.createReduxStore)("core/patterns",{...E});(0,a.register)(h),f(h).registerPrivateActions(n),f(h).registerPrivateSelectors(r);var b=window.wp.element,C=window.wp.components,v=window.wp.i18n,S=window.wp.notices,k=window.wp.compose,P=window.wp.htmlEntities;const T=e=>(0,P.decodeEntities)(e),I="wp_pattern_category";function B({categoryTerms:e,onChange:t,categoryMap:n}){const[r,a]=(0,b.useState)(""),o=(0,k.useDebounce)(a,500),s=(0,b.useMemo)((()=>Array.from(n.values()).map((e=>T(e.label))).filter((e=>""===r||e.toLowerCase().includes(r.toLowerCase()))).sort(((e,t)=>e.localeCompare(t)))),[r,n]);return(0,b.createElement)(C.FormTokenField,{className:"patterns-menu-items__convert-modal-categories",value:e,suggestions:s,onChange:function(e){const n=e.reduce(((e,t)=>(e.some((e=>e.toLowerCase()===t.toLowerCase()))||e.push(t),e)),[]);t(n)},onInputChange:o,label:(0,v.__)("Categories"),tokenizeOnBlur:!0,__experimentalExpandOnFocus:!0,__next40pxDefaultSize:!0})}function R({onSuccess:e,onError:t,content:n,onClose:r,className:o="patterns-menu-items__convert-modal"}){const[s,i]=(0,b.useState)(u.full),[p,d]=(0,b.useState)([]),[m,_]=(0,b.useState)(""),[w,y]=(0,b.useState)(!1),{createPattern:g}=f((0,a.useDispatch)(h)),{saveEntityRecord:E,invalidateResolution:k}=(0,a.useDispatch)(c.store),{createErrorNotice:P}=(0,a.useDispatch)(S.store),{corePatternCategories:T,userPatternCategories:R}=(0,a.useSelect)((e=>{const{getUserPatternCategories:t,getBlockPatternCategories:n}=e(c.store);return{corePatternCategories:n(),userPatternCategories:t()}})),N=(0,b.useMemo)((()=>{const e=new Map;return[...R,...T].forEach((t=>{e.has(t.label)||"query"===t.name||e.set(t.label,{label:t.label,value:t.label,name:t.name})})),e}),[R,T]);async function M(r,a){if(m&&!w)try{y(!0);const t=await Promise.all(p.map((e=>async function(e){try{const t=N.get(e),n=t?{name:t