A platform for community discussion. Free, open, simple.
FIX: paste mention from post to rich editor (#34184)
Renato Atilio3df5807d8768
diff --git a/app/assets/javascripts/discourse/app/static/prosemirror/extensions/mention.js b/app/assets/javascripts/discourse/app/static/prosemirror/extensions/mention.jsindex 83ecbc30e1a..cc424b53dec 100644--- a/app/assets/javascripts/discourse/app/static/prosemirror/extensions/mention.js+++ b/app/assets/javascripts/discourse/app/static/prosemirror/extensions/mention.js@@ -24,11 +24,12 @@ const extension = {selectable: false,parseDOM: [{+ priority: 60,tag: "a.mention",preserveWhitespace: "full",getAttrs: (dom) => {return {- name: dom.getAttribute("data-name"),+ name: dom.getAttribute("data-name") ?? dom.textContent.slice(1),};},},diff --git a/spec/system/composer/prosemirror_editor_spec.rb b/spec/system/composer/prosemirror_editor_spec.rbindex 2a416fa7e41..dd799c3d721 100644--- a/spec/system/composer/prosemirror_editor_spec.rb+++ b/spec/system/composer/prosemirror_editor_spec.rb@@ -666,6 +666,21 @@ describe "Composer - ProseMirror editor", type: :system doenddescribe "pasting content" do+ it "creates a mention when pasting an HTML anchor with class mention" do+ cdp.allow_clipboard+ open_composer++ html = %(<a href="/u/#{current_user.username}" class="mention">@#{current_user.username}</a>)+ cdp.copy_paste(html, html: true)++ expect(rich).to have_css("a.mention", text: current_user.username)+ expect(rich).to have_css("a.mention[data-name='#{current_user.username}']")+ expect(rich).to have_no_css("a.mention[href]")++ composer.toggle_rich_editor+ expect(composer).to have_value("@#{current_user.username}")+ end+it "does not freeze the editor when pasting markdown code blocks without a language" dowith_logs do |logger|open_composer