Skip to content

fix: improvements in editor exprience#2954

Merged
ahtesham-quraish merged 3 commits into
mainfrom
ahtesham/small-changes
Feb 20, 2026
Merged

fix: improvements in editor exprience#2954
ahtesham-quraish merged 3 commits into
mainfrom
ahtesham/small-changes

Conversation

@ahtesham-quraish
Copy link
Copy Markdown
Contributor

@ahtesham-quraish ahtesham-quraish commented Feb 13, 2026

What are the relevant tickets?

n/a

Description (What does it do?)

Changes

Heading Control

  • Removed H1 from the heading dropdown menu, limiting user selection to H2, H3, and H4
  • Preserved H1 support in the Heading extension to maintain banner functionality

Banner Section Insertion Logic

  • Updated learning resource embed insertion to detect when cursor is in the banner section
  • When in banner, learning resource input now inserts after banner and byline nodes instead of inside the banner
  • Applied the same logic to media embed insertion for consistent behavior

HTML Rendering

  • Changed LearningResourceInputNode renderHTML to use standard <p> tag instead of custom <learning-resource-input> tag
  • Changed MediaEmbedInputNode renderHTML to use standard <p> tag instead of custom <media-embed-input> tag

Screenshots (if appropriate):

Screen.Recording.2026-02-13.at.5.53.33.PM.mov

How can this be tested?

  • for input placeholders for media and course you need to move the cursor to banner or byline section and click on media or course card button from insert dropdown in controls and you would see the new placeholder in after the banner and byline section

Additional Context

Copy link
Copy Markdown
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

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

@ahtesham-quraish ahtesham-quraish added the Needs Review An open Pull Request that is ready for review label Feb 16, 2026
@ahtesham-quraish ahtesham-quraish marked this pull request as ready for review February 16, 2026 08:03
@ahtesham-quraish
Copy link
Copy Markdown
Contributor Author

ahtesham-quraish commented Feb 16, 2026

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:

@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.

Copy link
Copy Markdown
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

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 =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you keep the current approach, do you need to check isInByline?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No we dont need to it works fine

},

renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, unknown> }) {
return ["learning-resource-input", mergeAttributes(HTMLAttributes), 0]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, we have custom element for this, so we don't need to remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have code for a custom React renderer. I don't think we have code for a custom byline HTML element, do we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have code for a custom byline HTML element, do we?

I think yes we dont have

@ahtesham-quraish
Copy link
Copy Markdown
Contributor Author

@ChristopherChudzicki I rebased the branch and workflow passed now

@ahtesham-quraish ahtesham-quraish merged commit e5720d0 into main Feb 20, 2026
14 checks passed
@ahtesham-quraish ahtesham-quraish deleted the ahtesham/small-changes branch February 20, 2026 07:27
This was referenced Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants