aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-10-10 22:32:52 -0400
committerbobzel <zzzman@gmail.com>2024-10-10 22:32:52 -0400
commitde4cc95e406b10bd92975abd5eef8f708cbf8f02 (patch)
tree575498eca3fb89955a5747341661c028293a9dd6 /src/client/documents/Documents.ts
parentfc06a98deec3fa2b173f8ea30a4f4b1781447b19 (diff)
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.
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts7
1 files changed, 3 insertions, 4 deletions
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);
}