mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
blockquote tag support for HTML pasting in composer
This commit is contained in:
parent
24e89b6b38
commit
6272f35eec
@ -29,7 +29,7 @@ class Tag {
|
||||
}
|
||||
|
||||
static blocks() {
|
||||
return ["address", "article", "aside", "blockquote", "dd", "div", "dl", "dt", "fieldset",
|
||||
return ["address", "article", "aside", "dd", "div", "dl", "dt", "fieldset",
|
||||
"figcaption", "figure", "footer", "form", "header", "hgroup", "hr", "main", "nav",
|
||||
"ol", "p", "pre", "section", "table", "ul"];
|
||||
}
|
||||
@ -47,7 +47,7 @@ class Tag {
|
||||
}
|
||||
|
||||
static trimmable() {
|
||||
return [...Tag.blocks(), ...Tag.headings(), ...Tag.slices(), "li", "td", "th", "br", "hr"];
|
||||
return [...Tag.blocks(), ...Tag.headings(), ...Tag.slices(), "li", "td", "th", "br", "hr", "blockquote"];
|
||||
}
|
||||
|
||||
static block(name, prefix, suffix) {
|
||||
@ -201,6 +201,19 @@ class Tag {
|
||||
};
|
||||
}
|
||||
|
||||
static blockquote() {
|
||||
return class extends Tag {
|
||||
constructor() {
|
||||
super("blockquote", "\n> ", "\n");
|
||||
}
|
||||
|
||||
decorate(text) {
|
||||
text = text.trim().replace(/\n{2,}>/g, "\n>").replace(/\n/g, "\n> ");
|
||||
return super.decorate(text);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const tags = [
|
||||
@ -211,10 +224,10 @@ const tags = [
|
||||
Tag.cell("td"), Tag.cell("th"),
|
||||
Tag.replace("br", "\n"), Tag.replace("hr", "\n---\n"), Tag.replace("head", ""),
|
||||
Tag.keep("ins"), Tag.keep("del"), Tag.keep("small"), Tag.keep("big"),
|
||||
Tag.li(), Tag.link(), Tag.image(), Tag.code(),
|
||||
Tag.li(), Tag.link(), Tag.image(), Tag.code(), Tag.blockquote(),
|
||||
|
||||
// TO-DO CREATE: code, tbody, blockquote
|
||||
// UPDATE: ol, pre, thead, th, td
|
||||
// TO-DO CREATE: tbody
|
||||
// UPDATE: ol, thead, th, td
|
||||
];
|
||||
|
||||
class Element {
|
||||
|
@ -170,3 +170,17 @@ helloWorld();</code> consectetur.`;
|
||||
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
||||
QUnit.test("converts blockquote tag", assert => {
|
||||
let html = "<blockquote>Lorem ipsum</blockquote>";
|
||||
let output = "> Lorem ipsum";
|
||||
assert.equal(toMarkdown(html), output);
|
||||
|
||||
html = "<blockquote>Lorem ipsum</blockquote><blockquote><p>dolor sit amet</p></blockquote>";
|
||||
output = "> Lorem ipsum\n\n> dolor sit amet";
|
||||
assert.equal(toMarkdown(html), output);
|
||||
|
||||
html = "<blockquote>\nLorem ipsum\n<blockquote><p>dolor <blockquote>sit</blockquote> amet</p></blockquote></blockquote>";
|
||||
output = "> Lorem ipsum\n> > dolor\n> > > sit\n> > amet";
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user