diff options
| author | bobzel <zzzman@gmail.com> | 2025-06-11 13:01:44 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2025-06-11 13:01:44 -0400 |
| commit | 05845fa3e5a6d71a58845d058a15233ccf6d72c0 (patch) | |
| tree | b7ee99e171a2595d6656f15e2cfdcd596ccf4cc3 /src/client/views/nodes/scrapbook | |
| parent | b4db1e2467337468139d0e92ef94799c4143a0fc (diff) | |
refactor unwrapPlaceholder duplicated code to DocUtils.
Diffstat (limited to 'src/client/views/nodes/scrapbook')
| -rw-r--r-- | src/client/views/nodes/scrapbook/ScrapbookBox.tsx | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx index 2db76c76f..ff757af88 100644 --- a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx +++ b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx @@ -23,6 +23,7 @@ import './ScrapbookBox.scss'; import { ScrapbookItemConfig } from './ScrapbookPreset'; import { createPreset, getPresetNames } from './ScrapbookPresetRegistry'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { DocUtils } from '../../../documents/DocUtils'; function createPlaceholder(cfg: ScrapbookItemConfig, doc: Doc) { const placeholder = new Doc(); @@ -207,25 +208,18 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() rejectDrop = (de: DragManager.DropEvent, subView?: DocumentView) => false; // allow all Docs to be dropped onto scrapbook -- let filterAddDocument make the final decision. /** - * 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 - */ - unwrapPlaceholders = (items: Doc[]): Doc[] => items.flatMap(d => (d.$type === DocumentType.COL ? this.unwrapPlaceholders(DocListCast(d[Doc.LayoutDataKey(d)])) : [d])); - - /** * Filter function to determine if a document can be added to the scrapbook. * This checks if the document matches any of the placeholder slots in the scrapbook. * @param docs - The document(s) being added to the scrapbook. * @returns true if the document can be added, false otherwise. */ filterAddDocument = (docs: Doc | Doc[]) => { - toList(docs).forEach(doc => slotRealDocIntoPlaceholders(doc, this.unwrapPlaceholders(this.ScrapbookLayoutDocs))); + toList(docs).forEach(doc => slotRealDocIntoPlaceholders(doc, DocUtils.unwrapPlaceholders(this.ScrapbookLayoutDocs))); return false; }; @computed get regenPrompt() { - const allDocs = this.unwrapPlaceholders(this.ScrapbookLayoutDocs); // find all non-collections in scrapbook (e.g., placeholder content docs) + const allDocs = DocUtils.unwrapPlaceholders(this.ScrapbookLayoutDocs); // find all non-collections in scrapbook (e.g., placeholder content docs) const internalTagsSet = new Set<string>(allDocs.flatMap(doc => StrListCast(doc.$tags_chat).filter(tag => !tag.startsWith?.('ASPECT_')))); const internalTags = Array.from(internalTagsSet).join(', '); |
