aboutsummaryrefslogtreecommitdiff
path: root/src/fields/RichTextField.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-10-17 17:41:49 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-10-17 17:41:49 -0400
commitc933ae724c1bf77fa8bd83c3c9e27d0029ef5cb0 (patch)
treedf16f68e9bdb822e5f91c997a431c4b130377290 /src/fields/RichTextField.ts
parent98d0bba3e59ab7ec9dfbf5e6c9c58e6ac1d22ae3 (diff)
parentdd93f5175064850c6c0e47f025cd7bbba1f23106 (diff)
Merge branch 'ajs-before-executable' of https://github.com/brown-dash/Dash-Web into ajs-before-executable
Diffstat (limited to 'src/fields/RichTextField.ts')
-rw-r--r--src/fields/RichTextField.ts23
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
+ );
+ }
}