Skip to content

A platform for community discussion. Free, open, simple.

UX: convert emdash+hyphen to a horizontal rule on rich editor (#32085)

Renato Atilio2134925d7af7
diff --git a/app/assets/javascripts/discourse/app/static/prosemirror/core/inputrules.js b/app/assets/javascripts/discourse/app/static/prosemirror/core/inputrules.js
index 673e9a5083c..c95a1e9d39d 100644
--- a/app/assets/javascripts/discourse/app/static/prosemirror/core/inputrules.js
+++ b/app/assets/javascripts/discourse/app/static/prosemirror/core/inputrules.js
@@ -33,9 +33,11 @@ export function buildInputRules(extensions, params, includeDefault = true) {
markInputRule(/(?:^|(?<!\*))\*([^*]+)\*$/, schema.marks.em),
markInputRule(/(?<=^|\s)_([^_]+)_$/, schema.marks.em),
markInputRule(/`([^`]+)`$/, schema.marks.code),
- new InputRule(/^(\u2013-|___\s|\*\*\*\s)$/, horizontalRuleHandler, {
- inCodeMark: false,
- })
+ new InputRule(
+ /^(\u2013-|\u2014-|___\s|\*\*\*\s)$/,
+ horizontalRuleHandler,
+ { inCodeMark: false }
+ )
);
}
diff --git a/spec/system/composer/prosemirror_editor_spec.rb b/spec/system/composer/prosemirror_editor_spec.rb
index 8104cae00bf..8cb260e240e 100644
--- a/spec/system/composer/prosemirror_editor_spec.rb
+++ b/spec/system/composer/prosemirror_editor_spec.rb
@@ -163,11 +163,11 @@ describe "Composer - ProseMirror editor", type: :system do
)
end
- it "supports ---, *** or ___ to create a horizontal rule" do
+ it "supports ---, ***, ___, en-dash+hyphen, em-dash+hyphen to create a horizontal rule" do
open_composer_and_toggle_rich_editor
- composer.type_content("Hey\n---\nThere\n*** Friend\n___ ")
+ composer.type_content("Hey\n---There\n*** Friend\n___ How\n\u2013-are\n\u2014-you")
- expect(rich).to have_css("hr", count: 3)
+ expect(rich).to have_css("hr", count: 5)
end
end