diff options
Diffstat (limited to 'src/fields/RichTextField.ts')
-rw-r--r-- | src/fields/RichTextField.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/fields/RichTextField.ts b/src/fields/RichTextField.ts index 613bb0fd1..dc636031a 100644 --- a/src/fields/RichTextField.ts +++ b/src/fields/RichTextField.ts @@ -48,4 +48,27 @@ export class RichTextField extends ObjectField { '' ); } + + public static textToRtf(text: string, imgDocId?: string) { + return new RichTextField( + JSON.stringify({ + // this is a RichText json that has the question text placed above a related image + doc: { + type: 'doc', + content: [ + { + type: 'paragraph', + attrs: { align: 'center', color: null, id: null, indent: null, inset: null, lineSpacing: null, paddingBottom: null, paddingTop: null }, + content: [ + ...(text ? [{ type: 'text', text }] : []), // + ...(imgDocId ? [{ type: 'dashDoc', attrs: { width: '200px', height: '200px', title: 'dashDoc', float: 'unset', hidden: false, docId: imgDocId } }] : []), + ], + }, + ], + }, + selection: { type: 'text', anchor: 2, head: 2 }, + }), + text + ); + } } |