Compare commits
39 Commits
jazz-vue@0
...
jazz-vue@0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23521e6468 | ||
|
|
1627eb7652 | ||
|
|
ff846d9095 | ||
|
|
8d7d62d64f | ||
|
|
65a8227b2b | ||
|
|
a846e0730e | ||
|
|
e9c0e65170 | ||
|
|
14636606bd | ||
|
|
5118ff6585 | ||
|
|
51a0f86b99 | ||
|
|
fa61ab4eb5 | ||
|
|
d4cdd43cf7 | ||
|
|
c5d5fb25f7 | ||
|
|
38f2276fdd | ||
|
|
b92bfce041 | ||
|
|
e3fd7bf6e3 | ||
|
|
7526e444d6 | ||
|
|
28522bd062 | ||
|
|
824be82f94 | ||
|
|
8a9ef8ac78 | ||
|
|
5fb2f959f1 | ||
|
|
7a900d43f3 | ||
|
|
c8624d56d2 | ||
|
|
8ed7c3947d | ||
|
|
ec0e61a442 | ||
|
|
824d417d4e | ||
|
|
9f1ce81e09 | ||
|
|
48b32b6a72 | ||
|
|
03fec5f1b3 | ||
|
|
cdd7ac98cc | ||
|
|
8218a272ee | ||
|
|
25d146ead8 | ||
|
|
3f4d493286 | ||
|
|
d476b06d0e | ||
|
|
22baf1f547 | ||
|
|
d6ec873b1e | ||
|
|
160b30406b | ||
|
|
3e473eff50 | ||
|
|
a9cf6da27a |
@@ -1,5 +1,22 @@
|
||||
# chat-rn-expo-clerk
|
||||
|
||||
## 1.0.117
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-expo@0.13.26
|
||||
- jazz-react-native-media-images@0.13.26
|
||||
|
||||
## 1.0.116
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
- jazz-react-native-media-images@0.13.25
|
||||
|
||||
## 1.0.115
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useLocalSearchParams } from "expo-router";
|
||||
import { useAccount, useCoState } from "jazz-expo";
|
||||
import { ProgressiveImg } from "jazz-expo";
|
||||
import { createImage } from "jazz-react-native-media-images";
|
||||
import { Group, ID } from "jazz-tools";
|
||||
import { CoPlainText, Group, ID } from "jazz-tools";
|
||||
import { useEffect, useLayoutEffect, useState } from "react";
|
||||
import React, {
|
||||
SafeAreaView,
|
||||
@@ -71,8 +71,8 @@ export default function Conversation() {
|
||||
|
||||
const loadChat = async (chatId: ID<Chat>) => {
|
||||
try {
|
||||
const chat = await Chat.load(chatId, me);
|
||||
setChat(chat);
|
||||
const chat = await Chat.load(chatId);
|
||||
if (chat) setChat(chat);
|
||||
} catch (error) {
|
||||
console.log("Error loading chat", error);
|
||||
Alert.alert("Error", `Error loading chat: ${error}`);
|
||||
@@ -82,7 +82,12 @@ export default function Conversation() {
|
||||
const sendMessage = () => {
|
||||
if (!chat) return;
|
||||
if (message.trim()) {
|
||||
chat.push(Message.create({ text: message }, { owner: chat._owner }));
|
||||
chat.push(
|
||||
Message.create(
|
||||
{ text: CoPlainText.create(message, chat._owner) },
|
||||
chat._owner,
|
||||
),
|
||||
);
|
||||
setMessage("");
|
||||
}
|
||||
};
|
||||
@@ -104,7 +109,12 @@ export default function Conversation() {
|
||||
maxSize: 2048,
|
||||
});
|
||||
|
||||
chat.push(Message.create({ text: "", image }, { owner: chat._owner }));
|
||||
chat.push(
|
||||
Message.create(
|
||||
{ text: CoPlainText.create("", chat._owner), image },
|
||||
chat._owner,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert("Error", "Failed to upload image");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "chat-rn-expo-clerk",
|
||||
"main": "index.js",
|
||||
"version": "1.0.115",
|
||||
"version": "1.0.117",
|
||||
"scripts": {
|
||||
"build": "expo export -p ios",
|
||||
"start": "expo start",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CoList, CoMap, ImageDefinition, co } from "jazz-tools";
|
||||
import { CoList, CoMap, CoPlainText, ImageDefinition, co } from "jazz-tools";
|
||||
|
||||
export class Message extends CoMap {
|
||||
text = co.string;
|
||||
text = co.ref(CoPlainText);
|
||||
image = co.optional.ref(ImageDefinition);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# chat-rn-expo
|
||||
|
||||
## 1.0.104
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-expo@0.13.26
|
||||
|
||||
## 1.0.103
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 1.0.102
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chat-rn-expo",
|
||||
"version": "1.0.102",
|
||||
"version": "1.0.104",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "expo export -p ios",
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# chat-rn
|
||||
|
||||
## 1.0.112
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react-native@0.13.26
|
||||
|
||||
## 1.0.111
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a846e07]
|
||||
- cojson@0.13.25
|
||||
- cojson-transport-ws@0.13.25
|
||||
- jazz-react-native@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 1.0.110
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chat-rn",
|
||||
"version": "1.0.110",
|
||||
"version": "1.0.112",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Clipboard from "@react-native-clipboard/clipboard";
|
||||
import { useAccount, useCoState } from "jazz-react-native";
|
||||
import { Group, ID, Profile } from "jazz-tools";
|
||||
import { CoPlainText, Group, ID, Profile } from "jazz-tools";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
Alert,
|
||||
@@ -83,7 +83,10 @@ export function ChatScreen({ navigation }: { navigation: any }) {
|
||||
if (!loadedChat) return;
|
||||
if (message.trim()) {
|
||||
loadedChat.push(
|
||||
Message.create({ text: message }, { owner: loadedChat?._owner }),
|
||||
Message.create(
|
||||
{ text: CoPlainText.create(message, loadedChat?._owner) },
|
||||
loadedChat?._owner,
|
||||
),
|
||||
);
|
||||
setMessage("");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CoList, CoMap, co } from "jazz-tools";
|
||||
import { CoList, CoMap, CoPlainText, co } from "jazz-tools";
|
||||
|
||||
export class Message extends CoMap {
|
||||
text = co.string;
|
||||
text = co.ref(CoPlainText);
|
||||
}
|
||||
|
||||
export class Chat extends CoList.Of(co.ref(Message)) {}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# chat-vue
|
||||
|
||||
## 0.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-browser@0.13.26
|
||||
- jazz-vue@0.13.26
|
||||
|
||||
## 0.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-browser@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
- jazz-vue@0.13.25
|
||||
|
||||
## 0.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "chat-vue",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.95",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build-type-check": "run-p type-check \"build-only {@}\" --",
|
||||
"build-type-check": "run-p type-check \"build {@}\" --",
|
||||
"preview": "vite preview",
|
||||
"build": "vite build",
|
||||
"type-check": "vue-tsc --build --force",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<BubbleContainer :fromMe="lastEdit.by?.isMe">
|
||||
<BubbleBody>{{ msg.text }}</BubbleBody>
|
||||
<BubbleInfo :by="lastEdit.by?.profile?.name" :madeAt="lastEdit.madeAt" />
|
||||
</BubbleContainer>
|
||||
</template>
|
||||
<BubbleContainer :fromMe="lastEdit.by?.isMe">
|
||||
<BubbleBody>{{ msg.text }}</BubbleBody>
|
||||
<BubbleInfo :by="lastEdit.by?.profile?.name" :madeAt="lastEdit.madeAt" />
|
||||
</BubbleContainer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from "vue";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CoList, CoMap, co } from "jazz-tools";
|
||||
import { CoList, CoMap, CoPlainText, co } from "jazz-tools";
|
||||
|
||||
export class Message extends CoMap {
|
||||
text = co.string;
|
||||
text = co.ref(CoPlainText);
|
||||
}
|
||||
|
||||
export class Chat extends CoList.Of(co.ref(Message)) {}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import type { ID } from "jazz-tools";
|
||||
import { CoPlainText, type ID } from "jazz-tools";
|
||||
import { useCoState } from "jazz-vue";
|
||||
import { type PropType, computed, defineComponent, ref } from "vue";
|
||||
import ChatBody from "../components/ChatBody.vue";
|
||||
@@ -61,7 +61,12 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function handleSubmit(text: string) {
|
||||
chat?.value?.push(Message.create({ text }, { owner: chat.value._owner }));
|
||||
chat?.value?.push(
|
||||
Message.create(
|
||||
{ text: CoPlainText.create(text, chat.value._owner) },
|
||||
chat.value._owner,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# jazz-example-chat
|
||||
|
||||
## 0.0.193
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-inspector@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.192
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.25
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.191
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-example-chat",
|
||||
"private": true,
|
||||
"version": "0.0.191",
|
||||
"version": "0.0.193",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createImage, useAccount, useCoState } from "jazz-react";
|
||||
import { Account, ID } from "jazz-tools";
|
||||
import { Account, CoPlainText, ID } from "jazz-tools";
|
||||
import { useState } from "react";
|
||||
import { Chat, Message } from "./schema.ts";
|
||||
import {
|
||||
@@ -36,7 +36,15 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
|
||||
}
|
||||
|
||||
createImage(file, { owner: chat._owner }).then((image) => {
|
||||
chat.push(Message.create({ text: file.name, image: image }, chat._owner));
|
||||
chat.push(
|
||||
Message.create(
|
||||
{
|
||||
text: CoPlainText.create(file.name, chat._owner),
|
||||
image: image,
|
||||
},
|
||||
chat._owner,
|
||||
),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -66,7 +74,12 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
|
||||
|
||||
<TextInput
|
||||
onSubmit={(text) => {
|
||||
chat.push(Message.create({ text }, { owner: chat._owner }));
|
||||
chat.push(
|
||||
Message.create(
|
||||
{ text: CoPlainText.create(text, chat._owner) },
|
||||
chat._owner,
|
||||
),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</InputBar>
|
||||
@@ -75,7 +88,7 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
|
||||
}
|
||||
|
||||
function ChatBubble(props: { me: Account; msg: Message }) {
|
||||
if (!props.me.canRead(props.msg)) {
|
||||
if (!props.me.canRead(props.msg) || !props.msg.text?.toString()) {
|
||||
return (
|
||||
<BubbleContainer fromMe={false}>
|
||||
<BubbleBody fromMe={false}>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CoList, CoMap, ImageDefinition, co } from "jazz-tools";
|
||||
import { CoList, CoMap, CoPlainText, ImageDefinition, co } from "jazz-tools";
|
||||
|
||||
export class Message extends CoMap {
|
||||
text = co.string;
|
||||
text = co.ref(CoPlainText);
|
||||
image = co.optional.ref(ImageDefinition);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import clsx from "clsx";
|
||||
import { ProgressiveImg } from "jazz-react";
|
||||
import { ImageDefinition } from "jazz-tools";
|
||||
import { CoPlainText, ImageDefinition } from "jazz-tools";
|
||||
import { ImageIcon } from "lucide-react";
|
||||
import { useId, useRef } from "react";
|
||||
|
||||
@@ -70,7 +70,10 @@ export function BubbleBody(props: {
|
||||
);
|
||||
}
|
||||
|
||||
export function BubbleText(props: { text: string; className?: string }) {
|
||||
export function BubbleText(props: {
|
||||
text: CoPlainText | string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<p className={clsx("px-2 leading-relaxed", props.className)}>
|
||||
{props.text}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# minimal-auth-clerk
|
||||
|
||||
## 0.0.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
- jazz-react-auth-clerk@0.13.26
|
||||
|
||||
## 0.0.91
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-react-auth-clerk@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.90
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "clerk",
|
||||
"private": true,
|
||||
"version": "0.0.90",
|
||||
"version": "0.0.92",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# file-share-svelte
|
||||
|
||||
## 0.0.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-inspector-element@0.13.26
|
||||
- jazz-svelte@0.13.26
|
||||
|
||||
## 0.0.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-svelte@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
- jazz-inspector-element@0.13.25
|
||||
|
||||
## 0.0.74
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "file-share-svelte",
|
||||
"version": "0.0.74",
|
||||
"version": "0.0.76",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# jazz-tailwind-demo-auth-starter
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-inspector@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.25
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "filestream",
|
||||
"private": true,
|
||||
"version": "0.0.30",
|
||||
"version": "0.0.32",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# form
|
||||
|
||||
## 0.1.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.1.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.1.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "form",
|
||||
"private": true,
|
||||
"version": "0.1.31",
|
||||
"version": "0.1.33",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -62,7 +62,7 @@ function CreateOrderForm({
|
||||
onSave: (draft: DraftBubbleTeaOrder) => void;
|
||||
}) {
|
||||
const draft = useCoState(DraftBubbleTeaOrder, id, {
|
||||
resolve: { addOns: true },
|
||||
resolve: { addOns: true, instructions: true },
|
||||
});
|
||||
|
||||
if (!draft) return;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { CoPlainText } from "jazz-tools";
|
||||
import {
|
||||
BubbleTeaAddOnTypes,
|
||||
BubbleTeaBaseTeaTypes,
|
||||
@@ -12,6 +13,18 @@ export function OrderForm({
|
||||
order: BubbleTeaOrder | DraftBubbleTeaOrder;
|
||||
onSave?: (e: React.FormEvent<HTMLFormElement>) => void;
|
||||
}) {
|
||||
// Handles updates to the instructions field of the order.
|
||||
// If instructions already exist, applyDiff updates them incrementally.
|
||||
// Otherwise, creates a new CoPlainText instance for the instructions.
|
||||
const handleInstructionsChange = (
|
||||
e: React.ChangeEvent<HTMLTextAreaElement>,
|
||||
) => {
|
||||
if (order.instructions) {
|
||||
return order.instructions.applyDiff(e.target.value);
|
||||
}
|
||||
order.instructions = CoPlainText.create(e.target.value, order._owner);
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={onSave} className="grid gap-5">
|
||||
<div className="flex flex-col gap-2">
|
||||
@@ -88,9 +101,9 @@ export function OrderForm({
|
||||
<textarea
|
||||
name="instructions"
|
||||
id="instructions"
|
||||
value={order.instructions}
|
||||
value={`${order.instructions}`}
|
||||
className="dark:bg-transparent"
|
||||
onChange={(e) => (order.instructions = e.target.value)}
|
||||
onChange={handleInstructionsChange}
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Account, CoList, CoMap, co } from "jazz-tools";
|
||||
import { Account, CoList, CoMap, CoPlainText, co } from "jazz-tools";
|
||||
|
||||
export const BubbleTeaAddOnTypes = [
|
||||
"Pearl",
|
||||
@@ -28,7 +28,7 @@ export class BubbleTeaOrder extends CoMap {
|
||||
addOns = co.ref(ListOfBubbleTeaAddOns);
|
||||
deliveryDate = co.Date;
|
||||
withMilk = co.boolean;
|
||||
instructions = co.optional.string;
|
||||
instructions = co.optional.ref(CoPlainText);
|
||||
}
|
||||
|
||||
export class DraftBubbleTeaOrder extends CoMap {
|
||||
@@ -36,7 +36,7 @@ export class DraftBubbleTeaOrder extends CoMap {
|
||||
addOns = co.optional.ref(ListOfBubbleTeaAddOns);
|
||||
deliveryDate = co.optional.Date;
|
||||
withMilk = co.optional.boolean;
|
||||
instructions = co.optional.string;
|
||||
instructions = co.optional.ref(CoPlainText);
|
||||
|
||||
get hasChanges() {
|
||||
return Object.keys(this._edits).length > 1 || this.addOns?.hasChanges;
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# image-upload
|
||||
|
||||
## 0.0.89
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-upload",
|
||||
"private": true,
|
||||
"version": "0.0.87",
|
||||
"version": "0.0.89",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# jazz-example-inspector
|
||||
|
||||
## 0.0.143
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.26
|
||||
|
||||
## 0.0.142
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a846e07]
|
||||
- cojson@0.13.25
|
||||
- cojson-transport-ws@0.13.25
|
||||
- jazz-inspector@0.13.25
|
||||
|
||||
## 0.0.141
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-inspector-app",
|
||||
"private": true,
|
||||
"version": "0.0.141",
|
||||
"version": "0.0.143",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# multi-cursors
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "multi-cursors",
|
||||
"private": true,
|
||||
"version": "0.0.83",
|
||||
"version": "0.0.85",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# multiauth
|
||||
|
||||
## 0.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
- jazz-react-auth-clerk@0.13.26
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-react-auth-clerk@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "multiauth",
|
||||
"private": true,
|
||||
"version": "0.0.31",
|
||||
"version": "0.0.33",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# jazz-example-musicplayer
|
||||
|
||||
## 0.0.114
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-inspector@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.113
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.25
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.112
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-example-music-player",
|
||||
"private": true,
|
||||
"version": "0.0.112",
|
||||
"version": "0.0.114",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# organization
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "organization",
|
||||
"private": true,
|
||||
"version": "0.0.83",
|
||||
"version": "0.0.85",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# passkey-svelte
|
||||
|
||||
## 0.0.80
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-svelte@0.13.26
|
||||
|
||||
## 0.0.79
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-svelte@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "passkey-svelte",
|
||||
"version": "0.0.78",
|
||||
"version": "0.0.80",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# minimal-auth-passkey
|
||||
|
||||
## 0.0.90
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.89
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "passkey",
|
||||
"private": true,
|
||||
"version": "0.0.88",
|
||||
"version": "0.0.90",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# passphrase
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "passphrase",
|
||||
"private": true,
|
||||
"version": "0.0.85",
|
||||
"version": "0.0.87",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# jazz-password-manager
|
||||
|
||||
## 0.0.111
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.110
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.109
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-password-manager",
|
||||
"private": true,
|
||||
"version": "0.0.109",
|
||||
"version": "0.0.111",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# jazz-example-pets
|
||||
|
||||
## 0.0.209
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.208
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.207
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-example-pets",
|
||||
"private": true,
|
||||
"version": "0.0.207",
|
||||
"version": "0.0.209",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# reactions
|
||||
|
||||
## 0.0.89
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "reactions",
|
||||
"private": true,
|
||||
"version": "0.0.87",
|
||||
"version": "0.0.89",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
22
examples/richtext-tiptap/CHANGELOG.md
Normal file
22
examples/richtext-tiptap/CHANGELOG.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# richtext-tiptap
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
- jazz-richtext-tiptap@0.1.2
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
- jazz-richtext-tiptap@0.1.1
|
||||
|
||||
## 0.1.0
|
||||
|
||||
Initial release.
|
||||
124
examples/richtext-tiptap/README.md
Normal file
124
examples/richtext-tiptap/README.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# Jazz RichText Tiptap Example
|
||||
|
||||
A demonstration of collaborative rich text editing with Jazz, React, and Tiptap.
|
||||
|
||||
Live version: [https://richtext-tiptap-demo.jazz.tools](https://richtext-tiptap-demo.jazz.tools)
|
||||
|
||||
## Overview
|
||||
|
||||
This example shows how to implement collaborative rich text editing using:
|
||||
|
||||
- **Jazz** for real-time synchronization
|
||||
- **CoRichText** for collaborative rich text data structures
|
||||
- **Tiptap** for the rich text editor UI
|
||||
- **React** for the component framework
|
||||
|
||||
The example features:
|
||||
|
||||
- Side-by-side plaintext and rich text editors
|
||||
- Real-time collaboration across devices
|
||||
- Persistent document storage
|
||||
|
||||
## Getting started
|
||||
|
||||
You can either
|
||||
|
||||
1. Clone the jazz repository, and run the app within the monorepo.
|
||||
2. Or create a new Jazz project using this example as a template.
|
||||
|
||||
### Using the example as a template
|
||||
|
||||
Create a new Jazz project, and use this example as a template.
|
||||
|
||||
```bash
|
||||
npx create-jazz-app@latest richtext-tiptap-app --example richtext-tiptap
|
||||
```
|
||||
|
||||
Go to the new project directory.
|
||||
|
||||
```bash
|
||||
cd richtext-tiptap-app
|
||||
```
|
||||
|
||||
Run the dev server.
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Using the monorepo
|
||||
|
||||
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||
|
||||
Clone the jazz repository.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/garden-co/jazz.git
|
||||
```
|
||||
|
||||
Install and build dependencies.
|
||||
|
||||
```bash
|
||||
pnpm i && npx turbo build
|
||||
```
|
||||
|
||||
Go to the example directory.
|
||||
|
||||
```bash
|
||||
cd jazz/examples/richtext-tiptap/
|
||||
```
|
||||
|
||||
Start the dev server.
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||
|
||||
## How it works
|
||||
|
||||
This example demonstrates two key functionalities:
|
||||
|
||||
1. **CoRichText** - Jazz's collaborative rich text data structure
|
||||
2. **Rich text integration** - Using Tiptap with Jazz
|
||||
|
||||
### Key components
|
||||
|
||||
- `src/schema.ts` - Defines the data model, including the `bio` field using CoRichText
|
||||
- `src/Editor.tsx` - Implements both plaintext and rich text editor views
|
||||
- `jazz-richtext-tiptap` - Provides the plugin that connects Jazz to Tiptap
|
||||
|
||||
### Implementation details
|
||||
|
||||
The example shows how to:
|
||||
|
||||
- Create and store CoRichText values
|
||||
- Set up a plaintext editor with CoRichText
|
||||
- Set up a Tiptap editor with a Jazz plugin
|
||||
|
||||
## Extending this example
|
||||
|
||||
You can extend this example by:
|
||||
|
||||
- Adding formatting options to the rich text toolbar
|
||||
- Adding multiple collaborative documents
|
||||
- Building document history or versioning
|
||||
|
||||
## Configuration: sync server
|
||||
|
||||
By default, the app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
||||
|
||||
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/main.tsx](./src/main.tsx).
|
||||
|
||||
## Learn more
|
||||
|
||||
To learn more about Jazz's collaborative text capabilities:
|
||||
|
||||
- [Jazz documentation](https://jazz.tools/docs)
|
||||
- [CoText documentation](https://jazz.tools/docs/using-covalues/cotext)
|
||||
- [Tiptap documentation](https://tiptap.dev/docs)
|
||||
|
||||
## Questions / problems / feedback
|
||||
|
||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||
BIN
examples/richtext-tiptap/favicon.ico
Normal file
BIN
examples/richtext-tiptap/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
13
examples/richtext-tiptap/index.html
Normal file
13
examples/richtext-tiptap/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en" class="h-full">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Rich text Tiptap example app | Jazz</title>
|
||||
</head>
|
||||
<body class="h-full flex flex-col">
|
||||
<div id="root" class="align-self-center flex-1"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
45
examples/richtext-tiptap/package.json
Normal file
45
examples/richtext-tiptap/package.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "richtext-tiptap",
|
||||
"private": true,
|
||||
"version": "0.1.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"format-and-lint": "biome check .",
|
||||
"format-and-lint:fix": "biome check . --write"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.12.0",
|
||||
"@tiptap/extension-color": "^2.12.0",
|
||||
"@tiptap/extension-list-item": "^2.12.0",
|
||||
"@tiptap/extension-text-style": "^2.12.0",
|
||||
"@tiptap/pm": "^2.12.0",
|
||||
"@tiptap/react": "^2.12.0",
|
||||
"@tiptap/starter-kit": "^2.12.0",
|
||||
"clsx": "^2.1.1",
|
||||
"jazz-react": "workspace:*",
|
||||
"jazz-richtext-tiptap": "workspace:*",
|
||||
"jazz-tools": "workspace:*",
|
||||
"lucide-react": "^0.509.0",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@playwright/test": "^1.50.1",
|
||||
"@types/react": "~18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.3",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"globals": "^15.11.0",
|
||||
"is-ci": "^3.0.1",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
46
examples/richtext-tiptap/playwright.config.ts
Normal file
46
examples/richtext-tiptap/playwright.config.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
import isCI from "is-ci";
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: isCI,
|
||||
/* Retry on CI only */
|
||||
retries: isCI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: isCI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: "html",
|
||||
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: "http://localhost:5173/",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
permissions: ["clipboard-read", "clipboard-write"],
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: [
|
||||
{
|
||||
command: "pnpm preview --port 5173",
|
||||
url: "http://localhost:5173/",
|
||||
reuseExistingServer: !isCI,
|
||||
},
|
||||
],
|
||||
});
|
||||
6
examples/richtext-tiptap/postcss.config.js
Normal file
6
examples/richtext-tiptap/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
41
examples/richtext-tiptap/src/App.tsx
Normal file
41
examples/richtext-tiptap/src/App.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { useAccount, useIsAuthenticated } from "jazz-react";
|
||||
import { AuthButton } from "./AuthButton.tsx";
|
||||
import { Editor } from "./Editor.tsx";
|
||||
import { Logo } from "./Logo.tsx";
|
||||
|
||||
function App() {
|
||||
const { me } = useAccount({
|
||||
resolve: { profile: { bio: true }, root: true },
|
||||
});
|
||||
|
||||
const isAuthenticated = useIsAuthenticated();
|
||||
|
||||
return (
|
||||
<>
|
||||
<header>
|
||||
<nav className="container flex justify-between items-center py-3">
|
||||
{isAuthenticated ? (
|
||||
<span>You're logged in.</span>
|
||||
) : (
|
||||
<span>Authenticate to share the data with another device.</span>
|
||||
)}
|
||||
<AuthButton />
|
||||
</nav>
|
||||
</header>
|
||||
<main className="container mt-16 flex flex-col gap-8">
|
||||
<Logo />
|
||||
|
||||
<div className="text-center">
|
||||
<h1>
|
||||
Welcome{me?.profile.firstName ? <>, {me?.profile.firstName}</> : ""}
|
||||
!
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{me ? <Editor value={me.profile.bio} /> : null}
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
45
examples/richtext-tiptap/src/AuthButton.tsx
Normal file
45
examples/richtext-tiptap/src/AuthButton.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import { useAccount, usePasskeyAuth } from "jazz-react";
|
||||
import { APPLICATION_NAME } from "./main";
|
||||
|
||||
export function AuthButton() {
|
||||
const { logOut } = useAccount();
|
||||
|
||||
const auth = usePasskeyAuth({
|
||||
appName: APPLICATION_NAME,
|
||||
});
|
||||
|
||||
function handleLogOut() {
|
||||
logOut();
|
||||
window.history.pushState({}, "", "/");
|
||||
}
|
||||
|
||||
if (auth.state === "signedIn") {
|
||||
return (
|
||||
<button
|
||||
className="bg-stone-100 py-1.5 px-3 text-sm rounded-md"
|
||||
onClick={handleLogOut}
|
||||
>
|
||||
Log out
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
className="bg-stone-100 py-1.5 px-3 text-sm rounded-md"
|
||||
onClick={() => auth.signUp("")}
|
||||
>
|
||||
Sign up
|
||||
</button>
|
||||
<button
|
||||
onClick={() => auth.logIn()}
|
||||
className="bg-stone-100 py-1.5 px-3 text-sm rounded-md"
|
||||
>
|
||||
Log in
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
72
examples/richtext-tiptap/src/Editor.tsx
Normal file
72
examples/richtext-tiptap/src/Editor.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import { EditorContent, useEditor } from "@tiptap/react";
|
||||
import StarterKit from "@tiptap/starter-kit";
|
||||
import clsx from "clsx";
|
||||
import { JazzSyncExtension } from "jazz-richtext-tiptap";
|
||||
import { CoRichText } from "jazz-tools";
|
||||
import { BoldIcon, ItalicIcon, type LucideIcon } from "lucide-react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export function Editor({ value }: { value: CoRichText }) {
|
||||
const extensions = [
|
||||
StarterKit,
|
||||
// Jazz sync!
|
||||
JazzSyncExtension.configure({ coRichText: value }),
|
||||
];
|
||||
|
||||
const editor = useEditor({ extensions });
|
||||
|
||||
const toggleBold = useCallback(() => {
|
||||
editor?.chain().focus().toggleBold().run();
|
||||
}, [editor]);
|
||||
|
||||
const toggleItalic = useCallback(() => {
|
||||
editor?.chain().focus().toggleItalic().run();
|
||||
}, [editor]);
|
||||
|
||||
const isBold = editor?.isActive("bold");
|
||||
const isItalic = editor?.isActive("italic");
|
||||
|
||||
return (
|
||||
<div className="max-w-2xl bg-white rounded-xl shadow-md border border-black/10 w-full">
|
||||
<div className="flex p-4 gap-2 border-b border-black/10">
|
||||
<EditorMenuToggleButton
|
||||
onClick={toggleBold}
|
||||
isActive={isBold}
|
||||
icon={BoldIcon}
|
||||
/>
|
||||
<EditorMenuToggleButton
|
||||
onClick={toggleItalic}
|
||||
isActive={isItalic}
|
||||
icon={ItalicIcon}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<EditorContent
|
||||
editor={editor}
|
||||
className="prose prose-sm sm:prose lg:prose-lg xl:prose-xl [&>.ProseMirror]:active:ring-0 [&>.ProseMirror]:p-4"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EditorMenuToggleButton({
|
||||
onClick,
|
||||
isActive,
|
||||
icon: Icon,
|
||||
}: {
|
||||
onClick: () => void;
|
||||
isActive: boolean | undefined;
|
||||
icon: LucideIcon;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
className={clsx(
|
||||
"w-8 h-8 flex items-center justify-center rounded-md text-sm font-medium",
|
||||
isActive ? "bg-black text-white" : "bg-gray-100 text-black/70",
|
||||
)}
|
||||
>
|
||||
<Icon size="1.25em" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
21
examples/richtext-tiptap/src/Logo.tsx
Normal file
21
examples/richtext-tiptap/src/Logo.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
export function Logo() {
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 386 146"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="text-black w-48 mx-auto"
|
||||
>
|
||||
<path
|
||||
d="M176.725 33.865H188.275V22.7H176.725V33.865ZM164.9 129.4H172.875C182.72 129.4 188.275 123.9 188.275 114.22V43.6H176.725V109.545C176.725 115.65 173.975 118.51 167.925 118.51H164.9V129.4ZM245.298 53.28C241.613 45.47 233.363 41.95 222.748 41.95C208.998 41.95 200.748 48.44 197.888 58.615L208.613 61.915C210.648 55.315 216.368 52.565 222.638 52.565C231.933 52.565 235.673 56.415 236.058 64.61C226.433 65.93 216.643 67.195 209.768 69.23C200.583 72.145 195.743 77.865 195.743 86.83C195.743 96.51 202.673 104.65 215.818 104.65C225.443 104.65 232.318 101.35 237.213 94.365V103H247.388V66.425C247.388 61.475 247.168 57.185 245.298 53.28ZM217.853 95.245C210.483 95.245 207.128 91.34 207.128 86.72C207.128 82.045 210.593 79.515 215.323 77.92C220.328 76.435 226.983 75.5 235.948 74.18C235.893 76.93 235.673 80.725 234.738 83.475C233.418 89.25 227.643 95.245 217.853 95.245ZM251.22 103H301.545V92.715H269.535L303.195 45.47V43.6H254.3V53.885H284.935L251.22 101.185V103ZM304.815 103H355.14V92.715H323.13L356.79 45.47V43.6H307.895V53.885H338.53L304.815 101.185V103Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M136.179 44.8277C136.179 44.8277 136.179 44.8277 136.179 44.8276V21.168C117.931 28.5527 97.9854 32.6192 77.0897 32.6192C65.1466 32.6192 53.5138 31.2908 42.331 28.7737V51.4076C42.331 51.4076 42.331 51.4076 42.331 51.4076V81.1508C41.2955 80.4385 40.1568 79.8458 38.9405 79.3915C36.1732 78.358 33.128 78.0876 30.1902 78.6145C27.2524 79.1414 24.5539 80.4419 22.4358 82.3516C20.3178 84.2613 18.8754 86.6944 18.291 89.3433C17.7066 91.9921 18.0066 94.7377 19.1528 97.2329C20.2991 99.728 22.2403 101.861 24.7308 103.361C27.2214 104.862 30.1495 105.662 33.1448 105.662H33.1455C33.6061 105.662 33.8365 105.662 34.0314 105.659C44.5583 105.449 53.042 96.9656 53.2513 86.4386C53.2534 86.3306 53.2544 86.2116 53.2548 86.0486H53.2552V85.7149L53.2552 85.5521V82.0762L53.2552 53.1993C61.0533 54.2324 69.0092 54.7656 77.0897 54.7656C77.6696 54.7656 78.2489 54.7629 78.8276 54.7574V110.696C77.792 109.983 76.6533 109.391 75.437 108.936C72.6697 107.903 69.6246 107.632 66.6867 108.159C63.7489 108.686 61.0504 109.987 58.9323 111.896C56.8143 113.806 55.3719 116.239 54.7875 118.888C54.2032 121.537 54.5031 124.283 55.6494 126.778C56.7956 129.273 58.7368 131.405 61.2273 132.906C63.7179 134.406 66.646 135.207 69.6414 135.207C70.1024 135.207 70.3329 135.207 70.5279 135.203C81.0548 134.994 89.5385 126.51 89.7478 115.983C89.7517 115.788 89.7517 115.558 89.7517 115.097V111.621L89.7517 54.3266C101.962 53.4768 113.837 51.4075 125.255 48.2397V80.9017C124.219 80.1894 123.081 79.5966 121.864 79.1424C119.097 78.1089 116.052 77.8384 113.114 78.3653C110.176 78.8922 107.478 80.1927 105.36 82.1025C103.242 84.0122 101.799 86.4453 101.215 89.0941C100.631 91.743 100.931 94.4886 102.077 96.9837C103.223 99.4789 105.164 101.612 107.655 103.112C110.145 104.612 113.073 105.413 116.069 105.413C116.53 105.413 116.76 105.413 116.955 105.409C127.482 105.2 135.966 96.7164 136.175 86.1895C136.179 85.9945 136.179 85.764 136.179 85.3029V81.8271L136.179 44.8277Z"
|
||||
fill="#3313F7"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
1
examples/richtext-tiptap/src/apiKey.ts
Normal file
1
examples/richtext-tiptap/src/apiKey.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const apiKey = "richtext-tiptap-example@garden.co";
|
||||
84
examples/richtext-tiptap/src/index.css
Normal file
84
examples/richtext-tiptap/src/index.css
Normal file
@@ -0,0 +1,84 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
.ProseMirror {
|
||||
min-height: 12rem;
|
||||
}
|
||||
.ProseMirror:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.tiptap :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.tiptap ul,
|
||||
.tiptap ol {
|
||||
padding: 0 1rem;
|
||||
margin: 1.25rem 1rem 1.25rem 0.4rem;
|
||||
}
|
||||
.tiptap ul li p,
|
||||
.tiptap ol li p {
|
||||
margin-top: 0.25em;
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
.tiptap h1,
|
||||
.tiptap h2,
|
||||
.tiptap h3,
|
||||
.tiptap h4,
|
||||
.tiptap h5,
|
||||
.tiptap h6 {
|
||||
line-height: 1.1;
|
||||
margin-top: 2.5rem;
|
||||
text-wrap: pretty;
|
||||
}
|
||||
.tiptap h1,
|
||||
.tiptap h2 {
|
||||
margin-top: 3.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.tiptap h1 {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
.tiptap h2 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.tiptap h3 {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
.tiptap h4,
|
||||
.tiptap h5,
|
||||
.tiptap h6 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
.tiptap code {
|
||||
background-color: var(--purple-light);
|
||||
border-radius: 0.4rem;
|
||||
color: var(--black);
|
||||
font-size: 0.85rem;
|
||||
padding: 0.25em 0.3em;
|
||||
}
|
||||
.tiptap pre {
|
||||
background: var(--black);
|
||||
border-radius: 0.5rem;
|
||||
color: var(--white);
|
||||
font-family: "JetBrainsMono", monospace;
|
||||
margin: 1.5rem 0;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
.tiptap pre code {
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: 0.8rem;
|
||||
padding: 0;
|
||||
}
|
||||
.tiptap blockquote {
|
||||
border-left: 3px solid var(--gray-3);
|
||||
margin: 1.5rem 0;
|
||||
padding-left: 1rem;
|
||||
}
|
||||
.tiptap hr {
|
||||
border: none;
|
||||
border-top: 1px solid var(--gray-2);
|
||||
margin: 2rem 0;
|
||||
}
|
||||
32
examples/richtext-tiptap/src/main.tsx
Normal file
32
examples/richtext-tiptap/src/main.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { JazzProvider } from "jazz-react";
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import App from "./App.tsx";
|
||||
import "./index.css";
|
||||
import "prosemirror-example-setup/style/style.css";
|
||||
import "prosemirror-view/style/prosemirror.css";
|
||||
import "prosemirror-menu/style/menu.css";
|
||||
import { apiKey } from "./apiKey.ts";
|
||||
import { JazzAccount } from "./schema.ts";
|
||||
|
||||
// We use this to identify the app in the passkey auth
|
||||
export const APPLICATION_NAME = "Jazz richtext Tiptap example";
|
||||
|
||||
declare module "jazz-react" {
|
||||
export interface Register {
|
||||
Account: JazzAccount;
|
||||
}
|
||||
}
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<JazzProvider
|
||||
sync={{
|
||||
peer: `wss://cloud.jazz.tools/?key=${apiKey}`,
|
||||
}}
|
||||
AccountSchema={JazzAccount}
|
||||
>
|
||||
<App />
|
||||
</JazzProvider>
|
||||
</StrictMode>,
|
||||
);
|
||||
68
examples/richtext-tiptap/src/schema.ts
Normal file
68
examples/richtext-tiptap/src/schema.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Learn about schemas here:
|
||||
* https://jazz.tools/docs/react/schemas/covalues
|
||||
*/
|
||||
|
||||
import { Account, CoMap, CoRichText, Group, Profile, co } from "jazz-tools";
|
||||
|
||||
/** The account profile is an app-specific per-user public `CoMap`
|
||||
* where you can store top-level objects for that user */
|
||||
export class JazzProfile extends Profile {
|
||||
/**
|
||||
* Learn about CoValue field/item types here:
|
||||
* https://jazz.tools/docs/react/schemas/covalues#covalue-fielditem-types
|
||||
*/
|
||||
firstName = co.string;
|
||||
bio = co.ref(CoRichText);
|
||||
|
||||
// Add public fields here
|
||||
}
|
||||
|
||||
/** The account root is an app-specific per-user private `CoMap`
|
||||
* where you can store top-level objects for that user */
|
||||
export class AccountRoot extends CoMap {
|
||||
dateOfBirth = co.Date;
|
||||
|
||||
// Add private fields here
|
||||
|
||||
get age() {
|
||||
if (!this.dateOfBirth) return null;
|
||||
|
||||
return new Date().getFullYear() - this.dateOfBirth.getFullYear();
|
||||
}
|
||||
}
|
||||
|
||||
export class JazzAccount extends Account {
|
||||
profile = co.ref(JazzProfile);
|
||||
root = co.ref(AccountRoot);
|
||||
|
||||
/** The account migration is run on account creation and on every log-in.
|
||||
* You can use it to set up the account root and any other initial CoValues you need.
|
||||
*/
|
||||
migrate(this: JazzAccount) {
|
||||
if (this.root === undefined) {
|
||||
const group = Group.create();
|
||||
|
||||
this.root = AccountRoot.create(
|
||||
{ dateOfBirth: new Date("1/1/1990") },
|
||||
group,
|
||||
);
|
||||
}
|
||||
|
||||
if (this.profile === undefined) {
|
||||
const group = Group.create();
|
||||
group.addMember("everyone", "reader"); // The profile info is visible to everyone
|
||||
|
||||
this.profile = JazzProfile.create(
|
||||
{
|
||||
name: "Anonymous user",
|
||||
firstName: "",
|
||||
bio: CoRichText.create("<p>A <strong>hu<em>man</strong></em>.</p>", {
|
||||
owner: group,
|
||||
}),
|
||||
},
|
||||
group,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
examples/richtext-tiptap/src/vite-env.d.ts
vendored
Normal file
1
examples/richtext-tiptap/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
23
examples/richtext-tiptap/tailwind.config.ts
Normal file
23
examples/richtext-tiptap/tailwind.config.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Config } from "tailwindcss";
|
||||
|
||||
const config: Config = {
|
||||
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
||||
theme: {
|
||||
extend: {
|
||||
container: {
|
||||
center: true,
|
||||
padding: {
|
||||
DEFAULT: "0.75rem",
|
||||
sm: "1rem",
|
||||
},
|
||||
screens: {
|
||||
lg: "600px",
|
||||
xl: "600px",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
} as const;
|
||||
|
||||
export default config;
|
||||
24
examples/richtext-tiptap/tsconfig.app.json
Normal file
24
examples/richtext-tiptap/tsconfig.app.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
"moduleResolution": "Bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
7
examples/richtext-tiptap/tsconfig.json
Normal file
7
examples/richtext-tiptap/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
22
examples/richtext-tiptap/tsconfig.node.json
Normal file
22
examples/richtext-tiptap/tsconfig.node.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
"moduleResolution": "Bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
8
examples/richtext-tiptap/vercel.json
Normal file
8
examples/richtext-tiptap/vercel.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"build": {
|
||||
"env": {
|
||||
"APP_NAME": "richtext-tiptap"
|
||||
}
|
||||
},
|
||||
"ignoreCommand": "node ../../ignore-vercel-build.js"
|
||||
}
|
||||
7
examples/richtext-tiptap/vite.config.ts
Normal file
7
examples/richtext-tiptap/vite.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
});
|
||||
@@ -1,5 +1,22 @@
|
||||
# richtext
|
||||
|
||||
## 0.0.79
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
- jazz-richtext-prosemirror@0.1.13
|
||||
|
||||
## 0.0.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
- jazz-richtext-prosemirror@0.1.12
|
||||
|
||||
## 0.0.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "richtext",
|
||||
"private": true,
|
||||
"version": "0.0.77",
|
||||
"version": "0.0.79",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -9,7 +9,9 @@ import { EditorView } from "prosemirror-view";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
export function Editor() {
|
||||
const { me } = useAccount({ resolve: { profile: true, root: true } });
|
||||
const { me } = useAccount({
|
||||
resolve: { profile: { bio: true }, root: true },
|
||||
});
|
||||
const editorRef = useRef<HTMLDivElement>(null);
|
||||
const viewRef = useRef<EditorView | null>(null);
|
||||
|
||||
@@ -53,7 +55,7 @@ export function Editor() {
|
||||
</label>
|
||||
<textarea
|
||||
className="flex-1 border border-stone-200 dark:border-stone-700 rounded shadow-sm py-2 px-3 font-mono text-sm bg-stone-50 dark:bg-stone-900 text-stone-900 dark:text-stone-100 whitespace-pre-wrap break-words resize-none"
|
||||
value={me.profile.bio?.toString()}
|
||||
value={`${me.profile.bio}`}
|
||||
onChange={(e) => me.profile.bio?.applyDiff(e.target.value)}
|
||||
rows={10}
|
||||
/>
|
||||
|
||||
@@ -59,9 +59,10 @@ export class JazzAccount extends Account {
|
||||
{
|
||||
name: "Anonymous user",
|
||||
firstName: "",
|
||||
bio: CoRichText.create("<p>A <strong>hu<em>man</strong></em>.</p>", {
|
||||
owner: group,
|
||||
}),
|
||||
bio: CoRichText.create(
|
||||
"<p>A <strong>hu<em>man</strong></em>.</p>",
|
||||
group,
|
||||
),
|
||||
},
|
||||
group,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# todo-vue
|
||||
|
||||
## 0.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-browser@0.13.26
|
||||
- jazz-vue@0.13.26
|
||||
|
||||
## 0.0.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-browser@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
- jazz-vue@0.13.25
|
||||
|
||||
## 0.0.91
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "todo-vue",
|
||||
"version": "0.0.91",
|
||||
"version": "0.0.93",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# jazz-example-todo
|
||||
|
||||
## 0.0.208
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.207
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.206
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-example-todo",
|
||||
"private": true,
|
||||
"version": "0.0.206",
|
||||
"version": "0.0.208",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Account, CoList, CoMap, Profile, co } from "jazz-tools";
|
||||
import { Account, CoList, CoMap, CoPlainText, Profile, co } from "jazz-tools";
|
||||
|
||||
/** Walkthrough: Defining the data model with CoJSON
|
||||
*
|
||||
@@ -13,7 +13,7 @@ import { Account, CoList, CoMap, Profile, co } from "jazz-tools";
|
||||
/** An individual task which collaborators can tick or rename */
|
||||
export class Task extends CoMap {
|
||||
done = co.boolean;
|
||||
text = co.string;
|
||||
text = co.ref(CoPlainText);
|
||||
}
|
||||
|
||||
export class ListOfTasks extends CoList.Of(co.ref(Task)) {}
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "./basicComponents";
|
||||
|
||||
import { useCoState } from "jazz-react";
|
||||
import { ID } from "jazz-tools";
|
||||
import { CoPlainText, ID } from "jazz-tools";
|
||||
import { useParams } from "react-router";
|
||||
import uniqolor from "uniqolor";
|
||||
import { InviteButton } from "./components/InviteButton";
|
||||
@@ -50,9 +50,9 @@ export function ProjectTodoTable() {
|
||||
const task = Task.create(
|
||||
{
|
||||
done: false,
|
||||
text,
|
||||
text: CoPlainText.create(text, project._owner),
|
||||
},
|
||||
{ owner: project._owner },
|
||||
project._owner,
|
||||
);
|
||||
|
||||
// push will cause useCoState to rerender this component, both here and on other devices
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { CoPlainText } from "jazz-tools";
|
||||
import { ListOfTasks, Task, TodoProject } from "./1_schema";
|
||||
|
||||
export function generateRandomProject(numTasks: number): TodoProject {
|
||||
@@ -12,7 +13,10 @@ export function generateRandomProject(numTasks: number): TodoProject {
|
||||
for (let i = 0; i < numTasks; i++) {
|
||||
const task = Task.create({
|
||||
done: faker.datatype.boolean(),
|
||||
text: faker.lorem.sentence({ min: 3, max: 8 }),
|
||||
text: CoPlainText.create(
|
||||
faker.lorem.sentence({ min: 3, max: 8 }),
|
||||
tasks._owner,
|
||||
),
|
||||
});
|
||||
tasks.push(task);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# version-history
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ff846d9]
|
||||
- jazz-tools@0.13.26
|
||||
- jazz-inspector@0.13.26
|
||||
- jazz-react@0.13.26
|
||||
|
||||
## 0.0.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.25
|
||||
- jazz-react@0.13.25
|
||||
- jazz-tools@0.13.25
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "version-history",
|
||||
"private": true,
|
||||
"version": "0.0.85",
|
||||
"version": "0.0.87",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useAccount, useCoState } from "jazz-react";
|
||||
import { Group, ID } from "jazz-tools";
|
||||
import { CoPlainText, Group, ID } from "jazz-tools";
|
||||
import { useState } from "react";
|
||||
import { IssueComponent } from "./Issue.tsx";
|
||||
import { IssueVersionHistory } from "./IssueVersionHistory.tsx";
|
||||
@@ -21,11 +21,14 @@ function App() {
|
||||
const newIssue = Issue.create(
|
||||
{
|
||||
title: "Buy terrarium",
|
||||
description: "Make sure it's big enough for 10 snails.",
|
||||
description: CoPlainText.create(
|
||||
"Make sure it's big enough for 10 snails.",
|
||||
group,
|
||||
),
|
||||
estimate: 5,
|
||||
status: "backlog",
|
||||
},
|
||||
{ owner: group },
|
||||
group,
|
||||
);
|
||||
setIssueID(newIssue.id);
|
||||
window.history.pushState({}, "", `?issue=${newIssue.id}`);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { CoPlainText } from "jazz-tools";
|
||||
import { Issue } from "./schema";
|
||||
export function IssueComponent({ issue }: { issue: Issue }) {
|
||||
return (
|
||||
@@ -16,9 +17,12 @@ export function IssueComponent({ issue }: { issue: Issue }) {
|
||||
<label className="flex flex-col gap-2">
|
||||
Description
|
||||
<textarea
|
||||
value={issue.description}
|
||||
value={`${issue.description}`}
|
||||
onChange={(event) => {
|
||||
issue.description = event.target.value;
|
||||
issue.description = CoPlainText.create(
|
||||
event.target.value,
|
||||
issue._owner,
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createInviteLink, useAccount } from "jazz-react";
|
||||
import { useCoState } from "jazz-react";
|
||||
import { ID } from "jazz-tools";
|
||||
import { CoPlainText, ID } from "jazz-tools";
|
||||
import { IssueComponent } from "./Issue.tsx";
|
||||
import { Issue, Project } from "./schema.ts";
|
||||
export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {
|
||||
@@ -19,7 +19,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {
|
||||
Issue.create(
|
||||
{
|
||||
title: "",
|
||||
description: "",
|
||||
description: CoPlainText.create("", project._owner),
|
||||
estimate: 0,
|
||||
status: "backlog",
|
||||
},
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
* https://jazz.tools/docs/react/schemas/covalues
|
||||
*/
|
||||
|
||||
import { CoList, CoMap, co } from "jazz-tools";
|
||||
import { CoList, CoMap, CoPlainText, co } from "jazz-tools";
|
||||
|
||||
export class Issue extends CoMap {
|
||||
title = co.string;
|
||||
description = co.string;
|
||||
description = co.ref(CoPlainText);
|
||||
estimate = co.number;
|
||||
status? = co.literal("backlog", "in progress", "done");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import clsx from "clsx";
|
||||
import Link from "next/link";
|
||||
|
||||
export function Testimonial({
|
||||
children,
|
||||
@@ -6,13 +7,51 @@ export function Testimonial({
|
||||
role,
|
||||
className,
|
||||
size = "md",
|
||||
imageUrl,
|
||||
darkImageUrl,
|
||||
url,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
name: string;
|
||||
role: string;
|
||||
className?: string;
|
||||
size?: "sm" | "md";
|
||||
imageUrl?: string;
|
||||
darkImageUrl?: string;
|
||||
url?: string;
|
||||
}) {
|
||||
const content = (
|
||||
<>
|
||||
{imageUrl && (
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt=""
|
||||
className={clsx(
|
||||
"rounded-full size-10 sm:size-12",
|
||||
darkImageUrl && "dark:hidden",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{darkImageUrl && (
|
||||
<img
|
||||
src={darkImageUrl}
|
||||
alt=""
|
||||
className={clsx("rounded-full size-10 sm:size-12 hidden dark:inline")}
|
||||
/>
|
||||
)}
|
||||
<div className="text-sm sm:text-base">
|
||||
<div className="font-semibold text-highlight">{name}</div>
|
||||
<div className="text-stone-600 dark:text-stone-500">{role}</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
const authorClassName = clsx("inline-flex items-center gap-x-4", {
|
||||
"mt-6": size === "md",
|
||||
"mt-4": size === "sm",
|
||||
});
|
||||
|
||||
return (
|
||||
<figure className={clsx("max-w-2xl", className)}>
|
||||
<svg
|
||||
@@ -34,19 +73,15 @@ export function Testimonial({
|
||||
>
|
||||
{children}
|
||||
</blockquote>
|
||||
<figcaption
|
||||
className={clsx("flex items-center gap-x-6", {
|
||||
"mt-6": size === "md",
|
||||
"mt-4": size === "sm",
|
||||
})}
|
||||
>
|
||||
<div className="text-sm leading-6 sm:text-base">
|
||||
<div className="font-semibold text-highlight">{name}</div>
|
||||
<div className="mt-0.5 text-stone-600 dark:text-stone-500">
|
||||
{role}
|
||||
</div>
|
||||
</div>
|
||||
</figcaption>
|
||||
{url ? (
|
||||
<figcaption>
|
||||
<Link href={url} target="_blank" className={authorClassName}>
|
||||
{content}
|
||||
</Link>
|
||||
</figcaption>
|
||||
) : (
|
||||
<figcaption className={authorClassName}>{content}</figcaption>
|
||||
)}
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ export default function Home() {
|
||||
</p>
|
||||
</Testimonial>
|
||||
|
||||
<ProblemStatementSection />
|
||||
|
||||
<ChatDemoSection />
|
||||
|
||||
<ProblemStatementSection />
|
||||
|
||||
<LocalFirstFeaturesSection />
|
||||
|
||||
<CollaborationFeaturesSection />
|
||||
|
||||
@@ -1,37 +1,71 @@
|
||||
import { Button } from "@garden-co/design-system/src/components/atoms/Button";
|
||||
import { Card } from "@garden-co/design-system/src/components/atoms/Card";
|
||||
import { H2 } from "@garden-co/design-system/src/components/atoms/Headings";
|
||||
import { Prose } from "@garden-co/design-system/src/components/molecules/Prose";
|
||||
import { SectionHeader } from "@garden-co/design-system/src/components/molecules/SectionHeader";
|
||||
import { Testimonial } from "@garden-co/design-system/src/components/molecules/Testimonial";
|
||||
|
||||
function TheoTestimonial({
|
||||
size,
|
||||
className,
|
||||
}: { size?: "sm" | "md"; className?: string }) {
|
||||
return (
|
||||
<Testimonial
|
||||
size={size}
|
||||
name="Theo"
|
||||
role="@theo"
|
||||
imageUrl="/theo.jpg"
|
||||
darkImageUrl="/theo-dark.jpg"
|
||||
url="https://x.com/theo"
|
||||
className={className}
|
||||
>
|
||||
<p>
|
||||
I talked with the team. They work really hard. The Jazz team clearly
|
||||
cares, almost maybe too much, about making Jazz a great solution.
|
||||
</p>
|
||||
<p>
|
||||
One of the best experiences I've had working with open source devs on a
|
||||
short notice.
|
||||
</p>
|
||||
</Testimonial>
|
||||
);
|
||||
}
|
||||
|
||||
export function EarlyAdopterSection() {
|
||||
return (
|
||||
<Card className="p-4 md:py-16">
|
||||
<div className="lg:max-w-3xl md:text-center mx-auto space-y-6">
|
||||
<p className="uppercase text-primary tracking-widest text-sm font-medium ">
|
||||
Become an early adopter
|
||||
</p>
|
||||
<H2>We'll help you build your next app with Jazz</H2>
|
||||
<Prose className="md:text-balance mx-auto">
|
||||
<p>
|
||||
It's early days, but we work hard every day to make Jazz a
|
||||
great tool for our users.
|
||||
</p>
|
||||
<p>
|
||||
We want to hear about what you're building, so we can help you
|
||||
every step of the way. We'll prioritize features that you need
|
||||
to succeed.
|
||||
</p>
|
||||
</Prose>
|
||||
<div className="flex md:justify-center gap-3">
|
||||
<Button href="https://discord.gg/utDMjHYg42" variant="primary">
|
||||
Let's talk on Discord
|
||||
</Button>
|
||||
<Button href="/docs" variant="secondary">
|
||||
Read <span className="sm:hidden">docs</span>{" "}
|
||||
<span className="hidden sm:inline">the documentation</span>
|
||||
</Button>
|
||||
<div className="grid grid grid-cols-3 items-center gap-y-12">
|
||||
<TheoTestimonial size="md" className="col-span-3 lg:hidden" />
|
||||
<div className="col-span-3 lg:col-span-2">
|
||||
<div className="max-w-3xl space-y-6">
|
||||
<SectionHeader
|
||||
kicker="Get started"
|
||||
title="Let's build your next app together"
|
||||
/>
|
||||
|
||||
<Prose className="md:text-pretty mb-6">
|
||||
<p>
|
||||
Whether you're building something big with Jazz or just trying
|
||||
things out, we've got a team of developers who have seen and built
|
||||
everything.
|
||||
</p>
|
||||
<p>
|
||||
We're happy to help you hands-on with your app, and ready to
|
||||
tailor Jazz features to your needs.
|
||||
</p>
|
||||
</Prose>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<Button href="/docs" variant="primary">
|
||||
Read docs
|
||||
</Button>
|
||||
<Button href="https://discord.gg/utDMjHYg42" variant="secondary">
|
||||
Join Discord
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<TheoTestimonial
|
||||
size="sm"
|
||||
className="hidden lg:block lg:pl-8 lg:py-8 lg:border-l"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,34 @@ group.addMember(bob, "writer");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Change a member's role
|
||||
|
||||
To change a member's role, use the `addMember` method.
|
||||
|
||||
<CodeGroup>
|
||||
```ts
|
||||
group.addMember(bob, "reader");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Bob just went from a writer to a reader.
|
||||
|
||||
Note: only admins can change a member's role.
|
||||
|
||||
## Removing a member
|
||||
|
||||
To remove a member, use the `removeMember` method.
|
||||
|
||||
<CodeGroup>
|
||||
```ts
|
||||
group.removeMember(bob);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
This only works if you are an admin, and Bob is not an admin.
|
||||
|
||||
Admins cannot remove other admins, but they can remove themselves, as long as there is another admin present.
|
||||
|
||||
## Getting the Group of an existing CoValue
|
||||
|
||||
You can get the group of an existing CoValue by using `coValue._owner`.
|
||||
@@ -117,4 +145,4 @@ if (bob.canAdmin(value)) {
|
||||
console.log("Bob cannot access value");
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
</CodeGroup>
|
||||
|
||||
@@ -102,7 +102,7 @@ See [Groups as permission scopes](/docs/groups/intro) for more information on ho
|
||||
|
||||
## Reading Text
|
||||
|
||||
CoText values work like JavaScript strings:
|
||||
CoText values work similarly to JavaScript strings:
|
||||
|
||||
<CodeGroup>
|
||||
```ts twoslash
|
||||
@@ -114,12 +114,32 @@ const note = CoPlainText.create("Meeting notes", { owner: me });
|
||||
// ---cut---
|
||||
// Get the text content
|
||||
console.log(note.toString()); // "Meeting notes"
|
||||
console.log(`${note}`); // "Meeting notes"
|
||||
|
||||
// Check the text length
|
||||
console.log(note.length); // 14
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<ContentByFramework framework="react">
|
||||
When using CoTexts in JSX, you can read the text directly:
|
||||
<CodeGroup>
|
||||
```tsx twoslash
|
||||
import * as React from "react";
|
||||
import { CoPlainText, Account } from "jazz-tools";
|
||||
import { createJazzTestAccount } from 'jazz-tools/testing';
|
||||
const me = await createJazzTestAccount();
|
||||
const note = CoPlainText.create("Meeting notes", { owner: me });
|
||||
|
||||
// ---cut---
|
||||
<>
|
||||
<p>{note.toString()}</p>
|
||||
<p>{note}</p>
|
||||
</>
|
||||
```
|
||||
</CodeGroup>
|
||||
</ContentByFramework>
|
||||
|
||||
## Making Edits
|
||||
|
||||
Insert and delete text with intuitive methods:
|
||||
|
||||
BIN
homepage/homepage/public/theo-dark.jpg
Normal file
BIN
homepage/homepage/public/theo-dark.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user