aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/RichTextField.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/new_fields/RichTextField.ts')
-rw-r--r--src/new_fields/RichTextField.ts10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/new_fields/RichTextField.ts b/src/new_fields/RichTextField.ts
index 92b19b921..bd24bad1a 100644
--- a/src/new_fields/RichTextField.ts
+++ b/src/new_fields/RichTextField.ts
@@ -36,7 +36,7 @@ export class RichTextField extends ObjectField {
if (paragraph.content) {
output += paragraph.content.map((block: any) => block.text).join("");
} else {
- output += "\n";
+ output += i === 0 ? "" : "\n";
}
addNewLine && (output += "\n");
}
@@ -47,7 +47,6 @@ export class RichTextField extends ObjectField {
let elements = plainText.split("\n");
!elements[elements.length - 1].length && elements.pop();
let parsed = JSON.parse(this.Data);
- let blankCount = 0;
parsed.doc.content = elements.map(text => {
let paragraph: any = { type: "paragraph" };
if (text.length) {
@@ -56,16 +55,13 @@ export class RichTextField extends ObjectField {
marks: [],
text
}];
- } else {
- blankCount++;
}
return paragraph;
});
- let selection = plainText.length + 2 * blankCount;
parsed.selection = {
type: "text",
- anchor: selection,
- head: selection
+ anchor: 1,
+ head: 1
};
return JSON.stringify(parsed);
}