diff --git a/docs/content/docs/features/blocks/math.mdx b/docs/content/docs/features/blocks/math.mdx index d8f2a7ae60..a112f45c5e 100644 --- a/docs/content/docs/features/blocks/math.mdx +++ b/docs/content/docs/features/blocks/math.mdx @@ -17,7 +17,7 @@ npm install @blocknote/math-block ## Adding to your editor -The package exports `createReactMathBlockSpec` (the block) and `createReactInlineMathSpec` (the inline content). Add them to your schema's `blockSpecs` and `inlineContentSpecs` respectively: +The package exports `createReactMathBlockSpec` (the block) and `createReactInlineMathSpec` (the inline content). Add them to your schema's `blockSpecs` and `inlineContentSpecs` respectively, and import the package's stylesheet, which styles the rendered formulas: ```tsx import { BlockNoteSchema } from "@blocknote/core"; @@ -25,6 +25,7 @@ import { createReactMathBlockSpec, createReactInlineMathSpec, } from "@blocknote/math-block"; +import "@blocknote/math-block/style.css"; const schema = BlockNoteSchema.create().extend({ blockSpecs: { diff --git a/examples/05-interoperability/05-converting-blocks-to-pdf/src/App.tsx b/examples/05-interoperability/05-converting-blocks-to-pdf/src/App.tsx index bfce34f37a..e825247f94 100644 --- a/examples/05-interoperability/05-converting-blocks-to-pdf/src/App.tsx +++ b/examples/05-interoperability/05-converting-blocks-to-pdf/src/App.tsx @@ -10,6 +10,7 @@ import "@blocknote/core/fonts/inter.css"; import * as locales from "@blocknote/core/locales"; import { BlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { createReactDiagramBlockSpec } from "@blocknote/diagram-block"; import { diagramBlockMapping } from "@blocknote/diagram-block/typst-exporter"; import { diff --git a/examples/05-interoperability/06-converting-blocks-to-docx/src/App.tsx b/examples/05-interoperability/06-converting-blocks-to-docx/src/App.tsx index 3a047c97af..52150406d8 100644 --- a/examples/05-interoperability/06-converting-blocks-to-docx/src/App.tsx +++ b/examples/05-interoperability/06-converting-blocks-to-docx/src/App.tsx @@ -9,6 +9,7 @@ import "@blocknote/core/fonts/inter.css"; import * as locales from "@blocknote/core/locales"; import { BlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { createReactInlineMathSpec, createReactMathBlockSpec, diff --git a/examples/05-interoperability/07-converting-blocks-to-odt/src/App.tsx b/examples/05-interoperability/07-converting-blocks-to-odt/src/App.tsx index 9a59344fef..dd61ed6d8e 100644 --- a/examples/05-interoperability/07-converting-blocks-to-odt/src/App.tsx +++ b/examples/05-interoperability/07-converting-blocks-to-odt/src/App.tsx @@ -9,6 +9,7 @@ import * as locales from "@blocknote/core/locales"; import "@blocknote/core/fonts/inter.css"; import { BlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { createReactInlineMathSpec, createReactMathBlockSpec, diff --git a/examples/05-interoperability/08-converting-blocks-to-react-email/src/App.tsx b/examples/05-interoperability/08-converting-blocks-to-react-email/src/App.tsx index 26f9925453..95652ef3bd 100644 --- a/examples/05-interoperability/08-converting-blocks-to-react-email/src/App.tsx +++ b/examples/05-interoperability/08-converting-blocks-to-react-email/src/App.tsx @@ -10,6 +10,7 @@ import { filterSuggestionItems } from "@blocknote/core/extensions"; import "@blocknote/core/fonts/inter.css"; import { BlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { SuggestionMenuController, getDefaultReactSlashMenuItems, diff --git a/examples/06-custom-schema/09-math-block/src/App.tsx b/examples/06-custom-schema/09-math-block/src/App.tsx index def4ecf3b1..877cff44e5 100644 --- a/examples/06-custom-schema/09-math-block/src/App.tsx +++ b/examples/06-custom-schema/09-math-block/src/App.tsx @@ -12,6 +12,7 @@ import { } from "@blocknote/math-block"; import { BlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { blockTypeSelectItems, FormattingToolbar, diff --git a/packages/math-block/package.json b/packages/math-block/package.json index d14a313ce3..e66f34955f 100644 --- a/packages/math-block/package.json +++ b/packages/math-block/package.json @@ -45,6 +45,10 @@ "import": "./dist/blocknote-math-block.js", "require": "./dist/blocknote-math-block.cjs" }, + "./style.css": { + "import": "./src/style.css", + "style": "./src/style.css" + }, "./docx-exporter": { "types": "./types/src/docx-exporter/index.d.ts", "import": "./dist/docx-exporter.js", diff --git a/packages/math-block/src/helpers/latexToHTMLString.ts b/packages/math-block/src/helpers/latexToHTMLString.ts index c87575d51d..89814020c5 100644 --- a/packages/math-block/src/helpers/latexToHTMLString.ts +++ b/packages/math-block/src/helpers/latexToHTMLString.ts @@ -1,5 +1,4 @@ import katex from "katex"; -import "katex/dist/katex.min.css"; export const latexToHTMLString = ( latex: string, diff --git a/packages/math-block/src/style.css b/packages/math-block/src/style.css new file mode 100644 index 0000000000..c50500801b --- /dev/null +++ b/packages/math-block/src/style.css @@ -0,0 +1,2 @@ +/* KaTeX's stylesheet: the editor shows each formula with KaTeX's HTML output. */ +@import "katex/dist/katex.min.css"; diff --git a/tests/src/end-to-end/versioning/attributionTooltip.test.tsx b/tests/src/end-to-end/versioning/attributionTooltip.test.tsx index a96f31db77..fd9a7775ef 100644 --- a/tests/src/end-to-end/versioning/attributionTooltip.test.tsx +++ b/tests/src/end-to-end/versioning/attributionTooltip.test.tsx @@ -15,6 +15,7 @@ import { } from "@blocknote/math-block"; import { BlockNoteView as MantineBlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { createReactBlockSpec } from "@blocknote/react"; import { expect, test, vi } from "vite-plus/test"; import { render } from "vitest-browser-react"; diff --git a/tests/src/end-to-end/versioning/block-comparison.test.tsx b/tests/src/end-to-end/versioning/block-comparison.test.tsx index 2354fb4fb9..eb943af93e 100644 --- a/tests/src/end-to-end/versioning/block-comparison.test.tsx +++ b/tests/src/end-to-end/versioning/block-comparison.test.tsx @@ -12,6 +12,7 @@ import { } from "@blocknote/core/y"; import { BlockNoteView } from "@blocknote/mantine"; import "@blocknote/mantine/style.css"; +import "@blocknote/math-block/style.css"; import { createBundledHighlighter } from "@shikijs/core"; import { createJavaScriptRegexEngine } from "@shikijs/engine-javascript"; import { testDocument } from "@shared/testDocument.js";