-
Notifications
You must be signed in to change notification settings - Fork 289
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
💻 Automatically add curly braces for individual keywords #5285
Conversation
Hello @jpelay, existing adventures may have such keywords but the warningbox isn't shown to them, one might argue that it should! I think we should utilize the function you created in Lines 59 to 61 in 10d6365
Perhaps related to this, did you check the threads starting from #5297 (comment) ?! |
Hi @jpelay , i think this PR should be of highest priority because the content of adventures are changed and teachers see curly braces. It'd be nice to finish it this week. I'll review it once you make progress and think it's ready! |
Hi Hasan!
This is in an interesting question. I assumed that people would want to include the keywords as they are use in real programs,
You have to start editing the adventure for the warningbox to be shown. |
I think they will, especially after they see the message you provide in the warningbox!
Do you think we should check and show it at the beginning as well? If so, we could show it after the CKEditor is initialilzed. |
Done, mate! |
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.
We just need to fix the tests and we should be good to go:))) with tiny comments!
cy.get('[data-cke-tooltip-text="Bold (Ctrl+B)"]').click() | ||
cy.get('[data-cke-tooltip-text="Bold (Ctrl+B)"]').click() |
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.
Any reason for these?! Or just to test them?!
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.
you could also control it from the instance we set on window. We use it here for instance: https://github.com/hedyorg/hedy/blob/main/tests/cypress/e2e/for-teacher_page/customize-adventure_page/adventure_content_field.cy.js
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.
Any reason for these?! Or just to test them?!
Targeting the editor window to actually type on it is very hard with Cypress, so I just make it the focused element by clicking on one of the options and then use realType
from cypress-real-events
to actually type on the editor. Got that from this issue: cypress-io/cypress#26155
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.
you could also control it from the instance we set on window. We use it here for instance: https://github.com/hedyorg/hedy/blob/main/tests/cypress/e2e/for-teacher_page/customize-adventure_page/adventure_content_field.cy.js
This is working, isn't it?!
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.
Perhaps we could suggest our way:-)
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.
This is working, isn't it?!
It isn't, hence why I did it that way. Just setting the value of the editor doesn't fire a change event.
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.
I think it does. But you need to give it an html tag that you mean to write; ckEditor.setData("<code>to</code>
")`
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.
This is probably more stable since you may remove the bold button from your bar or we add something else and ckEditor changes the attribute. I like this discussion and just posted a comment :))
cypress-io/cypress#26155 (comment)
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.
Oh yes! You're right, updated the tests to reflect your suggestion, thanks!
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.
Thanks for all the work!
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
Adds a function that automatically surrounds individual keywords with curly braces son teachers don't have to, and for the cases where one individual word might match with several keywords, a warning message is displayed, asking the user to select one of the keywords that might match that one.
This video shows an example of how the alert message is displayed:
2024-03-20.20-43-44.mp4
How to test
Follow these steps to verify this PR works as intended:
to
in English and check that the alert message is displayed.dev_database.json
and search for the field associated to the adventure you just edited, and check that the fieldformatted_content
correctly has curly braces surrounding the keywords