9 lines
42 KiB
JavaScript
9 lines
42 KiB
JavaScript
|
|
/*! This file is auto-generated */
|
||
|
|
(function() {
|
||
|
|
"use strict";var wp;(wp||={}).richText=(()=>{var tn=Object.create;var Tt=Object.defineProperty;var en=Object.getOwnPropertyDescriptor;var rn=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,on=Object.prototype.hasOwnProperty;var q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),jt=(e,t)=>{for(var r in t)Tt(e,r,{get:t[r],enumerable:!0})},ie=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rn(t))!on.call(e,o)&&o!==r&&Tt(e,o,{get:()=>t[o],enumerable:!(n=en(t,o))||n.enumerable});return e};var d=(e,t,r)=>(r=e!=null?tn(nn(e)):{},ie(t||!e||!e.__esModule?Tt(r,"default",{value:e,enumerable:!0}):r,e)),sn=e=>ie(Tt({},"__esModule",{value:!0}),e);var W=q((no,se)=>{se.exports=window.wp.data});var le=q((ho,me)=>{me.exports=window.wp.escapeHtml});var Le=q((hi,Oe)=>{Oe.exports=window.wp.a11y});var De=q((gi,_e)=>{_e.exports=window.wp.i18n});var Pe=q((Ti,He)=>{He.exports=window.wp.privateApis});var B=q((Ai,je)=>{je.exports=window.wp.element});var $=q((Ni,Be)=>{Be.exports=window.wp.compose});var Yt=q((Ci,Ke)=>{Ke.exports=window.wp.deprecated});var Dt=q((Ui,ur)=>{ur.exports=window.wp.keycodes});var zr=q((Zs,Wr)=>{Wr.exports=window.wp.dom});var eo={};jt(eo,{RichTextData:()=>G,__experimentalRichText:()=>to,__unstableCreateElement:()=>z,__unstableToDom:()=>Jt,__unstableUseRichText:()=>Mr,applyFormat:()=>At,concat:()=>ve,create:()=>L,getActiveFormat:()=>ct,getActiveFormats:()=>Q,getActiveObject:()=>Ee,getTextContent:()=>st,insert:()=>ft,insertObject:()=>Ae,isCollapsed:()=>et,isEmpty:()=>we,join:()=>xe,privateApis:()=>ne,registerFormatType:()=>Te,remove:()=>mt,removeFormat:()=>ut,replace:()=>Fe,slice:()=>St,split:()=>Ne,store:()=>C,toHTMLString:()=>I,toggleFormat:()=>Me,unregisterFormatType:()=>ke,useAnchor:()=>Zr,useAnchorRef:()=>qr});var Ft=d(W(),1);var ce=d(W(),1);function cn(e={},t){switch(t.type){case"ADD_FORMAT_TYPES":return{...e,...t.formatTypes.reduce((r,n)=>({...r,[n.name]:n}),{})};case"REMOVE_FORMAT_TYPES":return Object.fromEntries(Object.entries(e).filter(([r])=>!t.names.includes(r)))}return e}var ae=(0,ce.combineReducers)({formatTypes:cn});var Kt={};jt(Kt,{getFormatType:()=>an,getFormatTypeForBareElement:()=>un,getFormatTypeForClassName:()=>fn,getFormatTypes:()=>Bt});var ue=d(W(),1),Bt=(0,ue.createSelector)(e=>Object.values(e.formatTypes),e=>[e.formatTypes]);function an(e,t){return e.formatTypes[t]}function un(e,t){let r=Bt(e);return r.find(({className:n,tagName:o})=>n===null&&t===o)||r.find(({className:n,tagName:o})=>n===null&&o==="*")}function fn(e,t){return Bt(e).find(({className:r})=>r===null?!1:` ${t} `.indexOf(` ${r} `)>=0)}var Ut={};jt(Ut,{addFormatTypes:()=>mn,removeFormatTypes:()=>ln});function mn(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Array.isArray(e)?e:[e]}}function ln(e){return{type:"REMOVE_FORMAT_TYPES",names:Array.isArray(e)?e:[e]}}var pn="core/rich-text",C=(0,Ft.createReduxStore)(pn,{reducer:ae,selectors:Kt,actions:Ut});(0,Ft.register)(C);function nt(e,t){if(e===t)return!0;if(!e||!t||e.type!==t.type)return!1;let r=e.attributes,n=t.attributes;if((e.unregisteredAttributes||t.unregisteredAttributes)&&(r={...r,...e.unregisteredAttributes},n={...n,...t.unregisteredAttributes}),r===n)return!0;if(!r||!n)return!1;let o=Object.keys(r),i=Object.keys(n);if(o.length!==i.length)return!1;let s=o.length;for(let c=0;c<s;c++){let a=o[c];if(r[a]!==n[a])return!1}return!0}function H(e){let t=e.formats.slice();return t.forEach((r,n)=>{let o=t[n-1];if(o){let i=r.slice();i.forEach((s,c)=>{let a=o[c];nt(s,a)&&(i[c]=a)}),t[n]=i}}),{...e,formats:t}}function fe(e,t,r){return e=e.slice(),e[t]=r,e}function At(e,t,r=e.start,n=e.end){let{formats:o,activeFormats:i}=e,s=o.slice();if(r===n){let c=s[r]?.find(({type:a})=>a===t.type);if(c){let a=s[r].indexOf(c);for(;s[r]&&s[r][a]===c;)s[r]=fe(s[r],a,t),r--;for(n++;s[n]&&s[n][a]===c;)s[n]=fe(s[n],a,t),n++}}else{let c=1/0;for(let a=r;a<n;a++)if(s[a]){s[a]=s[a].filter(({type:f})=>f!==t.type);let u=s[a].length;u<c&&(c=u)}else s[a]=[],c=0;for(let a=r;a<n;a++)s[a].splice(c,0,t)}return H({...e,formats:s,activeFormats:[...i?.filter(({type:c})=>c!==t.type)||[],t]})}var
|
||
|
|
`),j=R[x],p=o(A);if(j&&j.forEach((k,J)=>{if(p&&N&&dn(j,N,J)){p=o(p);return}let{type:rt,tagName:ht,attributes:Vt,unregisteredAttributes:xt}=k,Yr=l&&k===F,Qr=i(p),Ir=n(Qr,Nt({type:rt,tagName:ht,attributes:Vt,unregisteredAttributes:xt,boundaryClass:Yr,isEditableTree:l}));s(p)&&c(p).length===0&&a(p),p=n(Ir,"")}),x===0&&(f&&b===0&&f(A,p),m&&E===0&&m(A,p)),g===D){let k=y[x];if(!k)continue;let{type:J,attributes:rt,innerHTML:ht}=k,Vt=qt(J);if(l&&J==="#comment")p=n(i(p),{type:"span",attributes:{contenteditable:"false","data-rich-text-comment":rt["data-rich-text-comment"]}}),n(n(p,{type:"span"}),rt["data-rich-text-comment"].trim());else if(!l&&J==="script")p=n(i(p),Nt({type:"script",isEditableTree:l})),n(p,{html:decodeURIComponent(rt["data-rich-text-script"])});else if(Vt?.contentEditable===!1){if(ht||l){if(p=i(p),l){let xt={contenteditable:"false","data-rich-text-bogus":!0};b===x&&E===x+1&&(xt["data-rich-text-format-boundary"]=!0),p=n(p,{type:"span",attributes:xt}),l&&x+1===v.length&&n(i(p),gt)}p=n(p,Nt({...k,isEditableTree:l})),ht&&n(p,{html:ht})}}else p=n(i(p),Nt({...k,object:!0,isEditableTree:l}));p=n(i(p),"")}else!t&&g===`
|
||
|
|
`?(p=n(i(p),{type:"br",attributes:l?{"data-rich-text-line-break":"true"}:void 0,object:!0}),p=n(i(p),"")):s(p)?u(p,g):p=n(i(p),g);f&&b===x+1&&f(A,p),m&&E===x+1&&m(A,p),_&&x===v.length&&(n(i(p),gt),T&&v.length===0&&n(i(p),{type:"span",attributes:{"data-rich-text-placeholder":T,style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),N=j,O=g}return A}function I({value:e,preserveWhiteSpace:t}){let r=Ct({value:e,preserveWhiteSpace:t,createEmpty:hn,append:yn,getLastChild:gn,getParent:vn,isText:En,getText:wn,remove:xn,appendText:bn});return he(r.children)}function hn(){return{}}function gn({children:e}){return e&&e[e.length-1]}function yn(e,t){return typeof t=="string"&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function bn(e,t){e.text+=t}function vn({parent:e}){return e}function En({text:e}){return typeof e=="string"}function wn({text:e}){return e}function xn(e){let t=e.parent.children.indexOf(e);return t!==-1&&e.parent.children.splice(t,1),e}function Tn({type:e,attributes:t,object:r,children:n}){if(e==="#comment")return`<!--${t["data-rich-text-comment"]}-->`;let o="";for(let i in t)(0,it.isValidAttributeName)(i)&&(o+=` ${i}="${(0,it.escapeAttribute)(t[i])}"`);return r?`<${e}${o}>`:`<${e}${o}>${he(n)}</${e}>`}function he(e=[]){return e.map(t=>t.html!==void 0?t.html:t.text===void 0?Tn(t):(0,it.escapeEditableHTML)(t.text)).join("")}function st({text:e}){return e.replace(D,"")}function ot(){return{formats:[],replacements:[],text:""}}function Fn({tagName:e,attributes:t}){let r;if(t&&t.class&&(r=(0,Wt.select)(C).getFormatTypeForClassName(t.class),r&&(t.class=` ${t.class} `.replace(` ${r.className} `," ").trim(),t.class||delete t.class)),r||(r=(0,Wt.select)(C).getFormatTypeForBareElement(e)),!r)return t?{type:e,attributes:t}:{type:e};if(r.__experimentalCreatePrepareEditableTree&&!r.__experimentalCreateOnChangeEditableValue)return null;if(!t)return{formatType:r,type:r.name,tagName:e};let n={},o={},i={...t};for(let c in r.attributes){let a=r.attributes[c];n[c]=i[a],delete i[a],typeof n[c]>"u"&&delete n[c]}for(let c in i)o[c]=t[c];r.contentEditable===!1&&delete o.contenteditable;let s={formatType:r,type:r.name,tagName:e};return Object.keys(n).length&&(s.attributes=n),Object.keys(o).length&&(s.unregisteredAttributes=o),s}var G=class yt{#t;static empty(){return new yt}static fromPlainText(t){return new yt(L({text:t}))}static fromHTMLString(t){return new yt(L({html:t}))}static fromHTMLElement(t,r={}){let{preserveWhiteSpace:n=!1}=r,o=n?t:ye(t),i=new yt(L({element:o}));return Object.defineProperty(i,"originalHTML",{value:t.innerHTML}),i}constructor(t=ot()){this.#t=t}toPlainText(){return st(this.#t)}toHTMLString({preserveWhiteSpace:t}={}){return this.originalHTML||I({value:this.#t,preserveWhiteSpace:t})}valueOf(){return this.toHTMLString()}toString(){return this.toHTMLString()}toJSON(){return this.toHTMLString()}get length(){return this.text.length}get formats(){return this.#t.formats}get replacements(){return this.#t.replacements}get text(){return this.#t.text}};for(let e of Object.getOwnPropertyNames(String.prototype))G.prototype.hasOwnProperty(e)||Object.defineProperty(G.prototype,e,{value(...t){return this.toHTMLString()[e](...t)}});function L({element:e,text:t,html:r,range:n,__unstableIsEditableTree:o}={}){return r instanceof G?{text:r.text,formats:r.formats,replacements:r.replacements}:typeof t=="string"&&t.length>0?{formats:Array(t.length),replacements:Array(t.length),text:t}:(typeof r=="string"&&r.length>0&&(e=z(document,r)),typeof e!="object"?ot():be({element:e,range:n,isEditableTree:o}))}function tt(e,t,r,n){if(!r)return;let{parentNode:o}=t,{startContainer:i,startOffset:s,endContainer:c,endOffset:a}=r,u=e.text.length;n.start!==void 0?e.start=u+n.start:t===i&&t.nodeType===t.TEXT_NODE?e.start=u+s:o===i&&t===i.childNodes[s]?e.start=u:o===i&&t===i.childNodes[s-1]?e.start=u+n.text.length:t===i&&(e.start=u),n.end!==void 0?e.end=u+n.end:t===c&&t.nodeType===t.TEXT_NODE?e.end=u+a:o===c&&t===c.childNodes[a-1]?e.end=u+n.text.length:o===c&&t===c.childNod
|
||
|
|
`}));continue}let u=Fn({tagName:a,attributes:Cn({element:c})});if(u?.formatType?.contentEditable===!1){delete u.formatType,tt(n,c,t,ot()),Z(n,{formats:[,],replacements:[{...u,innerHTML:c.innerHTML}],text:D});continue}u&&delete u.formatType;let f=be({element:c,range:t,isEditableTree:r});if(tt(n,c,t,f),!u||c.getAttribute("data-rich-text-placeholder")||c.getAttribute("data-rich-text-bogus"))Z(n,f);else if(f.text.length===0)u.attributes&&Z(n,{formats:[,],replacements:[u],text:D});else{let m=function(l){if(m.formats===l)return m.newFormats;let T=l?[u,...l]:[u];return m.formats=l,m.newFormats=T,T};var i=m;m.newFormats=[u],Z(n,{...f,formats:Array.from(f.formats,m)})}}return n}function Cn({element:e}){if(!e.hasAttributes())return;let t=e.attributes.length,r;for(let n=0;n<t;n++){let{name:o,value:i}=e.attributes[n];if(o.indexOf("data-rich-text-")===0)continue;let s=/^on/i.test(o)?"data-disable-rich-text-"+o:o;r=r||{},r[s]=i}return r}function Z(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function ve(...e){return H(e.reduce(Z,L()))}function ct(e,t){return Q(e).find(({type:r})=>r===t)}function Ee({start:e,end:t,replacements:r,text:n}){if(!(e+1!==t||n[e]!==D))return r[e]}function et({start:e,end:t}){if(!(e===void 0||t===void 0))return e===t}function we({text:e}){return e.length===0}function xe(e,t=""){return typeof t=="string"&&(t=L({text:t})),H(e.reduce((r,{formats:n,replacements:o,text:i})=>({formats:r.formats.concat(t.formats,n),replacements:r.replacements.concat(t.replacements,o),text:r.text+t.text+i})))}var at=d(W(),1);function Te(e,t){if(t={name:e,...t},typeof t.name!="string"){window.console.error("Format names must be strings.");return}if(!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(t.name)){window.console.error("Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format");return}if((0,at.select)(C).getFormatType(t.name)){window.console.error('Format "'+t.name+'" is already registered.');return}if(typeof t.tagName!="string"||t.tagName===""){window.console.error("Format tag names must be a string.");return}if((typeof t.className!="string"||t.className==="")&&t.className!==null){window.console.error("Format class names must be a string, or null to handle bare elements.");return}if(!/^[_a-zA-Z]+[a-zA-Z0-9_-]*$/.test(t.className)){window.console.error("A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers.");return}if(t.className===null){let r=(0,at.select)(C).getFormatTypeForBareElement(t.tagName);if(r&&r.name!=="core/unknown"){window.console.error(`Format "${r.name}" is already registered to handle bare tag name "${t.tagName}".`);return}}else{let r=(0,at.select)(C).getFormatTypeForClassName(t.className);if(r){window.console.error(`Format "${r.name}" is already registered to handle class name "${t.className}".`);return}}if(!("title"in t)||t.title===""){window.console.error('The format "'+t.name+'" must have a title.');return}if("keywords"in t&&t.keywords.length>3){window.console.error('The format "'+t.name+'" can have a maximum of 3 keywords.');return}if(typeof t.title!="string"){window.console.error("Format titles must be strings.");return}return(0,at.dispatch)(C).addFormatTypes(t),t}function ut(e,t,r=e.start,n=e.end){let{formats:o,activeFormats:i}=e,s=o.slice();if(r===n){let c=s[r]?.find(({type:a})=>a===t);if(c){for(;s[r]?.find(a=>a===c);)zt(s,r,t),r--;for(n++;s[n]?.find(a=>a===c);)zt(s,n,t),n++}}else for(let c=r;c<n;c++)s[c]&&zt(s,c,t);return H({...e,formats:s,activeFormats:i?.filter(({type:c})=>c!==t)||[]})}function zt(e,t,r){let n=e[t].filter(({type:o})=>o!==r);n.length?e[t]=n:delete e[t]}function ft(e,t,r=e.start,n=e.end){let{formats:o,replacements:i,text:s}=e;typeof t=="string"&&(t=L({text:t}));let c=r+t.text.length;return H({formats:o.slice(0,r).concat(t.formats,o.slice(n)),replacements:i.slice(0,r).concat(t.replacements,i.slice(n)),text:s.slice(0,r)+t.text+s.slice(n),start:c,end:c})}function
|
||
|
|
(window.wp ||= {}).richText = wp.richText;
|
||
|
|
})();
|