Skip to content

[WEB-64] [EDITOR] Code Blocks :D #352

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

Merged
merged 28 commits into from
Jun 7, 2023

Conversation

josh-ramos-22
Copy link
Contributor

Why are the changes needed?

Currently there is no way to add code snippets to documents. This PR adds code blocks to the editor which allows authors to integrate code snippets with syntax highlighting support for 15+ languages!

Changes

  • Added CodeContentBlock to the cse-ui-kit . Contains the styling for the underlaying code block
  • Created new button CreateCodeBlock and integrated it into editor/index.tsx.
  • New File CodeBlock.tsx contains implementation of code blocks with the following features
    • Syntax Highlighting support for 15+ languages (view screenshots below for full list)
      • Selected via drop down selection menu
    • Support for tabbing so you don't have to spam spacebar.
  • New file util/normalize-tokens.ts: Contains helper function to map between Slate and PrismJS (syntax highlighting library)
  • New file styles/PrismTheme.tsx contains stylesheet use for syntax highlighting. Stored as a javascript string to simplify implementation.

Screenshots

Basic Demo
Screenshot 2023-05-09 154541

Interface when python code snippet is focused
Screenshot 2023-05-09 152627

Language selection dropdown menu with full list of supported languages
dropdown

Copy link
Contributor

@lauraw0 lauraw0 left a comment

Choose a reason for hiding this comment

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

just some small changes required here and there but besides those it looks amazing! The syntax highlighting looks really clean! your code in general is also very clean :DD

Copy link
Contributor

@lauraw0 lauraw0 left a comment

Choose a reason for hiding this comment

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

LGTM

@josh-ramos-22 josh-ramos-22 merged commit c89c9c9 into main Jun 7, 2023
@josh-ramos-22 josh-ramos-22 deleted the WEB_64_EDITOR_implement_code_blocks branch June 7, 2023 06:31
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.

2 participants