Skip to content

Commit

Permalink
use local ws server by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Dec 12, 2023
1 parent ae6ea2b commit 16993f0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion codemirror.next/codemirror.next.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const userColor = usercolors[random.uint32() % usercolors.length]
const ydoc = new Y.Doc()
// const provider = new WebrtcProvider('codemirror6-demo-room', ydoc)
const provider = new WebsocketProvider(
'wss://demos.yjs.dev/ws',
`ws${location.protocol.slice(4)}//${location.host}/ws`, // use the local ws server
// 'wss://demos.yjs.dev/ws', // alternatively use the public ws server
'codemirror.next-demo',
ydoc
)
Expand Down
5 changes: 3 additions & 2 deletions codemirror/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import 'codemirror/mode/javascript/javascript.js'
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider(
'wss://demos.yjs.dev/ws',
'codemirror-demo-2',
`ws${location.protocol.slice(4)}//${location.host}/ws`, // use the local ws server
// 'wss://demos.yjs.dev/ws', // alternatively use the public ws server
'codemirror-demo',
ydoc
)
const ytext = ydoc.getText('codemirror')
Expand Down
4 changes: 3 additions & 1 deletion demo-server/demo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ setInterval(() => {
docs.forEach(doc => { conns += doc.conns.size })
const stats = {
conns,
docs: docs.size
docs: docs.size,
websocket: `ws://localhost:${port}`,
http: `http://localhost:${port}`
}
console.log(`${new Date().toISOString()} Stats: ${JSON.stringify(stats)}`)
}, 10000)
Expand Down
7 changes: 6 additions & 1 deletion monaco/monaco.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import * as monaco from 'monaco-editor'

window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev/ws', 'monaco-demo', ydoc)
const provider = new WebsocketProvider(
`ws${location.protocol.slice(4)}//${location.host}/ws`, // use the local ws server
// 'wss://demos.yjs.dev/ws', // alternatively use the public ws server
'monaco-demo',
ydoc
)
const ytext = ydoc.getText('monaco')

const editor = monaco.editor.create(/** @type {HTMLElement} */ (document.getElementById('monaco-editor')), {
Expand Down
7 changes: 6 additions & 1 deletion prosemirror-versions/prosemirror-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ window.addEventListener('load', () => {
const permanentUserData = new Y.PermanentUserData(ydoc)
permanentUserData.setUserMapping(ydoc, ydoc.clientID, user.username)
ydoc.gc = false
const provider = new WebsocketProvider('wss://demos.yjs.dev/ws', 'prosemirror-versions-demo', ydoc)
const provider = new WebsocketProvider(
`ws${location.protocol.slice(4)}//${location.host}/ws`, // use the local ws server
// 'wss://demos.yjs.dev/ws', // alternatively use the public ws server
'prosemirror-versions-demo',
ydoc
)
const yXmlFragment = ydoc.get('prosemirror', Y.XmlFragment)

const editor = document.createElement('div')
Expand Down
7 changes: 6 additions & 1 deletion prosemirror/prosemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import { keymap } from 'prosemirror-keymap'

window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev/ws', 'prosemirror-demo', ydoc)
const provider = new WebsocketProvider(
`ws${location.protocol.slice(4)}//${location.host}/ws`, // use the local ws server
// 'wss://demos.yjs.dev/ws', // alternatively use the public ws server
'prosemirror-demo',
ydoc
)
const yXmlFragment = ydoc.getXmlFragment('prosemirror')

const editor = document.createElement('div')
Expand Down
7 changes: 6 additions & 1 deletion quill/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ Quill.register('modules/cursors', QuillCursors)

window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev/ws', 'quill-demo-5', ydoc)
const provider = new WebsocketProvider(
`ws${location.protocol.slice(4)}//${location.host}/ws`, // use the local ws server
// 'wss://demos.yjs.dev/ws', // alternatively use the public ws server
'quill-demo-5',
ydoc
)
const ytext = ydoc.getText('quill')
const editorContainer = document.createElement('div')
editorContainer.setAttribute('id', 'editor')
Expand Down

0 comments on commit 16993f0

Please sign in to comment.