mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-30 07:20:01 +01:00
114bff87cf
- [Block Library - Query Pagination Next]: Hide block if custom query has no results - [WP 5.9] Fix: HTML tags like inline images in nav links break submenu layout - Check for nextpage to display page links for paginated posts - Navigation: Set the default for --navigation-layout-align to "flex-start" when using vertical orientation - [Block Library - Query Loop]: Use gap for the grid view - Update page list flex variables to match navigation. - Site logo: Fix range control on landscape logo - Restore canvas padding for classic themes - RichText: Fix dead key input on Windows - Fix: Impossible to clear colors if color palettes are removed. - Gallery block: pass any custom attributes through the gallery v2 migration script - Reduce specificity of legacy font sizes defined by core - Update: Improve escaping on the search block See #54487. Props isabel_brison. Built from https://develop.svn.wordpress.org/trunk@52551 git-svn-id: http://core.svn.wordpress.org/trunk@52141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
36 KiB
JavaScript
2 lines
36 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 o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.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 o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));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,o;function a(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={},o="undefined"!=typeof WeakMap,t.a=function(e,t){var n,s;function l(){n=o?new WeakMap:i()}function u(){var n,r,o,a,i,l=arguments.length;for(a=new Array(l),o=0;o<l;o++)a[o]=arguments[o];for(i=t.apply(null,a),(n=s(i)).isUniqueByDependants||(n.lastDependants&&!c(i,n.lastDependants,0)&&n.clear(),n.lastDependants=i),r=n.head;r;){if(c(r.args,a,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,a)},a[0]=null,r.args=a,n.head&&(n.head.prev=r,r.next=n.head),n.head=r,r.val}return t||(t=a),s=o?function(e){var t,o,a,c,s,l=n,u=!0;for(t=0;t<e.length;t++){if(o=e[t],!(s=o)||"object"!=typeof s){u=!1;break}l.has(o)?l=l.get(o):(a=new WeakMap,l.set(o,a),l=a)}return l.has(r)||((c=i()).isUniqueByDependants=u,l.set(r,c)),l.get(r)}:function(){return n},u.getDependants=t,u.clear=l,l(),u}},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 S})),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 Ae})),n.d(t,"__UNSTABLE_LINE_SEPARATOR",(function(){return T})),n.d(t,"unregisterFormatType",(function(){return Se})),n.d(t,"__unstableCanIndentListItems",(function(){return Ne})),n.d(t,"__unstableCanOutdentListItems",(function(){return De})),n.d(t,"__unstableIndentListItems",(function(){return ke})),n.d(t,"__unstableOutdentListItems",(function(){return Me})),n.d(t,"__unstableChangeListType",(function(){return Pe})),n.d(t,"__unstableCreateElement",(function(){return x})),n.d(t,"useAnchorRef",(function(){return $e})),n.d(t,"__experimentalRichText",(function(){return Qe})),n.d(t,"__unstableUseRichText",(function(){return Je})),n.d(t,"__unstableFormatEdit",(function(){return et}));var r={};n.r(r),n.d(r,"getFormatTypes",(function(){return l})),n.d(r,"getFormatType",(function(){return u})),n.d(r,"getFormatTypeForBareElement",(function(){return f})),n.d(r,"getFormatTypeForClassName",(function(){return d}));var o={};n.r(o),n.d(o,"addFormatTypes",(function(){return m})),n.d(o,"removeFormatTypes",(function(){return p}));var a=n("1ZqX"),i=n("YLtl");var c=Object(a.combineReducers)({formatTypes:function(){let 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{...e,...Object(i.keyBy)(t.formatTypes,"name")};case"REMOVE_FORMAT_TYPES":return Object(i.omit)(e,t.names)}return e}}),s=n("pPDe");const l=Object(s.a)(e=>Object.values(e.formatTypes),e=>[e.formatTypes]);function u(e,t){return e.formatTypes[t]}function f(e,t){return Object(i.find)(l(e),e=>{let{className:n,tagName:r}=e;return null===n&&t===r})}function d(e,t){return Object(i.find)(l(e),e=>{let{className:n}=e;return null!==n&&` ${t} `.indexOf(` ${n} `)>=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(a.createReduxStore)("core/rich-text",{reducer:c,selectors:r,actions:o});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 o=Object.keys(n),a=Object.keys(r);if(o.length!==a.length)return!1;const i=o.length;for(let e=0;e<i;e++){const t=o[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 o=e.slice();o.forEach((e,t)=>{const n=r[t];h(e,n)&&(o[t]=n)}),t[n]=o}}),{...e,formats:t}}function v(e,t,n){return(e=e.slice())[t]=n,e}function y(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end;const{formats:o,activeFormats:a}=e,c=o.slice();if(n===r){const e=Object(i.find)(c[n],{type:t.type});if(e){const o=c[n].indexOf(e);for(;c[n]&&c[n][o]===e;)c[n]=v(c[n],o,t),n--;for(r++;c[r]&&c[r][o]===e;)c[r]=v(c[r],o,t),r++}}else{let e=1/0;for(let o=n;o<r;o++)if(c[o]){c[o]=c[o].filter(e=>{let{type:n}=e;return n!==t.type});const n=c[o].length;n<e&&(e=n)}else c[o]=[],e=0;for(let o=n;o<r;o++)c[o].splice(e,0,t)}return b({...e,formats:c,activeFormats:[...Object(i.reject)(a,{type:t.type}),t]})}function x(e,t){let{implementation:n}=e;return x.body||(x.body=n.createHTMLDocument("").body),x.body.innerHTML=t,x.body}Object(a.register)(g);const T="\u2028";function E(e){let t,{type:n,attributes:r}=e;if(r&&r.class&&(t=Object(a.select)(g).getFormatTypeForClassName(r.class),t&&(r.class=` ${r.class} `.replace(` ${t.className} `," ").trim(),r.class||delete r.class)),t||(t=Object(a.select)(g).getFormatTypeForBareElement(n)),!t)return r?{type:n,attributes:r}:{type:n};if(t.__experimentalCreatePrepareEditableTree&&!t.__experimentalCreateOnChangeEditableValue)return null;if(!r)return{type:t.name};const o={},i={},c={...r};for(const e in t.attributes){const n=t.attributes[e];o[e]=c[n],t.__unstableFilterAttributeValue&&(o[e]=t.__unstableFilterAttributeValue(e,o[e])),delete c[n],void 0===o[e]&&delete o[e]}for(const e in c)i[e]=r[e];return{type:t.name,attributes:o,unregisteredAttributes:i}}function O(){let{element:e,text:t,html:n,range:r,multilineTag:o,multilineWrapperTags:a,__unstableIsEditableTree:i,preserveWhiteSpace:c}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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:""}:o?R({element:e,range:r,multilineTag:o,multilineWrapperTags:a,isEditableTree:i,preserveWhiteSpace:c}):F({element:e,range:r,isEditableTree:i,preserveWhiteSpace:c}))}function w(e,t,n,r){if(!n)return;const{parentNode:o}=t,{startContainer:a,startOffset:i,endContainer:c,endOffset:s}=n,l=e.text.length;void 0!==r.start?e.start=l+r.start:t===a&&t.nodeType===t.TEXT_NODE?e.start=l+i:o===a&&t===a.childNodes[i]?e.start=l:o===a&&t===a.childNodes[i-1]?e.start=l+r.text.length:t===a&&(e.start=l),void 0!==r.end?e.end=l+r.end:t===c&&t.nodeType===t.TEXT_NODE?e.end=l+s:o===c&&t===c.childNodes[s-1]?e.end=l+r.text.length:o===c&&t===c.childNodes[s]?e.end=l:t===c&&(e.end=l+s)}function _(e,t,n){if(!t)return;const{startContainer:r,endContainer:o}=t;let{startOffset:a,endOffset:i}=t;return e===r&&(a=n(e.nodeValue.slice(0,a)).length),e===o&&(i=n(e.nodeValue.slice(0,i)).length),{startContainer:r,startOffset:a,endContainer:o,endOffset:i}}function j(e){return e.replace(/[\n\r\t]+/g," ")}function C(e){return e.replace(new RegExp("[\ufeff]","gu"),"")}function F(e){let{element:t,range:n,multilineTag:r,multilineWrapperTags:o,currentWrapperTags:a=[],isEditableTree:i,preserveWhiteSpace:c}=e;const s={formats:[],replacements:[],text:""};if(!t)return s;if(!t.hasChildNodes())return w(s,t,n,{formats:[],replacements:[],text:""}),s;const l=t.childNodes.length;for(let e=0;e<l;e++){const l=t.childNodes[e],f=l.nodeName.toLowerCase();if(l.nodeType===l.TEXT_NODE){let e=C;c||(e=e=>C(j(e)));const t=e(l.nodeValue);n=_(l,n,e),w(s,l,n,{text:t}),s.formats.length+=t.length,s.replacements.length+=t.length,s.text+=t;continue}if(l.nodeType!==l.ELEMENT_NODE)continue;if(i&&(l.getAttribute("data-rich-text-placeholder")||"br"===f&&!l.getAttribute("data-rich-text-line-break"))){w(s,l,n,{formats:[],replacements:[],text:""});continue}if("script"===f){const e={formats:[,],replacements:[{type:f,attributes:{"data-rich-text-script":l.getAttribute("data-rich-text-script")||encodeURIComponent(l.innerHTML)}}],text:""};w(s,l,n,e),A(s,e);continue}if("br"===f){w(s,l,n,{formats:[],replacements:[],text:""}),A(s,O({text:"\n"}));continue}const d=E({type:f,attributes:L({element:l})});if(o&&-1!==o.indexOf(f)){const e=R({element:l,range:n,multilineTag:r,multilineWrapperTags:o,currentWrapperTags:[...a,d],isEditableTree:i,preserveWhiteSpace:c});w(s,l,n,e),A(s,e);continue}const m=F({element:l,range:n,multilineTag:r,multilineWrapperTags:o,isEditableTree:i,preserveWhiteSpace:c});if(w(s,l,n,m),d)if(0===m.text.length)d.attributes&&A(s,{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],A(s,{...m,formats:Array.from(m.formats,u)})}else A(s,m)}return s}function R(e){let{element:t,range:n,multilineTag:r,multilineWrapperTags:o,currentWrapperTags:a=[],isEditableTree:i,preserveWhiteSpace:c}=e;const s={formats:[],replacements:[],text:""};if(!t||!t.hasChildNodes())return s;const l=t.children.length;for(let e=0;e<l;e++){const l=t.children[e];if(l.nodeName.toLowerCase()!==r)continue;const u=F({element:l,range:n,multilineTag:r,multilineWrapperTags:o,currentWrapperTags:a,isEditableTree:i,preserveWhiteSpace:c});(0!==e||a.length>0)&&A(s,{formats:[,],replacements:a.length>0?[a]:[,],text:T}),w(s,l,n,u),A(s,u)}return s}function L(e){let{element:t}=e;if(!t.hasAttributes())return;const n=t.attributes.length;let r;for(let e=0;e<n;e++){const{name:n,value:o}=t.attributes[e];if(0===n.indexOf("data-rich-text-"))continue;r=r||{},r[/^on/i.test(n)?"data-disable-rich-text-"+n:n]=o}return r}function A(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function S(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b(t.reduce(A,O()))}function N(e){let{formats:t,start:n,end:r,activeFormats:o}=e,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(void 0===n)return a;if(n===r){if(o)return o;const e=t[n-1]||a,r=t[n]||a;return e.length<r.length?e:r}return t[n]||a}function D(e,t){return Object(i.find)(N(e),{type:t})}function k(e){let{start:t,end:n,replacements:r,text:o}=e;if(t+1===n&&""===o[t])return r[t]}function W(e){let{text:t}=e;return t.replace(new RegExp("","g"),"").replace(new RegExp(T,"g"),"\n")}function M(e){let{start:t,text:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,o=r;for(;o--;)if(n[o]===T)return o}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:o}=e,a=r[M(e,o)];if(!a||0===a.length)return t===n;return a[a.length-1].type===t}function $(e){let{start:t,end:n}=e;if(void 0!==t&&void 0!==n)return t===n}function V(e){let{text:t}=e;return 0===t.length}function K(e){let{text:t,start:n,end:r}=e;return n===r&&(0===t.length||(0===n&&t.slice(0,1)===T||(n===t.length&&t.slice(-1)===T||t.slice(n-1,r+1)===`${T}${T}`)))}function H(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof t&&(t=O({text:t})),b(e.reduce((e,n)=>{let{formats:r,replacements:o,text:a}=n;return{formats:e.formats.concat(t.formats,r),replacements:e.replacements.concat(t.replacements,o),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(a.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(a.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(a.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(a.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){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end;const{formats:o,activeFormats:a}=e,c=o.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)(a,{type:t})})}function z(e,t,n){const r=e[t].filter(e=>{let{type:t}=e;return t!==n});r.length?e[t]=r:delete e[t]}function U(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end;const{formats:o,replacements:a,text:i}=e;"string"==typeof t&&(t=O({text:t}));const c=n+t.text.length;return b({formats:o.slice(0,n).concat(t.formats,o.slice(r)),replacements:a.slice(0,n).concat(t.replacements,a.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(e,t,n){let{formats:r,replacements:o,text:a,start:i,end:c}=e;return a=a.replace(t,(function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];const l=a[a.length-2];let u,f,d=n;return"function"==typeof d&&(d=n(e,...a)),"object"==typeof d?(u=d.formats,f=d.replacements,d=d.text):(u=Array(d.length),f=Array(d.length),r[l]&&(u=u.fill(r[l]))),r=r.slice(0,l).concat(u,r.slice(l+e.length)),o=o.slice(0,l).concat(f,o.slice(l+e.length)),i&&(i=c=l+d.length),d})),b({formats:r,replacements:o,text:a,start:i,end:c})}function G(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end;const r=e.text.slice(0,t),o=r.lastIndexOf(T),a=e.replacements[o];let i=[,];a&&(i=[a]);const c={formats:[,],replacements:i,text:T};return U(e,c,t,n)}function Z(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{replacements:n,text:r,start:o,end:a}=e,i=$(e);let c,s=o-1,l=i?o-1:o,u=a;if(t||(s=a,l=o,u=i?a+1:a),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,l,u);return c}}function J(e,t,n,r){return U(e,{formats:[,],replacements:[t],text:""},n,r)}function Q(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end;const{formats:r,replacements:o,text:a}=e;return void 0===t||void 0===n?{...e}:{formats:r.slice(t,n),replacements:o.slice(t,n),text:a.slice(t,n)}}function ee(e,t){let{formats:n,replacements:r,text:o,start:a,end:i}=e;if("string"!=typeof t)return te(...arguments);let c=0;return o.split(t).map(e=>{const o=c,s={formats:n.slice(o,o+e.length),replacements:r.slice(o,o+e.length),text:e};return c+=t.length+e.length,void 0!==a&&void 0!==i&&(a>=o&&a<c?s.start=a-o:a<o&&i>o&&(s.start=0),i>=o&&i<c?s.end=i-o:a<c&&i>c&&(s.end=e.length)),s})}function te(e){let{formats:t,replacements:n,text:r,start:o,end:a}=e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;if(void 0===o||void 0===a)return;const s={formats:t.slice(0,i),replacements:n.slice(0,i),text:r.slice(0,i)},l={formats:t.slice(c),replacements:n.slice(c),text:r.slice(c),start:0,end:0};return[Y(s,/\u2028+$/,""),Y(l,/^\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(e){let{type:t,attributes:n,unregisteredAttributes:r,object:o,boundaryClass:i,isEditableTree:c}=e;const s=(l=t,Object(a.select)(g).getFormatType(l));var l;let u={};if(i&&(u["data-rich-text-format-boundary"]="true"),!s)return n&&(u={...n,...u}),{type:t,attributes:ne(u,c),object:o};u={...r,...u};for(const e in n){const t=!!s.attributes&&s.attributes[e];t?u[t]=n[e]:u[e]=n[e]}return s.className&&(u.class?u.class=`${s.className} ${u.class}`:u.class=s.className),{type:s.tagName,object:s.object,attributes:ne(u,c)}}function oe(e,t,n){do{if(e[n]!==t[n])return!1}while(n--);return!0}function ae(e){let{value:t,multilineTag:n,preserveWhiteSpace:r,createEmpty:o,append:a,getLastChild:i,getParent:c,isText:s,getText:l,remove:u,appendText:f,onStartIndex:d,onEndIndex:m,isEditableTree:p,placeholder:g}=e;const{formats:h,replacements:b,text:v,start:y,end:x}=t,E=h.length+1,O=o(),w={type:n},_=N(t),j=_[_.length-1];let C,F,R;n?(a(a(O,{type:n}),""),F=C=[w]):a(O,"");for(let e=0;e<E;e++){const t=v.charAt(e),o=p&&(!R||R===T||"\n"===R);let E=h[e];n&&(E=t===T?C=(b[e]||[]).reduce((e,t)=>(e.push(t,w),e),[w]):[...C,...E||[]]);let _=i(O);if(o&&t===T){let e=_;for(;!s(e);)e=i(e);a(c(e),"\ufeff")}if(R===T){let t=_;for(;!s(t);)t=i(t);d&&y===e&&d(O,t),m&&x===e&&m(O,t)}if(E&&E.forEach((e,n)=>{if(_&&F&&oe(E,F,n)&&(t!==T||E.length-1!==n))return void(_=i(_));const{type:r,attributes:o,unregisteredAttributes:f}=e,d=p&&t!==T&&e===j,m=c(_),g=a(m,re({type:r,attributes:o,unregisteredAttributes:f,boundaryClass:d,isEditableTree:p}));s(_)&&0===l(_).length&&u(_),_=a(g,"")}),t!==T){var L;if(0===e&&(d&&0===y&&d(O,_),m&&0===x&&m(O,_)),""===t)p||"script"!==(null===(L=b[e])||void 0===L?void 0:L.type)?_=a(c(_),re({...b[e],object:!0,isEditableTree:p})):(_=a(c(_),re({type:"script",isEditableTree:p})),a(_,{html:decodeURIComponent(b[e].attributes["data-rich-text-script"])})),_=a(c(_),"");else r||"\n"!==t?s(_)?f(_,t):_=a(c(_),t):(_=a(c(_),{type:"br",attributes:p?{"data-rich-text-line-break":"true"}:void 0,object:!0}),_=a(c(_),""));d&&y===e+1&&d(O,_),m&&x===e+1&&m(O,_),o&&e===v.length&&(a(c(_),"\ufeff"),g&&0===v.length&&a(c(_),{type:"span",attributes:{"data-rich-text-placeholder":g,contenteditable:"false",style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),F=E,R=t}else F=E,R=t}return O}function ie(e,t,n){const r=e.parentNode;let o=0;for(;e=e.previousSibling;)o++;return n=[o,...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 le(e,t){e.appendData(t)}function ue(e){let{lastChild:t}=e;return t}function fe(e){let{parentNode:t}=e;return t}function de(e){return e.nodeType===e.TEXT_NODE}function me(e){let{nodeValue:t}=e;return t}function pe(e){return e.parentNode.removeChild(e)}function ge(e){let{value:t,multilineTag:n,prepareEditableTree:r,isEditableTree:o=!0,placeholder:a,doc:i=document}=e,c=[],s=[];r&&(t={...t,formats:r(t)});return{body:ae({value:t,multilineTag:n,createEmpty:()=>x(i,""),append:se,getLastChild:ue,getParent:fe,isText:de,getText:me,remove:pe,appendText:le,onStartIndex(e,t){c=ie(t,e,[t.nodeValue.length])},onEndIndex(e,t){s=ie(t,e,[t.nodeValue.length])},isEditableTree:o,placeholder:a}),selection:{startPath:c,endPath:s}}}function he(e){let{value:t,current:n,multilineTag:r,prepareEditableTree:o,__unstableDomOnly:a,placeholder:i}=e;const{body:c,selection:s}=ge({value:t,multilineTag:r,prepareEditableTree:o,placeholder:i,doc:n.ownerDocument});!function e(t,n){let r,o=0;for(;r=t.firstChild;){const a=n.childNodes[o];if(a)if(a.isEqualNode(r))t.removeChild(r);else if(a.nodeName!==r.nodeName||a.nodeType===a.TEXT_NODE&&a.data!==r.data)n.replaceChild(r,a);else{const n=a.attributes,o=r.attributes;if(n){let e=n.length;for(;e--;){const{name:t}=n[e];r.getAttribute(t)||a.removeAttribute(t)}}if(o)for(let e=0;e<o.length;e++){const{name:t,value:n}=o[e];a.getAttribute(t)!==n&&a.setAttribute(t,n)}e(r,a),t.removeChild(r)}else n.appendChild(r);o++}for(;n.childNodes[o];)n.removeChild(n.childNodes[o])}(c,n),void 0===t.start||a||function(e,t){let{startPath:n,endPath:r}=e;const{node:o,offset:a}=ce(t,n),{node:i,offset:c}=ce(t,r),{ownerDocument:s}=t,{defaultView:l}=s,u=l.getSelection(),f=s.createRange();f.setStart(o,a),f.setEnd(i,c);const{activeElement:d}=s;if(u.rangeCount>0){if(m=f,p=u.getRangeAt(0),m.startContainer===p.startContainer&&m.startOffset===p.startOffset&&m.endContainer===p.endContainer&&m.endOffset===p.endOffset)return;u.removeAllRanges()}var m,p;u.addRange(f),d!==s.activeElement&&d instanceof l.HTMLElement&&d.focus()}(s,n)}var be=n("Vx3V");function ve(e){let{value:t,multilineTag:n,preserveWhiteSpace:r}=e;return Fe(ae({value:t,multilineTag:n,preserveWhiteSpace:r,createEmpty:ye,append:Te,getLastChild:xe,getParent:Oe,isText:we,getText:_e,remove:je,appendText:Ee}).children)}function ye(){return{}}function xe(e){let{children:t}=e;return t&&t[t.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(e){let{parent:t}=e;return t}function we(e){let{text:t}=e;return"string"==typeof t}function _e(e){let{text:t}=e;return t}function je(e){const t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function Ce(e){let{type:t,attributes:n,object:r,children:o}=e,a="";for(const e in n)Object(be.isValidAttributeName)(e)&&(a+=` ${e}="${Object(be.escapeAttribute)(n[e])}"`);return r?`<${t}${a}>`:`<${t}${a}>${Fe(o)}</${t}>`}function Fe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>void 0!==e.html?e.html:void 0===e.text?Ce(e):Object(be.escapeEditableHTML)(e.text)).join("")}var Re=n("gdqT"),Le=n("l3Sj");function Ae(e,t){return D(e,t.type)?(t.title&&Object(Re.speak)(Object(Le.sprintf)(Object(Le.__)("%s removed."),t.title),"assertive"),q(e,t.type)):(t.title&&Object(Re.speak)(Object(Le.sprintf)(Object(Le.__)("%s applied."),t.title),"assertive"),y(e,t))}function Se(e){const t=Object(a.select)(g).getFormatType(e);if(t)return Object(a.dispatch)(g).removeFormatTypes(e),t;window.console.error(`Format ${e} is not registered.`)}function Ne(e){const t=M(e);if(void 0===t)return!1;const{replacements:n}=e,r=M(e,t),o=n[t]||[],a=n[r]||[];return o.length<=a.length}function De(e){const{replacements:t,start:n}=e;return void 0!==t[M(e,n)]}function ke(e,t){if(!Ne(e))return e;const n=M(e),r=M(e,n),{text:o,replacements:a,end:i}=e,c=a.slice(),s=function(e,t){let{text:n,replacements:r}=e;const o=r[t]||[];let a=t;for(;a-- >=0;){if(n[a]!==T)continue;const e=r[a]||[];if(e.length===o.length+1)return a;if(e.length<=o.length)return}}(e,n);for(let e=n;e<i;e++)if(o[e]===T)if(s){const t=a[s]||[];c[e]=t.concat((c[e]||[]).slice(t.length-1))}else{const n=a[r]||[],o=n[n.length-1]||t;c[e]=n.concat([o],(c[e]||[]).slice(n.length))}return{...e,replacements:c}}function We(e,t){let{text:n,replacements:r}=e;const o=r[t]||[];let a=t;for(;a-- >=0;){if(n[a]!==T)continue;if((r[a]||[]).length===o.length-1)return a}}function Me(e){if(!De(e))return e;const{text:t,replacements:n,start:r,end:o}=e,a=M(e,r),i=n.slice(0),c=n[We(e,a)]||[],s=function(e,t){let{text:n,replacements:r}=e;const o=r[t]||[];let a=t;for(let e=t||0;e<n.length;e++){if(n[e]!==T)continue;if(!((r[e]||[]).length>=o.length))return a;a=e}return a}(e,M(e,o));for(let e=a;e<=s;e++){if(t[e]!==T)continue;const n=i[e]||[];i[e]=c.concat(n.slice(c.length+1)),0===i[e].length&&delete i[e]}return{...e,replacements:i}}function Pe(e,t){const{text:n,replacements:r,start:o,end:a}=e,i=M(e,o),c=r[i]||[],s=r[M(e,a)]||[],l=We(e,i),u=r.slice(),f=c.length-1,d=s.length-1;let m;for(let e=l+1||0;e<n.length;e++)if(n[e]===T){if((u[e]||[]).length<=f)break;u[e]&&(m=!0,u[e]=u[e].map((e,n)=>n<f||n>d?e:t))}return m?{...e,replacements:u}:e}var Ie=n("GRId");function $e(e){let{ref:t,value:n,settings:r={}}=e;const{tagName:o,className:a,name:i}=r,c=i?D(n,i):void 0;return Object(Ie.useMemo)(()=>{if(!t.current)return;const{ownerDocument:{defaultView:e}}=t.current,n=e.getSelection();if(!n.rangeCount)return;const r=n.getRangeAt(0);if(!c)return r;let i=r.startContainer;for(i=i.nextElementSibling||i;i.nodeType!==i.ELEMENT_NODE;)i=i.parentNode;return i.closest(o+(a?"."+a:""))},[c,n.start,n.end,o,a])}var Ve=n("K9lf");function Ke(e){let{record:t}=e;const n=Object(Ie.useRef)(),{activeFormats:r=[]}=t.current;return Object(Ie.useEffect)(()=>{if(!r||!r.length)return;const e=n.current.querySelector("*[data-rich-text-format-boundary]");if(!e)return;const{ownerDocument:t}=e,{defaultView:o}=t,a=`.rich-text:focus *[data-rich-text-format-boundary] {${"background-color: "+o.getComputedStyle(e).color.replace(")",", 0.2)").replace("rgb","rgba")}}`;let i=t.getElementById("rich-text-boundary-style");i||(i=t.createElement("style"),i.id="rich-text-boundary-style",t.head.appendChild(i)),i.innerHTML!==a&&(i.innerHTML=a)},[r]),n}function He(e){const t=Object(Ie.useRef)(e);return t.current=e,Object(Ve.useRefEffect)(e=>{function n(n){const{record:r,multilineTag:o,preserveWhiteSpace:a}=t.current;if($(r.current)||!e.contains(e.ownerDocument.activeElement))return;const i=Q(r.current),c=W(i),s=ve({value:i,multilineTag:o,preserveWhiteSpace:a});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",o||""),n.preventDefault()}return e.addEventListener("copy",n),()=>{e.removeEventListener("copy",n)}},[])}var Be=n("RxS6");const qe=[];function ze(e){const[,t]=Object(Ie.useReducer)(()=>({})),n=Object(Ie.useRef)(e);return n.current=e,Object(Ve.useRefEffect)(e=>{function r(r){const{keyCode:o,shiftKey:a,altKey:i,metaKey:c,ctrlKey:s}=r;if(a||i||c||s||o!==Be.LEFT&&o!==Be.RIGHT)return;const{record:l,applyRecord:u}=n.current,{text:f,formats:d,start:m,end:p,activeFormats:g=[]}=l.current,h=$(l.current),{ownerDocument:b}=e,{defaultView:v}=b,{direction:y}=v.getComputedStyle(e),x="rtl"===y?Be.RIGHT:Be.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]||qe,O=d[m]||qe,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(l.current._newActiveFormats=w);r.preventDefault();const C=(_?w:T?O:E).slice(0,j),F={...l.current,activeFormats:C};l.current=F,u(F),t()}return e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r)}},[])}function Ue(e){const t=Object(Ie.useRef)(e);return t.current=e,Object(Ve.useRefEffect)(e=>{function n(n){const{keyCode:r,shiftKey:o,altKey:a,metaKey:i,ctrlKey:c}=n,{multilineTag:s,createRecord:l,handleChange:u}=t.current;if(o||a||i||c||r!==Be.SPACE||"li"!==s)return;const f=l();if(!$(f))return;const{text:d,start:m}=f,p=d[m-1];p&&p!==T||(u(ke(f,{type:e.tagName.toLowerCase()})),n.preventDefault())}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}const Xe=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),Ye=[];function Ge(e){const t=Object(Ie.useRef)(e);return t.current=e,Object(Ve.useRefEffect)(e=>{const{ownerDocument:n}=e,{defaultView:r}=n;let o,a=!1;function i(e){if(a)return;let n;e&&(n=e.inputType);const{record:r,applyRecord:o,createRecord:i,handleChange:c}=t.current;if(n&&(0===n.indexOf("format")||Xe.has(n)))return void o(r.current);const s=i(),{start:l,activeFormats:u=[]}=r.current;c(function(e){let{value:t,start:n,end:r,formats:o}=e;const a=Math.min(n,r),i=Math.max(n,r),c=t.formats[a-1]||[],s=t.formats[i]||[];for(t.activeFormats=o.map((e,t)=>{if(c[t]){if(h(e,c[t]))return c[t]}else if(s[t]&&h(e,s[t]))return s[t];return e});--r>=n;)t.activeFormats.length>0?t.formats[r]=t.activeFormats:delete t.formats[r];return t}({value:s,start:l,end:s.start,formats:u}))}function c(o){if(n.activeElement!==e)return;const{record:c,applyRecord:s,createRecord:l,isSelected:u,onSelectionChange:f}=t.current;if("selectionchange"!==o.type&&!u)return;if("true"!==e.contentEditable)return;if(a)return;const{start:d,end:m,text:p}=l(),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 o=n.childNodes[r];o&&o.nodeType===o.ELEMENT_NODE&&o.getAttribute("data-rich-text-placeholder")&&t.collapseToStart()}(r));const h={...g,start:d,end:m,activeFormats:g._newActiveFormats,_newActiveFormats:void 0},b=N(h,Ye);h.activeFormats=b,c.current=h,s(h,{domOnly:!0}),f(d,m)}function s(){a=!0,n.removeEventListener("selectionchange",c)}function l(){a=!1,i({inputType:"insertText"}),n.addEventListener("selectionchange",c)}function u(){const{record:e,isSelected:a,onSelectionChange:i,applyRecord:s}=t.current;if(a)s(e.current),i(e.current.start,e.current.end);else{const t=void 0;e.current={...e.current,start:t,end:t,activeFormats:Ye},i(t,t)}o=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",l),e.addEventListener("focus",u),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",l),e.removeEventListener("focus",u),e.removeEventListener("blur",f),e.removeEventListener("keyup",c),e.removeEventListener("mouseup",c),e.removeEventListener("touchend",c),n.removeEventListener("selectionchange",c),r.cancelAnimationFrame(o)}},[])}function Ze(e){const t=Object(Ie.useRef)(e);return t.current=e,Object(Ve.useRefEffect)(e=>{function n(e){const{keyCode:n}=e,{createRecord:r,handleChange:o,multilineTag:a}=t.current;if(e.defaultPrevented)return;if(n!==Be.DELETE&&n!==Be.BACKSPACE)return;const i=r(),{start:c,end:s,text:l}=i,u=n===Be.BACKSPACE;if(0===c&&0!==s&&s===l.length)return o(X(i)),void e.preventDefault();if(a){let t;t=u&&0===i.start&&0===i.end&&K(i)?Z(i,!u):Z(i,u),t&&(o(t),e.preventDefault())}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}function Je(e){let{value:t="",selectionStart:n,selectionEnd:r,placeholder:o,preserveWhiteSpace:i,onSelectionChange:c,onChange:s,__unstableMultilineTag:l,__unstableDisableFormats:u,__unstableIsSelected:f,__unstableDependencies:d=[],__unstableAfterParse:m,__unstableBeforeSerialize:p,__unstableAddInvisibleFormats:g}=e;const h=Object(a.useRegistry)(),[,b]=Object(Ie.useReducer)(()=>({})),v=Object(Ie.useRef)();function y(){const{ownerDocument:{defaultView:e}}=v.current,t=e.getSelection(),n=t.rangeCount>0?t.getRangeAt(0):null;return O({element:v.current,range:n,multilineTag:l,multilineWrapperTags:"li"===l?["ul","ol"]:void 0,__unstableIsEditableTree:!0,preserveWhiteSpace:i})}function x(e){let{domOnly:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};he({value:e,current:v.current,multilineTag:l,multilineWrapperTags:"li"===l?["ul","ol"]:void 0,prepareEditableTree:g,__unstableDomOnly:t,placeholder:o})}const T=Object(Ie.useRef)(t),E=Object(Ie.useRef)();function w(){T.current=t,E.current=O({html:t,multilineTag:l,multilineWrapperTags:"li"===l?["ul","ol"]:void 0,preserveWhiteSpace:i}),u&&(E.current.formats=Array(t.length),E.current.replacements=Array(t.length)),m&&(E.current.formats=m(E.current)),E.current.start=n,E.current.end=r}const _=Object(Ie.useRef)(!1);if(E.current)n===E.current.start&&r===E.current.end||(_.current=f,E.current={...E.current,start:n,end:r});else{var j,C,F;w();"core/text-color"===(null===(j=E.current)||void 0===j||null===(C=j.formats[0])||void 0===C||null===(F=C[0])||void 0===F?void 0:F.type)&&function(e){E.current=e,T.current=ve({value:p?{...e,formats:p(e)}:e,multilineTag:l,preserveWhiteSpace:i});const{formats:t,text:n}=e;h.batch(()=>{s(T.current,{__unstableFormats:t,__unstableText:n})}),b()}(E.current)}function R(e){E.current=e,x(e),T.current=u?e.text:ve({value:p?{...e,formats:p(e)}:e,multilineTag:l,preserveWhiteSpace:i});const{start:t,end:n,formats:r,text:o}=e;h.batch(()=>{c(t,n),s(T.current,{__unstableFormats:r,__unstableText:o})}),b()}function L(){w(),x(E.current)}const A=Object(Ie.useRef)(!1);Object(Ie.useLayoutEffect)(()=>{A.current&&t!==T.current&&L()},[t]),Object(Ie.useLayoutEffect)(()=>{_.current&&(L(),_.current=!1)},[_.current]);const S=Object(Ve.useMergeRefs)([v,Object(Ie.useCallback)(e=>{e&&(e.style.whiteSpace="pre-wrap",e.style.minWidth="1px")},[]),Ke({record:E}),He({record:E,multilineTag:l,preserveWhiteSpace:i}),Object(Ve.useRefEffect)(e=>{function t(t){const{target:n}=t;if(n===e||n.textContent)return;const{ownerDocument:r}=n,{defaultView:o}=r,a=r.createRange(),i=o.getSelection();a.selectNode(n),i.removeAllRanges(),i.addRange(a)}return e.addEventListener("click",t),()=>{e.removeEventListener("click",t)}},[]),ze({record:E,applyRecord:x}),Ze({createRecord:y,handleChange:R,multilineTag:l}),Ue({multilineTag:l,createRecord:y,handleChange:R}),Ge({record:E,applyRecord:x,createRecord:y,handleChange:R,isSelected:f,onSelectionChange:c}),Object(Ve.useRefEffect)(e=>{function t(e){if(e.defaultPrevented)return;const{keyCode:t,altKey:n,metaKey:r,ctrlKey:o,key:a}=e;t!==Be.SPACE||n||r||o||" "===a&&(e.target.ownerDocument.execCommand("insertText",!1," "),e.preventDefault())}return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[]),Object(Ve.useRefEffect)(()=>{L(),A.current=!0},[o,...d])]);return{value:E.current,onChange:R,ref:S}}function Qe(){}function et(e){let{formatTypes:t,onChange:n,onFocus:r,value:o,forwardedRef:a}=e;return t.map(e=>{const{name:t,edit:i}=e;if(!i)return null;const c=D(o,t),s=void 0!==c,l=k(o),u=void 0!==l&&l.type===t;return Object(Ie.createElement)(i,{key:t,isActive:s,activeAttributes:s&&c.attributes||{},isObjectActive:u,activeObjectAttributes:u&&l.attributes||{},value:o,onChange:n,onFocus:r,contentRef:a})})}}}); |