-
Notifications
You must be signed in to change notification settings - Fork 33
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: insert link plugin tinymce #455
feat: insert link plugin tinymce #455
Conversation
Thanks for the pull request, @johnvente! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
d3cded8
to
53ce3a6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #455 +/- ##
==========================================
- Coverage 90.70% 89.07% -1.64%
==========================================
Files 229 263 +34
Lines 4206 4721 +515
Branches 855 974 +119
==========================================
+ Hits 3815 4205 +390
- Misses 371 487 +116
- Partials 20 29 +9 ☔ View full report in Codecov by Sentry. |
6125a8d
to
15f00a8
Compare
25f0815
to
173e9f3
Compare
src/editors/sharedComponents/InsertLinkModal/BlocksList/index.jsx
Outdated
Show resolved
Hide resolved
src/editors/sharedComponents/InsertLinkModal/BlockLink/index.test.jsx
Outdated
Show resolved
Hide resolved
896a584
to
9cd8d8b
Compare
src/editors/sharedComponents/InsertLinkModal/BlocksList/index.jsx
Outdated
Show resolved
Hide resolved
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.
All my comments were already addressed, thank you!
To Whom It May Concern: This functionality was approved by product in this post |
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.
Overall this looks really great! It's super exciting to see this functionality built out.
I left a couple comments about possibly moving some things out of utils.js
, as well as a comment with some questions about URL validation.
Thank you so much for this PR!
{isInsertLinkOpen && ( | ||
<InsertLinkModal | ||
isOpen={isInsertLinkOpen} |
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.
It looks like the rest of the modals handle isOpen
entirely internally. Does this still work without the isInsertLinkOpen &&
?
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.
it does work without isInsertLinkOpen &&
the main problem is that the status of the modal keeps the same even if I open or close it which means for instance I selected an url that is inside the tree (an unit for example) and I open it again and it shows the link selected without that does not re-render the modal component
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.
In general I'm not a huge fan of having things live in a utils
file (https://youtu.be/-J3wNP6u5YU?t=328 explains my reasoning behind that quite well). I'm not opposed to keeping this file if need be, but I'll go through it and see if I have any suggestions for what may be better homes for the things it contains.
Hi @brian-smith-tcril! Thanks for taking a look here. I disagree with moving utils.js, principally the functions, because it's better to have functions that are reusable outside of a component. That way, you could use them in other parts of the code, and for testing purposes, it's easier to test those functions if they are outside a component. It would be tricky to test if they were inside a component, as discussed in this article. I understand that if for now they are only used inside one component, you might want to keep them there. I could move the functions to their respective component folders instead of having only one utils file, so each component will have its own utils |
This sounds like a reasonable solution to me. For example, the That would effectively communicate the current usage scope of each function, and it would make it easy for someone who wants to use one more generally to refactor (by simply moving the file and changing an import path) |
2429b3e
to
c963cfa
Compare
@johnvente it looks like the CI failures should be resolved if you rebase on latest |
Because that's how the native link button behaves. It doesn't make sense to have different UX for the internal link button and the native link button. |
Okay, I will check that would it be enough with that? |
edbbd18
to
b11bf08
Compare
@brian-smith-tcril I added a fix for that use case but for the insertion bar not yet since the native plugin is active even when there is not text selected or when the editor is empty completely so is active all the time we should limit our plugin only for text selected instead of trying to have the behavior of the native plugin I'm not sure how long can take and I won't be able to check it after this friday please let me know what do you recommend here |
That is more like new feature that a bug fixing since our code was made for text selected not when the user has insertion bar to edit a link. I will try as much as I can to check it but the time is very short |
16b54a3
to
989b538
Compare
Hi @brian-smith-tcril I added the support to edit a new link as you mentioned here could you take a look please? I will be checking it |
Sorry for the delay here, I won't be able to make changes here but any request please let know to @felipemontoya @mariajgrimaldi Good luck |
@johnvente thank you for all of your work on this! I plan on taking this over at the beginning of next week. I know it's turned out to be more complicated than expected, and you've done an amazing job getting it to this point. I'm really happy to be able to use this as a base to get it across the finish line. Thanks again and all the best! |
editor.on('SelectionChange', () => { | ||
const node = editor.selection.getNode(); | ||
const isLink = node.nodeName === 'A'; | ||
const hasTextSelected = editor.selection.getContent().length > 0; | ||
api.setActive(isLink); | ||
api.setDisabled(!isLink && !hasTextSelected); | ||
}); |
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.
editor.on('SelectionChange', () => { | |
const node = editor.selection.getNode(); | |
const isLink = node.nodeName === 'A'; | |
const hasTextSelected = editor.selection.getContent().length > 0; | |
api.setActive(isLink); | |
api.setDisabled(!isLink && !hasTextSelected); | |
}); | |
editor.on('SelectionChange', () => { | |
const node = editor.selection.getNode(); | |
const isLink = node.nodeName === 'A'; | |
let isInternalLink = false; | |
if (isLink) { | |
const selectedHTML = editor.selection.getContent({ format: 'html' }) || node.outerHTML; | |
const regexDataBlockId = new RegExp(/data-block-id="([^"]+)"/); | |
isInternalLink = regexDataBlockId.test(selectedHTML); | |
} | |
const hasTextSelected = editor.selection.getContent().length > 0; | |
api.setActive(isInternalLink); | |
api.setDisabled(!isInternalLink && !hasTextSelected); | |
}); |
By doing this I was able to get it so the "jump to" button is only enabled when trying to edit internal links, but I was able to break it decently quickly (and uncovered another bug in the process).
The native link editor doesn't remove data-block-id
, so by
- Creating an internal link using the "jump to" dialog
- Editing that internal link and changing it to be an external link using the native link dialog
We end up with a link on the page with an associated block id even though the url doesn't match anymore.
This gets cleaned up when opening the "jump to" menu during the block id/url validation, but I'd like to clean it up before getting in there.
I'm looking into ways to do that without duplicating too much code.
Hi @brian-smith-tcril, I hope you're doing well. I wanted to ask how the development of this feature is going. What is still needed to finish closing it? Do you need help with anything? Best regards |
@santiagosuarezedunext I have been focused on the edx-platform node 18 upgrade. I'll get back to this once I've worked through the issues with that. |
Hello @brian-smith-tcril, I hope you are well. |
@santiagosuarezedunext I have been busy with Redwood and haven't had time to dive into this, but I have deployed the current code from this PR on a sandbox here: https://studio.pr-1070-e8373e.sandboxes.opencraft.hosting/ The current implementation differs significantly from what was originally proposed and approved here: https://openedx.atlassian.net/wiki/spaces/OEPM/pages/3887071233/Problem+Authors+don+t+have+enough+options+to+create+the+content+they+would+like?focusedCommentId=3932585997 To move forward with this, the implementation deployed to the sandbox should go through Product and UX/UI testing. That testing should result in updated requirements for getting this PR into a mergeable state. If I were to perform the Product/UX/UI testing, I would not pass the current implementation because:
If, however, someone decides that having 2 link buttons is acceptable, I would still not pass the current implementation because:
@ali-hugo tagging you for visibility. I'm going to put this PR in draft mode until Product and UI has determined the best path forward. |
@brian-smith-tcril Thanks for putting this on my radar. I wanted to check out the sandbox so created an account, but I don't seem to be receiving a verification mail. Is it possible for you to verify my email address on your side? |
@brian-smith-tcril i have the same error that @ali-hugo have. |
@santiagosuarezedunext I have marked your user as "Active" and "Staff." Could you try again and let me know if you're still having problems logging in? Thank you for your patience! |
It already works for me, thanks @brian-smith-tcril |
Hi! Thank you for your contribution to this repo. This repo is being deprecated and all the code is being moved to |
Closing as we've now moved this code, per the notice above. Please re-open this PR against https://github.com/openedx/frontend-app-course-authoring/ if you'd like to continue it. Feel free to reach out to me if you aren't sure how to do that using git and I can help (basically: add your local |
@johnvente Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This plugin allows you to insert a link into the text editor. Additionally, you can search for sections, subsections, and units within the course and insert the URL for any of them
Demo
demo-jum-to.mov
How to test it (Devstack)
You need to have this Waffle flag activated
new_core_editors.use_new_text_editor
Create waffle flag
Doc here
~/workspace/frontend-app-course-authoring
module.config.js
with the following configIf you have cloned frontend-lib-content-components already you can do this