WordPress/wp-includes/js/dist/rich-text.min.js
gziolo c3ea09ebb8 Editor: Update WordPress packages published for Gutenberg 10.6
It contains several changes in addition to regular update to WordPress packages:
- All newly exposed blocks are now registered on the server.
- Dutone block support was added.
- Border block support was updated.
- New shared function `construct_wp_query_args` was added for the family of Query blocks - it might need some further work.

Props youknowriad.
See #52991.



Built from https://develop.svn.wordpress.org/trunk@50929


git-svn-id: http://core.svn.wordpress.org/trunk@50538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-19 15:09:27 +00:00

2 lines
36 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.richText=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=557)}({0:function(e,t){e.exports=window.wp.element},10:function(e,t){e.exports=window.wp.compose},12:function(e,t){e.exports=window.wp.keycodes},19:function(e,t){e.exports=window.wp.dom},2:function(e,t){e.exports=window.lodash},26:function(e,t,n){"use strict";var r,a;function o(e){return[e]}function i(){var e={clear:function(){e.head=null}};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}r={},a="undefined"!=typeof WeakMap,t.a=function(e,t){var n,s;function l(){n=a?new WeakMap:i()}function u(){var n,r,a,o,i,l=arguments.length;for(o=new Array(l),a=0;a<l;a++)o[a]=arguments[a];for(i=t.apply(null,o),(n=s(i)).isUniqueByDependants||(n.lastDependants&&!c(i,n.lastDependants,0)&&n.clear(),n.lastDependants=i),r=n.head;r;){if(c(r.args,o,1))return r!==n.head&&(r.prev.next=r.next,r.next&&(r.next.prev=r.prev),r.next=n.head,r.prev=null,n.head.prev=r,n.head=r),r.val;r=r.next}return r={val:e.apply(null,o)},o[0]=null,r.args=o,n.head&&(n.head.prev=r,r.next=n.head),n.head=r,r.val}return t||(t=o),s=a?function(e){var t,a,o,c,s,l=n,u=!0;for(t=0;t<e.length;t++){if(a=e[t],!(s=a)||"object"!=typeof s){u=!1;break}l.has(a)?l=l.get(a):(o=new WeakMap,l.set(a,o),l=o)}return l.has(r)||((c=i()).isUniqueByDependants=u,l.set(r,c)),l.get(r)}:function(){return n},u.getDependants=t,u.clear=l,l(),u}},5:function(e,t){e.exports=window.wp.data},557:function(e,t,n){"use strict";n.r(t),n.d(t,"store",(function(){return g})),n.d(t,"applyFormat",(function(){return y})),n.d(t,"concat",(function(){return L})),n.d(t,"create",(function(){return _})),n.d(t,"getActiveFormat",(function(){return P})),n.d(t,"getActiveObject",(function(){return W})),n.d(t,"getTextContent",(function(){return M})),n.d(t,"__unstableIsListRootSelected",(function(){return $})),n.d(t,"__unstableIsActiveListType",(function(){return H})),n.d(t,"isCollapsed",(function(){return V})),n.d(t,"isEmpty",(function(){return K})),n.d(t,"__unstableIsEmptyLine",(function(){return B})),n.d(t,"join",(function(){return z})),n.d(t,"registerFormatType",(function(){return U})),n.d(t,"removeFormat",(function(){return G})),n.d(t,"remove",(function(){return Y})),n.d(t,"replace",(function(){return Z})),n.d(t,"insert",(function(){return X})),n.d(t,"__unstableInsertLineSeparator",(function(){return J})),n.d(t,"__unstableRemoveLineSeparator",(function(){return Q})),n.d(t,"insertObject",(function(){return ee})),n.d(t,"slice",(function(){return te})),n.d(t,"split",(function(){return ne})),n.d(t,"__unstableToDom",(function(){return he})),n.d(t,"toHTMLString",(function(){return ye})),n.d(t,"toggleFormat",(function(){return Ae})),n.d(t,"__UNSTABLE_LINE_SEPARATOR",(function(){return T})),n.d(t,"unregisterFormatType",(function(){return Ne})),n.d(t,"__unstableCanIndentListItems",(function(){return Se})),n.d(t,"__unstableCanOutdentListItems",(function(){return De})),n.d(t,"__unstableIndentListItems",(function(){return Re})),n.d(t,"__unstableOutdentListItems",(function(){return Ie})),n.d(t,"__unstableChangeListType",(function(){return Pe})),n.d(t,"__unstableCreateElement",(function(){return x})),n.d(t,"useAnchorRef",(function(){return Me})),n.d(t,"__experimentalRichText",(function(){return Qe})),n.d(t,"__unstableFormatEdit",(function(){return Ve}));var r={};n.r(r),n.d(r,"getFormatTypes",(function(){return l})),n.d(r,"getFormatType",(function(){return u})),n.d(r,"getFormatTypeForBareElement",(function(){return f})),n.d(r,"getFormatTypeForClassName",(function(){return d}));var a={};n.r(a),n.d(a,"addFormatTypes",(function(){return m})),n.d(a,"removeFormatTypes",(function(){return p}));var o=n(5),i=n(2);var c=Object(o.combineReducers)({formatTypes:function(e={},t){switch(t.type){case"ADD_FORMAT_TYPES":return{...e,...Object(i.keyBy)(t.formatTypes,"name")};case"REMOVE_FORMAT_TYPES":return Object(i.omit)(e,t.names)}return e}}),s=n(26);const l=Object(s.a)(e=>Object.values(e.formatTypes),e=>[e.formatTypes]);function u(e,t){return e.formatTypes[t]}function f(e,t){return Object(i.find)(l(e),({className:e,tagName:n})=>null===e&&t===n)}function d(e,t){return Object(i.find)(l(e),({className:e})=>null!==e&&` ${t} `.indexOf(` ${e} `)>=0)}function m(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Object(i.castArray)(e)}}function p(e){return{type:"REMOVE_FORMAT_TYPES",names:Object(i.castArray)(e)}}const g=Object(o.createReduxStore)("core/rich-text",{reducer:c,selectors:r,actions:a});function h(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 a=Object.keys(n),o=Object.keys(r);if(a.length!==o.length)return!1;const i=a.length;for(let e=0;e<i;e++){const t=a[e];if(n[t]!==r[t])return!1}return!0}function b(e){const t=e.formats.slice();return t.forEach((e,n)=>{const r=t[n-1];if(r){const a=e.slice();a.forEach((e,t)=>{const n=r[t];h(e,n)&&(a[t]=n)}),t[n]=a}}),{...e,formats:t}}function v(e,t,n){return(e=e.slice())[t]=n,e}function y(e,t,n=e.start,r=e.end){const{formats:a,activeFormats:o}=e,c=a.slice();if(n===r){const e=Object(i.find)(c[n],{type:t.type});if(e){const a=c[n].indexOf(e);for(;c[n]&&c[n][a]===e;)c[n]=v(c[n],a,t),n--;for(r++;c[r]&&c[r][a]===e;)c[r]=v(c[r],a,t),r++}}else{let e=1/0;for(let a=n;a<r;a++)if(c[a]){c[a]=c[a].filter(({type:e})=>e!==t.type);const n=c[a].length;n<e&&(e=n)}else c[a]=[],e=0;for(let a=n;a<r;a++)c[a].splice(e,0,t)}return b({...e,formats:c,activeFormats:[...Object(i.reject)(o,{type:t.type}),t]})}function x({implementation:e},t){return x.body||(x.body=e.createHTMLDocument("").body),x.body.innerHTML=t,x.body}Object(o.register)(g);const T="\u2028";function E(e,t){for(const n in e)if(e[n]===t)return n}function O({type:e,attributes:t}){let n;if(t&&t.class&&(n=Object(o.select)("core/rich-text").getFormatTypeForClassName(t.class),n&&(t.class=` ${t.class} `.replace(` ${n.className} `," ").trim(),t.class||delete t.class)),n||(n=Object(o.select)("core/rich-text").getFormatTypeForBareElement(e)),!n)return t?{type:e,attributes:t}:{type:e};if(n.__experimentalCreatePrepareEditableTree&&!n.__experimentalCreateOnChangeEditableValue)return null;if(!t)return{type:n.name};const r={},a={};for(const e in t){const o=E(n.attributes,e);o?r[o]=t[e]:a[e]=t[e]}return{type:n.name,attributes:r,unregisteredAttributes:a}}function _({element:e,text:t,html:n,range:r,multilineTag:a,multilineWrapperTags:o,__unstableIsEditableTree:i,preserveWhiteSpace:c}={}){return"string"==typeof t&&t.length>0?{formats:Array(t.length),replacements:Array(t.length),text:t}:("string"==typeof n&&n.length>0&&(e=x(document,n)),"object"!=typeof e?{formats:[],replacements:[],text:""}:a?S({element:e,range:r,multilineTag:a,multilineWrapperTags:o,isEditableTree:i,preserveWhiteSpace:c}):N({element:e,range:r,isEditableTree:i,preserveWhiteSpace:c}))}function w(e,t,n,r){if(!n)return;const{parentNode:a}=t,{startContainer:o,startOffset:i,endContainer:c,endOffset:s}=n,l=e.text.length;void 0!==r.start?e.start=l+r.start:t===o&&t.nodeType===t.TEXT_NODE?e.start=l+i:a===o&&t===o.childNodes[i]?e.start=l:a===o&&t===o.childNodes[i-1]?e.start=l+r.text.length:t===o&&(e.start=l),void 0!==r.end?e.end=l+r.end:t===c&&t.nodeType===t.TEXT_NODE?e.end=l+s:a===c&&t===c.childNodes[s-1]?e.end=l+r.text.length:a===c&&t===c.childNodes[s]?e.end=l:t===c&&(e.end=l+s)}function F(e,t,n){if(!t)return;const{startContainer:r,endContainer:a}=t;let{startOffset:o,endOffset:i}=t;return e===r&&(o=n(e.nodeValue.slice(0,o)).length),e===a&&(i=n(e.nodeValue.slice(0,i)).length),{startContainer:r,startOffset:o,endContainer:a,endOffset:i}}function C(e){return e.replace(/[\n\r\t]+/g," ")}const j=new RegExp("\ufeff","g");function A(e){return e.replace(j,"")}function N({element:e,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a=[],isEditableTree:o,preserveWhiteSpace:i}){const c={formats:[],replacements:[],text:""};if(!e)return c;if(!e.hasChildNodes())return w(c,e,t,{formats:[],replacements:[],text:""}),c;const s=e.childNodes.length;for(let u=0;u<s;u++){const s=e.childNodes[u],f=s.nodeName.toLowerCase();if(s.nodeType===s.TEXT_NODE){let e=A;i||(e=e=>A(C(e)));const n=e(s.nodeValue);w(c,s,t=F(s,t,e),{text:n}),c.formats.length+=n.length,c.replacements.length+=n.length,c.text+=n;continue}if(s.nodeType!==s.ELEMENT_NODE)continue;if(o&&(s.getAttribute("data-rich-text-placeholder")||"br"===f&&!s.getAttribute("data-rich-text-line-break"))){w(c,s,t,{formats:[],replacements:[],text:""});continue}if("br"===f){w(c,s,t,{formats:[],replacements:[],text:""}),R(c,_({text:"\n"}));continue}const d=c.formats[c.formats.length-1],m=d&&d[d.length-1],p=O({type:f,attributes:D({element:s})}),g=h(p,m)?m:p;if(r&&-1!==r.indexOf(f)){const e=S({element:s,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:[...a,g],isEditableTree:o,preserveWhiteSpace:i});w(c,s,t,e),R(c,e);continue}const b=N({element:s,range:t,multilineTag:n,multilineWrapperTags:r,isEditableTree:o,preserveWhiteSpace:i});if(w(c,s,t,b),g)if(0===b.text.length)g.attributes&&R(c,{formats:[,],replacements:[g],text:""});else{function l(e){if(l.formats===e)return l.newFormats;const t=e?[g,...e]:[g];return l.formats=e,l.newFormats=t,t}l.newFormats=[g],R(c,{...b,formats:Array.from(b.formats,l)})}else R(c,b)}return c}function S({element:e,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a=[],isEditableTree:o,preserveWhiteSpace:i}){const c={formats:[],replacements:[],text:""};if(!e||!e.hasChildNodes())return c;const s=e.children.length;for(let l=0;l<s;l++){const s=e.children[l];if(s.nodeName.toLowerCase()!==n)continue;const u=N({element:s,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a,isEditableTree:o,preserveWhiteSpace:i});(0!==l||a.length>0)&&R(c,{formats:[,],replacements:a.length>0?[a]:[,],text:T}),w(c,s,t,u),R(c,u)}return c}function D({element:e}){if(!e.hasAttributes())return;const t=e.attributes.length;let n;for(let r=0;r<t;r++){const{name:t,value:a}=e.attributes[r];0!==t.indexOf("data-rich-text-")&&(n=n||{},n[t]=a)}return n}function R(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function L(...e){return b(e.reduce(R,_()))}function I({formats:e,start:t,end:n,activeFormats:r},a=[]){if(void 0===t)return a;if(t===n){if(r)return r;const n=e[t-1]||a,o=e[t]||a;return n.length<o.length?n:o}return e[t]||a}function P(e,t){return Object(i.find)(I(e),{type:t})}function W({start:e,end:t,replacements:n,text:r}){if(e+1===t&&""===r[e])return n[e]}function M({text:e}){return e.replace(new RegExp("","g"),"").replace(new RegExp(T,"g"),"\n")}function k({start:e,text:t},n=e){let r=n;for(;r--;)if(t[r]===T)return r}function $(e){const{replacements:t,start:n}=e,r=t[k(e,n)];return!r||r.length<1}function H(e,t,n){const{replacements:r,start:a}=e,o=r[k(e,a)];if(!o||0===o.length)return t===n;return o[o.length-1].type===t}function V({start:e,end:t}){if(void 0!==e&&void 0!==t)return e===t}function K({text:e}){return 0===e.length}function B({text:e,start:t,end:n}){return t===n&&(0===e.length||(0===t&&e.slice(0,1)===T||(t===e.length&&e.slice(-1)===T||e.slice(t-1,n+1)===`${T}${T}`)))}function z(e,t=""){return"string"==typeof t&&(t=_({text:t})),b(e.reduce((e,{formats:n,replacements:r,text:a})=>({formats:e.formats.concat(t.formats,n),replacements:e.replacements.concat(t.replacements,r),text:e.text+t.text+a})))}function U(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(Object(o.select)(g).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=Object(o.select)(g).getFormatTypeForBareElement(t.tagName);if(e)return void window.console.error(`Format "${e.name}" is already registered to handle bare tag name "${t.tagName}".`)}else{const e=Object(o.select)(g).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 Object(o.dispatch)(g).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 G(e,t,n=e.start,r=e.end){const{formats:a,activeFormats:o}=e,c=a.slice();if(n===r){const e=Object(i.find)(c[n],{type:t});if(e){for(;Object(i.find)(c[n],e);)q(c,n,t),n--;for(r++;Object(i.find)(c[r],e);)q(c,r,t),r++}}else for(let e=n;e<r;e++)c[e]&&q(c,e,t);return b({...e,formats:c,activeFormats:Object(i.reject)(o,{type:t})})}function q(e,t,n){const r=e[t].filter(({type:e})=>e!==n);r.length?e[t]=r:delete e[t]}function X(e,t,n=e.start,r=e.end){const{formats:a,replacements:o,text:i}=e;"string"==typeof t&&(t=_({text:t}));const c=n+t.text.length;return b({formats:a.slice(0,n).concat(t.formats,a.slice(r)),replacements:o.slice(0,n).concat(t.replacements,o.slice(r)),text:i.slice(0,n)+t.text+i.slice(r),start:c,end:c})}function Y(e,t,n){return X(e,_(),t,n)}function Z({formats:e,replacements:t,text:n,start:r,end:a},o,i){return n=n.replace(o,(n,...o)=>{const c=o[o.length-2];let s,l,u=i;return"function"==typeof u&&(u=i(n,...o)),"object"==typeof u?(s=u.formats,l=u.replacements,u=u.text):(s=Array(u.length),l=Array(u.length),e[c]&&(s=s.fill(e[c]))),e=e.slice(0,c).concat(s,e.slice(c+n.length)),t=t.slice(0,c).concat(l,t.slice(c+n.length)),r&&(r=a=c+u.length),u}),b({formats:e,replacements:t,text:n,start:r,end:a})}function J(e,t=e.start,n=e.end){const r=e.text.slice(0,t).lastIndexOf(T),a=e.replacements[r];let o=[,];a&&(o=[a]);return X(e,{formats:[,],replacements:o,text:T},t,n)}function Q(e,t=!0){const{replacements:n,text:r,start:a,end:o}=e,i=V(e);let c,s=a-1,l=i?a-1:a,u=o;if(t||(s=o,l=a,u=i?o+1:o),r[s]===T){if(i&&n[s]&&n[s].length){const t=n.slice();t[s]=n[s].slice(0,-1),c={...e,replacements:t}}else c=Y(e,l,u);return c}}function ee(e,t,n,r){return X(e,{formats:[,],replacements:[t],text:""},n,r)}function te(e,t=e.start,n=e.end){const{formats:r,replacements:a,text:o}=e;return void 0===t||void 0===n?{...e}:{formats:r.slice(t,n),replacements:a.slice(t,n),text:o.slice(t,n)}}function ne({formats:e,replacements:t,text:n,start:r,end:a},o){if("string"!=typeof o)return re(...arguments);let i=0;return n.split(o).map(n=>{const c=i,s={formats:e.slice(c,c+n.length),replacements:t.slice(c,c+n.length),text:n};return i+=o.length+n.length,void 0!==r&&void 0!==a&&(r>=c&&r<i?s.start=r-c:r<c&&a>c&&(s.start=0),a>=c&&a<i?s.end=a-c:r<i&&a>i&&(s.end=n.length)),s})}function re({formats:e,replacements:t,text:n,start:r,end:a},o=r,i=a){const c={formats:e.slice(0,o),replacements:t.slice(0,o),text:n.slice(0,o)},s={formats:e.slice(i),replacements:t.slice(i),text:n.slice(i),start:0,end:0};return[Z(c,/\u2028+$/,""),Z(s,/^\u2028+/,"")]}function ae({type:e,attributes:t,unregisteredAttributes:n,object:r,boundaryClass:a}){const i=(c=e,Object(o.select)(g).getFormatType(c));var c;let s={};if(a&&(s["data-rich-text-format-boundary"]="true"),!i)return t&&(s={...t,...s}),{type:e,attributes:s,object:r};s={...n,...s};for(const e in t){const n=!!i.attributes&&i.attributes[e];n?s[n]=t[e]:s[e]=t[e]}return i.className&&(s.class?s.class=`${i.className} ${s.class}`:s.class=i.className),{type:i.tagName,object:i.object,attributes:s}}function oe(e,t,n){do{if(e[n]!==t[n])return!1}while(n--);return!0}function ie({value:e,multilineTag:t,preserveWhiteSpace:n,createEmpty:r,append:a,getLastChild:o,getParent:i,isText:c,getText:s,remove:l,appendText:u,onStartIndex:f,onEndIndex:d,isEditableTree:m,placeholder:p}){const{formats:g,replacements:h,text:b,start:v,end:y}=e,x=g.length+1,E=r(),O={type:t},_=I(e),w=_[_.length-1];let F,C,j;t?(a(a(E,{type:t}),""),C=F=[O]):a(E,"");for(let e=0;e<x;e++){const r=b.charAt(e),x=m&&(!j||j===T||"\n"===j);let _=g[e];t&&(_=r===T?F=(h[e]||[]).reduce((e,t)=>(e.push(t,O),e),[O]):[...F,..._||[]]);let A=o(E);if(x&&r===T){let e=A;for(;!c(e);)e=o(e);a(i(e),"\ufeff")}if(j===T){let t=A;for(;!c(t);)t=o(t);f&&v===e&&f(E,t),d&&y===e&&d(E,t)}_&&_.forEach((e,t)=>{if(A&&C&&oe(_,C,t)&&(r!==T||_.length-1!==t))return void(A=o(A));const{type:n,attributes:u,unregisteredAttributes:f}=e,d=m&&r!==T&&e===w,p=i(A),g=a(p,ae({type:n,attributes:u,unregisteredAttributes:f,boundaryClass:d}));c(A)&&0===s(A).length&&l(A),A=a(g,"")}),r!==T?(0===e&&(f&&0===v&&f(E,A),d&&0===y&&d(E,A)),""===r?(A=a(i(A),ae({...h[e],object:!0})),A=a(i(A),"")):n||"\n"!==r?c(A)?u(A,r):A=a(i(A),r):(A=a(i(A),{type:"br",attributes:m?{"data-rich-text-line-break":"true"}:void 0,object:!0}),A=a(i(A),"")),f&&v===e+1&&f(E,A),d&&y===e+1&&d(E,A),x&&e===b.length&&(a(i(A),"\ufeff"),p&&0===b.length&&a(i(A),{type:"span",attributes:{"data-rich-text-placeholder":p,contenteditable:"false",style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),C=_,j=r):(C=_,j=r)}return E}function ce(e,t,n){const r=e.parentNode;let a=0;for(;e=e.previousSibling;)a++;return n=[a,...n],r!==t&&(n=ce(r,t,n)),n}function se(e,t){for(t=[...t];e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}function le(e,t){"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 ue(e,t){e.appendData(t)}function fe({lastChild:e}){return e}function de({parentNode:e}){return e}function me(e){return e.nodeType===e.TEXT_NODE}function pe({nodeValue:e}){return e}function ge(e){return e.parentNode.removeChild(e)}function he({value:e,multilineTag:t,prepareEditableTree:n,isEditableTree:r=!0,placeholder:a,doc:o=document}){let i=[],c=[];n&&(e={...e,formats:n(e)});return{body:ie({value:e,multilineTag:t,createEmpty:()=>x(o,""),append:le,getLastChild:fe,getParent:de,isText:me,getText:pe,remove:ge,appendText:ue,onStartIndex(e,t){i=ce(t,e,[t.nodeValue.length])},onEndIndex(e,t){c=ce(t,e,[t.nodeValue.length])},isEditableTree:r,placeholder:a}),selection:{startPath:i,endPath:c}}}function be({value:e,current:t,multilineTag:n,prepareEditableTree:r,__unstableDomOnly:a,placeholder:o}){const{body:i,selection:c}=he({value:e,multilineTag:n,prepareEditableTree:r,placeholder:o,doc:t.ownerDocument});!function e(t,n){let r,a=0;for(;r=t.firstChild;){const o=n.childNodes[a];if(o)if(o.isEqualNode(r))t.removeChild(r);else if(o.nodeName!==r.nodeName||o.nodeType===o.TEXT_NODE&&o.data!==r.data)n.replaceChild(r,o);else{const n=o.attributes,a=r.attributes;if(n){let e=n.length;for(;e--;){const{name:t}=n[e];r.getAttribute(t)||o.removeAttribute(t)}}if(a)for(let e=0;e<a.length;e++){const{name:t,value:n}=a[e];o.getAttribute(t)!==n&&o.setAttribute(t,n)}e(r,o),t.removeChild(r)}else n.appendChild(r);a++}for(;n.childNodes[a];)n.removeChild(n.childNodes[a])}(i,t),void 0===e.start||a||function({startPath:e,endPath:t},n){const{node:r,offset:a}=se(n,e),{node:o,offset:i}=se(n,t),{ownerDocument:c}=n,{defaultView:s}=c,l=s.getSelection(),u=c.createRange();u.setStart(r,a),u.setEnd(o,i);const{activeElement:f}=c;if(l.rangeCount>0){if(d=u,m=l.getRangeAt(0),d.startContainer===m.startContainer&&d.startOffset===m.startOffset&&d.endContainer===m.endContainer&&d.endOffset===m.endOffset)return;l.removeAllRanges()}var d,m;l.addRange(u),f!==c.activeElement&&f instanceof s.HTMLElement&&f.focus()}(c,t)}var ve=n(95);function ye({value:e,multilineTag:t,preserveWhiteSpace:n}){return je(ie({value:e,multilineTag:t,preserveWhiteSpace:n,createEmpty:xe,append:Ee,getLastChild:Te,getParent:_e,isText:we,getText:Fe,remove:Ce,appendText:Oe}).children)}function xe(){return{}}function Te({children:e}){return e&&e[e.length-1]}function Ee(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Oe(e,t){e.text+=t}function _e({parent:e}){return e}function we({text:e}){return"string"==typeof e}function Fe({text:e}){return e}function Ce(e){const t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function je(e=[]){return e.map(e=>void 0===e.text?function({type:e,attributes:t,object:n,children:r}){let a="";for(const e in t)Object(ve.isValidAttributeName)(e)&&(a+=` ${e}="${Object(ve.escapeAttribute)(t[e])}"`);return n?`<${e}${a}>`:`<${e}${a}>${je(r)}</${e}>`}(e):Object(ve.escapeEditableHTML)(e.text)).join("")}function Ae(e,t){return P(e,t.type)?G(e,t.type):y(e,t)}function Ne(e){const t=Object(o.select)(g).getFormatType(e);if(t)return Object(o.dispatch)(g).removeFormatTypes(e),t;window.console.error(`Format ${e} is not registered.`)}function Se(e){const t=k(e);if(void 0===t)return!1;const{replacements:n}=e,r=k(e,t),a=n[t]||[],o=n[r]||[];return a.length<=o.length}function De(e){const{replacements:t,start:n}=e;return void 0!==t[k(e,n)]}function Re(e,t){if(!Se(e))return e;const n=k(e),r=k(e,n),{text:a,replacements:o,end:i}=e,c=o.slice(),s=function({text:e,replacements:t},n){const r=t[n]||[];let a=n;for(;a-- >=0;){if(e[a]!==T)continue;const n=t[a]||[];if(n.length===r.length+1)return a;if(n.length<=r.length)return}}(e,n);for(let e=n;e<i;e++)if(a[e]===T)if(s){const t=o[s]||[];c[e]=t.concat((c[e]||[]).slice(t.length-1))}else{const n=o[r]||[],a=n[n.length-1]||t;c[e]=n.concat([a],(c[e]||[]).slice(n.length))}return{...e,replacements:c}}function Le({text:e,replacements:t},n){const r=t[n]||[];let a=n;for(;a-- >=0;){if(e[a]!==T)continue;if((t[a]||[]).length===r.length-1)return a}}function Ie(e){if(!De(e))return e;const{text:t,replacements:n,start:r,end:a}=e,o=k(e,r),i=n.slice(0),c=n[Le(e,o)]||[],s=function({text:e,replacements:t},n){const r=t[n]||[];let a=n;for(let o=n||0;o<e.length;o++){if(e[o]!==T)continue;if(!((t[o]||[]).length>=r.length))return a;a=o}return a}(e,k(e,a));for(let e=o;e<=s;e++){if(t[e]!==T)continue;const n=i[e]||[];i[e]=c.concat(n.slice(c.length+1)),0===i[e].length&&delete i[e]}return{...e,replacements:i}}function Pe(e,t){const{text:n,replacements:r,start:a,end:o}=e,i=k(e,a),c=r[i]||[],s=r[k(e,o)]||[],l=Le(e,i),u=r.slice(),f=c.length-1,d=s.length-1;let m;for(let e=l+1||0;e<n.length;e++)if(n[e]===T){if((u[e]||[]).length<=f)break;u[e]&&(m=!0,u[e]=u[e].map((e,n)=>n<f||n>d?e:t))}return m?{...e,replacements:u}:e}var We=n(0);function Me({ref:e,value:t,settings:n={}}){const{tagName:r,className:a,name:o}=n,i=o?P(t,o):void 0;return Object(We.useMemo)(()=>{if(!e.current)return;const{ownerDocument:{defaultView:t}}=e.current,n=t.getSelection();if(!n.rangeCount)return;const o=n.getRangeAt(0);if(!i)return o;let c=o.startContainer;for(c=c.nextElementSibling||c;c.nodeType!==c.ELEMENT_NODE;)c=c.parentNode;return c.closest(r+(a?"."+a:""))},[i,t.start,t.end,r,a])}var ke=n(12),$e=n(19),He=n(10);function Ve({formatTypes:e,onChange:t,onFocus:n,value:r,forwardedRef:a}){return e.map(e=>{const{name:o,edit:i}=e;if(!i)return null;const c=P(r,o),s=void 0!==c,l=W(r),u=void 0!==l&&l.type===o;return Object(We.createElement)(i,{key:o,isActive:s,activeAttributes:s&&c.attributes||{},isObjectActive:u,activeObjectAttributes:u&&l.attributes||{},value:r,onChange:t,onFocus:n,contentRef:a})})}function Ke(e){return e(g).getFormatTypes()}const Be=new Set(["a","audio","button","details","embed","iframe","input","label","select","textarea","video"]);function ze(e){const t=Object(We.useRef)(e);return t.current=e,Object(He.useRefEffect)(e=>{function n(n){const{record:r,multilineTag:a,preserveWhiteSpace:o}=t.current;if(V(r.current)||!e.contains(e.ownerDocument.activeElement))return;const i=te(r.current),c=M(i),s=ye({value:i,multilineTag:a,preserveWhiteSpace:o});n.clipboardData.setData("text/plain",c),n.clipboardData.setData("text/html",s),n.clipboardData.setData("rich-text","true"),n.preventDefault()}return e.addEventListener("copy",n),()=>{e.removeEventListener("copy",n)}},[])}const Ue=[];function Ge(e){const t=Object(We.useRef)(e);return t.current=e,Object(He.useRefEffect)(e=>{function n(n){const{keyCode:r,shiftKey:a,altKey:o,metaKey:i,ctrlKey:c}=n;if(a||o||i||c||r!==ke.LEFT&&r!==ke.RIGHT)return;const{record:s,applyRecord:l,setActiveFormats:u}=t.current,{text:f,formats:d,start:m,end:p,activeFormats:g=[]}=s.current,h=V(s.current),{ownerDocument:b}=e,{defaultView:v}=b,{direction:y}=v.getComputedStyle(e),x="rtl"===y?ke.RIGHT:ke.LEFT,T=n.keyCode===x;if(h&&0===g.length){if(0===m&&T)return;if(p===f.length&&!T)return}if(!h)return;const E=d[m-1]||Ue,O=d[m]||Ue;let _=g.length,w=O;if(E.length>O.length&&(w=E),E.length<O.length?(!T&&g.length<O.length&&_++,T&&g.length>E.length&&_--):E.length>O.length&&(!T&&g.length>O.length&&_--,T&&g.length<E.length&&_++),_===g.length)return void(s.current._newActiveFormats=T?E:O);n.preventDefault();const F=w.slice(0,_),C={...s.current,activeFormats:F};s.current=C,l(C),u(F)}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}function qe(e){const t=Object(We.useRef)(e);return t.current=e,Object(He.useRefEffect)(e=>{function n(e){const{keyCode:n}=e,{didAutomaticChange:r,undo:a}=t.current;r&&a&&(n!==ke.DELETE&&n!==ke.BACKSPACE&&n!==ke.ESCAPE||(e.preventDefault(),a()))}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}const Xe=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),Ye={whiteSpace:"pre-wrap",minWidth:"1px"},Ze=[];function Je(e){return t=>e.reduce((e,n)=>n(e,t.text),t.formats)}var Qe=Object(We.forwardRef)((function({tagName:e="div",value:t="",selectionStart:n,selectionEnd:r,children:a,allowedFormats:i,withoutInteractiveFormatting:c,placeholder:s,disabled:l,preserveWhiteSpace:u,onPaste:f,format:d="string",onDelete:m,onEnter:p,onSelectionChange:g,onChange:b,unstableOnFocus:v,clientId:y,identifier:x,__unstableMultilineTag:E,__unstableMultilineRootTag:O,__unstableDisableFormats:w,__unstableDidAutomaticChange:F,__unstableInputRule:C,__unstableMarkAutomaticChange:j,__unstableAllowPrefixTransformations:A,__unstableUndo:N,__unstableIsCaretWithinFormattedText:S,__unstableOnEnterFormattedText:D,__unstableOnExitFormattedText:R,__unstableOnCreateUndoLevel:L,__unstableIsSelected:P},W){const M=Object(We.useRef)(),[k=[],$]=Object(We.useState)(),{formatTypes:H,prepareHandlers:K,valueHandlers:z,changeHandlers:U,dependencies:q}=function({clientId:e,identifier:t,withoutInteractiveFormatting:n,allowedFormats:r}){const a=Object(o.useSelect)(Ke,[]),i=Object(We.useMemo)(()=>a.filter(({name:e,tagName:t})=>!(r&&!r.includes(e))&&(!n||!Be.has(t))),[a,r,Be]),c=Object(o.useSelect)(n=>i.reduce((r,a)=>(a.__experimentalGetPropsForEditableTreePreparation&&(r[a.name]=a.__experimentalGetPropsForEditableTreePreparation(n,{richTextIdentifier:t,blockClientId:e})),r),{}),[i,e,t]),s=Object(o.useDispatch)(),l=[],u=[],f=[],d=[];return i.forEach(n=>{if(n.__experimentalCreatePrepareEditableTree){const r=c[n.name],a=n.__experimentalCreatePrepareEditableTree(r,{richTextIdentifier:t,blockClientId:e});n.__experimentalCreateOnChangeEditableValue?u.push(a):l.push(a);for(const e in r)d.push(r[e])}if(n.__experimentalCreateOnChangeEditableValue){let r={};n.__experimentalGetPropsForEditableTreeChangeHandler&&(r=n.__experimentalGetPropsForEditableTreeChangeHandler(s,{richTextIdentifier:t,blockClientId:e})),f.push(n.__experimentalCreateOnChangeEditableValue({...c[n.name]||{},...r},{richTextIdentifier:t,blockClientId:e}))}}),{formatTypes:i,prepareHandlers:l,valueHandlers:u,changeHandlers:f,dependencies:d}}({clientId:y,identifier:x,withoutInteractiveFormatting:c,allowedFormats:i});function Z(){return M.current.ownerDocument}function J(){return Z().defaultView}function ee(e){if(w)return{text:e,formats:Array(e.length),replacements:Array(e.length)};if("string"!==d)return e;const t=Je(z),n=_({html:e,multilineTag:E,multilineWrapperTags:"li"===E?["ul","ol"]:void 0,preserveWhiteSpace:u});return n.formats=t(n),n}function te(e){return H.forEach(t=>{t.__experimentalCreatePrepareEditableTree&&(e=G(e,t.name,0,e.text.length))}),e}function ne(e){return w?e.text:(e=te(e),"string"===d?ye({value:e,multilineTag:E,preserveWhiteSpace:u}):void 0)}O||"string"!=typeof e||(O=e);const re=Object(We.useRef)(t),ae=Object(We.useRef)(Object(We.useMemo)(()=>{const e=ee(t);return e.start=n,e.end=r,e},[]));function oe(){const e=J().getSelection(),t=e.rangeCount>0?e.getRangeAt(0):null;return _({element:M.current,range:t,multilineTag:E,multilineWrapperTags:"li"===E?["ul","ol"]:void 0,__unstableIsEditableTree:!0,preserveWhiteSpace:u})}function ie(e,{domOnly:t}={}){be({value:e,current:M.current,multilineTag:E,multilineWrapperTags:"li"===E?["ul","ol"]:void 0,prepareEditableTree:Je(K),__unstableDomOnly:t,placeholder:s})}const ce=Object(We.useRef)(t);function se(){ce.current!==re.current&&(L(),ce.current=re.current)}const le=Object(We.useRef)(!1),ue=Object(We.useRef)();function fe(e){if(le.current)return;let t;if(e&&(t=e.inputType),!t&&e&&e.nativeEvent&&(t=e.nativeEvent.inputType),t&&(0===t.indexOf("format")||Xe.has(t)))return void ie(ae.current);const n=oe(),{start:r,activeFormats:a=[]}=ae.current,o=function({value:e,start:t,end:n,formats:r}){const a=e.formats[t-1]||[],o=e.formats[n]||[];for(e.activeFormats=r.map((e,t)=>{if(a[t]){if(h(e,a[t]))return a[t]}else if(o[t]&&h(e,o[t]))return o[t];return e});--n>=t;)e.activeFormats.length>0?e.formats[n]=e.activeFormats:delete e.formats[n];return e}({value:n,start:r,end:n.start,formats:a});if(pe(o,{withoutHistory:!0}),J().clearTimeout(ue.current),ue.current=J().setTimeout(se,1e3),"insertText"!==t)return;A&&C&&C(o,ne);const i=H.reduce((e,{__unstableInputRule:t})=>(t&&(e=t(e)),e),o);i!==o&&(se(),pe({...i,activeFormats:a}),j())}const de=Object(We.useRef)(!1);function me(e){if(!M.current)return;if(M.current.ownerDocument.activeElement!==M.current)return;if("selectionchange"!==e.type&&!P)return;if(l)return;if(le.current)return;const{start:t,end:n,text:r}=oe(),a=ae.current;if(r!==a.text)return void fe();if(t===a.start&&n===a.end)return void(0===a.text.length&&0===t&&function(e){const t=e.getSelection(),{anchorNode:n,anchorOffset:r}=t;if(n.nodeType!==n.ELEMENT_NODE)return;const a=n.childNodes[r];a&&a.nodeType===a.ELEMENT_NODE&&a.getAttribute("data-rich-text-placeholder")&&t.collapseToStart()}(J()));const o={...a,start:t,end:n,activeFormats:a._newActiveFormats,_newActiveFormats:void 0},i=I(o,Ze);o.activeFormats=i,!S&&i.length?D():S&&!i.length&&R(),ae.current=o,ie(o,{domOnly:!0}),g(t,n),$(i)}function pe(e,{withoutHistory:t}={}){w&&(e.formats=Array(e.text.length),e.replacements=Array(e.text.length)),ie(e);const{start:n,end:r,activeFormats:a=[]}=e;Object.values(U).forEach(t=>{t(e.formats,e.text)}),re.current=ne(e),ae.current=e,g(n,r),b(re.current),$(a),t||se()}function ge(e){const{target:t}=e;if(t===M.current||t.textContent)return;const{parentNode:n}=t,r=Array.from(n.childNodes).indexOf(t),a=Z().createRange(),o=J().getSelection();a.setStart(t.parentNode,r),a.setEnd(t.parentNode,r+1),o.removeAllRanges(),o.addRange(a)}const he=Object(We.useRef)();function ve(){re.current=t,ae.current=ee(t),ae.current.start=n,ae.current.end=r,ie(ae.current)}function xe(){M.current.focus(),ie(ae.current)}Object(We.useEffect)(()=>{de.current&&ve()},[e,s]),Object(We.useEffect)(()=>{de.current&&t!==re.current&&ve()},[t]),Object(We.useEffect)(()=>{de.current&&(!P||n===ae.current.start&&r===ae.current.end?ae.current={...ae.current,start:n,end:r}:ve())},[n,r,P]),Object(We.useEffect)(()=>{de.current&&ve()},q),Object(We.useLayoutEffect)(()=>(ie(ae.current,{domOnly:!0}),de.current=!0,()=>{Z().removeEventListener("selectionchange",me),J().cancelAnimationFrame(he.current),J().clearTimeout(ue.current)}),[]);const Te={role:"textbox","aria-multiline":!0,"aria-label":s,ref:Object(He.useMergeRefs)([W,M,ze({record:ae,multilineTag:E,preserveWhiteSpace:u}),Ge({record:ae,applyRecord:ie,setActiveFormats:$}),qe({didAutomaticChange:F,undo:N})]),style:Ye,className:"rich-text",onPaste:function(e){if(!P)return void e.preventDefault();const{clipboardData:t}=e;let n="",r="";try{n=t.getData("text/plain"),r=t.getData("text/html")}catch(e){try{r=t.getData("Text")}catch(e){return}}if(e.preventDefault(),window.console.log("Received HTML:\n\n",r),window.console.log("Received plain text:\n\n",n),w)return void pe(X(ae.current,n));const a=H.reduce((e,{__unstablePasteRule:t})=>(t&&e===ae.current&&(e=t(ae.current,{html:r,plainText:n})),e),ae.current);if(a===ae.current){if(f){const e=Object($e.getFilesFromDataTransfer)(t),a="true"===t.getData("rich-text");f({value:te(ae.current),onChange:pe,html:r,plainText:n,isInternal:a,files:[...e],activeFormats:k})}}else pe(a)},onInput:fe,onCompositionStart:function(){le.current=!0,Z().removeEventListener("selectionchange",me)},onCompositionEnd:function(){le.current=!1,fe({inputType:"insertText"}),Z().addEventListener("selectionchange",me)},onKeyDown:function(e){e.defaultPrevented||(function(e){const{keyCode:t}=e;if(e.defaultPrevented)return;if(t!==ke.DELETE&&t!==ke.BACKSPACE)return;const n=oe(),{start:r,end:a,text:o}=n,i=t===ke.BACKSPACE;if(0===r&&0!==a&&a===o.length)return pe(Y(n)),void e.preventDefault();if(E){let t;if(t=i&&0===n.start&&0===n.end&&B(n)?Q(n,!i):Q(n,i),t)return pe(t),void e.preventDefault()}!m||!V(n)||k.length||i&&0!==r||!i&&a!==o.length||(m({isReverse:i,value:n}),e.preventDefault())}(e),function(e){e.keyCode===ke.ENTER&&(e.preventDefault(),p&&p({value:te(oe()),onChange:pe,shiftKey:e.shiftKey}))}(e),function(e){const{keyCode:t,shiftKey:n,altKey:r,metaKey:a,ctrlKey:o}=e;if(n||r||a||o||t!==ke.SPACE||"li"!==E)return;const i=oe();if(!V(i))return;const{text:c,start:s}=i,l=c[s-1];l&&l!==T||(pe(Re(i,{type:O})),e.preventDefault())}(e))},onFocus:function(){if(v&&v(),P)g(ae.current.start,ae.current.end),$(I({...ae.current,activeFormats:void 0},Ze));else{const e=void 0;ae.current={...ae.current,start:e,end:e,activeFormats:Ze},g(e,e),$(Ze)}he.current=J().requestAnimationFrame(me),Z().addEventListener("selectionchange",me)},onBlur:function(){Z().removeEventListener("selectionchange",me)},onMouseDown:ge,onTouchStart:ge,onKeyUp:me,onMouseUp:me,onTouchEnd:me,contentEditable:!l||void 0,suppressContentEditableWarning:!l};return function({activeFormats:e,ref:t}){Object(We.useEffect)(()=>{if(!e||!e.length)return;const n=t.current.querySelector("*[data-rich-text-format-boundary]");if(!n)return;const{ownerDocument:r}=n,{defaultView:a}=r,o=`.rich-text:focus *[data-rich-text-format-boundary] {${"background-color: "+a.getComputedStyle(n).color.replace(")",", 0.2)").replace("rgb","rgba")}}`;let i=r.getElementById("rich-text-boundary-style");i||(i=r.createElement("style"),i.id="rich-text-boundary-style",r.head.appendChild(i)),i.innerHTML!==o&&(i.innerHTML=o)},[e])}({ref:M,activeFormats:k}),function({ref:e}){Object(We.useEffect)(()=>{0},[])}({ref:M}),Object(We.createElement)(We.Fragment,null,P&&Object(We.createElement)(Ve,{value:ae.current,onChange:pe,onFocus:xe,formatTypes:H,forwardedRef:M}),a&&a({isSelected:P,value:ae.current,onChange:pe,onFocus:xe,editableProps:Te,editableTagName:e}),!a&&Object(We.createElement)(e,Te))}))},95:function(e,t){e.exports=window.wp.escapeHtml}});