aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/RichTextField.ts
diff options
context:
space:
mode:
authorSam Wilkins <35748010+samwilkins333@users.noreply.github.com>2019-08-22 12:02:00 -0400
committerGitHub <noreply@github.com>2019-08-22 12:02:00 -0400
commit333d9e97ca97f993c17ffab192030f236bc90780 (patch)
treed98a41025da01f47b7d89ae4afd64f4d2358121a /src/new_fields/RichTextField.ts
parent0ee435f6bd686c667a067fa750b4589cedfb0070 (diff)
parent65aec7b22e63de15e0d911971fa4e5a32d09d9b5 (diff)
Merge pull request #259 from browngraphicslab/bulletdictation
Bullet Dictation and bug fixes
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;