From de4cc95e406b10bd92975abd5eef8f708cbf8f02 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 10 Oct 2024 22:32:52 -0400 Subject: fixed being able to use text menu on text in comparison box. Allow TextDocuments to be created with a RichText field. Changed comparisonBox to horizontally center flashcard text. --- src/client/documents/Documents.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/client/documents/Documents.ts') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 5f2a592ae..0d7e0b20e 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -240,7 +240,6 @@ export class DocumentOptions { borderWidth?: STRt = new StrInfo('Width of user-added border', false); borderColor?: STRt = new StrInfo('Color of user-added border', false); text_fontColor?: STRt = new StrInfo('Color of text', false); - text_align?: STRt = new StrInfo('alignment'); hCentering?: 'h-left' | 'h-center' | 'h-right'; isDefaultTemplateDoc?: BOOLt = new BoolInfo(''); contentBold?: BOOLt = new BoolInfo(''); @@ -697,7 +696,7 @@ export namespace Docs { dataProps.author_date = new DateField(); if (fieldKey) { dataProps[`${fieldKey}_modificationDate`] = new DateField(); - dataProps[fieldKey] = options.data ?? data; + dataProps[fieldKey] = (options as unknown as { [key: string]: FieldType | undefined })[fieldKey] ?? data; // so that the list of annotations is already initialised, prevents issues in addonly. // without this, if a doc has no annotations but the user has AddOnly privileges, they won't be able to add an annotation because they would have needed to create the field's list which they don't have permissions to do. @@ -827,7 +826,7 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.MESSAGE), field, options, undefined, fieldKey); } - export function TextDocument(text: string, options: DocumentOptions = {}, fieldKey: string = 'text') { + export function TextDocument(text: string | RichTextField, options: DocumentOptions = {}, fieldKey: string = 'text') { const rtf = { doc: { type: 'doc', @@ -846,7 +845,7 @@ export namespace Docs { selection: { type: 'text', anchor: 1, head: 1 }, storedMarks: [], }; - const field = text ? new RichTextField(JSON.stringify(rtf), text) : undefined; + const field = text instanceof RichTextField ? text : text ? new RichTextField(JSON.stringify(rtf), text) : options.text instanceof RichTextField ? options.text : undefined; return InstanceFromProto(Prototypes.get(DocumentType.RTF), field, options, undefined, fieldKey); } -- cgit v1.2.3-70-g09d2