File Editor
Directories:
.. (Back)
vendor
Files:
a11y.js
a11y.min.js
annotations.js
annotations.min.js
api-fetch.js
api-fetch.min.js
autop.js
autop.min.js
blob.js
blob.min.js
block-editor.js
block-editor.min.js
block-library.js
block-library.min.js
block-serialization-default-parser.js
block-serialization-default-parser.min.js
blocks.js
blocks.min.js
components.js
components.min.js
compose.js
compose.min.js
core-data.js
core-data.min.js
data-controls.js
data-controls.min.js
data.js
data.min.js
date.js
date.min.js
deprecated.js
deprecated.min.js
dom-ready.js
dom-ready.min.js
dom.js
dom.min.js
edit-post.js
edit-post.min.js
editor.js
editor.min.js
element.js
element.min.js
escape-html.js
escape-html.min.js
format-library.js
format-library.min.js
hooks.js
hooks.min.js
html-entities.js
html-entities.min.js
i18n.js
i18n.min.js
is-shallow-equal.js
is-shallow-equal.min.js
keycodes.js
keycodes.min.js
list-reusable-blocks.js
list-reusable-blocks.min.js
media-utils.js
media-utils.min.js
notices.js
notices.min.js
nux.js
nux.min.js
plugins.js
plugins.min.js
priority-queue.js
priority-queue.min.js
redux-routine.js
redux-routine.min.js
rich-text.js
rich-text.min.js
server-side-render.js
server-side-render.min.js
shortcode.js
shortcode.min.js
token-list.js
token-list.min.js
url.js
url.min.js
viewport.js
viewport.min.js
wordcount.js
wordcount.min.js
Create New File
Create
Edit File: rich-text.min.js
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")}({"1OyB":function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",(function(){return r}))},"1ZqX":function(e,t){!function(){e.exports=this.wp.data}()},"25BE":function(e,t,n){"use strict";function r(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}n.d(t,"a",(function(){return r}))},Ff2n:function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}n.d(t,"a",(function(){return r}))},GRId:function(e,t){!function(){e.exports=this.wp.element}()},JX7q:function(e,t,n){"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,"a",(function(){return r}))},Ji7U:function(e,t,n){"use strict";function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}n.d(t,"a",(function(){return a}))},K9lf:function(e,t){!function(){e.exports=this.wp.compose}()},KQm4:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n("25BE");function a(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||Object(r.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}},NMb1:function(e,t){!function(){e.exports=this.wp.deprecated}()},RxS6:function(e,t){!function(){e.exports=this.wp.keycodes}()},TSYQ:function(e,t,n){var r; /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */!function(){"use strict";var n={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var o=a.apply(null,r);o&&e.push(o)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var c in r)n.call(r,c)&&r[c]&&e.push(c);else e.push(r.toString())}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(r=function(){return a}.apply(t,[]))||(e.exports=r)}()},U8pU:function(e,t,n){"use strict";function r(e){return(r="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"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}n.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}()},foSv:function(e,t,n){"use strict";function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}n.d(t,"a",(function(){return r}))},g56x:function(e,t){!function(){e.exports=this.wp.hooks}()},md7G:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n("U8pU"),a=n("JX7q");function i(e,t){return!t||"object"!==Object(r.a)(t)&&"function"!=typeof t?Object(a.a)(e):t}},pPDe:function(e,t,n){"use strict";var r,a;function i(e){return[e]}function o(){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:o()}function u(){var n,r,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),(n=s(o)).isUniqueByDependants||(n.lastDependants&&!c(o,n.lastDependants,0)&&n.clear(),n.lastDependants=o),r=n.head;r;){if(c(r.args,i,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,i)},i[0]=null,r.args=i,n.head&&(n.head.prev=r,r.next=n.head),n.head=r,r.val}return t||(t=i),s=a?function(e){var t,a,i,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):(i=new WeakMap,l.set(a,i),l=i)}return l.has(r)||((c=o()).isUniqueByDependants=u,l.set(r,c)),l.get(r)}:function(){return n},u.getDependants=t,u.clear=l,l(),u}},rePB:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},rl8x:function(e,t){!function(){e.exports=this.wp.isShallowEqual}()},vpQ4:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n("rePB");function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),a.forEach((function(t){Object(r.a)(e,t,n[t])}))}return e}},vuIU:function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}n.d(t,"a",(function(){return a}))},wx14:function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},yyEc:function(e,t,n){"use strict";n.r(t),n.d(t,"applyFormat",(function(){return O})),n.d(t,"concat",(function(){return I})),n.d(t,"create",(function(){return F})),n.d(t,"getActiveFormat",(function(){return M})),n.d(t,"getActiveObject",(function(){return H})),n.d(t,"getTextContent",(function(){return U})),n.d(t,"__unstableIsListRootSelected",(function(){return B})),n.d(t,"__unstableIsActiveListType",(function(){return W})),n.d(t,"isCollapsed",(function(){return V})),n.d(t,"isEmpty",(function(){return q})),n.d(t,"__unstableIsEmptyLine",(function(){return z})),n.d(t,"join",(function(){return G})),n.d(t,"registerFormatType",(function(){return J})),n.d(t,"removeFormat",(function(){return Z})),n.d(t,"remove",(function(){return te})),n.d(t,"replace",(function(){return ne})),n.d(t,"insert",(function(){return ee})),n.d(t,"__unstableInsertLineSeparator",(function(){return re})),n.d(t,"__unstableRemoveLineSeparator",(function(){return ae})),n.d(t,"insertObject",(function(){return ie})),n.d(t,"slice",(function(){return oe})),n.d(t,"split",(function(){return ce})),n.d(t,"__unstableToDom",(function(){return je})),n.d(t,"toHTMLString",(function(){return Ce})),n.d(t,"toggleFormat",(function(){return Le})),n.d(t,"__UNSTABLE_LINE_SEPARATOR",(function(){return j})),n.d(t,"unregisterFormatType",(function(){return Me})),n.d(t,"__unstableIndentListItems",(function(){return He})),n.d(t,"__unstableOutdentListItems",(function(){return Ke})),n.d(t,"__unstableChangeListType",(function(){return Be})),n.d(t,"__unstableCreateElement",(function(){return x})),n.d(t,"__experimentalRichText",(function(){return mt})),n.d(t,"__unstableFormatEdit",(function(){return at}));var r={};n.r(r),n.d(r,"getFormatTypes",(function(){return u})),n.d(r,"getFormatType",(function(){return f})),n.d(r,"getFormatTypeForBareElement",(function(){return d})),n.d(r,"getFormatTypeForClassName",(function(){return p}));var a={};n.r(a),n.d(a,"addFormatTypes",(function(){return h})),n.d(a,"removeFormatTypes",(function(){return m}));var i=n("1ZqX"),o=n("vpQ4"),c=n("YLtl");var s=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=n("pPDe"),u=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)(u(e),(function(e){var n=e.className,r=e.tagName;return null===n&&t===r}))}function p(e,t){return Object(c.find)(u(e),(function(e){var n=e.className;return null!==n&&" ".concat(t," ").indexOf(" ".concat(n," "))>=0}))}function h(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Object(c.castArray)(e)}}function m(e){return{type:"REMOVE_FORMAT_TYPES",names:Object(c.castArray)(e)}}Object(i.registerStore)("core/rich-text",{reducer:s,selectors:r,actions:a});var v=n("KQm4");function b(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.type!==t.type)return!1;var n=e.attributes,r=t.attributes;if(n===r)return!0;if(!n||!r)return!1;var a=Object.keys(n),i=Object.keys(r);if(a.length!==i.length)return!1;for(var o=a.length,c=0;c<o;c++){var s=a[c];if(n[s]!==r[s])return!1}return!0}function g(e){var t=e.formats.slice();return t.forEach((function(e,n){var r=t[n-1];if(r){var a=e.slice();a.forEach((function(e,t){var n=r[t];b(e,n)&&(a[t]=n)})),t[n]=a}})),Object(o.a)({},e,{formats:t})}function y(e,t,n){return(e=e.slice())[t]=n,e}function O(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,i=e.activeFormats,s=a.slice();if(n===r){var l=Object(c.find)(s[n],{type:t.type});if(l){for(var u=s[n].indexOf(l);s[n]&&s[n][u]===l;)s[n]=y(s[n],u,t),n--;for(r++;s[r]&&s[r][u]===l;)s[r]=y(s[r],u,t),r++}}else{for(var f=1/0,d=n;d<r;d++)if(s[d]){s[d]=s[d].filter((function(e){return e.type!==t.type}));var p=s[d].length;p<f&&(f=p)}else s[d]=[],f=0;for(var h=n;h<r;h++)s[h].splice(f,0,t)}return g(Object(o.a)({},e,{formats:s,activeFormats:[].concat(Object(v.a)(Object(c.reject)(i,{type:t.type})),[t])}))}var T=n("U8pU");function x(e,t){var n=e.implementation;return x.body||(x.body=n.createHTMLDocument("").body),x.body.innerHTML=t,x.body}var j="\u2028",E=window.Node,_=E.TEXT_NODE,C=E.ELEMENT_NODE;function w(e,t){for(var n in e)if(e[n]===t)return n}function F(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.element,n=e.text,r=e.html,a=e.range,i=e.multilineTag,o=e.multilineWrapperTags,c=e.__unstableIsEditableTree;return"string"==typeof n&&n.length>0?{formats:Array(n.length),replacements:Array(n.length),text:n}:("string"==typeof r&&r.length>0&&(t=x(document,r)),"object"!==Object(T.a)(t)?{formats:[],replacements:[],text:""}:i?k({element:t,range:a,multilineTag:i,multilineWrapperTags:o,isEditableTree:c}):R({element:t,range:a,isEditableTree:c}))}function S(e,t,n,r){if(n){var a=t.parentNode,i=n.startContainer,o=n.startOffset,c=n.endContainer,s=n.endOffset,l=e.text.length;void 0!==r.start?e.start=l+r.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+r.text.length:t===i&&(e.start=l),void 0!==r.end?e.end=l+r.end:t===c&&t.nodeType===_?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)}}var N=new RegExp("\ufeff","g");function A(e){return e.replace(/[\n\r\t]+/g," ").replace(N,"")}function R(e){var t=e.element,n=e.range,r=e.multilineTag,a=e.multilineWrapperTags,c=e.currentWrapperTags,s=void 0===c?[]:c,l=e.isEditableTree,u={formats:[],replacements:[],text:""};if(!t)return u;if(!t.hasChildNodes())return S(u,t,n,{formats:[],replacements:[],text:""}),u;for(var f=t.childNodes.length,d=function(e){var c=t.childNodes[e],f=c.nodeName.toLowerCase();if(c.nodeType===_){var d=A(c.nodeValue);return n=function(e,t,n){if(t){var r=t.startContainer,a=t.endContainer,i=t.startOffset,o=t.endOffset;return e===r&&(i=n(e.nodeValue.slice(0,i)).length),e===a&&(o=n(e.nodeValue.slice(0,o)).length),{startContainer:r,startOffset:i,endContainer:a,endOffset:o}}}(c,n,A),S(u,c,n,{text:d}),u.formats.length+=d.length,u.replacements.length+=d.length,u.text+=d,"continue"}if(c.nodeType!==C)return"continue";if(l&&(c.getAttribute("data-rich-text-placeholder")||"br"===f&&!c.getAttribute("data-rich-text-line-break")))return S(u,c,n,{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 S(u,c,n,p),D(u,p),"continue"}if("script"===f){var h={formats:[,],replacements:[{type:f,attributes:{"data-rich-text-script":c.getAttribute("data-rich-text-script")||encodeURIComponent(c.innerHTML)}}],text:""};return S(u,c,n,h),D(u,h),"continue"}if("br"===f)return S(u,c,n,{formats:[],replacements:[],text:""}),D(u,F({text:"\n"})),"continue";var m=u.formats[u.formats.length-1],g=m&&m[m.length-1],y=function(e){var t,n=e.type,r=e.attributes;if(r&&r.class&&(t=Object(i.select)("core/rich-text").getFormatTypeForClassName(r.class))&&(r.class=" ".concat(r.class," ").replace(" ".concat(t.className," ")," ").trim(),r.class||delete r.class),t||(t=Object(i.select)("core/rich-text").getFormatTypeForBareElement(n)),!t)return r?{type:n,attributes:r}:{type:n};if(t.__experimentalCreatePrepareEditableTree&&!t.__experimentalCreateOnChangeEditableValue)return null;if(!r)return{type:t.name};var a={},o={};for(var c in r){var s=w(t.attributes,c);s?a[s]=r[c]:o[c]=r[c]}return{type:t.name,attributes:a,unregisteredAttributes:o}}({type:f,attributes:P({element:c})}),O=b(y,g)?g:y;if(a&&-1!==a.indexOf(f)){var T=k({element:c,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:[].concat(Object(v.a)(s),[O]),isEditableTree:l});return S(u,c,n,T),D(u,T),"continue"}var x=R({element:c,range:n,multilineTag:r,multilineWrapperTags:a,isEditableTree:l});S(u,c,n,x),O?0===x.text.length?O.attributes&&D(u,{formats:[,],replacements:[O],text:""}):D(u,Object(o.a)({},x,{formats:Array.from(x.formats,(function(e){return e?[O].concat(Object(v.a)(e)):[O]}))})):D(u,x)},p=0;p<f;p++)d(p);return u}function k(e){var t=e.element,n=e.range,r=e.multilineTag,a=e.multilineWrapperTags,i=e.currentWrapperTags,o=void 0===i?[]:i,c=e.isEditableTree,s={formats:[],replacements:[],text:""};if(!t||!t.hasChildNodes())return s;for(var l=t.children.length,u=0;u<l;u++){var f=t.children[u];if(f.nodeName.toLowerCase()===r){var d=R({element:f,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:o,isEditableTree:c});(0!==u||o.length>0)&&D(s,{formats:[,],replacements:o.length>0?[o]:[,],text:j}),S(s,f,n,d),D(s,d)}}return s}function P(e){var t=e.element;if(t.hasAttributes()){for(var n,r=t.attributes.length,a=0;a<r;a++){var i=t.attributes[a],o=i.name,c=i.value;if(0!==o.indexOf("data-rich-text-"))(n=n||{})[/^on/i.test(o)?"data-disable-rich-text-"+o:o]=c}return n}}function D(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function I(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g(t.reduce(D,F()))}function L(e){var t=e.formats,n=e.start,r=e.end,a=e.activeFormats;if(void 0===n)return[];if(n===r){if(a)return a;var i=t[n-1]||[],o=t[n]||[];return i.length<o.length?i:o}return t[n]||[]}function M(e,t){return Object(c.find)(L(e),{type:t})}function H(e){var t=e.start,n=e.end,r=e.replacements,a=e.text;if(t+1===n&&""===a[t])return r[t]}function U(e){return e.text}function K(e){for(var t=e.start,n=e.text,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,a=r;a--;)if(n[a]===j)return a}function B(e){var t=e.replacements[K(e,e.start)];return!t||t.length<1}function W(e,t,n){var r=e.replacements[K(e,e.start)];return r&&0!==r.length?r[r.length-1].type===t:t===n}function V(e){var t=e.start,n=e.end;if(void 0!==t&&void 0!==n)return t===n}function q(e){return 0===e.text.length}function z(e){var t=e.text,n=e.start,r=e.end;return n===r&&(0===t.length||(0===n&&t.slice(0,1)===j||(n===t.length&&t.slice(-1)===j||t.slice(n-1,r+1)==="".concat(j).concat(j))))}function G(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof t&&(t=F({text:t})),g(e.reduce((function(e,n){var r=n.formats,a=n.replacements,i=n.text;return{formats:e.formats.concat(t.formats,r),replacements:e.replacements.concat(t.replacements,a),text:e.text+t.text+i}})))}var Y=n("GRId"),X=n("g56x"),Q=n("K9lf");function J(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 n=Object(i.select)("core/rich-text").getFormatTypeForBareElement(t.tagName);if(n)return void window.console.error('Format "'.concat(n.name,'" is already registered to handle bare tag name "').concat(t.tagName,'".'))}else{var r=Object(i.select)("core/rich-text").getFormatTypeForClassName(t.className);if(r)return void window.console.error('Format "'.concat(r.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)return Object(i.dispatch)("core/rich-text").addFormatTypes(t),t.__experimentalCreatePrepareEditableTree&&Object(X.addFilter)("experimentalRichText",e,(function(n){var r="format_prepare_props_(".concat(e,")_"),a="format_on_change_props_(".concat(e,")_"),s=function(i){var c=Object(o.a)({},i),s=Object.keys(i).reduce((function(e,t){return t.startsWith(r)&&(e[t.slice(r.length)]=i[t]),t.startsWith(a)&&(e[t.slice(a.length)]=i[t]),e}),{}),l={richTextIdentifier:i.identifier,blockClientId:i.clientId};return t.__experimentalCreateOnChangeEditableValue?(c["format_value_functions_(".concat(e,")")]=t.__experimentalCreatePrepareEditableTree(s,l),c["format_on_change_functions_(".concat(e,")")]=t.__experimentalCreateOnChangeEditableValue(s,l)):c["format_prepare_functions_(".concat(e,")")]=t.__experimentalCreatePrepareEditableTree(s,l),Object(Y.createElement)(n,c)},l=[];return t.__experimentalGetPropsForEditableTreePreparation&&l.push(Object(i.withSelect)((function(e,n){var a=n.clientId,i=n.identifier;return Object(c.mapKeys)(t.__experimentalGetPropsForEditableTreePreparation(e,{richTextIdentifier:i,blockClientId:a}),(function(e,t){return r+t}))}))),t.__experimentalGetPropsForEditableTreeChangeHandler&&l.push(Object(i.withDispatch)((function(e,n){var r=n.clientId,i=n.identifier;return Object(c.mapKeys)(t.__experimentalGetPropsForEditableTreeChangeHandler(e,{richTextIdentifier:i,blockClientId:r}),(function(e,t){return a+t}))}))),l.length?Object(Q.compose)(l)(s):s})),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 Z(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,i=e.activeFormats,s=a.slice();if(n===r){var l=Object(c.find)(s[n],{type:t});if(l){for(;Object(c.find)(s[n],l);)$(s,n,t),n--;for(r++;Object(c.find)(s[r],l);)$(s,r,t),r++}}else for(var u=n;u<r;u++)s[u]&&$(s,u,t);return g(Object(o.a)({},e,{formats:s,activeFormats:Object(c.reject)(i,{type:t})}))}function $(e,t,n){var r=e[t].filter((function(e){return e.type!==n}));r.length?e[t]=r:delete e[t]}function ee(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,i=e.replacements,o=e.text;"string"==typeof t&&(t=F({text:t}));var c=n+t.text.length;return g({formats:a.slice(0,n).concat(t.formats,a.slice(r)),replacements:i.slice(0,n).concat(t.replacements,i.slice(r)),text:o.slice(0,n)+t.text+o.slice(r),start:c,end:c})}function te(e,t,n){return ee(e,F(),t,n)}function ne(e,t,n){var r=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),s=1;s<t;s++)i[s-1]=arguments[s];var l,u,f=i[i.length-2],d=n;return"function"==typeof d&&(d=n.apply(void 0,[e].concat(i))),"object"===Object(T.a)(d)?(l=d.formats,u=d.replacements,d=d.text):(l=Array(d.length),u=Array(d.length),r[f]&&(l=l.fill(r[f]))),r=r.slice(0,f).concat(l,r.slice(f+e.length)),a=a.slice(0,f).concat(u,a.slice(f+e.length)),o&&(o=c=f+d.length),d})),g({formats:r,replacements:a,text:i,start:o,end:c})}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,r=U(e).slice(0,t),a=r.lastIndexOf(j),i=e.replacements[a],o=[,];i&&(o=[i]);var c={formats:[,],replacements:o,text:j};return ee(e,c,t,n)}function ae(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.replacements,r=e.text,a=e.start,i=e.end,c=V(e),s=a-1,l=c?a-1:a,u=i;if(t||(s=i,l=a,u=c?i+1:i),r[s]===j){var f;if(c&&n[s]&&n[s].length){var d=n.slice();d[s]=n[s].slice(0,-1),f=Object(o.a)({},e,{replacements:d})}else f=te(e,l,u);return f}}function ie(e,t,n,r){return ee(e,{formats:[,],replacements:[t],text:""},n,r)}function oe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,r=e.formats,a=e.replacements,i=e.text;return void 0===t||void 0===n?Object(o.a)({},e):{formats:r.slice(t,n),replacements:a.slice(t,n),text:i.slice(t,n)}}function ce(e,t){var n=e.formats,r=e.replacements,a=e.text,i=e.start,o=e.end;if("string"!=typeof t)return se.apply(void 0,arguments);var c=0;return a.split(t).map((function(e){var a=c,s={formats:n.slice(a,a+e.length),replacements:r.slice(a,a+e.length),text:e};return c+=t.length+e.length,void 0!==i&&void 0!==o&&(i>=a&&i<c?s.start=i-a:i<a&&o>a&&(s.start=0),o>=a&&o<c?s.end=o-a:i<c&&o>c&&(s.end=e.length)),s}))}function se(e){var t=e.formats,n=e.replacements,r=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,s={formats:t.slice(0,o),replacements:n.slice(0,o),text:r.slice(0,o)},l={formats:t.slice(c),replacements:n.slice(c),text:r.slice(c),start:0,end:0};return[ne(s,/\u2028+$/,""),ne(l,/^\u2028+/,"")]}function le(e,t){if(t)return e;var n={};for(var r in e){var a=r;r.startsWith("data-disable-rich-text-")&&(a=r.slice("data-disable-rich-text-".length)),n[a]=e[r]}return n}function ue(e){var t=e.type,n=e.attributes,r=e.unregisteredAttributes,a=e.object,c=e.boundaryClass,s=e.isEditableTree,l=function(e){return Object(i.select)("core/rich-text").getFormatType(e)}(t),u={};if(c&&(u["data-rich-text-format-boundary"]="true"),!l)return n&&(u=Object(o.a)({},n,u)),{type:t,attributes:le(u,s),object:a};for(var f in u=Object(o.a)({},r,u),n){var d=!!l.attributes&&l.attributes[f];d?u[d]=n[f]:u[f]=n[f]}return l.className&&(u.class?u.class="".concat(l.className," ").concat(u.class):u.class=l.className),{type:l.tagName,object:l.object,attributes:le(u,s)}}function fe(e){var t,n,r,a=e.value,i=e.multilineTag,c=e.createEmpty,s=e.append,l=e.getLastChild,u=e.getParent,f=e.isText,d=e.getText,p=e.remove,h=e.appendText,m=e.onStartIndex,b=e.onEndIndex,g=e.isEditableTree,y=e.placeholder,O=a.formats,T=a.replacements,x=a.text,E=a.start,_=a.end,C=O.length+1,w=c(),F={type:i},S=L(a),N=S[S.length-1];i?(s(s(w,{type:i}),""),n=t=[F]):s(w,"");for(var A=function(e){var a=x.charAt(e),c=g&&(!r||r===j||"\n"===r),C=O[e];i&&(C=a===j?t=(T[e]||[]).reduce((function(e,t){return e.push(t,F),e}),[F]):[].concat(Object(v.a)(t),Object(v.a)(C||[])));var S=l(w);if(c&&a===j){for(var A=S;!f(A);)A=l(A);s(u(A),"\ufeff")}if(r===j){for(var R=S;!f(R);)R=l(R);m&&E===e&&m(w,R),b&&_===e&&b(w,R)}if(C&&C.forEach((function(e,t){if(!S||!n||e!==n[t]||a===j&&C.length-1===t){var r=e.type,i=e.attributes,o=e.unregisteredAttributes,c=g&&a!==j&&e===N,h=u(S),m=s(h,ue({type:r,attributes:i,unregisteredAttributes:o,boundaryClass:c,isEditableTree:g}));f(S)&&0===d(S).length&&p(S),S=s(m,"")}else S=l(S)})),a===j)return n=C,r=a,"continue";0===e&&(m&&0===E&&m(w,S),b&&0===_&&b(w,S)),""===a?(g||"script"!==T[e].type?S=s(u(S),ue(Object(o.a)({},T[e],{object:!0,isEditableTree:g}))):(S=s(u(S),ue({type:"script",isEditableTree:g})),s(S,{html:decodeURIComponent(T[e].attributes["data-rich-text-script"])})),S=s(u(S),"")):"\n"===a?(S=s(u(S),{type:"br",attributes:g?{"data-rich-text-line-break":"true"}:void 0,object:!0}),S=s(u(S),"")):f(S)?h(S,a):S=s(u(S),a),m&&E===e+1&&m(w,S),b&&_===e+1&&b(w,S),c&&e===x.length&&(s(u(S),"\ufeff"),y&&0===x.length&&s(u(S),{type:"span",attributes:{"data-rich-text-placeholder":y,contenteditable:"false"}})),n=C,r=a},R=0;R<C;R++)A(R);return w}var de=window.Node.TEXT_NODE;function pe(e,t,n){for(var r=e.parentNode,a=0;e=e.previousSibling;)a++;return n=[a].concat(Object(v.a)(n)),r!==t&&(n=pe(r,t,n)),n}function he(e,t){for(t=Object(v.a)(t);e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}var me=function(){return x(document,"")};function ve(e,t){"string"==typeof t&&(t=e.ownerDocument.createTextNode(t));var n=t,r=n.type,a=n.attributes;if(r)for(var i in t=e.ownerDocument.createElement(r),a)t.setAttribute(i,a[i]);return e.appendChild(t)}function be(e,t){e.appendData(t)}function ge(e){return e.lastChild}function ye(e){return e.parentNode}function Oe(e){return e.nodeType===de}function Te(e){return e.nodeValue}function xe(e){return e.parentNode.removeChild(e)}function je(e){var t=e.value,n=e.multilineTag,r=e.prepareEditableTree,a=e.isEditableTree,i=void 0===a||a,c=e.placeholder,s=[],l=[];return r&&(t=Object(o.a)({},t,{formats:r(t)})),{body:fe({value:t,multilineTag:n,createEmpty:me,append:ve,getLastChild:ge,getParent:ye,isText:Oe,getText:Te,remove:xe,appendText:be,onStartIndex:function(e,t){s=pe(t,e,[t.nodeValue.length])},onEndIndex:function(e,t){l=pe(t,e,[t.nodeValue.length])},isEditableTree:i,placeholder:c}),selection:{startPath:s,endPath:l}}}function Ee(e){var t=e.value,n=e.current,r=e.multilineTag,a=e.prepareEditableTree,i=e.__unstableDomOnly,o=je({value:t,multilineTag:r,prepareEditableTree:a,placeholder:e.placeholder}),c=o.body,s=o.selection;!function e(t,n){var r,a=0;for(;r=t.firstChild;){var i=n.childNodes[a];if(i)if(i.isEqualNode(r))t.removeChild(r);else if(i.nodeName!==r.nodeName||i.nodeType===de&&i.data!==r.data)n.replaceChild(r,i);else{var o=i.attributes,c=r.attributes;if(o)for(var s=o.length;s--;){var l=o[s].name;r.getAttribute(l)||i.removeAttribute(l)}if(c)for(var u=0;u<c.length;u++){var f=c[u],d=(l=f.name,f.value);i.getAttribute(l)!==d&&i.setAttribute(l,d)}e(r,i),t.removeChild(r)}else n.appendChild(r);a++}for(;n.childNodes[a];)n.removeChild(n.childNodes[a])}(c,n),void 0===t.start||i||function(e,t){var n=e.startPath,r=e.endPath,a=he(t,n),i=a.node,o=a.offset,c=he(t,r),s=c.node,l=c.offset,u=window.getSelection(),f=t.ownerDocument,d=f.createRange();d.setStart(i,o),d.setEnd(s,l),f.activeElement!==t&&t.focus();if(u.rangeCount>0){if(p=d,h=u.getRangeAt(0),p.startContainer===h.startContainer&&p.startOffset===h.startOffset&&p.endContainer===h.endContainer&&p.endOffset===h.endOffset)return;u.removeAllRanges()}var p,h;u.addRange(d)}(s,n)}var _e=n("Vx3V");function Ce(e){return Ie(fe({value:e.value,multilineTag:e.multilineTag,createEmpty:we,append:Se,getLastChild:Fe,getParent:Ae,isText:Re,getText:ke,remove:Pe,appendText:Ne}).children)}function we(){return{}}function Fe(e){var t=e.children;return t&&t[t.length-1]}function Se(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Ne(e,t){e.text+=t}function Ae(e){return e.parent}function Re(e){return"string"==typeof e.text}function ke(e){return e.text}function Pe(e){var t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function De(e){var t=e.type,n=e.attributes,r=e.object,a=e.children,i="";for(var o in n)Object(_e.isValidAttributeName)(o)&&(i+=" ".concat(o,'="').concat(Object(_e.escapeAttribute)(n[o]),'"'));return r?"<".concat(t).concat(i,">"):"<".concat(t).concat(i,">").concat(Ie(a),"</").concat(t,">")}function Ie(){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?De(e):Object(_e.escapeHTML)(e.text)})).join("")}function Le(e,t){return M(e,t.type)?Z(e,t.type):O(e,t)}function Me(e){var t=Object(i.select)("core/rich-text").getFormatType(e);if(t)return t.__experimentalCreatePrepareEditableTree&&Object(X.removeFilter)("experimentalRichText",e),Object(i.dispatch)("core/rich-text").removeFormatTypes(e),t;window.console.error("Format ".concat(e," is not registered."))}function He(e,t){var n=K(e);if(void 0===n)return e;var r=e.text,a=e.replacements,i=e.end,c=K(e,n),s=a[n]||[],l=a[c]||[];if(s.length>l.length)return e;for(var u=a.slice(),f=function(e,t){for(var n=e.text,r=e.replacements,a=r[t]||[],i=t;i-- >=0;)if(n[i]===j){var o=r[i]||[];if(o.length===a.length+1)return i;if(o.length<=a.length)return}}(e,n),d=n;d<i;d++)if(r[d]===j)if(f){var p=a[f]||[];u[d]=p.concat((u[d]||[]).slice(p.length-1))}else{var h=a[c]||[],m=h[h.length-1]||t;u[d]=h.concat([m],(u[d]||[]).slice(h.length))}return Object(o.a)({},e,{replacements:u})}function Ue(e,t){for(var n=e.text,r=e.replacements,a=r[t]||[],i=t;i-- >=0;){if(n[i]===j)if((r[i]||[]).length===a.length-1)return i}}function Ke(e){var t=e.text,n=e.replacements,r=e.start,a=e.end,i=K(e,r);if(void 0===n[i])return e;for(var c=n.slice(0),s=n[Ue(e,i)]||[],l=function(e,t){for(var n=e.text,r=e.replacements,a=r[t]||[],i=t,o=t||0;o<n.length;o++)if(n[o]===j){if(!((r[o]||[]).length>=a.length))return i;i=o}return i}(e,K(e,a)),u=i;u<=l;u++)if(t[u]===j){var f=c[u]||[];c[u]=s.concat(f.slice(s.length+1)),0===c[u].length&&delete c[u]}return Object(o.a)({},e,{replacements:c})}function Be(e,t){for(var n,r=e.text,a=e.replacements,i=e.start,c=e.end,s=K(e,i),l=a[s]||[],u=a[K(e,c)]||[],f=Ue(e,s),d=a.slice(),p=l.length-1,h=u.length-1,m=f+1||0;m<r.length;m++)if(r[m]===j){if((d[m]||[]).length<=p)break;d[m]&&(n=!0,d[m]=d[m].map((function(e,n){return n<p||n>h?e:t})))}return n?Object(o.a)({},e,{replacements:d}):e}var We=n("wx14"),Ve=n("1OyB"),qe=n("vuIU"),ze=n("md7G"),Ge=n("foSv"),Ye=n("JX7q"),Xe=n("Ji7U"),Qe=n("TSYQ"),Je=n.n(Qe),Ze=n("RxS6"),$e=n("rl8x"),et=n.n($e),tt=n("NMb1"),nt=n.n(tt),rt=new Set(["a","audio","button","details","embed","iframe","input","label","select","textarea","video"]),at=Object(i.withSelect)((function(e){return{formatTypes:e("core/rich-text").getFormatTypes()}}))((function(e){var t=e.formatTypes,n=e.onChange,r=e.value,a=e.allowedFormats,i=e.withoutInteractiveFormatting;return t.map((function(e){var t=e.name,o=e.edit,c=e.tagName;if(!o)return null;if(a&&-1===a.indexOf(t))return null;if(i&&rt.has(c))return null;var s=M(r,t),l=void 0!==s,u=H(r),f=void 0!==u&&u.type===t;return Object(Y.createElement)(o,{key:t,isActive:l,activeAttributes:l&&s.attributes||{},isObjectActive:f,activeObjectAttributes:f&&u.attributes||{},value:r,onChange:n})}))})),it=n("Ff2n"),ot=function(e){return Object(c.pickBy)(e,(function(e,t){return n=t,Object(c.startsWith)(n,"aria-")&&!Object(c.isNil)(e);var n}))},ct=function(e){function t(){var e;return Object(Ve.a)(this,t),(e=Object(ze.a)(this,Object(Ge.a)(t).call(this))).bindEditorNode=e.bindEditorNode.bind(Object(Ye.a)(e)),e}return Object(Xe.a)(t,e),Object(qe.a)(t,[{key:"shouldComponentUpdate",value:function(e){var t=this;Object(c.isEqual)(this.props.style,e.style)||(this.editorNode.setAttribute("style",""),Object.assign(this.editorNode.style,Object(o.a)({},e.style||{},{whiteSpace:"pre-wrap"}))),Object(c.isEqual)(this.props.className,e.className)||(this.editorNode.className=e.className),this.props.start!==e.start&&this.editorNode.setAttribute("start",e.start),this.props.reversed!==e.reversed&&(this.editorNode.reversed=e.reversed);var n=function(e,t){var n=Object(c.keys)(ot(e)),r=Object(c.keys)(ot(t));return{removedKeys:Object(c.difference)(n,r),updatedKeys:r.filter((function(n){return!Object(c.isEqual)(e[n],t[n])}))}}(this.props,e),r=n.removedKeys,a=n.updatedKeys;return r.forEach((function(e){return t.editorNode.removeAttribute(e)})),a.forEach((function(n){return t.editorNode.setAttribute(n,e[n])})),!1}},{key:"bindEditorNode",value:function(e){this.editorNode=e,this.props.setRef(e)}},{key:"render",value:function(){var e=this.props,t=e.tagName,n=void 0===t?"div":t,r=e.style,a=void 0===r?{}:r,i=e.record,c=e.valueToEditableHTML,s=e.className,l=Object(it.a)(e,["tagName","style","record","valueToEditableHTML","className"]);delete l.setRef;return Object(Y.createElement)(n,Object(o.a)({role:"textbox","aria-multiline":!0,className:s,contentEditable:!0,ref:this.bindEditorNode,style:Object(o.a)({},a,{whiteSpace:"pre-wrap"}),suppressContentEditableWarning:!0,dangerouslySetInnerHTML:{__html:c(i)}},l))}}]),t}(Y.Component);var st=window,lt=st.getSelection,ut=st.getComputedStyle,ft=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),dt=document.createElement("style");function pt(e,t){var n=Object.keys(e).reduce((function(n,r){return r.startsWith(t)&&n.push(e[r]),n}),[]);return function(e){return n.reduce((function(t,n){return n(t,e.text)}),e.formats)}}document.head.appendChild(dt);var ht=function(e){function t(e){var n,r=e.value,a=e.selectionStart,i=e.selectionEnd;return Object(Ve.a)(this,t),(n=Object(ze.a)(this,Object(Ge.a)(t).apply(this,arguments))).onFocus=n.onFocus.bind(Object(Ye.a)(n)),n.onBlur=n.onBlur.bind(Object(Ye.a)(n)),n.onChange=n.onChange.bind(Object(Ye.a)(n)),n.handleDelete=n.handleDelete.bind(Object(Ye.a)(n)),n.handleEnter=n.handleEnter.bind(Object(Ye.a)(n)),n.handleSpace=n.handleSpace.bind(Object(Ye.a)(n)),n.handleHorizontalNavigation=n.handleHorizontalNavigation.bind(Object(Ye.a)(n)),n.onPaste=n.onPaste.bind(Object(Ye.a)(n)),n.onCreateUndoLevel=n.onCreateUndoLevel.bind(Object(Ye.a)(n)),n.onInput=n.onInput.bind(Object(Ye.a)(n)),n.onCompositionEnd=n.onCompositionEnd.bind(Object(Ye.a)(n)),n.onSelectionChange=n.onSelectionChange.bind(Object(Ye.a)(n)),n.createRecord=n.createRecord.bind(Object(Ye.a)(n)),n.applyRecord=n.applyRecord.bind(Object(Ye.a)(n)),n.valueToFormat=n.valueToFormat.bind(Object(Ye.a)(n)),n.setRef=n.setRef.bind(Object(Ye.a)(n)),n.valueToEditableHTML=n.valueToEditableHTML.bind(Object(Ye.a)(n)),n.onPointerDown=n.onPointerDown.bind(Object(Ye.a)(n)),n.formatToValue=n.formatToValue.bind(Object(Ye.a)(n)),n.Editable=n.Editable.bind(Object(Ye.a)(n)),n.onKeyDown=function(e){e.defaultPrevented||(n.handleDelete(e),n.handleEnter(e),n.handleSpace(e),n.handleHorizontalNavigation(e))},n.state={},n.lastHistoryValue=r,n.value=r,n.record=n.formatToValue(r),n.record.start=a,n.record.end=i,n}return Object(Xe.a)(t,e),Object(qe.a)(t,[{key:"componentWillUnmount",value:function(){document.removeEventListener("selectionchange",this.onSelectionChange),window.cancelAnimationFrame(this.rafId)}},{key:"setRef",value:function(e){e?this.editableRef=e:delete this.editableRef}},{key:"createRecord",value:function(){var e=this.props.__unstableMultilineTag,t=lt(),n=t.rangeCount>0?t.getRangeAt(0):null;return F({element:this.editableRef,range:n,multilineTag:e,multilineWrapperTags:"li"===e?["ul","ol"]:void 0,__unstableIsEditableTree:!0})}},{key:"applyRecord",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.domOnly,r=this.props.__unstableMultilineTag;Ee({value:e,current:this.editableRef,multilineTag:r,multilineWrapperTags:"li"===r?["ul","ol"]:void 0,prepareEditableTree:pt(this.props,"format_prepare_functions"),__unstableDomOnly:n,placeholder:this.props.placeholder})}},{key:"onPaste",value:function(e){var t=this.props,n=t.formatTypes,r=t.onPaste,a=e.clipboardData,i=a.items,o=a.files;i=Object(c.isNil)(i)?[]:i,o=Object(c.isNil)(o)?[]:o;var s="",l="";try{s=a.getData("text/plain"),l=a.getData("text/html")}catch(e){try{l=a.getData("Text")}catch(e){return}}e.preventDefault(),window.console.log("Received HTML:\n\n",l),window.console.log("Received plain text:\n\n",s);var u=this.record,f=n.reduce((function(e,t){var n=t.__unstablePasteRule;return n&&e===u&&(e=n(u,{html:l,plainText:s})),e}),u);if(f===u){if(r){var d=Object(c.find)([].concat(Object(v.a)(i),Object(v.a)(o)),(function(e){var t=e.type;return/^image\/(?:jpe?g|png|gif)$/.test(t)}));r({value:this.removeEditorOnlyFormats(u),onChange:this.onChange,html:l,plainText:s,image:d})}}else this.onChange(f)}},{key:"onFocus",value:function(){var e=this.props.unstableOnFocus;e&&e(),this.recalculateBoundaryStyle();this.record=Object(o.a)({},this.record,{start:void 0,end:void 0,activeFormats:void 0}),this.props.onSelectionChange(void 0,void 0),this.setState({activeFormats:void 0}),this.rafId=window.requestAnimationFrame(this.onSelectionChange),document.addEventListener("selectionchange",this.onSelectionChange),this.props.setFocusedElement&&(nt()("wp.blockEditor.RichText setFocusedElement prop",{alternative:"selection state from the block editor store."}),this.props.setFocusedElement(this.props.instanceId))}},{key:"onBlur",value:function(){document.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"onInput",value:function(e){var t;if(e&&e.nativeEvent&&e.nativeEvent.isComposing)document.removeEventListener("selectionchange",this.onSelectionChange);else if(e&&(t=e.inputType),t||(t=e.nativeEvent.inputType),!t||0!==t.indexOf("format")&&!ft.has(t)){var n=this.createRecord(),r=this.record,a=r.start,i=r.activeFormats,c=void 0===i?[]:i,s=function(e){var t=e.value,n=e.start,r=e.end,a=e.formats,i=t.formats[n-1]||[],o=t.formats[r]||[];for(t.activeFormats=a.map((function(e,t){if(i[t]){if(b(e,i[t]))return i[t]}else if(o[t]&&b(e,o[t]))return o[t];return e}));--r>=n;)t.activeFormats.length>0?t.formats[r]=t.activeFormats:delete t.formats[r];return t}({value:n,start:a,end:n.start,formats:c});this.onChange(s,{withoutHistory:!0});var l=this.props,u=l.__unstableInputRule,f=l.__unstableMarkAutomaticChange,d=l.formatTypes,p=l.setTimeout;if((0,l.clearTimeout)(this.onInput.timeout),this.onInput.timeout=p(this.onCreateUndoLevel,1e3),"insertText"===t){u&&u(s,this.valueToFormat);var h=d.reduce((function(e,t){var n=t.__unstableInputRule;return n&&(e=n(e)),e}),s);h!==s&&(this.onCreateUndoLevel(),this.onChange(Object(o.a)({},h,{activeFormats:c})),f())}}else this.applyRecord(this.record)}},{key:"onCompositionEnd",value:function(){this.onInput({inputType:"insertText"}),document.addEventListener("selectionchange",this.onSelectionChange)}},{key:"onSelectionChange",value:function(e){if(("selectionchange"===e.type||this.props.__unstableIsSelected)&&(!e.nativeEvent||!e.nativeEvent.isComposing)){var t=this.createRecord(),n=t.start,r=t.end,a=t.text,i=this.record;if(a===i.text)if(n!==i.start||r!==i.end){var c=this.props,s=c.__unstableIsCaretWithinFormattedText,l=c.__unstableOnEnterFormattedText,u=c.__unstableOnExitFormattedText,f=Object(o.a)({},i,{start:n,end:r,activeFormats:void 0}),d=L(f);f.activeFormats=d,!s&&d.length?l():s&&!d.length&&u(),this.record=f,this.applyRecord(f,{domOnly:!0}),this.props.onSelectionChange(n,r),this.setState({activeFormats:d}),d.length>0&&this.recalculateBoundaryStyle()}else 0===i.text.length&&0===n&&function(){var e=window.getSelection(),t=e.anchorNode,n=e.anchorOffset;if(t.nodeType===t.ELEMENT_NODE){var r=t.childNodes[n];r&&r.nodeType===r.ELEMENT_NODE&&r.getAttribute("data-rich-text-placeholder")&&e.collapseToStart()}}();else this.onInput()}}},{key:"recalculateBoundaryStyle",value:function(){var e=this.editableRef.querySelector("*[data-rich-text-format-boundary]");if(e){var t=ut(e).color.replace(")",", 0.2)").replace("rgb","rgba"),n=".rich-text:focus ".concat("*[data-rich-text-format-boundary]"),r="background-color: ".concat(t);dt.innerHTML="".concat(n," {").concat(r,"}")}}},{key:"onChange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.withoutHistory;this.applyRecord(e);var r=e.start,a=e.end,i=e.activeFormats,o=void 0===i?[]:i,s=Object(c.pickBy)(this.props,(function(e,t){return t.startsWith("format_on_change_functions_")}));Object.values(s).forEach((function(t){t(e.formats,e.text)})),this.value=this.valueToFormat(e),this.record=e,this.props.onChange(this.value),this.props.onSelectionChange(r,a),this.setState({activeFormats:o}),n||this.onCreateUndoLevel()}},{key:"onCreateUndoLevel",value:function(){this.lastHistoryValue!==this.value&&(this.props.__unstableOnCreateUndoLevel(),this.lastHistoryValue=this.value)}},{key:"handleDelete",value:function(e){var t=e.keyCode;if(t===Ze.DELETE||t===Ze.BACKSPACE||t===Ze.ESCAPE){if(this.props.__unstableDidAutomaticChange)return e.preventDefault(),void this.props.__unstableUndo();if(t!==Ze.ESCAPE){var n=this.props,r=n.onDelete,a=n.__unstableMultilineTag,i=this.state.activeFormats,o=void 0===i?[]:i,c=this.createRecord(),s=c.start,l=c.end,u=c.text,f=t===Ze.BACKSPACE;if(a){var d=ae(c,f);d&&(this.onChange(d),e.preventDefault())}if(0===s&&0!==l&&l===u.length)return this.onChange(te(c)),void e.preventDefault();!r||!V(c)||o.length||f&&0!==s||!f&&l!==u.length||(r({isReverse:f,value:c}),e.preventDefault())}}}},{key:"handleEnter",value:function(e){if(e.keyCode===Ze.ENTER){e.preventDefault();var t=this.props.onEnter;t&&t({value:this.removeEditorOnlyFormats(this.createRecord()),onChange:this.onChange,shiftKey:e.shiftKey})}}},{key:"handleSpace",value:function(e){var t=e.keyCode,n=e.shiftKey,r=e.altKey,a=e.metaKey,i=e.ctrlKey,o=this.props,c=o.tagName,s=o.__unstableMultilineTag;if(!(n||r||a||i||t!==Ze.SPACE||"li"!==s)){var l=this.createRecord();if(V(l)){var u=l.text[l.start-1];u&&u!==j||(this.onChange(He(l,{type:c})),e.preventDefault())}}}},{key:"handleHorizontalNavigation",value:function(e){var t=this,n=e.keyCode,r=e.shiftKey,a=e.altKey,i=e.metaKey,c=e.ctrlKey;if(!(r||a||i||c||n!==Ze.LEFT&&n!==Ze.RIGHT)){var s=this.record,l=s.text,u=s.formats,f=s.start,d=s.end,p=s.activeFormats,h=void 0===p?[]:p,m=V(s),v="rtl"===ut(this.editableRef).direction?Ze.RIGHT:Ze.LEFT,b=e.keyCode===v;if(m&&0===h.length){if(0===f&&b)return;if(d===l.length&&!b)return}if(m){e.preventDefault();var g=u[f-1]||[],y=u[f]||[],O=h.length,T=y;if(g.length>y.length&&(T=g),g.length<y.length?(!b&&h.length<y.length&&O++,b&&h.length>g.length&&O--):g.length>y.length&&(!b&&h.length>y.length&&O--,b&&h.length<g.length&&O++),this.props.setTimeout((function(){return t.recalculateBoundaryStyle()})),O!==h.length){var x=T.slice(0,O),j=Object(o.a)({},s,{activeFormats:x});return this.record=j,this.applyRecord(j),void this.setState({activeFormats:x})}var E=f+(b?-1:1),_=b?g:y,C=Object(o.a)({},s,{start:E,end:E,activeFormats:_});this.record=C,this.applyRecord(C),this.props.onSelectionChange(E,E),this.setState({activeFormats:_})}}}},{key:"onPointerDown",value:function(e){var t=e.target;if(t!==this.editableRef&&!t.textContent){var n=t.parentNode,r=Array.from(n.childNodes).indexOf(t),a=t.ownerDocument.createRange(),i=lt();a.setStart(t.parentNode,r),a.setEnd(t.parentNode,r+1),i.removeAllRanges(),i.addRange(a)}}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.tagName,r=t.value,a=t.selectionStart,i=t.selectionEnd,s=t.placeholder,l=t.__unstableIsSelected,u=n===e.tagName&&r!==e.value&&r!==this.value;u=u||l&&!e.isSelected&&(this.record.start!==a||this.record.end!==i);var f=function(e,t){return t.startsWith("format_prepare_props_")},d=Object(c.pickBy)(this.props,f),p=Object(c.pickBy)(e,f);(u=(u=u||!et()(d,p))||s!==e.placeholder)?(this.value=r,this.record=this.formatToValue(r),this.record.start=a,this.record.end=i,this.applyRecord(this.record)):this.record.start===a&&this.record.end===i||(this.record=Object(o.a)({},this.record,{start:a,end:i}))}},{key:"formatToValue",value:function(e){var t=this.props,n=t.format,r=t.__unstableMultilineTag;if("string"!==n)return e;var a=pt(this.props,"format_value_functions");return(e=F({html:e,multilineTag:r,multilineWrapperTags:"li"===r?["ul","ol"]:void 0})).formats=a(e),e}},{key:"valueToEditableHTML",value:function(e){return je({value:e,multilineTag:this.props.__unstableMultilineTag,prepareEditableTree:pt(this.props,"format_prepare_functions"),placeholder:this.props.placeholder}).body.innerHTML}},{key:"removeEditorOnlyFormats",value:function(e){return this.props.formatTypes.forEach((function(t){t.__experimentalCreatePrepareEditableTree&&(e=Z(e,t.name,0,e.text.length))})),e}},{key:"valueToFormat",value:function(e){var t=this.props,n=t.format,r=t.__unstableMultilineTag;if(e=this.removeEditorOnlyFormats(e),"string"===n)return Ce({value:e,multilineTag:r})}},{key:"Editable",value:function(e){var t=this,n=this.props,r=n.tagName,a=void 0===r?"div":r,i=n.style,o=n.className,c=n.placeholder,s=a;return Object(Y.createElement)(ct,Object(We.a)({},e,{tagName:a,style:i,record:this.record,valueToEditableHTML:this.valueToEditableHTML,"aria-label":c},ot(this.props),{className:Je()("rich-text",o),key:s,onPaste:this.onPaste,onInput:this.onInput,onCompositionEnd:this.onCompositionEnd,onKeyDown:e.onKeyDown?function(n){e.onKeyDown(n),t.onKeyDown(n)}:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,onMouseDown:this.onPointerDown,onTouchStart:this.onPointerDown,setRef:this.setRef,onKeyUp:this.onSelectionChange,onMouseUp:this.onSelectionChange,onTouchEnd:this.onSelectionChange}))}},{key:"render",value:function(){var e=this.props,t=e.__unstableIsSelected,n=e.children,r=e.allowedFormats,a=e.withoutInteractiveFormatting;return Object(Y.createElement)(Y.Fragment,null,t&&Object(Y.createElement)(at,{allowedFormats:r,withoutInteractiveFormatting:a,value:this.record,onChange:this.onChange}),n&&n({isSelected:t,value:this.record,onChange:this.onChange,Editable:this.Editable}),!n&&Object(Y.createElement)(this.Editable,null))}}]),t}(Y.Component);ht.defaultProps={format:"string",value:""};var mt=Object(Q.compose)([Object(i.withSelect)((function(e){return{formatTypes:e("core/rich-text").getFormatTypes()}})),Q.withSafeTimeout])(ht)}});
Save Changes
Rename File
Rename