mirror of
https://github.com/discourse/discourse.git
synced 2025-03-14 10:33:43 +00:00
UX: make an em-dash from en-dash plus hyphen on rich editor (#31787)
As `--` is converted to an en-dash, we need to make an en-dash plus another `-` into an em-dash.
This commit is contained in:
@ -25,12 +25,15 @@ const extension = {
|
||||
},
|
||||
},
|
||||
{
|
||||
match: new RegExp(`(${SCOPED_ABBR_RE.source})$`, "i"),
|
||||
// existing for markdown-it, plus: en-dash + hyphen -> em-dash
|
||||
match: new RegExp(`(${SCOPED_ABBR_RE.source}|\u2013-)$`, "i"),
|
||||
handler: (state, match, start, end) => {
|
||||
return state.tr.replaceWith(
|
||||
start,
|
||||
end,
|
||||
state.schema.text(replaceScopedStr(match[0]))
|
||||
state.schema.text(
|
||||
replaceScopedStr(match[0]).replace(/\u2013-$/, "\u2014")
|
||||
)
|
||||
);
|
||||
},
|
||||
},
|
||||
|
@ -130,12 +130,12 @@ describe "Composer - ProseMirror editor", type: :system do
|
||||
it "supports typographer replacements" do
|
||||
open_composer_and_toggle_rich_editor
|
||||
composer.type_content(
|
||||
"foo +- bar... test???? wow!!!! x,, y-- a--> b<-- c-> d<- e<-> f<--> (tm) (pa)",
|
||||
"foo +- bar... test???? wow!!!! x,, y-- --- a--> b<-- c-> d<- e<-> f<--> (tm) (pa)",
|
||||
)
|
||||
|
||||
expect(rich).to have_css(
|
||||
"p",
|
||||
text: "foo ± bar… test??? wow!!! x, y– a–> b←- c→ d← e←> f←→ ™ ¶",
|
||||
text: "foo ± bar… test??? wow!!! x, y– — a–> b←- c→ d← e←> f←→ ™ ¶",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user