CoreFiles by mySites.guru
codemirror-lint.min.js1 lines, 16,753 bytes, from Joomla_6.1.2-Stable-Full_Package.zip
Raw History Compare with 6.1.1
md5
87216fb6f742d5c4826d917620dec636
sha1
d65b582456d5925d4e378f47419c0e478e379334
sha256
c7983dac815b62ec8f7aa0e31aebc802ddc9fac1f4cce2517acc92b98b6363e3
import{getPanel as re,showPanel as ae,EditorView as D,Decoration as T,ViewPlugin as ce,gutter as fe,showTooltip as de,hoverTooltip as ue,GutterMarker as me,WidgetType as he,logException as ge}from"@codemirror/view";import{RangeSet as I,StateEffect as S,StateField as E,Facet as $,combineConfig as K,RangeSetBuilder as pe}from"@codemirror/state";function x(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var o=n[i];typeof o=="string"?t.setAttribute(i,o):o!=null&&(t[i]=o)}e++}for(;e<arguments.length;e++)N(t,arguments[e]);return t}function N(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var n=0;n<e.length;n++)N(t,e[n]);else throw new RangeError("Unsupported child node: "+e)}class V{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}}class C{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let o=i.facet(y).markerFilter;o&&(e=o(e,i));let s=e.slice().sort((u,b)=>u.from-b.from||u.to-b.to),r=new pe,l=[],a=0,c=i.doc.iter(),d=0,w=i.doc.length;for(let u=0;;){let b=u==s.length?null:s[u];if(!b&&!l.length)break;let g,m;if(l.length)g=a,m=l.reduce((f,k)=>Math.min(f,k.to),b&&b.from>g?b.from:1e8);else{if(g=b.from,g>w)break;m=b.to,l.push(b),u++}for(;u<s.length;){let f=s[u];if(f.from==g&&(f.to>f.from||f.to==g))l.push(f),u++,m=Math.min(f.to,m);else{m=Math.min(f.from,m);break}}m=Math.min(m,w);let L=!1;if(l.some(f=>f.from==g&&(f.to==m||m==w))&&(L=g==m,!L&&m-g<10)){let f=g-(d+c.value.length);f>0&&(c.next(f),d=g);for(let k=g;;){if(k>=m){L=!0;break}if(!c.lineBreak&&d+c.value.length>k)break;k=d+c.value.length,d+=c.value.length,c.next()}}let z=ne(l);if(L)r.add(g,g,T.widget({widget:new Se(z),diagnostics:l.slice()}));else{let f=l.reduce((k,H)=>H.markClass?k+" "+H.markClass:k,"");r.add(g,m,T.mark({class:"cm-lintRange cm-lintRange-"+z+f,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>m)}))}if(a=m,a==w)break;for(let f=0;f<l.length;f++)l[f].to<=a&&l.splice(f--,1)}let p=r.finish();return new C(p,n,v(p))}}function v(t,e=null,n=0){let i=null;return t.between(n,1e9,(o,s,{spec:r})=>{if(!(e&&r.diagnostics.indexOf(e)<0))if(!i)i=new V(o,s,e||r.diagnostics[0]);else{if(r.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new V(i.from,s,i.diagnostic)}}),i}function Y(t,e){let n=e.pos,i=e.end||n,o=t.state.facet(y).hideOn(t,n,i);if(o!=null)return o;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(r=>r.is(P))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function _(t,e){return t.field(h,!1)?e:e.concat(S.appendConfig.of(le))}function q(t,e){return{effects:_(t,[P.of(e)])}}const P=S.define(),O=S.define(),U=S.define(),h=E.define({create(){return new C(T.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,o=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=v(n,t.selected.diagnostic,s)||v(n,null,s)}!n.size&&o&&e.state.facet(y).autoPanel&&(o=null),t=new C(n,o,i)}for(let n of e.effects)if(n.is(P)){let i=e.state.facet(y).autoPanel?n.value.length?R.open:null:t.panel;t=C.init(n.value,i,e.state)}else n.is(O)?t=new C(t.diagnostics,n.value?R.open:null,t.selected):n.is(U)&&(t=new C(t.diagnostics,t.panel,n.value));return t},provide:t=>[ae.from(t,e=>e.panel),D.decorations.from(t,e=>e.diagnostics)]});function be(t){let e=t.field(h,!1);return e?e.diagnostics.size:0}const we=T.mark({class:"cm-lintRange cm-lintRange-active"});function ke(t,e,n){let{diagnostics:i}=t.state.field(h),o,s=-1,r=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(a,c,{spec:d})=>{if(e>=a&&e<=c&&(a==c||(e>a||n>0)&&(e<c||n<0)))return o=d.diagnostics,s=a,r=c,!1});let l=t.state.facet(y).tooltipFilter;return o&&l&&(o=l(o,t.state)),o?{pos:s,end:r,above:t.state.doc.lineAt(s).to<r,create(){return{dom:W(t,o)}}}:null}function W(t,e){return x("ul",{class:"cm-tooltip-lint"},e.map(n=>te(t,n,!1)))}const Z=t=>{let e=t.state.field(h,!1);(!e||!e.panel)&&t.dispatch({effects:_(t.state,[O.of(!0)])});let n=re(t,R.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},B=t=>{let e=t.state.field(h,!1);return!e||!e.panel?!1:(t.dispatch({effects:O.of(!1)}),!0)},X=t=>{let e=t.state.field(h,!1);if(!e)return!1;let n=t.state.selection.main,i=v(e.diagnostics,null,n.to+1);return!i&&(i=v(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},xe=t=>{let{state:e}=t,n=e.field(h,!1);if(!n)return!1;let i=e.selection.main,o,s,r,l;return n.diagnostics.between(0,e.doc.length,(a,c)=>{c<i.to&&(o==null||o<a)&&(o=a,s=c),(r==null||a>r)&&(r=a,l=c)}),r==null||o==null&&r==i.from?!1:(t.dispatch({selection:{anchor:o??r,head:s??l},scrollIntoView:!0}),!0)},ye=[{key:"Mod-Shift-m",run:Z,preventDefault:!0},{key:"F8",run:X}],J=ce.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(y);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:n}=e.facet(y);n.length&&ve(n.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(q(this.view.state,i.reduce((o,s)=>o.concat(s))))},i=>{ge(this.view.state,i)})}}update(t){let e=t.state.facet(y);(t.docChanged||e!=t.startState.facet(y)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function ve(t,e,n){let i=[],o=-1;for(let s of t)s.then(r=>{i.push(r),clearTimeout(o),i.length==t.length?e(i):o=setTimeout(()=>e(i),200)},n)}const y=$.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...K(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Q,tooltipFilter:Q,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,o,s)=>e(i,o,s)||n(i,o,s):e:n,autoPanel:(e,n)=>e||n})}}});function Q(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function Ce(t,e={}){return[y.of({source:t,config:e}),J,le]}function Te(t){let e=t.plugin(J);e&&e.force()}function ee(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let o=n[i];if(/[a-zA-Z]/.test(o)&&!e.some(s=>s.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function te(t,e,n){var i;let o=n?ee(e.actions):[];return x("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},x("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,r)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let b=v(t.state.field(h).diagnostics,e);b&&s.apply(t,b.from,b.to)},{name:c}=s,d=o[r]?c.indexOf(o[r]):-1,w=d<0?c:[c.slice(0,d),x("u",c.slice(d,d+1)),c.slice(d+1)],p=s.markClass?" "+s.markClass:"";return x("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${d<0?"":` (access key "${o[r]})"`}.`},w)}),e.source&&x("div",{class:"cm-diagnosticSource"},e.source))}class Se extends he{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return x("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ie{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=te(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class R{constructor(e){this.view=e,this.items=[];let n=o=>{if(!(o.ctrlKey||o.altKey||o.metaKey)){if(o.keyCode==27)B(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],r=ee(s.actions);for(let l=0;l<r.length;l++)if(r[l].toUpperCase().charCodeAt(0)==o.keyCode){let a=v(this.view.state.field(h).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;o.preventDefault()}},i=o=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(o.target)&&this.moveSelection(s)};this.list=x("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=x("div",{class:"cm-panel-lint"},this.list,x("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>B(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(h).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(h),i=0,o=!1,s=null,r=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:c})=>{for(let d of c.diagnostics){if(r.has(d))continue;r.add(d);let w=-1,p;for(let u=i;u<this.items.length;u++)if(this.items[u].diagnostic==d){w=u;break}w<0?(p=new ie(this.view,d),this.items.splice(i,0,p),o=!0):(p=this.items[w],w>i&&(this.items.splice(i,w-i),o=!0)),n&&p.diagnostic==n.diagnostic?p.dom.hasAttribute("aria-selected")||(p.dom.setAttribute("aria-selected","true"),s=p):p.dom.hasAttribute("aria-selected")&&p.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();this.items.length==0&&(this.items.push(new ie(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/c:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(h),i=v(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:U.of(i)})}static open(e){return new R(e)}}function M(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function A(t){return M(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Pe=D.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:A("#d11")},".cm-lintRange-warning":{backgroundImage:A("orange")},".cm-lintRange-info":{backgroundImage:A("#999")},".cm-lintRange-hint":{backgroundImage:A("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Re(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function ne(t){let e="hint",n=1;for(let i of t){let o=Re(i.severity);o>n&&(n=o,e=i.severity)}return e}class oe extends me{constructor(e){super(),this.diagnostics=e,this.severity=ne(e)}toDOM(e){let n=document.createElement("div");n.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,o=e.state.facet(F).tooltipFilter;return o&&(i=o(i,e.state)),i.length&&(n.onmouseover=()=>De(e,n,i)),n}}function Le(t,e){let n=i=>{let o=e.getBoundingClientRect();if(!(i.clientX>o.left-10&&i.clientX<o.right+10&&i.clientY>o.top-10&&i.clientY<o.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),t.state.field(se)&&t.dispatch({effects:j.of(null)})}};window.addEventListener("mousemove",n)}function De(t,e,n){function i(){let r=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(r.from)&&t.dispatch({effects:j.of({pos:r.from,above:!1,clip:!1,create(){return{dom:W(t,n),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Le(t,e)}let{hoverTime:o}=t.state.facet(F),s=setTimeout(i,o);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,o)}}function Me(t,e){let n=Object.create(null);for(let o of e){let s=t.lineAt(o.from);(n[s.from]||(n[s.from]=[])).push(o)}let i=[];for(let o in n)i.push(new oe(n[o]).range(+o));return I.of(i,!0)}const Ae=fe({class:"cm-gutter-lint",markers:t=>t.state.field(G),widgetMarker:(t,e,n)=>{let i=[];return t.state.field(G).between(n.from,n.to,(o,s,r)=>{o>n.from&&o<n.to&&i.push(...r.diagnostics)}),i.length?new oe(i):null}}),G=E.define({create(){return I.empty},update(t,e){t=t.map(e.changes);let n=e.state.facet(F).markerFilter;for(let i of e.effects)if(i.is(P)){let o=i.value;n&&(o=n(o||[],e.state)),t=Me(e.state.doc,o.slice(0))}return t}}),j=S.define(),se=E.define({create(){return null},update(t,e){return t&&e.docChanged&&(t=Y(e,t)?null:{...t,pos:e.changes.mapPos(t.pos)}),e.effects.reduce((n,i)=>i.is(j)?i.value:n,t)},provide:t=>de.from(t)}),Fe=D.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:M('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:M('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:M('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),le=[h,D.decorations.compute([h],t=>{let{selected:e,panel:n}=t.field(h);return!e||!n||e.from==e.to?T.none:T.set([we.range(e.from,e.to)])}),ue(ke,{hideOn:Y}),Pe],F=$.define({combine(t){return K(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Ie(t={}){return[F.of(t),G,Ae,Fe,se]}function Ee(t,e){let n=t.field(h,!1);if(n&&n.diagnostics.size){let i=[],o=[],s=-1;for(let r=I.iter([n.diagnostics]);;r.next()){for(let l=0;l<i.length;l++)(!r.value||r.value.spec.diagnostics.indexOf(i[l])<0)&&(e(i[l],o[l],s),i.splice(l,1),o.splice(l--,1));if(!r.value)break;for(let l of r.value.spec.diagnostics)i.indexOf(l)<0&&(i.push(l),o.push(r.from));s=r.to}}}export{B as closeLintPanel,be as diagnosticCount,Ee as forEachDiagnostic,Te as forceLinting,Ie as lintGutter,ye as lintKeymap,Ce as linter,X as nextDiagnostic,Z as openLintPanel,xe as previousDiagnostic,q as setDiagnostics,P as setDiagnosticsEffect};

The same content is in 17 releases, Joomla 6.1.0-beta2 to 6.1.4. See them all, or every version of this file.