ui/tokens.css from the server's dev (tokens.lock.json; repin to the beta tag at release). scripts/fetch-vendor.sh copies the server's vendored CodeMirror and Lezer modules into ui/vendor/, each checked against the server's own pin first, with the bare module names rewritten to sibling files (the page has no import map); vendor.lock.json records both hashes, and the script with no argument verifies the copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 lines
21 KiB
JavaScript
4 lines
21 KiB
JavaScript
/* esm.sh - @codemirror/search@6.7.2 */
|
|
import{getDialog as ge,showDialog as xe,EditorView as M,Decoration as m,ViewPlugin as ie,showPanel as ye,runScopeHandlers as Me,getPanel as se}from"./cm-view.mjs";import{codePointAt as ve,fromCodePoint as Se,codePointSize as be,EditorSelection as g,Facet as le,combineConfig as oe,CharCategory as p,StateEffect as G,StateField as Ce,RangeSetBuilder as ke,Prec as Le,EditorState as We,findClusterBreak as ce}from"./cm-state.mjs";function u(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){var i=r[n];typeof i=="string"?t.setAttribute(n,i):i!=null&&(t[n]=i)}e++}for(;e<arguments.length;e++)ee(t,arguments[e]);return t}function ee(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 r=0;r<e.length;r++)ee(t,e[r]);else throw new RangeError("Unsupported child node: "+e)}var te=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t,y=class{constructor(e,r,n=0,i=e.length,s,l){this.test=l,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=s?o=>s(te(o)):te,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ve(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=Se(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=be(e);let i=this.normalize(r);if(i.length)for(let s=0,l=n,o=!0;;s++){let c=i.charCodeAt(s),a=this.match(c,l,o,this.bufferPos+this.bufferStart,s==i.length-1);if(a)return this.value=a,this;if(s==i.length-1)break;o&&s<r.length&&r.charCodeAt(s)==c?l++:o=!1}}}match(e,r,n,i,s){let l=null;for(let o=0;o<this.matches.length;){let c=this.matches[o],a=!1;this.query.charCodeAt(c.index)==e&&(c.index==this.query.length-1?l={from:c.from,to:i,precise:s&&c.precise}:(c.index++,a=!0)),a?o++:this.matches.splice(o,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?l={from:r,to:i,precise:n&&s}:this.matches.push({from:r,index:1,precise:n})),l&&this.test&&!this.test(l.from,l.to,this.buffer,this.bufferStart)&&(l=null),l}};typeof Symbol<"u"&&(y.prototype[Symbol.iterator]=function(){return this});var ae={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Q="gm"+(/x/.unicode==null?"":"u"),q=class{constructor(e,r,n,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=ae,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new E(e,r,n,i,s);this.re=new RegExp(r,Q+(n?.ignoreCase?"i":"")),this.test=n?.test,this.iter=e.iter();let l=e.lineAt(i);this.curLineStart=l.from,this.matchPos=R(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=R(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},B=new WeakMap,w=class t{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let i=B.get(e);if(!i||i.from>=n||i.to<=r){let o=new t(r,e.sliceString(r,n));return B.set(e,o),o}if(i.from==r&&i.to==n)return i;let{text:s,from:l}=i;return l>r&&(s=e.sliceString(r,l)+s,l=r),i.to<n&&(s+=e.sliceString(i.to,n)),B.set(e,new t(l,s)),new t(r,s.slice(r-l,n-l))}},E=class{constructor(e,r,n,i,s){this.text=e,this.to=s,this.done=!1,this.value=ae,this.matchPos=R(e,i),this.re=new RegExp(r,Q+(n?.ignoreCase?"i":"")),this.test=n?.test,this.flat=w.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,i=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this.matchPos=R(this.text,i+(n==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=w.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(q.prototype[Symbol.iterator]=E.prototype[Symbol.iterator]=function(){return this});function Ae(t){try{return new RegExp(t,Q),!0}catch{return!1}}function R(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}var Fe=t=>{let e=ge(t,"cm-goto-line");if(e){let l=e.dom.querySelector("input[type=text]");return l&&l.select(),!0}let{state:r}=t,n=String(r.doc.lineAt(t.state.selection.main.head).number),{close:i,result:s}=xe(t,{class:"cm-goto-line",label:r.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:r.phrase("go")});return s.then(l=>{let o=l&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(l.elements.line.value);if(!o){t.dispatch({effects:i});return}let c=r.doc.lineAt(r.selection.main.head),[,a,h,f,A]=o,pe=f?+f.slice(1):0,C=h?+h:c.number;if(h&&A){let z=C/100;a&&(z=z*(a=="-"?-1:1)+c.number/r.doc.lines),C=Math.round(r.doc.lines*z)}else h&&a&&(C=C*(a=="-"?-1:1)+c.number);let Y=r.doc.line(Math.max(1,Math.min(r.doc.lines,C))),Z=g.cursor(Y.from+Math.max(0,Math.min(pe,Y.length)));t.dispatch({effects:[i,M.scrollIntoView(Z.from,{y:"center"})],selection:Z})}),!0},De={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},he=le.define({combine(t){return oe(t,De,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function Ze(t){let e=[Pe,Re];return t&&e.push(he.of(t)),e}var qe=m.mark({class:"cm-selectionMatch"}),we=m.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function re(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=p.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=p.Word)}function Ee(t,e,r,n){return t(e.sliceDoc(r,r+1))==p.Word&&t(e.sliceDoc(n-1,n))==p.Word}var Re=ie.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(he),{state:r}=t,n=r.selection;if(n.ranges.length>1)return m.none;let i=n.main,s,l=null;if(i.empty){if(!e.highlightWordAroundCursor)return m.none;let c=r.wordAt(i.head);if(!c)return m.none;l=r.charCategorizer(i.head),s=r.sliceDoc(c.from,c.to)}else{let c=i.to-i.from;if(c<e.minSelectionLength||c>200)return m.none;if(e.wholeWords){if(s=r.sliceDoc(i.from,i.to),l=r.charCategorizer(i.head),!(re(l,r,i.from,i.to)&&Ee(l,r,i.from,i.to)))return m.none}else if(s=r.sliceDoc(i.from,i.to),!s)return m.none}let o=[];for(let c of t.visibleRanges){let a=new y(r.doc,s,c.from,c.to);for(;!a.next().done;){let{from:h,to:f}=a.value;if((!l||re(l,r,h,f))&&(i.empty&&h<=i.from&&f>=i.to?o.push(we.range(h,f)):(h>=i.to||f<=i.from)&&o.push(qe.range(h,f)),o.length>e.maxMatches))return m.none}}return m.set(o)}},{decorations:t=>t.decorations}),Pe=M.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Ie=({state:t,dispatch:e})=>{let{selection:r}=t,n=g.create(r.ranges.map(i=>t.wordAt(i.head)||g.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function Te(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),s=i&&i.from==r.from&&i.to==r.to;for(let l=!1,o=new y(t.doc,e,n[n.length-1].to);;)if(o.next(),o.done){if(l)return null;o=new y(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),l=!0}else{if(l&&n.some(c=>c.from==o.value.from))continue;if(s){let c=t.wordAt(o.value.from);if(!c||c.from!=o.value.from||c.to!=o.value.to)continue}return o.value}}var Oe=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(s=>s.from===s.to))return Ie({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=n))return!1;let i=Te(t,n);return i?(e(t.update({selection:t.selection.addRange(g.range(i.from,i.to),!1),effects:M.scrollIntoView(i.to)})),!0):!1},v=le.define({combine(t){return oe(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new K(e),scrollToMatch:e=>M.scrollIntoView(e)})}});function et(t){return t?[v.of(t),j]:j}var P=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Ae(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
|
|
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new H(this):new V(this)}getCursor(e,r=0,n){let i=e.doc?e:We.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?b(this,i,r,n):S(this,i,r,n)}},I=class{constructor(e){this.spec=e}};function $e(t,e,r){return(n,i,s,l)=>{if(r&&!r(n,i,s,l))return!1;let o=n>=l&&i<=l+s.length?s.slice(n-l,i-l):e.doc.sliceString(n,i);return t(o,e,n,i)}}function S(t,e,r,n){let i;return t.wholeWord&&(i=_e(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=$e(t.test,e,i)),new y(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:s=>s.toLowerCase(),i)}function _e(t,e){return(r,n,i,s)=>((s>r||s+i.length<n)&&(s=Math.max(0,r-2),i=t.sliceString(s,Math.min(t.length,n+2))),(e(T(i,r-s))!=p.Word||e(O(i,r-s))!=p.Word)&&(e(O(i,n-s))!=p.Word||e(T(i,n-s))!=p.Word))}var V=class extends I{constructor(e){super(e)}nextMatch(e,r,n){let i=S(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,r+this.spec.unquoted.length);i=S(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==r&&i.value.to==n?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let s=Math.max(r,i-1e4-this.spec.unquoted.length),l=S(this.spec,e,s,i),o=null;for(;!l.nextOverlapping().done;)o=l.value;if(o)return o;if(s==r)return null;i-=1e4}}prevMatch(e,r,n){let i=this.prevMatchInRange(e,0,r);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=r||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=S(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let s=S(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}};function Ne(t,e,r){return(n,i,s)=>(!r||r(n,i,s))&&t(s[0],e,n,i)}function b(t,e,r,n){let i;return t.wholeWord&&(i=ze(e.charCategorizer(e.selection.main.head))),t.test&&(i=Ne(t.test,e,i)),new q(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},r,n)}function T(t,e){return t.slice(ce(t,e,!1),e)}function O(t,e){return t.slice(e,ce(t,e))}function ze(t){return(e,r,n)=>!n[0].length||(t(T(n.input,n.index))!=p.Word||t(O(n.input,n.index))!=p.Word)&&(t(O(n.input,n.index+n[0].length))!=p.Word||t(T(n.input,n.index+n[0].length))!=p.Word)}var H=class extends I{nextMatch(e,r,n){let i=b(this.spec,e,n,e.doc.length).next();return i.done&&(i=b(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let s=Math.max(r,n-i*1e4),l=b(this.spec,e,s,n),o=null;for(;!l.next().done;)o=l.value;if(o&&(s==r||o.from>s+10))return o;if(s==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let s=+n.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+n.slice(i)}return r})}matchAll(e,r){let n=b(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let s=b(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}},L=G.define(),U=G.define(),x=Ce.define({create(t){return new k(N(t).create(),null)},update(t,e){for(let r of e.effects)r.is(L)?t=new k(r.value.create(),t.panel):r.is(U)&&(t=new k(t.query,r.value?J:null));return t},provide:t=>ye.from(t,e=>e.panel)});function tt(t){let e=t.field(x,!1);return e?e.query.spec:N(t)}function rt(t){var e;return((e=t.field(x,!1))===null||e===void 0?void 0:e.panel)!=null}var k=class{constructor(e,r){this.query=e,this.panel=r}},Be=m.mark({class:"cm-searchMatch"}),Ve=m.mark({class:"cm-searchMatch cm-searchMatch-selected"}),He=ie.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(x))}update(t){let e=t.state.field(x);(e!=t.startState.field(x)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return m.none;let{view:r}=this,n=new ke;for(let i=0,s=r.visibleRanges,l=s.length;i<l;i++){let{from:o,to:c}=s[i];for(;i<l-1&&c>s[i+1].from-500;)c=s[++i].to;t.highlight(r.state,o,c,(a,h)=>{let f=r.state.selection.ranges.some(A=>A.from==a&&A.to==h);n.add(a,h,f?Ve:Be)})}return n.finish()}},{decorations:t=>t.decorations});function W(t){return e=>{let r=e.state.field(x,!1);return r&&r.query.spec.valid?t(e,r):de(e)}}var $=W((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let i=g.single(n.from,n.to),s=t.state.facet(v);return t.dispatch({selection:i,effects:[X(t,n),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),fe(t),!0}),_=W((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,i=e.prevMatch(r,n,n);if(!i)return!1;let s=g.single(i.from,i.to),l=t.state.facet(v);return t.dispatch({selection:s,effects:[X(t,i),l.scrollToMatch(s.main,t)],userEvent:"select.search"}),fe(t),!0}),Ke=W((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:g.create(r.map(n=>g.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),je=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,s=[],l=0;for(let o=new y(t.doc,t.sliceDoc(n,i));!o.next().done;){if(s.length>1e3)return!1;o.value.from==n&&(l=s.length),s.push(g.range(o.value.from,o.value.to))}return e(t.update({selection:g.create(s,l),userEvent:"select.search.matches"})),!0},ne=W((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let s=e.nextMatch(r,n,n);if(!s)return!1;let l=s,o=[],c,a,h=[];l.precise?l.from==n&&l.to==i&&(a=r.toText(e.getReplacement(l)),o.push({from:l.from,to:l.to,insert:a}),l=e.nextMatch(r,l.from,l.to),h.push(M.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+"."))):l=e.nextMatch(r,l.from,l.to);let f=t.state.changes(o);return l&&(c=g.single(l.from,l.to).map(f),h.push(X(t,l)),h.push(r.facet(v).scrollToMatch(c.main,t))),t.dispatch({changes:f,selection:c,effects:h,userEvent:"input.replace"}),!0}),Ge=W((t,{query:e})=>{if(t.state.readOnly)return!1;let r=[];for(let i of e.matchAll(t.state,1e9)){let{from:s,to:l,precise:o}=i;o&&r.push({from:s,to:l,insert:e.getReplacement(i)})}if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:M.announce.of(n),userEvent:"input.replace.all"}),!0});function J(t){return t.state.facet(v).createPanel(t)}function N(t,e){var r,n,i,s,l;let o=t.selection.main,c=o.empty||o.to>o.from+100?"":t.sliceDoc(o.from,o.to);if(e&&!c)return e;let a=t.facet(v);return new P({search:((r=e?.literal)!==null&&r!==void 0?r:a.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:a.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:a.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:a.regexp,wholeWord:(l=e?.wholeWord)!==null&&l!==void 0?l:a.wholeWord})}function ue(t){let e=se(t,J);return e&&e.dom.querySelector("[main-field]")}function fe(t){let e=ue(t);e&&e==t.root.activeElement&&e.select()}var de=t=>{let e=t.state.field(x,!1);if(e&&e.panel){let r=ue(t);if(r&&r!=t.root.activeElement){let n=N(t.state,e.query.spec);n.valid&&t.dispatch({effects:L.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[U.of(!0),e?L.of(N(t.state,e.query.spec)):G.appendConfig.of(j)]});return!0},me=t=>{let e=t.state.field(x,!1);if(!e||!e.panel)return!1;let r=se(t,J);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:U.of(!1)}),!0},nt=[{key:"Mod-f",run:de,scope:"editor search-panel"},{key:"F3",run:$,shift:_,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:$,shift:_,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:me,scope:"editor search-panel"},{key:"Mod-Shift-l",run:je},{key:"Mod-Alt-g",run:Fe},{key:"Mod-d",run:Oe,preventDefault:!0}],K=class{constructor(e){this.view=e;let r=this.query=e.state.field(x).query.spec;this.commit=this.commit.bind(this),this.searchField=u("input",{value:r.search,placeholder:d(e,"Find"),"aria-label":d(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=u("input",{value:r.replace,placeholder:d(e,"Replace"),"aria-label":d(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=u("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=u("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=u("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(i,s,l){return u("button",{class:"cm-button",name:i,onclick:s,type:"button"},l)}this.dom=u("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>$(e),[d(e,"next")]),n("prev",()=>_(e),[d(e,"previous")]),n("select",()=>Ke(e),[d(e,"all")]),u("label",null,[this.caseField,d(e,"match case")]),u("label",null,[this.reField,d(e,"regexp")]),u("label",null,[this.wordField,d(e,"by word")]),...e.state.readOnly?[]:[u("br"),this.replaceField,n("replace",()=>ne(e),[d(e,"replace")]),n("replaceAll",()=>Ge(e),[d(e,"replace all")])],u("button",{name:"close",onclick:()=>me(e),"aria-label":d(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new P({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:L.of(e)}))}keydown(e){Me(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?_:$)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ne(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(L)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(v).top}};function d(t,e){return t.state.phrase(e)}var F=30,D=/[\s\.,:;?!]/;function X(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),i=t.state.doc.lineAt(r).to,s=Math.max(n.from,e-F),l=Math.min(i,r+F),o=t.state.sliceDoc(s,l);if(s!=n.from){for(let c=0;c<F;c++)if(!D.test(o[c+1])&&D.test(o[c])){o=o.slice(c);break}}if(l!=i){for(let c=o.length-1;c>o.length-F;c--)if(!D.test(o[c-1])&&D.test(o[c])){o=o.slice(0,c);break}}return M.announce.of(`${t.state.phrase("current match")}. ${o} ${t.state.phrase("on line")} ${n.number}.`)}var Qe=M.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),j=[x,Le.low(He),Qe];export{q as RegExpCursor,y as SearchCursor,P as SearchQuery,me as closeSearchPanel,$ as findNext,_ as findPrevious,tt as getSearchQuery,Fe as gotoLine,Ze as highlightSelectionMatches,de as openSearchPanel,Ge as replaceAll,ne as replaceNext,et as search,nt as searchKeymap,rt as searchPanelOpen,Ke as selectMatches,Oe as selectNextOccurrence,je as selectSelectionMatches,L as setSearchQuery};
|
|
//# sourceMappingURL=search.bundle.mjs.map
|