64 lines
1.8 KiB
HTML
64 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Yjs Prosemirror Example</title>
|
|
<link rel=stylesheet href="https://prosemirror.net/css/editor.css">
|
|
<style>
|
|
placeholder {
|
|
display: inline;
|
|
border: 1px solid #ccc;
|
|
color: #ccc;
|
|
}
|
|
placeholder:after {
|
|
content: "☁";
|
|
font-size: 200%;
|
|
line-height: 0.1;
|
|
font-weight: bold;
|
|
}
|
|
.ProseMirror img { max-width: 100px }
|
|
.ProseMirror-yjs-cursor {
|
|
position: absolute;
|
|
border-left: black;
|
|
border-left-style: solid;
|
|
border-left-width: 2px;
|
|
border-color: orange;
|
|
height: 1em;
|
|
}
|
|
.ProseMirror-yjs-cursor > div {
|
|
position: relative;
|
|
top: -1.05em;
|
|
font-size: 13px;
|
|
background-color: rgb(250, 129, 0);
|
|
font-family: serif;
|
|
font-style: normal;
|
|
font-weight: normal;
|
|
line-height: normal;
|
|
user-select: none;
|
|
color: white;
|
|
padding-left: 2px;
|
|
padding-right: 2px;
|
|
}
|
|
</style>
|
|
</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 '../index.js'
|
|
import { TextareaBinding } from '../bindings/textarea.js'
|
|
import { WebsocketProvider } from '../provider/websocket.js'
|
|
|
|
const provider = new WebsocketProvider('ws://localhost:1234/')
|
|
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> |