Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code 是否可以让代码镜像行支持复制粘贴超链接以进行标记?_Visual Studio Code_Jupyter Notebook_Markdown_Codemirror - Fatal编程技术网

Visual studio code 是否可以让代码镜像行支持复制粘贴超链接以进行标记?

Visual studio code 是否可以让代码镜像行支持复制粘贴超链接以进行标记?,visual-studio-code,jupyter-notebook,markdown,codemirror,Visual Studio Code,Jupyter Notebook,Markdown,Codemirror,jupyter笔记本电池是一个(如果需要,请纠正我)。如果您不熟悉jupyter笔记本,请查看 这是空白标记单元格的代码 <div class="cell text_cell unrendered unselected" tabindex="2"> <div class="prompt input_prompt"></div> <div class="inner_cell"> <div class="ctb_h

jupyter笔记本电池是一个(如果需要,请纠正我)。如果您不熟悉jupyter笔记本,请查看

这是空白标记单元格的代码

<div class="cell text_cell unrendered unselected" tabindex="2">
    <div class="prompt input_prompt"></div>
    <div class="inner_cell">
        <div class="ctb_hideshow">
            <div class="celltoolbar"></div>
        </div>
        <div class="input_area" aria-label="Edit Markup Text here">
            <div class="CodeMirror cm-s-default CodeMirror-wrap">
                <div
                    style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.59999px; left: 5.6px;">
                    <textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0"
                        style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea>
                </div>
                <div class="CodeMirror-vscrollbar" cm-not-content="true">
                    <div style="min-width: 1px; height: 0px;"></div>
                </div>
                <div class="CodeMirror-hscrollbar" cm-not-content="true">
                    <div style="height: 100%; min-height: 1px; width: 0px;"></div>
                </div>
                <div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div>
                <div class="CodeMirror-gutter-filler" cm-not-content="true"></div>
                <div class="CodeMirror-scroll" tabindex="-1">
                    <div class="CodeMirror-sizer"
                        style="margin-left: 0px; margin-bottom: -12px; border-right-width: 18px; min-height: 28px; padding-right: 0px; padding-bottom: 0px;">
                        <div style="position: relative; top: 0px;">
                            <div class="CodeMirror-lines" role="presentation">
                                <div role="presentation" style="position: relative; outline: none;">
                                    <div class="CodeMirror-measure"></div>
                                    <div class="CodeMirror-measure"></div>
                                    <div style="position: relative; z-index: 1;"></div>
                                    <div class="CodeMirror-cursors">
                                        <div class="CodeMirror-cursor" style="left: 5.6px; top: 0px; height: 16.8px;">
                                            &nbsp;</div>
                                    </div>
                                    <div class="CodeMirror-code" role="presentation">
                                        <pre class=" CodeMirror-line "
                                            role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div
                        style="position: absolute; height: 18px; width: 1px; border-bottom: 0px solid transparent; top: 28px;">
                    </div>
                    <div class="CodeMirror-gutters" style="display: none; height: 46px;"></div>
                </div>
            </div>
        </div>
        <div class="text_cell_render rendered_html" tabindex="-1">
            <p>Type <em>Markdown</em> and LaTeX: <span class="MathJax_Preview" style="color: inherit;"><span
                        class="MJXp-math" id="MJXp-Span-1"><span class="MJXp-msubsup" id="MJXp-Span-2"><span
                                class="MJXp-mi MJXp-italic" id="MJXp-Span-3" style="margin-right: 0.05em;">α</span><span
                                class="MJXp-mn MJXp-script" id="MJXp-Span-4"
                                style="vertical-align: 0.5em;">2</span></span></span></span>
                <script type="math/tex" id="MathJax-Element-1">\alpha^2</script>
            </p>
        </div>
    </div>
</div>

​
类型标记和乳胶:α2
\α^2

在VS代码中编辑标记、复制URL并粘贴到文本上会使文本成为标记链接/超链接


是否可以在代码镜像行中实现此功能

我想这就是你的意思:当用户粘贴链接时,在CodeMirror编辑器中将其设置为可点击的超链接

初始化时,使用codemirror的
beforeChange
功能禁用粘贴事件。当用户粘贴到
.codemirr
中时,请检查剪贴板内容是否以
http://
https://
开头,如果是这样,则我们创建一个CodeMirror小部件超链接,否则我们只插入找到的剪贴板内容

我发现的唯一问题是你不能一个接一个地粘贴链接

好了,问这个问题的用户已经不在了。还有一个“问题”是,您无法使用
editor.getValue()
获取该行的值。不确定是否有办法将可单击的元素插入编辑器并使用编辑器的值捕获它

注意:StackOverflow会阻止代码段中的链接,因此您无法在此处看到它的实际操作,但您可以查看我的

$(函数(){
变量编辑器选项={
是的,
一线号码:1,
行号:对,
智能缩进:没错,
换行:对,
indentWithTabs:true,
刷新:是的,
模式:“javascript”
};
//初始化
$('.content')。每个(函数(){
var self=$(这是);
var editor=codemirr.fromTextArea(self.find(“.editor”)[0],editorOptions);
self[0]。编辑器=编辑器;
editor.save();
//禁用粘贴事件
编辑器.on(“更改前”,函数(u,更改){
如果(change.origin==“粘贴”)更改.cancel()
});
});
$(文档).on('paste','.codemirr',函数(e){
//防止默认粘贴事件
e、 预防默认值();
var content=$(this).closest('.content');
变量编辑器=内容[0]。编辑器;
navigator.clipboard.readText()。然后(text=>{
if(text.match(/^(https?:\/\/).*/g)){
//如果剪贴板内容以“http://”或“https://”开头,请创建codemirror小部件
var newText=文本;
var el=$('')[0];
var line=editor.getCursor().line;
var ch=editor.getCursor().ch;
var isEmptyLine=editor.getLine(line.trim()=”;
if(isEmptyLine){
//如果行为空,则在此处插入小部件
replaceRange(“”,{line});
}else if(ch==0){
//如果字符位置为零,则不要执行任何操作
编辑器.replaceRange(“”+“\n”,位置);
}否则{
//若行中有内容,则在新行中插入小部件
replaceRange(“\n”+”,{line});
line++;
}
var widget=editor.markText({line,ch:0},{line,ch:1}{
替换为:el
});
editor.focus();
}否则{
//否则只需插入剪贴板内容。
//将html元素粘贴到codemirror编辑器中时,请使用insertText而不是insertHTML。
document.execCommand('insertText',false,text);
}
});
});
});
.content{
宽度:450px;
位置:绝对位置;
最高:50%;
左:50%;
转换:翻译(-50%,-50%);
}
.CodeMirror{
身高:适合的内容!重要;
边界半径:5px;
边框:1px实心#ddd;
}
.码镜像线{
线高:1.5!重要;
}
.CodeMirror vscrollbar,
.codemirr hscrollbar{
不透明度:0;
指针事件:无;
}
.降价链接{
背景:e8f0fe;
光标:指针;
填充物:2px 5px;
}

尝试插入以“http://”或“https://”开头的文本
var str=“你好,世界!”;
log(“你好,这里!”);
$(文档).on('click','.btn',function(){
$(this.toggleClass('active');
});

我想这就是你的意思:当用户粘贴链接时,在CodeMirror编辑器中将其设置为可点击的超链接

初始化时,使用codemirror的
beforeChange
功能禁用粘贴事件。当用户粘贴到
.codemirr
中时,请检查剪贴板内容是否以
http://
https://
开头,如果是这样,则我们创建一个CodeMirror小部件超链接,否则我们只插入找到的剪贴板内容

我发现的唯一问题是你不能一个接一个地粘贴链接

好了,问这个问题的用户已经不在了。还有一个“问题”是,您无法使用
editor.getValue()
获取该行的值。不确定是否有办法插入可点击的ele