acejs实现enter回车换行监测上一行注释内容代码

代码语言:html

所属分类:其他

代码描述:acejs实现enter回车换行监测上一行注释内容代码

代码标签: acejs enter 回车 换行 监测 上一行 注释 内容 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

    <style type="text/css">
        .codeview {
            position: relative;
        }
        .codeview .runcode {
          
            margin: 0;
        }
        .codeview .runresult {
            background: black;
            color: white;
            padding: 5px;
            margin: 0;
        }
        .codeview .runbtn {
            cursor: pointer;
            position: absolute;
            top: 0;
            z-index: 111;
            display: block;
            width: 19px;
            height:19px;
            background-size: cover;
            background-image: url('//repo.bfw.wiki/bfwrepo/icon/5f7a6d023237f.png');
        }

    </style>
</head>
<body>
    <div class="codeview">
        <div class='runbtn' title="点击运行代码">
           
        </div>
        <pre id="editor1" class='runcode'>
echo "bfw" ;
//注释内容
echo "is" ;
echo "good" ;
echo "site" ;</pre>
        <div class='runresult'>
            运行结果
        </div>
    </div>



    <!-- load ace -->
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ace/ace.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
    <script>
        $(function() {

            $('.codeview .runbtn').click(function() {
                $(this).parent().find(".runresult").html("bfw is a good site");
            });
        });
        var editor1 = ace.edit("editor1", {
            theme: "ace/theme/monokai",
            mode: "ace/mode/php",
            maxLines: 10,
            wrap: true,
            autoScrollEditorIntoView: true
        });
         editor1.setFontSize(18);
         
         // 监听键盘按键事件

editor1.commands.addCommand({
    name: 'onEnter',
    bindKey: {win: 'Enter', mac: 'Enter'},
    exec: function(editor).........完整代码请登录后点击上方下载按钮下载查看

网友评论0