Skip to content

feat(tables): overhaul table cells #1429

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

Merged
merged 78 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
88889fb
feat: got the initial types working
nperez0111 Feb 12, 2025
9c7fa17
fix: resolve dragging
nperez0111 Feb 12, 2025
21b4de1
feat: getting somewhere
nperez0111 Feb 12, 2025
4c55225
fix: remove tableCell from blocks
nperez0111 Feb 13, 2025
0ae7cf8
fix: use table-cell
nperez0111 Feb 13, 2025
cb36ad3
feat: support for merging & splitting cells
nperez0111 Feb 17, 2025
fb05167
fix: only show split button when it can be split
nperez0111 Feb 17, 2025
26f57cf
refactor: better typing for table ops
nperez0111 Feb 17, 2025
ae9da58
feat: allow text align buttons to work on table cell content
nperez0111 Feb 17, 2025
951252c
feat: support table header rows & cols
nperez0111 Feb 18, 2025
539d8bc
fix: disallow dragging columns with rowspans or colspans more than 1
nperez0111 Feb 18, 2025
f3f88a1
refactor: add getColspan and getRowspan helpers
nperez0111 Feb 18, 2025
895f4f4
fix: better handling of dragging to be row and colspan aware
nperez0111 Feb 18, 2025
f2625e0
refactor: resolve columnWidth preservation
nperez0111 Feb 18, 2025
97e02fa
fix: filter out nulls
nperez0111 Feb 18, 2025
c60560c
fix: accessing undefined
nperez0111 Feb 18, 2025
3a590ba
fix: when re-ordering columns, re-order column widths too
nperez0111 Feb 18, 2025
288bfee
Merge branch 'main' into tables
nperez0111 Feb 18, 2025
580d3bf
fix: add translations and build fixes
nperez0111 Feb 18, 2025
d4e8afe
test: make columnWidths only be an array of undefined again
nperez0111 Feb 18, 2025
eee7b08
fix: use undefined
nperez0111 Feb 19, 2025
87e3efb
fix: rm unused var
nperez0111 Feb 19, 2025
f1c4ad1
refactor: minor cleanup
nperez0111 Feb 19, 2025
e2506e2
docs: better describe & expose table relative vs absolute positioning
nperez0111 Feb 19, 2025
c9a6f4e
refactor: mark undefined instead
nperez0111 Feb 19, 2025
77f3e5f
refactor: cleanup
nperez0111 Feb 19, 2025
290b43c
refactor: cleanup
nperez0111 Feb 19, 2025
9092fdd
refactor: update the names to be much clearer
nperez0111 Feb 20, 2025
74345df
refactor: add a break
nperez0111 Feb 20, 2025
e2fb498
refactor: simplify table cell selections
nperez0111 Feb 20, 2025
9a34984
refactor: use isTableCell check
nperez0111 Feb 20, 2025
3413fca
test: add tests to headers, rowspans and colspan
nperez0111 Feb 20, 2025
db490a8
fix: switch to dropdown arrow
nperez0111 Feb 20, 2025
55617d3
refactor: clean up color picker
nperez0111 Feb 20, 2025
0bcd5a2
feat: leverage prosemirror-tables for adding/deleting columns & rows
nperez0111 Feb 20, 2025
710d2e5
fix: handle extending table errors
nperez0111 Feb 21, 2025
b050510
fix(table): better handling of the dropzone for dragging rows and col…
nperez0111 Feb 21, 2025
b3c08c2
feat: dragging columns and rows now stably works
nperez0111 Feb 21, 2025
2111f2f
fix: get build running again
nperez0111 Feb 21, 2025
33941a3
fix(table): drop cursors for table row & col re-ordering works again
nperez0111 Feb 21, 2025
21da581
fix: do not output a columnWidth if not defined
nperez0111 Feb 21, 2025
5d406dd
refactor: use the cells or rows in the table to decide which decos to…
nperez0111 Feb 21, 2025
a698036
fix: make extend buttons more robust and colspan rowspan aware
nperez0111 Feb 21, 2025
c6af87e
fix: minor bug fix
nperez0111 Feb 21, 2025
2365d46
fix(table): extending an empty table's columns needs at least 1 cell
nperez0111 Feb 24, 2025
e164fad
refactor: minor cleanup
nperez0111 Feb 24, 2025
cc7e699
fix(tables): better handling of the expand table buttons
nperez0111 Feb 26, 2025
d43dbeb
refactor: rename internal fns
nperez0111 Feb 26, 2025
1c333d1
refactor(tables): move the canColumnBeDraggedInto logic and clarify m…
nperez0111 Feb 26, 2025
f0695b5
refactor: clearer bounds checking
nperez0111 Feb 26, 2025
244410a
fix: unused import
nperez0111 Feb 26, 2025
00a3bdb
refactor: do not expose absolute positioning
nperez0111 Feb 26, 2025
4ab7a72
fix: return an empty array if out of bounds
nperez0111 Feb 26, 2025
ce3675d
fix(tables): fix a bug with block content being out of date when appl…
nperez0111 Feb 26, 2025
c37917e
chore: fix build
nperez0111 Feb 26, 2025
55ce7df
feat: implement table cell handle button
nperez0111 Feb 26, 2025
4420d09
fix: move button cursor style
nperez0111 Feb 26, 2025
95bd4b3
fix(table): table cell merging (#1446)
nperez0111 Feb 26, 2025
bc5153a
fix: handle edge case of colspan or rowspan on an empty row
nperez0111 Feb 26, 2025
10dcb5c
fix(table): table cell merging (#1446)
nperez0111 Feb 26, 2025
10d3bc5
docs: minor comment of explanation
nperez0111 Feb 27, 2025
26f90c7
refactor: move table helpers to utils folder
nperez0111 Feb 27, 2025
a831781
style: switch cursors
nperez0111 Feb 27, 2025
31408ea
feat: allow toggling the header row/col via the table row/col handle …
nperez0111 Feb 27, 2025
66ad01c
refactor: rename tablecellhandle to TableCellButton
nperez0111 Feb 27, 2025
7fe3824
refactor: rename to menubutton
nperez0111 Feb 27, 2025
df2b218
fix: pdf transformer for table cells
nperez0111 Feb 27, 2025
77117a5
fix: allow table blocks to be dragged around
nperez0111 Feb 27, 2025
4c2c79b
Merge branch 'main' into tables
nperez0111 Feb 27, 2025
2644e84
Merge branch 'main' into tables
nperez0111 Feb 28, 2025
5bc695c
Merge branch 'main' into tables
matthewlipski Feb 28, 2025
a767959
Fixed ShadCN checked menu item styles
matthewlipski Feb 28, 2025
e6ded9d
fix: tableHeader text alignment
nperez0111 Feb 28, 2025
6b3438e
fix: rename dir
nperez0111 Feb 28, 2025
52cd035
feat(tables): add the ability to enable/disable table features (#1470)
nperez0111 Feb 28, 2025
7eb0fd2
Merge branch 'main' into tables
nperez0111 Feb 28, 2025
a46113b
chore: add back translation
nperez0111 Feb 28, 2025
1aa2c86
Merge branch 'main' into tables
nperez0111 Feb 28, 2025
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
6 changes: 6 additions & 0 deletions examples/03-ui-components/15-advanced-tables/.bnexample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"playground": true,
"docs": true,
"author": "nperez0111",
"tags": ["Intermediate", "UI Components", "Tables", "Appearance & Styling"]
}
305 changes: 305 additions & 0 deletions examples/03-ui-components/15-advanced-tables/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
// This enables the advanced table features
tables: {
splitCells: true,
cellBackgroundColor: true,
cellTextColor: true,
headers: true,
},
initialContent: [
{
id: "7e498b3d-d42e-4ade-9be0-054b292715ea",
type: "heading",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
level: 2,
},
content: [
{
type: "text",
text: "Advanced Tables",
styles: {},
},
],
children: [],
},
{
id: "cbf287c6-770b-413a-bff5-ad490a0b562a",
type: "table",
props: {
textColor: "default",
},
content: {
type: "tableContent",
columnWidths: [199, 148, 201],
headerRows: 1,
rows: [
{
cells: [
{
type: "tableCell",
content: [
{
type: "text",
text: "This row has headers",
styles: {},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "default",
textColor: "default",
textAlignment: "center",
},
},
{
type: "tableCell",
content: [
{
type: "text",
text: "This is ",
styles: {},
},
{
type: "text",
text: "RED",
styles: {
bold: true,
},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "red",
textColor: "default",
textAlignment: "center",
},
},
{
type: "tableCell",
content: [
{
type: "text",
text: "Text is Blue",
styles: {},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "default",
textColor: "blue",
textAlignment: "center",
},
},
],
},
{
cells: [
{
type: "tableCell",
content: [
{
type: "text",
text: "This spans 2 columns\nand 2 rows",
styles: {},
},
],
props: {
colspan: 2,
rowspan: 2,
backgroundColor: "yellow",
textColor: "default",
textAlignment: "left",
},
},
{
type: "tableCell",
content: [
{
type: "text",
text: "Sooo many features",
styles: {},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "gray",
textColor: "default",
textAlignment: "left",
},
},
],
},
{
cells: [
{
type: "tableCell",
content: [],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "gray",
textColor: "purple",
textAlignment: "left",
},
},
],
},
{
cells: [
{
type: "tableCell",
content: [
{
type: "text",
text: "A cell",
styles: {},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "default",
textColor: "default",
textAlignment: "left",
},
},
{
type: "tableCell",
content: [
{
type: "text",
text: "Another Cell",
styles: {},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "default",
textColor: "default",
textAlignment: "right",
},
},
{
type: "tableCell",
content: [
{
type: "text",
text: "Aligned center",
styles: {},
},
],
props: {
colspan: 1,
rowspan: 1,
backgroundColor: "default",
textColor: "default",
textAlignment: "center",
},
},
],
},
],
},
children: [],
},
{
id: "16e76a94-74e5-42e2-b461-fc9da9f381f7",
type: "paragraph",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [
{
type: "text",
text: "Featuring:",
styles: {},
},
],
children: [
{
id: "785fc9f7-8554-47f4-a4df-8fe2f1438cac",
type: "bulletListItem",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [
{
type: "text",
text: "Cell background & foreground coloring",
styles: {},
},
],
children: [],
},
{
id: "1d0adf08-1b42-421a-b9ea-b3125dcc96d9",
type: "bulletListItem",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [
{
type: "text",
text: "Splitting & merging cells",
styles: {},
},
],
children: [],
},
{
id: "99991aa7-9d86-4d06-9073-b1a9c0329062",
type: "bulletListItem",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [
{
type: "text",
text: "Header row & column",
styles: {},
},
],
children: [],
},
],
},
{
id: "c7bf2a7c-8972-44f1-acd8-cf60fa734068",
type: "paragraph",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [],
children: [],
},
],
});

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor}></BlockNoteView>;
}
13 changes: 13 additions & 0 deletions examples/03-ui-components/15-advanced-tables/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Advanced Tables

This example enables the following features in tables:

- Split cells
- Cell background color
- Cell text color
- Table row and column headers

**Relevant Docs:**

- [Tables](/docs/editor-basics/tables)
- [Editor Setup](/docs/editor-basics/setup)
14 changes: 14 additions & 0 deletions examples/03-ui-components/15-advanced-tables/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>Advanced Tables</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/03-ui-components/15-advanced-tables/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";

const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
37 changes: 37 additions & 0 deletions examples/03-ui-components/15-advanced-tables/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@blocknote/example-advanced-tables",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"private": true,
"version": "0.12.4",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint . --max-warnings 0"
},
"dependencies": {
"@blocknote/core": "latest",
"@blocknote/react": "latest",
"@blocknote/ariakit": "latest",
"@blocknote/mantine": "latest",
"@blocknote/shadcn": "latest",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^8.10.0",
"vite": "^5.3.4"
},
"eslintConfig": {
"extends": [
"../../../.eslintrc.js"
]
},
"eslintIgnore": [
"dist"
]
}
Loading
Loading