-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing newline after header #80
Comments
Message from the future , thanks for tracing it @rienswagerman 😉. How did you go about working around this? |
Message from the future 2.0, @rienswagerman @jraoult have you found any solutions? |
@anmeln I create a sub-class called /**
* The only purpose of this custom converter is to disabled new line collapsing
* algorithm to stay consistent with Quill's behaviour.
*
* @see https://github.com/nozer/quill-delta-to-html/issues/80
*/
class KeepNewLineConverter extends QuillDeltaToHtmlConverter {
constructor(deltaOps: Array<unknown>, options: Options) {
super(deltaOps, options);
}
get superOptions() {
// `options` is declared private in the parent class so we centralise access
// here to minimize the use of ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return this.options as unknown as NonNullable<Options>;
}
override _renderInlines(ops: Array<DeltaInsertOp>, isInlineGroup = true) {
const html = ops
.map((op: DeltaInsertOp) => {
return this._renderInline(op, null) as unknown;
})
.join("");
if (!isInlineGroup) {
return html;
}
const startParaTag = makeStartTag(this.superOptions.paragraphTag);
const endParaTag = makeEndTag(this.superOptions.paragraphTag);
if (html === BrTag || this.superOptions.multiLineParagraph) {
return startParaTag + html + endParaTag;
}
return (
startParaTag +
html
.split(BrTag)
.map((v) => {
return v === "" ? BrTag : v;
})
.join(endParaTag + startParaTag) +
endParaTag
);
}
} Now I'll be honest, I'm not sure how committed you are to the Quill ecosystem, but I'd suggest staying away if you sill can. It is pretty much abandoned and not the future (what a shame, though, it was good). |
A newline is removed when adding a header inside a paragraph.
I've looked into the '_renderInlines' function in /src/QuillDeltaToHtmlConverter.ts and found that the second newline is removed in lines 276 - 279.
I am not sure why that condition is in there...
The text was updated successfully, but these errors were encountered: