From e65cc25bc774de2263dc639207cc80bc121ca33a Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 14 Aug 2024 21:05:16 +0200 Subject: [PATCH] chore: update examples --- .github/workflows/playground.yml | 19 +++++++++++++++++++ README.md | 13 +++++++++++-- playground/deno.ts | 2 ++ playground/node.mjs | 2 ++ playground/public/index.html | 6 +++++- playground/public/prosemirror/index.html | 15 ++++++++++++++- playground/public/prosemirror/index.js | 7 +++++-- playground/public/tiptap/index.html | 15 ++++++++++++++- playground/public/tiptap/index.js | 11 ++++++----- playground/wrangler.toml | 13 +++---------- 10 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/playground.yml diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml new file mode 100644 index 0000000..cc2e2be --- /dev/null +++ b/.github/workflows/playground.yml @@ -0,0 +1,19 @@ +name: Playground deploy + +on: + push: + branches: + - main + +jobs: + # https://github.com/cloudflare/wrangler-action + deploy: + runs-on: ubuntu-latest + name: Deploy + steps: + - uses: actions/checkout@v4 + - name: Deploy + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + workingDirectory: "playground" diff --git a/README.md b/README.md index 5ba0260..8ebd64e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ > [!IMPORTANT] > 🚧 This is still a work in progress. Feedback and contributions are welcome! +## 🍿 Demo + +Checkout + ## Usage We first need to initiate universal cross-hooks: @@ -143,9 +147,14 @@ import * as Y from "yjs"; import { WebsocketProvider } from "y-crossws/provider"; const ydoc = new Y.Doc(); -const wsUrl = `ws://${window.location.host}`; const roomName = "default"; -const provider = new WebsocketProvider(wsURL, roomName, ydoc /* options */); + +const wsProto = window.location.protocol === "https:" ? "wss:" : "ws:"; +const wsUrl = `${wsProto}://${window.location.host}/_ws`; + +const provider = new WebsocketProvider(wsURL, roomName, ydoc, { + /* options */ +}); ``` ### Provider options diff --git a/playground/deno.ts b/playground/deno.ts index 55fd711..08a6fb0 100644 --- a/playground/deno.ts +++ b/playground/deno.ts @@ -7,6 +7,8 @@ const mimes = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", + ".svg": "image/svg+xml", + ".json": "application/json", }; Deno.serve( diff --git a/playground/node.mjs b/playground/node.mjs index e0980b6..865c644 100644 --- a/playground/node.mjs +++ b/playground/node.mjs @@ -8,6 +8,8 @@ const mimes = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", + ".svg": "image/svg+xml", + ".json": "application/json", }; const server = createServer(async (req, res) => { diff --git a/playground/public/index.html b/playground/public/index.html index 8d5266b..b5c5447 100644 --- a/playground/public/index.html +++ b/playground/public/index.html @@ -4,7 +4,7 @@ - ycrossws demos: + y-cross demos: +
+ + Learn more about y-crossws in github + diff --git a/playground/public/prosemirror/index.html b/playground/public/prosemirror/index.html index 5d8b616..ade8955 100644 --- a/playground/public/prosemirror/index.html +++ b/playground/public/prosemirror/index.html @@ -5,7 +5,20 @@ -
+ + +
+
+ +
+ + + Loading demo... +
+
+