Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
@@ -18,7 +18,7 @@ function contains(parent,child){if(child.nodeType==3){child=child.parentNode;}
|
||||
if(parent.contains){return parent.contains(child)}
|
||||
do{if(child.nodeType==11){child=child.host;}
|
||||
if(child==parent){return true}}while(child=child.parentNode)}
|
||||
function activeElt(doc){var activeElement;try{activeElement=doc.activeElement;}catch(e){activeElement=doc.body||null;}
|
||||
function activeElt(rootNode){var doc=rootNode.ownerDocument||rootNode;var activeElement;try{activeElement=rootNode.activeElement;}catch(e){activeElement=doc.body||null;}
|
||||
while(activeElement&&activeElement.shadowRoot&&activeElement.shadowRoot.activeElement){activeElement=activeElement.shadowRoot.activeElement;}
|
||||
return activeElement}
|
||||
function addClass(node,cls){var current=node.className;if(!classTest(cls).test(current)){node.className+=(current?" ":"")+cls;}}
|
||||
@@ -27,6 +27,8 @@ return b}
|
||||
var selectInput=function(node){node.select();};if(ios){selectInput=function(node){node.selectionStart=0;node.selectionEnd=node.value.length;};}
|
||||
else if(ie){selectInput=function(node){try{node.select();}catch(_e){}};}
|
||||
function doc(cm){return cm.display.wrapper.ownerDocument}
|
||||
function root(cm){return rootNode(cm.display.wrapper)}
|
||||
function rootNode(element){return element.getRootNode?element.getRootNode():element.ownerDocument}
|
||||
function win(cm){return doc(cm).defaultView}
|
||||
function bind(f){var args=Array.prototype.slice.call(arguments,1);return function(){return f.apply(null,args)}}
|
||||
function copyObj(obj,target,overwrite){if(!target){target={};}
|
||||
@@ -754,7 +756,7 @@ op.barMeasure=measureForScrollbars(cm);if(display.maxLineChanged&&!cm.options.li
|
||||
if(op.updatedDisplay||op.selectionChanged){op.preparedSelection=display.input.prepareSelection();}}
|
||||
function endOperation_W2(op){var cm=op.cm;if(op.adjustWidthTo!=null){cm.display.sizer.style.minWidth=op.adjustWidthTo+"px";if(op.maxScrollLeft<cm.doc.scrollLeft){setScrollLeft(cm,Math.min(cm.display.scroller.scrollLeft,op.maxScrollLeft),true);}
|
||||
cm.display.maxLineChanged=false;}
|
||||
var takeFocus=op.focus&&op.focus==activeElt(doc(cm));if(op.preparedSelection){cm.display.input.showSelection(op.preparedSelection,takeFocus);}
|
||||
var takeFocus=op.focus&&op.focus==activeElt(root(cm));if(op.preparedSelection){cm.display.input.showSelection(op.preparedSelection,takeFocus);}
|
||||
if(op.updatedDisplay||op.startHeight!=cm.doc.height){updateScrollbars(cm,op.barMeasure);}
|
||||
if(op.updatedDisplay){setDocumentHeight(cm,op.barMeasure);}
|
||||
if(op.selectionChanged){restartBlink(cm);}
|
||||
@@ -794,10 +796,10 @@ line.stateAfter=context.line%5==0?context.save():null;context.nextLine();}
|
||||
if(+new Date>end){startWorker(cm,cm.options.workDelay);return true}});doc.highlightFrontier=context.line;doc.modeFrontier=Math.max(doc.modeFrontier,context.line);if(changedLines.length){runInOp(cm,function(){for(var i=0;i<changedLines.length;i++){regLineChange(cm,changedLines[i],"text");}});}}
|
||||
var DisplayUpdate=function(cm,viewport,force){var display=cm.display;this.viewport=viewport;this.visible=visibleLines(display,cm.doc,viewport);this.editorIsHidden=!display.wrapper.offsetWidth;this.wrapperHeight=display.wrapper.clientHeight;this.wrapperWidth=display.wrapper.clientWidth;this.oldDisplayWidth=displayWidth(cm);this.force=force;this.dims=getDimensions(cm);this.events=[];};DisplayUpdate.prototype.signal=function(emitter,type){if(hasHandler(emitter,type)){this.events.push(arguments);}};DisplayUpdate.prototype.finish=function(){for(var i=0;i<this.events.length;i++){signal.apply(null,this.events[i]);}};function maybeClipScrollbars(cm){var display=cm.display;if(!display.scrollbarsClipped&&display.scroller.offsetWidth){display.nativeBarWidth=display.scroller.offsetWidth-display.scroller.clientWidth;display.heightForcer.style.height=scrollGap(cm)+"px";display.sizer.style.marginBottom=-display.nativeBarWidth+"px";display.sizer.style.borderRightWidth=scrollGap(cm)+"px";display.scrollbarsClipped=true;}}
|
||||
function selectionSnapshot(cm){if(cm.hasFocus()){return null}
|
||||
var active=activeElt(doc(cm));if(!active||!contains(cm.display.lineDiv,active)){return null}
|
||||
var active=activeElt(root(cm));if(!active||!contains(cm.display.lineDiv,active)){return null}
|
||||
var result={activeElt:active};if(window.getSelection){var sel=win(cm).getSelection();if(sel.anchorNode&&sel.extend&&contains(cm.display.lineDiv,sel.anchorNode)){result.anchorNode=sel.anchorNode;result.anchorOffset=sel.anchorOffset;result.focusNode=sel.focusNode;result.focusOffset=sel.focusOffset;}}
|
||||
return result}
|
||||
function restoreSelection(snapshot){if(!snapshot||!snapshot.activeElt||snapshot.activeElt==activeElt(snapshot.activeElt.ownerDocument)){return}
|
||||
function restoreSelection(snapshot){if(!snapshot||!snapshot.activeElt||snapshot.activeElt==activeElt(rootNode(snapshot.activeElt))){return}
|
||||
snapshot.activeElt.focus();if(!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName)&&snapshot.anchorNode&&contains(document.body,snapshot.anchorNode)&&contains(document.body,snapshot.focusNode)){var doc=snapshot.activeElt.ownerDocument;var sel=doc.defaultView.getSelection(),range=doc.createRange();range.setEnd(snapshot.anchorNode,snapshot.anchorOffset);range.collapse(false);sel.removeAllRanges();sel.addRange(range);sel.extend(snapshot.focusNode,snapshot.focusOffset);}}
|
||||
function updateDisplayIfNeeded(cm,update){var display=cm.display,doc=cm.doc;if(update.editorIsHidden){resetView(cm);return false}
|
||||
if(!update.force&&update.visible.from>=display.viewFrom&&update.visible.to<=display.viewTo&&(display.updateLineNumbers==null||display.updateLineNumbers>=display.viewTo)&&display.renderedView==display.view&&countDirtyView(cm)==0){return false}
|
||||
@@ -1301,7 +1303,7 @@ function handleKeyBinding(cm,e){var name=keyName(e,true);if(!name){return false}
|
||||
if(e.shiftKey&&!cm.state.keySeq){return dispatchKey(cm,"Shift-"+name,e,function(b){return doHandleBinding(cm,b,true);})||dispatchKey(cm,name,e,function(b){if(typeof b=="string"?/^go[A-Z]/.test(b):b.motion){return doHandleBinding(cm,b)}})}else{return dispatchKey(cm,name,e,function(b){return doHandleBinding(cm,b);})}}
|
||||
function handleCharBinding(cm,e,ch){return dispatchKey(cm,"'"+ch+"'",e,function(b){return doHandleBinding(cm,b,true);})}
|
||||
var lastStoppedKey=null;function onKeyDown(e){var cm=this;if(e.target&&e.target!=cm.display.input.getField()){return}
|
||||
cm.curOp.focus=activeElt(doc(cm));if(signalDOMEvent(cm,e)){return}
|
||||
cm.curOp.focus=activeElt(root(cm));if(signalDOMEvent(cm,e)){return}
|
||||
if(ie&&ie_version<11&&e.keyCode==27){e.returnValue=false;}
|
||||
var code=e.keyCode;cm.display.shift=code==16||e.shiftKey;var handled=handleKeyBinding(cm,e);if(presto){lastStoppedKey=handled?code:null;if(!handled&&code==88&&!hasCopyEvent&&(mac?e.metaKey:e.ctrlKey)){cm.replaceSelection("",null,"cut");}}
|
||||
if(gecko&&!mac&&!handled&&code==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand){document.execCommand("cut");}
|
||||
@@ -1341,7 +1343,7 @@ if(value.addNew==null){value.addNew=mac?event.metaKey:event.ctrlKey;}
|
||||
if(value.moveOnDrag==null){value.moveOnDrag=!(mac?event.altKey:event.ctrlKey);}
|
||||
return value}
|
||||
function leftButtonDown(cm,pos,repeat,event){if(ie){setTimeout(bind(ensureFocus,cm),0);}
|
||||
else{cm.curOp.focus=activeElt(doc(cm));}
|
||||
else{cm.curOp.focus=activeElt(root(cm));}
|
||||
var behavior=configureMouse(cm,repeat,event);var sel=cm.doc.sel,contained;if(cm.options.dragDrop&&dragAndDrop&&!cm.isReadOnly()&&repeat=="single"&&(contained=sel.contains(pos))>-1&&(cmp((contained=sel.ranges[contained]).from(),pos)<0||pos.xRel>0)&&(cmp(contained.to(),pos)>0||pos.xRel<0)){leftButtonStartDrag(cm,event,pos,behavior);}
|
||||
else
|
||||
{leftButtonSelect(cm,event,pos,behavior);}}
|
||||
@@ -1358,25 +1360,25 @@ if(unit=="word"){return cm.findWordAt(pos)}
|
||||
if(unit=="line"){return new Range(Pos(pos.line,0),clipPos(cm.doc,Pos(pos.line+1,0)))}
|
||||
var result=unit(cm,pos);return new Range(result.from,result.to)}
|
||||
function leftButtonSelect(cm,event,start,behavior){if(ie){delayBlurEvent(cm);}
|
||||
var display=cm.display,doc$1=cm.doc;e_preventDefault(event);var ourRange,ourIndex,startSel=doc$1.sel,ranges=startSel.ranges;if(behavior.addNew&&!behavior.extend){ourIndex=doc$1.sel.contains(start);if(ourIndex>-1){ourRange=ranges[ourIndex];}
|
||||
var display=cm.display,doc=cm.doc;e_preventDefault(event);var ourRange,ourIndex,startSel=doc.sel,ranges=startSel.ranges;if(behavior.addNew&&!behavior.extend){ourIndex=doc.sel.contains(start);if(ourIndex>-1){ourRange=ranges[ourIndex];}
|
||||
else
|
||||
{ourRange=new Range(start,start);}}else{ourRange=doc$1.sel.primary();ourIndex=doc$1.sel.primIndex;}
|
||||
{ourRange=new Range(start,start);}}else{ourRange=doc.sel.primary();ourIndex=doc.sel.primIndex;}
|
||||
if(behavior.unit=="rectangle"){if(!behavior.addNew){ourRange=new Range(start,start);}
|
||||
start=posFromMouse(cm,event,true,true);ourIndex=-1;}else{var range=rangeForUnit(cm,start,behavior.unit);if(behavior.extend){ourRange=extendRange(ourRange,range.anchor,range.head,behavior.extend);}
|
||||
else
|
||||
{ourRange=range;}}
|
||||
if(!behavior.addNew){ourIndex=0;setSelection(doc$1,new Selection([ourRange],0),sel_mouse);startSel=doc$1.sel;}else if(ourIndex==-1){ourIndex=ranges.length;setSelection(doc$1,normalizeSelection(cm,ranges.concat([ourRange]),ourIndex),{scroll:false,origin:"*mouse"});}else if(ranges.length>1&&ranges[ourIndex].empty()&&behavior.unit=="char"&&!behavior.extend){setSelection(doc$1,normalizeSelection(cm,ranges.slice(0,ourIndex).concat(ranges.slice(ourIndex+1)),0),{scroll:false,origin:"*mouse"});startSel=doc$1.sel;}else{replaceOneSelection(doc$1,ourIndex,ourRange,sel_mouse);}
|
||||
if(!behavior.addNew){ourIndex=0;setSelection(doc,new Selection([ourRange],0),sel_mouse);startSel=doc.sel;}else if(ourIndex==-1){ourIndex=ranges.length;setSelection(doc,normalizeSelection(cm,ranges.concat([ourRange]),ourIndex),{scroll:false,origin:"*mouse"});}else if(ranges.length>1&&ranges[ourIndex].empty()&&behavior.unit=="char"&&!behavior.extend){setSelection(doc,normalizeSelection(cm,ranges.slice(0,ourIndex).concat(ranges.slice(ourIndex+1)),0),{scroll:false,origin:"*mouse"});startSel=doc.sel;}else{replaceOneSelection(doc,ourIndex,ourRange,sel_mouse);}
|
||||
var lastPos=start;function extendTo(pos){if(cmp(lastPos,pos)==0){return}
|
||||
lastPos=pos;if(behavior.unit=="rectangle"){var ranges=[],tabSize=cm.options.tabSize;var startCol=countColumn(getLine(doc$1,start.line).text,start.ch,tabSize);var posCol=countColumn(getLine(doc$1,pos.line).text,pos.ch,tabSize);var left=Math.min(startCol,posCol),right=Math.max(startCol,posCol);for(var line=Math.min(start.line,pos.line),end=Math.min(cm.lastLine(),Math.max(start.line,pos.line));line<=end;line++){var text=getLine(doc$1,line).text,leftPos=findColumn(text,left,tabSize);if(left==right){ranges.push(new Range(Pos(line,leftPos),Pos(line,leftPos)));}
|
||||
lastPos=pos;if(behavior.unit=="rectangle"){var ranges=[],tabSize=cm.options.tabSize;var startCol=countColumn(getLine(doc,start.line).text,start.ch,tabSize);var posCol=countColumn(getLine(doc,pos.line).text,pos.ch,tabSize);var left=Math.min(startCol,posCol),right=Math.max(startCol,posCol);for(var line=Math.min(start.line,pos.line),end=Math.min(cm.lastLine(),Math.max(start.line,pos.line));line<=end;line++){var text=getLine(doc,line).text,leftPos=findColumn(text,left,tabSize);if(left==right){ranges.push(new Range(Pos(line,leftPos),Pos(line,leftPos)));}
|
||||
else if(text.length>leftPos){ranges.push(new Range(Pos(line,leftPos),Pos(line,findColumn(text,right,tabSize))));}}
|
||||
if(!ranges.length){ranges.push(new Range(start,start));}
|
||||
setSelection(doc$1,normalizeSelection(cm,startSel.ranges.slice(0,ourIndex).concat(ranges),ourIndex),{origin:"*mouse",scroll:false});cm.scrollIntoView(pos);}else{var oldRange=ourRange;var range=rangeForUnit(cm,pos,behavior.unit);var anchor=oldRange.anchor,head;if(cmp(range.anchor,anchor)>0){head=range.head;anchor=minPos(oldRange.from(),range.anchor);}else{head=range.anchor;anchor=maxPos(oldRange.to(),range.head);}
|
||||
var ranges$1=startSel.ranges.slice(0);ranges$1[ourIndex]=bidiSimplify(cm,new Range(clipPos(doc$1,anchor),head));setSelection(doc$1,normalizeSelection(cm,ranges$1,ourIndex),sel_mouse);}}
|
||||
setSelection(doc,normalizeSelection(cm,startSel.ranges.slice(0,ourIndex).concat(ranges),ourIndex),{origin:"*mouse",scroll:false});cm.scrollIntoView(pos);}else{var oldRange=ourRange;var range=rangeForUnit(cm,pos,behavior.unit);var anchor=oldRange.anchor,head;if(cmp(range.anchor,anchor)>0){head=range.head;anchor=minPos(oldRange.from(),range.anchor);}else{head=range.anchor;anchor=maxPos(oldRange.to(),range.head);}
|
||||
var ranges$1=startSel.ranges.slice(0);ranges$1[ourIndex]=bidiSimplify(cm,new Range(clipPos(doc,anchor),head));setSelection(doc,normalizeSelection(cm,ranges$1,ourIndex),sel_mouse);}}
|
||||
var editorSize=display.wrapper.getBoundingClientRect();var counter=0;function extend(e){var curCount=++counter;var cur=posFromMouse(cm,e,true,behavior.unit=="rectangle");if(!cur){return}
|
||||
if(cmp(cur,lastPos)!=0){cm.curOp.focus=activeElt(doc(cm));extendTo(cur);var visible=visibleLines(display,doc$1);if(cur.line>=visible.to||cur.line<visible.from){setTimeout(operation(cm,function(){if(counter==curCount){extend(e);}}),150);}}else{var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;if(outside){setTimeout(operation(cm,function(){if(counter!=curCount){return}
|
||||
if(cmp(cur,lastPos)!=0){cm.curOp.focus=activeElt(root(cm));extendTo(cur);var visible=visibleLines(display,doc);if(cur.line>=visible.to||cur.line<visible.from){setTimeout(operation(cm,function(){if(counter==curCount){extend(e);}}),150);}}else{var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;if(outside){setTimeout(operation(cm,function(){if(counter!=curCount){return}
|
||||
display.scroller.scrollTop+=outside;extend(e);}),50);}}}
|
||||
function done(e){cm.state.selectingText=false;counter=Infinity;if(e){e_preventDefault(e);display.input.focus();}
|
||||
off(display.wrapper.ownerDocument,"mousemove",move);off(display.wrapper.ownerDocument,"mouseup",up);doc$1.history.lastSelOrigin=null;}
|
||||
off(display.wrapper.ownerDocument,"mousemove",move);off(display.wrapper.ownerDocument,"mouseup",up);doc.history.lastSelOrigin=null;}
|
||||
var move=operation(cm,function(e){if(e.buttons===0||!e_button(e)){done(e);}
|
||||
else{extend(e);}});var up=operation(cm,done);cm.state.selectingText=up;on(display.wrapper.ownerDocument,"mousemove",move);on(display.wrapper.ownerDocument,"mouseup",up);}
|
||||
function bidiSimplify(cm,range){var anchor=range.anchor;var head=range.head;var anchorLine=getLine(cm.doc,anchor.line);if(cmp(anchor,head)==0&&anchor.sticky==head.sticky){return range}
|
||||
@@ -1521,7 +1523,7 @@ return new Range(Pos(pos.line,start),Pos(pos.line,end))},toggleOverwrite:functio
|
||||
if(this.state.overwrite=!this.state.overwrite){addClass(this.display.cursorDiv,"CodeMirror-overwrite");}
|
||||
else
|
||||
{rmClass(this.display.cursorDiv,"CodeMirror-overwrite");}
|
||||
signal(this,"overwriteToggle",this,this.state.overwrite);},hasFocus:function(){return this.display.input.getField()==activeElt(doc(this))},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:methodOp(function(x,y){scrollToCoords(this,x,y);}),getScrollInfo:function(){var scroller=this.display.scroller;return{left:scroller.scrollLeft,top:scroller.scrollTop,height:scroller.scrollHeight-scrollGap(this)-this.display.barHeight,width:scroller.scrollWidth-scrollGap(this)-this.display.barWidth,clientHeight:displayHeight(this),clientWidth:displayWidth(this)}},scrollIntoView:methodOp(function(range,margin){if(range==null){range={from:this.doc.sel.primary().head,to:null};if(margin==null){margin=this.options.cursorScrollMargin;}}else if(typeof range=="number"){range={from:Pos(range,0),to:null};}else if(range.from==null){range={from:range,to:null};}
|
||||
signal(this,"overwriteToggle",this,this.state.overwrite);},hasFocus:function(){return this.display.input.getField()==activeElt(root(this))},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:methodOp(function(x,y){scrollToCoords(this,x,y);}),getScrollInfo:function(){var scroller=this.display.scroller;return{left:scroller.scrollLeft,top:scroller.scrollTop,height:scroller.scrollHeight-scrollGap(this)-this.display.barHeight,width:scroller.scrollWidth-scrollGap(this)-this.display.barWidth,clientHeight:displayHeight(this),clientWidth:displayWidth(this)}},scrollIntoView:methodOp(function(range,margin){if(range==null){range={from:this.doc.sel.primary().head,to:null};if(margin==null){margin=this.options.cursorScrollMargin;}}else if(typeof range=="number"){range={from:Pos(range,0),to:null};}else if(range.from==null){range={from:range,to:null};}
|
||||
if(!range.to){range.to=range.from;}
|
||||
range.margin=margin||0;if(range.from.line!=null){scrollToRange(this,range);}else{scrollToCoordsRange(this,range.from,range.to,range.margin);}}),setSize:methodOp(function(width,height){var this$1=this;var interpret=function(val){return typeof val=="number"||/^\d+$/.test(String(val))?val+"px":val;};if(width!=null){this.display.wrapper.style.width=interpret(width);}
|
||||
if(height!=null){this.display.wrapper.style.height=interpret(height);}
|
||||
@@ -1559,8 +1561,8 @@ if(ie_version<=11){setTimeout(operation(cm,function(){return this$1.updateFromDO
|
||||
this$1.composing.done=true;}});on(div,"touchstart",function(){return input.forceCompositionEnd();});on(div,"input",function(){if(!this$1.composing){this$1.readFromDOMSoon();}});function onCopyCut(e){if(!belongsToInput(e)||signalDOMEvent(cm,e)){return}
|
||||
if(cm.somethingSelected()){setLastCopied({lineWise:false,text:cm.getSelections()});if(e.type=="cut"){cm.replaceSelection("",null,"cut");}}else if(!cm.options.lineWiseCopyCut){return}else{var ranges=copyableRanges(cm);setLastCopied({lineWise:true,text:ranges.text});if(e.type=="cut"){cm.operation(function(){cm.setSelections(ranges.ranges,0,sel_dontScroll);cm.replaceSelection("",null,"cut");});}}
|
||||
if(e.clipboardData){e.clipboardData.clearData();var content=lastCopied.text.join("\n");e.clipboardData.setData("Text",content);if(e.clipboardData.getData("Text")==content){e.preventDefault();return}}
|
||||
var kludge=hiddenTextarea(),te=kludge.firstChild;disableBrowserMagic(te);cm.display.lineSpace.insertBefore(kludge,cm.display.lineSpace.firstChild);te.value=lastCopied.text.join("\n");var hadFocus=activeElt(div.ownerDocument);selectInput(te);setTimeout(function(){cm.display.lineSpace.removeChild(kludge);hadFocus.focus();if(hadFocus==div){input.showPrimarySelection();}},50);}
|
||||
on(div,"copy",onCopyCut);on(div,"cut",onCopyCut);};ContentEditableInput.prototype.screenReaderLabelChanged=function(label){if(label){this.div.setAttribute('aria-label',label);}else{this.div.removeAttribute('aria-label');}};ContentEditableInput.prototype.prepareSelection=function(){var result=prepareSelection(this.cm,false);result.focus=activeElt(this.div.ownerDocument)==this.div;return result};ContentEditableInput.prototype.showSelection=function(info,takeFocus){if(!info||!this.cm.display.view.length){return}
|
||||
var kludge=hiddenTextarea(),te=kludge.firstChild;disableBrowserMagic(te);cm.display.lineSpace.insertBefore(kludge,cm.display.lineSpace.firstChild);te.value=lastCopied.text.join("\n");var hadFocus=activeElt(rootNode(div));selectInput(te);setTimeout(function(){cm.display.lineSpace.removeChild(kludge);hadFocus.focus();if(hadFocus==div){input.showPrimarySelection();}},50);}
|
||||
on(div,"copy",onCopyCut);on(div,"cut",onCopyCut);};ContentEditableInput.prototype.screenReaderLabelChanged=function(label){if(label){this.div.setAttribute('aria-label',label);}else{this.div.removeAttribute('aria-label');}};ContentEditableInput.prototype.prepareSelection=function(){var result=prepareSelection(this.cm,false);result.focus=activeElt(rootNode(this.div))==this.div;return result};ContentEditableInput.prototype.showSelection=function(info,takeFocus){if(!info||!this.cm.display.view.length){return}
|
||||
if(info.focus||takeFocus){this.showPrimarySelection();}
|
||||
this.showMultipleSelections(info);};ContentEditableInput.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()};ContentEditableInput.prototype.showPrimarySelection=function(){var sel=this.getSelection(),cm=this.cm,prim=cm.doc.sel.primary();var from=prim.from(),to=prim.to();if(cm.display.viewTo==cm.display.viewFrom||from.line>=cm.display.viewTo||to.line<cm.display.viewFrom){sel.removeAllRanges();return}
|
||||
var curAnchor=domToPos(cm,sel.anchorNode,sel.anchorOffset);var curFocus=domToPos(cm,sel.focusNode,sel.focusOffset);if(curAnchor&&!curAnchor.bad&&curFocus&&!curFocus.bad&&cmp(minPos(curAnchor,curFocus),from)==0&&cmp(maxPos(curAnchor,curFocus),to)==0){return}
|
||||
@@ -1572,7 +1574,7 @@ if(rng){if(!gecko&&cm.state.focused){sel.collapse(start.node,start.offset);if(!r
|
||||
if(old&&sel.anchorNode==null){sel.addRange(old);}
|
||||
else if(gecko){this.startGracePeriod();}}
|
||||
this.rememberSelection();};ContentEditableInput.prototype.startGracePeriod=function(){var this$1=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){this$1.gracePeriod=false;if(this$1.selectionChanged()){this$1.cm.operation(function(){return this$1.cm.curOp.selectionChanged=true;});}},20);};ContentEditableInput.prototype.showMultipleSelections=function(info){removeChildrenAndAdd(this.cm.display.cursorDiv,info.cursors);removeChildrenAndAdd(this.cm.display.selectionDiv,info.selection);};ContentEditableInput.prototype.rememberSelection=function(){var sel=this.getSelection();this.lastAnchorNode=sel.anchorNode;this.lastAnchorOffset=sel.anchorOffset;this.lastFocusNode=sel.focusNode;this.lastFocusOffset=sel.focusOffset;};ContentEditableInput.prototype.selectionInEditor=function(){var sel=this.getSelection();if(!sel.rangeCount){return false}
|
||||
var node=sel.getRangeAt(0).commonAncestorContainer;return contains(this.div,node)};ContentEditableInput.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"){if(!this.selectionInEditor()||activeElt(this.div.ownerDocument)!=this.div){this.showSelection(this.prepareSelection(),true);}
|
||||
var node=sel.getRangeAt(0).commonAncestorContainer;return contains(this.div,node)};ContentEditableInput.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"){if(!this.selectionInEditor()||activeElt(rootNode(this.div))!=this.div){this.showSelection(this.prepareSelection(),true);}
|
||||
this.div.focus();}};ContentEditableInput.prototype.blur=function(){this.div.blur();};ContentEditableInput.prototype.getField=function(){return this.div};ContentEditableInput.prototype.supportsTouch=function(){return true};ContentEditableInput.prototype.receivedFocus=function(){var this$1=this;var input=this;if(this.selectionInEditor()){setTimeout(function(){return this$1.pollSelection();},20);}
|
||||
else
|
||||
{runInOp(this.cm,function(){return input.cm.curOp.selectionChanged=true;});}
|
||||
@@ -1650,7 +1652,7 @@ input.composing={start:start,range:cm.markText(start,cm.getCursor("to"),{classNa
|
||||
return result};TextareaInput.prototype.showSelection=function(drawn){var cm=this.cm,display=cm.display;removeChildrenAndAdd(display.cursorDiv,drawn.cursors);removeChildrenAndAdd(display.selectionDiv,drawn.selection);if(drawn.teTop!=null){this.wrapper.style.top=drawn.teTop+"px";this.wrapper.style.left=drawn.teLeft+"px";}};TextareaInput.prototype.reset=function(typing){if(this.contextMenuPending||this.composing&&typing){return}
|
||||
var cm=this.cm;this.resetting=true;if(cm.somethingSelected()){this.prevInput="";var content=cm.getSelection();this.textarea.value=content;if(cm.state.focused){selectInput(this.textarea);}
|
||||
if(ie&&ie_version>=9){this.hasSelection=content;}}else if(!typing){this.prevInput=this.textarea.value="";if(ie&&ie_version>=9){this.hasSelection=null;}}
|
||||
this.resetting=false;};TextareaInput.prototype.getField=function(){return this.textarea};TextareaInput.prototype.supportsTouch=function(){return false};TextareaInput.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!mobile||activeElt(this.textarea.ownerDocument)!=this.textarea)){try{this.textarea.focus();}
|
||||
this.resetting=false;};TextareaInput.prototype.getField=function(){return this.textarea};TextareaInput.prototype.supportsTouch=function(){return false};TextareaInput.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!mobile||activeElt(rootNode(this.textarea))!=this.textarea)){try{this.textarea.focus();}
|
||||
catch(e){}}};TextareaInput.prototype.blur=function(){this.textarea.blur();};TextareaInput.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0;};TextareaInput.prototype.receivedFocus=function(){this.slowPoll();};TextareaInput.prototype.slowPoll=function(){var this$1=this;if(this.pollingFast){return}
|
||||
this.polling.set(this.cm.options.pollInterval,function(){this$1.poll();if(this$1.cm.state.focused){this$1.slowPoll();}});};TextareaInput.prototype.fastPoll=function(){var missed=false,input=this;input.pollingFast=true;function p(){var changed=input.poll();if(!changed&&!missed){missed=true;input.polling.set(60,p);}
|
||||
else{input.pollingFast=false;input.slowPoll();}}
|
||||
@@ -1678,14 +1680,14 @@ if(ie&&ie_version>=9){prepareSelectAllHack();}
|
||||
if(captureRightClick){e_stop(e);var mouseup=function(){off(window,"mouseup",mouseup);setTimeout(rehide,20);};on(window,"mouseup",mouseup);}else{setTimeout(rehide,50);}};TextareaInput.prototype.readOnlyChanged=function(val){if(!val){this.reset();}
|
||||
this.textarea.disabled=val=="nocursor";this.textarea.readOnly=!!val;};TextareaInput.prototype.setUneditable=function(){};TextareaInput.prototype.needsContentAttribute=false;function fromTextArea(textarea,options){options=options?copyObj(options):{};options.value=textarea.value;if(!options.tabindex&&textarea.tabIndex){options.tabindex=textarea.tabIndex;}
|
||||
if(!options.placeholder&&textarea.placeholder){options.placeholder=textarea.placeholder;}
|
||||
if(options.autofocus==null){var hasFocus=activeElt(textarea.ownerDocument);options.autofocus=hasFocus==textarea||textarea.getAttribute("autofocus")!=null&&hasFocus==document.body;}
|
||||
if(options.autofocus==null){var hasFocus=activeElt(rootNode(textarea));options.autofocus=hasFocus==textarea||textarea.getAttribute("autofocus")!=null&&hasFocus==document.body;}
|
||||
function save(){textarea.value=cm.getValue();}
|
||||
var realSubmit;if(textarea.form){on(textarea.form,"submit",save);if(!options.leaveSubmitMethodAlone){var form=textarea.form;realSubmit=form.submit;try{var wrappedSubmit=form.submit=function(){save();form.submit=realSubmit;form.submit();form.submit=wrappedSubmit;};}catch(e){}}}
|
||||
options.finishInit=function(cm){cm.save=save;cm.getTextArea=function(){return textarea;};cm.toTextArea=function(){cm.toTextArea=isNaN;save();textarea.parentNode.removeChild(cm.getWrapperElement());textarea.style.display="";if(textarea.form){off(textarea.form,"submit",save);if(!options.leaveSubmitMethodAlone&&typeof textarea.form.submit=="function"){textarea.form.submit=realSubmit;}}};};textarea.style.display="none";var cm=CodeMirror(function(node){return textarea.parentNode.insertBefore(node,textarea.nextSibling);},options);return cm}
|
||||
function addLegacyProps(CodeMirror){CodeMirror.off=off;CodeMirror.on=on;CodeMirror.wheelEventPixels=wheelEventPixels;CodeMirror.Doc=Doc;CodeMirror.splitLines=splitLinesAuto;CodeMirror.countColumn=countColumn;CodeMirror.findColumn=findColumn;CodeMirror.isWordChar=isWordCharBasic;CodeMirror.Pass=Pass;CodeMirror.signal=signal;CodeMirror.Line=Line;CodeMirror.changeEnd=changeEnd;CodeMirror.scrollbarModel=scrollbarModel;CodeMirror.Pos=Pos;CodeMirror.cmpPos=cmp;CodeMirror.modes=modes;CodeMirror.mimeModes=mimeModes;CodeMirror.resolveMode=resolveMode;CodeMirror.getMode=getMode;CodeMirror.modeExtensions=modeExtensions;CodeMirror.extendMode=extendMode;CodeMirror.copyState=copyState;CodeMirror.startState=startState;CodeMirror.innerMode=innerMode;CodeMirror.commands=commands;CodeMirror.keyMap=keyMap;CodeMirror.keyName=keyName;CodeMirror.isModifierKey=isModifierKey;CodeMirror.lookupKey=lookupKey;CodeMirror.normalizeKeyMap=normalizeKeyMap;CodeMirror.StringStream=StringStream;CodeMirror.SharedTextMarker=SharedTextMarker;CodeMirror.TextMarker=TextMarker;CodeMirror.LineWidget=LineWidget;CodeMirror.e_preventDefault=e_preventDefault;CodeMirror.e_stopPropagation=e_stopPropagation;CodeMirror.e_stop=e_stop;CodeMirror.addClass=addClass;CodeMirror.contains=contains;CodeMirror.rmClass=rmClass;CodeMirror.keyNames=keyNames;}
|
||||
defineOptions(CodeMirror);addEditorMethods(CodeMirror);var dontDelegate="iter insert remove copy getEditor constructor".split(" ");for(var prop in Doc.prototype){if(Doc.prototype.hasOwnProperty(prop)&&indexOf(dontDelegate,prop)<0){CodeMirror.prototype[prop]=(function(method){return function(){return method.apply(this.doc,arguments)}})(Doc.prototype[prop]);}}
|
||||
eventMixin(Doc);CodeMirror.inputStyles={"textarea":TextareaInput,"contenteditable":ContentEditableInput};CodeMirror.defineMode=function(name){if(!CodeMirror.defaults.mode&&name!="null"){CodeMirror.defaults.mode=name;}
|
||||
defineMode.apply(this,arguments);};CodeMirror.defineMIME=defineMIME;CodeMirror.defineMode("null",function(){return({token:function(stream){return stream.skipToEnd();}});});CodeMirror.defineMIME("text/plain","null");CodeMirror.defineExtension=function(name,func){CodeMirror.prototype[name]=func;};CodeMirror.defineDocExtension=function(name,func){Doc.prototype[name]=func;};CodeMirror.fromTextArea=fromTextArea;addLegacyProps(CodeMirror);CodeMirror.version="5.65.14";return CodeMirror;})));;(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
||||
defineMode.apply(this,arguments);};CodeMirror.defineMIME=defineMIME;CodeMirror.defineMode("null",function(){return({token:function(stream){return stream.skipToEnd();}});});CodeMirror.defineMIME("text/plain","null");CodeMirror.defineExtension=function(name,func){CodeMirror.prototype[name]=func;};CodeMirror.defineDocExtension=function(name,func){Doc.prototype[name]=func;};CodeMirror.fromTextArea=fromTextArea;addLegacyProps(CodeMirror);CodeMirror.version="5.65.18";return CodeMirror;})));;(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
||||
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
||||
define(["../../lib/codemirror"],mod);else
|
||||
mod(CodeMirror);})(function(CodeMirror){"use strict";function Context(indented,column,type,info,align,prev){this.indented=indented;this.column=column;this.type=type;this.info=info;this.align=align;this.prev=prev;}
|
||||
|
||||
Reference in new issue
Block a user