diff src/test/editor.html @ 20:3ea49246d6a7

bbcode work
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 13 Jul 2022 22:00:00 -0600
parents da006d1c1eba
children
line wrap: on
line diff
--- a/src/test/editor.html	Wed Jul 13 08:47:13 2022 -0600
+++ b/src/test/editor.html	Wed Jul 13 22:00:00 2022 -0600
@@ -9,7 +9,23 @@
 				white-space: pre-wrap;
 			}
 		</style>
+		<script src="/site.js"></script>
 		<script>
+			function getBrowser() {
+				let userAgent = navigator.userAgent;
+				if( userAgent.match(/chrome|chromium|crios/i) )
+					return 'chrome';
+				if( userAgent.match(/firefox|fxios/i) )
+					return 'firefox';
+				if( userAgent.match(/safari/i) )
+					return 'safari';
+				if( userAgent.match(/opr\//i) )
+					return 'opera';
+				if( userAgent.match(/edg/i) )
+					return 'edge';
+				return "unknown";
+			}
+
 			function log() {
 				let edit = document.querySelector('[contentEditable]');
 				console.log(edit.innerHTML);
@@ -18,25 +34,19 @@
 			function test() {
 				let edit = document.querySelector('[contentEditable]');
 				edit.focus();
-				let s = getSelection();
-				let r = s.getRangeAt(0);
-				//console.log(s);
-				r.deleteContents();
-				let t = document.createTextNode('\n');
-				r.insertNode(t);
-				r.collapse();
+				editorEnter();
 			}
 		</script>
 	</head>
 	<body>
 		<p>top</p>
-		<div contentEditable>
+		<div contentEditable onkeypress="return editorKey()">
 aaa <b>bbb</b> <i>iii</i>
 1
 2
 3
 zzz
-		</div>
+</div>
 		<p>
 			<button onclick="log()">log</button>
 			<button onclick="test()">test</button>