2024-05-23 21:39:28 +02:00
|
|
|
|
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(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:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{RichTextData:()=>j,__experimentalRichText:()=>Xe,__unstableCreateElement:()=>y,__unstableToDom:()=>be,__unstableUseRichText:()=>Be,applyFormat:()=>h,concat:()=>Y,create:()=>V,getActiveFormat:()=>G,getActiveFormats:()=>T,getActiveObject:()=>Z,getTextContent:()=>H,insert:()=>oe,insertObject:()=>ie,isCollapsed:()=>J,isEmpty:()=>Q,join:()=>ee,registerFormatType:()=>te,remove:()=>ae,removeFormat:()=>ne,replace:()=>se,slice:()=>ce,split:()=>le,store:()=>f,toHTMLString:()=>_,toggleFormat:()=>Le,unregisterFormatType:()=>Ce,useAnchor:()=>De,useAnchorRef:()=>Se});var n={};e.r(n),e.d(n,{getFormatType:()=>i,getFormatTypeForBareElement:()=>c,getFormatTypeForClassName:()=>l,getFormatTypes:()=>s});var r={};e.r(r),e.d(r,{addFormatTypes:()=>u,removeFormatTypes:()=>d});const o=window.wp.data;const a=(0,o.combineReducers)({formatTypes:function(e={},t){switch(t.type){case"ADD_FORMAT_TYPES":return{...e,...t.formatTypes.reduce(((e,t)=>({...e,[t.name]:t})),{})};case"REMOVE_FORMAT_TYPES":return Object.fromEntries(Object.entries(e).filter((([e])=>!t.names.includes(e))))}return e}}),s=(0,o.createSelector)((e=>Object.values(e.formatTypes)),(e=>[e.formatTypes]));function i(e,t){return e.formatTypes[t]}function c(e,t){const n=s(e);return n.find((({className:e,tagName:n})=>null===e&&t===n))||n.find((({className:e,tagName:t})=>null===e&&"*"===t))}function l(e,t){return s(e).find((({className:e})=>null!==e&&` ${t} `.indexOf(` ${e} `)>=0))}function u(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Array.isArray(e)?e:[e]}}function d(e){return{type:"REMOVE_FORMAT_TYPES",names:Array.isArray(e)?e:[e]}}const f=(0,o.createReduxStore)("core/rich-text",{reducer:a,selectors:n,actions:r});function m(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.type!==t.type)return!1;const n=e.attributes,r=t.attributes;if(n===r)return!0;if(!n||!r)return!1;const o=Object.keys(n),a=Object.keys(r);if(o.length!==a.length)return!1;const s=o.length;for(let e=0;e<s;e++){const t=o[e];if(n[t]!==r[t])return!1}return!0}function p(e){const t=e.formats.slice();return t.forEach(((e,n)=>{const r=t[n-1];if(r){const o=e.slice();o.forEach(((e,t)=>{const n=r[t];m(e,n)&&(o[t]=n)})),t[n]=o}})),{...e,formats:t}}function g(e,t,n){return(e=e.slice())[t]=n,e}function h(e,t,n=e.start,r=e.end){const{formats:o,activeFormats:a}=e,s=o.slice();if(n===r){const e=s[n]?.find((({type:e})=>e===t.type));if(e){const o=s[n].indexOf(e);for(;s[n]&&s[n][o]===e;)s[n]=g(s[n],o,t),n--;for(r++;s[r]&&s[r][o]===e;)s[r]=g(s[r],o,t),r++}}else{let e=1/0;for(let o=n;o<r;o++)if(s[o]){s[o]=s[o].filter((({type:e})=>e!==t.type));const n=s[o].length;n<e&&(e=n)}else s[o]=[],e=0;for(let o=n;o<r;o++)s[o].splice(e,0,t)}return p({...e,formats:s,activeFormats:[...a?.filter((({type:e})=>e!==t.type))||[],t]})}function y({implementation:e},t){return y.body||(y.body=e.createHTMLDocument("").body),y.body.innerHTML=t,y.body}(0,o.register)(f);const v="",E="\ufeff",b=window.wp.escapeHtml;function T(e,t=[]){const{formats:n,start:r,end:o,activeFormats:a}=e;if(void 0===r)return t;if(r===o){if(a)return a;const e=n[r-1]||t,o=n[r]||t;return e.length<o.length?e:o}if(!n[r])return t;const s=n.slice(r,o),i=[...s[0]];let c=s.length;for(;c--;){const e=s[c];if(!e)return t;let n=i.length;for(;n--;){const t=i[n];e.find((e=>m(t,e)))||i.splice(n,1)}if(0===i.length)return t}return i||t}function x(e){return(0,o.select)(f).getFormatType(e)}function w(e,t){if(t)return e;const n={};for(const t in e){let r=t;t.startsWith("data-disable-rich-text-")&&(r=t.slice(23)),n[r]=e[t]}return n}function N({type:e,tagName:t,attributes:n,unregisteredAttributes:r,object:o,boundaryClass:a,isEditableTree:s}){const i=x(e);let c={};if(a&&s&&(c["data-rich-text-form
|