Skip to content

Conversation

@EricGrill
Copy link
Contributor

Summary

Fixes #7640 - Hidden link remains when deleting link in markdown widget

When a user deletes all text within a link in the visual markdown editor, the empty link markup was being left behind (visible when switching to raw markdown mode).

Problem

Reproduction:

  1. Open page with markdown widget
  2. Insert a link inside
  3. Delete the linked text in rich text mode
  4. Switch to markdown mode - the empty hyperlink [](url) remains

Solution

Added a Slate normalizer in withInlines.js that automatically removes link nodes when they become empty (have no text content).

The normalizer:

  • Checks if a node is a link element
  • Uses Node.string() to get text content
  • Removes the node if text is empty
  • Falls through to default normalizer otherwise

Files Changed

  • packages/decap-cms-widget-markdown/src/MarkdownControl/plugins/inlines/withInlines.js

Test Plan

  • Create a link in the visual markdown editor
  • Delete all text within the link
  • Verify the link wrapper is also removed
  • Switch to raw mode and verify no empty []() markup

Generated with Claude Code

When a user deletes all text within a link in the visual markdown
editor, the empty link markup was being left behind (visible when
switching to raw markdown mode).

This adds a Slate normalizer that automatically removes link nodes
when they become empty (have no text content), ensuring the link
markup is properly cleaned up along with the text.

Fixes decaporg#7640
@EricGrill EricGrill requested a review from a team as a code owner January 14, 2026 18:58
@martinjagodic martinjagodic merged commit f1f1d13 into decaporg:main Jan 15, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hidden link remains when deleting link in markdown widget

2 participants