Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
"y-partykit": "^0.0.25",
"yjs": "^13.6.27",
"zod": "^3.25.67",
"zustand": "^5.0.3"
"zustand": "^5.0.3",
"@blocknote/math": "latest",
"katex": "^0.16.22"
},
"devDependencies": {
"@blocknote/ariakit": "workspace:^",
Expand Down
10 changes: 10 additions & 0 deletions examples/01-basic/14-math/.bnexample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"playground": true,
"docs": true,
"author": "nperez0111",
"tags": ["Basic"],
"dependencies": {
"@blocknote/math": "latest",
"katex": "^0.16.22"
}
}
3 changes: 3 additions & 0 deletions examples/01-basic/14-math/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Math Block

TODO
14 changes: 14 additions & 0 deletions examples/01-basic/14-math/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Math Block</title>
<script>
<!-- AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY -->
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/01-basic/14-math/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./src/App.jsx";

const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
29 changes: 29 additions & 0 deletions examples/01-basic/14-math/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@blocknote/example-basic-math",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"private": true,
"version": "0.12.4",
"scripts": {
"start": "vite",
"dev": "vite",
"build:prod": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@blocknote/core": "latest",
"@blocknote/react": "latest",
"@blocknote/ariakit": "latest",
"@blocknote/mantine": "latest",
"@blocknote/shadcn": "latest",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"@blocknote/math": "latest",
"katex": "^0.16.22"
},
"devDependencies": {
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.0",
"@vitejs/plugin-react": "^4.3.1",
"vite": "^5.3.4"
}
}
43 changes: 43 additions & 0 deletions examples/01-basic/14-math/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { BlockNoteSchema, createCodeBlockSpec } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { createMathBlockSpec } from "@blocknote/math";
import "katex/dist/katex.min.css";
import { useEffect } from "react";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
schema: BlockNoteSchema.create().extend({
blockSpecs: {
math: createMathBlockSpec(),
},
}),
initialContent: [
{
type: "paragraph",
content: "Checkout this math!",
},
{
type: "math",
props: {
expression: "2x^2",
},
},
{
type: "paragraph",
},
],
});
useEffect(() => {
return editor.onChange(() => {
console.log(editor.blocksToFullHTML(editor.document));
console.log(editor.blocksToHTMLLossy(editor.document));
});
}, []);

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
}
36 changes: 36 additions & 0 deletions examples/01-basic/14-math/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"composite": true
},
"include": [
"."
],
"__ADD_FOR_LOCAL_DEV_references": [
{
"path": "../../../packages/core/"
},
{
"path": "../../../packages/react/"
}
]
}
32 changes: 32 additions & 0 deletions examples/01-basic/14-math/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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),
},
}));
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export class FormattingToolbarView implements PluginView {
from,
to,
});
console.log({ shouldShow });

// in jsdom, Range.prototype.getClientRects is not implemented,
// this would cause `getSelectionBoundingBox` to fail
Expand Down
23 changes: 23 additions & 0 deletions packages/math/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Loading
Loading