WordPress/wp-includes/js/dist/rich-text.min.js
desrosj 5a4b00a618 Grouped merges for 5.2.12.
- Update `lodash` to the latest version `4.17.21`.
- Disable some attributes for rich text.
- Use hashed/deterministic moduleIDs in webpack config.

Props ellatrix, peterwilsoncc, get_dave, mcsf, talldanwp, youknowriad, desrosj, nerrad, gziolo.
Merges [50940-50941,50984-50985,51426] to the 5.2 branch.
Built from https://develop.svn.wordpress.org/branches/5.2@51756


git-svn-id: http://core.svn.wordpress.org/branches/5.2@51363 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 21:22:54 +00:00

1 line
29 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.wp=this.wp||{},this.wp.richText=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="yyEc")}({"1ZqX":function(e,t){!function(){e.exports=this.wp.data}()},"25BE":function(e,t,r){"use strict";function n(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}r.d(t,"a",(function(){return n}))},"4eJC":function(e,t,r){e.exports=function(e,t){var r,n,a,i=0;function o(){var t,o,c=n,u=arguments.length;e:for(;c;){if(c.args.length===arguments.length){for(o=0;o<u;o++)if(c.args[o]!==arguments[o]){c=c.next;continue e}return c!==n&&(c===a&&(a=c.prev),c.prev.next=c.next,c.next&&(c.next.prev=c.prev),c.next=n,c.prev=null,n.prev=c,n=c),c.val}c=c.next}for(t=new Array(u),o=0;o<u;o++)t[o]=arguments[o];return c={args:t,val:e.apply(null,t)},n?(n.prev=c,c.next=n):a=c,i===r?(a=a.prev).next=null:i++,n=c,c.val}return t&&t.maxSize&&(r=t.maxSize),o.clear=function(){n=null,a=null,i=0},o}},GRId:function(e,t){!function(){e.exports=this.wp.element}()},K9lf:function(e,t){!function(){e.exports=this.wp.compose}()},KQm4:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r("25BE");function a(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||Object(n.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}},U8pU:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e){return(a="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)})(e)}r.d(t,"a",(function(){return a}))},Vx3V:function(e,t){!function(){e.exports=this.wp.escapeHtml}()},YLtl:function(e,t){!function(){e.exports=this.lodash}()},g56x:function(e,t){!function(){e.exports=this.wp.hooks}()},pPDe:function(e,t,r){"use strict";var n,a;function i(e){return[e]}function o(){var e={clear:function(){e.head=null}};return e}function c(e,t,r){var n;if(e.length!==t.length)return!1;for(n=r;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}n={},a="undefined"!=typeof WeakMap,t.a=function(e,t){var r,u;function l(){r=a?new WeakMap:o()}function s(){var r,n,a,i,o,l=arguments.length;for(i=new Array(l),a=0;a<l;a++)i[a]=arguments[a];for(o=t.apply(null,i),(r=u(o)).isUniqueByDependants||(r.lastDependants&&!c(o,r.lastDependants,0)&&r.clear(),r.lastDependants=o),n=r.head;n;){if(c(n.args,i,1))return n!==r.head&&(n.prev.next=n.next,n.next&&(n.next.prev=n.prev),n.next=r.head,n.prev=null,r.head.prev=n,r.head=n),n.val;n=n.next}return n={val:e.apply(null,i)},i[0]=null,n.args=i,r.head&&(r.head.prev=n,n.next=r.head),r.head=n,n.val}return t||(t=i),u=a?function(e){var t,a,i,c,u,l=r,s=!0;for(t=0;t<e.length;t++){if(a=e[t],!(u=a)||"object"!=typeof u){s=!1;break}l.has(a)?l=l.get(a):(i=new WeakMap,l.set(a,i),l=i)}return l.has(n)||((c=o()).isUniqueByDependants=s,l.set(n,c)),l.get(n)}:function(){return r},s.getDependants=t,s.clear=l,l(),s}},rePB:function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",(function(){return n}))},vpQ4:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r("rePB");function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},a=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),a.forEach((function(t){Object(n.a)(e,t,r[t])}))}return e}},wx14:function(e,t,r){"use strict";function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}r.d(t,"a",(function(){return n}))},yyEc:function(e,t,r){"use strict";r.r(t),r.d(t,"applyFormat",(function(){return y})),r.d(t,"charAt",(function(){return T})),r.d(t,"concat",(function(){return L})),r.d(t,"create",(function(){return N})),r.d(t,"getActiveFormat",(function(){return M})),r.d(t,"getActiveObject",(function(){return R})),r.d(t,"getSelectionEnd",(function(){return W})),r.d(t,"getSelectionStart",(function(){return B})),r.d(t,"getTextContent",(function(){return U})),r.d(t,"isCollapsed",(function(){return z})),r.d(t,"isEmpty",(function(){return G})),r.d(t,"isEmptyLine",(function(){return H})),r.d(t,"join",(function(){return Y})),r.d(t,"registerFormatType",(function(){return te})),r.d(t,"removeFormat",(function(){return re})),r.d(t,"remove",(function(){return ie})),r.d(t,"replace",(function(){return oe})),r.d(t,"insert",(function(){return ae})),r.d(t,"insertLineBreak",(function(){return ce})),r.d(t,"insertLineSeparator",(function(){return ue})),r.d(t,"insertObject",(function(){return le})),r.d(t,"slice",(function(){return se})),r.d(t,"split",(function(){return fe})),r.d(t,"apply",(function(){return Ae})),r.d(t,"unstableToDom",(function(){return Ne})),r.d(t,"toHTMLString",(function(){return Se})),r.d(t,"toggleFormat",(function(){return ze})),r.d(t,"LINE_SEPARATOR",(function(){return E})),r.d(t,"unregisterFormatType",(function(){return Ge})),r.d(t,"indentListItems",(function(){return Ye})),r.d(t,"outdentListItems",(function(){return Ke})),r.d(t,"changeListType",(function(){return Qe})),r.d(t,"__unstableUpdateFormats",(function(){return Xe})),r.d(t,"__unstableGetActiveFormats",(function(){return V}));var n={};r.r(n),r.d(n,"getFormatTypes",(function(){return s})),r.d(n,"getFormatType",(function(){return f})),r.d(n,"getFormatTypeForBareElement",(function(){return d})),r.d(n,"getFormatTypeForClassName",(function(){return p}));var a={};r.r(a),r.d(a,"addFormatTypes",(function(){return m})),r.d(a,"removeFormatTypes",(function(){return v}));var i=r("1ZqX"),o=r("vpQ4"),c=r("YLtl");var u=Object(i.combineReducers)({formatTypes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ADD_FORMAT_TYPES":return Object(o.a)({},e,Object(c.keyBy)(t.formatTypes,"name"));case"REMOVE_FORMAT_TYPES":return Object(c.omit)(e,t.names)}return e}}),l=r("pPDe"),s=Object(l.a)((function(e){return Object.values(e.formatTypes)}),(function(e){return[e.formatTypes]}));function f(e,t){return e.formatTypes[t]}function d(e,t){return Object(c.find)(s(e),(function(e){var r=e.tagName;return t===r}))}function p(e,t){return Object(c.find)(s(e),(function(e){var r=e.className;return null!==r&&" ".concat(t," ").indexOf(" ".concat(r," "))>=0}))}function m(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Object(c.castArray)(e)}}function v(e){return{type:"REMOVE_FORMAT_TYPES",names:Object(c.castArray)(e)}}Object(i.registerStore)("core/rich-text",{reducer:u,selectors:n,actions:a});var g=r("KQm4");function h(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.type!==t.type)return!1;var r=e.attributes,n=t.attributes;if(r===n)return!0;if(!r||!n)return!1;var a=Object.keys(r),i=Object.keys(n);if(a.length!==i.length)return!1;for(var o=a.length,c=0;c<o;c++){var u=a[c];if(r[u]!==n[u])return!1}return!0}function b(e){var t=e.formats.slice();return t.forEach((function(e,r){var n=t[r-1];if(n){var a=e.slice();a.forEach((function(e,t){var r=n[t];h(e,r)&&(a[t]=r)})),t[r]=a}})),Object(o.a)({},e,{formats:t})}function y(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,i=e.activeFormats,u=a.slice();if(r===n){var l=Object(c.find)(u[r],{type:t.type});if(l){for(;Object(c.find)(u[r],l);)x(u,r,t),r--;for(n++;Object(c.find)(u[n],l);)x(u,n,t),n++}}else for(var s=r;s<n;s++)x(u,s,t);return b(Object(o.a)({},e,{formats:u,activeFormats:[].concat(Object(g.a)(Object(c.reject)(i,{type:t.type})),[t])}))}function x(e,t,r){if(e[t]){var n=e[t].filter((function(e){return e.type!==r.type}));n.push(r),e[t]=n}else e[t]=[r]}function T(e,t){return e.text[t]}var O=r("U8pU");function j(e,t){var r=e.implementation;return j.body||(j.body=r.createHTMLDocument("").body),j.body.innerHTML=t,j.body}var E="\u2028",w=window.Node,_=w.TEXT_NODE,C=w.ELEMENT_NODE;function F(e,t){for(var r in e)if(e[r]===t)return r}function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.element,r=e.text,n=e.html,a=e.range,i=e.multilineTag,o=e.multilineWrapperTags,c=e.__unstableIsEditableTree;return"string"==typeof r&&r.length>0?{formats:Array(r.length),replacements:Array(r.length),text:r}:("string"==typeof n&&n.length>0&&(t=j(document,n)),"object"!==Object(O.a)(t)?{formats:[],replacements:[],text:""}:i?I({element:t,range:a,multilineTag:i,multilineWrapperTags:o,isEditableTree:c}):S({element:t,range:a,isEditableTree:c}))}function A(e,t,r,n){if(r){var a=t.parentNode,i=r.startContainer,o=r.startOffset,c=r.endContainer,u=r.endOffset,l=e.text.length;void 0!==n.start?e.start=l+n.start:t===i&&t.nodeType===_?e.start=l+o:a===i&&t===i.childNodes[o]?e.start=l:a===i&&t===i.childNodes[o-1]?e.start=l+n.text.length:t===i&&(e.start=l),void 0!==n.end?e.end=l+n.end:t===c&&t.nodeType===_?e.end=l+u:a===c&&t===c.childNodes[u-1]?e.end=l+n.text.length:a===c&&t===c.childNodes[u]?e.end=l:t===c&&(e.end=l+u)}}function P(e){return e.replace(/[\n\r\t]+/g," ")}function S(e){var t=e.element,r=e.range,n=e.multilineTag,a=e.multilineWrapperTags,c=e.currentWrapperTags,u=void 0===c?[]:c,l=e.isEditableTree,s={formats:[],replacements:[],text:""};if(!t)return s;if(!t.hasChildNodes())return A(s,t,r,{formats:[],replacements:[],text:""}),s;for(var f=t.childNodes.length,d=function(e){var c=t.childNodes[e],f=c.nodeName.toLowerCase();if(c.nodeType===_){var d=P(c.nodeValue);return r=function(e,t,r){if(t){var n=t.startContainer,a=t.endContainer,i=t.startOffset,o=t.endOffset;return e===n&&(i=r(e.nodeValue.slice(0,i)).length),e===a&&(o=r(e.nodeValue.slice(0,o)).length),{startContainer:n,startOffset:i,endContainer:a,endOffset:o}}}(c,r,P),A(s,c,r,{text:d}),s.formats.length+=d.length,s.replacements.length+=d.length,s.text+=d,"continue"}if(c.nodeType!==C)return"continue";if(c.getAttribute("data-rich-text-padding")||l&&"br"===f&&!c.getAttribute("data-rich-text-line-break"))return A(s,c,r,{formats:[],replacements:[],text:""}),"continue";if("script"===f){var p={formats:[,],replacements:[{type:f,attributes:{"data-rich-text-script":c.getAttribute("data-rich-text-script")||encodeURIComponent(c.innerHTML)}}],text:""};return A(s,c,r,p),k(s,p),"continue"}if("br"===f)return A(s,c,r,{formats:[],replacements:[],text:""}),k(s,N({text:"\n"})),"continue";var m=s.formats[s.formats.length-1],v=m&&m[m.length-1],b=function(e){var t,r=e.type,n=e.attributes;if(n&&n.class&&(t=Object(i.select)("core/rich-text").getFormatTypeForClassName(n.class))&&(n.class=" ".concat(n.class," ").replace(" ".concat(t.className," ")," ").trim(),n.class||delete n.class),t||(t=Object(i.select)("core/rich-text").getFormatTypeForBareElement(r)),!t)return n?{type:r,attributes:n}:{type:r};if(t.__experimentalCreatePrepareEditableTree&&!t.__experimentalCreateOnChangeEditableValue)return null;if(!n)return{type:t.name};var a={},o={};for(var c in n){var u=F(t.attributes,c);u?a[u]=n[c]:o[c]=n[c]}return{type:t.name,attributes:a,unregisteredAttributes:o}}({type:f,attributes:D({element:c})}),y=h(b,v)?v:b;if(a&&-1!==a.indexOf(f)){var x=I({element:c,range:r,multilineTag:n,multilineWrapperTags:a,currentWrapperTags:[].concat(Object(g.a)(u),[y]),isEditableTree:l});return A(s,c,r,x),k(s,x),"continue"}var T=S({element:c,range:r,multilineTag:n,multilineWrapperTags:a,isEditableTree:l});A(s,c,r,T),y?0===T.text.length?y.attributes&&k(s,{formats:[,],replacements:[y],text:""}):k(s,Object(o.a)({},T,{formats:Array.from(T.formats,(function(e){return e?[y].concat(Object(g.a)(e)):[y]}))})):k(s,T)},p=0;p<f;p++)d(p);return s}function I(e){var t=e.element,r=e.range,n=e.multilineTag,a=e.multilineWrapperTags,i=e.currentWrapperTags,o=void 0===i?[]:i,c=e.isEditableTree,u={formats:[],replacements:[],text:""};if(!t||!t.hasChildNodes())return u;for(var l=t.children.length,s=0;s<l;s++){var f=t.children[s];if(f.nodeName.toLowerCase()===n){var d=S({element:f,range:r,multilineTag:n,multilineWrapperTags:a,currentWrapperTags:o,isEditableTree:c});(0!==s||o.length>0)&&k(u,{formats:[,],replacements:o.length>0?[o]:[,],text:E}),A(u,f,r,d),k(u,d)}}return u}function D(e){var t=e.element;if(t.hasAttributes()){for(var r,n=t.attributes.length,a=0;a<n;a++){var i=t.attributes[a],o=i.name,c=i.value;if(0!==o.indexOf("data-rich-text-"))(r=r||{})[/^on/i.test(o)?"data-disable-rich-text-"+o:o]=c}return r}}function k(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function L(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return b(t.reduce(k,N()))}function V(e){var t=e.formats,r=e.start,n=e.end,a=e.activeFormats;if(void 0===r)return[];if(r===n){if(a)return a;var i=t[r-1]||[],o=t[r]||[];return i.length<o.length?i:o}return t[r]||[]}function M(e,t){return Object(c.find)(V(e),{type:t})}function R(e){var t=e.start,r=e.end,n=e.replacements,a=e.text;if(t+1===r&&""===a[t])return n[t]}function W(e){return e.end}function B(e){return e.start}function U(e){return e.text}function z(e){var t=e.start,r=e.end;if(void 0!==t&&void 0!==r)return t===r}function G(e){return 0===e.text.length}function H(e){var t=e.text,r=e.start,n=e.end;return r===n&&(0===t.length||(0===r&&t.slice(0,1)===E||(r===t.length&&t.slice(-1)===E||t.slice(r-1,n+1)==="".concat(E).concat(E))))}function Y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof t&&(t=N({text:t})),b(e.reduce((function(e,r){var n=r.formats,a=r.replacements,i=r.text;return{formats:e.formats.concat(t.formats,n),replacements:e.replacements.concat(t.replacements,a),text:e.text+t.text+i}})))}var q=r("rePB"),K=r("wx14"),Q=r("GRId"),X=r("4eJC"),Z=r.n(X),$=r("g56x"),J=r("K9lf"),ee=[];function te(e,t){if("string"==typeof(t=Object(o.a)({name:e},t)).name)if(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(t.name))if(Object(i.select)("core/rich-text").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){var r=Object(i.select)("core/rich-text").getFormatTypeForBareElement(t.tagName);if(r)return void window.console.error('Format "'.concat(r.name,'" is already registered to handle bare tag name "').concat(t.tagName,'".'))}else{var n=Object(i.select)("core/rich-text").getFormatTypeForClassName(t.className);if(n)return void window.console.error('Format "'.concat(n.name,'" is already registered to handle class name "').concat(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){Object(i.dispatch)("core/rich-text").addFormatTypes(t);var a=Z()((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ee,t=arguments.length>1?arguments[1]:void 0;return[].concat(Object(g.a)(e),[t])}));return t.__experimentalCreatePrepareEditableTree&&Object($.addFilter)("experimentalRichText",e,(function(r){var n=r;(t.__experimentalCreatePrepareEditableTree||t.__experimentalCreateFormatToValue||t.__experimentalCreateValueToFormat)&&(n=function(n){var i={};if(t.__experimentalCreatePrepareEditableTree&&(i.prepareEditableTree=a(n.prepareEditableTree,t.__experimentalCreatePrepareEditableTree(n["format_".concat(e)],{richTextIdentifier:n.identifier,blockClientId:n.clientId}))),t.__experimentalCreateOnChangeEditableValue){var c=Object.keys(n).reduce((function(t,r){var a=n[r],i="format_".concat(e,"_dispatch_");r.startsWith(i)&&(t[r.replace(i,"")]=a);return t}),{});i.onChangeEditableValue=a(n.onChangeEditableValue,t.__experimentalCreateOnChangeEditableValue(Object(o.a)({},n["format_".concat(e)],c),{richTextIdentifier:n.identifier,blockClientId:n.clientId}))}return Object(Q.createElement)(r,Object(K.a)({},n,i))});var u=[];return t.__experimentalGetPropsForEditableTreePreparation&&u.push(Object(i.withSelect)((function(r,n){var a=n.clientId,i=n.identifier;return Object(q.a)({},"format_".concat(e),t.__experimentalGetPropsForEditableTreePreparation(r,{richTextIdentifier:i,blockClientId:a}))}))),t.__experimentalGetPropsForEditableTreeChangeHandler&&u.push(Object(i.withDispatch)((function(r,n){var a=n.clientId,i=n.identifier,o=t.__experimentalGetPropsForEditableTreeChangeHandler(r,{richTextIdentifier:i,blockClientId:a});return Object(c.mapKeys)(o,(function(t,r){return"format_".concat(e,"_dispatch_").concat(r)}))}))),Object(J.compose)(u)(n)})),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 re(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,i=e.activeFormats,u=a.slice();if(r===n){var l=Object(c.find)(u[r],{type:t});if(l){for(;Object(c.find)(u[r],l);)ne(u,r,t),r--;for(n++;Object(c.find)(u[n],l);)ne(u,n,t),n++}}else for(var s=r;s<n;s++)u[s]&&ne(u,s,t);return b(Object(o.a)({},e,{formats:u,activeFormats:Object(c.reject)(i,{type:t})}))}function ne(e,t,r){var n=e[t].filter((function(e){return e.type!==r}));n.length?e[t]=n:delete e[t]}function ae(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,i=e.replacements,o=e.text;"string"==typeof t&&(t=N({text:t}));var c=r+t.text.length;return b({formats:a.slice(0,r).concat(t.formats,a.slice(n)),replacements:i.slice(0,r).concat(t.replacements,i.slice(n)),text:o.slice(0,r)+t.text+o.slice(n),start:c,end:c})}function ie(e,t,r){return ae(e,N(),t,r)}function oe(e,t,r){var n=e.formats,a=e.replacements,i=e.text,o=e.start,c=e.end;return i=i.replace(t,(function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),u=1;u<t;u++)i[u-1]=arguments[u];var l,s,f=i[i.length-2],d=r;return"function"==typeof d&&(d=r.apply(void 0,[e].concat(i))),"object"===Object(O.a)(d)?(l=d.formats,s=d.replacements,d=d.text):(l=Array(d.length),s=Array(d.length),n[f]&&(l=l.fill(n[f]))),n=n.slice(0,f).concat(l,n.slice(f+e.length)),a=a.slice(0,f).concat(s,a.slice(f+e.length)),o&&(o=c=f+d.length),d})),b({formats:n,replacements:a,text:i,start:o,end:c})}function ce(e){return ae(e,"\n")}function ue(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,n=U(e).slice(0,t),a=n.lastIndexOf(E),i=e.replacements[a],o=[,];i&&(o=[i]);var c={formats:[,],replacements:o,text:E};return ae(e,c,t,r)}function le(e,t,r,n){return ae(e,{formats:[,],replacements:[t],text:""},r,n)}function se(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,n=e.formats,a=e.replacements,i=e.text;return void 0===t||void 0===r?Object(o.a)({},e):{formats:n.slice(t,r),replacements:a.slice(t,r),text:i.slice(t,r)}}function fe(e,t){var r=e.formats,n=e.replacements,a=e.text,i=e.start,o=e.end;if("string"!=typeof t)return de.apply(void 0,arguments);var c=0;return a.split(t).map((function(e){var a=c,u={formats:r.slice(a,a+e.length),replacements:n.slice(a,a+e.length),text:e};return c+=t.length+e.length,void 0!==i&&void 0!==o&&(i>=a&&i<c?u.start=i-a:i<a&&o>a&&(u.start=0),o>=a&&o<c?u.end=o-a:i<c&&o>c&&(u.end=e.length)),u}))}function de(e){var t=e.formats,r=e.replacements,n=e.text,a=e.start,i=e.end,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i,u={formats:t.slice(0,o),replacements:r.slice(0,o),text:n.slice(0,o)},l={formats:t.slice(c),replacements:r.slice(c),text:n.slice(c),start:0,end:0};return[oe(u,/\u2028+$/,""),oe(l,/^\u2028+/,"")]}function pe(e,t){if(t)return e;var r={};for(var n in e){var a=n;n.startsWith("data-disable-rich-text-")&&(a=n.slice("data-disable-rich-text-".length)),r[a]=e[n]}return r}function me(e){var t=e.type,r=e.attributes,n=e.unregisteredAttributes,a=e.object,c=e.boundaryClass,u=e.isEditableTree,l=function(e){return Object(i.select)("core/rich-text").getFormatType(e)}(t),s={};if(c&&(s["data-rich-text-format-boundary"]="true"),!l)return r&&(s=Object(o.a)({},r,s)),{type:t,attributes:pe(s,u),object:a};for(var f in s=Object(o.a)({},n,s),r){var d=!!l.attributes&&l.attributes[f];d?s[d]=r[f]:s[f]=r[f]}return l.className&&(s.class?s.class="".concat(l.className," ").concat(s.class):s.class=l.className),{type:l.tagName,object:l.object,attributes:pe(s,u)}}var ve={type:"br",attributes:{"data-rich-text-padding":"true"},object:!0};function ge(e){var t,r,n,a=e.value,i=e.multilineTag,c=e.createEmpty,u=e.append,l=e.getLastChild,s=e.getParent,f=e.isText,d=e.getText,p=e.remove,m=e.appendText,v=e.onStartIndex,h=e.onEndIndex,b=e.isEditableTree,y=a.formats,x=a.replacements,T=a.text,O=a.start,j=a.end,w=y.length+1,_=c(),C={type:i},F=V(a),N=F[F.length-1];i?(u(u(_,{type:i}),""),r=t=[C]):u(_,"");for(var A=function(e){var a=T.charAt(e),c=b&&(!n||n===E||"\n"===n),w=y[e];i&&(w=a===E?t=(x[e]||[]).reduce((function(e,t){return e.push(t,C),e}),[C]):[].concat(Object(g.a)(t),Object(g.a)(w||[])));var F=l(_);if(c&&a===E){for(var A=F;!f(A);)A=l(A);u(s(A),ve),u(s(A),"")}if(n===E){for(var P=F;!f(P);)P=l(P);v&&O===e&&v(_,P),h&&j===e&&h(_,P)}if(w&&w.forEach((function(e,t){if(!F||!r||e!==r[t]||a===E&&w.length-1===t){var n=e.type,i=e.attributes,o=e.unregisteredAttributes,c=b&&a!==E&&e===N,m=s(F),v=u(m,me({type:n,attributes:i,unregisteredAttributes:o,boundaryClass:c,isEditableTree:b}));f(F)&&0===d(F).length&&p(F),F=u(v,"")}else F=l(F)})),a===E)return r=w,n=a,"continue";0===e&&(v&&0===O&&v(_,F),h&&0===j&&h(_,F)),""===a?(b||"script"!==x[e].type?F=u(s(F),me(Object(o.a)({},x[e],{object:!0,isEditableTree:b}))):(F=u(s(F),me({type:"script",isEditableTree:b})),u(F,{html:decodeURIComponent(x[e].attributes["data-rich-text-script"])})),F=u(s(F),"")):"\n"===a?(F=u(s(F),{type:"br",attributes:b?{"data-rich-text-line-break":"true"}:void 0,object:!0}),F=u(s(F),"")):f(F)?m(F,a):F=u(s(F),a),v&&O===e+1&&v(_,F),h&&j===e+1&&h(_,F),c&&e===T.length&&u(s(F),ve),r=w,n=a},P=0;P<w;P++)A(P);return _}var he=window.Node.TEXT_NODE;function be(e,t,r){for(var n=e.parentNode,a=0;e=e.previousSibling;)a++;return r=[a].concat(Object(g.a)(r)),n!==t&&(r=be(n,t,r)),r}function ye(e,t){for(t=Object(g.a)(t);e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}var xe=function(){return j(document,"")};function Te(e,t){"string"==typeof t&&(t=e.ownerDocument.createTextNode(t));var r=t,n=r.type,a=r.attributes;if(n)for(var i in t=e.ownerDocument.createElement(n),a)t.setAttribute(i,a[i]);return e.appendChild(t)}function Oe(e,t){e.appendData(t)}function je(e){return e.lastChild}function Ee(e){return e.parentNode}function we(e){return e.nodeType===he}function _e(e){return e.nodeValue}function Ce(e){return e.parentNode.removeChild(e)}function Fe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;return e.reduce((function(e,r){return r(e,t.text)}),t.formats)}function Ne(e){var t=e.value,r=e.multilineTag,n=e.prepareEditableTree,a=e.isEditableTree,i=void 0===a||a,c=[],u=[];return{body:ge({value:Object(o.a)({},t,{formats:Fe(n,t)}),multilineTag:r,createEmpty:xe,append:Te,getLastChild:je,getParent:Ee,isText:we,getText:_e,remove:Ce,appendText:Oe,onStartIndex:function(e,t){c=be(t,e,[t.nodeValue.length])},onEndIndex:function(e,t){u=be(t,e,[t.nodeValue.length])},isEditableTree:i}),selection:{startPath:c,endPath:u}}}function Ae(e){var t=e.value,r=e.current,n=e.multilineTag,a=e.prepareEditableTree,i=e.__unstableDomOnly,o=Ne({value:t,multilineTag:n,prepareEditableTree:a}),c=o.body,u=o.selection;!function e(t,r){var n,a=0;for(;n=t.firstChild;){var i=r.childNodes[a];if(i)if(i.isEqualNode(n))t.removeChild(n);else if(i.nodeName!==n.nodeName||i.nodeType===he&&i.data!==n.data)r.replaceChild(n,i);else{var o=i.attributes,c=n.attributes;if(o)for(var u=0;u<o.length;u++){var l=o[u].name;n.getAttribute(l)||i.removeAttribute(l)}if(c)for(var s=0;s<c.length;s++){var f=c[s],d=(l=f.name,f.value);i.getAttribute(l)!==d&&i.setAttribute(l,d)}e(n,i),t.removeChild(n)}else r.appendChild(n);a++}for(;r.childNodes[a];)r.removeChild(r.childNodes[a])}(c,r),void 0===t.start||i||function(e,t){var r=e.startPath,n=e.endPath,a=ye(t,r),i=a.node,o=a.offset,c=ye(t,n),u=c.node,l=c.offset,s=window.getSelection(),f=t.ownerDocument,d=f.createRange();if(d.setStart(i,o),d.setEnd(u,l),s.rangeCount>0){if(p=d,m=s.getRangeAt(0),p.startContainer===m.startContainer&&p.startOffset===m.startOffset&&p.endContainer===m.endContainer&&p.endOffset===m.endOffset)return void(f.activeElement!==t&&t.focus());s.removeAllRanges()}var p,m;s.addRange(d)}(u,r)}var Pe=r("Vx3V");function Se(e){return Ue(ge({value:e.value,multilineTag:e.multilineTag,createEmpty:Ie,append:ke,getLastChild:De,getParent:Ve,isText:Me,getText:Re,remove:We,appendText:Le}).children)}function Ie(){return{}}function De(e){var t=e.children;return t&&t[t.length-1]}function ke(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Le(e,t){e.text+=t}function Ve(e){return e.parent}function Me(e){return"string"==typeof e.text}function Re(e){return e.text}function We(e){var t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function Be(e){var t=e.type,r=e.attributes,n=e.object,a=e.children,i="";for(var o in r)Object(Pe.isValidAttributeName)(o)&&(i+=" ".concat(o,'="').concat(Object(Pe.escapeAttribute)(r[o]),'"'));return n?"<".concat(t).concat(i,">"):"<".concat(t).concat(i,">").concat(Ue(a),"</").concat(t,">")}function Ue(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map((function(e){return void 0!==e.html?e.html:void 0===e.text?Be(e):Object(Pe.escapeHTML)(e.text)})).join("")}function ze(e,t){return M(e,t.type)?re(e,t.type):y(e,t)}function Ge(e){var t=Object(i.select)("core/rich-text").getFormatType(e);if(t)return t.__experimentalCreatePrepareEditableTree&&t.__experimentalGetPropsForEditableTreePreparation&&Object($.removeFilter)("experimentalRichText",e),Object(i.dispatch)("core/rich-text").removeFormatTypes(e),t;window.console.error("Format ".concat(e," is not registered."))}function He(e){for(var t=e.start,r=e.text,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,a=n;a--;)if(r[a]===E)return a}function Ye(e,t){var r=He(e);if(void 0===r)return e;var n=e.text,a=e.replacements,i=e.end,c=He(e,r),u=a[r]||[],l=a[c]||[];if(u.length>l.length)return e;for(var s=a.slice(),f=function(e,t){for(var r=e.text,n=e.replacements,a=n[t]||[],i=t;i-- >=0;)if(r[i]===E){var o=n[i]||[];if(o.length===a.length+1)return i;if(o.length<=a.length)return}}(e,r),d=r;d<i;d++)if(n[d]===E)if(f){var p=a[f]||[];s[d]=p.concat((s[d]||[]).slice(p.length-1))}else{var m=a[c]||[],v=m[m.length-1]||t;s[d]=m.concat([v],(s[d]||[]).slice(m.length))}return Object(o.a)({},e,{replacements:s})}function qe(e,t){for(var r=e.text,n=e.replacements,a=n[t]||[],i=t;i-- >=0;){if(r[i]===E)if((n[i]||[]).length===a.length-1)return i}}function Ke(e){var t=e.text,r=e.replacements,n=e.start,a=e.end,i=He(e,n);if(void 0===r[i])return e;for(var c=r.slice(0),u=r[qe(e,i)]||[],l=function(e,t){for(var r=e.text,n=e.replacements,a=n[t]||[],i=t,o=t||0;o<r.length;o++)if(r[o]===E){if(!((n[o]||[]).length>=a.length))return i;i=o}return i}(e,He(e,a)),s=i;s<=l;s++)if(t[s]===E){var f=c[s]||[];c[s]=u.concat(f.slice(u.length+1)),0===c[s].length&&delete c[s]}return Object(o.a)({},e,{replacements:c})}function Qe(e,t){for(var r,n=e.text,a=e.replacements,i=e.start,c=e.end,u=He(e,i),l=a[u]||[],s=a[He(e,c)]||[],f=qe(e,u),d=a.slice(),p=l.length-1,m=s.length-1,v=f+1||0;v<n.length;v++)if(n[v]===E){if((d[v]||[]).length<=p)break;d[v]&&(r=!0,d[v]=d[v].map((function(e,r){return r<p||r>m?e:t})))}return r?Object(o.a)({},e,{replacements:d}):e}function Xe(e){var t=e.value,r=e.start,n=e.end,a=e.formats,i=t.formats[r-1]||[],o=t.formats[n]||[];for(t.activeFormats=a.map((function(e,t){if(i[t]){if(h(e,i[t]))return i[t]}else if(o[t]&&h(e,o[t]))return o[t];return e}));--n>=r;)t.activeFormats.length>0?t.formats[n]=t.activeFormats:delete t.formats[n];return t}}});