aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 1d7c73306..be382afe3 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1218,6 +1218,15 @@ export namespace Docs {
);
}
+ export function CardDeckDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
+ return InstanceFromProto(
+ Prototypes.get(DocumentType.COL),
+ new List(documents),
+ { backgroundColor: 'transparent', dropAction: dropActionType.move, _forceActive: true, _freeform_noZoom: true, _freeform_noAutoPan: true, ...options, _type_collection: CollectionViewType.Card },
+ id
+ );
+ }
+
export function LinearDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Linear }, id);
}
@@ -1864,6 +1873,44 @@ export namespace DocUtils {
return newCollection;
}
}
+
+ export function spreadCards(docList: Doc[], x: number = 0, y: number = 0, spreadAngle: number = 30, radius: number = 100, create: boolean = true) {
+ const totalCards = docList.length;
+ const halfSpreadAngle = spreadAngle * 0.5;
+ const angleStep = spreadAngle / (totalCards - 1);
+
+ runInAction(() => {
+ docList.forEach((d, i) => {
+ DocUtils.iconify(d);
+ const angle = (-halfSpreadAngle + angleStep * i) * (Math.PI / 180); // Convert degrees to radians
+ d.x = x + Math.cos(angle) * radius;
+ d.y = y + Math.sin(angle) * radius;
+ d.rotation = angle; // Assuming 'd.rotation' sets the rotation, adjust accordingly
+ d._timecodeToShow = undefined;
+ });
+ });
+
+ if (create) {
+ const newCollection = Docs.Create.CardDeckDocument(docList, {
+ title: 'card-spread',
+ _freeform_noZoom: true,
+ x: x - radius,
+ y: y - radius,
+ _width: radius * 2,
+ _height: radius * 2,
+ dragWhenActive: true,
+ _layout_fitWidth: false
+ });
+ // Adjust position based on the collection's dimensions if needed
+ newCollection.x = NumCast(newCollection.x) + NumCast(newCollection._width) / 2 - radius;
+ newCollection.y = NumCast(newCollection.y) + NumCast(newCollection._height) / 2 - radius;
+ newCollection._width = newCollection._height = radius * 2;
+ return newCollection;
+ }
+ }
+
+
+
export function makeIntoPortal(doc: Doc, layoutDoc: Doc, allLinks: Doc[]) {
const portalLink = allLinks.find(d => d.link_anchor_1 === doc && d.link_relationship === 'portal to:portal from');
if (!portalLink) {