27 lines
		
	
	
		
			889 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			889 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
<head>
 | 
						|
    <title>Yjs Textarea Example</title>
 | 
						|
    <link rel=stylesheet href="https://prosemirror.net/css/editor.css">
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
  <div class="code-html">
 | 
						|
    <textarea style="width:80%;" rows=40 autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
 | 
						|
  </div>
 | 
						|
  <script class="code-js" src="./build/textarea.js">
 | 
						|
import * as Y from 'yjs'
 | 
						|
import { WebsocketProvider } from 'yjs/provider/websocket.mjs'
 | 
						|
import { TextareaBinding } from 'yjs/bindings/textarea.mjs'
 | 
						|
 | 
						|
const provider = new WebsocketProvider('wss://api.yjs.website')
 | 
						|
const ydocument = provider.get('textarea')
 | 
						|
const type = ydocument.define('textarea', Y.Text)
 | 
						|
const textarea = document.querySelector('textarea')
 | 
						|
const binding = new TextareaBinding(type, textarea)
 | 
						|
 | 
						|
window.textareaExample = {
 | 
						|
  provider, ydocument, type, textarea, binding
 | 
						|
}
 | 
						|
  </script>
 | 
						|
</body>
 | 
						|
</html> |