@actualwave/react-native-codeditor 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +53 -3
- package/SKILL.md +469 -0
- package/THIRD_PARTY_NOTICES +120 -0
- package/app.plugin.js +1 -1
- package/lib/module/CodeEditor.js +73 -2
- package/lib/module/WebViewAPI.js +4 -0
- package/lib/typescript/src/CodeEditor.d.ts +21 -2
- package/lib/typescript/src/EditorAPI.d.ts +44 -1
- package/lib/typescript/src/WebViewAPI.d.ts +5 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/package.json +12 -4
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-core.js +39 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-css.js +19 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-glsl.js +1 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-graphql.js +50 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-icu-messageformat.js +1 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-react-native.js +6 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-sksl.js +7 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-sql.js +5 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-embed-tailwind.js +63 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-glsl.js +20 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-icu-messageformat.js +11 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-react-native.js +71 -0
- package/src/assets/codemirror/@actualwave_codemirror-lang-sksl.js +7 -2
- package/src/assets/codemirror/@codemirror_autocomplete.js +9 -9
- package/src/assets/codemirror/@codemirror_commands.js +86 -86
- package/src/assets/codemirror/@codemirror_lang-css.js +2 -2
- package/src/assets/codemirror/@codemirror_lang-go.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-html.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-javascript.js +4 -4
- package/src/assets/codemirror/@codemirror_lang-jinja.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-json.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-less.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-liquid.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-markdown.js +2 -2
- package/src/assets/codemirror/@codemirror_lang-python.js +1 -1
- package/src/assets/codemirror/@codemirror_lang-sql.js +4 -4
- package/src/assets/codemirror/@codemirror_lang-xml.js +1 -1
- package/src/assets/codemirror/@codemirror_language.js +11 -11
- package/src/assets/codemirror/@codemirror_legacy-modes_mode_clike.js +1 -1
- package/src/assets/codemirror/@codemirror_legacy-modes_mode_mathematica.js +1 -1
- package/src/assets/codemirror/@codemirror_legacy-modes_mode_oz.js +1 -1
- package/src/assets/codemirror/@codemirror_legacy-modes_mode_verilog.js +1 -1
- package/src/assets/codemirror/@codemirror_lint.js +5 -5
- package/src/assets/codemirror/@codemirror_merge.js +4 -4
- package/src/assets/codemirror/@codemirror_search.js +8 -8
- package/src/assets/codemirror/@codemirror_state.js +1 -1
- package/src/assets/codemirror/@codemirror_theme-one-dark.js +3 -3
- package/src/assets/codemirror/@codemirror_view.js +6 -6
- package/src/assets/codemirror/@lezer_common.js +2 -2
- package/src/assets/codemirror/@lezer_css.js +1 -1
- package/src/assets/codemirror/@lezer_javascript.js +1 -1
- package/src/assets/codemirror/@lezer_lr.js +1 -1
- package/src/assets/codemirror/@lezer_markdown.js +4 -4
- package/src/assets/codemirror/@lezer_sass.js +1 -1
- package/src/assets/codemirror/_core.js +129 -129
- package/src/assets/codemirror-editor.umd.js +130 -17
- package/src/assets/editor.html +49 -2
- package/lib/typescript/app.plugin.d.ts +0 -3
- package/lib/typescript/babel.config.d.ts +0 -10
- package/lib/typescript/react-native.config.d.ts +0 -2
- package/lib/typescript/scripts/copy-assets.d.ts +0 -2
|
@@ -12,7 +12,7 @@ async function moduleInitFunction(requireAsyncModule,exports={}){const module={e
|
|
|
12
12
|
function ensureAnchor(expr,start){var _a;let{source}=expr,addStart=start&&"^"!=source[0],addEnd="$"!=source[source.length-1];return addStart||addEnd?new RegExp(`${addStart?"^":""}(?:${source})${addEnd?"$":""}`,null!==(_a=expr.flags)&&void 0!==_a?_a:expr.ignoreCase?"i":""):expr}/**
|
|
13
13
|
This annotation is added to transactions that are produced by
|
|
14
14
|
picking a completion.
|
|
15
|
-
|
|
15
|
+
*//**
|
|
16
16
|
Helper function that returns a transaction spec which inserts a
|
|
17
17
|
completion's text in the main selection range, and any other
|
|
18
18
|
selection range that has the same text in front of it.
|
|
@@ -54,7 +54,7 @@ function score(option){return 100*(option.boost||0)+(option.apply?10:0)+(option.
|
|
|
54
54
|
interpreted as indicating a placeholder.
|
|
55
55
|
*/function snippet(template){let snippet=Snippet.parse(template);return(editor,completion,from,to)=>{let{text,ranges}=snippet.instantiate(editor.state,from),{main}=editor.state.selection,spec={changes:{from,to:to==main.from?main.to:to,insert:state.Text.of(text)},scrollIntoView:!0,annotations:completion?[pickedCompletion.of(completion),state.Transaction.userEvent.of("input.complete")]:void 0};if(ranges.length&&(spec.selection=fieldSelection(ranges,0)),ranges.some(r=>0<r.field)){let active=new ActiveSnippet(ranges,0),effects=spec.effects=[setActive.of(active)];void 0===editor.state.field(snippetState,!1)&&effects.push(state.StateEffect.appendConfig.of([snippetState,addSnippetKeymap,snippetPointerHandler,baseTheme]))}editor.dispatch(editor.state.update(spec))}}function moveField(dir){return({state,dispatch})=>{let active=state.field(snippetState,!1);if(!active||0>dir&&0==active.active)return!1;let next=active.active+dir,last=0<dir&&!active.ranges.some(r=>r.field==next+dir);return dispatch(state.update({selection:fieldSelection(active.ranges,next),effects:setActive.of(last?null:new ActiveSnippet(active.ranges,next)),scrollIntoView:!0})),!0}}/**
|
|
56
56
|
A command that clears the active snippet, if any.
|
|
57
|
-
|
|
57
|
+
*//**
|
|
58
58
|
Check if there is an active snippet with a next field for
|
|
59
59
|
`nextSnippetField` to move to.
|
|
60
60
|
*/function hasNextSnippetField(state){let active=state.field(snippetState,!1);return!!(active&&active.ranges.some(r=>r.field==active.active+1))}/**
|
|
@@ -68,7 +68,7 @@ function score(option){return 100*(option.boost||0)+(option.apply?10:0)+(option.
|
|
|
68
68
|
A completion source that will scan the document for words (using a
|
|
69
69
|
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
|
|
70
70
|
return those as completions.
|
|
71
|
-
|
|
71
|
+
*//**
|
|
72
72
|
Extension to enable bracket-closing behavior. When a closeable
|
|
73
73
|
bracket is typed, its closing bracket is immediately inserted
|
|
74
74
|
after the cursor. When closing a bracket directly in front of a
|
|
@@ -98,7 +98,7 @@ function handleSame(state$1,token,allowTriple,config){let stringPrefixes=config.
|
|
|
98
98
|
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
|
99
99
|
- PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")`
|
|
100
100
|
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
|
|
101
|
-
|
|
101
|
+
*//**
|
|
102
102
|
Get the current completion status. When completions are available,
|
|
103
103
|
this will return `"active"`. When completions are pending (in the
|
|
104
104
|
process of being queried), this returns `"pending"`. Otherwise, it
|
|
@@ -175,9 +175,9 @@ let preciseTo=0,byWordTo=0,byWordFolded=!1,adjacentTo=0,adjacentStart=-1,adjacen
|
|
|
175
175
|
// a case folded character is encountered in such a match
|
|
176
176
|
// If we've found a partial adjacent match, these track its state
|
|
177
177
|
// Go over the option's text, scanning for the various kinds of matches
|
|
178
|
-
for(let next,i=0,e=Math.min(word.length,200),prevType=0/* Tp.NonWord */;i<e&&byWordTo<len;){next=state.codePointAt(word,i),0>direct&&(preciseTo<len&&next==chars[preciseTo]&&(precise[preciseTo++]=i),adjacentTo<len&&(next==chars[adjacentTo]||next==folded[adjacentTo]?(0==adjacentTo&&(adjacentStart=i),adjacentEnd=i+1,adjacentTo++):adjacentTo=0));let ch,type=255>next?48<=next&&57>=next||97<=next&&122>=next?2/* Tp.Lower */:65<=next&&90>=next?1/* Tp.Upper */:0/* Tp.NonWord */:(ch=state.fromCodePoint(next))==ch.toLowerCase()?ch==ch.toUpperCase()?0:2/* Tp.Lower */:1/* Tp.Upper */ /* Tp.NonWord */;(!i||1==type/* Tp.Upper */&&hasLower||0==prevType/* Tp.NonWord */&&0!=type/* Tp.NonWord */)&&(chars[byWordTo]==next||folded[byWordTo]==next&&(byWordFolded=!0)?byWord[byWordTo++]=i:byWord.length&&(wordAdjacent=!1)),prevType=type,i+=state.codePointSize(next)}return byWordTo==len&&0==byWord[0]&&wordAdjacent?this.result(-100/* Penalty.ByWord */+(byWordFolded?-200/* Penalty.CaseFold */:0),byWord,word):adjacentTo==len&&0==adjacentStart?this.ret(-200/* Penalty.CaseFold */-word.length+(adjacentEnd==word.length?0:-100/* Penalty.NotFull */),[0,adjacentEnd]):-1<direct?this.ret(-700/* Penalty.NotStart */-word.length,[direct,direct+this.pattern.length]):adjacentTo==len?this.ret(-900/* Penalty.NotStart */-word.length,[adjacentStart,adjacentEnd]):byWordTo==len?this.result(-100/* Penalty.ByWord */+(byWordFolded?-200/* Penalty.CaseFold */:0)+-700/* Penalty.NotStart */+(wordAdjacent?0:-1100/* Penalty.Gap */),byWord,word):2==chars.length?null:this.result((any[0]?-700/* Penalty.NotStart */:0)+-200/* Penalty.CaseFold */+-1100/* Penalty.Gap */,any,word)}result(score,positions,word){let result=[],i=0;for(let pos of positions){let to=pos+(this.astral?state.codePointSize(state.codePointAt(word,pos)):1);i&&result[i-1]==pos?result[i-1]=to:(result[i++]=pos,result[i++]=to)}return this.ret(score-word.length,result)}}class StrictMatcher{constructor(pattern){this.pattern=pattern,this.matched=[],this.score=0,this.folded=pattern.toLowerCase()}match(word){if(word.length<this.pattern.length)return null;let start=word.slice(0,this.pattern.length),match=start==this.pattern?0:start.toLowerCase()==this.folded?-200/* Penalty.CaseFold */:null;return null==match?null:(this.matched=[0,start.length],this.score=match+(word.length==this.pattern.length?0:-100/* Penalty.NotFull */),this)}}const completionConfig=state.Facet.define({combine(configs){return state.combineConfig(configs,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:defaultPositionInfo,filterStrict:!1,compareCompletions:(a,b)=>(a.sortText||a.label).localeCompare(b.sortText||b.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(a,b)=>a&&b,closeOnBlur:(a,b)=>a&&b,icons:(a,b)=>a&&b,tooltipClass:(a,b)=>c=>joinClass(a(c),b(c)),optionClass:(a,b)=>c=>joinClass(a(c),b(c)),addToOptions:(a,b)=>a.concat(b),filterStrict:(a,b)=>a||b})}}),setSelectedEffect=state.StateEffect.define();class CompletionTooltip{constructor(view,stateField,applyCompletion){this.view=view,this.stateField=stateField,this.applyCompletion=applyCompletion,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:pos=>this.placeInfo(pos),key:this},this.space=null,this.currentClass="";let cState=view.state.field(stateField),{options,selected}=cState.open,config=view.state.facet(completionConfig);this.optionContent=optionContent(config),this.optionClass=config.optionClass,this.tooltipClass=config.tooltipClass,this.range=rangeAroundSelected(options.length,selected,config.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(view.state),this.dom.addEventListener("mousedown",e=>{let{options}=view.state.field(stateField).open;for(let match,dom=e.target;dom&&dom!=this.dom;dom=dom.parentNode)if("LI"==dom.nodeName&&(match=/-(\d+)$/.exec(dom.id))&&+match[1]<options.length)return this.applyCompletion(view,options[+match[1]]),void e.preventDefault();if(e.target==this.list){let move=this.list.classList.contains("cm-completionListIncompleteTop")&&e.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&e.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=move&&(view.dispatch({effects:setSelectedEffect.of(move)}),e.preventDefault())}}),this.dom.addEventListener("focusout",e=>{let state=view.state.field(this.stateField,!1);state&&state.tooltip&&view.state.facet(completionConfig).closeOnBlur&&e.relatedTarget!=view.contentDOM&&view.dispatch({effects:closeCompletionEffect.of(null)})}),this.showOptions(options,cState.id)}mount(){this.updateSel()}showOptions(options,id){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(options,id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(update){var _a;let cState=update.state.field(this.stateField),prevState=update.startState.field(this.stateField);if(this.updateTooltipClass(update.state),cState!=prevState){let{options,selected,disabled}=cState.open;prevState.open&&prevState.open.options==options||(this.range=rangeAroundSelected(options.length,selected,update.state.facet(completionConfig).maxRenderedOptions),this.showOptions(options,cState.id)),this.updateSel(),disabled!=(null===(_a=prevState.open)||void 0===_a?void 0:_a.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!disabled)}}updateTooltipClass(state){let cls=this.tooltipClass(state);if(cls!=this.currentClass){for(let c of this.currentClass.split(" "))c&&this.dom.classList.remove(c);for(let c of cls.split(" "))c&&this.dom.classList.add(c);this.currentClass=cls}}positioned(space){this.space=space,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let cState=this.view.state.field(this.stateField),open=cState.open;(-1<open.selected&&open.selected<this.range.from||open.selected>=this.range.to)&&(this.range=rangeAroundSelected(open.options.length,open.selected,this.view.state.facet(completionConfig).maxRenderedOptions),this.showOptions(open.options,cState.id));let newSel=this.updateSelectedOption(open.selected);if(newSel){this.destroyInfo();let{completion}=open.options[open.selected],{info}=completion;if(!info)return;let infoResult="string"==typeof info?document.createTextNode(info):info(completion);if(!infoResult)return;"then"in infoResult?infoResult.then(obj=>{obj&&this.view.state.field(this.stateField,!1)==cState&&this.addInfoPane(obj,completion)}).catch(e=>view.logException(this.view.state,e,"completion info")):(this.addInfoPane(infoResult,completion),newSel.setAttribute("aria-describedby",this.info.id))}}addInfoPane(content,completion){this.destroyInfo();let wrap=this.info=document.createElement("div");if(wrap.className="cm-tooltip cm-completionInfo",wrap.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=content.nodeType)wrap.appendChild(content),this.infoDestroy=null;else{let{dom,destroy}=content;wrap.appendChild(dom),this.infoDestroy=destroy||null}this.dom.appendChild(wrap),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(selected){let set=null;for(let opt=this.list.firstChild,i=this.range.from;opt;opt=opt.nextSibling,i++)"LI"==opt.nodeName&&opt.id?i==selected?opt.hasAttribute("aria-selected")||(opt.setAttribute("aria-selected","true"),set=opt):opt.hasAttribute("aria-selected")&&(opt.removeAttribute("aria-selected"),opt.removeAttribute("aria-describedby")):i--;return set&&scrollIntoView(this.list,set),set}measureInfo(){let sel=this.dom.querySelector("[aria-selected]");if(!sel||!this.info)return null;let listRect=this.dom.getBoundingClientRect(),infoRect=this.info.getBoundingClientRect(),selRect=sel.getBoundingClientRect(),space=this.space;if(!space){let docElt=this.dom.ownerDocument.documentElement;space={left:0,top:0,right:docElt.clientWidth,bottom:docElt.clientHeight}}return selRect.top>Math.min(space.bottom,listRect.bottom)-10||selRect.bottom<Math.max(space.top,listRect.top)+10?null:this.view.state.facet(completionConfig).positionInfo(this.view,listRect,selRect,infoRect,space,this.dom)}placeInfo(pos){this.info&&(pos?(pos.style&&(this.info.style.cssText=pos.style),this.info.className="cm-tooltip cm-completionInfo "+(pos.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(options,id,range){const ul=document.createElement("ul");ul.id=id,ul.setAttribute("role","listbox"),ul.setAttribute("aria-expanded","true"),ul.setAttribute("aria-label",this.view.state.phrase("Completions")),ul.addEventListener("mousedown",e=>{e.target==ul&&e.preventDefault()});let curSection=null;for(let i=range.from;i<range.to;i++){let{completion,match}=options[i],{section}=completion;if(section){let name="string"==typeof section?section:section.name;if(name!=curSection&&(i>range.from||0==range.from))if(curSection=name,"string"!=typeof section&§ion.header)ul.appendChild(section.header(section));else{let header=ul.appendChild(document.createElement("completion-section"));header.textContent=name}}const li=ul.appendChild(document.createElement("li"));li.id=id+"-"+i,li.setAttribute("role","option");let cls=this.optionClass(completion);cls&&(li.className=cls);for(let source of this.optionContent){let node=source(completion,this.view.state,this.view,match);node&&li.appendChild(node)}}return range.from&&ul.classList.add("cm-completionListIncompleteTop"),range.to<options.length&&ul.classList.add("cm-completionListIncompleteBottom"),ul}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}class CompletionDialog{constructor(options,attrs,tooltip,timestamp,selected,disabled){this.options=options,this.attrs=attrs,this.tooltip=tooltip,this.timestamp=timestamp,this.selected=selected,this.disabled=disabled}setSelected(selected,id){return selected==this.selected||selected>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(id,selected),this.tooltip,this.timestamp,selected,this.disabled)}static build(active,state,id,prev,conf,didSetActive){if(prev&&!didSetActive&&active.some(s=>s.isPending))return prev.setDisabled();let options=sortOptions(active,state);if(!options.length)return prev&&active.some(a=>a.isPending)?prev.setDisabled():null;let selected=state.facet(completionConfig).selectOnOpen?0:-1;if(prev&&prev.selected!=selected&&-1!=prev.selected){let selectedValue=prev.options[prev.selected].completion;for(let i=0;i<options.length;i++)if(options[i].completion==selectedValue){selected=i;break}}return new CompletionDialog(options,makeAttrs(id,selected),{pos:active.reduce((a,b)=>b.hasResult()?Math.min(a,b.from):a,1e8),create:createTooltip,above:conf.aboveCursor},prev?prev.timestamp:Date.now(),selected,!1)}map(changes){return new CompletionDialog(this.options,this.attrs,{...this.tooltip,pos:changes.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new CompletionDialog(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class CompletionState{constructor(active,id,open){this.active=active,this.id=id,this.open=open}static start(){return new CompletionState(none,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(tr){let{state}=tr,conf=state.facet(completionConfig),sources=conf.override||state.languageDataAt("autocomplete",cur(state)).map(asSource),active=sources.map(source=>{let value=this.active.find(s=>s.source==source)||new ActiveSource(source,this.active.some(a=>0!=a.state/* State.Inactive */)?1/* State.Pending */:0/* State.Inactive */);return value.update(tr,conf)});active.length==this.active.length&&active.every((a,i)=>a==this.active[i])&&(active=this.active);let open=this.open,didSet=tr.effects.some(e=>e.is(setActiveEffect));open&&tr.docChanged&&(open=open.map(tr.changes)),tr.selection||active.some(a=>a.hasResult()&&tr.changes.touchesRange(a.from,a.to))||!sameResults(active,this.active)||didSet?open=CompletionDialog.build(active,state,this.id,open,conf,didSet):open&&open.disabled&&!active.some(a=>a.isPending)&&(open=null),!open&&active.every(a=>!a.isPending)&&active.some(a=>a.hasResult())&&(active=active.map(a=>a.hasResult()?new ActiveSource(a.source,0/* State.Inactive */):a));for(let effect of tr.effects)effect.is(setSelectedEffect)&&(open=open&&open.setSelected(effect.value,this.id));return active==this.active&&open==this.open?this:new CompletionState(active,this.id,open)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?baseAttrs:noAttrs}}const baseAttrs={"aria-autocomplete":"list"},noAttrs={},none=[];class ActiveSource{constructor(source,state,explicit=!1){this.source=source,this.state=state,this.explicit=explicit}hasResult(){return!1}get isPending(){return 1==this.state/* State.Pending */}update(tr,conf){let type=getUpdateType(tr,conf),value=this;(8&type/* UpdateType.Reset */||16&type/* UpdateType.ResetIfTouching */&&this.touches(tr))&&(value=new ActiveSource(value.source,0/* State.Inactive */)),4&type/* UpdateType.Activate */&&0==value.state/* State.Inactive */&&(value=new ActiveSource(this.source,1/* State.Pending */)),value=value.updateFor(tr,type);for(let effect of tr.effects)if(effect.is(startCompletionEffect))value=new ActiveSource(value.source,1/* State.Pending */,effect.value);else if(effect.is(closeCompletionEffect))value=new ActiveSource(value.source,0/* State.Inactive */);else if(effect.is(setActiveEffect))for(let active of effect.value)active.source==value.source&&(value=active);return value}updateFor(tr,type){return this.map(tr.changes)}map(changes){return this}touches(tr){return tr.changes.touchesRange(cur(tr.state))}}class ActiveResult extends ActiveSource{constructor(source,explicit,limit,result,from,to){super(source,3/* State.Result */,explicit),this.limit=limit,this.result=result,this.from=from,this.to=to}hasResult(){return!0}updateFor(tr,type){var _a;if(!(3&type/* UpdateType.SimpleInteraction */))return this.map(tr.changes);let result=this.result;result.map&&!tr.changes.empty&&(result=result.map(result,tr.changes));let from=tr.changes.mapPos(this.from),to=tr.changes.mapPos(this.to,1),pos=cur(tr.state);if(pos>to||!result||2&type/* UpdateType.Backspacing */&&(cur(tr.startState)==this.from||pos<this.limit))return new ActiveSource(this.source,4&type/* UpdateType.Activate */?1/* State.Pending */:0/* State.Inactive */);let limit=tr.changes.mapPos(this.limit);return checkValid(result.validFor,tr.state,from,to)?new ActiveResult(this.source,this.explicit,limit,result,from,to):result.update&&(result=result.update(result,from,to,new CompletionContext(tr.state,pos,!1)))?new ActiveResult(this.source,this.explicit,limit,result,result.from,null!==(_a=result.to)&&void 0!==_a?_a:cur(tr.state)):new ActiveSource(this.source,1/* State.Pending */,this.explicit)}map(mapping){if(mapping.empty)return this;let result=this.result.map?this.result.map(this.result,mapping):this.result;return result?new ActiveResult(this.source,this.explicit,mapping.mapPos(this.limit),this.result,mapping.mapPos(this.from),mapping.mapPos(this.to,1)):new ActiveSource(this.source,0/* State.Inactive */)}touches(tr){return tr.changes.touchesRange(this.from,this.to)}}const setActiveEffect=state.StateEffect.define({map(sources,mapping){return sources.map(s=>s.map(mapping))}}),completionState=state.StateField.define({create(){return CompletionState.start()},update(value,tr){return value.update(tr)},provide:f=>[view.showTooltip.from(f,val=>val.tooltip),view.EditorView.contentAttributes.from(f,state=>state.attrs)]}),createTooltip=completionTooltip(completionState,applyCompletion),acceptCompletion=view=>{let cState=view.state.field(completionState,!1);return!(view.state.readOnly||!cState||!cState.open||0>cState.open.selected||cState.open.disabled||Date.now()-cState.open.timestamp<view.state.facet(completionConfig).interactionDelay)&&applyCompletion(view,cState.open.options[cState.open.selected])},startCompletion=view=>{let cState=view.state.field(completionState,!1);return!!cState&&(view.dispatch({effects:startCompletionEffect.of(!0)}),!0)},closeCompletion=view=>{let cState=view.state.field(completionState,!1);return!!(cState&&cState.active.some(a=>0!=a.state/* State.Inactive */))&&(view.dispatch({effects:closeCompletionEffect.of(null)}),!0)};/**
|
|
178
|
+
for(let next,i=0,e=Math.min(word.length,200),prevType=0/* Tp.NonWord */;i<e&&byWordTo<len;){next=state.codePointAt(word,i),0>direct&&(preciseTo<len&&next==chars[preciseTo]&&(precise[preciseTo++]=i),adjacentTo<len&&(next==chars[adjacentTo]||next==folded[adjacentTo]?(0==adjacentTo&&(adjacentStart=i),adjacentEnd=i+1,adjacentTo++):adjacentTo=0));let ch,type=255>next?48<=next&&57>=next||97<=next&&122>=next?2/* Tp.Lower */:65<=next&&90>=next?1/* Tp.Upper */:0/* Tp.NonWord */:(ch=state.fromCodePoint(next))==ch.toLowerCase()?ch==ch.toUpperCase()?0:2/* Tp.Lower */:1/* Tp.Upper *//* Tp.NonWord */;(!i||1==type/* Tp.Upper */&&hasLower||0==prevType/* Tp.NonWord */&&0!=type/* Tp.NonWord */)&&(chars[byWordTo]==next||folded[byWordTo]==next&&(byWordFolded=!0)?byWord[byWordTo++]=i:byWord.length&&(wordAdjacent=!1)),prevType=type,i+=state.codePointSize(next)}return byWordTo==len&&0==byWord[0]&&wordAdjacent?this.result(-100/* Penalty.ByWord */+(byWordFolded?-200/* Penalty.CaseFold */:0),byWord,word):adjacentTo==len&&0==adjacentStart?this.ret(-200/* Penalty.CaseFold */-word.length+(adjacentEnd==word.length?0:-100/* Penalty.NotFull */),[0,adjacentEnd]):-1<direct?this.ret(-700/* Penalty.NotStart */-word.length,[direct,direct+this.pattern.length]):adjacentTo==len?this.ret(-900/* Penalty.NotStart */-word.length,[adjacentStart,adjacentEnd]):byWordTo==len?this.result(-100/* Penalty.ByWord */+(byWordFolded?-200/* Penalty.CaseFold */:0)+-700/* Penalty.NotStart */+(wordAdjacent?0:-1100/* Penalty.Gap */),byWord,word):2==chars.length?null:this.result((any[0]?-700/* Penalty.NotStart */:0)+-200/* Penalty.CaseFold */+-1100/* Penalty.Gap */,any,word)}result(score,positions,word){let result=[],i=0;for(let pos of positions){let to=pos+(this.astral?state.codePointSize(state.codePointAt(word,pos)):1);i&&result[i-1]==pos?result[i-1]=to:(result[i++]=pos,result[i++]=to)}return this.ret(score-word.length,result)}}class StrictMatcher{constructor(pattern){this.pattern=pattern,this.matched=[],this.score=0,this.folded=pattern.toLowerCase()}match(word){if(word.length<this.pattern.length)return null;let start=word.slice(0,this.pattern.length),match=start==this.pattern?0:start.toLowerCase()==this.folded?-200/* Penalty.CaseFold */:null;return null==match?null:(this.matched=[0,start.length],this.score=match+(word.length==this.pattern.length?0:-100/* Penalty.NotFull */),this)}}const completionConfig=state.Facet.define({combine(configs){return state.combineConfig(configs,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:defaultPositionInfo,filterStrict:!1,compareCompletions:(a,b)=>(a.sortText||a.label).localeCompare(b.sortText||b.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(a,b)=>a&&b,closeOnBlur:(a,b)=>a&&b,icons:(a,b)=>a&&b,tooltipClass:(a,b)=>c=>joinClass(a(c),b(c)),optionClass:(a,b)=>c=>joinClass(a(c),b(c)),addToOptions:(a,b)=>a.concat(b),filterStrict:(a,b)=>a||b})}}),setSelectedEffect=state.StateEffect.define();class CompletionTooltip{constructor(view,stateField,applyCompletion){this.view=view,this.stateField=stateField,this.applyCompletion=applyCompletion,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:pos=>this.placeInfo(pos),key:this},this.space=null,this.currentClass="";let cState=view.state.field(stateField),{options,selected}=cState.open,config=view.state.facet(completionConfig);this.optionContent=optionContent(config),this.optionClass=config.optionClass,this.tooltipClass=config.tooltipClass,this.range=rangeAroundSelected(options.length,selected,config.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(view.state),this.dom.addEventListener("mousedown",e=>{let{options}=view.state.field(stateField).open;for(let match,dom=e.target;dom&&dom!=this.dom;dom=dom.parentNode)if("LI"==dom.nodeName&&(match=/-(\d+)$/.exec(dom.id))&&+match[1]<options.length)return this.applyCompletion(view,options[+match[1]]),void e.preventDefault();if(e.target==this.list){let move=this.list.classList.contains("cm-completionListIncompleteTop")&&e.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&e.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=move&&(view.dispatch({effects:setSelectedEffect.of(move)}),e.preventDefault())}}),this.dom.addEventListener("focusout",e=>{let state=view.state.field(this.stateField,!1);state&&state.tooltip&&view.state.facet(completionConfig).closeOnBlur&&e.relatedTarget!=view.contentDOM&&view.dispatch({effects:closeCompletionEffect.of(null)})}),this.showOptions(options,cState.id)}mount(){this.updateSel()}showOptions(options,id){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(options,id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(update){var _a;let cState=update.state.field(this.stateField),prevState=update.startState.field(this.stateField);if(this.updateTooltipClass(update.state),cState!=prevState){let{options,selected,disabled}=cState.open;prevState.open&&prevState.open.options==options||(this.range=rangeAroundSelected(options.length,selected,update.state.facet(completionConfig).maxRenderedOptions),this.showOptions(options,cState.id)),this.updateSel(),disabled!=(null===(_a=prevState.open)||void 0===_a?void 0:_a.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!disabled)}}updateTooltipClass(state){let cls=this.tooltipClass(state);if(cls!=this.currentClass){for(let c of this.currentClass.split(" "))c&&this.dom.classList.remove(c);for(let c of cls.split(" "))c&&this.dom.classList.add(c);this.currentClass=cls}}positioned(space){this.space=space,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let cState=this.view.state.field(this.stateField),open=cState.open;(-1<open.selected&&open.selected<this.range.from||open.selected>=this.range.to)&&(this.range=rangeAroundSelected(open.options.length,open.selected,this.view.state.facet(completionConfig).maxRenderedOptions),this.showOptions(open.options,cState.id));let newSel=this.updateSelectedOption(open.selected);if(newSel){this.destroyInfo();let{completion}=open.options[open.selected],{info}=completion;if(!info)return;let infoResult="string"==typeof info?document.createTextNode(info):info(completion);if(!infoResult)return;"then"in infoResult?infoResult.then(obj=>{obj&&this.view.state.field(this.stateField,!1)==cState&&this.addInfoPane(obj,completion)}).catch(e=>view.logException(this.view.state,e,"completion info")):(this.addInfoPane(infoResult,completion),newSel.setAttribute("aria-describedby",this.info.id))}}addInfoPane(content,completion){this.destroyInfo();let wrap=this.info=document.createElement("div");if(wrap.className="cm-tooltip cm-completionInfo",wrap.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=content.nodeType)wrap.appendChild(content),this.infoDestroy=null;else{let{dom,destroy}=content;wrap.appendChild(dom),this.infoDestroy=destroy||null}this.dom.appendChild(wrap),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(selected){let set=null;for(let opt=this.list.firstChild,i=this.range.from;opt;opt=opt.nextSibling,i++)"LI"==opt.nodeName&&opt.id?i==selected?opt.hasAttribute("aria-selected")||(opt.setAttribute("aria-selected","true"),set=opt):opt.hasAttribute("aria-selected")&&(opt.removeAttribute("aria-selected"),opt.removeAttribute("aria-describedby")):i--;return set&&scrollIntoView(this.list,set),set}measureInfo(){let sel=this.dom.querySelector("[aria-selected]");if(!sel||!this.info)return null;let listRect=this.dom.getBoundingClientRect(),infoRect=this.info.getBoundingClientRect(),selRect=sel.getBoundingClientRect(),space=this.space;if(!space){let docElt=this.dom.ownerDocument.documentElement;space={left:0,top:0,right:docElt.clientWidth,bottom:docElt.clientHeight}}return selRect.top>Math.min(space.bottom,listRect.bottom)-10||selRect.bottom<Math.max(space.top,listRect.top)+10?null:this.view.state.facet(completionConfig).positionInfo(this.view,listRect,selRect,infoRect,space,this.dom)}placeInfo(pos){this.info&&(pos?(pos.style&&(this.info.style.cssText=pos.style),this.info.className="cm-tooltip cm-completionInfo "+(pos.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(options,id,range){const ul=document.createElement("ul");ul.id=id,ul.setAttribute("role","listbox"),ul.setAttribute("aria-expanded","true"),ul.setAttribute("aria-label",this.view.state.phrase("Completions")),ul.addEventListener("mousedown",e=>{e.target==ul&&e.preventDefault()});let curSection=null;for(let i=range.from;i<range.to;i++){let{completion,match}=options[i],{section}=completion;if(section){let name="string"==typeof section?section:section.name;if(name!=curSection&&(i>range.from||0==range.from))if(curSection=name,"string"!=typeof section&§ion.header)ul.appendChild(section.header(section));else{let header=ul.appendChild(document.createElement("completion-section"));header.textContent=name}}const li=ul.appendChild(document.createElement("li"));li.id=id+"-"+i,li.setAttribute("role","option");let cls=this.optionClass(completion);cls&&(li.className=cls);for(let source of this.optionContent){let node=source(completion,this.view.state,this.view,match);node&&li.appendChild(node)}}return range.from&&ul.classList.add("cm-completionListIncompleteTop"),range.to<options.length&&ul.classList.add("cm-completionListIncompleteBottom"),ul}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}class CompletionDialog{constructor(options,attrs,tooltip,timestamp,selected,disabled){this.options=options,this.attrs=attrs,this.tooltip=tooltip,this.timestamp=timestamp,this.selected=selected,this.disabled=disabled}setSelected(selected,id){return selected==this.selected||selected>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(id,selected),this.tooltip,this.timestamp,selected,this.disabled)}static build(active,state,id,prev,conf,didSetActive){if(prev&&!didSetActive&&active.some(s=>s.isPending))return prev.setDisabled();let options=sortOptions(active,state);if(!options.length)return prev&&active.some(a=>a.isPending)?prev.setDisabled():null;let selected=state.facet(completionConfig).selectOnOpen?0:-1;if(prev&&prev.selected!=selected&&-1!=prev.selected){let selectedValue=prev.options[prev.selected].completion;for(let i=0;i<options.length;i++)if(options[i].completion==selectedValue){selected=i;break}}return new CompletionDialog(options,makeAttrs(id,selected),{pos:active.reduce((a,b)=>b.hasResult()?Math.min(a,b.from):a,1e8),create:createTooltip,above:conf.aboveCursor},prev?prev.timestamp:Date.now(),selected,!1)}map(changes){return new CompletionDialog(this.options,this.attrs,{...this.tooltip,pos:changes.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new CompletionDialog(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class CompletionState{constructor(active,id,open){this.active=active,this.id=id,this.open=open}static start(){return new CompletionState(none,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(tr){let{state}=tr,conf=state.facet(completionConfig),sources=conf.override||state.languageDataAt("autocomplete",cur(state)).map(asSource),active=sources.map(source=>{let value=this.active.find(s=>s.source==source)||new ActiveSource(source,this.active.some(a=>0!=a.state/* State.Inactive */)?1/* State.Pending */:0/* State.Inactive */);return value.update(tr,conf)});active.length==this.active.length&&active.every((a,i)=>a==this.active[i])&&(active=this.active);let open=this.open,didSet=tr.effects.some(e=>e.is(setActiveEffect));open&&tr.docChanged&&(open=open.map(tr.changes)),tr.selection||active.some(a=>a.hasResult()&&tr.changes.touchesRange(a.from,a.to))||!sameResults(active,this.active)||didSet?open=CompletionDialog.build(active,state,this.id,open,conf,didSet):open&&open.disabled&&!active.some(a=>a.isPending)&&(open=null),!open&&active.every(a=>!a.isPending)&&active.some(a=>a.hasResult())&&(active=active.map(a=>a.hasResult()?new ActiveSource(a.source,0/* State.Inactive */):a));for(let effect of tr.effects)effect.is(setSelectedEffect)&&(open=open&&open.setSelected(effect.value,this.id));return active==this.active&&open==this.open?this:new CompletionState(active,this.id,open)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?baseAttrs:noAttrs}}const baseAttrs={"aria-autocomplete":"list"},noAttrs={},none=[];class ActiveSource{constructor(source,state,explicit=!1){this.source=source,this.state=state,this.explicit=explicit}hasResult(){return!1}get isPending(){return 1==this.state/* State.Pending */}update(tr,conf){let type=getUpdateType(tr,conf),value=this;(8&type/* UpdateType.Reset */||16&type/* UpdateType.ResetIfTouching */&&this.touches(tr))&&(value=new ActiveSource(value.source,0/* State.Inactive */)),4&type/* UpdateType.Activate */&&0==value.state/* State.Inactive */&&(value=new ActiveSource(this.source,1/* State.Pending */)),value=value.updateFor(tr,type);for(let effect of tr.effects)if(effect.is(startCompletionEffect))value=new ActiveSource(value.source,1/* State.Pending */,effect.value);else if(effect.is(closeCompletionEffect))value=new ActiveSource(value.source,0/* State.Inactive */);else if(effect.is(setActiveEffect))for(let active of effect.value)active.source==value.source&&(value=active);return value}updateFor(tr,type){return this.map(tr.changes)}map(changes){return this}touches(tr){return tr.changes.touchesRange(cur(tr.state))}}class ActiveResult extends ActiveSource{constructor(source,explicit,limit,result,from,to){super(source,3/* State.Result */,explicit),this.limit=limit,this.result=result,this.from=from,this.to=to}hasResult(){return!0}updateFor(tr,type){var _a;if(!(3&type/* UpdateType.SimpleInteraction */))return this.map(tr.changes);let result=this.result;result.map&&!tr.changes.empty&&(result=result.map(result,tr.changes));let from=tr.changes.mapPos(this.from),to=tr.changes.mapPos(this.to,1),pos=cur(tr.state);if(pos>to||!result||2&type/* UpdateType.Backspacing */&&(cur(tr.startState)==this.from||pos<this.limit))return new ActiveSource(this.source,4&type/* UpdateType.Activate */?1/* State.Pending */:0/* State.Inactive */);let limit=tr.changes.mapPos(this.limit);return checkValid(result.validFor,tr.state,from,to)?new ActiveResult(this.source,this.explicit,limit,result,from,to):result.update&&(result=result.update(result,from,to,new CompletionContext(tr.state,pos,!1)))?new ActiveResult(this.source,this.explicit,limit,result,result.from,null!==(_a=result.to)&&void 0!==_a?_a:cur(tr.state)):new ActiveSource(this.source,1/* State.Pending */,this.explicit)}map(mapping){if(mapping.empty)return this;let result=this.result.map?this.result.map(this.result,mapping):this.result;return result?new ActiveResult(this.source,this.explicit,mapping.mapPos(this.limit),this.result,mapping.mapPos(this.from),mapping.mapPos(this.to,1)):new ActiveSource(this.source,0/* State.Inactive */)}touches(tr){return tr.changes.touchesRange(this.from,this.to)}}const setActiveEffect=state.StateEffect.define({map(sources,mapping){return sources.map(s=>s.map(mapping))}}),completionState=state.StateField.define({create(){return CompletionState.start()},update(value,tr){return value.update(tr)},provide:f=>[view.showTooltip.from(f,val=>val.tooltip),view.EditorView.contentAttributes.from(f,state=>state.attrs)]}),createTooltip=completionTooltip(completionState,applyCompletion),acceptCompletion=view=>{let cState=view.state.field(completionState,!1);return!(view.state.readOnly||!cState||!cState.open||0>cState.open.selected||cState.open.disabled||Date.now()-cState.open.timestamp<view.state.facet(completionConfig).interactionDelay)&&applyCompletion(view,cState.open.options[cState.open.selected])},startCompletion=view=>{let cState=view.state.field(completionState,!1);return!!cState&&(view.dispatch({effects:startCompletionEffect.of(!0)}),!0)},closeCompletion=view=>{let cState=view.state.field(completionState,!1);return!!(cState&&cState.active.some(a=>0!=a.state/* State.Inactive */))&&(view.dispatch({effects:closeCompletionEffect.of(null)}),!0)};/**
|
|
179
179
|
Explicitly start autocompletion.
|
|
180
|
-
|
|
180
|
+
*//**
|
|
181
181
|
Close the currently active completion.
|
|
182
182
|
*/class RunningQuery{constructor(active,context){this.active=active,this.context=context,this.time=Date.now(),this.updates=[],this.done=void 0}}const MaxUpdateCount=50,MinAbortTime=1e3,completionPlugin=view.ViewPlugin.fromClass(class{constructor(view){this.view=view,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0/* CompositionState.None */;for(let active of view.state.field(completionState).active)active.isPending&&this.startQuery(active)}update(update){let cState=update.state.field(completionState),conf=update.state.facet(completionConfig);if(update.selectionSet||update.docChanged||update.startState.field(completionState)!=cState){let doesReset=update.transactions.some(tr=>{let type=getUpdateType(tr,conf);return 8&type/* UpdateType.Reset */||(tr.selection||tr.docChanged)&&!(3&type/* UpdateType.SimpleInteraction */)});for(let query,i=0;i<this.running.length;i++)if(query=this.running[i],doesReset||query.context.abortOnDocChange&&update.docChanged||query.updates.length+update.transactions.length>MaxUpdateCount&&Date.now()-query.time>MinAbortTime){for(let handler of query.context.abortListeners)try{handler()}catch(e){view.logException(this.view.state,e)}query.context.abortListeners=null,this.running.splice(i--,1)}else query.updates.push(...update.transactions);-1<this.debounceUpdate&&clearTimeout(this.debounceUpdate),update.transactions.some(tr=>tr.effects.some(e=>e.is(startCompletionEffect)))&&(this.pendingStart=!0);let delay=this.pendingStart?50:conf.activateOnTypingDelay;if(this.debounceUpdate=cState.active.some(a=>a.isPending&&!this.running.some(q=>q.active.source==a.source))?setTimeout(()=>this.startUpdate(),delay):-1,0!=this.composing/* CompositionState.None */)for(let tr of update.transactions)tr.isUserEvent("input.type")?this.composing=2/* CompositionState.Changed */:2==this.composing/* CompositionState.Changed */&&tr.selection&&(this.composing=3/* CompositionState.ChangedAndMoved */)}}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state}=this.view,cState=state.field(completionState);for(let active of cState.active)active.isPending&&!this.running.some(r=>r.active.source==active.source)&&this.startQuery(active);this.running.length&&cState.open&&cState.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(completionConfig).updateSyncTime))}startQuery(active){let{state}=this.view,pos=cur(state),context=new CompletionContext(state,pos,active.explicit,this.view),pending=new RunningQuery(active,context);this.running.push(pending),Promise.resolve(active.source(context)).then(result=>{pending.context.aborted||(pending.done=result||null,this.scheduleAccept())},err=>{this.view.dispatch({effects:closeCompletionEffect.of(null)}),view.logException(this.view.state,err)})}scheduleAccept(){this.running.every(q=>void 0!==q.done)?this.accept():0>this.debounceAccept&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(completionConfig).updateSyncTime))}// For each finished query in this.running, try to create a result
|
|
183
183
|
// or, if appropriate, restart the query.
|
|
@@ -189,9 +189,9 @@ let active=new ActiveSource(query.active.source,0/* State.Inactive */);for(let t
|
|
|
189
189
|
this.startQuery(current)}(updated.length||cState.open&&cState.open.disabled)&&this.view.dispatch({effects:setActiveEffect.of(updated)})}},{eventHandlers:{blur(event){let state=this.view.state.field(completionState,!1);if(state&&state.tooltip&&this.view.state.facet(completionConfig).closeOnBlur){let dialog=state.open&&view.getTooltip(this.view,state.open.tooltip);dialog&&dialog.dom.contains(event.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:closeCompletionEffect.of(null)}),10)}},compositionstart(){this.composing=1/* CompositionState.Started */},compositionend(){3==this.composing/* CompositionState.ChangedAndMoved */&&setTimeout(()=>this.view.dispatch({effects:startCompletionEffect.of(!1)}),20),this.composing=0/* CompositionState.None */}}}),windows="object"==typeof navigator&&/Win/.test(navigator.platform),commitCharacters=state.Prec.highest(view.EditorView.domEventHandlers({keydown(event,view){let field=view.state.field(completionState,!1);if(!field||!field.open||field.open.disabled||0>field.open.selected||1<event.key.length||event.ctrlKey&&!(windows&&event.altKey)||event.metaKey)return!1;let option=field.open.options[field.open.selected],result=field.active.find(a=>a.source==option.source),commitChars=option.completion.commitCharacters||result.result.commitCharacters;return commitChars&&-1<commitChars.indexOf(event.key)&&applyCompletion(view,option),!1}})),baseTheme=view.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:"\"\xB7\xB7\xB7\"",opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:`${400/* Info.Width */}px`,boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`${30/* Info.Margin */}px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`${30/* Info.Margin */}px`},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\uD835\uDC65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\uD835\uDC36'"}},".cm-completionIcon-type":{"&:after":{content:"'\uD835\uDC61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11\uFE0E'"}// Disable emoji rendering
|
|
190
190
|
},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class FieldPos{constructor(field,line,from,to){this.field=field,this.line=line,this.from=from,this.to=to}}class FieldRange{constructor(field,from,to){this.field=field,this.from=from,this.to=to}map(changes){let from=changes.mapPos(this.from,-1,state.MapMode.TrackDel),to=changes.mapPos(this.to,1,state.MapMode.TrackDel);return null==from||null==to?null:new FieldRange(this.field,from,to)}}class Snippet{constructor(lines,fieldPositions){this.lines=lines,this.fieldPositions=fieldPositions}instantiate(state,pos){let text=[],lineStart=[pos],lineObj=state.doc.lineAt(pos),baseIndent=/^\s*/.exec(lineObj.text)[0];for(let line of this.lines){if(text.length){let indent=baseIndent,tabs=/^\t*/.exec(line)[0].length;for(let i=0;i<tabs;i++)indent+=state.facet(language.indentUnit);lineStart.push(pos+indent.length-tabs),line=indent+line.slice(tabs)}text.push(line),pos+=line.length+1}let ranges=this.fieldPositions.map(pos=>new FieldRange(pos.field,lineStart[pos.line]+pos.from,lineStart[pos.line]+pos.to));return{text,ranges}}static parse(template){let m,fields=[],lines=[],positions=[];for(let line of template.split(/\r\n?|\n/)){for(;m=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line);){let seq=m[1]?+m[1]:null,rawName=m[2]||m[3]||"",found=-1,name=rawName.replace(/\\[{}]/g,m=>m[1]);for(let i=0;i<fields.length;i++)(null==seq?!!name&&fields[i].name==name:fields[i].seq==seq)&&(found=i);if(0>found){let i=0;for(;i<fields.length&&(null==seq||null!=fields[i].seq&&fields[i].seq<seq);)i++;fields.splice(i,0,{seq,name}),found=i;for(let pos of positions)pos.field>=found&&pos.field++}for(let pos of positions)if(pos.line==lines.length&&pos.from>m.index){let snip=m[2]?3+(m[1]||"").length:2;pos.from-=snip,pos.to-=snip}positions.push(new FieldPos(found,lines.length,m.index,m.index+name.length)),line=line.slice(0,m.index)+rawName+line.slice(m.index+m[0].length)}line=line.replace(/\\([{}])/g,(_,brace,index)=>{for(let pos of positions)pos.line==lines.length&&pos.from>index&&(pos.from--,pos.to--);return brace}),lines.push(line)}return new Snippet(lines,positions)}}let fieldMarker=view.Decoration.widget({widget:new class extends view.WidgetType{toDOM(){let span=document.createElement("span");return span.className="cm-snippetFieldPosition",span}ignoreEvent(){return!1}}}),fieldRange=view.Decoration.mark({class:"cm-snippetField"});class ActiveSnippet{constructor(ranges,active){this.ranges=ranges,this.active=active,this.deco=view.Decoration.set(ranges.map(r=>(r.from==r.to?fieldMarker:fieldRange).range(r.from,r.to)),!0)}map(changes){let ranges=[];for(let r of this.ranges){let mapped=r.map(changes);if(!mapped)return null;ranges.push(mapped)}return new ActiveSnippet(ranges,this.active)}selectionInsideField(sel){return sel.ranges.every(range=>this.ranges.some(r=>r.field==this.active&&r.from<=range.from&&r.to>=range.to))}}const setActive=state.StateEffect.define({map(value,changes){return value&&value.map(changes)}}),moveToField=state.StateEffect.define(),snippetState=state.StateField.define({create(){return null},update(value,tr){for(let effect of tr.effects){if(effect.is(setActive))return effect.value;if(effect.is(moveToField)&&value)return new ActiveSnippet(value.ranges,effect.value)}return value&&tr.docChanged&&(value=value.map(tr.changes)),value&&tr.selection&&!value.selectionInsideField(tr.selection)&&(value=null),value},provide:f=>view.EditorView.decorations.from(f,val=>val?val.deco:view.Decoration.none)}),clearSnippet=({state,dispatch})=>{let active=state.field(snippetState,!1);return!!active&&(dispatch(state.update({effects:setActive.of(null)})),!0)},nextSnippetField=moveField(1),prevSnippetField=moveField(-1),defaultSnippetKeymap=[{key:"Tab",run:nextSnippetField,shift:prevSnippetField},{key:"Escape",run:clearSnippet}],snippetKeymap=state.Facet.define({combine(maps){return maps.length?maps[0]:defaultSnippetKeymap}}),addSnippetKeymap=state.Prec.highest(view.keymap.compute([snippetKeymap],state=>state.facet(snippetKeymap))),snippetPointerHandler=view.EditorView.domEventHandlers({mousedown(event,view){let pos,active=view.state.field(snippetState,!1);if(!active||null==(pos=view.posAtCoords({x:event.clientX,y:event.clientY})))return!1;let match=active.ranges.find(r=>r.from<=pos&&r.to>=pos);return!!(match&&match.field!=active.active)&&(view.dispatch({selection:fieldSelection(active.ranges,match.field),effects:setActive.of(active.ranges.some(r=>r.field>match.field)?new ActiveSnippet(active.ranges,match.field):null),scrollIntoView:!0}),!0)}}),wordCaches=Object.create(null),completeAnyWord=context=>{var _a;let wordChars=null!==(_a=context.state.languageDataAt("wordChars",context.pos)[0])&&void 0!==_a?_a:"",re=wordRE(wordChars),token=context.matchBefore(mapRE(re,s=>s+"$"));if(!token&&!context.explicit)return null;let from=token?token.from:context.pos,options=collectWords(context.state.doc,wordCache(wordChars),re,5e4/* C.Range */,from);return{from,options,validFor:mapRE(re,s=>"^"+s)}},defaults={brackets:["(","[","{","'","\""],before:")]}:;>",stringPrefixes:[]},closeBracketEffect=state.StateEffect.define({map(value,mapping){let mapped=mapping.mapPos(value,-1,state.MapMode.TrackAfter);return null==mapped?void 0:mapped}}),closedBracket=new class extends state.RangeValue{};/**
|
|
191
191
|
Move to the next snippet field, if available.
|
|
192
|
-
|
|
192
|
+
*//**
|
|
193
193
|
Move to the previous snippet field, if available.
|
|
194
|
-
|
|
194
|
+
*//**
|
|
195
195
|
A facet that can be used to configure the key bindings used by
|
|
196
196
|
snippets. The default binds Tab to
|
|
197
197
|
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
|
|
@@ -200,7 +200,7 @@ this.startQuery(current)}(updated.length||cState.open&&cState.open.disabled)&&th
|
|
|
200
200
|
*/closedBracket.startSide=1,closedBracket.endSide=-1;const bracketState=state.StateField.define({create(){return state.RangeSet.empty},update(value,tr){if(value=value.map(tr.changes),tr.selection){let line=tr.state.doc.lineAt(tr.selection.main.head);value=value.update({filter:from=>from>=line.from&&from<=line.to})}for(let effect of tr.effects)effect.is(closeBracketEffect)&&(value=value.update({add:[closedBracket.range(effect.value,effect.value+1)]}));return value}}),definedClosing="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D",android="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),inputHandler=view.EditorView.inputHandler.of((view,from,to,insert)=>{if((android?view.composing:view.compositionStarted)||view.state.readOnly)return!1;let sel=view.state.selection.main;if(2<insert.length||2==insert.length&&1==state.codePointSize(state.codePointAt(insert,0))||from!=sel.from||to!=sel.to)return!1;let tr=insertBracket(view.state,insert);return!!tr&&(view.dispatch(tr),!0)}),deleteBracketPair=({state:state$1,dispatch})=>{if(state$1.readOnly)return!1;let conf=config(state$1,state$1.selection.main.head),tokens=conf.brackets||defaults.brackets,dont=null,changes=state$1.changeByRange(range=>{if(range.empty){let before=prevChar(state$1.doc,range.head);for(let token of tokens)if(token==before&&nextChar(state$1.doc,range.head)==closing(state.codePointAt(token,0)))return{changes:{from:range.head-token.length,to:range.head+token.length},range:state.EditorSelection.cursor(range.head-token.length)}}return{range:dont=range}});return dont||dispatch(state$1.update(changes,{scrollIntoView:!0,userEvent:"delete.backward"})),!dont},closeBracketsKeymap=[{key:"Backspace",run:deleteBracketPair}],completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{mac:"Alt-`",run:startCompletion},{mac:"Alt-i",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:moveCompletionSelection(!0)},{key:"ArrowUp",run:moveCompletionSelection(!1)},{key:"PageDown",run:moveCompletionSelection(!0,"page")},{key:"PageUp",run:moveCompletionSelection(!1,"page")},{key:"Enter",run:acceptCompletion}],completionKeymapExt=state.Prec.highest(view.keymap.computeN([completionConfig],state=>state.facet(completionConfig).defaultKeymap?[completionKeymap]:[])),completionArrayCache=new WeakMap;/**
|
|
201
201
|
Command that implements deleting a pair of matching brackets when
|
|
202
202
|
the cursor is between them.
|
|
203
|
-
|
|
203
|
+
*//**
|
|
204
204
|
Close-brackets related key bindings. Binds Backspace to
|
|
205
205
|
[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
|
|
206
206
|
*/return dist.CompletionContext=CompletionContext,dist.acceptCompletion=acceptCompletion,dist.autocompletion=autocompletion,dist.clearSnippet=clearSnippet,dist.closeBrackets=closeBrackets,dist.closeBracketsKeymap=closeBracketsKeymap,dist.closeCompletion=closeCompletion,dist.completeAnyWord=completeAnyWord,dist.completeFromList=completeFromList,dist.completionKeymap=completionKeymap,dist.completionStatus=completionStatus,dist.currentCompletions=currentCompletions,dist.deleteBracketPair=deleteBracketPair,dist.hasNextSnippetField=hasNextSnippetField,dist.hasPrevSnippetField=hasPrevSnippetField,dist.ifIn=ifIn,dist.ifNotIn=ifNotIn,dist.insertBracket=insertBracket,dist.insertCompletionText=insertCompletionText,dist.moveCompletionSelection=moveCompletionSelection,dist.nextSnippetField=nextSnippetField,dist.pickedCompletion=pickedCompletion,dist.prevSnippetField=prevSnippetField,dist.selectedCompletion=selectedCompletion,dist.selectedCompletionIndex=selectedCompletionIndex,dist.setSelectedCompletion=setSelectedCompletion,dist.snippet=snippet,dist.snippetCompletion=snippetCompletion,dist.snippetKeymap=snippetKeymap,dist.startCompletion=startCompletion,dist}(),index=/*@__PURE__*/function getDefaultExportFromCjs(x){return x}(distExports);return module.exports=index,module.exports}
|
|
@@ -81,7 +81,7 @@ for(let next,at=start.head;;){if(next=forward?pos.childAfter(at):pos.childBefore
|
|
|
81
81
|
will also delete that whitespace. When the cursor is between
|
|
82
82
|
matching brackets, an additional newline will be inserted after
|
|
83
83
|
the cursor.
|
|
84
|
-
*/function newlineAndIndent(atEof){return({state:state$1,dispatch})=>{if(state$1.readOnly)return!1;let changes=state$1.changeByRange(range=>{let{from,to}=range,line=state$1.doc.lineAt(from),explode=!atEof&&from==to&&isBetweenBrackets(state$1,from);atEof&&(from=to=(to<=line.to?line:state$1.doc.lineAt(to)).to);let cx=new language.IndentContext(state$1,{simulateBreak:from,simulateDoubleBreak:!!explode}),indent=language.getIndentation(cx,from);for(null==indent&&(indent=state.countColumn(/^\s*/.exec(state$1.doc.lineAt(from).text)[0],state$1.tabSize));to<line.to&&/\s/.test(line.text[to-line.from]);)to++;explode?
|
|
84
|
+
*/function newlineAndIndent(atEof){return({state:state$1,dispatch})=>{if(state$1.readOnly)return!1;let changes=state$1.changeByRange(range=>{let{from,to}=range,line=state$1.doc.lineAt(from),explode=!atEof&&from==to&&isBetweenBrackets(state$1,from);atEof&&(from=to=(to<=line.to?line:state$1.doc.lineAt(to)).to);let cx=new language.IndentContext(state$1,{simulateBreak:from,simulateDoubleBreak:!!explode}),indent=language.getIndentation(cx,from);for(null==indent&&(indent=state.countColumn(/^\s*/.exec(state$1.doc.lineAt(from).text)[0],state$1.tabSize));to<line.to&&/\s/.test(line.text[to-line.from]);)to++;explode?{from,to}=explode:from>line.from&&from<line.from+100&&!/\S/.test(line.text.slice(0,from))&&(from=line.from);let insert=["",language.indentString(state$1,indent)];return explode&&insert.push(language.indentString(state$1,cx.lineIndent(line.from,-1))),{changes:{from,to,insert:state.Text.of(insert)},range:state.EditorSelection.cursor(from+1+insert[1].length)}});return dispatch(state$1.update(changes,{scrollIntoView:!0,userEvent:"input"})),!0}}function changeBySelectedLine(state$1,f){let atLine=-1;return state$1.changeByRange(range=>{let changes=[];for(let line,pos=range.from;pos<=range.to;)line=state$1.doc.lineAt(pos),line.number>atLine&&(range.empty||range.to>line.from)&&(f(line,changes,range),atLine=line.number),pos=line.to+1;let changeSet=state$1.changes(changes);return{changes,range:state.EditorSelection.range(changeSet.mapPos(range.anchor,1),changeSet.mapPos(range.head,1))}})}/**
|
|
85
85
|
Auto-indent the selected lines. This uses the [indentation service
|
|
86
86
|
facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
|
|
87
87
|
information.
|
|
@@ -90,42 +90,42 @@ for(let next,at=start.head;;){if(next=forward?pos.childAfter(at):pos.childBefore
|
|
|
90
90
|
if available, otherwise falling back to block comments.
|
|
91
91
|
*/const toggleComment=target=>{let{state}=target,line=state.doc.lineAt(state.selection.main.from),config=getConfig(target.state,line.from);return config.line?toggleLineComment(target):!!config.block&&toggleBlockCommentByLine(target)},toggleLineComment=command(changeLineComment,0/* CommentOption.Toggle */),lineComment=command(changeLineComment,1/* CommentOption.Comment */),lineUncomment=command(changeLineComment,2/* CommentOption.Uncomment */),toggleBlockComment=command(changeBlockComment,0/* CommentOption.Toggle */),blockComment=command(changeBlockComment,1/* CommentOption.Comment */),blockUncomment=command(changeBlockComment,2/* CommentOption.Uncomment */),toggleBlockCommentByLine=command((o,s)=>changeBlockComment(o,s,selectedLineRanges(s)),0/* CommentOption.Toggle */),SearchMargin=50,fromHistory=state.Annotation.define(),isolateHistory=state.Annotation.define(),invertedEffects=state.Facet.define(),historyConfig=state.Facet.define({combine(configs){return state.combineConfig(configs,{minDepth:100,newGroupDelay:500,joinToEvent:(_t,isAdjacent)=>isAdjacent},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(a,b)=>(tr,adj)=>a(tr,adj)||b(tr,adj)})}}),historyField_=state.StateField.define({create(){return HistoryState.empty},update(state$1,tr){let config=tr.state.facet(historyConfig),fromHist=tr.annotation(fromHistory);if(fromHist){let item=HistEvent.fromTransaction(tr,fromHist.selection),from=fromHist.side,other=0==from/* BranchName.Done */?state$1.undone:state$1.done;return other=item?updateBranch(other,other.length,config.minDepth,item):addSelection(other,tr.startState.selection),new HistoryState(0==from/* BranchName.Done */?fromHist.rest:other,0==from/* BranchName.Done */?other:fromHist.rest)}let isolate=tr.annotation(isolateHistory);if(("full"==isolate||"before"==isolate)&&(state$1=state$1.isolate()),!1===tr.annotation(state.Transaction.addToHistory))return tr.changes.empty?state$1:state$1.addMapping(tr.changes.desc);let event=HistEvent.fromTransaction(tr),time=tr.annotation(state.Transaction.time),userEvent=tr.annotation(state.Transaction.userEvent);return event?state$1=state$1.addChanges(event,time,userEvent,config,tr):tr.selection&&(state$1=state$1.addSelection(tr.startState.selection,time,userEvent,config.newGroupDelay)),("full"==isolate||"after"==isolate)&&(state$1=state$1.isolate()),state$1},toJSON(value){return{done:value.done.map(e=>e.toJSON()),undone:value.undone.map(e=>e.toJSON())}},fromJSON(json){return new HistoryState(json.done.map(HistEvent.fromJSON),json.undone.map(HistEvent.fromJSON))}}),historyField=historyField_,undo=cmd(0/* BranchName.Done */,!1),redo=cmd(1/* BranchName.Undone */,!1),undoSelection=cmd(0/* BranchName.Done */,!0),redoSelection=cmd(1/* BranchName.Undone */,!0),undoDepth=depth(0/* BranchName.Done */),redoDepth=depth(1/* BranchName.Undone */);/**
|
|
92
92
|
Comment the current selection using line comments.
|
|
93
|
-
|
|
93
|
+
*//**
|
|
94
94
|
Uncomment the current selection using line comments.
|
|
95
|
-
|
|
95
|
+
*//**
|
|
96
96
|
Comment or uncomment the current selection using block comments.
|
|
97
97
|
The block comment syntax is taken from the
|
|
98
98
|
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
|
99
99
|
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
|
100
|
-
|
|
100
|
+
*//**
|
|
101
101
|
Comment the current selection using block comments.
|
|
102
|
-
|
|
102
|
+
*//**
|
|
103
103
|
Uncomment the current selection using block comments.
|
|
104
|
-
|
|
104
|
+
*//**
|
|
105
105
|
Comment or uncomment the lines around the current selection using
|
|
106
106
|
block comments.
|
|
107
|
-
|
|
107
|
+
*//**
|
|
108
108
|
Transaction annotation that will prevent that transaction from
|
|
109
109
|
being combined with other transactions in the undo history. Given
|
|
110
110
|
`"before"`, it'll prevent merging with previous transactions. With
|
|
111
111
|
`"after"`, subsequent transactions won't be combined with this
|
|
112
112
|
one. With `"full"`, the transaction is isolated on both sides.
|
|
113
|
-
|
|
113
|
+
*//**
|
|
114
114
|
This facet provides a way to register functions that, given a
|
|
115
115
|
transaction, provide a set of effects that the history should
|
|
116
116
|
store when inverting the transaction. This can be used to
|
|
117
117
|
integrate some kinds of effects in the history, so that they can
|
|
118
118
|
be undone (and redone again).
|
|
119
|
-
|
|
119
|
+
*//**
|
|
120
120
|
Redo a group of history events. Returns false if no group was
|
|
121
121
|
available.
|
|
122
|
-
|
|
122
|
+
*//**
|
|
123
123
|
Undo a change or selection change.
|
|
124
|
-
|
|
124
|
+
*//**
|
|
125
125
|
Redo a change or selection change.
|
|
126
|
-
|
|
126
|
+
*//**
|
|
127
127
|
The amount of redoable change events available in a given state.
|
|
128
|
-
|
|
128
|
+
*/// History events store groups of changes or effects that need to be
|
|
129
129
|
// undone/redone together.
|
|
130
130
|
class HistEvent{constructor(// The changes in this event. Normal events hold at least one
|
|
131
131
|
// change or effect. But it may be necessary to store selection
|
|
@@ -151,185 +151,185 @@ static fromTransaction(tr,selection){let effects=none;for(let invert of tr.start
|
|
|
151
151
|
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
|
152
152
|
*/const historyKeymap=[{key:"Mod-z",run:undo,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:redo,preventDefault:!0},{linux:"Ctrl-Shift-z",run:redo,preventDefault:!0},{key:"Mod-u",run:undoSelection,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:redoSelection,preventDefault:!0}],cursorCharLeft=view=>cursorByChar(view,!ltrAtCursor(view)),cursorCharRight=view=>cursorByChar(view,ltrAtCursor(view)),cursorCharForward=view=>cursorByChar(view,!0),cursorCharBackward=view=>cursorByChar(view,!1),cursorCharForwardLogical=target=>moveByCharLogical(target,!0),cursorCharBackwardLogical=target=>moveByCharLogical(target,!1),cursorGroupLeft=view=>cursorByGroup(view,!ltrAtCursor(view)),cursorGroupRight=view=>cursorByGroup(view,ltrAtCursor(view)),cursorGroupForward=view=>cursorByGroup(view,!0),cursorGroupBackward=view=>cursorByGroup(view,!1),cursorGroupForwardWin=view=>moveSel(view,range=>range.empty?view.moveByChar(range,!0,start=>toGroupStart(view,range.head,start)):rangeEnd(range,!0)),segmenter="undefined"!=typeof Intl&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null,cursorSubwordForward=view=>cursorBySubword(view,!0),cursorSubwordBackward=view=>cursorBySubword(view,!1),cursorSyntaxLeft=view=>moveSel(view,range=>moveBySyntax(view.state,range,!ltrAtCursor(view))),cursorSyntaxRight=view=>moveSel(view,range=>moveBySyntax(view.state,range,ltrAtCursor(view))),cursorLineUp=view=>cursorByLine(view,!1),cursorLineDown=view=>cursorByLine(view,!0),cursorPageUp=view=>cursorByPage(view,!1),cursorPageDown=view=>cursorByPage(view,!0),cursorLineBoundaryForward=view=>moveSel(view,range=>moveByLineBoundary(view,range,!0)),cursorLineBoundaryBackward=view=>moveSel(view,range=>moveByLineBoundary(view,range,!1)),cursorLineBoundaryLeft=view=>moveSel(view,range=>moveByLineBoundary(view,range,!ltrAtCursor(view))),cursorLineBoundaryRight=view=>moveSel(view,range=>moveByLineBoundary(view,range,ltrAtCursor(view))),cursorLineStart=view=>moveSel(view,range=>state.EditorSelection.cursor(view.lineBlockAt(range.head).from,1)),cursorLineEnd=view=>moveSel(view,range=>state.EditorSelection.cursor(view.lineBlockAt(range.head).to,-1)),cursorMatchingBracket=({state,dispatch})=>toMatchingBracket(state,dispatch,!1),selectMatchingBracket=({state,dispatch})=>toMatchingBracket(state,dispatch,!0),selectCharLeft=view=>selectByChar(view,!ltrAtCursor(view)),selectCharRight=view=>selectByChar(view,ltrAtCursor(view)),selectCharForward=view=>selectByChar(view,!0),selectCharBackward=view=>selectByChar(view,!1),selectCharForwardLogical=target=>extendSel(target,range=>byCharLogical(target.state,range,!0)),selectCharBackwardLogical=target=>extendSel(target,range=>byCharLogical(target.state,range,!1)),selectGroupLeft=view=>selectByGroup(view,!ltrAtCursor(view)),selectGroupRight=view=>selectByGroup(view,ltrAtCursor(view)),selectGroupForward=view=>selectByGroup(view,!0),selectGroupBackward=view=>selectByGroup(view,!1),selectGroupForwardWin=view=>extendSel(view,range=>view.moveByChar(range,!0,start=>toGroupStart(view,range.head,start))),selectSubwordForward=view=>selectBySubword(view,!0),selectSubwordBackward=view=>selectBySubword(view,!1),selectSyntaxLeft=view=>extendSel(view,range=>moveBySyntax(view.state,range,!ltrAtCursor(view))),selectSyntaxRight=view=>extendSel(view,range=>moveBySyntax(view.state,range,ltrAtCursor(view))),selectLineUp=view=>selectByLine(view,!1),selectLineDown=view=>selectByLine(view,!0),selectPageUp=view=>selectByPage(view,!1),selectPageDown=view=>selectByPage(view,!0),selectLineBoundaryForward=view=>extendSel(view,range=>moveByLineBoundary(view,range,!0)),selectLineBoundaryBackward=view=>extendSel(view,range=>moveByLineBoundary(view,range,!1)),selectLineBoundaryLeft=view=>extendSel(view,range=>moveByLineBoundary(view,range,!ltrAtCursor(view))),selectLineBoundaryRight=view=>extendSel(view,range=>moveByLineBoundary(view,range,ltrAtCursor(view))),selectLineStart=view=>extendSel(view,range=>state.EditorSelection.cursor(view.lineBlockAt(range.head).from)),selectLineEnd=view=>extendSel(view,range=>state.EditorSelection.cursor(view.lineBlockAt(range.head).to)),cursorDocStart=({state,dispatch})=>(dispatch(setSel(state,{anchor:0})),!0),cursorDocEnd=({state,dispatch})=>(dispatch(setSel(state,{anchor:state.doc.length})),!0),selectDocStart=({state,dispatch})=>(dispatch(setSel(state,{anchor:state.selection.main.anchor,head:0})),!0),selectDocEnd=({state,dispatch})=>(dispatch(setSel(state,{anchor:state.selection.main.anchor,head:state.doc.length})),!0),selectAll=({state,dispatch})=>(dispatch(state.update({selection:{anchor:0,head:state.doc.length},userEvent:"select"})),!0),selectLine=({state:state$1,dispatch})=>{let ranges=selectedLineBlocks(state$1).map(({from,to})=>state.EditorSelection.range(from,Math.min(to+1,state$1.doc.length)));return dispatch(state$1.update({selection:state.EditorSelection.create(ranges),userEvent:"select"})),!0},selectParentSyntax=({state:state$1,dispatch})=>{let selection=updateSel(state$1.selection,range=>{let tree=language.syntaxTree(state$1),stack=tree.resolveStack(range.from,1);if(range.empty){let stackBefore=tree.resolveStack(range.from,-1);stackBefore.node.from>=stack.node.from&&stackBefore.node.to<=stack.node.to&&(stack=stackBefore)}for(let cur=stack;cur;cur=cur.next){let{node}=cur;if((node.from<range.from&&node.to>=range.to||node.to>range.to&&node.from<=range.from)&&cur.next)return state.EditorSelection.range(node.to,node.from)}return range});return!selection.eq(state$1.selection)&&(dispatch(setSel(state$1,selection)),!0)},addCursorAbove=view=>addCursorVertically(view,!1),addCursorBelow=view=>addCursorVertically(view,!0),simplifySelection=({state:state$1,dispatch})=>{let cur=state$1.selection,selection=null;return(1<cur.ranges.length?selection=state.EditorSelection.create([cur.main]):!cur.main.empty&&(selection=state.EditorSelection.create([state.EditorSelection.cursor(cur.main.head)])),!!selection)&&(dispatch(setSel(state$1,selection)),!0)},deleteByChar=(target,forward,byIndentUnit)=>deleteBy(target,range=>{let before,targetPos,pos=range.from,{state:state$1}=target,line=state$1.doc.lineAt(pos);if(byIndentUnit&&!forward&&pos>line.from&&pos<line.from+200&&!/[^ \t]/.test(before=line.text.slice(0,pos-line.from))){if("\t"==before[before.length-1])return pos-1;let col=state.countColumn(before,state$1.tabSize),drop=col%language.getIndentUnit(state$1)||language.getIndentUnit(state$1);for(let i=0;i<drop&&" "==before[before.length-1-i];i++)pos--;targetPos=pos}else targetPos=state.findClusterBreak(line.text,pos-line.from,forward,forward)+line.from,targetPos==pos&&line.number!=(forward?state$1.doc.lines:1)?targetPos+=forward?1:-1:!forward&&/[\ufe00-\ufe0f]/.test(line.text.slice(targetPos-line.from,pos-line.from))&&(targetPos=state.findClusterBreak(line.text,targetPos-line.from,!1,!1)+line.from);return targetPos}),deleteCharBackward=view=>deleteByChar(view,!1,!0),deleteCharBackwardStrict=view=>deleteByChar(view,!1,!1),deleteCharForward=view=>deleteByChar(view,!0,!1),deleteByGroup=(target,forward)=>deleteBy(target,range=>{let pos=range.head,{state:state$1}=target,line=state$1.doc.lineAt(pos),categorize=state$1.charCategorizer(pos);for(let cat=null;;){if(pos==(forward?line.to:line.from)){pos==range.head&&line.number!=(forward?state$1.doc.lines:1)&&(pos+=forward?1:-1);break}let next=state.findClusterBreak(line.text,pos-line.from,forward)+line.from,nextChar=line.text.slice(Math.min(pos,next)-line.from,Math.max(pos,next)-line.from),nextCat=categorize(nextChar);if(null!=cat&&nextCat!=cat)break;(" "!=nextChar||pos!=range.head)&&(cat=nextCat),pos=next}return pos}),deleteGroupBackward=target=>deleteByGroup(target,!1),deleteGroupForward=target=>deleteByGroup(target,!0),deleteGroupForwardWin=view=>deleteBy(view,range=>view.moveByChar(range,!0,start=>toGroupStart(view,range.head,start)).head),deleteToLineEnd=view=>deleteBy(view,range=>{let lineEnd=view.lineBlockAt(range.head).to;return range.head<lineEnd?lineEnd:Math.min(view.state.doc.length,range.head+1)}),deleteToLineStart=view=>deleteBy(view,range=>{let lineStart=view.lineBlockAt(range.head).from;return range.head>lineStart?lineStart:Math.max(0,range.head-1)}),deleteLineBoundaryBackward=view=>deleteBy(view,range=>{let lineStart=view.moveToLineBoundary(range,!1).head;return range.head>lineStart?lineStart:Math.max(0,range.head-1)}),deleteLineBoundaryForward=view=>deleteBy(view,range=>{let lineStart=view.moveToLineBoundary(range,!0).head;return range.head<lineStart?lineStart:Math.min(view.state.doc.length,range.head+1)}),deleteTrailingWhitespace=({state,dispatch})=>{if(state.readOnly)return!1;let changes=[];for(let pos=0,prev="",iter=state.doc.iter();;){if(iter.next(),iter.lineBreak||iter.done){let trailing=prev.search(/\s+$/);if(-1<trailing&&changes.push({from:pos-(prev.length-trailing),to:pos}),iter.done)break;prev=""}else prev=iter.value;pos+=iter.value.length}return!!changes.length&&(dispatch(state.update({changes,userEvent:"delete"})),!0)},splitLine=({state:state$1,dispatch})=>{if(state$1.readOnly)return!1;let changes=state$1.changeByRange(range=>({changes:{from:range.from,to:range.to,insert:state.Text.of(["",""])},range:state.EditorSelection.cursor(range.from)}));return dispatch(state$1.update(changes,{scrollIntoView:!0,userEvent:"input"})),!0},transposeChars=({state:state$1,dispatch})=>{if(state$1.readOnly)return!1;let changes=state$1.changeByRange(range=>{if(!range.empty||0==range.from||range.from==state$1.doc.length)return{range};let pos=range.from,line=state$1.doc.lineAt(pos),from=pos==line.from?pos-1:state.findClusterBreak(line.text,pos-line.from,!1)+line.from,to=pos==line.to?pos+1:state.findClusterBreak(line.text,pos-line.from,!0)+line.from;return{changes:{from,to,insert:state$1.doc.slice(pos,to).append(state$1.doc.slice(from,pos))},range:state.EditorSelection.cursor(to)}});return!changes.changes.empty&&(dispatch(state$1.update(changes,{scrollIntoView:!0,userEvent:"move.character"})),!0)},moveLineUp=({state,dispatch})=>moveLine(state,dispatch,!1),moveLineDown=({state,dispatch})=>moveLine(state,dispatch,!0),copyLineUp=({state,dispatch})=>copyLine(state,dispatch,!1),copyLineDown=({state,dispatch})=>copyLine(state,dispatch,!0),deleteLine=view=>{if(view.state.readOnly)return!1;let{state}=view,changes=state.changes(selectedLineBlocks(state).map(({from,to})=>(0<from?from--:to<state.doc.length&&to++,{from,to}))),selection=updateSel(state.selection,range=>{let dist;if(view.lineWrapping){let block=view.lineBlockAt(range.head),pos=view.coordsAtPos(range.head,range.assoc||1);pos&&(dist=block.bottom+view.documentTop-pos.bottom+view.defaultLineHeight/2)}return view.moveVertically(range,!0,dist)}).map(changes);return view.dispatch({changes,selection,scrollIntoView:!0,userEvent:"delete.line"}),!0},insertNewline=({state,dispatch})=>(dispatch(state.update(state.replaceSelection(state.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),insertNewlineKeepIndent=({state:state$1,dispatch})=>(dispatch(state$1.update(state$1.changeByRange(range=>{let indent=/^\s*/.exec(state$1.doc.lineAt(range.from).text)[0];return{changes:{from:range.from,to:range.to,insert:state$1.lineBreak+indent},range:state.EditorSelection.cursor(range.from+indent.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0),insertNewlineAndIndent=newlineAndIndent(!1),insertBlankLine=newlineAndIndent(!0),indentSelection=({state,dispatch})=>{if(state.readOnly)return!1;let updated=Object.create(null),context=new language.IndentContext(state,{overrideIndentation:start=>{let found=updated[start];return null==found?-1:found}}),changes=changeBySelectedLine(state,(line,changes,range)=>{let indent=language.getIndentation(context,line.from);if(null==indent)return;/\S/.test(line.text)||(indent=0);let cur=/^\s*/.exec(line.text)[0],norm=language.indentString(state,indent);(cur!=norm||range.from<line.from+cur.length)&&(updated[line.from]=indent,changes.push({from:line.from,to:line.from+cur.length,insert:norm}))});return changes.changes.empty||dispatch(state.update(changes,{userEvent:"indent"})),!0},indentMore=({state,dispatch})=>!state.readOnly&&(dispatch(state.update(changeBySelectedLine(state,(line,changes)=>{changes.push({from:line.from,insert:state.facet(language.indentUnit)})}),{userEvent:"input.indent"})),!0),indentLess=({state:state$1,dispatch})=>!state$1.readOnly&&(dispatch(state$1.update(changeBySelectedLine(state$1,(line,changes)=>{let space=/^\s*/.exec(line.text)[0];if(!space)return;let col=state.countColumn(space,state$1.tabSize),keep=0,insert=language.indentString(state$1,Math.max(0,col-language.getIndentUnit(state$1)));for(;keep<space.length&&keep<insert.length&&space.charCodeAt(keep)==insert.charCodeAt(keep);)keep++;changes.push({from:line.from+keep,to:line.from+space.length,insert:insert.slice(keep)})}),{userEvent:"delete.dedent"})),!0),toggleTabFocusMode=view=>(view.setTabFocusMode(),!0),temporarilySetTabFocusMode=view=>(view.setTabFocusMode(2e3),!0),insertTab=({state,dispatch})=>state.selection.ranges.some(r=>!r.empty)?indentMore({state,dispatch}):(dispatch(state.update(state.replaceSelection("\t"),{scrollIntoView:!0,userEvent:"input"})),!0),emacsStyleKeymap=[{key:"Ctrl-b",run:cursorCharLeft,shift:selectCharLeft,preventDefault:!0},{key:"Ctrl-f",run:cursorCharRight,shift:selectCharRight},{key:"Ctrl-p",run:cursorLineUp,shift:selectLineUp},{key:"Ctrl-n",run:cursorLineDown,shift:selectLineDown},{key:"Ctrl-a",run:cursorLineStart,shift:selectLineStart},{key:"Ctrl-e",run:cursorLineEnd,shift:selectLineEnd},{key:"Ctrl-d",run:deleteCharForward},{key:"Ctrl-h",run:deleteCharBackward},{key:"Ctrl-k",run:deleteToLineEnd},{key:"Ctrl-Alt-h",run:deleteGroupBackward},{key:"Ctrl-o",run:splitLine},{key:"Ctrl-t",run:transposeChars},{key:"Ctrl-v",run:cursorPageDown}],standardKeymap=[{key:"ArrowLeft",run:cursorCharLeft,shift:selectCharLeft,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cursorGroupLeft,shift:selectGroupLeft,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:cursorLineBoundaryLeft,shift:selectLineBoundaryLeft,preventDefault:!0},{key:"ArrowRight",run:cursorCharRight,shift:selectCharRight,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cursorGroupRight,shift:selectGroupRight,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cursorLineBoundaryRight,shift:selectLineBoundaryRight,preventDefault:!0},{key:"ArrowUp",run:cursorLineUp,shift:selectLineUp,preventDefault:!0},{mac:"Cmd-ArrowUp",run:cursorDocStart,shift:selectDocStart},{mac:"Ctrl-ArrowUp",run:cursorPageUp,shift:selectPageUp},{key:"ArrowDown",run:cursorLineDown,shift:selectLineDown,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cursorDocEnd,shift:selectDocEnd},{mac:"Ctrl-ArrowDown",run:cursorPageDown,shift:selectPageDown},{key:"PageUp",run:cursorPageUp,shift:selectPageUp},{key:"PageDown",run:cursorPageDown,shift:selectPageDown},{key:"Home",run:cursorLineBoundaryBackward,shift:selectLineBoundaryBackward,preventDefault:!0},{key:"Mod-Home",run:cursorDocStart,shift:selectDocStart},{key:"End",run:cursorLineBoundaryForward,shift:selectLineBoundaryForward,preventDefault:!0},{key:"Mod-End",run:cursorDocEnd,shift:selectDocEnd},{key:"Enter",run:insertNewlineAndIndent,shift:insertNewlineAndIndent},{key:"Mod-a",run:selectAll},{key:"Backspace",run:deleteCharBackward,shift:deleteCharBackward,preventDefault:!0},{key:"Delete",run:deleteCharForward,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:deleteGroupBackward,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:deleteGroupForward,preventDefault:!0},{mac:"Mod-Backspace",run:deleteLineBoundaryBackward,preventDefault:!0},{mac:"Mod-Delete",run:deleteLineBoundaryForward,preventDefault:!0}].concat(emacsStyleKeymap.map(b=>({mac:b.key,run:b.run,shift:b.shift}))),defaultKeymap=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Mod-Alt-ArrowUp",run:addCursorAbove},{key:"Mod-Alt-ArrowDown",run:addCursorBelow},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:!0},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket},{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment},{key:"Ctrl-m",mac:"Shift-Alt-m",run:toggleTabFocusMode}].concat(standardKeymap),indentWithTab={key:"Tab",run:indentMore,shift:indentLess};/**
|
|
153
153
|
Move the selection one character to the right.
|
|
154
|
-
|
|
154
|
+
*//**
|
|
155
155
|
Move the selection one character forward.
|
|
156
|
-
|
|
156
|
+
*//**
|
|
157
157
|
Move the selection one character backward.
|
|
158
|
-
|
|
158
|
+
*//**
|
|
159
159
|
Move the selection one character backward, in logical string index
|
|
160
160
|
order.
|
|
161
|
-
|
|
161
|
+
*//**
|
|
162
162
|
Move the selection one group to the right.
|
|
163
|
-
|
|
163
|
+
*//**
|
|
164
164
|
Move the selection one group forward.
|
|
165
|
-
|
|
165
|
+
*//**
|
|
166
166
|
Move the selection one group backward.
|
|
167
|
-
|
|
167
|
+
*//**
|
|
168
168
|
Move the selection one group or camel-case subword backward.
|
|
169
|
-
|
|
169
|
+
*//**
|
|
170
170
|
Move the cursor over the next syntactic element to the right.
|
|
171
|
-
|
|
171
|
+
*//**
|
|
172
172
|
Move the selection one line down.
|
|
173
|
-
|
|
173
|
+
*//**
|
|
174
174
|
Move the selection one page down.
|
|
175
|
-
|
|
175
|
+
*//**
|
|
176
176
|
Move the selection to previous line wrap point, or failing that to
|
|
177
177
|
the start of the line. If the line is indented, and the cursor
|
|
178
178
|
isn't already at the end of the indentation, this will move to the
|
|
179
179
|
end of the indentation instead of the start of the line.
|
|
180
|
-
|
|
180
|
+
*//**
|
|
181
181
|
Move the selection one line wrap point to the left.
|
|
182
|
-
|
|
182
|
+
*//**
|
|
183
183
|
Move the selection one line wrap point to the right.
|
|
184
|
-
|
|
184
|
+
*//**
|
|
185
185
|
Move the selection to the start of the line.
|
|
186
|
-
|
|
186
|
+
*//**
|
|
187
187
|
Move the selection to the end of the line.
|
|
188
|
-
|
|
188
|
+
*//**
|
|
189
189
|
Extend the selection to the bracket matching the one the selection
|
|
190
190
|
head is currently on, if any.
|
|
191
|
-
|
|
191
|
+
*//**
|
|
192
192
|
Move the selection head one character to the right.
|
|
193
|
-
|
|
193
|
+
*//**
|
|
194
194
|
Move the selection head one character forward.
|
|
195
|
-
|
|
195
|
+
*//**
|
|
196
196
|
Move the selection head one character backward.
|
|
197
|
-
|
|
197
|
+
*//**
|
|
198
198
|
Move the selection head one character forward by logical
|
|
199
199
|
(non-direction aware) string index order.
|
|
200
|
-
|
|
200
|
+
*//**
|
|
201
201
|
Move the selection head one character backward by logical string
|
|
202
202
|
index order.
|
|
203
|
-
|
|
203
|
+
*//**
|
|
204
204
|
Move the selection head one group to the right.
|
|
205
|
-
|
|
205
|
+
*//**
|
|
206
206
|
Move the selection head one group forward.
|
|
207
|
-
|
|
207
|
+
*//**
|
|
208
208
|
Move the selection head one group backward.
|
|
209
|
-
|
|
209
|
+
*//**
|
|
210
210
|
Move the selection head one group forward in the default Windows
|
|
211
211
|
style, skipping to the start of the next group.
|
|
212
|
-
|
|
212
|
+
*//**
|
|
213
213
|
Move the selection head one group or subword backward.
|
|
214
|
-
|
|
214
|
+
*//**
|
|
215
215
|
Move the selection head over the next syntactic element to the left.
|
|
216
|
-
|
|
216
|
+
*//**
|
|
217
217
|
Move the selection head over the next syntactic element to the right.
|
|
218
|
-
|
|
218
|
+
*//**
|
|
219
219
|
Move the selection head one line down.
|
|
220
|
-
|
|
220
|
+
*//**
|
|
221
221
|
Move the selection head one page down.
|
|
222
|
-
|
|
222
|
+
*//**
|
|
223
223
|
Move the selection head to the next line boundary.
|
|
224
|
-
|
|
224
|
+
*//**
|
|
225
225
|
Move the selection head to the previous line boundary.
|
|
226
|
-
|
|
226
|
+
*//**
|
|
227
227
|
Move the selection head one line boundary to the left.
|
|
228
|
-
|
|
228
|
+
*//**
|
|
229
229
|
Move the selection head one line boundary to the right.
|
|
230
|
-
|
|
230
|
+
*//**
|
|
231
231
|
Move the selection head to the start of the line.
|
|
232
|
-
|
|
232
|
+
*//**
|
|
233
233
|
Move the selection head to the end of the line.
|
|
234
|
-
|
|
234
|
+
*//**
|
|
235
235
|
Move the selection to the start of the document.
|
|
236
|
-
|
|
236
|
+
*//**
|
|
237
237
|
Move the selection to the end of the document.
|
|
238
|
-
|
|
238
|
+
*//**
|
|
239
239
|
Move the selection head to the start of the document.
|
|
240
|
-
|
|
240
|
+
*//**
|
|
241
241
|
Move the selection head to the end of the document.
|
|
242
|
-
|
|
242
|
+
*//**
|
|
243
243
|
Select the entire document.
|
|
244
|
-
|
|
244
|
+
*//**
|
|
245
245
|
Expand the selection to cover entire lines.
|
|
246
|
-
|
|
246
|
+
*//**
|
|
247
247
|
Select the next syntactic construct that is larger than the
|
|
248
248
|
selection. Note that this will only work insofar as the language
|
|
249
249
|
[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
|
|
250
250
|
syntax tree.
|
|
251
|
-
|
|
251
|
+
*//**
|
|
252
252
|
Expand the selection by adding a cursor below the heads of
|
|
253
253
|
currently selected ranges.
|
|
254
|
-
|
|
254
|
+
*//**
|
|
255
255
|
Simplify the current selection. When multiple ranges are selected,
|
|
256
256
|
reduce it to its main range. Otherwise, if the selection is
|
|
257
257
|
non-empty, convert it to a cursor selection.
|
|
258
|
-
|
|
258
|
+
*//**
|
|
259
259
|
Delete the selection, or, for cursor selections, the character or
|
|
260
260
|
indentation unit before the cursor.
|
|
261
|
-
|
|
261
|
+
*//**
|
|
262
262
|
Delete the selection or the character before the cursor. Does not
|
|
263
263
|
implement any extended behavior like deleting whole indentation
|
|
264
264
|
units in one go.
|
|
265
|
-
|
|
265
|
+
*//**
|
|
266
266
|
Delete the selection or the character after the cursor.
|
|
267
|
-
|
|
267
|
+
*//**
|
|
268
268
|
Delete the selection or backward until the end of the next
|
|
269
269
|
[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
|
|
270
270
|
whitespace when they consist of a single space.
|
|
271
|
-
|
|
271
|
+
*//**
|
|
272
272
|
Delete the selection or forward until the end of the next group.
|
|
273
|
-
|
|
273
|
+
*//**
|
|
274
274
|
Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
|
275
275
|
that uses the Windows convention of also deleting the whitespace
|
|
276
276
|
after a word.
|
|
277
|
-
|
|
277
|
+
*//**
|
|
278
278
|
Delete the selection, or, if it is a cursor selection, delete to
|
|
279
279
|
the end of the line. If the cursor is directly at the end of the
|
|
280
280
|
line, delete the line break after it.
|
|
281
|
-
|
|
281
|
+
*//**
|
|
282
282
|
Delete the selection, or, if it is a cursor selection, delete to
|
|
283
283
|
the start of the line. If the cursor is directly at the start of the
|
|
284
284
|
line, delete the line break before it.
|
|
285
|
-
|
|
285
|
+
*//**
|
|
286
286
|
Delete the selection, or, if it is a cursor selection, delete to
|
|
287
287
|
the start of the line or the next line wrap before the cursor.
|
|
288
|
-
|
|
288
|
+
*//**
|
|
289
289
|
Delete the selection, or, if it is a cursor selection, delete to
|
|
290
290
|
the end of the line or the next line wrap after the cursor.
|
|
291
|
-
|
|
291
|
+
*//**
|
|
292
292
|
Delete all whitespace directly before a line end from the
|
|
293
293
|
document.
|
|
294
|
-
|
|
294
|
+
*//**
|
|
295
295
|
Replace each selection range with a line break, leaving the cursor
|
|
296
296
|
on the line before the break.
|
|
297
|
-
|
|
297
|
+
*//**
|
|
298
298
|
Flip the characters before and after the cursor(s).
|
|
299
|
-
|
|
299
|
+
*//**
|
|
300
300
|
Move the selected lines down one line.
|
|
301
|
-
|
|
301
|
+
*//**
|
|
302
302
|
Create a copy of the selected lines. Keep the selection in the bottom copy.
|
|
303
|
-
|
|
303
|
+
*//**
|
|
304
304
|
Delete selected lines.
|
|
305
|
-
|
|
305
|
+
*//**
|
|
306
306
|
Replace the selection with a newline.
|
|
307
|
-
|
|
307
|
+
*//**
|
|
308
308
|
Replace the selection with a newline and the same amount of
|
|
309
309
|
indentation as the line above.
|
|
310
|
-
|
|
310
|
+
*//**
|
|
311
311
|
Create a blank, indented line below the current line.
|
|
312
|
-
|
|
312
|
+
*//**
|
|
313
313
|
Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
|
|
314
314
|
lines.
|
|
315
|
-
|
|
315
|
+
*//**
|
|
316
316
|
Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
|
|
317
317
|
selected lines.
|
|
318
|
-
|
|
318
|
+
*//**
|
|
319
319
|
Enables or disables
|
|
320
320
|
[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this
|
|
321
321
|
prevents the editor's key bindings from capturing Tab or
|
|
322
322
|
Shift-Tab, making it possible for the user to move focus out of
|
|
323
323
|
the editor with the keyboard.
|
|
324
|
-
|
|
324
|
+
*//**
|
|
325
325
|
Temporarily enables [tab-focus
|
|
326
326
|
mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until
|
|
327
327
|
another key is pressed.
|
|
328
|
-
|
|
328
|
+
*//**
|
|
329
329
|
Insert a tab character at the cursor or, if something is selected,
|
|
330
330
|
use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire
|
|
331
331
|
selection.
|
|
332
|
-
|
|
332
|
+
*//**
|
|
333
333
|
Array of key bindings containing the Emacs-style bindings that are
|
|
334
334
|
available on macOS by default.
|
|
335
335
|
|
|
@@ -347,7 +347,7 @@ static fromTransaction(tr,selection){let effects=none;for(let invert of tr.start
|
|
|
347
347
|
- Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
|
|
348
348
|
- Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
|
|
349
349
|
- Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
|
|
350
|
-
|
|
350
|
+
*//**
|
|
351
351
|
An array of key bindings closely sticking to platform-standard or
|
|
352
352
|
widely used bindings. (This includes the bindings from
|
|
353
353
|
[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
|
|
@@ -379,7 +379,7 @@ static fromTransaction(tr,selection){let effects=none;for(let invert of tr.start
|
|
|
379
379
|
- Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
|
380
380
|
- Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward).
|
|
381
381
|
- Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward).
|
|
382
|
-
|
|
382
|
+
*//**
|
|
383
383
|
The default keymap. Includes all bindings from
|
|
384
384
|
[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
|
|
385
385
|
|
|
@@ -403,7 +403,7 @@ static fromTransaction(tr,selection){let effects=none;for(let invert of tr.start
|
|
|
403
403
|
- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
|
|
404
404
|
- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
|
|
405
405
|
- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode).
|
|
406
|
-
|
|
406
|
+
*//**
|
|
407
407
|
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
|
|
408
408
|
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
|
|
409
409
|
Please see the [Tab example](../../examples/tab/) before using
|