mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-06 19:01:44 +01:00
ebca9841e8
This brings the JS packages up to date and is the first step that will allow us to include the other block editor updates for WordPress 5.9: FSE infrastrucutre, site editor and global styles. Props noisysocks. See #54337. Built from https://develop.svn.wordpress.org/trunk@52042 git-svn-id: http://core.svn.wordpress.org/trunk@51634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
34 KiB
JavaScript
2 lines
34 KiB
JavaScript
/*! 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="yyEc")}({"1ZqX":function(e,t){e.exports=window.wp.data},GRId:function(e,t){e.exports=window.wp.element},K9lf:function(e,t){e.exports=window.wp.compose},RxS6:function(e,t){e.exports=window.wp.keycodes},Vx3V:function(e,t){e.exports=window.wp.escapeHtml},YLtl:function(e,t){e.exports=window.lodash},gdqT:function(e,t){e.exports=window.wp.a11y},l3Sj:function(e,t){e.exports=window.wp.i18n},pPDe: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 u(){n=a?new WeakMap:i()}function l(){var n,r,a,o,i,u=arguments.length;for(o=new Array(u),a=0;a<u;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,u=n,l=!0;for(t=0;t<e.length;t++){if(a=e[t],!(s=a)||"object"!=typeof s){l=!1;break}u.has(a)?u=u.get(a):(o=new WeakMap,u.set(a,o),u=o)}return u.has(r)||((c=i()).isUniqueByDependants=l,u.set(r,c)),u.get(r)}:function(){return n},l.getDependants=t,l.clear=u,u(),l}},yyEc: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 A})),n.d(t,"create",(function(){return O})),n.d(t,"getActiveFormat",(function(){return D})),n.d(t,"getActiveObject",(function(){return k})),n.d(t,"getTextContent",(function(){return W})),n.d(t,"__unstableIsListRootSelected",(function(){return P})),n.d(t,"__unstableIsActiveListType",(function(){return I})),n.d(t,"isCollapsed",(function(){return $})),n.d(t,"isEmpty",(function(){return V})),n.d(t,"__unstableIsEmptyLine",(function(){return K})),n.d(t,"join",(function(){return H})),n.d(t,"registerFormatType",(function(){return B})),n.d(t,"removeFormat",(function(){return q})),n.d(t,"remove",(function(){return X})),n.d(t,"replace",(function(){return Y})),n.d(t,"insert",(function(){return U})),n.d(t,"__unstableInsertLineSeparator",(function(){return G})),n.d(t,"__unstableRemoveLineSeparator",(function(){return Z})),n.d(t,"insertObject",(function(){return J})),n.d(t,"slice",(function(){return Q})),n.d(t,"split",(function(){return ee})),n.d(t,"__unstableToDom",(function(){return ge})),n.d(t,"toHTMLString",(function(){return ve})),n.d(t,"toggleFormat",(function(){return Le})),n.d(t,"__UNSTABLE_LINE_SEPARATOR",(function(){return T})),n.d(t,"unregisterFormatType",(function(){return Se})),n.d(t,"__unstableCanIndentListItems",(function(){return Ae})),n.d(t,"__unstableCanOutdentListItems",(function(){return Ne})),n.d(t,"__unstableIndentListItems",(function(){return De})),n.d(t,"__unstableOutdentListItems",(function(){return We})),n.d(t,"__unstableChangeListType",(function(){return Me})),n.d(t,"__unstableCreateElement",(function(){return x})),n.d(t,"useAnchorRef",(function(){return Ie})),n.d(t,"__experimentalRichText",(function(){return Je})),n.d(t,"__unstableUseRichText",(function(){return Ze})),n.d(t,"__unstableFormatEdit",(function(){return Qe}));var r={};n.r(r),n.d(r,"getFormatTypes",(function(){return u})),n.d(r,"getFormatType",(function(){return l})),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("1ZqX"),i=n("YLtl");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("pPDe");const u=Object(s.a)(e=>Object.values(e.formatTypes),e=>[e.formatTypes]);function l(e,t){return e.formatTypes[t]}function f(e,t){return Object(i.find)(u(e),({className:e,tagName:n})=>null===e&&t===n)}function d(e,t){return Object(i.find)(u(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({type:e,attributes:t}){let n;if(t&&t.class&&(n=Object(o.select)(g).getFormatTypeForClassName(t.class),n&&(t.class=` ${t.class} `.replace(` ${n.className} `," ").trim(),t.class||delete t.class)),n||(n=Object(o.select)(g).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={},i={...t};for(const e in n.attributes){const t=n.attributes[e];r[e]=i[t],n.__unstableFilterAttributeValue&&(r[e]=n.__unstableFilterAttributeValue(e,r[e])),delete i[t],void 0===r[e]&&delete r[e]}for(const e in i)a[e]=t[e];return{type:n.name,attributes:r,unregisteredAttributes:a}}function O({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?R({element:e,range:r,multilineTag:a,multilineWrapperTags:o,isEditableTree:i,preserveWhiteSpace:c}):F({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,u=e.text.length;void 0!==r.start?e.start=u+r.start:t===o&&t.nodeType===t.TEXT_NODE?e.start=u+i:a===o&&t===o.childNodes[i]?e.start=u:a===o&&t===o.childNodes[i-1]?e.start=u+r.text.length:t===o&&(e.start=u),void 0!==r.end?e.end=u+r.end:t===c&&t.nodeType===t.TEXT_NODE?e.end=u+s:a===c&&t===c.childNodes[s-1]?e.end=u+r.text.length:a===c&&t===c.childNodes[s]?e.end=u:t===c&&(e.end=u+s)}function _(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 j(e){return e.replace(/[\n\r\t]+/g," ")}function C(e){return e.replace(new RegExp("[\ufeff]","gu"),"")}function F({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 l=0;l<s;l++){const s=e.childNodes[l],f=s.nodeName.toLowerCase();if(s.nodeType===s.TEXT_NODE){let e=C;i||(e=e=>C(j(e)));const n=e(s.nodeValue);w(c,s,t=_(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("script"===f){const e={formats:[,],replacements:[{type:f,attributes:{"data-rich-text-script":s.getAttribute("data-rich-text-script")||encodeURIComponent(s.innerHTML)}}],text:""};w(c,s,t,e),S(c,e);continue}if("br"===f){w(c,s,t,{formats:[],replacements:[],text:""}),S(c,O({text:"\n"}));continue}const d=E({type:f,attributes:L({element:s})});if(r&&-1!==r.indexOf(f)){const e=R({element:s,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:[...a,d],isEditableTree:o,preserveWhiteSpace:i});w(c,s,t,e),S(c,e);continue}const m=F({element:s,range:t,multilineTag:n,multilineWrapperTags:r,isEditableTree:o,preserveWhiteSpace:i});if(w(c,s,t,m),d)if(0===m.text.length)d.attributes&&S(c,{formats:[,],replacements:[d],text:""});else{function u(e){if(u.formats===e)return u.newFormats;const t=e?[d,...e]:[d];return u.formats=e,u.newFormats=t,t}u.newFormats=[d],S(c,{...m,formats:Array.from(m.formats,u)})}else S(c,m)}return c}function R({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 u=0;u<s;u++){const s=e.children[u];if(s.nodeName.toLowerCase()!==n)continue;const l=F({element:s,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a,isEditableTree:o,preserveWhiteSpace:i});(0!==u||a.length>0)&&S(c,{formats:[,],replacements:a.length>0?[a]:[,],text:T}),w(c,s,t,l),S(c,l)}return c}function L({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];if(0===t.indexOf("data-rich-text-"))continue;n=n||{},n[/^on/i.test(t)?"data-disable-rich-text-"+t:t]=a}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 A(...e){return b(e.reduce(S,O()))}function N({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 D(e,t){return Object(i.find)(N(e),{type:t})}function k({start:e,end:t,replacements:n,text:r}){if(e+1===t&&""===r[e])return n[e]}function W({text:e}){return e.replace(new RegExp("","g"),"").replace(new RegExp(T,"g"),"\n")}function M({start:e,text:t},n=e){let r=n;for(;r--;)if(t[r]===T)return r}function P(e){const{replacements:t,start:n}=e,r=t[M(e,n)];return!r||r.length<1}function I(e,t,n){const{replacements:r,start:a}=e,o=r[M(e,a)];if(!o||0===o.length)return t===n;return o[o.length-1].type===t}function $({start:e,end:t}){if(void 0!==e&&void 0!==t)return e===t}function V({text:e}){return 0===e.length}function K({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 H(e,t=""){return"string"==typeof t&&(t=O({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 B(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 q(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);)z(c,n,t),n--;for(r++;Object(i.find)(c[r],e);)z(c,r,t),r++}}else for(let e=n;e<r;e++)c[e]&&z(c,e,t);return b({...e,formats:c,activeFormats:Object(i.reject)(o,{type:t})})}function z(e,t,n){const r=e[t].filter(({type:e})=>e!==n);r.length?e[t]=r:delete e[t]}function U(e,t,n=e.start,r=e.end){const{formats:a,replacements:o,text:i}=e;"string"==typeof t&&(t=O({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 X(e,t,n){return U(e,O(),t,n)}function Y({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,u,l=i;return"function"==typeof l&&(l=i(n,...o)),"object"==typeof l?(s=l.formats,u=l.replacements,l=l.text):(s=Array(l.length),u=Array(l.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(u,t.slice(c+n.length)),r&&(r=a=c+l.length),l}),b({formats:e,replacements:t,text:n,start:r,end:a})}function G(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 U(e,{formats:[,],replacements:o,text:T},t,n)}function Z(e,t=!0){const{replacements:n,text:r,start:a,end:o}=e,i=$(e);let c,s=a-1,u=i?a-1:a,l=o;if(t||(s=o,u=a,l=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=X(e,u,l);return c}}function J(e,t,n,r){return U(e,{formats:[,],replacements:[t],text:""},n,r)}function Q(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 ee({formats:e,replacements:t,text:n,start:r,end:a},o){if("string"!=typeof o)return te(...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 te({formats:e,replacements:t,text:n,start:r,end:a},o=r,i=a){if(void 0===r||void 0===a)return;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[Y(c,/\u2028+$/,""),Y(s,/^\u2028+/,"")]}function ne(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("data-disable-rich-text-".length)),n[r]=e[t]}return n}function re({type:e,attributes:t,unregisteredAttributes:n,object:r,boundaryClass:a,isEditableTree:i}){const c=(s=e,Object(o.select)(g).getFormatType(s));var s;let u={};if(a&&(u["data-rich-text-format-boundary"]="true"),!c)return t&&(u={...t,...u}),{type:e,attributes:ne(u,i),object:r};u={...n,...u};for(const e in t){const n=!!c.attributes&&c.attributes[e];n?u[n]=t[e]:u[e]=t[e]}return c.className&&(u.class?u.class=`${c.className} ${u.class}`:u.class=c.className),{type:c.tagName,object:c.object,attributes:ne(u,i)}}function ae(e,t,n){do{if(e[n]!==t[n])return!1}while(n--);return!0}function oe({value:e,multilineTag:t,preserveWhiteSpace:n,createEmpty:r,append:a,getLastChild:o,getParent:i,isText:c,getText:s,remove:u,appendText:l,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},w=N(e),_=w[w.length-1];let j,C,F;t?(a(a(E,{type:t}),""),C=j=[O]):a(E,"");for(let e=0;e<x;e++){const r=b.charAt(e),x=m&&(!F||F===T||"\n"===F);let w=g[e];t&&(w=r===T?j=(h[e]||[]).reduce((e,t)=>(e.push(t,O),e),[O]):[...j,...w||[]]);let L=o(E);if(x&&r===T){let e=L;for(;!c(e);)e=o(e);a(i(e),"\ufeff")}if(F===T){let t=L;for(;!c(t);)t=o(t);f&&v===e&&f(E,t),d&&y===e&&d(E,t)}if(w&&w.forEach((e,t)=>{if(L&&C&&ae(w,C,t)&&(r!==T||w.length-1!==t))return void(L=o(L));const{type:n,attributes:l,unregisteredAttributes:f}=e,d=m&&r!==T&&e===_,p=i(L),g=a(p,re({type:n,attributes:l,unregisteredAttributes:f,boundaryClass:d,isEditableTree:m}));c(L)&&0===s(L).length&&u(L),L=a(g,"")}),r!==T){var R;if(0===e&&(f&&0===v&&f(E,L),d&&0===y&&d(E,L)),""===r)m||"script"!==(null===(R=h[e])||void 0===R?void 0:R.type)?L=a(i(L),re({...h[e],object:!0,isEditableTree:m})):(L=a(i(L),re({type:"script",isEditableTree:m})),a(L,{html:decodeURIComponent(h[e].attributes["data-rich-text-script"])})),L=a(i(L),"");else n||"\n"!==r?c(L)?l(L,r):L=a(i(L),r):(L=a(i(L),{type:"br",attributes:m?{"data-rich-text-line-break":"true"}:void 0,object:!0}),L=a(i(L),""));f&&v===e+1&&f(E,L),d&&y===e+1&&d(E,L),x&&e===b.length&&(a(i(L),"\ufeff"),p&&0===b.length&&a(i(L),{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=w,F=r}else C=w,F=r}return E}function ie(e,t,n){const r=e.parentNode;let a=0;for(;e=e.previousSibling;)a++;return n=[a,...n],r!==t&&(n=ie(r,t,n)),n}function ce(e,t){for(t=[...t];e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}function se(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 le({lastChild:e}){return e}function fe({parentNode:e}){return e}function de(e){return e.nodeType===e.TEXT_NODE}function me({nodeValue:e}){return e}function pe(e){return e.parentNode.removeChild(e)}function ge({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:oe({value:e,multilineTag:t,createEmpty:()=>x(o,""),append:se,getLastChild:le,getParent:fe,isText:de,getText:me,remove:pe,appendText:ue,onStartIndex(e,t){i=ie(t,e,[t.nodeValue.length])},onEndIndex(e,t){c=ie(t,e,[t.nodeValue.length])},isEditableTree:r,placeholder:a}),selection:{startPath:i,endPath:c}}}function he({value:e,current:t,multilineTag:n,prepareEditableTree:r,__unstableDomOnly:a,placeholder:o}){const{body:i,selection:c}=ge({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}=ce(n,e),{node:o,offset:i}=ce(n,t),{ownerDocument:c}=n,{defaultView:s}=c,u=s.getSelection(),l=c.createRange();l.setStart(r,a),l.setEnd(o,i);const{activeElement:f}=c;if(u.rangeCount>0){if(d=l,m=u.getRangeAt(0),d.startContainer===m.startContainer&&d.startOffset===m.startOffset&&d.endContainer===m.endContainer&&d.endOffset===m.endOffset)return;u.removeAllRanges()}var d,m;u.addRange(l),f!==c.activeElement&&f instanceof s.HTMLElement&&f.focus()}(c,t)}var be=n("Vx3V");function ve({value:e,multilineTag:t,preserveWhiteSpace:n}){return Ce(oe({value:e,multilineTag:t,preserveWhiteSpace:n,createEmpty:ye,append:Te,getLastChild:xe,getParent:Oe,isText:we,getText:_e,remove:je,appendText:Ee}).children)}function ye(){return{}}function xe({children:e}){return e&&e[e.length-1]}function Te(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Ee(e,t){e.text+=t}function Oe({parent:e}){return e}function we({text:e}){return"string"==typeof e}function _e({text:e}){return e}function je(e){const t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function Ce(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 a="";for(const e in t)Object(be.isValidAttributeName)(e)&&(a+=` ${e}="${Object(be.escapeAttribute)(t[e])}"`);return n?`<${e}${a}>`:`<${e}${a}>${Ce(r)}</${e}>`}(e):Object(be.escapeEditableHTML)(e.text)).join("")}var Fe=n("gdqT"),Re=n("l3Sj");function Le(e,t){return D(e,t.type)?(t.title&&Object(Fe.speak)(Object(Re.sprintf)(Object(Re.__)("%s removed."),t.title),"assertive"),q(e,t.type)):(t.title&&Object(Fe.speak)(Object(Re.sprintf)(Object(Re.__)("%s applied."),t.title),"assertive"),y(e,t))}function Se(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 Ae(e){const t=M(e);if(void 0===t)return!1;const{replacements:n}=e,r=M(e,t),a=n[t]||[],o=n[r]||[];return a.length<=o.length}function Ne(e){const{replacements:t,start:n}=e;return void 0!==t[M(e,n)]}function De(e,t){if(!Ae(e))return e;const n=M(e),r=M(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 ke({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 We(e){if(!Ne(e))return e;const{text:t,replacements:n,start:r,end:a}=e,o=M(e,r),i=n.slice(0),c=n[ke(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,M(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 Me(e,t){const{text:n,replacements:r,start:a,end:o}=e,i=M(e,a),c=r[i]||[],s=r[M(e,o)]||[],u=ke(e,i),l=r.slice(),f=c.length-1,d=s.length-1;let m;for(let e=u+1||0;e<n.length;e++)if(n[e]===T){if((l[e]||[]).length<=f)break;l[e]&&(m=!0,l[e]=l[e].map((e,n)=>n<f||n>d?e:t))}return m?{...e,replacements:l}:e}var Pe=n("GRId");function Ie({ref:e,value:t,settings:n={}}){const{tagName:r,className:a,name:o}=n,i=o?D(t,o):void 0;return Object(Pe.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 $e=n("K9lf");function Ve({record:e}){const t=Object(Pe.useRef)(),{activeFormats:n=[]}=e.current;return Object(Pe.useEffect)(()=>{if(!n||!n.length)return;const e=t.current.querySelector("*[data-rich-text-format-boundary]");if(!e)return;const{ownerDocument:r}=e,{defaultView:a}=r,o=`.rich-text:focus *[data-rich-text-format-boundary] {${"background-color: "+a.getComputedStyle(e).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)},[n]),t}function Ke(e){const t=Object(Pe.useRef)(e);return t.current=e,Object($e.useRefEffect)(e=>{function n(n){const{record:r,multilineTag:a,preserveWhiteSpace:o}=t.current;if($(r.current)||!e.contains(e.ownerDocument.activeElement))return;const i=Q(r.current),c=W(i),s=ve({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.clipboardData.setData("rich-text-multi-line-tag",a||""),n.preventDefault()}return e.addEventListener("copy",n),()=>{e.removeEventListener("copy",n)}},[])}var He=n("RxS6");const Be=[];function qe(e){const[,t]=Object(Pe.useReducer)(()=>({})),n=Object(Pe.useRef)(e);return n.current=e,Object($e.useRefEffect)(e=>{function r(r){const{keyCode:a,shiftKey:o,altKey:i,metaKey:c,ctrlKey:s}=r;if(o||i||c||s||a!==He.LEFT&&a!==He.RIGHT)return;const{record:u,applyRecord:l}=n.current,{text:f,formats:d,start:m,end:p,activeFormats:g=[]}=u.current,h=$(u.current),{ownerDocument:b}=e,{defaultView:v}=b,{direction:y}=v.getComputedStyle(e),x="rtl"===y?He.RIGHT:He.LEFT,T=r.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]||Be,O=d[m]||Be,w=T?E:O,_=g.every((e,t)=>e===w[t]);let j=g.length;if(_?j<w.length&&j++:j--,j===g.length)return void(u.current._newActiveFormats=w);r.preventDefault();const C=(_?w:T?O:E).slice(0,j),F={...u.current,activeFormats:C};u.current=F,l(F),t()}return e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r)}},[])}function ze(e){const t=Object(Pe.useRef)(e);return t.current=e,Object($e.useRefEffect)(e=>{function n(n){const{keyCode:r,shiftKey:a,altKey:o,metaKey:i,ctrlKey:c}=n,{multilineTag:s,createRecord:u,handleChange:l}=t.current;if(a||o||i||c||r!==He.SPACE||"li"!==s)return;const f=u();if(!$(f))return;const{text:d,start:m}=f,p=d[m-1];p&&p!==T||(l(De(f,{type:e.tagName.toLowerCase()})),n.preventDefault())}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}const Ue=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),Xe=[];function Ye(e){const t=Object(Pe.useRef)(e);return t.current=e,Object($e.useRefEffect)(e=>{const{ownerDocument:n}=e,{defaultView:r}=n;let a,o=!1;function i(e){if(o)return;let n;e&&(n=e.inputType);const{record:r,applyRecord:a,createRecord:i,handleChange:c}=t.current;if(n&&(0===n.indexOf("format")||Ue.has(n)))return void a(r.current);const s=i(),{start:u,activeFormats:l=[]}=r.current;c(function({value:e,start:t,end:n,formats:r}){const a=Math.min(t,n),o=Math.max(t,n),i=e.formats[a-1]||[],c=e.formats[o]||[];for(e.activeFormats=r.map((e,t)=>{if(i[t]){if(h(e,i[t]))return i[t]}else if(c[t]&&h(e,c[t]))return c[t];return e});--n>=t;)e.activeFormats.length>0?e.formats[n]=e.activeFormats:delete e.formats[n];return e}({value:s,start:u,end:s.start,formats:l}))}function c(a){if(n.activeElement!==e)return;const{record:c,applyRecord:s,createRecord:u,isSelected:l,onSelectionChange:f}=t.current;if("selectionchange"!==a.type&&!l)return;if("true"!==e.contentEditable)return;if(o)return;const{start:d,end:m,text:p}=u(),g=c.current;if(p!==g.text)return void i();if(d===g.start&&m===g.end)return void(0===g.text.length&&0===d&&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()}(r));const h={...g,start:d,end:m,activeFormats:g._newActiveFormats,_newActiveFormats:void 0},b=N(h,Xe);h.activeFormats=b,c.current=h,s(h,{domOnly:!0}),f(d,m)}function s(){o=!0,n.removeEventListener("selectionchange",c)}function u(){o=!1,i({inputType:"insertText"}),n.addEventListener("selectionchange",c)}function l(){const{record:e,isSelected:o,onSelectionChange:i,applyRecord:s}=t.current;if(o)s(e.current),i(e.current.start,e.current.end);else{const t=void 0;e.current={...e.current,start:t,end:t,activeFormats:Xe},i(t,t)}a=r.requestAnimationFrame(c),n.addEventListener("selectionchange",c)}function f(){n.removeEventListener("selectionchange",c)}return e.addEventListener("input",i),e.addEventListener("compositionstart",s),e.addEventListener("compositionend",u),e.addEventListener("focus",l),e.addEventListener("blur",f),e.addEventListener("keyup",c),e.addEventListener("mouseup",c),e.addEventListener("touchend",c),()=>{e.removeEventListener("input",i),e.removeEventListener("compositionstart",s),e.removeEventListener("compositionend",u),e.removeEventListener("focus",l),e.removeEventListener("blur",f),e.removeEventListener("keyup",c),e.removeEventListener("mouseup",c),e.removeEventListener("touchend",c),n.removeEventListener("selectionchange",c),r.cancelAnimationFrame(a)}},[])}function Ge(e){const t=Object(Pe.useRef)(e);return t.current=e,Object($e.useRefEffect)(e=>{function n(e){const{keyCode:n}=e,{createRecord:r,handleChange:a,multilineTag:o}=t.current;if(e.defaultPrevented)return;if(n!==He.DELETE&&n!==He.BACKSPACE)return;const i=r(),{start:c,end:s,text:u}=i,l=n===He.BACKSPACE;if(0===c&&0!==s&&s===u.length)return a(X(i)),void e.preventDefault();if(o){let t;t=l&&0===i.start&&0===i.end&&K(i)?Z(i,!l):Z(i,l),t&&(a(t),e.preventDefault())}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}function Ze({value:e="",selectionStart:t,selectionEnd:n,placeholder:r,preserveWhiteSpace:a,onSelectionChange:i,onChange:c,__unstableMultilineTag:s,__unstableDisableFormats:u,__unstableIsSelected:l,__unstableDependencies:f=[],__unstableAfterParse:d,__unstableBeforeSerialize:m,__unstableAddInvisibleFormats:p}){const g=Object(o.useRegistry)(),[,h]=Object(Pe.useReducer)(()=>({})),b=Object(Pe.useRef)();function v(){const{ownerDocument:{defaultView:e}}=b.current,t=e.getSelection(),n=t.rangeCount>0?t.getRangeAt(0):null;return O({element:b.current,range:n,multilineTag:s,multilineWrapperTags:"li"===s?["ul","ol"]:void 0,__unstableIsEditableTree:!0,preserveWhiteSpace:a})}function y(e,{domOnly:t}={}){he({value:e,current:b.current,multilineTag:s,multilineWrapperTags:"li"===s?["ul","ol"]:void 0,prepareEditableTree:p,__unstableDomOnly:t,placeholder:r})}const x=Object(Pe.useRef)(e),T=Object(Pe.useRef)();function E(){x.current=e,T.current=O({html:e,multilineTag:s,multilineWrapperTags:"li"===s?["ul","ol"]:void 0,preserveWhiteSpace:a}),u&&(T.current.formats=Array(e.length),T.current.replacements=Array(e.length)),d&&(T.current.formats=d(T.current)),T.current.start=t,T.current.end=n}const w=Object(Pe.useRef)(!1);if(T.current)t===T.current.start&&n===T.current.end||(w.current=l,T.current={...T.current,start:t,end:n});else{var _,j,C;E();"core/text-color"===(null===(_=T.current)||void 0===_||null===(j=_.formats[0])||void 0===j||null===(C=j[0])||void 0===C?void 0:C.type)&&function(e){T.current=e,x.current=ve({value:m?{...e,formats:m(e)}:e,multilineTag:s,preserveWhiteSpace:a});const{formats:t,text:n}=e;g.batch(()=>{c(x.current,{__unstableFormats:t,__unstableText:n})}),h()}(T.current)}function F(e){T.current=e,y(e),x.current=u?e.text:ve({value:m?{...e,formats:m(e)}:e,multilineTag:s,preserveWhiteSpace:a});const{start:t,end:n,formats:r,text:o}=e;g.batch(()=>{i(t,n),c(x.current,{__unstableFormats:r,__unstableText:o})}),h()}function R(){E(),y(T.current)}const L=Object(Pe.useRef)(!1);Object(Pe.useLayoutEffect)(()=>{L.current&&e!==x.current&&R()},[e]),Object(Pe.useLayoutEffect)(()=>{w.current&&(R(),w.current=!1)},[w.current]);const S=Object($e.useMergeRefs)([b,Object(Pe.useCallback)(e=>{e&&(e.style.whiteSpace="pre-wrap",e.style.minWidth="1px")},[]),Ve({record:T}),Ke({record:T,multilineTag:s,preserveWhiteSpace:a}),Object($e.useRefEffect)(e=>{function t(t){const{target:n}=t;if(n===e||n.textContent)return;const{ownerDocument:r}=n,{defaultView:a}=r,o=r.createRange(),i=a.getSelection();o.selectNode(n),i.removeAllRanges(),i.addRange(o)}return e.addEventListener("click",t),()=>{e.removeEventListener("click",t)}},[]),qe({record:T,applyRecord:y}),Ge({createRecord:v,handleChange:F,multilineTag:s}),ze({multilineTag:s,createRecord:v,handleChange:F}),Ye({record:T,applyRecord:y,createRecord:v,handleChange:F,isSelected:l,onSelectionChange:i}),Object($e.useRefEffect)(e=>{function t(e){if(e.defaultPrevented)return;const{keyCode:t,altKey:n,metaKey:r,ctrlKey:a}=e;t!==He.SPACE||n||r||a||(e.target.ownerDocument.execCommand("insertText",!1," "),e.preventDefault())}return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[]),Object($e.useRefEffect)(()=>{R(),L.current=!0},[r,...f])]);return{value:T.current,onChange:F,ref:S}}function Je(){}function Qe({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=D(r,o),s=void 0!==c,u=k(r),l=void 0!==u&&u.type===o;return Object(Pe.createElement)(i,{key:o,isActive:s,activeAttributes:s&&c.attributes||{},isObjectActive:l,activeObjectAttributes:l&&u.attributes||{},value:r,onChange:t,onFocus:n,contentRef:a})})}}}); |