基本编辑器

CodeMirror 是一个灵活的文本代码编辑器。它是专门用于编辑代码,并附带一些语言模块和插件,实现更先进的编辑功能。

 
1
<script>
2
    // Code goes here
3
4
    // For demo purpose - animation css script
5
    function animationHover(element, animation) {
6
        element = $(element);
7
        element.hover(
8
            function () {
9
                element.addClass('animated ' + animation);
10
            },
11
            function () {
12
                //wait for animation to finish before removing classes
13
                window.setTimeout(function () {
14
                    element.removeClass('animated ' + animation);
15
                }, 2000);
16
            });
17
    }
18
</script>
19
主题示例

CodeMirror提供丰富的API接口和CSS主题,详情请访问 http://codemirror.net/

26
 
1
var SpeechApp = angular.module('SpeechApp', []);
2
3
function VoiceCtrl($scope) {
4
5
    $scope.said='...';
6
7
    $scope.helloWorld = function() {
8
        $scope.said = "Hello world!";
9
    }
10
11
    $scope.commands = {
12
        'hello (world)': function() {
13
            if (typeof console !== "undefined") console.log('hello world!')
14
            $scope.$apply($scope.helloWorld);
15
        },
16
        'hey': function() {
17
            if (typeof console !== "undefined") console.log('hey!')
18
            $scope.$apply($scope.helloWorld);
19
        }
20
    };
21
22
    annyang.debug();
23
    annyang.init($scope.commands);
24
    annyang.start();
25
}
26