diff options
author | bobzel <zzzman@gmail.com> | 2024-10-17 13:31:25 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-10-17 13:31:25 -0400 |
commit | 5e3f9d84da226e62ce109cc2c0b00ba76eb45189 (patch) | |
tree | 7516f80d96cb28088a49b1cba0edf7df78821c47 /src/fields/RichTextField.ts | |
parent | 14f412611299fc350f13b6f96be913d59533cfb3 (diff) | |
parent | 4a9330e996b9117fb27560b9898b6fc1dbb78f96 (diff) |
Merge branch 'master' into ajs-before-executable
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 + ); + } } |