Build 574548stable
Module 35277
4,402 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{b:()=>o}),n(134528),n(947204);var i=n(719442),r=n(317681),s=n(820066),a=n(551483);let o={...i.gB,resetSelectionToEditorStart(e){i.gB.select(e,s.VW.start(e,[]))},resetSelectionToEditorEnd(e){i.gB.select(e,s.VW.end(e,[]))},delete(e,t){let{at:n,distance:r,unit:a,reverse:o=!1,select:l=!1,bounds:u,voids:c}=t;if(null==n){if(null==e.selection)return;n=e.selection}let[d,_]=s.ZF.isRange(n)?s.ZF.edges(n):s.VW.edges(e,n);if(null!=r||null!=a)if(o){let t=s.VW.before(e,d,{distance:r,unit:a})??s.VW.start(e,[]);if("character"===a&&(r??1)===1&&s.PW.equals(d.path,_.path)){let n=s.VW.leaf(e,d.path),i=null!=n?n[0].text:"";i.length>0&&null!=i[i.length-1].match(/[\u0E00-\u0E7F]/)&&(t=s.VW.before(e,d,{distance:r,unit:"offset"})??s.VW.start(e,[]))}d=t}else _=s.VW.after(e,_,{distance:r,unit:a})??s.VW.end(e,[]);if(null!=u){let[e,t]=s.ZF.edges(u);s.Kh.isBefore(d,e)&&(d=e),s.Kh.isAfter(_,t)&&(_=t)}!s.Kh.equals(d,_)&&(i.gB.delete(e,{at:{anchor:d,focus:_},hanging:!0,voids:c}),l&&s.VW.hasPath(e,d.path)&&i.gB.select(e,d))},textToText(e,t,n){let r=s.VW.getSelectionOverlap(e,n),[a,o]=s.ZF.edges(n),l=s.VW.before(e,a)??s.VW.start(e,[]),c=s.VW.after(e,o);s.ZF.isExpanded(n)&&i.gB.delete(e,{at:n,voids:!0}),i.gB.insertText(e,t,{at:l}),l=l??s.VW.start(e,[]),c=c??s.VW.end(e,[]),u(e,r,l,c,c)},textToVoid(e,t,n){let r=s.VW.getSelectionOverlap(e,n),a=s.ZF.start(n),o=s.PW.next(a.path),l={path:s.PW.next(o),offset:0};i.gB.delete(e,{at:n,voids:!0}),0===a.offset&&i.gB.insertNodes(e,[{text:""}],{at:a.path}),i.gB.insertNodes(e,[t],{at:a}),s.VW.hasPath(e,l.path)&&s.l5.isText(s.VW.node(e,l.path)[0])||i.gB.insertNodes(e,[{text:""}],{at:l.path}),u(e,r,a,l,l)},textToInline(e,t,n){let r=s.VW.getSelectionOverlap(e,n),a=t.children[t.children.length-1],o=s.ZF.start(n),l=s.PW.next(o.path),c={path:s.PW.child(l,t.children.length-1),offset:s.l5.isText(a)?a.text.length:0};i.gB.delete(e,{at:n,voids:!0}),0===o.offset&&i.gB.insertNodes(e,[{text:""}],{at:o.path}),i.gB.insertNodes(e,[t],{at:o}),u(e,r,o,c,c)},voidToText(e,t,n){let r=s.VW.getSelectionOverlap(e,n),a=s.VW.before(e,n)??s.VW.start(e,[]),o={path:a.path,offset:a.offset+t.length};i.gB.delete(e,{at:n,voids:!0}),i.gB.insertText(e,t,{at:a}),u(e,r,a,a,o)},removeInline(e,t){let n=s.VW.getSelectionOverlap(e,t),r=s.VW.before(e,t)??s.VW.start(e,[]);i.gB.delete(e,{at:t,voids:!0}),u(e,n,r,r,r)},removeInlineChildren(e,t){let[n,r]=t,a=s.VW.getSelectionOverlap(e,r),o={path:s.PW.child(r,0),offset:0};s.VW.withoutNormalizing(e,()=>{for(let t=n.children.length-1;t>=0;t--)i.gB.removeNodes(e,{at:s.PW.child(r,t),voids:!0})}),u(e,a,null,o,null)},selectCommandOption(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=r.n$(e);if(null!=a)for(let r=0;r<a[0].children.length;r++){let o=a[0].children[r];if(s.AS.isType(o,"applicationCommandOption")&&o.optionName===t)return void(n?i.gB.select(e,[0,r]):i.gB.select(e,s.VW.end(e,[0,r])))}},selectPreviousCommandOption(e){if(null==r.n$(e))return;let t=null!=e.selection?e.selection.focus.path:s.VW.end(e,a.Xg).path,n=r.M3(e),o=s.VW.previous(e,{at:t,match:e=>e!==n?.[0]&&s.AS.isType(e,"applicationCommandOption")});null!=o?i.gB.select(e,o[1]):s.PW.isAfter(t,a.fP)&&i.gB.select(e,s.VW.end(e,a.fP))},selectNextCommandOption(e){if(null==r.n$(e))return;let t=null!=e.selection?e.selection.focus.path:s.VW.start(e,a.Xg).path,n=r.M3(e),l=s.VW.next(e,{at:t,match:e=>e!==n?.[0]&&s.AS.isType(e,"applicationCommandOption")});null!=l?i.gB.select(e,l[1]):o.resetSelectionToEditorEnd(e)},insertCommandOption(e,t){o.resetSelectionToEditorEnd(e),o.insertNodes(e,[{type:"applicationCommandOption",optionName:t.name,optionDisplayName:t.displayName,optionType:t.type,children:[{text:""}]}])},keyboardMove(e,t){let{distance:n=1,unit:r="character",reverse:a=!1,edge:o}=t??{},l=e.selection;if(null==l)return;let u=l.focus;if(s.ZF.isExpanded(l)){if(void 0===o&&"character"===r)return void i.gB.collapse(e,{edge:a?"start":"end"});"focus"!==o&&(u="line"===r||a?s.ZF.start(l):s.ZF.end(l))}let c=(a?s.VW.before:s.VW.after)(e,u,{unit:r,distance:n});null!=c&&i.gB.setSelection(e,"focus"===o?{focus:c}:{anchor:c,focus:c})}};function l(e,t,n,i,r){switch(t){case"start":return n;case"inside":return i;case"end":return r}return e}function u(e,t,n,i,r){if(null==t.anchor&&null==t.focus)return;let s=l(e.selection?.anchor,t.anchor,n,i,r),a=l(e.selection?.focus,t.focus,n,i,r);null==s||null==a||o.select(e,{anchor:s,focus:a})}}