aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-03-09 19:05:30 -0500
committerbobzel <zzzman@gmail.com>2024-03-09 19:05:30 -0500
commitf1ed1cff137c06afc4d4db8a8778f7827404889b (patch)
tree8dcf213eabe1472bc92dbada69b3cfcbc8d0e363 /src/client/documents/Documents.ts
parent7164179264d057986bfd5f303c61248f1c189406 (diff)
fixed up default text that uses a template to process an initial carriage return properly. fixed text with inherited templates to be able to show fields with a default dashField value from template that can be overidden on instance.
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index e6969d1f3..7a3b965fe 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -3,7 +3,7 @@ import { action, reaction, runInAction } from 'mobx';
import { basename } from 'path';
import { DateField } from '../../fields/DateField';
import { Doc, DocListCast, Field, LinkedTo, Opt, StrListCast, updateCachedAcls } from '../../fields/Doc';
-import { Initializing } from '../../fields/DocSymbols';
+import { DocData, Initializing } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { HtmlField } from '../../fields/HtmlField';
import { InkField, PointData } from '../../fields/InkField';
@@ -1981,10 +1981,8 @@ export namespace DocUtils {
}
}
- export function GetNewTextDoc(title: string, x: number, y: number, width?: number, height?: number, noMargins?: boolean, annotationOn?: Doc, backgroundColor?: string) {
+ export function GetNewTextDoc(title: string, x: number, y: number, width?: number, height?: number, annotationOn?: Doc, backgroundColor?: string) {
const tbox = Docs.Create.TextDocument('', {
- _xMargin: noMargins ? 0 : undefined,
- _yMargin: noMargins ? 0 : undefined,
annotationOn,
backgroundColor,
_width: width || 200,
@@ -1997,11 +1995,14 @@ export namespace DocUtils {
_layout_enableAltContentUI: BoolCast(Doc.UserDoc().defaultToFlashcards),
title,
});
+
const template = Doc.UserDoc().defaultTextLayout;
if (template instanceof Doc) {
+ // if a default text template is specified
tbox._width = NumCast(template._width);
tbox.layout_fieldKey = 'layout_' + StrCast(template.title);
- Doc.GetProto(tbox)[StrCast(tbox.layout_fieldKey)] = template;
+ Doc.GetProto(tbox)[StrCast(tbox.layout_fieldKey)] = template; // set the text doc's layout to render with the text template
+ tbox[DocData].proto = template; // and also set the text doc to inherit from the template (this allows the template to specify default field values)
}
return tbox;
}