Skip to content

Commit 115c46c

Browse files
committed
Merge branch 'refs/heads/main' into releases
# Conflicts: # docs/package.json # lerna.json # package-lock.json # packages/ariakit/package.json # packages/core/package.json # packages/mantine/package.json # packages/react/package.json # packages/shadcn/package.json # playground/package.json # tests/package.json
2 parents fe5ba74 + f69a59f commit 115c46c

File tree

524 files changed

+8613
-1373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

524 files changed

+8613
-1373
lines changed

docs/auth.ts

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,27 @@ export const {
1010
callbacks: {
1111
signIn: async (params) => {
1212
if (params.profile!.sponsorInfo) {
13-
// TODO
13+
// user is sponsor
1414
return true;
1515
}
16+
// user is signed in to github, but not a sponsor.
17+
// TODO: We could redirect to pricing page here
1618
return true;
17-
return "https://github.com/sponsors/TypeCellOS"; // TODO
19+
// return "https://www.blocknotejs.org/pricing";
20+
},
21+
// https://authjs.dev/guides/extending-the-session
22+
jwt({ token, user }) {
23+
if (user) {
24+
// User is available during sign-in
25+
token.sponsorInfo = (user as any).sponsorInfo;
26+
}
27+
return token;
28+
},
29+
session: async (params) => {
30+
(params.session.user as any).sponsorInfo = (
31+
params.token as any
32+
).sponsorInfo;
33+
return params.session;
1834
},
1935
},
2036
providers: [
@@ -55,9 +71,11 @@ export const {
5571
"Content-Type": "application/json",
5672
Authorization: `Bearer ${tokens.access_token}`,
5773
},
74+
// organization(login:"TypeCellOS") {
75+
// user(login:"YousefED") {
5876
body: JSON.stringify({
5977
query: `{
60-
organization(login:"TypeCellOS") {
78+
user(login:"YousefED") {
6179
sponsorshipForViewerAsSponsor(activeOnly:false) {
6280
isActive,
6381
tier {
@@ -71,10 +89,35 @@ export const {
7189
});
7290

7391
if (resSponsor.ok) {
92+
// Mock data. TODO: disable and test actial data
93+
// profile.sponsorInfo = {
94+
// isActive: true,
95+
// tier: {
96+
// name: "test",
97+
// monthlyPriceInDollars: 100,
98+
// },
99+
// };
100+
// use API data:
101+
74102
const data = await resSponsor.json();
103+
// eslint-disable-next-line no-console
104+
console.log("sponsor data", data);
105+
106+
// {
107+
// "data": {
108+
// "user": {
109+
// "sponsorshipForViewerAsSponsor": {
110+
// "isActive": true,
111+
// "tier": {
112+
// "name": "$90 a month",
113+
// "monthlyPriceInDollars": 90
114+
// }
115+
// }
116+
// }
117+
// }
118+
// }
75119

76-
profile.sponsorInfo =
77-
data.data.organization.sponsorshipForViewerAsSponsor;
120+
profile.sponsorInfo = data.data.user.sponsorshipForViewerAsSponsor;
78121
}
79122

80123
return profile;
@@ -87,7 +130,7 @@ export const {
87130
email: profile.email,
88131
image: profile.avatar_url,
89132
username: profile.login,
90-
sponsorInfo: profile.sponsorsTypeCell,
133+
sponsorInfo: profile.sponsorInfo,
91134
};
92135
},
93136
}),

docs/components/AuthNavButton.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ export function AuthNavButton(props: any) {
4141
/>
4242
</NavbarMenu>
4343
) : (
44-
<></>
45-
// TODO: design button
46-
// <button
47-
// onClick={async () => {
48-
// await signIn("github");
49-
// }}>
50-
// Sign in
51-
// </button>
44+
<>
45+
{/* TODO: move to footer */}{" "}
46+
{/* <button
47+
onClick={async () => {
48+
await signIn("github", {});
49+
}}>
50+
Sign in
51+
</button> */}
52+
</>
5253
);
5354
}
5455

docs/components/cards.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import type { ComponentProps, CSSProperties, ReactNode } from "react";
66
const classes = {
77
cards: cn(
88
"nextra-cards nx-mt-4 nx-gap-4 nx-grid",
9-
"nx-not-prose" // for nextra-theme-docs
9+
"nx-not-prose", // for nextra-theme-docs
1010
),
1111
card: cn(
1212
"nextra-card nx-group nx-flex nx-flex-col nx-justify-between nx-overflow-hidden nx-rounded-lg nx-border nx-border-gray-200",
1313
"nx-text-current nx-no-underline dark:nx-shadow-none",
1414
"hover:nx-shadow-gray-100 dark:hover:nx-shadow-none nx-shadow-gray-100",
1515
"active:nx-shadow-sm active:nx-shadow-gray-200",
16-
"nx-transition-all nx-duration-200 hover:nx-border-gray-300"
16+
"nx-transition-all nx-duration-200 hover:nx-border-gray-300",
1717
),
1818
title: cn(
19-
"nx-flex nx-font-semibold nx-items-start nx-text-gray-700 hover:nx-text-gray-900"
19+
"nx-flex nx-font-semibold nx-items-start nx-text-gray-700 hover:nx-text-gray-900",
2020
),
2121
};
2222

@@ -54,14 +54,14 @@ export function Card({
5454
href={href}
5555
className={cn(
5656
classes.card,
57-
"nx-bg-gray-100 nx-shadow dark:nx-border-neutral-700 dark:nx-bg-neutral-800 dark:nx-text-gray-50 hover:nx-shadow-lg dark:hover:nx-border-neutral-500 dark:hover:nx-bg-neutral-700"
57+
"nx-bg-gray-100 nx-shadow dark:nx-border-neutral-700 dark:nx-bg-neutral-800 dark:nx-text-gray-50 hover:nx-shadow-lg dark:hover:nx-border-neutral-500 dark:hover:nx-bg-neutral-700",
5858
)}
5959
{...props}>
6060
{children}
6161
<span
6262
className={cn(
6363
classes.title,
64-
"dark:nx-text-gray-300 dark:hover:nx-text-gray-100"
64+
"dark:nx-text-gray-300 dark:hover:nx-text-gray-100",
6565
)}>
6666
{icon}
6767
<span className="nx-flex nx-gap-1">
@@ -79,21 +79,29 @@ export function Card({
7979
className={cn(
8080
classes.card,
8181
"nx-bg-transparent nx-shadow-sm dark:nx-border-neutral-800 hover:nx-bg-slate-50 hover:nx-shadow-md dark:hover:nx-border-neutral-700 dark:hover:nx-bg-neutral-900",
82-
"nx-flex nx-items-start nx-gap-2 nx-p-4 nx-text-gray-700"
82+
"nx-flex nx-items-start nx-gap-2 nx-p-4 nx-text-gray-700",
8383
)}
8484
{...props}>
8585
<span
8686
className={cn(
8787
classes.title,
88-
"dark:nx-text-neutral-200 dark:hover:nx-text-neutral-50 nx-flex nx-items-center"
88+
"dark:nx-text-neutral-200 dark:hover:nx-text-neutral-50 nx-flex nx-items-center",
8989
)}>
90-
{icon}
9190
{title}
91+
{icon}
9292
{animatedArrow}
9393
</span>
9494
{/* <div className="hover:nx-text-gray-900 nx-items-right">test</div> */}
95-
<div className="text-xs nx-flex nx-items-center nx-gap-2">
96-
{authorImage && <Image className="rounded-md size-5" width={50} height={50} src={authorImage} alt={authorName + " profile image"} />}{" "}
95+
<div className="nx-flex nx-items-center nx-gap-2 text-xs">
96+
{authorImage && (
97+
<Image
98+
className="size-5 rounded-md"
99+
width={50}
100+
height={50}
101+
src={authorImage}
102+
alt={authorName + " profile image"}
103+
/>
104+
)}{" "}
97105
{authorName && <span>{authorName}</span>}
98106
{/* <span>·</span>
99107
<span>💖</span> */}
Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import { signIn } from "next-auth/react";
12
import dynamic from "next/dynamic";
23
import { AiFillGithub } from "react-icons/ai";
34
import { SiStackblitz } from "react-icons/si";
45

6+
import CTAButton from "../../components/pages/landing/shared/CTAButton";
7+
import { SectionHeader } from "../../components/pages/landing/shared/Headings";
58
import { examples } from "./generated/exampleComponents.gen";
9+
10+
import "../pages/landing/gradients.css";
611
import "./styles.css";
712

813
const baseGitHubURL = "https://github.com/TypeCellOS/BlockNote/tree/main/";
@@ -20,38 +25,83 @@ export function ExampleBlock(props: {
2025
name: keyof typeof examples;
2126
path: string;
2227
children: any;
28+
isProExample?: {
29+
userStatus: "business" | "starter" | "free" | undefined;
30+
};
2331
}) {
24-
// const example = examplesFlattened.find((e) => e.slug === props.name);
25-
// if (!example) {
26-
// throw new Error("invalid example");
27-
// }
32+
const showCode =
33+
!props.isProExample ||
34+
props.isProExample.userStatus === "starter" ||
35+
props.isProExample.userStatus === "business";
2836

2937
return (
3038
<div className="demo nx-bg-primary-700/5 dark:nx-bg-primary-300/10 mt-6 rounded-lg p-4">
31-
<div className={"flex flex-row gap-6 pb-4"}>
32-
<a
33-
className={
34-
"nx-select-none nx-text-gray-600 hover:nx-text-black dark:nx-text-gray-200 dark:hover:nx-text-white flex flex-row items-center gap-1"
35-
}
36-
href={`${baseGitHubURL}${props.path}/`}
37-
target="_blank">
38-
<AiFillGithub />
39-
<div className={"text-sm"}>GitHub</div>
40-
</a>
41-
<a
42-
className={
43-
"nx-select-none nx-text-gray-600 hover:nx-text-black dark:nx-text-gray-200 dark:hover:nx-text-white flex flex-row items-center gap-1"
44-
}
45-
href={`${baseStackBlitzURL}${props.path}/`}
46-
target="_blank">
47-
<SiStackblitz />
48-
<div className={"text-sm"}>StackBlitz</div>
49-
</a>
50-
</div>
39+
{showCode && (
40+
<div className={"z-10 flex flex-row gap-6 pb-4"}>
41+
<a
42+
className={
43+
"nx-select-none nx-text-gray-600 hover:nx-text-black dark:nx-text-gray-200 dark:hover:nx-text-white flex flex-row items-center gap-1"
44+
}
45+
href={`${baseGitHubURL}${props.path}/`}
46+
target="_blank">
47+
<AiFillGithub />
48+
<div className={"text-sm"}>GitHub</div>
49+
</a>
50+
<a
51+
className={
52+
"nx-select-none nx-text-gray-600 hover:nx-text-black dark:nx-text-gray-200 dark:hover:nx-text-white flex flex-row items-center gap-1"
53+
}
54+
href={`${baseStackBlitzURL}${props.path}/`}
55+
target="_blank">
56+
<SiStackblitz />
57+
<div className={"text-sm"}>StackBlitz</div>
58+
</a>
59+
</div>
60+
)}
5161
<div className={"demo-contents h-96 overflow-auto rounded-lg"}>
5262
<ThemedExample name={props.name} />
5363
</div>
54-
{props.children}
64+
{showCode ? (
65+
props.children
66+
) : (
67+
<div
68+
className={
69+
"relative flex h-96 flex-col items-center justify-center gap-2"
70+
}>
71+
<div className={"absolute h-1/2 w-1/2"}>
72+
<div className={"cta-glow h-full w-full"}></div>
73+
</div>
74+
<div className={"z-10 flex w-2/3 flex-col items-center"}>
75+
<SectionHeader>Pro Example</SectionHeader>
76+
<p className={"text-center text-[#00000080] dark:text-[#FFFFFFB2]"}>
77+
Get access to the full source code for pro examples by subscribing
78+
to BlockNote Pro
79+
</p>
80+
<div className={"mt-8"}>
81+
<CTAButton
82+
href={"/pricing"}
83+
color={"pro"}
84+
size={"large"}
85+
hoverGlow={true}>
86+
Get BlockNote Pro
87+
</CTAButton>
88+
</div>
89+
{!props.isProExample?.userStatus && (
90+
<p className={"mt-1 text-xs"}>
91+
Or{" "}
92+
<button
93+
className={"nx-text-primary-600"}
94+
onClick={async () => {
95+
await signIn("github", {});
96+
}}>
97+
sign in
98+
</button>{" "}
99+
via GitHub
100+
</p>
101+
)}
102+
</div>
103+
</div>
104+
)}
55105
</div>
56106
);
57107
}

docs/components/example/ExampleList.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Card, Cards } from "../../components/cards";
22
import { EXAMPLES_LIST } from "../../components/example/generated/exampleList.gen";
3+
import { ProBadge } from "../../components/example/ProBadge";
4+
import { proExamplesList } from "../../components/example/proExamplesList";
35

46
export function ExampleGroup(props: { examples: (typeof EXAMPLES_LIST)[0] }) {
57
return (
@@ -14,6 +16,7 @@ export function ExampleGroup(props: { examples: (typeof EXAMPLES_LIST)[0] }) {
1416
key={i}
1517
title={project.text}
1618
href={project.link}
19+
icon={proExamplesList.includes(project.text) && <ProBadge />}
1720
authorName={project.author}
1821
authorImage={`https://github.com/${project.author}.png`}
1922
/>

docs/components/example/ProBadge.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function ProBadge() {
2+
return (
3+
<span className="nx-rounded-full mx-1 inline-flex items-center bg-indigo-600/10 px-1.5 text-xs font-medium text-indigo-600 ring-1 ring-inset ring-indigo-600">
4+
Pro
5+
</span>
6+
);
7+
}

docs/components/example/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import { useSession } from "next-auth/react";
2+
import { getProLevel } from "../../util/authUtil";
13
import { examples } from "./generated/exampleComponents.gen";
24

35
export function Example(props: { name: keyof typeof examples }) {
4-
6+
const session = useSession();
57
const example = examples[props.name];
68
if (!example) {
79
throw new Error(`Example ${props.name} not found`);
810
}
911
const ExampleWithCode = example.ExampleWithCode;
12+
const userStatus = getProLevel(session);
1013

11-
return <ExampleWithCode name={props.name} />;
14+
return (
15+
<ExampleWithCode
16+
name={props.name}
17+
isProExample={example.pro ? { userStatus } : undefined}
18+
/>
19+
);
1220
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { EXAMPLES_LIST } from "@/components/example/generated/exampleList.gen";
2+
import { examples } from "@/components/example/generated/exampleComponents.gen";
3+
4+
export const proExamplesList = ([] as (typeof EXAMPLES_LIST)[number]["items"])
5+
.concat(...EXAMPLES_LIST.map((example) => example.items))
6+
.filter((example) => {
7+
return examples[
8+
example.link.replace("/examples/", "") as keyof typeof examples
9+
].pro;
10+
})
11+
.map((example) => example.text);

docs/components/pages/landing/faq/FAQ.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Link } from "nextra-theme-docs";
21
import { SectionIntro } from "@/components/pages/landing/shared/Headings";
32
import { Section } from "@/components/pages/landing/shared/Section";
3+
import { Link } from "nextra-theme-docs";
44

55
const faqs = [
66
{
@@ -24,7 +24,7 @@ const faqs = [
2424
id: 4,
2525
question: "Is BlockNote really free?",
2626
answer: `100% of BlockNote is open source. While the library is free, we offer paid consultancy and support services to help sustain BlockNote.
27-
Sponsoring the project is encouraged if you are using BlockNote in a commercial project.`,
27+
If you are using BlockNote in a commercial project, we encourage to sign up for BlockNote Pro!`,
2828
},
2929
];
3030

0 commit comments

Comments
 (0)