aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-04-23 22:02:51 -0400
committerbobzel <zzzman@gmail.com>2025-04-23 22:02:51 -0400
commit0e6d7b45c14301d426f85eeef0a96ab8dceebc25 (patch)
tree5eb67dd31b631189caf6ceb1192088c8e934349a /src/client/documents
parentdb2029602586985b7113fa436851b19746eac673 (diff)
parent78ac87b8acf63079071e5e8805692ed8c30042ce (diff)
Merge branch 'master' into aarav_edit
Diffstat (limited to 'src/client/documents')
-rw-r--r--src/client/documents/DocUtils.ts53
-rw-r--r--src/client/documents/DocumentTypes.ts1
-rw-r--r--src/client/documents/Documents.ts44
3 files changed, 58 insertions, 40 deletions
diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts
index 7b36c3a66..df14dce5a 100644
--- a/src/client/documents/DocUtils.ts
+++ b/src/client/documents/DocUtils.ts
@@ -308,6 +308,7 @@ export namespace DocUtils {
*/
export async function DocumentFromType(type: string, path: string, options: DocumentOptions, overwriteDoc?: Doc): Promise<Opt<Doc>> {
let ctor: ((path: string, options: DocumentOptions, overwriteDoc?: Doc) => Doc | Promise<Doc | undefined>) | undefined;
+
if (type.indexOf('image') !== -1) {
ctor = Docs.Create.ImageDocument;
if (!options._width) options._width = 300;
@@ -711,33 +712,31 @@ export namespace DocUtils {
nativeWidth: 40,
nativeHeight: 40,
})
- : (defaultTextTemplate?.type === DocumentType.JOURNAL ? Docs.Create.DailyJournalDocument:Docs.Create.TextDocument)(
- '',
- {
- annotationOn,
- backgroundColor,
- x,
- y,
- title,
- ...(defaultTextTemplate
- ? {} // if the new doc will inherit from a template, don't set any layout fields since that would block the inheritance
- : {
- _width: width || BoolCast(Doc.UserDoc().fitBox) ? Number(StrCast(Doc.UserDoc().fontSize).replace('px', '')) * 1.5 * 6 : 200,
- _height: BoolCast(Doc.UserDoc().fitBox) ? Number(StrCast(Doc.UserDoc().fontSize).replace('px', '')) * 1.5 : 35,
- _layout_autoHeight: true,
- backgroundColor: StrCast(Doc.UserDoc().textBackgroundColor),
- borderColor: Doc.UserDoc().borderColor as string,
- borderWidth: Doc.UserDoc().borderWidth as number,
- text_centered: BoolCast(Doc.UserDoc().textCentered),
- text_fitBox: BoolCast(Doc.UserDoc().fitBox),
- text_align: StrCast(Doc.UserDoc().textAlign),
- text_fontColor: StrCast(Doc.UserDoc().fontColor),
- text_fontFamily: StrCast(Doc.UserDoc().fontFamily),
- text_fontWeight: StrCast(Doc.UserDoc().fontWeight),
- text_fontStyle: StrCast(Doc.UserDoc().fontStyle),
- text_fontDecoration: StrCast(Doc.UserDoc().fontDecoration),
- }),
- });
+ : (defaultTextTemplate?.type === DocumentType.JOURNAL ? Docs.Create.DailyJournalDocument : Docs.Create.TextDocument)('', {
+ annotationOn,
+ backgroundColor,
+ x,
+ y,
+ title,
+ ...(defaultTextTemplate
+ ? {} // if the new doc will inherit from a template, don't set any layout fields since that would block the inheritance
+ : {
+ _width: width || BoolCast(Doc.UserDoc().fitBox) ? Number(StrCast(Doc.UserDoc().fontSize).replace('px', '')) * 1.5 * 6 : 200,
+ _height: BoolCast(Doc.UserDoc().fitBox) ? Number(StrCast(Doc.UserDoc().fontSize).replace('px', '')) * 1.5 : 35,
+ _layout_autoHeight: true,
+ backgroundColor: StrCast(Doc.UserDoc().textBackgroundColor),
+ borderColor: Doc.UserDoc().borderColor as string,
+ borderWidth: Doc.UserDoc().borderWidth as number,
+ text_centered: BoolCast(Doc.UserDoc().textCentered),
+ text_fitBox: BoolCast(Doc.UserDoc().fitBox),
+ text_align: StrCast(Doc.UserDoc().textAlign),
+ text_fontColor: StrCast(Doc.UserDoc().fontColor),
+ text_fontFamily: StrCast(Doc.UserDoc().fontFamily),
+ text_fontWeight: StrCast(Doc.UserDoc().fontWeight),
+ text_fontStyle: StrCast(Doc.UserDoc().fontStyle),
+ text_fontDecoration: StrCast(Doc.UserDoc().fontDecoration),
+ }),
+ });
if (defaultTextTemplate) {
tbox.layout_fieldKey = 'layout_' + StrCast(defaultTextTemplate.title);
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index 5c6559836..cef44e999 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -44,6 +44,7 @@ export enum DocumentType {
SCRIPTDB = 'scriptdb', // database of scripts
GROUPDB = 'groupdb', // database of groups
+ SCRAPBOOK = 'scrapbook',
JOURNAL = 'journal', // AARAV ADD
}
export enum CollectionViewType {
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index bf9cc5bd4..e694419a4 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -525,6 +525,18 @@ export class DocumentOptions {
ai?: string; // to mark items as ai generated
ai_firefly_seed?: number;
ai_firefly_prompt?: string;
+
+ /**
+ * JSON‐stringified slot configuration for ScrapbookBox
+ */
+ scrapbookConfig?: string;
+
+ /**
+ * The list of embedded Doc instances in each Scrapbook slot
+ */
+ scrapbookContents?: List<Doc>;
+
+ _outpaintingMetadata?: STRt = new StrInfo('serialized JSON metadata needed for image outpainting', false);
}
export const DocOptions = new DocumentOptions();
@@ -574,19 +586,6 @@ export namespace Docs {
options: { acl: '' },
},
],
-
- // AARAV ADD //
- [
- DocumentType.JOURNAL,
- {
- layout: { view: EmptyBox, dataField: 'text' },
- options: {
- title: 'Daily Journal',
- acl_Guest: SharingPermissions.View,
- },
- },
- ],
- // AARAV ADD //
]);
const suffix = 'Proto';
@@ -919,6 +918,25 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.RTF), field, options, undefined, fieldKey);
}
+ export function ScrapbookDocument(items: Doc[] = [], options: DocumentOptions = {}, fieldKey: string = 'items') {
+ return InstanceFromProto(
+ Prototypes.get(DocumentType.SCRAPBOOK),
+ new List<Doc>(items),
+ {
+ title:
+ options.title ??
+ new Date().toLocaleDateString(undefined, {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ }),
+ ...options,
+ },
+ undefined,
+ fieldKey
+ );
+ }
+
// AARAV ADD //
export function DailyJournalDocument(text: string | RichTextField, options: DocumentOptions = {}, fieldKey: string = 'text') {