diff --git a/examples/03-ui-components/15-advanced-tables/.bnexample.json b/examples/03-ui-components/15-advanced-tables/.bnexample.json
new file mode 100644
index 0000000000..9c4787320e
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/.bnexample.json
@@ -0,0 +1,6 @@
+{
+ "playground": true,
+ "docs": true,
+ "author": "nperez0111",
+ "tags": ["Intermediate", "UI Components", "Tables", "Appearance & Styling"]
+}
diff --git a/examples/03-ui-components/15-advanced-tables/App.tsx b/examples/03-ui-components/15-advanced-tables/App.tsx
new file mode 100644
index 0000000000..dfe89812a9
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/App.tsx
@@ -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 ;
+}
diff --git a/examples/03-ui-components/15-advanced-tables/README.md b/examples/03-ui-components/15-advanced-tables/README.md
new file mode 100644
index 0000000000..0eb9e78c32
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/README.md
@@ -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)
diff --git a/examples/03-ui-components/15-advanced-tables/index.html b/examples/03-ui-components/15-advanced-tables/index.html
new file mode 100644
index 0000000000..b4bd86e618
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Advanced Tables
+
+
+
+
+
+
diff --git a/examples/03-ui-components/15-advanced-tables/main.tsx b/examples/03-ui-components/15-advanced-tables/main.tsx
new file mode 100644
index 0000000000..f88b490fbd
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/main.tsx
@@ -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(
+
+
+
+);
diff --git a/examples/03-ui-components/15-advanced-tables/package.json b/examples/03-ui-components/15-advanced-tables/package.json
new file mode 100644
index 0000000000..9d7b623424
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/package.json
@@ -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"
+ ]
+}
\ No newline at end of file
diff --git a/examples/03-ui-components/15-advanced-tables/tsconfig.json b/examples/03-ui-components/15-advanced-tables/tsconfig.json
new file mode 100644
index 0000000000..1bd8ab3c57
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/tsconfig.json
@@ -0,0 +1,36 @@
+{
+ "__comment": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
+ "compilerOptions": {
+ "target": "ESNext",
+ "useDefineForClassFields": true,
+ "lib": [
+ "DOM",
+ "DOM.Iterable",
+ "ESNext"
+ ],
+ "allowJs": false,
+ "skipLibCheck": true,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true,
+ "forceConsistentCasingInFileNames": true,
+ "module": "ESNext",
+ "moduleResolution": "Node",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "composite": true
+ },
+ "include": [
+ "."
+ ],
+ "__ADD_FOR_LOCAL_DEV_references": [
+ {
+ "path": "../../../packages/core/"
+ },
+ {
+ "path": "../../../packages/react/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/examples/03-ui-components/15-advanced-tables/vite.config.ts b/examples/03-ui-components/15-advanced-tables/vite.config.ts
new file mode 100644
index 0000000000..f62ab20bc2
--- /dev/null
+++ b/examples/03-ui-components/15-advanced-tables/vite.config.ts
@@ -0,0 +1,32 @@
+// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
+import react from "@vitejs/plugin-react";
+import * as fs from "fs";
+import * as path from "path";
+import { defineConfig } from "vite";
+// import eslintPlugin from "vite-plugin-eslint";
+// https://vitejs.dev/config/
+export default defineConfig((conf) => ({
+ plugins: [react()],
+ optimizeDeps: {},
+ build: {
+ sourcemap: true,
+ },
+ resolve: {
+ alias:
+ conf.command === "build" ||
+ !fs.existsSync(path.resolve(__dirname, "../../packages/core/src"))
+ ? {}
+ : ({
+ // Comment out the lines below to load a built version of blocknote
+ // or, keep as is to load live from sources with live reload working
+ "@blocknote/core": path.resolve(
+ __dirname,
+ "../../packages/core/src/"
+ ),
+ "@blocknote/react": path.resolve(
+ __dirname,
+ "../../packages/react/src/"
+ ),
+ } as any),
+ },
+}));
diff --git a/package-lock.json b/package-lock.json
index 870cf7bdcf..479d99616b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9794,9 +9794,9 @@
}
},
"node_modules/@tiptap/core": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.7.1.tgz",
- "integrity": "sha512-/sOJ3J2OWxQrho6MWgE9xaRBln5MC4BEuevTYIGia4zrc523lX9s+h/lUeLtCPhI0+J6z9Vz+v3G/uoEqWCL+A==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.11.5.tgz",
+ "integrity": "sha512-jb0KTdUJaJY53JaN7ooY3XAxHQNoMYti/H6ANo707PsLXVeEqJ9o8+eBup1JU5CuwzrgnDc2dECt2WIGX9f8Jw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9806,9 +9806,9 @@
}
},
"node_modules/@tiptap/extension-bold": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-2.7.1.tgz",
- "integrity": "sha512-k03srawDKtS8P4w2TKv59MzgvZoKGssTGqvOF1YDxArriB2pK3jz6i4jbGs79qRlyGyWFSCEkpF9amFrCajlIw==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-2.11.5.tgz",
+ "integrity": "sha512-OAq03MHEbl7MtYCUzGuwb0VpOPnM0k5ekMbEaRILFU5ZC7cEAQ36XmPIw1dQayrcuE8GZL35BKub2qtRxyC9iA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9834,9 +9834,9 @@
}
},
"node_modules/@tiptap/extension-code": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-2.7.1.tgz",
- "integrity": "sha512-VC9/AzIyfIKaxvTW1hIJUc373IY3D5Z3ykODPaNqplrvqonwULxrciLLh+GcCAwTjH8XnJtc66IaM9VDYxrSTw==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-2.11.5.tgz",
+ "integrity": "sha512-xOvHevNIQIcCCVn9tpvXa1wBp0wHN/2umbAZGTVzS+AQtM7BTo0tz8IyzwxkcZJaImONcUVYLOLzt2AgW1LltA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9846,9 +9846,9 @@
}
},
"node_modules/@tiptap/extension-collaboration": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-collaboration/-/extension-collaboration-2.7.1.tgz",
- "integrity": "sha512-u6eDKDuzJ9Fd9ZPul7wAnSzqaq+ovRaVsDRYrNDYUYT2QlbWJtI8HKE/5Mt1Ml0Xnpwn3UcLwJdo0iN4/A4IOQ==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-collaboration/-/extension-collaboration-2.11.5.tgz",
+ "integrity": "sha512-3tMMq0E+FM3/3YBUMq5rLvks2DC/t1XLH2Kz/VcuVCxqg1Zg5s9nKOl6CcUZ8gbdvZoEd/GYoQyROJ957v9wzw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9860,9 +9860,9 @@
}
},
"node_modules/@tiptap/extension-collaboration-cursor": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-collaboration-cursor/-/extension-collaboration-cursor-2.7.1.tgz",
- "integrity": "sha512-aYVuztLFTFfoh+bQMQV+f/+iTrq6L99YJF+TRW4CfnD6gsThX3fk4tbGXWVoE8Zd6SQMAjote4TZZBwGbANtdg==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-collaboration-cursor/-/extension-collaboration-cursor-2.11.5.tgz",
+ "integrity": "sha512-sazBzi5HCHgGRihSzWHhHFMSI9oU0v/qqiDZYJ/zhzCKEWONx8WlS6WTxo6z3l6/Qz9lm7clmHNUQNWxnssAOA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9889,9 +9889,9 @@
}
},
"node_modules/@tiptap/extension-gapcursor": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-2.7.1.tgz",
- "integrity": "sha512-oSfir7KRnnZ46PsZrSpgpSYr+0zYmIvwL0HhCzaUg8a44ISg730MhrD0jZibQ/+AWatLVHx8Pcd/eHm/R9+rXA==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-2.11.5.tgz",
+ "integrity": "sha512-kcWa+Xq9cb6lBdiICvLReuDtz/rLjFKHWpW3jTTF3FiP3wx4H8Rs6bzVtty7uOVTfwupxZRiKICAMEU6iT0xrQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9902,9 +9902,9 @@
}
},
"node_modules/@tiptap/extension-hard-break": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-2.7.1.tgz",
- "integrity": "sha512-zy7lK2d0tu6BagzqkBwp2cIXM2t/QbHiKap1roj9B+QafsF9Im9p92bEK6fJEw+qC/j0PucR668MYsfUU7d2gQ==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-2.11.5.tgz",
+ "integrity": "sha512-q9doeN+Yg9F5QNTG8pZGYfNye3tmntOwch683v0CCVCI4ldKaLZ0jG3NbBTq+mosHYdgOH2rNbIORlRRsQ+iYQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9914,9 +9914,9 @@
}
},
"node_modules/@tiptap/extension-history": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-history/-/extension-history-2.7.1.tgz",
- "integrity": "sha512-cQrnZxqdFykGllQ4icivEw1IwCm9s8cB/nVqJj09Sl8VyR28PuOVJUDBXfD81c3id+R152hoCEgZmzwkBmNrHQ==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-history/-/extension-history-2.11.5.tgz",
+ "integrity": "sha512-b+wOS33Dz1azw6F1i9LFTEIJ/gUui0Jwz5ZvmVDpL2ZHBhq1Ui0/spTT+tuZOXq7Y/uCbKL8Liu4WoedIvhboQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9927,9 +9927,9 @@
}
},
"node_modules/@tiptap/extension-horizontal-rule": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-2.7.1.tgz",
- "integrity": "sha512-6MAUp5gahrKk0jIHJOgmcfmuscU/UU+7zyTUqTWPI6lll1Wu2HYQPzQKlFT3L8QAE+XXj7vlY9vMFMleGsw1Eg==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-2.11.5.tgz",
+ "integrity": "sha512-3up2r1Du8/5/4ZYzTC0DjTwhgPI3dn8jhOCLu73m5F3OGvK/9whcXoeWoX103hYMnGDxBlfOje71yQuN35FL4A==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9940,9 +9940,9 @@
}
},
"node_modules/@tiptap/extension-italic": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-2.7.1.tgz",
- "integrity": "sha512-xH8X63C3ewEpN53qdV1UsdkeQA6/srOtuwGf0rLhiYI4whg02WQTQ2A66VEuRk1kPTkpu8nmD3bf9OvvlPqE0Q==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-2.11.5.tgz",
+ "integrity": "sha512-9VGfb2/LfPhQ6TjzDwuYLRvw0A6VGbaIp3F+5Mql8XVdTBHb2+rhELbyhNGiGVR78CaB/EiKb6dO9xu/tBWSYA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9952,11 +9952,11 @@
}
},
"node_modules/@tiptap/extension-link": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-2.7.1.tgz",
- "integrity": "sha512-CoM43k2xDVN+SaDctuFNf/ELox1hCizAXnyt4oEMXpEfOZCQ4BjwKYBior0LxClg6vEvO0n8KzhS9LAAVZHS8Q==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-2.11.5.tgz",
+ "integrity": "sha512-4Iu/aPzevbYpe50xDI0ZkqRa6nkZ9eF270Ue2qaF3Ab47nehj+9Jl78XXzo8+LTyFMnrETI73TAs1aC/IGySeQ==",
"dependencies": {
- "linkifyjs": "^4.1.0"
+ "linkifyjs": "^4.2.0"
},
"funding": {
"type": "github",
@@ -9968,9 +9968,9 @@
}
},
"node_modules/@tiptap/extension-paragraph": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-2.7.1.tgz",
- "integrity": "sha512-qMZvyadhzKCQ5oqpeh9AwJnHgaH8T8NYu+cQUT27EPGSzsvLjVq1CdgMpmh5WRvwVpi7GtelHfokle/nenH14w==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-2.11.5.tgz",
+ "integrity": "sha512-YFBWeg7xu/sBnsDIF/+nh9Arf7R0h07VZMd0id5Ydd2Qe3c1uIZwXxeINVtH0SZozuPIQFAT8ICe9M0RxmE+TA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9980,9 +9980,9 @@
}
},
"node_modules/@tiptap/extension-strike": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-2.7.1.tgz",
- "integrity": "sha512-NF9z/7suQ+vg+a6HmbCk5yWPxuue68D1fy/T/fkcoqLHO+gGtp0CvmZfJK5eBDFWrfHsSVzr/YNNZktcW4ApPg==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-2.11.5.tgz",
+ "integrity": "sha512-PVfUiCqrjvsLpbIoVlegSY8RlkR64F1Rr2RYmiybQfGbg+AkSZXDeO0eIrc03//4gua7D9DfIozHmAKv1KN3ow==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -9992,9 +9992,9 @@
}
},
"node_modules/@tiptap/extension-table-cell": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-table-cell/-/extension-table-cell-2.7.1.tgz",
- "integrity": "sha512-nEkCnQcdgtmPrOSMGM+g/Qvmy3dkSKxlFvnwgqZOlDTE3eYfNZCWu6pYchuy4wkTmEGnesZtO2ngHipJKnhKHw==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-table-cell/-/extension-table-cell-2.11.5.tgz",
+ "integrity": "sha512-S967Au0pgeULstP3FaasOf/LEh72p61Ooh1PcUMF/az4x8EeGgpcEUARpVUxsGxLFvogv6LmhPHZdtcGgdHcBw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -10004,9 +10004,9 @@
}
},
"node_modules/@tiptap/extension-table-header": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-table-header/-/extension-table-header-2.7.1.tgz",
- "integrity": "sha512-KKFMk1kXGpGZDshK17hEMu4HSAfw/Ux31mfIaKfuL9QJJ/J5Fd/Lnatz9SCfVzGnFFa1JO+qelCw+/uRbcsAMg==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-table-header/-/extension-table-header-2.11.5.tgz",
+ "integrity": "sha512-O1iBtzZP1XZDi4h1Xmgq1T63il+fpKPvBIMZ0JJH9TyCw5i5rcrMLL2dyy5zaWK3BFRJuYBNSke4c+VWnr/g6w==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -10016,9 +10016,9 @@
}
},
"node_modules/@tiptap/extension-table-row": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-table-row/-/extension-table-row-2.7.1.tgz",
- "integrity": "sha512-nUMvMtRCSCV1w5AJVcRE1+/MiK/sdM3ZiR3x+plOo6m24+DRlETg8AN5ierOvWoObb56apl5onk8A75/ZRPlAg==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-table-row/-/extension-table-row-2.11.5.tgz",
+ "integrity": "sha512-+/VWhCuW24BcM5aaIc/f0bC6ZR1Q5gnuqw13MIo7gyPx7iIY6BXK8roGiZSs8wYAN4uBEf3EKFm0bSZwQuAeyg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -10028,9 +10028,9 @@
}
},
"node_modules/@tiptap/extension-text": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-2.7.1.tgz",
- "integrity": "sha512-4VsX661judEpjzFokTDe1ZBI/6tJxvPeo2qZ4gFMUOH133sgEtMPwx0KtUi1uDtXjxa3G5w5Frdu8SNTB048sA==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-2.11.5.tgz",
+ "integrity": "sha512-Gq1WwyhFpCbEDrLPIHt5A8aLSlf8bfz4jm417c8F/JyU0J5dtYdmx0RAxjnLw1i7ZHE7LRyqqAoS0sl7JHDNSQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -10040,9 +10040,9 @@
}
},
"node_modules/@tiptap/extension-underline": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-2.7.1.tgz",
- "integrity": "sha512-J5LH1DsHNke4f1nnY0x0O3vdGIKgawhhDsVkp6PncCBN+Q/ZQP+q8elaCsLXd4WpqTdkN4LKV7Kf2fALgLoG4g==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-2.11.5.tgz",
+ "integrity": "sha512-YpWHXNIkSoRSuzT2cvgKpyJ2tTz3LzqkTM64uC+uTJ8cUkvXIWUWejJR42q8ma/mTlQe4lHff4IQ0Sf58Digtw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -10052,28 +10052,28 @@
}
},
"node_modules/@tiptap/pm": {
- "version": "2.7.1",
- "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-2.7.1.tgz",
- "integrity": "sha512-gG++eBQu9SObWCmxZDv6tkwFHVmbg7phowy0F7Nihq9Um7/oae5Ag9skfiG8GG9eYdw54paEAY/MP+tE3x/smA==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-2.11.5.tgz",
+ "integrity": "sha512-z9JFtqc5ZOsdQLd9vRnXfTCQ8v5ADAfRt9Nm7SqP6FUHII8E1hs38ACzf5xursmth/VonJYb5+73Pqxk1hGIPw==",
"dependencies": {
"prosemirror-changeset": "^2.2.1",
"prosemirror-collab": "^1.3.1",
- "prosemirror-commands": "^1.6.0",
+ "prosemirror-commands": "^1.6.2",
"prosemirror-dropcursor": "^1.8.1",
"prosemirror-gapcursor": "^1.3.2",
"prosemirror-history": "^1.4.1",
"prosemirror-inputrules": "^1.4.0",
"prosemirror-keymap": "^1.2.2",
- "prosemirror-markdown": "^1.13.0",
+ "prosemirror-markdown": "^1.13.1",
"prosemirror-menu": "^1.2.4",
- "prosemirror-model": "^1.22.3",
+ "prosemirror-model": "^1.23.0",
"prosemirror-schema-basic": "^1.2.3",
"prosemirror-schema-list": "^1.4.1",
"prosemirror-state": "^1.4.3",
- "prosemirror-tables": "^1.4.0",
+ "prosemirror-tables": "^1.6.3",
"prosemirror-trailing-node": "^3.0.0",
- "prosemirror-transform": "^1.10.0",
- "prosemirror-view": "^1.33.10"
+ "prosemirror-transform": "^1.10.2",
+ "prosemirror-view": "^1.37.0"
},
"funding": {
"type": "github",
@@ -10351,6 +10351,11 @@
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz",
"integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ=="
},
+ "node_modules/@types/linkify-it": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz",
+ "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="
+ },
"node_modules/@types/lodash": {
"version": "4.17.5",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.5.tgz",
@@ -10384,6 +10389,15 @@
"@types/lodash": "*"
}
},
+ "node_modules/@types/markdown-it": {
+ "version": "14.1.2",
+ "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz",
+ "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==",
+ "dependencies": {
+ "@types/linkify-it": "^5",
+ "@types/mdurl": "^2"
+ }
+ },
"node_modules/@types/mdast": {
"version": "3.0.15",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.15.tgz",
@@ -10392,6 +10406,11 @@
"@types/unist": "^2"
}
},
+ "node_modules/@types/mdurl": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz",
+ "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg=="
+ },
"node_modules/@types/mdx": {
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.13.tgz",
@@ -19623,9 +19642,9 @@
}
},
"node_modules/linkifyjs": {
- "version": "4.1.3",
- "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.3.tgz",
- "integrity": "sha512-auMesunaJ8yfkHvK4gfg1K0SaKX/6Wn9g2Aac/NwX+l5VdmFZzo/hdPGxEOETj+ryRa4/fiOPjeeKURSAJx1sg=="
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.2.0.tgz",
+ "integrity": "sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw=="
},
"node_modules/load-json-file": {
"version": "6.2.0",
@@ -24823,13 +24842,13 @@
}
},
"node_modules/prosemirror-commands": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.6.0.tgz",
- "integrity": "sha512-xn1U/g36OqXn2tn5nGmvnnimAj/g1pUx2ypJJIe8WkVX83WyJVC5LTARaxZa2AtQRwntu9Jc5zXs9gL9svp/mg==",
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.6.2.tgz",
+ "integrity": "sha512-0nDHH++qcf/BuPLYvmqZTUUsPJUCPBUXt0J1ErTcDIS369CTp773itzLGIgIXG4LJXOlwYCr44+Mh4ii6MP1QA==",
"dependencies": {
"prosemirror-model": "^1.0.0",
"prosemirror-state": "^1.0.0",
- "prosemirror-transform": "^1.0.0"
+ "prosemirror-transform": "^1.10.2"
}
},
"node_modules/prosemirror-dropcursor": {
@@ -24883,10 +24902,11 @@
}
},
"node_modules/prosemirror-markdown": {
- "version": "1.13.0",
- "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.0.tgz",
- "integrity": "sha512-UziddX3ZYSYibgx8042hfGKmukq5Aljp2qoBiJRejD/8MH70siQNz5RB1TrdTPheqLMy4aCe4GYNF10/3lQS5g==",
+ "version": "1.13.1",
+ "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.1.tgz",
+ "integrity": "sha512-Sl+oMfMtAjWtlcZoj/5L/Q39MpEnVZ840Xo330WJWUvgyhNmLBLN7MsHn07s53nG/KImevWHSE6fEj4q/GihHw==",
"dependencies": {
+ "@types/markdown-it": "^14.0.0",
"markdown-it": "^14.0.0",
"prosemirror-model": "^1.20.0"
}
@@ -24903,9 +24923,9 @@
}
},
"node_modules/prosemirror-model": {
- "version": "1.23.0",
- "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.23.0.tgz",
- "integrity": "sha512-Q/fgsgl/dlOAW9ILu4OOhYWQbc7TQd4BwKH/RwmUjyVf8682Be4zj3rOYdLnYEcGzyg8LL9Q5IWYKD8tdToreQ==",
+ "version": "1.24.1",
+ "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.24.1.tgz",
+ "integrity": "sha512-YM053N+vTThzlWJ/AtPtF1j0ebO36nvbmDy4U7qA2XQB8JVaQp1FmB9Jhrps8s+z+uxhhVTny4m20ptUvhk0Mg==",
"dependencies": {
"orderedmap": "^2.0.0"
}
@@ -24939,15 +24959,15 @@
}
},
"node_modules/prosemirror-tables": {
- "version": "1.6.1",
- "resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.6.1.tgz",
- "integrity": "sha512-p8WRJNA96jaNQjhJolmbxTzd6M4huRE5xQ8OxjvMhQUP0Nzpo4zz6TztEiwk6aoqGBhz9lxRWR1yRZLlpQN98w==",
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.6.4.tgz",
+ "integrity": "sha512-TkDY3Gw52gRFRfRn2f4wJv5WOgAOXLJA2CQJYIJ5+kdFbfj3acR4JUW6LX2e1hiEBiUwvEhzH5a3cZ5YSztpIA==",
"dependencies": {
- "prosemirror-keymap": "^1.1.2",
- "prosemirror-model": "^1.8.1",
- "prosemirror-state": "^1.3.1",
- "prosemirror-transform": "^1.2.1",
- "prosemirror-view": "^1.13.3"
+ "prosemirror-keymap": "^1.2.2",
+ "prosemirror-model": "^1.24.1",
+ "prosemirror-state": "^1.4.3",
+ "prosemirror-transform": "^1.10.2",
+ "prosemirror-view": "^1.37.2"
}
},
"node_modules/prosemirror-trailing-node": {
@@ -30351,32 +30371,32 @@
"license": "MPL-2.0",
"dependencies": {
"@emoji-mart/data": "^1.2.1",
- "@tiptap/core": "^2.7.1",
- "@tiptap/extension-bold": "^2.7.1",
- "@tiptap/extension-code": "^2.7.1",
- "@tiptap/extension-collaboration": "^2.7.1",
- "@tiptap/extension-collaboration-cursor": "^2.7.1",
- "@tiptap/extension-gapcursor": "^2.7.1",
- "@tiptap/extension-hard-break": "^2.7.1",
- "@tiptap/extension-history": "^2.7.1",
- "@tiptap/extension-horizontal-rule": "^2.7.1",
- "@tiptap/extension-italic": "^2.7.1",
- "@tiptap/extension-link": "^2.7.1",
- "@tiptap/extension-paragraph": "^2.7.1",
- "@tiptap/extension-strike": "^2.7.1",
- "@tiptap/extension-table-cell": "^2.7.1",
- "@tiptap/extension-table-header": "^2.7.1",
- "@tiptap/extension-table-row": "^2.7.1",
- "@tiptap/extension-text": "^2.7.1",
- "@tiptap/extension-underline": "^2.7.1",
- "@tiptap/pm": "^2.7.1",
+ "@tiptap/core": "^2.11.5",
+ "@tiptap/extension-bold": "^2.11.5",
+ "@tiptap/extension-code": "^2.11.5",
+ "@tiptap/extension-collaboration": "^2.11.5",
+ "@tiptap/extension-collaboration-cursor": "^2.11.5",
+ "@tiptap/extension-gapcursor": "^2.11.5",
+ "@tiptap/extension-hard-break": "^2.11.5",
+ "@tiptap/extension-history": "^2.11.5",
+ "@tiptap/extension-horizontal-rule": "^2.11.5",
+ "@tiptap/extension-italic": "^2.11.5",
+ "@tiptap/extension-link": "^2.11.5",
+ "@tiptap/extension-paragraph": "^2.11.5",
+ "@tiptap/extension-strike": "^2.11.5",
+ "@tiptap/extension-table-cell": "^2.11.5",
+ "@tiptap/extension-table-header": "^2.11.5",
+ "@tiptap/extension-table-row": "^2.11.5",
+ "@tiptap/extension-text": "^2.11.5",
+ "@tiptap/extension-underline": "^2.11.5",
+ "@tiptap/pm": "^2.11.5",
"emoji-mart": "^5.6.0",
"hast-util-from-dom": "^4.2.0",
"prosemirror-dropcursor": "^1.8.1",
"prosemirror-highlight": "^0.9.0",
- "prosemirror-model": "^1.23.0",
+ "prosemirror-model": "^1.24.1",
"prosemirror-state": "^1.4.3",
- "prosemirror-tables": "^1.6.1",
+ "prosemirror-tables": "^1.6.4",
"prosemirror-transform": "^1.10.2",
"prosemirror-view": "^1.38.0",
"rehype-format": "^5.0.0",
diff --git a/packages/ariakit/src/components.ts b/packages/ariakit/src/components.ts
index 9819fcfb21..71e75e151c 100644
--- a/packages/ariakit/src/components.ts
+++ b/packages/ariakit/src/components.ts
@@ -10,6 +10,7 @@ import {
MenuLabel,
MenuTrigger,
} from "./menu/Menu.js";
+import { MenuButton } from "./menu/Button.js";
import { Panel } from "./panel/Panel.js";
import { PanelButton } from "./panel/PanelButton.js";
import { PanelFileInput } from "./panel/PanelFileInput.js";
@@ -101,6 +102,7 @@ export const components: Components = {
Divider: MenuDivider,
Label: MenuLabel,
Item: MenuItem,
+ Button: MenuButton,
},
Popover: {
Root: Popover,
diff --git a/packages/ariakit/src/menu/Button.tsx b/packages/ariakit/src/menu/Button.tsx
new file mode 100644
index 0000000000..04ad11500a
--- /dev/null
+++ b/packages/ariakit/src/menu/Button.tsx
@@ -0,0 +1,44 @@
+import { Button as AriakitButton } from "@ariakit/react";
+
+import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
+import { ComponentProps } from "@blocknote/react";
+import { forwardRef } from "react";
+
+export const MenuButton = forwardRef<
+ HTMLButtonElement,
+ ComponentProps["Generic"]["Menu"]["Button"]
+>((props, ref) => {
+ const {
+ className,
+ children,
+ icon,
+ onClick,
+ label,
+ onDragEnd,
+ onDragStart,
+ draggable,
+ ...rest
+ } = props;
+
+ // false, because rest props can be added by ariakit when button is used as a trigger
+ // assertEmpty in this case is only used at typescript level, not runtime level
+ assertEmpty(rest, false);
+
+ return (
+
+ {icon}
+ {children}
+
+ );
+});
diff --git a/packages/ariakit/src/style.css b/packages/ariakit/src/style.css
index fdc42499db..2f55720b70 100644
--- a/packages/ariakit/src/style.css
+++ b/packages/ariakit/src/style.css
@@ -47,6 +47,7 @@
.bn-ak-button {
outline-style: none;
+ cursor: pointer;
}
.bn-ak-menu-item[aria-selected="true"],
@@ -159,7 +160,8 @@
box-shadow: none;
}
-.bn-ariakit .bn-table-handle {
+.bn-ariakit .bn-table-handle,
+.bn-ariakit .bn-table-cell-handle {
height: fit-content;
padding: 0;
width: fit-content;
@@ -167,7 +169,8 @@
.bn-ariakit .bn-side-menu,
.bn-ariakit .bn-table-handle,
-.bn-ariakit .bn-extend-button {
+.bn-ariakit .bn-extend-button,
+.bn-ariakit .bn-table-cell-handle {
color: gray;
}
diff --git a/packages/core/package.json b/packages/core/package.json
index 64e81847a6..ea34b33605 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -58,32 +58,32 @@
},
"dependencies": {
"@emoji-mart/data": "^1.2.1",
- "@tiptap/core": "^2.7.1",
- "@tiptap/extension-bold": "^2.7.1",
- "@tiptap/extension-code": "^2.7.1",
- "@tiptap/extension-collaboration": "^2.7.1",
- "@tiptap/extension-collaboration-cursor": "^2.7.1",
- "@tiptap/extension-gapcursor": "^2.7.1",
- "@tiptap/extension-hard-break": "^2.7.1",
- "@tiptap/extension-history": "^2.7.1",
- "@tiptap/extension-horizontal-rule": "^2.7.1",
- "@tiptap/extension-italic": "^2.7.1",
- "@tiptap/extension-link": "^2.7.1",
- "@tiptap/extension-paragraph": "^2.7.1",
- "@tiptap/extension-strike": "^2.7.1",
- "@tiptap/extension-table-cell": "^2.7.1",
- "@tiptap/extension-table-header": "^2.7.1",
- "@tiptap/extension-table-row": "^2.7.1",
- "@tiptap/extension-text": "^2.7.1",
- "@tiptap/extension-underline": "^2.7.1",
- "@tiptap/pm": "^2.7.1",
+ "@tiptap/core": "^2.11.5",
+ "@tiptap/extension-bold": "^2.11.5",
+ "@tiptap/extension-code": "^2.11.5",
+ "@tiptap/extension-collaboration": "^2.11.5",
+ "@tiptap/extension-collaboration-cursor": "^2.11.5",
+ "@tiptap/extension-gapcursor": "^2.11.5",
+ "@tiptap/extension-hard-break": "^2.11.5",
+ "@tiptap/extension-history": "^2.11.5",
+ "@tiptap/extension-horizontal-rule": "^2.11.5",
+ "@tiptap/extension-italic": "^2.11.5",
+ "@tiptap/extension-link": "^2.11.5",
+ "@tiptap/extension-paragraph": "^2.11.5",
+ "@tiptap/extension-strike": "^2.11.5",
+ "@tiptap/extension-table-cell": "^2.11.5",
+ "@tiptap/extension-table-header": "^2.11.5",
+ "@tiptap/extension-table-row": "^2.11.5",
+ "@tiptap/extension-text": "^2.11.5",
+ "@tiptap/extension-underline": "^2.11.5",
+ "@tiptap/pm": "^2.11.5",
"emoji-mart": "^5.6.0",
"hast-util-from-dom": "^4.2.0",
"prosemirror-dropcursor": "^1.8.1",
"prosemirror-highlight": "^0.9.0",
- "prosemirror-model": "^1.23.0",
+ "prosemirror-model": "^1.24.1",
"prosemirror-state": "^1.4.3",
- "prosemirror-tables": "^1.6.1",
+ "prosemirror-tables": "^1.6.4",
"prosemirror-transform": "^1.10.2",
"prosemirror-view": "^1.38.0",
"rehype-format": "^5.0.0",
diff --git a/packages/core/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap b/packages/core/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap
index ae1f061ad3..e1bca36762 100644
--- a/packages/core/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap
@@ -314,80 +314,172 @@ exports[`Test insertBlocks > Insert multiple blocks after 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -840,80 +932,172 @@ exports[`Test insertBlocks > Insert multiple blocks before 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1326,80 +1510,172 @@ exports[`Test insertBlocks > Insert single basic block after 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1818,80 +2094,172 @@ exports[`Test insertBlocks > Insert single basic block before (without type) 1`]
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -2304,80 +2672,172 @@ exports[`Test insertBlocks > Insert single basic block before 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -2847,80 +3307,172 @@ exports[`Test insertBlocks > Insert single complex block after 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -3390,80 +3942,172 @@ exports[`Test insertBlocks > Insert single complex block before 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap b/packages/core/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap
index c3a3a512fd..f4e686823e 100644
--- a/packages/core/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap
@@ -246,80 +246,172 @@ exports[`Test mergeBlocks > Basic 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -704,80 +796,172 @@ exports[`Test mergeBlocks > Blocks have different types 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1162,80 +1346,172 @@ exports[`Test mergeBlocks > First block has children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1619,80 +1895,172 @@ exports[`Test mergeBlocks > Second block has children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -2094,80 +2462,172 @@ exports[`Test mergeBlocks > Second block is empty 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap b/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap
index a190ac024b..b295b6357d 100644
--- a/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap
@@ -263,80 +263,172 @@ exports[`Test moveBlocksDown > Basic 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -738,80 +830,172 @@ exports[`Test moveBlocksDown > Into children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -1213,80 +1397,172 @@ exports[`Test moveBlocksDown > Last block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -1688,80 +1964,172 @@ exports[`Test moveBlocksDown > Multiple blocks 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2163,80 +2531,172 @@ exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`]
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2638,80 +3098,172 @@ exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -3123,80 +3675,172 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -3598,80 +4242,172 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -4072,80 +4808,172 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -4547,80 +5375,172 @@ exports[`Test moveBlocksDown > Out of children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -5021,80 +5941,172 @@ exports[`Test moveBlocksUp > Basic 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -5496,80 +6508,172 @@ exports[`Test moveBlocksUp > First block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -5971,80 +7075,172 @@ exports[`Test moveBlocksUp > Into children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -6446,80 +7642,172 @@ exports[`Test moveBlocksUp > Multiple blocks 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -6921,80 +8209,172 @@ exports[`Test moveBlocksUp > Multiple blocks ending in block with children 1`] =
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -7396,80 +8776,172 @@ exports[`Test moveBlocksUp > Multiple blocks ending in nested block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -7853,80 +9325,172 @@ exports[`Test moveBlocksUp > Multiple blocks starting and ending in nested block
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -8345,80 +9909,172 @@ exports[`Test moveBlocksUp > Multiple blocks starting in block with children 1`]
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -8819,80 +10475,172 @@ exports[`Test moveBlocksUp > Multiple blocks starting in nested block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -9294,80 +11042,172 @@ exports[`Test moveBlocksUp > Out of children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap b/packages/core/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap
index bf74b07893..75d5602f2e 100644
--- a/packages/core/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap
@@ -227,80 +227,172 @@ exports[`Test removeBlocks > Remove all child blocks 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -615,80 +707,172 @@ exports[`Test removeBlocks > Remove multiple consecutive blocks 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1370,80 +1554,172 @@ exports[`Test removeBlocks > Remove single block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap b/packages/core/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap
index d2a59a02a8..8b16a1536d 100644
--- a/packages/core/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap
@@ -176,80 +176,172 @@ exports[`Test replaceBlocks > Remove multiple consecutive blocks 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -931,80 +1023,172 @@ exports[`Test replaceBlocks > Remove single block 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1370,80 +1554,172 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with multiple
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -1769,80 +2045,172 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single ba
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -2225,80 +2593,172 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single co
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -3755,80 +4215,172 @@ exports[`Test replaceBlocks > Replace single block with multiple 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -4224,80 +4776,172 @@ exports[`Test replaceBlocks > Replace single block with single basic 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -4750,80 +5394,172 @@ exports[`Test replaceBlocks > Replace single block with single complex 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap b/packages/core/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap
index 3a4217b2e9..f07442152c 100644
--- a/packages/core/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap
@@ -280,80 +280,172 @@ exports[`Test splitBlocks > Basic 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -772,80 +864,172 @@ exports[`Test splitBlocks > Block has children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -1264,80 +1448,172 @@ exports[`Test splitBlocks > Don't keep props 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -1756,80 +2032,172 @@ exports[`Test splitBlocks > Don't keep type 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2242,80 +2610,172 @@ exports[`Test splitBlocks > End of content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2735,80 +3195,172 @@ exports[`Test splitBlocks > Keep type 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap b/packages/core/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap
index d85aed11c5..dfdc926ac4 100644
--- a/packages/core/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap
@@ -263,80 +263,172 @@ exports[`Test updateBlock > Revert all props 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -738,80 +830,172 @@ exports[`Test updateBlock > Revert single prop 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -1213,80 +1397,172 @@ exports[`Test updateBlock > Update all props 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -1688,80 +1964,172 @@ exports[`Test updateBlock > Update children 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2161,80 +2529,172 @@ exports[`Test updateBlock > Update inline content to no content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2383,80 +2843,172 @@ exports[`Test updateBlock > Update inline content to table content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -2712,80 +3264,172 @@ exports[`Test updateBlock > Update inline content to table content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -3183,80 +3827,172 @@ exports[`Test updateBlock > Update no content to empty inline content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -3620,16 +4356,14 @@ exports[`Test updateBlock > Update no content to empty table content 1`] = `
},
{
"children": [],
- "content": {
- "columnWidths": [],
- "rows": [],
- "type": "tableContent",
- },
+ "content": [],
"id": "image-0",
"props": {
+ "backgroundColor": "default",
+ "textAlignment": "left",
"textColor": "default",
},
- "type": "table",
+ "type": "paragraph",
},
{
"children": [],
@@ -3656,80 +4390,172 @@ exports[`Test updateBlock > Update no content to empty table content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -4133,80 +4959,172 @@ exports[`Test updateBlock > Update no content to inline content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -4576,80 +5494,172 @@ exports[`Test updateBlock > Update no content to table content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "red",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "right",
+ "textColor": "red",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -4686,80 +5696,172 @@ exports[`Test updateBlock > Update no content to table content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
- "cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ "cells": [
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -5161,80 +6263,172 @@ exports[`Test updateBlock > Update single prop 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -6825,80 +8019,172 @@ exports[`Test updateBlock > Update type 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -7299,80 +8585,172 @@ exports[`Test updateBlock > Update with plain content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
@@ -7760,80 +9138,172 @@ exports[`Test updateBlock > Update with styled content 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
- },
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
- },
- ],
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts b/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts
index c4ec545b14..dc0e91bb6d 100644
--- a/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts
+++ b/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts
@@ -275,7 +275,34 @@ describe("Test updateBlock", () => {
type: "tableContent",
rows: [
{
- cells: ["Cell 1", "Cell 2", "Cell 3"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Cell 1"],
+ },
+ {
+ type: "tableCell",
+ content: ["Cell 2"],
+ props: {
+ backgroundColor: "red",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "right",
+ textColor: "red",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Cell 3"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
{
cells: ["Cell 4", "Cell 5", "Cell 6"],
diff --git a/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.ts b/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.ts
index 9581e16a36..a1cd756a3c 100644
--- a/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.ts
+++ b/packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.ts
@@ -222,7 +222,7 @@ function updateChildren<
editor: BlockNoteEditor,
blockInfo: BlockInfo
) {
- if (block.children !== undefined) {
+ if (block.children !== undefined && block.children.length > 0) {
const childNodes = block.children.map((child) => {
return blockToNode(child, state.schema, editor.schema.styleSchema);
});
diff --git a/packages/core/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap b/packages/core/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap
index b0fd1378ad..b5bde19afc 100644
--- a/packages/core/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap
+++ b/packages/core/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap
@@ -317,80 +317,172 @@ exports[`Test getSelection & setSelection > Ends in table 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -553,80 +645,172 @@ exports[`Test getSelection & setSelection > Starts in table 1`] = `
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 5",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 5",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 6",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 6",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 7",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 7",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 8",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 8",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 9",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 9",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/blockManipulation/setupTestEnv.ts b/packages/core/src/api/blockManipulation/setupTestEnv.ts
index 3182816494..537847a810 100644
--- a/packages/core/src/api/blockManipulation/setupTestEnv.ts
+++ b/packages/core/src/api/blockManipulation/setupTestEnv.ts
@@ -117,7 +117,20 @@ const testDocument: PartialBlock[] = [
type: "tableContent",
rows: [
{
- cells: ["Cell 1", "Cell 2", "Cell 3"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Cell 1"],
+ },
+ {
+ type: "tableCell",
+ content: ["Cell 2"],
+ },
+ {
+ type: "tableCell",
+ content: ["Cell 3"],
+ },
+ ],
},
{
cells: ["Cell 4", "Cell 5", "Cell 6"],
diff --git a/packages/core/src/api/blockManipulation/tables/tables.test.ts b/packages/core/src/api/blockManipulation/tables/tables.test.ts
new file mode 100644
index 0000000000..91b8a45dd0
--- /dev/null
+++ b/packages/core/src/api/blockManipulation/tables/tables.test.ts
@@ -0,0 +1,1987 @@
+import { describe, expect, it } from "vitest";
+
+import { Block, DefaultBlockSchema } from "../../../blocks/defaultBlocks.js";
+import {
+ getCellsAtColumnHandle,
+ getCellsAtRowHandle,
+ getRelativeTableCells,
+ getAbsoluteTableCells,
+ moveColumn,
+ moveRow,
+ cropEmptyRowsOrColumns,
+} from "./tables.js";
+
+/**
+ * Simple table
+ * | 1-1 | 1-2 | 1-3 |
+ * | 2-1 | 2-2 | 2-3 |
+ */
+const simpleTable = {
+ type: "table",
+ id: "table-0",
+ props: {
+ textColor: "default",
+ },
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 100],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-1", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-2", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-1", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-2", styles: {} }],
+ },
+ ],
+ },
+ ],
+ },
+ children: [],
+} satisfies Block<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ any,
+ any
+>;
+
+/**
+ * Normal table
+ * | 1-1 | 1-2 | 1-3 |
+ * | 2-1 | 2-2 | 2-3 |
+ *
+ * Table with colspan
+ * | 1-1 | 1-1 | 1-2 |
+ * | 2-1 | 2-2 | 2-3 |
+ */
+const tableWithColspan = {
+ type: "table",
+ id: "table-0",
+ props: {
+ textColor: "default",
+ },
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 100],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 2,
+ rowspan: 1,
+ },
+ content: [
+ { type: "text", text: "1-1", styles: {} },
+ { type: "text", text: "1-2", styles: {} },
+ ],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-3", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-1", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-3", styles: {} }],
+ },
+ ],
+ },
+ ],
+ },
+ children: [],
+} satisfies Block<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ any,
+ any
+>;
+
+/**
+ * Normal table
+ * | 1-1 | 1-2 | 1-3 |
+ * | 2-1 | 2-2 | 2-3 |
+ * | 3-1 | 3-2 | 3-3 |
+ *
+ * Table with rowspan
+ * | 1-1 | 1-2 | 1-3 |
+ * | 1-1 | 2-1 | 2-2 |
+ * | 3-1 | 3-2 | 3-3 |
+ */
+const tableWithRowspan = {
+ type: "table",
+ id: "table-0",
+ props: {
+ textColor: "default",
+ },
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 100],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 2,
+ },
+ content: [
+ { type: "text", text: "1-1", styles: {} },
+ { type: "text", text: "2-1", styles: {} },
+ ],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-3", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-3", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-1", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-3", styles: {} }],
+ },
+ ],
+ },
+ ],
+ },
+ children: [],
+} satisfies Block<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ any,
+ any
+>;
+
+/**
+ * Normal table
+ * | 1-1 | 1-2 | 1-3 |
+ * | 2-1 | 2-2 | 2-3 |
+ * | 3-1 | 3-2 | 3-3 |
+ *
+ * Table with colspan and rowspan
+ * | 1-1 | 1-2 | 1-3 |
+ * | 1-1 | 2-1 | 2-1 |
+ * | 3-1 | 3-2 | 3-3 |
+ */
+const tableWithColspanAndRowspan = {
+ type: "table",
+ id: "table-0",
+ props: {
+ textColor: "default",
+ },
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 100],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 2,
+ },
+ content: [
+ { type: "text", text: "1-1", styles: {} },
+ { type: "text", text: "2-1", styles: {} },
+ ],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-3", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 2,
+ rowspan: 1,
+ },
+ content: [
+ { type: "text", text: "2-2", styles: {} },
+ { type: "text", text: "2-3", styles: {} },
+ ],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-1", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-3", styles: {} }],
+ },
+ ],
+ },
+ ],
+ },
+ children: [],
+} satisfies Block<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ any,
+ any
+>;
+
+/**
+ * Normal table
+ * | 1-1 | 1-2 | 1-3 |
+ * | 2-1 | 2-2 | 2-3 |
+ * | 3-1 | 3-2 | 3-3 |
+ *
+ * Table with colspans and rowspans
+ * | 1-1 | 1-2 | 1-2 |
+ * | 1-1 | 2-1 | 2-1 |
+ * | 3-1 | 2-1 | 2-1 |
+ */
+const tableWithColspansAndRowspans = {
+ type: "table",
+ id: "table-0",
+ props: {
+ textColor: "default",
+ },
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 100],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 2,
+ },
+ content: [
+ { type: "text", text: "1-1", styles: {} },
+ { type: "text", text: "2-1", styles: {} },
+ ],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 2,
+ rowspan: 1,
+ },
+ content: [
+ { type: "text", text: "1-2", styles: {} },
+ { type: "text", text: "1-3", styles: {} },
+ ],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 2,
+ rowspan: 2,
+ },
+ content: [
+ { type: "text", text: "2-2", styles: {} },
+ { type: "text", text: "2-3", styles: {} },
+ { type: "text", text: "3-2", styles: {} },
+ { type: "text", text: "3-3", styles: {} },
+ ],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-1", styles: {} }],
+ },
+ ],
+ },
+ ],
+ },
+ children: [],
+} satisfies Block<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ any,
+ any
+>;
+
+/**
+ * Normal table
+ * | 1-1 | 1-2 | 1-3 | 1-4 |
+ * | 2-1 | 2-2 | 2-3 | 2-4 |
+ * | 3-1 | 3-2 | 3-3 | 3-4 |
+ *
+ * Table with complex rowspans and colspans
+ * | 1-1 | 1-1 | 1-2 | 1-3 |
+ * | 1-1 | 1-1 | 2-1 | 2-2 |
+ * | 3-1 | 3-2 | 2-1 | 3-3 |
+ */
+const tableWithComplexRowspansAndColspans = {
+ type: "table",
+ id: "table-0",
+ props: {
+ textColor: "default",
+ },
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 100],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 2,
+ rowspan: 2,
+ },
+ content: [
+ { type: "text", text: "1-1", styles: {} },
+ { type: "text", text: "1-2", styles: {} },
+ { type: "text", text: "2-1", styles: {} },
+ { type: "text", text: "2-2", styles: {} },
+ ],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-3", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "1-4", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 2,
+ },
+ content: [
+ { type: "text", text: "2-3", styles: {} },
+ { type: "text", text: "3-3", styles: {} },
+ ],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "2-4", styles: {} }],
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-1", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-2", styles: {} }],
+ },
+ {
+ type: "tableCell",
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text", text: "3-3", styles: {} }],
+ },
+ ],
+ },
+ ],
+ },
+ children: [],
+} satisfies Block<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ any,
+ any
+>;
+
+describe("Test getAbsoluteTableCellIndices", () => {
+ it("should resolve relative table cell indices to absolute table cell indices", () => {
+ expect(getAbsoluteTableCells({ row: 0, col: 0 }, simpleTable)).toEqual({
+ row: 0,
+ col: 0,
+ cell: simpleTable.content.rows[0].cells[0],
+ });
+ expect(getAbsoluteTableCells({ row: 0, col: 1 }, simpleTable)).toEqual({
+ row: 0,
+ col: 1,
+ cell: simpleTable.content.rows[0].cells[1],
+ });
+ expect(getAbsoluteTableCells({ row: 1, col: 0 }, simpleTable)).toEqual({
+ row: 1,
+ col: 0,
+ cell: simpleTable.content.rows[1].cells[0],
+ });
+ expect(getAbsoluteTableCells({ row: 1, col: 1 }, simpleTable)).toEqual({
+ row: 1,
+ col: 1,
+ cell: simpleTable.content.rows[1].cells[1],
+ });
+ });
+
+ it("should resolve relative table cell indices to absolute table cell indices with colspan", () => {
+ expect(getAbsoluteTableCells({ row: 0, col: 0 }, tableWithColspan)).toEqual(
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithColspan.content.rows[0].cells[0],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 0, col: 1 }, tableWithColspan)).toEqual(
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithColspan.content.rows[0].cells[1],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 1, col: 0 }, tableWithColspan)).toEqual(
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithColspan.content.rows[1].cells[0],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 1, col: 1 }, tableWithColspan)).toEqual(
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithColspan.content.rows[1].cells[1],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 1, col: 2 }, tableWithColspan)).toEqual(
+ {
+ row: 1,
+ col: 2,
+ cell: tableWithColspan.content.rows[1].cells[2],
+ }
+ );
+ });
+
+ it("should resolve relative table cell indices to absolute table cell indices with rowspan", () => {
+ expect(getAbsoluteTableCells({ row: 0, col: 0 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithRowspan.content.rows[0].cells[0],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 0, col: 1 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithRowspan.content.rows[0].cells[1],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 0, col: 2 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithRowspan.content.rows[0].cells[2],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 1, col: 0 }, tableWithRowspan)).toEqual(
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithRowspan.content.rows[1].cells[0],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 1, col: 1 }, tableWithRowspan)).toEqual(
+ {
+ row: 1,
+ col: 2,
+ cell: tableWithRowspan.content.rows[1].cells[1],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 2, col: 0 }, tableWithRowspan)).toEqual(
+ {
+ row: 2,
+ col: 0,
+ cell: tableWithRowspan.content.rows[2].cells[0],
+ }
+ );
+ expect(getAbsoluteTableCells({ row: 2, col: 1 }, tableWithRowspan)).toEqual(
+ {
+ row: 2,
+ col: 1,
+ cell: tableWithRowspan.content.rows[2].cells[1],
+ }
+ );
+ });
+
+ it("should resolve complex rowspans and colspans", () => {
+ expect(
+ getAbsoluteTableCells(
+ { row: 0, col: 0 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 0,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[0],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 0, col: 1 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 0,
+ col: 2,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[1],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 0, col: 2 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 0,
+ col: 3,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[2],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 1, col: 0 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 1,
+ col: 2,
+ cell: tableWithComplexRowspansAndColspans.content.rows[1].cells[0],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 1, col: 1 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 1,
+ col: 3,
+ cell: tableWithComplexRowspansAndColspans.content.rows[1].cells[1],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 2, col: 0 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 2,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[0],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 2, col: 1 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 2,
+ col: 1,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[1],
+ });
+ expect(
+ getAbsoluteTableCells(
+ { row: 2, col: 2 },
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row: 2,
+ col: 3,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[2],
+ });
+ });
+});
+
+describe("Test getRelativeTableCellIndices", () => {
+ it("should resolve absolute table cell indices to relative table cell indices", () => {
+ expect(getRelativeTableCells({ row: 0, col: 0 }, simpleTable)).toEqual({
+ row: 0,
+ col: 0,
+ cell: simpleTable.content.rows[0].cells[0],
+ });
+ expect(getRelativeTableCells({ row: 0, col: 1 }, simpleTable)).toEqual({
+ row: 0,
+ col: 1,
+ cell: simpleTable.content.rows[0].cells[1],
+ });
+ expect(getRelativeTableCells({ row: 1, col: 0 }, simpleTable)).toEqual({
+ row: 1,
+ col: 0,
+ cell: simpleTable.content.rows[1].cells[0],
+ });
+ expect(getRelativeTableCells({ row: 1, col: 1 }, simpleTable)).toEqual({
+ row: 1,
+ col: 1,
+ cell: simpleTable.content.rows[1].cells[1],
+ });
+ });
+
+ it("should resolve absolute table cell indices to relative table cell indices with colspan", () => {
+ expect(getRelativeTableCells({ row: 0, col: 0 }, tableWithColspan)).toEqual(
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithColspan.content.rows[0].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 0, col: 1 }, tableWithColspan)).toEqual(
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithColspan.content.rows[0].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 0, col: 2 }, tableWithColspan)).toEqual(
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithColspan.content.rows[0].cells[1],
+ }
+ );
+ expect(getRelativeTableCells({ row: 1, col: 0 }, tableWithColspan)).toEqual(
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithColspan.content.rows[1].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 1, col: 1 }, tableWithColspan)).toEqual(
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithColspan.content.rows[1].cells[1],
+ }
+ );
+ expect(getRelativeTableCells({ row: 1, col: 2 }, tableWithColspan)).toEqual(
+ {
+ row: 1,
+ col: 2,
+ cell: tableWithColspan.content.rows[1].cells[2],
+ }
+ );
+ });
+
+ it("should resolve absolute table cell indices to relative table cell indices with rowspan", () => {
+ expect(getRelativeTableCells({ row: 0, col: 0 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithRowspan.content.rows[0].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 0, col: 1 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithRowspan.content.rows[0].cells[1],
+ }
+ );
+ expect(getRelativeTableCells({ row: 0, col: 2 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithRowspan.content.rows[0].cells[2],
+ }
+ );
+ expect(getRelativeTableCells({ row: 1, col: 0 }, tableWithRowspan)).toEqual(
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithRowspan.content.rows[0].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 1, col: 1 }, tableWithRowspan)).toEqual(
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithRowspan.content.rows[1].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 1, col: 2 }, tableWithRowspan)).toEqual(
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithRowspan.content.rows[1].cells[1],
+ }
+ );
+ expect(getRelativeTableCells({ row: 2, col: 0 }, tableWithRowspan)).toEqual(
+ {
+ row: 2,
+ col: 0,
+ cell: tableWithRowspan.content.rows[2].cells[0],
+ }
+ );
+ expect(getRelativeTableCells({ row: 2, col: 1 }, tableWithRowspan)).toEqual(
+ {
+ row: 2,
+ col: 1,
+ cell: tableWithRowspan.content.rows[2].cells[1],
+ }
+ );
+ expect(getRelativeTableCells({ row: 2, col: 2 }, tableWithRowspan)).toEqual(
+ {
+ row: 2,
+ col: 2,
+ cell: tableWithRowspan.content.rows[2].cells[2],
+ }
+ );
+ });
+
+ it("should resolve absolute table cell indices to relative table cell indices with colspan and rowspan", () => {
+ expect(
+ getRelativeTableCells({ row: 0, col: 0 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 0,
+ col: 0,
+ cell: tableWithColspanAndRowspan.content.rows[0].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 0, col: 1 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 0,
+ col: 1,
+ cell: tableWithColspanAndRowspan.content.rows[0].cells[1],
+ });
+ expect(
+ getRelativeTableCells({ row: 0, col: 2 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 0,
+ col: 2,
+ cell: tableWithColspanAndRowspan.content.rows[0].cells[2],
+ });
+ expect(
+ getRelativeTableCells({ row: 1, col: 0 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 0,
+ col: 0,
+ cell: tableWithColspanAndRowspan.content.rows[0].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 1, col: 1 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 1,
+ col: 0,
+ cell: tableWithColspanAndRowspan.content.rows[1].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 1, col: 2 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 1,
+ col: 0,
+ cell: tableWithColspanAndRowspan.content.rows[1].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 2, col: 0 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 2,
+ col: 0,
+ cell: tableWithColspanAndRowspan.content.rows[2].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 2, col: 1 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 2,
+ col: 1,
+ cell: tableWithColspanAndRowspan.content.rows[2].cells[1],
+ });
+ expect(
+ getRelativeTableCells({ row: 2, col: 2 }, tableWithColspanAndRowspan)
+ ).toEqual({
+ row: 2,
+ col: 2,
+ cell: tableWithColspanAndRowspan.content.rows[2].cells[2],
+ });
+ });
+
+ it("should resolve absolute table cell indices to relative table cell indices with colspans and rowspans", () => {
+ expect(
+ getRelativeTableCells({ row: 0, col: 0 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 0,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[0].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 0, col: 1 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 0,
+ col: 1,
+ cell: tableWithColspansAndRowspans.content.rows[0].cells[1],
+ });
+ expect(
+ getRelativeTableCells({ row: 0, col: 2 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 0,
+ col: 1,
+ cell: tableWithColspansAndRowspans.content.rows[0].cells[1],
+ });
+ expect(
+ getRelativeTableCells({ row: 1, col: 0 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 0,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[0].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 1, col: 1 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 1,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[1].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 1, col: 2 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 1,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[1].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 2, col: 0 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 2,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[2].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 2, col: 1 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 1,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[1].cells[0],
+ });
+ expect(
+ getRelativeTableCells({ row: 2, col: 2 }, tableWithColspansAndRowspans)
+ ).toEqual({
+ row: 1,
+ col: 0,
+ cell: tableWithColspansAndRowspans.content.rows[1].cells[0],
+ });
+ });
+});
+
+describe("resolveAbsoluteTableCellIndices and resolveRelativeTableCellIndices should be inverse functions", () => {
+ it("should work for simple tables", () => {
+ for (let row = 0; row < simpleTable.content.rows.length; row++) {
+ for (
+ let col = 0;
+ col < simpleTable.content.rows[row].cells.length;
+ col++
+ ) {
+ expect(
+ getRelativeTableCells(
+ getAbsoluteTableCells({ row, col }, simpleTable),
+ simpleTable
+ )
+ ).toEqual({ row, col, cell: simpleTable.content.rows[row].cells[col] });
+ }
+ }
+ });
+ it("should work for tables with colspans", () => {
+ for (let row = 0; row < tableWithColspan.content.rows.length; row++) {
+ for (
+ let col = 0;
+ col < tableWithColspan.content.rows[row].cells.length;
+ col++
+ ) {
+ expect(
+ getRelativeTableCells(
+ getAbsoluteTableCells({ row, col }, tableWithColspan),
+ tableWithColspan
+ )
+ ).toEqual({
+ row,
+ col,
+ cell: tableWithColspan.content.rows[row].cells[col],
+ });
+ }
+ }
+ });
+
+ it("should work for tables with rowspans", () => {
+ for (let row = 0; row < tableWithRowspan.content.rows.length; row++) {
+ for (
+ let col = 0;
+ col < tableWithRowspan.content.rows[row].cells.length;
+ col++
+ ) {
+ expect(
+ getRelativeTableCells(
+ getAbsoluteTableCells({ row, col }, tableWithRowspan),
+ tableWithRowspan
+ )
+ ).toEqual({
+ row,
+ col,
+ cell: tableWithRowspan.content.rows[row].cells[col],
+ });
+ }
+ }
+ });
+
+ it("should work for tables with colspans and rowspans", () => {
+ for (
+ let row = 0;
+ row < tableWithColspanAndRowspan.content.rows.length;
+ row++
+ ) {
+ for (
+ let col = 0;
+ col < tableWithColspanAndRowspan.content.rows[row].cells.length;
+ col++
+ ) {
+ expect(
+ getRelativeTableCells(
+ getAbsoluteTableCells({ row, col }, tableWithColspanAndRowspan),
+ tableWithColspanAndRowspan
+ )
+ ).toEqual({
+ row,
+ col,
+ cell: tableWithColspanAndRowspan.content.rows[row].cells[col],
+ });
+ }
+ }
+ });
+
+ it("should work for tables with complex rowspans and colspans", () => {
+ for (
+ let row = 0;
+ row < tableWithComplexRowspansAndColspans.content.rows.length;
+ row++
+ ) {
+ for (
+ let col = 0;
+ col <
+ tableWithComplexRowspansAndColspans.content.rows[row].cells.length;
+ col++
+ ) {
+ expect(
+ getRelativeTableCells(
+ getAbsoluteTableCells(
+ { row, col },
+ tableWithComplexRowspansAndColspans
+ ),
+ tableWithComplexRowspansAndColspans
+ )
+ ).toEqual({
+ row,
+ col,
+ cell: tableWithComplexRowspansAndColspans.content.rows[row].cells[
+ col
+ ],
+ });
+ }
+ }
+ });
+});
+
+describe("Test getRow", () => {
+ it("should get the row of the table", () => {
+ expect(getCellsAtRowHandle(simpleTable, 0)).toEqual(
+ simpleTable.content.rows[0].cells.map((cell, col) => ({
+ row: 0,
+ col,
+ cell,
+ }))
+ );
+ });
+
+ it("should get the row of the table with colspan", () => {
+ expect(getCellsAtRowHandle(tableWithColspan, 0)).toEqual([
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithColspan.content.rows[0].cells[0],
+ },
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithColspan.content.rows[0].cells[1],
+ },
+ ]);
+
+ expect(getCellsAtRowHandle(tableWithColspan, 1)).toEqual([
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithColspan.content.rows[1].cells[0],
+ },
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithColspan.content.rows[1].cells[1],
+ },
+ {
+ row: 1,
+ col: 2,
+ cell: tableWithColspan.content.rows[1].cells[2],
+ },
+ ]);
+ });
+
+ it("should get the row of the table with rowspan", () => {
+ expect(getCellsAtRowHandle(tableWithRowspan, 0)).toEqual([
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithRowspan.content.rows[0].cells[0],
+ },
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithRowspan.content.rows[0].cells[1],
+ },
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithRowspan.content.rows[0].cells[2],
+ },
+ ]);
+
+ expect(getCellsAtRowHandle(tableWithRowspan, 1)).toEqual([
+ {
+ row: 2,
+ col: 0,
+ cell: tableWithRowspan.content.rows[2].cells[0],
+ },
+ {
+ row: 2,
+ col: 1,
+ cell: tableWithRowspan.content.rows[2].cells[1],
+ },
+ {
+ row: 2,
+ col: 2,
+ cell: tableWithRowspan.content.rows[2].cells[2],
+ },
+ ]);
+ });
+
+ it("should get the row of the table with complex rowspans and colspans", () => {
+ expect(getCellsAtRowHandle(tableWithComplexRowspansAndColspans, 0)).toEqual(
+ [
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[0],
+ },
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[1],
+ },
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[2],
+ },
+ ]
+ );
+ expect(getCellsAtRowHandle(tableWithComplexRowspansAndColspans, 1)).toEqual(
+ [
+ {
+ row: 2,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[0],
+ },
+ {
+ row: 2,
+ col: 1,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[1],
+ },
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[1].cells[0],
+ },
+ {
+ row: 2,
+ col: 2,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[2],
+ },
+ ]
+ );
+ expect(getCellsAtRowHandle(tableWithComplexRowspansAndColspans, 2)).toEqual(
+ []
+ );
+ });
+});
+
+describe("Test getColumn", () => {
+ it("should get the column of the table", () => {
+ expect(getCellsAtColumnHandle(simpleTable, 0)).toEqual([
+ {
+ row: 0,
+ col: 0,
+ cell: simpleTable.content.rows[0].cells[0],
+ },
+ {
+ row: 1,
+ col: 0,
+ cell: simpleTable.content.rows[1].cells[0],
+ },
+ ]);
+
+ expect(getCellsAtColumnHandle(simpleTable, 1)).toEqual([
+ {
+ row: 0,
+ col: 1,
+ cell: simpleTable.content.rows[0].cells[1],
+ },
+ {
+ row: 1,
+ col: 1,
+ cell: simpleTable.content.rows[1].cells[1],
+ },
+ ]);
+ expect(getCellsAtColumnHandle(simpleTable, 2)).toEqual([]);
+ });
+
+ it("should get the column of the table with colspan", () => {
+ expect(getCellsAtColumnHandle(tableWithColspan, 0)).toEqual([
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithColspan.content.rows[0].cells[0],
+ },
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithColspan.content.rows[1].cells[0],
+ },
+ ]);
+
+ expect(getCellsAtColumnHandle(tableWithColspan, 1)).toEqual([
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithColspan.content.rows[0].cells[1],
+ },
+ {
+ row: 1,
+ col: 2,
+ cell: tableWithColspan.content.rows[1].cells[2],
+ },
+ ]);
+ expect(getCellsAtColumnHandle(tableWithColspan, 2)).toEqual([]);
+ });
+
+ it("should get the column of the table with rowspan", () => {
+ expect(getCellsAtColumnHandle(tableWithRowspan, 0)).toEqual([
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithRowspan.content.rows[0].cells[0],
+ },
+ {
+ row: 2,
+ col: 0,
+ cell: tableWithRowspan.content.rows[2].cells[0],
+ },
+ ]);
+
+ expect(getCellsAtColumnHandle(tableWithRowspan, 1)).toEqual([
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithRowspan.content.rows[0].cells[1],
+ },
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithRowspan.content.rows[1].cells[0],
+ },
+ {
+ row: 2,
+ col: 1,
+ cell: tableWithRowspan.content.rows[2].cells[1],
+ },
+ ]);
+
+ expect(getCellsAtColumnHandle(tableWithRowspan, 2)).toEqual([
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithRowspan.content.rows[0].cells[2],
+ },
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithRowspan.content.rows[1].cells[1],
+ },
+ {
+ row: 2,
+ col: 2,
+ cell: tableWithRowspan.content.rows[2].cells[2],
+ },
+ ]);
+ expect(getCellsAtColumnHandle(tableWithRowspan, 3)).toEqual([]);
+ });
+
+ it("should get the column of the table with complex rowspans and colspans", () => {
+ expect(
+ getCellsAtColumnHandle(tableWithComplexRowspansAndColspans, 0)
+ ).toEqual([
+ {
+ row: 0,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[0],
+ },
+ {
+ row: 2,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[0],
+ },
+ ]);
+ expect(
+ getCellsAtColumnHandle(tableWithComplexRowspansAndColspans, 1)
+ ).toEqual([
+ {
+ row: 0,
+ col: 1,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[1],
+ },
+ {
+ row: 1,
+ col: 0,
+ cell: tableWithComplexRowspansAndColspans.content.rows[1].cells[0],
+ },
+ ]);
+ expect(
+ getCellsAtColumnHandle(tableWithComplexRowspansAndColspans, 2)
+ ).toEqual([
+ {
+ row: 0,
+ col: 2,
+ cell: tableWithComplexRowspansAndColspans.content.rows[0].cells[2],
+ },
+ {
+ row: 1,
+ col: 1,
+ cell: tableWithComplexRowspansAndColspans.content.rows[1].cells[1],
+ },
+ {
+ row: 2,
+ col: 2,
+ cell: tableWithComplexRowspansAndColspans.content.rows[2].cells[2],
+ },
+ ]);
+ expect(
+ getCellsAtColumnHandle(tableWithComplexRowspansAndColspans, 3)
+ ).toEqual([]);
+ });
+});
+
+describe("Test moveColumn", () => {
+ it("should move the column of the table", () => {
+ expect(moveColumn(simpleTable, 0, 1)).toEqual([
+ {
+ cells: [
+ simpleTable.content.rows[0].cells[1],
+ simpleTable.content.rows[0].cells[0],
+ ],
+ },
+ {
+ cells: [
+ simpleTable.content.rows[1].cells[1],
+ simpleTable.content.rows[1].cells[0],
+ ],
+ },
+ ]);
+ });
+});
+
+describe("Test moveRow", () => {
+ it("should move the row of the table", () => {
+ expect(moveRow(simpleTable, 0, 1)).toEqual([
+ {
+ cells: [
+ simpleTable.content.rows[1].cells[0],
+ simpleTable.content.rows[1].cells[1],
+ ],
+ },
+ {
+ cells: [
+ simpleTable.content.rows[0].cells[0],
+ simpleTable.content.rows[0].cells[1],
+ ],
+ },
+ ]);
+ });
+});
+
+describe("Test cropEmptyRowsOrColumns", () => {
+ const emptyCell = {
+ type: "tableCell" as const,
+ props: {
+ backgroundColor: "red",
+ textColor: "blue",
+ textAlignment: "left" as const,
+ colspan: 1,
+ rowspan: 1,
+ },
+ content: [{ type: "text" as const, text: "", styles: {} }],
+ };
+ it("should crop the empty rows of the table", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...simpleTable,
+ content: {
+ ...simpleTable.content,
+ rows: simpleTable.content.rows.concat([
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ ]),
+ },
+ },
+ "rows"
+ )
+ ).toEqual([
+ {
+ cells: [
+ simpleTable.content.rows[0].cells[0],
+ simpleTable.content.rows[0].cells[1],
+ ],
+ },
+ {
+ cells: [
+ simpleTable.content.rows[1].cells[0],
+ simpleTable.content.rows[1].cells[1],
+ ],
+ },
+ ]);
+ });
+
+ it("should crop the empty rows of a table with colspan", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithColspan,
+ content: {
+ ...tableWithColspan.content,
+ rows: tableWithColspan.content.rows.concat([
+ {
+ cells: [emptyCell, emptyCell, emptyCell],
+ },
+ ]),
+ },
+ },
+ "rows"
+ )
+ ).toEqual(tableWithColspan.content.rows);
+ });
+
+ it("should crop the empty columns of a table with colspan", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithColspan,
+ content: {
+ ...tableWithColspan.content,
+ rows: [
+ {
+ cells: [...tableWithColspan.content.rows[0].cells, emptyCell],
+ },
+ {
+ cells: [...tableWithColspan.content.rows[1].cells, emptyCell],
+ },
+ ],
+ },
+ },
+ "columns"
+ )
+ ).toEqual(tableWithColspan.content.rows);
+ });
+
+ it("should crop the empty rows of a table with rowspan", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithRowspan,
+ content: {
+ ...tableWithRowspan.content,
+ rows: tableWithRowspan.content.rows.concat([
+ {
+ cells: [emptyCell, emptyCell, emptyCell],
+ },
+ ]),
+ },
+ },
+ "rows"
+ )
+ ).toEqual(tableWithRowspan.content.rows);
+ });
+
+ it("should crop the empty columns of a table with rowspan", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithRowspan,
+ content: {
+ ...tableWithRowspan.content,
+ rows: [
+ {
+ cells: [...tableWithRowspan.content.rows[0].cells, emptyCell],
+ },
+ {
+ cells: [...tableWithRowspan.content.rows[1].cells, emptyCell],
+ },
+ {
+ cells: [...tableWithRowspan.content.rows[2].cells, emptyCell],
+ },
+ ],
+ },
+ },
+ "columns"
+ )
+ ).toEqual(tableWithRowspan.content.rows);
+ });
+
+ it("should crop the empty rows of a table with colspan and rowspan", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithColspanAndRowspan,
+ content: {
+ ...tableWithColspanAndRowspan.content,
+ rows: tableWithColspanAndRowspan.content.rows.concat([
+ {
+ cells: [emptyCell, emptyCell, emptyCell],
+ },
+ ]),
+ },
+ },
+ "rows"
+ )
+ ).toEqual(tableWithColspanAndRowspan.content.rows);
+ });
+
+ it("should crop the empty columns of a table with colspan and rowspan", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithColspanAndRowspan,
+ content: {
+ ...tableWithColspanAndRowspan.content,
+ rows: [
+ {
+ cells: [
+ ...tableWithColspanAndRowspan.content.rows[0].cells,
+ emptyCell,
+ ],
+ },
+ {
+ cells: [
+ ...tableWithColspanAndRowspan.content.rows[1].cells,
+ emptyCell,
+ ],
+ },
+ {
+ cells: [
+ ...tableWithColspanAndRowspan.content.rows[2].cells,
+ emptyCell,
+ ],
+ },
+ ],
+ },
+ },
+ "columns"
+ )
+ ).toEqual(tableWithColspanAndRowspan.content.rows);
+ });
+
+ it("should crop the empty rows of a table with complex rowspans and colspans", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithComplexRowspansAndColspans,
+ content: {
+ ...tableWithComplexRowspansAndColspans.content,
+ rows: tableWithComplexRowspansAndColspans.content.rows.concat([
+ {
+ cells: [emptyCell, emptyCell, emptyCell, emptyCell],
+ },
+ ]),
+ },
+ },
+ "rows"
+ )
+ ).toEqual(tableWithComplexRowspansAndColspans.content.rows);
+ });
+
+ it("should crop the empty columns of a table with complex rowspans and colspans", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...tableWithComplexRowspansAndColspans,
+ content: {
+ ...tableWithComplexRowspansAndColspans.content,
+ rows: [
+ {
+ cells: [
+ ...tableWithComplexRowspansAndColspans.content.rows[0].cells,
+ emptyCell,
+ ],
+ },
+ {
+ cells: [
+ ...tableWithComplexRowspansAndColspans.content.rows[1].cells,
+ emptyCell,
+ ],
+ },
+ {
+ cells: [
+ ...tableWithComplexRowspansAndColspans.content.rows[2].cells,
+ emptyCell,
+ ],
+ },
+ ],
+ },
+ },
+ "columns"
+ )
+ ).toEqual(tableWithComplexRowspansAndColspans.content.rows);
+ });
+
+ it("should not crop out the last row of a table", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...simpleTable,
+ content: {
+ ...simpleTable.content,
+ rows: [
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ ],
+ },
+ },
+ "rows"
+ )
+ ).toEqual([
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ ]);
+ });
+
+ it("should not crop out the last column of a table", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...simpleTable,
+ content: {
+ ...simpleTable.content,
+ rows: [
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ ],
+ },
+ },
+ "columns"
+ )
+ ).toEqual([
+ {
+ cells: [emptyCell],
+ },
+ {
+ cells: [emptyCell],
+ },
+ ]);
+ });
+
+ it("should preserve any colspan or rowspan on that last row", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...simpleTable,
+ content: {
+ ...simpleTable.content,
+ rows: [
+ {
+ cells: [
+ {
+ ...emptyCell,
+ props: {
+ ...emptyCell.props,
+ rowspan: 2,
+ },
+ },
+ emptyCell,
+ ],
+ },
+ {
+ cells: [emptyCell],
+ },
+ ],
+ },
+ },
+ "rows"
+ )
+ ).toEqual([
+ {
+ cells: [
+ {
+ ...emptyCell,
+ props: {
+ ...emptyCell.props,
+ rowspan: 2,
+ },
+ },
+ emptyCell,
+ ],
+ },
+ {
+ cells: [emptyCell],
+ },
+ ]);
+ });
+
+ it("should preserve any colspan or rowspan on that last column", () => {
+ expect(
+ cropEmptyRowsOrColumns(
+ {
+ ...simpleTable,
+ content: {
+ ...simpleTable.content,
+ rows: [
+ {
+ cells: [
+ {
+ ...emptyCell,
+ props: {
+ ...emptyCell.props,
+ colspan: 2,
+ },
+ },
+ ],
+ },
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ ],
+ },
+ },
+ "columns"
+ )
+ ).toEqual([
+ {
+ cells: [
+ {
+ ...emptyCell,
+ props: {
+ ...emptyCell.props,
+ colspan: 2,
+ },
+ },
+ ],
+ },
+ {
+ cells: [emptyCell, emptyCell],
+ },
+ ]);
+ });
+});
diff --git a/packages/core/src/api/blockManipulation/tables/tables.ts b/packages/core/src/api/blockManipulation/tables/tables.ts
new file mode 100644
index 0000000000..a84e62351c
--- /dev/null
+++ b/packages/core/src/api/blockManipulation/tables/tables.ts
@@ -0,0 +1,887 @@
+import { DefaultBlockSchema } from "../../../blocks/defaultBlocks.js";
+import {
+ BlockFromConfigNoChildren,
+ PartialTableContent,
+ TableCell,
+ TableContent,
+} from "../../../schema/blocks/types.js";
+import {
+ isPartialLinkInlineContent,
+ isStyledTextInlineContent,
+} from "../../../schema/index.js";
+import {
+ getColspan,
+ getRowspan,
+ isPartialTableCell,
+ mapTableCell,
+} from "../../../util/table.js";
+
+/**
+ * Here be dragons.
+ *
+ * Tables are complex because of rowspan and colspan behavior.
+ * The majority of this file is concerned with translating between "relative" and "absolute" indices.
+ *
+ * The following diagram may help explain the relationship between the different indices:
+ *
+ * One-based indexing of rows and columns in a table:
+ * | 1-1 | 1-2 | 1-3 |
+ * | 2-1 | 2-2 | 2-3 |
+ * | 3-1 | 3-2 | 3-3 |
+ *
+ * A complicated table with colspans and rowspans:
+ * | 1-1 | 1-2 | 1-2 |
+ * | 2-1 | 2-1 | 2-2 |
+ * | 2-1 | 2-1 | 3-1 |
+ *
+ * You can see here that we have:
+ * - two cells that contain the value "1-2", because it has a colspan of 2.
+ * - four cells that contain the value "2-1", because it has a rowspan of 2 and a colspan of 2.
+ *
+ * This would be represented in block note json (roughly) as:
+ * [
+ * {
+ * "cells": [
+ * {
+ * "type": "tableCell",
+ * "content": ["1,1"],
+ * "props": {
+ * "colspan": 1,
+ * "rowspan": 1
+ * },
+ * },
+ * {
+ * "type": "tableCell",
+ * "content": ["1,2"],
+ * "props": {
+ * "colspan": 2,
+ * "rowspan": 1
+ * }
+ * }
+ * ],
+ * },
+ * {
+ * "cells": [
+ * {
+ * "type": "tableCell",
+ * "content": ["2,1"],
+ * "props": {
+ * "colspan": 2,
+ * "rowspan": 2
+ * }
+ * },
+ * {
+ * "type": "tableCell",
+ * "content": ["2,2"],
+ * "props": {
+ * "colspan": 1,
+ * "rowspan": 1
+ * }
+ * ],
+ * },
+ * {
+ * "cells": [
+ * {
+ * "type": "tableCell",
+ * "content": ["3,1"],
+ * "props": {
+ * "colspan": 1,
+ * "rowspan": 1,
+ * }
+ * }
+ * ]
+ * }
+ * ]
+ *
+ * Which maps cleanly to the following HTML:
+ *
+ *
+ *
+ * | 1-1 |
+ * 1-2 |
+ *
+ *
+ * | 2-1 |
+ * 2-2 |
+ *
+ *
+ * | 3-1 |
+ *
+ *
+ *
+ * We have a problem though, from the block json, there is no way to tell that the cell "2-1" is the second cell in the second row.
+ * To resolve this, we created the occupancy grid, which is a grid of all the cells in the table, as though they were only 1x1 cells.
+ * See {@link OccupancyGrid} for more information.
+ *
+ */
+
+/**
+ * Relative cell indices are relative to the table block's content.
+ *
+ * This is a sparse representation of the table and is how HTML and BlockNote JSON represent tables.
+ *
+ * For example, if we have a table with a rowspan of 2, the second row may only have 1 element in a 2x2 table.
+ *
+ * ```
+ * // Visual representation of the table
+ * | 1-1 | 1-2 | // has 2 cells
+ * | 1-1 | 2-2 | // has only 1 cell
+ * // Relative cell indices
+ * [{ row: 1, col: 1, rowspan: 2 }, { row: 1, col: 2 }] // has 2 cells
+ * [{ row: 1, col: 2 }] // has only 1 cell
+ * ```
+ */
+export type RelativeCellIndices = {
+ row: number;
+ col: number;
+};
+
+/**
+ * Absolute cell indices are relative to the table's layout (it's {@link OccupancyGrid}).
+ *
+ * It is as though the table is a grid of 1x1 cells, and any colspan or rowspan results in multiple 1x1 cells being occupied.
+ *
+ * For example, if we have a table with a colspan of 2, it will occupy 2 cells in the layout grid.
+ *
+ * ```
+ * // Visual representation of the table
+ * | 1-1 | 1-1 | // has 2 cells
+ * | 2-1 | 2-2 | // has 2 cell
+ * // Absolute cell indices
+ * [{ row: 1, col: 1, colspan: 2 }, { row: 1, col: 2, colspan: 2 }] // has 2 cells
+ * [{ row: 1, col: 1 }, { row: 1, col: 2 }] // has 2 cells
+ * ```
+ */
+export type AbsoluteCellIndices = {
+ row: number;
+ col: number;
+};
+
+/**
+ * An occupancy grid is a grid of the occupied cells in the table.
+ * It is used to track the occupied cells in the table to know where to place the next cell.
+ *
+ * Since it allows us to resolve cell indices both {@link RelativeCellIndices} and {@link AbsoluteCellIndices}, it is the core data structure for table operations.
+ */
+type OccupancyGrid = (RelativeCellIndices & {
+ /**
+ * The rowspan of the cell.
+ */
+ rowspan: number;
+ /**
+ * The colspan of the cell.
+ */
+ colspan: number;
+ /**
+ * The cell.
+ */
+ cell: TableCell;
+})[][];
+
+/**
+ * This will return the {@link OccupancyGrid} of the table.
+ * By laying out the table as though it were a grid of 1x1 cells, we can easily track where the cells are located (both relatively and absolutely).
+ *
+ * @returns an {@link OccupancyGrid}
+ */
+export function getTableCellOccupancyGrid(
+ block: BlockFromConfigNoChildren
+): OccupancyGrid {
+ const { height, width } = getDimensionsOfTable(block);
+
+ /**
+ * Create a grid to track occupied cells
+ * This is used because rowspans and colspans take up multiple spaces
+ * So, we need to track the occupied cells in the grid to know where to place the next cell
+ */
+ const grid: OccupancyGrid = new Array(height)
+ .fill(false)
+ .map(() => new Array(width).fill(null));
+
+ // Find the next unoccupied cell in the table, row-major order
+ const findNextAvailable = (row: number, col: number) => {
+ for (let i = row; i < height; i++) {
+ for (let j = col; j < width; j++) {
+ if (!grid[i][j]) {
+ return { row: i, col: j };
+ }
+ }
+ }
+
+ throw new Error(
+ "Unable to create occupancy grid for table, no more available cells"
+ );
+ };
+
+ // Build up the grid, trying to fill in the cells with the correct relative row and column indices
+ for (let row = 0; row < block.content.rows.length; row++) {
+ for (let col = 0; col < block.content.rows[row].cells.length; col++) {
+ const cell = mapTableCell(block.content.rows[row].cells[col]);
+ const rowspan = getRowspan(cell);
+ const colspan = getColspan(cell);
+
+ // Rowspan and colspan complicate things, by taking up multiple cells in the grid
+ // We need to iterate over the cells that the rowspan and colspan take up
+ // and fill in the grid with the correct relative row and column indices
+ const { row: startRow, col: startCol } = findNextAvailable(row, col);
+
+ // Fill in the rowspan X colspan cells, starting from the next available cell, with the correct relative row and column indices
+ for (let i = startRow; i < startRow + rowspan; i++) {
+ for (let j = startCol; j < startCol + colspan; j++) {
+ if (grid[i][j]) {
+ // The cell is already occupied, the table is malformed
+ throw new Error(
+ `Unable to create occupancy grid for table, cell at ${i},${j} is already occupied`
+ );
+ }
+
+ grid[i][j] = {
+ row,
+ col,
+ rowspan,
+ colspan,
+ cell,
+ };
+ }
+ }
+ }
+ }
+
+ // console.log(grid);
+
+ return grid;
+}
+
+/**
+ * Given an {@link OccupancyGrid}, this will return the {@link TableContent} rows.
+ *
+ * @note This will remove duplicates from the occupancy grid. And does no bounds checking for validity of the occupancy grid.
+ */
+export function getTableRowsFromOccupancyGrid(
+ occupancyGrid: OccupancyGrid
+): TableContent["rows"] {
+ // Because a cell can have a rowspan or colspan, it can occupy multiple cells in the occupancy grid
+ // So, we need to remove duplicates from the occupancy grid before we can return the table rows
+ const seen = new Set();
+
+ return occupancyGrid.map((row) => {
+ // Just read out the cells in the occupancy grid, removing duplicates
+ return {
+ cells: row
+ .map((cell) => {
+ if (seen.has(cell.row + ":" + cell.col)) {
+ return false;
+ }
+ seen.add(cell.row + ":" + cell.col);
+ return cell.cell;
+ })
+ .filter((cell): cell is TableCell => cell !== false),
+ };
+ });
+}
+
+/**
+ * This will resolve the relative cell indices within the table block to the absolute cell indices within the table, accounting for colspan and rowspan.
+ *
+ * @note It will return only the first cell (i.e. top-left) that matches the relative cell indices. To find the other absolute cell indices this cell occupies, you can assume it is the rowspan and colspan number of cells away from the top-left cell.
+ *
+ * @returns The {@link AbsoluteCellIndices} and the {@link TableCell} at the absolute position.
+ */
+export function getAbsoluteTableCells(
+ /**
+ * The relative position of the cell in the table.
+ */
+ relativeCellIndices: RelativeCellIndices,
+ /**
+ * The table block containing the cell.
+ */
+ block: BlockFromConfigNoChildren,
+ /**
+ * The occupancy grid of the table.
+ */
+ occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
+): AbsoluteCellIndices & {
+ cell: TableCell;
+} {
+ for (let r = 0; r < occupancyGrid.length; r++) {
+ for (let c = 0; c < occupancyGrid[r].length; c++) {
+ // console.log(r, c, occupancyGrid);
+ const cell = occupancyGrid[r][c];
+ if (
+ cell.row === relativeCellIndices.row &&
+ cell.col === relativeCellIndices.col
+ ) {
+ return { row: r, col: c, cell: cell.cell };
+ }
+ }
+ }
+
+ throw new Error(
+ `Unable to resolve relative table cell indices for table, cell at ${relativeCellIndices.row},${relativeCellIndices.col} is not occupied`
+ );
+}
+
+/**
+ * This will get the dimensions of the table block.
+ *
+ * @returns The height and width of the table.
+ */
+export function getDimensionsOfTable(
+ block: BlockFromConfigNoChildren
+): {
+ /**
+ * The number of rows in the table.
+ */
+ height: number;
+ /**
+ * The number of columns in the table.
+ */
+ width: number;
+} {
+ // Due to the way we store the table, the height is always the number of rows
+ const height = block.content.rows.length;
+
+ // Calculating the width is a bit more complex, as it is the maximum width of any row
+ let width = 0;
+ block.content.rows.forEach((row) => {
+ // Find the width of the row by summing the colspan of each cell
+ let rowWidth = 0;
+ row.cells.forEach((cell) => {
+ rowWidth += getColspan(cell);
+ });
+
+ // Update the width if the row is wider than the current width
+ width = Math.max(width, rowWidth);
+ });
+
+ return { height, width };
+}
+
+/**
+ * This will resolve the absolute cell indices within the table block to the relative cell indices within the table, accounting for colspan and rowspan.
+ *
+ * @returns The {@link RelativeCellIndices} and the {@link TableCell} at the relative position.
+ */
+export function getRelativeTableCells(
+ /**
+ * The {@link AbsoluteCellIndices} of the cell in the table.
+ */
+ absoluteCellIndices: AbsoluteCellIndices,
+ /**
+ * The table block containing the cell.
+ */
+ block: BlockFromConfigNoChildren,
+ /**
+ * The occupancy grid of the table.
+ */
+ occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
+):
+ | (RelativeCellIndices & {
+ cell: TableContent["rows"][number]["cells"][number];
+ })
+ | undefined {
+ const occupancyCell =
+ occupancyGrid[absoluteCellIndices.row]?.[absoluteCellIndices.col];
+
+ // Double check that the cell can be accessed
+ if (!occupancyCell) {
+ // The cell is not occupied, so it is invalid
+ return undefined;
+ }
+
+ return {
+ row: occupancyCell.row,
+ col: occupancyCell.col,
+ cell: occupancyCell.cell,
+ };
+}
+
+/**
+ * This will get all the cells within a relative row of a table block.
+ *
+ * This method always starts the search for the row at the first column of the table.
+ *
+ * ```
+ * // Visual representation of a table
+ * | A | B | C |
+ * | | D | E |
+ * | F | G | H |
+ * // "A" has a rowspan of 2
+ *
+ * // getCellsAtRowHandle(0)
+ * // returns [
+ * { row: 0, col: 0, cell: "A" },
+ * { row: 0, col: 1, cell: "B" },
+ * { row: 0, col: 2, cell: "C" },
+ * ]
+ *
+ * // getCellsAtColumnHandle(1)
+ * // returns [
+ * { row: 1, col: 0, cell: "F" },
+ * { row: 1, col: 1, cell: "G" },
+ * { row: 1, col: 2, cell: "H" },
+ * ]
+ * ```
+ *
+ * As you can see, you may not be able to retrieve all nodes given a relative row index, as cells can span multiple rows.
+ *
+ * @returns All of the cells associated with the relative row of the table. (All cells that have the same relative row index)
+ */
+export function getCellsAtRowHandle(
+ block: BlockFromConfigNoChildren,
+ relativeRowIndex: RelativeCellIndices["row"]
+) {
+ const occupancyGrid = getTableCellOccupancyGrid(block);
+
+ if (relativeRowIndex < 0 || relativeRowIndex >= occupancyGrid.length) {
+ return [];
+ }
+
+ // First need to resolve the relative row index to an absolute row index
+ let absoluteRow = 0;
+
+ // Jump through the occupied cells ${relativeCellIndices.row} times to find the absolute row position
+ for (let i = 0; i < relativeRowIndex; i++) {
+ const cell = occupancyGrid[absoluteRow]?.[0];
+
+ if (!cell) {
+ return [];
+ }
+
+ // Skip the cells that the rowspan takes up
+ absoluteRow += cell.rowspan;
+ }
+
+ // Then for each column, get the cell at the absolute row index as a relative cell index
+ const cells = new Array(occupancyGrid[0].length)
+ .fill(false)
+ .map((_v, col) => {
+ return getRelativeTableCells(
+ { row: absoluteRow, col },
+ block,
+ occupancyGrid
+ );
+ })
+ .filter(
+ (a): a is RelativeCellIndices & { cell: TableCell } =>
+ a !== undefined
+ );
+
+ // Filter out duplicates based on row and col properties
+ return cells.filter((cell, index) => {
+ return (
+ cells.findIndex((c) => c.row === cell.row && c.col === cell.col) === index
+ );
+ });
+}
+
+/**
+ * This will get all the cells within a relative column of a table block.
+ *
+ * This method always starts the search for the column at the first row of the table.
+ *
+ * ```
+ * // Visual representation of a table
+ * | A | B |
+ * | C | D | E |
+ * | F | G | H |
+ * // "A" has a colspan of 2
+ *
+ * // getCellsAtColumnHandle(0)
+ * // returns [
+ * { row: 0, col: 0, cell: "A" },
+ * { row: 1, col: 0, cell: "C" },
+ * { row: 2, col: 0, cell: "F" },
+ * ]
+ *
+ * // getCellsAtColumnHandle(1)
+ * // returns [
+ * { row: 0, col: 1, cell: "B" },
+ * { row: 1, col: 2, cell: "E" },
+ * { row: 2, col: 2, cell: "F" },
+ * ]
+ * ```
+ *
+ * As you can see, you may not be able to retrieve all nodes given a relative column index, as cells can span multiple columns.
+ *
+ * @returns All of the cells associated with the relative column of the table. (All cells that have the same relative column index)
+ */
+export function getCellsAtColumnHandle(
+ block: BlockFromConfigNoChildren,
+ relativeColumnIndex: RelativeCellIndices["col"]
+) {
+ const occupancyGrid = getTableCellOccupancyGrid(block);
+
+ if (
+ relativeColumnIndex < 0 ||
+ relativeColumnIndex >= occupancyGrid[0].length
+ ) {
+ return [];
+ }
+
+ // First need to resolve the relative column index to an absolute column index
+ let absoluteCol = 0;
+
+ // Now that we've already resolved the absolute row position, we can jump through the occupied cells ${relativeCellIndices.col} times to find the absolute column position
+ for (let i = 0; i < relativeColumnIndex; i++) {
+ const cell = occupancyGrid[0]?.[absoluteCol];
+
+ if (!cell) {
+ return [];
+ }
+
+ // Skip the cells that the colspan takes up
+ absoluteCol += cell.colspan;
+ }
+
+ // Then for each row, get the cell at the absolute column index as a relative cell index
+ const cells = new Array(occupancyGrid.length)
+ .fill(false)
+ .map((_v, row) => {
+ return getRelativeTableCells(
+ { row, col: absoluteCol },
+ block,
+ occupancyGrid
+ );
+ })
+ .filter(
+ (a): a is RelativeCellIndices & { cell: TableCell } =>
+ a !== undefined
+ );
+
+ // Filter out duplicates based on row and col properties
+ return cells.filter((cell, index) => {
+ return (
+ cells.findIndex((c) => c.row === cell.row && c.col === cell.col) === index
+ );
+ });
+}
+
+/**
+ * This moves a column from one index to another.
+ *
+ * @note This is a destructive operation, it will modify the provided {@link OccupancyGrid} in place.
+ */
+export function moveColumn(
+ block: BlockFromConfigNoChildren,
+ fromColIndex: RelativeCellIndices["col"],
+ toColIndex: RelativeCellIndices["col"],
+ occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
+): TableContent["rows"] {
+ // To move cells in a column, we need to layout the whole table
+ // and then move the cells accordingly.
+ const { col: absoluteSourceCol } = getAbsoluteTableCells(
+ {
+ row: 0,
+ col: fromColIndex,
+ },
+ block,
+ occupancyGrid
+ );
+ const { col: absoluteTargetCol } = getAbsoluteTableCells(
+ {
+ row: 0,
+ col: toColIndex,
+ },
+ block,
+ occupancyGrid
+ );
+
+ /**
+ * Currently, this function assumes that the caller has already checked that the source and target columns are valid.
+ * Such as by using {@link canColumnBeDraggedInto}. In the future, we may want to have the move logic be smarter
+ * and handle invalid column indices in some way.
+ */
+ occupancyGrid.forEach((row) => {
+ // Move the cell to the target column
+ const [sourceCell] = row.splice(absoluteSourceCol, 1);
+ row.splice(absoluteTargetCol, 0, sourceCell);
+ });
+
+ return getTableRowsFromOccupancyGrid(occupancyGrid);
+}
+
+/**
+ * This moves a row from one index to another.
+ *
+ * @note This is a destructive operation, it will modify the {@link OccupancyGrid} in place.
+ */
+export function moveRow(
+ block: BlockFromConfigNoChildren,
+ fromRowIndex: RelativeCellIndices["row"],
+ toRowIndex: RelativeCellIndices["row"],
+ occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
+): TableContent["rows"] {
+ // To move cells in a column, we need to layout the whole table
+ // and then move the cells accordingly.
+ const { row: absoluteSourceRow } = getAbsoluteTableCells(
+ {
+ row: fromRowIndex,
+ col: 0,
+ },
+ block,
+ occupancyGrid
+ );
+ const { row: absoluteTargetRow } = getAbsoluteTableCells(
+ {
+ row: toRowIndex,
+ col: 0,
+ },
+ block,
+ occupancyGrid
+ );
+
+ /**
+ * Currently, this function assumes that the caller has already checked that the source and target rows are valid.
+ * Such as by using {@link canRowBeDraggedInto}. In the future, we may want to have the move logic be smarter
+ * and handle invalid row indices in some way.
+ */
+ const [sourceRow] = occupancyGrid.splice(absoluteSourceRow, 1);
+ occupancyGrid.splice(absoluteTargetRow, 0, sourceRow);
+
+ return getTableRowsFromOccupancyGrid(occupancyGrid);
+}
+
+/**
+ * This will check if a cell is empty.
+ *
+ * @returns True if the cell is empty, false otherwise.
+ */
+function isCellEmpty(
+ cell:
+ | PartialTableContent["rows"][number]["cells"][number]
+ | undefined
+): boolean {
+ if (!cell) {
+ return true;
+ }
+ if (isPartialTableCell(cell)) {
+ return isCellEmpty(cell.content);
+ } else if (typeof cell === "string") {
+ return cell.length === 0;
+ } else if (Array.isArray(cell)) {
+ return cell.every((c) =>
+ typeof c === "string"
+ ? c.length === 0
+ : isStyledTextInlineContent(c)
+ ? c.text.length === 0
+ : isPartialLinkInlineContent(c)
+ ? typeof c.content === "string"
+ ? c.content.length === 0
+ : c.content.every((s) => s.text.length === 0)
+ : false
+ );
+ } else {
+ return false;
+ }
+}
+
+/**
+ * This will remove empty rows or columns from the table.
+ *
+ * @note This is a destructive operation, it will modify the {@link OccupancyGrid} in place.
+ */
+export function cropEmptyRowsOrColumns(
+ block: BlockFromConfigNoChildren,
+ removeEmpty: "columns" | "rows",
+ occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
+): TableContent["rows"] {
+ if (removeEmpty === "columns") {
+ // strips empty columns on the right
+ let emptyColsOnRight = 0;
+ for (
+ let cellIndex = occupancyGrid[0].length - 1;
+ cellIndex >= 0;
+ cellIndex--
+ ) {
+ const isEmpty = occupancyGrid.every(
+ (row) =>
+ isCellEmpty(row[cellIndex].cell) && row[cellIndex].colspan === 1
+ );
+ if (!isEmpty) {
+ break;
+ }
+
+ emptyColsOnRight++;
+ }
+
+ for (let i = occupancyGrid.length - 1; i >= 0; i--) {
+ // We maintain at least one cell, even if all the cells are empty
+ const cellsToRemove = Math.max(
+ occupancyGrid[i].length - emptyColsOnRight,
+ 1
+ );
+ occupancyGrid[i] = occupancyGrid[i].slice(0, cellsToRemove);
+ }
+
+ return getTableRowsFromOccupancyGrid(occupancyGrid);
+ }
+
+ // strips empty rows at the bottom
+ let emptyRowsOnBottom = 0;
+ for (let rowIndex = occupancyGrid.length - 1; rowIndex >= 0; rowIndex--) {
+ const isEmpty = occupancyGrid[rowIndex].every(
+ (cell) => isCellEmpty(cell.cell) && cell.rowspan === 1
+ );
+ if (!isEmpty) {
+ break;
+ }
+
+ emptyRowsOnBottom++;
+ }
+
+ // We maintain at least one row, even if all the rows are empty
+ const rowsToRemove = Math.min(emptyRowsOnBottom, occupancyGrid.length - 1);
+
+ occupancyGrid.splice(occupancyGrid.length - rowsToRemove, rowsToRemove);
+
+ return getTableRowsFromOccupancyGrid(occupancyGrid);
+}
+
+/**
+ * This will add a specified number of rows or columns to the table (filling with empty cells).
+ *
+ * @note This is a destructive operation, it will modify the {@link OccupancyGrid} in place.
+ */
+export function addRowsOrColumns(
+ block: BlockFromConfigNoChildren,
+ addType: "columns" | "rows",
+ /**
+ * The number of rows or columns to add.
+ *
+ * @note if negative, it will remove rows or columns.
+ */
+ numToAdd: number,
+ occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
+): TableContent["rows"] {
+ const { width, height } = getDimensionsOfTable(block);
+
+ if (addType === "columns") {
+ // Add empty columns to the right
+ occupancyGrid.forEach((row, rowIndex) => {
+ if (numToAdd >= 0) {
+ for (let i = 0; i < numToAdd; i++) {
+ row.push({
+ row: rowIndex,
+ col: Math.max(...row.map((r) => r.col)) + 1,
+ rowspan: 1,
+ colspan: 1,
+ cell: mapTableCell(""),
+ });
+ }
+ } else {
+ // Remove columns on the right
+ row.splice(width + numToAdd, -1 * numToAdd);
+ }
+ });
+ } else {
+ if (numToAdd > 0) {
+ // Add empty rows to the bottom
+ for (let i = 0; i < numToAdd; i++) {
+ const newRow = new Array(width).fill(null).map((_, colIndex) => ({
+ row: height + i,
+ col: colIndex,
+ rowspan: 1,
+ colspan: 1,
+ cell: mapTableCell(""),
+ }));
+ occupancyGrid.push(newRow);
+ }
+ } else if (numToAdd < 0) {
+ // Remove rows at the bottom
+ occupancyGrid.splice(height + numToAdd, -1 * numToAdd);
+ }
+ }
+
+ return getTableRowsFromOccupancyGrid(occupancyGrid);
+}
+
+/**
+ * Checks if a row can be safely dropped at the target row index without splitting merged cells.
+ */
+export function canRowBeDraggedInto(
+ block: BlockFromConfigNoChildren,
+ draggingIndex: RelativeCellIndices["row"],
+ targetRowIndex: RelativeCellIndices["row"]
+) {
+ // Check cells at the target row
+ const targetCells = getCellsAtRowHandle(block, targetRowIndex);
+
+ // If no cells have rowspans > 1, dragging is always allowed
+ const hasMergedCells = targetCells.some((cell) => getRowspan(cell.cell) > 1);
+ if (!hasMergedCells) {
+ return true;
+ }
+
+ let endRowIndex = targetRowIndex;
+ let startRowIndex = targetRowIndex;
+ targetCells.forEach((cell) => {
+ const rowspan = getRowspan(cell.cell);
+ endRowIndex = Math.max(endRowIndex, cell.row + rowspan - 1);
+ startRowIndex = Math.min(startRowIndex, cell.row);
+ });
+
+ // Check the direction of the drag
+ const isDraggingDown = draggingIndex < targetRowIndex;
+
+ // Allow dragging only at the start/end of merged cells
+ // Otherwise, the target row was within a merged cell which we don't allow
+ return isDraggingDown
+ ? targetRowIndex === endRowIndex
+ : targetRowIndex === startRowIndex;
+}
+
+/**
+ * Checks if a column can be safely dropped at the target column index without splitting merged cells.
+ */
+export function canColumnBeDraggedInto(
+ block: BlockFromConfigNoChildren,
+ draggingIndex: RelativeCellIndices["col"],
+ targetColumnIndex: RelativeCellIndices["col"]
+) {
+ // Check cells at the target column
+ const targetCells = getCellsAtColumnHandle(block, targetColumnIndex);
+
+ // If no cells have colspans > 1, dragging is always allowed
+ const hasMergedCells = targetCells.some((cell) => getColspan(cell.cell) > 1);
+ if (!hasMergedCells) {
+ return true;
+ }
+
+ let endColumnIndex = targetColumnIndex;
+ let startColumnIndex = targetColumnIndex;
+ targetCells.forEach((cell) => {
+ const colspan = getColspan(cell.cell);
+ endColumnIndex = Math.max(endColumnIndex, cell.col + colspan - 1);
+ startColumnIndex = Math.min(startColumnIndex, cell.col);
+ });
+
+ // Check the direction of the drag
+ const isDraggingRight = draggingIndex < targetColumnIndex;
+
+ // Allow dragging only at the start/end of merged cells
+ // Otherwise, the target column was within a merged cell which we don't allow
+ return isDraggingRight
+ ? targetColumnIndex === endColumnIndex
+ : targetColumnIndex === startColumnIndex;
+}
+
+/**
+ * Checks if two cells are in the same column.
+ *
+ * @returns True if the cells are in the same column, false otherwise.
+ */
+export function areInSameColumn(
+ from: RelativeCellIndices,
+ to: RelativeCellIndices,
+ block: BlockFromConfigNoChildren
+) {
+ // Table indices are relative to the table, so we need to resolve the absolute cell indices
+ const anchorAbsoluteCellIndices = getAbsoluteTableCells(from, block);
+
+ // Table indices are relative to the table, so we need to resolve the absolute cell indices
+ const headAbsoluteCellIndices = getAbsoluteTableCells(to, block);
+
+ // Compare the column indices to determine the merge direction
+ return anchorAbsoluteCellIndices.col === headAbsoluteCellIndices.col;
+}
diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html
index 326207757a..0a607ca98c 100644
--- a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html
+++ b/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html
@@ -23,41 +23,83 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html
index 326207757a..0a607ca98c 100644
--- a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html
+++ b/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html
@@ -23,41 +23,83 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html
index 5bf0ff1271..cab1cac6f1 100644
--- a/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html
+++ b/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html
@@ -38,41 +38,83 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html
index 8b979aa417..9c4f9b7629 100644
--- a/packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html
+++ b/packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html
@@ -23,41 +23,83 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html
index 4e9713621a..b2724689d2 100644
--- a/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html
+++ b/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html
@@ -23,41 +23,83 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
@@ -76,41 +118,83 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html
index 2e6fbce5d2..034816337e 100644
--- a/packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html
+++ b/packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html
@@ -24,68 +24,160 @@
undefined,
undefined,
],
+ "headerCols": undefined,
+ "headerRows": undefined,
"rows": [
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [],
+ "type": "tableCell",
+ },
+ {
+ "content": [],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [
- {
- "styles": {},
- "text": "Table Cell",
- "type": "text",
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 1",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 1",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 2",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 2",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
{
"cells": [
- [],
- [
- {
- "styles": {},
- "text": "Cell 3",
- "type": "text",
+ {
+ "content": [],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 3",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
- [
- {
- "styles": {},
- "text": "Cell 4",
- "type": "text",
+ "type": "tableCell",
+ },
+ {
+ "content": [
+ {
+ "styles": {},
+ "text": "Cell 4",
+ "type": "text",
+ },
+ ],
+ "props": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
- ],
+ "type": "tableCell",
+ },
],
},
],
diff --git a/packages/core/src/api/clipboard/toClipboard/copyExtension.ts b/packages/core/src/api/clipboard/toClipboard/copyExtension.ts
index ab70211bdd..30d57bd66f 100644
--- a/packages/core/src/api/clipboard/toClipboard/copyExtension.ts
+++ b/packages/core/src/api/clipboard/toClipboard/copyExtension.ts
@@ -2,9 +2,8 @@ import { Extension } from "@tiptap/core";
import { Fragment, Node } from "prosemirror-model";
import { NodeSelection, Plugin } from "prosemirror-state";
import { CellSelection } from "prosemirror-tables";
-import * as pmView from "prosemirror-view";
+import type { EditorView } from "prosemirror-view";
-import { EditorView } from "prosemirror-view";
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
import {
BlockSchema,
@@ -24,7 +23,7 @@ function fragmentToExternalHTML<
I extends InlineContentSchema,
S extends StyleSchema
>(
- view: pmView.EditorView,
+ view: EditorView,
selectedFragment: Fragment,
editor: BlockNoteEditor
) {
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/external.html
new file mode 100644
index 0000000000..03ecb174b0
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/external.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
|---|
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/internal.html
new file mode 100644
index 0000000000..972eb90512
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/internal.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
|---|
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/external.html
new file mode 100644
index 0000000000..9306b01089
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/external.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/internal.html
new file mode 100644
index 0000000000..b07ff89563
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/internal.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/external.html
new file mode 100644
index 0000000000..4c1d3e7203
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/external.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/internal.html
new file mode 100644
index 0000000000..95f848187d
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/internal.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
|---|
Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html
new file mode 100644
index 0000000000..780396996c
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html
new file mode 100644
index 0000000000..10e00b6852
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html
@@ -0,0 +1 @@
+Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
Table Cell | Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html
new file mode 100644
index 0000000000..1e0671ec07
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html
@@ -0,0 +1 @@
+Table Cell | Table Cell |
Table Cell | Table Cell |
Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html
new file mode 100644
index 0000000000..49f80e058f
--- /dev/null
+++ b/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html
@@ -0,0 +1 @@
+Table Cell | Table Cell |
Table Cell | Table Cell |
Table Cell | Table Cell |
\ No newline at end of file
diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md
new file mode 100644
index 0000000000..812aac2d02
--- /dev/null
+++ b/packages/core/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md
@@ -0,0 +1,4 @@
+| Table Cell | Table Cell | Table Cell |
+| ---------- | ---------- | ---------- |
+| Table Cell | Table Cell | Table Cell |
+| Table Cell | Table Cell | Table Cell |
diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md
new file mode 100644
index 0000000000..812aac2d02
--- /dev/null
+++ b/packages/core/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md
@@ -0,0 +1,4 @@
+| Table Cell | Table Cell | Table Cell |
+| ---------- | ---------- | ---------- |
+| Table Cell | Table Cell | Table Cell |
+| Table Cell | Table Cell | Table Cell |
diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md
new file mode 100644
index 0000000000..3e52272fe0
--- /dev/null
+++ b/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md
@@ -0,0 +1,5 @@
+| | | |
+| ---------- | ---------- | ---------- |
+| Table Cell | Table Cell | Table Cell |
+| Table Cell | Table Cell | Table Cell |
+| Table Cell | Table Cell | Table Cell |
diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md
new file mode 100644
index 0000000000..5f817e4d91
--- /dev/null
+++ b/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md
@@ -0,0 +1,5 @@
+| | | |
+| ---------- | ---------- | ---------- |
+| Table Cell | | Table Cell |
+| Table Cell | Table Cell | |
+| | Table Cell | Table Cell |
diff --git a/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap b/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap
index aa439ea041..245ab3ba9c 100644
--- a/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap
+++ b/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap
@@ -1879,11 +1879,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
100,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -1900,11 +1903,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
200,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -1921,11 +1927,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
300,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -1947,11 +1956,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
100,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -1968,11 +1980,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
200,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -1989,11 +2004,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
300,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2015,11 +2033,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
100,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2036,11 +2057,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
200,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2057,11 +2081,14 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": [
300,
],
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2101,9 +2128,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2120,9 +2150,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2139,9 +2172,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2163,9 +2199,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2182,9 +2221,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2201,9 +2243,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2225,9 +2270,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2244,9 +2292,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2263,9 +2314,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2291,7 +2345,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
}
`;
-exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedColWidths to/from prosemirror 1`] = `
+exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/headerCols to/from prosemirror 1`] = `
{
"attrs": {
"backgroundColor": "default",
@@ -2305,11 +2359,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
- "colwidth": [
- 100,
- ],
+ "colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2322,13 +2377,16 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"type": "tableParagraph",
},
],
- "type": "tableCell",
+ "type": "tableHeader",
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2345,11 +2403,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
- "colwidth": [
- 300,
- ],
+ "colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2371,11 +2430,34 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
- "colwidth": [
- 100,
- ],
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableHeader",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2392,9 +2474,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2409,13 +2494,63 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
],
"type": "tableCell",
},
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
- "colwidth": [
- 300,
- ],
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableHeader",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2433,15 +2568,105 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
],
"type": "tableRow",
},
+ ],
+ "type": "table",
+ },
+ ],
+ "type": "blockContainer",
+}
+`;
+
+exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/headerRows to/from prosemirror 1`] = `
+{
+ "attrs": {
+ "backgroundColor": "default",
+ "id": "1",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
{
"content": [
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
- "colwidth": [
- 100,
- ],
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableHeader",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableHeader",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableHeader",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2458,9 +2683,12 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
"colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
@@ -2477,11 +2705,748 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
},
{
"attrs": {
+ "backgroundColor": "default",
"colspan": 1,
- "colwidth": [
- 300,
- ],
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
"rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ ],
+ "type": "table",
+ },
+ ],
+ "type": "blockContainer",
+}
+`;
+
+exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedCellColors to/from prosemirror 1`] = `
+{
+ "attrs": {
+ "backgroundColor": "default",
+ "id": "1",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "red",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "blue",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "blue",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "yellow",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "red",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ ],
+ "type": "table",
+ },
+ ],
+ "type": "blockContainer",
+}
+`;
+
+exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedColWidths to/from prosemirror 1`] = `
+{
+ "attrs": {
+ "backgroundColor": "default",
+ "id": "1",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": null,
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ ],
+ "type": "table",
+ },
+ ],
+ "type": "blockContainer",
+}
+`;
+
+exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedRowspansAndColspans to/from prosemirror 1`] = `
+{
+ "attrs": {
+ "backgroundColor": "default",
+ "id": "1",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "red",
+ "colspan": 2,
+ "colwidth": [
+ 100,
+ 200,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "blue",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "yellow",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "red",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 100,
+ ],
+ "rowspan": 2,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 2,
+ "colwidth": [
+ 200,
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ ],
+ "type": "tableRow",
+ },
+ {
+ "content": [
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 200,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
+ },
+ "content": [
+ {
+ "content": [
+ {
+ "text": "Table Cell",
+ "type": "text",
+ },
+ ],
+ "type": "tableParagraph",
+ },
+ ],
+ "type": "tableCell",
+ },
+ {
+ "attrs": {
+ "backgroundColor": "default",
+ "colspan": 1,
+ "colwidth": [
+ 300,
+ ],
+ "rowspan": 1,
+ "textAlignment": "left",
+ "textColor": "default",
},
"content": [
{
diff --git a/packages/core/src/api/nodeConversions/blockToNode.ts b/packages/core/src/api/nodeConversions/blockToNode.ts
index 58fad5eeb7..e689ef2578 100644
--- a/packages/core/src/api/nodeConversions/blockToNode.ts
+++ b/packages/core/src/api/nodeConversions/blockToNode.ts
@@ -1,4 +1,4 @@
-import { Mark, Node, Schema } from "@tiptap/pm/model";
+import { Attrs, Fragment, Mark, Node, Schema } from "@tiptap/pm/model";
import UniqueID from "../../extensions/UniqueID/UniqueID.js";
import type {
@@ -16,7 +16,9 @@ import {
isPartialLinkInlineContent,
isStyledTextInlineContent,
} from "../../schema/inlineContent/types.js";
+import { getColspan, isPartialTableCell } from "../../util/table.js";
import { UnreachableCaseError } from "../../util/typescript.js";
+import { getAbsoluteTableCells } from "../blockManipulation/tables/tables.js";
/**
* Convert a StyledText inline element to a
@@ -174,34 +176,75 @@ export function tableContentToNodes<
styleSchema: StyleSchema
): Node[] {
const rowNodes: Node[] = [];
+ // Header rows and columns are used to determine the type of the cell
+ // If headerRows is 1, then the first row is a header row
+ const headerRows = new Array(tableContent.headerRows ?? 0).fill(true);
+ // If headerCols is 1, then the first column is a header column
+ const headerCols = new Array(tableContent.headerCols ?? 0).fill(true);
- for (const row of tableContent.rows) {
+ const columnWidths: (number | undefined)[] = tableContent.columnWidths ?? [];
+
+ for (let rowIndex = 0; rowIndex < tableContent.rows.length; rowIndex++) {
+ const row = tableContent.rows[rowIndex];
const columnNodes: Node[] = [];
- for (let i = 0; i < row.cells.length; i++) {
- const cell = row.cells[i];
- let pNode: Node;
+ const isHeaderRow = headerRows[rowIndex];
+ for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex++) {
+ const cell = row.cells[cellIndex];
+ const isHeaderCol = headerCols[cellIndex];
+ /**
+ * The attributes of the cell to apply to the node
+ */
+ const attrs: Attrs | undefined = undefined;
+ /**
+ * The content of the cell to apply to the node
+ */
+ let content: Fragment | Node | readonly Node[] | null = null;
+
+ // Colwidths are absolutely referenced to the table, so we need to resolve the relative cell index to the absolute cell index
+ const absoluteCellIndex = getAbsoluteTableCells(
+ {
+ row: rowIndex,
+ col: cellIndex,
+ },
+ { type: "table", content: tableContent } as any
+ );
+
+ // Assume the column width is the width of the cell at the absolute cell index
+ let colwidth: (number | undefined)[] | null = columnWidths[
+ absoluteCellIndex.col
+ ]
+ ? [columnWidths[absoluteCellIndex.col]]
+ : null;
+
if (!cell) {
- pNode = schema.nodes["tableParagraph"].createChecked({});
+ // No-op
} else if (typeof cell === "string") {
- pNode = schema.nodes["tableParagraph"].createChecked(
- {},
- schema.text(cell)
- );
+ content = schema.text(cell);
+ } else if (isPartialTableCell(cell)) {
+ if (cell.content) {
+ content = inlineContentToNodes(cell.content, schema, styleSchema);
+ }
+ const colspan = getColspan(cell);
+
+ if (colspan > 1) {
+ // If the cell has a > 1 colspan, we need to get the column width for each cell in the span
+ colwidth = new Array(colspan).fill(false).map((_, i) => {
+ // Starting from the absolute column index, get the column width for each cell in the span
+ return columnWidths[absoluteCellIndex.col + i] ?? undefined;
+ });
+ }
} else {
- const textNodes = inlineContentToNodes(cell, schema, styleSchema);
- pNode = schema.nodes["tableParagraph"].createChecked({}, textNodes);
+ content = inlineContentToNodes(cell, schema, styleSchema);
}
- const cellNode = schema.nodes["tableCell"].createChecked(
+ const cellNode = schema.nodes[
+ isHeaderCol || isHeaderRow ? "tableHeader" : "tableCell"
+ ].createChecked(
{
- // The colwidth array should have multiple values when the colspan of
- // a cell is greater than 1. However, this is not yet implemented so
- // we can always assume a length of 1.
- colwidth: tableContent.columnWidths?.[i]
- ? [tableContent.columnWidths[i]]
- : null,
+ ...(isPartialTableCell(cell) ? cell.props : {}),
+ colwidth,
},
- pNode
+ schema.nodes["tableParagraph"].createChecked(attrs, content)
);
columnNodes.push(cellNode);
}
diff --git a/packages/core/src/api/nodeConversions/nodeToBlock.ts b/packages/core/src/api/nodeConversions/nodeToBlock.ts
index a3c224647a..5d25d1ea58 100644
--- a/packages/core/src/api/nodeConversions/nodeToBlock.ts
+++ b/packages/core/src/api/nodeConversions/nodeToBlock.ts
@@ -10,6 +10,7 @@ import type {
InlineContentSchema,
StyleSchema,
Styles,
+ TableCell,
TableContent,
} from "../../schema/index.js";
import { getBlockInfoWithManualOffset } from "../getBlockInfoFromPos.js";
@@ -31,36 +32,97 @@ export function contentNodeToTableContent<
const ret: TableContent = {
type: "tableContent",
columnWidths: [],
+ headerRows: undefined,
+ headerCols: undefined,
rows: [],
};
- contentNode.content.forEach((rowNode, _offset, index) => {
+ /**
+ * A matrix of boolean values indicating whether a cell is a header.
+ * The first index is the row index, the second index is the cell index.
+ */
+ const headerMatrix: boolean[][] = [];
+
+ contentNode.content.forEach((rowNode, _offset, rowIndex) => {
const row: TableContent["rows"][0] = {
cells: [],
};
- if (index === 0) {
+ if (rowIndex === 0) {
rowNode.content.forEach((cellNode) => {
- // The colwidth array should have multiple values when the colspan of a
- // cell is greater than 1. However, this is not yet implemented so we
- // can always assume a length of 1.
- ret.columnWidths.push(cellNode.attrs.colwidth?.[0] || undefined);
+ let colWidth = cellNode.attrs.colwidth as null | undefined | number[];
+ if (colWidth === undefined || colWidth === null) {
+ colWidth = new Array(cellNode.attrs.colspan ?? 1).fill(undefined);
+ }
+ ret.columnWidths.push(...colWidth);
});
}
- rowNode.content.forEach((cellNode) => {
- row.cells.push(
- contentNodeToInlineContent(
- cellNode.firstChild!,
- inlineContentSchema,
- styleSchema
+ row.cells = rowNode.content.content.map((cellNode, cellIndex) => {
+ if (!headerMatrix[rowIndex]) {
+ headerMatrix[rowIndex] = [];
+ }
+ // Mark the cell as a header if it is a tableHeader node.
+ headerMatrix[rowIndex][cellIndex] = cellNode.type.name === "tableHeader";
+ // Convert cell content to inline content and merge adjacent styled text nodes
+ const content = cellNode.content.content
+ .map((child) =>
+ contentNodeToInlineContent(child, inlineContentSchema, styleSchema)
)
- );
+ // The reason that we merge this content is that we allow table cells to contain multiple tableParagraph nodes
+ // So that we can leverage prosemirror-tables native merging
+ // If the schema only allowed a single tableParagraph node, then the merging would not work and cause prosemirror to fit the content into a new cell
+ .reduce((acc, contentPartial) => {
+ if (!acc.length) {
+ return contentPartial;
+ }
+
+ const last = acc[acc.length - 1];
+ const first = contentPartial[0];
+
+ // Only merge if the last and first content are both styled text nodes and have the same styles
+ if (
+ isStyledTextInlineContent(last) &&
+ isStyledTextInlineContent(first) &&
+ JSON.stringify(last.styles) === JSON.stringify(first.styles)
+ ) {
+ // Join them together if they have the same styles
+ last.text += "\n" + first.text;
+ acc.push(...contentPartial.slice(1));
+ return acc;
+ }
+ acc.push(...contentPartial);
+ return acc;
+ }, [] as InlineContent[]);
+
+ return {
+ type: "tableCell",
+ content,
+ props: {
+ colspan: cellNode.attrs.colspan,
+ rowspan: cellNode.attrs.rowspan,
+ backgroundColor: cellNode.attrs.backgroundColor,
+ textColor: cellNode.attrs.textColor,
+ textAlignment: cellNode.attrs.textAlignment,
+ },
+ } satisfies TableCell;
});
ret.rows.push(row);
});
+ for (let i = 0; i < headerMatrix.length; i++) {
+ if (headerMatrix[i].every((isHeader) => isHeader)) {
+ ret.headerRows = (ret.headerRows ?? 0) + 1;
+ }
+ }
+
+ for (let i = 0; i < headerMatrix[0]?.length; i++) {
+ if (headerMatrix.every((row) => row[i])) {
+ ret.headerCols = (ret.headerCols ?? 0) + 1;
+ }
+ }
+
return ret;
}
diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json b/packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json
index 62f9034427..b1ebb03e09 100644
--- a/packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json
+++ b/packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json
@@ -374,80 +374,171 @@
null,
null
],
+ "headerRows": 1,
"rows": [
{
"cells": [
- [
- {
- "type": "text",
- "text": "Cell 1",
- "styles": {}
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 1",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ],
- [
- {
- "type": "text",
- "text": "Cell 2",
- "styles": {}
+ },
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 2",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ],
- [
- {
- "type": "text",
- "text": "Cell 3",
- "styles": {}
+ },
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 3",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ]
+ }
]
},
{
"cells": [
- [
- {
- "type": "text",
- "text": "Cell 4",
- "styles": {}
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 4",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ],
- [
- {
- "type": "text",
- "text": "Cell 5",
- "styles": {}
+ },
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 5",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ],
- [
- {
- "type": "text",
- "text": "Cell 6",
- "styles": {}
+ },
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 6",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ]
+ }
]
},
{
"cells": [
- [
- {
- "type": "text",
- "text": "Cell 7",
- "styles": {}
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 7",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ],
- [
- {
- "type": "text",
- "text": "Cell 8",
- "styles": {}
+ },
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 8",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ],
- [
- {
- "type": "text",
- "text": "Cell 9",
- "styles": {}
+ },
+ {
+ "type": "tableCell",
+ "content": [
+ {
+ "type": "text",
+ "text": "Cell 9",
+ "styles": {}
+ }
+ ],
+ "props": {
+ "colspan": 1,
+ "rowspan": 1,
+ "backgroundColor": "default",
+ "textColor": "default",
+ "textAlignment": "left"
}
- ]
+ }
]
}
]
diff --git a/packages/core/src/api/testUtil/cases/defaultSchema.ts b/packages/core/src/api/testUtil/cases/defaultSchema.ts
index b533d62157..2dbfaffb5c 100644
--- a/packages/core/src/api/testUtil/cases/defaultSchema.ts
+++ b/packages/core/src/api/testUtil/cases/defaultSchema.ts
@@ -391,13 +391,115 @@ export const defaultSchemaTestCases: EditorTestCases<
type: "tableContent",
rows: [
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
],
},
@@ -414,13 +516,115 @@ export const defaultSchemaTestCases: EditorTestCases<
columnWidths: [100, 200, 300],
rows: [
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
],
},
@@ -437,13 +641,582 @@ export const defaultSchemaTestCases: EditorTestCases<
columnWidths: [100, undefined, 300],
rows: [
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ {
+ name: "table/mixedCellColors",
+ blocks: [
+ {
+ type: "table",
+ content: {
+ type: "tableContent",
+ columnWidths: [100, undefined, 300],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "red",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "blue",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "blue",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "yellow",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "red",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ {
+ name: "table/mixedRowspansAndColspans",
+ blocks: [
+ {
+ type: "table",
+ content: {
+ type: "tableContent",
+ columnWidths: [100, 200, 300],
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "red",
+ colspan: 2,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "blue",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "yellow",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "red",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 2,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 2,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
+ ],
+ },
+ },
+ ],
+ },
+ {
+ name: "table/headerRows",
+ blocks: [
+ {
+ type: "table",
+ content: {
+ headerRows: 1,
+ type: "tableContent",
+ rows: [
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
{
- cells: ["Table Cell", "Table Cell", "Table Cell"],
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ {
+ name: "table/headerCols",
+ blocks: [
+ {
+ type: "table",
+ content: {
+ headerCols: 1,
+ type: "tableContent",
+ rows: [
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
+ },
+ {
+ cells: [
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ {
+ type: "tableCell",
+ content: ["Table Cell"],
+ props: {
+ backgroundColor: "default",
+ colspan: 1,
+ rowspan: 1,
+ textAlignment: "left",
+ textColor: "default",
+ },
+ },
+ ],
},
],
},
diff --git a/packages/core/src/api/testUtil/partialBlockTestUtil.ts b/packages/core/src/api/testUtil/partialBlockTestUtil.ts
index e6e8802cc1..8c6a15f623 100644
--- a/packages/core/src/api/testUtil/partialBlockTestUtil.ts
+++ b/packages/core/src/api/testUtil/partialBlockTestUtil.ts
@@ -1,7 +1,12 @@
import { Block, PartialBlock } from "../../blocks/defaultBlocks.js";
import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
import UniqueID from "../../extensions/UniqueID/UniqueID.js";
-import { BlockSchema, TableContent } from "../../schema/blocks/types.js";
+import {
+ BlockSchema,
+ PartialTableCell,
+ TableCell,
+ TableContent,
+} from "../../schema/blocks/types.js";
import {
InlineContent,
InlineContentSchema,
@@ -28,8 +33,16 @@ function textShorthandToStyledText(
}
function partialContentToInlineContent(
- content: PartialInlineContent | TableContent | undefined
-): InlineContent[] | TableContent | undefined {
+ content:
+ | PartialInlineContent
+ | PartialTableCell
+ | TableContent
+ | undefined
+):
+ | InlineContent[]
+ | TableContent
+ | TableCell
+ | undefined {
if (typeof content === "string") {
return textShorthandToStyledText(content);
}
@@ -59,6 +72,8 @@ function partialContentToInlineContent(
return {
type: "tableContent",
columnWidths: content.columnWidths,
+ headerRows: content.headerRows,
+ headerCols: content.headerCols,
rows: content.rows.map((row) => ({
...row,
cells: row.cells.map(
@@ -66,6 +81,18 @@ function partialContentToInlineContent(
),
})),
};
+ } else if (content?.type === "tableCell") {
+ return {
+ type: "tableCell",
+ content: partialContentToInlineContent(content.content) as any[],
+ props: {
+ backgroundColor: content.props?.backgroundColor ?? "default",
+ textColor: content.props?.textColor ?? "default",
+ textAlignment: content.props?.textAlignment ?? "left",
+ colspan: content.props?.colspan ?? 1,
+ rowspan: content.props?.rowspan ?? 1,
+ },
+ } satisfies TableCell;
}
return content;
@@ -103,7 +130,13 @@ export function partialBlockToBlockForTesting<
contentType === "inline"
? []
: contentType === "table"
- ? { type: "tableContent", columnWidths: [], rows: [] }
+ ? {
+ type: "tableContent",
+ columnWidths: undefined,
+ headerRows: undefined,
+ headerCols: undefined,
+ rows: [],
+ }
: (undefined as any),
children: [] as any,
...partialBlock,
@@ -131,6 +164,8 @@ export function partialBlockToBlockForTesting<
content?.columnWidths ||
content?.rows[0]?.cells.map(() => undefined) ||
[],
+ headerRows: content?.headerRows || undefined,
+ headerCols: content?.headerCols || undefined,
rows:
content?.rows.map((row) => ({
cells: row.cells.map((cell) => partialContentToInlineContent(cell)),
diff --git a/packages/core/src/blocks/TableBlockContent/TableBlockContent.ts b/packages/core/src/blocks/TableBlockContent/TableBlockContent.ts
index bb35506176..1375a528f3 100644
--- a/packages/core/src/blocks/TableBlockContent/TableBlockContent.ts
+++ b/packages/core/src/blocks/TableBlockContent/TableBlockContent.ts
@@ -1,4 +1,3 @@
-import { Node } from "@tiptap/core";
import { TableCell } from "@tiptap/extension-table-cell";
import { TableHeader } from "@tiptap/extension-table-header";
import { TableRow } from "@tiptap/extension-table-row";
@@ -107,7 +106,7 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
},
});
-const TableParagraph = Node.create({
+const TableParagraph = createStronglyTypedTiptapNode({
name: "tableParagraph",
group: "tableContent",
content: "inline*",
@@ -160,10 +159,17 @@ export const Table = createBlockSpecFromStronglyTypedTiptapNode(
TableExtension,
TableParagraph,
TableHeader.extend({
- content: "tableContent",
+ /**
+ * We allow table headers and cells to have multiple tableContent nodes because
+ * when merging cells, prosemirror-tables will concat the contents of the cells naively.
+ * This would cause that content to overflow into other cells when prosemirror tries to enforce the cell structure.
+ *
+ * So, we manually fix this up when reading back in the `nodeToBlock` and only ever place a single tableContent back into the cell.
+ */
+ content: "tableContent+",
}),
TableCell.extend({
- content: "tableContent",
+ content: "tableContent+",
}),
TableRow,
]
diff --git a/packages/core/src/blocks/defaultBlockTypeGuards.ts b/packages/core/src/blocks/defaultBlockTypeGuards.ts
index 169f9d97ea..1704456045 100644
--- a/packages/core/src/blocks/defaultBlockTypeGuards.ts
+++ b/packages/core/src/blocks/defaultBlockTypeGuards.ts
@@ -1,3 +1,4 @@
+import { CellSelection } from "prosemirror-tables";
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
import {
BlockFromConfig,
@@ -14,6 +15,7 @@ import {
defaultInlineContentSchema,
} from "./defaultBlocks.js";
import { defaultProps } from "./defaultProps.js";
+import { Selection } from "prosemirror-state";
export function checkDefaultBlockTypeInSchema<
BlockType extends keyof DefaultBlockSchema,
@@ -159,3 +161,9 @@ export function checkBlockHasDefaultProp<
> {
return checkBlockTypeHasDefaultProp(prop, block.type, editor);
}
+
+export function isTableCellSelection(
+ selection: Selection
+): selection is CellSelection {
+ return selection instanceof CellSelection;
+}
diff --git a/packages/core/src/editor/Block.css b/packages/core/src/editor/Block.css
index 6bf1061815..07413fa894 100644
--- a/packages/core/src/editor/Block.css
+++ b/packages/core/src/editor/Block.css
@@ -499,23 +499,23 @@ NESTED BLOCKS
/* TEXT ALIGNMENT */
[data-text-alignment="left"] {
- justify-content: flex-start;
- text-align: left;
+ justify-content: flex-start !important;
+ text-align: left !important;
}
[data-text-alignment="center"] {
- justify-content: center;
- text-align: center;
+ justify-content: center !important;
+ text-align: center !important;
}
[data-text-alignment="right"] {
- justify-content: flex-end;
- text-align: right;
+ justify-content: flex-end !important;
+ text-align: right !important;
}
[data-text-alignment="justify"] {
- justify-content: flex-start;
- text-align: justify;
+ justify-content: flex-start !important;
+ text-align: justify !important;
}
.bn-block-column-list {
diff --git a/packages/core/src/editor/BlockNoteEditor.ts b/packages/core/src/editor/BlockNoteEditor.ts
index 030a9fc281..980cc0cc4c 100644
--- a/packages/core/src/editor/BlockNoteEditor.ts
+++ b/packages/core/src/editor/BlockNoteEditor.ts
@@ -258,6 +258,36 @@ export type BlockNoteEditorOptions<
*/
tabBehavior: "prefer-navigate-ui" | "prefer-indent";
+ /**
+ * Allows enabling / disabling features of tables.
+ */
+ tables?: {
+ /**
+ * Whether to allow splitting and merging cells within a table.
+ *
+ * @default false
+ */
+ splitCells?: boolean;
+ /**
+ * Whether to allow changing the background color of cells.
+ *
+ * @default false
+ */
+ cellBackgroundColor?: boolean;
+ /**
+ * Whether to allow changing the text color of cells.
+ *
+ * @default false
+ */
+ cellTextColor?: boolean;
+ /**
+ * Whether to allow changing cells into headers.
+ *
+ * @default false
+ */
+ headers?: boolean;
+ };
+
trailingBlock?: boolean;
/**
@@ -307,7 +337,10 @@ export class BlockNoteEditor<
> extends EventEmitter<{
create: void;
}> {
- private readonly _pmSchema: Schema;
+ /**
+ * The underlying prosemirror schema
+ */
+ public readonly pmSchema: Schema;
/**
* extensions that are added to the editor, can be tiptap extensions or prosemirror plugins
@@ -400,10 +433,17 @@ export class BlockNoteEditor<
public readonly resolveFileUrl?: (url: string) => Promise;
public readonly resolveUsers?: (userIds: string[]) => Promise;
-
- public get pmSchema() {
- return this._pmSchema;
- }
+ /**
+ * Editor settings
+ */
+ public readonly settings: {
+ tables: {
+ splitCells: boolean;
+ cellBackgroundColor: boolean;
+ cellTextColor: boolean;
+ headers: boolean;
+ };
+ };
public static create<
BSchema extends BlockSchema = DefaultBlockSchema,
@@ -443,6 +483,14 @@ export class BlockNoteEditor<
}
this.dictionary = options.dictionary || en;
+ this.settings = {
+ tables: {
+ splitCells: options?.tables?.splitCells ?? false,
+ cellBackgroundColor: options?.tables?.cellBackgroundColor ?? false,
+ cellTextColor: options?.tables?.cellTextColor ?? false,
+ headers: options?.tables?.headers ?? false,
+ },
+ };
// apply defaults
const newOptions = {
@@ -625,18 +673,18 @@ export class BlockNoteEditor<
view: any;
contentComponent: any;
};
- this._pmSchema = this._tiptapEditor.schema;
+ this.pmSchema = this._tiptapEditor.schema;
} else {
// In headless mode, we don't instantiate an underlying TipTap editor,
// but we still need the schema
- this._pmSchema = getSchema(tiptapOptions.extensions!);
+ this.pmSchema = getSchema(tiptapOptions.extensions!);
}
this.emit("create");
}
- dispatch(tr: Transaction) {
+ dispatch = (tr: Transaction) => {
this._tiptapEditor.dispatch(tr);
- }
+ };
/**
* Mount the editor to a parent DOM element. Call mount(undefined) to clean up
@@ -650,10 +698,20 @@ export class BlockNoteEditor<
this._tiptapEditor.mount(parentElement, contentComponent);
};
+ /**
+ * Get the underlying prosemirror view
+ */
public get prosemirrorView() {
return this._tiptapEditor.view;
}
+ /**
+ * Get the underlying prosemirror state
+ */
+ public get prosemirrorState() {
+ return this._tiptapEditor.state;
+ }
+
public get domElement() {
return this.prosemirrorView?.dom as HTMLDivElement | undefined;
}
@@ -702,7 +760,7 @@ export class BlockNoteEditor<
public get document(): Block[] {
const blocks: Block[] = [];
- this._tiptapEditor.state.doc.firstChild!.descendants((node) => {
+ this.prosemirrorState.doc.firstChild!.descendants((node) => {
blocks.push(
nodeToBlock(
node,
diff --git a/packages/core/src/extensions/BackgroundColor/BackgroundColorExtension.ts b/packages/core/src/extensions/BackgroundColor/BackgroundColorExtension.ts
index 63ca193e65..fca4922a1a 100644
--- a/packages/core/src/extensions/BackgroundColor/BackgroundColorExtension.ts
+++ b/packages/core/src/extensions/BackgroundColor/BackgroundColorExtension.ts
@@ -7,7 +7,7 @@ export const BackgroundColorExtension = Extension.create({
addGlobalAttributes() {
return [
{
- types: ["blockContainer"],
+ types: ["blockContainer", "tableCell", "tableHeader"],
attributes: {
backgroundColor: {
default: defaultProps.backgroundColor.default,
diff --git a/packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts b/packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts
index 135c5a67d5..7b35776b41 100644
--- a/packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts
+++ b/packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts
@@ -1,8 +1,35 @@
import { Plugin, PluginKey, PluginView } from "prosemirror-state";
+import {
+ addColumnAfter,
+ addColumnBefore,
+ addRowAfter,
+ addRowBefore,
+ CellSelection,
+ deleteColumn,
+ deleteRow,
+ mergeCells,
+ splitCell,
+} from "prosemirror-tables";
import { Decoration, DecorationSet, EditorView } from "prosemirror-view";
+import {
+ addRowsOrColumns,
+ areInSameColumn,
+ canColumnBeDraggedInto,
+ canRowBeDraggedInto,
+ cropEmptyRowsOrColumns,
+ getCellsAtColumnHandle,
+ getCellsAtRowHandle,
+ getDimensionsOfTable,
+ moveColumn,
+ moveRow,
+ RelativeCellIndices,
+} from "../../api/blockManipulation/tables/tables.js";
import { nodeToBlock } from "../../api/nodeConversions/nodeToBlock.js";
import { getNodeById } from "../../api/nodeUtil.js";
-import { checkBlockIsDefaultType } from "../../blocks/defaultBlockTypeGuards.js";
+import {
+ checkBlockIsDefaultType,
+ isTableCellSelection,
+} from "../../blocks/defaultBlockTypeGuards.js";
import { DefaultBlockSchema } from "../../blocks/defaultBlocks.js";
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
import {
@@ -16,6 +43,7 @@ import { getDraggableBlockFromElement } from "../getDraggableBlockFromElement.js
let dragImageElement: HTMLElement | undefined;
+// TODO consider switching this to jotai, it is a bit messy and noisy
export type TableHandlesState<
I extends InlineContentSchema,
S extends StyleSchema
@@ -159,7 +187,10 @@ export class TableHandlesView<
"dragover",
this.dragOverHandler as EventListener
);
- pmView.root.addEventListener("drop", this.dropHandler as EventListener);
+ pmView.root.addEventListener(
+ "drop",
+ this.dropHandler as unknown as EventListener
+ );
}
viewMousedownHandler = () => {
@@ -284,11 +315,11 @@ export class TableHandlesView<
referencePosTable: tableRect,
block: tableBlock,
widgetContainer,
- colIndex: hideHandles ? undefined : this.state!.colIndex,
- rowIndex: hideHandles ? undefined : this.state!.rowIndex,
+ colIndex: hideHandles ? undefined : this.state?.colIndex,
+ rowIndex: hideHandles ? undefined : this.state?.rowIndex,
referencePosCell: hideHandles
? undefined
- : this.state!.referencePosCell,
+ : this.state?.referencePosCell,
};
} else {
const colIndex = getChildIndex(target.domNode);
@@ -427,7 +458,7 @@ export class TableHandlesView<
dropHandler = (event: DragEvent) => {
this.mouseState = "up";
if (this.state === undefined || this.state.draggingState === undefined) {
- return;
+ return false;
}
if (
@@ -443,33 +474,64 @@ export class TableHandlesView<
const { draggingState, colIndex, rowIndex } = this.state;
- const rows = this.state.block.content.rows;
+ const columnWidths = this.state.block.content.columnWidths;
if (draggingState.draggedCellOrientation === "row") {
- const rowToMove = rows[draggingState.originalIndex];
- rows.splice(draggingState.originalIndex, 1);
- rows.splice(rowIndex, 0, rowToMove);
+ if (
+ !canRowBeDraggedInto(
+ this.state.block,
+ draggingState.originalIndex,
+ rowIndex
+ )
+ ) {
+ // If the target row is invalid, don't move the row
+ return false;
+ }
+ const newTable = moveRow(
+ this.state.block,
+ draggingState.originalIndex,
+ rowIndex
+ );
+ this.editor.updateBlock(this.state.block, {
+ type: "table",
+ content: {
+ ...this.state.block.content,
+ rows: newTable as any,
+ },
+ });
} else {
- const cellsToMove = rows.map(
- (row) => row.cells[draggingState.originalIndex]
+ if (
+ !canColumnBeDraggedInto(
+ this.state.block,
+ draggingState.originalIndex,
+ colIndex
+ )
+ ) {
+ // If the target column is invalid, don't move the column
+ return false;
+ }
+ const newTable = moveColumn(
+ this.state.block,
+ draggingState.originalIndex,
+ colIndex
);
- rows.forEach((row, rowIndex) => {
- row.cells.splice(draggingState.originalIndex, 1);
- row.cells.splice(colIndex, 0, cellsToMove[rowIndex]);
+ const [columnWidth] = columnWidths.splice(draggingState.originalIndex, 1);
+ columnWidths.splice(colIndex, 0, columnWidth);
+ this.editor.updateBlock(this.state.block, {
+ type: "table",
+ content: {
+ ...this.state.block.content,
+ columnWidths,
+ rows: newTable as any,
+ },
});
}
- this.editor.updateBlock(this.state.block, {
- type: "table",
- content: {
- type: "tableContent",
- rows: rows,
- },
- });
-
// Have to reset text cursor position to the block as `updateBlock` moves
// the existing selection out of the block.
this.editor.setTextCursorPosition(this.state.block.id);
+
+ return true;
};
// Updates drag handles when the table is modified or removed.
update() {
@@ -488,8 +550,9 @@ export class TableHandlesView<
return;
}
- const rowCount = this.state.block.content.rows.length;
- const colCount = this.state.block.content.rows[0].cells.length;
+ const { height: rowCount, width: colCount } = getDimensionsOfTable(
+ this.state.block
+ );
if (
this.state.rowIndex !== undefined &&
@@ -520,8 +583,12 @@ export class TableHandlesView<
) {
const row = tableBody.children[this.state.rowIndex];
const cell = row.children[this.state.colIndex];
-
- this.state.referencePosCell = cell.getBoundingClientRect();
+ if (cell) {
+ this.state.referencePosCell = cell.getBoundingClientRect();
+ } else {
+ this.state.rowIndex = undefined;
+ this.state.colIndex = undefined;
+ }
}
this.state.referencePosTable = tableBody.getBoundingClientRect();
@@ -538,7 +605,7 @@ export class TableHandlesView<
);
this.pmView.root.removeEventListener(
"drop",
- this.dropHandler as EventListener
+ this.dropHandler as unknown as EventListener
);
}
}
@@ -594,35 +661,53 @@ export class TableHandlesProsemirrorPlugin<
if (newIndex === this.view.state.draggingState.originalIndex) {
return DecorationSet.create(state.doc, decorations);
+ } else if (
+ this.view.state.draggingState.draggedCellOrientation === "row" &&
+ !canRowBeDraggedInto(
+ this.view.state.block,
+ this.view.state.draggingState.originalIndex,
+ newIndex
+ )
+ ) {
+ return DecorationSet.create(state.doc, decorations);
+ } else if (
+ this.view.state.draggingState.draggedCellOrientation === "col" &&
+ !canColumnBeDraggedInto(
+ this.view.state.block,
+ this.view.state.draggingState.originalIndex,
+ newIndex
+ )
+ ) {
+ return DecorationSet.create(state.doc, decorations);
}
// Gets the table to show the drop cursor in.
const tableResolvedPos = state.doc.resolve(this.view.tablePos + 1);
- const tableNode = tableResolvedPos.node();
+ const originalIndex = this.view.state.draggingState.originalIndex;
if (this.view.state.draggingState.draggedCellOrientation === "row") {
- // Gets the row at the new index.
- const rowResolvedPos = state.doc.resolve(
- tableResolvedPos.posAtIndex(newIndex) + 1
+ const cellsInRow = getCellsAtRowHandle(
+ this.view.state.block,
+ newIndex
);
- const rowNode = rowResolvedPos.node();
- // Iterates over all cells in the row.
- for (let i = 0; i < rowNode.childCount; i++) {
- // Gets each cell in the row.
+ cellsInRow.forEach(({ row, col }) => {
+ // Gets each row in the table.
+ const rowResolvedPos = state.doc.resolve(
+ tableResolvedPos.posAtIndex(row) + 1
+ );
+
+ // Gets the cell within the row.
const cellResolvedPos = state.doc.resolve(
- rowResolvedPos.posAtIndex(i) + 1
+ rowResolvedPos.posAtIndex(col) + 1
);
const cellNode = cellResolvedPos.node();
-
// Creates a decoration at the start or end of each cell,
// depending on whether the new index is before or after the
// original index.
const decorationPos =
cellResolvedPos.pos +
- (newIndex > this.view.state.draggingState.originalIndex
- ? cellNode.nodeSize - 2
- : 0);
+ (newIndex > originalIndex ? cellNode.nodeSize - 2 : 0);
decorations.push(
// The widget is a small bar which spans the width of the cell.
Decoration.widget(decorationPos, () => {
@@ -635,9 +720,7 @@ export class TableHandlesProsemirrorPlugin<
// table cells is an odd number of pixels. So this makes the
// positioning slightly more consistent regardless of where
// the row is being dropped.
- if (
- newIndex > this.view!.state!.draggingState!.originalIndex
- ) {
+ if (newIndex > originalIndex) {
widget.style.bottom = "-2px";
} else {
widget.style.top = "-3px";
@@ -647,18 +730,22 @@ export class TableHandlesProsemirrorPlugin<
return widget;
})
);
- }
+ });
} else {
- // Iterates over all rows in the table.
- for (let i = 0; i < tableNode.childCount; i++) {
+ const cellsInColumn = getCellsAtColumnHandle(
+ this.view.state.block,
+ newIndex
+ );
+
+ cellsInColumn.forEach(({ row, col }) => {
// Gets each row in the table.
const rowResolvedPos = state.doc.resolve(
- tableResolvedPos.posAtIndex(i) + 1
+ tableResolvedPos.posAtIndex(row) + 1
);
- // Gets the cell at the new index in the row.
+ // Gets the cell within the row.
const cellResolvedPos = state.doc.resolve(
- rowResolvedPos.posAtIndex(newIndex) + 1
+ rowResolvedPos.posAtIndex(col) + 1
);
const cellNode = cellResolvedPos.node();
@@ -667,9 +754,7 @@ export class TableHandlesProsemirrorPlugin<
// original index.
const decorationPos =
cellResolvedPos.pos +
- (newIndex > this.view.state.draggingState.originalIndex
- ? cellNode.nodeSize - 2
- : 0);
+ (newIndex > originalIndex ? cellNode.nodeSize - 2 : 0);
decorations.push(
// The widget is a small bar which spans the height of the cell.
@@ -683,9 +768,7 @@ export class TableHandlesProsemirrorPlugin<
// table cells is an odd number of pixels. So this makes the
// positioning slightly more consistent regardless of where
// the column is being dropped.
- if (
- newIndex > this.view!.state!.draggingState!.originalIndex
- ) {
+ if (newIndex > originalIndex) {
widget.style.right = "-2px";
} else {
widget.style.left = "-3px";
@@ -695,7 +778,7 @@ export class TableHandlesProsemirrorPlugin<
return widget;
})
);
- }
+ });
}
return DecorationSet.create(state.doc, decorations);
@@ -834,4 +917,273 @@ export class TableHandlesProsemirrorPlugin<
unfreezeHandles = () => {
this.view!.menuFrozen = false;
};
+
+ getCellsAtRowHandle = (
+ block: BlockFromConfigNoChildren,
+ relativeRowIndex: RelativeCellIndices["row"]
+ ) => {
+ return getCellsAtRowHandle(block, relativeRowIndex);
+ };
+
+ /**
+ * Get all the cells in a column of the table block.
+ */
+ getCellsAtColumnHandle = (
+ block: BlockFromConfigNoChildren,
+ relativeColumnIndex: RelativeCellIndices["col"]
+ ) => {
+ return getCellsAtColumnHandle(block, relativeColumnIndex);
+ };
+
+ /**
+ * Sets the selection to the given cell or a range of cells.
+ * @returns The new state after the selection has been set.
+ */
+ private setCellSelection = (
+ relativeStartCell: RelativeCellIndices,
+ relativeEndCell: RelativeCellIndices = relativeStartCell
+ ) => {
+ const view = this.view;
+
+ if (!view) {
+ throw new Error("Table handles view not initialized");
+ }
+
+ const state = this.editor.prosemirrorState;
+ const tableResolvedPos = state.doc.resolve(view.tablePos! + 1);
+ const startRowResolvedPos = state.doc.resolve(
+ tableResolvedPos.posAtIndex(relativeStartCell.row) + 1
+ );
+ const startCellResolvedPos = state.doc.resolve(
+ // No need for +1, since CellSelection expects the position before the cell
+ startRowResolvedPos.posAtIndex(relativeStartCell.col)
+ );
+ const endRowResolvedPos = state.doc.resolve(
+ tableResolvedPos.posAtIndex(relativeEndCell.row) + 1
+ );
+ const endCellResolvedPos = state.doc.resolve(
+ // No need for +1, since CellSelection expects the position before the cell
+ endRowResolvedPos.posAtIndex(relativeEndCell.col)
+ );
+
+ // Begin a new transaction to set the selection
+ const tr = state.tr;
+
+ // Set the selection to the given cell or a range of cells
+ tr.setSelection(
+ new CellSelection(startCellResolvedPos, endCellResolvedPos)
+ );
+
+ // Quickly apply the transaction to get the new state to update the selection before splitting the cell
+ return state.apply(tr);
+ };
+
+ /**
+ * Adds a row or column to the table using prosemirror-table commands
+ */
+ addRowOrColumn = (
+ index: RelativeCellIndices["row"] | RelativeCellIndices["col"],
+ direction:
+ | { orientation: "row"; side: "above" | "below" }
+ | { orientation: "column"; side: "left" | "right" }
+ ) => {
+ const state = this.setCellSelection(
+ direction.orientation === "row"
+ ? { row: index, col: 0 }
+ : { row: 0, col: index }
+ );
+ if (direction.orientation === "row") {
+ if (direction.side === "above") {
+ return addRowBefore(state, this.editor.dispatch);
+ } else {
+ return addRowAfter(state, this.editor.dispatch);
+ }
+ } else {
+ if (direction.side === "left") {
+ return addColumnBefore(state, this.editor.dispatch);
+ } else {
+ return addColumnAfter(state, this.editor.dispatch);
+ }
+ }
+ };
+
+ /**
+ * Removes a row or column from the table using prosemirror-table commands
+ */
+ removeRowOrColumn = (
+ index: RelativeCellIndices["row"] | RelativeCellIndices["col"],
+ direction: "row" | "column"
+ ) => {
+ const state = this.setCellSelection(
+ direction === "row" ? { row: index, col: 0 } : { row: 0, col: index }
+ );
+
+ if (direction === "row") {
+ return deleteRow(state, this.editor.dispatch);
+ } else {
+ return deleteColumn(state, this.editor.dispatch);
+ }
+ };
+
+ /**
+ * Merges the cells in the table block.
+ */
+ mergeCells = (cellsToMerge?: {
+ relativeStartCell: RelativeCellIndices;
+ relativeEndCell: RelativeCellIndices;
+ }) => {
+ const state = cellsToMerge
+ ? this.setCellSelection(
+ cellsToMerge.relativeStartCell,
+ cellsToMerge.relativeEndCell
+ )
+ : this.editor.prosemirrorState;
+
+ return mergeCells(state, this.editor.dispatch);
+ };
+
+ /**
+ * Splits the cell in the table block.
+ * If no cell is provided, the current cell selected will be split.
+ */
+ splitCell = (relativeCellToSplit?: RelativeCellIndices) => {
+ const state = relativeCellToSplit
+ ? this.setCellSelection(relativeCellToSplit)
+ : this.editor.prosemirrorState;
+
+ return splitCell(state, this.editor.dispatch);
+ };
+
+ /**
+ * Gets the start and end cells of the current cell selection.
+ * @returns The start and end cells of the current cell selection.
+ */
+ getCellSelection = ():
+ | undefined
+ | {
+ from: RelativeCellIndices;
+ to: RelativeCellIndices;
+ /**
+ * All of the cells that are within the selected range.
+ */
+ cells: RelativeCellIndices[];
+ } => {
+ // Based on the current selection, find the table cells that are within the selected range
+ const state = this.editor.prosemirrorState;
+ const selection = state.selection;
+
+ let $fromCell = selection.$from;
+ let $toCell = selection.$to;
+ if (isTableCellSelection(selection)) {
+ // When the selection is a table cell selection, we can find the
+ // from and to cells by iterating over the ranges in the selection
+ const { ranges } = selection;
+ ranges.forEach((range) => {
+ $fromCell = range.$from.min($fromCell ?? range.$from);
+ $toCell = range.$to.max($toCell ?? range.$to);
+ });
+ } else {
+ // When the selection is a normal text selection
+ // Assumes we are within a tableParagraph
+ // And find the from and to cells by resolving the positions
+ $fromCell = state.doc.resolve(
+ selection.$from.pos - selection.$from.parentOffset - 1
+ );
+ $toCell = state.doc.resolve(
+ selection.$to.pos - selection.$to.parentOffset - 1
+ );
+
+ // Opt-out when the selection is not pointing into cells
+ if ($fromCell.pos === 0 || $toCell.pos === 0) {
+ return undefined;
+ }
+ }
+
+ // Find the row and table that the from and to cells are in
+ const $fromRow = state.doc.resolve(
+ $fromCell.pos - $fromCell.parentOffset - 1
+ );
+ const $toRow = state.doc.resolve($toCell.pos - $toCell.parentOffset - 1);
+
+ // Find the table
+ const $table = state.doc.resolve($fromRow.pos - $fromRow.parentOffset - 1);
+
+ // Find the column and row indices of the from and to cells
+ const fromColIndex = $fromCell.index($fromRow.depth);
+ const fromRowIndex = $fromRow.index($table.depth);
+ const toColIndex = $toCell.index($toRow.depth);
+ const toRowIndex = $toRow.index($table.depth);
+
+ const cells: RelativeCellIndices[] = [];
+ for (let row = fromRowIndex; row <= toRowIndex; row++) {
+ for (let col = fromColIndex; col <= toColIndex; col++) {
+ cells.push({ row, col });
+ }
+ }
+
+ return {
+ from: {
+ row: fromRowIndex,
+ col: fromColIndex,
+ },
+ to: {
+ row: toRowIndex,
+ col: toColIndex,
+ },
+ cells,
+ };
+ };
+
+ /**
+ * Gets the direction of the merge based on the current cell selection.
+ *
+ * Returns undefined when there is no cell selection, or the selection is not within a table.
+ */
+ getMergeDirection = (
+ block:
+ | BlockFromConfigNoChildren
+ | undefined
+ ) => {
+ const isSelectingTableCells = isTableCellSelection(
+ this.editor.prosemirrorState.selection
+ )
+ ? this.editor.prosemirrorState.selection
+ : undefined;
+
+ if (
+ !isSelectingTableCells ||
+ !block ||
+ // Only offer the merge button if there is more than one cell selected.
+ isSelectingTableCells.ranges.length <= 1
+ ) {
+ return undefined;
+ }
+
+ const cellSelection = this.getCellSelection();
+
+ if (!cellSelection) {
+ return undefined;
+ }
+
+ if (areInSameColumn(cellSelection.from, cellSelection.to, block)) {
+ return "vertical";
+ }
+
+ return "horizontal";
+ };
+
+ cropEmptyRowsOrColumns = (
+ block: BlockFromConfigNoChildren,
+ removeEmpty: "columns" | "rows"
+ ) => {
+ return cropEmptyRowsOrColumns(block, removeEmpty);
+ };
+
+ addRowsOrColumns = (
+ block: BlockFromConfigNoChildren,
+ addType: "columns" | "rows",
+ numToAdd: number
+ ) => {
+ return addRowsOrColumns(block, addType, numToAdd);
+ };
}
diff --git a/packages/core/src/extensions/TextAlignment/TextAlignmentExtension.ts b/packages/core/src/extensions/TextAlignment/TextAlignmentExtension.ts
index 358ddd0d54..cabde01b91 100644
--- a/packages/core/src/extensions/TextAlignment/TextAlignmentExtension.ts
+++ b/packages/core/src/extensions/TextAlignment/TextAlignmentExtension.ts
@@ -14,6 +14,8 @@ export const TextAlignmentExtension = Extension.create({
"bulletListItem",
"numberedListItem",
"checkListItem",
+ "tableCell",
+ "tableHeader",
],
attributes: {
textAlignment: {
diff --git a/packages/core/src/extensions/TextColor/TextColorExtension.ts b/packages/core/src/extensions/TextColor/TextColorExtension.ts
index a2f4637cf8..4060fea6d6 100644
--- a/packages/core/src/extensions/TextColor/TextColorExtension.ts
+++ b/packages/core/src/extensions/TextColor/TextColorExtension.ts
@@ -7,7 +7,7 @@ export const TextColorExtension = Extension.create({
addGlobalAttributes() {
return [
{
- types: ["blockContainer"],
+ types: ["blockContainer", "tableCell", "tableHeader"],
attributes: {
textColor: {
default: defaultProps.textColor.default,
diff --git a/packages/core/src/i18n/locales/ar.ts b/packages/core/src/i18n/locales/ar.ts
index 496afb342f..29475f75e2 100644
--- a/packages/core/src/i18n/locales/ar.ts
+++ b/packages/core/src/i18n/locales/ar.ts
@@ -141,6 +141,8 @@ export const ar: Dictionary = {
drag_handle: {
delete_menuitem: "حذف",
colors_menuitem: "ألوان",
+ header_row_menuitem: "عنوان الصف",
+ header_column_menuitem: "عنوان العمود",
},
table_handle: {
delete_column_menuitem: "حذف عمود",
@@ -149,6 +151,9 @@ export const ar: Dictionary = {
add_right_menuitem: "إضافة عمود إلى اليمين",
add_above_menuitem: "إضافة صف أعلى",
add_below_menuitem: "إضافة صف أسفل",
+ split_cell_menuitem: "تقسيم الخلية",
+ merge_cells_menuitem: "جمع الخلايا",
+ background_color_menuitem: "لون الخلفية",
},
suggestion_menu: {
no_items_title: "لم يتم العثور على عناصر",
@@ -264,6 +269,9 @@ export const ar: Dictionary = {
align_justify: {
tooltip: "ضبط النص",
},
+ table_cell_merge: {
+ tooltip: "جمع الخلايا",
+ },
comment: {
tooltip: "إضافة ملاحظة",
},
diff --git a/packages/core/src/i18n/locales/en.ts b/packages/core/src/i18n/locales/en.ts
index 15f1536d73..b8115837ac 100644
--- a/packages/core/src/i18n/locales/en.ts
+++ b/packages/core/src/i18n/locales/en.ts
@@ -156,6 +156,8 @@ export const en = {
drag_handle: {
delete_menuitem: "Delete",
colors_menuitem: "Colors",
+ header_row_menuitem: "Header row",
+ header_column_menuitem: "Header column",
},
table_handle: {
delete_column_menuitem: "Delete column",
@@ -164,6 +166,9 @@ export const en = {
add_right_menuitem: "Add column right",
add_above_menuitem: "Add row above",
add_below_menuitem: "Add row below",
+ split_cell_menuitem: "Split cell",
+ merge_cells_menuitem: "Merge cells",
+ background_color_menuitem: "Background color",
},
suggestion_menu: {
no_items_title: "No items found",
@@ -279,6 +284,9 @@ export const en = {
align_justify: {
tooltip: "Justify text",
},
+ table_cell_merge: {
+ tooltip: "Merge cells",
+ },
comment: {
tooltip: "Add comment",
},
diff --git a/packages/core/src/i18n/locales/fr.ts b/packages/core/src/i18n/locales/fr.ts
index eb3c6aa1b1..25ab5297ae 100644
--- a/packages/core/src/i18n/locales/fr.ts
+++ b/packages/core/src/i18n/locales/fr.ts
@@ -180,6 +180,8 @@ export const fr: Dictionary = {
drag_handle: {
delete_menuitem: "Supprimer",
colors_menuitem: "Couleurs",
+ header_row_menuitem: "En-tête de ligne",
+ header_column_menuitem: "En-tête de colonne",
},
table_handle: {
delete_column_menuitem: "Supprimer la colonne",
@@ -188,6 +190,9 @@ export const fr: Dictionary = {
add_right_menuitem: "Ajouter une colonne à droite",
add_above_menuitem: "Ajouter une ligne au-dessus",
add_below_menuitem: "Ajouter une ligne en dessous",
+ split_cell_menuitem: "Diviser la cellule",
+ merge_cells_menuitem: "Fusionner les cellules",
+ background_color_menuitem: "Couleur de fond",
},
suggestion_menu: {
no_items_title: "Aucun élément trouvé",
@@ -303,6 +308,9 @@ export const fr: Dictionary = {
align_justify: {
tooltip: "Justifier le texte",
},
+ table_cell_merge: {
+ tooltip: "Fusionner les cellules",
+ },
comment: {
tooltip: "Ajouter un commentaire",
},
diff --git a/packages/core/src/i18n/locales/is.ts b/packages/core/src/i18n/locales/is.ts
index 022207b818..798c17d6ab 100644
--- a/packages/core/src/i18n/locales/is.ts
+++ b/packages/core/src/i18n/locales/is.ts
@@ -148,6 +148,8 @@ export const is: Dictionary = {
drag_handle: {
delete_menuitem: "Eyða",
colors_menuitem: "Litir",
+ header_row_menuitem: "Höfuðröð",
+ header_column_menuitem: "Höfuðdálkur",
},
table_handle: {
delete_column_menuitem: "Eyða dálki",
@@ -156,6 +158,9 @@ export const is: Dictionary = {
add_right_menuitem: "Bæta dálki við til hægri",
add_above_menuitem: "Bæta röð við fyrir ofan",
add_below_menuitem: "Bæta röð við fyrir neðan",
+ split_cell_menuitem: "Splita dálk",
+ merge_cells_menuitem: "Sameina dálka",
+ background_color_menuitem: "Breyta bakgrunni",
},
suggestion_menu: {
no_items_title: "Engir hlutir fundust",
@@ -271,6 +276,9 @@ export const is: Dictionary = {
align_justify: {
tooltip: "Jafna texta",
},
+ table_cell_merge: {
+ tooltip: "Sameina dálka",
+ },
comment: {
tooltip: "Bæta við athugasemd",
},
diff --git a/packages/core/src/i18n/locales/ja.ts b/packages/core/src/i18n/locales/ja.ts
index 4ed8ba1721..2ddd826332 100644
--- a/packages/core/src/i18n/locales/ja.ts
+++ b/packages/core/src/i18n/locales/ja.ts
@@ -176,6 +176,8 @@ export const ja: Dictionary = {
drag_handle: {
delete_menuitem: "削除",
colors_menuitem: "色を変更",
+ header_row_menuitem: "行の見出し",
+ header_column_menuitem: "列の見出し",
},
table_handle: {
delete_column_menuitem: "列を削除",
@@ -184,6 +186,9 @@ export const ja: Dictionary = {
add_right_menuitem: "右に列を追加",
add_above_menuitem: "上に行を追加",
add_below_menuitem: "下に行を追加",
+ split_cell_menuitem: "セルを分割",
+ merge_cells_menuitem: "セルを結合",
+ background_color_menuitem: "背景色を変更",
},
suggestion_menu: {
no_items_title: "アイテムが見つかりません",
@@ -299,6 +304,9 @@ export const ja: Dictionary = {
align_justify: {
tooltip: "両端揃え",
},
+ table_cell_merge: {
+ tooltip: "セルを結合",
+ },
comment: {
tooltip: "コメントを追加",
},
diff --git a/packages/core/src/i18n/locales/ko.ts b/packages/core/src/i18n/locales/ko.ts
index 463978dc78..0256c72ce3 100644
--- a/packages/core/src/i18n/locales/ko.ts
+++ b/packages/core/src/i18n/locales/ko.ts
@@ -169,6 +169,8 @@ export const ko: Dictionary = {
drag_handle: {
delete_menuitem: "삭제",
colors_menuitem: "색깔",
+ header_row_menuitem: "행 제목",
+ header_column_menuitem: "열 제목",
},
table_handle: {
delete_column_menuitem: "열 1개 삭제",
@@ -177,6 +179,9 @@ export const ko: Dictionary = {
add_right_menuitem: "오른쪽에 열 1개 추가",
add_above_menuitem: "위에 행 1개 추가",
add_below_menuitem: "아래에 행 1개 추가",
+ split_cell_menuitem: "셀 분할",
+ merge_cells_menuitem: "셀 병합",
+ background_color_menuitem: "배경색 변경",
},
suggestion_menu: {
no_items_title: "항목을 찾을 수 없음",
@@ -292,6 +297,9 @@ export const ko: Dictionary = {
align_justify: {
tooltip: "텍스트 양쪽 맞춤",
},
+ table_cell_merge: {
+ tooltip: "셀 병합",
+ },
comment: {
tooltip: "코멘트 추가",
},
diff --git a/packages/core/src/i18n/locales/nl.ts b/packages/core/src/i18n/locales/nl.ts
index 9b890a54cf..a4eebaae24 100644
--- a/packages/core/src/i18n/locales/nl.ts
+++ b/packages/core/src/i18n/locales/nl.ts
@@ -156,6 +156,8 @@ export const nl: Dictionary = {
drag_handle: {
delete_menuitem: "Verwijder",
colors_menuitem: "Kleuren",
+ header_row_menuitem: "Kopregel",
+ header_column_menuitem: "Kopkolom",
},
table_handle: {
delete_column_menuitem: "Verwijder kolom",
@@ -164,6 +166,9 @@ export const nl: Dictionary = {
add_right_menuitem: "Voeg kolom rechts toe",
add_above_menuitem: "Voeg rij boven toe",
add_below_menuitem: "Voeg rij onder toe",
+ split_cell_menuitem: "Splits cel",
+ merge_cells_menuitem: "Voeg cellen samen",
+ background_color_menuitem: "Achtergrondkleur wijzigen",
},
suggestion_menu: {
no_items_title: "Geen items gevonden",
@@ -278,6 +283,9 @@ export const nl: Dictionary = {
align_justify: {
tooltip: "Tekst uitvullen",
},
+ table_cell_merge: {
+ tooltip: "Voeg cellen samen",
+ },
comment: {
tooltip: "Commentaar toevoegen",
},
diff --git a/packages/core/src/i18n/locales/no.ts b/packages/core/src/i18n/locales/no.ts
index 2c6f2c1756..27e37b052f 100644
--- a/packages/core/src/i18n/locales/no.ts
+++ b/packages/core/src/i18n/locales/no.ts
@@ -156,6 +156,8 @@ export const no: Dictionary = {
drag_handle: {
delete_menuitem: "Slett",
colors_menuitem: "Farger",
+ header_row_menuitem: "Rad overskrift",
+ header_column_menuitem: "Kolonne overskrift",
},
table_handle: {
delete_column_menuitem: "Slett kolonne",
@@ -164,6 +166,9 @@ export const no: Dictionary = {
add_right_menuitem: "Legg til kolonne til høyre",
add_above_menuitem: "Legg til rad over",
add_below_menuitem: "Legg til rad under",
+ split_cell_menuitem: "Del celle",
+ merge_cells_menuitem: "Slå sammen celler",
+ background_color_menuitem: "Bakgrunnsfarge",
},
suggestion_menu: {
no_items_title: "Ingen elementer funnet",
@@ -281,6 +286,9 @@ export const no: Dictionary = {
comment: {
tooltip: "Legg til kommentar",
},
+ table_cell_merge: {
+ tooltip: "Slå sammen celler",
+ },
},
file_panel: {
upload: {
diff --git a/packages/core/src/i18n/locales/pl.ts b/packages/core/src/i18n/locales/pl.ts
index e776bcd479..78a8461e45 100644
--- a/packages/core/src/i18n/locales/pl.ts
+++ b/packages/core/src/i18n/locales/pl.ts
@@ -140,6 +140,8 @@ export const pl: Dictionary = {
drag_handle: {
delete_menuitem: "Usuń",
colors_menuitem: "Kolory",
+ header_row_menuitem: "Nagłówek wiersza",
+ header_column_menuitem: "Nagłówek kolumny",
},
table_handle: {
delete_column_menuitem: "Usuń kolumnę",
@@ -148,6 +150,9 @@ export const pl: Dictionary = {
add_right_menuitem: "Dodaj kolumnę po prawej",
add_above_menuitem: "Dodaj wiersz powyżej",
add_below_menuitem: "Dodaj wiersz poniżej",
+ split_cell_menuitem: "Podziel komórkę",
+ merge_cells_menuitem: "Połącz komórki",
+ background_color_menuitem: "Zmień kolor tła",
},
suggestion_menu: {
no_items_title: "Nie znaleziono elementów",
@@ -263,6 +268,9 @@ export const pl: Dictionary = {
align_justify: {
tooltip: "Wyjustuj tekst",
},
+ table_cell_merge: {
+ tooltip: "Połącz komórki",
+ },
comment: {
tooltip: "Dodaj komentarz",
},
diff --git a/packages/core/src/i18n/locales/pt.ts b/packages/core/src/i18n/locales/pt.ts
index bf9fbd52db..764f06c4b2 100644
--- a/packages/core/src/i18n/locales/pt.ts
+++ b/packages/core/src/i18n/locales/pt.ts
@@ -148,6 +148,8 @@ export const pt: Dictionary = {
drag_handle: {
delete_menuitem: "Excluir",
colors_menuitem: "Cores",
+ header_row_menuitem: "Cabeçalho de linha",
+ header_column_menuitem: "Cabeçalho de coluna",
},
table_handle: {
delete_column_menuitem: "Excluir coluna",
@@ -156,6 +158,9 @@ export const pt: Dictionary = {
add_right_menuitem: "Adicionar coluna à direita",
add_above_menuitem: "Adicionar linha acima",
add_below_menuitem: "Adicionar linha abaixo",
+ split_cell_menuitem: "Dividir célula",
+ merge_cells_menuitem: "Juntar células",
+ background_color_menuitem: "Alterar cor de fundo",
},
suggestion_menu: {
no_items_title: "Nenhum item encontrado",
@@ -271,6 +276,9 @@ export const pt: Dictionary = {
align_justify: {
tooltip: "Justificar texto",
},
+ table_cell_merge: {
+ tooltip: "Juntar células",
+ },
comment: {
tooltip: "Adicionar comentário",
},
diff --git a/packages/core/src/i18n/locales/ru.ts b/packages/core/src/i18n/locales/ru.ts
index 809fcc6347..3fc2b2b05c 100644
--- a/packages/core/src/i18n/locales/ru.ts
+++ b/packages/core/src/i18n/locales/ru.ts
@@ -183,6 +183,8 @@ export const ru: Dictionary = {
drag_handle: {
delete_menuitem: "Удалить",
colors_menuitem: "Цвета",
+ header_row_menuitem: "Заголовок строки",
+ header_column_menuitem: "Заголовок столбца",
},
table_handle: {
delete_column_menuitem: "Удалить столбец",
@@ -191,6 +193,9 @@ export const ru: Dictionary = {
add_right_menuitem: "Добавить столбец справа",
add_above_menuitem: "Добавить строку выше",
add_below_menuitem: "Добавить строку ниже",
+ split_cell_menuitem: "Разделить ячейку",
+ merge_cells_menuitem: "Объединить ячейки",
+ background_color_menuitem: "Цвет фона",
},
suggestion_menu: {
no_items_title: "ничего не найдено",
@@ -306,6 +311,9 @@ export const ru: Dictionary = {
align_justify: {
tooltip: "По середине текст",
},
+ table_cell_merge: {
+ tooltip: "Объединить ячейки",
+ },
comment: {
tooltip: "Добавить комментарий",
},
diff --git a/packages/core/src/i18n/locales/uk.ts b/packages/core/src/i18n/locales/uk.ts
index afda90672b..454617216d 100644
--- a/packages/core/src/i18n/locales/uk.ts
+++ b/packages/core/src/i18n/locales/uk.ts
@@ -181,6 +181,8 @@ export const uk: Dictionary = {
drag_handle: {
delete_menuitem: "Видалити",
colors_menuitem: "Кольори",
+ header_row_menuitem: "Заголовок рядка",
+ header_column_menuitem: "Заголовок стовпця",
},
table_handle: {
delete_column_menuitem: "Видалити стовпець",
@@ -189,6 +191,9 @@ export const uk: Dictionary = {
add_right_menuitem: "Додати стовпець справа",
add_above_menuitem: "Додати рядок вище",
add_below_menuitem: "Додати рядок нижче",
+ split_cell_menuitem: "Розділити клітинку",
+ merge_cells_menuitem: "Об'єднати клітинки",
+ background_color_menuitem: "Змінити колір фону",
},
suggestion_menu: {
no_items_title: "Нічого не знайдено",
@@ -303,6 +308,9 @@ export const uk: Dictionary = {
align_justify: {
tooltip: "Вирівняти за шириною",
},
+ table_cell_merge: {
+ tooltip: "Об'єднати клітинки",
+ },
comment: {
tooltip: "Додати коментар",
},
diff --git a/packages/core/src/i18n/locales/vi.ts b/packages/core/src/i18n/locales/vi.ts
index 41b12d088f..a557472618 100644
--- a/packages/core/src/i18n/locales/vi.ts
+++ b/packages/core/src/i18n/locales/vi.ts
@@ -155,6 +155,8 @@ export const vi: Dictionary = {
drag_handle: {
delete_menuitem: "Xóa",
colors_menuitem: "Màu sắc",
+ header_row_menuitem: "Tiêu đề hàng",
+ header_column_menuitem: "Tiêu đề cột",
},
table_handle: {
delete_column_menuitem: "Xóa cột",
@@ -163,6 +165,9 @@ export const vi: Dictionary = {
add_right_menuitem: "Thêm cột bên phải",
add_above_menuitem: "Thêm hàng phía trên",
add_below_menuitem: "Thêm hàng phía dưới",
+ split_cell_menuitem: "Chia ô",
+ merge_cells_menuitem: "Gộp ô",
+ background_color_menuitem: "Màu nền",
},
suggestion_menu: {
no_items_title: "Không tìm thấy mục nào",
@@ -278,6 +283,9 @@ export const vi: Dictionary = {
align_justify: {
tooltip: "Căn đều văn bản",
},
+ table_cell_merge: {
+ tooltip: "Gộp các ô",
+ },
comment: {
tooltip: "Thêm bình luận",
},
diff --git a/packages/core/src/i18n/locales/zh.ts b/packages/core/src/i18n/locales/zh.ts
index 7ae9fa384d..7d935af33b 100644
--- a/packages/core/src/i18n/locales/zh.ts
+++ b/packages/core/src/i18n/locales/zh.ts
@@ -189,6 +189,8 @@ export const zh: Dictionary = {
drag_handle: {
delete_menuitem: "删除",
colors_menuitem: "颜色",
+ header_row_menuitem: "行标题",
+ header_column_menuitem: "列标题",
},
table_handle: {
delete_column_menuitem: "删除列",
@@ -197,6 +199,9 @@ export const zh: Dictionary = {
add_right_menuitem: "右侧添加列",
add_above_menuitem: "上方添加行",
add_below_menuitem: "下方添加行",
+ split_cell_menuitem: "拆分单元格",
+ merge_cells_menuitem: "合并单元格",
+ background_color_menuitem: "背景色",
},
suggestion_menu: {
no_items_title: "无匹配项",
@@ -312,6 +317,9 @@ export const zh: Dictionary = {
align_justify: {
tooltip: "文本对齐",
},
+ table_cell_merge: {
+ tooltip: "合并单元格",
+ },
comment: {
tooltip: "添加评论",
},
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index beb6a66996..e63cc06fd9 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -53,6 +53,7 @@ export * from "./schema/index.js";
export * from "./util/browser.js";
export * from "./util/combineByGroup.js";
export * from "./util/esmDependencies.js";
+export * from "./util/table.js";
export * from "./util/string.js";
export * from "./util/typescript.js";
export { UnreachableCaseError, assertEmpty } from "./util/typescript.js";
diff --git a/packages/core/src/schema/blocks/types.ts b/packages/core/src/schema/blocks/types.ts
index 082ccc4469..dac8f5c9e9 100644
--- a/packages/core/src/schema/blocks/types.ts
+++ b/packages/core/src/schema/blocks/types.ts
@@ -144,14 +144,33 @@ export type BlockSchemaWithBlock<
[k in BType]: C;
};
+export type TableCellProps = {
+ backgroundColor: string;
+ textColor: string;
+ textAlignment: "left" | "center" | "right" | "justify";
+ colspan?: number;
+ rowspan?: number;
+};
+
+export type TableCell<
+ I extends InlineContentSchema,
+ S extends StyleSchema = StyleSchema
+> = {
+ type: "tableCell";
+ props: TableCellProps;
+ content: InlineContent[];
+};
+
export type TableContent<
I extends InlineContentSchema,
S extends StyleSchema = StyleSchema
> = {
type: "tableContent";
columnWidths: (number | undefined)[];
+ headerRows?: number;
+ headerCols?: number;
rows: {
- cells: InlineContent[][];
+ cells: InlineContent[][] | TableCell[];
}[];
};
@@ -220,14 +239,25 @@ export type SpecificBlock<
*
*/
+export type PartialTableCell<
+ I extends InlineContentSchema,
+ S extends StyleSchema = StyleSchema
+> = {
+ type: "tableCell";
+ props?: Partial;
+ content?: PartialInlineContent;
+};
+
export type PartialTableContent<
I extends InlineContentSchema,
S extends StyleSchema = StyleSchema
> = {
type: "tableContent";
columnWidths?: (number | undefined)[];
+ headerRows?: number;
+ headerCols?: number;
rows: {
- cells: PartialInlineContent[];
+ cells: PartialInlineContent[] | PartialTableCell[];
}[];
};
diff --git a/packages/core/src/util/table.ts b/packages/core/src/util/table.ts
new file mode 100644
index 0000000000..e06aca7b1e
--- /dev/null
+++ b/packages/core/src/util/table.ts
@@ -0,0 +1,107 @@
+import type {
+ InlineContentSchema,
+ StyleSchema,
+ PartialInlineContent,
+ InlineContent,
+} from "../schema";
+import { PartialTableCell, TableCell } from "../schema/blocks/types.js";
+
+/**
+ * This will map a table cell to a TableCell object.
+ * This is useful for when we want to get the full table cell object from a partial table cell.
+ * It is guaranteed to return a new TableCell object.
+ */
+export function mapTableCell<
+ T extends InlineContentSchema,
+ S extends StyleSchema
+>(
+ content: PartialInlineContent | PartialTableCell | TableCell
+): TableCell {
+ return isTableCell(content)
+ ? { ...content }
+ : isPartialTableCell(content)
+ ? {
+ type: "tableCell",
+ content: ([] as InlineContent[]).concat(content.content as any),
+ props: {
+ backgroundColor: content.props?.backgroundColor ?? "default",
+ textColor: content.props?.textColor ?? "default",
+ textAlignment: content.props?.textAlignment ?? "left",
+ colspan: content.props?.colspan ?? 1,
+ rowspan: content.props?.rowspan ?? 1,
+ },
+ }
+ : {
+ type: "tableCell",
+ content: ([] as InlineContent[]).concat(content as any),
+ props: {
+ backgroundColor: "default",
+ textColor: "default",
+ textAlignment: "left",
+ colspan: 1,
+ rowspan: 1,
+ },
+ };
+}
+
+export function isPartialTableCell<
+ T extends InlineContentSchema,
+ S extends StyleSchema
+>(
+ content:
+ | TableCell
+ | PartialInlineContent
+ | PartialTableCell
+ | undefined
+ | null
+): content is PartialTableCell {
+ return (
+ content !== undefined &&
+ content !== null &&
+ typeof content !== "string" &&
+ !Array.isArray(content) &&
+ content.type === "tableCell"
+ );
+}
+
+export function isTableCell<
+ T extends InlineContentSchema,
+ S extends StyleSchema
+>(
+ content:
+ | TableCell
+ | PartialInlineContent
+ | PartialTableCell
+ | undefined
+ | null
+): content is TableCell {
+ return (
+ isPartialTableCell(content) &&
+ content.props !== undefined &&
+ content.content !== undefined
+ );
+}
+
+export function getColspan(
+ cell:
+ | TableCell
+ | PartialTableCell
+ | PartialInlineContent
+): number {
+ if (isTableCell(cell)) {
+ return cell.props.colspan ?? 1;
+ }
+ return 1;
+}
+
+export function getRowspan(
+ cell:
+ | TableCell
+ | PartialTableCell
+ | PartialInlineContent
+): number {
+ if (isTableCell(cell)) {
+ return cell.props.rowspan ?? 1;
+ }
+ return 1;
+}
diff --git a/packages/mantine/src/components.tsx b/packages/mantine/src/components.tsx
index 24c8650ec1..0f6b1e10b2 100644
--- a/packages/mantine/src/components.tsx
+++ b/packages/mantine/src/components.tsx
@@ -12,6 +12,7 @@ import {
MenuLabel,
MenuTrigger,
} from "./menu/Menu.js";
+import { Button } from "./menu/Button.js";
import { Panel } from "./panel/Panel.js";
import { PanelButton } from "./panel/PanelButton.js";
import { PanelFileInput } from "./panel/PanelFileInput.js";
@@ -90,6 +91,7 @@ export const components: Components = {
Divider: MenuDivider,
Label: MenuLabel,
Item: MenuItem,
+ Button: Button,
},
Popover: {
Root: Popover,
diff --git a/packages/mantine/src/menu/Button.tsx b/packages/mantine/src/menu/Button.tsx
new file mode 100644
index 0000000000..9c431557b2
--- /dev/null
+++ b/packages/mantine/src/menu/Button.tsx
@@ -0,0 +1,60 @@
+import {
+ ActionIcon as MantineActionIcon,
+ Button as MantineButton,
+} from "@mantine/core";
+
+import { assertEmpty } from "@blocknote/core";
+import { ComponentProps } from "@blocknote/react";
+import { forwardRef } from "react";
+
+export const Button = forwardRef<
+ HTMLButtonElement,
+ ComponentProps["Generic"]["Menu"]["Button"]
+>((props, ref) => {
+ const {
+ className,
+ children,
+ icon,
+ onClick,
+ onDragEnd,
+ onDragStart,
+ draggable,
+ label,
+ ...rest
+ } = props;
+
+ // false, because rest props can be added by mantine when button is used as a trigger
+ // assertEmpty in this case is only used at typescript level, not runtime level
+ assertEmpty(rest, false);
+
+ if (icon) {
+ return (
+
+ {icon}
+
+ );
+ }
+
+ return (
+
+ {children}
+
+ );
+});
diff --git a/packages/mantine/src/style.css b/packages/mantine/src/style.css
index fa120da74f..44b9ec7c54 100644
--- a/packages/mantine/src/style.css
+++ b/packages/mantine/src/style.css
@@ -503,14 +503,15 @@
/* Table Handle styling */
.bn-mantine .bn-table-handle,
-.bn-mantine .bn-extend-button {
+.bn-mantine .bn-extend-button,
+.bn-mantine .bn-table-cell-handle {
align-items: center;
background-color: var(--bn-colors-menu-background);
border: var(--bn-border);
border-radius: var(--bn-border-radius-small);
box-shadow: var(--bn-shadow-light);
color: var(--bn-colors-side-menu);
- cursor: pointer;
+ cursor: grab;
display: flex;
height: fit-content;
justify-content: center;
@@ -518,14 +519,23 @@
padding: 0;
}
+.bn-mantine .bn-table-cell-handle {
+ padding: 0 4px;
+}
+
.bn-mantine .bn-table-handle svg {
margin-inline: -4px;
}
+.bn-mantine .bn-table-handle-not-draggable {
+ cursor: pointer;
+}
+
.bn-mantine .bn-table-handle:hover,
.bn-mantine .bn-table-handle-dragging,
.bn-mantine .bn-extend-button:hover,
-.bn-mantine .bn-extend-button-editing {
+.bn-mantine .bn-extend-button-editing,
+.bn-mantine .bn-table-cell-handle:hover {
background-color: var(--bn-colors-hovered-background);
}
@@ -544,7 +554,8 @@
}
/* Drag Handle & Table Handle Menu styling */
-.bn-mantine .bn-drag-handle-menu {
+.bn-mantine .bn-drag-handle-menu,
+.bn-mantine .bn-table-handle-menu {
overflow: visible;
}
diff --git a/packages/react/src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx b/packages/react/src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx
index 3e3b966729..63ad8c08d1 100644
--- a/packages/react/src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx
+++ b/packages/react/src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx
@@ -6,6 +6,7 @@ import {
BlockSchema,
formatKeyboardShortcut,
InlineContentSchema,
+ isTableCellSelection,
StyleSchema,
} from "@blocknote/core";
@@ -92,8 +93,12 @@ export const CreateLinkButton = () => {
}
}
+ if (isTableCellSelection(editor.prosemirrorState.selection)) {
+ return false;
+ }
+
return true;
- }, [linkInSchema, selectedBlocks]);
+ }, [linkInSchema, selectedBlocks, editor.prosemirrorState.selection]);
if (
!show ||
diff --git a/packages/react/src/components/FormattingToolbar/DefaultButtons/TableCellMergeButton.tsx b/packages/react/src/components/FormattingToolbar/DefaultButtons/TableCellMergeButton.tsx
new file mode 100644
index 0000000000..bb11326a08
--- /dev/null
+++ b/packages/react/src/components/FormattingToolbar/DefaultButtons/TableCellMergeButton.tsx
@@ -0,0 +1,69 @@
+import {
+ DefaultBlockSchema,
+ InlineContentSchema,
+ StyleSchema,
+} from "@blocknote/core";
+import { useCallback, useMemo } from "react";
+import { RiMergeCellsHorizontal, RiMergeCellsVertical } from "react-icons/ri";
+
+import { useComponentsContext } from "../../../editor/ComponentsContext.js";
+import { useBlockNoteEditor } from "../../../hooks/useBlockNoteEditor.js";
+import { useSelectedBlocks } from "../../../hooks/useSelectedBlocks.js";
+import { useDictionary } from "../../../i18n/dictionary.js";
+
+export const TableCellMergeButton = () => {
+ const dict = useDictionary();
+ const Components = useComponentsContext()!;
+
+ const editor = useBlockNoteEditor<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ InlineContentSchema,
+ StyleSchema
+ >();
+
+ const selectedBlocks = useSelectedBlocks(editor);
+ const mergeDirection = useMemo(() => {
+ // Checks if only one block is selected.
+ if (selectedBlocks.length !== 1) {
+ return undefined;
+ }
+
+ const block = selectedBlocks[0];
+
+ if (block.type === "table") {
+ return editor.tableHandles?.getMergeDirection(block);
+ }
+
+ return undefined;
+ }, [editor, selectedBlocks]);
+
+ const onClick = useCallback(() => {
+ editor.tableHandles?.mergeCells();
+ }, [editor]);
+
+ if (
+ !editor.isEditable ||
+ mergeDirection === undefined ||
+ !editor.settings.tables.splitCells
+ ) {
+ return null;
+ }
+
+ return (
+
+ ) : (
+
+ )
+ }
+ onClick={onClick}
+ />
+ );
+};
diff --git a/packages/react/src/components/FormattingToolbar/DefaultButtons/TextAlignButton.tsx b/packages/react/src/components/FormattingToolbar/DefaultButtons/TextAlignButton.tsx
index b946dace16..e057a23179 100644
--- a/packages/react/src/components/FormattingToolbar/DefaultButtons/TextAlignButton.tsx
+++ b/packages/react/src/components/FormattingToolbar/DefaultButtons/TextAlignButton.tsx
@@ -4,7 +4,9 @@ import {
checkBlockTypeHasDefaultProp,
DefaultProps,
InlineContentSchema,
+ mapTableCell,
StyleSchema,
+ TableContent,
} from "@blocknote/core";
import { useCallback, useMemo } from "react";
import { IconType } from "react-icons";
@@ -47,6 +49,23 @@ export const TextAlignButton = (props: { textAlignment: TextAlignment }) => {
if (checkBlockHasDefaultProp("textAlignment", block, editor)) {
return block.props.textAlignment;
}
+ if (block.type === "table") {
+ const cellSelection = editor.tableHandles?.getCellSelection();
+ if (!cellSelection) {
+ return;
+ }
+ const allCellsInTable = cellSelection.cells.map(
+ ({ row, col }) =>
+ mapTableCell(
+ (block.content as TableContent).rows[row].cells[col]
+ ).props.textAlignment
+ );
+ const firstAlignment = allCellsInTable[0];
+
+ if (allCellsInTable.every((alignment) => alignment === firstAlignment)) {
+ return firstAlignment;
+ }
+ }
return;
}, [editor, selectedBlocks]);
@@ -60,6 +79,40 @@ export const TextAlignButton = (props: { textAlignment: TextAlignment }) => {
editor.updateBlock(block, {
props: { textAlignment: textAlignment },
});
+ } else if (block.type === "table") {
+ const cellSelection = editor.tableHandles?.getCellSelection();
+ if (!cellSelection) {
+ continue;
+ }
+
+ const newTable = (block.content as TableContent).rows.map(
+ (row) => {
+ return {
+ ...row,
+ cells: row.cells.map((cell) => {
+ return mapTableCell(cell);
+ }),
+ };
+ }
+ );
+
+ // Apply the text alignment to the cells that are within the selected range
+ cellSelection.cells.forEach(({ row, col }) => {
+ newTable[row].cells[col].props.textAlignment = textAlignment;
+ });
+
+ editor.updateBlock(block, {
+ type: "table",
+ content: {
+ ...(block.content as TableContent),
+ type: "tableContent",
+ rows: newTable,
+ } as any,
+ });
+
+ // Have to reset text cursor position to the block as `updateBlock`
+ // moves the existing selection out of the block.
+ editor.setTextCursorPosition(block);
}
}
},
@@ -67,7 +120,11 @@ export const TextAlignButton = (props: { textAlignment: TextAlignment }) => {
);
const show = useMemo(() => {
- return !!selectedBlocks.find((block) => "textAlignment" in block.props);
+ return !!selectedBlocks.find(
+ (block) =>
+ "textAlignment" in block.props ||
+ (block.type === "table" && block.children)
+ );
}, [selectedBlocks]);
if (!show || !editor.isEditable) {
diff --git a/packages/react/src/components/FormattingToolbar/FormattingToolbar.tsx b/packages/react/src/components/FormattingToolbar/FormattingToolbar.tsx
index 5ec9b5d14c..89e4c1ac87 100644
--- a/packages/react/src/components/FormattingToolbar/FormattingToolbar.tsx
+++ b/packages/react/src/components/FormattingToolbar/FormattingToolbar.tsx
@@ -21,6 +21,7 @@ import { AddCommentButton } from "./DefaultButtons/AddCommentButton.js";
import { AddTiptapCommentButton } from "./DefaultButtons/AddTiptapCommentButton.js";
import { FileDownloadButton } from "./DefaultButtons/FileDownloadButton.js";
import { FilePreviewButton } from "./DefaultButtons/FilePreviewButton.js";
+import { TableCellMergeButton } from "./DefaultButtons/TableCellMergeButton.js";
import { TextAlignButton } from "./DefaultButtons/TextAlignButton.js";
import { FormattingToolbarProps } from "./FormattingToolbarProps.js";
@@ -28,6 +29,7 @@ export const getFormattingToolbarItems = (
blockTypeSelectItems?: BlockTypeSelectItem[]
): JSX.Element[] => [
,
+ ,
,
,
,
diff --git a/packages/react/src/components/SideMenu/DragHandleMenu/DefaultItems/TableHeadersItem.tsx b/packages/react/src/components/SideMenu/DragHandleMenu/DefaultItems/TableHeadersItem.tsx
new file mode 100644
index 0000000000..7f2e88fd86
--- /dev/null
+++ b/packages/react/src/components/SideMenu/DragHandleMenu/DefaultItems/TableHeadersItem.tsx
@@ -0,0 +1,106 @@
+import {
+ BlockSchema,
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ SpecificBlock,
+ StyleSchema,
+} from "@blocknote/core";
+import { ReactNode } from "react";
+
+import { useComponentsContext } from "../../../../editor/ComponentsContext.js";
+import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
+import { DragHandleMenuProps } from "../DragHandleMenuProps.js";
+
+export const TableRowHeaderItem = <
+ BSchema extends BlockSchema = DefaultBlockSchema,
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: Omit, "block"> & {
+ block: SpecificBlock<{ table: DefaultBlockSchema["table"] }, "table", I, S>;
+ children: ReactNode;
+ }
+) => {
+ const Components = useComponentsContext()!;
+
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+
+ if (props.block.type !== "table" || !editor.settings.tables.headers) {
+ return null;
+ }
+
+ // TODO only support 1 header row for now
+ const isHeaderRow = Boolean(props.block.content.headerRows);
+
+ return (
+ {
+ // The block may have been modified and out of date, so we get the latest block
+ const block = editor.getBlock(props.block.id);
+ if (!block) {
+ return;
+ }
+ editor.updateBlock(block, {
+ ...block,
+ content: {
+ ...block.content,
+ headerRows: isHeaderRow ? undefined : 1,
+ },
+ });
+ }}>
+ {props.children}
+
+ );
+};
+
+export const TableColumnHeaderItem = <
+ BSchema extends BlockSchema = DefaultBlockSchema,
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: Omit, "block"> & {
+ block: SpecificBlock<{ table: DefaultBlockSchema["table"] }, "table", I, S>;
+ children: ReactNode;
+ }
+) => {
+ const Components = useComponentsContext()!;
+
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+
+ if (props.block.type !== "table" || !editor.settings.tables.headers) {
+ return null;
+ }
+
+ // TODO only support 1 header column for now
+ const isHeaderColumn = Boolean(props.block.content.headerCols);
+
+ return (
+ {
+ editor.updateBlock(props.block, {
+ type: "table",
+ content: {
+ ...props.block.content,
+ type: "tableContent",
+ headerCols: isHeaderColumn ? undefined : 1,
+ },
+ });
+ }}>
+ {props.children}
+
+ );
+};
diff --git a/packages/react/src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx b/packages/react/src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx
index f28b907cd5..53910b69a7 100644
--- a/packages/react/src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx
+++ b/packages/react/src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx
@@ -13,6 +13,10 @@ import { useDictionary } from "../../../i18n/dictionary.js";
import { BlockColorsItem } from "./DefaultItems/BlockColorsItem.js";
import { RemoveBlockItem } from "./DefaultItems/RemoveBlockItem.js";
import { DragHandleMenuProps } from "./DragHandleMenuProps.js";
+import {
+ TableColumnHeaderItem,
+ TableRowHeaderItem,
+} from "./DefaultItems/TableHeadersItem.js";
/**
* By default, the DragHandleMenu component will render with default items.
@@ -43,6 +47,12 @@ export const DragHandleMenu = <
{dict.drag_handle.colors_menuitem}
+
+ {dict.drag_handle.header_row_menuitem}
+
+
+ {dict.drag_handle.header_column_menuitem}
+
>
)}
diff --git a/packages/react/src/components/TableHandles/ExtendButton/ExtendButton.tsx b/packages/react/src/components/TableHandles/ExtendButton/ExtendButton.tsx
index 60aaaeabe4..8ec1fafe4f 100644
--- a/packages/react/src/components/TableHandles/ExtendButton/ExtendButton.tsx
+++ b/packages/react/src/components/TableHandles/ExtendButton/ExtendButton.tsx
@@ -21,52 +21,6 @@ import { RiAddFill } from "react-icons/ri";
import { useComponentsContext } from "../../../editor/ComponentsContext.js";
import { ExtendButtonProps } from "./ExtendButtonProps.js";
-function cropEmptyRowsOrColumns<
- I extends InlineContentSchema,
- S extends StyleSchema
->(
- content: PartialTableContent,
- removeEmpty: "columns" | "rows"
-): PartialTableContent {
- let emptyColsOnRight = 0;
-
- if (removeEmpty === "columns") {
- // strips empty columns to the right and empty rows at the bottom
- for (let i = content.rows[0].cells.length - 1; i >= 0; i--) {
- const isEmpty = content.rows.every((row) => row.cells[i].length === 0);
- if (!isEmpty) {
- break;
- }
-
- emptyColsOnRight++;
- }
- }
-
- const rows: PartialTableContent["rows"] = [];
- for (let i = content.rows.length - 1; i >= 0; i--) {
- if (removeEmpty === "rows") {
- if (
- rows.length === 0 &&
- content.rows[i].cells.every((cell) => cell.length === 0)
- ) {
- // empty row at bottom
- continue;
- }
- }
-
- rows.unshift({
- cells: content.rows[i].cells.slice(
- 0,
- content.rows[0].cells.length - emptyColsOnRight
- ),
- });
- }
-
- return {
- ...content,
- rows,
- };
-}
// Rounds a number up or down, depending on whether we're close (as defined by
// `margin`) to the next integer.
const marginRound = (num: number, margin = 0.3) => {
@@ -82,54 +36,6 @@ const marginRound = (num: number, margin = 0.3) => {
}
};
-const getContentWithAddedRows = <
- I extends InlineContentSchema,
- S extends StyleSchema
->(
- content: PartialTableContent,
- rowsToAdd: number,
- numCols: number
-): PartialTableContent => {
- const newRow: PartialTableContent["rows"][number] = {
- cells: Array(numCols).fill([]),
- };
-
- const newRows: PartialTableContent["rows"] = [];
- for (let i = 0; i < rowsToAdd; i++) {
- newRows.push(newRow);
- }
- return {
- type: "tableContent",
- columnWidths: content.columnWidths,
- rows: [...content.rows, ...newRows],
- };
-};
-
-const getContentWithAddedCols = <
- I extends InlineContentSchema,
- S extends StyleSchema
->(
- content: PartialTableContent,
- colsToAdd: number
-): PartialTableContent => {
- const newCell: PartialTableContent["rows"][number]["cells"][number] =
- [];
- const newCells: PartialTableContent["rows"][number]["cells"] = [];
- for (let i = 0; i < colsToAdd; i++) {
- newCells.push(newCell);
- }
-
- return {
- type: "tableContent",
- columnWidths: content.columnWidths
- ? [...content.columnWidths, ...newCells.map(() => undefined)]
- : undefined,
- rows: content.rows.map((row) => ({
- cells: [...row.cells, ...newCells],
- })),
- };
-};
-
export const ExtendButton = <
I extends InlineContentSchema = DefaultInlineContentSchema,
S extends StyleSchema = DefaultStyleSchema
@@ -157,10 +63,12 @@ export const ExtendButton = <
props.onMouseDown();
setEditingState({
originalContent: props.block.content,
- originalCroppedContent: cropEmptyRowsOrColumns(
- props.block.content,
- props.orientation === "addOrRemoveColumns" ? "columns" : "rows"
- ),
+ originalCroppedContent: {
+ rows: props.editor.tableHandles!.cropEmptyRowsOrColumns(
+ props.block,
+ props.orientation === "addOrRemoveColumns" ? "columns" : "rows"
+ ),
+ } as PartialTableContent,
startPos:
props.orientation === "addOrRemoveColumns"
? event.clientX
@@ -180,21 +88,27 @@ export const ExtendButton = <
}
props.editor.updateBlock(props.block, {
type: "table",
- content:
- props.orientation === "addOrRemoveColumns"
- ? getContentWithAddedCols(props.block.content, 1)
- : getContentWithAddedRows(
- props.block.content,
- 1,
- props.block.content.rows[0].cells.length
- ),
+ content: {
+ ...props.block.content,
+ rows:
+ props.orientation === "addOrRemoveColumns"
+ ? props.editor.tableHandles!.addRowsOrColumns(
+ props.block,
+ "columns",
+ 1
+ )
+ : props.editor.tableHandles!.addRowsOrColumns(
+ props.block,
+ "rows",
+ 1
+ ),
+ } as any,
});
}, [props.block, props.orientation, props.editor]);
// Extends columns/rows on when moving the mouse.
useEffect(() => {
const callback = (event: MouseEvent) => {
- // console.log("callback", event);
if (!editingState) {
throw new Error("editingState is undefined");
}
@@ -238,17 +152,27 @@ export const ExtendButton = <
) {
props.editor.updateBlock(props.block, {
type: "table",
- content:
- props.orientation === "addOrRemoveColumns"
- ? getContentWithAddedCols(
- editingState.originalCroppedContent,
- newNumCells - numCroppedCells
- )
- : getContentWithAddedRows(
- editingState.originalCroppedContent,
- newNumCells - numCroppedCells,
- editingState.originalContent.rows[0].cells.length
- ),
+ content: {
+ ...props.block.content,
+ rows:
+ props.orientation === "addOrRemoveColumns"
+ ? props.editor.tableHandles!.addRowsOrColumns(
+ {
+ type: "table",
+ content: editingState.originalCroppedContent,
+ } as any,
+ "columns",
+ newNumCells - numCroppedCells
+ )
+ : props.editor.tableHandles!.addRowsOrColumns(
+ {
+ type: "table",
+ content: editingState.originalCroppedContent,
+ } as any,
+ "rows",
+ newNumCells - numCroppedCells
+ ),
+ } as any,
});
// Edge case for updating block content as `updateBlock` causes the
diff --git a/packages/react/src/components/TableHandles/TableCellButton.tsx b/packages/react/src/components/TableHandles/TableCellButton.tsx
new file mode 100644
index 0000000000..00ef9f3a21
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableCellButton.tsx
@@ -0,0 +1,67 @@
+import {
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ StyleSchema,
+} from "@blocknote/core";
+import { ReactNode } from "react";
+
+import { createPortal } from "react-dom";
+import { MdArrowDropDown } from "react-icons/md";
+import { useComponentsContext } from "../../editor/ComponentsContext.js";
+import { TableCellButtonProps } from "./TableCellButtonProps.js";
+import { TableCellMenu } from "./TableCellMenu/TableCellMenu.js";
+
+/**
+ * By default, the TableCellHandle component will render with the default icon.
+ * However, you can override the icon to render by passing children.
+ */
+export const TableCellButton = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableCellButtonProps & { children?: ReactNode }
+) => {
+ const Components = useComponentsContext()!;
+
+ const Component = props.tableCellMenu || TableCellMenu;
+
+ if (
+ !props.editor.settings.tables.splitCells &&
+ !props.editor.settings.tables.cellBackgroundColor &&
+ !props.editor.settings.tables.cellTextColor
+ ) {
+ // Hide the button altogether if all table cell settings are disabled
+ return null;
+ }
+
+ return (
+ {
+ if (open) {
+ props.freezeHandles();
+ } else {
+ props.unfreezeHandles();
+ props.editor.focus();
+ }
+ }}
+ position={"right"}>
+
+
+ {props.children || (
+
+ )}
+
+
+ {/* the menu can extend outside of the table, so we use a portal to prevent clipping */}
+ {createPortal(
+ ,
+ props.menuContainer
+ )}
+
+ );
+};
diff --git a/packages/react/src/components/TableHandles/TableCellButtonProps.ts b/packages/react/src/components/TableHandles/TableCellButtonProps.ts
new file mode 100644
index 0000000000..bfaca01810
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableCellButtonProps.ts
@@ -0,0 +1,41 @@
+import {
+ BlockNoteEditor,
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ StyleSchema,
+ TableHandlesState,
+} from "@blocknote/core";
+import { TableCellMenuProps } from "./TableCellMenu/TableCellMenuProps.js";
+import { FC } from "react";
+
+export type TableCellButtonProps<
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+> = {
+ editor: BlockNoteEditor<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ I,
+ S
+ >;
+ rowIndex: number;
+ colIndex: number;
+ menuContainer: HTMLDivElement;
+ tableCellMenu?: FC>;
+} & Pick, "block"> &
+ Pick<
+ Exclude<
+ BlockNoteEditor<
+ {
+ table: DefaultBlockSchema["table"];
+ },
+ I,
+ S
+ >["tableHandles"],
+ undefined
+ >,
+ "freezeHandles" | "unfreezeHandles"
+ >;
diff --git a/packages/react/src/components/TableHandles/TableCellMenu/DefaultButtons/ColorPicker.tsx b/packages/react/src/components/TableHandles/TableCellMenu/DefaultButtons/ColorPicker.tsx
new file mode 100644
index 0000000000..91b0951ec0
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableCellMenu/DefaultButtons/ColorPicker.tsx
@@ -0,0 +1,112 @@
+import {
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ isTableCell,
+ mapTableCell,
+ StyleSchema,
+} from "@blocknote/core";
+
+import { useComponentsContext } from "../../../../editor/ComponentsContext.js";
+import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
+import { useDictionary } from "../../../../i18n/dictionary.js";
+import { ColorPicker } from "../../../ColorPicker/ColorPicker.js";
+import { TableCellMenuProps } from "../TableCellMenuProps.js";
+import { ReactNode } from "react";
+
+export const ColorPickerButton = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableCellMenuProps & {
+ children?: ReactNode;
+ }
+) => {
+ const Components = useComponentsContext()!;
+ const dict = useDictionary();
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+
+ const updateColor = (color: string, type: "text" | "background") => {
+ const newTable = props.block.content.rows.map((row) => {
+ return {
+ ...row,
+ cells: row.cells.map((cell) => mapTableCell(cell)),
+ };
+ });
+
+ if (type === "text") {
+ newTable[props.rowIndex].cells[props.colIndex].props.textColor = color;
+ } else {
+ newTable[props.rowIndex].cells[props.colIndex].props.backgroundColor =
+ color;
+ }
+
+ editor.updateBlock(props.block, {
+ type: "table",
+ content: {
+ ...props.block.content,
+ rows: newTable,
+ },
+ });
+
+ // Have to reset text cursor position to the block as `updateBlock`
+ // moves the existing selection out of the block.
+ editor.setTextCursorPosition(props.block);
+ };
+
+ const currentCell =
+ props.block.content.rows[props.rowIndex]?.cells?.[props.colIndex];
+
+ if (
+ !currentCell ||
+ (editor.settings.tables.cellTextColor === false &&
+ editor.settings.tables.cellBackgroundColor === false)
+ ) {
+ return null;
+ }
+
+ return (
+
+
+
+ {props.children || dict.drag_handle.colors_menuitem}
+
+
+
+
+ updateColor(color, "text"),
+ }
+ : undefined
+ }
+ background={
+ editor.settings.tables.cellBackgroundColor
+ ? {
+ color: isTableCell(currentCell)
+ ? currentCell.props.backgroundColor
+ : "default",
+ setColor: (color) => updateColor(color, "background"),
+ }
+ : undefined
+ }
+ />
+
+
+ );
+};
diff --git a/packages/react/src/components/TableHandles/TableCellMenu/DefaultButtons/SplitButton.tsx b/packages/react/src/components/TableHandles/TableCellMenu/DefaultButtons/SplitButton.tsx
new file mode 100644
index 0000000000..1e8f5c9ab0
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableCellMenu/DefaultButtons/SplitButton.tsx
@@ -0,0 +1,54 @@
+import {
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ getColspan,
+ getRowspan,
+ InlineContentSchema,
+ isTableCell,
+ StyleSchema,
+} from "@blocknote/core";
+
+import { useComponentsContext } from "../../../../editor/ComponentsContext.js";
+import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
+import { useDictionary } from "../../../../i18n/dictionary.js";
+import { TableCellMenuProps } from "../TableCellMenuProps.js";
+
+export const SplitButton = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableCellMenuProps
+) => {
+ const Components = useComponentsContext()!;
+ const dict = useDictionary();
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+
+ const currentCell =
+ props.block.content.rows[props.rowIndex]?.cells?.[props.colIndex];
+
+ if (
+ !currentCell ||
+ !isTableCell(currentCell) ||
+ (getRowspan(currentCell) === 1 && getColspan(currentCell) === 1) ||
+ !editor.settings.tables.splitCells
+ ) {
+ return null;
+ }
+
+ return (
+ {
+ editor.tableHandles?.splitCell({
+ row: props.rowIndex,
+ col: props.colIndex,
+ });
+ }}>
+ {dict.table_handle.split_cell_menuitem}
+
+ );
+};
diff --git a/packages/react/src/components/TableHandles/TableCellMenu/TableCellMenu.tsx b/packages/react/src/components/TableHandles/TableCellMenu/TableCellMenu.tsx
new file mode 100644
index 0000000000..91987b428a
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableCellMenu/TableCellMenu.tsx
@@ -0,0 +1,41 @@
+import {
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ StyleSchema,
+} from "@blocknote/core";
+import { ReactNode } from "react";
+
+import { useComponentsContext } from "../../../editor/ComponentsContext.js";
+import { ColorPickerButton } from "./DefaultButtons/ColorPicker.js";
+import { SplitButton } from "./DefaultButtons/SplitButton.js";
+import { TableCellMenuProps } from "./TableCellMenuProps.js";
+
+export const TableCellMenu = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableCellMenuProps & { children?: ReactNode }
+) => {
+ const Components = useComponentsContext()!;
+
+ return (
+
+ {props.children || (
+ <>
+
+
+ >
+ )}
+
+ );
+};
diff --git a/packages/react/src/components/TableHandles/TableCellMenu/TableCellMenuProps.ts b/packages/react/src/components/TableHandles/TableCellMenu/TableCellMenuProps.ts
new file mode 100644
index 0000000000..8147e2ac25
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableCellMenu/TableCellMenuProps.ts
@@ -0,0 +1,17 @@
+import {
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ SpecificBlock,
+ StyleSchema,
+} from "@blocknote/core";
+
+export type TableCellMenuProps<
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+> = {
+ block: SpecificBlock<{ table: DefaultBlockSchema["table"] }, "table", I, S>;
+ rowIndex: number;
+ colIndex: number;
+};
diff --git a/packages/react/src/components/TableHandles/TableHandle.tsx b/packages/react/src/components/TableHandles/TableHandle.tsx
index 451de4b845..8ceb450569 100644
--- a/packages/react/src/components/TableHandles/TableHandle.tsx
+++ b/packages/react/src/components/TableHandles/TableHandle.tsx
@@ -1,11 +1,13 @@
import {
DefaultInlineContentSchema,
DefaultStyleSchema,
+ getColspan,
+ getRowspan,
InlineContentSchema,
mergeCSSClasses,
StyleSchema,
} from "@blocknote/core";
-import { ReactNode, useState } from "react";
+import { ReactNode, useMemo, useState } from "react";
import { createPortal } from "react-dom";
import { MdDragIndicator } from "react-icons/md";
@@ -29,6 +31,23 @@ export const TableHandle = <
const Component = props.tableHandleMenu || TableHandleMenu;
+ const isDraggable = useMemo(() => {
+ const tableHandles = props.editor.tableHandles;
+ if (!tableHandles || !props.block) {
+ return false;
+ }
+
+ if (props.orientation === "column") {
+ return tableHandles
+ .getCellsAtColumnHandle(props.block, props.index)
+ .every(({ cell }) => getColspan(cell) === 1);
+ }
+
+ return tableHandles
+ .getCellsAtRowHandle(props.block, props.index)
+ .every(({ cell }) => getRowspan(cell) === 1);
+ }, [props.block, props.editor.tableHandles, props.index, props.orientation]);
+
return (
{
@@ -46,9 +65,10 @@ export const TableHandle = <
{
setIsDragging(true);
props.dragStart(e);
diff --git a/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/AddButton.tsx b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/AddButton.tsx
index e90289647f..9d764cd1a2 100644
--- a/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/AddButton.tsx
+++ b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/AddButton.tsx
@@ -3,7 +3,6 @@ import {
DefaultInlineContentSchema,
DefaultStyleSchema,
InlineContentSchema,
- PartialTableContent,
StyleSchema,
} from "@blocknote/core";
@@ -12,11 +11,15 @@ import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
import { useDictionary } from "../../../../i18n/dictionary.js";
import { TableHandleMenuProps } from "../TableHandleMenuProps.js";
-export const AddRowButton = <
+export const AddButton = <
I extends InlineContentSchema = DefaultInlineContentSchema,
S extends StyleSchema = DefaultStyleSchema
>(
- props: TableHandleMenuProps & { side: "above" | "below" }
+ props: TableHandleMenuProps &
+ (
+ | { orientation: "row"; side: "above" | "below" }
+ | { orientation: "column"; side: "left" | "right" }
+ )
) => {
const Components = useComponentsContext()!;
const dict = useDictionary();
@@ -27,95 +30,23 @@ export const AddRowButton = <
S
>();
- return (
- {
- const emptyCol = props.block.content.rows[props.index].cells.map(
- () => []
- );
- const rows = [...props.block.content.rows];
- rows.splice(props.index + (props.side === "below" ? 1 : 0), 0, {
- cells: emptyCol,
- });
-
- editor.updateBlock(props.block, {
- type: "table",
- content: {
- type: "tableContent",
- columnWidths: props.block.content.columnWidths,
- rows,
- },
- });
-
- // Have to reset text cursor position to the block as `updateBlock`
- // moves the existing selection out of the block.
- editor.setTextCursorPosition(props.block);
- }}>
- {dict.table_handle[`add_${props.side}_menuitem`]}
-
- );
-};
-
-export const AddColumnButton = <
- I extends InlineContentSchema = DefaultInlineContentSchema,
- S extends StyleSchema = DefaultStyleSchema
->(
- props: TableHandleMenuProps & { side: "left" | "right" }
-) => {
- const Components = useComponentsContext()!;
- const dict = useDictionary();
+ const tableHandles = editor.tableHandles;
- const editor = useBlockNoteEditor<
- { table: DefaultBlockSchema["table"] },
- I,
- S
- >();
+ if (!tableHandles) {
+ return null;
+ }
return (
{
- const columnWidths = [...props.block.content.columnWidths];
- columnWidths.splice(
- props.index + (props.side === "right" ? 1 : 0),
- 0,
- undefined
+ tableHandles.addRowOrColumn(
+ props.index,
+ props.orientation === "row"
+ ? { orientation: "row", side: props.side }
+ : { orientation: "column", side: props.side }
);
- const content: PartialTableContent = {
- type: "tableContent",
- columnWidths,
- rows: props.block.content.rows.map((row) => {
- const cells = [...row.cells];
- cells.splice(props.index + (props.side === "right" ? 1 : 0), 0, []);
- return { cells };
- }),
- };
-
- editor.updateBlock(props.block, {
- type: "table",
- content: content,
- });
-
- // Have to reset text cursor position to the block as `updateBlock`
- // moves the existing selection out of the block.
- editor.setTextCursorPosition(props.block);
}}>
{dict.table_handle[`add_${props.side}_menuitem`]}
);
};
-
-export const AddButton = <
- I extends InlineContentSchema = DefaultInlineContentSchema,
- S extends StyleSchema = DefaultStyleSchema
->(
- props: TableHandleMenuProps &
- (
- | { orientation: "row"; side: "above" | "below" }
- | { orientation: "column"; side: "left" | "right" }
- )
-) =>
- props.orientation === "row" ? (
-
- ) : (
-
- );
diff --git a/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/ColorPicker.tsx b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/ColorPicker.tsx
new file mode 100644
index 0000000000..1010b5c34d
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/ColorPicker.tsx
@@ -0,0 +1,140 @@
+import {
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ isTableCell,
+ mapTableCell,
+ StyleSchema,
+} from "@blocknote/core";
+
+import { useComponentsContext } from "../../../../editor/ComponentsContext.js";
+import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
+import { useDictionary } from "../../../../i18n/dictionary.js";
+import { ColorPicker } from "../../../ColorPicker/ColorPicker.js";
+import { TableHandleMenuProps } from "../TableHandleMenuProps.js";
+import { ReactNode, useMemo } from "react";
+
+export const ColorPickerButton = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableHandleMenuProps & {
+ children?: ReactNode;
+ }
+) => {
+ const Components = useComponentsContext()!;
+ const dict = useDictionary();
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+ const tableHandles = editor.tableHandles;
+
+ const currentCells = useMemo(() => {
+ if (!tableHandles || !props.block) {
+ return [];
+ }
+
+ if (props.orientation === "row") {
+ return tableHandles.getCellsAtRowHandle(props.block, props.index);
+ }
+
+ return tableHandles.getCellsAtColumnHandle(props.block, props.index);
+ }, [props.block, props.index, props.orientation, tableHandles]);
+
+ const updateColor = (color: string, type: "text" | "background") => {
+ const newTable = props.block.content.rows.map((row) => {
+ return {
+ ...row,
+ cells: row.cells.map((cell) => mapTableCell(cell)),
+ };
+ });
+
+ currentCells.forEach(({ row, col }) => {
+ if (type === "text") {
+ newTable[row].cells[col].props.textColor = color;
+ } else {
+ newTable[row].cells[col].props.backgroundColor = color;
+ }
+ });
+
+ editor.updateBlock(props.block, {
+ type: "table",
+ content: {
+ ...props.block.content,
+ rows: newTable,
+ },
+ });
+
+ // Have to reset text cursor position to the block as `updateBlock`
+ // moves the existing selection out of the block.
+ editor.setTextCursorPosition(props.block);
+ };
+
+ if (
+ !currentCells ||
+ !currentCells[0] ||
+ !tableHandles ||
+ (editor.settings.tables.cellTextColor === false &&
+ editor.settings.tables.cellBackgroundColor === false)
+ ) {
+ return null;
+ }
+
+ const firstCell = mapTableCell(currentCells[0].cell);
+
+ return (
+
+
+
+ {/* TODO should I be using the dictionary here? */}
+ {props.children || dict.drag_handle.colors_menuitem}
+
+
+
+
+
+ isTableCell(cell) &&
+ cell.props.textColor === firstCell.props.textColor
+ )
+ ? firstCell.props.textColor
+ : "default",
+ setColor: (color) => {
+ updateColor(color, "text");
+ },
+ }
+ : undefined
+ }
+ background={
+ editor.settings.tables.cellBackgroundColor
+ ? {
+ color: currentCells.every(
+ ({ cell }) =>
+ isTableCell(cell) &&
+ cell.props.backgroundColor ===
+ firstCell.props.backgroundColor
+ )
+ ? firstCell.props.backgroundColor
+ : "default",
+ setColor: (color) => updateColor(color, "background"),
+ }
+ : undefined
+ }
+ />
+
+
+ );
+};
diff --git a/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/DeleteButton.tsx b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/DeleteButton.tsx
index dc71823af8..bbcf616692 100644
--- a/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/DeleteButton.tsx
+++ b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/DeleteButton.tsx
@@ -3,7 +3,6 @@ import {
DefaultInlineContentSchema,
DefaultStyleSchema,
InlineContentSchema,
- PartialTableContent,
StyleSchema,
} from "@blocknote/core";
@@ -12,11 +11,11 @@ import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
import { useDictionary } from "../../../../i18n/dictionary.js";
import { TableHandleMenuProps } from "../TableHandleMenuProps.js";
-export const DeleteRowButton = <
+export const DeleteButton = <
I extends InlineContentSchema = DefaultInlineContentSchema,
S extends StyleSchema = DefaultStyleSchema
>(
- props: TableHandleMenuProps
+ props: TableHandleMenuProps & { orientation: "row" | "column" }
) => {
const Components = useComponentsContext()!;
const dict = useDictionary();
@@ -26,81 +25,20 @@ export const DeleteRowButton = <
S
>();
- return (
- {
- const content: PartialTableContent = {
- type: "tableContent",
- columnWidths: props.block.content.columnWidths,
- rows: props.block.content.rows.filter(
- (_, index) => index !== props.index
- ),
- };
-
- editor.updateBlock(props.block, {
- type: "table",
- content,
- });
-
- // Have to reset text cursor position to the block as `updateBlock`
- // moves the existing selection out of the block.
- editor.setTextCursorPosition(props.block);
- }}>
- {dict.table_handle.delete_row_menuitem}
-
- );
-};
-
-export const DeleteColumnButton = <
- I extends InlineContentSchema = DefaultInlineContentSchema,
- S extends StyleSchema = DefaultStyleSchema
->(
- props: TableHandleMenuProps
-) => {
- const Components = useComponentsContext()!;
- const dict = useDictionary();
+ const tableHandles = editor.tableHandles;
- const editor = useBlockNoteEditor<
- { table: DefaultBlockSchema["table"] },
- I,
- S
- >();
+ if (!tableHandles) {
+ return null;
+ }
return (
{
- const content: PartialTableContent = {
- type: "tableContent",
- columnWidths: props.block.content.columnWidths.filter(
- (_, index) => index !== props.index
- ),
- rows: props.block.content.rows.map((row) => ({
- cells: row.cells.filter((_, index) => index !== props.index),
- })),
- };
-
- editor.updateBlock(props.block, {
- type: "table",
- content,
- });
-
- // Have to reset text cursor position to the block as `updateBlock`
- // moves the existing selection out of the block.
- editor.setTextCursorPosition(props.block);
+ tableHandles.removeRowOrColumn(props.index, props.orientation);
}}>
- {dict.table_handle.delete_column_menuitem}
+ {props.orientation === "row"
+ ? dict.table_handle.delete_row_menuitem
+ : dict.table_handle.delete_column_menuitem}
);
};
-
-export const DeleteButton = <
- I extends InlineContentSchema = DefaultInlineContentSchema,
- S extends StyleSchema = DefaultStyleSchema
->(
- props: TableHandleMenuProps & { orientation: "row" | "column" }
-) =>
- props.orientation === "row" ? (
-
- ) : (
-
- );
diff --git a/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/TableHeaderButton.tsx b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/TableHeaderButton.tsx
new file mode 100644
index 0000000000..1860127f64
--- /dev/null
+++ b/packages/react/src/components/TableHandles/TableHandleMenu/DefaultButtons/TableHeaderButton.tsx
@@ -0,0 +1,114 @@
+import {
+ DefaultBlockSchema,
+ DefaultInlineContentSchema,
+ DefaultStyleSchema,
+ InlineContentSchema,
+ StyleSchema,
+} from "@blocknote/core";
+
+import { useComponentsContext } from "../../../../editor/ComponentsContext.js";
+import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
+import { TableHandleMenuProps } from "../TableHandleMenuProps.js";
+import { useDictionary } from "../../../../i18n/dictionary.js";
+
+export const TableHeaderRowButton = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableHandleMenuProps & { orientation: "row" | "column" }
+) => {
+ const Components = useComponentsContext()!;
+ const dict = useDictionary();
+
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+ const tableHandles = editor.tableHandles;
+
+ if (
+ !tableHandles ||
+ props.index !== 0 ||
+ props.orientation !== "row" ||
+ !editor.settings.tables.headers
+ ) {
+ return null;
+ }
+
+ // We only support 1 header row for now
+ const isHeaderRow = Boolean(props.block.content.headerRows);
+
+ return (
+ {
+ // The block may have been modified and out of date, so we get the latest block
+ const block = editor.getBlock(props.block.id);
+ if (!block) {
+ return;
+ }
+ editor.updateBlock(block, {
+ ...block,
+ content: {
+ ...block.content,
+ headerRows: isHeaderRow ? undefined : 1,
+ },
+ });
+ }}>
+ {dict.drag_handle.header_row_menuitem}
+
+ );
+};
+
+export const TableHeaderColumnButton = <
+ I extends InlineContentSchema = DefaultInlineContentSchema,
+ S extends StyleSchema = DefaultStyleSchema
+>(
+ props: TableHandleMenuProps & { orientation: "row" | "column" }
+) => {
+ const Components = useComponentsContext()!;
+ const dict = useDictionary();
+
+ const editor = useBlockNoteEditor<
+ { table: DefaultBlockSchema["table"] },
+ I,
+ S
+ >();
+ const tableHandles = editor.tableHandles;
+
+ if (
+ !tableHandles ||
+ props.index !== 0 ||
+ props.orientation !== "column" ||
+ !editor.settings.tables.headers
+ ) {
+ return null;
+ }
+
+ // We only support 1 header column for now
+ const isHeaderColumn = Boolean(props.block.content.headerCols);
+
+ return (
+ {
+ // The block may have been modified and out of date, so we get the latest block
+ const block = editor.getBlock(props.block.id);
+ if (!block) {
+ return;
+ }
+ editor.updateBlock(block, {
+ ...block,
+ content: {
+ ...block.content,
+ headerCols: isHeaderColumn ? undefined : 1,
+ },
+ });
+ }}>
+ {dict.drag_handle.header_column_menuitem}
+
+ );
+};
diff --git a/packages/react/src/components/TableHandles/TableHandleMenu/TableHandleMenu.tsx b/packages/react/src/components/TableHandles/TableHandleMenu/TableHandleMenu.tsx
index 57f0cd9bd6..b9710d6e06 100644
--- a/packages/react/src/components/TableHandles/TableHandleMenu/TableHandleMenu.tsx
+++ b/packages/react/src/components/TableHandles/TableHandleMenu/TableHandleMenu.tsx
@@ -10,6 +10,9 @@ import { useComponentsContext } from "../../../editor/ComponentsContext.js";
import { AddButton } from "./DefaultButtons/AddButton.js";
import { DeleteButton } from "./DefaultButtons/DeleteButton.js";
import { TableHandleMenuProps } from "./TableHandleMenuProps.js";
+import { ColorPickerButton } from "./DefaultButtons/ColorPicker.js";
+import { TableHeaderColumnButton } from "./DefaultButtons/TableHeaderButton.js";
+import { TableHeaderRowButton } from "./DefaultButtons/TableHeaderButton.js";
export const TableHandleMenu = <
I extends InlineContentSchema = DefaultInlineContentSchema,
@@ -40,6 +43,21 @@ export const TableHandleMenu = <
index={props.index}
side={props.orientation === "row" ? "below" : ("right" as any)}
/>
+
+
+
>
)}
diff --git a/packages/react/src/components/TableHandles/TableHandleProps.ts b/packages/react/src/components/TableHandles/TableHandleProps.ts
index c7c2272df3..3d0ab0766d 100644
--- a/packages/react/src/components/TableHandles/TableHandleProps.ts
+++ b/packages/react/src/components/TableHandles/TableHandleProps.ts
@@ -11,8 +11,6 @@ import { DragEvent, FC } from "react";
import { DragHandleMenuProps } from "../SideMenu/DragHandleMenu/DragHandleMenuProps.js";
-type NonUndefined = T extends undefined ? never : T;
-
export type TableHandleProps<
I extends InlineContentSchema = DefaultInlineContentSchema,
S extends StyleSchema = DefaultStyleSchema
@@ -41,14 +39,15 @@ export type TableHandleProps<
>;
} & Pick, "block"> &
Pick<
- NonUndefined<
+ Exclude<
BlockNoteEditor<
{
table: DefaultBlockSchema["table"];
},
I,
S
- >["tableHandles"]
+ >["tableHandles"],
+ undefined
>,
"dragEnd" | "freezeHandles" | "unfreezeHandles"
>;
diff --git a/packages/react/src/components/TableHandles/TableHandlesController.tsx b/packages/react/src/components/TableHandles/TableHandlesController.tsx
index 31ccecf4d3..6e69f23463 100644
--- a/packages/react/src/components/TableHandles/TableHandlesController.tsx
+++ b/packages/react/src/components/TableHandles/TableHandlesController.tsx
@@ -16,11 +16,14 @@ import { TableHandle } from "./TableHandle.js";
import { TableHandleProps } from "./TableHandleProps.js";
import { useExtendButtonsPositioning } from "./hooks/useExtendButtonsPositioning.js";
import { useTableHandlesPositioning } from "./hooks/useTableHandlesPositioning.js";
+import { TableCellButton } from "./TableCellButton.js";
+import { TableCellButtonProps } from "./TableCellButtonProps.js";
export const TableHandlesController = <
I extends InlineContentSchema = DefaultInlineContentSchema,
S extends StyleSchema = DefaultStyleSchema
>(props: {
+ tableCellHandle?: FC>;
tableHandle?: FC>;
extendButton?: FC>;
}) => {
@@ -75,7 +78,7 @@ export const TableHandlesController = <
state?.draggingState?.mousePos,
]);
- const { rowHandle, colHandle } = useTableHandlesPositioning(
+ const { rowHandle, colHandle, cellHandle } = useTableHandlesPositioning(
state?.show || false,
state?.referencePosCell || null,
state?.referencePosTable || null,
@@ -98,6 +101,7 @@ export const TableHandlesController = <
const TableHandleComponent = props.tableHandle || TableHandle;
const ExtendButtonComponent = props.extendButton || ExtendButton;
+ const TableCellHandleComponent = props.tableCellHandle || TableCellButton;
return (
<>
@@ -148,6 +152,23 @@ export const TableHandlesController = <
)}
+ {menuContainerRef &&
+ cellHandle.isMounted &&
+ state.colIndex !== undefined &&
+ state.rowIndex !== undefined && (
+
+ )}
+
{/* note that the extend buttons are always shown (we don't look at isMounted etc,
because otherwise the table slightly shifts when they unmount */}
{
// Will be null on initial render when used in UI component controllers.
- if (referencePosCell === null || referencePosTable === null) {
+ if (
+ referencePosCell === null ||
+ referencePosTable === null ||
+ // Ignore cell handle when dragging
+ (draggingState && orientation === "cell")
+ ) {
return;
}
@@ -84,7 +111,9 @@ function useTableHandlePosition(
const fn =
orientation === "row"
? getBoundingClientRectRow
- : getBoundingClientRectCol;
+ : orientation === "col"
+ ? getBoundingClientRectCol
+ : getBoundingClientRectCell;
return fn(referencePosCell, referencePosTable, draggingState);
},
});
@@ -115,6 +144,7 @@ export function useTableHandlesPositioning(
): {
rowHandle: ReturnType;
colHandle: ReturnType;
+ cellHandle: ReturnType;
} {
const rowHandle = useTableHandlePosition(
"row",
@@ -130,12 +160,20 @@ export function useTableHandlesPositioning(
referencePosTable,
draggingState
);
+ const cellHandle = useTableHandlePosition(
+ "cell",
+ show,
+ referencePosCell,
+ referencePosTable,
+ draggingState
+ );
return useMemo(
() => ({
rowHandle,
colHandle,
+ cellHandle,
}),
- [colHandle, rowHandle]
+ [colHandle, rowHandle, cellHandle]
);
}
diff --git a/packages/react/src/editor/ComponentsContext.tsx b/packages/react/src/editor/ComponentsContext.tsx
index 38ef7765fd..0bbd6d4dcb 100644
--- a/packages/react/src/editor/ComponentsContext.tsx
+++ b/packages/react/src/editor/ComponentsContext.tsx
@@ -34,6 +34,19 @@ type ToolbarButtonType = {
| { children: ReactNode; label?: string }
| { children?: undefined; label: string }
);
+
+type MenuButtonType = {
+ className?: string;
+ onClick?: (e: MouseEvent) => void;
+ icon?: ReactNode;
+ onDragStart?: (e: React.DragEvent) => void;
+ onDragEnd?: (e: React.DragEvent) => void;
+ draggable?: boolean;
+} & (
+ | { children: ReactNode; label?: string }
+ | { children?: undefined; label: string }
+);
+
export type ComponentProps = {
FormattingToolbar: {
Root: ToolbarRootType;
@@ -279,6 +292,7 @@ export type ComponentProps = {
children?: ReactNode;
sub?: boolean;
};
+ Button: MenuButtonType;
};
Popover: {
Root: {
diff --git a/packages/shadcn/src/components.ts b/packages/shadcn/src/components.ts
index c365118537..0b719e4fbe 100644
--- a/packages/shadcn/src/components.ts
+++ b/packages/shadcn/src/components.ts
@@ -10,6 +10,7 @@ import {
MenuLabel,
MenuTrigger,
} from "./menu/Menu.js";
+import { MenuButton } from "./menu/Button.js";
import { Panel } from "./panel/Panel.js";
import { PanelTab } from "./panel/PanelTab.js";
import { PanelTextInput } from "./panel/PanelTextInput.js";
@@ -101,6 +102,7 @@ export const components: Components = {
Divider: MenuDivider,
Label: MenuLabel,
Item: MenuItem,
+ Button: MenuButton,
},
Popover: {
Root: Popover,
diff --git a/packages/shadcn/src/menu/Button.tsx b/packages/shadcn/src/menu/Button.tsx
new file mode 100644
index 0000000000..1ac021e553
--- /dev/null
+++ b/packages/shadcn/src/menu/Button.tsx
@@ -0,0 +1,45 @@
+import { assertEmpty } from "@blocknote/core";
+import { ComponentProps } from "@blocknote/react";
+import { forwardRef } from "react";
+
+import { cn } from "../lib/utils.js";
+import { useShadCNComponentsContext } from "../ShadCNComponentsContext.js";
+
+export const MenuButton = forwardRef<
+ HTMLButtonElement,
+ ComponentProps["Generic"]["Menu"]["Button"]
+>((props, ref) => {
+ const {
+ className,
+ children,
+ icon,
+ onClick,
+ onDragEnd,
+ onDragStart,
+ draggable,
+ label,
+ ...rest
+ } = props;
+
+ // false, because rest props can be added by ariakit when button is used as a trigger
+ // assertEmpty in this case is only used at typescript level, not runtime level
+ assertEmpty(rest, false);
+
+ const ShadCNComponents = useShadCNComponentsContext()!;
+
+ return (
+
+ {icon}
+ {children}
+
+ );
+});
diff --git a/packages/shadcn/src/menu/Menu.tsx b/packages/shadcn/src/menu/Menu.tsx
index 5e1f4ae135..6ed2cc3b48 100644
--- a/packages/shadcn/src/menu/Menu.tsx
+++ b/packages/shadcn/src/menu/Menu.tsx
@@ -149,7 +149,7 @@ export const MenuItem = forwardRef<
if (checked !== undefined) {
return (
- {props.transformer.transformInlineContent(cell)}
+ {props.transformer.transformInlineContent(
+ mapTableCell(cell).content
+ )}
))}
diff --git a/playground/src/examples.gen.tsx b/playground/src/examples.gen.tsx
index 32bb88d44b..442c480b5c 100644
--- a/playground/src/examples.gen.tsx
+++ b/playground/src/examples.gen.tsx
@@ -657,6 +657,27 @@
"slug": "ui-components"
}
},
+ {
+ "projectSlug": "advanced-tables",
+ "fullSlug": "ui-components/advanced-tables",
+ "pathFromRoot": "examples/03-ui-components/15-advanced-tables",
+ "config": {
+ "playground": true,
+ "docs": true,
+ "author": "nperez0111",
+ "tags": [
+ "Intermediate",
+ "UI Components",
+ "Tables",
+ "Appearance & Styling"
+ ]
+ },
+ "title": "Advanced Tables",
+ "group": {
+ "pathFromRoot": "examples/03-ui-components",
+ "slug": "ui-components"
+ }
+ },
{
"projectSlug": "link-toolbar-buttons",
"fullSlug": "ui-components/link-toolbar-buttons",
diff --git a/vitest.workspace.ts b/vitest.workspace.ts
new file mode 100644
index 0000000000..4c3c4592c1
--- /dev/null
+++ b/vitest.workspace.ts
@@ -0,0 +1,13 @@
+import { defineWorkspace } from "vitest/config";
+
+export default defineWorkspace([
+ "./packages/xl-docx-exporter/vite.config.ts",
+ "./packages/react/vite.config.ts",
+ "./packages/shadcn/vite.config.ts",
+ "./packages/server-util/vite.config.ts",
+ "./packages/xl-pdf-exporter/vite.config.ts",
+ "./packages/mantine/vite.config.ts",
+ "./packages/core/vite.config.ts",
+ "./packages/xl-multi-column/vite.config.ts",
+ "./packages/ariakit/vite.config.ts",
+]);