Add a Custom Block for Katex (fixes #741) #2019
Open
+159
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
/claim #741
/fixes #741
Description:
Custom Block for KaTeX Equations (#741)
This PR adds a new custom block for rendering LaTeX equations using KaTeX, addressing the feature request in #741. The block provides a user-friendly interface for inputting and editing mathematical expressions directly in the editor, similar to Notion's equation feature.
Changes
New Block Implementation: Added
packages/core/src/blocks/Equation/block.ts
defining the equation block spec.props.latex
.<div class="equation" data-latex="...">
from HTML.Integration:
packages/core/src/blocks/index.ts
.defaultBlockSpecs
inpackages/core/src/blocks/defaultBlocks.ts
for default schema inclusion.defaultBlocks.ts
from the Equation block file.Dependencies: Added
katex
to@blocknote/core
dependencies for rendering.Keyboard Shortcut: Cmd/Ctrl + Alt + E to insert a new equation block at the cursor position.
TypeScript Fixes: Adjusted spec structure using
createBlockSpec
with proper overloads to resolve type errors.Usage