Skip to content

Commit

Permalink
Minor sprucing: (#47)
Browse files Browse the repository at this point in the history
* Change package names
* Put README in published package
* Change Yjs to a peer dep (no impact on examples since peer deps
  are installed if necesasry).
  • Loading branch information
aboodman authored Dec 19, 2023
1 parent 2cf2175 commit d1e8538
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 48 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# `@rocicorp/reflect-yjs`
# `reflect-yjs`

This library enables storing and syncing Yjs documents via [Reflect](https://reflect.net/).
This library enables collaborative text editing in [Reflect](https://reflect.net/) via [Yjs](https://yjs.dev/).

Live demo at https://type.reflect.net/.

## Features

- **Awareness**: A robust implementation of Yjs "awareness" is included. Awareness is correctly cleaned up in all cases including tab-close, tab/browser-crash, navigation, tab-switch, offline, etc.
- **Multiple Documents**: A single Reflect room can host any number of Yjs documents efficiently.
- **Chunking** (soon): Large Yjs documents are automatically broken down into smaller pieces for efficient incremental updates.
- **Chunking**: Large Yjs documents are automatically broken down into smaller pieces for efficient incremental updates.
- **Validation**: Easily run custom validation on the server-side to filter profanity, enforce max length, or any other constraint you need.
- **Editor Integration Examples**: Contains practical examples for `codemirror-yjs`, `monaco-yjs`, `tiptap-yjs`.

## Getting Started

### Installation

To install `@rocicorp/reflect-yjs`, run the following command:

```bash
npm install @rocicorp/reflect-yjs@latest
```
See https://hello.reflect.net/how/text

### Running an Example

Expand Down
4 changes: 2 additions & 2 deletions examples/codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"@codemirror/lang-javascript": "^6.2.1",
"@rocicorp/eslint-config": "^0.5.1",
"@rocicorp/prettier-config": "^0.2.0",
"@rocicorp/reflect-yjs": "0.0.1",
"@rocicorp/reflect": "^0.38.202312080119",
"@rocicorp/reflect": ">=0.38.202312080119 <=0.39.0",

This comment has been minimized.

Copy link
@grgbkr

grgbkr Dec 19, 2023

Why change the exmaples to use a range like this for their reflect dep?

"@types/react-dom": "^18.2.17",
"@types/react": "^18.2.38",
"@vitejs/plugin-react": "^4.2.0",
Expand All @@ -27,6 +26,7 @@
"react-codemirror2": "^7.3.0",
"react-dom": "^18.2.0",
"react": "^18.2.0",
"reflect-yjs": "0.0.1",
"typescript": "^5.3.2",
"vite": "^5.0.2",
"y-codemirror": "^3.0.1"
Expand Down
6 changes: 1 addition & 5 deletions examples/codemirror/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {CodemirrorBinding} from 'y-codemirror';
import * as Y from 'yjs';
import './index.css';
import styles from './index.module.css';
import {
Provider,
mutators,
mutators as yjsMutators,
} from '@rocicorp/reflect-yjs';
import {Provider, mutators, mutators as yjsMutators} from 'reflect-yjs';
import {UserInfo, randUserInfo} from './user-info.js';

const userID = nanoid();
Expand Down
2 changes: 1 addition & 1 deletion examples/codemirror/src/reflect/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {AuthHandler, ReflectServerOptions} from '@rocicorp/reflect/server';
import {mutators as yjsMutators, Mutators} from '@rocicorp/reflect-yjs';
import {mutators as yjsMutators, Mutators} from 'reflect-yjs';

const authHandler: AuthHandler = (auth: string, _roomID: string) => {
if (auth) {
Expand Down
4 changes: 2 additions & 2 deletions examples/monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"devDependencies": {
"@rocicorp/eslint-config": "^0.5.1",
"@rocicorp/prettier-config": "^0.2.0",
"@rocicorp/reflect": "^0.38.202312080119",
"@rocicorp/reflect-yjs": "0.0.1",
"@rocicorp/reflect": ">=0.38.202312080119 <=0.39.0",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.0",
Expand All @@ -27,6 +26,7 @@
"nanoid": "^5.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"reflect-yjs": "0.0.1",
"typescript": "^5.3.2",
"vite": "^5.0.2",
"y-monaco": "^0.1.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/monaco/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Provider, mutators as yjsMutators} from '@rocicorp/reflect-yjs';
import {Provider, mutators as yjsMutators} from 'reflect-yjs';
import {Reflect} from '@rocicorp/reflect/client';
import * as monaco from 'monaco-editor';
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
Expand Down
2 changes: 1 addition & 1 deletion examples/monaco/src/reflect/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {mutators as yjsMutators, updateYJS} from '@rocicorp/reflect-yjs';
import {mutators as yjsMutators, updateYJS} from 'reflect-yjs';
// @ts-expect-error "no ts support"
import {regex} from 'badwords-list';

Expand Down
7 changes: 3 additions & 4 deletions examples/tiptap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@rocicorp/reflect": "^0.38.202312080119",
"@rocicorp/reflect-yjs": "0.0.1",
"@rocicorp/reflect": ">=0.38.202312080119 <=0.39.0",
"@tiptap/core": "^2.0.4",
"@tiptap/extension-collaboration": "^2.0.4",
"@tiptap/extension-collaboration-cursor": "^2.0.4",
Expand All @@ -35,8 +34,8 @@
"lexical": "^0.11.1",
"nanoid": "^5.0.3",
"next": "^13.5.4",
"typescript": "^5.3.2",
"yjs": "^13.6.10"
"reflect-yjs": "0.0.1",
"typescript": "^5.3.2"
},
"dependencies": {
"@tiptap/extension-code-block-lowlight": "^2.1.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/tiptap/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import React, { useEffect, useState } from "react";
import { Provider } from "@rocicorp/reflect-yjs";
import { Provider } from "reflect-yjs";
import { UserInfo } from "./TextEditor";

export function Footer({
Expand Down
2 changes: 1 addition & 1 deletion examples/tiptap/src/components/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import "./TextEditor.css";
import React, { useState, useEffect } from "react";
import * as Y from "yjs";
import { Provider, mutators as yjsMutators } from "@rocicorp/reflect-yjs";
import { Provider, mutators as yjsMutators } from "reflect-yjs";
import { Reflect } from "@rocicorp/reflect/client";
import { nanoid } from "nanoid";
import { EditorContent, useEditor } from "@tiptap/react";
Expand Down
2 changes: 1 addition & 1 deletion examples/tiptap/src/reflect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
AuthHandler,
ReflectServerOptions,
} from "@rocicorp/reflect/server";
import { mutators as yjsMutators, Mutators } from "@rocicorp/reflect-yjs";
import { mutators as yjsMutators, Mutators } from "reflect-yjs";
import { WriteTransaction } from "@rocicorp/reflect";

const authHandler: AuthHandler = (auth: string, _roomID: string) => {
Expand Down
54 changes: 36 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "reflect-yjs",
"name": "@rocicorp/reflect-yjs",
"version": "0.0.0",
"private": true,
"license": "Apache-2.0",
Expand Down

0 comments on commit d1e8538

Please sign in to comment.