Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02084a5

Browse files
committed
add demo project to repository
1 parenta1ddb78 commit02084a5

File tree

6 files changed

+418
-351
lines changed

6 files changed

+418
-351
lines changed

‎demo/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<metacharset="utf-8"/>
5+
<title>Yjs Quill Example</title>
6+
<scripttype="text/javascript"src="../dist/quill-demo.js"async></script>
7+
<linkrel=stylesheethref="./quill.css"asyncdefer>
8+
<linkrel=stylesheethref="//cdn.quilljs.com/1.3.6/quill.snow.css"async
9+
defer>
10+
<linkrel=stylesheethref="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css"async
11+
defer>
12+
<linkrel=stylesheethref="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai-sublime.min.css"async
13+
defer>
14+
</head>
15+
<body>
16+
<buttontype="button"id="y-connect-btn">Disconnect</button>
17+
<p></p>
18+
<p>This is a demo of the<ahref="https://github.com/yjs/yjs">Yjs</a><ahref="https://quilljs.com/">Quill</a> binding:<ahref="https://github.com/yjs/y-quill">y-quill</a>.</p>
19+
<p>The content of this editor is shared with every client that visits this domain.</p>
20+
</body>
21+
</html>

‎demo/quill-demo.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* eslint-env browser */
2+
3+
import*asYfrom'yjs'
4+
import{WebrtcProvider}from'y-webrtc'
5+
import{QuillBinding}from'y-quill'
6+
importQuillfrom'quill'
7+
importQuillCursorsfrom'quill-cursors'
8+
9+
Quill.register('modules/cursors',QuillCursors)
10+
11+
window.addEventListener('load',()=>{
12+
constydoc=newY.Doc()
13+
constprovider=newWebrtcProvider('quill-demo',ydoc)
14+
consttype=ydoc.getText('quill')
15+
consteditorContainer=document.createElement('div')
16+
editorContainer.setAttribute('id','editor')
17+
document.body.insertBefore(editorContainer,null)
18+
19+
vareditor=newQuill(editorContainer,{
20+
modules:{
21+
cursors:true,
22+
toolbar:[
23+
[{header:[1,2,false]}],
24+
['bold','italic','underline'],
25+
['image','code-block']
26+
],
27+
history:{
28+
userOnly:true
29+
}
30+
},
31+
placeholder:'Start collaborating...',
32+
theme:'snow'// or 'bubble'
33+
})
34+
35+
constbinding=newQuillBinding(type,editor,provider.awareness)
36+
37+
/*
38+
// Define user name and user name
39+
// Check the quill-cursors package on how to change the way cursors are rendered
40+
provider.awareness.setLocalStateField('user', {
41+
name: 'Typing Jimmy',
42+
color: 'blue'
43+
})
44+
*/
45+
46+
constconnectBtn=document.getElementById('y-connect-btn')
47+
connectBtn.addEventListener('click',()=>{
48+
if(provider.shouldConnect){
49+
provider.disconnect()
50+
connectBtn.textContent='Connect'
51+
}else{
52+
provider.connect()
53+
connectBtn.textContent='Disconnect'
54+
}
55+
})
56+
57+
//@ts-ignore
58+
window.example={ provider, ydoc, type, binding, Y}
59+
})

‎demo/quill.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#editor {
2+
min-height:500px;
3+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp