view src/test/editor.html @ 36:b54e9e2212b7

try sceditor
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 03 Aug 2022 23:55:17 -0600
parents 3ea49246d6a7
children
line wrap: on
line source

<!doctype html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<style>
			[contentEditable] {
				padding: 7px;
				border: 1px solid #777;
				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);
				//console.log(edit.textContent);
			}
			function test() {
				let edit = document.querySelector('[contentEditable]');
				edit.focus();
				editorEnter();
			}
		</script>
	</head>
	<body>
		<p>top</p>
		<div contentEditable onkeypress="return editorKey()">
aaa <b>bbb</b> <i>iii</i>
1
2
3
zzz
</div>
		<p>
			<button onclick="log()">log</button>
			<button onclick="test()">test</button>
		</p>
		<p>bottom</p>
	</body>
</html>