aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/RichTextField.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-08-23 11:22:31 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-08-23 11:22:31 -0400
commit56753f8d87f7647d7012fd1c4c35daffc116ec11 (patch)
tree4ff3aeb8c50d6006c0d5b5c9748cdf9fd49d558c /src/new_fields/RichTextField.ts
parentf0f0cc36654183921076db5a341fe7cac2bfdd3c (diff)
parentac23ac310985ac9042694473df3defb2adbd09f2 (diff)
merged with master
Diffstat (limited to 'src/new_fields/RichTextField.ts')
-rw-r--r--src/new_fields/RichTextField.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/new_fields/RichTextField.ts b/src/new_fields/RichTextField.ts
index cae5623e6..1b52e6f82 100644
--- a/src/new_fields/RichTextField.ts
+++ b/src/new_fields/RichTextField.ts
@@ -28,6 +28,12 @@ export class RichTextField extends ObjectField {
return `new RichTextField("${this.Data}")`;
}
+ public static Initialize = (initial: string) => {
+ !initial.length && (initial = " ");
+ let pos = initial.length + 1;
+ return `{"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"${initial}"}]}]},"selection":{"type":"text","anchor":${pos},"head":${pos}}}`;
+ }
+
[ToPlainText]() {
// Because we're working with plain text, just concatenate all paragraphs
let content = JSON.parse(this.Data).doc.content;