Skip to content

Commit c5bac19

Browse files
authored
Readme (#37)
* exclude history, make blockgroup lowercase * update readme * update title * update commands / readme * add badges * add collab gif * update snaps * update comment
1 parent 58509da commit c5bac19

37 files changed

+163
-72
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
- name: Install Dependencies
4444
run: npm install
4545

46-
- name: Bootstrap packages
47-
run: npm run bootstrap
46+
# - name: Bootstrap packages
47+
# run: npm run bootstrap
4848

4949
- name: Lint packages
5050
run: npm run lint

.resources/animations.gif

1.65 MB
Loading

.resources/collaboration.gif

1.03 MB
Loading

.resources/dragdrop.gif

572 KB
Loading

.resources/nesting.gif

966 KB
Loading

.resources/placeholders.gif

565 KB
Loading

.resources/selectmenu.gif

2.29 MB
Loading

.resources/slashmenu.gif

1.69 MB
Loading

README.md

+76-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,72 @@
11
# BlockNote
22

3-
Welcome to the BlockNote editor. Let's build a block based WYSIWYG editor with killer UX!
3+
<a href="https://discord.gg/aDQxXezfNj"><img alt="Discord" src="https://img.shields.io/badge/Chat on discord%20-%237289DA.svg?&style=for-the-badge&logo=discord&logoColor=white"/></a>
4+
5+
[![npm version](https://badge.fury.io/js/%blocknote%2Fcore.svg)](https://badge.fury.io/js/%blocknote%2Fcore)
6+
7+
**Welcome to BlockNote editor: a "Notion-style" block-based extensible text editor built on top of [Prosemirror](https://prosemirror.net/) and [Tiptap](https://tiptap.dev/).**
8+
9+
# Live demo
10+
11+
Play with the editor @ [https://blocknote-main.vercel.app/](https://blocknote-main.vercel.app/).
12+
13+
(Source in [examples/editor](/examples/editor))
14+
15+
# Example code (React)
16+
17+
```typescript
18+
import { EditorContent, useEditor } from "@blocknote/core";
19+
import "@blocknote/core/style.css";
20+
21+
function App() {
22+
const editor = useEditor({
23+
onUpdate: ({ editor }) => {
24+
// Log the document to console on every update
25+
console.log(editor.getJSON());
26+
},
27+
});
28+
29+
return <EditorContent editor={editor} />;
30+
}
31+
```
32+
33+
# Features
34+
35+
BlockNote comes with a number of features and components to make it easy to embed a high-quality block-based editor in your app:
36+
37+
### Animations:
38+
39+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/animations.gif?raw=true" width="400" />
40+
41+
### Helpful placeholders:
42+
43+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/placeholders.gif?raw=true" width="400" />
44+
![placeholders](.resources/placeholders.gif)
45+
46+
### Drag and drop blocks:
47+
48+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/dragdrop.gif?raw=true" width="400" />
49+
![dragdrop](.resources/dragdrop.gif)
50+
51+
### Nesting / indentation with tab and shift+tab:
52+
53+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/nesting.gif?raw=true" width="400" />
54+
55+
### Slash (/) menu:
56+
57+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/slashmenu.gif?raw=true" width="400" />
58+
59+
### Format menu:
60+
61+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/selectmenu.gif?raw=true" width="400" />
62+
63+
### Real-time collaboration:
64+
65+
<img src="https://github.com/YousefED/BlockNote/blob/readme/.resources/collaboration.gif?raw=true" width="400" />
66+
67+
# Contributing
68+
69+
Directory structure:
470

571
```
672
blocknote
@@ -9,27 +75,26 @@ blocknote
975
└── tests - Playwright end to end tests
1076
```
1177

12-
# Development
13-
14-
We use [Lerna](https://lerna.js.org/) to manage the monorepo with separate packages.
15-
1678
## Running
1779

1880
To run the project, open the command line in the project's root directory and enter the following commands:
1981

2082
# Install all required npm modules for lerna, and bootstrap lerna packages
2183
npm install
22-
npm run bootstrap
2384

24-
# Start the editor project
85+
# Start the example project
2586
npm start
2687

27-
## Updating packages
28-
29-
If you've pulled changes from git that add new or update existing dependencies, use `npm run bootstrap` instead of `npm install` to install updated dependencies!
30-
3188
## Adding packages
3289

3390
- Add the dependency to the relevant `package.json` file (packages/xxx/package.json)
3491
- run `npm run install-new-packages`
3592
- Double check `package-lock.json` to make sure only the relevant packages have been affected
93+
94+
# Credits ❤️
95+
96+
BlockNote builds directly on two awesome projects; [Prosemirror](https://prosemirror.net/) by Marijn Haverbeke and [Tiptap](https://tiptap.dev/). Consider sponsoring those libraries when using BlockNote: [Prosemirror](https://marijnhaverbeke.nl/fund/), [Tiptap](https://github.com/sponsors/ueberdosis).
97+
98+
BlockNote is built as part of [TypeCell](https://www.typecell.org). TypeCell is proudly sponsored by the renowned [NLNet foundation](https://nlnet.nl/foundation/) who are on a mission to support an open internet, and protect the privacy and security of internet users. Check them out!
99+
100+
<a href="https://nlnet.nl"><img src="https://nlnet.nl/image/logos/NGIAssure_tag.svg" alt="NLNet" width="100"></a>

examples/editor/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<!-- <link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> -->
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite App</title>
7+
<title>BlockNote demo</title>
88
</head>
99
<body>
1010
<div id="root"></div>

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
"bootstrap": "lerna bootstrap --ci -- --force && patch-package",
2121
"install-new-packages": "lerna bootstrap -- --force && patch-package",
2222
"playwright": "npx playwright test",
23-
"install-playwright": "npx playwright install --with-deps"
23+
"install-playwright": "npx playwright install --with-deps",
24+
"postinstall": "npm run bootstrap",
25+
"deploy": "lerna publish",
26+
"prepublishOnly": "npm run build && cp README.md packages/core/README.md",
27+
"postpublish": "rm -rf packages/core/README.md"
2428
},
2529
"overrides": {
2630
"react": "^17.0.2",

packages/core/README.md

-3
This file was deleted.

packages/core/package.json

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
{
22
"name": "@blocknote/core",
3-
"private": true,
4-
"version": "0.0.0",
3+
"private": false,
4+
"license": "MIT",
5+
"version": "0.0.1",
56
"files": [
6-
"dist"
7+
"dist",
8+
"types",
9+
"src"
710
],
11+
"keywords": [
12+
"react",
13+
"javascript",
14+
"editor",
15+
"typescript",
16+
"prosemirror",
17+
"wysiwyg",
18+
"rich-text-editor",
19+
"notion",
20+
"yjs",
21+
"block-based",
22+
"tiptap"
23+
],
24+
"description": "A \"Notion-style\" block-based extensible text editor built on top of Prosemirror and Tiptap.",
825
"type": "module",
926
"source": "src/index.ts",
1027
"types": "./types/src/index.d.ts",

packages/core/src/extensions/Blocks/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export const blocks: any[] = [
1010
Node.create({
1111
name: "doc",
1212
topNode: true,
13-
content: "blockGroup",
13+
content: "blockgroup",
1414
}),
1515
];

packages/core/src/extensions/Blocks/nodes/Block.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const Block = Node.create<IBlock>({
5252
},
5353

5454
// A block always contains content, and optionally a blockGroup which contains nested blocks
55-
content: "tccontent blockGroup?",
55+
content: "tccontent blockgroup?",
5656

5757
defining: true,
5858

packages/core/src/extensions/Blocks/nodes/BlockGroup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mergeAttributes, Node } from "@tiptap/core";
22
import styles from "./Block.module.css";
33

44
export const BlockGroup = Node.create({
5-
name: "blockGroup",
5+
name: "blockgroup",
66

77
addOptions() {
88
return {

packages/core/src/extensions/TrailingNode/TrailingNodeExtension.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Extension } from "@tiptap/core";
2-
import { PluginKey, Plugin } from "prosemirror-state";
2+
import { Plugin, PluginKey } from "prosemirror-state";
33

44
// based on https://github.com/ueberdosis/tiptap/blob/40a9404c94c7fef7900610c195536384781ae101/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts
55

@@ -52,8 +52,8 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
5252

5353
let lastNode = tr.doc.lastChild;
5454

55-
if (!lastNode || lastNode.type.name !== "blockGroup") {
56-
throw new Error("Expected blockGroup");
55+
if (!lastNode || lastNode.type.name !== "blockgroup") {
56+
throw new Error("Expected blockgroup");
5757
}
5858

5959
lastNode = lastNode.lastChild;

packages/core/src/extensions/UniqueID/UniqueID.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import { Plugin, PluginKey } from "prosemirror-state";
1010
import { v4 } from "uuid";
1111

1212
/**
13-
* Code from tiptap UniqueID extension
14-
* TODO: this is a pro extension, but with MIT license, discuss with TipTap
13+
* Code from Tiptap UniqueID extension (https://tiptap.dev/api/extensions/unique-id)
14+
* This extension is licensed under MIT (even though it's part of Tiptap pro).
15+
*
16+
* If you're a user of BlockNote, we still recommend to support their awesome work and become a sponsor!
17+
* https://tiptap.dev/pro
1518
*/
1619

1720
/**

packages/core/src/useEditor.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEditor as useEditorTiptap, EditorOptions } from "@tiptap/react";
1+
import { EditorOptions, useEditor as useEditorTiptap } from "@tiptap/react";
22

33
import { DependencyList } from "react";
44
import { getBlockNoteExtensions } from "./BlockNoteExtensions";
@@ -7,6 +7,7 @@ import rootStyles from "./root.module.css";
77

88
type BlockNoteEditorOptions = EditorOptions & {
99
enableBlockNoteExtensions: boolean;
10+
disableHistoryExtension: boolean;
1011
};
1112

1213
const blockNoteExtensions = getBlockNoteExtensions();
@@ -20,13 +21,17 @@ export const useEditor = (
2021
options: Partial<BlockNoteEditorOptions> = {},
2122
deps: DependencyList = []
2223
) => {
24+
const extensions = options.disableHistoryExtension
25+
? blockNoteExtensions.filter((e) => e.name !== "history")
26+
: blockNoteExtensions;
27+
2328
const tiptapOptions = {
2429
...blockNoteOptions,
2530
...options,
2631
extensions:
2732
options.enableBlockNoteExtensions === false
2833
? options.extensions
29-
: [...(options.extensions || []), ...blockNoteExtensions],
34+
: [...(options.extensions || []), ...extensions],
3035
editorProps: {
3136
attributes: {
3237
...(options.editorProps?.attributes || {}),

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/dragHandleDocStructure-chromium-darwin.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",
@@ -53,4 +53,4 @@
5353
]
5454
}
5555
]
56-
}
56+
}

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/dragHandleDocStructure-chromium-linux.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/dragHandleDocStructure-firefox-darwin.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",
@@ -53,4 +53,4 @@
5353
]
5454
}
5555
]
56-
}
56+
}

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/dragHandleDocStructure-firefox-linux.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/dragHandleDocStructure-webkit-darwin.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",
@@ -53,4 +53,4 @@
5353
]
5454
}
5555
]
56-
}
56+
}

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/dragHandleDocStructure-webkit-linux.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandleadd-chromium-darwin.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",
@@ -53,4 +53,4 @@
5353
]
5454
}
5555
]
56-
}
56+
}

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandleadd-chromium-linux.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",

tests/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandleadd-firefox-darwin.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "doc",
33
"content": [
44
{
5-
"type": "blockGroup",
5+
"type": "blockgroup",
66
"content": [
77
{
88
"type": "tcblock",
@@ -39,7 +39,7 @@
3939
]
4040
},
4141
{
42-
"type": "blockGroup",
42+
"type": "blockgroup",
4343
"content": [
4444
{
4545
"type": "tcblock",
@@ -68,4 +68,4 @@
6868
]
6969
}
7070
]
71-
}
71+
}

0 commit comments

Comments
 (0)