WordPress/wp-includes/js/dist/annotations.min.js

2 lines
7.1 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:function(){return B}});var n={};e.r(n),e.d(n,{__experimentalGetAllAnnotationsForBlock:function(){return N},__experimentalGetAnnotations:function(){return w},__experimentalGetAnnotationsForBlock:function(){return b},__experimentalGetAnnotationsForRichText:function(){return O}});var r={};e.r(r),e.d(r,{__experimentalAddAnnotation:function(){return F},__experimentalRemoveAnnotation:function(){return G},__experimentalRemoveAnnotationsBySource:function(){return j},__experimentalUpdateAnnotationRange:function(){return V}});var o=window.wp.richText,a=window.wp.i18n;const i="core/annotations",u="core/annotation",l="annotation-text-";const c={name:u,title:(0,a.__)("Annotation"),tagName:"mark",className:"annotation-text",attributes:{className:"class",id:"id"},edit(){return null},__experimentalGetPropsForEditableTreePreparation(e,t){let{richTextIdentifier:n,blockClientId:r}=t;return{annotations:e(i).__experimentalGetAnnotationsForRichText(r,n)}},__experimentalCreatePrepareEditableTree(e){let{annotations:t}=e;return(e,n)=>{if(0===t.length)return e;let r={formats:e,text:n};return r=function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((t=>{let{start:n,end:r}=t;n>e.text.length&&(n=e.text.length),r>e.text.length&&(r=e.text.length);const a=l+t.source,i=l+t.id;e=(0,o.applyFormat)(e,{type:u,attributes:{className:a,id:i}},n,r)})),e}(r,t),r.formats}},__experimentalGetPropsForEditableTreeChangeHandler(e){return{removeAnnotation:e(i).__experimentalRemoveAnnotation,updateAnnotationRange:e(i).__experimentalUpdateAnnotationRange}},__experimentalCreateOnChangeEditableValue(e){return t=>{const n=function(e){const t={};return e.forEach(((e,n)=>{(e=(e=e||[]).filter((e=>e.type===u))).forEach((e=>{let{id:r}=e.attributes;r=r.replace(l,""),t.hasOwnProperty(r)||(t[r]={start:n}),t[r].end=n+1}))})),t}(t),{removeAnnotation:r,updateAnnotationRange:o,annotations:a}=e;!function(e,t,n){let{removeAnnotation:r,updateAnnotationRange:o}=n;e.forEach((e=>{const n=t[e.id];if(!n)return void r(e.id);const{start:a,end:i}=e;a===n.start&&i===n.end||o(e.id,n.start,n.end)}))}(a,n,{removeAnnotation:r,updateAnnotationRange:o})}}},{name:s,...d}=c;(0,o.registerFormatType)(s,d);var p=window.wp.hooks,f=window.wp.data;function v(e,t){const n=e.filter(t);return e.length===n.length?e:n}(0,p.addFilter)("editor.BlockListBlock","core/annotations",(e=>(0,f.withSelect)(((e,t)=>{let{clientId:n,className:r}=t;return{className:e(i).__experimentalGetAnnotationsForBlock(n).map((e=>"is-annotated-by-"+e.source)).concat(r).filter(Boolean).join(" ")}}))(e)));const g=(e,t)=>Object.entries(e).reduce(((e,n)=>{let[r,o]=n;return{...e,[r]:t(o)}}),{});function m(e){return"number"==typeof e.start&&"number"==typeof e.end&&e.start<=e.end}var h=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;switch(n.type){case"ANNOTATION_ADD":const r=n.blockClientId,o={id:n.id,blockClientId:r,richTextIdentifier:n.richTextIdentifier,source:n.source,selector:n.selector,range:n.range};if("range"===o.selector&&!m(o.range))return t;const a=null!==(e=null==t?void 0:t[r])&&void 0!==e?e:[];return{...t,[r]:[...a,o]};case"ANNOTATION_REMOVE":return g(t,(e=>v(e,(e=>e.id!==n.annotationId))));case"ANNOTATION_UPDATE_RANGE":return g(t,(e=>{let t=!1;const r=e.map((e=>e.id===n.annotationId?(t=!0,{...e,range:{start:n.start,end:n.end}}):e));return t?r:e}));case"ANNOTATION_REMOVE_SOURCE":return g(t,(e=>v(e,(e=>e.source!==n.source))))}return t},_={};function A(e){return[e]}function y(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}function x(e,t){var n,r=t||A;function o(e){var t,r,o,a,i,u=n,l=!0