Add vim demo controls and addons.
This commit is contained in:
		
							parent
							
								
									2e1b33aea4
								
							
						
					
					
						commit
						6e16540912
					
				@ -3,7 +3,10 @@
 | 
			
		||||
<head>
 | 
			
		||||
<title>Jody's CodeMirror</title>
 | 
			
		||||
<link rel="stylesheet" href="lib/codemirror.css">
 | 
			
		||||
<link rel="stylesheet" href="addon/dialog/dialog.css">
 | 
			
		||||
<script src="lib/codemirror.js"></script>
 | 
			
		||||
<script src="addon/dialog/dialog.js"></script>
 | 
			
		||||
<script src="addon/search/searchcursor.js"></script>
 | 
			
		||||
<script src="mode/markdown/markdown.js"></script>
 | 
			
		||||
<script src="keymap/vim.js"></script>
 | 
			
		||||
<style type="text/css">
 | 
			
		||||
@ -18,21 +21,38 @@
 | 
			
		||||
<form><textarea id="editor" name="editor">
 | 
			
		||||
{{{notetxt}}}
 | 
			
		||||
</textarea></form>
 | 
			
		||||
<div style="font-size: 13px; width: 300px; height: 30px;">Key buffer: <span id="command-display"></span></div>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
    var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
 | 
			
		||||
        mode:  "markdown",
 | 
			
		||||
        lineNumbers: "true",
 | 
			
		||||
        keyMap: "vim",
 | 
			
		||||
        showCursorWhenSelecting: true,
 | 
			
		||||
        viewportMargin: Infinity
 | 
			
		||||
    });
 | 
			
		||||
    // Add my .vimrc stuff.
 | 
			
		||||
    CodeMirror.Vim.map('jj', '<Esc>', 'insert')
 | 
			
		||||
    CodeMirror.Vim.map(';', ':')
 | 
			
		||||
    CodeMirror.Vim.map(':', ';')
 | 
			
		||||
    //CodeMirror.commands.save = function(){ alert("Saving"); }
 | 
			
		||||
    var commandDisplay = document.getElementById('command-display');
 | 
			
		||||
    var keys = ''
 | 
			
		||||
    CodeMirror.on(editor, 'vim-keypress', function(key) {
 | 
			
		||||
        keys = keys + key
 | 
			
		||||
        commandDisplay.innerHTML = keys
 | 
			
		||||
    })
 | 
			
		||||
    CodeMirror.on(editor, 'vim-command-done', function(e) {
 | 
			
		||||
        keys = ''
 | 
			
		||||
        commandDisplay.innerHTML = keys
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    var typingTimer;
 | 
			
		||||
    editor.on("changes", function() {
 | 
			
		||||
        clearTimeout(typingTimer);
 | 
			
		||||
        typingTimer = setTimeout(
 | 
			
		||||
        function() {
 | 
			
		||||
            console.log(editor.getValue());
 | 
			
		||||
            //console.log(editor.getValue());
 | 
			
		||||
           var request = new XMLHttpRequest();
 | 
			
		||||
            request.onreadystatechange = function () {
 | 
			
		||||
                var DONE = this.DONE || 4;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user