diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:56:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:56:49 +0000 |
commit | a415c29efee45520ae252d2aa28f1083a521cd7b (patch) | |
tree | f4ade4b6668ecc0765de7e1424f7c1427ad433ff /wp-includes/js/dist/rich-text.min.js | |
parent | Initial commit. (diff) | |
download | wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.tar.xz wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.zip |
Adding upstream version 6.4.3+dfsg1.upstream/6.4.3+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/rich-text.min.js')
-rw-r--r-- | wp-includes/js/dist/rich-text.min.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/wp-includes/js/dist/rich-text.min.js b/wp-includes/js/dist/rich-text.min.js new file mode 100644 index 0000000..40c8e1c --- /dev/null +++ b/wp-includes/js/dist/rich-text.min.js @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},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,{__experimentalRichText:function(){return Ke},__unstableCreateElement:function(){return E},__unstableFormatEdit:function(){return Ye},__unstableToDom:function(){return le},__unstableUseRichText:function(){return qe},applyFormat:function(){return b},concat:function(){return D},create:function(){return N},getActiveFormat:function(){return k},getActiveFormats:function(){return O},getActiveObject:function(){return M},getTextContent:function(){return $},insert:function(){return B},insertObject:function(){return X},isCollapsed:function(){return j},isEmpty:function(){return V},join:function(){return P},registerFormatType:function(){return W},remove:function(){return z},removeFormat:function(){return H},replace:function(){return U},slice:function(){return q},split:function(){return K},store:function(){return h},toHTMLString:function(){return pe},toggleFormat:function(){return Fe},unregisterFormatType:function(){return _e},useAnchor:function(){return Oe},useAnchorRef:function(){return Se}});var n={};e.r(n),e.d(n,{getFormatType:function(){return l},getFormatTypeForBareElement:function(){return f},getFormatTypeForClassName:function(){return d},getFormatTypes:function(){return u}});var r={};e.r(r),e.d(r,{addFormatTypes:function(){return m},removeFormatTypes:function(){return p}});var o=window.wp.data;var 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={};function i(e){return[e]}function c(e,t,n){var r;if(e.length!==t.length)return!1;for(r=n;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}const u=function(e,t){var n,r=t||i;function o(){n=new WeakMap}function a(){var t,o,a,i,u,l=arguments.length;for(i=new Array(l),a=0;a<l;a++)i[a]=arguments[a];for(t=function(e){var t,r,o,a,i,c=n,u=!0;for(t=0;t<e.length;t++){if(!(i=r=e[t])||"object"!=typeof i){u=!1;break}c.has(r)?c=c.get(r):(o=new WeakMap,c.set(r,o),c=o)}return c.has(s)||((a=function(){var e={clear:function(){e.head=null}};return e}()).isUniqueByDependants=u,c.set(s,a)),c.get(s)}(u=r.apply(null,i)),t.isUniqueByDependants||(t.lastDependants&&!c(u,t.lastDependants,0)&&t.clear(),t.lastDependants=u),o=t.head;o;){if(c(o.args,i,1))return o!==t.head&&(o.prev.next=o.next,o.next&&(o.next.prev=o.prev),o.next=t.head,o.prev=null,t.head.prev=o,t.head=o),o.val;o=o.next}return o={val:e.apply(null,i)},i[0]=null,o.args=i,t.head&&(t.head.prev=o,o.next=t.head),t.head=o,o.val}return a.getDependants=r,a.clear=o,o(),a}((e=>Object.values(e.formatTypes)),(e=>[e.formatTypes]));function l(e,t){return e.formatTypes[t]}function f(e,t){const n=u(e);return n.find((({className:e,tagName:n})=>null===e&&t===n))||n.find((({className:e,tagName:t})=>null===e&&"*"===t))}function d(e,t){return u(e).find((({className:e})=>null!==e&&` ${t} `.indexOf(` ${e} `)>=0))}function m(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Array.isArray(e)?e:[e]}}function p(e){return{type:"REMOVE_FORMAT_TYPES",names:Array.isArray(e)?e:[e]}}const h=(0,o.createReduxStore)("core/rich-text",{reducer:a,selectors:n,actions:r});function g(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 v(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];g(e,n)&&(o[t]=n)})),t[n]=o}})),{...e,formats:t}}function y(e,t,n){return(e=e.slice())[t]=n,e}function b(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]=y(s[n],o,t),n--;for(r++;s[r]&&s[r][o]===e;)s[r]=y(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 v({...e,formats:s,activeFormats:[...a?.filter((({type:e})=>e!==t.type))||[],t]})}function E({implementation:e},t){return E.body||(E.body=e.createHTMLDocument("").body),E.body.innerHTML=t,E.body}(0,o.register)(h);const x="",T="\ufeff";function w({tagName:e,attributes:t}){let n;if(t&&t.class&&(n=(0,o.select)(h).getFormatTypeForClassName(t.class),n&&(t.class=` ${t.class} `.replace(` ${n.className} `," ").trim(),t.class||delete t.class)),n||(n=(0,o.select)(h).getFormatTypeForBareElement(e)),!n)return t?{type:e,attributes:t}:{type:e};if(n.__experimentalCreatePrepareEditableTree&&!n.__experimentalCreateOnChangeEditableValue)return null;if(!t)return{formatType:n,type:n.name,tagName:e};const r={},a={},s={...t};for(const e in n.attributes){const t=n.attributes[e];r[e]=s[t],n.__unstableFilterAttributeValue&&(r[e]=n.__unstableFilterAttributeValue(e,r[e])),delete s[t],void 0===r[e]&&delete r[e]}for(const e in s)a[e]=t[e];return!1===n.contentEditable&&delete a.contenteditable,{formatType:n,type:n.name,tagName:e,attributes:r,unregisteredAttributes:a}}function N({element:e,text:t,html:n,range:r,__unstableIsEditableTree:o,preserveWhiteSpace:a}={}){return"string"==typeof t&&t.length>0?{formats:Array(t.length),replacements:Array(t.length),text:t}:("string"==typeof n&&n.length>0&&(e=E(document,n)),"object"!=typeof e?{formats:[],replacements:[],text:""}:A({element:e,range:r,isEditableTree:o,preserveWhiteSpace:a}))}function C(e,t,n,r){if(!n)return;const{parentNode:o}=t,{startContainer:a,startOffset:s,endContainer:i,endOffset:c}=n,u=e.text.length;void 0!==r.start?e.start=u+r.start:t===a&&t.nodeType===t.TEXT_NODE?e.start=u+s:o===a&&t===a.childNodes[s]?e.start=u:o===a&&t===a.childNodes[s-1]?e.start=u+r.text.length:t===a&&(e.start=u),void 0!==r.end?e.end=u+r.end:t===i&&t.nodeType===t.TEXT_NODE?e.end=u+c:o===i&&t===i.childNodes[c-1]?e.end=u+r.text.length:o===i&&t===i.childNodes[c]?e.end=u:t===i&&(e.end=u+c)}function F(e,t,n){if(!t)return;const{startContainer:r,endContainer:o}=t;let{startOffset:a,endOffset:s}=t;return e===r&&(a=n(e.nodeValue.slice(0,a)).length),e===o&&(s=n(e.nodeValue.slice(0,s)).length),{startContainer:r,startOffset:a,endContainer:o,endOffset:s}}function _(e){return e.replace(/[\n\r\t]+/g," ")}function L(e){return e.replace(new RegExp(`[${T}${x}]`,"gu"),"")}function A({element:e,range:t,isEditableTree:n,preserveWhiteSpace:r}){const o={formats:[],replacements:[],text:""};if(!e)return o;if(!e.hasChildNodes())return C(o,e,t,{formats:[],replacements:[],text:""}),o;const a=e.childNodes.length;for(let s=0;s<a;s++){const i=e.childNodes[s],c=i.nodeName.toLowerCase();if(i.nodeType===i.TEXT_NODE){let f=L;r||(f=e=>L(_(e)));const d=f(i.nodeValue);C(o,i,t=F(i,t,f),{text:d}),o.formats.length+=d.length,o.replacements.length+=d.length,o.text+=d;continue}if(i.nodeType!==i.ELEMENT_NODE)continue;if(n&&(i.getAttribute("data-rich-text-placeholder")||"br"===c&&!i.getAttribute("data-rich-text-line-break"))){C(o,i,t,{formats:[],replacements:[],text:""});continue}if("script"===c){const m={formats:[,],replacements:[{type:c,attributes:{"data-rich-text-script":i.getAttribute("data-rich-text-script")||encodeURIComponent(i.innerHTML)}}],text:x};C(o,i,t,m),S(o,m);continue}if("br"===c){C(o,i,t,{formats:[],replacements:[],text:""}),S(o,N({text:"\n"}));continue}const u=w({tagName:c,attributes:R({element:i})});if(!1===u?.formatType?.contentEditable){delete u.formatType,C(o,i,t,{formats:[],replacements:[],text:""}),S(o,{formats:[,],replacements:[{...u,innerHTML:i.innerHTML}],text:x});continue}u&&delete u.formatType;const l=A({element:i,range:t,isEditableTree:n,preserveWhiteSpace:r});if(C(o,i,t,l),u)if(0===l.text.length)u.attributes&&S(o,{formats:[,],replacements:[u],text:x});else{function p(e){if(p.formats===e)return p.newFormats;const t=e?[u,...e]:[u];return p.formats=e,p.newFormats=t,t}p.newFormats=[u],S(o,{...l,formats:Array.from(l.formats,p)})}else S(o,l)}return o}function R({element:e}){if(!e.hasAttributes())return;const t=e.attributes.length;let n;for(let r=0;r<t;r++){const{name:t,value:o}=e.attributes[r];if(0===t.indexOf("data-rich-text-"))continue;n=n||{},n[/^on/i.test(t)?"data-disable-rich-text-"+t:t]=o}return n}function S(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function D(...e){return v(e.reduce(S,N()))}function O(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=>g(t,e)))||i.splice(n,1)}if(0===i.length)return t}return i||t}function k(e,t){return O(e).find((({type:e})=>e===t))}function M({start:e,end:t,replacements:n,text:r}){if(e+1===t&&r[e]===x)return n[e]}function $({text:e}){return e.replace(x,"")}function j({start:e,end:t}){if(void 0!==e&&void 0!==t)return e===t}function V({text:e}){return 0===e.length}function P(e,t=""){return"string"==typeof t&&(t=N({text:t})),v(e.reduce(((e,{formats:n,replacements:r,text:o})=>({formats:e.formats.concat(t.formats,n),replacements:e.replacements.concat(t.replacements,r),text:e.text+t.text+o}))))}function W(e,t){if("string"==typeof(t={name:e,...t}).name)if(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(t.name))if((0,o.select)(h).getFormatType(t.name))window.console.error('Format "'+t.name+'" is already registered.');else if("string"==typeof t.tagName&&""!==t.tagName)if("string"==typeof t.className&&""!==t.className||null===t.className)if(/^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test(t.className)){if(null===t.className){const e=(0,o.select)(h).getFormatTypeForBareElement(t.tagName);if(e&&"core/unknown"!==e.name)return void window.console.error(`Format "${e.name}" is already registered to handle bare tag name "${t.tagName}".`)}else{const e=(0,o.select)(h).getFormatTypeForClassName(t.className);if(e)return void window.console.error(`Format "${e.name}" is already registered to handle class name "${t.className}".`)}if("title"in t&&""!==t.title)if("keywords"in t&&t.keywords.length>3)window.console.error('The format "'+t.name+'" can have a maximum of 3 keywords.');else{if("string"==typeof t.title)return(0,o.dispatch)(h).addFormatTypes(t),t;window.console.error("Format titles must be strings.")}else window.console.error('The format "'+t.name+'" must have a title.')}else window.console.error("A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.");else window.console.error("Format class names must be a string, or null to handle bare elements.");else window.console.error("Format tag names must be a string.");else 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");else window.console.error("Format names must be strings.")}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));if(e){for(;s[n]?.find((t=>t===e));)I(s,n,t),n--;for(r++;s[r]?.find((t=>t===e));)I(s,r,t),r++}}else for(let e=n;e<r;e++)s[e]&&I(s,e,t);return v({...e,formats:s,activeFormats:a?.filter((({type:e})=>e!==t))||[]})}function I(e,t,n){const r=e[t].filter((({type:e})=>e!==n));r.length?e[t]=r:delete e[t]}function B(e,t,n=e.start,r=e.end){const{formats:o,replacements:a,text:s}=e;"string"==typeof t&&(t=N({text:t}));const i=n+t.text.length;return v({formats:o.slice(0,n).concat(t.formats,o.slice(r)),replacements:a.slice(0,n).concat(t.replacements,a.slice(r)),text:s.slice(0,n)+t.text+s.slice(r),start:i,end:i})}function z(e,t,n){return B(e,N(),t,n)}function U({formats:e,replacements:t,text:n,start:r,end:o},a,s){return n=n.replace(a,((n,...a)=>{const i=a[a.length-2];let c,u,l=s;return"function"==typeof l&&(l=s(n,...a)),"object"==typeof l?(c=l.formats,u=l.replacements,l=l.text):(c=Array(l.length),u=Array(l.length),e[i]&&(c=c.fill(e[i]))),e=e.slice(0,i).concat(c,e.slice(i+n.length)),t=t.slice(0,i).concat(u,t.slice(i+n.length)),r&&(r=o=i+l.length),l})),v({formats:e,replacements:t,text:n,start:r,end:o})}function X(e,t,n,r){return B(e,{formats:[,],replacements:[t],text:x},n,r)}function q(e,t=e.start,n=e.end){const{formats:r,replacements:o,text:a}=e;return void 0===t||void 0===n?{...e}:{formats:r.slice(t,n),replacements:o.slice(t,n),text:a.slice(t,n)}}function K({formats:e,replacements:t,text:n,start:r,end:o},a){if("string"!=typeof a)return function({formats:e,replacements:t,text:n,start:r,end:o},a=r,s=o){if(void 0===r||void 0===o)return;const i={formats:e.slice(0,a),replacements:t.slice(0,a),text:n.slice(0,a)},c={formats:e.slice(s),replacements:t.slice(s),text:n.slice(s),start:0,end:0};return[i,c]}(...arguments);let s=0;return n.split(a).map((n=>{const i=s,c={formats:e.slice(i,i+n.length),replacements:t.slice(i,i+n.length),text:n};return s+=a.length+n.length,void 0!==r&&void 0!==o&&(r>=i&&r<s?c.start=r-i:r<i&&o>i&&(c.start=0),o>=i&&o<s?c.end=o-i:r<s&&o>s&&(c.end=n.length)),c}))}function Y(e){return(0,o.select)(h).getFormatType(e)}function G(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 Z({type:e,tagName:t,attributes:n,unregisteredAttributes:r,object:o,boundaryClass:a,isEditableTree:s}){const i=Y(e);let c={};if(a&&s&&(c["data-rich-text-format-boundary"]="true"),!i)return n&&(c={...n,...c}),{type:e,attributes:G(c,s),object:o};c={...r,...c};for(const e in n){const t=!!i.attributes&&i.attributes[e];t?c[t]=n[e]:c[e]=n[e]}return i.className&&(c.class?c.class=`${i.className} ${c.class}`:c.class=i.className),s&&!1===i.contentEditable&&(c.contenteditable="false"),{type:t||i.tagName,object:i.object,attributes:G(c,s)}}function J(e,t,n){do{if(e[n]!==t[n])return!1}while(n--);return!0}function Q({value:e,preserveWhiteSpace:t,createEmpty:n,append:r,getLastChild:o,getParent:a,isText:s,getText:i,remove:c,appendText:u,onStartIndex:l,onEndIndex:f,isEditableTree:d,placeholder:m}){const{formats:p,replacements:h,text:g,start:v,end:y}=e,b=p.length+1,E=n(),w=O(e),N=w[w.length-1];let C,F;r(E,"");for(let e=0;e<b;e++){const n=g.charAt(e),b=d&&(!F||"\n"===F),w=p[e];let _=o(E);if(w&&w.forEach(((e,t)=>{if(_&&C&&J(w,C,t))return void(_=o(_));const{type:n,tagName:u,attributes:l,unregisteredAttributes:f}=e,m=d&&e===N,p=a(_),h=r(p,Z({type:n,tagName:u,attributes:l,unregisteredAttributes:f,boundaryClass:m,isEditableTree:d}));s(_)&&0===i(_).length&&c(_),_=r(h,"")})),0===e&&(l&&0===v&&l(E,_),f&&0===y&&f(E,_)),n===x){const t=h[e];if(!t)continue;const{type:n,attributes:o,innerHTML:s}=t,i=Y(n);d||"script"!==n?!1===i?.contentEditable?(_=r(a(_),Z({...t,isEditableTree:d,boundaryClass:v===e&&y===e+1})),s&&r(_,{html:s})):_=r(a(_),Z({...t,object:!0,isEditableTree:d})):(_=r(a(_),Z({type:"script",isEditableTree:d})),r(_,{html:decodeURIComponent(o["data-rich-text-script"])})),_=r(a(_),"")}else t||"\n"!==n?s(_)?u(_,n):_=r(a(_),n):(_=r(a(_),{type:"br",attributes:d?{"data-rich-text-line-break":"true"}:void 0,object:!0}),_=r(a(_),""));l&&v===e+1&&l(E,_),f&&y===e+1&&f(E,_),b&&e===g.length&&(r(a(_),T),m&&0===g.length&&r(a(_),{type:"span",attributes:{"data-rich-text-placeholder":m,style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),C=w,F=n}return E}function ee(e,t){return e===t||e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}function te(e,t,n){const r=e.parentNode;let o=0;for(;e=e.previousSibling;)o++;return n=[o,...n],r!==t&&(n=te(r,t,n)),n}function ne(e,t){for(t=[...t];e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}function re(e,t){if(void 0!==t.html)return e.innerHTML+=t.html;"string"==typeof t&&(t=e.ownerDocument.createTextNode(t));const{type:n,attributes:r}=t;if(n){t=e.ownerDocument.createElement(n);for(const e in r)t.setAttribute(e,r[e])}return e.appendChild(t)}function oe(e,t){e.appendData(t)}function ae({lastChild:e}){return e}function se({parentNode:e}){return e}function ie(e){return e.nodeType===e.TEXT_NODE}function ce({nodeValue:e}){return e}function ue(e){return e.parentNode.removeChild(e)}function le({value:e,prepareEditableTree:t,isEditableTree:n=!0,placeholder:r,doc:o=document}){let a=[],s=[];t&&(e={...e,formats:t(e)});return{body:Q({value:e,createEmpty:()=>E(o,""),append:re,getLastChild:ae,getParent:se,isText:ie,getText:ce,remove:ue,appendText:oe,onStartIndex(e,t){a=te(t,e,[t.nodeValue.length])},onEndIndex(e,t){s=te(t,e,[t.nodeValue.length])},isEditableTree:n,placeholder:r}),selection:{startPath:a,endPath:s}}}function fe({value:e,current:t,prepareEditableTree:n,__unstableDomOnly:r,placeholder:o}){const{body:a,selection:s}=le({value:e,prepareEditableTree:n,placeholder:o,doc:t.ownerDocument});de(a,t),void 0===e.start||r||function({startPath:e,endPath:t},n){const{node:r,offset:o}=ne(n,e),{node:a,offset:s}=ne(n,t),{ownerDocument:i}=n,{defaultView:c}=i,u=c.getSelection(),l=i.createRange();l.setStart(r,o),l.setEnd(a,s);const{activeElement:f}=i;if(u.rangeCount>0){if(ee(l,u.getRangeAt(0)))return;u.removeAllRanges()}u.addRange(l),f!==i.activeElement&&f instanceof c.HTMLElement&&f.focus()}(s,t)}function de(e,t){let n,r=0;for(;n=e.firstChild;){const o=t.childNodes[r];if(o)if(o.isEqualNode(n))e.removeChild(n);else if(o.nodeName!==n.nodeName||o.nodeType===o.TEXT_NODE&&o.data!==n.data)t.replaceChild(n,o);else{const t=o.attributes,r=n.attributes;if(t){let e=t.length;for(;e--;){const{name:r}=t[e];n.getAttribute(r)||o.removeAttribute(r)}}if(r)for(let e=0;e<r.length;e++){const{name:t,value:n}=r[e];o.getAttribute(t)!==n&&o.setAttribute(t,n)}de(n,o),e.removeChild(n)}else t.appendChild(n);r++}for(;t.childNodes[r];)t.removeChild(t.childNodes[r])}var me=window.wp.escapeHtml;function pe({value:e,preserveWhiteSpace:t}){return we(Q({value:e,preserveWhiteSpace:t,createEmpty:he,append:ve,getLastChild:ge,getParent:be,isText:Ee,getText:xe,remove:Te,appendText:ye}).children)}function he(){return{}}function ge({children:e}){return e&&e[e.length-1]}function ve(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function ye(e,t){e.text+=t}function be({parent:e}){return e}function Ee({text:e}){return"string"==typeof e}function xe({text:e}){return e}function Te(e){const t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function we(e=[]){return e.map((e=>void 0!==e.html?e.html:void 0===e.text?function({type:e,attributes:t,object:n,children:r}){let o="";for(const e in t)(0,me.isValidAttributeName)(e)&&(o+=` ${e}="${(0,me.escapeAttribute)(t[e])}"`);return n?`<${e}${o}>`:`<${e}${o}>${we(r)}</${e}>`}(e):(0,me.escapeEditableHTML)(e.text))).join("")}var Ne=window.wp.a11y,Ce=window.wp.i18n;function Fe(e,t){return k(e,t.type)?(t.title&&(0,Ne.speak)((0,Ce.sprintf)((0,Ce.__)("%s removed."),t.title),"assertive"),H(e,t.type)):(t.title&&(0,Ne.speak)((0,Ce.sprintf)((0,Ce.__)("%s applied."),t.title),"assertive"),b(e,t))}function _e(e){const t=(0,o.select)(h).getFormatType(e);if(t)return(0,o.dispatch)(h).removeFormatTypes(e),t;window.console.error(`Format ${e} is not registered.`)}var Le=window.wp.element,Ae=window.wp.deprecated,Re=e.n(Ae);function Se({ref:e,value:t,settings:n={}}){Re()("`useAnchorRef` hook",{since:"6.1",alternative:"`useAnchor` hook"});const{tagName:r,className:o,name:a}=n,s=a?k(t,a):void 0;return(0,Le.useMemo)((()=>{if(!e.current)return;const{ownerDocument:{defaultView:t}}=e.current,n=t.getSelection();if(!n.rangeCount)return;const a=n.getRangeAt(0);if(!s)return a;let i=a.startContainer;for(i=i.nextElementSibling||i;i.nodeType!==i.ELEMENT_NODE;)i=i.parentNode;return i.closest(r+(o?"."+o:""))}),[s,t.start,t.end,r,o])}function De(e,t,n){if(!e)return;const{ownerDocument:r}=e,{defaultView:o}=r,a=o.getSelection();if(!a)return;if(!a.rangeCount)return;const s=a.getRangeAt(0);if(!s||!s.startContainer)return;const i=function(e,t,n,r){let o=e.startContainer;if(o.nodeType===o.TEXT_NODE&&e.startOffset===o.length&&o.nextSibling)for(o=o.nextSibling;o.firstChild;)o=o.firstChild;if(o.nodeType!==o.ELEMENT_NODE&&(o=o.parentElement),!o)return;if(o===t)return;if(!t.contains(o))return;const a=n+(r?"."+r:"");for(;o!==t;){if(o.matches(a))return o;o=o.parentElement}}(s,e,t,n);return i||function(e,t){return{contextElement:t,getBoundingClientRect(){return t.contains(e.startContainer)?e.getBoundingClientRect():t.getBoundingClientRect()}}}(s,e)}function Oe({editableContentElement:e,settings:t={}}){const{tagName:n,className:r}=t,[o,a]=(0,Le.useState)((()=>De(e,n,r)));return(0,Le.useLayoutEffect)((()=>{if(!e)return;const{ownerDocument:t}=e;function o(){a(De(e,n,r))}function s(){t.addEventListener("selectionchange",o)}function i(){t.removeEventListener("selectionchange",o)}return e===t.activeElement&&s(),e.addEventListener("focusin",s),e.addEventListener("focusout",i),i}),[e,n,r]),o}var ke=window.wp.compose;const Me="pre-wrap",$e="1px";function je({record:e}){const t=(0,Le.useRef)(),{activeFormats:n=[],replacements:r,start:o}=e.current,a=r[o];return(0,Le.useEffect)((()=>{if(!(n&&n.length||a))return;const e="*[data-rich-text-format-boundary]",r=t.current.querySelector(e);if(!r)return;const{ownerDocument:o}=r,{defaultView:s}=o,i=`${`.rich-text:focus ${e}`} {${`background-color: ${s.getComputedStyle(r).color.replace(")",", 0.2)").replace("rgb","rgba")}`}}`,c="rich-text-boundary-style";let u=o.getElementById(c);u||(u=o.createElement("style"),u.id=c,o.head.appendChild(u)),u.innerHTML!==i&&(u.innerHTML=i)}),[n,a]),t}function Ve(e){const t=(0,Le.useRef)(e);return t.current=e,(0,ke.useRefEffect)((e=>{function n(n){const{record:r,preserveWhiteSpace:o}=t.current,{ownerDocument:a}=e;if(j(r.current)||!e.contains(a.activeElement))return;const s=q(r.current),i=$(s),c=pe({value:s,preserveWhiteSpace:o});n.clipboardData.setData("text/plain",i),n.clipboardData.setData("text/html",c),n.clipboardData.setData("rich-text","true"),n.preventDefault(),"cut"===n.type&&a.execCommand("delete")}return e.addEventListener("copy",n),e.addEventListener("cut",n),()=>{e.removeEventListener("copy",n),e.removeEventListener("cut",n)}}),[])}var Pe=window.wp.keycodes;const We=[];function He(e){const[,t]=(0,Le.useReducer)((()=>({}))),n=(0,Le.useRef)(e);return n.current=e,(0,ke.useRefEffect)((e=>{function r(r){const{keyCode:o,shiftKey:a,altKey:s,metaKey:i,ctrlKey:c}=r;if(a||s||i||c||o!==Pe.LEFT&&o!==Pe.RIGHT)return;const{record:u,applyRecord:l}=n.current,{text:f,formats:d,start:m,end:p,activeFormats:h=[]}=u.current,g=j(u.current),{ownerDocument:v}=e,{defaultView:y}=v,{direction:b}=y.getComputedStyle(e),E="rtl"===b?Pe.RIGHT:Pe.LEFT,x=r.keyCode===E;if(g&&0===h.length){if(0===m&&x)return;if(p===f.length&&!x)return}if(!g)return;const T=d[m-1]||We,w=d[m]||We,N=x?T:w,C=h.every(((e,t)=>e===N[t]));let F=h.length;if(C?F<N.length&&F++:F--,F===h.length)return void(u.current._newActiveFormats=N);r.preventDefault();const _=(C?N:x?w:T).slice(0,F),L={...u.current,activeFormats:_};u.current=L,l(L),t()}return e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r)}}),[])}const Ie=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),Be=[],ze="data-rich-text-placeholder";function Ue(e){const t=(0,Le.useRef)(e);return t.current=e,(0,ke.useRefEffect)((e=>{const{ownerDocument:n}=e,{defaultView:r}=n;let o=!1;function a(e){if(o)return;let n;e&&(n=e.inputType);const{record:r,applyRecord:a,createRecord:s,handleChange:i}=t.current;if(n&&(0===n.indexOf("format")||Ie.has(n)))return void a(r.current);const c=s(),{start:u,activeFormats:l=[]}=r.current,f=function({value:e,start:t,end:n,formats:r}){const o=Math.min(t,n),a=Math.max(t,n),s=e.formats[o-1]||[],i=e.formats[a]||[];for(e.activeFormats=r.map(((e,t)=>{if(s[t]){if(g(e,s[t]))return s[t]}else if(i[t]&&g(e,i[t]))return i[t];return e}));--n>=t;)e.activeFormats.length>0?e.formats[n]=e.activeFormats:delete e.formats[n];return e}({value:c,start:u,end:c.start,formats:l});i(f)}function s(){const{record:s,applyRecord:i,createRecord:c,onSelectionChange:u}=t.current;if("true"!==e.contentEditable)return;if(n.activeElement!==e){if("true"!==n.activeElement.contentEditable)return;if(!n.activeElement.contains(e))return;const t=r.getSelection(),{anchorNode:o,focusNode:a}=t;if(e.contains(o)&&e!==o&&e.contains(a)&&e!==a){const{start:e,end:t}=c();s.current.activeFormats=Be,u(e,t)}else if(e.contains(o)&&e!==o){const{start:e,end:t=e}=c();s.current.activeFormats=Be,u(t)}else if(e.contains(a)){const{start:e,end:t=e}=c();s.current.activeFormats=Be,u(void 0,t)}return}if(o)return;const{start:l,end:f,text:d}=c(),m=s.current;if(d!==m.text)return void a();if(l===m.start&&f===m.end)return void(0===m.text.length&&0===l&&function(e){const t=e.getSelection(),{anchorNode:n,anchorOffset:r}=t;if(n.nodeType!==n.ELEMENT_NODE)return;const o=n.childNodes[r];o&&o.nodeType===o.ELEMENT_NODE&&o.hasAttribute(ze)&&t.collapseToStart()}(r));const p={...m,start:l,end:f,activeFormats:m._newActiveFormats,_newActiveFormats:void 0},h=O(p,Be);p.activeFormats=h,s.current=p,i(p,{domOnly:!0}),u(l,f)}function i(){o=!0,n.removeEventListener("selectionchange",s),e.querySelector(`[${ze}]`)?.remove()}function c(){o=!1,a({inputType:"insertText"}),n.addEventListener("selectionchange",s)}function u(){const{record:n,isSelected:r,onSelectionChange:o,applyRecord:a}=t.current;if(!e.parentElement.closest('[contenteditable="true"]'))if(r)a(n.current),o(n.current.start,n.current.end);else{const e=void 0;n.current={...n.current,start:e,end:e,activeFormats:Be}}}return e.addEventListener("input",a),e.addEventListener("compositionstart",i),e.addEventListener("compositionend",c),e.addEventListener("focus",u),n.addEventListener("selectionchange",s),()=>{e.removeEventListener("input",a),e.removeEventListener("compositionstart",i),e.removeEventListener("compositionend",c),e.removeEventListener("focus",u),n.removeEventListener("selectionchange",s)}}),[])}function Xe(e){const t=(0,Le.useRef)(e);return t.current=e,(0,ke.useRefEffect)((e=>{function n(e){const{keyCode:n}=e,{createRecord:r,handleChange:o}=t.current;if(e.defaultPrevented)return;if(n!==Pe.DELETE&&n!==Pe.BACKSPACE)return;const a=r(),{start:s,end:i,text:c}=a;0===s&&0!==i&&i===c.length&&(o(z(a)),e.preventDefault())}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}),[])}function qe({value:e="",selectionStart:t,selectionEnd:n,placeholder:r,preserveWhiteSpace:a,onSelectionChange:s,onChange:i,__unstableDisableFormats:c,__unstableIsSelected:u,__unstableDependencies:l=[],__unstableAfterParse:f,__unstableBeforeSerialize:d,__unstableAddInvisibleFormats:m}){const p=(0,o.useRegistry)(),[,h]=(0,Le.useReducer)((()=>({}))),g=(0,Le.useRef)();function v(){const{ownerDocument:{defaultView:e}}=g.current,t=e.getSelection(),n=t.rangeCount>0?t.getRangeAt(0):null;return N({element:g.current,range:n,__unstableIsEditableTree:!0,preserveWhiteSpace:a})}function y(e,{domOnly:t}={}){fe({value:e,current:g.current,prepareEditableTree:m,__unstableDomOnly:t,placeholder:r})}const b=(0,Le.useRef)(e),E=(0,Le.useRef)();function x(){b.current=e,E.current=N({html:e,preserveWhiteSpace:a}),c&&(E.current.formats=Array(e.length),E.current.replacements=Array(e.length)),f&&(E.current.formats=f(E.current)),E.current.start=t,E.current.end=n}const T=(0,Le.useRef)(!1);if(E.current)t===E.current.start&&n===E.current.end||(T.current=u,E.current={...E.current,start:t,end:n,activeFormats:void 0});else{T.current=u,x();"core/text-color"===E.current?.formats[0]?.[0]?.type&&function(e){E.current=e,b.current=pe({value:d?{...e,formats:d(e)}:e,preserveWhiteSpace:a});const{formats:t,text:n}=e;p.batch((()=>{i(b.current,{__unstableFormats:t,__unstableText:n})})),h()}(E.current)}function w(e){E.current=e,y(e),b.current=c?e.text:pe({value:d?{...e,formats:d(e)}:e,preserveWhiteSpace:a});const{start:t,end:n,formats:r,text:o}=e;p.batch((()=>{s(t,n),i(b.current,{__unstableFormats:r,__unstableText:o})})),h()}function C(){x(),y(E.current)}const F=(0,Le.useRef)(!1);(0,Le.useLayoutEffect)((()=>{F.current&&e!==b.current&&(C(),h())}),[e]),(0,Le.useLayoutEffect)((()=>{T.current&&(g.current.ownerDocument.activeElement!==g.current&&g.current.focus(),y(E.current),T.current=!1)}),[T.current]);const _=(0,ke.useMergeRefs)([g,(0,Le.useCallback)((e=>{e&&(e.style.whiteSpace=Me,e.style.minWidth=$e)}),[]),je({record:E}),Ve({record:E,preserveWhiteSpace:a}),(0,ke.useRefEffect)((e=>{function t(t){const{target:n}=t;if(n===e||n.textContent&&n.isContentEditable)return;const{ownerDocument:r}=n,{defaultView:o}=r,a=o.getSelection();if(a.containsNode(n))return;const s=r.createRange(),i=n.isContentEditable?n:n.closest("[contenteditable]");s.selectNode(i),a.removeAllRanges(),a.addRange(s),t.preventDefault()}function n(n){n.relatedTarget&&!e.contains(n.relatedTarget)&&"A"===n.relatedTarget.tagName&&t(n)}return e.addEventListener("click",t),e.addEventListener("focusin",n),()=>{e.removeEventListener("click",t),e.removeEventListener("focusin",n)}}),[]),He({record:E,applyRecord:y}),Xe({createRecord:v,handleChange:w}),Ue({record:E,applyRecord:y,createRecord:v,handleChange:w,isSelected:u,onSelectionChange:s}),(0,ke.useRefEffect)((e=>{const{ownerDocument:t}=e,{defaultView:n}=t,r=n?.getSelection();let o;function a(){return r.rangeCount?r.getRangeAt(0):null}function s(e){const n="keydown"===e.type?"keyup":"pointerup";function r(){t.removeEventListener(n,s),t.removeEventListener("selectionchange",r),t.removeEventListener("input",r)}function s(){r(),ee(o,a())||t.dispatchEvent(new Event("selectionchange"))}t.addEventListener(n,s),t.addEventListener("selectionchange",r),t.addEventListener("input",r),o=a()}return e.addEventListener("pointerdown",s),e.addEventListener("keydown",s),()=>{e.removeEventListener("pointerdown",s),e.removeEventListener("keydown",s)}}),[]),(0,ke.useRefEffect)((()=>{C(),F.current=!0}),[r,...l])]);return{value:E.current,getValue:()=>E.current,onChange:w,ref:_}}function Ke(){}function Ye({formatTypes:e,onChange:t,onFocus:n,value:r,forwardedRef:o}){return e.map((e=>{const{name:a,edit:s}=e;if(!s)return null;const i=k(r,a),c=void 0!==i,u=M(r),l=void 0!==u&&u.type===a;return(0,Le.createElement)(s,{key:a,isActive:c,activeAttributes:c&&i.attributes||{},isObjectActive:l,activeObjectAttributes:l&&u.attributes||{},value:r,onChange:t,onFocus:n,contentRef:o})}))}(window.wp=window.wp||{}).richText=t}();
\ No newline at end of file |