Mercurial Hosting > freedit
comparison src/site.js @ 21:33731231093a
fix bbcode editing
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 17 Jul 2022 08:24:52 -0600 |
parents | 3ea49246d6a7 |
children | 4fdc4ec0050b |
comparison
equal
deleted
inserted
replaced
20:3ea49246d6a7 | 21:33731231093a |
---|---|
29 err += '\ncolumn = ' + col; | 29 err += '\ncolumn = ' + col; |
30 if (error && error.stack) | 30 if (error && error.stack) |
31 err += '\nstack = ' + error.stack; | 31 err += '\nstack = ' + error.stack; |
32 ajax( '/error_log.js', 'err='+encodeURIComponent(err) ); | 32 ajax( '/error_log.js', 'err='+encodeURIComponent(err) ); |
33 }; | 33 }; |
34 | |
35 function editorEnter() { | |
36 let s = getSelection(); | |
37 let r = s.getRangeAt(0); | |
38 r.deleteContents(); | |
39 let t = document.createTextNode('\n'); | |
40 r.insertNode(t); | |
41 let isFucked = getSelection().getRangeAt(0).collapsed; | |
42 //console.log(isFucked); | |
43 r.collapse(); | |
44 if(isFucked) { | |
45 s.removeAllRanges(); | |
46 s.addRange(r); | |
47 } | |
48 } | |
49 | |
50 function editorKey() { | |
51 //console.log(event); | |
52 if( event.code === 'Enter' ) { | |
53 editorEnter(); | |
54 return false; | |
55 } | |
56 } |