Closed literakl closed 4 years ago
Hey, @literakl . Sorry, but the library doesn't provide a default parser function for type: "quote" . It must be a parser function defined within your project or library. So, you will need to accustom it to your needs accordingly.
Here is the list of parser functions, provided with the library. https://github.com/pavittarx/editorjs-html#supported-block-types
Here is the source, for said parser functions. https://github.com/pavittarx/editorjs-html/blob/master/src/transforms.js
As, you can see, the block of type: "quote" is not being handled by the library,
Trobouleshooting Information:
More on custom parser functions here, https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks
You were right. It was a custom parser. Would you add table and quote render to your library?
quote: (obj) => {
let html = `<blockquote style="text-align:${obj.data.alignment};">`;
if (obj.data.caption != null && obj.data.caption !== '') {
html += `<p>${obj.data.caption}</p> `;
}
html += `${obj.data.text} </blockquote>`;
return html;
},
and
table: (obj) => {
let rows = '', rendered = '';
obj.data.content.map((row) => {
let cells = '';
row.map((cell) => {
cells += `<td class="tc-table__cell"><div class="tc-table__area">${
cell}</div></td>\n`;
});
rows += `<tr>${cells}</tr>\n`;
});
rendered += `${'<div class="ce-block"><div class="ce-block__content"><div class="tc-editor cdx-block">'
+ '<div class="tc-table__wrap">\n<table class="tc-table"><tbody>'}${
rows}</tbody></table>\n</div></div></div></div>\n`;
return rendered;
},
@literakl Since, editorjs supports quote and table blocks by default. I would be more than happy to add them. To provide your changes or suggestions, please open a PR (Pull Request) with suggested changes.
I have the following source:
It produces following HTML code:
It should skip the first paragraph when the
caption
is empty.