Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix txt, pdf & html export line spacing (#2215)

Abdulrehman-Jafercb1d32d177fd
diff --git a/packages/core/content-types/tiptap.js b/packages/core/content-types/tiptap.js
index 7628ebcd6..ed4693e28 100644
--- a/packages/core/content-types/tiptap.js
+++ b/packages/core/content-types/tiptap.js
@@ -59,16 +59,17 @@ export class Tiptap {
return elem.attribs.class.includes("checked") ? " ✅ " : " ☐ ";
});
},
- paragraph: (elem, walk, builder, formatOptions) => {
+ paragraph: (elem, walk, builder) => {
+ const { "data-spacing": dataSpacing } = elem.attribs;
if (elem.parent && elem.parent.name === "li") {
walk(elem.children, builder);
} else {
builder.openBlock({
- leadingLineBreaks: formatOptions.leadingLineBreaks || 2
+ leadingLineBreaks: dataSpacing == "single" ? 1 : 2
});
walk(elem.children, builder);
builder.closeBlock({
- trailingLineBreaks: formatOptions.trailingLineBreaks || 2
+ trailingLineBreaks: 1
});
}
}
diff --git a/packages/core/utils/templates/html/template.js b/packages/core/utils/templates/html/template.js
index 71a32458f..f15e9f853 100644
--- a/packages/core/utils/templates/html/template.js
+++ b/packages/core/utils/templates/html/template.js
@@ -52,6 +52,22 @@ const template = (data) => `<!DOCTYPE html>
h6 {
color: #212121;
}
+
+ p {
+ margin-bottom: 0px;
+ }
+
+ p[data-spacing="double"] {
+ margin-top: 1em;
+ }
+
+ p[data-spacing="single"] {
+ margin-top: 0px;
+ }
+
+ p[data-spacing="single"]:empty {
+ margin-top: 1em;
+ }
pre.codeblock {
overflow-x: auto;