Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to BlockNote, Image support, Video Support, tamagui theme, white and black theme #503

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

milaiwi
Copy link
Collaborator

@milaiwi milaiwi commented Feb 4, 2025

Changes Overview

This PR introduces several significant updates to the editor functionality and UI:

  1. Converted useEditor from TipTap to Custom BlockNoteSchema

    • Replaced the existing TipTap-based editor with a custom BlockNoteSchema implementation.
    • Why? BlockNoteSchema provides more out-of-the-box features, is easier to maintain, and is more scalable for future enhancements.
    • Note: This change was inspired by the open-source project Mintter. Huge thanks to their team for the guidance and examples!
  2. Added Theme Switching in Bottom Left Corner Using Tamagui

    • Implemented a theme switcher in the bottom-left corner of the editor interface.
    • Utilized Tamagui for a seamless and responsive UI experience.
    • Why? This improves user customization and aligns with modern design practices.
  3. Added Image and Video Support

    • Enabled image and video embedding in the editor.
    • Why? This enhances the editor's functionality, making it more versatile for content creation.
    • Note: The current implementation needs further optimization for performance and usability. This will be addressed in future updates.

Why This PR is a Single Unit

I understand that these changes could have been broken into smaller, more focused PRs. However, many of these updates were interdependent and built on top of each other, making it challenging to separate them without causing inconsistencies or breaking functionality. This PR serves as a comprehensive update for testing and gathering feedback.


Next Steps

  • Error Fixing and Import Cleanup: There are several errors and import changes that need to be addressed. These will be resolved after merging, as this PR is primarily for temporary testing and gathering opinions.
  • Optimization: Image and video support will be further optimized in subsequent updates.
  • Feedback Welcome: Please share your thoughts on the changes, especially the BlockNoteSchema implementation and theme switcher. Your feedback will help refine these features before finalizing them.

Acknowledgments

Special thanks to the Mintter open-source project for their work on BlockNoteSchema, which greatly influenced this implementation. Their contributions to the community are invaluable!


@milaiwi
Copy link
Collaborator Author

milaiwi commented Feb 4, 2025

I will clean the code up, just want suggestions!

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces a major architectural change, converting the editor from TipTap to BlockNote while adding image/video support and implementing theme switching using Tamagui.

  • Critical security concern in /electron/main/filesystem/storage/MediaStore.ts - potential path traversal vulnerability in file operations and lack of file size limits
  • Unsafe implementation in /src/lib/blocknote/core/extensions/LinkMenu/LinkMenuPlugin.ts - direct use of user-provided URLs without sanitization in link handling
  • Empty configuration files .tamagui/tamagui-components.config.cjs and .tamagui/tamagui.config.json could break theme functionality
  • Commented out code and @ts-ignore directives throughout BlockNote implementation suggest incomplete migration
  • Memory leak potential in /src/components/Editor/types/Video/video.tsx from unremoved event listeners and unsafe type assertions

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

293 file(s) reviewed, 456 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +32 to +33
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Disabling these accessibility rules may make the app less accessible to keyboard and screen reader users. Consider enabling them and properly handling keyboard interactions.

@@ -48,7 +48,7 @@ jobs:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: "--max-old-space-size=8192"
NODE_OPTIONS: '--max-old-space-size=8192'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider moving NODE_OPTIONS to a shared environment variable at the job level since it's used multiple times with the same value

}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Files should end with a newline character to follow POSIX standards and avoid potential issues with text processing tools. Consider adding back the trailing newline.

Suggested change
}
}

Comment on lines +1896 to +1926
var conf = {
themes,
defaultFont: "body",
animations,
shouldAddPrefersColorThemes: true,
themeClassNameOnRoot: true,
shorthands,
fonts: {
heading: headingFont,
body: bodyFont,
mono: monoFont,
editorBody
},
tokens: (0, import_web4.createTokens)({
color,
radius,
zIndex,
space,
size,
opacity: {
low: 0.4,
medium: 0.6,
high: 0.8,
full: 1
}
}),
media,
settings: {
webContainerType: "inherit"
}
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider extracting opacity values into a separate constants file for better maintainability

"hsl(0, 0%, 56.1%)",
"hsl(0, 0%, 52.3%)",
"hsl(0, 0%, 43.5%)",
"hsl(0, 0%, 92.0%)",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Duplicate value 'hsl(0, 0%, 92.0%)' in light_customGray palette may cause confusion with gray12

*/
defaultOpened={true}
trigger={'hover'}
closeDelay={10000000}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using 10000000 as closeDelay is a fragile solution. Consider implementing proper menu state management or using Infinity

let index = 0

const groups = _.groupBy(props.filteredItems, (i) => i.group)
// const showNostr = trpc.experiments.get.useQuery().data?.nostr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Remove commented out code related to Nostr if it's no longer needed

Comment on lines 31 to 34
setTimeout(() => {
scroller.current = document.getElementById('scroll-page-wrapper')
}, 100)
}, [])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using setTimeout to access DOM element is fragile. Consider using a MutationObserver or effect cleanup to handle scroll-page-wrapper availability.

Comment on lines 38 to 54
useEffect(() => {
// Updates whether the item is selected with the keyboard (triggered on selectedIndex prop change).
updateSelection()

// if (
// isSelected() &&
// itemRef.current &&
// itemRef.current.getBoundingClientRect().left > MIN_LEFT_MARGIN //TODO: Kinda hacky, fix
// // This check is needed because initially the menu is initialized somewhere above outside the screen (with left = 1)
// // scrollIntoView() is called before the menu is set in the right place, and without the check would scroll to the top of the page every time
// ) {
// itemRef.current.scrollIntoView({
// behavior: 'smooth',
// block: 'nearest',
// })
// }
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Missing dependency array causing unnecessary re-renders on every render cycle

Suggested change
useEffect(() => {
// Updates whether the item is selected with the keyboard (triggered on selectedIndex prop change).
updateSelection()
// if (
// isSelected() &&
// itemRef.current &&
// itemRef.current.getBoundingClientRect().left > MIN_LEFT_MARGIN //TODO: Kinda hacky, fix
// // This check is needed because initially the menu is initialized somewhere above outside the screen (with left = 1)
// // scrollIntoView() is called before the menu is set in the right place, and without the check would scroll to the top of the page every time
// ) {
// itemRef.current.scrollIntoView({
// behavior: 'smooth',
// block: 'nearest',
// })
// }
})
useEffect(() => {
// Updates whether the item is selected with the keyboard (triggered on selectedIndex prop change).
updateSelection()
// if (
// isSelected() &&
// itemRef.current &&
// itemRef.current.getBoundingClientRect().left > MIN_LEFT_MARGIN //TODO: Kinda hacky, fix
// // This check is needed because initially the menu is initialized somewhere above outside the screen (with left = 1)
// // scrollIntoView() is called before the menu is set in the right place, and without the check would scroll to the top of the page every time
// ) {
// itemRef.current.scrollIntoView({
// behavior: 'smooth',
// block: 'nearest',
// })
// }
}, [props.isSelected])


return () => newRect as DOMRect
},
[referencePos.current], // eslint-disable-line
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Dependency array includes referencePos.current which may cause unnecessary rerenders. Should use referencePos instead.

Suggested change
[referencePos.current], // eslint-disable-line
[referencePos], // Track the ref itself, not its current value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant