From 08b40f21d9295f36277827ac33085f82c9ee1646 Mon Sep 17 00:00:00 2001 From: sharkiecodes Date: Fri, 6 Jun 2025 11:07:59 -0400 Subject: clean-up --- .../collections/collectionFreeForm/MarqueeView.tsx | 4 +- src/client/views/nodes/ImageBox.tsx | 8 +- .../views/nodes/formattedText/FormattedTextBox.tsx | 23 --- src/client/views/nodes/scrapbook/ScrapbookBox.scss | 63 ++++++ src/client/views/nodes/scrapbook/ScrapbookBox.tsx | 216 +++++---------------- .../nodes/scrapbook/ScrapbookSettingsPanel.tsx | 60 ------ .../views/nodes/scrapbook/ScrapbookSlot.scss | 85 -------- src/client/views/nodes/scrapbook/ScrapbookSlot.tsx | 28 --- .../views/nodes/scrapbook/ScrapbookSlotTypes.ts | 25 --- .../views/nodes/scrapbook/scrapbookleftover.ts | 6 +- 10 files changed, 114 insertions(+), 404 deletions(-) create mode 100644 src/client/views/nodes/scrapbook/ScrapbookBox.scss delete mode 100644 src/client/views/nodes/scrapbook/ScrapbookSettingsPanel.tsx delete mode 100644 src/client/views/nodes/scrapbook/ScrapbookSlot.scss delete mode 100644 src/client/views/nodes/scrapbook/ScrapbookSlot.tsx delete mode 100644 src/client/views/nodes/scrapbook/ScrapbookSlotTypes.ts (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index b8d203cf6..9f96163cd 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -16,7 +16,7 @@ import { DocumentType } from '../../../documents/DocumentTypes'; import { Docs, DocumentOptions } from '../../../documents/Documents'; import { SnappingManager, freeformScrollMode } from '../../../util/SnappingManager'; import { Transform } from '../../../util/Transform'; -import { UndoManager, undoBatch } from '../../../util/UndoManager'; +import { UndoManager, undoBatch, undoable } from '../../../util/UndoManager'; import { ContextMenu } from '../../ContextMenu'; import { ObservableReactComponent } from '../../ObservableReactComponent'; import { MarqueeViewBounds } from '../../PinFuncs'; @@ -548,7 +548,7 @@ export class MarqueeView extends ObservableReactComponent { const selectedDocs = this.marqueeSelect(false); diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 2473f1c0a..79a218e45 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -46,7 +46,6 @@ import { FocusViewOptions } from './FocusViewOptions'; import './ImageBox.scss'; import { OpenWhere } from './OpenWhere'; import { gptImageLabel } from '../../apis/gpt/GPT'; -import { ImageLabelBox } from '../collections/collectionFreeForm/ImageLabelBox'; const DefaultPath = '/assets/unknown-file-icon-hi.png'; export class ImageEditorData { @@ -157,13 +156,10 @@ export class ImageBox extends ViewBoxAnnotatableComponent() { this.Document.$tags_chat = new List(); tokens.forEach(tok => { (this.Document.$tags_chat as List).push(tok)}); - (this.Document.$tags_chat as List).push(`ASPECT_${aspectRatio}`); - //!!! changed may 11 (this.Document.$tags_chat as List).push(label); + (this.Document.$tags_chat as List).push(`ASPECT_${aspectRatio}`); // 6) flip on “show tags” in the layout // (same flag that ImageLabelBox.toggleDisplayInformation uses) - //note to self: What if i used my own field (ex: Document.$auto_description or something - //Would i still have to toggle it on for it to show in the metadata? this.Document._layout_showTags = true; } catch (err) { @@ -172,8 +168,6 @@ export class ImageBox extends ViewBoxAnnotatableComponent() { } }; - //Doc.getDescription(this.Document).then(desc => this.desc = desc) - diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index 04a14a15f..ad75d320a 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -329,29 +329,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent(); - gptAPICall(RTFCast(this.Document[Doc.LayoutDataKey(this.Document)])?.Text ?? StrCast(this.Document[Doc.LayoutDataKey(this.Document)]), GPTCallType.CLASSIFYTEXTMINIMAL).then(desc => (this.Document.$tags_chat as List).push(desc)); - this.Document._layout_showTags = true;*/ - - - // 2) grab whatever’s actually in the field (either RTF or plain string) -/* - const rawText = RTFCast(this.Document[Doc.LayoutDataKey(this.Document)])?.Text ?? StrCast(this.Document[Doc.LayoutDataKey(this.Document)]) - - // 3) pick minimal vs. full classification based on "[placeholder]" substring - if (rawText.includes("[placeholder]")) { - this.Document.$tags_chat = new List(); - gptAPICall(RTFCast(this.Document[Doc.LayoutDataKey(this.Document)])?.Text ?? StrCast(this.Document[Doc.LayoutDataKey(this.Document)]), GPTCallType.CLASSIFYTEXTMINIMAL).then(desc => { - (this.Document.$tags_chat as List).push(desc); - }); - } else { - this.Document.$tags_chat = new List(); - gptAPICall(RTFCast(this.Document[Doc.LayoutDataKey(this.Document)])?.Text ?? StrCast(this.Document[Doc.LayoutDataKey(this.Document)]), GPTCallType.CLASSIFYTEXTFULL).then(desc => { - (this.Document.$tags_chat as List).push(desc); - })}; - // 4) make sure the UI will show tags - this.Document._layout_showTags = true;*/ - }; leafText = (node: Node) => { diff --git a/src/client/views/nodes/scrapbook/ScrapbookBox.scss b/src/client/views/nodes/scrapbook/ScrapbookBox.scss new file mode 100644 index 000000000..8dc93df60 --- /dev/null +++ b/src/client/views/nodes/scrapbook/ScrapbookBox.scss @@ -0,0 +1,63 @@ + +.scrapbook-box { + /* Make sure the container fills its parent, and set a base background */ + position: relative; /* so that absolute children (loading overlay, etc.) are positioned relative to this */ + width: 100%; + height: 100%; + background: beige; + overflow: hidden; /* prevent scrollbars if children overflow */ +} + +/* Loading overlay that covers the entire scrapbook while AI-generation is in progress */ +.scrapbook-box-loading-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + background: rgba(255, 255, 255, 0.8); + z-index: 10; /* sits above the ImageBox and other content */ +} + +/* The (this.selectedPreset = e.currentTarget.value)} - style={{ position: 'absolute', top: 8, left: 8, zIndex: 20 }} + + {this.src && this.imgDoc && ( + + )} + + + {getPresetNames().map(name => ( + + ))} + + {this._props.isContentActive() && ( -
e.stopPropagation()} - > +
-
- )} - - - {/*
Drop an image here
*/} -
- ); - } -} - - - -//function extractScrapbookConfigs(docs: Doc[]): ScrapbookItemConfig[] { - //return docs.map(doc => extractConfig(doc)); -//} - -// function extractConfig(doc: Doc): ScrapbookItemConfig { -// const layoutKey = Doc.LayoutDataKey(doc); -// const childDocs = doc[layoutKey] ? DocListCast(doc[layoutKey]) : []; - -// const isContainer = childDocs.length > 0; - -// const cfg: ScrapbookItemConfig = { -// type: isContainer ? DocumentType.COL : doc.$type, -// tag: -// acceptTag: doc.accepts_tagType, -// x: doc.x || 0, -// y: doc.y || 0, -// width: doc._width, -// height: doc._height, -// }; - -// if (isContainer) { -// cfg.containerWidth = doc.proto._width; -// cfg.containerHeight = doc.proto._height; -// cfg.children = childDocs.map(child => extractConfig(child)); -// } + + )} -// return cfg; -// } + + + ); + } +} -// Register scrapbook Docs.Prototypes.TemplateMap.set(DocumentType.SCRAPBOOK, { diff --git a/src/client/views/nodes/scrapbook/ScrapbookSettingsPanel.tsx b/src/client/views/nodes/scrapbook/ScrapbookSettingsPanel.tsx deleted file mode 100644 index 5808ab4d1..000000000 --- a/src/client/views/nodes/scrapbook/ScrapbookSettingsPanel.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faRedoAlt } from '@fortawesome/free-solid-svg-icons'; -import { action } from 'mobx'; - -export default class ScrapbookSettingsPanel extends React.Component { - - constructor(props) { - super(props); - this.state = { regenerating: false }; - } - - regenerateScrapbook = async () => { - this.setState({ regenerating: true }); - try { - // Example API call or method invoking ChatGPT for JSON - const newLayout = await fetch('/api/generate-scrapbook-layout', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ currentLayout: this.props.currentLayout }) - }).then(res => res.json()); - - action(() => { - // Apply new layout - this.props.applyNewLayout(newLayout); - })(); - } catch (err) { - console.error('Failed to regenerate layout:', err); - } finally { - this.setState({ regenerating: false }); - } - }; - - render() { - const { regenerating } = this.state; - - return ( -
- -
- ); - } -} \ No newline at end of file diff --git a/src/client/views/nodes/scrapbook/ScrapbookSlot.scss b/src/client/views/nodes/scrapbook/ScrapbookSlot.scss deleted file mode 100644 index ae647ad36..000000000 --- a/src/client/views/nodes/scrapbook/ScrapbookSlot.scss +++ /dev/null @@ -1,85 +0,0 @@ -//IGNORE FOR NOW, CURRENTLY NOT USED IN SCRAPBOOK IMPLEMENTATION -.scrapbook-slot { - position: absolute; - background-color: rgba(245, 245, 245, 0.7); - border: 2px dashed #ccc; - border-radius: 5px; - box-sizing: border-box; - transition: all 0.2s ease; - overflow: hidden; - - &.scrapbook-slot-over { - border-color: #4a90e2; - background-color: rgba(74, 144, 226, 0.1); - } - - &.scrapbook-slot-filled { - border-style: solid; - border-color: rgba(0, 0, 0, 0.1); - background-color: transparent; - - &.scrapbook-slot-over { - border-color: #4a90e2; - background-color: rgba(74, 144, 226, 0.1); - } - } - - .scrapbook-slot-empty { - display: flex; - align-items: center; - justify-content: center; - width: 100%; - height: 100%; - } - - .scrapbook-slot-placeholder { - text-align: center; - color: #888; - } - - .scrapbook-slot-title { - font-weight: bold; - margin-bottom: 5px; - } - - .scrapbook-slot-instruction { - font-size: 0.9em; - font-style: italic; - } - - .scrapbook-slot-content { - width: 100%; - height: 100%; - position: relative; - } - - .scrapbook-slot-controls { - position: absolute; - top: 5px; - right: 5px; - z-index: 10; - opacity: 0; - transition: opacity 0.2s ease; - - .scrapbook-slot-remove-btn { - background-color: rgba(255, 255, 255, 0.8); - border: 1px solid #ccc; - border-radius: 50%; - width: 20px; - height: 20px; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; - font-size: 10px; - - &:hover { - background-color: rgba(255, 0, 0, 0.1); - } - } - } - - &:hover .scrapbook-slot-controls { - opacity: 1; - } -} \ No newline at end of file diff --git a/src/client/views/nodes/scrapbook/ScrapbookSlot.tsx b/src/client/views/nodes/scrapbook/ScrapbookSlot.tsx deleted file mode 100644 index 2c8f93778..000000000 --- a/src/client/views/nodes/scrapbook/ScrapbookSlot.tsx +++ /dev/null @@ -1,28 +0,0 @@ - -//IGNORE FOR NOW, CURRENTLY NOT USED IN SCRAPBOOK IMPLEMENTATION -export interface SlotDefinition { - id: string; - x: number; y: number; - defaultWidth: number; - defaultHeight: number; - } - - export interface SlotContentMap { - slotId: string; - docId?: string; - } - - export interface ScrapbookConfig { - slots: SlotDefinition[]; - contents?: SlotContentMap[]; - } - - export const DEFAULT_SCRAPBOOK_CONFIG: ScrapbookConfig = { - slots: [ - { id: "slot1", x: 10, y: 10, defaultWidth: 180, defaultHeight: 120 }, - { id: "slot2", x: 200, y: 10, defaultWidth: 180, defaultHeight: 120 }, - // …etc - ], - contents: [] - }; - \ No newline at end of file diff --git a/src/client/views/nodes/scrapbook/ScrapbookSlotTypes.ts b/src/client/views/nodes/scrapbook/ScrapbookSlotTypes.ts deleted file mode 100644 index 686917d9a..000000000 --- a/src/client/views/nodes/scrapbook/ScrapbookSlotTypes.ts +++ /dev/null @@ -1,25 +0,0 @@ -// ScrapbookSlotTypes.ts -export interface SlotDefinition { - id: string; - title: string; - x: number; - y: number; - defaultWidth: number; - defaultHeight: number; - } - - export interface ScrapbookConfig { - slots: SlotDefinition[]; - contents?: { slotId: string; docId: string }[]; - } - - // give it three slots by default: - export const DEFAULT_SCRAPBOOK_CONFIG: ScrapbookConfig = { - slots: [ - { id: "main", title: "Main Content", x: 20, y: 20, defaultWidth: 360, defaultHeight: 200 }, - { id: "notes", title: "Notes", x: 20, y: 240, defaultWidth: 360, defaultHeight: 160 }, - { id: "resources", title: "Resources", x: 400, y: 20, defaultWidth: 320, defaultHeight: 380 }, - ], - contents: [], - }; - \ No newline at end of file diff --git a/src/client/views/nodes/scrapbook/scrapbookleftover.ts b/src/client/views/nodes/scrapbook/scrapbookleftover.ts index 2f381ab95..ee7a858e4 100644 --- a/src/client/views/nodes/scrapbook/scrapbookleftover.ts +++ b/src/client/views/nodes/scrapbook/scrapbookleftover.ts @@ -1,8 +1,4 @@ - - - - - //DocListCast(this.Document.items).map(doc => DocListCast(doc[Doc.LayoutDataKey(doc)]) + //DocListCast(this.Document.items).map(doc => DocListCast(doc[Doc.LayoutDataKey(doc)]) if (placeholder) { /**Look at the autotags and see what matches*RTFCast(d[Doc.LayoutDataKey(d)])?.Text*/ -- cgit v1.2.3-70-g09d2