-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat(gsoc'24): minimal markdown editor using simplemde #26
base: master
Are you sure you want to change the base?
Conversation
e042dc4
to
94dba46
Compare
…r` gem - these filters are applied on forum_thread's title, forum_posts's body - error messages are now improves with proper altert message styling using bootstrap's alter class
…r` gem - these filters are applied on forum_thread's title, forum_posts's body - error messages are now improves with proper altert message styling using bootstrap's alter class
fbdfcb3
to
07c23ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except that pr looks good.
@tanmoysrt do you think, this feature also needs to have feature flag to enable and disable it from |
any specific reason for flag for markdown editor ? there should be no issue in main repo after merge until unless we update the gemfile.lock. |
Basically one can toggle this markdown editor according to their usecase. They may need just simple textarea without markdown editor. |
WalkthroughThe changes introduce a Markdown editor using SimpleMDE into the application, enhancing the user interface for forum posts and threads. The implementation includes updates to relevant HTML forms and JavaScript controllers to manage the editor, along with CSS enhancements for better styling. The integration allows users to format text and preview content while improving the overall structure and functionality of the discussion threads. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant View
participant SimpleMDE
participant Controller
User->>View: Open forum post creation
View->>Controller: Initialize SimpleMDE
Controller->>SimpleMDE: Load editor
User->>SimpleMDE: Edit post content
SimpleMDE-->>User: Provide rich text formatting
User->>View: Submit post
View->>Controller: Handle submission
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
@coderabbitai Generate unit and integration tests for this feature
…On Fri, 23 Aug, 2024, 9:12 pm coderabbitai[bot], ***@***.***> wrote:
Note
Currently processing new changes in this PR. This may take a few minutes,
please wait...
Commits
Files that changed from the base of the PR and between 470e204
<470e204>
and 4878c94
<4878c94>
.
Files selected for processing (6)
- app/assets/stylesheets/simple_discussion.scss (1 hunks)
- app/views/layouts/simple_discussion.html.erb (3 hunks)
- app/views/simple_discussion/forum_posts/_form.html.erb (2 hunks)
- app/views/simple_discussion/forum_threads/_form.html.erb (2 hunks)
- app/views/simple_discussion/forum_threads/_forum_thread.html.erb (1
hunks)
- app/views/simple_discussion/forum_threads/show.html.erb (1 hunks)
________________________________
< My GPUs mine bugs, not Crypto. >
--------------------------------
\
\ (\__/)
(•ㅅ•)
/ づ
Tip
You can get early access to new features in CodeRabbit.
Enable the early_access setting in your project's settings in CodeRabbit
to enable early access features such as new models, tools, and more.
------------------------------
Thank you for using CodeRabbit. We offer it for free to the OSS community
and would appreciate your support in helping us grow. If you find it
useful, would you consider giving us a shout-out on your favorite social
media?
Share
- X
<https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai>
- Mastodon
<https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai>
- Reddit
<https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai>
- LinkedIn
<https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code>
Tips Chat
There are 3 ways to chat with CodeRabbit <https://coderabbit.ai>:
- Review comments: Directly reply to a review comment made by
CodeRabbit. Example:
- I pushed a fix in commit <commit_id>.
- Generate unit testing code for this file.
- Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab):
Tag @coderabbitai in a new review comment at the desired location with
your query. Examples:
- @coderabbitai generate unit testing code for this file.
- @coderabbitai modularize this function.
- PR comments: Tag @coderabbitai in a new PR comment to ask questions
about the PR branch. For the best results, please provide a very specific
query, as very limited context is provided in this mode. Examples:
- @coderabbitai generate interesting stats about this repository
and render them as a table.
- @coderabbitai show all the console.log statements in this
repository.
- @coderabbitai read src/utils.ts and generate unit testing code.
- @coderabbitai read the files in the src/scheduler package and
generate a class diagram using mermaid and a README in the markdown format.
- @coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly
recommended to break down tasks such as reading entire modules into smaller
chunks. For a focused discussion, use review comments to chat about
specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
- @coderabbitai pause to pause the reviews on a PR.
- @coderabbitai resume to resume the paused reviews.
- @coderabbitai review to trigger an incremental review. This is
useful when automatic reviews are disabled for the repository.
- @coderabbitai full review to do a full review from scratch and
review all the files again.
- @coderabbitai summary to regenerate the summary of the PR.
- @coderabbitai resolve resolve all the CodeRabbit review comments.
- @coderabbitai configuration to show the current CodeRabbit
configuration for the repository.
- @coderabbitai help to get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR
description to prevent this PR from being reviewed.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml file to the root of your repository.
- Please see the configuration documentation
<https://docs.coderabbit.ai/guides/configure-coderabbit> for more
information.
- If your editor has YAML language server enabled, you can add the
path at the top of this file to enable auto-completion and validation: #
yaml-language-server: $schema=
https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation <https://coderabbit.ai/docs> for detailed
information on how to use CodeRabbit.
- Join our Discord Community <https://discord.com/invite/GsXnASn26c>
to get help, request features, and share feedback.
- Follow us on X/Twitter <https://twitter.com/coderabbitai> for
updates and announcements.
—
Reply to this email directly, view it on GitHub
<#26 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXYAECINA277W2XSMJGKALZS5J4XAVCNFSM6AAAAABKPRAY32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXGM2DKNBQG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- app/assets/stylesheets/simple_discussion.scss (1 hunks)
- app/views/layouts/simple_discussion.html.erb (3 hunks)
- app/views/simple_discussion/forum_posts/_form.html.erb (2 hunks)
- app/views/simple_discussion/forum_threads/_form.html.erb (2 hunks)
- app/views/simple_discussion/forum_threads/_forum_thread.html.erb (1 hunks)
- app/views/simple_discussion/forum_threads/show.html.erb (1 hunks)
Files skipped from review due to trivial changes (2)
- app/views/simple_discussion/forum_threads/_forum_thread.html.erb
- app/views/simple_discussion/forum_threads/show.html.erb
Additional comments not posted (10)
app/views/simple_discussion/forum_posts/_form.html.erb (2)
4-4
: Ensure the controller is correctly initialized.The addition of the
controller: "simplemde"
attribute suggests integration with the SimpleMDE editor. Verify that the controller is correctly initialized and functioning as expected.
16-16
: Update thetext_area
configuration.The
simplemde_target
data attribute is used to target the text area for the SimpleMDE editor. Ensure that this configuration aligns with how the editor is initialized and used in the application.app/views/simple_discussion/forum_threads/_form.html.erb (2)
3-3
: Ensure the controller is correctly initialized.The addition of the
controller: "simplemde"
attribute suggests integration with the SimpleMDE editor. Verify that the controller is correctly initialized and functioning as expected.
27-27
: Update thetext_area
configuration.The
simplemde_target
data attribute is used to target the text area for the SimpleMDE editor. Ensure that this configuration aligns with how the editor is initialized and used in the application.app/views/layouts/simple_discussion.html.erb (2)
79-80
: Verify external resource loading.The SimpleMDE CSS and JS files are loaded from a CDN. Ensure these resources are accessible and consider hosting them locally if necessary for better control and reliability.
123-160
: Review the SimpleMDE controller implementation.The Stimulus controller for SimpleMDE is responsible for initializing the editor and configuring its toolbar. Ensure that the toolbar options meet the application's requirements and that the editor is correctly initialized for all targeted text areas.
app/assets/stylesheets/simple_discussion.scss (4)
300-303
: Verify the usage of the.preview
class.Ensure that the
.preview
class is used appropriately and does not conflict with other elements.Run the following script to verify the usage of the
.preview
class:Verification successful
The
.preview
class is used appropriately.The
.preview
class is correctly used in the HTML file and styled in the SCSS file without any conflicts or issues identified. The::before
pseudo-element adds a "Preview" label, which aligns with its usage in the codebase.
- Location of usage:
app/views/layouts/simple_discussion.html.erb
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `.preview` class. # Test: Search for the `.preview` class usage. Expect: Occurrences in relevant HTML or templates. rg --type css --type html --type erb --type js '\.preview'Length of output: 233
320-321
: Verify the impact of the font size change for.CodeMirror-line span
.Ensure that the font size change to 18px does not cause layout issues or inconsistencies.
Run the following script to verify the impact of the font size change:
Verification successful
Font size change is isolated and verified.
The change to set the font size to 18px for
.CodeMirror-line span
is isolated to thesimple_discussion.scss
file, with no other dependencies or references in the codebase. This indicates that the change is unlikely to cause layout issues or inconsistencies.
- Location:
app/assets/stylesheets/simple_discussion.scss
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the font size change for `.CodeMirror-line span`. # Test: Search for the usage of `.CodeMirror-line span`. Expect: Consistent styling across components. rg --type css --type html --type erb --type js '\.CodeMirror-line span' -A 5Length of output: 261
310-318
: Verify the styling of blockquote elements.Ensure that the blockquote styling enhances readability and aligns with design guidelines.
Run the following script to verify the styling of blockquote elements:
305-307
: Verify the impact of the font size change.Ensure that the font size change to 18px does not cause layout issues or inconsistencies.
Run the following script to verify the impact of the font size change:
Verification successful
Font Size Change Impact Verified
The font size change to 18px for
.simple_discussion .forum-post p
and.CodeMirror p
appears to be isolated to thesimple_discussion.scss
file, with no other references found in the codebase. This suggests that the change is unlikely to cause layout issues or inconsistencies.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the font size change to 18px. # Test: Search for the usage of `.simple_discussion .forum-post p` and `.CodeMirror p`. Expect: Consistent styling across components. rg --type css --type html --type erb --type js '\.simple_discussion \.forum-post p' -A 5 rg --type css --type html --type erb --type js '\.CodeMirror p' -A 5Length of output: 934
Script:
#!/bin/bash # Description: Comprehensive search for the usage of `.simple_discussion .forum-post p` and `.CodeMirror p` across all file types. # Test: Search for the usage of `.simple_discussion .forum-post p` and `.CodeMirror p` in all file types to ensure comprehensive coverage. rg '\.simple_discussion \.forum-post p' -A 5 rg '\.CodeMirror p' -A 5Length of output: 846
Tip For best results, initiate chat on the files or code changes. @tachyons Here are the unit and integration tests for the SimpleMDE markdown editor feature: Unit TestsThese tests will verify the initialization and configuration of the SimpleMDE editor. // Assuming you are using a JavaScript testing framework like Jest
describe('SimpleMDE Initialization', () => {
let editor;
beforeEach(() => {
document.body.innerHTML = '<textarea id="editor"></textarea>';
editor = new SimpleMDE({
element: document.getElementById('editor'),
forceSync: true,
toolbar: ["bold", "italic", { name: "preview", action: SimpleMDE.togglePreview }],
spellChecker: false,
});
});
test('should initialize SimpleMDE with correct options', () => {
expect(editor.options.forceSync).toBe(true);
expect(editor.options.spellChecker).toBe(false);
expect(editor.options.toolbar.length).toBe(3);
});
test('should attach SimpleMDE to the correct element', () => {
expect(editor.element).toBe(document.getElementById('editor'));
});
}); Integration TestsThese tests will ensure that the editor interacts correctly with the form elements. // Assuming you are using a testing framework like Cypress for integration tests
describe('SimpleMDE Integration', () => {
beforeEach(() => {
cy.visit('/path-to-your-form-page');
});
it('should sync content with textarea', () => {
cy.get('.editor-toolbar button').contains('Bold').click();
cy.get('textarea').should('contain.value', '**');
});
it('should toggle preview mode', () => {
cy.get('.editor-toolbar button').contains('Preview').click();
cy.get('.editor-preview').should('be.visible');
});
}); These tests should cover the basic functionality of the SimpleMDE editor in your application. Adjust the paths and selectors according to your actual implementation. Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for the initialization and usage of SimpleMDE in the relevant files.
rg 'SimpleMDE' -A 5
Length of output: 862 |
@tachyons will we able to add the jest testing without introducing any js tooling(webpack and esbuild)? |
Fixes #15
This PR's covers following functionality
Screenshots:
Summary by CodeRabbit
New Features
Bug Fixes
Chores