Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: UI libs CSS+API refactor #698

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bd8c2e7
Cleaned up component context API
matthewlipski Apr 9, 2024
67709b9
WIP
matthewlipski Apr 11, 2024
abc0235
Refactored CSS & ShadCN API
matthewlipski Apr 19, 2024
f95006a
Fixed Ariakit component props
matthewlipski Apr 19, 2024
09f1093
Fixed Mantine component props
matthewlipski Apr 19, 2024
e6ad649
Fixed ShadCN component props
matthewlipski Apr 19, 2024
0f15fcd
Cleanup
matthewlipski Apr 19, 2024
015d2df
Misc fixes
matthewlipski Apr 19, 2024
7dfd920
- Added remaining components to context
matthewlipski Apr 24, 2024
487c0fb
Changed ShadCN suggestion menu to use Card
matthewlipski Apr 24, 2024
f818962
Small fix
matthewlipski Apr 24, 2024
89b7b87
Fixed linting
matthewlipski Apr 24, 2024
0896ca7
Fixed `BlockNoteViewRaw` typing
matthewlipski Apr 24, 2024
7d4b701
Misc fixes
matthewlipski Apr 24, 2024
d459a50
Misc fixes
matthewlipski Apr 24, 2024
e11e2ee
Fixed unit tests
matthewlipski Apr 24, 2024
62df240
Fixed Mantine sub menus
matthewlipski Apr 24, 2024
28d4fc1
Misc UI fixes
matthewlipski Apr 24, 2024
1023c09
Misc changes
matthewlipski Apr 24, 2024
d655d32
fix import
YousefED Apr 24, 2024
05b8a96
fix tablehandles performance issue / max call stack
YousefED Apr 24, 2024
2e8998e
Fixed PW tests
matthewlipski Apr 25, 2024
1a9b28e
Merge remote-tracking branch 'origin/refactor/ui-libs-api-css' into r…
matthewlipski Apr 25, 2024
2c506ff
Small fix
matthewlipski Apr 25, 2024
661e555
Added ShadCN/Ariakit tests
matthewlipski Apr 26, 2024
8f74a30
fix draghandles
YousefED Apr 29, 2024
f5b2fac
Merge branch 'refactor/ui-libs-api-css' of github.com:TypeCellOS/Bloc…
YousefED Apr 29, 2024
85e8ae5
add vercel rewrites
YousefED Apr 29, 2024
dc2fded
improve shadcn setup
YousefED Apr 29, 2024
8c53a67
Fixed remaining Ariakit/ShadCN/Mantine styles
matthewlipski Apr 29, 2024
bc6470c
extract strings from react package
YousefED Apr 29, 2024
9b02851
Merge branch 'refactor/ui-libs-api-css' of github.com:TypeCellOS/Bloc…
YousefED Apr 29, 2024
e97bcc9
extract all strings
YousefED Apr 29, 2024
c442d2c
clean i18n setup
YousefED Apr 29, 2024
1f0a370
fix build
YousefED Apr 29, 2024
be5a021
Fixed dark mode for Ariakit/ShadCN
matthewlipski Apr 30, 2024
b55ab71
Misc fixes
matthewlipski Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
},
},
ignorePatterns: ["**/ui/*"],
rules: {
curly: 1,
"import/no-extraneous-dependencies": [
Expand Down
5 changes: 3 additions & 2 deletions docs/components/pages/landing/hero/DemoEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCallback, useMemo, useState } from "react";
import YPartyKitProvider from "y-partykit/provider";
import * as Y from "yjs";
Expand Down
3 changes: 3 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"dependencies": {
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"@headlessui/react": "^1.7.18",
"@mantine/core": "^7.5.0",
"@next/bundle-analyzer": "^14.1.0",
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Getting started with BlockNote is quick and easy. Install the required packages
To install BlockNote with [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), run:

```console
npm install @blocknote/core @blocknote/react
npm install @blocknote/core @blocknote/react @blocknote/mantine
```

## Creating an Editor
Expand All @@ -26,7 +26,7 @@ With the `useCreateBlockNote` hook, we can create a new editor instance, then us

<Example name="basic/minimal" />

We also import `@blocknote/react/style.css` to add default styling for the editor and the `Inter` font that BlockNote exports (optional).
We also import `@blocknote/mantine/style.css` to add default styling for the editor and the `Inter` font that BlockNote exports (optional).

<Callout type="warning" emoji={""}>
<strong>Next.js usage (or other server-side React frameworks)</strong>
Expand Down
10 changes: 2 additions & 8 deletions examples/01-basic/01-minimal/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import "@blocknote/core/fonts/inter.css";
import { useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "@blocknote/core";

import { BlockNoteView } from "@blocknote/mantine";
// import { BlockNoteView } from "@blocknote/ariakit";
// import { BlockNoteView } from "@blocknote/shadcn";
import "@blocknote/mantine/style.css";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY,
});
const editor = useCreateBlockNote();

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/01-minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
5 changes: 3 additions & 2 deletions examples/01-basic/02-block-objects/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Block } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useState } from "react";

import "./styles.css";
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/02-block-objects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
5 changes: 3 additions & 2 deletions examples/01-basic/03-all-blocks/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

export default function App() {
// Creates a new editor instance.
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/03-all-blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
5 changes: 3 additions & 2 deletions examples/01-basic/04-selection-blocks/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Block } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useState } from "react";

import "./styles.css";
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/04-selection-blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
5 changes: 3 additions & 2 deletions examples/01-basic/05-block-manipulation/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

import "./styles.css";

Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/05-block-manipulation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
5 changes: 3 additions & 2 deletions examples/01-basic/06-file-uploading/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

// Uploads a file to tmpfiles.org and returns the URL to the uploaded file.
async function uploadFile(file: File) {
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/06-file-uploading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/01-basic/07-saving-loading/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Block, BlockNoteEditor, PartialBlock } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/react";
import "@blocknote/react/style.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useEffect, useMemo, useState } from "react";

async function saveToStorage(jsonBlocks: Block[]) {
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/07-saving-loading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
14 changes: 12 additions & 2 deletions examples/01-basic/08-shadcn/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import "@blocknote/core/fonts/inter.css";
import { useCreateBlockNote } from "@blocknote/react";
import "@blocknote/react/style.css";
import { BlockNoteView } from "@blocknote/shadcn";
import "@blocknote/shadcn/style.css";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote();

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
return (
<BlockNoteView
editor={editor}
shadCNComponents={
{
// Pass modified ShadCN components from your project here.
// Otherwise, the default ShadCN components will be used.
}
}
/>
);
}
4 changes: 2 additions & 2 deletions examples/01-basic/08-shadcn/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic Setup TODO
# Use with ShadCN

This example shows the minimal code required to set up a BlockNote editor in React.
This example shows how you can integrate BlockNote with ShadCN, replacing the default Mantine UI with ShadCN components.

**Relevant Docs:**

Expand Down
2 changes: 1 addition & 1 deletion examples/01-basic/08-shadcn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Basic Setup TODO</title>
<title>Use with ShadCN</title>
</head>
<body>
<div id="root"></div>
Expand Down
7 changes: 5 additions & 2 deletions examples/01-basic/08-shadcn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.0",
"@blocknote/react": "^0.12.0",
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
6 changes: 6 additions & 0 deletions examples/01-basic/09-ariakit/.bnexample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"playground": true,
"docs": true,
"author": "matthewlipski",
"tags": ["Basic"]
}
12 changes: 12 additions & 0 deletions examples/01-basic/09-ariakit/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "@blocknote/core/fonts/inter.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/ariakit";
import "@blocknote/ariakit/style.css";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote();

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
}
7 changes: 7 additions & 0 deletions examples/01-basic/09-ariakit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Use with Ariakit

This example shows how you can integrate BlockNote with Ariakit, replacing the default Mantine UI with Ariakit components.

**Relevant Docs:**

- [Editor Setup](/docs/editor-basics/setup)
14 changes: 14 additions & 0 deletions examples/01-basic/09-ariakit/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html lang="en">
<head>
<script>
<!-- AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY -->
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Use with Ariakit</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";

import { Button } from "./components/ui/button";
import "./style.css";
const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<Button variant="ghost" size="icon">
{/* <Archive className="h-4 w-4" /> */}
hello
</Button>
<App />
</React.StrictMode>
);
37 changes: 37 additions & 0 deletions examples/01-basic/09-ariakit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@blocknote/example-ariakit",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"private": true,
"version": "0.12.0",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "^0.12.1",
"@blocknote/react": "^0.12.2",
"@blocknote/ariakit": "^0.12.2",
"@blocknote/mantine": "^0.12.2",
"@blocknote/shadcn": "^0.12.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.0.4",
"eslint": "^8.10.0",
"vite": "^4.4.8"
},
"eslintConfig": {
"extends": [
"../../../.eslintrc.js"
]
},
"eslintIgnore": [
"dist"
]
}
Loading
Loading