fix: improvements in editor exprience#2954
Conversation
218b47f to
f8b0cea
Compare
f8b0cea to
b32ce3a
Compare
ChristopherChudzicki
left a comment
There was a problem hiding this comment.
The heading / html changes look good.
Regarding this:
Updated learning resource embed insertion to detect when cursor is in the banner section
Maybe I am doing something wrong, but I was having trouble inserting cards on local and RC. The video below shows the issue I was having:
- Clicked Insert -> Course Card
- Placeholder says "paste course url here" (or something similar to that)
- I pasted a URL
Didn't embed. Did I do this wrong?
learning_resource_cards.mov
@ChristopherChudzicki I have tested RC it works fine, after inserting the url you need to hit enter because it does not detect the url automatically. this is done this way after pasting the url we need to hit enter. |
ChristopherChudzicki
left a comment
There was a problem hiding this comment.
Heading and highlight change look good 👍. I do have a couple of questions/suggestions about the other changes, particularly useLearningResourceEmbed
Was the change to card behavior a particular feature request? If it wasn't I'd be inclined omit it or switch to the disabled approach. IMO, it would be good to avoid referencing the other extensions (banner, byline) by name... good if learning resource extension is self-contained.
| const { $from } = selection | ||
|
|
||
| // Check if we're inside a banner node | ||
| const isInBanner = |
There was a problem hiding this comment.
Question: The issue was that on RC with cursor in banner (A) the "Course Card" button was enabled and (B) it was a no-op. This addresses (B) by inserting after the banner.
Is that understanding correct?
My inclination is that we should address (A) and disable the insertion inside the banner/byline. (We have the issue for other features, too... Editor Toolbar doesn't show disabled states correctly for schema constraints; mostly inherited from our template, I think.)
Here's one way the button could be disabled: https://github.com/mitodl/mit-learn/compare/ahtesham/small-changes..ahtesham-cc/small-changes ...
One nice thing about the disabling approach is that it doesn't have hard-coded referneces to other extensions. E.g., if we have a new document type or change the schema, it would be good not to have to change the extension code here.
What do you think?
Same comment re useMediaEmbed
There was a problem hiding this comment.
I did not follow your understand. The objective is that if our cursor is at banner or byline section and user click on course card button then cursor should move to empty paragraph and placeholder should show.
There was a problem hiding this comment.
Continuing slack discussion:
we need to check the position of the cursor before inserting the node
It would be good to this without hardcoding references to other extensions. Here's one possibility: https://github.com/mitodl/mit-learn/compare/ahtesham/small-changes..ahtesham/small-changes-cc-suggestion
Another benefit is that the wouldInsertAtPosition and getFirstInsertablePosition functions make sense in isolation, so are good candidates for a utility file, and can be used in both useLearningResourceEmbed and useMediaEmbed.
I think this will also address Sentry's concern.
|
|
||
| let insertPos = selection.from | ||
|
|
||
| if (isInBanner) { |
There was a problem hiding this comment.
If you keep the current approach, do you need to check isInByline?
There was a problem hiding this comment.
No we dont need to it works fine
| }, | ||
|
|
||
| renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, unknown> }) { | ||
| return ["learning-resource-input", mergeAttributes(HTMLAttributes), 0] |
There was a problem hiding this comment.
I see a few other places custom HTML seem to be used, e.g.,
renderHTML({ HTMLAttributes }) {
return ["byline", mergeAttributes(HTMLAttributes), 0]
},
Should we remove that, too?
There was a problem hiding this comment.
No, we have custom element for this, so we don't need to remove it.
There was a problem hiding this comment.
We have code for a custom React renderer. I don't think we have code for a custom byline HTML element, do we?
There was a problem hiding this comment.
I don't think we have code for a custom byline HTML element, do we?
I think yes we dont have
|
@ChristopherChudzicki I rebased the branch and workflow passed now |
What are the relevant tickets?
n/a
Description (What does it do?)
Changes
Heading Control
Banner Section Insertion Logic
HTML Rendering
LearningResourceInputNoderenderHTML to use standard<p>tag instead of custom<learning-resource-input>tagMediaEmbedInputNoderenderHTML to use standard<p>tag instead of custom<media-embed-input>tagScreenshots (if appropriate):
Screen.Recording.2026-02-13.at.5.53.33.PM.mov
How can this be tested?
Additional Context