aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/DocUtils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-06-11 13:01:44 -0400
committerbobzel <zzzman@gmail.com>2025-06-11 13:01:44 -0400
commit05845fa3e5a6d71a58845d058a15233ccf6d72c0 (patch)
treeb7ee99e171a2595d6656f15e2cfdcd596ccf4cc3 /src/client/documents/DocUtils.ts
parentb4db1e2467337468139d0e92ef94799c4143a0fc (diff)
refactor unwrapPlaceholder duplicated code to DocUtils.
Diffstat (limited to 'src/client/documents/DocUtils.ts')
-rw-r--r--src/client/documents/DocUtils.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts
index dee929c89..9704867d5 100644
--- a/src/client/documents/DocUtils.ts
+++ b/src/client/documents/DocUtils.ts
@@ -587,6 +587,15 @@ export namespace DocUtils {
doc.onClick = FollowLinkScript();
}
+ /**
+ * iterate through all items and their children and return a flat list of leaf placeholder content Docs
+ * @param items
+ * @returns list of placeholder content Docs
+ */
+ export function unwrapPlaceholders(items: Doc[]): Doc[] {
+ return items.flatMap(d => (d.$type === DocumentType.COL ? unwrapPlaceholders(DocListCast(d[Doc.LayoutDataKey(d)])) : [d]));
+ }
+
export function LeavePushpin(doc: Doc, annotationField: string) {
if (doc.followLinkToggle) return undefined;
const context = Cast(doc.embedContainer, Doc, null) ?? Cast(doc.annotationOn, Doc, null);