Commit 5b0bedde authored by Simon Knox's avatar Simon Knox

Fix gfm pasting of custom emoji

parent f21f76b8
...@@ -26,6 +26,18 @@ export default class Emoji extends Node { ...@@ -26,6 +26,18 @@ export default class Emoji extends Node {
moji: el.textContent, moji: el.textContent,
}), }),
}, },
{
tag: 'img.emoji',
getAttrs: (el) => {
const name = el.getAttribute('title').replace(/^:|:$/g, '');
return {
name,
title: name,
moji: name,
};
},
},
], ],
toDOM: (node) => [ toDOM: (node) => [
'gl-emoji', 'gl-emoji',
......
...@@ -29,7 +29,7 @@ export default class Image extends BaseImage { ...@@ -29,7 +29,7 @@ export default class Image extends BaseImage {
}, },
// Matches HTML generated by Banzai::Filter::ImageLazyLoadFilter // Matches HTML generated by Banzai::Filter::ImageLazyLoadFilter
{ {
tag: 'img[src]', tag: 'img[src]:not(.emoji)',
getAttrs: (el) => { getAttrs: (el) => {
const imageSrc = el.src; const imageSrc = el.src;
const imageUrl = const imageUrl =
......
...@@ -201,6 +201,15 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -201,6 +201,15 @@ RSpec.describe 'Copy as GFM', :js do
GFM GFM
) )
aggregate_failures('CustomEmojiFilter') do
gfm = ':custom_emoji:'
html = '<img class="emoji" src="custom_emoji.svg" title=":custom_emoji:" height="20" width="20">'
output_gfm = html_to_gfm(html)
expect(output_gfm.strip).to eq(gfm.strip)
end
aggregate_failures('MathFilter: math as transformed from HTML to KaTeX') do aggregate_failures('MathFilter: math as transformed from HTML to KaTeX') do
gfm = '$`c = \pm\sqrt{a^2 + b^2}`$' gfm = '$`c = \pm\sqrt{a^2 + b^2}`$'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment