diff options
| author | bob <bcz@cs.brown.edu> | 2019-08-22 12:22:57 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-08-22 12:22:57 -0400 |
| commit | 6b9400270d213de203e4a314428be9a7a2d774ff (patch) | |
| tree | df02ff10f506f9ed72c51cd5a1ad71489d2a5877 /src/new_fields/RichTextField.ts | |
| parent | 224d58da7c8bf8a7eb27cb616100473afcad4f7b (diff) | |
| parent | 333d9e97ca97f993c17ffab192030f236bc90780 (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/new_fields/RichTextField.ts')
| -rw-r--r-- | src/new_fields/RichTextField.ts | 6 |
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; |
