remove orphan edges

This commit is contained in:
lexx committed 2023-11-29 17:10:15 +02:00
1 parent 2e5c80e1f6
commit ba25850191
11 files changed
+114 -16

No files matched your search

@@ -51,7 +51,7 @@ function print() { __p += __j.call(arguments, '') }
* @author RubaXa <trash@rubaxa.org>
* @author owenm <owen23355@gmail.com>
* @license MIT
*/function Tue(o,e){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(o);e&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(o,a).enumerable})),t.push.apply(t,s)}return t}function Oy(o){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Tue(Object(t),!0).forEach(function(s){Axe(o,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):Tue(Object(t)).forEach(function(s){Object.defineProperty(o,s,Object.getOwnPropertyDescriptor(t,s))})}return o}function xH(o){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xH=function(e){return typeof e}:xH=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xH(o)}function Axe(o,e,t){return e in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function zw(){return zw=Object.assign||function(o){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(o[s]=t[s])}return o},zw.apply(this,arguments)}function Dxe(o,e){if(o==null)return{};var t={},s=Object.keys(o),a,l;for(l=0;l<s.length;l++)a=s[l],!(e.indexOf(a)>=0)&&(t[a]=o[a]);return t}function Pxe(o,e){if(o==null)return{};var t=Dxe(o,e),s,a;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(o);for(a=0;a<l.length;a++)s=l[a],!(e.indexOf(s)>=0)&&(!Object.prototype.propertyIsEnumerable.call(o,s)||(t[s]=o[s]))}return t}var Mxe="1.15.0";function Fw(o){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(o)}var jw=Fw(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),tI=Fw(/Edge/i),Eue=Fw(/firefox/i),i6=Fw(/safari/i)&&!Fw(/chrome/i)&&!Fw(/android/i),t1e=Fw(/iP(ad|od|hone)/i),n1e=Fw(/chrome/i)&&Fw(/android/i),o1e={capture:!1,passive:!1};function hl(o,e,t){o.addEventListener(e,t,!jw&&o1e)}function La(o,e,t){o.removeEventListener(e,t,!jw&&o1e)}function rz(o,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),o)try{if(o.matches)return o.matches(e);if(o.msMatchesSelector)return o.msMatchesSelector(e);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(e)}catch{return!1}return!1}}function Rxe(o){return o.host&&o!==document&&o.host.nodeType?o.host:o.parentNode}function iy(o,e,t,s){if(o){t=t||document;do{if(e!=null&&(e[0]===">"?o.parentNode===t&&rz(o,e):rz(o,e))||s&&o===t)return o;if(o===t)break}while(o=Rxe(o))}return null}var Aue=/\s+/g;function $1(o,e,t){if(o&&e)if(o.classList)o.classList[t?"add":"remove"](e);else{var s=(" "+o.className+" ").replace(Aue," ").replace(" "+e+" "," ");o.className=(s+(t?" "+e:"")).replace(Aue," ")}}function Vr(o,e,t){var s=o&&o.style;if(s){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(o,""):o.currentStyle&&(t=o.currentStyle),e===void 0?t:t[e];!(e in s)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),s[e]=t+(typeof t=="string"?"":"px")}}function OD(o,e){var t="";if(typeof o=="string")t=o;else do{var s=Vr(o,"transform");s&&s!=="none"&&(t=s+" "+t)}while(!e&&(o=o.parentNode));var a=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return a&&new a(t)}function s1e(o,e,t){if(o){var s=o.getElementsByTagName(e),a=0,l=s.length;if(t)for(;a<l;a++)t(s[a],a);return s}return[]}function hy(){var o=document.scrollingElement;return o||document.documentElement}function yd(o,e,t,s,a){if(!(!o.getBoundingClientRect&&o!==window)){var l,u,d,h,b,y,C;if(o!==window&&o.parentNode&&o!==hy()?(l=o.getBoundingClientRect(),u=l.top,d=l.left,h=l.bottom,b=l.right,y=l.height,C=l.width):(u=0,d=0,h=window.innerHeight,b=window.innerWidth,y=window.innerHeight,C=window.innerWidth),(e||t)&&o!==window&&(a=a||o.parentNode,!jw))do if(a&&a.getBoundingClientRect&&(Vr(a,"transform")!=="none"||t&&Vr(a,"position")!=="static")){var E=a.getBoundingClientRect();u-=E.top+parseInt(Vr(a,"border-top-width")),d-=E.left+parseInt(Vr(a,"border-left-width")),h=u+l.height,b=d+l.width;break}while(a=a.parentNode);if(s&&o!==window){var R=OD(a||o),$=R&&R.a,Q=R&&R.d;R&&(u/=Q,d/=$,C/=$,y/=Q,h=u+y,b=d+C)}return{top:u,left:d,bottom:h,right:b,width:C,height:y}}}function Due(o,e,t){for(var s=_C(o,!0),a=yd(o)[e];s;){var l=yd(s)[t],u=void 0;if(t==="top"||t==="left"?u=a>=l:u=a<=l,!u)return s;if(s===hy())break;s=_C(s,!1)}return!1}function PD(o,e,t,s){for(var a=0,l=0,u=o.children;l<u.length;){if(u[l].style.display!=="none"&&u[l]!==Wr.ghost&&(s||u[l]!==Wr.dragged)&&iy(u[l],t.draggable,o,!1)){if(a===e)return u[l];a++}l++}return null}function lre(o,e){for(var t=o.lastElementChild;t&&(t===Wr.ghost||Vr(t,"display")==="none"||e&&!rz(t,e));)t=t.previousElementSibling;return t||null}function Lb(o,e){var t=0;if(!o||!o.parentNode)return-1;for(;o=o.previousElementSibling;)o.nodeName.toUpperCase()!=="TEMPLATE"&&o!==Wr.clone&&(!e||rz(o,e))&&t++;return t}function Pue(o){var e=0,t=0,s=hy();if(o)do{var a=OD(o),l=a.a,u=a.d;e+=o.scrollLeft*l,t+=o.scrollTop*u}whilLine truncated
*/function Tue(o,e){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(o);e&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(o,a).enumerable})),t.push.apply(t,s)}return t}function Oy(o){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Tue(Object(t),!0).forEach(function(s){Axe(o,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):Tue(Object(t)).forEach(function(s){Object.defineProperty(o,s,Object.getOwnPropertyDescriptor(t,s))})}return o}function xH(o){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xH=function(e){return typeof e}:xH=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xH(o)}function Axe(o,e,t){return e in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function zw(){return zw=Object.assign||function(o){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(o[s]=t[s])}return o},zw.apply(this,arguments)}function Dxe(o,e){if(o==null)return{};var t={},s=Object.keys(o),a,l;for(l=0;l<s.length;l++)a=s[l],!(e.indexOf(a)>=0)&&(t[a]=o[a]);return t}function Pxe(o,e){if(o==null)return{};var t=Dxe(o,e),s,a;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(o);for(a=0;a<l.length;a++)s=l[a],!(e.indexOf(s)>=0)&&(!Object.prototype.propertyIsEnumerable.call(o,s)||(t[s]=o[s]))}return t}var Mxe="1.15.0";function Fw(o){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(o)}var jw=Fw(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),tI=Fw(/Edge/i),Eue=Fw(/firefox/i),i6=Fw(/safari/i)&&!Fw(/chrome/i)&&!Fw(/android/i),t1e=Fw(/iP(ad|od|hone)/i),n1e=Fw(/chrome/i)&&Fw(/android/i),o1e={capture:!1,passive:!1};function hl(o,e,t){o.addEventListener(e,t,!jw&&o1e)}function La(o,e,t){o.removeEventListener(e,t,!jw&&o1e)}function rz(o,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),o)try{if(o.matches)return o.matches(e);if(o.msMatchesSelector)return o.msMatchesSelector(e);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(e)}catch{return!1}return!1}}function Rxe(o){return o.host&&o!==document&&o.host.nodeType?o.host:o.parentNode}function iy(o,e,t,s){if(o){t=t||document;do{if(e!=null&&(e[0]===">"?o.parentNode===t&&rz(o,e):rz(o,e))||s&&o===t)return o;if(o===t)break}while(o=Rxe(o))}return null}var Aue=/\s+/g;function $1(o,e,t){if(o&&e)if(o.classList)o.classList[t?"add":"remove"](e);else{var s=(" "+o.className+" ").replace(Aue," ").replace(" "+e+" "," ");o.className=(s+(t?" "+e:"")).replace(Aue," ")}}function Vr(o,e,t){var s=o&&o.style;if(s){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(o,""):o.currentStyle&&(t=o.currentStyle),e===void 0?t:t[e];!(e in s)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),s[e]=t+(typeof t=="string"?"":"px")}}function OD(o,e){var t="";if(typeof o=="string")t=o;else do{var s=Vr(o,"transform");s&&s!=="none"&&(t=s+" "+t)}while(!e&&(o=o.parentNode));var a=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return a&&new a(t)}function s1e(o,e,t){if(o){var s=o.getElementsByTagName(e),a=0,l=s.length;if(t)for(;a<l;a++)t(s[a],a);return s}return[]}function hy(){var o=document.scrollingElement;return o||document.documentElement}function yd(o,e,t,s,a){if(!(!o.getBoundingClientRect&&o!==window)){var l,u,d,h,b,y,C;if(o!==window&&o.parentNode&&o!==hy()?(l=o.getBoundingClientRect(),u=l.top,d=l.left,h=l.bottom,b=l.right,y=l.height,C=l.width):(u=0,d=0,h=window.innerHeight,b=window.innerWidth,y=window.innerHeight,C=window.innerWidth),(e||t)&&o!==window&&(a=a||o.parentNode,!jw))do if(a&&a.getBoundingClientRect&&(Vr(a,"transform")!=="none"||t&&Vr(a,"position")!=="static")){var E=a.getBoundingClientRect();u-=E.top+parseInt(Vr(a,"border-top-width")),d-=E.left+parseInt(Vr(a,"border-left-width")),h=u+l.height,b=d+l.width;break}while(a=a.parentNode);if(s&&o!==window){var R=OD(a||o),$=R&&R.a,Q=R&&R.d;R&&(u/=Q,d/=$,C/=$,y/=Q,h=u+y,b=d+C)}return{top:u,left:d,bottom:h,right:b,width:C,height:y}}}function Due(o,e,t){for(var s=_C(o,!0),a=yd(o)[e];s;){var l=yd(s)[t],u=void 0;if(t==="top"||t==="left"?u=a>=l:u=a<=l,!u)return s;if(s===hy())break;s=_C(s,!1)}return!1}function PD(o,e,t,s){for(var a=0,l=0,u=o.children;l<u.length;){if(u[l].style.display!=="none"&&u[l]!==Wr.ghost&&(s||u[l]!==Wr.dragged)&&iy(u[l],t.draggable,o,!1)){if(a===e)return u[l];a++}l++}return null}function lre(o,e){for(var t=o.lastElementChild;t&&(t===Wr.ghost||Vr(t,"display")==="none"||e&&!rz(t,e));)t=t.previousElementSibling;return t||null}function Lb(o,e){var t=0;if(!o||!o.parentNode)return-1;for(;o=o.previousElementSibling;)o.nodeName.toUpperCase()!=="TEMPLATE"&&o!==Wr.clone&&(!e||rz(o,e))&&t++;return t}function Pue(o){var e=0,t=0,s=hy();if(o)do{var a=OD(o),l=a.a,u=a.d;e+=o.scrollLeft*l,t+=o.scrollTop*u}whilLine truncated
`||n==="\r",Ra=(n,i)=>i<n.length&&i>=0?rm(n[i]):!1,mh=(n,i=4,c=!0,m=!0)=>{const p=Tu(" ",i),w=n.replace(/\t/g,p);return zn(w,(M,B)=>u0(B)||B===Kr?M.pcIsSpace||M.str===""&&c||M.str.length===w.length-1&&m||Ra(w,M.str.length+1)?{pcIsSpace:!1,str:M.str+Kr}:{pcIsSpace:!0,str:M.str+" "}:{pcIsSpace:rm(B),str:M.str+B},{pcIsSpace:!1,str:""}).str},$d=(n,i)=>{const c=Ke.fromDom(i),m=Ke.fromDom(n);return Ty(m,"pre,code",He(vt,c))},tg=(n,i)=>_n(n)&&eg(n.data)&&!$d(n,i),ng=n=>Jn(n)&&n.nodeName==="A"&&!n.hasAttribute("href")&&(n.hasAttribute("name")||n.hasAttribute("id")),im=(n,i)=>Tl(n)&&!tg(n,i)||ng(n)||af(n),af=Vc("data-mce-bookmark"),f0=Vc("data-mce-bogus"),tb=qg("data-mce-bogus","all"),e_=(n,i)=>{let c=0;if(im(n,n))return!1;{let m=n.firstChild;if(!m)return!0;const p=new _i(m,n);do{if(i){if(tb(m)){m=p.next(!0);continue}if(f0(m)){m=p.next();continue}}if(mi(m)){c++,m=p.next();continue}if(im(m,n))return!1;m=p.next()}while(m);return c<=1}},$a=(n,i=!0)=>e_(n.dom,i),ep="data-mce-block",og=n=>At(bs(n),i=>!/[A-Z]/.test(i)),du=n=>og(n).join(","),Bf=(n,i)=>Oe(i.querySelector(n))?(i.setAttribute(ep,"true"),i.getAttribute("data-mce-selected")==="inline-boundary"&&i.removeAttribute("data-mce-selected"),!0):(i.removeAttribute(ep),!1),sg=(n,i)=>{const c=du(n.getTransparentElements()),m=du(n.getBlockElements());return At(i.querySelectorAll(c),p=>Bf(m,p))},gh=(n,i)=>{var c;const m=i?"lastChild":"firstChild";for(let p=n[m];p;p=p[m])if($a(Ke.fromDom(p))){(c=p.parentNode)===null||c===void 0||c.removeChild(p);return}},Lu=(n,i)=>{const c=document.createRange(),m=n.parentNode;if(m){c.setStartBefore(n),c.setEndBefore(i);const p=c.extractContents();gh(p,!0),c.setStartAfter(i),c.setEndAfter(n);const w=c.extractContents();gh(w,!1),$a(Ke.fromDom(p))||m.insertBefore(p,n),$a(Ke.fromDom(i))||m.insertBefore(i,n),$a(Ke.fromDom(w))||m.insertBefore(w,n),m.removeChild(n)}},Nd=(n,i,c)=>{const m=n.getBlockElements(),p=Ke.fromDom(i),w=M=>ti(M)in m,x=M=>vt(M,p);Ne(lh(c),M=>{di(M,w,x).each(B=>{const q=r0(M,ae=>w(ae)&&!n.isValidChild(ti(B),ti(ae)));if(q.length>0){const ae=wi(B);Ne(q,fe=>{di(fe,w,x).each(be=>{Lu(be.dom,fe.dom)})}),ae.each(fe=>sg(n,fe.dom))}})})},rg=(n,i,c)=>{Ne([...c,...ig(n,i)?[i]:[]],m=>Ne(pl(Ke.fromDom(m),m.nodeName.toLowerCase()),p=>{Iv(n,p.dom)&&Kl(p)}))},d0=(n,i)=>{const c=sg(n,i);Nd(n,i,c),rg(n,i,c)},Rv=(n,i)=>{if(Nv(n,i)){const c=du(n.getBlockElements());Bf(c,i)}},$v=(n,i,c)=>{const m=w=>vt(w,Ke.fromDom(i)),p=oh(Ke.fromDom(c),m);qr(p,p.length-2).filter(kl).fold(()=>d0(n,i),w=>d0(n,w.dom))},ph=n=>n.hasAttribute(ep),tp=(n,i)=>un(n.getTransparentElements(),i),Nv=(n,i)=>Jn(i)&&tp(n,i.nodeName),ig=(n,i)=>Nv(n,i)&&ph(i),Iv=(n,i)=>Nv(n,i)&&!ph(i),rr=(n,i)=>i.type===1&&tp(n,i.name)&&L(i.attr(ep)),Ao=ys().browser,bh=n=>oo(n,kl),nb=n=>Ao.isFirefox()&&ti(n)==="table"?bh(Da(n)).filter(i=>ti(i)==="caption").bind(i=>bh(il(i)).map(c=>{const m=c.dom.offsetTop,p=i.dom.offsetTop,w=i.dom.offsetHeight;return m<=p?-w:0})).getOr(0):0,np=(n,i)=>n.children&&kt(n.children,i),WC=(n,i,c)=>{let m=0,p=0;const w=n.ownerDocument;if(c=c||n,i){if(c===n&&i.getBoundingClientRect&&Bi(Ke.fromDom(n),"position")==="static"){const M=i.getBoundingClientRect();return m=M.left+(w.documentElement.scrollLeft||n.scrollLeft)-w.documentElement.clientLeft,p=M.top+(w.documentElement.scrollTop||n.scrollTop)-w.documentElement.clientTop,{x:m,y:p}}let x=i;for(;x&&x!==c&&x.nodeType&&!np(x,c);){const M=x;m+=M.offsetLeft||0,p+=M.offsetTop||0,x=M.offsetParent}for(x=i.parentNode;x&&x!==c&&x.nodeType&&!np(x,c);)m-=x.scrollLeft||0,p-=x.scrollTop||0,x=x.parentNode;p+=nb(Ke.fromDom(i))}return{x:m,y:p}},Bv=(n,i={})=>{let c=0;const m={},p=Ke.fromDom(n),w=Eo(p),x=Me=>{i.referrerPolicy=Me},M=Me=>{i.contentCssCors=Me},B=Me=>{na(em(p),Me)},q=Me=>{const Ve=em(p);Je(Ve,"#"+Me).each(wr)},ae=Me=>wo(m,Me).getOrThunk(()=>({id:"mce-u"+c++,passed:[],failed:[],count:0})),fe=Me=>new Promise((Ve,gt)=>{let Ot;const wt=gn._addCacheSuffix(Me),Pt=ae(wt);m[wt]=Pt,Pt.count++;const hn=(Zt,yn)=>{Ne(Zt,Cn),Pt.status=yn,Pt.passed=[],Pt.failed=[],Ot&&(Ot.onload=null,Ot.onerror=null,Ot=null)},Hn=()=>hn(Pt.passed,2),$n=()=>hn(Pt.failed,3);if(Ve&&Pt.passed.push(Ve),gt&&Pt.failed.push(gt),Pt.status===1)return;if(Pt.status===2){Hn();return}if(Pt.status===3){$n();return}Pt.status=1;const Lt=Ke.fromTag("link",w.dom);Ju(Lt,{rel:"stylesheet",type:"text/css",id:Pt.id}),i.contentCssCors&&Pr(Lt,"crossOrigin","anonymous"),i.referrerPolicy&&Pr(Lt,"referrerpolicy",i.referrerPolicy),Ot=Lt.dom,Ot.onload=Hn,Ot.onerror=$n,B(Lt),Pr(Lt,"href",wt)}),be=Me=>Promise.allSettled(pt(Me,gt=>fe(gt).then(Qe(gt)))).then(gt=>{const Ot=bn(gt,wt=>wt.status==="fulfilled");return Ot.fail.length>0?Promise.reject(pt(Ot.fail,wt=>wt.reason)):pt(Ot.pass,wt=>wt.value)}),Le=Me=>{const Ve=gn._addCacheSuffix(Me);wo(m,Ve).each(gt=>{--gt.count===0&&(delete m[Ve],q(gt.id))})};return{load:fe,loadAll:be,unload:Le,unloadAll:Me=>{Ne(Me,Ve=>{Le(Ve)})},_setReferrerPolicy:x,_setContentCssCors:M}},Lv=(()=>{const n=new WeakMap;return{forElement:(c,m)=>{const w=ql(c).dom;return he Line truncated
Actual: `+be.join(","));if(!tr(i,Ye=>kt(be,Ye)))throw new Error("Not all branches were specified when using match. Specified: "+be.join(", ")+`
Required: `+i.join(", "));return fe[x].apply(null,B)},log:fe=>{console.log(fe,{constructors:i,constructor:x,params:B})}}}}),c}};pg.generate([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const ok=n=>{const i=[],c=[];return Ne(n,m=>{m.fold(p=>{i.push(p)},p=>{c.push(p)})}),{errors:i,values:c}},sk=n=>n.type==="inline-command"||n.type==="inline-format",r2=n=>n.type==="block-command"||n.type==="block-format",i2=n=>{const i=m=>bc.error({message:m,pattern:n}),c=(m,p,w)=>{if(n.format!==void 0){let x;if(oe(n.format)){if(!tr(n.format,L))return i(m+" pattern has non-string items in the `format` array");x=n.format}else if(L(n.format))x=[n.format];else return i(m+" pattern has non-string `format` parameter");return bc.value(p(x))}else return n.cmd!==void 0?L(n.cmd)?bc.value(w(n.cmd,n.value)):i(m+" pattern has non-string `cmd` parameter"):i(m+" pattern is missing both `format` and `cmd` parameters")};if(!te(n))return i("Raw pattern is not an object");if(!L(n.start))return i("Raw pattern is missing `start` parameter");if(n.end!==void 0){if(!L(n.end))return i("Inline pattern has non-string `end` parameter");if(n.start.length===0&&n.end.length===0)return i("Inline pattern has empty `start` and `end` parameters");let m=n.start,p=n.end;return p.length===0&&(p=m,m=""),c("Inline",w=>({type:"inline-format",start:m,end:p,format:w}),(w,x)=>({type:"inline-command",start:m,end:p,cmd:w,value:x}))}else return n.replacement!==void 0?L(n.replacement)?n.start.length===0?i("Replacement pattern has empty `start` parameter"):bc.value({type:"inline-command",start:"",end:n.start,cmd:"mceInsertContent",value:n.replacement}):i("Replacement pattern has non-string `replacement` parameter"):n.start.length===0?i("Block pattern has empty `start` parameter"):c("Block",m=>({type:"block-format",start:n.start,format:m[0]}),(m,p)=>({type:"block-command",start:n.start,cmd:m,value:p}))},hm=n=>At(n,r2),a2=n=>At(n,sk),r1=(n,i)=>({inlinePatterns:a2(n),blockPatterns:hm(n),dynamicPatternsLookup:i}),Ol=n=>{const i=ok(pt(n,i2));return Ne(i.errors,c=>console.error(c.message,c.pattern)),i.values},Pl=n=>i=>{const c=n(i);return Ol(c)},Tn=ys().deviceType,rk=Tn.isTouch(),nc=Qr.DOM,ik=n=>{const i=n.indexOf("=")>0?n.split(/[;,](?![^=;,]*(?:[;,]|$))/):n.split(",");return zn(i,(c,m)=>{const p=m.split("="),w=p[0],x=p.length>1?p[1]:w;return c[kc(w)]=kc(x),c},{})},l2=n=>K(n,RegExp),no=n=>i=>i.options.get(n),Pc=n=>L(n)||te(n),c2=(n,i="")=>c=>{const m=L(c);if(m)if(c.indexOf("=")!==-1){const p=ik(c);return{value:wo(p,n.id).getOr(i),valid:m}}else return{value:c,valid:m};else return{valid:!1,message:"Must be a string."}},fb=n=>{const i=n.options.register;i("id",{processor:"string",default:n.id}),i("selector",{processor:"string"}),i("target",{processor:"object"}),i("suffix",{processor:"string"}),i("cache_suffix",{processor:"string"}),i("base_url",{processor:"string"}),i("referrer_policy",{processor:"string",default:""}),i("language_load",{processor:"boolean",default:!0}),i("inline",{processor:"boolean",default:!1}),i("iframe_attrs",{processor:"object",default:{}}),i("doctype",{processor:"string",default:"<!DOCTYPE html>"}),i("document_base_url",{processor:"string",default:n.documentBaseUrl}),i("body_id",{processor:c2(n,"tinymce"),default:"tinymce"}),i("body_class",{processor:c2(n),default:""}),i("content_security_policy",{processor:"string",default:""}),i("br_in_pre",{processor:"boolean",default:!0}),i("forced_root_block",{processor:c=>{const m=L(c)&&yr(c);return m?{value:c,valid:m}:{valid:!1,message:"Must be a non-empty string."}},default:"p"}),i("forced_root_block_attrs",{processor:"object",default:{}}),i("newline_behavior",{processor:c=>{const m=kt(["block","linebreak","invert","default"],c);return m?{value:c,valid:m}:{valid:!1,message:"Must be one of: block, linebreak, invert or default."}},default:"default"}),i("br_newline_selector",{processor:"string",default:".mce-toc h2,figcaption,caption"}),i("no_newline_selector",{processor:"string",default:""}),i("keep_styles",{processor:"boolean",default:!0}),i("end_container_on_empty_block",{processor:c=>we(c)?{valid:!0,value:c}:L(c)?{valid:!0,value:c}:{valid:!1,message:"Must be boolean or a string"},default:"blockquote"}),i("font_size_style_values",{processor:"string",default:"xx-small,x-small,small,medium,large,x-large,xx-large"}),i("font_size_legacy_values",{processor:"string",default:"xx-small,small,medium,large,x-large,xx-large,300%"}),i("font_size_classes",{processor:"string",default:""}),i("automatic_uploads",{processor:"boolean",default:!0}),i("images_reuse_filename",{processor:"boolean",default:!1}),i("images_replace_blob_uris",{processor:"boolean",default:!0}),i("icons",{processor:"string",default:""}),i("icons_url",{processor:"string",default:""}),i("images_upload_url",{processor:"string",default:""}),i("images_upload_base_path",{processor:"string",default:""}),i("images_upload_credentials",{processor:"boolean",default:!1}),i("images_up Line truncated
+1 -1
View File
@@ -1,6 +1,6 @@
{
"main.js": {
"file": "assets/main.f303cf88.js",
"file": "assets/main.9f2d27e6.js",
"src": "main.js",
"isEntry": true,
"css": [
+1 -1
View File
@@ -2,7 +2,7 @@ export function sortByField(from, to, edges, fieldName) {
if (from === to) {
return edges;
}
let edgesTosort = edges?.filter((ed) => ed.field === fieldName && ed.depth === 1) ?? [];
let edgesTosort = edges?.filter((ed) => ed.field === fieldName && ed.depth === 1 ) ?? [];
let remainingEdge = edges?.filter((ed) => !(ed.field === fieldName && ed.depth === 1)) ?? [];
edgesTosort = array_move(edgesTosort,from, to);
+1
View File
@@ -18,6 +18,7 @@
easing: "cubic-bezier(1, 0, 0, 1)",
onUpdate: function (/**Event*/ evt) {
// reorder(evt.oldIndex,evt.newIndex);
console.log(evt)
dispatch("update", {
source: evt.oldIndex,
target: evt.newIndex,
@@ -17,7 +17,7 @@
$: references = graph.edges
.filter((edge) => edge.field === field.name)
.map((edge) => {
return graph.records.find((increc) => increc.id == edge.target && record.id == edge.source);
return graph.records.find((increc) => increc.id === edge.target && record.id === edge.source);
}).filter((rec) => (rec?.id ? true : false)) ?? [];
let collections = channel.schemas.filter((aschema) =>
@@ -21,6 +21,7 @@
.map((edge) => {
return graph.records.find((increc) => increc.id === edge.target && record.id === edge.source);
}).filter((rec) => (rec?.id ? true : false)) ?? [];
let collections = channel.schemas.filter((aschema) =>
field.collections.includes(aschema.name)
);
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace Lucent\Commands;
use Illuminate\Console\Command;
use Lucent\Edge\EdgeService;
use Lucent\Query\Query;
class RemoveOrphanEdges extends Command
{
protected $signature = 'lucent:removeOrphanEdges';
protected $description = 'Searches and remove orphan edges';
public function __construct(
)
{
parent::__construct();
}
public function handle(EdgeService $edgeService, Query $query): void
{
$edges = $edgeService->findAll();
foreach ($edges as $edge){
$source = $query->filter(["id" => $edge->source])->run()->records;
$target = $query->filter(["id" => $edge->target])->run()->records;
if($source->isEmpty() || $target->isEmpty()){
$this->info("Edge is orphan");
$edgeService->remove($edge);
}
}
}
}
+38 -2
View File
@@ -3,12 +3,16 @@
use Illuminate\Support\Facades\DB;
use Lucent\LucentException;
use PDOException;
use stdClass;
class EdgeRepo
{
public function __construct()
{
}
public static function insert(Edge $edge): void
public function insert(Edge $edge): void
{
try {
DB::table("edges")->insert($edge->toDB());
@@ -21,7 +25,7 @@ class EdgeRepo
}
public static function update(string $from, EdgeCollection $edges): void
public function update(string $from, EdgeCollection $edges): void
{
$edgesDB = collect($edges)->map(fn($e) => $e->toDB())->toArray();
DB::table("edges")->where("source", $from)->delete();
@@ -29,4 +33,36 @@ class EdgeRepo
}
public function findAll(): EdgeCollection
{
$edges = DB::table("edges")->get();
return new EdgeCollection(...$edges->map([$this, 'mapEdge'])->toArray());
}
public function mapEdge(stdClass $edge): Edge
{
return new Edge(
source: $edge->source,
target: $edge->target,
sourceSchema: $edge->sourceSchema,
targetSchema: $edge->targetSchema,
field: $edge->field,
rank: $edge->rank,
depth: $edge->depth ?? 0
);
}
public function remove(Edge $edge): void
{
DB::table("edges")
->where("source", $edge->source)
->where("target", $edge->target)
->where("sourceSchema", $edge->sourceSchema)
->where("targetSchema", $edge->targetSchema)
->where("field", $edge->field)
->delete();
}
}
+19 -3
View File
@@ -4,12 +4,14 @@ use Lucent\LucentException;
class EdgeService
{
public function __construct(public EdgeRepo $edgeRepo)
{
}
/**
* @throws LucentException
*/
public static function create(
public function create(
string $source,
string $target,
string $sourceSchema,
@@ -29,9 +31,23 @@ class EdgeService
field: $field,
rank: $rank,
);
EdgeRepo::insert($edge);
$this->edgeRepo->insert($edge);
return $edge;
}
public function update(string $from, EdgeCollection $edges): void
{
$this->edgeRepo->update($from, $edges);
}
public function findAll(): EdgeCollection
{
return $this->edgeRepo->findAll();
}
public function remove(Edge $edge): void
{
$this->edgeRepo->remove($edge);
}
}
+2
View File
@@ -10,6 +10,7 @@ use Lucent\Channel\ChannelService;
use Lucent\Commands\CompileSchemas;
use Lucent\Commands\LiveLink;
use Lucent\Commands\RebuildThumbnails;
use Lucent\Commands\RemoveOrphanEdges;
use Lucent\File\FileService;
use Lucent\File\ImageService;
use Lucent\Query\DatabaseGraph\DatabaseGraph;
@@ -68,6 +69,7 @@ class LucentServiceProvider extends ServiceProvider
CompileSchemas::class,
RebuildThumbnails::class,
LiveLink::class,
RemoveOrphanEdges::class,
]);
}
+9 -7
View File
@@ -7,7 +7,7 @@ use Lucent\Account\AuthService;
use Lucent\Channel\ChannelService;
use Lucent\Edge\Edge;
use Lucent\Edge\EdgeCollection;
use Lucent\Edge\EdgeRepo;
use Lucent\Edge\EdgeService;
use Lucent\File\FileService;
use Lucent\Id\Id;
use Lucent\LucentException;
@@ -28,7 +28,8 @@ readonly class RecordService
private Validator $recordValidator,
private Query $query,
private InputFormatter $inputFormatter,
private RecordRepo $recordRepo
private RecordRepo $recordRepo,
private EdgeService $edgeService
)
{
}
@@ -66,7 +67,8 @@ readonly class RecordService
$uniqueEdgesCollection = EdgeCollection::fromArray($uniqueEdges);
if ($uploadResult->isDuplicate) {
EdgeRepo::update($uploadResult->duplicateId, $uniqueEdgesCollection);
$this->edgeService->update($uploadResult->duplicateId, $uniqueEdgesCollection);
return $uploadResult->duplicateId;
}
@@ -87,8 +89,8 @@ readonly class RecordService
}
RecordRepo::create($record);
EdgeRepo::update($record->id, $uniqueEdgesCollection);
$this->revisionService->create($record,$uniqueEdgesCollection);
$this->edgeService->update($record->id, $uniqueEdgesCollection);
$this->revisionService->create($record, $uniqueEdgesCollection);
return $record->id;
}
@@ -150,10 +152,10 @@ readonly class RecordService
RecordRepo::update($newRecord);
if ($updateEdges) {
EdgeRepo::update($newRecord->id, $uniqueEdgesCollection);
$this->edgeService->update($newRecord->id, $uniqueEdgesCollection);
}
$this->revisionService->create($newRecord,$uniqueEdgesCollection);
$this->revisionService->create($newRecord, $uniqueEdgesCollection);
}