Skip to content

Rich Text: convert -- to em dash in editor - #77493

Open
shrivastavanolo wants to merge 1 commit into
WordPress:trunkfrom
shrivastavanolo:enhancement/rich-text-em-dash
Open

shrivastavanolo wants to merge 1 commit into
WordPress:trunkfrom
shrivastavanolo:enhancement/rich-text-em-dash

Conversation

@shrivastavanolo

Copy link
Copy Markdown
Contributor

What?

Closes #73022

Convert -- to an em dash (—) while typing in the RichText editor.

Why?

The front end converts -- to — via wp_texturize() but the editor didn't, breaking the WYSIWYG experience.

How?

Adds text-input-rules.js to packages/rich-text/src/hook/event-listeners/ with two rules:

  • Start of line: -- + any non-hyphen character → —. --- is excluded so the separator block transform still fires.
  • Mid-line: any run of 2+ hyphens preceded by a non-hyphen converts immediately, pair by pair.

__unstableInputRule was considered but not used as it's designed for format types, not character substitution imo.

Testing Instructions

  1. Insert a Paragraph block.
  2. Type -- at the start of a line → — .
  3. Type --- at the start of a line → separator block, no em dash.
  4. Type hello-- → hello—.
  5. Verify front end output matches editor.

Screenshots or screencast

Before

Editor Site
Screenshot 2026-04-20 at 4 37 08 PM Screenshot 2026-04-20 at 4 37 14 PM

After

Editor Site
Screenshot 2026-04-20 at 5 51 37 PM Screenshot 2026-04-20 at 5 33 54 PM

Use of AI Tools

Claude (Anthropic) was used to assist with code review and PR description drafting. All code was reviewed and tested by the author.

@github-actions github-actions Bot added the [Package] Rich text /packages/rich-text label Apr 20, 2026
@shrivastavanolo
shrivastavanolo marked this pull request as ready for review April 21, 2026 04:45
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Rich text.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: shrivastavanolo <shreya0shrivastava@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@shrivastavanolo
shrivastavanolo force-pushed the enhancement/rich-text-em-dash branch from 713a33e to 880eca6 Compare April 29, 2026 06:23
@ellatrix ellatrix mentioned this pull request Aug 13, 2026
33 of 70 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Rich text /packages/rich-text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rich text: show em dash in editor/convert two dashes into em dash

1 participant