diff --git a/modules/calendar/calendar.php b/modules/calendar/calendar.php index 73f71df4..1a553888 100644 --- a/modules/calendar/calendar.php +++ b/modules/calendar/calendar.php @@ -652,6 +652,7 @@ public function enqueue_admin_scripts() true ); + // TODO: Replace react and react-dom with the wp.element dependency wp_enqueue_script( 'publishpress-async-calendar-js', $this->module_url . 'lib/async-calendar/js/index.min.js', @@ -665,6 +666,7 @@ public function enqueue_admin_scripts() 'jquery-ui-droppable', 'jquery-inputmask', 'wp-i18n', + 'wp-element', 'date_i18n', ], PUBLISHPRESS_VERSION, diff --git a/modules/calendar/lib/async-calendar/js/index.jsx b/modules/calendar/lib/async-calendar/js/index.jsx index 67fcee09..e05ad126 100644 --- a/modules/calendar/lib/async-calendar/js/index.jsx +++ b/modules/calendar/lib/async-calendar/js/index.jsx @@ -1,8 +1,12 @@ import AsyncCalendar from "./AsyncCalendar"; -import {getDateWithNoTimezoneOffset, getDateInstanceFromString} from "./Functions"; +import { getDateWithNoTimezoneOffset, getDateInstanceFromString } from "./Functions"; +import { createRoot } from "@wp.element"; jQuery(() => { - ReactDOM.render( + const container = document.getElementById('publishpress-calendar-wrap'); + const root = createRoot(container); + + root.render( { items={publishpressCalendarParams.items} allowAddingMultipleAuthors={publishpressCalendarParams.allowAddingMultipleAuthors} requestFilter={publishpressCalendarParams.requestFilter} - strings={publishpressCalendarParams.strings}/>, - document.getElementById('publishpress-calendar-wrap') + strings={publishpressCalendarParams.strings} /> ); }); diff --git a/modules/calendar/lib/async-calendar/js/index.min.js b/modules/calendar/lib/async-calendar/js/index.min.js index e3524c2b..5b9a639d 100644 --- a/modules/calendar/lib/async-calendar/js/index.min.js +++ b/modules/calendar/lib/async-calendar/js/index.min.js @@ -1,3 +1,435 @@ -!function(e){var t={};function a(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(n,r,function(t){return e[t]}.bind(null,r));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=3)}([function(e,t,a){ -/*! @license DOMPurify 2.4.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.1/LICENSE */ -e.exports=function(){"use strict";function e(t){return(e="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})(t)}function t(e,a){return(t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,a)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function n(e,r,l){return(n=a()?Reflect.construct:function(e,a,n){var r=[null];r.push.apply(r,a);var l=new(Function.bind.apply(e,r));return n&&t(l,n.prototype),l}).apply(null,arguments)}function r(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?l(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a1?a-1:0),r=1;r/gm),Y=d(/\${[\w\W]*}/gm),V=d(/^data-[\-\w.\u00B7-\uFFFF]/),Q=d(/^aria-[\-\w]+$/),$=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),K=d(/^(?:\w+script|data):/i),J=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),X=d(/^html$/i),Z=function(){return"undefined"==typeof window?null:window},ee=function(t,a){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var n=null;a.currentScript&&a.currentScript.hasAttribute("data-tt-policy-suffix")&&(n=a.currentScript.getAttribute("data-tt-policy-suffix"));var r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};return function t(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z(),n=function(e){return t(e)};if(n.version="2.4.1",n.removed=[],!a||!a.document||9!==a.document.nodeType)return n.isSupported=!1,n;var l=a.document,i=a.document,o=a.DocumentFragment,s=a.HTMLTemplateElement,c=a.Node,u=a.Element,d=a.NodeFilter,m=a.NamedNodeMap,f=void 0===m?a.NamedNodeMap||a.MozNamedAttrMap:m,h=a.HTMLFormElement,g=a.DOMParser,y=a.trustedTypes,A=u.prototype,te=O(A,"cloneNode"),ae=O(A,"nextSibling"),ne=O(A,"childNodes"),re=O(A,"parentNode");if("function"==typeof s){var le=i.createElement("template");le.content&&le.content.ownerDocument&&(i=le.content.ownerDocument)}var ie=ee(y,l),oe=ie?ie.createHTML(""):"",se=i,ce=se.implementation,ue=se.createNodeIterator,pe=se.createDocumentFragment,de=se.getElementsByTagName,me=l.importNode,fe={};try{fe=N(i).documentMode?i.documentMode:{}}catch(e){}var he={};n.isSupported="function"==typeof re&&ce&&void 0!==ce.createHTMLDocument&&9!==fe;var ge,ye,be=W,ve=B,Ee=Y,Re=V,ke=Q,Ce=K,we=J,xe=$,Se=null,_e=D({},[].concat(r(F),r(j),r(M),r(L),r(U))),Te=null,Ae=D({},[].concat(r(H),r(q),r(G),r(z))),De=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ne=null,Oe=null,Fe=!0,je=!0,Me=!1,Ie=!1,Le=!1,Pe=!1,Ue=!1,He=!1,qe=!1,Ge=!1,ze=!0,We=!1,Be="user-content-",Ye=!0,Ve=!1,Qe={},$e=null,Ke=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Je=null,Xe=D({},["audio","video","img","source","image","track"]),Ze=null,et=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",at="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",rt=nt,lt=!1,it=null,ot=D({},[tt,at,nt],k),st=["application/xhtml+xml","text/html"],ct="text/html",ut=null,pt=i.createElement("form"),dt=function(e){return e instanceof RegExp||e instanceof Function},mt=function(t){ut&&ut===t||(t&&"object"===e(t)||(t={}),t=N(t),ge=ge=-1===st.indexOf(t.PARSER_MEDIA_TYPE)?ct:t.PARSER_MEDIA_TYPE,ye="application/xhtml+xml"===ge?k:R,Se="ALLOWED_TAGS"in t?D({},t.ALLOWED_TAGS,ye):_e,Te="ALLOWED_ATTR"in t?D({},t.ALLOWED_ATTR,ye):Ae,it="ALLOWED_NAMESPACES"in t?D({},t.ALLOWED_NAMESPACES,k):ot,Ze="ADD_URI_SAFE_ATTR"in t?D(N(et),t.ADD_URI_SAFE_ATTR,ye):et,Je="ADD_DATA_URI_TAGS"in t?D(N(Xe),t.ADD_DATA_URI_TAGS,ye):Xe,$e="FORBID_CONTENTS"in t?D({},t.FORBID_CONTENTS,ye):Ke,Ne="FORBID_TAGS"in t?D({},t.FORBID_TAGS,ye):{},Oe="FORBID_ATTR"in t?D({},t.FORBID_ATTR,ye):{},Qe="USE_PROFILES"in t&&t.USE_PROFILES,Fe=!1!==t.ALLOW_ARIA_ATTR,je=!1!==t.ALLOW_DATA_ATTR,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Ie=t.SAFE_FOR_TEMPLATES||!1,Le=t.WHOLE_DOCUMENT||!1,He=t.RETURN_DOM||!1,qe=t.RETURN_DOM_FRAGMENT||!1,Ge=t.RETURN_TRUSTED_TYPE||!1,Ue=t.FORCE_BODY||!1,ze=!1!==t.SANITIZE_DOM,We=t.SANITIZE_NAMED_PROPS||!1,Ye=!1!==t.KEEP_CONTENT,Ve=t.IN_PLACE||!1,xe=t.ALLOWED_URI_REGEXP||xe,rt=t.NAMESPACE||nt,t.CUSTOM_ELEMENT_HANDLING&&dt(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(De.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&dt(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(De.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(De.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ie&&(je=!1),qe&&(He=!0),Qe&&(Se=D({},r(U)),Te=[],!0===Qe.html&&(D(Se,F),D(Te,H)),!0===Qe.svg&&(D(Se,j),D(Te,q),D(Te,z)),!0===Qe.svgFilters&&(D(Se,M),D(Te,q),D(Te,z)),!0===Qe.mathMl&&(D(Se,L),D(Te,G),D(Te,z))),t.ADD_TAGS&&(Se===_e&&(Se=N(Se)),D(Se,t.ADD_TAGS,ye)),t.ADD_ATTR&&(Te===Ae&&(Te=N(Te)),D(Te,t.ADD_ATTR,ye)),t.ADD_URI_SAFE_ATTR&&D(Ze,t.ADD_URI_SAFE_ATTR,ye),t.FORBID_CONTENTS&&($e===Ke&&($e=N($e)),D($e,t.FORBID_CONTENTS,ye)),Ye&&(Se["#text"]=!0),Le&&D(Se,["html","head","body"]),Se.table&&(D(Se,["tbody"]),delete Ne.tbody),p&&p(t),ut=t)},ft=D({},["mi","mo","mn","ms","mtext"]),ht=D({},["foreignobject","desc","title","annotation-xml"]),gt=D({},["title","style","font","a","script"]),yt=D({},j);D(yt,M),D(yt,I);var bt=D({},L);D(bt,P);var vt=function(e){var t=re(e);t&&t.tagName||(t={namespaceURI:rt,tagName:"template"});var a=R(e.tagName),n=R(t.tagName);return!!it[e.namespaceURI]&&(e.namespaceURI===at?t.namespaceURI===nt?"svg"===a:t.namespaceURI===tt?"svg"===a&&("annotation-xml"===n||ft[n]):Boolean(yt[a]):e.namespaceURI===tt?t.namespaceURI===nt?"math"===a:t.namespaceURI===at?"math"===a&&ht[n]:Boolean(bt[a]):e.namespaceURI===nt?!(t.namespaceURI===at&&!ht[n])&&!(t.namespaceURI===tt&&!ft[n])&&!bt[a]&&(gt[a]||!yt[a]):!("application/xhtml+xml"!==ge||!it[e.namespaceURI]))},Et=function(e){E(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=oe}catch(t){e.remove()}}},Rt=function(e,t){try{E(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){E(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Te[e])if(He||qe)try{Et(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},kt=function(e){var t,a;if(Ue)e=""+e;else{var n=C(e,/^[\r\n\t ]+/);a=n&&n[0]}"application/xhtml+xml"===ge&&rt===nt&&(e=''+e+"");var r=ie?ie.createHTML(e):e;if(rt===nt)try{t=(new g).parseFromString(r,ge)}catch(e){}if(!t||!t.documentElement){t=ce.createDocument(rt,"template",null);try{t.documentElement.innerHTML=lt?"":r}catch(e){}}var l=t.body||t.documentElement;return e&&a&&l.insertBefore(i.createTextNode(a),l.childNodes[0]||null),rt===nt?de.call(t,Le?"html":"body")[0]:Le?t.documentElement:l},Ct=function(e){return ue.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},wt=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof f)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},xt=function(t){return"object"===e(c)?t instanceof c:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},St=function(e,t,a){he[e]&&b(he[e],(function(e){e.call(n,t,a,ut)}))},_t=function(e){var t;if(St("beforeSanitizeElements",e,null),wt(e))return Et(e),!0;if(_(/[\u0080-\uFFFF]/,e.nodeName))return Et(e),!0;var a=ye(e.nodeName);if(St("uponSanitizeElement",e,{tagName:a,allowedTags:Se}),e.hasChildNodes()&&!xt(e.firstElementChild)&&(!xt(e.content)||!xt(e.content.firstElementChild))&&_(/<[/\w]/g,e.innerHTML)&&_(/<[/\w]/g,e.textContent))return Et(e),!0;if("select"===a&&_(/