Mercurial Hosting > freedit
diff src/site.js @ 20:3ea49246d6a7
bbcode work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 13 Jul 2022 22:00:00 -0600 |
parents | 94e26bffd4fb |
children | 33731231093a |
line wrap: on
line diff
--- a/src/site.js Wed Jul 13 08:47:13 2022 -0600 +++ b/src/site.js Wed Jul 13 22:00:00 2022 -0600 @@ -32,6 +32,25 @@ ajax( '/error_log.js', 'err='+encodeURIComponent(err) ); }; -function time(time) { - document.write(new Date(time).toLocaleString()); +function editorEnter() { + let s = getSelection(); + let r = s.getRangeAt(0); + r.deleteContents(); + let t = document.createTextNode('\n'); + r.insertNode(t); + let isFucked = getSelection().getRangeAt(0).collapsed; + //console.log(isFucked); + r.collapse(); + if(isFucked) { + s.removeAllRanges(); + s.addRange(r); + } } + +function editorKey() { + //console.log(event); + if( event.code === 'Enter' ) { + editorEnter(); + return false; + } +}