debian-mirror-gitlab/app/assets/javascripts/behaviors/markdown/marks/strike.js
2022-08-27 11:52:29 +05:30

37 lines
890 B
JavaScript

// Transforms generated HTML back to GFM for Banzai::Filter::MarkdownFilter
export default () => ({
name: 'strike',
schema: {
attrs: {
strike: {
default: false,
},
inapplicable: {
default: false,
},
},
parseDOM: [
{ tag: 'li.inapplicable > s', attrs: { inapplicable: true } },
{ tag: 'li.inapplicable > p:first-of-type > s', attrs: { inapplicable: true } },
{ tag: 's', attrs: { strike: true } },
{ tag: 'del' },
],
toDOM: () => ['s', 0],
},
toMarkdown: {
open(_, mark) {
if (mark.attrs.strike) {
return '<s>';
}
return mark.attrs.inapplicable ? '' : '~~';
},
close(_, mark) {
if (mark.attrs.strike) {
return '</s>';
}
return mark.attrs.inapplicable ? '' : '~~';
},
mixable: true,
expelEnclosingWhitespace: true,
},
});