Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
aaaa7a3
added Latex Block
tidann Jun 2, 2025
737d9f2
added click to edit feature
Plouil Jun 2, 2025
3b49d70
Cleanup
tidann Jun 2, 2025
c0aa8f0
Revert "added click to edit feature"
tidann Jun 2, 2025
be80002
test
tidann Jun 2, 2025
1e12810
I did things
tidann Jun 2, 2025
aca4857
added codeeditor
tidann Jun 2, 2025
451a164
[temp] started syntax highlighting
tidann Jun 2, 2025
84db73a
refactoring
tidann Jun 2, 2025
ca14d68
refactor
tidann Jun 2, 2025
161b146
more refactor
tidann Jun 2, 2025
07a64db
better error handling and refactoring
tidann Jun 2, 2025
3447a34
Refactor LatexRenderer and MermaidRenderer to use shared styles for c…
tidann Jun 2, 2025
d0ae34a
Add text alignment and background color properties to LatexBlock and …
tidann Jun 2, 2025
44919f6
Add InlineLatex support to BlockNoteEditor and BlockNoteToolbar; mino…
tidann Jun 3, 2025
ddda804
Integrate useLatexDetection hook into BlockNoteEditor and update Inli…
tidann Jun 3, 2025
2713b33
Enhance InlineLatex component to manage focus state and update formul…
tidann Jun 3, 2025
29b2fe5
Implement Markdown parsing with LaTeX support in MarkdownButton compo…
tidann Jun 3, 2025
c7abf48
Remove debug logging from MarkdownButton and InlineLatex components t…
tidann Jun 3, 2025
b7812ee
Adding basic chart bloc
Math-s314 Jun 3, 2025
65bc6a6
Minor Corrections to Chart Block
Math-s314 Jun 3, 2025
4b57a79
Update package dependencies and refine ChartBlock configuration
tidann Jun 3, 2025
c4a3c9e
Fixed the gaussian integral
tidann Jun 3, 2025
666988f
Enhance InlineLatexButton and update icon in SlashMenuItems
tidann Jun 3, 2025
69d8037
Implement PDF export mappings for new block types and update dependen…
tidann Jun 3, 2025
c91ac7d
Enhance BlockNoteEditor with Markdown and LaTeX support
tidann Jun 3, 2025
a6eb8af
Remove debug logging from BlockNoteEditor and useLatexDetection for c…
tidann Jun 3, 2025
487607b
Refactor useLatexDetection by removing unused lastKeyRef logic for cl…
tidann Jun 3, 2025
eaf5638
Add SuggestionMenuController to BlockNoteEditor for inline LaTeX support
tidann Jun 3, 2025
01b8049
Add Backspace handling in LatexComponent for improved editing experience
tidann Jun 3, 2025
d650942
added inline latex pdf
tidann Jun 4, 2025
32d4b6c
Enhance DOCX export mappings by adding support for LaTeX, Mermaid, an…
tidann Jun 4, 2025
db4d492
Multiple functions chart and specific editor
Math-s314 Jun 4, 2025
686605c
Adding first version AI Latex creation
Math-s314 Jun 4, 2025
e1dc683
Mini corrections
Math-s314 Jun 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "added click to edit feature"
This reverts commit 32462d5.
  • Loading branch information
tidann authored and Math-s314 committed Jun 7, 2025
commit c0aa8f0b9db511b974983d5f1d98b97cfb6d44e3
37 changes: 0 additions & 37 deletions package-lock.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const DividerBlock = createReactBlockSpec(
$margin="1rem 0"
$css={`border: 1px solid ${colorsTokens['greyscale-300']};`}
/>

);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,45 @@ import { DocsBlockNoteEditor } from '../../types';

const LatexRenderer = ({
formula,
isEditing,
onFormulaChange,
editor,
block,
}: {
formula: string;
isEditing?: boolean;
onFormulaChange?: (formula: string) => void;
editor: DocsBlockNoteEditor;
block: any;
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const boxRef = useRef<HTMLDivElement>(null);
const { colorsTokens } = useCunninghamTheme();
const [inputValue, setInputValue] = useState(formula);
const [isEditing, setIsEditing] = useState(false);

// Live preview
useEffect(() => {
if (containerRef.current) {
try {
katex.render(isEditing ? inputValue : formula, containerRef.current, {
katex.render(formula, containerRef.current, {
displayMode: true,
throwOnError: false,
});
} catch {
containerRef.current.innerHTML = 'Invalid LaTeX formula';
}
}
}, [formula, inputValue, isEditing]);

// Click outside detection
useEffect(() => {
if (!isEditing) return;
const handleClickOutside = (event: MouseEvent) => {
if (
boxRef.current &&
!boxRef.current.contains(event.target as Node)
) {
setIsEditing(false);
// Optionally, update the formula when leaving edit mode
if (inputValue !== formula) {
onFormulaChange?.(inputValue);
}
}
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [isEditing, inputValue, formula, onFormulaChange]);
}, [formula]);

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
};

const handleBoxClick = () => {
if (editor.isEditable) setIsEditing(true);
const newValue = e.target.value;
setInputValue(newValue);
onFormulaChange?.(newValue);
};

return (
<Box
ref={boxRef}
$padding="1rem"
$background={colorsTokens['greyscale-100']}
style={{
borderRadius: '4px',
border: `1px solid ${colorsTokens['greyscale-300']}`,
overflowX: 'auto',
cursor: editor.isEditable ? 'pointer' : 'default',
}}
onClick={handleBoxClick}
>
{isEditing ? (
<Box $gap="1rem">
Expand All @@ -91,14 +60,11 @@ const LatexRenderer = ({
onChange={handleInputChange}
placeholder="Enter LaTeX formula..."
fullWidth
autoFocus
/>
<div ref={containerRef} />
</Box>
) : (
<Box $gap="0.5rem">
<div ref={containerRef} />
</Box>
<div ref={containerRef} />
)}
</Box>
);
Expand All @@ -118,6 +84,9 @@ export const LatexBlock = createReactBlockSpec(
},
{
render: ({ block, editor }) => {
const isEditing =
editor.isEditable && block.props.backgroundColor === 'default';

const handleFormulaChange = (newFormula: string) => {
editor.updateBlock(block, {
props: { formula: newFormula },
Expand All @@ -127,9 +96,8 @@ export const LatexBlock = createReactBlockSpec(
return (
<LatexRenderer
formula={block.props.formula}
isEditing={isEditing}
onFormulaChange={handleFormulaChange}
editor={editor}
block={block}
/>
);
},
Expand Down
105 changes: 0 additions & 105 deletions src/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@
"react-dom": "19.1.0",
"typescript": "5.8.3",
"yjs": "13.6.27"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
Loading