Skip to content

Commit ed65a05

Browse files
authored
FIX: rich editor html_inline parseDOM not setting the tag attr (#34175)
1 parent 7a7844c commit ed65a05

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

app/assets/javascripts/discourse/app/static/prosemirror/extensions/html-inline.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ const extension = {
3232
isolating: true,
3333
content: "inline*",
3434
attrs: { tag: {} },
35-
parseDOM: ALLOWED_INLINE.map((tag) => ({ tag })),
35+
parseDOM: ALLOWED_INLINE.map((tag) => ({
36+
tag,
37+
getAttrs: () => ({ tag }),
38+
})),
3639
toDOM: (node) => [node.attrs.tag, 0],
3740
},
3841
},

spec/system/composer/prosemirror_editor_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def body(title)
760760
expect(composer).to have_value("![image|244x66](upload://hGLky57lMjXvqCWRhcsH31ShzmO.png)")
761761
end
762762

763-
it "should correctly merge text with link marks created from parsing" do
763+
it "merges text with link marks created from parsing" do
764764
cdp.allow_clipboard
765765
open_composer
766766

@@ -773,6 +773,21 @@ def body(title)
773773

774774
expect(rich).to have_css("a", text: "lin")
775775
end
776+
777+
it "parses html inline tags from pasted HTML" do
778+
cdp.allow_clipboard
779+
open_composer
780+
781+
cdp.copy_paste("<mark>mark</mark> my <ins>words</ins> <kbd>ctrl</kbd>", html: true)
782+
783+
expect(rich).to have_css("mark", text: "mark")
784+
expect(rich).to have_css("ins", text: "words")
785+
expect(rich).to have_css("kbd", text: "ctrl")
786+
787+
composer.toggle_rich_editor
788+
789+
expect(composer).to have_value("<mark>mark</mark> my <ins>words</ins> <kbd>ctrl</kbd>")
790+
end
776791
end
777792

778793
describe "toolbar state updates" do

0 commit comments

Comments
 (0)